From: admin Date: Wed, 1 Dec 2004 10:39:14 +0000 (+0000) Subject: Merge with version on tag OCC-V2_1_0d X-Git-Tag: V2_1_0b1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d3dd282390888d7dc091ba2c2ffe7923bd7458e6;p=modules%2Fgeom.git Merge with version on tag OCC-V2_1_0d --- diff --git a/INSTALL b/INSTALL index cd622460b..93cdd1b3f 100644 --- a/INSTALL +++ b/INSTALL @@ -1,3 +1,3 @@ -This is the version 2.0.0 of GEOM +This is the version 2.1.0 of GEOM Compatible with : - - KERNEL 2.0.0 + - KERNEL 2.1.0 diff --git a/Makefile.in b/Makefile.in index d5c51e9cf..933016af0 100644 --- a/Makefile.in +++ b/Makefile.in @@ -22,6 +22,8 @@ GEOM_fr.xml \ GEOM.config \ GEOMCatalog.xml \ GEOMDS_Resources \ +ImportExport \ +ShHealing \ arc.png \ archimede.png \ axisinertia.png \ @@ -44,6 +46,7 @@ chamferface.png \ check.png \ circle.png \ circlepointvector.png \ +circle3points.png \ common.png \ cone.png \ conedxyz.png \ @@ -54,6 +57,7 @@ cylinderdxyz.png \ cylinderpointvector.png \ delete.png \ display.png \ +displayonly.png \ displayall.png \ erase.png \ eraseall.png \ @@ -69,6 +73,8 @@ line2points.png \ lineedge.png \ linepointvector.png \ mindist.png \ +mirrorPoint.png \ +mirrorAxe.png \ mirrorPlane.png \ ModuleGeom.png \ multirotation.png \ @@ -77,18 +83,24 @@ multirotationsimple.png \ multitranslation.png \ multitranslationdouble.png \ multitranslationsimple.png \ +offset.png \ orientation.png \ partition.png \ partitionkeep.png \ +partitionplane.png \ pipe.png \ plane.png \ planeWorking.png \ planedxyz.png \ +plane3points.png \ planeface.png \ planepointvector.png \ planeworkingface.png \ +planeworkingvector.png \ +planeworkingorigin.png \ point2.png \ pointonedge.png \ +polyline.png \ prism.png \ revol.png \ rotate.png \ @@ -109,7 +121,9 @@ tolerance.png \ torus.png \ torusdxyz.png \ toruspointvector.png \ -translation.png \ +translationDxyz.png \ +translationPoints.png \ +translationVector.png \ tree_compound.png \ tree_compsolid.png \ tree_edge.png \ @@ -119,12 +133,43 @@ tree_shell.png \ tree_solid.png \ tree_vertex.png \ tree_wire.png \ +tree_group_vertex.png \ +tree_group_edge.png \ +tree_group_face.png \ +tree_group_solid.png \ +tree_lcs.png \ vector.png \ vector2points.png \ vectordxyz.png \ whatis.png \ ellipse.png \ -ellipsepointvector.png +ellipsepointvector.png \ +bezier.png \ +interpol.png \ +spline.png \ +closecontour.png \ +suppressintwires.png \ +marker.png \ +marker2.png \ +marker3.png \ +position.png \ +position2.png \ +free_bound.png \ +point_coord.png \ +point3.png \ +shapeprocess.png \ +block_2f.png \ +block_6f.png \ +block_face_2e.png \ +block_face_4e.png \ +block_face_4v.png \ +block_multitrsf_double.png \ +block_multitrsf_simple.png \ +tree_block.png \ +subblock.png \ +group_new.png \ +group_edit.png \ +glue.png BIN_SCRIPT= \ VERSION diff --git a/adm_local/unix/make_commence.in b/adm_local/unix/make_commence.in index 4d758b99f..3dd63a555 100644 --- a/adm_local/unix/make_commence.in +++ b/adm_local/unix/make_commence.in @@ -31,7 +31,7 @@ C_DEPEND_FLAG = @C_DEPEND_FLAG@ # C++ CXX = @CXX@ -CXXFLAGS = @CXXFLAGS@ -Wparentheses -Wreturn-type -Wmissing-declarations -Winline +CXXFLAGS = @CXXFLAGS@ CXX_DEPEND_FLAG = @CXX_DEPEND_FLAG@ # JAVA diff --git a/bin/VERSION b/bin/VERSION index 1b4eeb6eb..3a9335afe 100755 --- a/bin/VERSION +++ b/bin/VERSION @@ -1 +1 @@ -THIS IS SALOME - GEOM VERSION: 2.0.0 +THIS IS SALOME - GEOM VERSION: 2.1.0 diff --git a/build_configure b/build_configure index f2614b741..7d997f9e8 100755 --- a/build_configure +++ b/build_configure @@ -14,7 +14,6 @@ CONF_DIR=`echo $0 | sed -e "s,[^/]*$,,;s,/$,,;s,^$,.,"` ######################################################################## # Test if the KERNEL_ROOT_DIR is set correctly - if test ! -d "${KERNEL_ROOT_DIR}"; then echo "failed : KERNEL_ROOT_DIR variable is not correct !" exit diff --git a/doc/html/INPUT/HTML/GEOM_Gen.html b/doc/html/INPUT/HTML/GEOM_Gen.html deleted file mode 100644 index 4e9967c09..000000000 --- a/doc/html/INPUT/HTML/GEOM_Gen.html +++ /dev/null @@ -1,262 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
interface GEOM_Gen
IDL file
Python
void GetCurrentStudy ( in long StudyID )
GetCurrentStudy ( StudyID )
short NbLabels ( )
return_value = NbLabels ( )
GEOM_Shape GetIORFromString ( in string ior )
return_value = GetIORFromString ( ior )
ListOfIOR GetReferencedObjects ( in GEOM_Shape shape )
return_value = GetReferencedObjects ( shape )
ListOfIOR GetObjects ( in GEOM_Shape shape )
return_value = GetObjects ( shape )
PointStruct MakePointStruct ( in double x, in double y, in double z )
return_value = MakePointStruct ( x, y, z )
DirStruct MakeDirection ( in PointStruct p )
return_value = MakeDirection ( p )
AxisStruct MakeAxisStruct ( in double x, in double y, in double z, in double vx, in double vy, in double vz )
return_value = MakeAxisStruct ( x, y, z, vx, vy, vz )
GEOM_Shape MakeBoolean ( in GEOM_Shape shape1, in GEOM_Shape shape2, in long operation )
return_value = MakeBoolean ( shape1, shape2, operation )
GEOM_Shape MakeFuse ( in GEOM_Shape shape1, in GEOM_Shape shape2 )
return_value = MakeFuse ( shape1, shape2 )
GEOM_Shape Partition ( in ListOfIOR ListShapes, in ListOfIOR ListTools, in ListOfIOR ListKeepInside, in ListOfIOR ListRemoveInside, in short Limit )
return_value = Partition ( ListShapes, ListTools, ListKeepInside, ListRemoveInside, Limit )
GEOM_Shape MakeFilling ( in GEOM_Shape shape, in short mindeg, in short maxdeg, in double tol3d, in double tol2d, in short nbiter )
return_value = MakeFilling ( shape, mindeg, maxdeg, tol3d, tol2d, nbiter )
GEOM_Shape MakeSewing ( in ListOfIOR ListShape, in double precision )
return_value = MakeSewing ( ListShape, precision )
GEOM_Shape MakeSewingShape ( in GEOM_Shape aShape, in double precision )
return_value = MakeSewingShape ( aShape, precision )
GEOM_Shape OrientationChange ( in GEOM_Shape shape )
return_value = OrientationChange ( shape )
GEOM_Shape MakePlacedBox ( in double x1, in double y1, in double z1, in double delta1, in double delta2, in double delta3 )
return_value = MakePlacedBox ( x1, y1, z1, delta1, delta2, delta3 )
GEOM_Shape MakePanel ( in GEOM_Shape shape, in short directiontype, in double delta )
return_value = MakePanel ( shape, directiontype, delta )
GEOM_Shape MakeGlueFaces ( in GEOM_Shape shape, in double tol3d )
return_value = MakeGlueFaces ( shape, tol3d )
GEOM_Shape MakeCopy ( in GEOM_Shape shape )
return_value = MakeCopy ( shape )
GEOM_Shape MakeTranslation ( in GEOM_Shape shape, in double x, in double y, in double z )
return_value = MakeTranslation ( shape, x, y, z )
GEOM_Shape MakeRotation ( in GEOM_Shape shape, in AxisStruct axis, in double angle )
return_value = MakeRotation ( shape, axis, angle )
GEOM_Shape MakeScaleTransform ( in GEOM_Shape shape, in PointStruct theCenterofScale, in double factor )
return_value = MakeScaleTransform ( shape, theCenterofScale, factor )
GEOM_Shape MakeMirrorByPlane ( in GEOM_Shape shape, in GEOM_Shape shapePlane )
return_value = MakeMirrorByPlane ( shape, shapePlane )
GEOM_Shape MakeRevolution ( in GEOM_Shape shape, in AxisStruct axis, in double angle )
return_value = MakeRevolution ( shape, axis, angle )
GEOM_Shape MakePrism ( in GEOM_Shape baseShape, in PointStruct P1, in PointStruct P2 )
return_value = MakePrism ( baseShape, P1, P2 )
GEOM_Shape MakePipe ( in GEOM_Shape pathShape, in GEOM_Shape baseShape )
return_value = MakePipe ( pathShape, baseShape )
GEOM_Shape MakeMultiTranslation1D ( in GEOM_Shape shape, in DirStruct dir, in double step, in short nbtimes )
return_value = MakeMultiTranslation1D ( shape, dir, step, nbtimes )
GEOM_Shape MakeMultiTranslation2D ( in GEOM_Shape shape, in DirStruct dir1, in double step1, in short nbtimes1, in DirStruct dir2, in double step2, in short nbtimes2 )
return_value = MakeMultiTranslation2D ( shape, dir1, step1, nbtimes1, dir2, step2, nbtimes2 )
GEOM_Shape MakeMultiRotation1D ( in GEOM_Shape shape, in DirStruct dir, in PointStruct loc, in short nbtimes )
return_value = MakeMultiRotation1D ( shape, dir, loc, nbtimes )
GEOM_Shape MakeMultiRotation2D ( in GEOM_Shape shape, in DirStruct dir, in PointStruct loc, in double ang, in short nbtimes1, in double step, in short nbtimes2 )
return_value = MakeMultiRotation2D ( shape, dir, loc, ang, nbtimes1, step, nbtimes2 )
GEOM_Shape MakeCDG ( in GEOM_Shape shape )
return_value = MakeCDG ( shape )
GEOM_Shape MakeVertex ( in double x, in double y, in double z )
return_value = MakeVertex ( x, y, z )
GEOM_Shape MakeVector ( in PointStruct pstruct1, in PointStruct pstruct2 )
return_value = MakeVector ( pstruct1, pstruct2 )
GEOM_Shape MakeLine ( in PointStruct pstruct, in DirStruct dstruct )
return_value = MakeLine ( pstruct, dstruct )
GEOM_Shape MakePlane ( in PointStruct pstruct, in DirStruct dstruct, in double trimsize )
return_value = MakePlane ( pstruct, dstruct, trimsize )
GEOM_Shape MakeCircle ( in PointStruct pstruct, in DirStruct dstruct, in double radius )
return_value = MakeCircle ( pstruct, dstruct, radius )
GEOM_Shape MakeArc ( in PointStruct pInit, in PointStruct pCircle, in PointStruct pEnd )
return_value = MakeArc ( pInit, pCircle, pEnd )
GEOM_Shape MakeBox ( in double x1, in double y1, in double z1, in double x2, in double y2, in double z2 )
return_value = MakeBox ( x1, y1, z1, x2, y2, z2 )
GEOM_Shape MakeCylinder ( in PointStruct pstruct, in DirStruct dstruct, in double radius, in double height )
return_value = MakeCylinder ( pstruct, dstruct, radius, height )
GEOM_Shape MakeSphere ( in double x1, in double y1, in double z1, in double radius )
return_value = MakeSphere ( x1, y1, z1, radius )
GEOM_Shape MakeTorus ( in PointStruct pstruct, in DirStruct dstruct, in double major_radius, in double minor_radius )
return_value = MakeTorus ( pstruct, dstruct, major_radius, minor_radius )
GEOM_Shape MakeCone ( in PointStruct pstruct, in DirStruct dstruct, in double radius1, in double radius2, in double height )
return_value = MakeCone ( pstruct, dstruct, radius1, radius2, height )
GEOM_Shape Archimede ( in GEOM_Shape shape, in double Weight, in double WaterDensity, in double MeshingDeflection )
return_value = Archimede ( shape, Weight, WaterDensity, MeshingDeflection )
GEOM_Shape MakeEdge ( in PointStruct pstruct1, in PointStruct pstruct2 )
return_value = MakeEdge ( pstruct1, pstruct2 )
GEOM_Shape MakeWire ( in ListOfIOR ListShape )
return_value = MakeWire ( ListShape )
GEOM_Shape MakeCompound ( in ListOfIOR ListShape )
return_value = MakeCompound ( ListShape )
GEOM_Shape MakeFace ( in GEOM_Shape shapeWire, in boolean wantplanarface )
return_value = MakeFace ( shapeWire, wantplanarface )
GEOM_Shape SubShape ( in GEOM_Shape shape, in short ShapeType, in ListOfSubShapeID ListOfID )
return_value = SubShape ( shape, ShapeType, ListOfID )
ListOfGeomShapes SubShapeAll ( in GEOM_Shape shape, in short ShapeType )
return_value = SubShapeAll ( shape, ShapeType )
GEOM_Shape SubShapeSorted ( in GEOM_Shape shape, in short ShapeType, in ListOfSubShapeID ListOfID )
return_value = SubShapeSorted ( shape, ShapeType, ListOfID )
ListOfGeomShapes SubShapeAllSorted ( in GEOM_Shape shape, in short ShapeType )
return_value = SubShapeAllSorted ( shape, ShapeType )
GEOM_Shape MakeFillet ( in GEOM_Shape shape, in double radius, in short ShapeType, in ListOfSubShapeID ListOfID )
return_value = MakeFillet ( shape, radius, ShapeType, ListOfID )
GEOM_Shape MakeChamfer ( in GEOM_Shape shape, in double d1, in double d2, in short ShapeType, in ListOfSubShapeID ListOfID )
return_value = MakeChamfer ( shape, d1, d2, ShapeType, ListOfID )
ListOfGeomShapes SuppressFaces ( in GEOM_Shape shape, in ListOfSubShapeID ListOfID )
return_value = SuppressFaces ( shape, ListOfID )
GEOM_Shape SuppressHole ( in GEOM_Shape shape, in ListOfSubShapeID ListOfIdFace, in ListOfSubShapeID ListOfIdWire, in ListOfSubShapeID ListOfIdEndFace )
return_value = SuppressHole ( shape, ListOfIdFace, ListOfIdWire, ListOfIdEndFace )
GEOM_Shape SuppressHolesInFaceOrShell ( in GEOM_Shape shapeFaceShell, in ListOfSubShapeID ListOfIdWires )
return_value = SuppressHolesInFaceOrShell ( shapeFaceShell, ListOfIdWires )
GEOM_Shape ImportIGES ( in string filename )
return_value = ImportIGES ( filename )
GEOM_Shape ImportBREP ( in string filename )
return_value = ImportBREP ( filename )
GEOM_Shape ImportSTEP ( in string filename )
return_value = ImportSTEP ( filename )
void ExportIGES ( in string filename, in GEOM_Shape theShape )
ExportIGES ( filename, theShape )
void ExportBREP ( in string filename, in GEOM_Shape theShape )
ExportBREP ( filename, theShape )
void ExportSTEP ( in string filename, in GEOM_Shape theShape )
ExportSTEP ( filename, theShape )
boolean CheckShape ( in GEOM_Shape shape )
return_value = CheckShape ( shape )

-
diff --git a/doc/html/INPUT/HTML/GEOM_Shape.html b/doc/html/INPUT/HTML/GEOM_Shape.html deleted file mode 100644 index bfee3cd70..000000000 --- a/doc/html/INPUT/HTML/GEOM_Shape.html +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - -
interface GEOM_Shape
IDL file
Python
TMPFile GetShapeStream ( )
return_value = GetShapeStream ( )
GEOM_Gen Engine ( )
return_value = Engine ( )

-
diff --git a/doc/html/INPUT/doxyfile b/doc/html/INPUT/doxyfile deleted file mode 100755 index ce82f87d7..000000000 --- a/doc/html/INPUT/doxyfile +++ /dev/null @@ -1,201 +0,0 @@ -# Doxyfile 1.3-rc1 - -#--------------------------------------------------------------------------- -# General configuration options -#--------------------------------------------------------------------------- -PROJECT_NAME = "SALOME - GEOM - v.2.0.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 = ../../../share/salome/idl/GEOM_Gen.idl \ - ../../../share/salome/idl/GEOM_Shape.idl -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 = html -HTML_FILE_EXTENSION = .html -HTML_HEADER = sources/myheader.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/html/INPUT/sources/Application-About.png b/doc/html/INPUT/sources/Application-About.png deleted file mode 100755 index 7b58330d5..000000000 Binary files a/doc/html/INPUT/sources/Application-About.png and /dev/null differ diff --git a/doc/html/INPUT/sources/Application-About1.jpg b/doc/html/INPUT/sources/Application-About1.jpg deleted file mode 100755 index cf7ab8ba0..000000000 Binary files a/doc/html/INPUT/sources/Application-About1.jpg and /dev/null differ diff --git a/doc/html/INPUT/sources/application.gif b/doc/html/INPUT/sources/application.gif deleted file mode 100644 index 0b05d5c18..000000000 Binary files a/doc/html/INPUT/sources/application.gif and /dev/null differ diff --git a/doc/html/INPUT/sources/application.jpg b/doc/html/INPUT/sources/application.jpg deleted file mode 100755 index a6979ab99..000000000 Binary files a/doc/html/INPUT/sources/application.jpg and /dev/null differ diff --git a/doc/html/INPUT/sources/bg_salome.gif b/doc/html/INPUT/sources/bg_salome.gif deleted file mode 100755 index 677b70468..000000000 Binary files a/doc/html/INPUT/sources/bg_salome.gif and /dev/null differ diff --git a/doc/html/INPUT/sources/logocorp.gif b/doc/html/INPUT/sources/logocorp.gif deleted file mode 100755 index 7697e0837..000000000 Binary files a/doc/html/INPUT/sources/logocorp.gif and /dev/null differ diff --git a/doc/html/INPUT/sources/myheader.html b/doc/html/INPUT/sources/myheader.html deleted file mode 100755 index 83ca543cd..000000000 --- a/doc/html/INPUT/sources/myheader.html +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - Main Page - - - -  -
- - - - - - -
-
-
- - - - diff --git a/doc/html/INPUT/sources/occ.gif b/doc/html/INPUT/sources/occ.gif deleted file mode 100755 index ce017c8ae..000000000 Binary files a/doc/html/INPUT/sources/occ.gif and /dev/null differ diff --git a/doc/html/INPUT/sources/static/doxygen.css b/doc/html/INPUT/sources/static/doxygen.css deleted file mode 100755 index 0a8e93d50..000000000 --- a/doc/html/INPUT/sources/static/doxygen.css +++ /dev/null @@ -1,49 +0,0 @@ -H1 { text-align: center; } -CAPTION { font-weight: bold } -A.qindex {} -A.qindexRef {} -A.el { text-decoration: none; font-weight: bold } -A.elRef { font-weight: bold } -A.code { text-decoration: none; font-weight: normal; color: #4444ee } -A.codeRef { font-weight: normal; color: #4444ee } -A:hover { text-decoration: none; background-color: lightblue } -DL.el { margin-left: -1cm } -DIV.fragment { width: 100%; border: none; background-color: #CCCCCC } -DIV.ah { background-color: #CCCCCC; font-weight: bold; color: #ffffff; margin-bottom: 3px; margin-top: 3px } -TD.md { background-color: lightblue; font-weight: bold; } -TD.mdname1 { background-color: lightblue; font-weight: bold; color: #602020; } -TD.mdname { background-color: lightblue; font-weight: bold; color: #602020; width: 600px; } -DIV.groupHeader { margin-left: 16px; margin-top: 12px; margin-bottom: 6px; font-weight: bold } -DIV.groupText { margin-left: 16px; font-style: italic; font-size: smaller } -BODY { background: url(sources/bg_salome.gif) } -TD.indexkey { - background-color: #CCCCCC; - font-weight: bold; - padding-right : 10px; - padding-top : 2px; - padding-left : 10px; - padding-bottom : 2px; - margin-left : 0px; - margin-right : 0px; - margin-top : 2px; - margin-bottom : 2px -} -TD.indexvalue { - background-color: #CCCCCC; - font-style: italic; - padding-right : 10px; - padding-top : 2px; - padding-left : 10px; - padding-bottom : 2px; - margin-left : 0px; - margin-right : 0px; - margin-top : 2px; - margin-bottom : 2px -} -span.keyword { color: #008000 } -span.keywordtype { color: #604020 } -span.keywordflow { color: #e08000 } -span.comment { color: #800000 } -span.preprocessor { color: #806020 } -span.stringliteral { color: #002080 } -span.charliteral { color: #008080 } diff --git a/doc/html/INPUT/sources/static/page2.html b/doc/html/INPUT/sources/static/page2.html deleted file mode 100755 index 54dab3f8e..000000000 --- a/doc/html/INPUT/sources/static/page2.html +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - Main Page - - - - -   -
- - - - - - - - -
- - -
-
- - -
- - diff --git a/doc/html/INPUT/sources/static/tree.js b/doc/html/INPUT/sources/static/tree.js deleted file mode 100755 index fdfc5a03c..000000000 --- a/doc/html/INPUT/sources/static/tree.js +++ /dev/null @@ -1,48 +0,0 @@ -foldersTree = gFld("SALOME v.2.0.0 ", "", "") - insDoc(foldersTree, gLnk("Main Page", "", "main.html")) - -aux1 = insFld(foldersTree, gFld("TUI Reference Guide", "")) - aux2 = insFld(aux1, gFld("Modules", "")) - aux3 = insFld(aux2, gFld("SALOME GEOMETRY module", "")) -/*! insDoc(aux3, gLnk("Overview", "", "overview_Geometry.html"))*/ - aux4 = insFld(aux3, gFld("Packages", "")) - insDoc(aux4, gLnk("GEOM", "", "namespaceGEOM.html")) -/*! insDoc(aux3, gLnk("Examples", "", "examples_GEOM.html")) -*/ - -/*! Data structures -*/ - insDoc(aux1, gLnk("Data Structures", "", "annotated.html")) - -/*! insDoc(aux1, gLnk("GEOM::GEOM_Gen", "", "interfaceGEOM_1_1GEOM__Gen.html")) - insDoc(aux1, gLnk("GEOM::GEOM_Shape", "", "interfaceGEOM_1_1GEOM__Shape.html")) -*/ - insDoc(aux1, gLnk("Class Hierarchy", "", "hierarchy.html")) - -/*! - aux3 = insFld(aux2, gFld("GEOM::GEOM_Gen", "", "interfaceGEOM_1_1GEOM__Gen.html")) - aux3 = insFld(aux2, gFld("GEOM::GEOM_Shape", "", "interfaceGEOM_1_1GEOM__Shape.html")) - aux3 = insFld(aux2, gFld("GEOM::AxisStruct", "", "structGEOM_1_1AxisStruct.html")) - aux3 = insFld(aux2, gFld("GEOM::DirStruct", "", "structGEOM_1_1DirStruct.html")) - aux3 = insFld(aux2, gFld("GEOM::PointStruct", "", "structGEOM_1_1PointStruct.html")) -*/ - insDoc(aux1, gLnk("Class methods list", "", "functions.html")) -/*! -aux1 = insFld(foldersTree, gFld("Namespace List", "", "namespaces.html")) - insDoc(aux1, gLnk("GEOM", "", "namespaceGEOM.html")) -*/ - insDoc(aux1, gLnk("Namespace Members", "", "namespacemembers.html")) - - insDoc(aux1, gLnk("File List", "", "files.html")) - -/*! - - insDoc(aux1, gLnk("GEOM_Gen.idl", "", "GEOM__Gen_8idl.html")) - insDoc(aux1, gLnk("GEOM_Shape.idl", "", "GEOM__Shape_8idl.html")) -*/ - -aux1 = insFld(foldersTree, gFld("IDL/Python mapping", "")) - insDoc(aux1, gLnk("Mapping of GEOMETRY IDL definitions to Python language", "", "page2.html")) - -/*! insDoc(foldersTree, gLnk("Graphical Class Hierarchy", "", "inherits.html")) -*/ diff --git a/doc/html/INPUT/sources/static/treeview.js b/doc/html/INPUT/sources/static/treeview.js deleted file mode 100644 index 55eb43d07..000000000 --- a/doc/html/INPUT/sources/static/treeview.js +++ /dev/null @@ -1,505 +0,0 @@ -//**************************************************************** -// You are free to copy the "Folder-Tree" script as long as you -// keep this copyright notice: -// Script found in: http://www.geocities.com/Paris/LeftBank/2178/ -// Author: Marcelino Alves Martins (martins@hks.com) December '97. -//**************************************************************** - -//Log of changes: -// 17 Feb 98 - Fix initialization flashing problem with Netscape -// -// 27 Jan 98 - Root folder starts open; support for USETEXTLINKS; -// make the ftien4 a js file -// -// DvH: Dec 2000 - Made some minor changes to support external -// references - -// Definition of class Folder -// ***************************************************************** - -function Folder(folderDescription, tagName, hreference) //constructor -{ - //constant data - this.desc = folderDescription - this.tagName = tagName - this.hreference = hreference - this.id = -1 - this.navObj = 0 - this.iconImg = 0 - this.nodeImg = 0 - this.isLastNode = 0 - - //dynamic data - this.isOpen = true - this.iconSrc = "ftv2folderopen.png" - this.children = new Array - this.nChildren = 0 - - //methods - this.initialize = initializeFolder - this.setState = setStateFolder - this.addChild = addChild - this.createIndex = createEntryIndex - this.hide = hideFolder - this.display = display - this.renderOb = drawFolder - this.totalHeight = totalHeight - this.subEntries = folderSubEntries - this.outputLink = outputFolderLink -} - -function setStateFolder(isOpen) -{ - var subEntries - var totalHeight - var fIt = 0 - var i=0 - - if (isOpen == this.isOpen) - return - - if (browserVersion == 2) - { - totalHeight = 0 - for (i=0; i < this.nChildren; i++) - totalHeight = totalHeight + this.children[i].navObj.clip.height - subEntries = this.subEntries() - if (this.isOpen) - totalHeight = 0 - totalHeight - for (fIt = this.id + subEntries + 1; fIt < nEntries; fIt++) - indexOfEntries[fIt].navObj.moveBy(0, totalHeight) - } - this.isOpen = isOpen - propagateChangesInState(this) -} - -function propagateChangesInState(folder) -{ - var i=0 - - if (folder.isOpen) - { - if (folder.nodeImg) - if (folder.isLastNode) - folder.nodeImg.src = "ftv2mlastnode.png" - else - folder.nodeImg.src = "ftv2mnode.png" - folder.iconImg.src = "ftv2folderopen.png" - for (i=0; i 0) - auxEv = "" - else - auxEv = "" - - if (level>0) - if (lastNode) //the last 'brother' in the children array - { - this.renderOb(leftSide + auxEv + "") -// leftSide = leftSide + "" - this.isLastNode = 1 - } - else - { - this.renderOb(leftSide + auxEv + "") - leftSide = leftSide + "" - this.isLastNode = 0 - } - else - this.renderOb("") - - if (nc > 0) - { - level = level + 1 - for (i=0 ; i < this.nChildren; i++) - { - if (i == this.nChildren-1) - this.children[i].initialize(level, 1, leftSide) - else - this.children[i].initialize(level, 0, leftSide) - } - } -} - -function drawFolder(leftSide) -{ - if (browserVersion == 2) { - if (!doc.yPos) - doc.yPos=8 - doc.write("") - } - if (browserVersion == 3) - { - doc.write("
") - } - - doc.write("\n") - doc.write("\n\n") - doc.write("\n
") - doc.write(leftSide) - this.outputLink() - doc.write("") - doc.write("") - if (USETEXTLINKS) - { - this.outputLink() - doc.write(this.desc + "") - } - else - doc.write(this.desc) - -/*! - if (this.tagName!="") - { - doc.write(" [external]") - } -*/ - doc.write("
\n") - - if (browserVersion == 2) { - doc.write("") - } - if (browserVersion == 3) { - doc.write("
") - } - - if (browserVersion == 1) { - this.navObj = doc.all["folder"+this.id] - this.iconImg = doc.all["folderIcon"+this.id] - this.nodeImg = doc.all["nodeIcon"+this.id] - } else if (browserVersion == 2) { - this.navObj = doc.layers["folder"+this.id] - this.iconImg = this.navObj.document.images["folderIcon"+this.id] - this.nodeImg = this.navObj.document.images["nodeIcon"+this.id] - doc.yPos=doc.yPos+this.navObj.clip.height - } else if (browserVersion == 3) { - this.navObj = doc.getElementById("folder"+this.id) - this.iconImg = doc.images.namedItem("folderIcon"+this.id) - this.nodeImg = doc.images.namedItem("nodeIcon"+this.id) - } -} - -function outputFolderLink() -{ - if (this.hreference) - { - doc.write(" 0) - doc.write("onClick='javascript:clickOnFolder("+this.id+")'") - doc.write(">") - } - else - doc.write("") -} - -function addChild(childNode) -{ - this.children[this.nChildren] = childNode - this.nChildren++ - return childNode -} - -function folderSubEntries() -{ - var i = 0 - var se = this.nChildren - - for (i=0; i < this.nChildren; i++){ - if (this.children[i].children) //is a folder - se = se + this.children[i].subEntries() - } - - return se -} - - -// Definition of class Item (a document or link inside a Folder) -// ************************************************************* - -function Item(itemDescription, tagName, itemLink) // Constructor -{ - // constant data - this.desc = itemDescription - this.tagName = tagName - this.link = itemLink - this.id = -1 //initialized in initalize() - this.navObj = 0 //initialized in render() - this.iconImg = 0 //initialized in render() - this.iconSrc = "ftv2doc.png" - - // methods - this.initialize = initializeItem - this.createIndex = createEntryIndex - this.hide = hideItem - this.display = display - this.renderOb = drawItem - this.totalHeight = totalHeight -} - -function hideItem() -{ - if (browserVersion == 1 || browserVersion == 3) { - if (this.navObj.style.display == "none") - return - this.navObj.style.display = "none" - } else { - if (this.navObj.visibility == "hidden") - return - this.navObj.visibility = "hidden" - } -} - -function initializeItem(level, lastNode, leftSide) -{ - this.createIndex() - - if (level>0) - if (lastNode) //the last 'brother' in the children array - { - this.renderOb(leftSide + "") - leftSide = leftSide + "" - } - else - { - this.renderOb(leftSide + "") - leftSide = leftSide + "" - } - else - this.renderOb("") -} - -function drawItem(leftSide) -{ - if (browserVersion == 2) - doc.write("") - if (browserVersion == 3) - doc.write("
") - - doc.write("\n\n") - doc.write("\n
") - doc.write(leftSide) - if (this.link!="") - { - doc.write("") - } - doc.write("") - if (this.link!="") - { - doc.write("") - } - doc.write("") - if (USETEXTLINKS && this.link!="") - doc.write("" + this.desc + "") - else - doc.write(this.desc) -/*! - if (this.tagName!="") - { - doc.write(" [external]"); - } -*/ - doc.write("\n
\n") - - if (browserVersion == 2) - doc.write("") - if (browserVersion == 3) - doc.write("
") - - if (browserVersion == 1) { - this.navObj = doc.all["item"+this.id] - this.iconImg = doc.all["itemIcon"+this.id] - } else if (browserVersion == 2) { - this.navObj = doc.layers["item"+this.id] - this.iconImg = this.navObj.document.images["itemIcon"+this.id] - doc.yPos=doc.yPos+this.navObj.clip.height - } else if (browserVersion == 3) { - this.navObj = doc.getElementById("item"+this.id) - this.iconImg = doc.images.namedItem("itemIcon"+this.id) - } -} - - -// Methods common to both objects (pseudo-inheritance) -// ******************************************************** - -function display() -{ - if (browserVersion == 1 || browserVersion == 3) - this.navObj.style.display = "block" - else - this.navObj.visibility = "show" -} - -function createEntryIndex() -{ - this.id = nEntries - indexOfEntries[nEntries] = this - nEntries++ -} - -// total height of subEntries open -function totalHeight() //used with browserVersion == 2 -{ - var h = this.navObj.clip.height - var i = 0 - - if (this.isOpen) //is a folder and _is_ open - for (i=0 ; i < this.nChildren; i++) - h = h + this.children[i].totalHeight() - - return h -} - - -// Events -// ********************************************************* - -function clickOnFolder(folderId) -{ - var clicked = indexOfEntries[folderId] - - if (!clicked.isOpen) - clickOnNode(folderId) - - return - - if (clicked.isSelected) - return -} - -function clickOnNode(folderId) -{ - var clickedFolder = 0 - var state = 0 - - clickedFolder = indexOfEntries[folderId] - state = clickedFolder.isOpen - - clickedFolder.setState(!state) //open<->close -} - -function initializeDocument() -{ - doc = document; - if (doc.all) - browserVersion = 1 //IE4 - else - if (doc.layers) - browserVersion = 2 //NS4 - else if(navigator.userAgent.toLowerCase().indexOf('gecko') != -1) - browserVersion = 3 //mozilla - else - browserVersion = 0 //other - - foldersTree.initialize(0, 1, "") - foldersTree.display() - - if (browserVersion > 0) - { - if(browserVersion != 3) - doc.write(" ") - - // close the whole tree - clickOnNode(0) - // open the root folder - clickOnNode(0) - } -} - -// Auxiliary Functions for Folder-Treee backward compatibility -// ********************************************************* - -function gFld(description, tagName, hreference) -{ - folder = new Folder(description, tagName, hreference) - return folder -} - -function gLnk(description, tagName, linkData) -{ - fullLink = "" - - if (linkData!="") - { - fullLink = "'"+linkData+"' target=\"basefrm\"" - } - - linkItem = new Item(description, tagName, fullLink) - return linkItem -} - -function insFld(parentFolder, childFolder) -{ - return parentFolder.addChild(childFolder) -} - -function insDoc(parentFolder, document) -{ - parentFolder.addChild(document) -} - -// Global variables -// **************** - -USETEXTLINKS = 1 -indexOfEntries = new Array -nEntries = 0 -doc = document -browserVersion = 0 -selectedFolder=0 diff --git a/doc/html/Makefile.in b/doc/html/Makefile.in deleted file mode 100644 index 135b2daef..000000000 --- a/doc/html/Makefile.in +++ /dev/null @@ -1,39 +0,0 @@ -# -* Makefile *- -# -# Author : Vasily Rusyaev (Open Cascade NN) -# Date : 13/02/2003 -# $Header: -# -# source path -top_srcdir=@top_srcdir@ -root_srcdir=@ROOT_SRCDIR@ -top_builddir=../.. -srcdir=@srcdir@ -VPATH=.:@srcdir@ -doxygen=@DOXYGEN@ - -@COMMENCE@ - -doc: - cp -fr $(srcdir)/INPUT ./; \ - cd INPUT; \ - sed 's|../../../share/salome|$(root_srcdir)|' doxyfile > doxyfile1; \ - mv -f doxyfile1 doxyfile; \ - $(doxygen) ./doxyfile; \ - cd ..; \ - cp -fr $(srcdir)/INPUT/sources/static/*.* ./html/ - cp -fr $(srcdir)/INPUT/sources/ html/ - cp -fr $(srcdir)/INPUT/HTML/ html/ - -clean: - rm -rf html - -distclean: clean - rm -rf INPUT - -install: - $(INSTALL) -d $(docdir); \ - cp -rf html $(docdir) - -uninstall: - rm -rf $(docdir)/html diff --git a/doc/salome/gui/GEOM/GEOM.log b/doc/salome/gui/GEOM/GEOM.log index af9c2ab24..e17a2ed87 100755 --- a/doc/salome/gui/GEOM/GEOM.log +++ b/doc/salome/gui/GEOM/GEOM.log @@ -127,6 +127,7 @@ whskin_frmset01.htm geom_hha.hhk geom.hhc geom.hhk +blocks.htm changing_displaying_parameters.htm files\introduction_to_geom.htm files\salome2_sp3_basicgui_functions.htm @@ -140,200 +141,267 @@ files\salome2_sp3_operationgui_functions.htm files\salome2_sp3_primitivegui_functions.htm files\salome2_sp3_repairgui_functions.htm files\salome2_sp3_transformationgui_functions.htm +newentity_blocks.htm +sketcher.htm +working_with_groups.htm geom.glo default.css -image23.gif -image59.jpg -image26.jpg -image12.gif -image15.jpg -files\salome2_sp3_repairgui_functions_salome2_sp3_repairgui_functions_image119.gif -files\salome2_sp3_primitivegui_functions_salome2_sp3_primitivegui_functions_image99.gif -files\salome2_sp3_measuregui_functions_salome2_sp3_measuregui_functions_image77.gif +image61.gif +image191.jpg +image180.jpg +image109.jpg +image97.jpg +image86.jpg +image75.jpg +image53.jpg +image20.jpg +files\salome2_sp3_transformationgui_functions_salome2_sp3_transformationgui_functions_image131.gif +files\salome2_sp3_basicgui_functions_salome2_sp3_basicgui_functions_image31.gif +image192.jpg +image181.jpg +image51.gif +image170.jpg +image98.jpg +image87.jpg +image76.jpg +image65.jpg +image54.jpg +image21.jpg +image10.jpg +files\salome2_sp3_transformationgui_functions_salome2_sp3_transformationgui_functions_image132.gif +files\salome2_sp3_repairgui_functions_salome2_sp3_repairgui_functions_image121.gif +files\salome2_sp3_basicgui_functions_salome2_sp3_basicgui_functions_image32.gif +image193.jpg +image182.jpg +image52.gif +image171.jpg +image160.jpg +image41.gif +image99.jpg +image88.jpg +image66.jpg +image55.jpg +image22.jpg +image11.jpg +files\salome2_sp3_transformationgui_functions_salome2_sp3_transformationgui_functions_image133.gif +files\salome2_sp3_repairgui_functions_salome2_sp3_repairgui_functions_image122.gif +files\salome2_sp3_operationgui_functions_salome2_sp3_operationgui_functions_image87.gif image3.jpg +files\salome2_sp3_basicgui_functions_salome2_sp3_basicgui_functions_image33.gif +image194.jpg +image183.jpg +image53.gif +image172.jpg +image42.gif +image161.jpg +image150.jpg +image89.jpg +image78.jpg +image20.gif +image67.jpg +image56.jpg +image23.jpg +image12.jpg +files\salome2_sp3_operationgui_functions_salome2_sp3_operationgui_functions_image88.gif +files\salome2_sp3_booleangui_functions_salome2_sp3_booleangui_functions_image1.gif files\salome2_sp3_basicgui_functions_salome2_sp3_basicgui_functions_image34.gif -salome2_sp3_buildgui_functions_salome2_sp3_buildgui_functions_image16.gif +image184.jpg +image173.jpg +image151.jpg +image32.gif image140.jpg -image24.gif -image27.jpg -image13.gif -image16.jpg -files\salome2_sp3_measuregui_functions_salome2_sp3_measuregui_functions_image78.gif -salome2_sp3_buildgui_functions_salome2_sp3_buildgui_functions_image17.gif -image141.jpg -image25.gif -image130.jpg -image28.jpg -image14.gif -image17.jpg +image79.jpg +image21.gif +image68.jpg +image57.jpg +image24.jpg +image13.jpg image2.gif image5.jpg -files\salome2_sp3_transformationgui_functions_salome2_sp3_transformationgui_functions_image130.gif -salome2_sp3_buildgui_functions_salome2_sp3_buildgui_functions_image18.gif +files\salome2_sp3_operationgui_functions_salome2_sp3_operationgui_functions_image89.gif +files\salome2_sp3_booleangui_functions_salome2_sp3_booleangui_functions_image2.gif +image196.jpg +image185.jpg +image44.gif +image163.jpg +image152.jpg +image141.jpg +image130.jpg +image22.gif +image69.jpg +image58.jpg +files\salome2_sp3_displaygui_functions_salome2_sp3_displaygui_functions_image51.gif +image11.gif +image14.jpg +files\salome2_sp3_generationgui_functions_salome2_sp3_generationgui_functions_image56.gif +files\salome2_sp3_booleangui_functions_salome2_sp3_booleangui_functions_image3.gif +image197.jpg +image56.gif +image186.jpg +image175.jpg +image164.jpg image142.jpg image131.jpg +image23.gif image120.jpg -image15.gif -image29.jpg -image18.jpg -files\salome2_sp3_transformationgui_functions_salome2_sp3_transformationgui_functions_image131.gif -files\salome2_sp3_primitivegui_functions_salome2_sp3_primitivegui_functions_image100.gif -salome2_sp3_buildgui_functions_salome2_sp3_buildgui_functions_image19.gif +image59.jpg +image26.jpg +image12.gif +image15.jpg +image7.jpg +image4.gif +files\salome2_sp3_generationgui_functions_salome2_sp3_generationgui_functions_image57.gif +files\salome2_sp3_displaygui_functions_salome2_sp3_displaygui_functions_image52.gif +files\salome2_sp3_booleangui_functions_salome2_sp3_booleangui_functions_image4.gif +salome2_sp3_buildgui_functions_salome2_sp3_buildgui_functions_image13.gif +image57.gif +image187.jpg +image176.jpg +image165.jpg +image154.jpg +image35.gif image132.jpg +image24.gif image121.jpg image110.jpg -image90.jpg -image16.gif -image19.jpg -image7.jpg -image4.gif -files\salome2_sp3_transformationgui_functions_salome2_sp3_transformationgui_functions_image132.gif -files\salome2_sp3_primitivegui_functions_salome2_sp3_primitivegui_functions_image101.gif +image27.jpg +image13.gif +image16.jpg +image8.jpg +image5.gif +files\salome2_sp3_measuregui_functions_salome2_sp3_measuregui_functions_image71.gif +files\salome2_sp3_generationgui_functions_salome2_sp3_generationgui_functions_image58.gif +files\salome2_sp3_displaygui_functions_salome2_sp3_displaygui_functions_image53.gif files\salome2_sp3_basicgui_functions_salome2_sp3_basicgui_functions_image27.gif +salome2_sp3_buildgui_functions_salome2_sp3_buildgui_functions_image14.gif +image199.jpg +image188.jpg +image166.jpg +image144.jpg image133.jpg +image25.gif image122.jpg image111.jpg image100.jpg -image91.jpg -image80.jpg -image17.gif -image8.jpg -image5.gif -files\salome2_sp3_transformationgui_functions_salome2_sp3_transformationgui_functions_image133.gif -files\salome2_sp3_primitivegui_functions_salome2_sp3_primitivegui_functions_image102.gif +image28.jpg +image14.gif +image17.jpg +image9.jpg +image6.gif +files\salome2_sp3_transformationgui_functions_salome2_sp3_transformationgui_functions_image128.gif +files\salome2_sp3_measuregui_functions_salome2_sp3_measuregui_functions_image72.gif +files\salome2_sp3_generationgui_functions_salome2_sp3_generationgui_functions_image59.gif +files\salome2_sp3_displaygui_functions_salome2_sp3_displaygui_functions_image54.gif files\salome2_sp3_basicgui_functions_salome2_sp3_basicgui_functions_image28.gif +salome2_sp3_buildgui_functions_salome2_sp3_buildgui_functions_image15.gif +i_blue.jpg +image200.jpg +image59.gif +image189.jpg +image167.jpg +image156.jpg +image37.gif +image145.jpg image134.jpg image123.jpg image112.jpg image101.jpg -image92.jpg -image81.jpg -image70.jpg -image9.jpg -image6.gif -files\salome2_sp3_primitivegui_functions_salome2_sp3_primitivegui_functions_image103.gif +image15.gif +image29.jpg +image18.jpg +image7.gif +files\salome2_sp3_transformationgui_functions_salome2_sp3_transformationgui_functions_image129.gif +files\salome2_sp3_measuregui_functions_salome2_sp3_measuregui_functions_image73.gif +files\salome2_sp3_displaygui_functions_salome2_sp3_displaygui_functions_image55.gif files\salome2_sp3_basicgui_functions_salome2_sp3_basicgui_functions_image29.gif +salome2_sp3_buildgui_functions_salome2_sp3_buildgui_functions_image16.gif +image201.jpg +image179.jpg +image49.gif +image168.jpg +image146.jpg image135.jpg image124.jpg image113.jpg image102.jpg -image93.jpg -image82.jpg -image71.jpg -image19.gif -image60.jpg -image7.gif -files\salome2_sp3_repairgui_functions_salome2_sp3_repairgui_functions_image120.gif -files\salome2_sp3_operationgui_functions_salome2_sp3_operationgui_functions_image87.gif -i_blue.jpg +image90.jpg +image16.gif +image19.jpg +image8.gif +files\salome2_sp3_repairgui_functions_salome2_sp3_repairgui_functions_image119.gif +files\salome2_sp3_primitivegui_functions_salome2_sp3_primitivegui_functions_image100.gif +files\salome2_sp3_measuregui_functions_salome2_sp3_measuregui_functions_image74.gif +salome2_sp3_buildgui_functions_salome2_sp3_buildgui_functions_image17.gif +image202.jpg +image169.jpg +image158.jpg +image147.jpg image136.jpg image125.jpg -image114.jpg image103.jpg -image94.jpg -image83.jpg -image72.jpg -image61.jpg -image8.gif -files\salome2_sp3_repairgui_functions_salome2_sp3_repairgui_functions_image121.gif -files\salome2_sp3_operationgui_functions_salome2_sp3_operationgui_functions_image88.gif +image91.jpg +image80.jpg +image17.gif +image9.gif +files\salome2_sp3_primitivegui_functions_salome2_sp3_primitivegui_functions_image101.gif +files\salome2_sp3_operationgui_functions_salome2_sp3_operationgui_functions_image90.gif +files\salome2_sp3_measuregui_functions_salome2_sp3_measuregui_functions_image75.gif +salome2_sp3_buildgui_functions_salome2_sp3_buildgui_functions_image18.gif +image203.jpg +image29.gif image137.jpg image126.jpg image115.jpg image104.jpg -image95.jpg -image84.jpg -image73.jpg -image62.jpg -image51.jpg -files\salome2_sp3_displaygui_functions_salome2_sp3_displaygui_functions_image51.gif -image9.gif -files\salome2_sp3_repairgui_functions_salome2_sp3_repairgui_functions_image122.gif -files\salome2_sp3_operationgui_functions_salome2_sp3_operationgui_functions_image89.gif +image92.jpg +image81.jpg +image70.jpg +files\salome2_sp3_primitivegui_functions_salome2_sp3_primitivegui_functions_image102.gif +files\salome2_sp3_primitivegui_functions_salome2_sp3_primitivegui_functions_image99.gif +files\salome2_sp3_measuregui_functions_salome2_sp3_measuregui_functions_image76.gif +salome2_sp3_buildgui_functions_salome2_sp3_buildgui_functions_image19.gif +image204.jpg +image149.jpg image138.jpg image127.jpg image116.jpg image105.jpg -image96.jpg -image85.jpg -image74.jpg -image63.jpg -image52.jpg -files\salome2_sp3_displaygui_functions_salome2_sp3_displaygui_functions_image52.gif -files\salome2_sp3_booleangui_functions_salome2_sp3_booleangui_functions_image1.gif +image93.jpg +image82.jpg +image71.jpg +image19.gif +image60.jpg +files\salome2_sp3_primitivegui_functions_salome2_sp3_primitivegui_functions_image103.gif +files\salome2_sp3_measuregui_functions_salome2_sp3_measuregui_functions_image77.gif +image205.jpg image139.jpg image128.jpg image117.jpg image106.jpg -image97.jpg -image86.jpg -image75.jpg -image53.jpg -image20.jpg -files\salome2_sp3_transformationgui_functions_salome2_sp3_transformationgui_functions_image128.gif -files\salome2_sp3_measuregui_functions_salome2_sp3_measuregui_functions_image71.gif -files\salome2_sp3_generationgui_functions_salome2_sp3_generationgui_functions_image56.gif -files\salome2_sp3_displaygui_functions_salome2_sp3_displaygui_functions_image53.gif -files\salome2_sp3_booleangui_functions_salome2_sp3_booleangui_functions_image2.gif +image94.jpg +image83.jpg +image72.jpg +image61.jpg +files\salome2_sp3_measuregui_functions_salome2_sp3_measuregui_functions_image78.gif +image206.jpg image129.jpg image118.jpg image107.jpg -image98.jpg -image87.jpg -image76.jpg -image65.jpg -image54.jpg -image21.jpg -image10.jpg -files\salome2_sp3_transformationgui_functions_salome2_sp3_transformationgui_functions_image129.gif -files\salome2_sp3_measuregui_functions_salome2_sp3_measuregui_functions_image72.gif -files\salome2_sp3_generationgui_functions_salome2_sp3_generationgui_functions_image57.gif -files\salome2_sp3_displaygui_functions_salome2_sp3_displaygui_functions_image54.gif -files\salome2_sp3_booleangui_functions_salome2_sp3_booleangui_functions_image3.gif +image95.jpg +image84.jpg +image73.jpg +image62.jpg +image51.jpg +image190.jpg image119.jpg image108.jpg -image99.jpg -image88.jpg -image77.jpg -image66.jpg -image55.jpg -image22.jpg -image11.jpg -files\salome2_sp3_measuregui_functions_salome2_sp3_measuregui_functions_image73.gif -files\salome2_sp3_generationgui_functions_salome2_sp3_generationgui_functions_image58.gif -files\salome2_sp3_displaygui_functions_salome2_sp3_displaygui_functions_image55.gif -files\salome2_sp3_booleangui_functions_salome2_sp3_booleangui_functions_image4.gif +image96.jpg +image85.jpg +image74.jpg +image63.jpg +image52.jpg +files\salome2_sp3_transformationgui_functions_salome2_sp3_transformationgui_functions_image130.gif files\salome2_sp3_basicgui_functions_salome2_sp3_basicgui_functions_image30.gif -image109.jpg -image89.jpg -image78.jpg -image20.gif -image67.jpg -image56.jpg -image23.jpg -image12.jpg -files\salome2_sp3_measuregui_functions_salome2_sp3_measuregui_functions_image74.gif -files\salome2_sp3_generationgui_functions_salome2_sp3_generationgui_functions_image59.gif -files\salome2_sp3_basicgui_functions_salome2_sp3_basicgui_functions_image31.gif -salome2_sp3_buildgui_functions_salome2_sp3_buildgui_functions_image13.gif -image79.jpg -image21.gif -image68.jpg -image57.jpg -image24.jpg -image13.jpg -files\salome2_sp3_measuregui_functions_salome2_sp3_measuregui_functions_image75.gif -files\salome2_sp3_basicgui_functions_salome2_sp3_basicgui_functions_image32.gif -salome2_sp3_buildgui_functions_salome2_sp3_buildgui_functions_image14.gif -image22.gif -image69.jpg -image58.jpg -image11.gif -image14.jpg -files\salome2_sp3_operationgui_functions_salome2_sp3_operationgui_functions_image90.gif -files\salome2_sp3_measuregui_functions_salome2_sp3_measuregui_functions_image76.gif -files\salome2_sp3_basicgui_functions_salome2_sp3_basicgui_functions_image33.gif -salome2_sp3_buildgui_functions_salome2_sp3_buildgui_functions_image15.gif ehlpdhtm.js geom.ppf default_ns.css @@ -372,9 +440,14 @@ whgdata\whlstfl17.htm whgdata\whlstfl18.htm whgdata\whlstfl19.htm whgdata\whlstfl20.htm +whgdata\whlstfl21.htm +whgdata\whlstfl22.htm whgdata\whlstf0.htm whgdata\whlstf1.htm whgdata\whlstf2.htm +whgdata\whlstf3.htm +whgdata\whlstf4.htm +whgdata\whlstf5.htm whgdata\whlstg0.htm geom.html geom_csh.html diff --git a/doc/salome/gui/GEOM/blocks.htm b/doc/salome/gui/GEOM/blocks.htm new file mode 100755 index 000000000..ce53dbc61 --- /dev/null +++ b/doc/salome/gui/GEOM/blocks.htm @@ -0,0 +1,144 @@ + + + + + + + + + + +Building of blocks + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Building of blocks

+ +

 

+ +
+ +

 

+ +

 

+ +

To use these options:

+ +

 

+ +

In the main menu select Blocks + submenu.

+ +

 

+ +

 

+ +

 

+ +

 

+ +

 

+ +

 

+ +

 

+ + + + + diff --git a/doc/salome/gui/GEOM/changing_displaying_parameters.htm b/doc/salome/gui/GEOM/changing_displaying_parameters.htm index d6f8f8527..db074bc3b 100755 --- a/doc/salome/gui/GEOM/changing_displaying_parameters.htm +++ b/doc/salome/gui/GEOM/changing_displaying_parameters.htm @@ -19,8 +19,8 @@ - - + + @@ -131,7 +131,7 @@ else href="#Transparency">Transparency

  • Isos

  • + href="#Isos">Isos (in OCC viewer only)

     

    diff --git a/doc/salome/gui/GEOM/files/salome2_sp3_basicgui_functions.htm b/doc/salome/gui/GEOM/files/salome2_sp3_basicgui_functions.htm index bc3fb8856..dc3c7060b 100755 --- a/doc/salome/gui/GEOM/files/salome2_sp3_basicgui_functions.htm +++ b/doc/salome/gui/GEOM/files/salome2_sp3_basicgui_functions.htm @@ -29,8 +29,8 @@ - - + + @@ -64,28 +64,82 @@ p.whs4 {font-size: 12pt;} p.whs5 {margin-left: 40px;} p.whs6 {font-family: 'Times New Roman', serif; font-size: 14pt;} img_whs7 {border-style: none; width: 20px; height: 20px;} -p.whs8 {font-size: 12pt; margin-left: 40px;} -img_whs9 {border-style: none; border: none; width: 200px; height: 176px;} -p.whs10 {color: #808080; font-size: 12pt;} -p.whs11 {font-size: 12pt; color: #000000;} -p.whs12 {color: #808080; font-size: 12pt; margin-left: 40px;} -img_whs13 {border-style: none; border: none; width: 150px; height: 140px;} -img_whs14 {border-style: none; border: none; width: 150px; height: 139px;} -img_whs15 {border-style: none; border: none; width: 200px; height: 193px;} -img_whs16 {border-style: none; border: none; width: 150px; height: 129px;} -img_whs17 {border-style: none; border: none; width: 200px; height: 211px;} -p.whs18 {font-size: 12pt; margin-left: 40px; font-weight: bold;} -img_whs19 {border-style: none; border: none; width: 150px; height: 154px;} -img_whs20 {border-style: none; border: none; width: 200px; height: 202px;} -img_whs21 {border-style: none; border: none; width: 150px; height: 123px;} -img_whs22 {border-style: none; border: none; width: 200px; height: 175px;} -img_whs23 {border-style: none; border: none; width: 150px; height: 128px;} -img_whs24 {border-style: none; border: none; width: 200px; height: 192px;} -p.whs25 {font-size: 12pt; font-weight: bold; color: #000000;} -img_whs26 {border-style: none; border: none; width: 150px; height: 131px;} -img_whs27 {border-style: none; border: none; width: 200px; height: 148px;} -p.whs28 {font-size: 12pt; margin-left: 0px;} -p.whs29 {font-size: 12pt; font-weight: bold; margin-left: 40px;} +table.whs8 {x-cell-content-align: top; border-spacing: 0; width: 84.306%; border-spacing: 0px;} +col.whs9 {width: 33.333%;} +col.whs10 {width: 28.501%;} +col.whs11 {width: 31.796%;} +tr.whs12 {x-cell-content-align: top;} +td.whs13 {width: 33.333%; padding-right: 10px; padding-left: 10px; border-right-style: none; border-left-style: none; border-top-style: none; border-bottom-style: none;} +img_whs14 {border-style: none; border: none; width: 218px; height: 250px;} +td.whs15 {width: 28.501%; padding-right: 10px; padding-left: 10px; border-right-style: none; border-top-style: none; border-bottom-style: none;} +p.whs16 {font-size: 12pt; margin-right: 0px;} +img_whs17 {border-style: none; border: none; width: 150px; height: 250px;} +td.whs18 {width: 31.796%; padding-right: 10px; padding-left: 10px; border-top-style: none; border-bottom-style: none; border-right-style: none;} +img_whs19 {border-style: none; border: none; width: 170px; height: 250px;} +p.whs20 {font-size: 12pt; margin-left: 40px;} +p.whs21 {color: #808080; font-size: 12pt;} +p.whs22 {font-size: 12pt; color: #000000;} +p.whs23 {color: #808080; font-size: 12pt; margin-left: 40px;} +img_whs24 {border-style: none; border: none; width: 150px; height: 140px;} +img_whs25 {border-style: none; border: none; width: 200px; height: 176px;} +img_whs26 {border-style: none; border: none; width: 150px; height: 139px;} +table.whs27 {x-cell-content-align: top; border-spacing: 0; width: 65.278%; border-spacing: 0px;} +col.whs28 {width: 50.213%;} +col.whs29 {width: 49.787%;} +td.whs30 {width: 50.213%; padding-right: 10px; padding-left: 10px; border-right-style: none; border-left-style: none; border-top-style: none; border-bottom-style: none;} +img_whs31 {border-style: none; border: none; width: 212px; height: 250px;} +td.whs32 {width: 49.787%; padding-right: 10px; padding-left: 10px; border-top-style: none; border-bottom-style: none; border-right-style: none;} +img_whs33 {border-style: none; border: none; width: 211px; height: 250px;} +img_whs34 {border-style: none; border: none; width: 150px; height: 129px;} +img_whs35 {border-style: none; border: none; width: 200px; height: 211px;} +p.whs36 {font-size: 12pt; margin-left: 40px; font-weight: bold;} +img_whs37 {border-style: none; border: none; width: 150px; height: 154px;} +img_whs38 {border-style: none; border: none; width: 200px; height: 202px;} +img_whs39 {border-style: none; border: none; width: 150px; height: 123px;} +p.whs40 {font-size: 14pt;} +img_whs41 {border-style: none; border: none; width: 20px; height: 20px;} +img_whs42 {border-style: none; border: none; width: 200px; height: 194px;} +p.whs43 {font-size: 12pt; font-weight: bold;} +p.whs44 {font-size: 12pt; font-weight: bold; font-style: italic; x-text-underline: off; /*begin!kadov{{*/ text-decoration: none; /*}}end!kadov*/ } +img_whs45 {border-style: none; border: none; width: 200px; height: 181px; float: none;} +img_whs46 {border-style: none; border: none; width: 175px; height: 181px;} +img_whs47 {border-style: none; border: none; width: 203px; height: 181px;} +img_whs48 {border-style: none; border: none; width: 200px; height: 175px;} +img_whs49 {border-style: none; border: none; width: 150px; height: 128px;} +table.whs50 {x-cell-content-align: top; border-spacing: 0; width: 94.306%; border-spacing: 0px;} +col.whs51 {width: 32.254%;} +col.whs52 {width: 32.547%;} +col.whs53 {width: 35.199%;} +td.whs54 {width: 32.254%; padding-right: 10px; padding-left: 10px; border-right-style: none; border-left-style: none; border-top-style: none; border-bottom-style: none;} +img_whs55 {border-style: none; border: none; width: 196px; height: 250px;} +td.whs56 {width: 32.547%; padding-right: 10px; padding-left: 10px; border-right-style: none; border-top-style: none; border-bottom-style: none;} +img_whs57 {border-style: none; border: none; width: 195px; height: 250px;} +td.whs58 {width: 35.199%; padding-right: 10px; padding-left: 10px; border-top-style: none; border-bottom-style: none; border-right-style: none;} +img_whs59 {border-style: none; border: none; width: 214px; height: 250px;} +p.whs60 {font-size: 12pt; font-weight: bold; color: #000000;} +img_whs61 {border-style: none; border: none; width: 150px; height: 131px;} +table.whs62 {x-cell-content-align: top; width: 100%; border-spacing: 0;} +td.whs63 {padding-right: 10px; padding-left: 10px; border-right-style: none; border-left-style: none; border-top-style: none; border-bottom-style: none;} +img_whs64 {border: none; width: 234px; height: 200px;} +td.whs65 {padding-right: 10px; padding-left: 10px; border-right-style: none; border-top-style: none; border-bottom-style: none;} +img_whs66 {border: none; width: 235px; height: 200px;} +td.whs67 {padding-right: 10px; padding-left: 10px; border-top-style: none; border-bottom-style: none; border-right-style: none;} +img_whs68 {border-style: none; border: none; width: 221px; height: 200px;} +p.whs69 {font-size: 12pt; margin-left: 0px;} +p.whs70 {font-size: 12pt; margin-left: 40px; font-weight: bold; text-indent: -40px;} +img_whs71 {border-style: none; border: none; width: 16px; height: 16px;} +table.whs72 {x-cell-content-align: top; border-spacing: 0; width: 81.667%;} +col.whs73 {width: 4.762%;} +p.whs74 {font-weight: bold; font-size: 14pt;} +img_whs75 {border: none; width: 272px; height: 250px;} +img_whs76 {border: none; width: 242px; height: 250px;} +p.whs77 {margin-left: 40px; font-weight: bold; text-indent: -40px; font-size: 14pt;} +p.whs78 {font-weight: bold; text-indent: -40px; font-size: 14pt; margin-left: 40px;} +img_whs79 {border: none; width: 257px; height: 250px;} +p.whs80 {font-weight: bold; text-indent: -40px; font-size: 14pt; margin-left: 80px;} +p.whs81 {font-weight: bold; margin-left: 80px; text-indent: -80px; font-size: 12pt;} +p.whs82 {font-weight: bold; text-indent: -80px; font-size: 12pt; margin-left: 120px;} +img_whs83 {border-style: none; border: none; width: 200px; height: 219px;} -->

    Displaying\hiding objects

    -

    Displaying\hiding different geometrical objects in the viewer - is possible using the following operations:

    +

    Visualization is available in both, OCC and VTK viewers. + These viewers work independently, i.e. visibility of objects and their + graphic attributes may differ in OCC and VTK viewer. It + is reasonable to use the OCC viewer for GEOM module.

    + +

     

    + +

    Displaying\hiding + different geometrical objects in the viewer is possible using the following + operations:

     

    @@ -125,13 +133,16 @@ else href="#DisplayAll">DisplayAll

  • DisplayOnly

  • + href="#EraseAll">EraseAll

  • EraseAll

  • + href="#Display">Display

  • EraseOnly

  • + href="#DisplayOnly">DisplayOnly

    + +
  • Erase

  •  

    @@ -141,9 +152,8 @@ else

     

    In the main menu select View - > Display mode or right-click on the necessary object in the - Object Browser and from the associated pop-up menu choose the required - operation.

    + or right-click on the necessary object in the Object Browser and + from the associated pop-up menu choose the required operation.

     

    @@ -169,39 +179,56 @@ else

     

    +

    EraseAll

    + +

     

    + +

    Description: + Erases all shapes displayed in the viewer.

    +

     

    -

    TUI + Command: sg.EraseAll()

    + +

     

    + +

     

    + +

    DisplayOnly

    + size=4> Display

     

    -

    Description: - Displays only the selected geometrical element.

    +

    Description: + Displays an object in 3D viewer.

     

    TUI - Command: sg.DisplayOnly(ID)

    + Command:

     

     

    -

    EraseAll

    +

    DisplayOnly

     

    Description: - Erases all shapes displayed in the viewer.

    + Displays only the selected geometrical element.

     

    TUI - Command: sg.EraseAll()

    + Command: sg.DisplayOnly(ID)

     

    @@ -209,7 +236,7 @@ else

    EraseOnly

    + size=4> Erase

     

    diff --git a/doc/salome/gui/GEOM/files/salome2_sp3_generationgui_functions.htm b/doc/salome/gui/GEOM/files/salome2_sp3_generationgui_functions.htm index 370347a64..260fc51a7 100755 --- a/doc/salome/gui/GEOM/files/salome2_sp3_generationgui_functions.htm +++ b/doc/salome/gui/GEOM/files/salome2_sp3_generationgui_functions.htm @@ -29,8 +29,8 @@ - - + + @@ -143,13 +143,14 @@ else

     

    @@ -163,20 +164,22 @@ else

     

    -

    Prism

    +

    Extrusion

    Description: Creates an extruded shape.

     

    -

    Result: GEOM_Shape +

    Result: GEOM_Object (edge, face, solid or compsolid).

     

    TUI Command : - geompy.MakePrism(GEOM_Shape, PointStruct, PointStruct)

    + geompy.MakePrism(baseShape, Vector, + Height), where baseShape is a basis of the prism, Vector is a normal + of the prism and Height is a height of the prism.

     

    @@ -213,13 +216,16 @@ else

     

    -

    Result: GEOM_Shape +

    Result: GEOM_Object (edge, face, solid or compsolid).

     

    TUI Command: - geompy.MakeRevolution(GEOM_Shape, AxisStruct, Double)

    + geompy.MakeRevolution(Shape, Axis, + Angle), where Shape is a shape to rotate, Axis is the axis of the + revolution and Angle is an angle by which Shape has to be rotated around + Axis.

     

    @@ -254,13 +260,17 @@ else

     

    -

    Result: GEOM_Shape +

    Result: GEOM_Object (face).

     

    TUI Command: - geompy.MakeFilling(GEOM_Shape, Short, Short, Double, Double, Short)

    + geompy.MakeFilling(Shape, MinDegree, + MaxDegree, Tol2D, Tol3D, NbIter), where Shape is a shape to fill, + MinDegree and MaxDegree are correspondingly maximal and minimal degree, + Tol2D is a tolerance for 2D and Tol3D is a tolerance for 3D, NbIter is + a number of iterations.

     

    @@ -300,13 +310,15 @@ else

     

    -

    Result: GEOM_Shape +

    Result: GEOM_Object (edge, face, solid or compsolid).

     

    TUI Command: - geompy.MakePipe(GEOM_Shape, GEOM_Shape)

    + geompy.MakePipe(baseShape, pathShape), + where baseShape is a shape to be extruded, pathShape is a path along which + baseShape is extruded.

     

    diff --git a/doc/salome/gui/GEOM/files/salome2_sp3_geomtoolsgui_functions.htm b/doc/salome/gui/GEOM/files/salome2_sp3_geomtoolsgui_functions.htm index 8c2a80c2f..c70dca7fa 100755 --- a/doc/salome/gui/GEOM/files/salome2_sp3_geomtoolsgui_functions.htm +++ b/doc/salome/gui/GEOM/files/salome2_sp3_geomtoolsgui_functions.htm @@ -30,8 +30,8 @@ - - + + @@ -137,10 +137,16 @@ else

     

    Select the required file and click OK. You file will be imported - into GEOM and its contents (geometrical objects) will be displayed in - the Object Browser. -

    + style="font-weight: bold;">OK. You file will be imported into GEOM + and its contents (geometrical objects) will be displayed in the Object Browser.

    + +

     

    + +

    TUI command: + geompy.Import(FileName, FormatName), + where FileName is a name of file which contains a shape, FormatName is + a string which describes a format of the file.

     

    @@ -160,8 +166,16 @@ else

     

    -

    Click OK - to confirm your exportation.  

    +

    Click OK + to confirm your exportation.  

    + +

     

    + +

    TUI command: + geompy.Export(Shape, FileName, FormatName), + where Shape is a shape to be exported, FileName is a name of a file to + which the shape is exported, FormatName is a string which describes the + file format.

     

    diff --git a/doc/salome/gui/GEOM/files/salome2_sp3_measuregui_functions.htm b/doc/salome/gui/GEOM/files/salome2_sp3_measuregui_functions.htm index 58e90c34a..c85165ba1 100755 --- a/doc/salome/gui/GEOM/files/salome2_sp3_measuregui_functions.htm +++ b/doc/salome/gui/GEOM/files/salome2_sp3_measuregui_functions.htm @@ -29,8 +29,8 @@ - - + + @@ -64,17 +64,22 @@ A:link { p.whs1 {font-size: 12pt;} img_whs2 {border-style: none; border: none; float: none; width: 30px; height: 30px;} p.whs3 {margin-left: 40px;} -p.whs4 {font-family: 'Times New Roman', serif; font-size: 14pt;} -img_whs5 {border-style: none; width: 20px; height: 20px;} -p.whs6 {font-family: 'Times New Roman', serif; font-size: 12pt;} -img_whs7 {border-style: none; border: none; width: 200px; height: 161px;} -p.whs8 {font-size: 12pt; margin-left: 40px;} -img_whs9 {border-style: none; border: none; width: 200px; height: 190px;} -img_whs10 {border-style: none; border: none; width: 200px; height: 175px;} -img_whs11 {border-style: none; border: none; width: 200px; height: 171px;} -img_whs12 {border-style: none; border: none; width: 200px; height: 151px;} -img_whs13 {border-style: none; border: none; width: 200px; height: 193px;} -img_whs14 {border-style: none; border: none; width: 200px; height: 219px;} +img_whs4 {border-style: none; border: none; width: 21px; height: 19px;} +p.whs5 {font-size: 12pt; margin-left: 40px;} +img_whs6 {border-style: none; border: none; width: 200px; height: 221px;} +p.whs7 {font-family: 'Times New Roman', serif; font-size: 14pt;} +img_whs8 {border-style: none; width: 20px; height: 20px;} +p.whs9 {font-family: 'Times New Roman', serif; font-size: 12pt;} +img_whs10 {border-style: none; border: none; width: 200px; height: 161px;} +img_whs11 {border-style: none; border: none; width: 200px; height: 190px;} +p.whs12 {font-size: 12pt; margin-left: 400px;} +img_whs13 {border-style: none; border: none; width: 200px; height: 175px;} +p.whs14 {font-size: 12pt; font-weight: bold;} +img_whs15 {border-style: none; border: none; width: 200px; height: 171px;} +p.whs16 {font-size: 12pt; font-weight: normal;} +img_whs17 {border-style: none; border: none; width: 200px; height: 151px;} +img_whs18 {border-style: none; border: none; width: 200px; height: 193px;} +img_whs19 {border-style: none; border: none; width: 200px; height: 219px;} --> + + + + + +

    1 + +

    SplitAngle – + this operator is intended for splitting faces based on conical surfaces, + surfaces of revolution and cylindrical surfaces by angle

    +

    SplitAngle.Angle – angle (in radians) defining + size of result segments.

    +

    SplitAngle.MaxTolerance – maximal possible + tolerance on result shape + + + +

    2 + +

    SplitClosedFaces + – this operator is intended for dividing all closed faces in the shape + according to the number of points.

    +

    SplitClosedFaces.NbSplitPoints – number of + points for cutting each closed faces. + + + +

    3 + +

    FixFaceSize + – this operator is intended for removing small faces (case of the spot + face and strip face)

    +

    FixFaceSize.Tolerance – work tolerance defining + which faces will be removed. + + + +

    4 + +

    DropSmallEdges + – this operator is intended for removing small edges or merging with neigbour. +  

    +

    DropSmallEdges.Tolerance3d – work tolerance + for detection and removing small edges. + + + +

    5 + +

    BsplineRestriction + –this operator is intended for re-approximation BSplines curves and surfaces + or conversion of the curves and surfaces to BSplines with specified parameters. +

    +

    BSplineRestriction.SurfaceMode - mode of approximation + of surfaces if restriction is necessary

    +

    BSplineRestriction.Curve3dMode -mode of conversion + of any 3D curve to BSpline and approximation.

    +

    BSplineRestriction.Curve2dMode - mode of conversion + of any 2D curve to BSpline and approximation

    +

    BSplineRestriction.Tolerance3d – work tolerance + for definition of the possibility of the approximation of the surfaces + and 3D curves with specified parameters.

    +

    BSplineRestriction.Tolerance2d - work tolerance + for definition of the possibility of the approximation of the 2D curves + with specified parameters.

    +

    BSplineRestriction.Continuity3d – desired continuity + of the resultant surfaces and 3D curves.

    +

    BSplineRestriction.Continuity2d – desired continuity + of the resultant 2D curves.

    +

    BSplineRestriction.RequiredDegree - required + degree of the resultant BSplines

    +

    BSplineRestriction.RequiredNbSegments - required + maximum number of segments of resultant BSplines. + + + +

    6 + +

    SplitContinuity + – this operator is intended for splitting shapes to achieve continuities + of curves and surfaces less than specified ones.

    +

    SplitContinuity.Tolerance3d - 3D tolerance + for correction of geometry.

    +

    SplitContinuity.SurfaceContinuity - required + continuity for surfaces.

    +

    SplitContinuity.CurveContinuity - required + continuity for curves. + + + +

    7 + +

    ToBezier - this + operator is intended for conversion of the curves and surfaces of the + all types into Bezier curves and surfaces.

    +

    ToBezier.SurfaceMode - mode of conversion of + the surfaces.

    +

    ToBezier.Curve3dMode – mode for conversion + of the 3D curves.

    +

    ToBezier.Curve2dMode – mode for conversion + of the 2D curves.

    +

    ToBezier.MaxTolerance – max possible tolerance + on the resultant shape. + + + +

    8 + +

    FixShape – this + operator is intended for correction of the invalid shapes

    +

    FixShape.Tolerance3d – work tolerance for detection + of the problems and correction of them.

    +

    FixShape.MaxTolerance3d - maximal possible + tolerance of the shape after correction. + + + +

    9 + +

    SameParameter + – this operator is intended for fixing edges having not same parameter + 2D and 3D curves.

    +

    SameParameter.Tolerance3d – tolerance for detection + and fix problems. + + + +

     

     

    @@ -201,43 +420,57 @@ else

     

    -

    +

     

     

    Example:

    -

     

    +

     

    -

     

    +

    Shape before applying Shape Processing (FixShape + operator).

     

    -

     

    +

       

    -

    Orientation -

    +

     

    + +

    The + same shape after applying Shape Processing.

    + +

     

    + +

    + +

     

    -

     

    +

     

    + +

    Suppress faces

    + +

     

    Description: - Changes the orientation of the faces of a shape.

    + Suppresses a face of a shape.

     

    -

    Result: GEOM_Shape.

    +

    Result: GEOM_Object + (ListOfGeomShapes).

     

    TUI Command: - geompy.OrientationChange(GEOM_Shape)

    + geompy.SuppressFaces(Shape, ListOfID), + where Shape is a shape to be processed, ListOfID is a list of faces ID's + to be removed.

     

    Arguments: - 1 shape (face, shell, solid or compsolid) + 1 value (vector length).

    + 1 shape + 1 selection of a face (Local Context).

     

    @@ -245,35 +478,56 @@ else

     

    -

    +

    + +

     

    + +

    Example:

     

    +

     

    +

     

    -

    Suppress - faces

    +

    Close contour

    -

     

    +

     

    -

    Description: - Suppresses a face of a shape.

    +

    Description : + Closes an open contour and modifies the underlying face (if needed) in + accordance with user specified mode:

    + +
      + +
    • By common vertex – a + vertex is created between the end points of the contour and its tolerance + is increased to a value of the gap between the ends of the contour;

    • + +
    • By new edge – a new edge + is inserted between the end points of the contour.

    • +

     

    -

    Result: GEOM_Shape - (ListOfGeomShapes).

    +

    Result: GEOM_Object.

     

    TUI Command: - geompy.SuppressFaces(GEOM_Shape, ListOfID)

    + geompy.CloseContour(Shape, Wires, + IsCommonVertex), where Shape is a shape to be processed, Wires + is a list of edges or wires IDÂ’s which has to be closed within the shape + (if the list contains only one element = -1, the shape itself is considered + as a wire),  IsCommonVertex + if this parameter is True a closure has to be done by creation of a common + vertex, otherwise an edge is added between the end vertices.

     

    -

    Arguments: - 1 shape + 1 selection of a face (Local Context).

    +

    Arguments: Contour (Wire, + or a set of Edges) + mode of closure (by vertex or by edge)

     

    @@ -281,21 +535,75 @@ else

     

    -

    +

    -

     

    +

     

    -

    Example:

    +

    Example:

    + +

     

    + +

    Suppress + internal wires

    + +

     

    + +

    Description : + Removes all internal wires or specified internal wires from user specified + faces.

    + +

     

    + +

    Result: GEOM_Object.

    + +

     

    + +

    TUI Command: + geompy.SuppressInternalWires(Shape, + Wires), where Shape is a shape where wires are to be removed, Wires + is a list of wires IDÂ’s to be removed; if the list is empty then all internal + wires are removed.

    + +

     

    + +

     

    + +

    Arguments:

    + +
      + +
    • User specified face

    • + +
    • User specified internal + wires (lying on this face except for its boundary), or, in case the "Remove + all internal wires" box is checked, all internal wires

    • +
    + +

     

    + +

    Dialog Box:

    + +

     

    + +

     

    -

     

    +

    Example:

    + +

     

    + +

       

    + +

     

     

    -

    Suppress - hole

    +

    Suppress + holes

     

    @@ -313,18 +621,15 @@ else

     

    -

    Result: GEOM_Shape.

    +

    Result: GEOM_Object.

     

    TUI Command: -

    - -

    geompy.SuppressHole(GEOM_Shape, - ListOfSubShapeID, ListOfSubShapeID, ListOfSubShapeID)

    - -

    geompy.SuppressHolesInFaceOrShell(GEOM_Shape, - ListOfSubShapeID)

    + geompy.SuppressHoles(Shape, + ListOfWireID), where Shape is a + shape where holes must be removed, ListOfWireID is a list of wire sub + shapes IDÂ’s. If it is empty, then all holes are removed.

     

    @@ -348,17 +653,217 @@ else

     

    -

     

    +

     

    -

      

    +

      

    Example:

    -

     

    +

     

    + +

       

    + +

     

    + +

     

    + +

     

    + +

    Sewing

    + +

     

    + +

    Description: + Sew several  shapes.

    + +

     

    + +

    Result: GEOM_Object.

    + +

     

    + +

    TUI Command : + geompy.MakeSewing(ListOfShape, Precision), + where ListOfShape is list of shapes to be sewed, Precision is a precision + for sewing.

    + +

     

    + +

    Arguments: + 1 or more shapes + 1 value (sew precision).

    + +

     

    + +

    Dialog Box:

    + +

     

    + +

    + +

     

    + +

    Example:

    + +

     

    + +

     

    + +

     

    + +

     

    + +

     

    + +

    Add point on edge

    + +

     

    + +

    Description: + Splits an edge in two in accordance with the specified mode (by length + or by parameter) and a value specifying the position of the point on edge + (for example val =0.5; mode = Length).

    + +

     

    + +

    Result: GEOM_Object.

    + +

     

    + +

    TUI Command : + geompy.DivideEdge(Shape, EdgeID, + Value, IsByParameter), where Shape is a shape which contains an + edge to be divided, EdgeID is the ID of the edge to be divided, if it + = -1, then Shape is an edge, Value is a paramter on the edge or a length. + IsByParameter if it is True then Value is the edge parameter in the range + [0:1] otherwise it is a length of the edge in the range [0:1]

    + +

     

    + +

    Arguments: + Edge, user-defined point

    + +

     

    + +

    Dialog + Box:

    + +

     

    + +

    + +

     

    + +

    Example:

    + +

     

    + +

         

    + +

     

    + +

     

    + +

     

    + +

    Glue faces

    + +

     

    + +

    Description: + Glues faces that are coincident with respect to the given tolerance

    + +

    value.

    + +

     

    + +

    Result: + GEOM_Object.

    + +

     

    + +

    TUI Command + : geompy.MakeGlueFaces(theShape, + theTolerance), where theShape is a compound of shapesto be glued, + theTolerance is a maximum distance between two faces, which can be considered + as coincident.

    + +

     

    + +

    Arguments: + 1 Compound + Tolerance Value

    + +

     

    + +

    Dialog Box:

    + +

     

    + +

    + +

     

    + +

    Example:

    + +

     

    + +

      

    + +

     

    + +

     

    + +

     

    + +

    Check free boundaries

    + +

     

    + +

    Description: + Detects wires and edges that correspond to the shape's boundary, and highlights + it

    + +

     

    + +

    Result: GEOM_Object.

    + +

     

    + +

    TUI Command : (NoError, ClosedWires, OpenWires) = geompy.GetFreeBoundary(Shape), + where Shape is a shape to be checked, NoError is false if an error occurred + while checking free boundaries, ClosedWires is a list of closed free boundary + wires, OpenWires is a list of open free boundary wires.

    + +

     

    + +

    Arguments: + Shape

    + +

     

    + +

    Dialog + Box:

    + +

     

    + +

    + +

     

    + +

    Example:

    + +

     

    + +

      

    -

       

    +

     

    -

     

    +

     

    + GEOM reference manual + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/doc/salome/gui/GEOM/geom_help_csh.html b/doc/salome/gui/GEOM/geom_help_csh.html new file mode 100755 index 000000000..e5123bbd5 --- /dev/null +++ b/doc/salome/gui/GEOM/geom_help_csh.html @@ -0,0 +1,100 @@ + + +GEOM reference manual + + + + + + + + + + + + + \ No newline at end of file diff --git a/doc/salome/gui/GEOM/geom_help_rhc.html b/doc/salome/gui/GEOM/geom_help_rhc.html new file mode 100755 index 000000000..26441d7b5 --- /dev/null +++ b/doc/salome/gui/GEOM/geom_help_rhc.html @@ -0,0 +1,100 @@ + + +GEOM reference manual + + + + + + + + + + + + + \ No newline at end of file diff --git a/doc/salome/gui/GEOM/image144.jpg b/doc/salome/gui/GEOM/image144.jpg new file mode 100755 index 000000000..cecf915ed Binary files /dev/null and b/doc/salome/gui/GEOM/image144.jpg differ diff --git a/doc/salome/gui/GEOM/image145.jpg b/doc/salome/gui/GEOM/image145.jpg new file mode 100755 index 000000000..a035c8d89 Binary files /dev/null and b/doc/salome/gui/GEOM/image145.jpg differ diff --git a/doc/salome/gui/GEOM/image146.jpg b/doc/salome/gui/GEOM/image146.jpg new file mode 100755 index 000000000..f0e021d97 Binary files /dev/null and b/doc/salome/gui/GEOM/image146.jpg differ diff --git a/doc/salome/gui/GEOM/image147.jpg b/doc/salome/gui/GEOM/image147.jpg new file mode 100755 index 000000000..e38c1dad2 Binary files /dev/null and b/doc/salome/gui/GEOM/image147.jpg differ diff --git a/doc/salome/gui/GEOM/image149.jpg b/doc/salome/gui/GEOM/image149.jpg new file mode 100755 index 000000000..2332885cd Binary files /dev/null and b/doc/salome/gui/GEOM/image149.jpg differ diff --git a/doc/salome/gui/GEOM/image150.jpg b/doc/salome/gui/GEOM/image150.jpg new file mode 100755 index 000000000..31fceea62 Binary files /dev/null and b/doc/salome/gui/GEOM/image150.jpg differ diff --git a/doc/salome/gui/GEOM/image151.jpg b/doc/salome/gui/GEOM/image151.jpg new file mode 100755 index 000000000..eda0dfcbd Binary files /dev/null and b/doc/salome/gui/GEOM/image151.jpg differ diff --git a/doc/salome/gui/GEOM/image152.jpg b/doc/salome/gui/GEOM/image152.jpg new file mode 100755 index 000000000..27ae4585c Binary files /dev/null and b/doc/salome/gui/GEOM/image152.jpg differ diff --git a/doc/salome/gui/GEOM/image154.jpg b/doc/salome/gui/GEOM/image154.jpg new file mode 100755 index 000000000..5129007a9 Binary files /dev/null and b/doc/salome/gui/GEOM/image154.jpg differ diff --git a/doc/salome/gui/GEOM/image156.jpg b/doc/salome/gui/GEOM/image156.jpg new file mode 100755 index 000000000..f2d718579 Binary files /dev/null and b/doc/salome/gui/GEOM/image156.jpg differ diff --git a/doc/salome/gui/GEOM/image158.jpg b/doc/salome/gui/GEOM/image158.jpg new file mode 100755 index 000000000..ccc843738 Binary files /dev/null and b/doc/salome/gui/GEOM/image158.jpg differ diff --git a/doc/salome/gui/GEOM/image160.jpg b/doc/salome/gui/GEOM/image160.jpg new file mode 100755 index 000000000..a88429f79 Binary files /dev/null and b/doc/salome/gui/GEOM/image160.jpg differ diff --git a/doc/salome/gui/GEOM/image161.jpg b/doc/salome/gui/GEOM/image161.jpg new file mode 100755 index 000000000..05970b97e Binary files /dev/null and b/doc/salome/gui/GEOM/image161.jpg differ diff --git a/doc/salome/gui/GEOM/image163.jpg b/doc/salome/gui/GEOM/image163.jpg new file mode 100755 index 000000000..8f87e356b Binary files /dev/null and b/doc/salome/gui/GEOM/image163.jpg differ diff --git a/doc/salome/gui/GEOM/image164.jpg b/doc/salome/gui/GEOM/image164.jpg new file mode 100755 index 000000000..a180e04d1 Binary files /dev/null and b/doc/salome/gui/GEOM/image164.jpg differ diff --git a/doc/salome/gui/GEOM/image165.jpg b/doc/salome/gui/GEOM/image165.jpg new file mode 100755 index 000000000..330b038b8 Binary files /dev/null and b/doc/salome/gui/GEOM/image165.jpg differ diff --git a/doc/salome/gui/GEOM/image166.jpg b/doc/salome/gui/GEOM/image166.jpg new file mode 100755 index 000000000..6dd85b9db Binary files /dev/null and b/doc/salome/gui/GEOM/image166.jpg differ diff --git a/doc/salome/gui/GEOM/image167.jpg b/doc/salome/gui/GEOM/image167.jpg new file mode 100755 index 000000000..775496ffc Binary files /dev/null and b/doc/salome/gui/GEOM/image167.jpg differ diff --git a/doc/salome/gui/GEOM/image168.jpg b/doc/salome/gui/GEOM/image168.jpg new file mode 100755 index 000000000..f69d2b8df Binary files /dev/null and b/doc/salome/gui/GEOM/image168.jpg differ diff --git a/doc/salome/gui/GEOM/image169.jpg b/doc/salome/gui/GEOM/image169.jpg new file mode 100755 index 000000000..573378f6f Binary files /dev/null and b/doc/salome/gui/GEOM/image169.jpg differ diff --git a/doc/salome/gui/GEOM/image170.jpg b/doc/salome/gui/GEOM/image170.jpg new file mode 100755 index 000000000..4e24375fa Binary files /dev/null and b/doc/salome/gui/GEOM/image170.jpg differ diff --git a/doc/salome/gui/GEOM/image171.jpg b/doc/salome/gui/GEOM/image171.jpg new file mode 100755 index 000000000..9e055888a Binary files /dev/null and b/doc/salome/gui/GEOM/image171.jpg differ diff --git a/doc/salome/gui/GEOM/image172.jpg b/doc/salome/gui/GEOM/image172.jpg new file mode 100755 index 000000000..2bee4472e Binary files /dev/null and b/doc/salome/gui/GEOM/image172.jpg differ diff --git a/doc/salome/gui/GEOM/image173.jpg b/doc/salome/gui/GEOM/image173.jpg new file mode 100755 index 000000000..c8f9126b5 Binary files /dev/null and b/doc/salome/gui/GEOM/image173.jpg differ diff --git a/doc/salome/gui/GEOM/image175.jpg b/doc/salome/gui/GEOM/image175.jpg new file mode 100755 index 000000000..30f72cb4c Binary files /dev/null and b/doc/salome/gui/GEOM/image175.jpg differ diff --git a/doc/salome/gui/GEOM/image176.jpg b/doc/salome/gui/GEOM/image176.jpg new file mode 100755 index 000000000..4652aa964 Binary files /dev/null and b/doc/salome/gui/GEOM/image176.jpg differ diff --git a/doc/salome/gui/GEOM/image179.jpg b/doc/salome/gui/GEOM/image179.jpg new file mode 100755 index 000000000..b7b076637 Binary files /dev/null and b/doc/salome/gui/GEOM/image179.jpg differ diff --git a/doc/salome/gui/GEOM/image180.jpg b/doc/salome/gui/GEOM/image180.jpg new file mode 100755 index 000000000..1c57ef013 Binary files /dev/null and b/doc/salome/gui/GEOM/image180.jpg differ diff --git a/doc/salome/gui/GEOM/image181.jpg b/doc/salome/gui/GEOM/image181.jpg new file mode 100755 index 000000000..d0171dfc9 Binary files /dev/null and b/doc/salome/gui/GEOM/image181.jpg differ diff --git a/doc/salome/gui/GEOM/image182.jpg b/doc/salome/gui/GEOM/image182.jpg new file mode 100755 index 000000000..3dcf6407e Binary files /dev/null and b/doc/salome/gui/GEOM/image182.jpg differ diff --git a/doc/salome/gui/GEOM/image183.jpg b/doc/salome/gui/GEOM/image183.jpg new file mode 100755 index 000000000..4b5903a2d Binary files /dev/null and b/doc/salome/gui/GEOM/image183.jpg differ diff --git a/doc/salome/gui/GEOM/image184.jpg b/doc/salome/gui/GEOM/image184.jpg new file mode 100755 index 000000000..5bf046de2 Binary files /dev/null and b/doc/salome/gui/GEOM/image184.jpg differ diff --git a/doc/salome/gui/GEOM/image185.jpg b/doc/salome/gui/GEOM/image185.jpg new file mode 100755 index 000000000..7fb6ef62a Binary files /dev/null and b/doc/salome/gui/GEOM/image185.jpg differ diff --git a/doc/salome/gui/GEOM/image186.jpg b/doc/salome/gui/GEOM/image186.jpg new file mode 100755 index 000000000..1de5f1d37 Binary files /dev/null and b/doc/salome/gui/GEOM/image186.jpg differ diff --git a/doc/salome/gui/GEOM/image187.jpg b/doc/salome/gui/GEOM/image187.jpg new file mode 100755 index 000000000..66531ab9d Binary files /dev/null and b/doc/salome/gui/GEOM/image187.jpg differ diff --git a/doc/salome/gui/GEOM/image188.jpg b/doc/salome/gui/GEOM/image188.jpg new file mode 100755 index 000000000..00f58a045 Binary files /dev/null and b/doc/salome/gui/GEOM/image188.jpg differ diff --git a/doc/salome/gui/GEOM/image189.jpg b/doc/salome/gui/GEOM/image189.jpg new file mode 100755 index 000000000..d02a23911 Binary files /dev/null and b/doc/salome/gui/GEOM/image189.jpg differ diff --git a/doc/salome/gui/GEOM/image190.jpg b/doc/salome/gui/GEOM/image190.jpg new file mode 100755 index 000000000..f02cdb609 Binary files /dev/null and b/doc/salome/gui/GEOM/image190.jpg differ diff --git a/doc/salome/gui/GEOM/image191.jpg b/doc/salome/gui/GEOM/image191.jpg new file mode 100755 index 000000000..92144cc51 Binary files /dev/null and b/doc/salome/gui/GEOM/image191.jpg differ diff --git a/doc/salome/gui/GEOM/image192.jpg b/doc/salome/gui/GEOM/image192.jpg new file mode 100755 index 000000000..57493b9c3 Binary files /dev/null and b/doc/salome/gui/GEOM/image192.jpg differ diff --git a/doc/salome/gui/GEOM/image193.jpg b/doc/salome/gui/GEOM/image193.jpg new file mode 100755 index 000000000..dc184f5fb Binary files /dev/null and b/doc/salome/gui/GEOM/image193.jpg differ diff --git a/doc/salome/gui/GEOM/image194.jpg b/doc/salome/gui/GEOM/image194.jpg new file mode 100755 index 000000000..3d374bf0e Binary files /dev/null and b/doc/salome/gui/GEOM/image194.jpg differ diff --git a/doc/salome/gui/GEOM/image196.jpg b/doc/salome/gui/GEOM/image196.jpg new file mode 100755 index 000000000..1f6dba3e6 Binary files /dev/null and b/doc/salome/gui/GEOM/image196.jpg differ diff --git a/doc/salome/gui/GEOM/image197.jpg b/doc/salome/gui/GEOM/image197.jpg new file mode 100755 index 000000000..11eb06e4a Binary files /dev/null and b/doc/salome/gui/GEOM/image197.jpg differ diff --git a/doc/salome/gui/GEOM/image199.jpg b/doc/salome/gui/GEOM/image199.jpg new file mode 100755 index 000000000..277d5ed59 Binary files /dev/null and b/doc/salome/gui/GEOM/image199.jpg differ diff --git a/doc/salome/gui/GEOM/image200.jpg b/doc/salome/gui/GEOM/image200.jpg new file mode 100755 index 000000000..c59017188 Binary files /dev/null and b/doc/salome/gui/GEOM/image200.jpg differ diff --git a/doc/salome/gui/GEOM/image201.jpg b/doc/salome/gui/GEOM/image201.jpg new file mode 100755 index 000000000..0a6a1b4d7 Binary files /dev/null and b/doc/salome/gui/GEOM/image201.jpg differ diff --git a/doc/salome/gui/GEOM/image202.jpg b/doc/salome/gui/GEOM/image202.jpg new file mode 100755 index 000000000..067426223 Binary files /dev/null and b/doc/salome/gui/GEOM/image202.jpg differ diff --git a/doc/salome/gui/GEOM/image203.jpg b/doc/salome/gui/GEOM/image203.jpg new file mode 100755 index 000000000..8ecfef537 Binary files /dev/null and b/doc/salome/gui/GEOM/image203.jpg differ diff --git a/doc/salome/gui/GEOM/image204.jpg b/doc/salome/gui/GEOM/image204.jpg new file mode 100755 index 000000000..ce23e6aa0 Binary files /dev/null and b/doc/salome/gui/GEOM/image204.jpg differ diff --git a/doc/salome/gui/GEOM/image205.jpg b/doc/salome/gui/GEOM/image205.jpg new file mode 100755 index 000000000..2e2243034 Binary files /dev/null and b/doc/salome/gui/GEOM/image205.jpg differ diff --git a/doc/salome/gui/GEOM/image206.jpg b/doc/salome/gui/GEOM/image206.jpg new file mode 100755 index 000000000..85e9e803d Binary files /dev/null and b/doc/salome/gui/GEOM/image206.jpg differ diff --git a/doc/salome/gui/GEOM/image207.jpg b/doc/salome/gui/GEOM/image207.jpg new file mode 100755 index 000000000..8d9322977 Binary files /dev/null and b/doc/salome/gui/GEOM/image207.jpg differ diff --git a/doc/salome/gui/GEOM/image208.jpg b/doc/salome/gui/GEOM/image208.jpg new file mode 100755 index 000000000..5b912726d Binary files /dev/null and b/doc/salome/gui/GEOM/image208.jpg differ diff --git a/doc/salome/gui/GEOM/image209.jpg b/doc/salome/gui/GEOM/image209.jpg new file mode 100755 index 000000000..3d2de5f09 Binary files /dev/null and b/doc/salome/gui/GEOM/image209.jpg differ diff --git a/doc/salome/gui/GEOM/image210.jpg b/doc/salome/gui/GEOM/image210.jpg new file mode 100755 index 000000000..c651db3c4 Binary files /dev/null and b/doc/salome/gui/GEOM/image210.jpg differ diff --git a/doc/salome/gui/GEOM/image211.jpg b/doc/salome/gui/GEOM/image211.jpg new file mode 100755 index 000000000..8217b6b69 Binary files /dev/null and b/doc/salome/gui/GEOM/image211.jpg differ diff --git a/doc/salome/gui/GEOM/image212.jpg b/doc/salome/gui/GEOM/image212.jpg new file mode 100755 index 000000000..0bea713e3 Binary files /dev/null and b/doc/salome/gui/GEOM/image212.jpg differ diff --git a/doc/salome/gui/GEOM/image213.jpg b/doc/salome/gui/GEOM/image213.jpg new file mode 100755 index 000000000..23f9da97b Binary files /dev/null and b/doc/salome/gui/GEOM/image213.jpg differ diff --git a/doc/salome/gui/GEOM/image214.jpg b/doc/salome/gui/GEOM/image214.jpg new file mode 100755 index 000000000..ed92bdd66 Binary files /dev/null and b/doc/salome/gui/GEOM/image214.jpg differ diff --git a/doc/salome/gui/GEOM/image215.jpg b/doc/salome/gui/GEOM/image215.jpg new file mode 100755 index 000000000..0cdc46dbe Binary files /dev/null and b/doc/salome/gui/GEOM/image215.jpg differ diff --git a/doc/salome/gui/GEOM/image216.jpg b/doc/salome/gui/GEOM/image216.jpg new file mode 100755 index 000000000..8cf5671cf Binary files /dev/null and b/doc/salome/gui/GEOM/image216.jpg differ diff --git a/doc/salome/gui/GEOM/image217.jpg b/doc/salome/gui/GEOM/image217.jpg new file mode 100755 index 000000000..f9e5cd72c Binary files /dev/null and b/doc/salome/gui/GEOM/image217.jpg differ diff --git a/doc/salome/gui/GEOM/image218.jpg b/doc/salome/gui/GEOM/image218.jpg new file mode 100755 index 000000000..96b49d861 Binary files /dev/null and b/doc/salome/gui/GEOM/image218.jpg differ diff --git a/doc/salome/gui/GEOM/image219.jpg b/doc/salome/gui/GEOM/image219.jpg new file mode 100755 index 000000000..62a5832b9 Binary files /dev/null and b/doc/salome/gui/GEOM/image219.jpg differ diff --git a/doc/salome/gui/GEOM/image220.jpg b/doc/salome/gui/GEOM/image220.jpg new file mode 100755 index 000000000..616ddb732 Binary files /dev/null and b/doc/salome/gui/GEOM/image220.jpg differ diff --git a/doc/salome/gui/GEOM/image29.gif b/doc/salome/gui/GEOM/image29.gif new file mode 100755 index 000000000..bb00746d4 Binary files /dev/null and b/doc/salome/gui/GEOM/image29.gif differ diff --git a/doc/salome/gui/GEOM/image32.gif b/doc/salome/gui/GEOM/image32.gif new file mode 100755 index 000000000..bbdf48a24 Binary files /dev/null and b/doc/salome/gui/GEOM/image32.gif differ diff --git a/doc/salome/gui/GEOM/image35.gif b/doc/salome/gui/GEOM/image35.gif new file mode 100755 index 000000000..30f430ade Binary files /dev/null and b/doc/salome/gui/GEOM/image35.gif differ diff --git a/doc/salome/gui/GEOM/image37.gif b/doc/salome/gui/GEOM/image37.gif new file mode 100755 index 000000000..8c1a2c52a Binary files /dev/null and b/doc/salome/gui/GEOM/image37.gif differ diff --git a/doc/salome/gui/GEOM/image41.gif b/doc/salome/gui/GEOM/image41.gif new file mode 100755 index 000000000..6e3661f6c Binary files /dev/null and b/doc/salome/gui/GEOM/image41.gif differ diff --git a/doc/salome/gui/GEOM/image42.gif b/doc/salome/gui/GEOM/image42.gif new file mode 100755 index 000000000..1e4003cca Binary files /dev/null and b/doc/salome/gui/GEOM/image42.gif differ diff --git a/doc/salome/gui/GEOM/image44.gif b/doc/salome/gui/GEOM/image44.gif new file mode 100755 index 000000000..51662793b Binary files /dev/null and b/doc/salome/gui/GEOM/image44.gif differ diff --git a/doc/salome/gui/GEOM/image49.gif b/doc/salome/gui/GEOM/image49.gif new file mode 100755 index 000000000..a54a22e45 Binary files /dev/null and b/doc/salome/gui/GEOM/image49.gif differ diff --git a/doc/salome/gui/GEOM/image51.gif b/doc/salome/gui/GEOM/image51.gif new file mode 100755 index 000000000..d04ebd08f Binary files /dev/null and b/doc/salome/gui/GEOM/image51.gif differ diff --git a/doc/salome/gui/GEOM/image52.gif b/doc/salome/gui/GEOM/image52.gif new file mode 100755 index 000000000..94537e0f4 Binary files /dev/null and b/doc/salome/gui/GEOM/image52.gif differ diff --git a/doc/salome/gui/GEOM/image53.gif b/doc/salome/gui/GEOM/image53.gif new file mode 100755 index 000000000..c976b6dab Binary files /dev/null and b/doc/salome/gui/GEOM/image53.gif differ diff --git a/doc/salome/gui/GEOM/image56.gif b/doc/salome/gui/GEOM/image56.gif new file mode 100755 index 000000000..049e1ebdc Binary files /dev/null and b/doc/salome/gui/GEOM/image56.gif differ diff --git a/doc/salome/gui/GEOM/image57.gif b/doc/salome/gui/GEOM/image57.gif new file mode 100755 index 000000000..e0f9e3109 Binary files /dev/null and b/doc/salome/gui/GEOM/image57.gif differ diff --git a/doc/salome/gui/GEOM/image59.gif b/doc/salome/gui/GEOM/image59.gif new file mode 100755 index 000000000..f470df22c Binary files /dev/null and b/doc/salome/gui/GEOM/image59.gif differ diff --git a/doc/salome/gui/GEOM/image61.gif b/doc/salome/gui/GEOM/image61.gif new file mode 100755 index 000000000..0a7efcdf1 Binary files /dev/null and b/doc/salome/gui/GEOM/image61.gif differ diff --git a/doc/salome/gui/GEOM/newentity_blocks.htm b/doc/salome/gui/GEOM/newentity_blocks.htm new file mode 100755 index 000000000..8fb6b1511 --- /dev/null +++ b/doc/salome/gui/GEOM/newentity_blocks.htm @@ -0,0 +1,347 @@ + + + + + + + + + + +Blocks + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Building by blocks

    + +

    Introduction.

    + +

     

    + +

    Below are some general notions about blocks:

    + +

     

    + +

    A block is a an elementary geometric solid that + has specific geometric constraints oriented for meshing. In the hexahedral + case, blocks have 6 faces and each face has 4 edges.  

    + +

     

    + +

    Tetrahedral Block - is a block with constraints for tetrahedral meshing. +

    + +

     

    + +

    Hexahedral Block - is a block with constraints for hexahedral meshing.

    + +

     

    + +

    Block Compound - is a compound composed of blocks only.

    + +

     

    + +

    To build a compound the user may take the following steps:

    + +

     

    + + + +

     

    + +

     

    + +

    Quadrangle + face

    + +

     

    + +

    Description: + Builds a face using the below mentioned arguments. This operation allows + to build a face bypassing the intermediate stage of building edges and + wires (in the case of building by 4 points) or wires (in the case of building + by 4 or 2 edges).

    + +

     

    + +

    Result : + GEOM_Object.

    + +

     

    + +

    TUI Command:

    + +
      + +
    • geompy.MakeQuadFaceVertices(V1, + V2, V3, V4), where V1, V2, V3, V4 are + four vertices from which a face is constructed. Edges are created automatically.

    • + +
    • geompy.MakeQuadFaceEdges(E1, + E2), where E1, E2 are edges from which the face is constructed, + two other edges are created automatically.

    • + +
    • geompy.MakeQuadFace(E1, E2, E3, E4), + where E1, E2, E3, E4 are four edges from which the face is constructed.

    • +
    + +

     

    + +

    Arguments: +

    + +
      + +
    • 4 Points, or

    • + +
    • 2 Edges, or

    • + +
    • 4 Edges.

    • +
    + +

     

    + +

    Dialog Box:

    + + + ++++ + + + + +
    +

    +

    +

    + +

     

    + +

     

    + +

    Example:

    + +

     

    + +

    + +

     

    + +

     

    + +

    Hexahedral + solid

    + +

     

    + +

    Description: + Builds a hexahedral solid either of the below mentioned arguments. This + operation allows to build a solid bypassing the intermediate stage of + building a shell and 4 faces (in the case of building by 2 faces) or just + a shell (in the case of building by 6 faces).

    + +

     

    + +

    Result : + GEOM_Object.

    + +

     

    + +

    TUI Command:

    + +
      + +
    • geompy.MakeHexaSolid(F1, + F2, F3, F4, F5, F6), where F1 – F6 are six faces from which the + hexahedron is constructed.

    • + +
    • geompy.MakeHexaSolidTwoFaces(F1, + F2), where F1 and F2 are faces from which the hexahedron is constructed, + other four faces are created automatically.

    • +
    + +

     

    + +

    Arguments: +

    + +
      + +
    • 2 Faces, or

    • + +
    • 6 Faces.

    • +
    + +

     

    + +

    Dialog Box:

    + +

     

    + + + +++ + + + +
    +

          

    +

    + +

     

    + +

    Example:

    + +

     

    + +

         

    + +

         

    + +

     

    + + + + + diff --git a/doc/salome/gui/GEOM/sketcher.htm b/doc/salome/gui/GEOM/sketcher.htm new file mode 100755 index 000000000..98a550894 --- /dev/null +++ b/doc/salome/gui/GEOM/sketcher.htm @@ -0,0 +1,225 @@ + + + + + + + + + + +Sketcher + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Sketcher

    + +

    Sketcher allows to create curves of 2 types: line + segment and arc.  The + curve is created from the current point (center of coordinates when the + sketcher is started).  The + end of the curve is defined by means of "destination", which + can be a destination point (for segment only) or destination direction + coupled with length of a segment or angle and radius of an arc.

    + +

     

    + +

    Sketcher is able to create planar curves only. Therefore, it is necessary + to select a working plane before starting a sketch (by default, XOY plane + is used). Sketcher creates curves lying in the current working plane (New + Entity -> Basic -> Working Plane).

    + +

     

    + +

    Description: + Creates curves (line segment and arc).

    + +

     

    + +

    Result: GEOM_Object.

    + +

     

    + +

    TUI Command: + geompy.MakeSketcher(Command, LWP), + where Command is a string containing the coordinates of points in the + local working plane, LWP is a list of 9 doubles which are coordinates + of OZ and OX of the local working plane.

    + +

     

    + +

    Arguments: +

    + +

    1. Element type (segment or arc).

    + +

    2. Destination type (point or direction).

    + +

    3. Destination point by means of:

    + +
      + +
    • absolute coordinates + X,Y;

    • + +
    • relative coordinates + DX, DY (with respect to the current point);

    • + +
    • selection of an existing + point.

    • +
    + +

    4. Destination direction by means of:

    + +
      + +
    • angle between the new + segment and the previous one;

    • + +
    • perpendicular to the + previous segment (same as previous, but angle is predefined and is equal + to 90 degrees);

    • + +
    • tangent to the previous + segment;

    • + +
    • vector components VX, + DY.

    • +
    + +

    5. Parameters of an element (for segment : + length or target X or Y coordinate value, for arc : radius and angle).

    + +

     

    + +

    Dialog Box:

    + +

     

    + +

      

    + +

     

    + +

    Example:

    + +

     

    + +

      

    + + + + + diff --git a/doc/salome/gui/GEOM/whdata/whftdata0.htm b/doc/salome/gui/GEOM/whdata/whftdata0.htm index 5fd2fa6f7..62ffe6714 100755 --- a/doc/salome/gui/GEOM/whdata/whftdata0.htm +++ b/doc/salome/gui/GEOM/whdata/whftdata0.htm @@ -10,6 +10,7 @@ diff --git a/doc/salome/gui/GEOM/whdata/whftdata0.xml b/doc/salome/gui/GEOM/whdata/whftdata0.xml index 2258debf3..dd9bb8b6d 100755 --- a/doc/salome/gui/GEOM/whdata/whftdata0.xml +++ b/doc/salome/gui/GEOM/whdata/whftdata0.xml @@ -1,5 +1,6 @@ + @@ -13,5 +14,8 @@ + + + diff --git a/doc/salome/gui/GEOM/whdata/whfts.htm b/doc/salome/gui/GEOM/whdata/whfts.htm index 8a1b3dabc..3858e4cda 100755 --- a/doc/salome/gui/GEOM/whdata/whfts.htm +++ b/doc/salome/gui/GEOM/whdata/whfts.htm @@ -6,9 +6,9 @@ diff --git a/doc/salome/gui/GEOM/whdata/whfts.xml b/doc/salome/gui/GEOM/whdata/whfts.xml index 3e5140071..71138925c 100755 --- a/doc/salome/gui/GEOM/whdata/whfts.xml +++ b/doc/salome/gui/GEOM/whdata/whfts.xml @@ -1,7 +1,7 @@ - + - + diff --git a/doc/salome/gui/GEOM/whdata/whfwdata0.htm b/doc/salome/gui/GEOM/whdata/whfwdata0.htm index f917bf1cd..82fe9859b 100755 --- a/doc/salome/gui/GEOM/whdata/whfwdata0.htm +++ b/doc/salome/gui/GEOM/whdata/whfwdata0.htm @@ -10,320 +10,730 @@ diff --git a/doc/salome/gui/GEOM/whdata/whfwdata0.xml b/doc/salome/gui/GEOM/whdata/whfwdata0.xml index af8f667a2..63e637001 100755 --- a/doc/salome/gui/GEOM/whdata/whfwdata0.xml +++ b/doc/salome/gui/GEOM/whdata/whfwdata0.xml @@ -1,318 +1,728 @@ - 0, - 0,6,8,3,2,4,9,10,11,12, - 2, - 2,9,10,11,12, - 0,8,3,2,4,9,10,12, - 6,3,2,4, - 2,9,10,11,12, - 3,2,9,10,12, - 6,3,4,10, - 2,9, - 3,9, - 6, - 11, - 6,4, - 9, - 7,12, - 6,12, - 3, - 11, - 2, - 9, - 0,6,8,3,2,4,9,10,11,12, - 5, - 8, - 6,12, - 11, - 6,10,12, - 1,8,2,4,9, - 1,8,3,4, - 8, - 0,6,8,3,2,7,4,9,10,11,12, - 1,7, - 5,7, - 1,4,9, - 1, - 2, - 8,2, - 9, - 0,11, - 8, - 8, - 5,7, - 2, - 0,5,7, - 4, - 0, - 0,6,8,3,5,2,4,9,10,11,12, - 3, - 1,6,3,9, - 8, - 3,4,12, - 6,11, - 10, - 8, - 7, - 4, - 10, - 1,3, - 2,9,10,11,12, - 7, - 11, - 8,2,12, - 12, - 10, - 9, - 6,8,5,2,4,9,10,11,12, - 1,9, - 5, - 6, - 3, - 10, - 8, - 2, - 8, - 6, - 9, - 6, - 9, - 0,6,8,3,5,2,4,9,10,11,12, - 1, - 0,6,8,3,2,7,4,9,10,11,12, - 0,8,5,10, - 6,8,9,10, - 6,2,9,10,12, - 2,10,12, - 0,8,5,7, - 5, - 5, - 8, - 0,6,2,9,10,11,12, - 6,2,4,9,10,12, - 6,8,3,5,2,4,10, - 2, - 7, - 6,2,4,10, - 5, - 5, - 5, - 4, - 0,6,3,2,4,9,10,11,12, - 4, - 1,7, - 7, - 6, - 6,2,4,9,11,12, - 12, - 6,7, - 9, - 2, - 3,5,4, - 1,7, - 1,4, - 3, - 6, - 1,6, - 0,1,6,8,3,2,7,4,9,10,12, - 6,8,3,2,4,9,10,11,12, - 0,1,6,8,3,5,2,7,4,9,10,11,12, - 6,8,3,4,9,10,11,12, - 8,3, - 0, - 2,4, - 8, - 9, - 4, - 10, - 5, - 11, - 0,5, - 8,11, - 1,7, - 1,8,5,7, - 7, - 3, - 8, - 12, - 9, - 1, - 0, - 0, - 6, - 8,11, - 9, - 2,9, - 6,4, - 4,11, - 11, - 4,9,11, - 4,9,11, - 11, - 7, - 6,8,3,5,2,4,9,10,11, - 9,12, - 2, - 3, - 10, - 8, - 9, - 2, - 4, - 10, - 10, - 4, - 2, - 4, - 6, - 9, - 2, - 12, - 12, - 12, - 12, - 12, - 6, - 2, - 6, - 6, - 12, - 12, - 11, - 4, - 4, - 10, - 10, - 12, - 2, - 2, - 4, - 6, - 8, - 8, - 0,6,8,3,5,2,7,4,9,10,11, - 9, - 6,8, - 12, - 0,5, - 1,9, - 11, - 1, - 12, - 7, - 8,5, - 6,2,4,10, - 0,6, - 0,1,6,8,3,5,2,7,4,9,10,11,12, - 7, - 3,5,12, - 1,6,3,5,9,11,12, - 10, - 1, - 11, - 11, - 2,10, - 2, - 0,6, - 3,10, - 9, - 6, - 12, - 9, - 6, - 2,9, - 9, - 2, - 6,2,4,10,12, - 0,5, - 2, - 5, - 11, - 1,10, - 6, - 0,8, - 2,9,10, - 1, - 9, - 1,11, - 12, - 5,7, - 6,8,3,2,4,9,10,11,12, - 8,4, - 6, - 0,5, - 12, - 12, - 1, - 12, - 7, - 7, - 3, - 0,6,8,3,5,2,7,4,9,10,11, - 9,11, - 6, - 0,2,12, - 0, - 0, - 0, - 11, - 5, - 0, - 0,1,6,8,3,5,4,9,11,12, - 4, - 6,4,11, - 0,6,3,4,9,12, - 2, - 6,4,10,11, - 10, - 7, - 1,7,12, - 5, - 8,4,11, - 4, - 4, - 11, - 11, - 11, - 11, - 8, - 12, - 6,8, - 8, - 10, - 3,12, - 1,12, - 12, - 0, - 11, - 8, - 0,6,8,3,5,2,4,9,10,11,12, - 12, - 8,4,10, - 0,5,9,10, - 1,6,8,3,5,4,11,12, - 8, - 0,6,8,2,9,10,11,12, - 6,2,11, - 6,8,2,4,10,12, - 2,4,10, - 0,5, - 0, - 8, - 9, - 9, - 8, - 1, - 7,12, - 6,4,11, - 0, - 0, - 2, - 2, - 2, - 2, - 8,7, - 9, + 3, + 3, + 1,12, + 1,15,11,12,7,9,10,5,13,4,3,16, + 10,3, + 11,12,10,13,3, + 14,1,15,11,12,9,10,5,13,4,3, + 12,7,10,5,4,3, + 11,12,10,13,3, + 15,11,12,10,13,4,3, + 11,12,7,9,10,6,5,4,3, + 10,3, + 14,15,12,10,4, + 15,12,7, + 14,12, + 12, + 12, + 15,12, + 15, + 15, + 15, + 12,3, + 12, + 12, + 12,16, + 12, + 16, + 12, + 7,5, + 10, + 10, + 14,15,8,13,16, + 7,10,13, + 15,12,7,13, + 4, + 12, + 12, + 10, + 13, + 12, + 12, + 15,3, + 10, + 14,1,15,11,12,7,9,10,5,13,4,3,16, + 7, + 6, + 6, + 14,3, + 6, + 3, + 11,7,9,13,3, + 3, + 12, + 11,12,7,13, + 7, + 7, + 2,15,9,10,5,3, + 9, + 15,12, + 14, + 12,3, + 14,0,10, + 2,9,5,4, + 6, + 9, + 12, + 12, + 9, + 14,1,15,8,11,12,7,9,10,5,13,4,3,16, + 2,8, + 8,6,3, + 12, + 12, + 14,0,2,10,5, + 3, + 14, + 2, + 3, + 14,12,3, + 15,11,9,13,3, + 13, + 11, + 10, + 1, + 12,9,10, + 9, + 8,10,6, + 3, + 1,8,6, + 12,5, + 12, + 12, + 12, + 12, + 1, + 14,1,15,8,11,12,7,9,10,6,5,13,4,3,16, + 12,4, + 2,7,10,4, + 15,13,3, + 14,9, + 14,12,10,5,13,4, + 7, + 9,10, + 11, + 9, + 8, + 12, + 10,5, + 12, + 14, + 14,11,5, + 2,4, + 11,12,10,13,3, + 15,8,12, + 8, + 12, + 12, + 12, + 12, + 12, + 12, + 12, + 15,11,9,13,3, + 13, + 11, + 12, + 11,12,7,10,5,3, + 15, + 14,15,11,12,7,9,10,6,5,13,3,16, + 16, + 2,12,7,10, + 15,6, + 15,12,7,3, + 12, + 12, + 12, + 12,4, + 11, + 12, + 10, + 10, + 9, + 15, + 15,11,12,10,3, + 9, + 12,7, + 10, + 15,12,7, + 10, + 10, + 10, + 8, + 14,1,15,11,12,7,9,10,6,5,13,4,3,16, + 12, + 2, + 15, + 12, + 12, + 11, + 14,1,15,8,11,12,7,9,10,5,13,4,3,16, + 6, + 1,11,9,6, + 11,7,9,10, + 13, + 13, + 13, + 15,11,7,10,13,3, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 1,8,9,6,3, + 6, + 6, + 12,9,13, + 12, + 12, + 12,13, + 1,15, + 12, + 15,13, + 15,13, + 13, + 6, + 14, + 14, + 14, + 14, + 14,11,12,7,10,5,13,3, + 12, + 16, + 9, + 9, + 14, + 15,11,12,7,9,6,5,4,3, + 14, + 3, + 12, + 15,12,13,3, + 8,3, + 15,11,7,5,3,16, + 15, + 6, + 6, + 6, + 12, + 12,5, + 14,1,15,11,12,7,10,5,13,4,3,16, + 12, + 15,16, + 0,10,5, + 2,8, + 8, + 10, + 7, + 7, + 14, + 14, + 14, + 14, + 14, + 14, + 14,12,7,10,5,13,3, + 10, + 10, + 9, + 9, + 13, + 12, + 3, + 8,7,3, + 8, + 7, + 10, + 11,10,5,13,4,3, + 12, + 12, + 12, + 14,6,5,4, + 2,8, + 8, + 14, + 12, + 2,5, + 4, + 12, + 14, + 7, + 2,7, + 1,2,8,11,7,9,10,6,5,13,4,3, + 14,15,11,12,7,9,10,5,13,4,3,16, + 14, + 1,2,8,11,12,7,9,10,6,5,13,4,3,16, + 12, + 14,15,8,11,12,7,9,10,5,13,4,3,16, + 9,5,4, + 12, + 16, + 5, + 1, + 3, + 12,10,5,13,3, + 12,10, + 6, + 9, + 16, + 10, + 3, + 12,5, + 11,7, + 14,10, + 14, + 6, + 12, + 12, + 6, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 9, + 1,12,10,6,5,16, + 12,9,10,5, + 2,8, + 13, + 2,8,9,6, + 8, + 13, + 12, + 6,4, + 10, + 9, + 13, + 9, + 12, + 10, + 10, + 10, + 12, + 10, + 14, + 12, + 10, + 10, + 14,2, + 12, + 12, + 12, + 1, + 1, + 7, + 12, + 9, + 9, + 9, + 14, + 5,3, + 3, + 3, + 15,12,9, + 12, + 10, + 15,10,3, + 15,12,7,10,5,3,16, + 10, + 12, + 12,5, + 10, + 10, + 10, + 12,10,5,3, + 10, + 10, + 12, + 15,12,13,3, + 3, + 8,13,3, + 15, + 15,12, + 0,11,12,7,9,10,6,5,4,3,16, + 16, + 11,3, + 10,13, + 3, + 3, + 10, + 4, + 11, + 9, + 10, + 10, + 3, + 5, + 11, + 11, + 5, + 3, + 5, + 7, + 10, + 12, + 14, + 14, + 3, + 3, + 3, + 13, + 13, + 13, + 10, + 10, + 13, + 13, + 13, + 10, + 7, + 3, + 3, + 13, + 7, + 14, + 14, + 14, + 7, + 13, + 13, + 12, + 5, + 15, + 5, + 11, + 11, + 13, + 3, + 3, + 5, + 3, + 9, + 10, + 9, + 12,7,10, + 7, + 12,7,9,10, + 12,10, + 10, + 12, + 12, + 15,13, + 9, + 9, + 14, + 0,1,8,11,12,7,9,10,6,5,4,3,16, + 12, + 14,10, + 10, + 5, + 3, + 7,9,10, + 7, + 9, + 7,9,10, + 10, + 10, + 11,3, + 13, + 1,12, + 2,10, + 12,13,3, + 12,13, + 13, + 2,6, + 9, + 13, + 0,10,13, + 12,13, + 8,12, + 7, + 12, + 10,13, + 13, + 13, + 10, + 10, + 15,12,9,6, + 12, + 13, + 12, + 15,11,12,7,5,3,16, + 12, + 7,13,3, + 14, + 1,12,7,10,13, + 10, + 10, + 1,2,8,11,12,7,9,10,6,5,13,4,3,16, + 1,6, + 12, + 13, + 8, + 15,12,10,6,13,4, + 12, + 12, + 14,2,12,7,10,6,13,4,16, + 12, + 11, + 2, + 0, + 12, + 14,3, + 11,3, + 12, + 10, + 15,3, + 3, + 15,3, + 12,5,3, + 1,15,12,7,3, + 12, + 11,4, + 10, + 3, + 7, + 7, + 13, + 10,16, + 15, + 7, + 15,10,13,3, + 15,5, + 10, + 14,15,11,12,9,13,3, + 3, + 3, + 3, + 9, + 3, + 1,6, + 12,3, + 12, + 12,6, + 12, + 15, + 3, + 3, + 15, + 2,11, + 7, + 12, + 12,10, + 12, + 1,9, + 10, + 9, + 14,3, + 12, + 15,11,10,3, + 11,3, + 11, + 11, + 11,3, + 11,3, + 2,12, + 12, + 6, + 10, + 15, + 12,16, + 16, + 10, + 2,12, + 13, + 3, + 5, + 8,12,6, + 12, + 12, + 15,12, + 12, + 14,15,11,12,7,9,10,5,13,4,3,16, + 12, + 5, + 9,10,5,16, + 12,7, + 1,6, + 7,13, + 13, + 12,10,5,3,16, + 2, + 15,12, + 12, + 13, + 8, + 8, + 11,10,13,4, + 10,4, + 15,12, + 0,1,15,8,11,12,7,9,10,6,5,4,3,16, + 15,12,10, + 10, + 7, + 1,12,10,13,3, + 1, + 1, + 1, + 12, + 6, + 1, + 1,2,8,12,7,9,10,6,5,13,4,16, + 9,4, + 9,4, + 12, + 10,16, + 5,13, + 14,12,7,5,13, + 1, + 3, + 3, + 13, + 14, + 12,10,3, + 15, + 12,3, + 14,11,7,10,5,13, + 3, + 9,3, + 12,10,3, + 14, + 12, + 11, + 3, + 12, + 12, + 12, + 12, + 12, + 14, + 8, + 15,13,3, + 14,2,8,13, + 13, + 13, + 15,8, + 12, + 6, + 12,5,16, + 0,12,9,5, + 10,5,16, + 5, + 16, + 12, + 12, + 12, + 12, + 12,9,13, + 12, + 12, + 13, + 11,13, + 13,3, + 14, + 15, + 15,10, + 14, + 13, + 12, + 13, + 15, + 12, + 13, + 12, + 13, + 12, + 7, + 7, + 12,7,9, + 12, + 12, + 9, + 11, + 10,13,4, + 0,2,10,13, + 13, + 10,13, + 1, + 12, + 3, + 3, + 12,9,10, + 14,1,15,8,11,12,7,9,10,6,5,13,4,3,16, + 9, + 14,11,12,10,13, + 15,11,12,9,10,5,4,16, + 5, + 12, + 1,11,10,6, + 3, + 14,2,15,12,7,9,10,6,5,13,4,3, + 14, + 14, + 14, + 14, + 12, + 9, + 9, + 1,15,11,12,7,9,10,13,3, + 12, + 15,11,7,13,3, + 11,12,7,9,5,13,3, + 5, + 5, + 9, + 9, + 14,11,12,5,3, + 1,6,3, + 6, + 6, + 1,6, + 9, + 6, + 15, + 5, + 10, + 10, + 10, + 9, + 12, + 9,5, + 2, + 8,12,10,13, + 14,12,7,5, + 1, + 1,12, + 15,12,6,3,16, + 15,9,3, + 11, + 11, + 3, + 3, + 3, + 9, + 9, + 15, + 3, + 15,9,3, + 11, + 11, + 3, + 3, + 3, + 9, + 9, + 8,9, + 9,10,3, + 11, + 11, + 9, + 9, diff --git a/doc/salome/gui/GEOM/whdata/whtdata0.htm b/doc/salome/gui/GEOM/whdata/whtdata0.htm index 33fb2dbe7..1e295373b 100755 --- a/doc/salome/gui/GEOM/whdata/whtdata0.htm +++ b/doc/salome/gui/GEOM/whdata/whtdata0.htm @@ -6,17 +6,20 @@ + + + + + + + + + + + + + + + + +

    Working with groups

    + +

    To perform operations with groups:

    + +

     

    + +

    In the main menu select New + entity > Groups.

    + +

     

    + +

    Create + a group

    + +

     

    + +

    Description: + Creates a group of subshapes of a geometrical object.

    + +

     

    + +

    Result: GEOM_Object.

    + +

     

    + +

    TUI Command: + geompy.CreateGroup(MainShape, ShapeType), + where MainShape is a shape for which the group is created, ShapeType is + a type of shapes in the created group.

    + +

     

    + +

    Arguments: + 1 Shape + Type of subshape.

    + +

     

    + +

    Dialog Box:

    + +

     

    + +

    + +

     

    + +

    Example:

    + +

     

    + +

    + +

     

    + +

     

    + +

     

    + +

    Edit + a group

    + +

     

    + +

    Description: + Allows to edit the existing group.

    + +

     

    + +

    Result: GEOM_Object.

    + +

     

    + +

    TUI Command: +

    + +
      + +
    • geompy.AddObject(Group, + SubShapeID), where Group is a group to which a sub shape has to + be added, SubShapeID is an ID of the sub shape to be added to the group

    • + +
    • geompy.RemoveObject(Group, + SubShapeID), where Group is a group from which a sub shape has + to be removed, SubShapeID is an ID of the sub shape to be removed from + the group

    • + +
    • geompy.GetObjectIDs(Group), + where Group is a group for which its object IDÂ’s are returned.

    • +
    + +

    Returns: + List of IDs.

    + +

     

    + +

    Arguments: + 1 Shape + its subshapes.

    + +

     

    + +

    Dialog Box:

    + +

     

    + +

    + + + + + diff --git a/doc/salome/tui/GEOM/HTML/GEOM_Gen.html b/doc/salome/tui/GEOM/HTML/GEOM_Gen.html index 4e9967c09..507db794d 100644 --- a/doc/salome/tui/GEOM/HTML/GEOM_Gen.html +++ b/doc/salome/tui/GEOM/HTML/GEOM_Gen.html @@ -1,262 +1,802 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    interface GEOM_Gen
    interface GEOM_Object
    IDL file
    Python
    string GetEntry ( )
    return_value = GetEntry ( )
    long GetStudyID ( )
    return_value = GetStudyID ( )
    long GetType ( )
    return_value = GetType ( )
    shape_type GetShapeType ( )
    return_value = GetShapeType ( )
    void SetName ( in string theName )
    SetName ( theName )
    string GetName ( )
    return_value = GetName ( )
    void SetStudyEntry ( in string theEntry )
    SetStudyEntry ( theEntry )
    string GetStudyEntry ( )
    return_value = GetStudyEntry ( )
    ListOfGO GetDependency ( )
    return_value = GetDependency ( )
    ListOfGO GetLastDependency ( )
    return_value = GetLastDependency ( )
    long getShape ( )
    return_value = getShape ( )
    TMPFile GetShapeStream ( )
    return_value = GetShapeStream ( )
    boolean IsMainShape ( )
    return_value = IsMainShape ( )
    ListOfLong GetSubShapeIndices ( )
    return_value = GetSubShapeIndices ( )
    GEOM_Object GetMainShape ( )
    return_value = GetMainShape ( )

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    interface GEOM_IOperations
    IDL file
    Python
    boolean IsDone ( )
    return_value = IsDone ( )
    void SetErrorCode ( in string theErrorID )
    SetErrorCode ( theErrorID )
    string GetErrorCode ( )
    return_value = GetErrorCode ( )
    long GetStudyID ( )
    return_value = GetStudyID ( )
    void StartOperation ( )
    StartOperation ( )
    void FinishOperation ( )
    FinishOperation ( )
    void AbortOperation ( )
    AbortOperation ( )

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    interface GEOM_IBasicOperations
    IDL file
    Python
    GEOM_Object MakePointXYZ ( in double theX, in double theY, in double theZ )
    return_value = MakePointXYZ ( theX, theY, theZ )
    GEOM_Object MakePointWithReference ( in GEOM_Object theReference, in double theX, in double theY, in double theZ )
    return_value = MakePointWithReference ( theReference, theX, theY, theZ )
    GEOM_Object MakePointOnCurve ( in GEOM_Object theRefCurve, in double theParameter )
    return_value = MakePointOnCurve ( theRefCurve, theParameter )
    GEOM_Object MakeVectorDXDYDZ ( in double theDX, in double theDY, in double theDZ )
    return_value = MakeVectorDXDYDZ ( theDX, theDY, theDZ )
    GEOM_Object MakeVectorTwoPnt ( in GEOM_Object thePnt1, in GEOM_Object thePnt2 )
    return_value = MakeVectorTwoPnt ( thePnt1, thePnt2 )
    GEOM_Object MakeLineTwoPnt ( in GEOM_Object thePnt1, in GEOM_Object thePnt2 )
    return_value = MakeLineTwoPnt ( thePnt1, thePnt2 )
    GEOM_Object MakePlaneThreePnt ( in GEOM_Object thePnt1, in GEOM_Object thePnt2, in GEOM_Object thePnt3, in double theTrimSize )
    return_value = MakePlaneThreePnt ( thePnt1, thePnt2, thePnt3, theTrimSize )
    GEOM_Object MakePlanePntVec ( in GEOM_Object thePnt, in GEOM_Object theVec, in double theTrimSize )
    return_value = MakePlanePntVec ( thePnt, theVec, theTrimSize )
    GEOM_Object MakePlaneFace ( in GEOM_Object theFace, in double theTrimSize )
    return_value = MakePlaneFace ( theFace, theTrimSize )
    GEOM_Object MakeMarker ( in double theOX, in double theOY, in double theOZ, in double theXDX, in double theXDY, in double theXDZ, in double theYDX, in double theYDY, in double theYDZ )
    return_value = MakeMarker ( theOX, theOY, theOZ, theXDX, theXDY, theXDZ, theYDX, theYDY, theYDZ )

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    interface GEOM_ITransformOperations
    IDL file
    Python
    GEOM_Object TranslateTwoPoints ( in GEOM_Object theObject, in GEOM_Object thePoint1, in GEOM_Object thePoint2 )
    return_value = TranslateTwoPoints ( theObject, thePoint1, thePoint2 )
    GEOM_Object TranslateTwoPointsCopy ( in GEOM_Object theObject, in GEOM_Object thePoint1, in GEOM_Object thePoint2 )
    return_value = TranslateTwoPointsCopy ( theObject, thePoint1, thePoint2 )
    GEOM_Object TranslateDXDYDZ ( in GEOM_Object theObject, in double theDX, in double theDY, in double theDZ )
    return_value = TranslateDXDYDZ ( theObject, theDX, theDY, theDZ )
    GEOM_Object TranslateDXDYDZCopy ( in GEOM_Object theObject, in double theDX, in double theDY, in double theDZ )
    return_value = TranslateDXDYDZCopy ( theObject, theDX, theDY, theDZ )
    GEOM_Object TranslateVector ( in GEOM_Object theObject, in GEOM_Object theVector )
    return_value = TranslateVector ( theObject, theVector )
    GEOM_Object TranslateVectorCopy ( in GEOM_Object theObject, in GEOM_Object theVector )
    return_value = TranslateVectorCopy ( theObject, theVector )
    GEOM_Object MultiTranslate1D ( in GEOM_Object theObject, in GEOM_Object theVector, in double theStep, in long theNbTimes )
    return_value = MultiTranslate1D ( theObject, theVector, theStep, theNbTimes )
    GEOM_Object MultiTranslate2D ( in GEOM_Object theObject, in GEOM_Object theVector1, in double theStep1, in long theNbTimes1, in GEOM_Object theVector2, in double theStep2, in long theNbTimes2 )
    return_value = MultiTranslate2D ( theObject, theVector1, theStep1, theNbTimes1, theVector2, theStep2, theNbTimes2 )
    GEOM_Object Rotate ( in GEOM_Object theObject, in GEOM_Object theAxis, in double theAngle )
    return_value = Rotate ( theObject, theAxis, theAngle )
    GEOM_Object RotateCopy ( in GEOM_Object theObject, in GEOM_Object theAxis, in double theAngle )
    return_value = RotateCopy ( theObject, theAxis, theAngle )
    GEOM_Object MultiRotate1D ( in GEOM_Object theObject, in GEOM_Object theAxis, in long theNbTimes )
    return_value = MultiRotate1D ( theObject, theAxis, theNbTimes )
    GEOM_Object MultiRotate2D ( in GEOM_Object theObject, in GEOM_Object theAxis, in double theAngle, in long theNbTimes1, in double theStep, in long theNbTimes2 )
    return_value = MultiRotate2D ( theObject, theAxis, theAngle, theNbTimes1, theStep, theNbTimes2 )
    GEOM_Object MirrorPlane ( in GEOM_Object theObject, in GEOM_Object thePlane )
    return_value = MirrorPlane ( theObject, thePlane )
    GEOM_Object MirrorPlaneCopy ( in GEOM_Object theObject, in GEOM_Object thePlane )
    return_value = MirrorPlaneCopy ( theObject, thePlane )
    GEOM_Object MirrorAxis ( in GEOM_Object theObject, in GEOM_Object theAxis )
    return_value = MirrorAxis ( theObject, theAxis )
    GEOM_Object MirrorAxisCopy ( in GEOM_Object theObject, in GEOM_Object theAxis )
    return_value = MirrorAxisCopy ( theObject, theAxis )
    GEOM_Object MirrorPoint ( in GEOM_Object theObject, in GEOM_Object thePoint )
    return_value = MirrorPoint ( theObject, thePoint )
    GEOM_Object MirrorPointCopy ( in GEOM_Object theObject, in GEOM_Object thePoint )
    return_value = MirrorPointCopy ( theObject, thePoint )
    GEOM_Object OffsetShape ( in GEOM_Object theObject, in double theOffset )
    return_value = OffsetShape ( theObject, theOffset )
    GEOM_Object OffsetShapeCopy ( in GEOM_Object theObject, in double theOffset )
    return_value = OffsetShapeCopy ( theObject, theOffset )
    GEOM_Object ScaleShape ( in GEOM_Object theObject, in GEOM_Object thePoint, in double theFactor )
    return_value = ScaleShape ( theObject, thePoint, theFactor )
    GEOM_Object ScaleShapeCopy ( in GEOM_Object theObject, in GEOM_Object thePoint, in double theFactor )
    return_value = ScaleShapeCopy ( theObject, thePoint, theFactor )
    GEOM_Object PositionShape ( in GEOM_Object theObject, in GEOM_Object theStartLCS, in GEOM_Object theEndLCS )
    return_value = PositionShape ( theObject, theStartLCS, theEndLCS )
    GEOM_Object PositionShapeCopy ( in GEOM_Object theObject, in GEOM_Object theStartLCS, in GEOM_Object theEndLCS )
    return_value = PositionShapeCopy ( theObject, theStartLCS, theEndLCS )

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    interface GEOM_I3DPrimOperations
    IDL file
    Python
    GEOM_Object MakeBoxDXDYDZ ( in double theDX, in double theDY, in double theDZ )
    return_value = MakeBoxDXDYDZ ( theDX, theDY, theDZ )
    GEOM_Object MakeBoxTwoPnt ( in GEOM_Object thePnt1, in GEOM_Object thePnt2 )
    return_value = MakeBoxTwoPnt ( thePnt1, thePnt2 )
    GEOM_Object MakeCylinderRH ( in double theR, in double theH )
    return_value = MakeCylinderRH ( theR, theH )
    GEOM_Object MakeCylinderPntVecRH ( in GEOM_Object thePnt, in GEOM_Object theAxis, in double theR, in double theH )
    return_value = MakeCylinderPntVecRH ( thePnt, theAxis, theR, theH )
    GEOM_Object MakeConeR1R2H ( in double theR1, in double theR2, in double theH )
    return_value = MakeConeR1R2H ( theR1, theR2, theH )
    GEOM_Object MakeConePntVecR1R2H ( in GEOM_Object thePnt, in GEOM_Object theAxis, in double theR1, in double theR2, in double theH )
    return_value = MakeConePntVecR1R2H ( thePnt, theAxis, theR1, theR2, theH )
    GEOM_Object MakeTorusRR ( in double theRMajor, in double theRMinor )
    return_value = MakeTorusRR ( theRMajor, theRMinor )
    GEOM_Object MakeTorusPntVecRR ( in GEOM_Object thePnt, in GEOM_Object theVec, in double theRMajor, in double theRMinor )
    return_value = MakeTorusPntVecRR ( thePnt, theVec, theRMajor, theRMinor )
    GEOM_Object MakeSphereR ( in double theR )
    return_value = MakeSphereR ( theR )
    GEOM_Object MakeSpherePntR ( in GEOM_Object thePnt, in double theR )
    return_value = MakeSpherePntR ( thePnt, theR )
    GEOM_Object MakePrismVecH ( in GEOM_Object theBase, in GEOM_Object theVec, in double theH )
    return_value = MakePrismVecH ( theBase, theVec, theH )
    GEOM_Object MakePrismTwoPnt ( in GEOM_Object theBase, in GEOM_Object thePoint1, in GEOM_Object thePoint2 )
    return_value = MakePrismTwoPnt ( theBase, thePoint1, thePoint2 )
    GEOM_Object MakePipe ( in GEOM_Object theBase, in GEOM_Object thePath )
    return_value = MakePipe ( theBase, thePath )
    GEOM_Object MakeRevolutionAxisAngle ( in GEOM_Object theBase, in GEOM_Object theAxis, in double theAngle )
    return_value = MakeRevolutionAxisAngle ( theBase, theAxis, theAngle )
    GEOM_Object MakeFilling ( in GEOM_Object theShape, in long theMinDeg, in long theMaxDeg, in double theTol2D, in double theTol3D, in long theNbIter )
    return_value = MakeFilling ( theShape, theMinDeg, theMaxDeg, theTol2D, theTol3D, theNbIter )

    + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + + +
    interface GEOM_IShapesOperations
    IDL file
    Python
    void GetCurrentStudy ( in long StudyID )
    GetCurrentStudy ( StudyID )
    GEOM_Object MakeEdge ( in GEOM_Object thePnt1, in GEOM_Object thePnt2 )
    return_value = MakeEdge ( thePnt1, thePnt2 )
    short NbLabels ( )
    return_value = NbLabels ( )
    GEOM_Object MakeWire ( in ListOfGO theEdgesAndWires )
    return_value = MakeWire ( theEdgesAndWires )
    GEOM_Shape GetIORFromString ( in string ior )
    return_value = GetIORFromString ( ior )
    GEOM_Object MakeFace ( in GEOM_Object theWire, in boolean isPlanarWanted )
    return_value = MakeFace ( theWire, isPlanarWanted )
    ListOfIOR GetReferencedObjects ( in GEOM_Shape shape )
    return_value = GetReferencedObjects ( shape )
    GEOM_Object MakeFaceWires ( in ListOfGO theWires, in boolean isPlanarWanted )
    return_value = MakeFaceWires ( theWires, isPlanarWanted )
    ListOfIOR GetObjects ( in GEOM_Shape shape )
    return_value = GetObjects ( shape )
    GEOM_Object MakeShell ( in ListOfGO theFacesAndShells )
    return_value = MakeShell ( theFacesAndShells )
    PointStruct MakePointStruct ( in double x, in double y, in double z )
    return_value = MakePointStruct ( x, y, z )
    GEOM_Object MakeSolidShell ( in GEOM_Object theShell )
    return_value = MakeSolidShell ( theShell )
    DirStruct MakeDirection ( in PointStruct p )
    return_value = MakeDirection ( p )
    GEOM_Object MakeSolidShells ( in ListOfGO theShells )
    return_value = MakeSolidShells ( theShells )
    AxisStruct MakeAxisStruct ( in double x, in double y, in double z, in double vx, in double vy, in double vz )
    return_value = MakeAxisStruct ( x, y, z, vx, vy, vz )
    GEOM_Object MakeCompound ( in ListOfGO theShapes )
    return_value = MakeCompound ( theShapes )
    GEOM_Shape MakeBoolean ( in GEOM_Shape shape1, in GEOM_Shape shape2, in long operation )
    return_value = MakeBoolean ( shape1, shape2, operation )
    GEOM_Object MakeGlueFaces ( in GEOM_Object theShape, in double theTolerance )
    return_value = MakeGlueFaces ( theShape, theTolerance )
    GEOM_Shape MakeFuse ( in GEOM_Shape shape1, in GEOM_Shape shape2 )
    return_value = MakeFuse ( shape1, shape2 )
    ListOfGO MakeExplode ( in GEOM_Object theShape, in long theShapeType, in boolean isSorted )
    return_value = MakeExplode ( theShape, theShapeType, isSorted )
    GEOM_Shape Partition ( in ListOfIOR ListShapes, in ListOfIOR ListTools, in ListOfIOR ListKeepInside, in ListOfIOR ListRemoveInside, in short Limit )
    return_value = Partition ( ListShapes, ListTools, ListKeepInside, ListRemoveInside, Limit )
    long NumberOfFaces ( in GEOM_Object theShape )
    return_value = NumberOfFaces ( theShape )
    GEOM_Shape MakeFilling ( in GEOM_Shape shape, in short mindeg, in short maxdeg, in double tol3d, in double tol2d, in short nbiter )
    return_value = MakeFilling ( shape, mindeg, maxdeg, tol3d, tol2d, nbiter )
    long NumberOfEdges ( in GEOM_Object theShape )
    return_value = NumberOfEdges ( theShape )
    GEOM_Shape MakeSewing ( in ListOfIOR ListShape, in double precision )
    return_value = MakeSewing ( ListShape, precision )
    GEOM_Object ChangeOrientation ( in GEOM_Object theShape )
    return_value = ChangeOrientation ( theShape )

    + + + + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + + +
    interface GEOM_IBlocksOperations
    IDL file
    Python
    GEOM_Shape MakeSewingShape ( in GEOM_Shape aShape, in double precision )
    return_value = MakeSewingShape ( aShape, precision )
    GEOM_Object MakeQuadFaceFourVertices ( in GEOM_Object thePnt1, in GEOM_Object thePnt2, in GEOM_Object thePnt3, in GEOM_Object thePnt4 )
    return_value = MakeQuadFaceFourVertices ( thePnt1, thePnt2, thePnt3, thePnt4 )
    GEOM_Shape OrientationChange ( in GEOM_Shape shape )
    return_value = OrientationChange ( shape )
    GEOM_Object MakeQuadFaceFourEdges ( in GEOM_Object theEdge1, in GEOM_Object theEdge2, in GEOM_Object theEdge3, in GEOM_Object theEdge4 )
    return_value = MakeQuadFaceFourEdges ( theEdge1, theEdge2, theEdge3, theEdge4 )
    GEOM_Shape MakePlacedBox ( in double x1, in double y1, in double z1, in double delta1, in double delta2, in double delta3 )
    return_value = MakePlacedBox ( x1, y1, z1, delta1, delta2, delta3 )
    GEOM_Object MakeQuadFaceTwoEdges ( in GEOM_Object theEdge1, in GEOM_Object theEdge2 )
    return_value = MakeQuadFaceTwoEdges ( theEdge1, theEdge2 )
    GEOM_Shape MakePanel ( in GEOM_Shape shape, in short directiontype, in double delta )
    return_value = MakePanel ( shape, directiontype, delta )
    GEOM_Object MakeHexaSolidSixFaces ( in GEOM_Object theFace1, in GEOM_Object theFace2, in GEOM_Object theFace3, in GEOM_Object theFace4, in GEOM_Object theFace5, in GEOM_Object theFace6 )
    return_value = MakeHexaSolidSixFaces ( theFace1, theFace2, theFace3, theFace4, theFace5, theFace6 )
    GEOM_Shape MakeGlueFaces ( in GEOM_Shape shape, in double tol3d )
    return_value = MakeGlueFaces ( shape, tol3d )
    GEOM_Object MakeHexaSolidTwoFaces ( in GEOM_Object theFace1, in GEOM_Object theFace2 )
    return_value = MakeHexaSolidTwoFaces ( theFace1, theFace2 )
    GEOM_Shape MakeCopy ( in GEOM_Shape shape )
    return_value = MakeCopy ( shape )
    GEOM_Object GetEdge ( in GEOM_Object theShape, in GEOM_Object thePoint1, in GEOM_Object thePoint2 )
    return_value = GetEdge ( theShape, thePoint1, thePoint2 )
    GEOM_Shape MakeTranslation ( in GEOM_Shape shape, in double x, in double y, in double z )
    return_value = MakeTranslation ( shape, x, y, z )
    GEOM_Object GetFaceByPoints ( in GEOM_Object theShape, in GEOM_Object thePoint1, in GEOM_Object thePoint2, in GEOM_Object thePoint3, in GEOM_Object thePoint4 )
    return_value = GetFaceByPoints ( theShape, thePoint1, thePoint2, thePoint3, thePoint4 )
    GEOM_Shape MakeRotation ( in GEOM_Shape shape, in AxisStruct axis, in double angle )
    return_value = MakeRotation ( shape, axis, angle )
    GEOM_Object GetFaceByEdges ( in GEOM_Object theShape, in GEOM_Object theEdge1, in GEOM_Object theEdge2 )
    return_value = GetFaceByEdges ( theShape, theEdge1, theEdge2 )
    GEOM_Shape MakeScaleTransform ( in GEOM_Shape shape, in PointStruct theCenterofScale, in double factor )
    return_value = MakeScaleTransform ( shape, theCenterofScale, factor )
    GEOM_Object GetOppositeFace ( in GEOM_Object theBlock, in GEOM_Object theFace )
    return_value = GetOppositeFace ( theBlock, theFace )
    GEOM_Shape MakeMirrorByPlane ( in GEOM_Shape shape, in GEOM_Shape shapePlane )
    return_value = MakeMirrorByPlane ( shape, shapePlane )
    GEOM_Object GetFaceNearPoint ( in GEOM_Object theShape, in GEOM_Object thePoint )
    return_value = GetFaceNearPoint ( theShape, thePoint )
    GEOM_Shape MakeRevolution ( in GEOM_Shape shape, in AxisStruct axis, in double angle )
    return_value = MakeRevolution ( shape, axis, angle )
    GEOM_Object GetFaceByNormale ( in GEOM_Object theBlock, in GEOM_Object theVector )
    return_value = GetFaceByNormale ( theBlock, theVector )
    GEOM_Shape MakePrism ( in GEOM_Shape baseShape, in PointStruct P1, in PointStruct P2 )
    return_value = MakePrism ( baseShape, P1, P2 )
    boolean IsCompoundOfBlocks ( in GEOM_Object theCompound, in long theMinNbFaces, in long theMaxNbFaces, out long theNbBlocks )
    [ return_value, theNbBlocks ] = IsCompoundOfBlocks ( theCompound, theMinNbFaces, theMaxNbFaces )
    GEOM_Shape MakePipe ( in GEOM_Shape pathShape, in GEOM_Shape baseShape )
    return_value = MakePipe ( pathShape, baseShape )
    ListOfGO ExplodeCompoundOfBlocks ( in GEOM_Object theCompound, in long theMinNbFaces, in long theMaxNbFaces )
    return_value = ExplodeCompoundOfBlocks ( theCompound, theMinNbFaces, theMaxNbFaces )
    GEOM_Shape MakeMultiTranslation1D ( in GEOM_Shape shape, in DirStruct dir, in double step, in short nbtimes )
    return_value = MakeMultiTranslation1D ( shape, dir, step, nbtimes )
    GEOM_Object GetBlockNearPoint ( in GEOM_Object theCompound, in GEOM_Object thePoint )
    return_value = GetBlockNearPoint ( theCompound, thePoint )
    GEOM_Shape MakeMultiTranslation2D ( in GEOM_Shape shape, in DirStruct dir1, in double step1, in short nbtimes1, in DirStruct dir2, in double step2, in short nbtimes2 )
    return_value = MakeMultiTranslation2D ( shape, dir1, step1, nbtimes1, dir2, step2, nbtimes2 )
    GEOM_Object GetBlockByParts ( in GEOM_Object theCompound, in ListOfGO theParts )
    return_value = GetBlockByParts ( theCompound, theParts )
    GEOM_Shape MakeMultiRotation1D ( in GEOM_Shape shape, in DirStruct dir, in PointStruct loc, in short nbtimes )
    return_value = MakeMultiRotation1D ( shape, dir, loc, nbtimes )
    ListOfGO GetBlocksByParts ( in GEOM_Object theCompound, in ListOfGO theParts )
    return_value = GetBlocksByParts ( theCompound, theParts )
    GEOM_Shape MakeMultiRotation2D ( in GEOM_Shape shape, in DirStruct dir, in PointStruct loc, in double ang, in short nbtimes1, in double step, in short nbtimes2 )
    return_value = MakeMultiRotation2D ( shape, dir, loc, ang, nbtimes1, step, nbtimes2 )
    GEOM_Object MakeMultiTransformation1D ( in GEOM_Object theBlock, in long theDirFace1, in long theDirFace2, in long theNbTimes )
    return_value = MakeMultiTransformation1D ( theBlock, theDirFace1, theDirFace2, theNbTimes )
    GEOM_Shape MakeCDG ( in GEOM_Shape shape )
    return_value = MakeCDG ( shape )
    GEOM_Object MakeMultiTransformation2D ( in GEOM_Object theBlock, in long theDirFace1U, in long theDirFace2U, in long theNbTimesU, in long theDirFace1V, in long theDirFace2V, in long theNbTimesV )
    return_value = MakeMultiTransformation2D ( theBlock, theDirFace1U, theDirFace2U, theNbTimesU, theDirFace1V, theDirFace2V, theNbTimesV )

    + + + + + + - - + + - - + + - - + + + +
    interface GEOM_IBooleanOperations
    IDL file
    Python
    GEOM_Shape MakeVertex ( in double x, in double y, in double z )
    return_value = MakeVertex ( x, y, z )
    GEOM_Object MakeBoolean ( in GEOM_Object theShape1, in GEOM_Object theShape2, in long theOperation )
    return_value = MakeBoolean ( theShape1, theShape2, theOperation )
    GEOM_Shape MakeVector ( in PointStruct pstruct1, in PointStruct pstruct2 )
    return_value = MakeVector ( pstruct1, pstruct2 )
    GEOM_Object MakePartition ( in ListOfGO theShapes, in ListOfGO theTools, in ListOfGO theKeepInside, in ListOfGO theRemoveInside, in short theLimit, in boolean theRemoveWebs, in ListOfLong theMaterials )
    return_value = MakePartition ( theShapes, theTools, theKeepInside, theRemoveInside, theLimit, theRemoveWebs, theMaterials )
    GEOM_Shape MakeLine ( in PointStruct pstruct, in DirStruct dstruct )
    return_value = MakeLine ( pstruct, dstruct )
    GEOM_Object MakeHalfPartition ( in GEOM_Object theShape, in GEOM_Object thePlane )
    return_value = MakeHalfPartition ( theShape, thePlane )

    + + + + + + + + + + + + + + + + + + + + + + - - + + - - + + - - + + - - + + + +
    interface GEOM_ICurvesOperations
    IDL file
    Python
    GEOM_Object MakeCirclePntVecR ( in GEOM_Object thePnt, in GEOM_Object theVec, in double theR )
    return_value = MakeCirclePntVecR ( thePnt, theVec, theR )
    GEOM_Object MakeCircleThreePnt ( in GEOM_Object thePnt1, in GEOM_Object thePnt2, in GEOM_Object thePnt3 )
    return_value = MakeCircleThreePnt ( thePnt1, thePnt2, thePnt3 )
    GEOM_Object MakeEllipse ( in GEOM_Object thePnt, in GEOM_Object theVec, in double theRMajor, in double theRMinor )
    return_value = MakeEllipse ( thePnt, theVec, theRMajor, theRMinor )
    GEOM_Object MakeArc ( in GEOM_Object thePnt1, in GEOM_Object thePnt2, in GEOM_Object thePnt3 )
    return_value = MakeArc ( thePnt1, thePnt2, thePnt3 )
    GEOM_Shape MakePlane ( in PointStruct pstruct, in DirStruct dstruct, in double trimsize )
    return_value = MakePlane ( pstruct, dstruct, trimsize )
    GEOM_Object MakePolyline ( in ListOfGO thePoints )
    return_value = MakePolyline ( thePoints )
    GEOM_Shape MakeCircle ( in PointStruct pstruct, in DirStruct dstruct, in double radius )
    return_value = MakeCircle ( pstruct, dstruct, radius )
    GEOM_Object MakeSplineBezier ( in ListOfGO thePoints )
    return_value = MakeSplineBezier ( thePoints )
    GEOM_Shape MakeArc ( in PointStruct pInit, in PointStruct pCircle, in PointStruct pEnd )
    return_value = MakeArc ( pInit, pCircle, pEnd )
    GEOM_Object MakeSplineInterpolation ( in ListOfGO thePoints )
    return_value = MakeSplineInterpolation ( thePoints )
    GEOM_Shape MakeBox ( in double x1, in double y1, in double z1, in double x2, in double y2, in double z2 )
    return_value = MakeBox ( x1, y1, z1, x2, y2, z2 )
    GEOM_Object MakeSketcher ( in string theCommand, in ListOfDouble theWorkingPlane )
    return_value = MakeSketcher ( theCommand, theWorkingPlane )

    + + + + + + - - + + - - + + - - + + - - + + - - + + + + + + + + + + + + + + + +
    interface GEOM_ILocalOperations
    IDL file
    Python
    GEOM_Shape MakeCylinder ( in PointStruct pstruct, in DirStruct dstruct, in double radius, in double height )
    return_value = MakeCylinder ( pstruct, dstruct, radius, height )
    GEOM_Object MakeFilletAll ( in GEOM_Object theShape, in double theR )
    return_value = MakeFilletAll ( theShape, theR )
    GEOM_Shape MakeSphere ( in double x1, in double y1, in double z1, in double radius )
    return_value = MakeSphere ( x1, y1, z1, radius )
    GEOM_Object MakeFilletEdges ( in GEOM_Object theShape, in double theR, in ListOfLong theEdges )
    return_value = MakeFilletEdges ( theShape, theR, theEdges )
    GEOM_Shape MakeTorus ( in PointStruct pstruct, in DirStruct dstruct, in double major_radius, in double minor_radius )
    return_value = MakeTorus ( pstruct, dstruct, major_radius, minor_radius )
    GEOM_Object MakeFilletFaces ( in GEOM_Object theShape, in double theR, in ListOfLong theFaces )
    return_value = MakeFilletFaces ( theShape, theR, theFaces )
    GEOM_Shape MakeCone ( in PointStruct pstruct, in DirStruct dstruct, in double radius1, in double radius2, in double height )
    return_value = MakeCone ( pstruct, dstruct, radius1, radius2, height )
    GEOM_Object MakeChamferAll ( in GEOM_Object theShape, in double theD )
    return_value = MakeChamferAll ( theShape, theD )
    GEOM_Shape Archimede ( in GEOM_Shape shape, in double Weight, in double WaterDensity, in double MeshingDeflection )
    return_value = Archimede ( shape, Weight, WaterDensity, MeshingDeflection )
    GEOM_Object MakeChamferEdge ( in GEOM_Object theShape, in double theD1, in double theD2, in long theFace1, in long theFace2 )
    return_value = MakeChamferEdge ( theShape, theD1, theD2, theFace1, theFace2 )
    GEOM_Object MakeChamferFaces ( in GEOM_Object theShape, in double theD1, in double theD2, in ListOfLong theFaces )
    return_value = MakeChamferFaces ( theShape, theD1, theD2, theFaces )
    GEOM_Object MakeArchimede ( in GEOM_Object theShape, in double theWeight, in double theWaterDensity, in double theMeshDeflection )
    return_value = MakeArchimede ( theShape, theWeight, theWaterDensity, theMeshDeflection )
    long GetSubShapeIndex ( in GEOM_Object theShape, in GEOM_Object theSubShape )
    return_value = GetSubShapeIndex ( theShape, theSubShape )

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    interface GEOM_IHealingOperations
    IDL file
    Python
    GEOM_Object ProcessShape ( in GEOM_Object theShapes, in string_array theOperators, in string_array theParameters, in string_array theValues )
    return_value = ProcessShape ( theShapes, theOperators, theParameters, theValues )
    void GetShapeProcessParameters ( out string_array theOperators, out string_array theParameters, out string_array theValues )
    [ theOperators, theParameters, theValues ] = GetShapeProcessParameters ( )
    GEOM_Object SuppressFaces ( in GEOM_Object theObject, in short_array theFaces )
    return_value = SuppressFaces ( theObject, theFaces )
    GEOM_Object CloseContour ( in GEOM_Object theObject, in short_array theWires, in boolean isCommonVertex )
    return_value = CloseContour ( theObject, theWires, isCommonVertex )
    GEOM_Object RemoveIntWires ( in GEOM_Object theObject, in short_array theWires )
    return_value = RemoveIntWires ( theObject, theWires )
    GEOM_Object FillHoles ( in GEOM_Object theObject, in short_array theWires )
    return_value = FillHoles ( theObject, theWires )
    GEOM_Object Sew ( in GEOM_Object theObject, in double theTolerance )
    return_value = Sew ( theObject, theTolerance )
    GEOM_Object DivideEdge ( in GEOM_Object theObject, in short theEdgeIndex, in double theValue, in boolean isByParameter )
    return_value = DivideEdge ( theObject, theEdgeIndex, theValue, isByParameter )
    boolean GetFreeBoundary ( in GEOM_Object theObject, out ListOfGO theClosedWires, out ListOfGO theOpenWires )
    [ return_value, theClosedWires, theOpenWires ] = GetFreeBoundary ( theObject )

    + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    interface GEOM_IInsertOperations
    IDL file
    Python
    GEOM_Object MakeCopy ( in GEOM_Object theOriginal )
    return_value = MakeCopy ( theOriginal )
    void Export ( in GEOM_Object theObject, in string theFileName, in string theFormatName )
    Export ( theObject, theFileName, theFormatName )
    GEOM_Object Import ( in string theFileName, in string theFormatName )
    return_value = Import ( theFileName, theFormatName )
    void ImportTranslators ( out string_array theFormats, out string_array thePatterns )
    [ theFormats, thePatterns ] = ImportTranslators ( )
    void ExportTranslators ( out string_array theFormats, out string_array thePatterns )
    [ theFormats, thePatterns ] = ExportTranslators ( )

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    interface GEOM_IMeasureOperations
    IDL file
    Python
    void GetBasicProperties ( in GEOM_Object theShape, out double theLength, out double theSurfArea, out double theVolume )
    [ theLength, theSurfArea, theVolume ] = GetBasicProperties ( theShape )
    GEOM_Object GetCentreOfMass ( in GEOM_Object theShape )
    return_value = GetCentreOfMass ( theShape )
    void GetInertia ( in GEOM_Object theShape, out double I11, out double I12, out double I13, out double I21, out double I22, out double I23, out double I31, out double I32, out double I33, out double Ix, out double Iy, out double Iz )
    [ I11, I12, I13, I21, I22, I23, I31, I32, I33, Ix, Iy, Iz ] = GetInertia ( theShape )
    void GetBoundingBox ( in GEOM_Object theShape, out double Xmin, out double Xmax, out double Ymin, out double Ymax, out double Zmin, out double Zmax )
    [ Xmin, Xmax, Ymin, Ymax, Zmin, Zmax ] = GetBoundingBox ( theShape )
    void GetTolerance ( in GEOM_Object theShape, out double FaceMin, out double FaceMax, out double EdgeMin, out double EdgeMax, out double VertMin, out double VertMax )
    [ FaceMin, FaceMax, EdgeMin, EdgeMax, VertMin, VertMax ] = GetTolerance ( theShape )
    boolean CheckShape ( in GEOM_Object theShape, out string theDescription )
    [ return_value, theDescription ] = CheckShape ( theShape )
    string WhatIs ( in GEOM_Object theShape )
    return_value = WhatIs ( theShape )
    double GetMinDistance ( in GEOM_Object theShape1, in GEOM_Object theShape2, out double X1, out double Y1, out double Z1, out double X2, out double Y2, out double Z2 )
    [ return_value, X1, Y1, Z1, X2, Y2, Z2 ] = GetMinDistance ( theShape1, theShape2 )
    void PointCoordinates ( in GEOM_Object theShape, out double X, out double Y, out double Z )
    [ X, Y, Z ] = PointCoordinates ( theShape )

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    interface GEOM_IGroupOperations
    IDL file
    Python
    GEOM_Object CreateGroup ( in GEOM_Object theMainShape, in long theShapeType )
    return_value = CreateGroup ( theMainShape, theShapeType )
    void AddObject ( in GEOM_Object theGroup, in long theSubShapeId )
    AddObject ( theGroup, theSubShapeId )
    void RemoveObject ( in GEOM_Object theGroup, in long theSubShapeId )
    RemoveObject ( theGroup, theSubShapeId )
    long GetType ( in GEOM_Object theGroup )
    return_value = GetType ( theGroup )
    GEOM_Object GetMainShape ( in GEOM_Object theGroup )
    return_value = GetMainShape ( theGroup )
    ListOfLong GetObjects ( in GEOM_Object theGroup )
    return_value = GetObjects ( theGroup )

    + + + + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + +
    interface GEOM_Gen
    IDL file
    Python
    GEOM_Shape MakeEdge ( in PointStruct pstruct1, in PointStruct pstruct2 )
    return_value = MakeEdge ( pstruct1, pstruct2 )
    void Undo ( in long theStudyID )
    Undo ( theStudyID )
    GEOM_Shape MakeWire ( in ListOfIOR ListShape )
    return_value = MakeWire ( ListShape )
    void Redo ( in long theStudyID )
    Redo ( theStudyID )
    GEOM_Shape MakeCompound ( in ListOfIOR ListShape )
    return_value = MakeCompound ( ListShape )
    SObject AddInStudy ( in Study theStudy, in GEOM_Object theObject, in string theName, in GEOM_Object theFather )
    return_value = AddInStudy ( theStudy, theObject, theName, theFather )
    GEOM_Shape MakeFace ( in GEOM_Shape shapeWire, in boolean wantplanarface )
    return_value = MakeFace ( shapeWire, wantplanarface )
    GEOM_IBasicOperations GetIBasicOperations ( in long theStudyID )
    return_value = GetIBasicOperations ( theStudyID )
    GEOM_Shape SubShape ( in GEOM_Shape shape, in short ShapeType, in ListOfSubShapeID ListOfID )
    return_value = SubShape ( shape, ShapeType, ListOfID )
    GEOM_ITransformOperations GetITransformOperations ( in long theStudyID )
    return_value = GetITransformOperations ( theStudyID )
    ListOfGeomShapes SubShapeAll ( in GEOM_Shape shape, in short ShapeType )
    return_value = SubShapeAll ( shape, ShapeType )
    GEOM_I3DPrimOperations GetI3DPrimOperations ( in long theStudyID )
    return_value = GetI3DPrimOperations ( theStudyID )
    GEOM_Shape SubShapeSorted ( in GEOM_Shape shape, in short ShapeType, in ListOfSubShapeID ListOfID )
    return_value = SubShapeSorted ( shape, ShapeType, ListOfID )
    GEOM_IShapesOperations GetIShapesOperations ( in long theStudyID )
    return_value = GetIShapesOperations ( theStudyID )
    ListOfGeomShapes SubShapeAllSorted ( in GEOM_Shape shape, in short ShapeType )
    return_value = SubShapeAllSorted ( shape, ShapeType )
    GEOM_IBooleanOperations GetIBooleanOperations ( in long theStudyID )
    return_value = GetIBooleanOperations ( theStudyID )
    GEOM_Shape MakeFillet ( in GEOM_Shape shape, in double radius, in short ShapeType, in ListOfSubShapeID ListOfID )
    return_value = MakeFillet ( shape, radius, ShapeType, ListOfID )
    GEOM_ICurvesOperations GetICurvesOperations ( in long theStudyID )
    return_value = GetICurvesOperations ( theStudyID )
    GEOM_Shape MakeChamfer ( in GEOM_Shape shape, in double d1, in double d2, in short ShapeType, in ListOfSubShapeID ListOfID )
    return_value = MakeChamfer ( shape, d1, d2, ShapeType, ListOfID )
    GEOM_ILocalOperations GetILocalOperations ( in long theStudyID )
    return_value = GetILocalOperations ( theStudyID )
    ListOfGeomShapes SuppressFaces ( in GEOM_Shape shape, in ListOfSubShapeID ListOfID )
    return_value = SuppressFaces ( shape, ListOfID )
    GEOM_IHealingOperations GetIHealingOperations ( in long theStudyID )
    return_value = GetIHealingOperations ( theStudyID )
    GEOM_Shape SuppressHole ( in GEOM_Shape shape, in ListOfSubShapeID ListOfIdFace, in ListOfSubShapeID ListOfIdWire, in ListOfSubShapeID ListOfIdEndFace )
    return_value = SuppressHole ( shape, ListOfIdFace, ListOfIdWire, ListOfIdEndFace )
    GEOM_IInsertOperations GetIInsertOperations ( in long theStudyID )
    return_value = GetIInsertOperations ( theStudyID )
    GEOM_Shape SuppressHolesInFaceOrShell ( in GEOM_Shape shapeFaceShell, in ListOfSubShapeID ListOfIdWires )
    return_value = SuppressHolesInFaceOrShell ( shapeFaceShell, ListOfIdWires )
    GEOM_IMeasureOperations GetIMeasureOperations ( in long theStudyID )
    return_value = GetIMeasureOperations ( theStudyID )
    GEOM_Shape ImportIGES ( in string filename )
    return_value = ImportIGES ( filename )
    GEOM_IBlocksOperations GetIBlocksOperations ( in long theStudyID )
    return_value = GetIBlocksOperations ( theStudyID )
    GEOM_Shape ImportBREP ( in string filename )
    return_value = ImportBREP ( filename )
    GEOM_IGroupOperations GetIGroupOperations ( in long theStudyID )
    return_value = GetIGroupOperations ( theStudyID )
    GEOM_Shape ImportSTEP ( in string filename )
    return_value = ImportSTEP ( filename )
    void RemoveObject ( in GEOM_Object theObject )
    RemoveObject ( theObject )
    void ExportIGES ( in string filename, in GEOM_Shape theShape )
    ExportIGES ( filename, theShape )
    GEOM_Object GetObject ( in long theStudyID, in string theEntry )
    return_value = GetObject ( theStudyID, theEntry )
    void ExportBREP ( in string filename, in GEOM_Shape theShape )
    ExportBREP ( filename, theShape )
    GEOM_Object AddSubShape ( in GEOM_Object theMainShape, in ListOfLong theIndices )
    return_value = AddSubShape ( theMainShape, theIndices )
    void ExportSTEP ( in string filename, in GEOM_Shape theShape )
    ExportSTEP ( filename, theShape )
    GEOM_Object GetIORFromString ( in string theIOR )
    return_value = GetIORFromString ( theIOR )
    boolean CheckShape ( in GEOM_Shape shape )
    return_value = CheckShape ( shape )
    string GetStringFromIOR ( in GEOM_Object theObject )
    return_value = GetStringFromIOR ( theObject )

    diff --git a/doc/salome/tui/GEOM/doxyfile b/doc/salome/tui/GEOM/doxyfile index a6df56f0e..92c502252 100755 --- a/doc/salome/tui/GEOM/doxyfile +++ b/doc/salome/tui/GEOM/doxyfile @@ -3,7 +3,7 @@ #--------------------------------------------------------------------------- # General configuration options #--------------------------------------------------------------------------- -PROJECT_NAME = "SALOME - GEOM - v.2.0.0" +PROJECT_NAME = "SALOME - GEOM - v.2.1.0" PROJECT_NUMBER = id#1.1 OUTPUT_DIRECTORY = ../ OUTPUT_LANGUAGE = English @@ -56,8 +56,7 @@ WARN_LOGFILE = log.txt #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- -INPUT = ../../../share/salome/idl/GEOM_Gen.idl \ - ../../../share/salome/idl/GEOM_Shape.idl +INPUT = ../../../share/salome/idl/GEOM_Gen.idl FILE_PATTERNS = RECURSIVE = NO EXCLUDE = diff --git a/doc/salome/tui/GEOM/sources/static/page2.html b/doc/salome/tui/GEOM/sources/static/page2.html index 54dab3f8e..1966a56fc 100755 --- a/doc/salome/tui/GEOM/sources/static/page2.html +++ b/doc/salome/tui/GEOM/sources/static/page2.html @@ -35,7 +35,6 @@
  • SALOME GEOMETRY module
  • diff --git a/doc/salome/tui/GEOM/sources/static/tree.js b/doc/salome/tui/GEOM/sources/static/tree.js index fdfc5a03c..3193416d8 100755 --- a/doc/salome/tui/GEOM/sources/static/tree.js +++ b/doc/salome/tui/GEOM/sources/static/tree.js @@ -1,4 +1,4 @@ -foldersTree = gFld("SALOME v.2.0.0 ", "", "") +foldersTree = gFld("SALOME v.2.1.0 ", "", "") insDoc(foldersTree, gLnk("Main Page", "", "main.html")) aux1 = insFld(foldersTree, gFld("TUI Reference Guide", "")) diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index 61b8afc20..63f649050 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -1,26 +1,5 @@ -// 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 : GEOM_Gen.idl -// Author : Lucien PIGNOLONI +// Author : Sergey RUIN #ifndef __GEOM_GEN__ #define __GEOM_GEN__ @@ -28,305 +7,1786 @@ #include "SALOME_Exception.idl" #include "SALOME_Component.idl" #include "SALOMEDS.idl" -#include "GEOM_Shape.idl" + +#include "SALOME_GenericObj.idl" module GEOM { + /*! + * Topological types of shapes (like Open Cascade types) + */ + enum shape_type { COMPOUND, COMPSOLID, SOLID, SHELL, + FACE, WIRE, EDGE, VERTEX, SHAPE }; + + typedef sequence string_array; + typedef sequence short_array; + typedef sequence ListOfLong; + typedef sequence ListOfDouble; + + interface GEOM_Object; + + typedef sequence ListOfGO; + + /*! + * GEOM_Object: interface of geometric object + */ + interface GEOM_Object : SALOME::GenericObj + { + + /*! + * Get an entry of the object in GEOM component. + */ + string GetEntry(); + + /*! + * Get ID of study, where the object is created. + */ + long GetStudyID(); + + /*! + * Get internal type of the object (POINT, BOX, CYLINDER, EXTRUSION...). + */ + long GetType(); + + /*! + * Get a shape_type of the object value. + */ + shape_type GetShapeType(); + + /*! + * Set name of the object. + * \param theName is a name which will be associated with this object. + */ + void SetName (in string theName); + + /*! + * Get name of the object associated with this object. + */ + string GetName(); + + /*! + * Set a Study entry where this object was published. + */ + void SetStudyEntry (in string theEntry); + + /*! + * Get a Study entry where this object was published. + */ + string GetStudyEntry(); + + /*! + * Get a list of all GEOM objects on which were the arguments + * when this object was constructed and modified. + * \note This method is supposed to be used by GUI only. + */ + ListOfGO GetDependency(); + + /*! + * Get a list of GEOM objects on which the last function that created or modified the object depends. + * \note This method is supposed to be used by GUI only. + */ + ListOfGO GetLastDependency(); + + /*! + * Get the TopoDS_Shape, for colocated case only. + */ + long getShape(); + + /*! + ###################################################################### + * Internal methods (For sub shape identification) + ###################################################################### + */ + + /*! + * Get geometric shape of the object as a byte stream + */ + SALOMEDS::TMPFile GetShapeStream(); + + /* + * Returns True if this object is not a sub shape of another object. + */ + boolean IsMainShape(); + + /* + * Get a list of ID's of sub shapes in the main shape. + * \note Internal method, suppopsed to be used only by GEOM_Client + */ + ListOfLong GetSubShapeIndices(); + + /* + * Get a main shape object to which this object is a sub shape + * \note Internal method, suppopsed to be used only by GEOM_Client + */ + GEOM_Object GetMainShape(); + + /* + * Return true if geom object representes a shape. + * For example, method return false for GEOM_MARKER + */ + boolean IsShape(); + }; + + + /*! + * GEOM_IOperations: basic methods of all geometric operations + */ + interface GEOM_IOperations : SALOME::GenericObj + { + /*! + * To know, if the operation was successfully performed + */ + boolean IsDone(); + + /*! + * Set the operation error code + * \param theErrorID is a string describing the error occured + * \note This method is supposed to be used only by interfaces inheriting from IOperations. + */ + void SetErrorCode (in string theErrorID); + + /*! + * Get the operation error code + */ + string GetErrorCode(); + + /*! + * Get ID of study, where the operation is defined + */ + long GetStudyID(); + + /*! + * Opens a new transaction + */ + void StartOperation(); + + /*! + * Closes the previously opened trasaction + */ + void FinishOperation(); + + /*! + * Aborts the previously opened transaction + */ + void AbortOperation(); + }; + + /*! + * GEOM_IBasicOperations: interface for basic geometry creation + * (Point, Vector, Plane, Marker) + */ + interface GEOM_IBasicOperations : GEOM_IOperations + { + /*! + * 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. + */ + GEOM_Object MakePointXYZ (in double theX, in double theY, in double theZ); + + /*! + * 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. + */ + GEOM_Object MakePointWithReference (in GEOM_Object theReference, + in double theX, in double theY, in double theZ); + + /*! + * 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. + */ + GEOM_Object MakePointOnCurve (in GEOM_Object theRefCurve, + in double theParameter); + + /*! + * 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. + */ + GEOM_Object MakeVectorDXDYDZ (in double theDX, + in double theDY, + in double theDZ); + + /*! + * 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. + */ + GEOM_Object MakeVectorTwoPnt (in GEOM_Object thePnt1, in GEOM_Object thePnt2); + + /*! + * 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. + */ + GEOM_Object MakeLine (in GEOM_Object thePnt, in GEOM_Object theDir); + + /*! + * 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. + */ + GEOM_Object MakeLineTwoPnt (in GEOM_Object thePnt1, in GEOM_Object thePnt2); + + /*! + * 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. + */ + GEOM_Object MakePlaneThreePnt (in GEOM_Object thePnt1, + in GEOM_Object thePnt2, + in GEOM_Object thePnt3, + in double theTrimSize); + + /*! + * 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. + */ + GEOM_Object MakePlanePntVec (in GEOM_Object thePnt, + in GEOM_Object theVec, + in double theTrimSize); + + /*! + * 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. + */ + GEOM_Object MakePlaneFace (in GEOM_Object theFace, + in double theTrimSize); + + /*! + * Create a local coordinate system. + * \param theOX,theOY,theOZ Three coordinates of coordinate system origin. + * \param theXDX,theXDY,theXDZ Three components of OX direction + * \param theYDX,theYDY,theYDZ Three components of OY direction + * \return New GEOM_Object, containing the created coordinate system. + */ + GEOM_Object MakeMarker (in double theOX , in double theOY , in double theOZ, + in double theXDX, in double theXDY, in double theXDZ, + in double theYDX, in double theYDY, in double theYDZ); + }; + + interface GEOM_ITransformOperations : GEOM_IOperations + { + /*! + * Translate the given object along the vector, specified by its end points. + * \param theObject The object to be translated. + * \param thePoint1 Start point of translation vector. + * \param thePoint2 End point of translation vector. + * \return theObject. + */ + GEOM_Object TranslateTwoPoints (in GEOM_Object theObject, + in GEOM_Object thePoint1, + in GEOM_Object thePoint2); + + /*! + * 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. + */ + GEOM_Object TranslateTwoPointsCopy (in GEOM_Object theObject, + in GEOM_Object thePoint1, + in GEOM_Object thePoint2); + + /*! + * Translate the given object along the vector, specified by its components. + * \param theObject The object to be translated. + * \param theDX,theDY,theDZ Components of translation vector. + * \return theObject. + */ + GEOM_Object TranslateDXDYDZ (in GEOM_Object theObject, + in double theDX, in double theDY, in double theDZ); + + /*! + * 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. + */ + GEOM_Object TranslateDXDYDZCopy (in GEOM_Object theObject, + in double theDX, in double theDY, in double theDZ); + + + /*! + * Translate the given object along the given vector. + * \param theObject The object to be translated. + * \param theVector Translation vector, giving both direction and distance. + * \return theObject. + */ + GEOM_Object TranslateVector (in GEOM_Object theObject, + in GEOM_Object theVector); + + /*! + * Translate the given object along the given vector, + * creating its copy before the translation. + * \param theObject The object to be translated. + * \param theVector Translation vector, giving both direction and distance. + * \return New GEOM_Object, containing the translated object. + */ + GEOM_Object TranslateVectorCopy (in GEOM_Object theObject, + in GEOM_Object theVector); + + /*! + * 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. + */ + GEOM_Object MultiTranslate1D (in GEOM_Object theObject, + in GEOM_Object theVector, + in double theStep, + in long theNbTimes); + + /*! + * 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. + */ + GEOM_Object MultiTranslate2D (in GEOM_Object theObject, + in GEOM_Object theVector1, + in double theStep1, + in long theNbTimes1, + in GEOM_Object theVector2, + in double theStep2, + in long theNbTimes2); + + /*! + * Rotate the given object around the given axis on the given angle. + * \param theObject The object to be rotated. + * \param theAxis Rotation axis. + * \param theAngle Rotation angle in radians. + * \return theObject. + */ + GEOM_Object Rotate (in GEOM_Object theObject, + in GEOM_Object theAxis, + in double theAngle); + + /*! + * 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. + */ + GEOM_Object RotateCopy (in GEOM_Object theObject, + in GEOM_Object theAxis, + in double theAngle); + + /*! + * 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. + */ + GEOM_Object MultiRotate1D (in GEOM_Object theObject, + in GEOM_Object theAxis, + in long theNbTimes); + + /*! + * 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. + */ + GEOM_Object MultiRotate2D (in GEOM_Object theObject, + in GEOM_Object theAxis, + in double theAngle, + in long theNbTimes1, + in double theStep, + in long theNbTimes2); + + /*! + * Replace the given object by an object, + * symmetrical to it relatively the given plane. + * \param theObject The object to be mirrored. + * \param thePlane Plane of symmetry. + */ + GEOM_Object MirrorPlane (in GEOM_Object theObject, in GEOM_Object thePlane); + + /*! + * 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. + */ + GEOM_Object MirrorPlaneCopy (in GEOM_Object theObject, in GEOM_Object thePlane); + + /*! + * Replace the given object by an object, + * symmetrical to it relatively the given axis. + * \param theObject The object to be mirrored. + * \param theAxis Axis of symmetry. + * \return theObject. + */ + GEOM_Object MirrorAxis (in GEOM_Object theObject, in GEOM_Object theAxis); + + /*! + * 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 object. + */ + GEOM_Object MirrorAxisCopy (in GEOM_Object theObject, in GEOM_Object theAxis); + + /*! + * Replace the given object by an object, symmetrical to it relatively the given point. + * \param theObject The object to be mirrored. + * \param thePoint Point of symmetry. + * \return theObject. + */ + GEOM_Object MirrorPoint (in GEOM_Object theObject, in GEOM_Object thePoint); + + /*! + * 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 object. + */ + GEOM_Object MirrorPointCopy (in GEOM_Object theObject, in GEOM_Object thePoint); + + /*! + * Replace the given object by its offset. + * \param theObject The base object for the offset. + * \param theOffset Offset value. + * \return theObject. + */ + GEOM_Object OffsetShape (in GEOM_Object theObject, in double theOffset); + + /*! + * 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. + */ + GEOM_Object OffsetShapeCopy (in GEOM_Object theObject, in double theOffset); + + /*! + * Scale the given object by the factor. + * \param theObject The object to be scaled. + * \param thePoint Center point for scaling. + * \param theFactor Scaling factor value. + * \return theObject. + */ + GEOM_Object ScaleShape (in GEOM_Object theObject, in GEOM_Object thePoint, + in double theFactor); + + /*! + * 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. + */ + GEOM_Object ScaleShapeCopy (in GEOM_Object theObject, in GEOM_Object thePoint, + in double theFactor); + + /*! + * Modify the Location of the given object by LCS + */ + GEOM_Object PositionShape (in GEOM_Object theObject, + in GEOM_Object theStartLCS, + in GEOM_Object theEndLCS); + + /*! + * Modify the Location of the given object by LCS + * creating its copy before the setting + */ + GEOM_Object PositionShapeCopy (in GEOM_Object theObject, + in GEOM_Object theStartLCS, + in GEOM_Object theEndLCS); + }; + + /*! + * GEOM_I3DPrimOperations: Interface for 3D primitives creation + * Box, Cylinder, Cone, Sphere, Prism (extrusion), + * Pipe (extrusion along contour), Revolution, Solid (from shell). + */ + interface GEOM_I3DPrimOperations : GEOM_IOperations + { + /*! + * 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. + */ + GEOM_Object MakeBoxDXDYDZ (in double theDX, in double theDY, in double theDZ); + + /*! + * 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. + */ + GEOM_Object MakeBoxTwoPnt (in GEOM_Object thePnt1, in GEOM_Object thePnt2); + + /*! + * 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. + */ + GEOM_Object MakeCylinderRH (in double theR, in double theH); + + /*! + * 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. + */ + GEOM_Object MakeCylinderPntVecRH (in GEOM_Object thePnt, + in GEOM_Object theAxis, + in double theR, + in double theH); + + /*! + * 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. + */ + GEOM_Object MakeConeR1R2H (in double theR1, in double theR2, in double theH); + + /*! + * 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. + */ + GEOM_Object MakeConePntVecR1R2H (in GEOM_Object thePnt, + in GEOM_Object theAxis, + in double theR1, + in double theR2, + in double theH); + + /*! + * 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. + */ + GEOM_Object MakeTorusRR (in double theRMajor, + in double theRMinor); + + /*! + * 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. + */ + GEOM_Object MakeTorusPntVecRR (in GEOM_Object thePnt, + in GEOM_Object theVec, + in double theRMajor, + in double theRMinor); + + /*! + * Create a sphere with given radius at the origin of coordinate system. + * \param theR Sphere radius. + * \return New GEOM_Object, containing the created sphere. + */ + GEOM_Object MakeSphereR (in double theR); + + /*! + * Create a sphere with given center and radius. + * \param thePnt Sphere center. + * \param theR Sphere radius. + * \return New GEOM_Object, containing the created . + */ + GEOM_Object MakeSpherePntR (in GEOM_Object thePnt, in double theR); + + /*! + * 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. + */ + GEOM_Object MakePrismVecH (in GEOM_Object theBase, + in GEOM_Object theVec, + in double theH); + + /*! + * 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. + */ + GEOM_Object MakePrismTwoPnt (in GEOM_Object theBase, + in GEOM_Object thePoint1, + in GEOM_Object thePoint2); + + /*! + * 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. + */ + GEOM_Object MakePipe (in GEOM_Object theBase, in GEOM_Object thePath); + + /*! + * 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. + */ + GEOM_Object MakeRevolutionAxisAngle (in GEOM_Object theBase, + in GEOM_Object theAxis, + in double theAngle); + + /*! + * Create a filling from the given 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. + */ + GEOM_Object MakeFilling (in GEOM_Object theShape, + in long theMinDeg, in long theMaxDeg, + in double theTol2D, in double theTol3D, + in long theNbIter); + }; + + /*! + * GEOM_IShapesOperations: Interface for Shapes creation: + * Edge from two points, Wire from edges, Face from wire, + * Shell from faces, Solid from shells, Compound from shapes + */ + interface GEOM_IShapesOperations : GEOM_IOperations + { + /*! + * 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. + */ + GEOM_Object MakeEdge (in GEOM_Object thePnt1, in GEOM_Object thePnt2); + + /*! + * Create a wire from the set of edges and wires. + * \param theEdgesAndWires List of edge and/or wires. + * \return New GEOM_Object, containing the created wire. + */ + GEOM_Object MakeWire (in ListOfGO theEdgesAndWires); + + /*! + * 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. + */ + GEOM_Object MakeFace (in GEOM_Object theWire, in boolean isPlanarWanted); + + /*! + * 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. + */ + GEOM_Object MakeFaceWires (in ListOfGO theWires, in boolean isPlanarWanted); + + /*! + * 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. + */ + GEOM_Object MakeShell (in ListOfGO theFacesAndShells); + + /*! + * Create a solid, bounded by the given shell. + * \param theShell Bounding shell. + * \return New GEOM_Object, containing the created solid. + */ + GEOM_Object MakeSolidShell (in GEOM_Object theShell); + + /*! + * Create a solid, bounded by the given shells. + * \param theShells Bounding shells. + * \return New GEOM_Object, containing the created solid. + */ + GEOM_Object MakeSolidShells (in ListOfGO theShells); + + /*! + * Create a compound of the given shapes. + * \param theShapes List of shapes to put in compound. + * \return New GEOM_Object, containing the created compound. + */ + GEOM_Object MakeCompound (in ListOfGO theShapes); + + /*! + * 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. + */ + GEOM_Object MakeGlueFaces (in GEOM_Object theShape, in double theTolerance); + + /*! + * Explode a shape on subshapes of a given type. + * \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 sub-shapes of type theShapeType, contained in theShape. + */ + ListOfGO MakeExplode (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. + * Don't try to apply modification operations on them. + */ + GEOM_Object GetSubShape (in GEOM_Object theMainShape, + in long theID); + + /*! + * Count number of faces in the given shape. + * \param theShape Shape to count faces in. + * \return Number of faces in the given shape. + */ + long NumberOfFaces (in GEOM_Object theShape); + + /*! + * Count number of edges in the given shape. + * \param theShape Shape to count edges in. + * \return Number of edges in theShape. + */ + long NumberOfEdges (in GEOM_Object theShape); + + /*! + * Reverses an orientation the given shape. + * \param theShape Shape to be reversed. + * \return The reversed copy of theShape. + */ + GEOM_Object ChangeOrientation (in GEOM_Object theShape); + }; + + /*! + * GEOM_IBlocksOperations: Interface for Blocks construction + * Face from points or edges, Block from faces, + * Blocks multi-translation and multi-rotation + */ + interface GEOM_IBlocksOperations : GEOM_IOperations + { + /*! + * Creation of blocks + */ + + /*! + * Create a quadrangle face from four edges. Order of Edges is not + * important. It is not necessary that edges share the same vertex. + * \param theEdge1,theEdge2,theEdge3,theEdge4 Edges for the face bound. + * \return New GEOM_Object, containing the created face. + */ + GEOM_Object MakeQuad (in GEOM_Object theEdge1, + in GEOM_Object theEdge2, + in GEOM_Object theEdge3, + in GEOM_Object theEdge4); + + /*! + * Create a quadrangle face on two edges. + * The missing edges will be built by creating the shortest ones. + * \param theEdge1,theEdge2 Two opposite edges for the face. + * \return New GEOM_Object, containing the created face. + */ + GEOM_Object MakeQuad2Edges (in GEOM_Object theEdge1, + in GEOM_Object theEdge2); + + /*! + * Create a quadrangle face with specified corners. + * The missing edges will be built by creating the shortest ones. + * \param thePnt1,thePnt2,thePnt3,thePnt4 Corner vertices for the face. + * \return New GEOM_Object, containing the created face. + */ + GEOM_Object MakeQuad4Vertices (in GEOM_Object thePnt1, + in GEOM_Object thePnt2, + in GEOM_Object thePnt3, + in GEOM_Object thePnt4); + + /*! + * 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 theFace1-theFace6 Faces for the hexahedral solid. + * \return New GEOM_Object, containing the created solid. + */ + GEOM_Object MakeHexa (in GEOM_Object theFace1, + in GEOM_Object theFace2, + in GEOM_Object theFace3, + in GEOM_Object theFace4, + in GEOM_Object theFace5, + in GEOM_Object theFace6); + + /*! + * Create a hexahedral solid between two given faces. + * The missing faces will be built by creating the smallest ones. + * \param theFace1,theFace2 Two opposite faces for the hexahedral solid. + * \return New GEOM_Object, containing the created solid. + */ + GEOM_Object MakeHexa2Faces (in GEOM_Object theFace1, + in GEOM_Object theFace2); + + /*! + * Extract elements of blocks and blocks compounds + */ + + /*! + * 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. + */ + GEOM_Object GetPoint (in GEOM_Object theShape, + in double theX, + in double theY, + in double theZ, + in double theEpsilon); + + /*! + * 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. + */ + GEOM_Object GetEdge (in GEOM_Object theShape, + in GEOM_Object thePoint1, + in GEOM_Object thePoint2); + + /*! + * 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. + */ + GEOM_Object GetEdgeNearPoint (in GEOM_Object theShape, + in GEOM_Object thePoint); + + /*! + * 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. + */ + GEOM_Object GetFaceByPoints (in GEOM_Object theShape, + in GEOM_Object thePoint1, + in GEOM_Object thePoint2, + in GEOM_Object thePoint3, + in GEOM_Object thePoint4); + + /*! + * 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. + */ + GEOM_Object GetFaceByEdges (in GEOM_Object theShape, + in GEOM_Object theEdge1, + in GEOM_Object theEdge2); + + /*! + * 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. + */ + GEOM_Object GetOppositeFace (in GEOM_Object theBlock, + in GEOM_Object theFace); + + /*! + * 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. + */ + GEOM_Object GetFaceNearPoint (in GEOM_Object theShape, + in GEOM_Object thePoint); + + /*! + * 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. + */ + GEOM_Object GetFaceByNormale (in GEOM_Object theBlock, + in GEOM_Object theVector); + + /*! + * Extract blocks from blocks compounds + */ + + /*! + * Check, if the compound contains only specified blocks. + * \param theCompound The compound to check. + * \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 TRUE, if the given compound contains only blocks. + * \return theNbBlocks Number of specified blocks in theCompound. + */ + boolean IsCompoundOfBlocks (in GEOM_Object theCompound, + in long theMinNbFaces, + in long theMaxNbFaces, + out long theNbBlocks); + + /*! + * Enumeration of Blocks Compound defects. + */ + 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 */ + }; + + /*! + * Description of Blocks Compound defect: type and incriminated sub-shapes. + */ + struct BCError + { + BCErrorType error; + ListOfLong incriminated; + }; + + /*! + * Sequence of all Blocks Compound defects. + */ + typedef sequence BCErrors; + + /*! + * 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. + * \return theErrors Structure, containing discovered errors and incriminated sub-shapes. + */ + boolean CheckCompoundOfBlocks (in GEOM_Object theCompound, + out BCErrors theErrors); + + /*! + * Convert sequence of Blocks Compound errors, returned by + * CheckCompoundOfBlocks(), into string. + * \param theCompound The bad compound. + * \param theErrors The sequence of \a theCompound errors. + * \return String, describing all the errors in form, suitable for printing. + */ + string PrintBCErrors (in GEOM_Object theCompound, + in BCErrors theErrors); + + /*! + * 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. + */ + ListOfGO ExplodeCompoundOfBlocks (in GEOM_Object theCompound, + in long theMinNbFaces, + in long theMaxNbFaces); + + /*! + * 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. + */ + GEOM_Object GetBlockNearPoint (in GEOM_Object theCompound, + in GEOM_Object thePoint); + + /*! + * 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. + */ + GEOM_Object GetBlockByParts (in GEOM_Object theCompound, + in ListOfGO theParts); + + /*! + * 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. + */ + ListOfGO GetBlocksByParts (in GEOM_Object theCompound, + in ListOfGO theParts); + + /*! + * Operations on blocks with gluing of result + */ + + /*! + * Multi-transformate block and glue the result. + * Transformation is defined so, as to superpose theDirFace1 with theDirFace2. + * \param theBlock Hexahedral solid to be multi-transformed. + * \param theDirFace1 First direction face global index. + * \param theDirFace2 Second direction face global index. + * \param theNbTimes Quantity of transformations to be done. + * \note Global index of sub-shape can be obtained, using method + * GEOM_ILocalOperations.GetSubShapeIndex(). + * \return New GEOM_Object, containing the result shape. + */ + GEOM_Object MakeMultiTransformation1D (in GEOM_Object theBlock, + in long theDirFace1, + in long theDirFace2, + in long theNbTimes); + + /*! + * Multi-transformate block and glue the result. + * \param theBlock Hexahedral solid to be multi-transformed. + * \param theDirFace1U,theDirFace2U Direction faces for the first transformation. + * \param theDirFace1V,theDirFace2V Direction faces for the second transformation. + * \param theNbTimesU,theNbTimesV Quantity of transformations to be done. + * \return New GEOM_Object, containing the result shape. + */ + GEOM_Object MakeMultiTransformation2D (in GEOM_Object theBlock, + in long theDirFace1U, + in long theDirFace2U, + in long theNbTimesU, + in long theDirFace1V, + in long theDirFace2V, + in long theNbTimesV); + }; + + /*! + * GEOM_IBooleanOperations: Interface for boolean operations (Cut, Fuse, Common) + */ + interface GEOM_IBooleanOperations : GEOM_IOperations + { + /*! + * 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. + */ + GEOM_Object MakeBoolean (in GEOM_Object theShape1, + in GEOM_Object theShape2, + in long theOperation); + + /*! + * Perform partition operation. + * \param theShapes Shapes to be intersected. + * \param theTools Shapes to intersect theShapes. + * \param theKeepInside Shapes, outside which the results will be deleted. + * Each shape from theKeepInside must belong to theShapes also. + * \param theRemoveInside Shapes, inside which the results will be deleted. + * Each shape from theRemoveInside must belong to theShapes also. + * \param theLimit Type of resulting shapes (corresponding to TopAbs_ShapeEnum). + * \param theRemoveWebs If TRUE, perform Glue 3D algorithm. + * \param theMaterials Material indices for each shape. Make sence, only if theRemoveWebs is TRUE. + * \return New GEOM_Object, containing the result shapes. + */ + GEOM_Object MakePartition (in ListOfGO theShapes, + in ListOfGO theTools, + in ListOfGO theKeepInside, + in ListOfGO theRemoveInside, + in short theLimit, + in boolean theRemoveWebs, + in ListOfLong theMaterials); + + /*! + * 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. + */ + GEOM_Object MakeHalfPartition (in GEOM_Object theShape, + in GEOM_Object thePlane); + }; + + /*! + * GEOM_ICurvesOperations: Interface for curves creation. + * Polyline, Circle, Spline (Bezier and Interpolation) + */ + interface GEOM_ICurvesOperations : GEOM_IOperations + { + /*! + * 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. + */ + GEOM_Object MakeCirclePntVecR (in GEOM_Object thePnt, + in GEOM_Object theVec, + in double theR); + /*! + * Create a circle, passing through three given points + * \param thePnt1,thePnt2,thePnt3 Points, defining the circle. + * \return New GEOM_Object, containing the created circle. + */ + GEOM_Object MakeCircleThreePnt (in GEOM_Object thePnt1, + in GEOM_Object thePnt2, + in GEOM_Object thePnt3); + + /*! + * 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. + */ + GEOM_Object MakeEllipse (in GEOM_Object thePnt, + in GEOM_Object theVec, + in double theRMajor, + in double theRMinor); + + /*! + * 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. + */ + GEOM_Object MakeArc (in GEOM_Object thePnt1, + in GEOM_Object thePnt2, + in GEOM_Object thePnt3); + + /*! + * Create a polyline on the set of points. + * \param thePoints Sequence of points for the polyline. + * \return New GEOM_Object, containing the created polyline. + */ + GEOM_Object MakePolyline (in ListOfGO thePoints); + + /*! + * 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. + */ + GEOM_Object MakeSplineBezier (in ListOfGO thePoints); + + /*! + * 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. + */ + GEOM_Object MakeSplineInterpolation (in ListOfGO thePoints); + + /*! + * 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. + */ + GEOM_Object MakeSketcher (in string theCommand, in ListOfDouble theWorkingPlane); + }; + + /*! + * GEOM_ILocalOperations: Interface for fillet and chamfer creation. + */ + interface GEOM_ILocalOperations : GEOM_IOperations + { + /*! + * 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. + */ + GEOM_Object MakeFilletAll (in GEOM_Object theShape, + in double theR); + + /*! + * Perform a fillet on the specified edges of the given shape + * \param theShape Shape, to perform fillet on. + * \param theR Fillet radius. + * \param theEdges Global indices of edges to perform fillet on. + * \note Global index of sub-shape can be obtained, using method GetSubShapeIndex(). + * \return New GEOM_Object, containing the result shape. + */ + GEOM_Object MakeFilletEdges (in GEOM_Object theShape, + in double theR, + in ListOfLong theEdges); + + /*! + * Perform a fillet on all edges of the specified faces of the given shape. + * \param theShape Shape, to perform fillet on. + * \param theR Fillet radius. + * \param theFaces Global indices of faces to perform fillet on. + * \note Global index of sub-shape can be obtained, using method GetSubShapeIndex(). + * \return New GEOM_Object, containing the result shape. + */ + GEOM_Object MakeFilletFaces (in GEOM_Object theShape, + in double theR, + in ListOfLong theFaces); + + /*! + * 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. + */ + GEOM_Object MakeChamferAll (in GEOM_Object theShape, + in double theD); + + /*! + * 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 GetSubShapeIndex(). + * \return New GEOM_Object, containing the result shape. + */ + GEOM_Object MakeChamferEdge (in GEOM_Object theShape, + in double theD1, in double theD2, + in long theFace1, in long theFace2); + + /*! + * 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 GetSubShapeIndex(). + * \return New GEOM_Object, containing the result shape. + */ + GEOM_Object MakeChamferFaces (in GEOM_Object theShape, + in double theD1, in double theD2, + in ListOfLong theFaces); + + /*! + * 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 od the mesh, using to compute the section. + * \return New GEOM_Object, containing a section of \a theShape + * by a plane, corresponding to water level. + */ + GEOM_Object MakeArchimede (in GEOM_Object theShape, + in double theWeight, + in double theWaterDensity, + in double theMeshDeflection); + + /*! + * Get global index of \a theSubShape in \a theShape. + * \param theShape Main shape. + * \param theSubShape Sub-shape of the main shape. + * \return global index of \a theSubShape in \a theShape. + */ + long GetSubShapeIndex (in GEOM_Object theShape, in GEOM_Object theSubShape); + }; + + /*! + * GEOM_IHealingOperations: Interface for shape healing operations. + * Shape Processing, SuppressFaces, etc. + */ + interface GEOM_IHealingOperations : GEOM_IOperations + { + /*! + * Apply a sequence of Shape Healing operators to the given object. + * \param theShapes 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. + */ + GEOM_Object ProcessShape (in GEOM_Object theShapes, + in string_array theOperators, + in string_array theParameters, + in string_array theValues); + + /*! + * Get default sequence of operators, their parameters and parameters' values + * of Shape Process operation. In the current implementation the defaults are + * read from the file pointed by CSF_ShHealingDefaults environmental variable. + * \param theOperators Output. Default list of names of operators. + * \param theParameters Output. Default list of names of parameters. + * \param theValues Output. List of default values of parameters, in the same order + * as parameters are listed in \a theParameters list. + */ + void GetShapeProcessParameters (out string_array theOperators, + out string_array theParameters, + out string_array theValues); + + /*! + * 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. + */ + GEOM_Object SuppressFaces (in GEOM_Object theObject, in short_array theFaces); + + /*! + * 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. + */ + GEOM_Object CloseContour (in GEOM_Object theObject, in short_array theWires, + in boolean isCommonVertex); + + /*! + * 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. + */ + GEOM_Object RemoveIntWires (in GEOM_Object theObject, in short_array theWires); + + /*! + * 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. + */ + GEOM_Object FillHoles (in GEOM_Object theObject, in short_array theWires); + + /*! + * Sewing of the given object. + * \param theObject Shape to be processed. + * \param theTolerance Required tolerance value. + * \return New GEOM_Object, containing processed shape. + */ + GEOM_Object Sew (in GEOM_Object theObject, in double theTolerance); + + /*! + * 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. + */ + GEOM_Object DivideEdge (in GEOM_Object theObject, in short theEdgeIndex, + in double theValue, in boolean isByParameter); + + /*! + * 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. + * \param theClosedWires Output. Closed wires on the free boundary of the given shape. + * \param theOpenWires Output. Open wires on the free boundary of the given shape. + * \return FALSE, if an error(s) occured during the method execution. + */ + boolean GetFreeBoundary (in GEOM_Object theObject, + out ListOfGO theClosedWires, + out ListOfGO theOpenWires); + }; + + /*! + * GEOM_IInsertOperations: Interface for shape insert operations (like copy, import). + * + */ + interface GEOM_IInsertOperations : GEOM_IOperations + { + /*! + * Create a copy of the given object + */ + GEOM_Object MakeCopy (in GEOM_Object theOriginal); + + /*! + * 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 ImportTranslators() method. + */ + void Export (in GEOM_Object theObject, in string theFileName, in string theFormatName); + + /*! + * 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 ImportTranslators() method. + * \return New GEOM_Object, containing the imported shape. + */ + GEOM_Object Import (in string theFileName, in string theFormatName); + + /*! + * Get the supported import formats and corresponding patterns for File dialog. + * \param theFormats Output. List of formats, available for import. + * \param thePatterns Output. List of file patterns, corresponding to available formats. + * \return Returns available formats and patterns through the arguments. + */ + void ImportTranslators (out string_array theFormats, + out string_array thePatterns); + + /*! + * Get the supported export formats and corresponding patterns for File dialog. + * \param theFormats Output. List of formats, available for export. + * \param thePatterns Output. List of file patterns, corresponding to available formats. + * \return Returns available formats and patterns through the arguments. + */ + void ExportTranslators (out string_array theFormats, + out string_array thePatterns); + }; + + /*! + * GEOM_IMeasureOperations: Interface for measurement (distance, whatis) and + * properties calculation (like Centre of Mass, Inertia, etc.). + * + */ + interface GEOM_IMeasureOperations : GEOM_IOperations + { + /*! + * Get summarized length of all wires, + * area of surface and volume of the given shape. + * \param theShape Shape to define properties of. + * \param theLength Output. Summarized length of all wires of the given shape. + * \param theSurfArea Output. Area of surface of the given shape. + * \param theVolume Output. Volume of the given shape. + * \return Returns shape properties through the last three arguments. + */ + void GetBasicProperties (in GEOM_Object theShape, + out double theLength, + out double theSurfArea, + out double theVolume); + + /*! + * 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. + */ + GEOM_Object GetCentreOfMass (in GEOM_Object theShape); + + /*! + * Get inertia matrix and moments of inertia of theShape. + * \param theShape Shape to calculate inertia of. + * \param I(1-3)(1-3) Output. Components of the inertia matrix of the given shape. + * \param Ix,Iy,Iz Output. Moments of inertia of the given shape. + * \return Returns inertia through the last twelve arguments. + */ + void GetInertia (in GEOM_Object theShape, + out double I11, out double I12, out double I13, + out double I21, out double I22, out double I23, + out double I31, out double I32, out double I33, + out double Ix , out double Iy , out double Iz); + + /*! + * Get parameters of bounding box of the given shape + * \param theShape Shape to obtain bounding box of. + * \param Xmin,Xmax Output. Limits of shape along OX axis. + * \param Ymin,Ymax Output. Limits of shape along OY axis. + * \param Zmin,Zmax Output. Limits of shape along OZ axis. + * \return Returns parameters of bounding box through the last six arguments. + */ + void GetBoundingBox (in GEOM_Object theShape, + out double Xmin, out double Xmax, + out double Ymin, out double Ymax, + out double Zmin, out double Zmax); + + /*! + * Get min and max tolerances of sub-shapes of theShape + * \param theShape Shape, to get tolerances of. + * \param FaceMin,FaceMax Output. Min and max tolerances of the faces. + * \param EdgeMin,EdgeMax Output. Min and max tolerances of the edges. + * \param VertMin,VertMax Output. Min and max tolerances of the vertices. + * \return Returns shape tolerances through the last six arguments. + */ + void GetTolerance (in GEOM_Object theShape, + out double FaceMin, out double FaceMax, + out double EdgeMin, out double EdgeMax, + out double VertMin, out double VertMax); + + /*! + * Check a topology of the given shape. + * \param theShape Shape to check validity of. + * \param theDescription Output. Description of problems in the shape, if they are. + * \return TRUE, if the shape "seems to be valid" from the topological point of view. + */ + boolean CheckShape (in GEOM_Object theShape, + out string theDescription); + + /*! + * Obtain description of the given shape + * \param theShape Shape to be described. + * \return Description of the given shape. + */ + string WhatIs (in GEOM_Object theShape); + + /*! + * Get minimal distance between the given shapes. + * \param theShape1,theShape2 Shapes to find minimal distance between. + * \param X1,Y1,Z1 Output. Coordinates of point on theShape1, nearest to theShape2. + * \param X2,Y2,Z2 Output. Coordinates of point on theShape2, nearest to theShape1. + * \return Value of the minimal distance between the given shapes. + */ + double GetMinDistance (in GEOM_Object theShape1, in GEOM_Object theShape2, + out double X1, out double Y1, out double Z1, + out double X2, out double Y2, out double Z2); + + + /*! + * Get point coordinates + */ + void PointCoordinates (in GEOM_Object theShape, out double X, out double Y, out double Z); + }; + + + /*! + * GEOM_IGroupOperations: Interface for groups creation. + */ + interface GEOM_IGroupOperations : GEOM_IOperations + { + /*! + * 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 + */ + GEOM_Object CreateGroup (in GEOM_Object theMainShape, in long theShapeType); + + /*! + * 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 ILocalOperations.GetSubShapeIndex() to get an ID by the sub shape + */ + void AddObject (in GEOM_Object theGroup, in long theSubShapeId); + + /*! + * 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 ILocalOperations.GetSubShapeIndex() to get an ID by the sub shape + */ + void RemoveObject (in GEOM_Object theGroup, in long theSubShapeId); + + /*! + * Returns a type of sub objects stored in the group + * \param theGroup is a GEOM group which type is returned. + */ + long GetType (in GEOM_Object theGroup); + + /*! + * 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 + */ + GEOM_Object GetMainShape (in GEOM_Object theGroup); + + /*! + * 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 + */ + ListOfLong GetObjects (in GEOM_Object theGroup); + }; + + + /*! + * GEOM_Gen: Interface to access other GEOM interfaces. + * Also contains some methods to access and manage GEOM objects. + */ interface GEOM_Gen : Engines::Component,SALOMEDS::Driver { - typedef sequence ListOfIOR ; - typedef sequence ListOfGeomShapes ; - - //--------------------------------------------------------------// - // Studies Management // - //--------------------------------------------------------------// - void GetCurrentStudy(in long StudyID) ; - - short NbLabels(); - - //--------------------------------------------------------------// - // Shapes Management // - //--------------------------------------------------------------// - GEOM_Shape GetIORFromString (in string ior); - ListOfIOR GetReferencedObjects(in GEOM_Shape shape); - ListOfIOR GetObjects (in GEOM_Shape shape); - - //--------------------------------------------------------------// - // Structures // - //--------------------------------------------------------------// - PointStruct MakePointStruct(in double x, - in double y, - in double z) ; - DirStruct MakeDirection (in PointStruct p) ; - AxisStruct MakeAxisStruct(in double x, - in double y, - in double z, - in double vx, - in double vy, - in double vz) ; - - //------------------------------------------------------------// - // Boolean Operations // - //------------------------------------------------------------// - GEOM_Shape MakeBoolean (in GEOM_Shape shape1, - in GEOM_Shape shape2, - in long operation) raises (SALOME::SALOME_Exception) ; - - GEOM_Shape MakeFuse( in GEOM_Shape shape1, - in GEOM_Shape shape2) raises (SALOME::SALOME_Exception) ; - - //-----------------------------------------------------------// - // Advanced Operations // - //-----------------------------------------------------------// - GEOM_Shape Partition (in ListOfIOR ListShapes, - in ListOfIOR ListTools, - in ListOfIOR ListKeepInside, - in ListOfIOR ListRemoveInside, - in short Limit) - raises (SALOME::SALOME_Exception) ; - - - GEOM_Shape MakeFilling(in GEOM_Shape shape, - in short mindeg, - in short maxdeg, - in double tol3d, - in double tol2d, - in short nbiter) raises (SALOME::SALOME_Exception) ; - GEOM_Shape MakeSewing (in ListOfIOR ListShape, - in double precision) raises (SALOME::SALOME_Exception) ; - GEOM_Shape MakeSewingShape( in GEOM_Shape aShape, - in double precision ) raises (SALOME::SALOME_Exception); - - GEOM_Shape OrientationChange(in GEOM_Shape shape) raises (SALOME::SALOME_Exception) ; - - GEOM_Shape MakePlacedBox(in double x1, in double y1, in double z1, - in double delta1, in double delta2, in double delta3) raises (SALOME::SALOME_Exception) ; - GEOM_Shape MakePanel(in GEOM_Shape shape, - in short directiontype, - in double delta) raises (SALOME::SALOME_Exception) ; - GEOM_Shape MakeGlueFaces(in GEOM_Shape shape, - in double tol3d) raises (SALOME::SALOME_Exception) ; - - //-----------------------------------------------------------// - // Transformations Operations // - //-----------------------------------------------------------// - GEOM_Shape MakeCopy(in GEOM_Shape shape) raises (SALOME::SALOME_Exception) ; - - GEOM_Shape MakeTranslation(in GEOM_Shape shape, - in double x, - in double y, - in double z) raises (SALOME::SALOME_Exception) ; - GEOM_Shape MakeRotation(in GEOM_Shape shape, - in AxisStruct axis, - in double angle) raises (SALOME::SALOME_Exception) ; - GEOM_Shape MakeScaleTransform(in GEOM_Shape shape, - in PointStruct theCenterofScale, - in double factor) raises (SALOME::SALOME_Exception) ; - GEOM_Shape MakeMirrorByPlane(in GEOM_Shape shape, - in GEOM_Shape shapePlane) raises (SALOME::SALOME_Exception) ; - GEOM_Shape MakeRevolution(in GEOM_Shape shape, - in AxisStruct axis, - in double angle) raises (SALOME::SALOME_Exception) ; - GEOM_Shape MakePrism(in GEOM_Shape baseShape, - in PointStruct P1, - in PointStruct P2) raises (SALOME::SALOME_Exception) ; - GEOM_Shape MakePipe(in GEOM_Shape pathShape, - in GEOM_Shape baseShape) raises (SALOME::SALOME_Exception) ; - - //-----------------------------------------------------------// - // Patterns Construction // - //-----------------------------------------------------------// - GEOM_Shape MakeMultiTranslation1D(in GEOM_Shape shape, - in DirStruct dir, - in double step, - in short nbtimes) raises (SALOME::SALOME_Exception) ; - GEOM_Shape MakeMultiTranslation2D(in GEOM_Shape shape, - in DirStruct dir1, - in double step1, - in short nbtimes1, - in DirStruct dir2, - in double step2, - in short nbtimes2) raises (SALOME::SALOME_Exception) ; - GEOM_Shape MakeMultiRotation1D(in GEOM_Shape shape, - in DirStruct dir, - in PointStruct loc, - in short nbtimes) raises (SALOME::SALOME_Exception) ; - GEOM_Shape MakeMultiRotation2D(in GEOM_Shape shape, - in DirStruct dir, - in PointStruct loc, - in double ang, - in short nbtimes1, - in double step, - in short nbtimes2) raises (SALOME::SALOME_Exception) ; - - //-----------------------------------------------------------// - // Mesures Construction // - //-----------------------------------------------------------// - GEOM_Shape MakeCDG(in GEOM_Shape shape) raises (SALOME::SALOME_Exception) ; - - - //-----------------------------------------------------------// - // Primitives Construction // - //-----------------------------------------------------------// - - GEOM_Shape MakeVertex(in double x, - in double y, - in double z) raises (SALOME::SALOME_Exception) ; - GEOM_Shape MakeVector (in PointStruct pstruct1, - in PointStruct pstruct2) raises (SALOME::SALOME_Exception) ; - GEOM_Shape MakeLine (in PointStruct pstruct, - in DirStruct dstruct) raises (SALOME::SALOME_Exception) ; - GEOM_Shape MakePlane (in PointStruct pstruct, - in DirStruct dstruct, - in double trimsize) raises (SALOME::SALOME_Exception) ; - GEOM_Shape MakeCircle(in PointStruct pstruct, - in DirStruct dstruct, - in double radius) raises (SALOME::SALOME_Exception) ; - GEOM_Shape MakeArc(in PointStruct pInit, - in PointStruct pCircle, - in PointStruct pEnd) raises (SALOME::SALOME_Exception) ; - - GEOM_Shape MakeEllipse(in PointStruct pstruct, - in DirStruct dstruct, - in double major_radius, - in double minor_radius) raises (SALOME::SALOME_Exception) ; - - //-----------------------------------------------------------// - // Sketcher // - //-----------------------------------------------------------// - GEOM_Shape MakeSketcher (in string Cmd) raises (SALOME::SALOME_Exception) ; - - //-----------------------------------------------------------// - // Primitives Construction // - //-----------------------------------------------------------// - GEOM_Shape MakeBox (in double x1, - in double y1, - in double z1, - in double x2, - in double y2, - in double z2) raises (SALOME::SALOME_Exception) ; - GEOM_Shape MakeCylinder(in PointStruct pstruct, - in DirStruct dstruct, - in double radius, - in double height) raises (SALOME::SALOME_Exception) ; - - GEOM_Shape MakeSphere (in double x1, - in double y1, - in double z1, - in double radius) raises (SALOME::SALOME_Exception) ; - - GEOM_Shape MakeTorus(in PointStruct pstruct, - in DirStruct dstruct, - in double major_radius, - in double minor_radius) raises (SALOME::SALOME_Exception) ; - - GEOM_Shape MakeCone(in PointStruct pstruct, - in DirStruct dstruct, - in double radius1, - in double radius2, - in double height) raises (SALOME::SALOME_Exception) ; - - //-----------------------------------------------------------// - // Archimede // - //-----------------------------------------------------------// - GEOM_Shape Archimede(in GEOM_Shape shape, - in double Weight, - in double WaterDensity, - in double MeshingDeflection) raises (SALOME::SALOME_Exception); - - - //-----------------------------------------------------------// - // Build // - //-----------------------------------------------------------// - GEOM_Shape MakeEdge (in PointStruct pstruct1, - in PointStruct pstruct2) raises (SALOME::SALOME_Exception) ; - GEOM_Shape MakeWire (in ListOfIOR ListShape) raises (SALOME::SALOME_Exception) ; - GEOM_Shape MakeCompound (in ListOfIOR ListShape) raises (SALOME::SALOME_Exception) ; - GEOM_Shape MakeFace (in GEOM_Shape shapeWire, - in boolean wantplanarface) raises (SALOME::SALOME_Exception) ; - GEOM_Shape MakeFaces (in ListOfIOR ListShape, - in boolean wantplanarface) raises (SALOME::SALOME_Exception) ; - GEOM_Shape MakeShell (in ListOfIOR ListShape) raises (SALOME::SALOME_Exception) ; - GEOM_Shape MakeSolid (in ListOfIOR ListShape) raises (SALOME::SALOME_Exception) ; - - - //-----------------------------------------------------------// - // Subshapes Construction for GUI only // - //-----------------------------------------------------------// - GEOM_Shape SubShape(in GEOM_Shape shape, - in short ShapeType, - in GEOM_Shape::ListOfSubShapeID ListOfID) raises (SALOME::SALOME_Exception) ; - - //-----------------------------------------------------------// - // Subshapes Construction for TUI or GUI // - //-----------------------------------------------------------// - ListOfGeomShapes SubShapeAll(in GEOM_Shape shape, - in short ShapeType) raises (SALOME::SALOME_Exception) ; - - //-----------------------------------------------------------// - // Subshapes Construction - // Use it to have the same order of subshapes if their - // order may change as a result of reconstruction using - // boolean operations, fillet etc. - //-----------------------------------------------------------// - GEOM_Shape SubShapeSorted(in GEOM_Shape shape, - in short ShapeType, - in GEOM_Shape::ListOfSubShapeID ListOfID) raises (SALOME::SALOME_Exception) ; - - ListOfGeomShapes SubShapeAllSorted(in GEOM_Shape shape, - in short ShapeType) raises (SALOME::SALOME_Exception) ; - - //-----------------------------------------------------------// - // Fillet and Chamfer construction // - //-----------------------------------------------------------// - GEOM_Shape MakeFillet(in GEOM_Shape shape, - in double radius, - in short ShapeType, - in GEOM_Shape::ListOfSubShapeID ListOfID) raises (SALOME::SALOME_Exception) ; - - GEOM_Shape MakeChamfer(in GEOM_Shape shape, - in double d1, - in double d2, - in short ShapeType, - in GEOM_Shape::ListOfSubShapeID ListOfID) raises (SALOME::SALOME_Exception) ; - - //-----------------------------------------------------------// - // Suppress faces in a shape // - //-----------------------------------------------------------// - ListOfGeomShapes SuppressFaces(in GEOM_Shape shape, - in GEOM_Shape::ListOfSubShapeID ListOfID) raises (SALOME::SALOME_Exception) ; - - //-----------------------------------------------------------// - // Suppress a single hole in topology (face) shell or solid // - // : ListOfIdEndFace may be an empty list // - // : used only when hole traverses the topology // - //-----------------------------------------------------------// - GEOM_Shape SuppressHole(in GEOM_Shape shape, - in GEOM_Shape::ListOfSubShapeID ListOfIdFace, - in GEOM_Shape::ListOfSubShapeID ListOfIdWire, - in GEOM_Shape::ListOfSubShapeID ListOfIdEndFace ) raises (SALOME::SALOME_Exception) ; - - //-----------------------------------------------------------// - // Suppress one or more holes in a face or a shell // - //-----------------------------------------------------------// - GEOM_Shape SuppressHolesInFaceOrShell(in GEOM_Shape shapeFaceShell, - in GEOM_Shape::ListOfSubShapeID ListOfIdWires ) raises (SALOME::SALOME_Exception) ; - - //-----------------------------------------------------------// - // Import/Export // - //-----------------------------------------------------------// - GEOM_Shape ImportIGES(in string filename) raises (SALOME::SALOME_Exception) ; - GEOM_Shape ImportBREP(in string filename) raises (SALOME::SALOME_Exception) ; - GEOM_Shape ImportSTEP(in string filename) raises (SALOME::SALOME_Exception) ; - - void ExportIGES(in string filename,in GEOM_Shape theShape) raises (SALOME::SALOME_Exception) ; - void ExportBREP(in string filename,in GEOM_Shape theShape) raises (SALOME::SALOME_Exception) ; - void ExportSTEP(in string filename,in GEOM_Shape theShape) raises (SALOME::SALOME_Exception) ; - //-----------------------------------------------------------// - // Check Shape // - //-----------------------------------------------------------// - boolean CheckShape(in GEOM_Shape shape) raises (SALOME::SALOME_Exception) ; + /*! + * Undo/Redo Management + */ + + void Undo (in long theStudyID); + + void Redo (in long theStudyID); + + /*! + * Publishing manangement + * Adds in theStudy a object theObject under with a name theName, + * if theFather is not NULL the object is placed under thFather's SObject. + * Returns a SObject where theObject is placed + */ + SALOMEDS::SObject AddInStudy (in SALOMEDS::Study theStudy, + in GEOM_Object theObject, + in string theName, + in GEOM_Object theFather); + + /*! + * Methods to access interfaces for objects creation and transformation + */ + GEOM_IBasicOperations GetIBasicOperations (in long theStudyID) raises (SALOME::SALOME_Exception); + GEOM_ITransformOperations GetITransformOperations(in long theStudyID) raises (SALOME::SALOME_Exception); + GEOM_I3DPrimOperations GetI3DPrimOperations (in long theStudyID) raises (SALOME::SALOME_Exception); + GEOM_IShapesOperations GetIShapesOperations (in long theStudyID) raises (SALOME::SALOME_Exception); + GEOM_IBooleanOperations GetIBooleanOperations (in long theStudyID) raises (SALOME::SALOME_Exception); + GEOM_ICurvesOperations GetICurvesOperations (in long theStudyID) raises (SALOME::SALOME_Exception); + GEOM_ILocalOperations GetILocalOperations (in long theStudyID) raises (SALOME::SALOME_Exception); + GEOM_IHealingOperations GetIHealingOperations (in long theStudyID) raises (SALOME::SALOME_Exception); + GEOM_IInsertOperations GetIInsertOperations (in long theStudyID) raises (SALOME::SALOME_Exception); + GEOM_IMeasureOperations GetIMeasureOperations (in long theStudyID) raises (SALOME::SALOME_Exception); + GEOM_IBlocksOperations GetIBlocksOperations (in long theStudyID) raises (SALOME::SALOME_Exception); + GEOM_IGroupOperations GetIGroupOperations (in long theStudyID) raises (SALOME::SALOME_Exception); + + /*! + * Objects Management + */ + + /*! + * Removes the object from the GEOM component + * \param theObject is a GEOM object to be removed + */ + void RemoveObject (in GEOM_Object theObject); + + /*! + * Returns an object defined by the study and its entry in the GEOM component + * \param theStudyID is a SALOMEDS Study ID + * \param theEntry is an entry of the requested GEOM object in the GEOM component + * \note if the object has not previously been created a NULL GEOM object is returned + */ + GEOM_Object GetObject (in long theStudyID, in string theEntry); + + /*! + * Add a sub shape defined by indices in \a theIndices + * (contains unique IDs of sub shapes inside theMainShape) + * \note The sub shape GEOM_Objects can has ONLY ONE function. + * Don't try to apply modification operations on them. + * \note Internal method + */ + GEOM_Object AddSubShape (in GEOM_Object theMainShape, in ListOfLong theIndices); + + /*! + * GEOM object's IOR Management + */ + + /*! + * Returns a GEOM Object defined by its IOR + * \param theIOR a string containg an IOR of the requested GEOM object + */ + GEOM_Object GetIORFromString (in string theIOR); + /*! + * Returns a string which contains an IOR of the GEOM object + * \param theObject is a GEOM object which IOR is requested + */ + string GetStringFromIOR (in GEOM_Object theObject); }; }; diff --git a/idl/GEOM_Shape.idl b/idl/GEOM_Shape.idl deleted file mode 100644 index a75c3486c..000000000 --- a/idl/GEOM_Shape.idl +++ /dev/null @@ -1,85 +0,0 @@ -// 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 : GEOM_Shape.idl -// Author : Lucien PIGNOLONI - -#ifndef __GEOM_Shape__ -#define __GEOM_Shape__ - -module GEOM -{ - //-----------------------------------------------------------------// - // Topological types for shapes (like Open Cascade types) // - //-----------------------------------------------------------------// - - enum shape_type { COMPOUND, COMPSOLID, SOLID, SHELL, - FACE, WIRE, EDGE, VERTEX, SHAPE } ; - - //----------------------------------------------------------------// - // Structures // - //--------------------------------------------------- ------------// - struct PointStruct { double x; - double y; - double z; } ; - struct DirStruct { PointStruct PS ; } ; // analog to Occ Direction - - struct AxisStruct { double x; - double y; - double z; - double vx; - double vy; - double vz; } ; - - //----------------------------------------------------------------// - // interface GEOM_Shape methods // - //----------------------------------------------------------------// - - interface GEOM_Gen; - - interface GEOM_Shape - { - typedef sequence ListOfSubShapeID ; - typedef sequence TMPFile; - - attribute string Name; // (to set and get) the name of shape (= CORBA IOR converted into a string) - attribute string MainName; // (to set and get) the name of mainshape (= CORBA IOR converted into a string) - - attribute boolean IsMainShape; // (...) true if this is a main shape (not a sub shape) - attribute string ShapeId; // (...) the entry of the shape in geom/OCAF document - attribute string StudyShapeId; // (...) the entry of the shape in the study/OCAF when added - attribute ListOfSubShapeID Index; // (...) list of references (number) identifing the sub shapes in the main shape - attribute shape_type ShapeType; // (...) a topological type of the shape - - attribute string NameType; // (...) a topological/geometrical name of the shape - - //Transfer resulting shape to client as sequence of bytes - //client can extract shape from stream using BrepTools::Read function - TMPFile GetShapeStream(); - - // the generator engine - GEOM_Gen Engine(); - - // Get the TopoDS_Shape, for colocated case only - long getShape(); - }; -}; -#endif diff --git a/idl/GEOM_Superv.idl b/idl/GEOM_Superv.idl new file mode 100644 index 000000000..d50c74abe --- /dev/null +++ b/idl/GEOM_Superv.idl @@ -0,0 +1,375 @@ +// 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 : GEOM_Superv.idl +// Author : Lucien PIGNOLONI + +#ifndef __GEOM_SUPERV__ +#define __GEOM_SUPERV__ + +#include "GEOM_Gen.idl" + +module GEOM +{ + interface GEOM_Superv : Engines::Component,SALOMEDS::Driver + { + //-----------------------------------------------------------// + // Set current study ID // + //-----------------------------------------------------------// + void SetStudyID (in long theStudyID) ; + + //-----------------------------------------------------------// + // Primitives Construction : BasicOperations // + //-----------------------------------------------------------// + GEOM_Object MakePointXYZ (in double theX, + in double theY, + in double theZ) ; + GEOM_Object MakePointWithReference (in GEOM_Object theReference, + in double theX, + in double theY, + in double theZ) ; + GEOM_Object MakePointOnCurve (in GEOM_Object theRefCurve, + in double theParameter) ; + GEOM_Object MakeVectorDXDYDZ (in double theDX, + in double theDY, + in double theDZ) ; + GEOM_Object MakeVectorTwoPnt (in GEOM_Object thePnt1, + in GEOM_Object thePnt2) ; + GEOM_Object MakeLineTwoPnt (in GEOM_Object thePnt1, + in GEOM_Object thePnt2) ; + GEOM_Object MakePlaneThreePnt (in GEOM_Object thePnt1, + in GEOM_Object thePnt2, + in GEOM_Object thePnt3, + in double theTrimSize) ; + GEOM_Object MakePlanePntVec (in GEOM_Object thePnt, + in GEOM_Object theVec, + in double theTrimSize) ; + GEOM_Object MakePlaneFace (in GEOM_Object theFace, + in double theTrimSize) ; + GEOM_Object MakeMarker (in double theOX , in double theOY , in double theOZ, + in double theXDX, in double theXDY, in double theXDZ, + in double theYDX, in double theYDY, in double theYDZ) ; + + //-----------------------------------------------------------// + // Primitives Construction : 3DPrimOperations // + //-----------------------------------------------------------// + GEOM_Object MakeBox (in double theX1, + in double theY1, + in double theZ1, + in double theX2, + in double theY2, + in double theZ2) ; + GEOM_Object MakeBoxDXDYDZ (in double theDX, + in double theDY, + in double theDZ) ; + GEOM_Object MakeBoxTwoPnt (in GEOM_Object thePnt1, + in GEOM_Object thePnt2) ; + GEOM_Object MakeCylinderPntVecRH (in GEOM_Object thePnt, + in GEOM_Object theAxis, + in double theRadius, + in double theHeight) ; + GEOM_Object MakeCylinderRH (in double theR, + in double theH) ; + GEOM_Object MakeSphere (in double theX, + in double theY, + in double theZ, + in double theRadius) ; + GEOM_Object MakeSphereR (in double theR) ; + GEOM_Object MakeSpherePntR (in GEOM_Object thePnt, + in double theR) ; + GEOM_Object MakeTorusPntVecRR (in GEOM_Object thePnt, + in GEOM_Object theVec, + in double theRMajor, + in double theRMinor) ; + GEOM_Object MakeTorusRR (in double theRMajor, + in double theRMinor) ; + GEOM_Object MakeConePntVecR1R2H (in GEOM_Object thePnt, + in GEOM_Object theAxis, + in double theR1, + in double theR2, + in double theHeight) ; + GEOM_Object MakeConeR1R2H (in double theR1, + in double theR2, + in double theHeight) ; + GEOM_Object MakePrismVecH (in GEOM_Object theBase, + in GEOM_Object theVec, + in double theH) ; + GEOM_Object MakePrismTwoPnt (in GEOM_Object theBase, + in GEOM_Object thePoint1, + in GEOM_Object thePoint2) ; + GEOM_Object MakePipe (in GEOM_Object theBase, + in GEOM_Object thePath) ; + GEOM_Object MakeRevolutionAxisAngle (in GEOM_Object theBase, + in GEOM_Object theAxis, + in double theAngle) ; + GEOM_Object MakeFilling (in GEOM_Object theShape, + in long theMinDeg, in long theMaxDeg, + in double theTol2D, in double theTol3D, + in long theNbIter) ; + + //-----------------------------------------------------------// + // BooleanOperations // + //-----------------------------------------------------------// + GEOM_Object MakeBoolean (in GEOM_Object theShape1, + in GEOM_Object theShape2, + in long theOperation) ; + GEOM_Object MakeFuse (in GEOM_Object theShape1, + in GEOM_Object theShape2) ; + GEOM_Object MakePartition (in ListOfGO theShapes, + in ListOfGO theTools, + in ListOfGO theKeepInside, + in ListOfGO theRemoveInside, + in short theLimit, + in boolean theRemoveWebs, + in ListOfLong theMaterials) ; + GEOM_Object MakeHalfPartition (in GEOM_Object theShape, + in GEOM_Object thePlane) ; + + //-----------------------------------------------------------// + // InsertOperations // + //-----------------------------------------------------------// + GEOM_Object MakeCopy (in GEOM_Object theOriginal) ; + void Export (in GEOM_Object theObject, in string theFileName, in string theFormatName) ; + GEOM_Object Import (in string theFileName, in string theFormatName) ; + void ImportTranslators (out string_array theFormats, + out string_array thePatterns) ; + void ExportTranslators (out string_array theFormats, + out string_array thePatterns) ; + + //-----------------------------------------------------------// + // TransformOperations // + //-----------------------------------------------------------// + GEOM_Object TranslateTwoPoints (in GEOM_Object theObject, + in GEOM_Object thePoint1, + in GEOM_Object thePoint2) ; + GEOM_Object TranslateTwoPointsCopy (in GEOM_Object theObject, + in GEOM_Object thePoint1, + in GEOM_Object thePoint2) ; + GEOM_Object TranslateDXDYDZ (in GEOM_Object theObject, + in double theDX, + in double theDY, + in double theDZ) ; + GEOM_Object TranslateDXDYDZCopy (in GEOM_Object theObject, + in double theDX, + in double theDY, + in double theDZ) ; + GEOM_Object TranslateVector (in GEOM_Object theObject, + in GEOM_Object theVector) ; + GEOM_Object TranslateVectorCopy (in GEOM_Object theObject, + in GEOM_Object theVector) ; + GEOM_Object MultiTranslate1D (in GEOM_Object theObject, + in GEOM_Object theVector, + in double theStep, + in long theNbTimes) ; + GEOM_Object MultiTranslate2D (in GEOM_Object theObject, + in GEOM_Object theVector1, + in double theStep1, + in long theNbTimes1, + in GEOM_Object theVector2, + in double theStep2, + in long theNbTimes2) ; + GEOM_Object Rotate (in GEOM_Object theObject, + in GEOM_Object theAxis, + in double theAngle) ; + GEOM_Object RotateCopy (in GEOM_Object theObject, + in GEOM_Object theAxis, + in double theAngle) ; + GEOM_Object MultiRotate1D (in GEOM_Object theObject, + in GEOM_Object theAxis, + in long theNbTimes) ; + GEOM_Object MultiRotate2D (in GEOM_Object theObject, + in GEOM_Object theAxis, + in double theAngle, + in long theNbTimes1, + in double theStep, + in long theNbTimes2) ; + GEOM_Object MirrorPlane (in GEOM_Object theObject, in GEOM_Object thePlane) ; + GEOM_Object MirrorPlaneCopy (in GEOM_Object theObject, in GEOM_Object thePlane) ; + GEOM_Object MirrorAxis (in GEOM_Object theObject, in GEOM_Object theAxis) ; + GEOM_Object MirrorAxisCopy (in GEOM_Object theObject, in GEOM_Object theAxis) ; + GEOM_Object MirrorPoint (in GEOM_Object theObject, in GEOM_Object thePoint) ; + GEOM_Object MirrorPointCopy (in GEOM_Object theObject, in GEOM_Object thePoint) ; + GEOM_Object OffsetShape (in GEOM_Object theObject, in double theOffset) ; + GEOM_Object OffsetShapeCopy (in GEOM_Object theObject, in double theOffset) ; + GEOM_Object ScaleShape (in GEOM_Object theObject, in GEOM_Object thePoint, + in double theFactor) ; + GEOM_Object ScaleShapeCopy (in GEOM_Object theObject, in GEOM_Object thePoint, + in double theFactor) ; + GEOM_Object PositionShape (in GEOM_Object theObject, + in GEOM_Object theStartLCS, + in GEOM_Object theEndLCS) ; + GEOM_Object PositionShapeCopy (in GEOM_Object theObject, + in GEOM_Object theStartLCS, + in GEOM_Object theEndLCS) ; + + //-----------------------------------------------------------// + // ShapesOperations // + //-----------------------------------------------------------// + GEOM_Object MakeEdge (in GEOM_Object thePnt1, in GEOM_Object thePnt2) ; + GEOM_Object MakeWire (in ListOfGO theEdgesAndWires) ; + GEOM_Object MakeFace (in GEOM_Object theWire, in boolean isPlanarWanted) ; + GEOM_Object MakeFaceWires (in ListOfGO theWires, in boolean isPlanarWanted) ; + GEOM_Object MakeShell (in ListOfGO theFacesAndShells) ; + GEOM_Object MakeSolidShell (in GEOM_Object theShell) ; + GEOM_Object MakeSolidShells (in ListOfGO theShells) ; + GEOM_Object MakeCompound (in ListOfGO theShapes) ; + GEOM_Object MakeGlueFaces (in GEOM_Object theShape, in double theTolerance) ; + ListOfGO MakeExplode (in GEOM_Object theShape, + in long theShapeType, + in boolean isSorted) ; + long NumberOfFaces (in GEOM_Object theShape) ; + long NumberOfEdges (in GEOM_Object theShape) ; + GEOM_Object ChangeOrientation (in GEOM_Object theShape) ; + + //-----------------------------------------------------------// + // BlocksOperations // + //-----------------------------------------------------------// + GEOM_Object MakeQuad4Vertices (in GEOM_Object thePnt1, + in GEOM_Object thePnt2, + in GEOM_Object thePnt3, + in GEOM_Object thePnt4) ; + GEOM_Object MakeQuad (in GEOM_Object theEdge1, + in GEOM_Object theEdge2, + in GEOM_Object theEdge3, + in GEOM_Object theEdge4) ; + GEOM_Object MakeQuad2Edges (in GEOM_Object theEdge1, + in GEOM_Object theEdge2) ; + GEOM_Object MakeHexa (in GEOM_Object theFace1, + in GEOM_Object theFace2, + in GEOM_Object theFace3, + in GEOM_Object theFace4, + in GEOM_Object theFace5, + in GEOM_Object theFace6) ; + GEOM_Object MakeHexa2Faces (in GEOM_Object theFace1, + in GEOM_Object theFace2) ; + GEOM_Object GetPoint (in GEOM_Object theShape, + in double theX, + in double theY, + in double theZ, + in double theEpsilon) ; + GEOM_Object GetEdge (in GEOM_Object theShape, + in GEOM_Object thePoint1, + in GEOM_Object thePoint2) ; + GEOM_Object GetEdgeNearPoint (in GEOM_Object theShape, + in GEOM_Object thePoint) ; + GEOM_Object GetFaceByPoints (in GEOM_Object theShape, + in GEOM_Object thePoint1, + in GEOM_Object thePoint2, + in GEOM_Object thePoint3, + in GEOM_Object thePoint4) ; + GEOM_Object GetFaceByEdges (in GEOM_Object theShape, + in GEOM_Object theEdge1, + in GEOM_Object theEdge2) ; + GEOM_Object GetOppositeFace (in GEOM_Object theBlock, + in GEOM_Object theFace) ; + GEOM_Object GetFaceNearPoint (in GEOM_Object theShape, + in GEOM_Object thePoint) ; + GEOM_Object GetFaceByNormale (in GEOM_Object theBlock, + in GEOM_Object theVector) ; + boolean IsCompoundOfBlocks (in GEOM_Object theCompound, + in long theMinNbFaces, + in long theMaxNbFaces, + out long theNbBlocks) ; + boolean CheckCompoundOfBlocks (in GEOM_Object theCompound, + out GEOM_IBlocksOperations::BCErrors theErrors) ; + string PrintBCErrors (in GEOM_Object theCompound, + in GEOM_IBlocksOperations::BCErrors theErrors) ; + ListOfGO ExplodeCompoundOfBlocks (in GEOM_Object theCompound, + in long theMinNbFaces, + in long theMaxNbFaces) ; + GEOM_Object GetBlockNearPoint (in GEOM_Object theCompound, + in GEOM_Object thePoint) ; + GEOM_Object GetBlockByParts (in GEOM_Object theCompound, + in ListOfGO theParts) ; + ListOfGO GetBlocksByParts (in GEOM_Object theCompound, + in ListOfGO theParts) ; + GEOM_Object MakeMultiTransformation1D (in GEOM_Object theBlock, + in long theDirFace1, + in long theDirFace2, + in long theNbTimes) ; + GEOM_Object MakeMultiTransformation2D (in GEOM_Object theBlock, + in long theDirFace1U, + in long theDirFace2U, + in long theNbTimesU, + in long theDirFace1V, + in long theDirFace2V, + in long theNbTimesV) ; + + //-----------------------------------------------------------// + // CurvesOperations // + //-----------------------------------------------------------// + GEOM_Object MakeCirclePntVecR (in GEOM_Object thePnt, + in GEOM_Object theVec, + in double theR) ; + GEOM_Object MakeCircleThreePnt (in GEOM_Object thePnt1, + in GEOM_Object thePnt2, + in GEOM_Object thePnt3) ; + GEOM_Object MakeEllipse (in GEOM_Object thePnt, + in GEOM_Object theVec, + in double theRMajor, + in double theRMinor) ; + GEOM_Object MakeArc (in GEOM_Object thePnt1, + in GEOM_Object thePnt2, + in GEOM_Object thePnt3) ; + GEOM_Object MakePolyline (in ListOfGO thePoints) ; + GEOM_Object MakeSplineBezier (in ListOfGO thePoints) ; + GEOM_Object MakeSplineInterpolation (in ListOfGO thePoints) ; + GEOM_Object MakeSketcher (in string theCommand, in ListOfDouble theWorkingPlane) ; + + //-----------------------------------------------------------// + // LocalOperations // + //-----------------------------------------------------------// + GEOM_Object MakeFilletAll (in GEOM_Object theShape, + in double theR) ; + GEOM_Object MakeFilletEdges (in GEOM_Object theShape, + in double theR, + in ListOfLong theEdges) ; + GEOM_Object MakeFilletFaces (in GEOM_Object theShape, + in double theR, + in ListOfLong theFaces) ; + GEOM_Object MakeChamferAll (in GEOM_Object theShape, + in double theD) ; + GEOM_Object MakeChamferEdge (in GEOM_Object theShape, + in double theD1, in double theD2, + in long theFace1, in long theFace2) ; + GEOM_Object MakeChamferFaces (in GEOM_Object theShape, + in double theD1, in double theD2, + in ListOfLong theFaces) ; + GEOM_Object MakeArchimede (in GEOM_Object theShape, + in double theWeight, + in double theWaterDensity, + in double theMeshDeflection) ; + long GetSubShapeIndex (in GEOM_Object theShape, in GEOM_Object theSubShape) ; + + //-----------------------------------------------------------// + // GroupOperations // + //-----------------------------------------------------------// + GEOM_Object CreateGroup (in GEOM_Object theMainShape, in long theShapeType) ; + void AddObject (in GEOM_Object theGroup, in long theSubShapeId) ; + void RemoveObject (in GEOM_Object theGroup, in long theSubShapeId) ; + long GetType (in GEOM_Object theGroup) ; + GEOM_Object GetMainShape(in GEOM_Object theGroup) ; + ListOfLong GetObjects(in GEOM_Object theGroup) ; + + }; +}; + +#endif diff --git a/idl/Makefile.in b/idl/Makefile.in index d7d1cae79..72f11d7c6 100644 --- a/idl/Makefile.in +++ b/idl/Makefile.in @@ -11,8 +11,8 @@ VPATH=.:${KERNEL_ROOT_DIR}/idl/salome @COMMENCE@ IDL_FILES = \ - GEOM_Shape.idl \ - GEOM_Gen.idl + GEOM_Gen.idl \ + GEOM_Superv.idl PY_CLIENT_IDL = $(IDL_FILES) diff --git a/resources/GEOMCatalog.xml b/resources/GEOMCatalog.xml index 9c7aecccf..136e16d19 100644 --- a/resources/GEOMCatalog.xml +++ b/resources/GEOMCatalog.xml @@ -1,5 +1,5 @@ - + @@ -10,334 +10,4138 @@ - - - GEOM - Geometry - Geom - NRI - 1.0 - Geom component - Open CASCADE - 1 - ModuleGeom.png + + + GEOM + Geometry + Geom + NRI + 2.0.0 + Geom component - Open CASCADE + 1 + ModuleGeom.png - - - - GEOM - No comment + + + + GEOM + No comment - - - - InitGeomEngine - - - - 1 - - - long - StudyID - - - - - - Engines::GEOM_Gen - geomEngine - - - - + + + + + Undo + + + + 1 + + + + theStudyID + long + + + + + + + + + Redo + + + + 1 + + + + theStudyID + long + + + + + + + + + AddInStudy + + + + 1 + + + + theStudy + Study + + + + theObject + GEOM_Object + + + + theName + string + + + + theFather + GEOM_Object + + + + + + return + SObject + + + + + + + + GetIBasicOperations + + + + 1 + + + + theStudyID + long + + + + + + return + GEOM_IBasicOperations + + + + + + + + GetITransformOperations + + + + 1 + + + + theStudyID + long + + + + + + return + GEOM_ITransformOperations + + + + + + + + GetI3DPrimOperations + + + + 1 + + + + theStudyID + long + + + + + + return + GEOM_I3DPrimOperations + + + + + + + + GetIShapesOperations + + + + 1 + + + + theStudyID + long + + + + + + return + GEOM_IShapesOperations + + + + + + + + GetIBooleanOperations + + + + 1 + + + + theStudyID + long + + + + + + return + GEOM_IBooleanOperations + + + + + + + + GetICurvesOperations + + + + 1 + + + + theStudyID + long + + + + + + return + GEOM_ICurvesOperations + + + + + + + + GetILocalOperations + + + + 1 + + + + theStudyID + long + + + + + + return + GEOM_ILocalOperations + + + + + + + + GetIHealingOperations + + + + 1 + + + + theStudyID + long + + + + + + return + GEOM_IHealingOperations + + + + + + + + GetIInsertOperations + + + + 1 + + + + theStudyID + long + + + + + + return + GEOM_IInsertOperations + + + + + + + + GetIMeasureOperations + + + + 1 + + + + theStudyID + long + + + + + + return + GEOM_IMeasureOperations + + + + + + + + GetIBlocksOperations + + + + 1 + + + + theStudyID + long + + + + + + return + GEOM_IBlocksOperations + + + + + + + + GetIGroupOperations + + + + 1 + + + + theStudyID + long + + + + + + return + GEOM_IGroupOperations + + + + + + + + RemoveObject + + + + 1 + + + + theObject + GEOM_Object + + + + + + + + + GetObject + + + + 1 + + + + theStudyID + long + + + + theEntry + string + + + + + + return + GEOM_Object + + + + + + + + AddSubShape + + + + 1 + + + + theMainShape + GEOM_Object + + + + theIndices + ListOfLong + + + + + + return + GEOM_Object + + + + + + + + GetIORFromString + + + + 1 + + + + ior + string + + + + + + return + GEOM_Object + + + + + + + + GetStringFromIOR + + + + 1 + + + + theObject + GEOM_Object + + + + + + return + string + + + + + + + + hostname = localhost + + + + GEOM_Superv + GEOM_Superv + OTHER + asv + 2.1.0 + unknown + 1 + + + + GEOM_Superv + unknown + + + SetStudyID + asv + 2.1.0 + unknown + 0 + + + theStudyID + long + unknown + + + + + + + MakePointXYZ + asv + 2.1.0 + unknown + 0 + + + theX + double + unknown + + + theY + double + unknown + + + theZ + double + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakePointWithReference + asv + 2.1.0 + unknown + 0 + + + theReference + GEOM_Object + unknown + + + theX + double + unknown + + + theY + double + unknown + + + theZ + double + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakePointOnCurve + asv + 2.1.0 + unknown + 0 + + + theRefCurve + GEOM_Object + unknown + + + theParameter + double + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakeVectorDXDYDZ + asv + 2.1.0 + unknown + 0 + + + theDX + double + unknown + + + theDY + double + unknown + + + theDZ + double + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakeVectorTwoPnt + asv + 2.1.0 + unknown + 0 + + + thePnt1 + GEOM_Object + unknown + + + thePnt2 + GEOM_Object + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakeLineTwoPnt + asv + 2.1.0 + unknown + 0 + + + thePnt1 + GEOM_Object + unknown + + + thePnt2 + GEOM_Object + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakePlaneThreePnt + asv + 2.1.0 + unknown + 0 + + + thePnt1 + GEOM_Object + unknown + + + thePnt2 + GEOM_Object + unknown + + + thePnt3 + GEOM_Object + unknown + + + theTrimSize + double + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakePlanePntVec + asv + 2.1.0 + unknown + 0 + + + thePnt + GEOM_Object + unknown + + + theVec + GEOM_Object + unknown + + + theTrimSize + double + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakePlaneFace + asv + 2.1.0 + unknown + 0 + + + theFace + GEOM_Object + unknown + + + theTrimSize + double + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakeMarker + asv + 2.1.0 + unknown + 0 + + + theOX + double + unknown + + + theOY + double + unknown + + + theOZ + double + unknown + + + theXDX + double + unknown + + + theXDY + double + unknown + + + theXDZ + double + unknown + + + theYDX + double + unknown + + + theYDY + double + unknown + + + theYDZ + double + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakeBox + asv + 2.1.0 + unknown + 0 + + + theX1 + double + unknown + + + theY1 + double + unknown + + + theZ1 + double + unknown + + + theX2 + double + unknown + + + theY2 + double + unknown + + + theZ2 + double + unknown + + + + + return + GEOM_Object + unknown + + + + - MakeAxisStruct - - - - 1 + MakeBoxDXDYDZ + asv + 2.1.0 + unknown + 0 + theDX double - x - + unknown + theDY double - y - + unknown + theDZ double - z - + unknown + + + + return + GEOM_Object + unknown + + + + + + MakeBoxTwoPnt + asv + 2.1.0 + unknown + 0 + + + thePnt1 + GEOM_Object + unknown + + + thePnt2 + GEOM_Object + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakeCylinderPntVecRH + asv + 2.1.0 + unknown + 0 + + + thePnt + GEOM_Object + unknown + + + theAxis + GEOM_Object + unknown + + + theRadius + double + unknown + + + theHeight + double + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakeCylinderRH + asv + 2.1.0 + unknown + 0 + + + theR + double + unknown + + + theH + double + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakeSphere + asv + 2.1.0 + unknown + 0 + + theX double - vx - + unknown + theY double - vy - + unknown + theZ double - vz - + unknown + + + theRadius + double + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakeSphereR + asv + 2.1.0 + unknown + 0 + + + theR + double + unknown - AxisStruct - axis - + return + GEOM_Object + unknown - - - - MakePointStruct - - - - 1 - - - double - x - - - - double - y - - - - double - z - - - - - - PointStruct - point - - - - - - - MakeBox - NRI - 1.0 - test XML - 1 - - - - double - x1 - X coordinate - - - double - y1 - Y coordinate - - - double - z1 - Z coordinate - - - double - x2 - X coordinate - - - double - y2 - Y coordinate - - - double - z2 - Z coordinate - - - - - GEOM_Shape - shape - boite - - - - - - MakeSphere - NRI - 1.0 - test XML - 1 - - - - double - x1 - X coordinate - - - double - y1 - Y coordinate - - - double - z1 - Z coordinate - - - double - radius - Sphere Radius - - - - - GEOM_Shape - shape - sphere - - - - - - MakeTranslation - NRI - 1.0 - test XML - 1 - - - - GEOM_Shape - shape1 - Shape - - - double - x1 - .. - - - double - y1 - .. - - - double - z1 - .. - - - - - GEOM_Shape - shape - Result - - - - - - MakeCopy - NRI - 1.0 - test XML - 1 - - - - GEOM_Shape - shape1 - Shape - - - - - GEOM_Shape - shape - Result - - - - - - MakeBoolean - NRI - 1.0 - test XML - 1 - - - - GEOM_Shape - shape1 - Shape - - - GEOM_Shape - shape2 - Tools - - - long - operation - Operation Type - - - - - GEOM_Shape - shape - Result - - - - - - MakeFuse - NRI - 1.0 - test XML - 1 - - - - GEOM_Shape - shape1 - Shape - - - GEOM_Shape - shape2 - Tools - - - - - GEOM_Shape - shape - Result - - - - - - hostname = localhost - + + + + + MakeSpherePntR + asv + 2.1.0 + unknown + 0 + + + thePnt + GEOM_Object + unknown + + + theR + double + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakeTorusPntVecRR + asv + 2.1.0 + unknown + 0 + + + thePnt + GEOM_Object + unknown + + + theVec + GEOM_Object + unknown + + + theRMajor + double + unknown + + + theRMinor + double + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakeTorusRR + asv + 2.1.0 + unknown + 0 + + + theRMajor + double + unknown + + + theRMinor + double + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakeConePntVecR1R2H + asv + 2.1.0 + unknown + 0 + + + thePnt + GEOM_Object + unknown + + + theAxis + GEOM_Object + unknown + + + theR1 + double + unknown + + + theR2 + double + unknown + + + theHeight + double + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakeConeR1R2H + asv + 2.1.0 + unknown + 0 + + + theR1 + double + unknown + + + theR2 + double + unknown + + + theHeight + double + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakePrismVecH + asv + 2.1.0 + unknown + 0 + + + theBase + GEOM_Object + unknown + + + theVec + GEOM_Object + unknown + + + theH + double + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakePrismTwoPnt + asv + 2.1.0 + unknown + 0 + + + theBase + GEOM_Object + unknown + + + thePoint1 + GEOM_Object + unknown + + + thePoint2 + GEOM_Object + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakePipe + asv + 2.1.0 + unknown + 0 + + + theBase + GEOM_Object + unknown + + + thePath + GEOM_Object + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakeRevolutionAxisAngle + asv + 2.1.0 + unknown + 0 + + + theBase + GEOM_Object + unknown + + + theAxis + GEOM_Object + unknown + + + theAngle + double + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakeFilling + asv + 2.1.0 + unknown + 0 + + + theShape + GEOM_Object + unknown + + + theMinDeg + long + unknown + + + theMaxDeg + long + unknown + + + theTol2D + double + unknown + + + theTol3D + double + unknown + + + theNbIter + long + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakeBoolean + asv + 2.1.0 + unknown + 0 + + + theShape1 + GEOM_Object + unknown + + + theShape2 + GEOM_Object + unknown + + + theOperation + long + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakeFuse + asv + 2.1.0 + unknown + 0 + + + theShape1 + GEOM_Object + unknown + + + theShape2 + GEOM_Object + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakePartition + asv + 2.1.0 + unknown + 0 + + + theShapes + ListOfGO + unknown + + + theTools + ListOfGO + unknown + + + theKeepInside + ListOfGO + unknown + + + theRemoveInside + ListOfGO + unknown + + + theLimit + short + unknown + + + theRemoveWebs + boolean + unknown + + + theMaterials + ListOfLong + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakeHalfPartition + asv + 2.1.0 + unknown + 0 + + + theShape + GEOM_Object + unknown + + + thePlane + GEOM_Object + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakeCopy + asv + 2.1.0 + unknown + 0 + + + theOriginal + GEOM_Object + unknown + + + + + return + GEOM_Object + unknown + + + + + + Export + asv + 2.1.0 + unknown + 0 + + + theObject + GEOM_Object + unknown + + + theFileName + string + unknown + + + theFormatName + string + unknown + + + + + + + Import + asv + 2.1.0 + unknown + 0 + + + theFileName + string + unknown + + + theFormatName + string + unknown + + + + + return + GEOM_Object + unknown + + + + + + ImportTranslators + asv + 2.1.0 + unknown + 0 + + + + theFormats + string_array + unknown + + + thePatterns + string_array + unknown + + + + + + ExportTranslators + asv + 2.1.0 + unknown + 0 + + + + theFormats + string_array + unknown + + + thePatterns + string_array + unknown + + + + + + TranslateTwoPoints + asv + 2.1.0 + unknown + 0 + + + theObject + GEOM_Object + unknown + + + thePoint1 + GEOM_Object + unknown + + + thePoint2 + GEOM_Object + unknown + + + + + return + GEOM_Object + unknown + + + + + + TranslateTwoPointsCopy + asv + 2.1.0 + unknown + 0 + + + theObject + GEOM_Object + unknown + + + thePoint1 + GEOM_Object + unknown + + + thePoint2 + GEOM_Object + unknown + + + + + return + GEOM_Object + unknown + + + + + + TranslateDXDYDZ + asv + 2.1.0 + unknown + 0 + + + theObject + GEOM_Object + unknown + + + theDX + double + unknown + + + theDY + double + unknown + + + theDZ + double + unknown + + + + + return + GEOM_Object + unknown + + + + + + TranslateDXDYDZCopy + asv + 2.1.0 + unknown + 0 + + + theObject + GEOM_Object + unknown + + + theDX + double + unknown + + + theDY + double + unknown + + + theDZ + double + unknown + + + + + return + GEOM_Object + unknown + + + + + + TranslateVector + asv + 2.1.0 + unknown + 0 + + + theObject + GEOM_Object + unknown + + + theVector + GEOM_Object + unknown + + + + + return + GEOM_Object + unknown + + + + + + TranslateVectorCopy + asv + 2.1.0 + unknown + 0 + + + theObject + GEOM_Object + unknown + + + theVector + GEOM_Object + unknown + + + + + return + GEOM_Object + unknown + + + + + + MultiTranslate1D + asv + 2.1.0 + unknown + 0 + + + theObject + GEOM_Object + unknown + + + theVector + GEOM_Object + unknown + + + theStep + double + unknown + + + theNbTimes + long + unknown + + + + + return + GEOM_Object + unknown + + + + + + MultiTranslate2D + asv + 2.1.0 + unknown + 0 + + + theObject + GEOM_Object + unknown + + + theVector1 + GEOM_Object + unknown + + + theStep1 + double + unknown + + + theNbTimes1 + long + unknown + + + theVector2 + GEOM_Object + unknown + + + theStep2 + double + unknown + + + theNbTimes2 + long + unknown + + + + + return + GEOM_Object + unknown + + + + + + Rotate + asv + 2.1.0 + unknown + 0 + + + theObject + GEOM_Object + unknown + + + theAxis + GEOM_Object + unknown + + + theAngle + double + unknown + + + + + return + GEOM_Object + unknown + + + + + + RotateCopy + asv + 2.1.0 + unknown + 0 + + + theObject + GEOM_Object + unknown + + + theAxis + GEOM_Object + unknown + + + theAngle + double + unknown + + + + + return + GEOM_Object + unknown + + + + + + MultiRotate1D + asv + 2.1.0 + unknown + 0 + + + theObject + GEOM_Object + unknown + + + theAxis + GEOM_Object + unknown + + + theNbTimes + long + unknown + + + + + return + GEOM_Object + unknown + + + + + + MultiRotate2D + asv + 2.1.0 + unknown + 0 + + + theObject + GEOM_Object + unknown + + + theAxis + GEOM_Object + unknown + + + theAngle + double + unknown + + + theNbTimes1 + long + unknown + + + theStep + double + unknown + + + theNbTimes2 + long + unknown + + + + + return + GEOM_Object + unknown + + + + + + MirrorPlane + asv + 2.1.0 + unknown + 0 + + + theObject + GEOM_Object + unknown + + + thePlane + GEOM_Object + unknown + + + + + return + GEOM_Object + unknown + + + + + + MirrorPlaneCopy + asv + 2.1.0 + unknown + 0 + + + theObject + GEOM_Object + unknown + + + thePlane + GEOM_Object + unknown + + + + + return + GEOM_Object + unknown + + + + + + MirrorAxis + asv + 2.1.0 + unknown + 0 + + + theObject + GEOM_Object + unknown + + + theAxis + GEOM_Object + unknown + + + + + return + GEOM_Object + unknown + + + + + + MirrorAxisCopy + asv + 2.1.0 + unknown + 0 + + + theObject + GEOM_Object + unknown + + + theAxis + GEOM_Object + unknown + + + + + return + GEOM_Object + unknown + + + + + + MirrorPoint + asv + 2.1.0 + unknown + 0 + + + theObject + GEOM_Object + unknown + + + thePoint + GEOM_Object + unknown + + + + + return + GEOM_Object + unknown + + + + + + MirrorPointCopy + asv + 2.1.0 + unknown + 0 + + + theObject + GEOM_Object + unknown + + + thePoint + GEOM_Object + unknown + + + + + return + GEOM_Object + unknown + + + + + + OffsetShape + asv + 2.1.0 + unknown + 0 + + + theObject + GEOM_Object + unknown + + + theOffset + double + unknown + + + + + return + GEOM_Object + unknown + + + + + + OffsetShapeCopy + asv + 2.1.0 + unknown + 0 + + + theObject + GEOM_Object + unknown + + + theOffset + double + unknown + + + + + return + GEOM_Object + unknown + + + + + + ScaleShape + asv + 2.1.0 + unknown + 0 + + + theObject + GEOM_Object + unknown + + + thePoint + GEOM_Object + unknown + + + theFactor + double + unknown + + + + + return + GEOM_Object + unknown + + + + + + ScaleShapeCopy + asv + 2.1.0 + unknown + 0 + + + theObject + GEOM_Object + unknown + + + thePoint + GEOM_Object + unknown + + + theFactor + double + unknown + + + + + return + GEOM_Object + unknown + + + + + + PositionShape + asv + 2.1.0 + unknown + 0 + + + theObject + GEOM_Object + unknown + + + theStartLCS + GEOM_Object + unknown + + + theEndLCS + GEOM_Object + unknown + + + + + return + GEOM_Object + unknown + + + + + + PositionShapeCopy + asv + 2.1.0 + unknown + 0 + + + theObject + GEOM_Object + unknown + + + theStartLCS + GEOM_Object + unknown + + + theEndLCS + GEOM_Object + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakeEdge + asv + 2.1.0 + unknown + 0 + + + thePnt1 + GEOM_Object + unknown + + + thePnt2 + GEOM_Object + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakeWire + asv + 2.1.0 + unknown + 0 + + + theEdgesAndWires + ListOfGO + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakeFace + asv + 2.1.0 + unknown + 0 + + + theWire + GEOM_Object + unknown + + + isPlanarWanted + boolean + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakeFaceWires + asv + 2.1.0 + unknown + 0 + + + theWires + ListOfGO + unknown + + + isPlanarWanted + boolean + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakeShell + asv + 2.1.0 + unknown + 0 + + + theFacesAndShells + ListOfGO + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakeSolidShell + asv + 2.1.0 + unknown + 0 + + + theShell + GEOM_Object + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakeSolidShells + asv + 2.1.0 + unknown + 0 + + + theShells + ListOfGO + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakeCompound + asv + 2.1.0 + unknown + 0 + + + theShapes + ListOfGO + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakeGlueFaces + asv + 2.1.0 + unknown + 0 + + + theShape + GEOM_Object + unknown + + + theTolerance + double + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakeExplode + asv + 2.1.0 + unknown + 0 + + + theShape + GEOM_Object + unknown + + + theShapeType + long + unknown + + + isSorted + boolean + unknown + + + + + return + ListOfGO + unknown + + + + + + NumberOfFaces + asv + 2.1.0 + unknown + 0 + + + theShape + GEOM_Object + unknown + + + + + return + long + unknown + + + + + + NumberOfEdges + asv + 2.1.0 + unknown + 0 + + + theShape + GEOM_Object + unknown + + + + + return + long + unknown + + + + + + ChangeOrientation + asv + 2.1.0 + unknown + 0 + + + theShape + GEOM_Object + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakeQuad4Vertices + asv + 2.1.0 + unknown + 0 + + + thePnt1 + GEOM_Object + unknown + + + thePnt2 + GEOM_Object + unknown + + + thePnt3 + GEOM_Object + unknown + + + thePnt4 + GEOM_Object + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakeQuad + asv + 2.1.0 + unknown + 0 + + + theEdge1 + GEOM_Object + unknown + + + theEdge2 + GEOM_Object + unknown + + + theEdge3 + GEOM_Object + unknown + + + theEdge4 + GEOM_Object + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakeQuad2Edges + asv + 2.1.0 + unknown + 0 + + + theEdge1 + GEOM_Object + unknown + + + theEdge2 + GEOM_Object + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakeHexa + asv + 2.1.0 + unknown + 0 + + + theFace1 + GEOM_Object + unknown + + + theFace2 + GEOM_Object + unknown + + + theFace3 + GEOM_Object + unknown + + + theFace4 + GEOM_Object + unknown + + + theFace5 + GEOM_Object + unknown + + + theFace6 + GEOM_Object + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakeHexa2Faces + asv + 2.1.0 + unknown + 0 + + + theFace1 + GEOM_Object + unknown + + + theFace2 + GEOM_Object + unknown + + + + + return + GEOM_Object + unknown + + + + + + GetPoint + asv + 2.1.0 + unknown + 0 + + + theShape + GEOM_Object + unknown + + + theX + double + unknown + + + theY + double + unknown + + + theZ + double + unknown + + + theEpsilon + double + unknown + + + + + return + GEOM_Object + unknown + + + + + + GetEdge + asv + 2.1.0 + unknown + 0 + + + theShape + GEOM_Object + unknown + + + thePoint1 + GEOM_Object + unknown + + + thePoint2 + GEOM_Object + unknown + + + + + return + GEOM_Object + unknown + + + + + + GetEdgeNearPoint + asv + 2.1.0 + unknown + 0 + + + theShape + GEOM_Object + unknown + + + thePoint + GEOM_Object + unknown + + + + + return + GEOM_Object + unknown + + + + + + GetFaceByPoints + asv + 2.1.0 + unknown + 0 + + + theShape + GEOM_Object + unknown + + + thePoint1 + GEOM_Object + unknown + + + thePoint2 + GEOM_Object + unknown + + + thePoint3 + GEOM_Object + unknown + + + thePoint4 + GEOM_Object + unknown + + + + + return + GEOM_Object + unknown + + + + + + GetFaceByEdges + asv + 2.1.0 + unknown + 0 + + + theShape + GEOM_Object + unknown + + + theEdge1 + GEOM_Object + unknown + + + theEdge2 + GEOM_Object + unknown + + + + + return + GEOM_Object + unknown + + + + + + GetOppositeFace + asv + 2.1.0 + unknown + 0 + + + theBlock + GEOM_Object + unknown + + + theFace + GEOM_Object + unknown + + + + + return + GEOM_Object + unknown + + + + + + GetFaceNearPoint + asv + 2.1.0 + unknown + 0 + + + theShape + GEOM_Object + unknown + + + thePoint + GEOM_Object + unknown + + + + + return + GEOM_Object + unknown + + + + + + GetFaceByNormale + asv + 2.1.0 + unknown + 0 + + + theBlock + GEOM_Object + unknown + + + theVector + GEOM_Object + unknown + + + + + return + GEOM_Object + unknown + + + + + + IsCompoundOfBlocks + asv + 2.1.0 + unknown + 0 + + + theCompound + GEOM_Object + unknown + + + theMinNbFaces + long + unknown + + + theMaxNbFaces + long + unknown + + + + + theNbBlocks + long + unknown + + + return + boolean + unknown + + + + + + CheckCompoundOfBlocks + asv + 2.1.0 + unknown + 0 + + + theCompound + GEOM_Object + unknown + + + + + theErrors + BCErrors + unknown + + + return + boolean + unknown + + + + + + PrintBCErrors + asv + 2.1.0 + unknown + 0 + + + theCompound + GEOM_Object + unknown + + + theErrors + BCErrors + unknown + + + + + return + string + unknown + + + + + + ExplodeCompoundOfBlocks + asv + 2.1.0 + unknown + 0 + + + theCompound + GEOM_Object + unknown + + + theMinNbFaces + long + unknown + + + theMaxNbFaces + long + unknown + + + + + return + ListOfGO + unknown + + + + + + GetBlockNearPoint + asv + 2.1.0 + unknown + 0 + + + theCompound + GEOM_Object + unknown + + + thePoint + GEOM_Object + unknown + + + + + return + GEOM_Object + unknown + + + + + + GetBlockByParts + asv + 2.1.0 + unknown + 0 + + + theCompound + GEOM_Object + unknown + + + theParts + ListOfGO + unknown + + + + + return + GEOM_Object + unknown + + + + + + GetBlocksByParts + asv + 2.1.0 + unknown + 0 + + + theCompound + GEOM_Object + unknown + + + theParts + ListOfGO + unknown + + + + + return + ListOfGO + unknown + + + + + + MakeMultiTransformation1D + asv + 2.1.0 + unknown + 0 + + + theBlock + GEOM_Object + unknown + + + theDirFace1 + long + unknown + + + theDirFace2 + long + unknown + + + theNbTimes + long + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakeMultiTransformation2D + asv + 2.1.0 + unknown + 0 + + + theBlock + GEOM_Object + unknown + + + theDirFace1U + long + unknown + + + theDirFace2U + long + unknown + + + theNbTimesU + long + unknown + + + theDirFace1V + long + unknown + + + theDirFace2V + long + unknown + + + theNbTimesV + long + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakeCirclePntVecR + asv + 2.1.0 + unknown + 0 + + + thePnt + GEOM_Object + unknown + + + theVec + GEOM_Object + unknown + + + theR + double + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakeCircleThreePnt + asv + 2.1.0 + unknown + 0 + + + thePnt1 + GEOM_Object + unknown + + + thePnt2 + GEOM_Object + unknown + + + thePnt3 + GEOM_Object + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakeEllipse + asv + 2.1.0 + unknown + 0 + + + thePnt + GEOM_Object + unknown + + + theVec + GEOM_Object + unknown + + + theRMajor + double + unknown + + + theRMinor + double + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakeArc + asv + 2.1.0 + unknown + 0 + + + thePnt1 + GEOM_Object + unknown + + + thePnt2 + GEOM_Object + unknown + + + thePnt3 + GEOM_Object + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakePolyline + asv + 2.1.0 + unknown + 0 + + + thePoints + ListOfGO + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakeSplineBezier + asv + 2.1.0 + unknown + 0 + + + thePoints + ListOfGO + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakeSplineInterpolation + asv + 2.1.0 + unknown + 0 + + + thePoints + ListOfGO + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakeSketcher + asv + 2.1.0 + unknown + 0 + + + theCommand + string + unknown + + + theWorkingPlane + ListOfDouble + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakeFilletAll + asv + 2.1.0 + unknown + 0 + + + theShape + GEOM_Object + unknown + + + theR + double + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakeFilletEdges + asv + 2.1.0 + unknown + 0 + + + theShape + GEOM_Object + unknown + + + theR + double + unknown + + + theEdges + ListOfLong + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakeFilletFaces + asv + 2.1.0 + unknown + 0 + + + theShape + GEOM_Object + unknown + + + theR + double + unknown + + + theFaces + ListOfLong + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakeChamferAll + asv + 2.1.0 + unknown + 0 + + + theShape + GEOM_Object + unknown + + + theD + double + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakeChamferEdge + asv + 2.1.0 + unknown + 0 + + + theShape + GEOM_Object + unknown + + + theD1 + double + unknown + + + theD2 + double + unknown + + + theFace1 + long + unknown + + + theFace2 + long + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakeChamferFaces + asv + 2.1.0 + unknown + 0 + + + theShape + GEOM_Object + unknown + + + theD1 + double + unknown + + + theD2 + double + unknown + + + theFaces + ListOfLong + unknown + + + + + return + GEOM_Object + unknown + + + + + + MakeArchimede + asv + 2.1.0 + unknown + 0 + + + theShape + GEOM_Object + unknown + + + theWeight + double + unknown + + + theWaterDensity + double + unknown + + + theMeshDeflection + double + unknown + + + + + return + GEOM_Object + unknown + + + + + + GetSubShapeIndex + asv + 2.1.0 + unknown + 0 + + + theShape + GEOM_Object + unknown + + + theSubShape + GEOM_Object + unknown + + + + + return + long + unknown + + + + + + CreateGroup + asv + 2.1.0 + unknown + 0 + + + theMainShape + GEOM_Object + unknown + + + theShapeType + long + unknown + + + + + return + GEOM_Object + unknown + + + + + + AddObject + asv + 2.1.0 + unknown + 0 + + + theGroup + GEOM_Object + unknown + + + theSubShapeId + long + unknown + + + + + + + RemoveObject + asv + 2.1.0 + unknown + 0 + + + theGroup + GEOM_Object + unknown + + + theSubShapeId + long + unknown + + + + + + + GetType + asv + 2.1.0 + unknown + 0 + + + theGroup + GEOM_Object + unknown + + + + + return + long + unknown + + + + + + GetMainShape + asv + 2.1.0 + unknown + 0 + + + theGroup + GEOM_Object + unknown + + + + + return + GEOM_Object + unknown + + + + + + GetObjects + asv + 2.1.0 + unknown + 0 + + + theGroup + GEOM_Object + unknown + + + + + return + ListOfLong + unknown + + + + + + + diff --git a/resources/GEOM_en.xml b/resources/GEOM_en.xml index aba68d130..b2e238212 100644 --- a/resources/GEOM_en.xml +++ b/resources/GEOM_en.xml @@ -17,18 +17,8 @@ - - - - - - - - - - - - + + @@ -48,10 +38,12 @@ - + + + @@ -70,6 +62,22 @@ + + + + + + + + + + + + + + + + @@ -82,8 +90,8 @@ - + @@ -95,13 +103,15 @@ - + - - + + + + - - + + @@ -109,28 +119,45 @@ + + + + + + + + + + + - - + - + + + + + + + + - - + + - - + + @@ -150,8 +177,8 @@ - - + @@ -162,15 +189,18 @@ + - - - - - + + + + + + + @@ -184,9 +214,11 @@ + + @@ -195,7 +227,7 @@ - + @@ -212,34 +244,66 @@ - + - - + + + + - - + + - - - - - - - + + + + + + + + + + + + + - + + + + + + + + - - + + + + + + + + + + + + + + + + + + + diff --git a/resources/GEOM_fr.xml b/resources/GEOM_fr.xml index b5c4eb07e..b353c215f 100644 --- a/resources/GEOM_fr.xml +++ b/resources/GEOM_fr.xml @@ -17,15 +17,15 @@ - - - + + + - - - + + + @@ -69,15 +69,16 @@ + - + - - - - - - + + + + + + @@ -93,13 +94,15 @@ - + - - + + + + - - + + @@ -209,13 +212,15 @@ - + - - + + + + - - + + diff --git a/resources/ImportExport b/resources/ImportExport new file mode 100644 index 000000000..574e0e2e3 --- /dev/null +++ b/resources/ImportExport @@ -0,0 +1,14 @@ +Import: BREP|IGES|STEP +Export: BREP|IGES|STEP + +BREP.Import: libBREPImport.so +BREP.Export: libBREPExport.so +BREP.Pattern: BREP Files ( *.brep ) + +IGES.Import: libIGESImport.so +IGES.Export: libIGESExport.so +IGES.Pattern: IGES Files ( *.iges *.igs ) + +STEP.Import: libSTEPImport.so +STEP.Export: libSTEPExport.so +STEP.Pattern: STEP Files ( *.step *.stp ) diff --git a/resources/ShHealing b/resources/ShHealing new file mode 100644 index 000000000..46edb31b3 --- /dev/null +++ b/resources/ShHealing @@ -0,0 +1,251 @@ + +!-------------------------------------------------------------------- +! Parameters for Shape Healing +!-------------------------------------------------------------------- + +ShapeProcess.exec.op : FixShape,FixFaceSize,DropSmallEdges,SameParameter + +ShapeProcess.SplitAngle.Angle : 3.1415928 +ShapeProcess.SplitAngle.MaxTolerance : 0.1 +ShapeProcess.SplitAngle.SegmentSurfaceMode : 1 + +ShapeProcess.SplitClosedFaces.NbSplitPoints : 1 +ShapeProcess.SplitClosedFaces.CloseTolerance : 0.05 +ShapeProcess.SplitClosedFaces.MaxTolerance : 0.1 +ShapeProcess.SplitClosedFaces.SegmentSurfaceMode : 1 + +ShapeProcess.FixFaceSize.Tolerance : 0.05 + +ShapeProcess.DropSmallEdges.Tolerance3d : 0.05 + +ShapeProcess.BSplineRestriction.SurfaceMode : 1 +ShapeProcess.BSplineRestriction.Curve3dMode : 1 +ShapeProcess.BSplineRestriction.Curve2dMode : 1 +ShapeProcess.BSplineRestriction.OffsetSurfaceMode : 1 +ShapeProcess.BSplineRestriction.OffsetCurve3dMode : 1 +ShapeProcess.BSplineRestriction.OffsetCurve2dMode : 1 +ShapeProcess.BSplineRestriction.LinearExtrusionMode : 1 +ShapeProcess.BSplineRestriction.RevolutionMode : 1 +ShapeProcess.BSplineRestriction.Tolerance3d : 1e-3 +ShapeProcess.BSplineRestriction.Tolerance2d : 1e-5 +ShapeProcess.BSplineRestriction.Continuity3d : C1 +ShapeProcess.BSplineRestriction.Continuity2d : C1 +ShapeProcess.BSplineRestriction.RequiredDegree : 15 +ShapeProcess.BSplineRestriction.RequiredNbSegments : 100 +ShapeProcess.BSplineRestriction.PreferDegree : 1 +ShapeProcess.BSplineRestriction.RationalToPolynomial : 1 +ShapeProcess.BSplineRestriction.MaxDegree : 15 +ShapeProcess.BSplineRestriction.MaxNbSegments : 10000 +ShapeProcess.BSplineRestriction.SegmentSurfaceMode : 1 +ShapeProcess.BSplineRestriction.ConvCurve3dMode : 0 +ShapeProcess.BSplineRestriction.ConvCurve2dMode : 0 +ShapeProcess.BSplineRestriction.PlaneMode : 0 +ShapeProcess.BSplineRestriction.BezierMode : 0 + +ShapeProcess.SplitContinuity.Tolerance3d :1.e-3 +ShapeProcess.SplitContinuity.SurfaceContinuity :C0 +ShapeProcess.SplitContinuity.CurveContinuity :C1 + +ShapeProcess.ToBezier.EdgeMode : 0 +ShapeProcess.ToBezier.SurfaceMode : 1 +ShapeProcess.ToBezier.PlaneMode : 1 +ShapeProcess.ToBezier.RevolutionMode : 1 +ShapeProcess.ToBezier.ExtrusionMode : 1 +ShapeProcess.ToBezier.BSplineMode : 1 +ShapeProcess.ToBezier.Curve3dMode : 1 +ShapeProcess.ToBezier.Curve2dMode : 1 +ShapeProcess.ToBezier.Line3dMode : 1 +ShapeProcess.ToBezier.Circle3dMode : 1 +ShapeProcess.ToBezier.Conic3dMode : 1 +ShapeProcess.ToBezier.MaxTolerance : 0.1 +ShapeProcess.ToBezier.SegmentSurfaceMode : 1 +ShapeProcess.ToBezier.MinCurveLength : 0.05 + +ShapeProcess.FixShape.Tolerance3d : 1.e-7 +ShapeProcess.FixShape.MaxTolerance3d : 1 +ShapeProcess.FixShape.MinTolerance3d : 1.e-7 +ShapeProcess.FixShape.FixFreeShellMode : -1 +ShapeProcess.FixShape.FixFreeFaceMode : -1 +ShapeProcess.FixShape.FixFreeWireMode : -1 +ShapeProcess.FixShape.FixSameParameterMode : -1 +ShapeProcess.FixShape.FixSolidMode : -1 +ShapeProcess.FixShape.FixShellMode : -1 +ShapeProcess.FixShape.FixFaceMode : -1 +ShapeProcess.FixShape.FixWireMode : -1 +ShapeProcess.FixShape.FixOrientationMode : -1 +ShapeProcess.FixShape.FixMissingSeamMode : -1 +ShapeProcess.FixShape.FixSmallAreaWireMode : -1 +ShapeProcess.FixShape.ModifyTopologyMode : 0 +ShapeProcess.FixShape.ModifyGeometryMode : 1 +ShapeProcess.FixShape.ClosedWireMode : 1 +ShapeProcess.FixShape.PreferencePCurveMode : 1 +ShapeProcess.FixShape.FixReorderMode : -1 +ShapeProcess.FixShape.FixSmallMode : -1 +ShapeProcess.FixShape.FixConnectedMode : -1 +ShapeProcess.FixShape.FixEdgeCurvesMode : -1 +ShapeProcess.FixShape.FixDegeneratedMode : -1 +ShapeProcess.FixShape.FixLackingMode : -1 +ShapeProcess.FixShape.FixSelfIntersectionMode : -1 +ShapeProcess.FixShape.FixReversed2dMode : -1 +ShapeProcess.FixShape.FixRemovePCurveMode : -1 +ShapeProcess.FixShape.FixRemoveCurve3dMode : -1 +ShapeProcess.FixShape.FixAddPCurveMode : -1 +ShapeProcess.FixShape.FixAddCurve3dMode : -1 +ShapeProcess.FixShape.FixSeamMode : -1 +ShapeProcess.FixShape.FixShiftedMode : -1 +ShapeProcess.FixShape.FixEdgeSameParameterMode : 0 +ShapeProcess.FixShape.FixSelfIntersectingEdgeMode : -1 +ShapeProcess.FixShape.FixIntersectingEdgesMode : -1 +ShapeProcess.FixShape.FixNonAdjacentIntersectingEdgesMode : -1 +ShapeProcess.FixShape.FixIntersectingWiresMode : -1 +ShapeProcess.FixShape.FixLoopWiresMode : -1 +ShapeProcess.FixShape.CreateOpenSolidMode :0 + +ShapeProcess.SameParameter.Force : 0 +ShapeProcess.SameParameter.Tolerance3d : 1.e-7 + +!=========================================================================== +! Description of parameters for Operations +!=========================================================================== +! .MaxTolerance : Maximal tolerance for comparing curves, points which is +! used by splitting tools. The tools that are used this +! parameter are the following: SplitAngle, SplitClosedFaces, +! ToBezier. This value should be the same for all tools in +! one sequence. To redefine default value uncomment +! appropriate line in each operator. +! .SegmentSurfaceMode : Mode for limiting surface by UV boundaries of face that +! is based on this surface. If flag is 1 the surface is +! limited. This mode is used by splitting tools (SplitAngle, +! SplitClosedFaces, ToBezier). This value should be the same +! for all tools in one sequence. To redefine default value +! uncomment appropriate line in each operator. +! BSplineRestriction : Approximation of general B-Spline and Bezier with particular B-Spline +! BSplineRestriction.ConvCurve3dMode : Mode of conversion of any 3D curve to BSpline and approximation, +! BSplineRestriction.ConvCurve2dMode : Mode of conversion of any 2D curve to BSpline and approximation, +! BSplineRestriction.PlaneMode : Mode of conversion of Geom_Plane to BSpline surface, +! BSplineRestriction.BezierMode : Mode of conversion of Besier surface to BSpline and approximation, +! BSplineRestriction.SurfaceMode : Mode of approximation of surfaces if restriction is necessary, yes/no +! BSplineRestriction.Curve3dMode : Mode of approximation of 3D curves if restriction is necessary, yes/no +! BSplineRestriction.Curve2dMode : Mode of approximation of 2D curves if restriction is necessary, yes/no +! BSplineRestriction.OffsetSurfaceMode : Mode of conversion of offset surfaces to BSpline surface, yes/no +! : Yes - surface is converted to BSpline surface +! : No - basis surface is processed but offset surface is kept. +! : This mode acts if BSplineRestriction.SurfaceMode is yes. +! BSplineRestriction.LinearExtrusionMode: Mode of conversion of linear extrusion surfaces to BSpline surface, yes/no +! : Yes - surface is converted to BSpline surface +! : No - basis curve is processed but extrusion surface is kept. +! : This mode acts if BSplineRestriction.SurfaceMode is yes. +! BSplineRestriction.RevolutionMode : Mode of conversion surfaces of revolution to BSpline surface, yes/no +! : Yes - surface is converted to BSpline surface +! : No - basis curve is processed but revolution surface is kept. +! : This mode acts if BSplineRestriction.SurfaceMode is yes. +! BSplineRestriction.OffsetCurve3dMode : Mode of conversion of 3d offset curves to BSpline curves, yes/no +! : Yes - curve is converted to BSpline curve +! : No - basis curve is processed but offset curve is kept. +! : This mode acts if BSplineRestriction.Curve3dMode is yes. +! BSplineRestriction.OffsetCurve2dMode : Mode of conversion of 2d offset curves to BSpline curves, yes/no +! : Yes - curve is converted to BSpline curve +! : No - basis curve is processed but offset curve is kept. +! : This mode acts if BSplineRestriction.Curve2dMode is yes. +! BSplineRestriction.Tolerance3d : Tolerance of 3D approximation +! BSplineRestriction.Tolerance2d : Tolerance of 2D approximation +! BSplineRestriction.Continuity3d : Required continuity of 3D geometry +! BSplineRestriction.Continuity2d : Required continuity of 2D geometry +! BSplineRestriction.RequiredDegree : Required degree of B-Spline +! BSplineRestriction.RequiredNbSegments : Required maximum number of segments of B-Spline +! BSplineRestriction.PreferDegree : Preference between requirement to degree and maximum number of segments, true/false +! BSplineRestriction.RationalToPolynomial: Mode of conversion of rational B-Spline to polynomial, yes/no +! BSplineRestriction.MaxDegree : Maximum allowed degree of B-Spline +! BSplineRestriction.MaxNbSegments : Maximum allowed number of segments in a B-Spline + +! DirectFaces : Conversion of elementary surface in left-handed coordinate system into right-handed +! no parameters + +! ElementaryToRevolution : Conversion of elementary revolutive surface into general surface of revolution +! no parameters + +! SameParameter : Conversion of edge to be SameRange and SameParameter +! SameParameter.Force : Mode of forced invoking, true/false +! SameParameter.Tolerance3d : 3D tolerance + +! SplitAngle : Split revolutive surface (elementary and general) into several surfaces +! SplitAngle.Angle : Maximum angle of revolution, radian + +! SplitClosedFaces : Split faces that have seam-edge or geometrically closed on closed surface. +! SplitClosedFaces.NbSplitPoints : Number of cuttings (number of resulting faces will be NbSplitPoints+1) +! SplitClosedFaces.CloseTolerance : Precision to define geometric closure. + +! SplitContinuity : Correction or split shapes to have speicified continuity +! SplitContinuity.Tolerance3d : 3D tolerance for correction of geometry +! SplitContinuity.SurfaceContinuity : Required continuity for surfaces +! SplitContinuity.CurveContinuity : Required continuity for curves + +! ToBezier : Conversion of geometry into Bezier +! ToBezier.SurfaceMode : Mode of conversion of surfaces, yes/no +! ToBezier.PlaneMode : Mode of conversion of Planes,yes/no. This mode acts if SurfaceMode is yes. +! ToBezier.RevolutionMode : Mode of conversion of Surfaces of Revolution (generatrix to bezier), yes/no. +! This mode acts if SurfaceMode is yes. +! ToBezier.ExtrusionMode : Mode of conversion of Surfaces of Extrusion (whole surface not only generatrix), yes/no. +! This mode acts if SurfaceMode is yes. +! ToBezier.BSplineMode : Mode of conversion of BSpline Surfaces, yes/no. This mode acts if SurfaceMode is yes. +! ToBezier.EdgeMode : Mode of translation edges (0- Free,1 - Shared,2- Both) +! : .Default - Free. Acts on translation curves 3d . +| : If it is 0 (Free) that only free edges are taken into +! : account for translation 3d curves, +! : if it is 1 (Shared) that only shared edges are taken into +! : account for translation 3d curves, +! : if it is 2 (Both) that all edges are taken into +! : account for translation 3d curves, +! ToBezier.Curve3dMode : Mode of conversion 3D curves, yes/no +! ToBezier.Curve2dMode : Mode of conversion 2D curves, yes/no +! ToBezier.Line3dMode : Mode of conversion 3D lines, yes/no +! ToBezier.Circle3dMode : Mode of conversion 3D circles, yes/no +! ToBezier.Conic3dMode : Mode of conversion 3D conics, yes/no +! ToBezier.MinCurveLength : Min length of created curves 3d.( default 0.05) + + +! FixFaceSize : Removing small faces +! FixFaceSize.Tolerance : Tolerance in 3d + +! DropSmallEdges : Eliminate small edges by removing or merging with neighbour +! DropSmallEdges.Tolerance3d : Tolerance (3d) + +! FixShape.Tolerance3d : Tolerance (3d) for fixing of shape. +! FixShape.MaxTolerance3d : Maximal possible value of increasing of tolerance during fixing. +! FixShape.MinTolerance3d : Minimal value of tolerance. +! FixShape.FixFreeShellMode : Mode for fixing free shells in the shape (default - -1, yes - 1 , no - 0). +! FixShape.FixFreeFaceMode : Mode for fixing free faces in the shape (default - -1, yes - 1 , no - 0). +! FixShape.FixFreeWireMode : Mode for fixing free wires in the shape (default - -1, yes - 1 , no - 0). +! FixShape.FixSameParameterMode : Mode for fixing same parameter on the whole shape (default - -1, yes - 1 , no - 0). +! FixShape.FixSolidMode : Mode for fixing solids (default - -1, yes - 1 , no - 0). +! FixShape.FixShellMode : Mode for fixing shells (default - -1, yes - 1 , no - 0). +! FixShape.FixFaceMode : Mode for fixing faces (default - -1, yes - 1 , no - 0). +! FixShape.FixWireMode : Mode for fixing wires (default - -1, yes - 1 , no - 0). +! FixShape.FixOrientationMode : Mode for fixing face orientation (default - -1, yes - 1 , no - 0). +! FixShape.FixMissingSeamMode : Mode for fixing face missing seam (default - -1, yes - 1 , no - 0). +! FixShape.FixSmallAreaWireMode : Mode for fixing small area wires (default - -1, yes - 1 , no - 0). +! FixShape.ModifyTopologyMode : Mode allowing of modifing of topology (default - 0, yes - 1 , no - 0). +! FixShape.ModifyGeometryMode : Mode allowing of modifing of geometry (default - 1, yes - 1 , no - 0). +! FixShape.ClosedWireMode : Mode defining whether the wire is to be closed. (default - 1, yes - 1 , no - 0). +! FixShape.PreferencePCurveMode : Mode defining of preference of 2d representation (default - 1, yes - 1 , no - 0). +! FixShape.FixReorderMode : Mode for fixing of order of the edges in the wire (default - -1, yes - 1 , no - 0). +! FixShape.FixSmallMode : Mode for removing of the small edges from the wire in the case when +! : ModifyTopologyMode equaled "yes" (default - -1, yes - 1 , no - 0). +! FixShape.FixConnectedMode : Mode for fixing of connecting of edges in the wire(default - -1, yes - 1 , no - 0). +! FixShape.FixEdgeCurvesMode : Moge for fixing each edge from the wire (default - -1, yes - 1 , no - 0). +! FixShape.FixDegeneratedMode : Moge for fixing cases of degenerate pcurve (default - -1, yes - 1 , no - 0). +! FixShape.FixLackingMode : Moge for fixing cases of lacking edge (default - -1, yes - 1 , no - 0). +! FixShape.FixSelfIntersectionMode : Mode for fixing of cases self-intersection of wire (default - -1, yes - 1 , no - 0). +! FixShape.FixReversed2dMode : Mode for fixing cases when pcurve is opposite curve3d (default - -1, yes - 1 , no - 0). +! FixShape.FixRemovePCurveMode : Mode for removing of pcurves from edges (default - -1, yes - 1 , no - 0). +! FixShape.FixRemoveCurve3dMode : Mode for removing of 3d curves from edges (default - -1, yes - 1 , no - 0). +! FixShape.FixAddPCurveMode : Mode for adding pcurves of the edges if missing (default - -1, yes - 1 , no - 0). +! FixShape.FixAddCurve3dMode : Mode for adding curves 3d of the edges if missing (default - -1, yes - 1 , no - 0). +! FixShape.FixSeamMode : Mode for fixing cases of seam edges. +! FixShape.FixShiftedMode : Mode for fixing cases when pcurves can be shifted on period on the closed surface +! (default - -1, yes - 1 , no - 0). +! FixShape.FixEdgeSameParameterMode : Mode for fixing same parameter for each edge (default - -1, yes - 1 , no - 0). +! FixShape.FixSelfIntersectingEdgeMode : Mode for fixing cases self-intrsection edge (default - -1, yes - 1 , no - 0). +! FixShape.FixIntersectingEdgesMode : Mode for fixing intersection adjacent edges. +! FixShape.FixNonAdjacentIntersectingEdgesMode : Mode for fixing intersection non-adjacent edges. +! diff --git a/resources/bezier.png b/resources/bezier.png new file mode 100644 index 000000000..2629a2b59 Binary files /dev/null and b/resources/bezier.png differ diff --git a/resources/block_2f.png b/resources/block_2f.png new file mode 100644 index 000000000..cd3b49247 Binary files /dev/null and b/resources/block_2f.png differ diff --git a/resources/block_6f.png b/resources/block_6f.png new file mode 100644 index 000000000..877add137 Binary files /dev/null and b/resources/block_6f.png differ diff --git a/resources/block_face_2e.png b/resources/block_face_2e.png new file mode 100644 index 000000000..5d704844e Binary files /dev/null and b/resources/block_face_2e.png differ diff --git a/resources/block_face_4e.png b/resources/block_face_4e.png new file mode 100644 index 000000000..c81fa4a25 Binary files /dev/null and b/resources/block_face_4e.png differ diff --git a/resources/block_face_4v.png b/resources/block_face_4v.png new file mode 100644 index 000000000..24f5c6513 Binary files /dev/null and b/resources/block_face_4v.png differ diff --git a/resources/block_multitrsf_double.png b/resources/block_multitrsf_double.png new file mode 100644 index 000000000..a148c7102 Binary files /dev/null and b/resources/block_multitrsf_double.png differ diff --git a/resources/block_multitrsf_simple.png b/resources/block_multitrsf_simple.png new file mode 100644 index 000000000..7efa63269 Binary files /dev/null and b/resources/block_multitrsf_simple.png differ diff --git a/resources/circle3points.png b/resources/circle3points.png new file mode 100644 index 000000000..a14c41b48 Binary files /dev/null and b/resources/circle3points.png differ diff --git a/resources/closecontour.png b/resources/closecontour.png new file mode 100644 index 000000000..9ab62f9a0 Binary files /dev/null and b/resources/closecontour.png differ diff --git a/resources/coordsys.png b/resources/coordsys.png new file mode 100755 index 000000000..823b37786 Binary files /dev/null and b/resources/coordsys.png differ diff --git a/resources/displayonly.png b/resources/displayonly.png new file mode 100644 index 000000000..602807551 Binary files /dev/null and b/resources/displayonly.png differ diff --git a/resources/free_bound.png b/resources/free_bound.png new file mode 100755 index 000000000..15b634ac8 Binary files /dev/null and b/resources/free_bound.png differ diff --git a/resources/glue.png b/resources/glue.png new file mode 100644 index 000000000..8c9a1518d Binary files /dev/null and b/resources/glue.png differ diff --git a/resources/group_edit.png b/resources/group_edit.png new file mode 100644 index 000000000..24f273613 Binary files /dev/null and b/resources/group_edit.png differ diff --git a/resources/group_new.png b/resources/group_new.png new file mode 100644 index 000000000..1ccac8fc6 Binary files /dev/null and b/resources/group_new.png differ diff --git a/resources/interpol.png b/resources/interpol.png new file mode 100644 index 000000000..0fe35f2f4 Binary files /dev/null and b/resources/interpol.png differ diff --git a/resources/marker.png b/resources/marker.png new file mode 100644 index 000000000..e9da6369f Binary files /dev/null and b/resources/marker.png differ diff --git a/resources/marker2.png b/resources/marker2.png new file mode 100644 index 000000000..4755c7916 Binary files /dev/null and b/resources/marker2.png differ diff --git a/resources/marker3.png b/resources/marker3.png new file mode 100644 index 000000000..835ea28bb Binary files /dev/null and b/resources/marker3.png differ diff --git a/resources/mirrorAxe.png b/resources/mirrorAxe.png new file mode 100644 index 000000000..6b6901647 Binary files /dev/null and b/resources/mirrorAxe.png differ diff --git a/resources/mirrorPoint.png b/resources/mirrorPoint.png new file mode 100644 index 000000000..cdffc171a Binary files /dev/null and b/resources/mirrorPoint.png differ diff --git a/resources/offset.png b/resources/offset.png new file mode 100644 index 000000000..6ce1561ad Binary files /dev/null and b/resources/offset.png differ diff --git a/resources/partitionplane.png b/resources/partitionplane.png new file mode 100644 index 000000000..96e8d663f Binary files /dev/null and b/resources/partitionplane.png differ diff --git a/resources/plane3points.png b/resources/plane3points.png new file mode 100644 index 000000000..d5b5d45dc Binary files /dev/null and b/resources/plane3points.png differ diff --git a/resources/planeworkingorigin.png b/resources/planeworkingorigin.png new file mode 100644 index 000000000..14370a348 Binary files /dev/null and b/resources/planeworkingorigin.png differ diff --git a/resources/planeworkingvector.png b/resources/planeworkingvector.png new file mode 100644 index 000000000..3ae81b68c Binary files /dev/null and b/resources/planeworkingvector.png differ diff --git a/resources/point3.png b/resources/point3.png new file mode 100644 index 000000000..53d5bab2c Binary files /dev/null and b/resources/point3.png differ diff --git a/resources/point_coord.png b/resources/point_coord.png new file mode 100644 index 000000000..ae02c4724 Binary files /dev/null and b/resources/point_coord.png differ diff --git a/resources/polyline.png b/resources/polyline.png new file mode 100644 index 000000000..6e21c6b25 Binary files /dev/null and b/resources/polyline.png differ diff --git a/resources/position.png b/resources/position.png new file mode 100644 index 000000000..5c308d745 Binary files /dev/null and b/resources/position.png differ diff --git a/resources/position2.png b/resources/position2.png new file mode 100644 index 000000000..12f4a0a8b Binary files /dev/null and b/resources/position2.png differ diff --git a/resources/shapeprocess.png b/resources/shapeprocess.png new file mode 100644 index 000000000..d9fa256ff Binary files /dev/null and b/resources/shapeprocess.png differ diff --git a/resources/spline.png b/resources/spline.png new file mode 100644 index 000000000..0fe35f2f4 Binary files /dev/null and b/resources/spline.png differ diff --git a/resources/subblock.png b/resources/subblock.png new file mode 100755 index 000000000..6c75aa4bf Binary files /dev/null and b/resources/subblock.png differ diff --git a/resources/suppressintwires.png b/resources/suppressintwires.png new file mode 100644 index 000000000..9ab62f9a0 Binary files /dev/null and b/resources/suppressintwires.png differ diff --git a/resources/translationDxyz.png b/resources/translationDxyz.png new file mode 100644 index 000000000..99549ed5e Binary files /dev/null and b/resources/translationDxyz.png differ diff --git a/resources/translationPoints.png b/resources/translationPoints.png new file mode 100644 index 000000000..9474b1132 Binary files /dev/null and b/resources/translationPoints.png differ diff --git a/resources/translationVector.png b/resources/translationVector.png new file mode 100644 index 000000000..78e6f9012 Binary files /dev/null and b/resources/translationVector.png differ diff --git a/resources/tree_block.png b/resources/tree_block.png new file mode 100644 index 000000000..aa74e796e Binary files /dev/null and b/resources/tree_block.png differ diff --git a/resources/tree_group_edge.png b/resources/tree_group_edge.png new file mode 100644 index 000000000..214be938a Binary files /dev/null and b/resources/tree_group_edge.png differ diff --git a/resources/tree_group_face.png b/resources/tree_group_face.png new file mode 100644 index 000000000..debb48ddf Binary files /dev/null and b/resources/tree_group_face.png differ diff --git a/resources/tree_group_solid.png b/resources/tree_group_solid.png new file mode 100644 index 000000000..d68588346 Binary files /dev/null and b/resources/tree_group_solid.png differ diff --git a/resources/tree_group_vertex.png b/resources/tree_group_vertex.png new file mode 100644 index 000000000..553a4b9d3 Binary files /dev/null and b/resources/tree_group_vertex.png differ diff --git a/resources/tree_lcs.png b/resources/tree_lcs.png new file mode 100644 index 000000000..853d47e0a Binary files /dev/null and b/resources/tree_lcs.png differ diff --git a/src/BREPExport/BREPExport.cxx b/src/BREPExport/BREPExport.cxx new file mode 100644 index 000000000..1d09a7c04 --- /dev/null +++ b/src/BREPExport/BREPExport.cxx @@ -0,0 +1,33 @@ +// File: BREPExport.cxx +// Created: Wed May 19 13:10:05 2004 +// Author: Pavel TELKOV +// + +#include "utilities.h" + +#include + +#include +#include + +//============================================================================= +/*! + * + */ +//============================================================================= + +extern "C" +{ +#ifdef WNT + __declspec(__dllexport) +#endif + int Export(const TopoDS_Shape& theShape, const TCollection_AsciiString& theFileName) + { + MESSAGE("Export BREP into file " << theFileName.ToCString()); + + if ( !BRepTools::Write( theShape, theFileName.ToCString() ) ) + return 0; + + return 1; + } +} diff --git a/src/BREPExport/Makefile.in b/src/BREPExport/Makefile.in new file mode 100644 index 000000000..8983e67c6 --- /dev/null +++ b/src/BREPExport/Makefile.in @@ -0,0 +1,47 @@ +# Copyright (C) 2003 CEA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org or email : webmaster.salome@opencascade.org +# +# +# +# File : Makefile.in +# Author : Pavel TELKOV +# Module : GEOM +# $Header$ + +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + +@COMMENCE@ + +EXPORT_HEADERS= + +# Libraries targets + +LIB = libBREPExport.la + +LIB_SRC = BREPExport.cxx + +# additionnal information to compil and link file +CPPFLAGS+= $(OCC_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome +CXXFLAGS+= $(OCC_CXXFLAGS) -I${KERNEL_ROOT_DIR}/include/salome + +LDFLAGS+= $(CAS_LDPATH) -lTKBRep -L${KERNEL_ROOT_DIR}/lib/salome + +@CONCLUDE@ diff --git a/src/BREPImport/BREPImport.cxx b/src/BREPImport/BREPImport.cxx new file mode 100644 index 000000000..492019032 --- /dev/null +++ b/src/BREPImport/BREPImport.cxx @@ -0,0 +1,37 @@ +// File: BREPImport.cxx +// Created: Wed May 19 14:29:52 2004 +// Author: Pavel TELKOV +// + +#include "utilities.h" + +#include +#include + +#include +#include + +//============================================================================= +/*! + * + */ +//============================================================================= + +extern "C" +{ +#ifdef WNT + __declspec(__dllexport) +#endif + TopoDS_Shape Import (const TCollection_AsciiString& theFileName, + TCollection_AsciiString& theError) + { + MESSAGE("Import BREP from file " << theFileName); + TopoDS_Shape aShape; + BRep_Builder B; + BRepTools::Read(aShape, theFileName.ToCString(), B); + if (aShape.IsNull()) { + theError = "BREP Import failed"; + } + return aShape; + } +} diff --git a/src/BREPImport/Makefile.in b/src/BREPImport/Makefile.in new file mode 100644 index 000000000..cc76e0c58 --- /dev/null +++ b/src/BREPImport/Makefile.in @@ -0,0 +1,45 @@ +# Copyright (C) 2003 CEA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org or email : webmaster.salome@opencascade.org +# +# +# +# File : Makefile.in +# Author : Pavel TELKOV +# Module : GEOM +# $Header$ + +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + +@COMMENCE@ + +# Libraries targets + +LIB= libBREPImport.la + +LIB_SRC = BREPImport.cxx + +# additionnal information to compil and link file +CPPFLAGS+= $(OCC_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome +CXXFLAGS+= $(OCC_CXXFLAGS) -I${KERNEL_ROOT_DIR}/include/salome + +LDFLAGS+= $(CAS_LDPATH) -lTKBRep -L${KERNEL_ROOT_DIR}/lib/salome + +@CONCLUDE@ diff --git a/src/BasicGUI/BasicGUI.cxx b/src/BasicGUI/BasicGUI.cxx index aef6d70b0..9398230f3 100644 --- a/src/BasicGUI/BasicGUI.cxx +++ b/src/BasicGUI/BasicGUI.cxx @@ -24,40 +24,60 @@ // File : BasicGUI.cxx // Author : Damien COQUERET // Module : GEOM -// $Header: +// $Header$ using namespace std; #include "BasicGUI.h" +#include "GeometryGUI.h" #include "QAD_RightFrame.h" +#include "QAD_Desktop.h" #include "OCCViewer_Viewer3d.h" +#include "OCCViewer_ViewFrame.h" +#include "OCCViewer_AISSelector.h" #include "OCCViewer_ViewPort3d.h" #include "SALOMEGUI_QtCatchCorbaException.hxx" +#include "utilities.h" + #include #include #include #include +#include #include "BasicGUI_PointDlg.h" // Method POINT #include "BasicGUI_LineDlg.h" // Method LINE #include "BasicGUI_CircleDlg.h" // Method CIRCLE #include "BasicGUI_EllipseDlg.h" // Method ELLIPSE #include "BasicGUI_ArcDlg.h" // Method ARC +#include "BasicGUI_CurveDlg.h" // Method CURVE #include "BasicGUI_VectorDlg.h" // Method VECTOR #include "BasicGUI_PlaneDlg.h" // Method PLANE #include "BasicGUI_WorkingPlaneDlg.h" // Method WORKING PLANE +#include "BasicGUI_MarkerDlg.h" // Method REPAIR + +BasicGUI* BasicGUI::myGUIObject = 0; + +//======================================================================= +// function : GetBasicGUI() +// purpose : Get the only BasicGUI object [ static ] +//======================================================================= +BasicGUI* BasicGUI::GetBasicGUI() +{ + if ( myGUIObject == 0 ) { + myGUIObject = new BasicGUI(); + } + return myGUIObject; +} //======================================================================= // function : BasicGUI() // purpose : Constructor //======================================================================= BasicGUI::BasicGUI() : - QObject() + GEOMGUI() { - myGeomBase = new GEOMBase(); - myGeomGUI = GEOMContext::GetGeomGUI(); - myGeom = myGeomGUI->myComponentGeom; } @@ -76,63 +96,59 @@ BasicGUI::~BasicGUI() //======================================================================= bool BasicGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) { - BasicGUI* myBasicGUI = new BasicGUI(); - myBasicGUI->myGeomGUI->EmitSignalDeactivateDialog(); + GeometryGUI::GetGeomGUI()->EmitSignalDeactivateDialog(); SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection()); + QDialog* aDlg = NULL; - switch (theCommandID) + switch ( theCommandID ) { case 4011: // POINT { Handle(AIS_InteractiveContext) ic; - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + QAD_StudyFrame* aFrame = QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame(); + if ( aFrame->getTypeView() == VIEW_OCC) + { + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)aFrame->getRightFrame()->getViewFrame())->getViewer(); ic = v3d->getAISContext(); } - BasicGUI_PointDlg *aDlg = new BasicGUI_PointDlg(parent, "", myBasicGUI, Sel, ic); + aDlg = new BasicGUI_PointDlg( parent, "", Sel ); break; } case 4012: // LINE - { - BasicGUI_LineDlg *aDlg = new BasicGUI_LineDlg(parent, "", myBasicGUI, Sel); - break; - } + aDlg = new BasicGUI_LineDlg(parent, "", Sel); + break; case 4013: // CIRCLE - { - BasicGUI_CircleDlg *aDlg = new BasicGUI_CircleDlg(parent, "", myBasicGUI, Sel); - break; - } + aDlg = new BasicGUI_CircleDlg(parent, "", Sel); + break; case 4014: // ELLIPSE - { - BasicGUI_EllipseDlg *aDlg = new BasicGUI_EllipseDlg(parent, "", myBasicGUI, Sel); - break; - } + aDlg = new BasicGUI_EllipseDlg(parent, "", Sel); + break; case 4015: // ARC - { - BasicGUI_ArcDlg *aDlg = new BasicGUI_ArcDlg(parent, "", myBasicGUI, Sel); - break ; - } + aDlg = new BasicGUI_ArcDlg(parent, "", Sel); + break ; case 4016: // VECTOR - { - BasicGUI_VectorDlg *aDlg = new BasicGUI_VectorDlg(parent, "", myBasicGUI, Sel); - break; - } + aDlg = new BasicGUI_VectorDlg(parent, "", Sel); + break; case 4017: // PLANE - { - BasicGUI_PlaneDlg *aDlg = new BasicGUI_PlaneDlg(parent, "", myBasicGUI, Sel); - break; - } + aDlg = new BasicGUI_PlaneDlg(parent, "", Sel); + break; case 4018: // WORKING PLANE - { - BasicGUI_WorkingPlaneDlg *aDlg = new BasicGUI_WorkingPlaneDlg(parent, "", myBasicGUI, Sel); - break; - } + aDlg = new BasicGUI_WorkingPlaneDlg(parent, "", Sel); + break; + case 4019: // CURVE + aDlg = new BasicGUI_CurveDlg( parent, "", Sel ); + break; + case 4020: // REPAIR + aDlg = new BasicGUI_MarkerDlg( parent, Sel ); + break; default: - { - parent->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); - break; - } + parent->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); + break; } + + if ( aDlg != NULL ) + aDlg->show(); + return true; } @@ -141,44 +157,43 @@ bool BasicGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) // function : 0nMousePress() // purpose : [static] manage mouse events //================================================================================= -bool BasicGUI::OnMousePress(QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame) +bool BasicGUI::OnMousePress( QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* theFrame ) { - BasicGUI* myBasicGUI = new BasicGUI(); - - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC) - return false; - - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); - OCCViewer_ViewPort* vp = ((OCCViewer_ViewFrame*)studyFrame->getRightFrame()->getViewFrame())->getViewPort(); - - /* Get the clicked or selected point */ - gp_Pnt thePoint; - - myBasicGUI->myGeomBase->EraseSimulationShape(); - BasicGUI_PointDlg *DialogPt = (BasicGUI_PointDlg*)(myBasicGUI->myGeomGUI->GetActiveDialogBox()); - - if(DialogPt->UseLocalContext()) { - ic->InitSelected(); - if(pe->state() == Qt::ShiftButton) - v3d->getAISSelector()->shiftSelect(); /* Append selection */ - else - v3d->getAISSelector()->select(); /* New selection */ + QDialog* aDlg = GeometryGUI::GetGeomGUI()->GetActiveDialogBox(); + + // Create Point dialog, OCC viewer + if ( aDlg && aDlg->isA( "BasicGUI_PointDlg" ) && theFrame->getTypeView() == VIEW_OCC ) + { + BasicGUI_PointDlg* aPntDlg = (BasicGUI_PointDlg*) aDlg; + if ( aPntDlg->acceptMouseEvent() ) + { + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)theFrame->getRightFrame()->getViewFrame())->getViewer(); + Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); - ic->InitSelected(); - if(ic->MoreSelected()) - thePoint = BRep_Tool::Pnt(TopoDS::Vertex(ic->SelectedShape())); - else - thePoint = myBasicGUI->ConvertClickToPoint(pe->x(), pe->y(), ((OCCViewer_ViewPort3d*)vp)->getView()); + gp_Pnt aPnt; + + ic->InitSelected(); + if( pe->state() == Qt::ShiftButton ) + v3d->getAISSelector()->shiftSelect(); // Append selection + else + v3d->getAISSelector()->select(); // New selection + + ic->InitSelected(); + if( ic->MoreSelected() ) + { + TopoDS_Shape aShape = ic->SelectedShape(); + if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX ) + aPnt = BRep_Tool::Pnt( TopoDS::Vertex( ic->SelectedShape() ) ); + } + else + { + OCCViewer_ViewPort* vp = ((OCCViewer_ViewFrame*)theFrame->getRightFrame()->getViewFrame())->getViewPort(); + aPnt = ConvertClickToPoint( pe->x(), pe->y(), ((OCCViewer_ViewPort3d*)vp)->getView() ); + } + + aPntDlg->OnPointSelected( aPnt ); // "feed" the point to point construction dialog + } // acceptMouseEvent() } - else - thePoint = myBasicGUI->ConvertClickToPoint(pe->x(), pe->y(), ((OCCViewer_ViewPort3d*)vp)->getView()); - - if(DialogPt != 0) - DialogPt->PointIntoCoordinates(thePoint, true); /* display point */ - else - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_ABORT")); - return false; } @@ -187,7 +202,7 @@ bool BasicGUI::OnMousePress(QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame // function : ConvertClickToPoint() // purpose : Returns the point clicked in 3D view //======================================================================= -gp_Pnt BasicGUI::ConvertClickToPoint(Standard_Real x, Standard_Real y, Handle(V3d_View) aView) +gp_Pnt BasicGUI::ConvertClickToPoint( int x, int y, Handle(V3d_View) aView) { V3d_Coordinate XEye, YEye, ZEye, XAt, YAt, ZAt; aView->Eye(XEye, YEye, ZEye); @@ -201,7 +216,7 @@ gp_Pnt BasicGUI::ConvertClickToPoint(Standard_Real x, Standard_Real y, Handle(V3 gp_Pln PlaneOfTheView = gp_Pln(AtPoint,EyeDir); Standard_Real X, Y, Z; - aView->Convert(int(x), int(y), X, Y, Z); + aView->Convert(x, y, X, Y, Z); gp_Pnt ConvertedPoint(X, Y, Z); gp_Pnt2d ConvertedPointOnPlane = ProjLib::Project(PlaneOfTheView, ConvertedPoint); @@ -209,237 +224,13 @@ gp_Pnt BasicGUI::ConvertClickToPoint(Standard_Real x, Standard_Real y, Handle(V3 return ResultPoint; } - -//======================================================================= -// function : MakePointAndDisplay -// purpose : -//======================================================================= -void BasicGUI::MakePointAndDisplay(const double x, const double y, const double z) -{ - try { - GEOM::GEOM_Shape_var P = myGeom->MakeVertex(x, y, z); - P->NameType(tr("GEOM_VERTEX")); - if (myGeomBase->Display(P)) - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); - } - catch(const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return; -} - - -//===================================================================================== -// function : MakeLineAndDisplay() -// purpose : Create an infinite oriented line (linear edge in fact) -//===================================================================================== -void BasicGUI::MakeLineAndDisplay(const gp_Pnt InitPoint, const gp_Pnt LastPoint) -{ - gp_Pnt P1, P2; - double dx, dy, dz; - myGeomBase->GetBipointDxDyDz(InitPoint, LastPoint, dx, dy, dz); - Standard_Real length = InitPoint.Distance(LastPoint); - if(length <= Precision::Confusion()) { - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_ABORT")); - return; - } - - Standard_Real coeff = 1E6 / length; - - /* To create a line with length = 1E6 */ - /* Precision::Infinite() is 1E100 in OCC */ - P1.SetX(InitPoint.X() - (coeff * dx)); - P1.SetY(InitPoint.Y() - (coeff * dy)); - P1.SetZ(InitPoint.Z() - (coeff * dz)); - - P2.SetX(LastPoint.X() + (coeff * dx)); - P2.SetY(LastPoint.Y() + (coeff * dy)); - P2.SetZ(LastPoint.Z() + (coeff * dz)); - - try { - GEOM::PointStruct pstruct = myGeom->MakePointStruct(P1.X(), P1.Y(), P1.Z()); - GEOM::PointStruct d = myGeom->MakePointStruct(P2.X(), P2.Y(), P2.Z()); - GEOM::DirStruct dstruct = myGeom->MakeDirection(d); - - GEOM::GEOM_Shape_ptr result = myGeom->MakeLine(pstruct, dstruct); - if(result->_is_nil()) { - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_ABORT")); - return; - } - result->NameType(tr("GEOM_LINE")); - - if(myGeomBase->Display(result)) - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_READY")); - } - catch(const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return; -} - - -//===================================================================================== -// function : MakeCircleAndDisplay() -// purpose : -//===================================================================================== -void BasicGUI::MakeCircleAndDisplay(const gp_Pnt CenterPoint, const gp_Dir dir, const Standard_Real Radius) -{ - try { - GEOM::PointStruct pstruct = myGeom->MakePointStruct(CenterPoint.X(), CenterPoint.Y(), CenterPoint.Z()); - GEOM::PointStruct d = myGeom->MakePointStruct(dir.X(), dir.Y(), dir.Z()); - GEOM::DirStruct dstruct = myGeom->MakeDirection(d); - - GEOM::GEOM_Shape_var result = myGeom->MakeCircle(pstruct, dstruct, Radius); - if(result->_is_nil()) { - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_ABORT")); - return; - } - result->NameType(tr("GEOM_CIRCLE")); - if(myGeomBase->Display(result)) - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); - } - catch(const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return; -} - - -//===================================================================================== -// function : MakeEllipseAndDisplay() -// purpose : -//===================================================================================== -void BasicGUI::MakeEllipseAndDisplay(const gp_Pnt CenterPoint, const gp_Dir dir, - const Standard_Real Major_Radius, const Standard_Real Minor_Radius) -{ - try { - GEOM::PointStruct pstruct = myGeom->MakePointStruct(CenterPoint.X(), CenterPoint.Y(), CenterPoint.Z()); - GEOM::PointStruct d = myGeom->MakePointStruct(dir.X(), dir.Y(), dir.Z()); - GEOM::DirStruct dstruct = myGeom->MakeDirection(d) ; - - GEOM::GEOM_Shape_var result = myGeom->MakeEllipse(pstruct, dstruct, Major_Radius, Minor_Radius); - if(result->_is_nil()) { - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_ABORT")); - return; - } - result->NameType(tr("GEOM_ELLIPSE")); - if(myGeomBase->Display(result)) - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); - } - catch(const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return; -} - - -//======================================================================================= -// function : MakeArcAndDisplay() -// purpose : Make an arc of circle from InitPoint to CirclePoint and passing on EndPoint -//======================================================================================= -void BasicGUI::MakeArcAndDisplay(gp_Pnt InitPoint, gp_Pnt CirclePoint, gp_Pnt EndPoint) -{ - gp_Vec v1(CirclePoint, InitPoint); - gp_Vec v2(CirclePoint, EndPoint); - if(v1.IsParallel(v2, Precision::Angular())) - return; - - try { - GEOM::PointStruct pI = myGeom->MakePointStruct(InitPoint.X(), InitPoint.Y(), InitPoint.Z()); - GEOM::PointStruct pC = myGeom->MakePointStruct(CirclePoint.X(), CirclePoint.Y(), CirclePoint.Z()); - GEOM::PointStruct pE = myGeom->MakePointStruct(EndPoint.X(), EndPoint.Y(), EndPoint.Z()); - GEOM::GEOM_Shape_var result = myGeom->MakeArc(pI, pC, pE); - if(result->_is_nil()) { - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_ABORT")); - return; - } - result->NameType(tr("GEOM_ARC")); - if (myGeomBase->Display(result)) - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); - } - catch(const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return; -} - - -//======================================================================= -// function : MakeVectorAndDisplay() -// purpose : -//======================================================================= -void BasicGUI::MakeVectorAndDisplay(const gp_Pnt P1, const gp_Pnt P2) -{ - try { - GEOM::PointStruct pstruct1 = myGeom->MakePointStruct(P1.X(), P1.Y(), P1.Z()); - GEOM::PointStruct pstruct2 = myGeom->MakePointStruct(P2.X(), P2.Y(), P2.Z()); - GEOM::GEOM_Shape_var Vector = myGeom->MakeVector(pstruct1, pstruct2); - Vector->NameType(tr("GEOM_VECTOR")); - if(myGeomBase->Display(Vector)) - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); - } - catch(const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return; -} - - -//======================================================================= -// function : MakePlaneAndDisplay() -// purpose : Plane point is P1 and dx, dy, dz define a normal vector -//======================================================================= -void BasicGUI::MakePlaneAndDisplay(const gp_Pnt P1, const Standard_Real dx, const Standard_Real dy, - const Standard_Real dz, const Standard_Real TrimSize) -{ - try { - gp_Dir aDirection; - aDirection.SetCoord(dx, dy, dz); - gp_Ax2 Axis(P1, aDirection); - - GEOM::PointStruct pstruct = myGeom->MakePointStruct(P1.X(), P1.Y(), P1.Z()); - GEOM::PointStruct d = myGeom->MakePointStruct(aDirection.X(), aDirection.Y(), aDirection.Z()); - GEOM::DirStruct dstruct = myGeom->MakeDirection(d); - GEOM::GEOM_Shape_ptr plane = myGeom->MakePlane(pstruct, dstruct, TrimSize); - plane->NameType(tr("GEOM_PLANE")); - if(myGeomBase->Display(plane)) - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); - } - catch(const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return; -} - - -//======================================================================= -// function : MakeWorkingPlane() -// purpose : Change the point of view3d -//======================================================================= -void BasicGUI::MakeWorkingPlane(const gp_Pnt P, const gp_Dir D) -{ - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_OCC) { - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_NOT_FOR_VTK_VIEWER")); - return; - } - - OCCViewer_ViewPort* vp = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewPort(); - Handle(V3d_View) view3d = ((OCCViewer_ViewPort3d*)vp)->getView(); - view3d->SetAt(P.X(), P.Y(), P.Z()); - view3d->SetProj(D.X(), D.Y(), D.Z()); - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); - return; -} - - //===================================================================================== // EXPORTED METHODS //===================================================================================== extern "C" { - bool OnGUIEvent(int theCommandID, QAD_Desktop* parent) - {return BasicGUI::OnGUIEvent(theCommandID, parent);} - - bool OnMousePress(QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame) - {return BasicGUI::OnMousePress(pe, parent, studyFrame);} + GEOMGUI* GetLibGUI() + { + return BasicGUI::GetBasicGUI(); + } } diff --git a/src/BasicGUI/BasicGUI.h b/src/BasicGUI/BasicGUI.h index ef5d957f1..418f446ed 100644 --- a/src/BasicGUI/BasicGUI.h +++ b/src/BasicGUI/BasicGUI.h @@ -24,11 +24,12 @@ // File : BasicGUI.h // Author : Damien COQUERET // Module : GEOM -// $Header: +// $Header$ #ifndef BASICGUI_H #define BASICGUI_H +#include "GEOMGUI.h" #include "GEOMBase.h" #include @@ -36,34 +37,24 @@ // class : BasicGUI // purpose : //================================================================================= -class BasicGUI : public QObject +class BasicGUI : public GEOMGUI { - Q_OBJECT /* for QT compatibility */ +protected: + BasicGUI(); // hide constructor to avoid direct creation public : - BasicGUI(); ~BasicGUI(); - static bool OnGUIEvent(int theCommandID, QAD_Desktop* parent); - static bool OnMousePress(QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame); + // Get the only BasicGUI object + static BasicGUI* GetBasicGUI(); - gp_Pnt ConvertClickToPoint(Standard_Real x, Standard_Real y, Handle(V3d_View) aView); + bool OnGUIEvent(int theCommandID, QAD_Desktop* parent); + bool OnMousePress(QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame); - void MakePointAndDisplay(const double x, const double y, const double z); - void MakeLineAndDisplay(const gp_Pnt InitPoint, const gp_Pnt LastPoint); - void MakeCircleAndDisplay(const gp_Pnt CenterPoint, const gp_Dir dir, const Standard_Real Radius); - void MakeEllipseAndDisplay(const gp_Pnt CenterPoint, const gp_Dir dir, - const Standard_Real Major_Radius, const Standard_Real Minor_Radius); - void MakeArcAndDisplay(gp_Pnt InitPoint, gp_Pnt CirclePoint, gp_Pnt EndPoint); - void MakeVectorAndDisplay(const gp_Pnt P1, const gp_Pnt P2); - void MakePlaneAndDisplay(const gp_Pnt P1, const Standard_Real dx, const Standard_Real dy, - const Standard_Real dz, const Standard_Real TrimSize); - void MakeWorkingPlane(const gp_Pnt P, const gp_Dir D); - - GEOMBase* myGeomBase; - GEOMContext* myGeomGUI; - GEOM::GEOM_Gen_var myGeom; /* Current Geom Component */ + gp_Pnt ConvertClickToPoint( int x, int y, Handle(V3d_View) aView ); +private: + static BasicGUI* myGUIObject; // the only BasicGUI object }; #endif diff --git a/src/BasicGUI/BasicGUI_ArcDlg.cxx b/src/BasicGUI/BasicGUI_ArcDlg.cxx index 4c3bfaa9c..2c1dbc537 100644 --- a/src/BasicGUI/BasicGUI_ArcDlg.cxx +++ b/src/BasicGUI/BasicGUI_ArcDlg.cxx @@ -28,11 +28,14 @@ #include "BasicGUI_ArcDlg.h" +#include "QAD_Desktop.h" #include #include #include #include +#include "GEOMImpl_Types.hxx" + #include "utilities.h" using namespace std; @@ -44,7 +47,7 @@ using namespace std; // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -BasicGUI_ArcDlg::BasicGUI_ArcDlg(QWidget* parent, const char* name, BasicGUI* theBasicGUI, SALOME_Selection* Sel, bool modal, WFlags fl) +BasicGUI_ArcDlg::BasicGUI_ArcDlg(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_ARC"))); @@ -58,20 +61,22 @@ BasicGUI_ArcDlg::BasicGUI_ArcDlg(QWidget* parent, const char* name, BasicGUI* th RadioButton2->close(TRUE); RadioButton3->close(TRUE); - GroupPoints = new DlgRef_3Sel_QTD(this, "GroupPoints"); - GroupPoints->GroupBox1->setTitle(tr("GEOM_POINTS")); - GroupPoints->TextLabel1->setText(tr("GEOM_POINT_I").arg("1")); - GroupPoints->TextLabel2->setText(tr("GEOM_POINT_I").arg("2")); - GroupPoints->TextLabel3->setText(tr("GEOM_POINT_I").arg("3")); - GroupPoints->PushButton1->setPixmap(image1); - GroupPoints->PushButton2->setPixmap(image1); - GroupPoints->PushButton3->setPixmap(image1); + Group3Pnts = new DlgRef_3Sel_QTD(this, "Group3Pnts"); + Group3Pnts->GroupBox1->setTitle(tr("GEOM_POINTS")); + Group3Pnts->TextLabel1->setText(tr("GEOM_POINT_I").arg("1")); + Group3Pnts->TextLabel2->setText(tr("GEOM_POINT_I").arg("2")); + Group3Pnts->TextLabel3->setText(tr("GEOM_POINT_I").arg("3")); - Layout1->addWidget(GroupPoints, 1, 0); - /***************************************************************/ + Group3Pnts->LineEdit1->setReadOnly( true ); + Group3Pnts->LineEdit2->setReadOnly( true ); + Group3Pnts->LineEdit3->setReadOnly( true ); + + Group3Pnts->PushButton1->setPixmap(image1); + Group3Pnts->PushButton2->setPixmap(image1); + Group3Pnts->PushButton3->setPixmap(image1); + + Layout1->addWidget( Group3Pnts, 2, 0 ); - /* Initialisations */ - myBasicGUI = theBasicGUI; Init(); } @@ -82,7 +87,6 @@ BasicGUI_ArcDlg::BasicGUI_ArcDlg(QWidget* parent, const char* name, BasicGUI* th //================================================================================= BasicGUI_ArcDlg::~BasicGUI_ArcDlg() { - // no need to delete child widgets, Qt does it all for us } @@ -93,32 +97,33 @@ BasicGUI_ArcDlg::~BasicGUI_ArcDlg() void BasicGUI_ArcDlg::Init() { /* init variables */ - myEditCurrentArgument = GroupPoints->LineEdit1; - myOkPoint1 = myOkPoint2 = myOkPoint3 = false; + myGeomGUI->SetState( 0 ); + globalSelection( GEOM_POINT ); - /* Vertices Filter for all arguments */ - myVertexFilter = new GEOM_ShapeTypeFilter(TopAbs_VERTEX, myGeom); - mySelection->AddFilter(myVertexFilter); + myEditCurrentArgument = Group3Pnts->LineEdit1; + myEditCurrentArgument->setFocus(); + + myPoint1 = myPoint2 = myPoint3 = GEOM::GEOM_Object::_nil(); /* 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(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect(GroupPoints->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(Group3Pnts->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(Group3Pnts->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(Group3Pnts->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupPoints->LineEdit3, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(Group3Pnts->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(Group3Pnts->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(Group3Pnts->LineEdit3, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - /* displays Dialog */ - GroupPoints->show(); - this->show(); - - return; + initName( tr( "GEOM_ARC" ) ); } @@ -128,28 +133,38 @@ void BasicGUI_ArcDlg::Init() //================================================================================= void BasicGUI_ArcDlg::ClickOnOk() { - this->ClickOnApply(); - ClickOnCancel(); - return; + if ( ClickOnApply() ) + ClickOnCancel(); } +//======================================================================= +// function : ClickOnCancel() +// purpose : +//======================================================================= +void BasicGUI_ArcDlg::ClickOnCancel() +{ + GEOMBase_Skeleton::ClickOnCancel(); +} //================================================================================= // function : ClickOnApply() // purpose : //================================================================================= -void BasicGUI_ArcDlg::ClickOnApply() +bool BasicGUI_ArcDlg::ClickOnApply() { - buttonApply->setFocus(); - QAD_Application::getDesktop()->putInfo(tr("")); - if (mySimulationTopoDs.IsNull()) - return; - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); + if ( !onAccept() ) + return false; + + initName(); - if(myOkPoint1 && myOkPoint2 && myOkPoint3) - myBasicGUI->MakeArcAndDisplay(myPoint1, myPoint2, myPoint3); - return; + // reset + myPoint1 = myPoint2 = myPoint3 = GEOM::GEOM_Object::_nil(); + Group3Pnts->LineEdit1->setText( "" ); + Group3Pnts->LineEdit2->setText( "" ); + Group3Pnts->LineEdit3->setText( "" ); + myEditCurrentArgument = Group3Pnts->LineEdit1; + + return true; } @@ -159,43 +174,28 @@ void BasicGUI_ArcDlg::ClickOnApply() //================================================================================= void BasicGUI_ArcDlg::SelectionIntoArgument() { - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); myEditCurrentArgument->setText(""); - QString aString = ""; /* name of selection */ - - int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString); - if (nbSel != 1) { - if (myEditCurrentArgument == GroupPoints->LineEdit1) - myOkPoint1 = false; - else if(myEditCurrentArgument == GroupPoints->LineEdit2) - myOkPoint2 = false; - else if(myEditCurrentArgument == GroupPoints->LineEdit3) - myOkPoint3 = false; + + if ( mySelection->IObjectCount() != 1 ) + { + if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) myPoint1 = GEOM::GEOM_Object::_nil(); + else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) myPoint2 = GEOM::GEOM_Object::_nil(); + else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) myPoint3 = GEOM::GEOM_Object::_nil(); return; } // nbSel == 1 - TopoDS_Shape S; - if(!myGeomBase->GetTopoFromSelection(mySelection, S)) - return; - - if(myEditCurrentArgument == GroupPoints->LineEdit1 && myGeomBase->VertexToPoint(S, myPoint1)) { - myEditCurrentArgument->setText(aString); - myOkPoint1 = true; - } - else if(myEditCurrentArgument == GroupPoints->LineEdit2 && myGeomBase->VertexToPoint(S, myPoint2)) { - myEditCurrentArgument->setText(aString); - myOkPoint2 = true; - } - else if(myEditCurrentArgument == GroupPoints->LineEdit3 && myGeomBase->VertexToPoint(S, myPoint3)) { - myEditCurrentArgument->setText(aString); - myOkPoint3 = true; + Standard_Boolean aRes = Standard_False; + GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( mySelection->firstIObject(), aRes ); + if ( !CORBA::is_nil( aSelectedObject ) && aRes ) + { + myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) ); + if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) myPoint1 = aSelectedObject; + else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) myPoint2 = aSelectedObject; + else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) myPoint3 = aSelectedObject; } - if(myOkPoint1 && myOkPoint2 && myOkPoint3) - this->MakeArcSimulationAndDisplay(); - return; + displayPreview(); } @@ -206,24 +206,13 @@ void BasicGUI_ArcDlg::SelectionIntoArgument() void BasicGUI_ArcDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); - mySelection->ClearFilters(); - - if(send == GroupPoints->PushButton1) { - GroupPoints->LineEdit1->setFocus(); - myEditCurrentArgument = GroupPoints->LineEdit1; - } - else if(send == GroupPoints->PushButton2) { - GroupPoints->LineEdit2->setFocus(); - myEditCurrentArgument = GroupPoints->LineEdit2; - } - else if(send == GroupPoints->PushButton3) { - GroupPoints->LineEdit3->setFocus(); - myEditCurrentArgument = GroupPoints->LineEdit3; - } - mySelection->AddFilter(myVertexFilter); - this->SelectionIntoArgument(); - return; + if ( send == Group3Pnts->PushButton1 ) myEditCurrentArgument = Group3Pnts->LineEdit1; + else if ( send == Group3Pnts->PushButton2 ) myEditCurrentArgument = Group3Pnts->LineEdit2; + else if ( send == Group3Pnts->PushButton3 ) myEditCurrentArgument = Group3Pnts->LineEdit3; + + myEditCurrentArgument->setFocus(); + SelectionIntoArgument(); } @@ -234,17 +223,13 @@ void BasicGUI_ArcDlg::SetEditCurrentArgument() void BasicGUI_ArcDlg::LineEditReturnPressed() { QLineEdit* send = (QLineEdit*)sender(); - if(send == GroupPoints->LineEdit1) - myEditCurrentArgument = GroupPoints->LineEdit1; - else if(send == GroupPoints->LineEdit2) - myEditCurrentArgument = GroupPoints->LineEdit2; - else if(send == GroupPoints->LineEdit3) - myEditCurrentArgument = GroupPoints->LineEdit3; - else - return; - - GEOMBase_Skeleton::LineEditReturnPressed(); - return; + if ( send == Group3Pnts->LineEdit1 || + send == Group3Pnts->LineEdit2 || + send == Group3Pnts->LineEdit3 ) + { + myEditCurrentArgument = send; + GEOMBase_Skeleton::LineEditReturnPressed(); + } } @@ -256,12 +241,28 @@ void BasicGUI_ArcDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - mySelection->AddFilter(myVertexFilter); - if(!mySimulationTopoDs.IsNull()) - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - return; + + myGeomGUI->SetState( 0 ); + globalSelection( GEOM_POINT ); + + myEditCurrentArgument = Group3Pnts->LineEdit1; + myEditCurrentArgument->setFocus(); + + Group3Pnts->LineEdit1->setText( "" ); + Group3Pnts->LineEdit2->setText( "" ); + Group3Pnts->LineEdit3->setText( "" ); + myPoint1 = myPoint2 = myPoint3 = GEOM::GEOM_Object::_nil(); } +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : public slot to deactivate if active +//================================================================================= +void BasicGUI_ArcDlg::DeactivateActiveDialog() +{ + myGeomGUI->SetState( -1 ); + GEOMBase_Skeleton::DeactivateActiveDialog(); +} //================================================================================= // function : enterEvent() @@ -269,45 +270,56 @@ void BasicGUI_ArcDlg::ActivateThisDialog() //================================================================================= void BasicGUI_ArcDlg::enterEvent(QEvent* e) { - if(GroupConstructors->isEnabled()) - return; - this->ActivateThisDialog(); - return; + if ( !GroupConstructors->isEnabled() ) + ActivateThisDialog(); } +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr BasicGUI_ArcDlg::createOperation() +{ + return getGeomEngine()->GetICurvesOperations( getStudyId() ); +} + +//================================================================================= +// function : isEqual +// purpose : it may also be needed to check for min distance between gp_Pnt-s... +//================================================================================= +static bool isEqual( const GEOM::GEOM_Object_var& thePnt1, const GEOM::GEOM_Object_var& thePnt2 ) +{ + return thePnt1->_is_equivalent( thePnt2 ); +} //================================================================================= -// function : MakeArcSimulationAndDisplay() +// function : isValid // purpose : //================================================================================= -void BasicGUI_ArcDlg::MakeArcSimulationAndDisplay() +bool BasicGUI_ArcDlg::isValid( QString& msg ) { - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); - - try { - if(myPoint2.IsEqual(myPoint1, Precision::Confusion()) || - myPoint2.IsEqual(myPoint3, Precision::Confusion())) { - myEditCurrentArgument->setText(""); - return; - } - - gp_Vec v1(myPoint2, myPoint1); - gp_Vec v2(myPoint2, myPoint3); - if(v1.IsParallel(v2, Precision::Angular())) { - myEditCurrentArgument->setText(""); - return; - } - - GC_MakeArcOfCircle Arc(myPoint1, myPoint2, myPoint3); - if(Arc.IsDone()) { - Handle(Geom_TrimmedCurve) curve = Arc.Value(); - mySimulationTopoDs = BRepBuilderAPI_MakeEdge(curve).Shape(); - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - } - } - catch(Standard_Failure) { - MESSAGE("Exception catched in MakeArcSimulationAndDisplay"); - } - return; + return !myPoint1->_is_nil() && !myPoint2->_is_nil() && !myPoint3->_is_nil() && + !isEqual( myPoint1, myPoint2 ) && !isEqual( myPoint1, myPoint3 ) && !isEqual( myPoint2, myPoint3 ); +} + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool BasicGUI_ArcDlg::execute( ObjectList& objects ) +{ + GEOM::GEOM_Object_var anObj = GEOM::GEOM_ICurvesOperations::_narrow( getOperation() )->MakeArc( myPoint1, myPoint2, myPoint3 ); + if ( !anObj->_is_nil() ) + objects.push_back( anObj._retn() ); + return true; +} + +//================================================================================= +// function : closeEvent +// purpose : +//================================================================================= +void BasicGUI_ArcDlg::closeEvent( QCloseEvent* e ) +{ + myGeomGUI->SetState( -1 ); + GEOMBase_Skeleton::closeEvent( e ); } diff --git a/src/BasicGUI/BasicGUI_ArcDlg.h b/src/BasicGUI/BasicGUI_ArcDlg.h index 408e7077b..b34721521 100644 --- a/src/BasicGUI/BasicGUI_ArcDlg.h +++ b/src/BasicGUI/BasicGUI_ArcDlg.h @@ -32,9 +32,6 @@ #include "GEOMBase_Skeleton.h" #include "DlgRef_3Sel_QTD.h" -#include "BasicGUI.h" -#include "GEOM_ShapeTypeFilter.hxx" - //================================================================================= // class : BasicGUI_ArcDlg // purpose : @@ -44,30 +41,33 @@ class BasicGUI_ArcDlg : public GEOMBase_Skeleton Q_OBJECT public: - BasicGUI_ArcDlg( QWidget* parent = 0, const char* name = 0, BasicGUI* theBasicGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + BasicGUI_ArcDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); ~BasicGUI_ArcDlg(); +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& ); + virtual bool execute( ObjectList& objects ); + + virtual void closeEvent( QCloseEvent* e ); + private : void Init(); void enterEvent(QEvent* e); - void MakeArcSimulationAndDisplay(); - - BasicGUI* myBasicGUI; - Handle(GEOM_ShapeTypeFilter) myVertexFilter; /* Filter selection */ - gp_Pnt myPoint1; - gp_Pnt myPoint2; - gp_Pnt myPoint3; - bool myOkPoint1; - bool myOkPoint2; - bool myOkPoint3; + GEOM::GEOM_Object_var myPoint1, myPoint2, myPoint3; - DlgRef_3Sel_QTD* GroupPoints; + DlgRef_3Sel_QTD* Group3Pnts; private slots: void ClickOnOk(); - void ClickOnApply(); + void ClickOnCancel(); + bool ClickOnApply(); + void ActivateThisDialog(); + void DeactivateActiveDialog(); + void LineEditReturnPressed(); void SelectionIntoArgument(); void SetEditCurrentArgument(); diff --git a/src/BasicGUI/BasicGUI_CircleDlg.cxx b/src/BasicGUI/BasicGUI_CircleDlg.cxx index a10e4049f..105e3becd 100644 --- a/src/BasicGUI/BasicGUI_CircleDlg.cxx +++ b/src/BasicGUI/BasicGUI_CircleDlg.cxx @@ -28,15 +28,12 @@ #include "BasicGUI_CircleDlg.h" -#include -#include -#include -#include +#include "QAD_Desktop.h" #include "QAD_Config.h" -#include "utilities.h" +#include "GEOMImpl_Types.hxx" -using namespace std; +#include "utilities.h" //================================================================================= // class : BasicGUI_CircleDlg() @@ -45,10 +42,11 @@ using namespace std; // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -BasicGUI_CircleDlg::BasicGUI_CircleDlg(QWidget* parent, const char* name, BasicGUI* theBasicGUI, SALOME_Selection* Sel, bool modal, WFlags fl) +BasicGUI_CircleDlg::BasicGUI_CircleDlg(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_CIRCLE_PV"))); + QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_CIRCLE_PNTS"))); QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); setCaption(tr("GEOM_CIRCLE_TITLE")); @@ -56,22 +54,38 @@ BasicGUI_CircleDlg::BasicGUI_CircleDlg(QWidget* parent, const char* name, BasicG /***************************************************************/ GroupConstructors->setTitle(tr("GEOM_CIRCLE")); RadioButton1->setPixmap(image0); - RadioButton2->close(TRUE); + RadioButton2->setPixmap(image2); RadioButton3->close(TRUE); - GroupPoints = new DlgRef_2Sel1Spin(this, "GroupPoints"); - GroupPoints->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); - GroupPoints->TextLabel1->setText(tr("GEOM_CENTER_POINT")); - GroupPoints->TextLabel2->setText(tr("GEOM_VECTOR")); - GroupPoints->TextLabel3->setText(tr("GEOM_RADIUS")); - GroupPoints->PushButton1->setPixmap(image1); - GroupPoints->PushButton2->setPixmap(image1); - - Layout1->addWidget(GroupPoints, 1, 0); + GroupPntVecR = new DlgRef_2Sel1Spin(this, "GroupPntVecR"); + GroupPntVecR->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); + + GroupPntVecR->TextLabel1->setText(tr("GEOM_CENTER_POINT")); + GroupPntVecR->TextLabel2->setText(tr("GEOM_VECTOR")); + GroupPntVecR->TextLabel3->setText(tr("GEOM_RADIUS")); + GroupPntVecR->PushButton1->setPixmap(image1); + GroupPntVecR->PushButton2->setPixmap(image1); + + GroupPntVecR->LineEdit1->setReadOnly( true ); + GroupPntVecR->LineEdit2->setReadOnly( true ); + + Group3Pnts = new DlgRef_3Sel_QTD(this, "Group3Pnts"); + Group3Pnts->GroupBox1->setTitle(tr("GEOM_3_POINTS")); + Group3Pnts->TextLabel1->setText(tr("GEOM_POINT1")); + Group3Pnts->TextLabel2->setText(tr("GEOM_POINT2")); + Group3Pnts->TextLabel3->setText(tr("GEOM_POINT3")); + Group3Pnts->PushButton1->setPixmap(image1); + Group3Pnts->PushButton2->setPixmap(image1); + Group3Pnts->PushButton3->setPixmap(image1); + + Group3Pnts->LineEdit1->setReadOnly( true ); + Group3Pnts->LineEdit2->setReadOnly( true ); + Group3Pnts->LineEdit3->setReadOnly( true ); + + Layout1->addWidget( GroupPntVecR, 2, 0 ); + Layout1->addWidget( Group3Pnts, 2, 0 ); /***************************************************************/ - /* Initialisations */ - myBasicGUI = theBasicGUI; Init(); } @@ -82,7 +96,6 @@ BasicGUI_CircleDlg::BasicGUI_CircleDlg(QWidget* parent, const char* name, BasicG //================================================================================= BasicGUI_CircleDlg::~BasicGUI_CircleDlg() { - // no need to delete child widgets, Qt does it all for us } @@ -93,45 +106,89 @@ BasicGUI_CircleDlg::~BasicGUI_CircleDlg() void BasicGUI_CircleDlg::Init() { /* init variables */ - myEditCurrentArgument = GroupPoints->LineEdit1; + myEditCurrentArgument = GroupPntVecR->LineEdit1; - myRadius = 100.0; - myOkPoint1 = myOkDir = false; + myPoint = myDir = myPoint1 = myPoint2 = myPoint3 = GEOM::GEOM_Object::_nil(); - myEdgeFilter = new GEOM_ShapeTypeFilter(TopAbs_EDGE, myGeom); - myVertexFilter = new GEOM_ShapeTypeFilter(TopAbs_VERTEX, myGeom); - mySelection->AddFilter(myVertexFilter); + myGeomGUI->SetState( 0 ); /* Get setting of step value from file configuration */ QString St = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep"); - step = St.toDouble(); + double aStep = St.toDouble(); /* min, max, step and decimals for spin boxes & initial values */ - GroupPoints->SpinBox_DX->RangeStepAndValidator(0.001, 999.999, step, 3); - GroupPoints->SpinBox_DX->SetValue(myRadius); + GroupPntVecR->SpinBox_DX->RangeStepAndValidator(0.001, 999.999, aStep, 3); + GroupPntVecR->SpinBox_DX->SetValue( 100 ); /* 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(GroupConstructors, SIGNAL(clicked(int)), this, SLOT(ConstructorsClicked(int))); - connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupPntVecR->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupPntVecR->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(Group3Pnts->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(Group3Pnts->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(Group3Pnts->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(GroupPntVecR->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(GroupPntVecR->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox_DX, SLOT(SetStep(double))); + connect(GroupPntVecR->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPntVecR->SpinBox_DX, SLOT(SetStep(double))); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ; - /* displays Dialog */ - GroupPoints->show(); - this->show(); + initName( tr( "GEOM_CIRCLE" ) ); - return; + Group3Pnts->hide(); + ConstructorsClicked( 0 ); } +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void BasicGUI_CircleDlg::ConstructorsClicked( int constructorId ) +{ + disconnect( mySelection, 0, this, 0 ); + myPoint = myDir = myPoint1 = myPoint2 = myPoint3 = GEOM::GEOM_Object::_nil(); + + switch ( constructorId ) + { + case 0: + { + Group3Pnts->hide(); + resize(0, 0); + GroupPntVecR->show(); + + myEditCurrentArgument = GroupPntVecR->LineEdit1; + GroupPntVecR->LineEdit1->setText(""); + GroupPntVecR->LineEdit2->setText(""); + break; + } + case 1: + { + GroupPntVecR->hide(); + resize( 0, 0 ); + Group3Pnts->show(); + + myEditCurrentArgument = Group3Pnts->LineEdit1; + Group3Pnts->LineEdit1->setText(""); + Group3Pnts->LineEdit2->setText(""); + Group3Pnts->LineEdit3->setText(""); + break; + } + } + + myEditCurrentArgument->setFocus(); + globalSelection( GEOM_POINT ); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); +} //================================================================================= // function : ClickOnOk() @@ -139,29 +196,32 @@ void BasicGUI_CircleDlg::Init() //================================================================================= void BasicGUI_CircleDlg::ClickOnOk() { - this->ClickOnApply(); - ClickOnCancel(); - return; + if ( ClickOnApply() ) + ClickOnCancel(); } //================================================================================= // function : ClickOnApply() // purpose : //================================================================================= -void BasicGUI_CircleDlg::ClickOnApply() +bool BasicGUI_CircleDlg::ClickOnApply() { - buttonApply->setFocus(); - QAD_Application::getDesktop()->putInfo(tr("")); - if (mySimulationTopoDs.IsNull()) - return; - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); + if ( !onAccept() ) + return false; - if(myOkPoint1 && myOkDir) - myBasicGUI->MakeCircleAndDisplay(myPoint1, myDir, myRadius); - return; + initName(); + ConstructorsClicked( getConstructorId() ); + return true; } +//======================================================================= +// function : ClickOnCancel() +// purpose : +//======================================================================= +void BasicGUI_CircleDlg::ClickOnCancel() +{ + GEOMBase_Skeleton::ClickOnCancel(); +} //================================================================================= // function : SelectionIntoArgument() @@ -169,40 +229,32 @@ void BasicGUI_CircleDlg::ClickOnApply() //================================================================================= void BasicGUI_CircleDlg::SelectionIntoArgument() { - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); myEditCurrentArgument->setText(""); - QString aString = ""; /* name of selection */ - int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString); - if (nbSel != 1) { - if(myEditCurrentArgument == GroupPoints->LineEdit1) - myOkPoint1 = false; - else if (myEditCurrentArgument == GroupPoints->LineEdit2) - myOkDir = false; + if ( mySelection->IObjectCount() != 1 ) + { + if ( myEditCurrentArgument == GroupPntVecR->LineEdit1 ) myPoint = GEOM::GEOM_Object::_nil(); + else if ( myEditCurrentArgument == GroupPntVecR->LineEdit2 ) myDir = GEOM::GEOM_Object::_nil(); + else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) myPoint1 = GEOM::GEOM_Object::_nil(); + else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) myPoint2 = GEOM::GEOM_Object::_nil(); + else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) myPoint3 = GEOM::GEOM_Object::_nil(); return; } - /* nbSel == 1 */ - TopoDS_Shape S; - if(!myGeomBase->GetTopoFromSelection(mySelection, S)) - return; - - /* gp_Pnt : not used */ - if(myEditCurrentArgument == GroupPoints->LineEdit1 && myGeomBase->VertexToPoint(S, myPoint1)) { - GroupPoints->LineEdit1->setText(aString); - myOkPoint1 = true; - } - else if(myEditCurrentArgument == GroupPoints->LineEdit2) { - BRepAdaptor_Curve curv(TopoDS::Edge(S)); - myDir = curv.Line().Direction(); - GroupPoints->LineEdit2->setText(aString); - myOkDir = true; + // nbSel == 1 + Standard_Boolean aRes = Standard_False; + GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( mySelection->firstIObject(), aRes ); + if ( !CORBA::is_nil( aSelectedObject ) && aRes ) + { + myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) ); + if ( myEditCurrentArgument == GroupPntVecR->LineEdit1 ) myPoint = aSelectedObject; + else if ( myEditCurrentArgument == GroupPntVecR->LineEdit2 ) myDir = aSelectedObject; + else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) myPoint1 = aSelectedObject; + else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) myPoint2 = aSelectedObject; + else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) myPoint3 = aSelectedObject; } - if(myOkPoint1 && myOkDir) - this->MakeCircleSimulationAndDisplay(); - return; + displayPreview(); } @@ -213,21 +265,20 @@ void BasicGUI_CircleDlg::SelectionIntoArgument() void BasicGUI_CircleDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); - mySelection->ClearFilters(); - if(send == GroupPoints->PushButton1) { - GroupPoints->LineEdit1->setFocus(); - myEditCurrentArgument = GroupPoints->LineEdit1; - mySelection->AddFilter(myVertexFilter); - } - else if(send == GroupPoints->PushButton2) { - GroupPoints->LineEdit2->setFocus(); - myEditCurrentArgument = GroupPoints->LineEdit2; - mySelection->AddFilter(myEdgeFilter); - } - this->SelectionIntoArgument(); - - return; + if ( send == GroupPntVecR->PushButton1 ) myEditCurrentArgument = GroupPntVecR->LineEdit1; + else if ( send == GroupPntVecR->PushButton2 ) myEditCurrentArgument = GroupPntVecR->LineEdit2; + else if ( send == Group3Pnts->PushButton1 ) myEditCurrentArgument = Group3Pnts->LineEdit1; + else if ( send == Group3Pnts->PushButton2 ) myEditCurrentArgument = Group3Pnts->LineEdit2; + else if ( send == Group3Pnts->PushButton3 ) myEditCurrentArgument = Group3Pnts->LineEdit3; + + myEditCurrentArgument->setFocus(); + + if ( myEditCurrentArgument == GroupPntVecR->LineEdit2 ) + globalSelection( GEOM_LINE ); + else + globalSelection( GEOM_POINT ); + SelectionIntoArgument(); } //================================================================================= @@ -237,15 +288,15 @@ void BasicGUI_CircleDlg::SetEditCurrentArgument() void BasicGUI_CircleDlg::LineEditReturnPressed() { QLineEdit* send = (QLineEdit*)sender(); - if(send == GroupPoints->LineEdit1) - myEditCurrentArgument = GroupPoints->LineEdit1; - else if (send == GroupPoints->LineEdit2) - myEditCurrentArgument = GroupPoints->LineEdit2; - else - return; - - GEOMBase_Skeleton::LineEditReturnPressed(); - return; + if ( send == GroupPntVecR->LineEdit1 || + send == GroupPntVecR->LineEdit2 || + send == Group3Pnts->LineEdit1 || + send == Group3Pnts->LineEdit2 || + send == Group3Pnts->LineEdit3 ) + { + myEditCurrentArgument = send; + GEOMBase_Skeleton::LineEditReturnPressed(); + } } @@ -256,13 +307,12 @@ void BasicGUI_CircleDlg::LineEditReturnPressed() void BasicGUI_CircleDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); + globalSelection( GEOM_POINT ); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - GroupPoints->LineEdit1->setFocus(); - myEditCurrentArgument = GroupPoints->LineEdit1; - mySelection->AddFilter(myVertexFilter); - if(!mySimulationTopoDs.IsNull()) - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - return; + + myGeomGUI->SetState( 0 ); + + ConstructorsClicked( getConstructorId() ); } @@ -272,44 +322,106 @@ void BasicGUI_CircleDlg::ActivateThisDialog() //================================================================================= void BasicGUI_CircleDlg::enterEvent(QEvent* e) { - if(GroupConstructors->isEnabled()) - return; - this->ActivateThisDialog(); - return; + if ( !GroupConstructors->isEnabled() ) + ActivateThisDialog(); } +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : public slot to deactivate if active +//================================================================================= +void BasicGUI_CircleDlg::DeactivateActiveDialog() +{ + myGeomGUI->SetState( -1 ); + GEOMBase_Skeleton::DeactivateActiveDialog(); +} //================================================================================= // function : ValueChangedInSpinBox() // purpose : //================================================================================= -void BasicGUI_CircleDlg::ValueChangedInSpinBox(double newValue) +void BasicGUI_CircleDlg::ValueChangedInSpinBox() { - myRadius = newValue; - if(myOkPoint1 && myOkDir) - MakeCircleSimulationAndDisplay(); - return; + displayPreview(); } +//================================================================================= +// function : getRadius() +// purpose : +//================================================================================= +double BasicGUI_CircleDlg::getRadius() const +{ + return GroupPntVecR->SpinBox_DX->GetValue(); +} //================================================================================= -// function : MakeCircleSimulationAndDisplay() +// function : createOperation // purpose : //================================================================================= -void BasicGUI_CircleDlg::MakeCircleSimulationAndDisplay() +GEOM::GEOM_IOperations_ptr BasicGUI_CircleDlg::createOperation() { - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); - - try { - gp_Ax2 anAxis(myPoint1, myDir); - gp_Circ circ(anAxis, myRadius); - BRepBuilderAPI_MakeEdge MakeEdge(circ); - mySimulationTopoDs = MakeEdge.Shape(); - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - } - catch(Standard_Failure) { - MESSAGE("Exception catched in MakeCircleSimulationAndDisplay"); + return getGeomEngine()->GetICurvesOperations( getStudyId() ); +} + +//================================================================================= +// function : isEqual +// purpose : it may also be needed to check for min distance between gp_Pnt-s... +//================================================================================= +static bool isEqual( const GEOM::GEOM_Object_var& thePnt1, const GEOM::GEOM_Object_var& thePnt2 ) +{ + return thePnt1->_is_equivalent( thePnt2 ); +} + +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool BasicGUI_CircleDlg::isValid( QString& msg ) +{ + const int id = getConstructorId(); + if ( id == 0 ) + return !myPoint->_is_nil() && !myDir->_is_nil() && getRadius() > 0; + else if ( id == 1 ) + return !myPoint1->_is_nil() && !myPoint2->_is_nil() && !myPoint3->_is_nil() && + !isEqual( myPoint1, myPoint2 ) && !isEqual( myPoint1, myPoint3 ) && !isEqual( myPoint2, myPoint3 ); + return false; +} + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool BasicGUI_CircleDlg::execute( ObjectList& objects ) +{ + bool res = false; + + GEOM::GEOM_Object_var anObj; + + switch ( getConstructorId() ) + { + case 0 : + anObj = GEOM::GEOM_ICurvesOperations::_narrow( getOperation() )->MakeCirclePntVecR( myPoint, myDir, getRadius() ); + res = true; + break; + case 1 : + anObj = GEOM::GEOM_ICurvesOperations::_narrow( getOperation() )->MakeCircleThreePnt( myPoint1, myPoint2, myPoint3 ); + res = true; + break; } - return; + + if ( !anObj->_is_nil() ) + objects.push_back( anObj._retn() ); + + return res; +} + +//================================================================================= +// function : closeEvent +// purpose : +//================================================================================= +void BasicGUI_CircleDlg::closeEvent( QCloseEvent* e ) +{ + myGeomGUI->SetState( -1 ); + GEOMBase_Skeleton::closeEvent( e ); } + diff --git a/src/BasicGUI/BasicGUI_CircleDlg.h b/src/BasicGUI/BasicGUI_CircleDlg.h index 1ed69fb55..a44c5df83 100644 --- a/src/BasicGUI/BasicGUI_CircleDlg.h +++ b/src/BasicGUI/BasicGUI_CircleDlg.h @@ -31,12 +31,15 @@ #include "GEOMBase_Skeleton.h" #include "DlgRef_2Sel1Spin.h" +#include "DlgRef_3Sel_QTD.h" #include "BasicGUI.h" +#include "GEOM_EdgeFilter.hxx" #include "GEOM_ShapeTypeFilter.hxx" #include + //================================================================================= // class : BasicGUI_CircleDlg // purpose : @@ -46,36 +49,41 @@ class BasicGUI_CircleDlg : public GEOMBase_Skeleton Q_OBJECT public: - BasicGUI_CircleDlg(QWidget* parent = 0, const char* name = 0, BasicGUI* theBasicGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + BasicGUI_CircleDlg(QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); ~BasicGUI_CircleDlg(); -private : - void Init(); - void enterEvent(QEvent* e); - void MakeCircleSimulationAndDisplay(); +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& ); + virtual bool execute( ObjectList& objects ); - BasicGUI* myBasicGUI; + virtual void closeEvent( QCloseEvent* e ); - double step; - Handle(GEOM_ShapeTypeFilter) myVertexFilter; - Handle(GEOM_ShapeTypeFilter) myEdgeFilter; /* Filter selection */ +private : + void Init(); + void enterEvent(QEvent* e); + double getRadius() const; - gp_Pnt myPoint1; - gp_Dir myDir; - Standard_Real myRadius; - bool myOkPoint1; - bool myOkDir; + GEOM::GEOM_Object_var myPoint, myDir, myPoint1, myPoint2, myPoint3; - DlgRef_2Sel1Spin* GroupPoints; + DlgRef_2Sel1Spin* GroupPntVecR; + DlgRef_3Sel_QTD* Group3Pnts; private slots: void ClickOnOk(); - void ClickOnApply(); + void ClickOnCancel(); + bool ClickOnApply(); + void ActivateThisDialog(); - void LineEditReturnPressed(); + void DeactivateActiveDialog(); + void SelectionIntoArgument(); + + void ConstructorsClicked( int ); + void LineEditReturnPressed(); void SetEditCurrentArgument(); - void ValueChangedInSpinBox(double newValue); + void ValueChangedInSpinBox(); }; diff --git a/src/BasicGUI/BasicGUI_CurveDlg.cxx b/src/BasicGUI/BasicGUI_CurveDlg.cxx new file mode 100644 index 000000000..245fe07a8 --- /dev/null +++ b/src/BasicGUI/BasicGUI_CurveDlg.cxx @@ -0,0 +1,318 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE +// +// 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 : BasicGUI_CurveDlg.cxx +// Author : Nicolas REJNERI +// Module : GEOM +// $Header$ + +#include "BasicGUI_CurveDlg.h" + +#include "QAD_Desktop.h" +#include "QAD_Config.h" +#include "utilities.h" + +#include "SALOME_ListIteratorOfListIO.hxx" +#include "SALOME_ListIO.hxx" + +#include "GEOMImpl_Types.hxx" + +using namespace std; + +//================================================================================= +// class : BasicGUI_CurveDlg() +// purpose : Constructs a BasicGUI_CurveDlg 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. +//================================================================================= +BasicGUI_CurveDlg::BasicGUI_CurveDlg(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_POLYLINE"))); + QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_SPLINE"))); + QPixmap image3(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_BEZIER"))); + + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); + + setCaption(tr("GEOM_CURVE_TITLE")); + + /***************************************************************/ + RadioButton1->setPixmap( image0 ); + RadioButton2->setPixmap( image3 ); + RadioButton3->setPixmap( image2 ); + + GroupPoints = new DlgRef_1Sel_QTD( this, "GroupPoints" ); + GroupPoints->GroupBox1->setTitle( tr( "GEOM_NODES" ) ); + GroupPoints->TextLabel1->setText( tr("GEOM_POINTS") ); + GroupPoints->PushButton1->setPixmap(image1); + + GroupPoints->LineEdit1->setReadOnly( true ); + + Layout1->addWidget(GroupPoints, 2, 0); + /***************************************************************/ + + Init(); +} + + +//================================================================================= +// function : ~BasicGUI_CurveDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +BasicGUI_CurveDlg::~BasicGUI_CurveDlg() +{ +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void BasicGUI_CurveDlg::Init() +{ + /* init variables */ + myEditCurrentArgument = GroupPoints->LineEdit1; + + myPoints = new GEOM::ListOfGO(); + myPoints->length( 0 ); + + globalSelection( GEOM_POINT ); + + /* 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(GroupConstructors, SIGNAL(clicked(int)), this, SLOT(ConstructorsClicked(int))); + + connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ; + + initName( tr( "GEOM_CURVE" ) ); + ConstructorsClicked( 0 ); +} + +//================================================================================= +// function : ConstructorsClicked() +// purpose : +//================================================================================= +void BasicGUI_CurveDlg::ConstructorsClicked( int id ) +{ + QString aTitle = tr( id == 0 ? "GEOM_POLYLINE" : id == 1 ? "GEOM_BEZIER" : "GEOM_INTERPOL" ); + GroupConstructors->setTitle( aTitle ); + + myPoints = new GEOM::ListOfGO(); + myPoints->length( 0 ); + + myEditCurrentArgument->setText(""); +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void BasicGUI_CurveDlg::SetEditCurrentArgument() +{ + if ( sender() == GroupPoints->PushButton1 ) + myEditCurrentArgument = GroupPoints->LineEdit1; + myEditCurrentArgument->setFocus(); + SelectionIntoArgument(); +} + + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void BasicGUI_CurveDlg::LineEditReturnPressed() +{ + if ( sender() == GroupPoints->LineEdit1 ) + { + myEditCurrentArgument = GroupPoints->LineEdit1; + GEOMBase_Skeleton::LineEditReturnPressed(); + } +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void BasicGUI_CurveDlg::ClickOnOk() +{ + if ( ClickOnApply() ) + ClickOnCancel(); +} + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +bool BasicGUI_CurveDlg::ClickOnApply() +{ + if ( !onAccept() ) + return false; + + initName(); + ConstructorsClicked( getConstructorId() ); + return true; +} + +//======================================================================= +// function : ClickOnCancel() +// purpose : +//======================================================================= +void BasicGUI_CurveDlg::ClickOnCancel() +{ + GEOMBase_Skeleton::ClickOnCancel(); +} + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void BasicGUI_CurveDlg::SelectionIntoArgument() +{ + myEditCurrentArgument->setText(""); + + Standard_Boolean aRes = Standard_False; + int i = 0; + myPoints->length( mySelection->IObjectCount() ); // this length may be greater than number of objects, + // that will actually be put into myPoints + for ( SALOME_ListIteratorOfListIO anIt( mySelection->StoredIObjects() ); anIt.More(); anIt.Next() ) + { + GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( anIt.Value(), aRes ); + if ( !CORBA::is_nil( aSelectedObject ) && aRes ) + { + //TopoDS_Shape aPointShape; + //if ( myGeomBase->GetShape( aSelectedObject, aPointShape, TopAbs_VERTEX ) ) + myPoints[i++] = aSelectedObject; + } + } + myPoints->length( i ); // this is the right length, smaller of equal to the previously set + if ( i ) + GroupPoints->LineEdit1->setText( QString::number( i ) + "_" + tr( "GEOM_POINT" ) + tr( "_S_" ) ); + + displayPreview(); +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void BasicGUI_CurveDlg::ActivateThisDialog() +{ + GEOMBase_Skeleton::ActivateThisDialog(); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + + myGeomGUI->SetState( 0 ); + + globalSelection( GEOM_POINT ); + ConstructorsClicked( getConstructorId() ); +} + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : public slot to deactivate if active +//================================================================================= +void BasicGUI_CurveDlg::DeactivateActiveDialog() +{ + myGeomGUI->SetState( -1 ); + GEOMBase_Skeleton::DeactivateActiveDialog(); +} + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void BasicGUI_CurveDlg::enterEvent(QEvent* e) +{ + if ( !GroupConstructors->isEnabled() ) + ActivateThisDialog(); +} + +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr BasicGUI_CurveDlg::createOperation() +{ + return getGeomEngine()->GetICurvesOperations( getStudyId() ); +} + +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool BasicGUI_CurveDlg::isValid( QString& msg ) +{ + return myPoints->length() > 1; +} + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool BasicGUI_CurveDlg::execute( ObjectList& objects ) +{ + bool res = false; + + GEOM::GEOM_Object_var anObj; + + switch ( getConstructorId() ) + { + case 0 : + anObj = GEOM::GEOM_ICurvesOperations::_narrow( getOperation() )->MakePolyline( myPoints ); + res = true; + break; + case 1 : + anObj = GEOM::GEOM_ICurvesOperations::_narrow( getOperation() )->MakeSplineBezier( myPoints ); + res = true; + break; + case 2 : + anObj = GEOM::GEOM_ICurvesOperations::_narrow( getOperation() )->MakeSplineInterpolation( myPoints ); + res = true; + break; + } + + if ( !anObj->_is_nil() ) + objects.push_back( anObj._retn() ); + + return res; +} + +//================================================================================= +// function : closeEvent +// purpose : +//================================================================================= +void BasicGUI_CurveDlg::closeEvent( QCloseEvent* e ) +{ + myGeomGUI->SetState( -1 ); + GEOMBase_Skeleton::closeEvent( e ); +} + diff --git a/src/BasicGUI/BasicGUI_CurveDlg.h b/src/BasicGUI/BasicGUI_CurveDlg.h new file mode 100644 index 000000000..24cee9eaf --- /dev/null +++ b/src/BasicGUI/BasicGUI_CurveDlg.h @@ -0,0 +1,80 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE +// +// 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 : BasicGUI_CurveDlg.h +// Author : Alexander SLADKOV +// Module : GEOM +// $Header$ + +#ifndef BASICGUI_CURVE_H +#define BASICGUI_CURVE_H + +#include "GEOMBase_Skeleton.h" +#include "DlgRef_1Sel_QTD.h" + +#include "BasicGUI.h" + +#include "GEOM_ShapeTypeFilter.hxx" + +//================================================================================= +// class : BasicGUI_CurveDlg +// purpose : +//================================================================================= +class BasicGUI_CurveDlg : public GEOMBase_Skeleton +{ + Q_OBJECT + +public: + BasicGUI_CurveDlg(QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + ~BasicGUI_CurveDlg(); + +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& ); + virtual bool execute( ObjectList& objects ); + + virtual void closeEvent( QCloseEvent* e ); + +private : + void Init(); + void enterEvent(QEvent* e); + + DlgRef_1Sel_QTD* GroupPoints; + GEOM::ListOfGO_var myPoints; + +private slots: + void ClickOnOk(); + void ClickOnCancel(); + bool ClickOnApply(); + + void ActivateThisDialog(); + void DeactivateActiveDialog(); + + void ConstructorsClicked( int ); + void LineEditReturnPressed(); + void SelectionIntoArgument(); + void SetEditCurrentArgument(); + +}; + +#endif // BASICGUI_CURVE_H diff --git a/src/BasicGUI/BasicGUI_EllipseDlg.cxx b/src/BasicGUI/BasicGUI_EllipseDlg.cxx index 80321b426..9f8d5bb90 100644 --- a/src/BasicGUI/BasicGUI_EllipseDlg.cxx +++ b/src/BasicGUI/BasicGUI_EllipseDlg.cxx @@ -26,13 +26,11 @@ // $Header$ #include "BasicGUI_EllipseDlg.h" - -#include -#include -#include -#include +#include "QAD_Desktop.h" #include "QAD_Config.h" +#include "GEOMImpl_Types.hxx" + #include "utilities.h" using namespace std; @@ -44,7 +42,7 @@ using namespace std; // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -BasicGUI_EllipseDlg::BasicGUI_EllipseDlg(QWidget* parent, const char* name, BasicGUI* theBasicGUI, SALOME_Selection* Sel, bool modal, WFlags fl) +BasicGUI_EllipseDlg::BasicGUI_EllipseDlg(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_ELLIPSE_PV"))); @@ -62,16 +60,17 @@ BasicGUI_EllipseDlg::BasicGUI_EllipseDlg(QWidget* parent, const char* name, Basi GroupPoints->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); GroupPoints->TextLabel1->setText(tr("GEOM_CENTER")); GroupPoints->TextLabel2->setText(tr("GEOM_VECTOR")); - GroupPoints->TextLabel3->setText(tr("GEOM_RADIUS_MINOR")); - GroupPoints->TextLabel4->setText(tr("GEOM_RADIUS_MAJOR")); + GroupPoints->TextLabel3->setText(tr("GEOM_RADIUS_MAJOR")); + GroupPoints->TextLabel4->setText(tr("GEOM_RADIUS_MINOR")); GroupPoints->PushButton1->setPixmap(image1); GroupPoints->PushButton2->setPixmap(image1); - Layout1->addWidget(GroupPoints, 1, 0); + GroupPoints->LineEdit1->setReadOnly( true ); + GroupPoints->LineEdit2->setReadOnly( true ); + + Layout1->addWidget(GroupPoints, 2, 0); /***************************************************************/ - /* Initialisations */ - myBasicGUI = theBasicGUI; Init(); } @@ -82,7 +81,6 @@ BasicGUI_EllipseDlg::BasicGUI_EllipseDlg(QWidget* parent, const char* name, Basi //================================================================================= BasicGUI_EllipseDlg::~BasicGUI_EllipseDlg() { - // no need to delete child widgets, Qt does it all for us } @@ -94,26 +92,28 @@ void BasicGUI_EllipseDlg::Init() { /* init variables */ myEditCurrentArgument = GroupPoints->LineEdit1; + globalSelection( GEOM_POINT ); - myMajorRadius = 200.0; - myMinorRadius = 100.0; - myOkPoint = myOkDir = false; + myPoint = myDir = GEOM::GEOM_Object::_nil(); - myEdgeFilter = new GEOM_ShapeTypeFilter(TopAbs_EDGE, myGeom); - myVertexFilter = new GEOM_ShapeTypeFilter(TopAbs_VERTEX, myGeom); - mySelection->AddFilter(myVertexFilter); + myGeomGUI->SetState( 0 ); /* Get setting of step value from file configuration */ QString St = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep"); - step = St.toDouble(); + double step = St.toDouble(); + double aMajorR( 200. ), aMinorR( 100. ); /* min, max, step and decimals for spin boxes & initial values */ - GroupPoints->SpinBox_DX->RangeStepAndValidator(0.001, 999.999, step, 3); - GroupPoints->SpinBox_DY->RangeStepAndValidator(0.001, 999.999, step, 3); - GroupPoints->SpinBox_DX->SetValue(myMajorRadius); - GroupPoints->SpinBox_DY->SetValue(myMinorRadius); + GroupPoints->SpinBox_DX->RangeStepAndValidator( 0.001, 999.999, step, 3 ); + GroupPoints->SpinBox_DY->RangeStepAndValidator( 0.001, 999.999, step, 3 ); + GroupPoints->SpinBox_DX->SetValue( aMajorR ); + GroupPoints->SpinBox_DY->SetValue( aMinorR ); /* 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())); @@ -131,11 +131,7 @@ void BasicGUI_EllipseDlg::Init() connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ; - /* displays Dialog */ - GroupPoints->show(); - this->show(); - - return; + initName( tr( "GEOM_ELLIPSE" ) ); } @@ -145,28 +141,40 @@ void BasicGUI_EllipseDlg::Init() //================================================================================= void BasicGUI_EllipseDlg::ClickOnOk() { - this->ClickOnApply(); - ClickOnCancel(); - return; + if ( ClickOnApply() ) + ClickOnCancel(); } + //================================================================================= // function : ClickOnApply() // purpose : //================================================================================= -void BasicGUI_EllipseDlg::ClickOnApply() +bool BasicGUI_EllipseDlg::ClickOnApply() { - buttonApply->setFocus(); - QAD_Application::getDesktop()->putInfo(tr("")); - if (mySimulationTopoDs.IsNull()) - return; - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); + if ( !onAccept() ) + return false; - if(myOkPoint && myOkDir) - myBasicGUI->MakeEllipseAndDisplay(myPoint, myDir, myMajorRadius, myMinorRadius); + initName(); + + // reset + myPoint = myDir = GEOM::GEOM_Object::_nil(); + GroupPoints->LineEdit1->setText( "" ); + GroupPoints->LineEdit2->setText( "" ); + myEditCurrentArgument = GroupPoints->LineEdit1; + globalSelection( GEOM_POINT ); + + return true; } +//======================================================================= +// function : ClickOnCancel() +// purpose : +//======================================================================= +void BasicGUI_EllipseDlg::ClickOnCancel() +{ + GEOMBase_Skeleton::ClickOnCancel(); +} //================================================================================= // function : SelectionIntoArgument() @@ -174,40 +182,25 @@ void BasicGUI_EllipseDlg::ClickOnApply() //================================================================================= void BasicGUI_EllipseDlg::SelectionIntoArgument() { - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); myEditCurrentArgument->setText(""); - QString aString = ""; /* name of selection */ - - int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString); - if (nbSel != 1) { - if(myEditCurrentArgument == GroupPoints->LineEdit1) - myOkPoint = false; - else if (myEditCurrentArgument == GroupPoints->LineEdit2) - myOkDir = false; + + if ( mySelection->IObjectCount() != 1 ) + { + if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) myPoint = GEOM::GEOM_Object::_nil(); + else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) myDir = GEOM::GEOM_Object::_nil(); return; } - /* nbSel == 1 */ - TopoDS_Shape S; - if(!myGeomBase->GetTopoFromSelection(mySelection, S)) - return; - - /* gp_Pnt : not used */ - if(myEditCurrentArgument == GroupPoints->LineEdit1 && myGeomBase->VertexToPoint(S, myPoint)) { - GroupPoints->LineEdit1->setText(aString); - myOkPoint = true; - } - else if (myEditCurrentArgument == GroupPoints->LineEdit2) { - BRepAdaptor_Curve curv(TopoDS::Edge(S)); - myDir = curv.Line().Direction(); - GroupPoints->LineEdit2->setText(aString); - myOkDir = true; + Standard_Boolean aRes = Standard_False; + GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( mySelection->firstIObject(), aRes ); + if ( !CORBA::is_nil( aSelectedObject ) && aRes ) + { + myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) ); + if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) myPoint = aSelectedObject; + else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) myDir = aSelectedObject; } - if(myOkPoint && myOkDir) - this->MakeEllipseSimulationAndDisplay(); - return; + displayPreview(); } @@ -218,21 +211,16 @@ void BasicGUI_EllipseDlg::SelectionIntoArgument() void BasicGUI_EllipseDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); - mySelection->ClearFilters(); - - if(send == GroupPoints->PushButton1) { - GroupPoints->LineEdit1->setFocus(); - myEditCurrentArgument = GroupPoints->LineEdit1; - mySelection->AddFilter(myVertexFilter); - } - else if(send == GroupPoints->PushButton2) { - GroupPoints->LineEdit2->setFocus(); - myEditCurrentArgument = GroupPoints->LineEdit2; - mySelection->AddFilter(myEdgeFilter); - } - this->SelectionIntoArgument(); - return; + if ( send == GroupPoints->PushButton1 ) myEditCurrentArgument = GroupPoints->LineEdit1; + else if ( send == GroupPoints->PushButton2 ) myEditCurrentArgument = GroupPoints->LineEdit2; + + myEditCurrentArgument->setFocus(); + if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) + globalSelection( GEOM_LINE ); + else + globalSelection( GEOM_POINT ); + SelectionIntoArgument(); } //================================================================================= @@ -242,15 +230,12 @@ void BasicGUI_EllipseDlg::SetEditCurrentArgument() void BasicGUI_EllipseDlg::LineEditReturnPressed() { QLineEdit* send = (QLineEdit*)sender(); - if(send == GroupPoints->LineEdit1) - myEditCurrentArgument = GroupPoints->LineEdit1; - else if (send == GroupPoints->LineEdit2) - myEditCurrentArgument = GroupPoints->LineEdit2; - else - return; - - GEOMBase_Skeleton::LineEditReturnPressed(); - return; + if ( send == GroupPoints->LineEdit1 || + send == GroupPoints->LineEdit2 ) + { + myEditCurrentArgument = send; + GEOMBase_Skeleton::LineEditReturnPressed(); + } } @@ -262,14 +247,26 @@ void BasicGUI_EllipseDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + GroupPoints->LineEdit1->setFocus(); myEditCurrentArgument = GroupPoints->LineEdit1; - mySelection->AddFilter(myVertexFilter); - if(!mySimulationTopoDs.IsNull()) - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - return; + + GroupPoints->LineEdit1->setText( "" ); + GroupPoints->LineEdit2->setText( "" ); + + myPoint = myDir = GEOM::GEOM_Object::_nil(); + globalSelection( GEOM_POINT ); } +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : public slot to deactivate if active +//================================================================================= +void BasicGUI_EllipseDlg::DeactivateActiveDialog() +{ + myGeomGUI->SetState( -1 ); + GEOMBase_Skeleton::DeactivateActiveDialog(); +} //================================================================================= // function : enterEvent() @@ -277,53 +274,67 @@ void BasicGUI_EllipseDlg::ActivateThisDialog() //================================================================================= void BasicGUI_EllipseDlg::enterEvent(QEvent* e) { - if (GroupConstructors->isEnabled()) - return; - this->ActivateThisDialog(); - return; + if ( !GroupConstructors->isEnabled() ) + ActivateThisDialog(); } - //================================================================================= // function : ValueChangedInSpinBox() // purpose : //================================================================================= void BasicGUI_EllipseDlg::ValueChangedInSpinBox(double newValue) { - QObject* send = (QObject*)sender(); - - if(send == GroupPoints->SpinBox_DX ) - myMajorRadius = newValue; - else if(send == GroupPoints->SpinBox_DY) - myMinorRadius = newValue; + displayPreview(); +} - if (myOkPoint && myOkDir) - MakeEllipseSimulationAndDisplay(); - return; +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr BasicGUI_EllipseDlg::createOperation() +{ + return getGeomEngine()->GetICurvesOperations( getStudyId() ); } +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool BasicGUI_EllipseDlg::isValid( QString& msg ) +{ + double aMajorR = GroupPoints->SpinBox_DX->GetValue(); + double aMinorR = GroupPoints->SpinBox_DY->GetValue(); + if ( aMajorR < aMinorR ) + { + msg = tr( "GEOM_ELLIPSE_ERROR_1" ); + return false; + } + return !myPoint->_is_nil() && !myDir->_is_nil(); +} //================================================================================= -// function : MakeEllipseSimulationAndDisplay() +// function : execute // purpose : //================================================================================= -void BasicGUI_EllipseDlg::MakeEllipseSimulationAndDisplay() +bool BasicGUI_EllipseDlg::execute( ObjectList& objects ) { - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); + double aMajorR = GroupPoints->SpinBox_DX->GetValue(); + double aMinorR = GroupPoints->SpinBox_DY->GetValue(); + GEOM::GEOM_Object_var anObj = GEOM::GEOM_ICurvesOperations::_narrow( getOperation() )->MakeEllipse( myPoint, myDir, aMajorR, aMinorR ); - if(myMajorRadius < myMinorRadius) - return; + if ( !anObj->_is_nil() ) + objects.push_back( anObj._retn() ); - try { - gp_Ax2 anAxis(myPoint, myDir); - gp_Elips ellipse(anAxis, myMajorRadius, myMinorRadius); - BRepBuilderAPI_MakeEdge MakeEdge(ellipse); - mySimulationTopoDs = MakeEdge.Shape(); - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - } - catch(Standard_Failure) { - MESSAGE("Exception catched in MakeEllipseSimulationAndDisplay"); - } - return; + return true; } + +//================================================================================= +// function : closeEvent +// purpose : +//================================================================================= +void BasicGUI_EllipseDlg::closeEvent( QCloseEvent* e ) +{ + myGeomGUI->SetState( -1 ); + GEOMBase_Skeleton::closeEvent( e ); +} + diff --git a/src/BasicGUI/BasicGUI_EllipseDlg.h b/src/BasicGUI/BasicGUI_EllipseDlg.h index 512b0c322..21491d29e 100644 --- a/src/BasicGUI/BasicGUI_EllipseDlg.h +++ b/src/BasicGUI/BasicGUI_EllipseDlg.h @@ -34,6 +34,7 @@ #include "BasicGUI.h" #include "GEOM_ShapeTypeFilter.hxx" +#include "GEOM_EdgeFilter.hxx" #include //================================================================================= @@ -45,34 +46,33 @@ class BasicGUI_EllipseDlg : public GEOMBase_Skeleton Q_OBJECT public: - BasicGUI_EllipseDlg(QWidget* parent = 0, const char* name = 0, BasicGUI* theBasicGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + BasicGUI_EllipseDlg(QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); ~BasicGUI_EllipseDlg(); +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& ); + virtual bool execute( ObjectList& objects ); + + virtual void closeEvent( QCloseEvent* e ); + private : void Init(); void enterEvent(QEvent* e); - void MakeEllipseSimulationAndDisplay(); - BasicGUI* myBasicGUI; - - double step; - Handle(GEOM_ShapeTypeFilter) myVertexFilter; - Handle(GEOM_ShapeTypeFilter) myEdgeFilter; /* Filter selection */ - - gp_Pnt myPoint; /* Central point of ellipse */ - bool myOkPoint; /* true when myPoint is defined */ - gp_Dir myDir; /* to set normal axis of ellipse */ - bool myOkDir; /* true when myPoint is defined */ - - Standard_Real myMajorRadius; - Standard_Real myMinorRadius; + GEOM::GEOM_Object_var myPoint, myDir; DlgRef_2Sel2Spin* GroupPoints; private slots: void ClickOnOk(); - void ClickOnApply(); + void ClickOnCancel(); + bool ClickOnApply(); + void ActivateThisDialog(); + void DeactivateActiveDialog(); + void LineEditReturnPressed(); void SelectionIntoArgument(); void SetEditCurrentArgument(); diff --git a/src/BasicGUI/BasicGUI_LineDlg.cxx b/src/BasicGUI/BasicGUI_LineDlg.cxx index a146f4d8e..fe435dc53 100644 --- a/src/BasicGUI/BasicGUI_LineDlg.cxx +++ b/src/BasicGUI/BasicGUI_LineDlg.cxx @@ -28,10 +28,9 @@ #include "BasicGUI_LineDlg.h" -#include -#include -#include -#include +#include "QAD_Desktop.h" + +#include "GEOMImpl_Types.hxx" #include "utilities.h" @@ -44,7 +43,7 @@ using namespace std; // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -BasicGUI_LineDlg::BasicGUI_LineDlg(QWidget* parent, const char* name, BasicGUI* theBasicGUI, SALOME_Selection* Sel, bool modal, WFlags fl) +BasicGUI_LineDlg::BasicGUI_LineDlg(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_LINE_2P"))); @@ -65,11 +64,12 @@ BasicGUI_LineDlg::BasicGUI_LineDlg(QWidget* parent, const char* name, BasicGUI* GroupPoints->PushButton1->setPixmap(image1); GroupPoints->PushButton2->setPixmap(image1); - Layout1->addWidget(GroupPoints, 1, 0); + GroupPoints->LineEdit1->setReadOnly( true ); + GroupPoints->LineEdit2->setReadOnly( true ); + + Layout1->addWidget(GroupPoints, 2, 0); /***************************************************************/ - /* Initialisations */ - myBasicGUI = theBasicGUI; Init(); } @@ -80,7 +80,6 @@ BasicGUI_LineDlg::BasicGUI_LineDlg(QWidget* parent, const char* name, BasicGUI* //================================================================================= BasicGUI_LineDlg::~BasicGUI_LineDlg() { - /* no need to delete child widgets, Qt does it all for us */ } @@ -93,15 +92,16 @@ void BasicGUI_LineDlg::Init() /* init variables */ myEditCurrentArgument = GroupPoints->LineEdit1; - myPoint1.SetCoord(0.0, 0.0, 0.0); - myPoint2.SetCoord(0.0, 0.0, 0.0); - myOkPoint1 = myOkPoint2 = false; - - /* Vertices Filter for all arguments */ - myVertexFilter = new GEOM_ShapeTypeFilter(TopAbs_VERTEX, myGeom); - mySelection->AddFilter(myVertexFilter); + myPoint1 = myPoint2 = GEOM::GEOM_Object::_nil(); + myGeomGUI->SetState( 0 ); + globalSelection( GEOM_POINT ); + /* 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())); @@ -113,11 +113,7 @@ void BasicGUI_LineDlg::Init() connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - /* displays Dialog */ - GroupPoints->show(); - this->show(); - - return; + initName( tr("GEOM_LINE") ); } @@ -127,27 +123,30 @@ void BasicGUI_LineDlg::Init() //================================================================================= void BasicGUI_LineDlg::ClickOnOk() { - this->ClickOnApply(); - ClickOnCancel(); - return; + if ( ClickOnApply() ) + ClickOnCancel(); +} + +//======================================================================= +// function : ClickOnCancel() +// purpose : +//======================================================================= +void BasicGUI_LineDlg::ClickOnCancel() +{ + GEOMBase_Skeleton::ClickOnCancel(); } //================================================================================= // function : ClickOnApply() // purpose : //================================================================================= -void BasicGUI_LineDlg::ClickOnApply() +bool BasicGUI_LineDlg::ClickOnApply() { - buttonApply->setFocus(); - QAD_Application::getDesktop()->putInfo(tr("")); - if (mySimulationTopoDs.IsNull()) - return; - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); + if ( !onAccept() ) + return false; - if(myOkPoint1 && myOkPoint2) - myBasicGUI->MakeLineAndDisplay(myPoint1, myPoint2); - return; + initName(); + return true; } @@ -157,37 +156,26 @@ void BasicGUI_LineDlg::ClickOnApply() //================================================================================= void BasicGUI_LineDlg::SelectionIntoArgument() { - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); myEditCurrentArgument->setText(""); - QString aString = ""; /* name of selection */ - - int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString); - if(nbSel != 1) { - if(myEditCurrentArgument == GroupPoints->LineEdit1) - myOkPoint1 = false; - else if(myEditCurrentArgument == GroupPoints->LineEdit2) - myOkPoint2 = false; - return; - } - // nbSel == 1 - TopoDS_Shape S; - if(!myGeomBase->GetTopoFromSelection(mySelection, S)) + if ( mySelection->IObjectCount() != 1 ) + { + if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) myPoint1 = GEOM::GEOM_Object::_nil(); + else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) myPoint2 = GEOM::GEOM_Object::_nil(); return; - - if(myEditCurrentArgument == GroupPoints->LineEdit1 && myGeomBase->VertexToPoint(S, myPoint1)) { - myEditCurrentArgument->setText(aString); - myOkPoint1 = true; } - else if(myEditCurrentArgument == GroupPoints->LineEdit2 && myGeomBase->VertexToPoint(S, myPoint2)) { - myEditCurrentArgument->setText(aString); - myOkPoint2 = true; + + // nbSel == 1 + Standard_Boolean aRes = Standard_False; + GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( mySelection->firstIObject(), aRes ); + if ( !CORBA::is_nil( aSelectedObject ) && aRes ) + { + myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) ); + if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) myPoint1 = aSelectedObject; + else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) myPoint2 = aSelectedObject; } - if(myOkPoint1 && myOkPoint2 && myPoint1.Distance(myPoint2) > Precision::Confusion()) - this->MakeLineSimulationAndDisplay(); - return; + displayPreview(); } @@ -198,20 +186,10 @@ void BasicGUI_LineDlg::SelectionIntoArgument() void BasicGUI_LineDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); - mySelection->ClearFilters(); - - if(send == GroupPoints->PushButton1) { - GroupPoints->LineEdit1->setFocus(); - myEditCurrentArgument = GroupPoints->LineEdit1; - } - else if(send == GroupPoints->PushButton2) { - GroupPoints->LineEdit2->setFocus(); - myEditCurrentArgument = GroupPoints->LineEdit2; - } - mySelection->AddFilter(myVertexFilter); - this->SelectionIntoArgument(); - - return; + if ( send == GroupPoints->PushButton1 ) myEditCurrentArgument = GroupPoints->LineEdit1; + else if ( send == GroupPoints->PushButton2 ) myEditCurrentArgument = GroupPoints->LineEdit2; + myEditCurrentArgument->setFocus(); + SelectionIntoArgument(); } @@ -222,15 +200,10 @@ void BasicGUI_LineDlg::SetEditCurrentArgument() void BasicGUI_LineDlg::LineEditReturnPressed() { QLineEdit* send = (QLineEdit*)sender(); - if(send == GroupPoints->LineEdit1) - myEditCurrentArgument = GroupPoints->LineEdit1; - else if(send == GroupPoints->LineEdit2) - myEditCurrentArgument = GroupPoints->LineEdit2; - else - return; - + if ( send == GroupPoints->LineEdit1 ) myEditCurrentArgument = GroupPoints->LineEdit1; + else if ( send == GroupPoints->LineEdit2 ) myEditCurrentArgument = GroupPoints->LineEdit2; + else return; GEOMBase_Skeleton::LineEditReturnPressed(); - return; } @@ -242,12 +215,27 @@ void BasicGUI_LineDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - mySelection->AddFilter(myVertexFilter); - if(!mySimulationTopoDs.IsNull()) - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - return; + + myGeomGUI->SetState( 0 ); + globalSelection( GEOM_POINT ); + + myEditCurrentArgument = GroupPoints->LineEdit1; + myEditCurrentArgument->setFocus(); + + GroupPoints->LineEdit1->setText( "" ); + GroupPoints->LineEdit2->setText( "" ); + myPoint1 = myPoint2 = GEOM::GEOM_Object::_nil(); } +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : public slot to deactivate if active +//================================================================================= +void BasicGUI_LineDlg::DeactivateActiveDialog() +{ + myGeomGUI->SetState( -1 ); + GEOMBase_Skeleton::DeactivateActiveDialog(); +} //================================================================================= // function : enterEvent() @@ -255,40 +243,47 @@ void BasicGUI_LineDlg::ActivateThisDialog() //================================================================================= void BasicGUI_LineDlg::enterEvent(QEvent* e) { - if(GroupConstructors->isEnabled()) - return; - this->ActivateThisDialog(); - return; + if ( !GroupConstructors->isEnabled() ) + ActivateThisDialog(); } +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr BasicGUI_LineDlg::createOperation() +{ + return getGeomEngine()->GetIBasicOperations( getStudyId() ); +} //================================================================================= -// function : MakeLineSimulationAndDisplay() -// purpose : An arrow (cone topology) is added to 'modifiedShape' -// : to simulate a vector or an 'oriented line' display. The result is in 'modifiedShape'. -// : If an arrow can't be added returns false and 'modifiedShape' isn't modified ! +// function : isValid +// purpose : //================================================================================= -void BasicGUI_LineDlg::MakeLineSimulationAndDisplay() +bool BasicGUI_LineDlg::isValid( QString& msg ) { - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); - - try { - mySimulationTopoDs = BRepBuilderAPI_MakeEdge(myPoint1, myPoint2).Shape(); - TopoDS_Shape arrow; - if(myGeomBase->CreateArrowForLinearEdge(mySimulationTopoDs, arrow)) { - TopoDS_Compound Comp; - BRep_Builder B; - B.MakeCompound (Comp); - B.Add(Comp, mySimulationTopoDs); - B.Add(Comp, arrow); - mySimulationTopoDs = Comp; - } - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - } - catch(Standard_Failure) { - MESSAGE("Exception catched in MakeLineSimulationAndDisplay"); - return; - } - return; + return !myPoint1->_is_nil() && !myPoint2->_is_nil(); } + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool BasicGUI_LineDlg::execute( ObjectList& objects ) +{ + GEOM::GEOM_Object_var anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->MakeLineTwoPnt( myPoint1, myPoint2 ); + if ( !anObj->_is_nil() ) + objects.push_back( anObj._retn() ); + return true; +} + +//================================================================================= +// function : closeEvent +// purpose : +//================================================================================= +void BasicGUI_LineDlg::closeEvent( QCloseEvent* e ) +{ + myGeomGUI->SetState( -1 ); + GEOMBase_Skeleton::closeEvent( e ); +} + diff --git a/src/BasicGUI/BasicGUI_LineDlg.h b/src/BasicGUI/BasicGUI_LineDlg.h index a30885753..82daf2f61 100644 --- a/src/BasicGUI/BasicGUI_LineDlg.h +++ b/src/BasicGUI/BasicGUI_LineDlg.h @@ -32,8 +32,6 @@ #include "GEOMBase_Skeleton.h" #include "DlgRef_2Sel_QTD.h" -#include "BasicGUI.h" -#include "GEOM_ShapeTypeFilter.hxx" //================================================================================= // class : BasicGUI_LineDlg @@ -44,28 +42,34 @@ class BasicGUI_LineDlg : public GEOMBase_Skeleton Q_OBJECT public: - BasicGUI_LineDlg(QWidget* parent = 0, const char* name = 0, BasicGUI* theBasicGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + BasicGUI_LineDlg(QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); ~BasicGUI_LineDlg(); +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& ); + virtual bool execute( ObjectList& objects ); + + virtual void closeEvent( QCloseEvent* e ); + private : void Init(); void enterEvent(QEvent* e); - void MakeLineSimulationAndDisplay(); - - BasicGUI* myBasicGUI; - Handle(GEOM_ShapeTypeFilter) myVertexFilter; /* Filter selection */ - gp_Pnt myPoint1; /* Points containing the vector */ - gp_Pnt myPoint2; - bool myOkPoint1; /* Are true when myPoint is defined */ - bool myOkPoint2; + GEOM::GEOM_Object_var myPoint1; + GEOM::GEOM_Object_var myPoint2; DlgRef_2Sel_QTD* GroupPoints; private slots: void ClickOnOk(); - void ClickOnApply(); + void ClickOnCancel(); + bool ClickOnApply(); + void ActivateThisDialog(); + void DeactivateActiveDialog(); + void LineEditReturnPressed(); void SelectionIntoArgument(); void SetEditCurrentArgument(); diff --git a/src/BasicGUI/BasicGUI_MarkerDlg.cxx b/src/BasicGUI/BasicGUI_MarkerDlg.cxx new file mode 100644 index 000000000..c73f91728 --- /dev/null +++ b/src/BasicGUI/BasicGUI_MarkerDlg.cxx @@ -0,0 +1,669 @@ +// 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 : BasicGUI_MarkerDlg.cxx +// Author : Sergey LITONIN +// Module : GEOM +// $Header$ + +#include "BasicGUI_MarkerDlg.h" +#include "DlgRef_SpinBox.h" +#include "QAD_Desktop.h" +#include "QAD_RightFrame.h" +#include "VTKViewer_ViewFrame.h" +#include "OCCViewer_ViewFrame.h" +#include "QAD_Config.h" +#include "GEOMImpl_Types.hxx" +#include "utilities.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//================================================================================= +// class : BasicGUI_MarkerDlg() +// purpose : Constructor +//================================================================================= +BasicGUI_MarkerDlg::BasicGUI_MarkerDlg( QWidget* theParent, SALOME_Selection* theSel ) +: GEOMBase_Skeleton( theParent, "BasicGUI_MarkerDlg", theSel, false, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) +{ + QPixmap iconCS1 ( QAD_Desktop::getResourceManager()->loadPixmap( "GEOM", tr( "ICON_MARKER" ) ) ); + QPixmap iconCS2 ( QAD_Desktop::getResourceManager()->loadPixmap( "GEOM", tr( "ICON_MARKER2" ) ) ); + QPixmap iconCS3 ( QAD_Desktop::getResourceManager()->loadPixmap( "GEOM", tr( "ICON_MARKER3" ) ) ); + QPixmap iconSelect( QAD_Desktop::getResourceManager()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) ); + + setCaption( tr( "CAPTION" ) ); + + GroupConstructors->setTitle( tr( "LOCALCS" ) ); + RadioButton1->setPixmap( iconCS1 ); + RadioButton2->setPixmap( iconCS2 ); + RadioButton3->setPixmap( iconCS3 ); + + Group1 = new DlgRef_1Sel_QTD(this, "Group1"); + Group1->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); + Group1->TextLabel1->setText(tr("GEOM_OBJECT")); + Group1->PushButton1->setPixmap(iconSelect); + + Group2 = new DlgRef_3Sel_QTD(this, "Group2"); + Group2->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); + Group2->TextLabel1->setText(tr("GEOM_POINT")); + Group2->TextLabel2->setText(tr("XDIR")); + Group2->TextLabel3->setText(tr("YDIR")); + Group2->PushButton1->setPixmap(iconSelect); + Group2->PushButton2->setPixmap(iconSelect); + Group2->PushButton3->setPixmap(iconSelect); + + aMainGrp = new QGroupBox( 1, Qt::Horizontal, this ); + aMainGrp->setFrameStyle( QFrame::NoFrame ); + aMainGrp->setInsideMargin( 0 ); + + QGroupBox* anOriGrp = new QGroupBox( 1, Qt::Vertical, tr( "ORIGIN" ), aMainGrp ); + new QLabel( tr( "GEOM_X" ), anOriGrp ); + myData[ X ] = new DlgRef_SpinBox( anOriGrp ); + new QLabel( tr( "GEOM_Y" ), anOriGrp ); + myData[ Y ] = new DlgRef_SpinBox( anOriGrp ); + new QLabel( tr( "GEOM_Z" ), anOriGrp ); + myData[ Z ] = new DlgRef_SpinBox( anOriGrp ); + + QGroupBox* aXAxisGrp = new QGroupBox( 1, Qt::Vertical, tr( "XDIR" ), aMainGrp ); + new QLabel( tr( "DX" ), aXAxisGrp ); + myData[ DX1 ] = new DlgRef_SpinBox( aXAxisGrp ); + new QLabel( tr( "DY" ), aXAxisGrp ); + myData[ DY1 ] = new DlgRef_SpinBox( aXAxisGrp ); + new QLabel( tr( "DZ" ), aXAxisGrp ); + myData[ DZ1 ] = new DlgRef_SpinBox( aXAxisGrp ); + + QGroupBox* anYAxisGrp = new QGroupBox( 1, Qt::Vertical, tr( "YDIR" ), aMainGrp ); + new QLabel( tr( "DX" ), anYAxisGrp ); + myData[ DX2 ] = new DlgRef_SpinBox( anYAxisGrp ); + new QLabel( tr( "DY" ), anYAxisGrp ); + myData[ DY2 ] = new DlgRef_SpinBox( anYAxisGrp ); + new QLabel( tr( "DZ" ), anYAxisGrp ); + myData[ DZ2 ] = new DlgRef_SpinBox( anYAxisGrp ); + + Layout1->addWidget( aMainGrp, 2, 0 ); + Layout1->addWidget( Group1, 2, 0 ); + Layout1->addWidget( Group2, 2, 0 ); + + Init( theSel ); +} + + +//================================================================================= +// function : ~BasicGUI_MarkerDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +BasicGUI_MarkerDlg::~BasicGUI_MarkerDlg() +{ +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void BasicGUI_MarkerDlg::Init( SALOME_Selection* theSel ) +{ + myBlockPreview = false; + myConstructorId = -1; + myEditCurrentArgument = Group1->LineEdit1; + Group1->LineEdit1->setReadOnly( true ); + Group2->LineEdit1->setReadOnly( true ); + Group2->LineEdit2->setReadOnly( true ); + Group2->LineEdit3->setReadOnly( true ); + + GeometryGUI* aGeomGUI = GeometryGUI::GetGeomGUI(); + + connect(GroupConstructors, SIGNAL(clicked(int)), this, SLOT(ConstructorsClicked(int))); + connect(Group1->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(Group2->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(Group2->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(Group2->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + + connect(Group1->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(Group2->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(Group2->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(Group2->LineEdit3, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( onClose() ) ); + connect( aGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( onDeactivate() ) ); + connect( aGeomGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( onClose() ) ); + + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( onOk() ) ); + connect( buttonApply, SIGNAL( clicked() ), this, SLOT( onApply() ) ); + + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionDone() ) ); + + initName( tr( "LCS_NAME" ) ); + + QString aStr = QAD_CONFIG->getSetting( "Geometry:SettingsGeomStep" ); + for ( DataMap::iterator anIter = myData.begin(); anIter != myData.end(); ++anIter ) + { + anIter.data()->RangeStepAndValidator( -999.999, 999.999, aStr.toDouble(), 3 ); + connect( anIter.data(), SIGNAL( valueChanged( double ) ), + this, SLOT( onValueChanged( double ) ) ); + } + + myBlockPreview = true; + for ( DataMap::iterator anIter = myData.begin(); anIter != myData.end(); ++anIter ) + anIter.data()->SetValue( 0 ); + myData[ DX1 ]->SetValue( 1 ); + myData[ DY2 ]->SetValue( 1 ); + myBlockPreview = false; + + ConstructorsClicked( 0 ); + + QAD_ViewFrame* aFrame = QAD_Application::getDesktop()->getActiveApp()-> + getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame(); + + VTKViewer_ViewFrame* aVTKFrame = dynamic_cast( aFrame ); + if ( aVTKFrame ) + { + aVTKFrame->AdjustTrihedrons( true ); + return; + } + + OCCViewer_ViewFrame* aOCCFrame = dynamic_cast( aFrame ); + if ( aOCCFrame ) + aOCCFrame->AdjustTrihedrons( true ); +} + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void BasicGUI_MarkerDlg::ConstructorsClicked( int constructorId ) +{ + if ( myConstructorId == constructorId && myConstructorId == 0 ) + { + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); + activate( GEOM_MARKER ); + displayPreview(); + return; + } + + myConstructorId = constructorId; + + disconnect(mySelection, 0, this, 0); + + switch (constructorId) + { + case 0: + { + Group1->hide(); + Group2->hide(); + resize(0, 0); + aMainGrp->show(); + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); + activate( GEOM_MARKER ); + break; + } + case 1: + { + Group2->hide(); + aMainGrp->hide(); + resize(0, 0); + Group1->show(); + + globalSelection( GEOM_ALLGEOM ); + myEditCurrentArgument = Group1->LineEdit1; + Group1->LineEdit1->setText(""); + break; + } + case 2: + { + aMainGrp->hide(); + Group1->show(); + resize(0, 0); + Group2->show(); + + globalSelection( GEOM_POINT ); + myEditCurrentArgument = Group2->LineEdit1; + Group2->LineEdit1->setText(""); + Group2->LineEdit2->setText(""); + Group2->LineEdit3->setText(""); + break; + } + } + + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(onSelectionDone())); + onSelectionDone(); +} + +//================================================================================= +// function : onOk() +// purpose : +//================================================================================= +void BasicGUI_MarkerDlg::onOk() +{ + if ( onApply() ) + onClose(); +} + +//======================================================================= +// function : onClose() +// purpose : +//======================================================================= +void BasicGUI_MarkerDlg::onClose() +{ + GEOMBase_Skeleton::ClickOnCancel(); +} + +//================================================================================= +// function : onApply() +// purpose : +//================================================================================= +bool BasicGUI_MarkerDlg::onApply() +{ + if ( !onAccept() ) + return false; + + initName(); + ConstructorsClicked( getConstructorId() ); + + return true; +} + +//================================================================================= +// function : onSelectionDone0() +// purpose : Reaction on selection when first method of creation is current one +//================================================================================= +void BasicGUI_MarkerDlg::onSelectionDone0() +{ + if ( mySelection->IObjectCount() == 1 ) + { + + Standard_Boolean aRes = Standard_False; + Handle(SALOME_InteractiveObject) anIO = mySelection->firstIObject(); + GEOM::GEOM_Object_var aSelectedObj = GEOMBase::ConvertIOinGEOMObject( anIO, aRes ); + + if ( aRes && !aSelectedObj->_is_nil() ) + { + TopoDS_Shape aShape; + if ( myGeomBase->GetShape( aSelectedObj, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) + { + if ( aSelectedObj->GetType() == GEOM_MARKER && aShape.ShapeType() == TopAbs_FACE ) + { + TopoDS_Face aFace = TopoDS::Face( aShape ); + Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast( BRep_Tool::Surface( aFace ) ); + + if ( !aPlane.IsNull() ) + { + gp_Ax3 anAx3 = aPlane->Pln().Position(); + gp_Pnt aLoc = anAx3.Location(); + gp_Dir aXDir = anAx3.XDirection(); + gp_Dir aYDir = anAx3.YDirection(); + + myData[ X ]->SetValue( aLoc.X() ); + myData[ Y ]->SetValue( aLoc.Y() ); + myData[ Z ]->SetValue( aLoc.Z() ); + + myData[ DX1 ]->SetValue( aXDir.X() ); + myData[ DY1 ]->SetValue( aXDir.Y() ); + myData[ DZ1 ]->SetValue( aXDir.Z() ); + + myData[ DX2 ]->SetValue( aYDir.X() ); + myData[ DY2 ]->SetValue( aYDir.Y() ); + myData[ DZ2 ]->SetValue( aYDir.Z() ); + //mySelection->ClearIObjects(); + } + } + else + { + if ( mySelection->HasIndex( anIO ) ) + { + TColStd_IndexedMapOfInteger aMap; + mySelection->GetIndex( anIO, aMap ); + if ( aMap.Extent() == 1 ) + { + int anIndex = aMap( 1 ); + TopTools_IndexedMapOfShape aShapes; + TopExp::MapShapes( aShape, aShapes ); + aShape = aShapes.FindKey( anIndex ); + //mySelection->ClearIObjects(); + } + } + + if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX ) + { + gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) ); + myData[ X ]->SetValue( aPnt.X() ); + myData[ Y ]->SetValue( aPnt.Y() ); + myData[ Z ]->SetValue( aPnt.Z() ); + } + } + } + } + } + + displayPreview(); +} + + +//================================================================================= +// function : onSelectionDone() +// purpose : Called when selection as changed or other case +//================================================================================= +void BasicGUI_MarkerDlg::onSelectionDone() +{ + if ( getConstructorId() == 0 ) + { + onSelectionDone0(); + return; + } + + + myEditCurrentArgument->setText(""); + QString aName; + + if ( mySelection->IObjectCount() == 1 ) { + Standard_Boolean aRes = Standard_False; + Handle(SALOME_InteractiveObject) anIO = mySelection->firstIObject(); + GEOM::GEOM_Object_var aSelectedObj = GEOMBase::ConvertIOinGEOMObject( anIO, aRes ); + + if ( !CORBA::is_nil( aSelectedObj ) && aRes ) { + aName = GEOMBase::GetName( aSelectedObj ); + TopoDS_Shape aShape; + if ( myGeomBase->GetShape( aSelectedObj, aShape, TopAbs_SHAPE ) ) { + GEOM::short_array anIndexes; + if ( mySelection->HasIndex( anIO ) ) { + TColStd_IndexedMapOfInteger aMap; + mySelection->GetIndex( anIO, aMap ); + int anIndex = aMap( 1 ); + TopTools_IndexedMapOfShape aShapes; + TopExp::MapShapes( aShape, aShapes ); + aShape = aShapes.FindKey( anIndex ); + } + + if ( getConstructorId() == 1 ) { + if ( !aShape.IsNull() ) { + gp_Pnt aPnt; + if (aShape.ShapeType() == TopAbs_VERTEX) { + aPnt = BRep_Tool::Pnt(TopoDS::Vertex(aShape)); + } + else { + GProp_GProps aSystem; + if (aShape.ShapeType() == TopAbs_EDGE || aShape.ShapeType() == TopAbs_WIRE) + BRepGProp::LinearProperties(aShape, aSystem); + else if (aShape.ShapeType() == TopAbs_FACE || aShape.ShapeType() == TopAbs_SHELL) + BRepGProp::SurfaceProperties(aShape, aSystem); + else + BRepGProp::VolumeProperties(aShape, aSystem); + + aPnt = aSystem.CentreOfMass(); + } + + gp_Ax3 anAx3; + anAx3.Transform(aShape.Location().Transformation()); + if(aShape.ShapeType() == TopAbs_FACE) { + Handle(Geom_Surface) aGS = BRep_Tool::Surface( TopoDS::Face( aShape ) ); + if (!aGS.IsNull() && aGS->IsKind( STANDARD_TYPE( Geom_Plane ) ) ) { + Handle(Geom_Plane) aGPlane = Handle(Geom_Plane)::DownCast( aGS ); + gp_Pln aPln = aGPlane->Pln(); + anAx3 = aPln.Position(); + } + } + + gp_Dir aDirX = anAx3.XDirection(); + gp_Dir aDirY = anAx3.YDirection(); + + myData[ X ]->SetValue( aPnt.X() ); + myData[ Y ]->SetValue( aPnt.Y() ); + myData[ Z ]->SetValue( aPnt.Z() ); + + myData[ DX1 ]->SetValue( aDirX.X() ); + myData[ DY1 ]->SetValue( aDirX.Y() ); + myData[ DZ1 ]->SetValue( aDirX.Z() ); + + myData[ DX2 ]->SetValue( aDirY.X() ); + myData[ DY2 ]->SetValue( aDirY.Y() ); + myData[ DZ2 ]->SetValue( aDirY.Z() ); + + myEditCurrentArgument->setText( aName ); + } + } + else if ( getConstructorId() == 2 ) { + if (myEditCurrentArgument == Group2->LineEdit1) { + if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX ) { + gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) ); + myData[ X ]->SetValue( aPnt.X() ); + myData[ Y ]->SetValue( aPnt.Y() ); + myData[ Z ]->SetValue( aPnt.Z() ); + myEditCurrentArgument->setText( aName ); + } + } + else if (myEditCurrentArgument == Group2->LineEdit2) { + if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_EDGE ) { + gp_Pnt aP1 = BRep_Tool::Pnt(TopExp::FirstVertex(TopoDS::Edge(aShape))); + gp_Pnt aP2 = BRep_Tool::Pnt(TopExp::LastVertex(TopoDS::Edge(aShape))); + gp_Dir aDir(gp_Vec(aP1, aP2)); + + myData[ DX1 ]->SetValue( aDir.X() ); + myData[ DY1 ]->SetValue( aDir.Y() ); + myData[ DZ1 ]->SetValue( aDir.Z() ); + myEditCurrentArgument->setText( aName ); + } + } + else if (myEditCurrentArgument == Group2->LineEdit3) { + if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_EDGE ) { + gp_Pnt aP1 = BRep_Tool::Pnt(TopExp::FirstVertex(TopoDS::Edge(aShape))); + gp_Pnt aP2 = BRep_Tool::Pnt(TopExp::LastVertex(TopoDS::Edge(aShape))); + gp_Dir aDir(gp_Vec(aP1, aP2)); + + myData[ DX2 ]->SetValue( aDir.X() ); + myData[ DY2 ]->SetValue( aDir.Y() ); + myData[ DZ2 ]->SetValue( aDir.Z() ); + myEditCurrentArgument->setText( aName ); + } + } + } + } + } + } + + displayPreview(); +} + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void BasicGUI_MarkerDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + + if(send == Group1->PushButton1) { + myEditCurrentArgument = Group1->LineEdit1; + globalSelection( GEOM_ALLGEOM ); + } + else if(send == Group2->PushButton1) { + myEditCurrentArgument = Group2->LineEdit1; + globalSelection( GEOM_POINT ); + } + else if(send == Group2->PushButton2) { + myEditCurrentArgument = Group2->LineEdit2; + globalSelection( GEOM_LINE ); + } + else if(send == Group2->PushButton3) { + myEditCurrentArgument = Group2->LineEdit3; + globalSelection( GEOM_LINE ); + } + + myEditCurrentArgument->setFocus(); + onSelectionDone(); +} + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void BasicGUI_MarkerDlg::LineEditReturnPressed() +{ + QLineEdit* send = (QLineEdit*)sender(); + + myEditCurrentArgument = send; + GEOMBase_Skeleton::LineEditReturnPressed(); +} + +//================================================================================= +// function : onActivate() +// purpose : +//================================================================================= +void BasicGUI_MarkerDlg::onActivate() +{ + GEOMBase_Skeleton::ActivateThisDialog(); + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionDone() ) ); + + ConstructorsClicked( getConstructorId() ); +} + +//================================================================================= +// function : onDeactivate() +// purpose : public slot to deactivate if active +//================================================================================= +void BasicGUI_MarkerDlg::onDeactivate() +{ + GEOMBase_Skeleton::DeactivateActiveDialog(); +} + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void BasicGUI_MarkerDlg::enterEvent(QEvent* e) +{ + if ( !GroupConstructors->isEnabled() ) + onActivate(); +} + +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr BasicGUI_MarkerDlg::createOperation() +{ + return getGeomEngine()->GetIBasicOperations( getStudyId() ); +} + +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool BasicGUI_MarkerDlg::isValid( QString& msg ) +{ + const int id = getConstructorId(); + gp_Vec v1( myData[ DX1 ]->GetValue(), myData[ DY1 ]->GetValue(), myData[ DZ1 ]->GetValue() ), + v2( myData[ DX2 ]->GetValue(), myData[ DY2 ]->GetValue(), myData[ DZ2 ]->GetValue() ); + bool isOrthogonal = v1.IsNormal( v2, Precision::Confusion() ); + switch ( id ) + { + case 0: + return isOrthogonal; + case 1: + return !Group1->LineEdit1->text().isEmpty() && isOrthogonal; + case 2: + return !Group2->LineEdit1->text().isEmpty() && + !Group2->LineEdit2->text().isEmpty() && + !Group2->LineEdit3->text().isEmpty() && isOrthogonal; + } + return false; +} + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool BasicGUI_MarkerDlg::execute( ObjectList& objects ) +{ + GEOM::GEOM_Object_var anObj = GEOM::GEOM_IBasicOperations::_narrow( + getOperation() )->MakeMarker( myData[ X ]->GetValue(), myData[ Y ]->GetValue(), myData[ Z ]->GetValue(), + myData[ DX1 ]->GetValue(), myData[ DY1 ]->GetValue(), myData[ DZ1 ]->GetValue(), + myData[ DX2 ]->GetValue(), myData[ DY2 ]->GetValue(), myData[ DZ2 ]->GetValue() ); + + if ( !anObj->_is_nil() ) + objects.push_back( anObj._retn() ); + + return true; +} + +//================================================================================= +// function : closeEvent +// purpose : +//================================================================================= +void BasicGUI_MarkerDlg::closeEvent( QCloseEvent* e ) +{ + GEOMBase_Skeleton::closeEvent( e ); +} + +//================================================================================= +// function : onValueChanged +// purpose : +//================================================================================= +void BasicGUI_MarkerDlg::onValueChanged( double ) +{ + displayPreview(); +} + +//================================================================================= +// function : displayPreview +// purpose : +//================================================================================= +void BasicGUI_MarkerDlg::displayPreview ( const bool activate, + const bool update, + const bool toRemoveFromEngine, + const double lineWidth ) +{ + if ( !myBlockPreview ) + { + GEOMBase_Skeleton::displayPreview( activate, update, toRemoveFromEngine, lineWidth ); + if ( myConstructorId == 0 ) + { + GEOMBase_Skeleton::activate( GEOM_MARKER ); + } + } +} + + + + + + + + + + + + + + diff --git a/src/BasicGUI/BasicGUI_MarkerDlg.h b/src/BasicGUI/BasicGUI_MarkerDlg.h new file mode 100644 index 000000000..127685c42 --- /dev/null +++ b/src/BasicGUI/BasicGUI_MarkerDlg.h @@ -0,0 +1,90 @@ +// 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 : BasicGUI_MarkerDlg.h +// Author : Sergey LITONIN +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_Marker_H +#define DIALOGBOX_Marker_H + +#include "GEOMBase_Skeleton.h" +#include "DlgRef_1Sel_QTD.h" +#include "DlgRef_3Sel_QTD.h" + +#include + +class DlgRef_SpinBox; + +class BasicGUI_MarkerDlg : public GEOMBase_Skeleton +{ + Q_OBJECT + +private: + enum { X, Y, Z, DX1, DY1, DZ1, DX2, DY2, DZ2 }; + typedef QMap< int, DlgRef_SpinBox* > DataMap; + +public: + BasicGUI_MarkerDlg( QWidget*, SALOME_Selection* ); + virtual ~BasicGUI_MarkerDlg(); + void Init( SALOME_Selection* ); + +protected: + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& ); + virtual bool execute( ObjectList& objects ); + virtual void closeEvent( QCloseEvent* e ); + virtual void displayPreview ( const bool activate = false, + const bool update = true, + const bool toRemoveFromEngine = true, + const double lineWidth = -1 ); + +private : + void enterEvent( QEvent* e ); + void onSelectionDone0(); + +private slots: + void onOk(); + void onClose(); + bool onApply(); + void onActivate(); + void onDeactivate(); + void onSelectionDone(); + void onValueChanged( double ); + void ConstructorsClicked( int ); + void LineEditReturnPressed(); + void SetEditCurrentArgument(); + +private: + DataMap myData; + int myConstructorId; + int myBlockPreview; + + QGroupBox* aMainGrp; + DlgRef_1Sel_QTD* Group1; + DlgRef_3Sel_QTD* Group2; + +}; + +#endif // DIALOGBOX_Marker_H diff --git a/src/BasicGUI/BasicGUI_PlaneDlg.cxx b/src/BasicGUI/BasicGUI_PlaneDlg.cxx index 6b3a77f8f..a8298c652 100644 --- a/src/BasicGUI/BasicGUI_PlaneDlg.cxx +++ b/src/BasicGUI/BasicGUI_PlaneDlg.cxx @@ -27,16 +27,10 @@ // $Header$ #include "BasicGUI_PlaneDlg.h" - -#include -#include -#include -#include -#include -#include #include "QAD_Config.h" +#include "QAD_Desktop.h" -#include "utilities.h" +#include "GEOMImpl_Types.hxx" using namespace std; @@ -47,11 +41,11 @@ using namespace std; // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -BasicGUI_PlaneDlg::BasicGUI_PlaneDlg(QWidget* parent, const char* name, BasicGUI* theBasicGUI, SALOME_Selection* Sel, bool modal, WFlags fl) +BasicGUI_PlaneDlg::BasicGUI_PlaneDlg(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_PLANE_PV"))); - QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_PLANE_DXYZ"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_PLANE_3PNTS"))); QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_PLANE_FACE"))); QPixmap image3(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); @@ -63,37 +57,43 @@ BasicGUI_PlaneDlg::BasicGUI_PlaneDlg(QWidget* parent, const char* name, BasicGUI RadioButton2->setPixmap(image1); RadioButton3->setPixmap(image2); - GroupPointDirection = new DlgRef_2Sel1Spin(this, "GroupPointDirection"); - GroupPointDirection->GroupBox1->setTitle(tr("GEOM_PLANE_PV")); - GroupPointDirection->TextLabel1->setText(tr("GEOM_POINT")); - GroupPointDirection->TextLabel2->setText(tr("GEOM_VECTOR")); - GroupPointDirection->TextLabel3->setText(tr("GEOM_PLANE_SIZE")); - GroupPointDirection->PushButton1->setPixmap(image3); - GroupPointDirection->PushButton2->setPixmap(image3); - - GroupPointPlusCoordinates = new DlgRef_1Sel4Spin(this, "GroupPointPlusCoordinates" ); - GroupPointPlusCoordinates->GroupBox1->setTitle(tr("GEOM_PLANE_PVC")); - GroupPointPlusCoordinates->TextLabel1->setText(tr("GEOM_POINT")); - GroupPointPlusCoordinates->TextLabel2->setText(tr("GEOM_COOR")); - GroupPointPlusCoordinates->TextLabel3->setText(tr("GEOM_DX")); - GroupPointPlusCoordinates->TextLabel4->setText(tr("GEOM_DY")); - GroupPointPlusCoordinates->TextLabel5->setText(tr("GEOM_DZ")); - GroupPointPlusCoordinates->TextLabel6->setText(tr("GEOM_PLANE_SIZE")); - GroupPointPlusCoordinates->PushButton1->setPixmap(image3); + GroupPntDir = new DlgRef_2Sel1Spin(this, "GroupPointDirection"); + GroupPntDir->GroupBox1->setTitle(tr("GEOM_PLANE_PV")); + GroupPntDir->TextLabel1->setText(tr("GEOM_POINT")); + GroupPntDir->TextLabel2->setText(tr("GEOM_VECTOR")); + GroupPntDir->TextLabel3->setText(tr("GEOM_PLANE_SIZE")); + GroupPntDir->PushButton1->setPixmap(image3); + GroupPntDir->PushButton2->setPixmap(image3); + GroupPntDir->LineEdit1->setReadOnly( true ); + GroupPntDir->LineEdit2->setReadOnly( true ); + + Group3Pnts = new DlgRef_3Sel1Spin(this, "Group3Pnts"); + Group3Pnts->GroupBox1->setTitle(tr("GEOM_3_POINTS")); + Group3Pnts->TextLabel1->setText(tr("GEOM_POINT1")); + Group3Pnts->TextLabel2->setText(tr("GEOM_POINT2")); + Group3Pnts->TextLabel3->setText(tr("GEOM_POINT3")); + Group3Pnts->TextLabel4->setText(tr("GEOM_PLANE_SIZE")); + Group3Pnts->PushButton1->setPixmap(image3); + Group3Pnts->PushButton2->setPixmap(image3); + Group3Pnts->PushButton3->setPixmap(image3); + + Group3Pnts->LineEdit1->setReadOnly( true ); + Group3Pnts->LineEdit2->setReadOnly( true ); + Group3Pnts->LineEdit3->setReadOnly( true ); GroupFace = new DlgRef_1Sel1Spin(this, "GroupFace"); GroupFace->GroupBox1->setTitle(tr("GEOM_FACE")); GroupFace->TextLabel1->setText(tr("GEOM_SELECTION")); GroupFace->TextLabel2->setText(tr("GEOM_PLANE_SIZE")); GroupFace->PushButton1->setPixmap(image3); + + GroupFace->LineEdit1->setReadOnly( true ); - Layout1->addWidget(GroupPointDirection, 1, 0); - Layout1->addWidget(GroupPointPlusCoordinates, 1, 0); - Layout1->addWidget(GroupFace, 1, 0); + Layout1->addWidget(GroupPntDir, 2, 0); + Layout1->addWidget(Group3Pnts, 2, 0); + Layout1->addWidget(GroupFace, 2, 0); /***************************************************************/ - /* Initialisation */ - myBasicGUI = theBasicGUI; Init(); } @@ -104,7 +104,6 @@ BasicGUI_PlaneDlg::BasicGUI_PlaneDlg(QWidget* parent, const char* name, BasicGUI //================================================================================= BasicGUI_PlaneDlg::~BasicGUI_PlaneDlg() { - /* no need to delete child widgets, Qt does it all for us */ } @@ -115,79 +114,63 @@ BasicGUI_PlaneDlg::~BasicGUI_PlaneDlg() void BasicGUI_PlaneDlg::Init() { /* init variables */ - myConstructorId = 0; - myEditCurrentArgument = GroupPointDirection->LineEdit1; + myEditCurrentArgument = GroupPntDir->LineEdit1; - myPoint1.SetCoord(0.0, 0.0, 0.0); - myOkPoint1 = myOkDirection = myOkCoordinates = myOkPlanarFace = false; + myPoint = myDir = myPoint1 = myPoint2 = myPoint3 = myFace = GEOM::GEOM_Object::_nil(); - /* Filters definition */ - myVertexFilter = new GEOM_ShapeTypeFilter(TopAbs_VERTEX, myGeom); - myEdgeFilter = new GEOM_ShapeTypeFilter(TopAbs_EDGE, myGeom); - myFaceFilter = new GEOM_FaceFilter(StdSelect_Plane, myGeom); - /* Filter for the next selection */ - mySelection->AddFilter(myVertexFilter); + myGeomGUI->SetState( 0 ); /* Get setting of step value from file configuration */ QString St = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep"); - step = St.toDouble(); - this->myTrimSize = 2000.0; + double aStep = St.toDouble(); + double aTrimSize = 2000.0; /* min, max, step and decimals for spin boxes */ - GroupPointDirection->SpinBox_DX->RangeStepAndValidator(0.001, 10000000.0, step, 3); - GroupPointDirection->SpinBox_DX->SetValue(myTrimSize); - - double SpecificStep = 1; - GroupPointPlusCoordinates->SpinBox_DX->RangeStepAndValidator(-999.999, 999.999, SpecificStep, 3); - GroupPointPlusCoordinates->SpinBox_DY->RangeStepAndValidator(-999.999, 999.999, SpecificStep, 3); - GroupPointPlusCoordinates->SpinBox_DZ->RangeStepAndValidator(-999.999, 999.999, SpecificStep, 3); - GroupPointPlusCoordinates->SpinBox_DX->SetValue(0.0); - GroupPointPlusCoordinates->SpinBox_DY->SetValue(0.0); - GroupPointPlusCoordinates->SpinBox_DZ->SetValue(1.0); - GroupPointPlusCoordinates->SpinBox_S->RangeStepAndValidator(0.001, 10000000.0, step, 3); - GroupPointPlusCoordinates->SpinBox_S->SetValue(myTrimSize) ; - - GroupFace->SpinBox_DX->RangeStepAndValidator(0.001, 10000000.0, step, 3); - GroupFace->SpinBox_DX->SetValue(myTrimSize); + GroupPntDir->SpinBox_DX->RangeStepAndValidator( 0.001, 10000000.0, aStep, 3 ); + GroupPntDir->SpinBox_DX->SetValue( aTrimSize ); + Group3Pnts->SpinBox_DX->RangeStepAndValidator(0.001, 10000000.0, aStep, 3); + Group3Pnts->SpinBox_DX->SetValue( aTrimSize ); + GroupFace->SpinBox_DX->RangeStepAndValidator(0.001, 10000000.0, aStep, 3); + GroupFace->SpinBox_DX->SetValue( aTrimSize ); /* 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(GroupConstructors, SIGNAL(clicked(int)), SLOT(ConstructorsClicked(int))); - - connect(GroupPointDirection->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect(GroupPointDirection->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect(GroupPointPlusCoordinates->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect(GroupFace->PushButton1, SIGNAL(clicked()), this, SLOT( SetEditCurrentArgument())); - - connect(GroupPointDirection->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupPointDirection->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupPointPlusCoordinates->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(GroupConstructors, SIGNAL(clicked(int)), this, SLOT(ConstructorsClicked(int))); + + connect(GroupPntDir->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupPntDir->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(Group3Pnts->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(Group3Pnts->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(Group3Pnts->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupFace->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + + connect(GroupPntDir->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(GroupPntDir->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(Group3Pnts->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(Group3Pnts->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(Group3Pnts->LineEdit3, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); connect(GroupFace->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupPointPlusCoordinates->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(GroupPointPlusCoordinates->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(GroupPointPlusCoordinates->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(GroupPointPlusCoordinates->SpinBox_S, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(GroupPointDirection->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupPntDir->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(Group3Pnts->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); connect(GroupFace->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPointPlusCoordinates->SpinBox_DX, SLOT(SetStep(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPointPlusCoordinates->SpinBox_DY, SLOT(SetStep(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPointPlusCoordinates->SpinBox_DZ, SLOT(SetStep(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPointPlusCoordinates->SpinBox_S, SLOT(SetStep(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPointDirection->SpinBox_DX, SLOT(SetStep(double))); + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPntDir->SpinBox_DX, SLOT(SetStep(double))); + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group3Pnts->SpinBox_DX, SLOT(SetStep(double))); connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupFace->SpinBox_DX, SLOT(SetStep(double))); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - /* Displays Dialog */ - GroupPointPlusCoordinates->hide(); - GroupFace->hide(); - GroupPointDirection->show(); - this->show(); + initName( tr( "GEOM_PLANE" ) ); - return ; + Group3Pnts->hide(); + GroupFace->hide(); + ConstructorsClicked( 0 ); } @@ -197,64 +180,60 @@ void BasicGUI_PlaneDlg::Init() //================================================================================= void BasicGUI_PlaneDlg::ConstructorsClicked(int constructorId) { - myConstructorId = constructorId; - mySelection->ClearFilters(); - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - myOkPoint1 = myOkDirection = myOkCoordinates = myOkPlanarFace = false; + disconnect(mySelection, 0, this, 0); + myPoint = myDir = myPoint1 = myPoint2 = myPoint3 = myFace = GEOM::GEOM_Object::_nil(); - switch (constructorId) - { + switch ( constructorId ) + { case 0: /* plane from a point and a direction (vector, edge...) */ { - GroupPointPlusCoordinates->hide(); - GroupFace->hide(); - resize(0, 0); - GroupPointDirection->show(); - - myEditCurrentArgument = GroupPointDirection->LineEdit1; - GroupPointDirection->LineEdit1->setText(tr("")); - GroupPointDirection->LineEdit2->setText(tr("")); - - /* for the first argument */ - mySelection->AddFilter(myVertexFilter); - break; + Group3Pnts->hide(); + GroupFace->hide(); + resize(0, 0); + GroupPntDir->show(); + + myEditCurrentArgument = GroupPntDir->LineEdit1; + GroupPntDir->LineEdit1->setText(tr("")); + GroupPntDir->LineEdit2->setText(tr("")); + + /* for the first argument */ + globalSelection( GEOM_POINT ); + break; } - case 1: /* plane from a point and vector coordinates */ + case 1: /* plane from 3 points */ { - GroupPointDirection->hide(); - GroupFace->hide(); - resize(0, 0); - GroupPointPlusCoordinates->show(); - - myEditCurrentArgument = GroupPointPlusCoordinates->LineEdit1; - GroupPointPlusCoordinates->LineEdit1->setText(tr("")); - GroupPointPlusCoordinates->SpinBox_DX->SetValue(0.0); - GroupPointPlusCoordinates->SpinBox_DY->SetValue(0.0); - GroupPointPlusCoordinates->SpinBox_DZ->SetValue(1.0); - myOkCoordinates = true; - - /* for the first argument */ - mySelection->AddFilter(myVertexFilter); - break; + GroupPntDir->hide(); + GroupFace->hide(); + resize(0, 0); + Group3Pnts->show(); + + myEditCurrentArgument = Group3Pnts->LineEdit1; + Group3Pnts->LineEdit1->setText(""); + Group3Pnts->LineEdit2->setText(""); + Group3Pnts->LineEdit3->setText(""); + + /* for the first argument */ + globalSelection( GEOM_POINT ); + break; } case 2: /* plane from a planar face selection */ { - GroupPointDirection->hide(); - GroupPointPlusCoordinates->hide(); - resize(0, 0); - GroupFace->show(); + GroupPntDir->hide(); + Group3Pnts->hide(); + resize(0, 0); + GroupFace->show(); - myEditCurrentArgument = GroupFace->LineEdit1; - GroupFace->LineEdit1->setText(tr("")); + myEditCurrentArgument = GroupFace->LineEdit1; + GroupFace->LineEdit1->setText(tr("")); - /* for the first argument */ - mySelection->AddFilter(myFaceFilter); - break; + /* for the first argument */ + globalSelection( GEOM_PLANE ); + break; } } - return; + + myEditCurrentArgument->setFocus(); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); } @@ -264,9 +243,8 @@ void BasicGUI_PlaneDlg::ConstructorsClicked(int constructorId) //================================================================================= void BasicGUI_PlaneDlg::ClickOnOk() { - this->ClickOnApply(); - ClickOnCancel(); - return ; + if ( ClickOnApply() ) + ClickOnCancel(); } @@ -274,39 +252,24 @@ void BasicGUI_PlaneDlg::ClickOnOk() // function : ClickOnApply() // purpose : //================================================================================= -void BasicGUI_PlaneDlg::ClickOnApply() +bool BasicGUI_PlaneDlg::ClickOnApply() { - buttonApply->setFocus(); - QAD_Application::getDesktop()->putInfo(tr("")); - if (mySimulationTopoDs.IsNull()) - return; - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); + if ( !onAccept() ) + return false; - switch(myConstructorId) - { - case 0 : /* args are myPoint1 and myDx, myDy, myDz from a vector(edge) */ - { - if(myOkPoint1 && myOkDirection) - myBasicGUI->MakePlaneAndDisplay(myPoint1, myDx, myDy, myDz, myTrimSize); - break; - } - case 1 : /* args are myPoint1 and myDx, myDy, myDz from a Spin Box */ - { - if(myOkPoint1) - myBasicGUI->MakePlaneAndDisplay(myPoint1, myDx, myDy, myDz, myTrimSize); - break; - } - case 2 : /* arg is a planar face selection */ - { - if(myOkPlanarFace) - myBasicGUI->MakePlaneAndDisplay(myPoint1, myDx, myDy, myDz, myTrimSize); - break; - } - } - return; + initName(); + ConstructorsClicked( getConstructorId() ); + return true; } +//======================================================================= +// function : ClickOnCancel() +// purpose : +//======================================================================= +void BasicGUI_PlaneDlg::ClickOnCancel() +{ + GEOMBase_Skeleton::ClickOnCancel(); +} //================================================================================= // function : SelectionIntoArgument() @@ -314,104 +277,34 @@ void BasicGUI_PlaneDlg::ClickOnApply() //================================================================================= void BasicGUI_PlaneDlg::SelectionIntoArgument() { - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); - QString aString = ""; + myEditCurrentArgument->setText(""); - int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString); - if(nbSel != 1) { - switch (myConstructorId) - { - case 0: - { - if(myEditCurrentArgument == GroupPointDirection->LineEdit1) { - GroupPointDirection->LineEdit1->setText(""); - myOkPoint1 = false ; - } - else if(myEditCurrentArgument == GroupPointDirection->LineEdit2) { - GroupPointDirection->LineEdit2->setText(""); - myOkDirection = false ; - } - break; - } - case 1: - { - if(myEditCurrentArgument == GroupPointPlusCoordinates->LineEdit1) { - GroupPointPlusCoordinates->LineEdit1->setText("") ; - myOkPoint1 = false ; - } - break; - } - case 2: - { - if(myEditCurrentArgument == GroupFace->LineEdit1) { - GroupFace->LineEdit1->setText("") ; - if(aString.compare("") == 0) - myOkPlanarFace = false; - else - myOkPlanarFace = true; - } - break; - } - } - return ; + if ( mySelection->IObjectCount() != 1 ) + { + if ( myEditCurrentArgument == GroupPntDir->LineEdit1 ) myPoint = GEOM::GEOM_Object::_nil(); + else if ( myEditCurrentArgument == GroupPntDir->LineEdit2 ) myDir = GEOM::GEOM_Object::_nil(); + else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) myPoint1 = GEOM::GEOM_Object::_nil(); + else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) myPoint2 = GEOM::GEOM_Object::_nil(); + else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) myPoint3 = GEOM::GEOM_Object::_nil(); + else if ( myEditCurrentArgument == GroupFace->LineEdit1 ) myFace = GEOM::GEOM_Object::_nil(); + return; } - /* nbSel == 1 */ - TopoDS_Shape S; - if(!myGeomBase->GetTopoFromSelection(mySelection, S)) - return ; - - /* FIRST CONSTRUCTOR */ - if(myEditCurrentArgument == GroupPointDirection->LineEdit1 && myGeomBase->VertexToPoint(S, myPoint1)) { - GroupPointDirection->LineEdit1->setText(aString); - myOkPoint1 = true; - } - else if( myEditCurrentArgument == GroupPointDirection->LineEdit2) { - /* We verify if the selection is a linear edge */ - gp_Pnt Pfirst, Plast; - if( myGeomBase->LinearEdgeExtremities(S, Pfirst, Plast)) { - myGeomBase->GetBipointDxDyDz(Pfirst, Plast, myDx, myDy, myDz); - GroupPointDirection->LineEdit2->setText(aString); - myOkDirection = true; - myTrimSize = GroupPointDirection->SpinBox_DX->GetValue(); - } - } - - /* SECOND CONSTRUCTOR */ - else if(myEditCurrentArgument == GroupPointPlusCoordinates->LineEdit1 && myGeomBase->VertexToPoint(S, myPoint1)) { - GroupPointPlusCoordinates->LineEdit1->setText(aString); - /* Get arguments */ - myDx = GroupPointPlusCoordinates->SpinBox_DX->GetValue(); - myDy = GroupPointPlusCoordinates->SpinBox_DY->GetValue(); - myDz = GroupPointPlusCoordinates->SpinBox_DZ->GetValue(); - myTrimSize = GroupPointPlusCoordinates->SpinBox_S->GetValue(); - myOkPoint1 = true; - myOkCoordinates = true; - } - - /* THIRD CONSTRUCTOR */ - else if(myEditCurrentArgument == GroupFace->LineEdit1) { - if(myOkPlanarFace) { - GroupFace->LineEdit1->setText(aString); - BRepAdaptor_Surface surf(TopoDS::Face(S)); - gp_Pln Plane = surf.Plane(); - - gp_Pnt myPoint1 = Plane.Location(); - gp_Ax1 ax = Plane.Axis(); - myDx = (ax.Direction()).X(); - myDy = (ax.Direction()).Y(); - myDz = (ax.Direction()).Z(); - myTrimSize = GroupFace->SpinBox_DX->GetValue(); - } + // nbSel == 1 + Standard_Boolean aRes = Standard_False; + GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( mySelection->firstIObject(), aRes ); + if ( !CORBA::is_nil( aSelectedObject ) && aRes ) + { + myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) ); + if ( myEditCurrentArgument == GroupPntDir->LineEdit1 ) myPoint = aSelectedObject; + else if ( myEditCurrentArgument == GroupPntDir->LineEdit2 ) myDir = aSelectedObject; + else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) myPoint1 = aSelectedObject; + else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) myPoint2 = aSelectedObject; + else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) myPoint3 = aSelectedObject; + else if ( myEditCurrentArgument == GroupFace->LineEdit1 ) myFace = aSelectedObject; } - /* Call method simulation */ - if((myOkPoint1 && myOkDirection) || (myOkPoint1 && myOkCoordinates) || myOkPlanarFace) { - if(myDx*myDx + myDy*myDy + myDz*myDz > Precision::Confusion()*Precision::Confusion()) - this->MakePlaneSimulationAndDisplay(); - } - return; + displayPreview(); } @@ -422,48 +315,24 @@ void BasicGUI_PlaneDlg::SelectionIntoArgument() void BasicGUI_PlaneDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); - mySelection->ClearFilters(); - switch(myConstructorId) - { - case 0: - { - if(send == GroupPointDirection->PushButton1) { - GroupPointDirection->LineEdit1->setFocus(); - myEditCurrentArgument = GroupPointDirection->LineEdit1; - mySelection->AddFilter(myVertexFilter); - } - else if(send == GroupPointDirection->PushButton2) { - GroupPointDirection->LineEdit2->setFocus(); - myEditCurrentArgument = GroupPointDirection->LineEdit2; - /* Edge filter here */ - mySelection->AddFilter(myEdgeFilter); - } - break; - } - case 1: - { - if(send == GroupPointPlusCoordinates->PushButton1) { - GroupPointPlusCoordinates->LineEdit1->setFocus(); - myEditCurrentArgument = GroupPointPlusCoordinates->LineEdit1; - /* Vertex filter here */ - mySelection->AddFilter(myVertexFilter); - } - break; - } - case 2: - { - if(send == GroupFace->PushButton1) { - GroupFace->LineEdit1->setFocus(); - myEditCurrentArgument = GroupFace->LineEdit1; - /* Face filter here */ - mySelection->AddFilter(myFaceFilter); - } - break; - } - } - this->SelectionIntoArgument(); - return; + if ( send == GroupPntDir->PushButton1 ) myEditCurrentArgument = GroupPntDir->LineEdit1; + else if ( send == GroupPntDir->PushButton2 ) myEditCurrentArgument = GroupPntDir->LineEdit2; + else if ( send == Group3Pnts->PushButton1 ) myEditCurrentArgument = Group3Pnts->LineEdit1; + else if ( send == Group3Pnts->PushButton2 ) myEditCurrentArgument = Group3Pnts->LineEdit2; + else if ( send == Group3Pnts->PushButton3 ) myEditCurrentArgument = Group3Pnts->LineEdit3; + else if ( send == GroupFace->PushButton1 ) myEditCurrentArgument = GroupFace->LineEdit1; + + myEditCurrentArgument->setFocus(); + + if ( myEditCurrentArgument == GroupPntDir->LineEdit2 ) + globalSelection( GEOM_LINE ); + else if ( myEditCurrentArgument == GroupFace->LineEdit1 ) + globalSelection( GEOM_PLANE ); + else + globalSelection( GEOM_POINT ); + + SelectionIntoArgument(); } @@ -473,20 +342,17 @@ void BasicGUI_PlaneDlg::SetEditCurrentArgument() //================================================================================= void BasicGUI_PlaneDlg::LineEditReturnPressed() { - QLineEdit* send = (QLineEdit*)sender(); - if(send == GroupPointDirection->LineEdit1) - myEditCurrentArgument = GroupPointDirection->LineEdit1; - else if (send == GroupPointDirection->LineEdit2) - myEditCurrentArgument = GroupPointDirection->LineEdit2; - else if (send == GroupPointPlusCoordinates->LineEdit1) - myEditCurrentArgument = GroupPointPlusCoordinates->LineEdit1; - else if (send == GroupFace->LineEdit1) - myEditCurrentArgument = GroupFace->LineEdit1; - else - return; - - GEOMBase_Skeleton::LineEditReturnPressed(); - return ; + QLineEdit* send = (QLineEdit*)sender(); + if ( send == GroupPntDir->LineEdit1 || + send == GroupPntDir->LineEdit2 || + send == Group3Pnts->LineEdit1 || + send == Group3Pnts->LineEdit2 || + send == Group3Pnts->LineEdit3 || + send == GroupFace->LineEdit1 ) + { + myEditCurrentArgument = send; + GEOMBase_Skeleton::LineEditReturnPressed(); + } } @@ -498,35 +364,21 @@ void BasicGUI_PlaneDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - switch(myConstructorId) - { - case 0: - { - GroupPointDirection->LineEdit1->setFocus(); - myEditCurrentArgument = GroupPointDirection->LineEdit1; - mySelection->AddFilter(myVertexFilter); - break; - } - case 1: - { - GroupPointPlusCoordinates->LineEdit1->setFocus(); - myEditCurrentArgument = GroupPointPlusCoordinates->LineEdit1; - mySelection->AddFilter(myVertexFilter); - break; - } - case 2: - { - GroupFace->LineEdit1->setFocus(); - myEditCurrentArgument = GroupFace->LineEdit1; - mySelection->AddFilter(myFaceFilter); - break; - } - } - if(!mySimulationTopoDs.IsNull()) - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - return; + + myGeomGUI->SetState( 0 ); + + ConstructorsClicked( getConstructorId() ); } +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : public slot to deactivate if active +//================================================================================= +void BasicGUI_PlaneDlg::DeactivateActiveDialog() +{ + myGeomGUI->SetState( -1 ); + GEOMBase_Skeleton::DeactivateActiveDialog(); +} //================================================================================= // function : enterEvent() @@ -534,10 +386,8 @@ void BasicGUI_PlaneDlg::ActivateThisDialog() //================================================================================= void BasicGUI_PlaneDlg::enterEvent(QEvent* e) { - if (GroupConstructors->isEnabled()) - return; - this->ActivateThisDialog(); - return; + if ( !GroupConstructors->isEnabled() ) + ActivateThisDialog(); } @@ -547,46 +397,103 @@ void BasicGUI_PlaneDlg::enterEvent(QEvent* e) //================================================================================= void BasicGUI_PlaneDlg::ValueChangedInSpinBox(double newValue) { - QObject* send = (QObject*)sender(); - - if(send == GroupPointPlusCoordinates->SpinBox_DX) - myDx = newValue; - else if(send == GroupPointPlusCoordinates->SpinBox_DY) - myDy = newValue; - else if(send == GroupPointPlusCoordinates->SpinBox_DZ) - myDz = newValue; - else if(send == GroupPointDirection->SpinBox_DX || send == GroupPointPlusCoordinates->SpinBox_S || send == GroupFace->SpinBox_DX) { - myTrimSize = newValue; - } else - return; + displayPreview(); +} - if((myOkPoint1 && myOkDirection) || (myOkPoint1 && myOkCoordinates) || myOkPlanarFace) { - if(myDx*myDx + myDy*myDy + myDz*myDz > Precision::Confusion() * Precision::Confusion()) - this->MakePlaneSimulationAndDisplay(); +//================================================================================= +// function : getSize() +// purpose : +//================================================================================= +double BasicGUI_PlaneDlg::getSize() const +{ + switch ( getConstructorId() ) + { + case 0 : return GroupPntDir->SpinBox_DX->GetValue(); + case 1 : return Group3Pnts->SpinBox_DX->GetValue(); + case 2 : return GroupFace->SpinBox_DX->GetValue(); } - return; + return 0.; +} + +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr BasicGUI_PlaneDlg::createOperation() +{ + return getGeomEngine()->GetIBasicOperations( getStudyId() ); } +//================================================================================= +// function : isEqual +// purpose : it may also be needed to check for min distance between gp_Pnt-s... +//================================================================================= +static bool isEqual( const GEOM::GEOM_Object_var& thePnt1, const GEOM::GEOM_Object_var& thePnt2 ) +{ + return thePnt1->_is_equivalent( thePnt2 ); +} //================================================================================= -// function : MakePlaneSimulationAndDisplay(() +// function : isValid // purpose : //================================================================================= -void BasicGUI_PlaneDlg::MakePlaneSimulationAndDisplay() +bool BasicGUI_PlaneDlg::isValid( QString& msg ) { - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); - - try { - gp_Dir aDirection(myDx, myDy, myDz); - /* We make a trimmed plane */ - gp_Pln gplane(myPoint1, aDirection); - mySimulationTopoDs = BRepBuilderAPI_MakeFace(gplane, -myTrimSize, +myTrimSize, -myTrimSize, +myTrimSize); - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - } - catch(Standard_Failure) { - MESSAGE( "Exception catched in MakePlaneSimulation" << endl ); - return; + const int id = getConstructorId(); + if ( getSize() <= 0 ) + { + msg = QString( "Please, enter size greater than 0." ); + return false; + } + if ( id == 0 ) + return !CORBA::is_nil( myPoint ) && !CORBA::is_nil( myDir ); + else if ( id == 1 ) + return !CORBA::is_nil( myPoint1 ) && !CORBA::is_nil( myPoint2 ) && !CORBA::is_nil( myPoint3 ) && + !isEqual( myPoint1, myPoint2 ) && !isEqual( myPoint1, myPoint3 ) && !isEqual( myPoint2, myPoint3 ); + else if ( id == 2 ) + return !CORBA::is_nil( myFace ); + return false; +} + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool BasicGUI_PlaneDlg::execute( ObjectList& objects ) +{ + bool res = false; + + GEOM::GEOM_Object_var anObj; + + switch ( getConstructorId() ) + { + case 0 : + anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->MakePlanePntVec( myPoint, myDir, getSize() ); + res = true; + break; + case 1 : + anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->MakePlaneThreePnt( myPoint1, myPoint2, myPoint3, getSize() ); + res = true; + break; + case 2 : + anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->MakePlaneFace( myFace, getSize() ); + res = true; + break; } - return; + + if ( !anObj->_is_nil() ) + objects.push_back( anObj._retn() ); + + return res; +} + +//================================================================================= +// function : closeEvent +// purpose : +//================================================================================= +void BasicGUI_PlaneDlg::closeEvent( QCloseEvent* e ) +{ + myGeomGUI->SetState( -1 ); + GEOMBase_Skeleton::closeEvent( e ); } + diff --git a/src/BasicGUI/BasicGUI_PlaneDlg.h b/src/BasicGUI/BasicGUI_PlaneDlg.h index d22895569..e333a91d8 100644 --- a/src/BasicGUI/BasicGUI_PlaneDlg.h +++ b/src/BasicGUI/BasicGUI_PlaneDlg.h @@ -30,14 +30,10 @@ #define DIALOGBOX_PLANE_H #include "GEOMBase_Skeleton.h" -#include "DlgRef_2Sel1Spin.h" -#include "DlgRef_1Sel4Spin.h" #include "DlgRef_1Sel1Spin.h" +#include "DlgRef_2Sel1Spin.h" +#include "DlgRef_3Sel1Spin.h" -#include "BasicGUI.h" - -#include "GEOM_FaceFilter.hxx" -#include "GEOM_ShapeTypeFilter.hxx" //================================================================================= // class : BasicGUI_PlaneDlg @@ -48,42 +44,36 @@ class BasicGUI_PlaneDlg : public GEOMBase_Skeleton Q_OBJECT public: - BasicGUI_PlaneDlg(QWidget* parent = 0, const char* name = 0, BasicGUI* theBasicGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + BasicGUI_PlaneDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); ~BasicGUI_PlaneDlg(); + +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& ); + virtual bool execute( ObjectList& objects ); + + virtual void closeEvent( QCloseEvent* e ); private : void Init(); void enterEvent(QEvent* e); - void MakePlaneSimulationAndDisplay(); - - BasicGUI* myBasicGUI; - - double step; - int myConstructorId; - Handle(GEOM_ShapeTypeFilter) myVertexFilter; /* Filters selection */ - Handle(GEOM_ShapeTypeFilter) myEdgeFilter; - Handle(GEOM_FaceFilter) myFaceFilter; - - gp_Pnt myPoint1; /* Point on the plane */ - - Standard_Real myDx; - Standard_Real myDy; - Standard_Real myDz; - Standard_Real myTrimSize; + double getSize() const; - bool myOkPoint1; /* true when argument is defined */ - bool myOkDirection; - bool myOkCoordinates; - bool myOkPlanarFace; + GEOM::GEOM_Object_var myPoint, myDir, myPoint1, myPoint2, myPoint3, myFace; - DlgRef_2Sel1Spin* GroupPointDirection; - DlgRef_1Sel4Spin* GroupPointPlusCoordinates; + DlgRef_2Sel1Spin* GroupPntDir; + DlgRef_3Sel1Spin* Group3Pnts; DlgRef_1Sel1Spin* GroupFace; private slots: void ClickOnOk(); - void ClickOnApply(); + void ClickOnCancel(); + bool ClickOnApply(); + void ActivateThisDialog(); + void DeactivateActiveDialog(); + void SelectionIntoArgument(); void LineEditReturnPressed(); void SetEditCurrentArgument(); diff --git a/src/BasicGUI/BasicGUI_PointDlg.cxx b/src/BasicGUI/BasicGUI_PointDlg.cxx index 52128eeac..d5f72b81b 100644 --- a/src/BasicGUI/BasicGUI_PointDlg.cxx +++ b/src/BasicGUI/BasicGUI_PointDlg.cxx @@ -30,16 +30,22 @@ using namespace std; #include "BasicGUI_PointDlg.h" #include "QAD_RightFrame.h" +#include "QAD_Desktop.h" +#include "QAD_Config.h" #include "OCCViewer_Viewer3d.h" -#include +#include "GEOMImpl_Types.hxx" + +#include "utilities.h" + +#include +#include +#include +#include +#include #include -#include -#if OCC_VERSION_MAJOR >= 5 -#include -#else -#include -#endif + +#include //================================================================================= // class : BasicGUI_PointDlg() @@ -48,40 +54,72 @@ using namespace std; // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -BasicGUI_PointDlg::BasicGUI_PointDlg(QWidget* parent, const char* name, BasicGUI* theBasicGUI, SALOME_Selection* Sel, const Handle (AIS_InteractiveContext)& ic, bool modal, WFlags fl) - :GEOMBase_Skeleton(parent, name, Sel, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +BasicGUI_PointDlg::BasicGUI_PointDlg(QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl) + :GEOMBase_Skeleton(parent, name, Sel, modal, fl ) { QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_POINT"))); QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_POINT_EDGE"))); QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); + QPixmap image3(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_POINT_REF"))); setCaption(tr("GEOM_POINT_TITLE")); + QGroupBox* aFrame = new QGroupBox( 1, Qt::Horizontal, this ); + aFrame->setInsideMargin( 0 ); + aFrame->setFrameStyle( QFrame::NoFrame ); + /***************************************************************/ GroupConstructors->setTitle(tr("GEOM_POINTS")); RadioButton1->setPixmap(image0); - RadioButton2->setPixmap(image1); - RadioButton3->close(TRUE); - - GroupPoints = new DlgRef_3Spin(this, "GroupPoints"); - GroupPoints->GroupBox1->setTitle(tr("GEOM_COORDINATES")); - GroupPoints->TextLabel1->setText(tr("GEOM_X")); - GroupPoints->TextLabel2->setText(tr("GEOM_Y")); - GroupPoints->TextLabel3->setText(tr("GEOM_Z")); - - GroupDimensions = new DlgRef_1Sel1Spin(this, "GroupDimensions"); - GroupDimensions->GroupBox1->setTitle(tr("GEOM_PARAM_POINT")); - GroupDimensions->TextLabel1->setText(tr("GEOM_EDGE")); - GroupDimensions->TextLabel2->setText(tr("GEOM_PARAMETER")); - GroupDimensions->PushButton1->setPixmap(image2); - - Layout1->addWidget(GroupPoints, 1, 0); - Layout1->addWidget(GroupDimensions, 1, 0); + RadioButton2->setPixmap(image3); + RadioButton3->setPixmap(image1); + + GroupXYZ = new DlgRef_3Spin( aFrame, "GroupXYZ" ); + GroupXYZ->GroupBox1->setTitle(tr("GEOM_COORDINATES")); + GroupXYZ->TextLabel1->setText(tr("GEOM_X")); + GroupXYZ->TextLabel2->setText(tr("GEOM_Y")); + GroupXYZ->TextLabel3->setText(tr("GEOM_Z")); + + GroupOnCurve = new DlgRef_1Sel1Spin( aFrame, "GroupOnCurve" ); + GroupOnCurve->GroupBox1->setTitle(tr("GEOM_PARAM_POINT")); + GroupOnCurve->TextLabel1->setText(tr("GEOM_EDGE")); + GroupOnCurve->TextLabel2->setText(tr("GEOM_PARAMETER")); + GroupOnCurve->PushButton1->setPixmap(image2); + + GroupRefPoint = new DlgRef_1Sel3Spin( aFrame, "GoupRefPoint" ); + GroupRefPoint->GroupBox1->setTitle(tr("GEOM_REF_POINT")); + GroupRefPoint->TextLabel1->setText(tr("GEOM_POINT")); + GroupRefPoint->PushButton1->setPixmap(image2); + GroupRefPoint->TextLabel2->setText(tr("GEOM_DX")); + GroupRefPoint->TextLabel3->setText(tr("GEOM_DY")); + GroupRefPoint->TextLabel4->setText(tr("GEOM_DZ")); + + Layout1->addWidget( aFrame, 2, 0 ); /***************************************************************/ - /* Initialisations */ - myBasicGUI = theBasicGUI; - Init(ic); + myCoordGrp = new QGroupBox( 2, Qt::Horizontal, tr( "GEOM_COORDINATES" ), aFrame ); + new QLabel( tr( "GEOM_X" ), myCoordGrp ); + myX = new QLineEdit( myCoordGrp ); + new QLabel( tr( "GEOM_Y" ), myCoordGrp ); + myY = new QLineEdit( myCoordGrp ); + new QLabel( tr( "GEOM_Z" ), myCoordGrp ); + myZ = new QLineEdit( myCoordGrp ); + + myX->setReadOnly( true ); + myY->setReadOnly( true ); + myZ->setReadOnly( true ); + + myX->setEnabled( false ); + myY->setEnabled( false ); + myZ->setEnabled( false ); + + QPalette aPal = myX->palette(); + aPal.setColor( QPalette::Disabled, QColorGroup::Text, QColor( 0, 0, 0 ) ) ; + myX->setPalette( aPal ); + myY->setPalette( aPal ); + myZ->setPalette( aPal ); + + Init(); } @@ -91,7 +129,6 @@ BasicGUI_PointDlg::BasicGUI_PointDlg(QWidget* parent, const char* name, BasicGUI //======================================================================= BasicGUI_PointDlg::~BasicGUI_PointDlg() { - /* no need to delete child widgets, Qt does it all for us */ } @@ -99,57 +136,41 @@ BasicGUI_PointDlg::~BasicGUI_PointDlg() // function : Init() // purpose : //================================================================================= -void BasicGUI_PointDlg::Init(const Handle(AIS_InteractiveContext)& ic) +void BasicGUI_PointDlg::Init() { - /* init variables */ - myConstructorId = 0; - myEditCurrentArgument = GroupDimensions->LineEdit1; + GroupOnCurve->LineEdit1->setReadOnly( true ); + GroupRefPoint->LineEdit1->setReadOnly( true ); - myIC = ic; - myParameter = 0.50; - myPoint.SetCoord(0.0, 0.0, 0.0); - myOkEdge = false; + myEdge = GEOM::GEOM_Object::_nil(); + myRefPoint = GEOM::GEOM_Object::_nil(); - myGeomGUI->myState = 0; + myEditCurrentArgument = 0; - /* Vertices Filter for all arguments */ - myEdgeFilter = new GEOM_ShapeTypeFilter(TopAbs_EDGE, myGeom); + myGeomGUI->SetState( 0 ); /* Get setting of step value from file configuration */ QString St = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep"); - step = St.toDouble(); + double step = St.toDouble(); /* min, max, step and decimals for spin boxes */ - double specificStep = 0.1; - GroupDimensions->SpinBox_DX->RangeStepAndValidator(-999999.99999, 999999.99999, specificStep, 5); - GroupPoints->SpinBox_DX->RangeStepAndValidator(-999.999, 999.999, step, 3); - GroupPoints->SpinBox_DY->RangeStepAndValidator(-999.999, 999.999, step, 3); - GroupPoints->SpinBox_DZ->RangeStepAndValidator(-999.999, 999.999, step, 3); - GroupDimensions->SpinBox_DX->SetValue(myParameter); - GroupPoints->SpinBox_DX->SetValue(0.0); - GroupPoints->SpinBox_DY->SetValue(0.0); - GroupPoints->SpinBox_DZ->SetValue(0.0); - - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { - myLocalContextId = myIC->OpenLocalContext(); - //myGeomBase->SetDisplayedObjectList(); - /* sub shapes selection */ - myLocalContextMode = TopAbs_VERTEX; - myIC->ActivateStandardMode(myLocalContextMode); - myUseLocalContext = true; - } - else - myUseLocalContext = false; - - TopoDS_Shape S; - bool displayPoint = true; - if(myGeomBase->GetTopoFromSelection(mySelection, S)) { - /* Filter a possibly previous selection and try to put it into coordinates */ - if(myGeomBase->VertexToPoint(S, myPoint)) - displayPoint = false; - } - this->PointIntoCoordinates(myPoint, displayPoint); - + GroupXYZ->SpinBox_DX->RangeStepAndValidator(-999.999, 999.999, step, 3); + GroupXYZ->SpinBox_DY->RangeStepAndValidator(-999.999, 999.999, step, 3); + GroupXYZ->SpinBox_DZ->RangeStepAndValidator(-999.999, 999.999, step, 3); + GroupXYZ->SpinBox_DX->SetValue(0.0); + GroupXYZ->SpinBox_DY->SetValue(0.0); + GroupXYZ->SpinBox_DZ->SetValue(0.0); + + GroupRefPoint->SpinBox_DX->RangeStepAndValidator(-999.999, 999.999, step, 3); + GroupRefPoint->SpinBox_DY->RangeStepAndValidator(-999.999, 999.999, step, 3); + GroupRefPoint->SpinBox_DZ->RangeStepAndValidator(-999.999, 999.999, step, 3); + GroupRefPoint->SpinBox_DX->SetValue(0.0); + GroupRefPoint->SpinBox_DY->SetValue(0.0); + GroupRefPoint->SpinBox_DZ->SetValue(0.0); + + step = 0.1; + GroupOnCurve->SpinBox_DX->RangeStepAndValidator(0., 1., step, 3); + GroupOnCurve->SpinBox_DX->SetValue( 0.5 ); + /* signals and slots connections */ connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel())); connect(myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog())); @@ -159,27 +180,30 @@ void BasicGUI_PointDlg::Init(const Handle(AIS_InteractiveContext)& ic) connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); connect(GroupConstructors, SIGNAL(clicked(int)), this, SLOT(ConstructorsClicked(int))); - connect(GroupDimensions->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect(GroupDimensions->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(GroupOnCurve->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupOnCurve->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupDimensions->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(GroupPoints->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(GroupPoints->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupOnCurve->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupXYZ->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupXYZ->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupXYZ->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupRefPoint->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupRefPoint->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupRefPoint->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupDimensions->SpinBox_DX, SLOT(SetStep(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox_DX, SLOT(SetStep(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox_DY, SLOT(SetStep(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox_DZ, SLOT(SetStep(double))); + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupOnCurve->SpinBox_DX, SLOT(SetStep(double))); + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupXYZ->SpinBox_DX, SLOT(SetStep(double))); + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupXYZ->SpinBox_DY, SLOT(SetStep(double))); + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupXYZ->SpinBox_DZ, SLOT(SetStep(double))); + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupRefPoint->SpinBox_DX, SLOT(SetStep(double))); + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupRefPoint->SpinBox_DY, SLOT(SetStep(double))); + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupRefPoint->SpinBox_DZ, SLOT(SetStep(double))); - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - /* displays Dialog */ - GroupDimensions->hide(); - GroupPoints->show(); - this->show(); + initName( tr("GEOM_VERTEX") ); - return; + ConstructorsClicked( 0 ); } @@ -188,56 +212,64 @@ void BasicGUI_PointDlg::Init(const Handle(AIS_InteractiveContext)& ic) // purpose : Radio button management //================================================================================= void BasicGUI_PointDlg::ConstructorsClicked(int constructorId) -{ - myConstructorId = constructorId; - mySelection->ClearFilters(); - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); - disconnect(mySelection, 0, this, 0); +{ + switch ( constructorId ) + { + case 0: + { + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); + + GroupRefPoint->hide(); + GroupOnCurve->hide(); - switch (constructorId) + GroupXYZ->show(); + + myCoordGrp->hide(); + break; + } + case 1: { - case 0: - { - if(myUseLocalContext == false && QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { - myLocalContextId = myIC->OpenLocalContext(); - //myGeomBase->SetDisplayedObjectList(); - /* sub shapes selection */ - myLocalContextMode = TopAbs_VERTEX; - myIC->ActivateStandardMode(myLocalContextMode); - myUseLocalContext = true; - } - - GroupDimensions->hide(); - resize(0, 0); - GroupPoints->show(); - - /* Display point simulation */ - PointIntoCoordinates(myPoint, true); - break; - } - case 1: - { - if(myUseLocalContext == true && QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { - myIC->CloseLocalContext(myLocalContextId); - myUseLocalContext = false; - } - - GroupPoints->hide(); - resize(0, 0); - GroupDimensions->show(); - - myEditCurrentArgument = GroupDimensions->LineEdit1; - GroupDimensions->LineEdit1->setText(""); - myOkEdge = false; - - /* filter for next selections */ - mySelection->AddFilter(myEdgeFilter); - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - break; - } + myEditCurrentArgument = GroupRefPoint->LineEdit1; + myEditCurrentArgument->setText(""); + myRefPoint = GEOM::GEOM_Object::_nil(); + + globalSelection( GEOM_POINT ); + + GroupXYZ->hide(); + GroupOnCurve->hide(); + + GroupRefPoint->show(); + + myCoordGrp->show(); + break; } - return; + case 2: + { + myEditCurrentArgument = GroupOnCurve->LineEdit1; + myEditCurrentArgument->setText(""); + myEdge = GEOM::GEOM_Object::_nil(); + + globalSelection( GEOM_EDGE ); + + GroupXYZ->hide(); + GroupRefPoint->hide(); + + GroupOnCurve->show(); + + myCoordGrp->show(); + break; + } + } + + myX->setText( "" ); + myY->setText( "" ); + myZ->setText( "" ); + + qApp->processEvents(); + updateGeometry(); + resize( minimumSize() ); + + displayPreview(); } @@ -247,9 +279,8 @@ void BasicGUI_PointDlg::ConstructorsClicked(int constructorId) //================================================================================= void BasicGUI_PointDlg::ClickOnOk() { - this->ClickOnApply(); - this->ClickOnCancel(); - return; + if ( ClickOnApply() ) + ClickOnCancel(); } @@ -257,52 +288,14 @@ void BasicGUI_PointDlg::ClickOnOk() // function : ClickOnApply() // purpose : //================================================================================= -void BasicGUI_PointDlg::ClickOnApply() +bool BasicGUI_PointDlg::ClickOnApply() { - buttonApply->setFocus(); - QAD_Application::getDesktop()->putInfo(tr("")); - if(mySimulationTopoDs.IsNull()) - return; - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); - - /* Close local context */ - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { - myIC->CloseLocalContext(myLocalContextId); - myUseLocalContext = false; - } + if ( !onAccept() ) + return false; - switch(myConstructorId) - { - case 0 : - { - /* Recup args and call method */ - double x = GroupPoints->SpinBox_DX->GetValue(); - double y = GroupPoints->SpinBox_DY->GetValue(); - double z = GroupPoints->SpinBox_DZ->GetValue(); - - myBasicGUI->MakePointAndDisplay(x,y,z); /* WARNING : no display if a local context is opened */ - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { - /* no display if a local context is opened */ - myLocalContextId = myIC->OpenLocalContext(); - //myGeomBase->SetDisplayedObjectList(); - /* sub shapes selection */ - myLocalContextMode = TopAbs_VERTEX; - myIC->ActivateStandardMode(myLocalContextMode); - myUseLocalContext = true; - } - break; - } - case 1 : - { - if(myOkEdge == true) { - /* this constructor method has no idl interface : we use same than constructor 0 */ - myBasicGUI->MakePointAndDisplay(myPoint.X(), myPoint.Y(), myPoint.Z()); - } - break; - } - } - return; + initName(); + ConstructorsClicked( getConstructorId() ); + return true; } @@ -312,18 +305,7 @@ void BasicGUI_PointDlg::ClickOnApply() //======================================================================= void BasicGUI_PointDlg::ClickOnCancel() { - if(myConstructorId == 0 && QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - myIC = v3d->getAISContext(); - if(myIC->HasOpenedContext()) { - myIC->CloseLocalContext(myLocalContextId); - myUseLocalContext = false; - } - } - - myGeomGUI->myState = -1; GEOMBase_Skeleton::ClickOnCancel(); - return; } @@ -333,32 +315,50 @@ void BasicGUI_PointDlg::ClickOnCancel() //================================================================================= void BasicGUI_PointDlg::SelectionIntoArgument() { - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); - myEditCurrentArgument->setText(""); - QString aString = ""; /* name of selection */ - - int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString); - if(nbSel != 1) { - myOkEdge = false; - return; + const int id = getConstructorId(); + + if ( ( id == 1 || id == 2 ) && myEditCurrentArgument != 0 ) + { + myEditCurrentArgument->setText(""); + myX->setText( "" ); + myY->setText( "" ); + myZ->setText( "" ); + myRefPoint = myEdge = GEOM::GEOM_Object::_nil(); } - - // nbSel == 1 - TopoDS_Shape S; - if(!myGeomBase->GetTopoFromSelection(mySelection, S)) - return; - - if(S.ShapeType() == TopAbs_EDGE) { - if(CalculateVertexOnCurve(TopoDS::Edge(S), myParameter, mySimulationTopoDs)) { - if(myGeomBase->VertexToPoint(mySimulationTopoDs, myPoint)) { - GroupDimensions->LineEdit1->setText(aString); - myOkEdge = true; - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); + + if ( mySelection->IObjectCount() == 1 ) + { + Standard_Boolean aRes = Standard_False; + GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( mySelection->firstIObject(), aRes ); + if ( !CORBA::is_nil( aSelectedObject ) && aRes ) + { + if ( id == 0 ) + { + // get CORBA reference to data object + TopoDS_Shape aShape = GeometryGUI::GetGeomGUI()->GetShapeReader().GetShape( + GeometryGUI::GetGeomGUI()->GetGeomGen(), aSelectedObject ); + if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX ) + { + gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) ); + GroupXYZ->SpinBox_DX->SetValue( aPnt.X() ); + GroupXYZ->SpinBox_DY->SetValue( aPnt.Y() ); + GroupXYZ->SpinBox_DZ->SetValue( aPnt.Z() ); + } } - } + else if ( id == 1 ) + { + myRefPoint = aSelectedObject; + GroupRefPoint->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) ); + } + else if ( id == 2 ) + { + myEdge = aSelectedObject; + GroupOnCurve->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) ); + } + } } - return; + + displayPreview(); } @@ -369,13 +369,11 @@ void BasicGUI_PointDlg::SelectionIntoArgument() void BasicGUI_PointDlg::LineEditReturnPressed() { QLineEdit* send = (QLineEdit*)sender(); - if(send == GroupDimensions->LineEdit1) - myEditCurrentArgument = GroupDimensions->LineEdit1; - else - return; - - GEOMBase_Skeleton::LineEditReturnPressed(); - return; + if ( send == GroupRefPoint->LineEdit1 || send == GroupOnCurve->LineEdit1 ) + { + myEditCurrentArgument = send; + GEOMBase_Skeleton::LineEditReturnPressed(); + } } @@ -387,13 +385,20 @@ void BasicGUI_PointDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); - if(send == GroupDimensions->PushButton1) { - GroupDimensions->LineEdit1->setFocus(); - myEditCurrentArgument = GroupDimensions->LineEdit1; - mySelection->AddFilter(myEdgeFilter); - this->SelectionIntoArgument(); + if ( send == GroupRefPoint->PushButton1 ) + { + GroupRefPoint->LineEdit1->setFocus(); + myEditCurrentArgument = GroupRefPoint->LineEdit1; + + globalSelection( GEOM_POINT ); + } + else if ( send == GroupOnCurve->PushButton1 ) + { + GroupOnCurve->LineEdit1->setFocus(); + myEditCurrentArgument = GroupOnCurve->LineEdit1; + + globalSelection( GEOM_EDGE ); } - return; } @@ -403,21 +408,8 @@ void BasicGUI_PointDlg::SetEditCurrentArgument() //================================================================================= void BasicGUI_PointDlg::enterEvent(QEvent* e) { - if (GroupConstructors->isEnabled()) - return; - this->ActivateThisDialog(); - return; -} - - -//======================================================================= -// function : closeEvent() -// purpose : -//======================================================================= -void BasicGUI_PointDlg::closeEvent(QCloseEvent* e) -{ - /* same than click on cancel button */ - this->ClickOnCancel(); + if ( !GroupConstructors->isEnabled() ) + ActivateThisDialog(); } @@ -428,26 +420,8 @@ void BasicGUI_PointDlg::closeEvent(QCloseEvent* e) void BasicGUI_PointDlg::ActivateThisDialog( ) { GEOMBase_Skeleton::ActivateThisDialog(); - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - - myGeomGUI->myState = 0; - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - myIC = v3d->getAISContext(); - myLocalContextId = myIC->OpenLocalContext(); - //myGeomBase->SetDisplayedObjectList(); - /* sub shapes selection */ - myLocalContextMode = TopAbs_VERTEX; - myIC->ActivateStandardMode(myLocalContextMode); - myUseLocalContext = true; - } - - if(myConstructorId == 1) - mySelection->AddFilter(myEdgeFilter); - - if(!mySimulationTopoDs.IsNull()) - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - return; + myGeomGUI->SetState( 0 ); + ConstructorsClicked( getConstructorId() ); } @@ -457,13 +431,8 @@ void BasicGUI_PointDlg::ActivateThisDialog( ) //================================================================================= void BasicGUI_PointDlg::DeactivateActiveDialog() { - if(myConstructorId == 0 && QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { - myIC->CloseLocalContext(myLocalContextId); - myUseLocalContext = false; - } - myGeomGUI->myState = -1; + myGeomGUI->SetState( -1 ); GEOMBase_Skeleton::DeactivateActiveDialog(); - return; } @@ -473,95 +442,127 @@ void BasicGUI_PointDlg::DeactivateActiveDialog() //================================================================================= void BasicGUI_PointDlg::ValueChangedInSpinBox(double newValue) { - DlgRef_SpinBox* send = (DlgRef_SpinBox*)sender(); - double vx, vy, vz; - - if(send == GroupPoints->SpinBox_DX) { - vx = newValue; - vy = GroupPoints->SpinBox_DY->GetValue(); - vz = GroupPoints->SpinBox_DZ->GetValue(); - } else if(send == GroupPoints->SpinBox_DY) { - vx = GroupPoints->SpinBox_DX->GetValue(); - vy = newValue; - vz = GroupPoints->SpinBox_DZ->GetValue(); - } else if(send == GroupPoints->SpinBox_DZ) { - vx = GroupPoints->SpinBox_DX->GetValue(); - vy = GroupPoints->SpinBox_DY->GetValue(); - vz = newValue; - } else if(send == GroupDimensions->SpinBox_DX) { - myParameter = newValue; - } else - return; - - switch(myConstructorId) - { - case 0: // default constructor - { - myPoint.SetCoord(vx, vy, vz); - mySimulationTopoDs = BRepBuilderAPI_MakeVertex (myPoint).Shape(); - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - break; - } - case 1: - { - this->SelectionIntoArgument(); - break; - } - } - return; + displayPreview(); } +//======================================================================= +// funcion : getParameter() +// purpose : +//======================================================================= +double BasicGUI_PointDlg::getParameter() const +{ + return GroupOnCurve->SpinBox_DX->GetValue(); +} //================================================================================= -// function : CalculateVertexOnCurve() -// purpose : Calculate a Vertex on the curve given by 'anEdge'. -// : The position of resultVertex is given by aParameter. -// : For a linear edge, aParameter=0.0 gives the first vertex of edge -// : aParameter=1.0 gives the last vertex of edge -// : aParameter=0.5 gives the vertex on the middle of edge -// : It is possible to get vertices out of edge using values > 1.0 or < 0.0 +// function : OnPointSelected +// purpose : //================================================================================= -bool BasicGUI_PointDlg::CalculateVertexOnCurve(const TopoDS_Edge& anEdge, const Standard_Real aParameter, TopoDS_Shape& resultVertex) +void BasicGUI_PointDlg::OnPointSelected( const gp_Pnt& thePnt ) { -#if OCC_VERSION_MAJOR >= 5 - if(anEdge.IsNull() || !BRepAlgo::IsValid(anEdge)) -#else - if(anEdge.IsNull() || !BRepAlgoAPI::IsValid(anEdge)) -#endif - return false; + if ( getConstructorId() == 0 ) + { + GroupXYZ->SpinBox_DX->SetValue( thePnt.X() ); + GroupXYZ->SpinBox_DY->SetValue( thePnt.Y() ); + GroupXYZ->SpinBox_DZ->SetValue( thePnt.Z() ); - Standard_Real first, last; - Handle(Geom_Curve) curv = BRep_Tool::Curve(anEdge, first, last); - if(!curv->IsCN(0)) - return false; - - Standard_Real param; - if(anEdge.Orientation() == TopAbs_FORWARD) - param = first + (last-first) * aParameter; - else - param = last + (first-last) * aParameter; - - gp_Pnt paramPoint; - curv->D0(param, paramPoint); - resultVertex = BRepBuilderAPI_MakeVertex(paramPoint); - return true; + displayPreview(); + } } +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr BasicGUI_PointDlg::createOperation() +{ + return getGeomEngine()->GetIBasicOperations( getStudyId() ); +} -//======================================================================= -// funcion : PointIntoCoordinates() -// purpose : Sets user point coordinates into this dialog Spin boxes -// : and displays it or not according to 'bool displayPoint' -//======================================================================= -void BasicGUI_PointDlg::PointIntoCoordinates(gp_Pnt P, bool displayPoint) +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool BasicGUI_PointDlg::isValid( QString& msg ) { - GroupPoints->SpinBox_DX->SetValue(P.X()); - GroupPoints->SpinBox_DY->SetValue(P.Y()); - GroupPoints->SpinBox_DZ->SetValue(P.Z()); - myPoint.SetCoord(P.X(), P.Y(), P.Z()); - if(displayPoint) { - mySimulationTopoDs = BRepBuilderAPI_MakeVertex(P).Shape(); - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); + const int id = getConstructorId(); + if ( id == 0 ) + return true; + else if ( id == 1 ) + return !myRefPoint->_is_nil(); + else if ( id == 2 ) + return !myEdge->_is_nil(); + return false; +} + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool BasicGUI_PointDlg::execute( ObjectList& objects ) +{ + bool res = false; + + GEOM::GEOM_Object_var anObj; + + switch ( getConstructorId() ) + { + case 0 : + { + double x = GroupXYZ->SpinBox_DX->GetValue(); + double y = GroupXYZ->SpinBox_DY->GetValue(); + double z = GroupXYZ->SpinBox_DZ->GetValue(); + + anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->MakePointXYZ( x,y,z ); + res = true; + break; + } + case 1 : + { + double dx = GroupRefPoint->SpinBox_DX->GetValue(); + double dy = GroupRefPoint->SpinBox_DY->GetValue(); + double dz = GroupRefPoint->SpinBox_DZ->GetValue(); + + anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->MakePointWithReference( myRefPoint, dx, dy, dz ); + res = true; + break; + } + case 2 : + anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->MakePointOnCurve( myEdge, getParameter() ); + res = true; + break; } - return; + + if ( getConstructorId() == 1 || getConstructorId() == 2 ) + { + TopoDS_Shape aShape; + if ( GEOMBase::GetShape( anObj, aShape ) && !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX ) + { + gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) ); + myX->setText( QString( "%1" ).arg( aPnt.X() ) ); + myY->setText( QString( "%1" ).arg( aPnt.Y() ) ); + myZ->setText( QString( "%1" ).arg( aPnt.Z() ) ); + } + else + { + myX->setText( "" ); + myY->setText( "" ); + myZ->setText( "" ); + } + } + + if ( !anObj->_is_nil() ) + objects.push_back( anObj._retn() ); + + return res; +} + +//================================================================================= +// function : closeEvent +// purpose : +//================================================================================= +void BasicGUI_PointDlg::closeEvent( QCloseEvent* e ) +{ + myGeomGUI->SetState( -1 ); + GEOMBase_Skeleton::closeEvent( e ); } diff --git a/src/BasicGUI/BasicGUI_PointDlg.h b/src/BasicGUI/BasicGUI_PointDlg.h index 2ee583633..48b248db8 100644 --- a/src/BasicGUI/BasicGUI_PointDlg.h +++ b/src/BasicGUI/BasicGUI_PointDlg.h @@ -32,11 +32,10 @@ #include "GEOMBase_Skeleton.h" #include "DlgRef_1Sel1Spin.h" #include "DlgRef_3Spin.h" +#include "DlgRef_1Sel3Spin.h" -#include "BasicGUI.h" - -#include "GEOM_ShapeTypeFilter.hxx" -#include +class QLineEdit; +class QGroupBox; //================================================================================= // class : BasicGUI_PointDlg @@ -47,38 +46,42 @@ class BasicGUI_PointDlg : public GEOMBase_Skeleton Q_OBJECT public: - BasicGUI_PointDlg(QWidget* parent = 0, const char* name = 0, BasicGUI* theBasicGUI = 0, SALOME_Selection* Sel = 0, const Handle(AIS_InteractiveContext)& ic = 0, bool modal = FALSE, WFlags fl = 0); + BasicGUI_PointDlg(QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); ~BasicGUI_PointDlg(); + + bool acceptMouseEvent() const { return ( getConstructorId() == 0 ); }; + void OnPointSelected( const gp_Pnt& ); // called by BasicGUI::OnMousePress() -private : - void Init(const Handle(AIS_InteractiveContext)& ic); - void enterEvent(QEvent* e); - void closeEvent(QCloseEvent* e); +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& ); + virtual bool execute( ObjectList& objects ); - BasicGUI* myBasicGUI; + virtual void closeEvent( QCloseEvent* e ); - double step; - int myConstructorId; - Handle(GEOM_ShapeTypeFilter) myEdgeFilter; /* filter for selection */ +private : + void Init(); + void enterEvent(QEvent* e); + double getParameter() const; - gp_Pnt myPoint; /* Is 'mySimulationTopoDs' */ - bool myOkEdge; /* true when an edge is selected by user */ - double myParameter; /* Parameter used to create a vertex on edge (point on curve) */ + GEOM::GEOM_Object_var myEdge; + GEOM::GEOM_Object_var myRefPoint; - /* Interactive and local context management see also : bool UseLocalContext() */ - Handle(AIS_InteractiveContext) myIC; /* Interactive context from IAPP */ - Standard_Integer myLocalContextId; /* identify a local context for this method */ - TopAbs_ShapeEnum myLocalContextMode; /* identify a selection mode into local context */ - bool myUseLocalContext; /* true when method as opened a local context */ + DlgRef_3Spin* GroupXYZ; + DlgRef_1Sel3Spin* GroupRefPoint; + DlgRef_1Sel1Spin* GroupOnCurve; - DlgRef_1Sel1Spin* GroupDimensions; - DlgRef_3Spin* GroupPoints; + QGroupBox* myCoordGrp; + QLineEdit* myX; + QLineEdit* myY; + QLineEdit* myZ; private slots: void ClickOnOk(); void ClickOnCancel(); - void ClickOnApply(); + bool ClickOnApply(); void ActivateThisDialog(); void DeactivateActiveDialog(); void LineEditReturnPressed(); @@ -86,16 +89,6 @@ private slots: void SetEditCurrentArgument(); void ConstructorsClicked(int constructorId); void ValueChangedInSpinBox(double newValue); - - bool CalculateVertexOnCurve(const TopoDS_Edge& anEdge, - const Standard_Real aParameter, - TopoDS_Shape& resultVertex); - -public: - void PointIntoCoordinates(gp_Pnt P, bool displayPoint); - /* return true if method has opened a local context */ - bool UseLocalContext(){return myUseLocalContext;}; - }; #endif // DIALOGBOX_POINT_H diff --git a/src/BasicGUI/BasicGUI_VectorDlg.cxx b/src/BasicGUI/BasicGUI_VectorDlg.cxx index 03baf4300..0af637cb3 100644 --- a/src/BasicGUI/BasicGUI_VectorDlg.cxx +++ b/src/BasicGUI/BasicGUI_VectorDlg.cxx @@ -29,12 +29,12 @@ using namespace std; #include "BasicGUI_VectorDlg.h" +#include "QAD_Desktop.h" #include "QAD_Config.h" -#include -#include -#include -#include -#include + +#include "GEOMImpl_Types.hxx" + +#include "utilities.h" //================================================================================= // class : BasicGUI_VectorDlg() @@ -43,8 +43,8 @@ using namespace std; // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -BasicGUI_VectorDlg::BasicGUI_VectorDlg(QWidget* parent, const char* name, BasicGUI* theBasicGUI, SALOME_Selection* Sel, bool modal, WFlags fl) - :GEOMBase_Skeleton(parent, name, Sel, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) +BasicGUI_VectorDlg::BasicGUI_VectorDlg(QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl) + :GEOMBase_Skeleton(parent, name, Sel, modal, fl ) { QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_VECTOR_2P"))); QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_VECTOR_DXYZ"))); @@ -65,6 +65,9 @@ BasicGUI_VectorDlg::BasicGUI_VectorDlg(QWidget* parent, const char* name, BasicG GroupPoints->PushButton1->setPixmap(image2); GroupPoints->PushButton2->setPixmap(image2); + GroupPoints->LineEdit1->setReadOnly( true ); + GroupPoints->LineEdit2->setReadOnly( true ); + GroupDimensions = new DlgRef_3Spin1Check(this, "GroupDimensions"); GroupDimensions->GroupBox1->setTitle(tr("GEOM_COORDINATES")); GroupDimensions->TextLabel1->setText(tr("GEOM_DX")); @@ -72,12 +75,11 @@ BasicGUI_VectorDlg::BasicGUI_VectorDlg(QWidget* parent, const char* name, BasicG GroupDimensions->TextLabel3->setText(tr("GEOM_DZ")); GroupDimensions->CheckBox1->setText(tr("GEOM_REVERSE_VECTOR")); - Layout1->addWidget(GroupPoints, 1, 0); - Layout1->addWidget(GroupDimensions, 1, 0); + Layout1->addWidget(GroupPoints, 2, 0); + Layout1->addWidget(GroupDimensions, 2, 0); /***************************************************************/ /* Initialisations */ - myBasicGUI = theBasicGUI; Init(); } @@ -88,7 +90,6 @@ BasicGUI_VectorDlg::BasicGUI_VectorDlg(QWidget* parent, const char* name, BasicG //================================================================================= BasicGUI_VectorDlg::~BasicGUI_VectorDlg() { - /* no need to delete child widgets, Qt does it all for us */ } @@ -99,36 +100,32 @@ BasicGUI_VectorDlg::~BasicGUI_VectorDlg() void BasicGUI_VectorDlg::Init() { /* init variables */ - myConstructorId = 0; myEditCurrentArgument = GroupPoints->LineEdit1; - myDx = 0.0; - myDy = 0.0; - myDz = 200.0; - myPoint1.SetCoord(0.0, 0.0, 0.0); - myPoint2.SetCoord(0.0, 0.0, 0.0); - myOkPoint1 = myOkPoint2 = false; - - /* Vertices Filter for all arguments */ - myVertexFilter = new GEOM_ShapeTypeFilter(TopAbs_VERTEX, myGeom); - mySelection->AddFilter(myVertexFilter); + myPoint1 = GEOM::GEOM_Object::_nil(); + myPoint2 = GEOM::GEOM_Object::_nil(); /* Get setting of step value from file configuration */ QString St = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep"); - step = St.toDouble(); + double step = St.toDouble(); /* min, max, step and decimals for spin boxes */ GroupDimensions->SpinBox_DX->RangeStepAndValidator(-999.999, 999.999, step, 3); GroupDimensions->SpinBox_DY->RangeStepAndValidator(-999.999, 999.999, step, 3); GroupDimensions->SpinBox_DZ->RangeStepAndValidator(-999.999, 999.999, step, 3); - GroupDimensions->SpinBox_DX->SetValue(myDx); - GroupDimensions->SpinBox_DY->SetValue(myDy); - GroupDimensions->SpinBox_DZ->SetValue(myDz); + double dx( 0. ), dy( 0. ), dz( 200. ); + GroupDimensions->SpinBox_DX->SetValue( dx ); + GroupDimensions->SpinBox_DY->SetValue( dy ); + GroupDimensions->SpinBox_DZ->SetValue( dz ); GroupDimensions->CheckBox1->setChecked(FALSE); /* 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(GroupConstructors, SIGNAL(clicked(int)), this, SLOT(ConstructorsClicked(int))); @@ -151,12 +148,10 @@ void BasicGUI_VectorDlg::Init() connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - /* displays Dialog */ - GroupDimensions->hide(); - GroupPoints->show(); - this->show(); + initName( tr("GEOM_VECTOR") ); - return; + GroupDimensions->hide(); + ConstructorsClicked( 0 ); } @@ -164,13 +159,11 @@ void BasicGUI_VectorDlg::Init() // function : ConstructorsClicked() // purpose : Radio button management //================================================================================= -void BasicGUI_VectorDlg::ConstructorsClicked(int constructorId) +void BasicGUI_VectorDlg::ConstructorsClicked( int constructorId ) { - myConstructorId = constructorId; - mySelection->ClearFilters(); - myGeomBase->EraseSimulationShape(); disconnect(mySelection, 0, this, 0); - myOkPoint1 = myOkPoint2 = false; + myPoint1 = GEOM::GEOM_Object::_nil(); + myPoint2 = GEOM::GEOM_Object::_nil(); switch (constructorId) { @@ -184,8 +177,7 @@ void BasicGUI_VectorDlg::ConstructorsClicked(int constructorId) GroupPoints->LineEdit1->setText(""); GroupPoints->LineEdit2->setText(""); - /* filter for next selection */ - mySelection->AddFilter(myVertexFilter); + globalSelection( GEOM_POINT ); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); break; } @@ -194,28 +186,18 @@ void BasicGUI_VectorDlg::ConstructorsClicked(int constructorId) GroupPoints->hide(); resize( 0, 0 ); GroupDimensions->show(); + + double dx( 0. ), dy( 0. ), dz( 0. ); + GroupDimensions->SpinBox_DX->SetValue( dx ); + GroupDimensions->SpinBox_DY->SetValue( dy ); + GroupDimensions->SpinBox_DZ->SetValue( dz ); - myDx = 0.0; - myDy = 0.0; - myDz = 200.0; - - GroupDimensions->SpinBox_DX->SetValue(myDx); - GroupDimensions->SpinBox_DY->SetValue(myDy); - GroupDimensions->SpinBox_DZ->SetValue(myDz); - - myPoint1.SetCoord(0.0, 0.0, 0.0) ; - myPoint2.SetCoord(myDx, myDy, myDz); - - GroupDimensions->CheckBox1->setChecked(FALSE); - - mySimulationTopoDs = BRepBuilderAPI_MakeEdge(myPoint1, myPoint2).Shape(); - /* Add arrow in simulation */ - bool noNeedToTest = AddArrowToSimulation(mySimulationTopoDs); - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); + GroupDimensions->CheckBox1->setChecked( FALSE ); break; } } - return; + + displayPreview(); } @@ -225,46 +207,34 @@ void BasicGUI_VectorDlg::ConstructorsClicked(int constructorId) //================================================================================= void BasicGUI_VectorDlg::ClickOnOk() { - this->ClickOnApply(); - ClickOnCancel(); - return; + if ( ClickOnApply() ) + ClickOnCancel(); } +//======================================================================= +// function : ClickOnCancel() +// purpose : +//======================================================================= +void BasicGUI_VectorDlg::ClickOnCancel() +{ + GEOMBase_Skeleton::ClickOnCancel(); +} //================================================================================= // function : ClickOnApply() // purpose : //================================================================================= -void BasicGUI_VectorDlg::ClickOnApply() +bool BasicGUI_VectorDlg::ClickOnApply() { buttonApply->setFocus(); - QAD_Application::getDesktop()->putInfo(tr("")); - if (mySimulationTopoDs.IsNull()) - return; - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); - - switch(myConstructorId) - { - case 0 : - { - if(myOkPoint1 && myOkPoint2) - myBasicGUI->MakeVectorAndDisplay(myPoint1, myPoint2); - break ; - } - case 1 : - { - /* Recup args and call method */ - myDx = GroupDimensions->SpinBox_DX->GetValue(); - myDy = GroupDimensions->SpinBox_DY->GetValue(); - myDz = GroupDimensions->SpinBox_DZ->GetValue(); - myPoint1.SetCoord(0.0, 0.0, 0.0); - myPoint2.SetCoord(myDx, myDy, myDz); - myBasicGUI->MakeVectorAndDisplay(myPoint1, myPoint2); - break; - } - } - return; + + if ( !onAccept() ) + return false; + + initName(); + if ( getConstructorId() != 1 ) + ConstructorsClicked( getConstructorId() ); + return true; } @@ -274,40 +244,28 @@ void BasicGUI_VectorDlg::ClickOnApply() //================================================================================= void BasicGUI_VectorDlg::SelectionIntoArgument() { - myGeomBase->EraseSimulationShape(); myEditCurrentArgument->setText(""); - QString aString = ""; /* name of selection */ - - int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString); - if (nbSel != 1) { - if (myEditCurrentArgument == GroupPoints->LineEdit1) - myOkPoint1 = false; - else if ( myEditCurrentArgument == GroupPoints->LineEdit2) - myOkPoint2 = false; - return; - } - // nbSel == 1 - TopoDS_Shape S; - if(!myGeomBase->GetTopoFromSelection(mySelection, S)) + if ( mySelection->IObjectCount() != 1 ) + { + if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) + myPoint1 = GEOM::GEOM_Object::_nil(); + else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) + myPoint2 = GEOM::GEOM_Object::_nil(); return; - - if(myEditCurrentArgument == GroupPoints->LineEdit1 && myGeomBase->VertexToPoint(S, myPoint1)) { - myEditCurrentArgument->setText(aString); - myOkPoint1 = true; - } - else if(myEditCurrentArgument == GroupPoints->LineEdit2 && myGeomBase->VertexToPoint(S, myPoint2)) { - myEditCurrentArgument->setText(aString); - myOkPoint2 = true; } - if(myOkPoint1 && myOkPoint2 && myPoint1.Distance(myPoint2) > Precision::Confusion()) { - mySimulationTopoDs = BRepBuilderAPI_MakeEdge(myPoint1, myPoint2).Shape(); - /* Add arrow in simulation */ - bool noNeedToTest = this->AddArrowToSimulation(mySimulationTopoDs); - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); + // nbSel == 1 + Standard_Boolean aRes = Standard_False; + GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( mySelection->firstIObject(), aRes ); + if ( !CORBA::is_nil( aSelectedObject ) && aRes ) + { + myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) ); + if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) myPoint1 = aSelectedObject; + else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) myPoint2 = aSelectedObject; } - return; + + displayPreview(); } @@ -317,23 +275,11 @@ void BasicGUI_VectorDlg::SelectionIntoArgument() //================================================================================= void BasicGUI_VectorDlg::SetEditCurrentArgument() { - if(myConstructorId != 0) - return; - QPushButton* send = (QPushButton*)sender(); - - if(send == GroupPoints->PushButton1) { - GroupPoints->LineEdit1->setFocus(); - myEditCurrentArgument = GroupPoints->LineEdit1; - } - else if(send == GroupPoints->PushButton2) { - GroupPoints->LineEdit2->setFocus(); - myEditCurrentArgument = GroupPoints->LineEdit2; - } - mySelection->AddFilter(myVertexFilter); - this->SelectionIntoArgument(); - - return; + if ( send == GroupPoints->PushButton1 ) myEditCurrentArgument = GroupPoints->LineEdit1; + else if ( send == GroupPoints->PushButton2 ) myEditCurrentArgument = GroupPoints->LineEdit2; + myEditCurrentArgument->setFocus(); + SelectionIntoArgument(); } @@ -344,15 +290,10 @@ void BasicGUI_VectorDlg::SetEditCurrentArgument() void BasicGUI_VectorDlg::LineEditReturnPressed() { QLineEdit* send = (QLineEdit*)sender(); - if(send == GroupPoints->LineEdit1) - myEditCurrentArgument = GroupPoints->LineEdit1; - else if (send == GroupPoints->LineEdit2) - myEditCurrentArgument = GroupPoints->LineEdit2; - else - return; - + if ( send == GroupPoints->LineEdit1 ) myEditCurrentArgument = GroupPoints->LineEdit1; + else if ( send == GroupPoints->LineEdit2 ) myEditCurrentArgument = GroupPoints->LineEdit2; + else return; GEOMBase_Skeleton::LineEditReturnPressed(); - return; } @@ -364,13 +305,19 @@ void BasicGUI_VectorDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - if(myConstructorId == 0) - mySelection->AddFilter(myVertexFilter); - if(!mySimulationTopoDs.IsNull()) - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - return; + + ConstructorsClicked( getConstructorId() ); } +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : public slot to deactivate if active +//================================================================================= +void BasicGUI_VectorDlg::DeactivateActiveDialog() +{ + myGeomGUI->SetState( -1 ); + GEOMBase_Skeleton::DeactivateActiveDialog(); +} //================================================================================= // function : enterEvent() @@ -378,91 +325,84 @@ void BasicGUI_VectorDlg::ActivateThisDialog() //================================================================================= void BasicGUI_VectorDlg::enterEvent(QEvent* e) { - if(GroupConstructors->isEnabled()) - return; - this->ActivateThisDialog(); - return; + if ( !GroupConstructors->isEnabled() ) + ActivateThisDialog(); } - //================================================================================= // function : ValueChangedInSpinBox() // purpose : //================================================================================= -void BasicGUI_VectorDlg::ValueChangedInSpinBox(double newValue) +void BasicGUI_VectorDlg::ValueChangedInSpinBox( double newValue ) { - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); - QObject* send = (QObject*)sender(); - - if(send == GroupDimensions->SpinBox_DX) - myDx = newValue; - else if (send == GroupDimensions->SpinBox_DY) - myDy = newValue; - else if (send == GroupDimensions->SpinBox_DZ) - myDz = newValue; - - myPoint1.SetCoord(0.0, 0.0, 0.0); - myPoint2.SetCoord(myDx, myDy, myDz); - - if(myPoint1.Distance(myPoint2) > Precision::Confusion()) { // mySimulationTopoDs - mySimulationTopoDs = BRepBuilderAPI_MakeEdge(myPoint1, myPoint2).Shape(); - /* Create simulation vector with an arrow */ - this->AddArrowToSimulation(mySimulationTopoDs); - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - } - return; + displayPreview(); } +//================================================================================= +// function : ReverseVector() +// purpose : 'state' not used here +//================================================================================= +void BasicGUI_VectorDlg::ReverseVector(int state) +{ + double dx = -GroupDimensions->SpinBox_DX->GetValue(); + double dy = -GroupDimensions->SpinBox_DY->GetValue(); + double dz = -GroupDimensions->SpinBox_DZ->GetValue(); + + GroupDimensions->SpinBox_DX->SetValue( dx ); + GroupDimensions->SpinBox_DY->SetValue( dy ); + GroupDimensions->SpinBox_DZ->SetValue( dz ); + + displayPreview(); +} //================================================================================= -// function : AddArrowToSimulation() -// purpose : An arrow (cone topology) is added to 'modifiedShape' -// : to simulate a vector or an 'oriented line' display. The result is in 'modifiedShape'. -// : If an arrow can't be added returns false and 'modifiedShape' isn't modified ! +// function : createOperation +// purpose : //================================================================================= -bool BasicGUI_VectorDlg::AddArrowToSimulation(TopoDS_Shape& modifiedShape) +GEOM::GEOM_IOperations_ptr BasicGUI_VectorDlg::createOperation() { - TopoDS_Shape arrow; - /* Try to add a cone simulation shape to show direction of a linear edge */ - if(myGeomBase->CreateArrowForLinearEdge(modifiedShape, arrow)) { - TopoDS_Compound Comp; - BRep_Builder B; - B.MakeCompound (Comp); - B.Add(Comp, modifiedShape); - B.Add(Comp, arrow); - modifiedShape = Comp; - return true; - } - return false; + return getGeomEngine()->GetIBasicOperations( getStudyId() ); } +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool BasicGUI_VectorDlg::isValid( QString& msg ) +{ + return getConstructorId() == 0 ? !myPoint1->_is_nil() && !myPoint2->_is_nil(): true; +} //================================================================================= -// function : ReverseVector() -// purpose : 'state' not used here +// function : execute +// purpose : //================================================================================= -void BasicGUI_VectorDlg::ReverseVector(int state) +bool BasicGUI_VectorDlg::execute( ObjectList& objects ) { - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); - - myDx = -myDx; - GroupDimensions->SpinBox_DX->SetValue(myDx); - myDy = -myDy; - GroupDimensions->SpinBox_DY->SetValue(myDy); - myDz = -myDz; - GroupDimensions->SpinBox_DZ->SetValue(myDz); - - myPoint1.SetCoord(0.0, 0.0, 0.0); - myPoint2.SetCoord(myDx, myDy, myDz); + bool res = false; - /* In the appropriate constructor */ - if(myPoint1.Distance(myPoint2) > Precision::Confusion()) { - mySimulationTopoDs = BRepBuilderAPI_MakeEdge(myPoint1, myPoint2).Shape(); - /* Add arrow in simulation */ - bool noNeedToTest = this->AddArrowToSimulation(mySimulationTopoDs); - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); + GEOM::GEOM_Object_var anObj; + + switch ( getConstructorId() ) { + case 0 : + anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->MakeVectorTwoPnt( myPoint1, myPoint2 ); + res = true; + break; + + case 1 : + { + double dx = GroupDimensions->SpinBox_DX->GetValue(); + double dy = GroupDimensions->SpinBox_DY->GetValue(); + double dz = GroupDimensions->SpinBox_DZ->GetValue(); + anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->MakeVectorDXDYDZ( dx,dy,dz ); + res = true; + break; + } } - return; + + if ( !anObj->_is_nil() ) + objects.push_back( anObj._retn() ); + + return res; } + diff --git a/src/BasicGUI/BasicGUI_VectorDlg.h b/src/BasicGUI/BasicGUI_VectorDlg.h index 41636b165..02c5e0ef2 100644 --- a/src/BasicGUI/BasicGUI_VectorDlg.h +++ b/src/BasicGUI/BasicGUI_VectorDlg.h @@ -45,35 +45,33 @@ class BasicGUI_VectorDlg : public GEOMBase_Skeleton Q_OBJECT public: - BasicGUI_VectorDlg(QWidget* parent = 0, const char* name = 0, BasicGUI* theBasicGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + BasicGUI_VectorDlg(QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); ~BasicGUI_VectorDlg(); + +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& ); + virtual bool execute( ObjectList& objects ); private : void Init(); void enterEvent(QEvent* e); - bool AddArrowToSimulation(TopoDS_Shape& modifiedShape); - BasicGUI* myBasicGUI; - - double step; - int myConstructorId; - Handle(GEOM_ShapeTypeFilter) myVertexFilter; /* Filter selection */ - - gp_Pnt myPoint1; /* Points containing the vector */ - gp_Pnt myPoint2; - bool myOkPoint1; /* Are true when myPoint is defined */ - bool myOkPoint2; - double myDx; - double myDy; - double myDz; + GEOM::GEOM_Object_var myPoint1; + GEOM::GEOM_Object_var myPoint2; DlgRef_2Sel_QTD* GroupPoints; DlgRef_3Spin1Check* GroupDimensions; private slots: void ClickOnOk(); - void ClickOnApply(); + void ClickOnCancel(); + bool ClickOnApply(); + void ActivateThisDialog(); + void DeactivateActiveDialog(); + void LineEditReturnPressed(); void SelectionIntoArgument(); void SetEditCurrentArgument(); diff --git a/src/BasicGUI/BasicGUI_WorkingPlaneDlg.cxx b/src/BasicGUI/BasicGUI_WorkingPlaneDlg.cxx index 515269302..991fc997a 100644 --- a/src/BasicGUI/BasicGUI_WorkingPlaneDlg.cxx +++ b/src/BasicGUI/BasicGUI_WorkingPlaneDlg.cxx @@ -1,23 +1,23 @@ // 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 +// 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 // // // @@ -28,56 +28,91 @@ using namespace std; #include "BasicGUI_WorkingPlaneDlg.h" -#include -#include +#include "GEOMBase.h" + +#include "OCCViewer_Viewer3d.h" +#include "OCCViewer_ViewPort3d.h" +#include "QAD_StudyFrame.h" +#include "QAD_RightFrame.h" +#include "QAD_Desktop.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include #include -#include +#include +#include + +#include "GEOMImpl_Types.hxx" + +#include //================================================================================= // class : BasicGUI_WorkingPlaneDlg() -// purpose : Constructs a BasicGUI_WorkingPlaneDlg which is a child of 'parent', with the +// purpose : Constructs a BasicGUI_WorkingPlaneDlg 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. //================================================================================= -BasicGUI_WorkingPlaneDlg::BasicGUI_WorkingPlaneDlg(QWidget* parent, const char* name, BasicGUI* theBasicGUI, SALOME_Selection* Sel, bool modal, WFlags fl) +BasicGUI_WorkingPlaneDlg::BasicGUI_WorkingPlaneDlg(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_WPLANE_FACE"))); - QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_WPLANE_FACE"))); + QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_WPLANE_VECTOR"))); + QPixmap image3(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_WPLANE_ORIGIN"))); setCaption(tr("GEOM_WPLANE_TITLE")); - + /***************************************************************/ GroupConstructors->setTitle(tr("GEOM_WPLANE")); - RadioButton1->setPixmap(image0); - RadioButton2->close(TRUE); - RadioButton3->close(TRUE); - - GroupWPlane = new DlgRef_1Sel_QTD(this, "GroupWPlane"); - GroupWPlane->GroupBox1->setTitle(tr("GEOM_WPLANE_FACE")); - GroupWPlane->TextLabel1->setText(tr("GEOM_SELECTION")); - GroupWPlane->PushButton1->setPixmap(image1); - - Layout1->addWidget(GroupWPlane, 1, 0); + RadioButton1->setPixmap(image1); + RadioButton2->setPixmap(image2); + RadioButton3->setPixmap(image3); + + Group1 = new DlgRef_1Sel_QTD(this, "Group1"); + Group1->GroupBox1->setTitle(tr("GEOM_WPLANE_FACE")); + Group1->TextLabel1->setText(tr("GEOM_SELECTION")); + Group1->PushButton1->setPixmap(image0); + Group1->LineEdit1->setReadOnly( true ); + + Group2 = new DlgRef_2Sel_QTD(this, "Group2"); + Group2->GroupBox1->setTitle(tr("GEOM_WPLANE_VECTOR")); + Group2->TextLabel1->setText(tr("GEOM_WPLANE_VX")); + Group2->TextLabel2->setText(tr("GEOM_WPLANE_VZ")); + Group2->PushButton1->setPixmap(image0); + Group2->PushButton2->setPixmap(image0); + Group2->LineEdit1->setReadOnly( true ); + Group2->LineEdit2->setReadOnly( true ); + + Group3 = new DlgRef_3Check_QTD(this, "Group3"); + Group3->GroupBox1->setTitle(tr("GEOM_WPLANE_ORIGIN")); + Group3->RadioButton1->setText(tr("GEOM_WPLANE_OXY")); + Group3->RadioButton2->setText(tr("GEOM_WPLANE_OYZ")); + Group3->RadioButton3->setText(tr("GEOM_WPLANE_OZX")); + + Layout1->addWidget(Group1, 1, 0); + Layout1->addWidget(Group2, 1, 0); + Layout1->addWidget(Group3, 1, 0); /***************************************************************/ - /* Initialisation */ - myBasicGUI = theBasicGUI; Init(); } - //================================================================================= // function : ~BasicGUI_WorkingPlaneDlg() // purpose : Destroys the object and frees any allocated resources //================================================================================= BasicGUI_WorkingPlaneDlg::~BasicGUI_WorkingPlaneDlg() { - // no need to delete child widgets, Qt does it all for us } - //================================================================================= // function : Init() // purpose : @@ -85,30 +120,113 @@ BasicGUI_WorkingPlaneDlg::~BasicGUI_WorkingPlaneDlg() void BasicGUI_WorkingPlaneDlg::Init() { /* init variables */ - myEditCurrentArgument = GroupWPlane->LineEdit1; + myEditCurrentArgument = Group1->LineEdit1; + myWPlane = GeometryGUI::GetGeomGUI()->GetWorkingPlane(); + + myGeomGUI->SetState( 0 ); - myOkPlane = false; + myFace = GEOM::GEOM_Object::_nil(); + myVectX = GEOM::GEOM_Object::_nil(); + myVectZ = GEOM::GEOM_Object::_nil(); + + aOriginType = 1; /* Filter definition */ - myFaceFilter = new GEOM_FaceFilter(StdSelect_Plane, myGeom); - mySelection->AddFilter(myFaceFilter); /* filter for next selection */ + globalSelection( GEOM_PLANE ); /* 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(GroupConstructors, SIGNAL(clicked(int)), this, SLOT(ConstructorsClicked(int))); + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); - connect(GroupWPlane->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupWPlane->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(Group1->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(Group1->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + + connect(Group2->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(Group2->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(Group2->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(Group2->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + + connect(Group3->GroupBox1, SIGNAL(clicked(int)), this, SLOT(GroupClicked(int))); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - /* displays Dialog */ - GroupWPlane->show(); - this->show(); + initName( tr( "GEOM_WPLANE" ) ); + ConstructorsClicked(0); +} - return; +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void BasicGUI_WorkingPlaneDlg::ConstructorsClicked(int constructorId) +{ + disconnect(mySelection, 0, this, 0); + myGeomGUI->SetState( 0 ); + + switch (constructorId) + { + case 0: + { + globalSelection( GEOM_PLANE ); + + Group2->hide(); + Group3->hide(); + resize(0, 0); + Group1->show(); + + myEditCurrentArgument = Group1->LineEdit1; + Group1->LineEdit1->setText(""); + myFace = GEOM::GEOM_Object::_nil(); + + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + break; + } + case 1: + { + globalSelection( GEOM_LINE ); + + Group1->hide(); + Group3->hide(); + resize(0, 0); + Group2->show(); + + myEditCurrentArgument = Group2->LineEdit1; + Group2->LineEdit1->setText(""); + Group2->LineEdit2->setText(""); + myVectX = GEOM::GEOM_Object::_nil(); + myVectZ = GEOM::GEOM_Object::_nil(); + + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + break; + } + case 2: + { + Group1->hide(); + Group2->hide(); + resize(0, 0); + Group3->show(); + + Group3->RadioButton1->setChecked(true); + aOriginType = 1; + break; + } + } + displayPreview(); } +//================================================================================= +// function : GroupClicked() +// purpose : Radio button management +//================================================================================= +void BasicGUI_WorkingPlaneDlg::GroupClicked(int groupId) +{ + aOriginType = groupId; +} //================================================================================= // function : ClickOnOk() @@ -116,26 +234,103 @@ void BasicGUI_WorkingPlaneDlg::Init() //================================================================================= void BasicGUI_WorkingPlaneDlg::ClickOnOk() { - this->ClickOnApply(); - ClickOnCancel(); - return; + if ( ClickOnApply() ) + ClickOnCancel(); } //================================================================================= // function : ClickOnApply() // purpose : //================================================================================= -void BasicGUI_WorkingPlaneDlg::ClickOnApply() +bool BasicGUI_WorkingPlaneDlg::ClickOnApply() { buttonApply->setFocus(); QAD_Application::getDesktop()->putInfo(tr("")); - if(myOkPlane) - myBasicGUI->MakeWorkingPlane(myLoc, myDir); - - return; + const int id = getConstructorId(); + + if (id == 0) { + if ( !CORBA::is_nil( myFace ) ) { + TopoDS_Face aPlaneShape; + if ( GEOMBase::GetShape( myFace, aPlaneShape, TopAbs_FACE ) ) { + Handle(Geom_Surface) aGS = BRep_Tool::Surface( TopoDS::Face( aPlaneShape ) ); + if ( !aGS.IsNull() && aGS->IsKind( STANDARD_TYPE( Geom_Plane ) ) ) { + Handle(Geom_Plane) aGPlane = Handle(Geom_Plane)::DownCast( aGS ); + gp_Pln aPln = aGPlane->Pln(); + + myWPlane = aPln.Position(); + GeometryGUI::GetGeomGUI()->SetWorkingPlane(myWPlane); + GeometryGUI::GetGeomGUI()->ActiveWorkingPlane(); + return true; + } + } + } + } else if (id == 1) { + if ( CORBA::is_nil( myVectX ) || CORBA::is_nil( myVectZ ) ) { + showError( "Two vectors have to be selected" ); + return false; + } + + TopoDS_Edge aVectX, aVectZ; + TopoDS_Vertex V1, V2; + gp_Vec aVX, aVZ; + if (GEOMBase::GetShape( myVectX, aVectX, TopAbs_EDGE ) && + GEOMBase::GetShape( myVectZ, aVectZ, TopAbs_EDGE )) { + TopExp::Vertices(aVectZ, V1, V2, Standard_True); + if (!V1.IsNull() && !V2.IsNull()) + aVZ = gp_Vec(BRep_Tool::Pnt(V1), BRep_Tool::Pnt(V2)); + else { + showError( "Bad OZ vector" ); + return false; + } + + TopExp::Vertices(aVectX, V1, V2, Standard_True); + if (!V1.IsNull() && !V2.IsNull()) + aVX = gp_Vec(BRep_Tool::Pnt(V1), BRep_Tool::Pnt(V2)); + else { + showError( "Bad OX vector" ); + return false; + } + + gp_Dir aDirZ = gp_Dir(aVZ.X(), aVZ.Y(), aVZ.Z()); + gp_Dir aDirX = gp_Dir(aVX.X(), aVX.Y(), aVX.Z()); + + if (aDirX.IsParallel(aDirZ, Precision::Confusion())) { + showError( "Parallel vectors selected" ); + return false; + } + + myWPlane = gp_Ax3(BRep_Tool::Pnt(V1), aDirZ, aDirX); + + GeometryGUI::GetGeomGUI()->SetWorkingPlane(myWPlane); + GeometryGUI::GetGeomGUI()->ActiveWorkingPlane(); + return true; + } + } else if (id == 2) { + gp_Pnt P1 = gp_Pnt(0., 0., 0.); + gp_Dir aDirZ, aDirX; + + if (aOriginType == 1) { + aDirZ = gp_Dir(0., 0., 1.); + aDirX = gp_Dir(1., 0., 0.); + } + else if (aOriginType == 2) { + aDirZ = gp_Dir(1., 0., 0.); + aDirX = gp_Dir(0., 1., 0.); + } + else if (aOriginType == 0) { + aDirZ = gp_Dir(0., 1., 0.); + aDirX = gp_Dir(0., 0., 1.); + } + + myWPlane = gp_Ax3(P1, aDirZ, aDirX); + + GeometryGUI::GetGeomGUI()->SetWorkingPlane(myWPlane); + GeometryGUI::GetGeomGUI()->ActiveWorkingPlane(); + return true; + } + return false; } - //================================================================================= // function : SelectionIntoArgument() // purpose : Called when selection as changed or other case @@ -143,29 +338,35 @@ void BasicGUI_WorkingPlaneDlg::ClickOnApply() void BasicGUI_WorkingPlaneDlg::SelectionIntoArgument() { myEditCurrentArgument->setText(""); - QString aString = ""; - int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString); - if(nbSel != 1) { - myOkPlane = false; + const int id = getConstructorId(); + if ( mySelection->IObjectCount() != 1 ) { + if(id == 0) + myFace = GEOM::GEOM_Object::_nil(); + else if(id == 1) { + if (myEditCurrentArgument == Group2->LineEdit1) + myVectX = GEOM::GEOM_Object::_nil(); + else if (myEditCurrentArgument == Group2->LineEdit2) + myVectZ = GEOM::GEOM_Object::_nil(); + } return; } - - /* nbSel == 1 */ - TopoDS_Shape S; - if(!myGeomBase->GetTopoFromSelection(mySelection, S)) + + // nbSel == 1 + Standard_Boolean aRes = Standard_False; + GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(mySelection->firstIObject(), aRes); + + if(!aRes || CORBA::is_nil( aSelectedObject )) return; - - BRepAdaptor_Surface surf(TopoDS::Face(S)); - gp_Pln Plane = surf.Plane(); - myLoc = Plane.Location(); - myDir = Plane.Axis().Direction(); - GroupWPlane->LineEdit1->setText(aString); - myOkPlane = true; + if(myEditCurrentArgument == Group1->LineEdit1) + myFace = aSelectedObject; + else if(myEditCurrentArgument == Group2->LineEdit1) + myVectX = aSelectedObject; + else if(myEditCurrentArgument == Group2->LineEdit2) + myVectZ = aSelectedObject; - /* no simulation */ - return; + myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) ); } @@ -175,9 +376,23 @@ void BasicGUI_WorkingPlaneDlg::SelectionIntoArgument() //================================================================================= void BasicGUI_WorkingPlaneDlg::SetEditCurrentArgument() { - GroupWPlane->LineEdit1->setFocus(); - this->SelectionIntoArgument(); - return; + QPushButton* send = (QPushButton*)sender(); + + if(send == Group1->PushButton1) { + myEditCurrentArgument = Group1->LineEdit1; + globalSelection( GEOM_PLANE ); + } + else if(send == Group2->PushButton1) { + myEditCurrentArgument = Group2->LineEdit1; + globalSelection( GEOM_LINE ); + } + else if(send == Group2->PushButton2) { + myEditCurrentArgument = Group2->LineEdit2; + globalSelection( GEOM_LINE ); + } + + myEditCurrentArgument->setFocus(); + SelectionIntoArgument(); } @@ -187,8 +402,11 @@ void BasicGUI_WorkingPlaneDlg::SetEditCurrentArgument() //================================================================================= void BasicGUI_WorkingPlaneDlg::LineEditReturnPressed() { - GEOMBase_Skeleton::LineEditReturnPressed(); - return; + QLineEdit* send = (QLineEdit*)sender(); + if(send == Group1->LineEdit1 || send == Group2->LineEdit1 || send == Group2->LineEdit2) { + myEditCurrentArgument = send; + GEOMBase_Skeleton::LineEditReturnPressed(); + } } @@ -196,23 +414,50 @@ void BasicGUI_WorkingPlaneDlg::LineEditReturnPressed() // function : ActivateThisDialog() // purpose : //================================================================================= -void BasicGUI_WorkingPlaneDlg::ActivateThisDialog() +void BasicGUI_WorkingPlaneDlg::ActivateThisDialog( ) { GEOMBase_Skeleton::ActivateThisDialog(); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - mySelection->AddFilter(myFaceFilter); - return; + + ConstructorsClicked( getConstructorId() ); } +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : public slot to deactivate if active +//================================================================================= +void BasicGUI_WorkingPlaneDlg::DeactivateActiveDialog() +{ + myGeomGUI->SetState( -1 ); + GEOMBase_Skeleton::DeactivateActiveDialog(); +} + +//======================================================================= +// function : ClickOnCancel() +// purpose : +//======================================================================= +void BasicGUI_WorkingPlaneDlg::ClickOnCancel() +{ + GEOMBase_Skeleton::ClickOnCancel(); +} + //================================================================================= // function : enterEvent() // purpose : //================================================================================= void BasicGUI_WorkingPlaneDlg::enterEvent(QEvent* e) { - if(GroupConstructors->isEnabled()) - return; - this->ActivateThisDialog(); - return; + if ( !GroupConstructors->isEnabled() ) + ActivateThisDialog(); +} + +//================================================================================= +// function : closeEvent +// purpose : +//================================================================================= +void BasicGUI_WorkingPlaneDlg::closeEvent( QCloseEvent* e ) +{ + myGeomGUI->SetState( -1 ); + GEOMBase_Skeleton::closeEvent( e ); } diff --git a/src/BasicGUI/BasicGUI_WorkingPlaneDlg.h b/src/BasicGUI/BasicGUI_WorkingPlaneDlg.h index 6e9b5baf6..ba4bf98ed 100644 --- a/src/BasicGUI/BasicGUI_WorkingPlaneDlg.h +++ b/src/BasicGUI/BasicGUI_WorkingPlaneDlg.h @@ -30,10 +30,9 @@ #include "GEOMBase_Skeleton.h" #include "DlgRef_1Sel_QTD.h" +#include "DlgRef_2Sel_QTD.h" +#include "DlgRef_3Check_QTD.h" -#include "BasicGUI.h" - -#include "GEOM_FaceFilter.hxx" //================================================================================= // class : BasicGUI_WorkingPlaneDlg @@ -44,30 +43,40 @@ class BasicGUI_WorkingPlaneDlg : public GEOMBase_Skeleton Q_OBJECT public: - BasicGUI_WorkingPlaneDlg( QWidget* parent = 0, const char* name = 0, BasicGUI* theBasicGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + BasicGUI_WorkingPlaneDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); ~BasicGUI_WorkingPlaneDlg(); + + virtual void closeEvent( QCloseEvent* e ); private: void Init(); void enterEvent(QEvent* e); - BasicGUI* myBasicGUI; + GEOM::GEOM_Object_var myFace; + GEOM::GEOM_Object_var myVectX; + GEOM::GEOM_Object_var myVectZ; - Handle(GEOM_FaceFilter) myFaceFilter; /* filter for selection */ + int aOriginType; - gp_Pnt myLoc; - gp_Dir myDir; - bool myOkPlane; /* to check when arguments are defined */ + DlgRef_1Sel_QTD* Group1; + DlgRef_2Sel_QTD* Group2; + DlgRef_3Check_QTD* Group3; - DlgRef_1Sel_QTD* GroupWPlane; + gp_Ax3 myWPlane; private slots: void ClickOnOk(); - void ClickOnApply(); + void ClickOnCancel(); + bool ClickOnApply(); + + void ConstructorsClicked(int constructorId); + void GroupClicked(int groupId); void SetEditCurrentArgument(); void SelectionIntoArgument(); void LineEditReturnPressed(); + void ActivateThisDialog(); + void DeactivateActiveDialog(); }; diff --git a/src/BasicGUI/Makefile.in b/src/BasicGUI/Makefile.in index 2dc8edf1b..dfc9c8a84 100644 --- a/src/BasicGUI/Makefile.in +++ b/src/BasicGUI/Makefile.in @@ -48,10 +48,11 @@ LIB_SRC = BasicGUI.cxx \ BasicGUI_ArcDlg.cxx \ BasicGUI_VectorDlg.cxx \ BasicGUI_PlaneDlg.cxx \ - BasicGUI_WorkingPlaneDlg.cxx + BasicGUI_WorkingPlaneDlg.cxx \ + BasicGUI_CurveDlg.cxx \ + BasicGUI_MarkerDlg.cxx LIB_MOC = \ - BasicGUI.h \ BasicGUI_PointDlg.h \ BasicGUI_LineDlg.h \ BasicGUI_CircleDlg.h \ @@ -59,9 +60,11 @@ LIB_MOC = \ BasicGUI_ArcDlg.h \ BasicGUI_VectorDlg.h \ BasicGUI_PlaneDlg.h \ - BasicGUI_WorkingPlaneDlg.h + BasicGUI_WorkingPlaneDlg.h \ + BasicGUI_CurveDlg.h \ + BasicGUI_MarkerDlg.h -LIB_CLIENT_IDL = +LIB_CLIENT_IDL = SALOME_GenericObj.idl LIB_SERVER_IDL = @@ -70,6 +73,6 @@ LIB_SERVER_IDL = CPPFLAGS += $(QT_INCLUDES) $(VTK_INCLUDES) $(OCC_INCLUDES) $(PYTHON_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome CXXFLAGS += -I${KERNEL_ROOT_DIR}/include/salome -LDFLAGS += -lGEOMFiltersSelection -lGEOMBase +LDFLAGS += -lGEOMFiltersSelection -lGEOMBase -lGEOMGUI @CONCLUDE@ diff --git a/src/BlocksGUI/BlocksGUI.cxx b/src/BlocksGUI/BlocksGUI.cxx new file mode 100644 index 000000000..39c125b28 --- /dev/null +++ b/src/BlocksGUI/BlocksGUI.cxx @@ -0,0 +1,131 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 CEA +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org or email : webmaster.salome@opencascade.org +// +// +// +// File : BooleanGUI.cxx +// Author : Julia DOOVSKIKH +// Module : GEOM +// $Header$ + +#include "BlocksGUI.h" + +#include "BlocksGUI_QuadFaceDlg.h" +#include "BlocksGUI_BlockDlg.h" +#include "BlocksGUI_TrsfDlg.h" +//#include "BlocksGUI_CheckMultiBlockDlg.h" +#include "BlocksGUI_ExplodeDlg.h" + +#include "SALOMEGUI_QtCatchCorbaException.hxx" + +#include "QAD_Desktop.h" +#include "QAD_MessageBox.h" + +BlocksGUI* BlocksGUI::myGUIObject = 0; + +//======================================================================= +// function : GetBlocksGUI() +// purpose : Get the only BlocksGUI object [ static ] +//======================================================================= +BlocksGUI* BlocksGUI::GetBlocksGUI() +{ + if ( myGUIObject == 0 ) + myGUIObject = new BlocksGUI(); + + return myGUIObject; +} + +//======================================================================= +// function : BlocksGUI() +// purpose : Constructor +//======================================================================= +BlocksGUI::BlocksGUI() + : GEOMGUI() +{ +} + +//======================================================================= +// function : ~BlocksGUI() +// purpose : Destructor +//======================================================================= +BlocksGUI::~BlocksGUI() +{ +} + +//======================================================================= +// function : OnGUIEvent() +// purpose : +//======================================================================= +bool BlocksGUI::OnGUIEvent( int theCommandID, QAD_Desktop* parent ) +{ + GeometryGUI::GetGeomGUI()->EmitSignalDeactivateDialog(); + + SALOME_Selection* Sel = SALOME_Selection::Selection + (QAD_Application::getDesktop()->getActiveStudy()->getSelection()); + + QDialog* aDlg = NULL; + + switch (theCommandID) + { + case 9999: + aDlg = new BlocksGUI_BlockDlg (parent, Sel); + break; + + case 9998: + aDlg = new BlocksGUI_TrsfDlg (parent, Sel); + break; + + case 9997: + aDlg = new BlocksGUI_QuadFaceDlg (parent, Sel); + break; + + case 9996: +// aDlg = new BlocksGUI_CheckMultiBlockDlg (parent, Sel); + QAD_MessageBox::warn1 (parent, + QObject::tr("WRN_WARNING"), + QObject::tr("WRN_NOT_IMPLEMENTED"), + QObject::tr("BUT_OK")); + break; + + case 9995: + aDlg = new BlocksGUI_ExplodeDlg (parent, Sel); + break; + + default: + parent->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); + break; + } + + if (aDlg != NULL) + aDlg->show(); + + return true; +} + +//===================================================================================== +// EXPORTED METHODS +//===================================================================================== +extern "C" +{ + GEOMGUI* GetLibGUI() + { + return BlocksGUI::GetBlocksGUI(); + } +} diff --git a/src/BlocksGUI/BlocksGUI.h b/src/BlocksGUI/BlocksGUI.h new file mode 100644 index 000000000..513b8accf --- /dev/null +++ b/src/BlocksGUI/BlocksGUI.h @@ -0,0 +1,54 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 CEA +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org or email : webmaster.salome@opencascade.org +// +// +// +// File : BuildGUI.h +// Author : Julia DOROVSKIKH +// Module : GEOM +// $Header$ + +#ifndef BLOCKSGUI_H +#define BLOCKSGUI_H + +#include "GEOMGUI.h" + +//================================================================================= +// class : BlocksGUI +// purpose : +//================================================================================= +class BlocksGUI : public GEOMGUI +{ + protected: + BlocksGUI(); // hide constructor to avoid direct creation + + public: + ~BlocksGUI(); + + // Get the only BuildGUI object + static BlocksGUI* GetBlocksGUI(); + + bool OnGUIEvent (int theCommandID, QAD_Desktop* parent); + +private: + static BlocksGUI* myGUIObject; // the only BlocksGUI object +}; + +#endif diff --git a/src/BlocksGUI/BlocksGUI_BlockDlg.cxx b/src/BlocksGUI/BlocksGUI_BlockDlg.cxx new file mode 100644 index 000000000..888ee3a63 --- /dev/null +++ b/src/BlocksGUI/BlocksGUI_BlockDlg.cxx @@ -0,0 +1,394 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 CEA +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org or email : webmaster.salome@opencascade.org +// +// +// +// File : BlocksGUI_BlockDlg.cxx +// Author : Julia DOROVSKIKH +// Module : GEOM +// $Header$ + +#include "BlocksGUI_BlockDlg.h" + +#include "QAD_Desktop.h" + +#include "GEOMImpl_Types.hxx" + +using namespace std; + +//================================================================================= +// class : BlocksGUI_BlockDlg() +// purpose : Constructs a BlocksGUI_BlockDlg which is a child of 'parent'. +//================================================================================= +BlocksGUI_BlockDlg::BlocksGUI_BlockDlg (QWidget* parent, + SALOME_Selection* Sel, + bool modal) + : GEOMBase_Skeleton(parent, "BlockDlg", Sel, modal, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) +{ + QPixmap image0 (QAD_Desktop::getResourceManager()->loadPixmap("GEOM", tr("ICON_DLG_BLOCK_2F"))); + QPixmap image1 (QAD_Desktop::getResourceManager()->loadPixmap("GEOM", tr("ICON_DLG_BLOCK_6F"))); + QPixmap imageS (QAD_Desktop::getResourceManager()->loadPixmap("GEOM", tr("ICON_SELECT"))); + + setCaption(tr("GEOM_BLOCK_TITLE")); + + /***************************************************************/ + GroupConstructors->setTitle(tr("GEOM_BLOCK")); + + RadioButton1->setPixmap(image0); + RadioButton2->setPixmap(image1); + RadioButton3->close(TRUE); + + // Create first group + Group2F = new DlgRef_2Sel_QTD(this, "Group2F"); + Group2F->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); + Group2F->TextLabel1->setText(tr("FACE_1")); + Group2F->TextLabel2->setText(tr("FACE_2")); + Group2F->PushButton1->setPixmap(imageS); + Group2F->PushButton2->setPixmap(imageS); + + // Create second group + Group6F = new DlgRef_6Sel_QTD(this, "Group2F"); + Group6F->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); + Group6F->TextLabel1->setText(tr("FACE_1")); + Group6F->TextLabel2->setText(tr("FACE_2")); + Group6F->TextLabel3->setText(tr("FACE_3")); + Group6F->TextLabel4->setText(tr("FACE_4")); + Group6F->TextLabel5->setText(tr("FACE_5")); + Group6F->TextLabel6->setText(tr("FACE_6")); + Group6F->PushButton1->setPixmap(imageS); + Group6F->PushButton2->setPixmap(imageS); + Group6F->PushButton3->setPixmap(imageS); + Group6F->PushButton4->setPixmap(imageS); + Group6F->PushButton5->setPixmap(imageS); + Group6F->PushButton6->setPixmap(imageS); + + // Add groups to layout + Layout1->addWidget(Group2F, 2, 0); + Layout1->addWidget(Group6F, 2, 0); + /***************************************************************/ + + Init(); +} + +//================================================================================= +// function : ~BlocksGUI_BlockDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +BlocksGUI_BlockDlg::~BlocksGUI_BlockDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void BlocksGUI_BlockDlg::Init() +{ + // init variables + Group2F->LineEdit1->setReadOnly(true); + Group2F->LineEdit2->setReadOnly(true); + + Group6F->LineEdit1->setReadOnly(true); + Group6F->LineEdit2->setReadOnly(true); + Group6F->LineEdit3->setReadOnly(true); + Group6F->LineEdit4->setReadOnly(true); + Group6F->LineEdit5->setReadOnly(true); + Group6F->LineEdit6->setReadOnly(true); + + // signals and slots connections + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + connect(GroupConstructors, SIGNAL(clicked(int)), this, SLOT(ConstructorsClicked(int))); + + connect(Group2F->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(Group2F->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + + connect(Group6F->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(Group6F->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(Group6F->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(Group6F->PushButton4, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(Group6F->PushButton5, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(Group6F->PushButton6, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ; + + // init controls and fields + initName(tr("GEOM_BLOCK")); + + myConstructorId = -1; + ConstructorsClicked(0); +} + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void BlocksGUI_BlockDlg::ConstructorsClicked (int constructorId) +{ + if (myConstructorId == constructorId) + return; + + myConstructorId = constructorId; + + switch (constructorId) { + case 0: + Group6F->hide(); + resize(0, 0); + Group2F->show(); + + myEditCurrentArgument = Group2F->LineEdit1; + Group2F->LineEdit1->setText(tr("")); + Group2F->LineEdit2->setText(tr("")); + break; + case 1: + Group2F->hide(); + resize(0, 0); + Group6F->show(); + + myEditCurrentArgument = Group6F->LineEdit1; + Group6F->LineEdit1->setText(tr("")); + Group6F->LineEdit2->setText(tr("")); + Group6F->LineEdit3->setText(tr("")); + Group6F->LineEdit4->setText(tr("")); + Group6F->LineEdit5->setText(tr("")); + Group6F->LineEdit6->setText(tr("")); + break; + default: + break; + } + + // init fields + myFace1 = myFace2 = GEOM::GEOM_Object::_nil(); + myFace3 = myFace4 = myFace5 = myFace6 = myFace1; + + globalSelection(GEOM_FACE); + SelectionIntoArgument(); +// connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void BlocksGUI_BlockDlg::ClickOnOk() +{ + if (ClickOnApply()) + ClickOnCancel(); +} + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +bool BlocksGUI_BlockDlg::ClickOnApply() +{ + if (!onAccept()) + return false; + + initName(); + return true; +} + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void BlocksGUI_BlockDlg::SelectionIntoArgument() +{ + erasePreview(); + myEditCurrentArgument->setText(""); + + if (mySelection->IObjectCount() != 1) + { + if (myEditCurrentArgument == Group2F->LineEdit1 || + myEditCurrentArgument == Group6F->LineEdit1) + myFace1 = GEOM::GEOM_Object::_nil(); + else if (myEditCurrentArgument == Group2F->LineEdit2 || + myEditCurrentArgument == Group6F->LineEdit2) + myFace2 = GEOM::GEOM_Object::_nil(); + else if (myEditCurrentArgument == Group6F->LineEdit3) + myFace3 = GEOM::GEOM_Object::_nil(); + else if (myEditCurrentArgument == Group6F->LineEdit4) + myFace4 = GEOM::GEOM_Object::_nil(); + else if (myEditCurrentArgument == Group6F->LineEdit5) + myFace5 = GEOM::GEOM_Object::_nil(); + else if (myEditCurrentArgument == Group6F->LineEdit6) + myFace6 = GEOM::GEOM_Object::_nil(); + return; + } + + // nbSel == 1 + Standard_Boolean testResult = Standard_False; + GEOM::GEOM_Object_var aSelectedObject = + GEOMBase::ConvertIOinGEOMObject( mySelection->firstIObject(), testResult ); + + if (!testResult || CORBA::is_nil( aSelectedObject )) + return; + + if (myEditCurrentArgument == Group2F->LineEdit1 || + myEditCurrentArgument == Group6F->LineEdit1) + myFace1 = aSelectedObject; + else if (myEditCurrentArgument == Group2F->LineEdit2 || + myEditCurrentArgument == Group6F->LineEdit2) + myFace2 = aSelectedObject; + else if (myEditCurrentArgument == Group6F->LineEdit3) + myFace3 = aSelectedObject; + else if (myEditCurrentArgument == Group6F->LineEdit4) + myFace4 = aSelectedObject; + else if (myEditCurrentArgument == Group6F->LineEdit5) + myFace5 = aSelectedObject; + else if (myEditCurrentArgument == Group6F->LineEdit6) + myFace6 = aSelectedObject; + + myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) ); + + displayPreview(); +} + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void BlocksGUI_BlockDlg::SetEditCurrentArgument() +{ + QPushButton* aSender = (QPushButton*)sender(); + + if (aSender == Group2F->PushButton1) { + myEditCurrentArgument = Group2F->LineEdit1; + } else if (aSender == Group2F->PushButton2) { + myEditCurrentArgument = Group2F->LineEdit2; + + } else if (aSender == Group6F->PushButton1) { + myEditCurrentArgument = Group6F->LineEdit1; + } else if (aSender == Group6F->PushButton2) { + myEditCurrentArgument = Group6F->LineEdit2; + } else if (aSender == Group6F->PushButton3) { + myEditCurrentArgument = Group6F->LineEdit3; + } else if (aSender == Group6F->PushButton4) { + myEditCurrentArgument = Group6F->LineEdit4; + } else if (aSender == Group6F->PushButton5) { + myEditCurrentArgument = Group6F->LineEdit5; + } else if (aSender == Group6F->PushButton6) { + myEditCurrentArgument = Group6F->LineEdit6; + } + + globalSelection(GEOM_FACE); + + myEditCurrentArgument->setFocus(); + SelectionIntoArgument(); +} + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void BlocksGUI_BlockDlg::ActivateThisDialog() +{ + GEOMBase_Skeleton::ActivateThisDialog(); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + + globalSelection(GEOM_FACE); + + SelectionIntoArgument(); +} + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void BlocksGUI_BlockDlg::enterEvent (QEvent* e) +{ + if (!GroupConstructors->isEnabled()) + ActivateThisDialog(); +} + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : public slot to deactivate if active +//================================================================================= +//void BlocksGUI_BlockDlg::DeactivateActiveDialog() +//{ +// GEOMBase_Skeleton::DeactivateActiveDialog(); +//} + +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr BlocksGUI_BlockDlg::createOperation() +{ + return getGeomEngine()->GetIBlocksOperations(getStudyId()); +} + +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool BlocksGUI_BlockDlg::isValid (QString&) +{ + switch (getConstructorId()) { + case 0: + return !(myFace1->_is_nil() || myFace2->_is_nil()); + case 1: + return !(myFace1->_is_nil() || myFace2->_is_nil() || + myFace3->_is_nil() || myFace4->_is_nil() || + myFace5->_is_nil() || myFace6->_is_nil()); + default: + return false; + } + return false; +} + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool BlocksGUI_BlockDlg::execute (ObjectList& objects) +{ + bool res = false; + + GEOM::GEOM_Object_var anObj; + + switch (getConstructorId()) { + case 0: + if (!CORBA::is_nil(myFace1) && !CORBA::is_nil(myFace2)) { + anObj = GEOM::GEOM_IBlocksOperations::_narrow(getOperation())-> + MakeHexa2Faces(myFace1, myFace2); + res = true; + } + break; + case 1: + if (!CORBA::is_nil(myFace1) && !CORBA::is_nil(myFace2) && + !CORBA::is_nil(myFace3) && !CORBA::is_nil(myFace4) && + !CORBA::is_nil(myFace5) && !CORBA::is_nil(myFace6)) { + anObj = GEOM::GEOM_IBlocksOperations::_narrow(getOperation())-> + MakeHexa(myFace1, myFace2, myFace3, myFace4, myFace5, myFace6); + res = true; + } + break; + } + + if (!anObj->_is_nil()) + objects.push_back(anObj._retn()); + + return res; +} diff --git a/src/BlocksGUI/BlocksGUI_BlockDlg.h b/src/BlocksGUI/BlocksGUI_BlockDlg.h new file mode 100644 index 000000000..91f98567b --- /dev/null +++ b/src/BlocksGUI/BlocksGUI_BlockDlg.h @@ -0,0 +1,80 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 CEA +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org or email : webmaster.salome@opencascade.org +// +// +// +// File : BlocksGUI_BlockDlg.h +// Author : Julia DOROVSKIKH +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_BLOCK_H +#define DIALOGBOX_BLOCK_H + +#include "GEOMBase_Skeleton.h" +#include "DlgRef_2Sel_QTD.h" +#include "DlgRef_6Sel_QTD.h" + + +//================================================================================= +// class : BlocksGUI_BlockDlg +// purpose : +//================================================================================= +class BlocksGUI_BlockDlg : public GEOMBase_Skeleton +{ + Q_OBJECT + +public: + BlocksGUI_BlockDlg (QWidget* parent, + SALOME_Selection* Sel, + bool modal = FALSE); + ~BlocksGUI_BlockDlg(); + +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid (QString&); + virtual bool execute (ObjectList& objects); + +private: + void Init(); + void enterEvent (QEvent* e); + +private: + int myConstructorId; + + GEOM::GEOM_Object_var myFace1, myFace2; + GEOM::GEOM_Object_var myFace3, myFace4, myFace5, myFace6; + + DlgRef_2Sel_QTD* Group2F; + DlgRef_6Sel_QTD* Group6F; + +private slots: + void ClickOnOk(); + bool ClickOnApply(); + void ActivateThisDialog(); +// void DeactivateActiveDialog(); + void ConstructorsClicked (int constructorId); + + void SelectionIntoArgument(); + void SetEditCurrentArgument(); +}; + +#endif // DIALOGBOX_BLOCK_H diff --git a/src/BlocksGUI/BlocksGUI_ExplodeDlg.cxx b/src/BlocksGUI/BlocksGUI_ExplodeDlg.cxx new file mode 100644 index 000000000..be34aa116 --- /dev/null +++ b/src/BlocksGUI/BlocksGUI_ExplodeDlg.cxx @@ -0,0 +1,485 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 CEA +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org or email : webmaster.salome@opencascade.org +// +// +// +// File : BlocksGUI_ExplodeDlg.cxx +// Author : Julia DOROVSKIKH +// Module : GEOM +// $Header$ + +#include "BlocksGUI_ExplodeDlg.h" + +#include "DlgRef_SpinBox.h" + +#include "GEOM_Displayer.h" + +#include "QAD_Desktop.h" +#include "SALOME_ListIteratorOfListIO.hxx" + +#include "utilities.h" + +#include + +#include +#include +#include + +//================================================================================= +// class : BlocksGUI_ExplodeDlg() +// purpose : Constructs a BlocksGUI_ExplodeDlg which is a child of 'parent'. +//================================================================================= +BlocksGUI_ExplodeDlg::BlocksGUI_ExplodeDlg (QWidget* parent, + SALOME_Selection* Sel, + bool modal) + : GEOMBase_Skeleton(parent, "ExplodeDlg", Sel, modal, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) +{ + QPixmap image1 (QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_BLOCK_EXPLODE"))); + QPixmap imageS (QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); + + setCaption(tr("GEOM_BLOCK_EXPLODE_TITLE")); + + /***************************************************************/ + GroupConstructors->setTitle(tr("GEOM_BLOCK_EXPLODE")); + + RadioButton1->setPixmap(image1); + RadioButton2->close(TRUE); + RadioButton3->close(TRUE); + + // Create first group + myGrp1 = new QGroupBox(1, Qt::Horizontal, tr("GEOM_ARGUMENTS"), this); + + QGroupBox* aSelGrp = new QGroupBox(3, Qt::Horizontal, myGrp1); + aSelGrp->setFrameStyle(QFrame::NoFrame); + aSelGrp->setInsideMargin(0); + + new QLabel(tr("GEOM_MAIN_OBJECT"), aSelGrp); + mySelBtn = new QPushButton(aSelGrp); + mySelBtn->setPixmap(imageS); + mySelName = new QLineEdit(aSelGrp); + mySelName->setReadOnly(true); + + QGroupBox* aSpinGrp = new QGroupBox(2, Qt::Horizontal, myGrp1); + aSpinGrp->setFrameStyle(QFrame::NoFrame); + aSpinGrp->setInsideMargin(0); + + new QLabel(tr("NB_FACES_MIN"), aSpinGrp); + mySpinBoxMin = new DlgRef_SpinBox(aSpinGrp); + + new QLabel(tr("NB_FACES_MAX"), aSpinGrp); + mySpinBoxMax = new DlgRef_SpinBox(aSpinGrp); + + QGroupBox* anInfoGrp = new QGroupBox(2, Qt::Horizontal, myGrp1); + anInfoGrp->setFrameStyle(QFrame::NoFrame); + anInfoGrp->setInsideMargin(0); + + myBlocksNb = new QTextEdit(anInfoGrp); + myBlocksNb->setReadOnly(true); + + QGroupBox* aCheckGrp = new QGroupBox(3, Qt::Horizontal, myGrp1); + aCheckGrp->setFrameStyle(QFrame::NoFrame); + aCheckGrp->setInsideMargin(0); + + myCheckBtn = new QCheckBox(aCheckGrp, "CheckButton1"); + myCheckBtn->setText(tr("GEOM_SUBSHAPE_SELECT")); + + // Add groups to layout + Layout1->addWidget(myGrp1, 1, 0); + /***************************************************************/ + + Init(); +} + +//================================================================================= +// function : ~BlocksGUI_ExplodeDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +BlocksGUI_ExplodeDlg::~BlocksGUI_ExplodeDlg() +{ + // no need to delete child widgets, Qt does it all for us + clearTemporary(); +} + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void BlocksGUI_ExplodeDlg::Init() +{ + // Set range of spinboxes + double SpecificStep = 1.0; + mySpinBoxMin->RangeStepAndValidator(0.0, 999.0, SpecificStep, 3); + mySpinBoxMax->RangeStepAndValidator(0.0, 999.0, SpecificStep, 3); + + if (QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_OCC) + myCheckBtn->setEnabled(false); + + // signals and slots connections + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + + connect(mySelBtn, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + + connect(mySpinBoxMin, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(mySpinBoxMax, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + + connect(myCheckBtn, SIGNAL(stateChanged(int)), this, SLOT(SubShapeToggled())); + + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + + myConstructorId = -1; + ConstructorsClicked(0); +} + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void BlocksGUI_ExplodeDlg::ConstructorsClicked (int constructorId) +{ + if (myConstructorId == constructorId) + return; + + myConstructorId = constructorId; + + switch (constructorId) { + case 0: + myGrp1->show(); + mySpinBoxMin->SetValue(6.0); + mySpinBoxMax->SetValue(6.0); + myCheckBtn->setChecked(FALSE); + break; + default: + break; + } + + // init fields + myEditCurrentArgument = mySelName; + myObject = GEOM::GEOM_Object::_nil(); + + activateSelection(); +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void BlocksGUI_ExplodeDlg::ClickOnOk() +{ + if (ClickOnApply()) + ClickOnCancel(); +} + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +bool BlocksGUI_ExplodeDlg::ClickOnApply() +{ + QAD_Application::getDesktop()->putInfo(tr("")); + + // Explode all sub shapes + if (isAllSubShapes()) { + // More than 30 subshapes : ask confirmation + if (myNbBlocks > 30) { + const QString caption = tr("GEOM_CONFIRM"); + const QString text = tr("GEOM_CONFIRM_INFO").arg(myNbBlocks); + const QString button0 = tr("GEOM_BUT_EXPLODE"); + const QString button1 = tr("GEOM_BUT_CANCEL"); + + if (QMessageBox::warning(this, caption, text, button0, button1) != 0) + return false; /* aborted */ + } + } + + if (!onAccept()) + return false; + + activateSelection(); + + return true; +} + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection has changed +//================================================================================= +void BlocksGUI_ExplodeDlg::SelectionIntoArgument() +{ + if (!isAllSubShapes()) + return; + + myObject = GEOM::GEOM_Object::_nil(); + mySelName->setText(""); + + if (mySelection->IObjectCount() == 1) { + Standard_Boolean aResult = Standard_False; + GEOM::GEOM_Object_var anObj = + GEOMBase::ConvertIOinGEOMObject(mySelection->firstIObject(), aResult); + + if ( aResult && !anObj->_is_nil() && GEOMBase::IsShape( anObj ) ) { + myObject = anObj; + mySelName->setText(GEOMBase::GetName(anObj)); + } + } + + updateButtonState(); +} + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void BlocksGUI_ExplodeDlg::SetEditCurrentArgument() +{ + QPushButton* aSender = (QPushButton*)sender(); + + if (mySelBtn == aSender) { + mySelName->setFocus(); + myEditCurrentArgument = mySelName; + myCheckBtn->setChecked(FALSE); + } + + activateSelection(); +} + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void BlocksGUI_ExplodeDlg::ActivateThisDialog() +{ + GEOMBase_Skeleton::ActivateThisDialog(); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + + activateSelection(); +} + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void BlocksGUI_ExplodeDlg::enterEvent (QEvent* e) +{ + if (!GroupConstructors->isEnabled()) + this->ActivateThisDialog(); +} + +//================================================================================= +// function : ValueChangedInSpinBox() +// purpose : +//================================================================================= +void BlocksGUI_ExplodeDlg::ValueChangedInSpinBox (double newValue) +{ + if (!isAllSubShapes()) + activateSelection(); + else + updateButtonState(); +} + +//================================================================================= +// function : SubShapeToggled() +// purpose : Allow user selection of all or only selected sub shapes +// : Called when 'myCheckBtn' state change +//================================================================================= +void BlocksGUI_ExplodeDlg::SubShapeToggled() +{ + activateSelection(); +} + +//================================================================================= +// function : activateSelection +// purpose : Redisplay preview and Activate selection +//================================================================================= +void BlocksGUI_ExplodeDlg::activateSelection() +{ + clearTemporary(); + erasePreview(true); + + if (isAllSubShapes()) { // Sub-shapes selection disabled + globalSelection( GEOM_ALLSHAPES ); + SelectionIntoArgument(); + + } else { + displayPreview(true, true, false); + globalSelection(GEOM_PREVIEW); + } +} + +//================================================================================= +// function : updateButtonState +// purpose : +//================================================================================= +void BlocksGUI_ExplodeDlg::updateButtonState() +{ + if (QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_OCC || + myObject->_is_nil()) { + myCheckBtn->setChecked(FALSE); + myCheckBtn->setEnabled(FALSE); + } else { + myCheckBtn->setEnabled(TRUE); + } + + myNbBlocks = 0; + + if (myObject->_is_nil()) { + myBlocksNb->setText(""); + } else { + bool isOnlyBlocks = GEOM::GEOM_IBlocksOperations::_narrow + (getOperation())->IsCompoundOfBlocks(myObject, + (int)mySpinBoxMin->GetValue(), + (int)mySpinBoxMax->GetValue(), + myNbBlocks); + if (isOnlyBlocks) + myBlocksNb->setText(tr("GEOM_NB_BLOCKS_NO_OTHERS").arg(myNbBlocks)); + else + myBlocksNb->setText(tr("GEOM_NB_BLOCKS_SOME_OTHERS").arg(myNbBlocks)); + } +} + +//================================================================================= +// function : isAllSubShapes +// purpose : +//================================================================================= +bool BlocksGUI_ExplodeDlg::isAllSubShapes() const +{ + return !myCheckBtn->isChecked() || !myCheckBtn->isEnabled(); +} + +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr BlocksGUI_ExplodeDlg::createOperation() +{ + return getGeomEngine()->GetIBlocksOperations(getStudyId()); +} + +//================================================================================= +// function : isValid() +// purpose : Verify validity of input data +//================================================================================= +bool BlocksGUI_ExplodeDlg::isValid (QString&) +{ + switch (getConstructorId()) { + case 0: + if (IsPreview()) + return !myObject->_is_nil(); + else + return !myObject->_is_nil() && (isAllSubShapes() || mySelection->IObjectCount()); + default: + return false; + } + + return false; +} + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool BlocksGUI_ExplodeDlg::execute (ObjectList& objects) +{ + GEOM::ListOfGO_var aList; + + switch (getConstructorId()) { + case 0: + aList = GEOM::GEOM_IBlocksOperations::_narrow(getOperation())->ExplodeCompoundOfBlocks + (myObject, + (int)mySpinBoxMin->GetValue(), + (int)mySpinBoxMax->GetValue()); + break; + } + + if (!aList->length()) + return false; + + if (IsPreview()) { + clearTemporary(); + + // Store objects. They will be put in study when "Apply" is pressed + for (int i = 0, n = aList->length(); i < n; i++) { + objects.push_back(GEOM::GEOM_Object::_duplicate(aList[i])); + myTmpObjs.push_back(GEOM::GEOM_Object::_duplicate(aList[i])); + } + + return objects.size() ? true : false; + } + + // Throw away sub-shapes not selected by user if not in preview mode + // and manual selection is active + if (!isAllSubShapes()) + { + QMap selected; + + // Get names of selected objects + SALOME_ListIteratorOfListIO it (mySelection->StoredIObjects()); + for (; it.More(); it.Next()) { + selected.insert(it.Value()->getName(), 0); + } + + // Iterate through result and select objects with names from selection + ObjectList toRemoveFromEnggine; + ObjectList::iterator anIter; + for (anIter = myTmpObjs.begin(); anIter != myTmpObjs.end(); ++anIter) { + if (selected.contains(GeometryGUI::GetORB()->object_to_string(*anIter))) + objects.push_back(*anIter); + else + toRemoveFromEnggine.push_back(*anIter); + } + + // Remove from engine useless objects + ObjectList::iterator anIter2 = toRemoveFromEnggine.begin(); + for (; anIter2 != toRemoveFromEnggine.end(); ++anIter2) + getGeomEngine()->RemoveObject(*anIter2); + + myTmpObjs.clear(); + + } else { + for (int i = 0, n = aList->length(); i < n; i++) + objects.push_back(GEOM::GEOM_Object::_duplicate(aList[i])); + } + + return objects.size(); +} + +//================================================================================= +// function : clearTemporary +// purpose : Remove temporary objects from engine +//================================================================================= +void BlocksGUI_ExplodeDlg::clearTemporary() +{ + ObjectList::iterator anIter; + for (anIter = myTmpObjs.begin(); anIter != myTmpObjs.end(); ++anIter) + getGeomEngine()->RemoveObject(*anIter); + + myTmpObjs.clear(); +} + +//================================================================ +// Function : getFather +// Purpose : Get father object for object to be added in study +// ( called with addInStudy method ) +//================================================================ +GEOM::GEOM_Object_ptr BlocksGUI_ExplodeDlg::getFather (GEOM::GEOM_Object_ptr) +{ + return myObject; +} diff --git a/src/BlocksGUI/BlocksGUI_ExplodeDlg.h b/src/BlocksGUI/BlocksGUI_ExplodeDlg.h new file mode 100644 index 000000000..73c44136c --- /dev/null +++ b/src/BlocksGUI/BlocksGUI_ExplodeDlg.h @@ -0,0 +1,104 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 CEA +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org or email : webmaster.salome@opencascade.org +// +// +// +// File : BlocksGUI_ExplodeDlg.h +// Author : Julia DOROVSKIKH +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_BLOCK_EXPLODE_H +#define DIALOGBOX_BLOCK_EXPLODE_H + +#include "GEOMBase_Skeleton.h" + +class DlgRef_SpinBox; +class QTextEdit; +class QCheckBox; + +//================================================================================= +// class : BlocksGUI_ExplodeDlg +// purpose : +//================================================================================= +class BlocksGUI_ExplodeDlg : public GEOMBase_Skeleton +{ + Q_OBJECT + +public: + BlocksGUI_ExplodeDlg (QWidget* parent, + SALOME_Selection* Sel, + bool modal = FALSE); + ~BlocksGUI_ExplodeDlg(); + +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid (QString& msg); + virtual bool execute (ObjectList& objects); + virtual GEOM::GEOM_Object_ptr getFather(GEOM::GEOM_Object_ptr theObj); + +private: + void Init(); + void enterEvent (QEvent* e); + + void activateSelection(); + + void updateButtonState(); + bool isAllSubShapes() const; + int shapeType() const; + + void clearTemporary(); + +private: + int myConstructorId; + + CORBA::Long myNbBlocks; + GEOM::GEOM_Object_var myObject; + + ObjectList myTmpObjs; + + QFrame* myGrp1; + + QPushButton* mySelBtn; + QLineEdit* mySelName; + + DlgRef_SpinBox* mySpinBoxMin; + DlgRef_SpinBox* mySpinBoxMax; + + QTextEdit* myBlocksNb; + + QCheckBox* myCheckBtn; + +private slots: + void ClickOnOk(); + bool ClickOnApply(); + void ActivateThisDialog(); + void ConstructorsClicked (int constructorId); + + void SelectionIntoArgument(); + void SetEditCurrentArgument(); + + void SubShapeToggled(); + + void ValueChangedInSpinBox (double newValue); +}; + +#endif // DIALOGBOX_BLOCK_EXPLODE_H diff --git a/src/BlocksGUI/BlocksGUI_QuadFaceDlg.cxx b/src/BlocksGUI/BlocksGUI_QuadFaceDlg.cxx new file mode 100644 index 000000000..c95296207 --- /dev/null +++ b/src/BlocksGUI/BlocksGUI_QuadFaceDlg.cxx @@ -0,0 +1,409 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 CEA +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org or email : webmaster.salome@opencascade.org +// +// +// +// File : BlocksGUI_QuadFaceDlg.cxx +// Author : Julia DOROVSKIKH +// Module : GEOM +// $Header$ + +#include "BlocksGUI_QuadFaceDlg.h" + +#include "QAD_Desktop.h" + +#include "GEOMImpl_Types.hxx" + +//using namespace std; + +//================================================================================= +// class : BlocksGUI_QuadFaceDlg() +// purpose : Constructs a BlocksGUI_QuadFaceDlg which is a child of 'parent'. +//================================================================================= +BlocksGUI_QuadFaceDlg::BlocksGUI_QuadFaceDlg (QWidget* parent, + SALOME_Selection* Sel, + bool modal) + : GEOMBase_Skeleton(parent, "QuadFaceDlg", Sel, modal, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) +{ + QPixmap image1 (QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_QUAD_FACE_4_VERT"))); + QPixmap image2 (QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_QUAD_FACE_2_EDGE"))); + QPixmap image3 (QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_QUAD_FACE_4_EDGE"))); + QPixmap imageS (QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); + + setCaption(tr("GEOM_QUAD_FACE_TITLE")); + + /***************************************************************/ + GroupConstructors->setTitle(tr("GEOM_QUAD_FACE")); + + RadioButton1->setPixmap(image1); + RadioButton2->setPixmap(image2); + RadioButton3->setPixmap(image3); + + // Create first group + myGrp1 = new QGroupBox(1, Qt::Horizontal, tr("GEOM_ARGUMENTS"), this); + + QGroupBox* aSelGrp1 = new QGroupBox(3, Qt::Horizontal, myGrp1); + aSelGrp1->setFrameStyle(QFrame::NoFrame); + aSelGrp1->setInsideMargin(0); + + createSelWg(tr("VERTEX_1"), imageS, aSelGrp1, Vertex1); + createSelWg(tr("VERTEX_2"), imageS, aSelGrp1, Vertex2); + createSelWg(tr("VERTEX_3"), imageS, aSelGrp1, Vertex3); + createSelWg(tr("VERTEX_4"), imageS, aSelGrp1, Vertex4); + + // Create second group + myGrp2 = new QGroupBox(1, Qt::Horizontal, tr("GEOM_ARGUMENTS"), this); + + QGroupBox* aSelGrp2 = new QGroupBox(3, Qt::Horizontal, myGrp2); + aSelGrp2->setFrameStyle(QFrame::NoFrame); + aSelGrp2->setInsideMargin(0); + + createSelWg(tr("EDGE_1"), imageS, aSelGrp2, Edge12); + createSelWg(tr("EDGE_2"), imageS, aSelGrp2, Edge22); + + // Create fird group + myGrp3 = new QGroupBox(1, Qt::Horizontal, tr("GEOM_ARGUMENTS"), this); + + QGroupBox* aSelGrp3 = new QGroupBox(3, Qt::Horizontal, myGrp3); + aSelGrp3->setFrameStyle(QFrame::NoFrame); + aSelGrp3->setInsideMargin(0); + + createSelWg(tr("EDGE_1"), imageS, aSelGrp3, Edge14); + createSelWg(tr("EDGE_2"), imageS, aSelGrp3, Edge24); + createSelWg(tr("EDGE_3"), imageS, aSelGrp3, Edge34); + createSelWg(tr("EDGE_4"), imageS, aSelGrp3, Edge44); + + (new QLabel(myGrp3))->setSizePolicy( + QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); + + // Add groups to layout + Layout1->addWidget(myGrp1, 2, 0); + Layout1->addWidget(myGrp2, 2, 0); + Layout1->addWidget(myGrp3, 2, 0); + /***************************************************************/ + + Init(); +} + +//================================================================================= +// function : ~BlocksGUI_QuadFaceDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +BlocksGUI_QuadFaceDlg::~BlocksGUI_QuadFaceDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void BlocksGUI_QuadFaceDlg::Init() +{ + // signals and slots connections + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + connect(GroupConstructors, SIGNAL(clicked(int)), this, SLOT(ConstructorsClicked(int))); + + QMap::iterator anIterBtn; + for (anIterBtn = mySelBtn.begin(); anIterBtn != mySelBtn.end(); ++anIterBtn) + connect(anIterBtn.data(), SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + + // init controls and fields + initName(tr("GEOM_QUAD_FACE")); + + myConstructorId = -1; + ConstructorsClicked(0); +} + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void BlocksGUI_QuadFaceDlg::ConstructorsClicked (int constructorId) +{ + if (myConstructorId == constructorId) + return; + + myConstructorId = constructorId; + + switch (constructorId) { + case 0: + myGrp2->hide(); + myGrp3->hide(); + myGrp1->show(); + myEditCurrentArgument = mySelName[Vertex1]; + break; + case 1: + myGrp1->hide(); + myGrp3->hide(); + myGrp2->show(); + myEditCurrentArgument = mySelName[Edge12]; + break; + case 2: + myGrp1->hide(); + myGrp2->hide(); + myGrp3->show(); + myEditCurrentArgument = mySelName[Edge14]; + break; + default: + break; + } + + // clear line edits + QMap::iterator anIterLE; + for (anIterLE = mySelName.begin(); anIterLE != mySelName.end(); ++anIterLE) + anIterLE.data()->setText(""); + + // init fields + myShape1 = myShape2 = GEOM::GEOM_Object::_nil(); + myShape3 = myShape4 = myShape1; + + activateSelection(); +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void BlocksGUI_QuadFaceDlg::ClickOnOk() +{ + if (ClickOnApply()) + ClickOnCancel(); +} + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +bool BlocksGUI_QuadFaceDlg::ClickOnApply() +{ + if (!onAccept()) + return false; + + initName(); + return true; +} + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection has changed +//================================================================================= +void BlocksGUI_QuadFaceDlg::SelectionIntoArgument() +{ + erasePreview(); + myEditCurrentArgument->setText(""); + + // Get index of current selection focus + int aCurrFocus = -1; + QMap::iterator anIter; + for (anIter = mySelName.begin(); anIter != mySelName.end(); ++anIter) { + if (myEditCurrentArgument == anIter.data()) { + aCurrFocus = anIter.key(); + break; + } + } + + GEOM::GEOM_Object_var anObj; + Standard_Boolean aResult = Standard_False; + if (mySelection->IObjectCount() == 1) { + anObj = GEOMBase::ConvertIOinGEOMObject(mySelection->firstIObject(), aResult); + if (aResult) { + if (anObj->_is_nil()) { + aResult = Standard_False; + } else { + mySelName[aCurrFocus]->setText(GEOMBase::GetName(anObj)); + } + } else { + anObj = GEOM::GEOM_Object::_nil(); + } + } + + if (aCurrFocus == Vertex1 || aCurrFocus == Edge12 || aCurrFocus == Edge14) { + myShape1 = anObj; + } else if (aCurrFocus == Vertex2 || aCurrFocus == Edge22 || aCurrFocus == Edge24) { + myShape2 = anObj; + } else if (aCurrFocus == Vertex3 || aCurrFocus == Edge34) { + myShape3 = anObj; + } else if (aCurrFocus == Vertex4 || aCurrFocus == Edge44) { + myShape4 = anObj; + } else { + return; + } + + displayPreview(); +} + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void BlocksGUI_QuadFaceDlg::SetEditCurrentArgument() +{ + QPushButton* aSender = (QPushButton*)sender(); + + QMap::iterator anIter; + for (anIter = mySelBtn.begin(); anIter != mySelBtn.end(); ++anIter) { + if (anIter.data() == aSender) { + mySelName[anIter.key()]->setFocus(); + myEditCurrentArgument = mySelName[anIter.key()]; + } + } + + activateSelection(); +} + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void BlocksGUI_QuadFaceDlg::ActivateThisDialog() +{ + GEOMBase_Skeleton::ActivateThisDialog(); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + + activateSelection(); + displayPreview(); +} + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void BlocksGUI_QuadFaceDlg::enterEvent (QEvent* e) +{ + if (!GroupConstructors->isEnabled()) + this->ActivateThisDialog(); +} + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +//void BlocksGUI_QuadFaceDlg::DeactivateActiveDialog() +//{ +// // disconnect selection +// GEOMBase_Skeleton::DeactivateActiveDialog(); +//} + +//================================================================================= +// function : createSelWg() +// purpose : +//================================================================================= +void BlocksGUI_QuadFaceDlg::createSelWg (const QString& theLbl, + QPixmap& thePix, + QWidget* theParent, + const int theId) +{ + new QLabel(theLbl, theParent); + mySelBtn[theId] = new QPushButton(theParent); + mySelBtn[theId]->setPixmap(thePix); + mySelName[theId] = new QLineEdit(theParent); + mySelName[theId]->setReadOnly(true); +} + +//================================================================================= +// function : activateSelection +// purpose : Activate selection in accordance with myEditCurrentArgument +//================================================================================= +void BlocksGUI_QuadFaceDlg::activateSelection() +{ + if (myEditCurrentArgument == mySelName[Vertex1] || + myEditCurrentArgument == mySelName[Vertex2] || + myEditCurrentArgument == mySelName[Vertex3] || + myEditCurrentArgument == mySelName[Vertex4]) { + + globalSelection(GEOM_POINT); + + } else { + globalSelection(GEOM_EDGE); + } + + SelectionIntoArgument(); +} + +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr BlocksGUI_QuadFaceDlg::createOperation() +{ + return getGeomEngine()->GetIBlocksOperations(getStudyId()); +} + +//================================================================================= +// function : isValid +// purpose : Verify validity of input data +//================================================================================= +bool BlocksGUI_QuadFaceDlg::isValid (QString&) +{ + switch (getConstructorId()) { + case 0: + return (!myShape1->_is_nil() && !myShape2->_is_nil() && + !myShape3->_is_nil() && !myShape4->_is_nil()); + case 1: + return (!myShape1->_is_nil() && !myShape2->_is_nil()); + case 2: + return (!myShape1->_is_nil() && !myShape2->_is_nil() && + !myShape3->_is_nil() && !myShape4->_is_nil()); + default: + return false; + } + return false; +} + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool BlocksGUI_QuadFaceDlg::execute (ObjectList& objects) +{ + bool res = false; + + GEOM::GEOM_Object_var anObj; + + switch (getConstructorId()) { + case 0: + anObj = GEOM::GEOM_IBlocksOperations::_narrow(getOperation())->MakeQuad4Vertices + (myShape1, myShape2, myShape3, myShape4); + res = true; + break; + case 1: + anObj = GEOM::GEOM_IBlocksOperations::_narrow(getOperation())->MakeQuad2Edges + (myShape1, myShape2); + res = true; + break; + case 2: + anObj = GEOM::GEOM_IBlocksOperations::_narrow(getOperation())->MakeQuad + (myShape1, myShape2, myShape3, myShape4); + res = true; + break; + default: + break; + } + + if (!anObj->_is_nil()) + objects.push_back(anObj._retn()); + + return res; +} diff --git a/src/BlocksGUI/BlocksGUI_QuadFaceDlg.h b/src/BlocksGUI/BlocksGUI_QuadFaceDlg.h new file mode 100644 index 000000000..bd7150e4c --- /dev/null +++ b/src/BlocksGUI/BlocksGUI_QuadFaceDlg.h @@ -0,0 +1,90 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 CEA +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org or email : webmaster.salome@opencascade.org +// +// +// +// File : BlocksGUI_QuadFaceDlg.h +// Author : Julia DOROVSKIKH +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_QUAD_FACE_H +#define DIALOGBOX_QUAD_FACE_H + +#include "GEOMBase_Skeleton.h" + +//================================================================================= +// class : BlocksGUI_QuadFaceDlg +// purpose : +//================================================================================= +class BlocksGUI_QuadFaceDlg : public GEOMBase_Skeleton +{ + Q_OBJECT + + enum { Vertex1, Vertex2, Vertex3, Vertex4, + Edge12, Edge22, + Edge14, Edge24, Edge34, Edge44 }; + +public: + BlocksGUI_QuadFaceDlg (QWidget* parent, + SALOME_Selection* Sel, + bool modal = FALSE); + ~BlocksGUI_QuadFaceDlg(); + +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid (QString& msg); + virtual bool execute (ObjectList& objects); + +private: + void Init(); + void enterEvent (QEvent* e); + + void createSelWg (const QString&, QPixmap&, QWidget*, const int); + void activateSelection(); + +private: + int myConstructorId; + + GEOM::GEOM_Object_var myShape1; + GEOM::GEOM_Object_var myShape2; + GEOM::GEOM_Object_var myShape3; + GEOM::GEOM_Object_var myShape4; + + QFrame* myGrp1; + QFrame* myGrp2; + QFrame* myGrp3; + + QMap mySelBtn; + QMap mySelName; + +private slots: + void ClickOnOk(); + bool ClickOnApply(); + void ActivateThisDialog(); +// void DeactivateActiveDialog(); + void ConstructorsClicked( int constructorId ); + + void SelectionIntoArgument(); + void SetEditCurrentArgument(); +}; + +#endif // DIALOGBOX_QUAD_FACE_H diff --git a/src/BlocksGUI/BlocksGUI_TrsfDlg.cxx b/src/BlocksGUI/BlocksGUI_TrsfDlg.cxx new file mode 100644 index 000000000..959df91a6 --- /dev/null +++ b/src/BlocksGUI/BlocksGUI_TrsfDlg.cxx @@ -0,0 +1,513 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 CEA +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org or email : webmaster.salome@opencascade.org +// +// +// +// File : BlocksGUI_TrsfDlg.cxx +// Author : Julia DOROVSKIKH +// Module : GEOM +// $Header$ + +#include "BlocksGUI_TrsfDlg.h" + +#include "DlgRef_SpinBox.h" + +#include "QAD_Desktop.h" + +#include + +//================================================================================= +// class : BlocksGUI_TrsfDlg() +// purpose : Constructs a BlocksGUI_TrsfDlg which is a child of 'parent'. +//================================================================================= +BlocksGUI_TrsfDlg::BlocksGUI_TrsfDlg (QWidget* parent, + SALOME_Selection* Sel, + bool modal) + : GEOMBase_Skeleton(parent, "TrsfDlg", Sel, modal, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) +{ + QPixmap image1 (QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_BLOCK_MULTITRSF_SIMPLE"))); + QPixmap image2 (QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_BLOCK_MULTITRSF_DOUBLE"))); + QPixmap imageS (QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); + + setCaption(tr("GEOM_BLOCK_MULTITRSF_TITLE")); + + /***************************************************************/ + GroupConstructors->setTitle(tr("GEOM_BLOCK_MULTITRSF")); + + RadioButton1->setPixmap(image1); + RadioButton2->setPixmap(image2); + RadioButton3->close(TRUE); + + // Create first group + myGrp1 = new QGroupBox(1, Qt::Horizontal, tr("GEOM_BLOCK_MULTITRSF_SIMPLE"), this); + + QGroupBox* aSelGrp1 = new QGroupBox(3, Qt::Horizontal, myGrp1); + aSelGrp1->setFrameStyle(QFrame::NoFrame); + aSelGrp1->setInsideMargin(0); + + createSelWg(tr("GEOM_MAIN_OBJECT"), imageS, aSelGrp1, MainObj1); + createSelWg(tr("FACE_1"), imageS, aSelGrp1, Face1); + createSelWg(tr("FACE_2"), imageS, aSelGrp1, Face2); + + QGroupBox* aSpinGrp1 = new QGroupBox(1, Qt::Vertical, myGrp1); + aSpinGrp1->setFrameStyle(QFrame::NoFrame); + aSpinGrp1->setInsideMargin(0); + + new QLabel(tr("GEOM_NB_TIMES"), aSpinGrp1); + mySpinBox[SpinBox1] = new DlgRef_SpinBox(aSpinGrp1); + + // Create second group + myGrp2 = new QGroupBox(1, Qt::Horizontal, tr("GEOM_BLOCK_MULTITRSF_DOUBLE"), this); + + // U trsf + QGroupBox* aSelGrp2U = new QGroupBox(3, Qt::Horizontal, myGrp2); + aSelGrp2U->setFrameStyle(QFrame::NoFrame); + aSelGrp2U->setInsideMargin(0); + + createSelWg(tr("GEOM_MAIN_OBJECT"), imageS, aSelGrp2U, MainObj2); + createSelWg(tr("FACE_1U"), imageS, aSelGrp2U, Face1U); + createSelWg(tr("FACE_2U"), imageS, aSelGrp2U, Face2U); + + QGroupBox* aSpinGrp2U = new QGroupBox(1, Qt::Vertical, myGrp2); + aSpinGrp2U->setFrameStyle(QFrame::NoFrame); + aSpinGrp2U->setInsideMargin(0); + + new QLabel(tr("GEOM_NB_TIMES_U"), aSpinGrp2U); + mySpinBox[SpinBox2U] = new DlgRef_SpinBox(aSpinGrp2U); + + // V trsf + QGroupBox* aSelGrp2V = new QGroupBox(3, Qt::Horizontal, myGrp2); + aSelGrp2V->setFrameStyle(QFrame::NoFrame); + aSelGrp2V->setInsideMargin(0); + + createSelWg(tr("FACE_1V"), imageS, aSelGrp2V, Face1V); + createSelWg(tr("FACE_2V"), imageS, aSelGrp2V, Face2V); + + QGroupBox* aSpinGrp2V = new QGroupBox(1, Qt::Vertical, myGrp2); + aSpinGrp2V->setFrameStyle(QFrame::NoFrame); + aSpinGrp2V->setInsideMargin(0); + + new QLabel(tr("GEOM_NB_TIMES_V"), aSpinGrp2V); + mySpinBox[SpinBox2V] = new DlgRef_SpinBox(aSpinGrp2V); + + (new QLabel(myGrp2))->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); + + // Add groups to layout + Layout1->addWidget( myGrp1, 2, 0 ); + Layout1->addWidget( myGrp2, 2, 0 ); + /***************************************************************/ + + Init(); +} + +//================================================================================= +// function : ~BlocksGUI_TrsfDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +BlocksGUI_TrsfDlg::~BlocksGUI_TrsfDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void BlocksGUI_TrsfDlg::Init() +{ + // Set range of spinboxes + double SpecificStep = 1.0; + QMap::iterator anIter; + for (anIter = mySpinBox.begin(); anIter != mySpinBox.end(); ++anIter) { + anIter.data()->RangeStepAndValidator(1.0, 999.999, SpecificStep, 3); + } + + // signals and slots connections + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + connect(GroupConstructors, SIGNAL(clicked(int)), this, SLOT(ConstructorsClicked(int))); + + QMap::iterator anIterBtn; + for (anIterBtn = mySelBtn.begin(); anIterBtn != mySelBtn.end(); ++anIterBtn) + connect(anIterBtn.data(), SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + + QMap::iterator anIterSpin; + for (anIterSpin = mySpinBox.begin(); anIterSpin != mySpinBox.end(); ++anIterSpin) + connect(anIterSpin.data(), SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + + // init controls and fields + initName(tr("GEOM_BLOCK_MULTITRSF")); + + myConstructorId = -1; + ConstructorsClicked(0); +} + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void BlocksGUI_TrsfDlg::ConstructorsClicked (int constructorId) +{ + if (myConstructorId == constructorId) + return; + + myConstructorId = constructorId; + + switch (constructorId) { + case 0: + myGrp2->hide(); + myGrp1->show(); + mySpinBox[SpinBox1]->SetValue(2.0); + myEditCurrentArgument = mySelName[MainObj1]; + myFaces[Face1] = -1; + myFaces[Face2] = -1; + break; + case 1: + myGrp1->hide(); + myGrp2->show(); + mySpinBox[SpinBox2U]->SetValue(2.0); + mySpinBox[SpinBox2V]->SetValue(2.0); + myEditCurrentArgument = mySelName[MainObj2]; + myFaces[Face1U] = -1; + myFaces[Face2U] = -1; + myFaces[Face1V] = -1; + myFaces[Face2V] = -1; + break; + default: + break; + } + + // clear line edits + QMap::iterator anIterLE; + for (anIterLE = mySelName.begin(); anIterLE != mySelName.end(); ++anIterLE) + anIterLE.data()->setText(""); + + // init fields + myShape = GEOM::GEOM_Object::_nil(); + + activateSelection(); +// enableWidgets(); +// displayPreview(); +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void BlocksGUI_TrsfDlg::ClickOnOk() +{ + if (ClickOnApply()) + ClickOnCancel(); +} + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +bool BlocksGUI_TrsfDlg::ClickOnApply() +{ + if (!onAccept()) + return false; + + initName(); + return true; +} + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection has changed +//================================================================================= +void BlocksGUI_TrsfDlg::SelectionIntoArgument() +{ + erasePreview(); + myEditCurrentArgument->setText(""); + + // Get index of current selection focus + int aCurrFocus = -1; + QMap::iterator anIter; + for (anIter = mySelName.begin(); anIter != mySelName.end(); ++anIter) { + if (myEditCurrentArgument == anIter.data()) { + aCurrFocus = anIter.key(); + break; + } + } + + // If selection of main object is activated + if (aCurrFocus == MainObj1 || aCurrFocus == MainObj2) { + if (mySelection->IObjectCount() == 1) { + Standard_Boolean aResult = Standard_False; + GEOM::GEOM_Object_var anObj = + GEOMBase::ConvertIOinGEOMObject(mySelection->firstIObject(), aResult); + + if (aResult && !anObj->_is_nil() && GEOMBase::IsShape( anObj ) ) { + myShape = anObj; + mySelName[aCurrFocus]->setText(GEOMBase::GetName(anObj)); + enableWidgets(); + return; + } + } + + myShape = GEOM::GEOM_Object::_nil(); + enableWidgets(); + } + // If face selection is activated + else if (aCurrFocus == Face1 || aCurrFocus == Face2 || + aCurrFocus == Face1U || aCurrFocus == Face2U || + aCurrFocus == Face1V || aCurrFocus == Face2V) { + if (mySelection->IObjectCount() == 1) { + Standard_Boolean aResult = Standard_False; + GEOM::GEOM_Object_var anObj = + GEOMBase::ConvertIOinGEOMObject(mySelection->firstIObject(), aResult); + + if ( aResult && !anObj->_is_nil() && GEOMBase::IsShape( anObj ) ) { + TColStd_IndexedMapOfInteger anIndexes; + mySelection->GetIndex(mySelection->firstIObject(), anIndexes); + + if (anIndexes.Extent() == 1) { + int anIndex = anIndexes(1); + QString aFaceName = QString(GEOMBase::GetName(anObj)) + ":%1"; + myEditCurrentArgument->setText(aFaceName.arg(anIndex)); + myFaces[aCurrFocus] = anIndex; + displayPreview(); + return; + } + } + } + + myFaces[aCurrFocus] = -1; + } +} + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void BlocksGUI_TrsfDlg::SetEditCurrentArgument() +{ + QPushButton* aSender = (QPushButton*)sender(); + + QMap::iterator anIter; + for (anIter = mySelBtn.begin(); anIter != mySelBtn.end(); ++anIter) { + if (anIter.data() == aSender) { + mySelName[anIter.key()]->setFocus(); + myEditCurrentArgument = mySelName[anIter.key()]; + break; + } + } + + activateSelection(); +} + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void BlocksGUI_TrsfDlg::ActivateThisDialog() +{ + GEOMBase_Skeleton::ActivateThisDialog(); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + + activateSelection(); + displayPreview(); +} + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void BlocksGUI_TrsfDlg::enterEvent (QEvent* e) +{ + if (!GroupConstructors->isEnabled()) + this->ActivateThisDialog(); +} + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +//void BlocksGUI_TrsfDlg::DeactivateActiveDialog() +//{ +// // disconnect selection +// GEOMBase_Skeleton::DeactivateActiveDialog(); +//} + +//================================================================================= +// function : ValueChangedInSpinBox() +// purpose : +//================================================================================= +void BlocksGUI_TrsfDlg::ValueChangedInSpinBox (double newValue) +{ + displayPreview(); +} + +//================================================================================= +// function : createSelWg() +// purpose : +//================================================================================= +void BlocksGUI_TrsfDlg::createSelWg (const QString& theLbl, + QPixmap& thePix, + QWidget* theParent, + const int theId) +{ + new QLabel(theLbl, theParent); + mySelBtn[theId] = new QPushButton(theParent); + mySelBtn[theId]->setPixmap(thePix); + mySelName[theId] = new QLineEdit(theParent); + mySelName[theId]->setReadOnly(true); +} + +//================================================================================= +// function : activateSelection +// purpose : Activate selection in accordance with myEditCurrentArgument +//================================================================================= +void BlocksGUI_TrsfDlg::activateSelection() +{ + if (!myShape->_is_nil() && + (myEditCurrentArgument == mySelName[ Face1 ] || + myEditCurrentArgument == mySelName[ Face2 ] || + myEditCurrentArgument == mySelName[ Face1U ] || + myEditCurrentArgument == mySelName[ Face2U ] || + myEditCurrentArgument == mySelName[ Face1V ] || + myEditCurrentArgument == mySelName[ Face2V ])) { + + // Local selection is available only in the OCC Viewer + if ( QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { + localSelection(myShape, TopAbs_FACE); + } else { + return; + } + } else { + globalSelection( GEOM_ALLSHAPES ); + } + + SelectionIntoArgument(); +} + +//================================================================================= +// function : enableWidgets +// purpose : Enable widgets of faces in accordance with value of main object +//================================================================================= +void BlocksGUI_TrsfDlg::enableWidgets() +{ + int anId = getConstructorId(); + + bool toEnable = !myShape->_is_nil(); + + if (anId == 0) { + mySelName[Face1]->setEnabled(toEnable); + mySelName[Face2]->setEnabled(toEnable); + mySelBtn[Face1]->setEnabled(toEnable); + mySelBtn[Face2]->setEnabled(toEnable); + + if (!toEnable) { + mySelName[Face1]->setText(""); + mySelName[Face2]->setText(""); + myFaces[Face1] = -1; + myFaces[Face2] = -1; + } + } else if (anId == 1) { + mySelName[Face1U]->setEnabled(toEnable); + mySelName[Face2U]->setEnabled(toEnable); + mySelName[Face1V]->setEnabled(toEnable); + mySelName[Face2V]->setEnabled(toEnable); + mySelBtn[Face1U]->setEnabled(toEnable); + mySelBtn[Face2U]->setEnabled(toEnable); + mySelBtn[Face1V]->setEnabled(toEnable); + mySelBtn[Face2V]->setEnabled(toEnable); + + if (!toEnable) { + mySelName[Face1U]->setText(""); + mySelName[Face2U]->setText(""); + mySelName[Face1V]->setText(""); + mySelName[Face2V]->setText(""); + myFaces[Face1U] = -1; + myFaces[Face2U] = -1; + myFaces[Face1V] = -1; + myFaces[Face2V] = -1; + } + } +} + +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr BlocksGUI_TrsfDlg::createOperation() +{ + return getGeomEngine()->GetIBlocksOperations(getStudyId()); +} + +//================================================================================= +// function : ClickOnApply() +// purpose : Verify validity of input data +//================================================================================= +bool BlocksGUI_TrsfDlg::isValid (QString&) +{ + switch (getConstructorId()) { + case 0: + return !myShape->_is_nil() && myFaces[Face1] > 0; + case 1: + return !myShape->_is_nil() && myFaces[Face1U] > 0 && myFaces[Face1V] > 0; + default: + return false; + } + return false; +} + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool BlocksGUI_TrsfDlg::execute (ObjectList& objects) +{ + bool res = false; + + GEOM::GEOM_Object_var anObj; + + switch (getConstructorId()) { + case 0: + anObj = GEOM::GEOM_IBlocksOperations::_narrow(getOperation())->MakeMultiTransformation1D + (myShape, + myFaces[Face1], + myFaces[Face2], + (int)mySpinBox[SpinBox1]->GetValue()); + res = true; + break; + case 1: + anObj = GEOM::GEOM_IBlocksOperations::_narrow(getOperation())->MakeMultiTransformation2D + (myShape, + myFaces[Face1U], + myFaces[Face2U], + (int)mySpinBox[SpinBox2U]->GetValue(), + myFaces[Face1V], + myFaces[Face2V], + (int)mySpinBox[SpinBox2V]->GetValue()); + res = true; + break; + } + + if (!anObj->_is_nil()) + objects.push_back(anObj._retn()); + + return res; +} diff --git a/src/BlocksGUI/BlocksGUI_TrsfDlg.h b/src/BlocksGUI/BlocksGUI_TrsfDlg.h new file mode 100644 index 000000000..1b3b782ff --- /dev/null +++ b/src/BlocksGUI/BlocksGUI_TrsfDlg.h @@ -0,0 +1,92 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 CEA +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org or email : webmaster.salome@opencascade.org +// +// +// +// File : BlocksGUI_TrsfDlg.h +// Author : Julia DOROVSKIKH +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_BLOCK_MULTITRSF_H +#define DIALOGBOX_BLOCK_MULTITRSF_H + +#include "GEOMBase_Skeleton.h" + +class DlgRef_SpinBox; + +//================================================================================= +// class : BlocksGUI_TrsfDlg +// purpose : +//================================================================================= +class BlocksGUI_TrsfDlg : public GEOMBase_Skeleton +{ + Q_OBJECT + + enum { MainObj1, Face1, Face2, MainObj2, Face1U, Face2U, Face1V, Face2V }; + enum { SpinBox1, SpinBox2U, SpinBox2V }; + +public: + BlocksGUI_TrsfDlg (QWidget* parent, + SALOME_Selection* Sel, + bool modal = FALSE); + ~BlocksGUI_TrsfDlg(); + +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid (QString& msg); + virtual bool execute (ObjectList& objects); + +private: + void Init(); + void enterEvent (QEvent* e); + + void createSelWg (const QString&, QPixmap&, QWidget*, const int); + void activateSelection(); + void enableWidgets(); + +private: + int myConstructorId; + + GEOM::GEOM_Object_var myShape; + QMap myFaces; + + QFrame* myGrp1; + QFrame* myGrp2; + + QMap mySelBtn; + QMap mySelName; + QMap mySpinBox; + +private slots: + void ClickOnOk(); + bool ClickOnApply(); + void ActivateThisDialog(); +// void DeactivateActiveDialog(); + void ConstructorsClicked (int constructorId); + + void SelectionIntoArgument(); + void SetEditCurrentArgument(); + + void ValueChangedInSpinBox (double newValue); +}; + +#endif // DIALOGBOX_BLOCK_MULTITRSF_H diff --git a/src/BlocksGUI/Makefile.in b/src/BlocksGUI/Makefile.in new file mode 100644 index 000000000..e36dd5fe8 --- /dev/null +++ b/src/BlocksGUI/Makefile.in @@ -0,0 +1,66 @@ +# GEOM BUILDGUI : +# +# Copyright (C) 2003 CEA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org or email : webmaster.salome@opencascade.org +# +# +# +# File : Makefile.in +# Author : Julia DOROVSKIKH (OCC) +# Module : GEOM +# $Header$ + +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + + +@COMMENCE@ + +# header files +EXPORT_HEADERS= + +# Libraries targets +LIB = libBlocksGUI.la + +LIB_SRC = \ + BlocksGUI.cxx \ + BlocksGUI_QuadFaceDlg.cxx \ + BlocksGUI_BlockDlg.cxx \ + BlocksGUI_ExplodeDlg.cxx \ + BlocksGUI_TrsfDlg.cxx + +LIB_MOC = \ + BlocksGUI_QuadFaceDlg.h \ + BlocksGUI_BlockDlg.h \ + BlocksGUI_ExplodeDlg.h \ + BlocksGUI_TrsfDlg.h + +LIB_CLIENT_IDL = SALOME_GenericObj.idl SALOME_Component.idl + +LIB_SERVER_IDL = + +# additionnal information to compil and link file + +CPPFLAGS += $(QT_INCLUDES) $(VTK_INCLUDES) $(OCC_INCLUDES) $(PYTHON_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome +CXXFLAGS += -I${KERNEL_ROOT_DIR}/include/salome + +LDFLAGS += -lGEOMFiltersSelection -lGEOMBase + +@CONCLUDE@ diff --git a/src/BooleanGUI/BooleanGUI.cxx b/src/BooleanGUI/BooleanGUI.cxx index da6531ff2..0e6c813d6 100644 --- a/src/BooleanGUI/BooleanGUI.cxx +++ b/src/BooleanGUI/BooleanGUI.cxx @@ -24,28 +24,36 @@ // File : BooleanGUI.cxx // Author : Damien COQUERET // Module : GEOM -// $Header: +// $Header$ using namespace std; #include "BooleanGUI.h" +#include "QAD_Desktop.h" #include "SALOMEGUI_QtCatchCorbaException.hxx" +#include "BooleanGUI_Dialog.h" -#include "BooleanGUI_FuseDlg.h" // Method FUSE -#include "BooleanGUI_CommonDlg.h" // Method COMMON -#include "BooleanGUI_CutDlg.h" // Method CUT -#include "BooleanGUI_SectionDlg.h" // Method SECTION +BooleanGUI* BooleanGUI::myGUIObject = 0; + +//======================================================================= +// function : GetBooleanGUI() +// purpose : Get the only BooleanGUI object [ static ] +//======================================================================= +BooleanGUI* BooleanGUI::GetBooleanGUI() +{ + if ( myGUIObject == 0 ) { + // init BooleanGUI only once + myGUIObject = new BooleanGUI(); + } + return myGUIObject; +} //======================================================================= // function : BooleanGUI() // purpose : Constructor //======================================================================= -BooleanGUI::BooleanGUI() : - QObject() +BooleanGUI::BooleanGUI() : GEOMGUI() { - myGeomBase = new GEOMBase(); - myGeomGUI = GEOMContext::GetGeomGUI(); - myGeom = myGeomGUI->myComponentGeom; } @@ -64,75 +72,34 @@ BooleanGUI::~BooleanGUI() //======================================================================= bool BooleanGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) { - BooleanGUI* myBooleanGUI = new BooleanGUI(); - myBooleanGUI->myGeomGUI->EmitSignalDeactivateDialog(); + GeometryGUI::GetGeomGUI()->EmitSignalDeactivateDialog(); SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection()); - switch (theCommandID) - { - case 5011: // FUSE - { - BooleanGUI_FuseDlg *aDlg = new BooleanGUI_FuseDlg(parent, "", myBooleanGUI, Sel); - break; - } - case 5012: // COMMON - { - BooleanGUI_CommonDlg *aDlg = new BooleanGUI_CommonDlg(parent, "", myBooleanGUI, Sel); - break; - } - case 5013: // CUT - { - BooleanGUI_CutDlg *aDlg = new BooleanGUI_CutDlg(parent, "", myBooleanGUI, Sel); - break; - } - case 5014: // SECTION - { - BooleanGUI_SectionDlg *aDlg = new BooleanGUI_SectionDlg(parent, "", myBooleanGUI, Sel); - break; - } - default: - { - parent->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); - break; - } - } - return true; -} - - -//======================================================================= -// function : MakeBooleanAndDisplay() -// purpose : -//======================================================================= -void BooleanGUI::MakeBooleanAndDisplay(GEOM::GEOM_Shape_ptr Shape1, GEOM::GEOM_Shape_ptr Shape2, const short operation) -{ - try { - GEOM::GEOM_Shape_ptr result = myGeom->MakeBoolean(Shape1, Shape2, operation); - if(result->_is_nil()) { - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_NULLSHAPE")); - return; - } - - TopoDS_Shape S = myGeomGUI->GetShapeReader().GetShape(myGeom, result); - Standard_CString type; - myGeomBase->GetShapeTypeString(S,type); - result->NameType(type); + int anOperation = 0; + if ( theCommandID == 5011 ) + anOperation = FUSE; + else if ( theCommandID == 5012 ) + anOperation = COMMON; + else if ( theCommandID == 5013 ) + anOperation = CUT; + else if ( theCommandID == 5014 ) + anOperation = SECTION; + else + return false; - if (myGeomBase->Display(result)) - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return; + QDialog* aDlg = new BooleanGUI_Dialog( anOperation, parent, "", Sel); + aDlg->show(); + + return true; } - //===================================================================================== // EXPORTED METHODS //===================================================================================== extern "C" { - bool OnGUIEvent(int theCommandID, QAD_Desktop* parent) - {return BooleanGUI::OnGUIEvent(theCommandID, parent);} + GEOMGUI* GetLibGUI() + { + return BooleanGUI::GetBooleanGUI(); + } } diff --git a/src/BooleanGUI/BooleanGUI.h b/src/BooleanGUI/BooleanGUI.h index 6fb9cde55..d7773d16a 100644 --- a/src/BooleanGUI/BooleanGUI.h +++ b/src/BooleanGUI/BooleanGUI.h @@ -24,35 +24,34 @@ // File : BooleanGUI.h // Author : Damien COQUERET // Module : GEOM -// $Header: +// $Header$ #ifndef BOOLEANGUI_H #define BOOLEANGUI_H -#include "GEOMBase.h" +#include "GEOMGUI.h" //================================================================================= // class : BooleanGUI // purpose : //================================================================================= -class BooleanGUI : public QObject +class BooleanGUI : public GEOMGUI { - Q_OBJECT /* for QT compatibility */ +protected: + BooleanGUI(); // hide constructor to avoid direct creation -public : - BooleanGUI(); - ~BooleanGUI(); +public: + enum BooleanOperation { COMMON = 1, CUT = 2, FUSE = 3, SECTION = 4 }; - static bool OnGUIEvent(int theCommandID, QAD_Desktop* parent); + ~BooleanGUI(); - void MakeBooleanAndDisplay(GEOM::GEOM_Shape_ptr Shape1, - GEOM::GEOM_Shape_ptr Shape2, - const short operation); + // Get the only BooleanGUI object + static BooleanGUI* GetBooleanGUI(); - GEOMBase* myGeomBase; - GEOMContext* myGeomGUI; - GEOM::GEOM_Gen_var myGeom; /* Current Geom Component */ + bool OnGUIEvent(int theCommandID, QAD_Desktop* parent); +private: + static BooleanGUI* myGUIObject; // the only BooleanGUI object }; #endif diff --git a/src/BooleanGUI/BooleanGUI_CommonDlg.cxx b/src/BooleanGUI/BooleanGUI_CommonDlg.cxx deleted file mode 100644 index db7b47d14..000000000 --- a/src/BooleanGUI/BooleanGUI_CommonDlg.cxx +++ /dev/null @@ -1,245 +0,0 @@ -// 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 : BooleanGUI_CommonDlg.cxx -// Author : Lucien PIGNOLONI -// Module : GEOM -// $Header$ - -using namespace std; -#include "BooleanGUI_CommonDlg.h" - -//================================================================================= -// class : BooleanGUI_CommonDlg() -// purpose : Constructs a BooleanGUI_CommonDlg 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. -//================================================================================= -BooleanGUI_CommonDlg::BooleanGUI_CommonDlg(QWidget* parent, const char* name, BooleanGUI* theBooleanGUI, 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_COMMON"))); - QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); - - setCaption(tr("GEOM_COMMON_TITLE")); - - /***************************************************************/ - GroupConstructors->setTitle(tr("GEOM_COMMON")); - RadioButton1->setPixmap(image0); - RadioButton2->close(TRUE); - RadioButton3->close(TRUE); - - GroupCommon = new DlgRef_2Sel_QTD(this, "GroupCommon"); - GroupCommon->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); - GroupCommon->TextLabel1->setText(tr("GEOM_OBJECT_I").arg("1")); - GroupCommon->TextLabel2->setText(tr("GEOM_OBJECT_I").arg("2")); - GroupCommon->PushButton1->setPixmap(image1); - GroupCommon->PushButton2->setPixmap(image1); - - Layout1->addWidget(GroupCommon, 1, 0); - /***************************************************************/ - - /* Initialisation */ - myBooleanGUI = theBooleanGUI; - Init(); -} - - -//================================================================================= -// function : ~BooleanGUI_CommonDlg() -// purpose : Destroys the object and frees any allocated resources -//================================================================================= -BooleanGUI_CommonDlg::~BooleanGUI_CommonDlg() -{ - /* no need to delete child widgets, Qt does it all for us */ -} - - - -//================================================================================= -// function : Init() -// purpose : -//================================================================================= -void BooleanGUI_CommonDlg::Init() -{ - /* init variables */ - myEditCurrentArgument = GroupCommon->LineEdit1; - myOkShape1 = myOkShape2 = false; - - /* signals and slots connections */ - connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); - connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); - - connect(GroupCommon->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupCommon->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - - connect(GroupCommon->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect(GroupCommon->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - - /* displays Dialog */ - GroupCommon->show(); - this->show(); - - return; -} - - -//================================================================================= -// function : ClickOnOk() -// purpose : -//================================================================================= -void BooleanGUI_CommonDlg::ClickOnOk() -{ - this->ClickOnApply(); - ClickOnCancel(); - return ; -} - - -//================================================================================= -// function : ClickOnApply() -// purpose : -//================================================================================= -void BooleanGUI_CommonDlg::ClickOnApply() -{ - QAD_Application::getDesktop()->putInfo(tr("")); - - if(myOkShape1 && myOkShape2) - myBooleanGUI->MakeBooleanAndDisplay(myGeomShape1 ,myGeomShape2, 1); - - return; -} - - -//================================================================================= -// function : SelectionIntoArgument() -// purpose : Called when selection has changed -//================================================================================= -void BooleanGUI_CommonDlg::SelectionIntoArgument() -{ - myEditCurrentArgument->setText(""); - QString aString = ""; - - int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString); - if(nbSel != 1) { - if(myEditCurrentArgument == GroupCommon->LineEdit1) - myOkShape1 = false; - else if( myEditCurrentArgument == GroupCommon->LineEdit2) - myOkShape2 = false; - return; - } - - /* nbSel == 1 */ - TopoDS_Shape S; - Standard_Boolean testResult; - Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); - - if(!myGeomBase->GetTopoFromSelection(mySelection, S)) - return; - - if(myEditCurrentArgument == GroupCommon->LineEdit1) { - myGeomShape1 = myGeomBase->ConvertIOinGEOMShape(IO, testResult); - if(!testResult) - return; - GroupCommon->LineEdit1->setText(aString); - myOkShape1 = true; - } - else if(myEditCurrentArgument == GroupCommon->LineEdit2) { - myGeomShape2 = myGeomBase->ConvertIOinGEOMShape(IO, testResult); - if(!testResult) - return; - GroupCommon->LineEdit2->setText(aString); - myOkShape2 = true; - } - return; -} - - -//================================================================================= -// function : SetEditCurrentArgument() -// purpose : -//================================================================================= -void BooleanGUI_CommonDlg::SetEditCurrentArgument() -{ - QPushButton* send = (QPushButton*)sender(); - - if(send == GroupCommon->PushButton1) { - GroupCommon->LineEdit1->setFocus(); - myEditCurrentArgument = GroupCommon->LineEdit1; - } - else if(send == GroupCommon->PushButton2) { - GroupCommon->LineEdit2->setFocus(); - myEditCurrentArgument = GroupCommon->LineEdit2; - } - SelectionIntoArgument(); - - return; -} - - - -//================================================================================= -// function : LineEditReturnPressed() -// purpose : -//================================================================================= -void BooleanGUI_CommonDlg::LineEditReturnPressed() -{ - QLineEdit* send = (QLineEdit*)sender(); - if(send == GroupCommon->LineEdit1) - myEditCurrentArgument = GroupCommon->LineEdit1; - else if(send == GroupCommon->LineEdit2) - myEditCurrentArgument = GroupCommon->LineEdit2; - else - return; - - GEOMBase_Skeleton::LineEditReturnPressed(); - return; -} - - -//================================================================================= -// function : ActivateThisDialog() -// purpose : -//================================================================================= -void BooleanGUI_CommonDlg::ActivateThisDialog() -{ - GEOMBase_Skeleton::ActivateThisDialog(); - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - return; -} - - -//================================================================================= -// function : enterEvent() -// purpose : when mouse enter onto the QWidget -//================================================================================= -void BooleanGUI_CommonDlg::enterEvent(QEvent * e) -{ - if (GroupConstructors->isEnabled()) - return; - this->ActivateThisDialog(); - return; -} diff --git a/src/BooleanGUI/BooleanGUI_CommonDlg.h b/src/BooleanGUI/BooleanGUI_CommonDlg.h deleted file mode 100644 index cb3b805f5..000000000 --- a/src/BooleanGUI/BooleanGUI_CommonDlg.h +++ /dev/null @@ -1,74 +0,0 @@ -// 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 : BooleanGUI_CommonDlg.h -// Author : Lucien PIGNOLONI -// Module : GEOM -// $Header$ - -#ifndef DIALOGBOX_COMMON_H -#define DIALOGBOX_COMMON_H - -#include "GEOMBase_Skeleton.h" -#include "DlgRef_2Sel_QTD.h" - -#include "BooleanGUI.h" - -#include - -//================================================================================= -// class : BooleanGUI_CommonDlg -// purpose : -//================================================================================= -class BooleanGUI_CommonDlg : public GEOMBase_Skeleton -{ - Q_OBJECT - -public: - BooleanGUI_CommonDlg(QWidget* parent = 0, const char* name = 0, BooleanGUI* theBooleanGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); - ~BooleanGUI_CommonDlg(); - -private: - void Init(); - void enterEvent(QEvent * e); - - BooleanGUI* myBooleanGUI; - - GEOM::GEOM_Shape_var myGeomShape1; /* is myShape1 */ - GEOM::GEOM_Shape_var myGeomShape2; /* is myShape2 */ - bool myOkShape1; - bool myOkShape2; /* to check when arguments are defined */ - - DlgRef_2Sel_QTD* GroupCommon; - -private slots: - void ClickOnOk(); - void ClickOnApply(); - void SetEditCurrentArgument(); - void SelectionIntoArgument(); - void LineEditReturnPressed(); - void ActivateThisDialog(); - -}; - -#endif // DIALOGBOX_COMMON_H diff --git a/src/BooleanGUI/BooleanGUI_CutDlg.cxx b/src/BooleanGUI/BooleanGUI_CutDlg.cxx deleted file mode 100644 index 4123fed72..000000000 --- a/src/BooleanGUI/BooleanGUI_CutDlg.cxx +++ /dev/null @@ -1,243 +0,0 @@ -// 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 : BooleanGUI_CutDlg.cxx -// Author : Lucien PIGNOLONI -// Module : GEOM -// $Header$ - -using namespace std; -#include "BooleanGUI_CutDlg.h" - -//================================================================================= -// class : BooleanGUI_CutDlg() -// purpose : Constructs a BooleanGUI_CutDlg 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. -//================================================================================= -BooleanGUI_CutDlg::BooleanGUI_CutDlg(QWidget* parent, const char* name, BooleanGUI* theBooleanGUI, 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_CUT"))); - QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); - - setCaption(tr("GEOM_CUT_TITLE")); - - /***************************************************************/ - GroupConstructors->setTitle(tr("GEOM_CUT")); - RadioButton1->setPixmap(image0); - RadioButton2->close(TRUE); - RadioButton3->close(TRUE); - - GroupCut = new DlgRef_2Sel_QTD(this, "GroupCut"); - GroupCut->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); - GroupCut->TextLabel1->setText(tr("GEOM_MAIN_OBJECT")); - GroupCut->TextLabel2->setText(tr("GEOM_TOOL_OBJECT")); - GroupCut->PushButton1->setPixmap(image1); - GroupCut->PushButton2->setPixmap(image1); - - Layout1->addWidget(GroupCut, 1, 0); - /***************************************************************/ - - /* Initialisation */ - myBooleanGUI = theBooleanGUI; - Init(); -} - - -//================================================================================= -// function : ~BooleanGUI_CutDlg() -// purpose : Destroys the object and frees any allocated resources -//================================================================================= -BooleanGUI_CutDlg::~BooleanGUI_CutDlg() -{ - /* no need to delete child widgets, Qt does it all for us */ -} - - -//================================================================================= -// function : Init() -// purpose : -//================================================================================= -void BooleanGUI_CutDlg::Init() -{ - /* init variables */ - myEditCurrentArgument = GroupCut->LineEdit1; - myOkShape1 = myOkShape2 = false; - - /* signals and slots connections */ - connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); - connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); - - connect(GroupCut->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupCut->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - - connect(GroupCut->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect(GroupCut->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - - /* displays Dialog */ - GroupCut->show(); - this->show(); - - return; -} - - -//================================================================================= -// function : ClickOnOk() -// purpose : -//================================================================================= -void BooleanGUI_CutDlg::ClickOnOk() -{ - this->ClickOnApply(); - ClickOnCancel(); - return ; -} - - -//================================================================================= -// function : ClickOnApply() -// purpose : -//================================================================================= -void BooleanGUI_CutDlg::ClickOnApply() -{ - QAD_Application::getDesktop()->putInfo(tr("")); - - if(myOkShape1 && myOkShape2) - myBooleanGUI->MakeBooleanAndDisplay(myGeomShape1 ,myGeomShape2, 2); - - return; -} - - -//================================================================================= -// function : SelectionIntoArgument() -// purpose : Called when selection has changed -//================================================================================= -void BooleanGUI_CutDlg::SelectionIntoArgument() -{ - myEditCurrentArgument->setText(""); - QString aString = ""; - - int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString); - if(nbSel != 1) { - if(myEditCurrentArgument == GroupCut->LineEdit1) - myOkShape1 = false; - else if( myEditCurrentArgument == GroupCut->LineEdit2) - myOkShape2 = false; - return; - } - - /* nbSel == 1 */ - TopoDS_Shape S; - Standard_Boolean testResult; - Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); - - if(!myGeomBase->GetTopoFromSelection(mySelection, S)) - return; - - if(myEditCurrentArgument == GroupCut->LineEdit1) { - myGeomShape1 = myGeomBase->ConvertIOinGEOMShape(IO, testResult); - if(!testResult) - return; - GroupCut->LineEdit1->setText(aString); - myOkShape1 = true; - } - else if(myEditCurrentArgument == GroupCut->LineEdit2) { - myGeomShape2 = myGeomBase->ConvertIOinGEOMShape(IO, testResult); - if(!testResult) - return; - GroupCut->LineEdit2->setText(aString); - myOkShape2 = true; - } - return; -} - - -//================================================================================= -// function : SetEditCurrentArgument() -// purpose : -//================================================================================= -void BooleanGUI_CutDlg::SetEditCurrentArgument() -{ - QPushButton* send = (QPushButton*)sender(); - - if(send == GroupCut->PushButton1) { - GroupCut->LineEdit1->setFocus(); - myEditCurrentArgument = GroupCut->LineEdit1; - } - else if(send == GroupCut->PushButton2) { - GroupCut->LineEdit2->setFocus(); - myEditCurrentArgument = GroupCut->LineEdit2; - } - SelectionIntoArgument(); - - return; -} - - -//================================================================================= -// function : LineEditReturnPressed() -// purpose : -//================================================================================= -void BooleanGUI_CutDlg::LineEditReturnPressed() -{ - QLineEdit* send = (QLineEdit*)sender(); - if(send == GroupCut->LineEdit1) - myEditCurrentArgument = GroupCut->LineEdit1; - else if(send == GroupCut->LineEdit2) - myEditCurrentArgument = GroupCut->LineEdit2; - else - return; - - GEOMBase_Skeleton::LineEditReturnPressed(); - return; -} - - -//================================================================================= -// function : ActivateThisDialog() -// purpose : -//================================================================================= -void BooleanGUI_CutDlg::ActivateThisDialog() -{ - GEOMBase_Skeleton::ActivateThisDialog(); - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - return; -} - - -//================================================================================= -// function : enterEvent() -// purpose : when mouse enter onto the QWidget -//================================================================================= -void BooleanGUI_CutDlg::enterEvent(QEvent * e) -{ - if(GroupConstructors->isEnabled()) - return; - this->ActivateThisDialog(); - return; -} diff --git a/src/BooleanGUI/BooleanGUI_CutDlg.h b/src/BooleanGUI/BooleanGUI_CutDlg.h deleted file mode 100644 index 212bdb176..000000000 --- a/src/BooleanGUI/BooleanGUI_CutDlg.h +++ /dev/null @@ -1,74 +0,0 @@ -// 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 : BooleanGUI_CutDlg.h -// Author : Lucien PIGNOLONI -// Module : GEOM -// $Header$ - -#ifndef DIALOGBOX_CUT_H -#define DIALOGBOX_CUT_H - -#include "GEOMBase_Skeleton.h" -#include "DlgRef_2Sel_QTD.h" - -#include "BooleanGUI.h" - -#include - -//================================================================================= -// class : BooleanGUI_CutDlg -// purpose : -//================================================================================= -class BooleanGUI_CutDlg : public GEOMBase_Skeleton -{ - Q_OBJECT - -public: - BooleanGUI_CutDlg( QWidget* parent = 0, const char* name = 0, BooleanGUI* theBooleanGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); - ~BooleanGUI_CutDlg(); - -private: - void Init(); - void enterEvent(QEvent* e); - - BooleanGUI* myBooleanGUI; - - GEOM::GEOM_Shape_var myGeomShape1; /* is myShape1 */ - GEOM::GEOM_Shape_var myGeomShape2; /* is myShape2 */ - bool myOkShape1; /* to check when arguments are defined */ - bool myOkShape2; - - DlgRef_2Sel_QTD* GroupCut; - -private slots: - void ClickOnOk(); - void ClickOnApply(); - void SetEditCurrentArgument(); - void SelectionIntoArgument(); - void LineEditReturnPressed(); - void ActivateThisDialog(); - -}; - -#endif // DIALOGBOX_CUT_H diff --git a/src/BooleanGUI/BooleanGUI_Dialog.cxx b/src/BooleanGUI/BooleanGUI_Dialog.cxx new file mode 100644 index 000000000..68bd77be8 --- /dev/null +++ b/src/BooleanGUI/BooleanGUI_Dialog.cxx @@ -0,0 +1,282 @@ +// 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 : BooleanGUI_Dialog.cxx +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +using namespace std; +#include "BooleanGUI_Dialog.h" +#include "BooleanGUI.h" +#include "DlgRef_2Sel_QTD.h" + +#include "QAD_Desktop.h" + +//================================================================================= +// class : BooleanGUI_Dialog() +// purpose : Constructs a BooleanGUI_Dialog 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. +//================================================================================= +BooleanGUI_Dialog::BooleanGUI_Dialog( const int theOperation, QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl) + :GEOMBase_Skeleton(parent, name, Sel, modal, fl), + myOperation( theOperation ) +{ + QPixmap image0; + QString aTitle, aCaption; + switch ( myOperation ) + { + case BooleanGUI::COMMON: + image0 = QPixmap( QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_COMMON"))); + aTitle = tr("GEOM_COMMON"); + aCaption = tr("GEOM_COMMON_TITLE"); + break; + case BooleanGUI::CUT: + image0 = QPixmap( QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_CUT"))); + aTitle = tr("GEOM_CUT"); + aCaption = tr("GEOM_CUT_TITLE"); + break; + case BooleanGUI::FUSE: + image0 = QPixmap( QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_FUSE"))); + aTitle = tr("GEOM_FUSE"); + aCaption = tr("GEOM_FUSE_TITLE"); + break; + case BooleanGUI::SECTION: + image0 = QPixmap( QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_SECTION"))); + aTitle = tr("GEOM_SECTION"); + aCaption = tr("GEOM_SECTION_TITLE"); + break; + } + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); + + setCaption( aCaption ); + + /***************************************************************/ + GroupConstructors->setTitle( aTitle ); + RadioButton1->setPixmap( image0 ); + RadioButton2->close(TRUE); + RadioButton3->close(TRUE); + + myGroup = new DlgRef_2Sel_QTD(this, "GroupCommon"); + myGroup->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); + if ( myOperation != BooleanGUI::CUT ) + { + myGroup->TextLabel1->setText(tr("GEOM_OBJECT_I").arg("1")); + myGroup->TextLabel2->setText(tr("GEOM_OBJECT_I").arg("2")); + } + else + { + myGroup->TextLabel1->setText(tr("GEOM_MAIN_OBJECT")); + myGroup->TextLabel2->setText(tr("GEOM_TOOL_OBJECT")); + } + + myGroup->PushButton1->setPixmap(image1); + myGroup->PushButton2->setPixmap(image1); + myGroup->LineEdit1->setReadOnly( true ); + myGroup->LineEdit2->setReadOnly( true ); + + Layout1->addWidget(myGroup, 2, 0); + /***************************************************************/ + + /* Initialisation */ + Init(); +} + + +//================================================================================= +// function : ~BooleanGUI_Dialog() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +BooleanGUI_Dialog::~BooleanGUI_Dialog() +{ +} + + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void BooleanGUI_Dialog::Init() +{ + /* init variables */ + myEditCurrentArgument = myGroup->LineEdit1; + + /* signals and slots connections */ + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + + connect(myGroup->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(myGroup->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + + connect(myGroup->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(myGroup->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + + initName( GroupConstructors->title() ); + + globalSelection( GEOM_ALLSHAPES ); +} + + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void BooleanGUI_Dialog::ClickOnOk() +{ + if ( ClickOnApply() ) + ClickOnCancel(); +} + + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +bool BooleanGUI_Dialog::ClickOnApply() +{ + if ( !onAccept() ) + return false; + + initName(); + return true; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection has changed +//================================================================================= +void BooleanGUI_Dialog::SelectionIntoArgument() +{ + myEditCurrentArgument->setText( "" ); + + if ( mySelection->IObjectCount() != 1 ) + { + if ( myEditCurrentArgument == myGroup->LineEdit1 ) myObject1 = GEOM::GEOM_Object::_nil(); + else if ( myEditCurrentArgument == myGroup->LineEdit2 ) myObject2 = GEOM::GEOM_Object::_nil(); + return; + } + + // nbSel == 1 + Standard_Boolean aRes = Standard_False; + GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( mySelection->firstIObject(), aRes ); + if ( !CORBA::is_nil( aSelectedObject ) && aRes && GEOMBase::IsShape( aSelectedObject ) ) + { + myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) ); + if ( myEditCurrentArgument == myGroup->LineEdit1 ) myObject1 = aSelectedObject; + else if ( myEditCurrentArgument == myGroup->LineEdit2 ) myObject2 = aSelectedObject; + } +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void BooleanGUI_Dialog::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + + if ( send == myGroup->PushButton1 ) myEditCurrentArgument = myGroup->LineEdit1; + else if ( send == myGroup->PushButton2 ) myEditCurrentArgument = myGroup->LineEdit2; + + myEditCurrentArgument->setFocus(); + SelectionIntoArgument(); +} + + + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void BooleanGUI_Dialog::LineEditReturnPressed() +{ + QLineEdit* send = (QLineEdit*)sender(); + if ( send == myGroup->LineEdit1 || send == myGroup->LineEdit2 ) + { + myEditCurrentArgument = send; + GEOMBase_Skeleton::LineEditReturnPressed(); + } +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void BooleanGUI_Dialog::ActivateThisDialog() +{ + GEOMBase_Skeleton::ActivateThisDialog(); + globalSelection( GEOM_ALLSHAPES ); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); +} + + +//================================================================================= +// function : enterEvent() +// purpose : when mouse enter onto the QWidget +//================================================================================= +void BooleanGUI_Dialog::enterEvent(QEvent * e) +{ + if ( !GroupConstructors->isEnabled() ) + ActivateThisDialog(); +} + +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr BooleanGUI_Dialog::createOperation() +{ + return getGeomEngine()->GetIBooleanOperations( getStudyId() ); +} + +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool BooleanGUI_Dialog::isValid( QString& msg ) +{ + return !CORBA::is_nil( myObject1 ) && !CORBA::is_nil( myObject2 ); +} + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool BooleanGUI_Dialog::execute( ObjectList& objects ) +{ + GEOM::GEOM_Object_var anObj; + + anObj = GEOM::GEOM_IBooleanOperations::_narrow( getOperation() )->MakeBoolean( myObject1, myObject2, myOperation ); + if ( !anObj->_is_nil() ) + objects.push_back( anObj._retn() ); + + return true; +} diff --git a/src/BooleanGUI/BooleanGUI_Dialog.h b/src/BooleanGUI/BooleanGUI_Dialog.h new file mode 100644 index 000000000..e9483dd39 --- /dev/null +++ b/src/BooleanGUI/BooleanGUI_Dialog.h @@ -0,0 +1,75 @@ +// 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 : BooleanGUI_Dialog.h +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +#ifndef BooleanGUI_Dialog_H +#define BooleanGUI_Dialog_H + +#include "GEOMBase_Skeleton.h" + +class DlgRef_2Sel_QTD; + +//================================================================================= +// class : BooleanGUI_Dialog +// purpose : +//================================================================================= +class BooleanGUI_Dialog : public GEOMBase_Skeleton +{ + Q_OBJECT + +public: + BooleanGUI_Dialog( const int theOperation, QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + ~BooleanGUI_Dialog(); + +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& ); + virtual bool execute( ObjectList& objects ); + +private: + int myOperation; + + void Init(); + void enterEvent(QEvent * e); + + GEOM::GEOM_Object_var myObject1; + GEOM::GEOM_Object_var myObject2; + + DlgRef_2Sel_QTD* myGroup; + +private slots: + void ClickOnOk(); + bool ClickOnApply(); + void SetEditCurrentArgument(); + void SelectionIntoArgument(); + void LineEditReturnPressed(); + void ActivateThisDialog(); + +}; + +#endif // BooleanGUI_Dialog_H diff --git a/src/BooleanGUI/BooleanGUI_FuseDlg.cxx b/src/BooleanGUI/BooleanGUI_FuseDlg.cxx deleted file mode 100644 index ea9ae1b3a..000000000 --- a/src/BooleanGUI/BooleanGUI_FuseDlg.cxx +++ /dev/null @@ -1,243 +0,0 @@ -// 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 : BooleanGUI_FuseDlg.cxx -// Author : Lucien PIGNOLONI -// Module : GEOM -// $Header$ - -using namespace std; -#include "BooleanGUI_FuseDlg.h" - -//================================================================================= -// class : BooleanGUI_FuseDlg() -// purpose : Constructs a BooleanGUI_FuseDlg 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. -//================================================================================= -BooleanGUI_FuseDlg::BooleanGUI_FuseDlg(QWidget* parent, const char* name, BooleanGUI* theBooleanGUI, 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_FUSE"))); - QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); - - setCaption(tr("GEOM_FUSE_TITLE")); - - /***************************************************************/ - GroupConstructors->setTitle(tr("GEOM_FUSE")); - RadioButton1->setPixmap(image0); - RadioButton2->close(TRUE); - RadioButton3->close(TRUE); - - GroupFuse = new DlgRef_2Sel_QTD(this, "GroupFuse"); - GroupFuse->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); - GroupFuse->TextLabel1->setText(tr("GEOM_OBJECT_I").arg("1")); - GroupFuse->TextLabel2->setText(tr("GEOM_OBJECT_I").arg("2")); - GroupFuse->PushButton1->setPixmap(image1); - GroupFuse->PushButton2->setPixmap(image1); - - Layout1->addWidget(GroupFuse, 1, 0); - /***************************************************************/ - - /* Initialisation */ - myBooleanGUI = theBooleanGUI; - Init(); -} - - -//================================================================================= -// function : ~BooleanGUI_FuseDlg() -// purpose : Destroys the object and frees any allocated resources -//================================================================================= -BooleanGUI_FuseDlg::~BooleanGUI_FuseDlg() -{ - /* no need to delete child widgets, Qt does it all for us */ -} - - -//================================================================================= -// function : Init() -// purpose : -//================================================================================= -void BooleanGUI_FuseDlg::Init() -{ - /* init variables */ - myEditCurrentArgument = GroupFuse->LineEdit1; - myOkShape1 = myOkShape2 = false; - - /* signals and slots connections */ - connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); - connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); - - connect(GroupFuse->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupFuse->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - - connect(GroupFuse->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect(GroupFuse->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - - /* displays Dialog */ - GroupFuse->show(); - this->show(); - - return; -} - - -//================================================================================= -// function : ClickOnOk() -// purpose : -//================================================================================= -void BooleanGUI_FuseDlg::ClickOnOk() -{ - this->ClickOnApply(); - ClickOnCancel(); - return; -} - - -//================================================================================= -// function : ClickOnApply() -// purpose : -//================================================================================= -void BooleanGUI_FuseDlg::ClickOnApply() -{ - QAD_Application::getDesktop()->putInfo(tr("")); - - if(myOkShape1 && myOkShape2) - myBooleanGUI->MakeBooleanAndDisplay(myGeomShape1 ,myGeomShape2, 3); - - return; -} - - -//================================================================================= -// function : SelectionIntoArgument() -// purpose : Called when selection has changed -//================================================================================= -void BooleanGUI_FuseDlg::SelectionIntoArgument() -{ - myEditCurrentArgument->setText(""); - QString aString = ""; - - int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString); - if(nbSel != 1) { - if(myEditCurrentArgument == GroupFuse->LineEdit1) - myOkShape1 = false; - else if( myEditCurrentArgument == GroupFuse->LineEdit2) - myOkShape2 = false; - return; - } - - /* nbSel == 1 */ - TopoDS_Shape S; - Standard_Boolean testResult; - Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); - - if(!myGeomBase->GetTopoFromSelection(mySelection, S)) - return; - - if(myEditCurrentArgument == GroupFuse->LineEdit1) { - myGeomShape1 = myGeomBase->ConvertIOinGEOMShape(IO, testResult); - if(!testResult) - return; - GroupFuse->LineEdit1->setText(aString); - myOkShape1 = true; - } - else if(myEditCurrentArgument == GroupFuse->LineEdit2) { - myGeomShape2 = myGeomBase->ConvertIOinGEOMShape(IO, testResult); - if(!testResult) - return; - GroupFuse->LineEdit2->setText(aString); - myOkShape2 = true; - } - return; -} - - -//================================================================================= -// function : SetEditCurrentArgument() -// purpose : -//================================================================================= -void BooleanGUI_FuseDlg::SetEditCurrentArgument() -{ - QPushButton* send = (QPushButton*)sender(); - - if(send == GroupFuse->PushButton1) { - GroupFuse->LineEdit1->setFocus(); - myEditCurrentArgument = GroupFuse->LineEdit1; - } - else if(send == GroupFuse->PushButton2) { - GroupFuse->LineEdit2->setFocus(); - myEditCurrentArgument = GroupFuse->LineEdit2; - } - SelectionIntoArgument(); - - return; -} - - -//================================================================================= -// function : LineEditReturnPressed() -// purpose : -//================================================================================= -void BooleanGUI_FuseDlg::LineEditReturnPressed() -{ - QLineEdit* send = (QLineEdit*)sender(); - if(send == GroupFuse->LineEdit1) - myEditCurrentArgument = GroupFuse->LineEdit1; - else if(send == GroupFuse->LineEdit2) - myEditCurrentArgument = GroupFuse->LineEdit2; - else - return; - - GEOMBase_Skeleton::LineEditReturnPressed(); - return; -} - - -//================================================================================= -// function : ActivateThisDialog() -// purpose : -//================================================================================= -void BooleanGUI_FuseDlg::ActivateThisDialog() -{ - GEOMBase_Skeleton::ActivateThisDialog(); - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - return; -} - - -//================================================================================= -// function : enterEvent() -// purpose : when mouse enter onto the QWidget -//================================================================================= -void BooleanGUI_FuseDlg::enterEvent(QEvent* e) -{ - if(GroupConstructors->isEnabled()) - return; - this->ActivateThisDialog(); - return; -} diff --git a/src/BooleanGUI/BooleanGUI_FuseDlg.h b/src/BooleanGUI/BooleanGUI_FuseDlg.h deleted file mode 100644 index 6898e64aa..000000000 --- a/src/BooleanGUI/BooleanGUI_FuseDlg.h +++ /dev/null @@ -1,74 +0,0 @@ -// 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 : BooleanGUI_FuseDlg.h -// Author : Lucien PIGNOLONI -// Module : GEOM -// $Header$ - -#ifndef DIALOGBOX_FUSE_H -#define DIALOGBOX_FUSE_H - -#include "GEOMBase_Skeleton.h" -#include "DlgRef_2Sel_QTD.h" - -#include "BooleanGUI.h" - -#include - -//================================================================================= -// class : BooleanGUI_FuseDlg -// purpose : -//================================================================================= -class BooleanGUI_FuseDlg : public GEOMBase_Skeleton -{ - Q_OBJECT - -public: - BooleanGUI_FuseDlg(QWidget* parent = 0, const char* name = 0, BooleanGUI* theBooleanGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); - ~BooleanGUI_FuseDlg(); - -private: - void Init(); - void enterEvent(QEvent* e); - - BooleanGUI* myBooleanGUI; - - GEOM::GEOM_Shape_var myGeomShape1; /* is myShape1 */ - GEOM::GEOM_Shape_var myGeomShape2; /* is myShape2 */ - bool myOkShape1; /* to check when arguments are defined */ - bool myOkShape2; - - DlgRef_2Sel_QTD* GroupFuse; - -private slots: - void ClickOnOk(); - void ClickOnApply(); - void SetEditCurrentArgument(); - void SelectionIntoArgument(); - void LineEditReturnPressed(); - void ActivateThisDialog(); - -}; - -#endif // DIALOGBOX_FUSE_H diff --git a/src/BooleanGUI/BooleanGUI_SectionDlg.cxx b/src/BooleanGUI/BooleanGUI_SectionDlg.cxx deleted file mode 100644 index 51bae1f9e..000000000 --- a/src/BooleanGUI/BooleanGUI_SectionDlg.cxx +++ /dev/null @@ -1,244 +0,0 @@ -// 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 : BooleanGUI_SectionDlg.cxx -// Author : Lucien PIGNOLONI -// Module : GEOM -// $Header$ - -using namespace std; -#include "BooleanGUI_SectionDlg.h" - -//================================================================================= -// class : BooleanGUI_SectionDlg() -// purpose : Constructs a BooleanGUI_SectionDlg 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. -//================================================================================= -BooleanGUI_SectionDlg::BooleanGUI_SectionDlg(QWidget* parent, const char* name, BooleanGUI* theBooleanGUI, 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_SECTION"))); - QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); - - setCaption(tr("GEOM_SECTION_TITLE")); - - /***************************************************************/ - GroupConstructors->setTitle(tr("GEOM_SECTION")); - RadioButton1->setPixmap(image0); - RadioButton2->close(TRUE); - RadioButton3->close(TRUE); - - GroupSection = new DlgRef_2Sel_QTD(this, "GroupSection"); - GroupSection->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); - GroupSection->TextLabel1->setText(tr("GEOM_OBJECT_I").arg("1")); - GroupSection->TextLabel2->setText(tr("GEOM_OBJECT_I").arg("2")); - GroupSection->PushButton1->setPixmap(image1); - GroupSection->PushButton2->setPixmap(image1); - - Layout1->addWidget(GroupSection, 1, 0); - /***************************************************************/ - - /* Initialisation */ - myBooleanGUI = theBooleanGUI; - Init(); -} - - -//================================================================================= -// function : ~BooleanGUI_SectionDlg() -// purpose : Destroys the object and frees any allocated resources -//================================================================================= -BooleanGUI_SectionDlg::~BooleanGUI_SectionDlg() -{ - /* no need to delete child widgets, Qt does it all for us */ -} - - - -//================================================================================= -// function : Init() -// purpose : -//================================================================================= -void BooleanGUI_SectionDlg::Init() -{ - /* init variables */ - myEditCurrentArgument = GroupSection->LineEdit1; - myOkShape1 = myOkShape2 = false; - - /* signals and slots connections */ - connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); - connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); - - connect(GroupSection->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupSection->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - - connect(GroupSection->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect(GroupSection->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - - /* displays Dialog */ - GroupSection->show(); - this->show(); - - return; -} - - -//================================================================================= -// function : ClickOnOk() -// purpose : -//================================================================================= -void BooleanGUI_SectionDlg::ClickOnOk() -{ - this->ClickOnApply(); - ClickOnCancel(); - return ; -} - - -//================================================================================= -// function : ClickOnApply() -// purpose : -//================================================================================= -void BooleanGUI_SectionDlg::ClickOnApply() -{ - QAD_Application::getDesktop()->putInfo(tr("")); - - if(myOkShape1 && myOkShape2) - myBooleanGUI->MakeBooleanAndDisplay(myGeomShape1 ,myGeomShape2, 4); - - return; -} - - -//================================================================================= -// function : SelectionIntoArgument() -// purpose : Called when selection has changed -//================================================================================= -void BooleanGUI_SectionDlg::SelectionIntoArgument() -{ - myEditCurrentArgument->setText(""); - QString aString = ""; - - int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString); - if(nbSel != 1) { - if(myEditCurrentArgument == GroupSection->LineEdit1) - myOkShape1 = false; - else if( myEditCurrentArgument == GroupSection->LineEdit2) - myOkShape2 = false; - return; - } - - /* nbSel == 1 */ - TopoDS_Shape S; - Standard_Boolean testResult; - Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); - - if(!myGeomBase->GetTopoFromSelection(mySelection, S)) - return; - - if(myEditCurrentArgument == GroupSection->LineEdit1) { - myGeomShape1 = myGeomBase->ConvertIOinGEOMShape(IO, testResult); - if(!testResult) - return; - GroupSection->LineEdit1->setText(aString); - myOkShape1 = true; - } - else if(myEditCurrentArgument == GroupSection->LineEdit2) { - myGeomShape2 = myGeomBase->ConvertIOinGEOMShape(IO, testResult); - if(!testResult) - return; - GroupSection->LineEdit2->setText(aString); - myOkShape2 = true; - } - return; -} - - -//================================================================================= -// function : SetEditCurrentArgument() -// purpose : -//================================================================================= -void BooleanGUI_SectionDlg::SetEditCurrentArgument() -{ - QPushButton* send = (QPushButton*)sender(); - - if(send == GroupSection->PushButton1) { - GroupSection->LineEdit1->setFocus(); - myEditCurrentArgument = GroupSection->LineEdit1; - } - else if(send == GroupSection->PushButton2) { - GroupSection->LineEdit2->setFocus(); - myEditCurrentArgument = GroupSection->LineEdit2; - } - SelectionIntoArgument(); - - return; -} - - -//================================================================================= -// function : LineEditReturnPressed() -// purpose : -//================================================================================= -void BooleanGUI_SectionDlg::LineEditReturnPressed() -{ - QLineEdit* send = (QLineEdit*)sender(); - if(send == GroupSection->LineEdit1) - myEditCurrentArgument = GroupSection->LineEdit1; - else if(send == GroupSection->LineEdit2) - myEditCurrentArgument = GroupSection->LineEdit2; - else - return; - - GEOMBase_Skeleton::LineEditReturnPressed(); - return; -} - - -//================================================================================= -// function : ActivateThisDialog() -// purpose : -//================================================================================= -void BooleanGUI_SectionDlg::ActivateThisDialog() -{ - GEOMBase_Skeleton::ActivateThisDialog(); - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - return; -} - - -//================================================================================= -// function : enterEvent() -// purpose : when mouse enter onto the QWidget -//================================================================================= -void BooleanGUI_SectionDlg::enterEvent(QEvent * e) -{ - if(GroupConstructors->isEnabled()) - return; - this->ActivateThisDialog(); - return; -} diff --git a/src/BooleanGUI/BooleanGUI_SectionDlg.h b/src/BooleanGUI/BooleanGUI_SectionDlg.h deleted file mode 100644 index ef1f35282..000000000 --- a/src/BooleanGUI/BooleanGUI_SectionDlg.h +++ /dev/null @@ -1,74 +0,0 @@ -// 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 : BooleanGUI_SectionDlg.h -// Author : Lucien PIGNOLONI -// Module : GEOM -// $Header: - -#ifndef DIALOGBOX_SECTION_H -#define DIALOGBOX_SECTION_H - -#include "GEOMBase_Skeleton.h" -#include "DlgRef_2Sel_QTD.h" - -#include "BooleanGUI.h" - -#include - -//================================================================================= -// class : BooleanGUI_SectionDlg -// purpose : -//================================================================================= -class BooleanGUI_SectionDlg : public GEOMBase_Skeleton -{ - Q_OBJECT - -public: - BooleanGUI_SectionDlg(QWidget* parent = 0, const char* name = 0, BooleanGUI* theBooleanGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); - ~BooleanGUI_SectionDlg(); - -private: - void Init(); - void enterEvent(QEvent* e); - - BooleanGUI* myBooleanGUI; - - GEOM::GEOM_Shape_var myGeomShape1; /* is myShape1 */ - GEOM::GEOM_Shape_var myGeomShape2; /* is myShape2 */ - bool myOkShape1; /* to check when arguments are defined */ - bool myOkShape2; - - DlgRef_2Sel_QTD* GroupSection; - -private slots: - void ClickOnOk(); - void ClickOnApply(); - void SetEditCurrentArgument(); - void SelectionIntoArgument(); - void LineEditReturnPressed(); - void ActivateThisDialog(); - -}; - -#endif // DIALOGBOX_SECTION_H diff --git a/src/BooleanGUI/Makefile.in b/src/BooleanGUI/Makefile.in index 92de526ff..61467e6d7 100644 --- a/src/BooleanGUI/Makefile.in +++ b/src/BooleanGUI/Makefile.in @@ -41,21 +41,14 @@ EXPORT_HEADERS= LIB = libBooleanGUI.la LIB_SRC = BooleanGUI.cxx \ - BooleanGUI_FuseDlg.cxx \ - BooleanGUI_CommonDlg.cxx \ - BooleanGUI_CutDlg.cxx \ - BooleanGUI_SectionDlg.cxx + BooleanGUI_Dialog.cxx LIB_MOC = \ - BooleanGUI.h \ - BooleanGUI_FuseDlg.h \ - BooleanGUI_CommonDlg.h \ - BooleanGUI_CutDlg.h \ - BooleanGUI_SectionDlg.h + BooleanGUI_Dialog.h -LIB_CLIENT_IDL = +LIB_CLIENT_IDL = SALOME_GenericObj.idl SALOME_Component.idl -LIB_SERVER_IDL = +LIB_SERVER_IDL = # additionnal information to compil and link file diff --git a/src/BuildGUI/BuildGUI.cxx b/src/BuildGUI/BuildGUI.cxx index 1460732e7..d361dde5e 100644 --- a/src/BuildGUI/BuildGUI.cxx +++ b/src/BuildGUI/BuildGUI.cxx @@ -24,12 +24,12 @@ // File : BooleanGUI.cxx // Author : Damien COQUERET // Module : GEOM -// $Header: +// $Header$ -using namespace std; #include "BuildGUI.h" #include "SALOMEGUI_QtCatchCorbaException.hxx" +#include "QAD_Desktop.h" #include "BuildGUI_EdgeDlg.h" // Method EDGE #include "BuildGUI_WireDlg.h" // Method WIRE @@ -38,16 +38,27 @@ using namespace std; #include "BuildGUI_SolidDlg.h" // Method SOLID #include "BuildGUI_CompoundDlg.h" // Method COMPOUND +BuildGUI* BuildGUI::myGUIObject = 0; + +//======================================================================= +// function : GetBuildGUI() +// purpose : Get the only BuildGUI object [ static ] +//======================================================================= +BuildGUI* BuildGUI::GetBuildGUI() +{ + if ( myGUIObject == 0 ) + myGUIObject = new BuildGUI(); + + return myGUIObject; +} + //======================================================================= // function : BuildGUI() // purpose : Constructor //======================================================================= -BuildGUI::BuildGUI() : - QObject() +BuildGUI::BuildGUI() +: GEOMGUI() { - myGeomBase = new GEOMBase(); - myGeomGUI = GEOMContext::GetGeomGUI(); - myGeom = myGeomGUI->myComponentGeom; } @@ -64,203 +75,40 @@ BuildGUI::~BuildGUI() // function : OnGUIEvent() // purpose : //======================================================================= -bool BuildGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) -{ - BuildGUI* myBuildGUI = new BuildGUI(); - myBuildGUI->myGeomGUI->EmitSignalDeactivateDialog(); - SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection()); - - switch (theCommandID) - { - case 4081: // GEOM::EDGE - { - BuildGUI_EdgeDlg *aDlg = new BuildGUI_EdgeDlg(parent, "", myBuildGUI, Sel); - break; - } - case 4082: // GEOM::WIRE - { - BuildGUI_WireDlg *aDlg = new BuildGUI_WireDlg(parent, "", myBuildGUI, Sel); - break; - } - case 4083: // GEOM::FACE - { - BuildGUI_FaceDlg *aDlg = new BuildGUI_FaceDlg(parent, "", myBuildGUI, Sel); - break; - } - case 4084: // GEOM::SHELL - { - BuildGUI_ShellDlg *aDlg = new BuildGUI_ShellDlg(parent, "", myBuildGUI, Sel); - break; - } - case 4085: // GEOM::SOLID - { - BuildGUI_SolidDlg *aDlg = new BuildGUI_SolidDlg(parent, "", myBuildGUI, Sel); - break; - } - case 4086: // GEOM::COMPOUND - { - BuildGUI_CompoundDlg *aDlg = new BuildGUI_CompoundDlg(parent, "", myBuildGUI, Sel); - break; - } - default: - { - parent->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); - break; - } - } - return true; -} - - -//===================================================================================== -// function : MakeLinearEdgeAndDisplay() -// purpose : -//===================================================================================== -void BuildGUI::MakeLinearEdgeAndDisplay(const gp_Pnt P1, const gp_Pnt P2) +bool BuildGUI::OnGUIEvent( int theCommandID, QAD_Desktop* parent ) { - try { - GEOM::PointStruct ps1 = myGeom->MakePointStruct(P1.X(), P1.Y(), P1.Z()); - GEOM::PointStruct ps2 = myGeom->MakePointStruct(P2.X(), P2.Y(), P2.Z()); - GEOM::GEOM_Shape_var result = myGeom->MakeEdge(ps1, ps2); - if(result->_is_nil()) { - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_NULLSHAPE")); - return; - } - result->NameType(tr("GEOM_EDGE")); - if(myGeomBase->Display(result)) - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); + GeometryGUI::GetGeomGUI()->EmitSignalDeactivateDialog(); + + SALOME_Selection* Sel = SALOME_Selection::Selection( + QAD_Application::getDesktop()->getActiveStudy()->getSelection() ); + + QDialog* aDlg = NULL; + + switch ( theCommandID ) + { + case 4081: aDlg = new BuildGUI_EdgeDlg ( parent, "", Sel ); break; + case 4082: aDlg = new BuildGUI_WireDlg ( parent, "", Sel ); break; + case 4083: aDlg = new BuildGUI_FaceDlg ( parent, "", Sel ); break; + case 4084: aDlg = new BuildGUI_ShellDlg ( parent, "", Sel ); break; + case 4085: aDlg = new BuildGUI_SolidDlg ( parent, "", Sel ); break; + case 4086: aDlg = new BuildGUI_CompoundDlg( parent, "", Sel ); break; + + default: parent->putInfo( tr( "GEOM_PRP_COMMAND" ).arg( theCommandID ) ); break; } - catch(const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return; -} - - -//===================================================================================== -// function : MakeWireAndDisplay() -// purpose : -//===================================================================================== -void BuildGUI::MakeWireAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR) -{ - try { - GEOM::GEOM_Shape_var result = myGeom->MakeWire(listShapesIOR); - if(result->_is_nil()) { - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_NULLSHAPE")); - return; - } - result->NameType(tr("GEOM_WIRE")); - if(myGeomBase->Display(result)) - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); - } - catch(const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return; -} - - -//===================================================================================== -// function : MakeFaceAndDisplay() -// purpose : -//===================================================================================== -void BuildGUI::MakeFaceAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR, - const Standard_Boolean wantPlanar) -{ - try { - GEOM::GEOM_Shape_var result = myGeom->MakeFaces(listShapesIOR, wantPlanar); - if(result->_is_nil()) { - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_NULLSHAPE")); - return; - } - if (wantPlanar) - result->NameType(tr("GEOM_PLANE")); - else - result->NameType(tr("GEOM_FACE")); - if(myGeomBase->Display(result)) - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); - } - catch(const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return; -} - - -//===================================================================================== -// function : MakeShellAndDisplay() -// purpose : -//===================================================================================== -void BuildGUI::MakeShellAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR) -{ - try { - GEOM::GEOM_Shape_var result = myGeom->MakeShell(listShapesIOR); - if(result->_is_nil()) { - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_NULLSHAPE")); - return; - } - result->NameType(tr("GEOM_SHELL")); - if(myGeomBase->Display(result)) - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); - } - catch(const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return; -} - - -//===================================================================================== -// function : MakeSolidAndDisplay() -// purpose : -//===================================================================================== -void BuildGUI::MakeSolidAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR) -{ - try { - GEOM::GEOM_Shape_var result = myGeom->MakeSolid(listShapesIOR); - if(result->_is_nil()) { - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_NULLSHAPE")); - return; - } - result->NameType(tr("GEOM_SOLID")); - if(myGeomBase->Display(result)) - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); - } - catch(const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return; -} - - -//===================================================================================== -// function : MakeCompoundAndDisplay() -// purpose : -//===================================================================================== -void BuildGUI::MakeCompoundAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR) -{ - try { - GEOM::GEOM_Shape_var result = myGeom->MakeCompound(listShapesIOR); - if(result->_is_nil()) { - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_NULLSHAPE")); - return; - } - result->NameType(tr("GEOM_COMPOUND")); - if(myGeomBase->Display(result)) - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); - } - catch(const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return; + + if ( aDlg != NULL ) + aDlg->show(); + + return true; } - //===================================================================================== // EXPORTED METHODS //===================================================================================== extern "C" { - bool OnGUIEvent(int theCommandID, QAD_Desktop* parent) - {return BuildGUI::OnGUIEvent(theCommandID, parent);} + GEOMGUI* GetLibGUI() + { + return BuildGUI::GetBuildGUI(); + } } diff --git a/src/BuildGUI/BuildGUI.h b/src/BuildGUI/BuildGUI.h index 7d50e6967..d7818c5a4 100644 --- a/src/BuildGUI/BuildGUI.h +++ b/src/BuildGUI/BuildGUI.h @@ -24,40 +24,32 @@ // File : BuildGUI.h // Author : Damien COQUERET // Module : GEOM -// $Header: +// $Header$ #ifndef BUILDGUI_H #define BUILDGUI_H -#include "GEOMBase.h" -#include +#include "GEOMGUI.h" //================================================================================= // class : BuildGUI // purpose : //================================================================================= -class BuildGUI : public QObject +class BuildGUI : public GEOMGUI { - Q_OBJECT /* for QT compatibility */ +protected: + BuildGUI(); // hide constructor to avoid direct creation public : - BuildGUI(); ~BuildGUI(); - static bool OnGUIEvent(int theCommandID, QAD_Desktop* parent); + // Get the only BuildGUI object + static BuildGUI* GetBuildGUI(); - void MakeLinearEdgeAndDisplay(const gp_Pnt P1, const gp_Pnt P2); - void MakeWireAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR); - void MakeFaceAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR, - const Standard_Boolean wantPlanar); - void MakeShellAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR); - void MakeSolidAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR); - void MakeCompoundAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR); - - GEOMBase* myGeomBase; - GEOMContext* myGeomGUI; - GEOM::GEOM_Gen_var myGeom; /* Current Geom Component */ + bool OnGUIEvent( int theCommandID, QAD_Desktop* parent ); +private: + static BuildGUI* myGUIObject; // the only BuildGUI object }; #endif diff --git a/src/BuildGUI/BuildGUI_CompoundDlg.cxx b/src/BuildGUI/BuildGUI_CompoundDlg.cxx index 29d3b26a8..b6f9f06b6 100644 --- a/src/BuildGUI/BuildGUI_CompoundDlg.cxx +++ b/src/BuildGUI/BuildGUI_CompoundDlg.cxx @@ -26,8 +26,9 @@ // Module : GEOM // $Header$ -using namespace std; #include "BuildGUI_CompoundDlg.h" +#include "QAD_Desktop.h" +#include "GEOMImpl_Types.hxx" //================================================================================= // class : BuildGUI_CompoundDlg() @@ -36,7 +37,7 @@ using namespace std; // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -BuildGUI_CompoundDlg::BuildGUI_CompoundDlg(QWidget* parent, const char* name, BuildGUI* theBuildGUI, SALOME_Selection* Sel, bool modal, WFlags fl) +BuildGUI_CompoundDlg::BuildGUI_CompoundDlg(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_BUILD_COMPOUND"))); @@ -50,16 +51,16 @@ BuildGUI_CompoundDlg::BuildGUI_CompoundDlg(QWidget* parent, const char* name, Bu RadioButton2->close(TRUE); RadioButton3->close(TRUE); - GroupPoints = new DlgRef_1Sel_QTD(this, "GroupPoints"); - GroupPoints->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); - GroupPoints->TextLabel1->setText(tr("GEOM_OBJECTS")); - GroupPoints->PushButton1->setPixmap(image1); + GroupShapes = new DlgRef_1Sel_QTD(this, "GroupShapes"); + GroupShapes->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); + GroupShapes->TextLabel1->setText(tr("GEOM_OBJECTS")); + GroupShapes->PushButton1->setPixmap(image1); + GroupShapes->LineEdit1->setReadOnly( true ); - Layout1->addWidget(GroupPoints, 1, 0); + Layout1->addWidget(GroupShapes, 2, 0); /***************************************************************/ /* Initialisations */ - myBuildGUI = theBuildGUI; Init(); } @@ -81,20 +82,20 @@ BuildGUI_CompoundDlg::~BuildGUI_CompoundDlg() void BuildGUI_CompoundDlg::Init() { /* init variables */ - myEditCurrentArgument = GroupPoints->LineEdit1; - myOkListShapes = false; + myEditCurrentArgument = GroupShapes->LineEdit1; + GroupShapes->LineEdit1->setReadOnly( true ); + + myOkShapes = false; /* signals and slots connections */ connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); - connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupShapes->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ; - /* displays Dialog */ - GroupPoints->show(); - this->show(); + globalSelection( GEOM_ALLSHAPES ); - return; + initName( tr( "GEOM_COMPOUND" ) ); } @@ -104,9 +105,8 @@ void BuildGUI_CompoundDlg::Init() //================================================================================= void BuildGUI_CompoundDlg::ClickOnOk() { - this->ClickOnApply(); - ClickOnCancel(); - return; + if ( ClickOnApply() ) + ClickOnCancel(); } @@ -114,12 +114,13 @@ void BuildGUI_CompoundDlg::ClickOnOk() // function : ClickOnApply() // purpose : //================================================================================= -void BuildGUI_CompoundDlg::ClickOnApply() +bool BuildGUI_CompoundDlg::ClickOnApply() { - QAD_Application::getDesktop()->putInfo(tr("")); - if(myOkListShapes) - myBuildGUI->MakeCompoundAndDisplay(myListShapes); - return; + if ( !onAccept() ) + return false; + + initName(); + return true; } @@ -129,26 +130,19 @@ void BuildGUI_CompoundDlg::ClickOnApply() //================================================================================= void BuildGUI_CompoundDlg::SelectionIntoArgument() { - myEditCurrentArgument->setText(""); + myEditCurrentArgument->setText( "" ); QString aString = ""; /* name of selection */ - myOkListShapes = false; - int nbSel = mySelection->IObjectCount(); - if(nbSel == 0) + myOkShapes = false; + int nbSel = GEOMBase::GetNameOfSelectedIObjects( mySelection, aString, true ); + if ( nbSel == 0 ) return; - aString = tr("%1_objects").arg(nbSel); - -// int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString); -// if(nbSel <= 1) { -// myOkListShapes = false; -// return; -// } + if ( nbSel != 1 ) + aString = QString( "%1_objects").arg( nbSel ); - myGeomBase->ConvertListOfIOInListOfIOR(mySelection->StoredIObjects(), myListShapes); - myEditCurrentArgument->setText(aString); - myOkListShapes = true; - /* no simulation */ - return; + GEOMBase::ConvertListOfIOInListOfGO( mySelection->StoredIObjects(), myShapes, true ); + myEditCurrentArgument->setText( aString ); + myOkShapes = true; } @@ -158,9 +152,14 @@ void BuildGUI_CompoundDlg::SelectionIntoArgument() //================================================================================= void BuildGUI_CompoundDlg::SetEditCurrentArgument() { - GroupPoints->LineEdit1->setFocus(); - this->SelectionIntoArgument(); - return; + QPushButton* send = (QPushButton*)sender(); + if (send != GroupShapes->PushButton1) + return; + + myEditCurrentArgument = GroupShapes->LineEdit1; + + myEditCurrentArgument->setFocus(); + SelectionIntoArgument(); } @@ -171,8 +170,8 @@ void BuildGUI_CompoundDlg::SetEditCurrentArgument() void BuildGUI_CompoundDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); + globalSelection( GEOM_ALLSHAPES ); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - return; } @@ -182,8 +181,40 @@ void BuildGUI_CompoundDlg::ActivateThisDialog() //================================================================================= void BuildGUI_CompoundDlg::enterEvent(QEvent* e) { - if (GroupConstructors->isEnabled()) - return; - this->ActivateThisDialog(); - return; + if ( !GroupConstructors->isEnabled() ) + ActivateThisDialog(); +} + +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr BuildGUI_CompoundDlg::createOperation() +{ + return getGeomEngine()->GetIShapesOperations( getStudyId() ); +} + +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool BuildGUI_CompoundDlg::isValid( QString& ) +{ + return myOkShapes; +} + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool BuildGUI_CompoundDlg::execute( ObjectList& objects ) +{ + GEOM::GEOM_Object_var anObj; + + anObj = GEOM::GEOM_IShapesOperations::_narrow( getOperation() )->MakeCompound( myShapes ); + + if ( !anObj->_is_nil() ) + objects.push_back( anObj._retn() ); + + return true; } diff --git a/src/BuildGUI/BuildGUI_CompoundDlg.h b/src/BuildGUI/BuildGUI_CompoundDlg.h index deb8a153b..848556ded 100644 --- a/src/BuildGUI/BuildGUI_CompoundDlg.h +++ b/src/BuildGUI/BuildGUI_CompoundDlg.h @@ -21,7 +21,7 @@ // // // -// File : GEOMBase_Context*_CompoundDlg.h +// File : GEOMBase_CompoundDlg.h // Author : Lucien PIGNOLONI // Module : GEOM // $Header$ @@ -32,8 +32,6 @@ #include "GEOMBase_Skeleton.h" #include "DlgRef_1Sel_QTD.h" -#include "BuildGUI.h" - //================================================================================= // class : BuildGUI_CompoundDlg // purpose : @@ -43,23 +41,27 @@ class BuildGUI_CompoundDlg : public GEOMBase_Skeleton Q_OBJECT public: - BuildGUI_CompoundDlg(QWidget* parent = 0, const char* name = 0, BuildGUI* theBuildGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + BuildGUI_CompoundDlg(QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); ~BuildGUI_CompoundDlg(); +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& msg ); + virtual bool execute( ObjectList& objects ); + private: void Init(); void enterEvent(QEvent* e); - BuildGUI* myBuildGUI; - - GEOM::GEOM_Gen::ListOfIOR myListShapes; - bool myOkListShapes; /* to check when arguments is defined */ - - DlgRef_1Sel_QTD* GroupPoints; + GEOM::ListOfGO myShapes; + bool myOkShapes; + DlgRef_1Sel_QTD* GroupShapes; + private slots: void ClickOnOk(); - void ClickOnApply(); + bool ClickOnApply(); void ActivateThisDialog(); void SelectionIntoArgument(); void SetEditCurrentArgument(); diff --git a/src/BuildGUI/BuildGUI_EdgeDlg.cxx b/src/BuildGUI/BuildGUI_EdgeDlg.cxx index 770cc70b3..33518dc5c 100644 --- a/src/BuildGUI/BuildGUI_EdgeDlg.cxx +++ b/src/BuildGUI/BuildGUI_EdgeDlg.cxx @@ -32,8 +32,8 @@ #include #include "utilities.h" - -using namespace std; +#include "QAD_Desktop.h" +#include "GEOMImpl_Types.hxx" //================================================================================= // class : BuildGUI_EdgeDlg() @@ -42,7 +42,7 @@ using namespace std; // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -BuildGUI_EdgeDlg::BuildGUI_EdgeDlg(QWidget* parent, const char* name, BuildGUI* theBuildGUI, SALOME_Selection* Sel, bool modal, WFlags fl) +BuildGUI_EdgeDlg::BuildGUI_EdgeDlg(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_BUILD_EDGE"))); @@ -62,12 +62,14 @@ BuildGUI_EdgeDlg::BuildGUI_EdgeDlg(QWidget* parent, const char* name, BuildGUI* GroupPoints->TextLabel2->setText(tr("GEOM_POINT_I").arg("2")); GroupPoints->PushButton1->setPixmap(image1); GroupPoints->PushButton2->setPixmap(image1); + + GroupPoints->LineEdit1->setReadOnly( true ); + GroupPoints->LineEdit2->setReadOnly( true ); - Layout1->addWidget(GroupPoints, 1, 0); + Layout1->addWidget(GroupPoints, 2, 0); /***************************************************************/ /* Initialisations */ - myBuildGUI = theBuildGUI; Init(); } @@ -90,14 +92,12 @@ void BuildGUI_EdgeDlg::Init() { /* init variables */ myEditCurrentArgument = GroupPoints->LineEdit1; + GroupPoints->LineEdit1->setReadOnly( true ); + GroupPoints->LineEdit2->setReadOnly( true ); - myPoint1.SetCoord(0.0, 0.0, 0.0); - myPoint2.SetCoord(0.0, 0.0, 0.0); myOkPoint1 = myOkPoint2 = false; - /* first filter used */ - myVertexFilter = new GEOM_ShapeTypeFilter(TopAbs_VERTEX, myGeom); - mySelection->AddFilter(myVertexFilter); + globalSelection( GEOM_POINT ); /* signals and slots connections */ connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); @@ -111,11 +111,7 @@ void BuildGUI_EdgeDlg::Init() connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ; - /* displays Dialog */ - GroupPoints->show(); - this->show(); - - return; + initName( tr( "GEOM_EDGE") ); } @@ -125,9 +121,8 @@ void BuildGUI_EdgeDlg::Init() //================================================================================= void BuildGUI_EdgeDlg::ClickOnOk() { - this->ClickOnApply(); - ClickOnCancel(); - return; + if ( ClickOnApply() ) + ClickOnCancel(); } @@ -135,17 +130,13 @@ void BuildGUI_EdgeDlg::ClickOnOk() // function : ClickOnApply() // purpose : //================================================================================= -void BuildGUI_EdgeDlg::ClickOnApply() +bool BuildGUI_EdgeDlg::ClickOnApply() { - QAD_Application::getDesktop()->putInfo(tr("")); - if (mySimulationTopoDs.IsNull()) - return; - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); + if ( !onAccept() ) + return false; - if(myOkPoint1 && myOkPoint2) - myBuildGUI->MakeLinearEdgeAndDisplay(myPoint1, myPoint2); - return; + initName(); + return true; } @@ -155,13 +146,10 @@ void BuildGUI_EdgeDlg::ClickOnApply() //================================================================================= void BuildGUI_EdgeDlg::SelectionIntoArgument() { - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); + erasePreview(); myEditCurrentArgument->setText(""); - QString aString = ""; /* name of selection */ - int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString); - if(nbSel != 1) { + if(mySelection->IObjectCount() != 1) { if(myEditCurrentArgument == GroupPoints->LineEdit1) myOkPoint1 = false; else if(myEditCurrentArgument == GroupPoints->LineEdit2) @@ -170,22 +158,24 @@ void BuildGUI_EdgeDlg::SelectionIntoArgument() } // nbSel == 1 - TopoDS_Shape S; - if(!myGeomBase->GetTopoFromSelection(mySelection, S)) - return; + Standard_Boolean testResult = Standard_False; + GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(mySelection->firstIObject(), testResult ); - if(myEditCurrentArgument == GroupPoints->LineEdit1 && myGeomBase->VertexToPoint(S, myPoint1)) { - myEditCurrentArgument->setText(aString); + if(!testResult) + return; + + if(myEditCurrentArgument == GroupPoints->LineEdit1) { + myPoint1 = aSelectedObject; myOkPoint1 = true; } - else if(myEditCurrentArgument == GroupPoints->LineEdit2 && myGeomBase->VertexToPoint(S, myPoint2)) { - myEditCurrentArgument->setText(aString); + else if(myEditCurrentArgument == GroupPoints->LineEdit2) { + myPoint2 = aSelectedObject; myOkPoint2 = true; } - - if(myOkPoint1 && myOkPoint2 && myPoint1.Distance(myPoint2) > Precision::Confusion()) - this->MakeEdgeSimulationAndDisplay(); - return; + + myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) ); + + displayPreview(); } @@ -196,15 +186,11 @@ void BuildGUI_EdgeDlg::SelectionIntoArgument() void BuildGUI_EdgeDlg::LineEditReturnPressed() { QLineEdit* send = (QLineEdit*)sender(); - if(send == GroupPoints->LineEdit1) - myEditCurrentArgument = GroupPoints->LineEdit1; - else if (send == GroupPoints->LineEdit2) - myEditCurrentArgument = GroupPoints->LineEdit2; - else - return; - - GEOMBase_Skeleton::LineEditReturnPressed(); - return; + if(send == GroupPoints->LineEdit1 || send == GroupPoints->LineEdit2) + { + myEditCurrentArgument = send; + GEOMBase_Skeleton::LineEditReturnPressed(); + } } @@ -214,21 +200,21 @@ void BuildGUI_EdgeDlg::LineEditReturnPressed() //================================================================================= void BuildGUI_EdgeDlg::SetEditCurrentArgument() { + QPushButton* send = (QPushButton*)sender(); - mySelection->ClearFilters(); + globalSelection(); if(send == GroupPoints->PushButton1) { - GroupPoints->LineEdit1->setFocus(); myEditCurrentArgument = GroupPoints->LineEdit1; + globalSelection( GEOM_POINT ); } else if(send == GroupPoints->PushButton2) { - GroupPoints->LineEdit2->setFocus(); myEditCurrentArgument = GroupPoints->LineEdit2; + globalSelection( GEOM_POINT ); } - mySelection->AddFilter(myVertexFilter); - this->SelectionIntoArgument(); - - return; + + myEditCurrentArgument->setFocus(); + SelectionIntoArgument(); } @@ -240,10 +226,8 @@ void BuildGUI_EdgeDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - mySelection->AddFilter(myVertexFilter); - if(!mySimulationTopoDs.IsNull()) - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - return; + globalSelection( GEOM_POINT ); + displayPreview(); } @@ -253,29 +237,40 @@ void BuildGUI_EdgeDlg::ActivateThisDialog() //================================================================================= void BuildGUI_EdgeDlg::enterEvent(QEvent* e) { - if (GroupConstructors->isEnabled()) - return; - this->ActivateThisDialog(); - return; + if ( !GroupConstructors->isEnabled() ) + ActivateThisDialog(); } +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr BuildGUI_EdgeDlg::createOperation() +{ + return getGeomEngine()->GetIShapesOperations( getStudyId() ); +} //================================================================================= -// function : MakeMirrorSimulationAndDisplay() -// purpose : S1 is a shape and S2 a mirror. +// function : isValid +// purpose : //================================================================================= -void BuildGUI_EdgeDlg::MakeEdgeSimulationAndDisplay() +bool BuildGUI_EdgeDlg::isValid( QString& ) { - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); - - try { - mySimulationTopoDs = BRepBuilderAPI_MakeEdge(myPoint1, myPoint2).Shape(); - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - } - catch(Standard_Failure) { - MESSAGE("Exception catched in MakeEdgeSimulationAndDisplay"); - return; - } - return; + return myOkPoint1 && myOkPoint2; +} + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool BuildGUI_EdgeDlg::execute( ObjectList& objects ) +{ + GEOM::GEOM_Object_var anObj; + + anObj = GEOM::GEOM_IShapesOperations::_narrow( getOperation() )->MakeEdge( myPoint1, myPoint2 ); + + if ( !anObj->_is_nil() ) + objects.push_back( anObj._retn() ); + + return true; } diff --git a/src/BuildGUI/BuildGUI_EdgeDlg.h b/src/BuildGUI/BuildGUI_EdgeDlg.h index 18c34e67e..b86590bff 100644 --- a/src/BuildGUI/BuildGUI_EdgeDlg.h +++ b/src/BuildGUI/BuildGUI_EdgeDlg.h @@ -32,10 +32,6 @@ #include "GEOMBase_Skeleton.h" #include "DlgRef_2Sel_QTD.h" -#include "BuildGUI.h" - -#include "GEOM_ShapeTypeFilter.hxx" - //================================================================================= // class : BuildGUI_EdgeDlg // purpose : @@ -45,27 +41,28 @@ class BuildGUI_EdgeDlg : public GEOMBase_Skeleton Q_OBJECT public: - BuildGUI_EdgeDlg(QWidget* parent = 0, const char* name = 0, BuildGUI* theBuildGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + BuildGUI_EdgeDlg(QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); ~BuildGUI_EdgeDlg(); +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& msg ); + virtual bool execute( ObjectList& objects ); + private : void Init(); void enterEvent(QEvent* e); - void MakeEdgeSimulationAndDisplay(); - - BuildGUI* myBuildGUI; - Handle(GEOM_ShapeTypeFilter) myVertexFilter; /* Filter selection */ - - gp_Pnt myPoint1; /* Points containing the vector */ - gp_Pnt myPoint2; + + GEOM::GEOM_Object_var myPoint1, myPoint2; /* Points containing the edge */ bool myOkPoint1; /* true when myPoint is defined */ bool myOkPoint2; - + DlgRef_2Sel_QTD* GroupPoints; private slots: void ClickOnOk(); - void ClickOnApply(); + bool ClickOnApply(); void ActivateThisDialog(); void LineEditReturnPressed(); void SelectionIntoArgument(); diff --git a/src/BuildGUI/BuildGUI_FaceDlg.cxx b/src/BuildGUI/BuildGUI_FaceDlg.cxx index 197231414..2b76cc7cf 100644 --- a/src/BuildGUI/BuildGUI_FaceDlg.cxx +++ b/src/BuildGUI/BuildGUI_FaceDlg.cxx @@ -28,6 +28,11 @@ using namespace std; #include "BuildGUI_FaceDlg.h" +#include "QAD_Desktop.h" +#include "GEOMImpl_Types.hxx" + +//Qt includes +#include //================================================================================= // class : BuildGUI_FaceDlg() @@ -36,7 +41,7 @@ using namespace std; // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -BuildGUI_FaceDlg::BuildGUI_FaceDlg(QWidget* parent, const char* name, BuildGUI* theBuildGUI, SALOME_Selection* Sel, bool modal, WFlags fl) +BuildGUI_FaceDlg::BuildGUI_FaceDlg(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_BUILD_FACE"))); @@ -50,17 +55,16 @@ BuildGUI_FaceDlg::BuildGUI_FaceDlg(QWidget* parent, const char* name, BuildGUI* RadioButton2->close(TRUE); RadioButton3->close(TRUE); - GroupPoints = new DlgRef_1Sel1Check_QTD(this, "GroupPoints"); - GroupPoints->GroupBox1->setTitle(tr("GEOM_FACE_FFW")); - GroupPoints->TextLabel1->setText(tr("GEOM_WIRES")); - GroupPoints->CheckButton1->setText(tr("GEOM_FACE_OPT")); - GroupPoints->PushButton1->setPixmap(image1); + GroupWire = new DlgRef_1Sel1Check_QTD(this, "GroupWire"); + GroupWire->GroupBox1->setTitle(tr("GEOM_FACE_FFW")); + GroupWire->TextLabel1->setText(tr("GEOM_WIRES")); + GroupWire->CheckButton1->setText(tr("GEOM_FACE_OPT")); + GroupWire->PushButton1->setPixmap(image1); - Layout1->addWidget(GroupPoints, 1, 0); + Layout1->addWidget(GroupWire, 2, 0); /***************************************************************/ /* Initialisations */ - myBuildGUI = theBuildGUI; Init(); } @@ -82,26 +86,21 @@ BuildGUI_FaceDlg::~BuildGUI_FaceDlg() void BuildGUI_FaceDlg::Init() { /* init variables */ - myEditCurrentArgument = GroupPoints->LineEdit1; - GroupPoints->CheckButton1->setChecked(TRUE); + myEditCurrentArgument = GroupWire->LineEdit1; + GroupWire->LineEdit1->setReadOnly( true ); - myOkListShapes = false; + GroupWire->CheckButton1->setChecked(TRUE); - myWireFilter = new GEOM_ShapeTypeFilter(TopAbs_WIRE, myGeom); - mySelection->AddFilter(myWireFilter); /* first filter used */ + globalSelection( GEOM_WIRE ); /* signals and slots connections */ connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); - connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupWire->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(GroupWire->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ; - /* displays Dialog */ - GroupPoints->show(); - this->show(); - - return; + initName(tr("GEOM_FACE")); } @@ -111,9 +110,8 @@ void BuildGUI_FaceDlg::Init() //================================================================================= void BuildGUI_FaceDlg::ClickOnOk() { - this->ClickOnApply(); - ClickOnCancel(); - return; + if ( ClickOnApply() ) + ClickOnCancel(); } @@ -121,12 +119,13 @@ void BuildGUI_FaceDlg::ClickOnOk() // function : ClickOnApply() // purpose : //================================================================================= -void BuildGUI_FaceDlg::ClickOnApply() +bool BuildGUI_FaceDlg::ClickOnApply() { - QAD_Application::getDesktop()->putInfo(tr("")); - if(myOkListShapes) - myBuildGUI->MakeFaceAndDisplay(myListShapes, GroupPoints->CheckButton1->isChecked()); - return; + if ( !onAccept() ) + return false; + + initName(); + return true; } @@ -137,21 +136,25 @@ void BuildGUI_FaceDlg::ClickOnApply() void BuildGUI_FaceDlg::SelectionIntoArgument() { myEditCurrentArgument->setText(""); - QString aString = ""; /* name of selection */ - - myOkListShapes = false; - int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString); - if(nbSel == 0) + QString aName; + + int aNbSel = GEOMBase::GetNameOfSelectedIObjects(mySelection, aName); + + if(aNbSel < 1) + { + myWires.length(0); + return; + } + + GEOMBase::ConvertListOfIOInListOfGO(mySelection->StoredIObjects(), myWires); + if (!myWires.length()) return; - if(nbSel != 1) - aString = tr("%1_objects").arg(nbSel); - - myGeomBase->ConvertListOfIOInListOfIOR(mySelection->StoredIObjects(), myListShapes); + if(aNbSel != 1) + aName = tr("%1_wires").arg(aNbSel); + + myEditCurrentArgument->setText( aName ); - myEditCurrentArgument->setText(aString); - myOkListShapes = true; - /* no simulation */ - return; + myEditCurrentArgument->setText( aName ); } @@ -161,11 +164,15 @@ void BuildGUI_FaceDlg::SelectionIntoArgument() //================================================================================= void BuildGUI_FaceDlg::SetEditCurrentArgument() { - GroupPoints->LineEdit1->setFocus(); - mySelection->ClearFilters(); - mySelection->AddFilter(myWireFilter); - this->SelectionIntoArgument(); - return; + QPushButton* send = (QPushButton*)sender(); + if (send != GroupWire->PushButton1) + return; + + globalSelection( GEOM_WIRE ); + myEditCurrentArgument = GroupWire->LineEdit1; + + myEditCurrentArgument->setFocus(); + SelectionIntoArgument(); } @@ -177,8 +184,7 @@ void BuildGUI_FaceDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - mySelection->AddFilter(myWireFilter); - return; + globalSelection( GEOM_WIRE ); } @@ -188,8 +194,43 @@ void BuildGUI_FaceDlg::ActivateThisDialog() //================================================================================= void BuildGUI_FaceDlg::enterEvent(QEvent* e) { - if (GroupConstructors->isEnabled()) - return; - this->ActivateThisDialog(); - return; + if ( !GroupConstructors->isEnabled() ) + ActivateThisDialog(); } + +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr BuildGUI_FaceDlg::createOperation() +{ + return getGeomEngine()->GetIShapesOperations( getStudyId() ); +} + +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool BuildGUI_FaceDlg::isValid( QString& ) +{ + return (myWires.length() != 0); +} + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool BuildGUI_FaceDlg::execute( ObjectList& objects ) +{ + GEOM::GEOM_Object_var anObj; + + bool isPlanarWanted = GroupWire->CheckButton1->isChecked(); + anObj = GEOM::GEOM_IShapesOperations::_narrow( + getOperation() )->MakeFaceWires( myWires, isPlanarWanted ); + + if ( !anObj->_is_nil() ) + objects.push_back( anObj._retn() ); + + return true; +} + diff --git a/src/BuildGUI/BuildGUI_FaceDlg.h b/src/BuildGUI/BuildGUI_FaceDlg.h index 86ce40a13..d91ba714c 100644 --- a/src/BuildGUI/BuildGUI_FaceDlg.h +++ b/src/BuildGUI/BuildGUI_FaceDlg.h @@ -32,10 +32,6 @@ #include "GEOMBase_Skeleton.h" #include "DlgRef_1Sel1Check_QTD.h" -#include "BuildGUI.h" - -#include "GEOM_ShapeTypeFilter.hxx" - //================================================================================= // class : BuildGUI_FaceDlg // purpose : @@ -45,26 +41,26 @@ class BuildGUI_FaceDlg : public GEOMBase_Skeleton Q_OBJECT public: - BuildGUI_FaceDlg(QWidget* parent = 0, const char* name = 0, BuildGUI* theBuildGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + BuildGUI_FaceDlg(QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); ~BuildGUI_FaceDlg(); +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& msg ); + virtual bool execute( ObjectList& objects ); + private: void Init(); void enterEvent(QEvent* e); - - BuildGUI* myBuildGUI; - - /* Filter selection */ - Handle(GEOM_ShapeTypeFilter) myWireFilter; - - GEOM::GEOM_Gen::ListOfIOR myListShapes; - bool myOkListShapes; /* to check when arguments is defined */ - - DlgRef_1Sel1Check_QTD* GroupPoints; + + GEOM::ListOfGO myWires; + + DlgRef_1Sel1Check_QTD* GroupWire; private slots: void ClickOnOk(); - void ClickOnApply(); + bool ClickOnApply(); void ActivateThisDialog(); void SelectionIntoArgument(); void SetEditCurrentArgument(); diff --git a/src/BuildGUI/BuildGUI_ShellDlg.cxx b/src/BuildGUI/BuildGUI_ShellDlg.cxx index 1f4df38cf..ff65505a6 100644 --- a/src/BuildGUI/BuildGUI_ShellDlg.cxx +++ b/src/BuildGUI/BuildGUI_ShellDlg.cxx @@ -26,11 +26,10 @@ // Module : GEOM // $Header: -using namespace std; #include "BuildGUI_ShellDlg.h" -#include "BuildGUI.h" #include "QAD_Desktop.h" +#include "GEOMImpl_Types.hxx" //================================================================================= // class : BuildGUI_ShellDlg() @@ -39,7 +38,7 @@ using namespace std; // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -BuildGUI_ShellDlg::BuildGUI_ShellDlg(QWidget* parent, const char* name, BuildGUI* theBuildGUI, SALOME_Selection* Sel, bool modal, WFlags fl) +BuildGUI_ShellDlg::BuildGUI_ShellDlg(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_BUILD_SHELL"))); @@ -57,12 +56,12 @@ BuildGUI_ShellDlg::BuildGUI_ShellDlg(QWidget* parent, const char* name, BuildGUI GroupShell->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); GroupShell->TextLabel1->setText(tr("GEOM_OBJECTS")); GroupShell->PushButton1->setPixmap(image1); + GroupShell->LineEdit1->setReadOnly( true ); - Layout1->addWidget(GroupShell, 1, 0); + Layout1->addWidget(GroupShell, 2, 0); /***************************************************************/ /* Initialisations */ - myBuildGUI = theBuildGUI; Init(); } @@ -85,11 +84,14 @@ void BuildGUI_ShellDlg::Init() { /* init variables */ myEditCurrentArgument = GroupShell->LineEdit1; - myOkListShapes = false; - - myFaceFilter = new GEOM_ShapeTypeFilter(TopAbs_FACE, myGeom); - /* Filter for the next selection */ - mySelection->AddFilter(myFaceFilter) ; + GroupShell->LineEdit1->setReadOnly( true ); + + myOkFacesAndShells = false; + + TColStd_MapOfInteger aMap; + aMap.Add(GEOM_SHELL); + aMap.Add(GEOM_FACE); + globalSelection( aMap ); /* signals and slots connections */ connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); @@ -99,11 +101,7 @@ void BuildGUI_ShellDlg::Init() connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - /* displays Dialog */ - GroupShell->show(); - this->show(); - - return; + initName(tr("GEOM_SHELL")); } @@ -113,9 +111,8 @@ void BuildGUI_ShellDlg::Init() //================================================================================= void BuildGUI_ShellDlg::ClickOnOk() { - this->ClickOnApply(); - ClickOnCancel(); - return ; + if ( ClickOnApply() ) + ClickOnCancel(); } @@ -123,13 +120,13 @@ void BuildGUI_ShellDlg::ClickOnOk() // function : ClickOnApply() // purpose : //================================================================================= -void BuildGUI_ShellDlg::ClickOnApply() +bool BuildGUI_ShellDlg::ClickOnApply() { - QAD_Application::getDesktop()->putInfo(tr("")); + if ( !onAccept() ) + return false; - if(myOkListShapes) - myBuildGUI->MakeShellAndDisplay(myListShapes); - return; + initName(); + return true; } @@ -139,21 +136,22 @@ void BuildGUI_ShellDlg::ClickOnApply() //================================================================================= void BuildGUI_ShellDlg::SelectionIntoArgument() { - myEditCurrentArgument->setText(""); - QString aString = ""; + myEditCurrentArgument->setText( "" ); + QString aString; - myOkListShapes = false; - int nbSel = mySelection->IObjectCount(); - if(nbSel == 0) + myOkFacesAndShells = false; + int nbSel = GEOMBase::GetNameOfSelectedIObjects( mySelection, aString, true ); + if ( nbSel == 0 ) return; + if ( nbSel != 1 ) + aString = QString( "%1_objects ").arg( nbSel ); - aString = tr("%1_objects").arg(nbSel); - - myGeomBase->ConvertListOfIOInListOfIOR(mySelection->StoredIObjects(), myListShapes); - myEditCurrentArgument->setText(aString); - myOkListShapes = true; + GEOMBase::ConvertListOfIOInListOfGO( mySelection->StoredIObjects(), myFacesAndShells, true ); + if ( !myFacesAndShells.length() ) + return; - return; + myEditCurrentArgument->setText( aString ); + myOkFacesAndShells = true; } @@ -163,11 +161,18 @@ void BuildGUI_ShellDlg::SelectionIntoArgument() //================================================================================= void BuildGUI_ShellDlg::SetEditCurrentArgument() { - mySelection->ClearFilters(); - GroupShell->LineEdit1->setFocus(); - mySelection->AddFilter(myFaceFilter); - this->SelectionIntoArgument(); - return; + QPushButton* send = (QPushButton*)sender(); + if (send != GroupShell->PushButton1) + return; + + TColStd_MapOfInteger aMap; + aMap.Add(GEOM_SHELL); + aMap.Add(GEOM_FACE); + globalSelection( aMap ); + myEditCurrentArgument = GroupShell->LineEdit1; + + myEditCurrentArgument->setFocus(); + SelectionIntoArgument(); } @@ -179,8 +184,10 @@ void BuildGUI_ShellDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - mySelection->AddFilter(myFaceFilter); - return; + TColStd_MapOfInteger aMap; + aMap.Add(GEOM_SHELL); + aMap.Add(GEOM_FACE); + globalSelection( aMap ); } @@ -190,8 +197,42 @@ void BuildGUI_ShellDlg::ActivateThisDialog() //================================================================================= void BuildGUI_ShellDlg::enterEvent(QEvent* e) { - if(GroupConstructors->isEnabled()) - return; - this->ActivateThisDialog(); - return; + if ( !GroupConstructors->isEnabled() ) + ActivateThisDialog(); +} + +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr BuildGUI_ShellDlg::createOperation() +{ + return getGeomEngine()->GetIShapesOperations( getStudyId() ); } + +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool BuildGUI_ShellDlg::isValid( QString& ) +{ + return myOkFacesAndShells; +} + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool BuildGUI_ShellDlg::execute( ObjectList& objects ) +{ + GEOM::GEOM_Object_var anObj; + + anObj = GEOM::GEOM_IShapesOperations::_narrow( + getOperation() )->MakeShell( myFacesAndShells ); + + if ( !anObj->_is_nil() ) + objects.push_back( anObj._retn() ); + + return true; +} + diff --git a/src/BuildGUI/BuildGUI_ShellDlg.h b/src/BuildGUI/BuildGUI_ShellDlg.h index 3bb860857..3c3c57c0b 100644 --- a/src/BuildGUI/BuildGUI_ShellDlg.h +++ b/src/BuildGUI/BuildGUI_ShellDlg.h @@ -32,10 +32,6 @@ #include "GEOMBase_Skeleton.h" #include "DlgRef_1Sel_QTD.h" -#include "BuildGUI.h" - -#include "GEOM_ShapeTypeFilter.hxx" - //================================================================================= // class : BuildGUI_ShellDlg // purpose : @@ -45,25 +41,29 @@ class BuildGUI_ShellDlg : public GEOMBase_Skeleton Q_OBJECT public: - BuildGUI_ShellDlg(QWidget* parent = 0, const char* name = 0, BuildGUI* theBuildGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + BuildGUI_ShellDlg(QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); ~BuildGUI_ShellDlg(); +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& msg ); + virtual bool execute( ObjectList& objects ); + private: void Init(); void enterEvent(QEvent * e); - BuildGUI* myBuildGUI; - - Handle(GEOM_ShapeTypeFilter) myFaceFilter; /* Filters selection */ - GEOM::GEOM_Gen::ListOfIOR myListShapes; - bool myOkListShapes; /* to check when arguments is defined */ + GEOM::ListOfGO myFacesAndShells; + bool myOkFacesAndShells; /* to check when arguments is defined */ DlgRef_1Sel_QTD* GroupShell; private slots: void ClickOnOk(); - void ClickOnApply(); + bool ClickOnApply(); void SetEditCurrentArgument(); + void LineEditReturnPressed(); void SelectionIntoArgument(); void ActivateThisDialog(); diff --git a/src/BuildGUI/BuildGUI_SolidDlg.cxx b/src/BuildGUI/BuildGUI_SolidDlg.cxx index d47526194..cdd99d738 100644 --- a/src/BuildGUI/BuildGUI_SolidDlg.cxx +++ b/src/BuildGUI/BuildGUI_SolidDlg.cxx @@ -26,11 +26,13 @@ // Module : GEOM // $Header: -using namespace std; #include "BuildGUI_SolidDlg.h" -#include "BuildGUI.h" #include "QAD_Desktop.h" +#include "GEOMImpl_Types.hxx" + +//Qt includes +#include //================================================================================= // class : BuildGUI_SolidDlg() @@ -39,7 +41,7 @@ using namespace std; // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -BuildGUI_SolidDlg::BuildGUI_SolidDlg(QWidget* parent, const char* name, BuildGUI* theBuildGUI, SALOME_Selection* Sel, bool modal, WFlags fl) +BuildGUI_SolidDlg::BuildGUI_SolidDlg(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_BUILD_SOLID"))); @@ -53,16 +55,17 @@ BuildGUI_SolidDlg::BuildGUI_SolidDlg(QWidget* parent, const char* name, BuildGUI RadioButton2->close(TRUE); RadioButton3->close(TRUE); - GroupSolid = new DlgRef_1Sel_QTD(this, "GroupSolid"); + GroupSolid = new DlgRef_1Sel1Check_QTD(this, "GroupSolid"); GroupSolid->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); GroupSolid->TextLabel1->setText(tr("GEOM_OBJECTS")); + GroupSolid->CheckButton1->setText(tr("GEOM_CREATE_SINGLE_SOLID")); GroupSolid->PushButton1->setPixmap(image1); + GroupSolid->LineEdit1->setReadOnly( true ); - Layout1->addWidget(GroupSolid, 1, 0); + Layout1->addWidget(GroupSolid, 2, 0); /***************************************************************/ /* Initialisations */ - myBuildGUI = theBuildGUI; Init(); } @@ -85,25 +88,23 @@ void BuildGUI_SolidDlg::Init() { /* init variables */ myEditCurrentArgument = GroupSolid->LineEdit1; - myOkListShapes = false; + GroupSolid->LineEdit1->setReadOnly( true ); + GroupSolid->CheckButton1->setChecked( true ); + + myOkShells = false; - myShellFilter = new GEOM_ShapeTypeFilter(TopAbs_SHELL, myGeom); - /* filter for next selection */ - mySelection->AddFilter(myShellFilter); + globalSelection( GEOM_SHELL ); /* signals and slots connections */ connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); connect(GroupSolid->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupSolid->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(EnableNameField(bool))); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - - /* displays Dialog */ - GroupSolid->show(); - this->show(); - return; + initName(tr("GEOM_SOLID")); } @@ -113,23 +114,21 @@ void BuildGUI_SolidDlg::Init() //================================================================================= void BuildGUI_SolidDlg::ClickOnOk() { - this->ClickOnApply(); - ClickOnCancel(); - return ; + if ( ClickOnApply() ) + ClickOnCancel(); } //================================================================================= // function : ClickOnApply() // purpose : //================================================================================= -void BuildGUI_SolidDlg::ClickOnApply() +bool BuildGUI_SolidDlg::ClickOnApply() { - QAD_Application::getDesktop()->putInfo(tr("")); - - if(myOkListShapes) - myBuildGUI->MakeSolidAndDisplay(myListShapes); + if ( !onAccept() ) + return false; - return; + initName(); + return true; } @@ -141,19 +140,20 @@ void BuildGUI_SolidDlg::SelectionIntoArgument() { myEditCurrentArgument->setText(""); QString aString = ""; - - myOkListShapes = false; - int nbSel = mySelection->IObjectCount(); + + myOkShells = false; + int nbSel = GEOMBase::GetNameOfSelectedIObjects(mySelection, aString); if (nbSel == 0) return; - - aString = tr("%1_objects").arg(nbSel); + if(nbSel != 1) + aString = tr("%1_objects").arg(nbSel); + + GEOMBase::ConvertListOfIOInListOfGO(mySelection->StoredIObjects(), myShells); + if (!myShells.length()) + return; - myGeomBase->ConvertListOfIOInListOfIOR(mySelection->StoredIObjects(), myListShapes); myEditCurrentArgument->setText(aString); - myOkListShapes = true; - - return ; + myOkShells = true; } //================================================================================= @@ -163,12 +163,14 @@ void BuildGUI_SolidDlg::SelectionIntoArgument() void BuildGUI_SolidDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); - mySelection->ClearFilters() ; - GroupSolid->LineEdit1->setFocus(); + if(send != GroupSolid->PushButton1) + return; + + globalSelection( GEOM_SHELL ); myEditCurrentArgument = GroupSolid->LineEdit1; - mySelection->AddFilter(myShellFilter); + + myEditCurrentArgument->setFocus(); SelectionIntoArgument(); - return; } @@ -180,8 +182,7 @@ void BuildGUI_SolidDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - mySelection->AddFilter(myShellFilter); - return; + globalSelection( GEOM_SHELL ); } @@ -191,8 +192,66 @@ void BuildGUI_SolidDlg::ActivateThisDialog() //================================================================================= void BuildGUI_SolidDlg::enterEvent(QEvent* e) { - if (GroupConstructors->isEnabled()) - return; - this->ActivateThisDialog(); - return; + if ( !GroupConstructors->isEnabled() ) + ActivateThisDialog(); +} + + +//================================================================================= +// function : EnableNameField() +// purpose : +//================================================================================= +void BuildGUI_SolidDlg::EnableNameField(bool toEnable) +{ + this->GroupBoxName->setEnabled(toEnable); +} + +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr BuildGUI_SolidDlg::createOperation() +{ + return getGeomEngine()->GetIShapesOperations( getStudyId() ); } + +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool BuildGUI_SolidDlg::isValid( QString& ) +{ + return myOkShells; +} + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool BuildGUI_SolidDlg::execute( ObjectList& objects ) +{ + bool toCreateSingleSolid = GroupSolid->CheckButton1->isChecked(); + + if ( toCreateSingleSolid ) + { + GEOM::GEOM_Object_var anObj = GEOM::GEOM_IShapesOperations::_narrow( + getOperation() )->MakeSolidShells( myShells ); + + if ( !anObj->_is_nil() ) + objects.push_back( anObj._retn() ); + } + else + { + for ( int i = 0, n = myShells.length(); i< n; i++ ) + { + GEOM::GEOM_Object_var anObj = GEOM::GEOM_IShapesOperations::_narrow( + getOperation() )->MakeSolidShell( myShells[ i ] ); + + if ( !anObj->_is_nil() ) + objects.push_back( anObj._retn() ); + } + } + + return true; +} + diff --git a/src/BuildGUI/BuildGUI_SolidDlg.h b/src/BuildGUI/BuildGUI_SolidDlg.h index 02ac32058..a767fba68 100644 --- a/src/BuildGUI/BuildGUI_SolidDlg.h +++ b/src/BuildGUI/BuildGUI_SolidDlg.h @@ -30,11 +30,7 @@ #define DIALOGBOX_SOLID_H #include "GEOMBase_Skeleton.h" -#include "DlgRef_1Sel_QTD.h" - -#include "BuildGUI.h" - -#include "GEOM_ShapeTypeFilter.hxx" +#include "DlgRef_1Sel1Check_QTD.h" //================================================================================= // class : BuildGUI_SolidDlg @@ -45,28 +41,33 @@ class BuildGUI_SolidDlg : public GEOMBase_Skeleton Q_OBJECT public: - BuildGUI_SolidDlg(QWidget* parent = 0, const char* name = 0, BuildGUI* theBuildGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + BuildGUI_SolidDlg(QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); ~BuildGUI_SolidDlg(); +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& msg ); + virtual bool execute( ObjectList& objects ); + private: void Init(); void enterEvent(QEvent * e); - BuildGUI* myBuildGUI; - - Handle(GEOM_ShapeTypeFilter) myShellFilter; /* filter for selection */ - GEOM::GEOM_Gen::ListOfIOR myListShapes; - bool myOkListShapes; /* to check when arguments is defined */ + GEOM::ListOfGO myShells; + bool myOkShells; /* to check when arguments is defined and + all shells are closed */ - DlgRef_1Sel_QTD* GroupSolid; + DlgRef_1Sel1Check_QTD* GroupSolid; private slots: void ClickOnOk(); - void ClickOnApply(); + bool ClickOnApply(); void SetEditCurrentArgument(); void LineEditReturnPressed(); void SelectionIntoArgument(); void ActivateThisDialog(); + void EnableNameField(bool toEnable); }; diff --git a/src/BuildGUI/BuildGUI_WireDlg.cxx b/src/BuildGUI/BuildGUI_WireDlg.cxx index 8b2ea49f9..f7f52d8ad 100644 --- a/src/BuildGUI/BuildGUI_WireDlg.cxx +++ b/src/BuildGUI/BuildGUI_WireDlg.cxx @@ -26,8 +26,9 @@ // Module : GEOM // $Header$ -using namespace std; #include "BuildGUI_WireDlg.h" +#include "QAD_Desktop.h" +#include "GEOMImpl_Types.hxx" //================================================================================= // class : BuildGUI_WireDlg() @@ -36,7 +37,7 @@ using namespace std; // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -BuildGUI_WireDlg::BuildGUI_WireDlg(QWidget* parent, const char* name, BuildGUI* theBuildGUI, SALOME_Selection* Sel, bool modal, WFlags fl) +BuildGUI_WireDlg::BuildGUI_WireDlg(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_BUILD_WIRE"))); @@ -54,12 +55,12 @@ BuildGUI_WireDlg::BuildGUI_WireDlg(QWidget* parent, const char* name, BuildGUI* GroupPoints->GroupBox1->setTitle(tr("GEOM_WIRE_CONNECT")); GroupPoints->TextLabel1->setText(tr("GEOM_OBJECTS")); GroupPoints->PushButton1->setPixmap(image1); + GroupPoints->LineEdit1->setReadOnly( true ); - Layout1->addWidget(GroupPoints, 1, 0); + Layout1->addWidget(GroupPoints, 2, 0); /***************************************************************/ /* Initialisations */ - myBuildGUI = theBuildGUI; Init(); } @@ -82,19 +83,22 @@ void BuildGUI_WireDlg::Init() { /* init variables */ myEditCurrentArgument = GroupPoints->LineEdit1; - myOkListShapes = false; + GroupPoints->LineEdit1->setReadOnly( true ); + + myOkEdgesAndWires = false; + + TColStd_MapOfInteger aMap; + aMap.Add(GEOM_WIRE); + aMap.Add(GEOM_EDGE); + globalSelection( aMap ); /* signals and slots connections */ connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); - connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ; - /* displays Dialog */ - GroupPoints->show(); - this->show(); - - return; + initName(tr("GEOM_WIRE")); } @@ -104,9 +108,8 @@ void BuildGUI_WireDlg::Init() //================================================================================= void BuildGUI_WireDlg::ClickOnOk() { - this->ClickOnApply(); - ClickOnCancel(); - return; + if ( ClickOnApply() ) + ClickOnCancel(); } @@ -114,12 +117,13 @@ void BuildGUI_WireDlg::ClickOnOk() // function : ClickOnApply() // purpose : //================================================================================= -void BuildGUI_WireDlg::ClickOnApply() +bool BuildGUI_WireDlg::ClickOnApply() { - QAD_Application::getDesktop()->putInfo(tr("")); - if(myOkListShapes) - myBuildGUI->MakeWireAndDisplay(myListShapes); - return; + if ( !onAccept() ) + return false; + + initName(); + return true; } @@ -132,17 +136,20 @@ void BuildGUI_WireDlg::SelectionIntoArgument() myEditCurrentArgument->setText(""); QString aString = ""; /* name of selection */ - int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString); - if(nbSel < 1) { - myOkListShapes = false; + myOkEdgesAndWires = false; + int nbSel = GEOMBase::GetNameOfSelectedIObjects(mySelection, aString); + + if(nbSel == 0) return; - } - - myGeomBase->ConvertListOfIOInListOfIOR(mySelection->StoredIObjects(), myListShapes); + if(nbSel != 1) + aString = tr("%1_objects").arg(nbSel); + + GEOMBase::ConvertListOfIOInListOfGO(mySelection->StoredIObjects(), myEdgesAndWires); + if (!myEdgesAndWires.length()) + return; + myEditCurrentArgument->setText(aString); - myOkListShapes = true; - /* no simulation */ - return; + myOkEdgesAndWires = true; } @@ -152,9 +159,18 @@ void BuildGUI_WireDlg::SelectionIntoArgument() //================================================================================= void BuildGUI_WireDlg::SetEditCurrentArgument() { - GroupPoints->LineEdit1->setFocus(); - this->SelectionIntoArgument(); - return; + QPushButton* send = (QPushButton*)sender(); + if (send != GroupPoints->PushButton1) + return; + + TColStd_MapOfInteger aMap; + aMap.Add(GEOM_WIRE); + aMap.Add(GEOM_EDGE); + globalSelection( aMap ); + myEditCurrentArgument = GroupPoints->LineEdit1; + + myEditCurrentArgument->setFocus(); + SelectionIntoArgument(); } @@ -166,7 +182,10 @@ void BuildGUI_WireDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - return; + TColStd_MapOfInteger aMap; + aMap.Add(GEOM_WIRE); + aMap.Add(GEOM_EDGE); + globalSelection( aMap ); } @@ -176,8 +195,42 @@ void BuildGUI_WireDlg::ActivateThisDialog() //================================================================================= void BuildGUI_WireDlg::enterEvent(QEvent* e) { - if (GroupConstructors->isEnabled()) - return; - this->ActivateThisDialog(); - return; + if ( !GroupConstructors->isEnabled() ) + ActivateThisDialog(); +} + +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr BuildGUI_WireDlg::createOperation() +{ + return getGeomEngine()->GetIShapesOperations( getStudyId() ); +} + +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool BuildGUI_WireDlg::isValid( QString& ) +{ + return myOkEdgesAndWires; +} + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool BuildGUI_WireDlg::execute( ObjectList& objects ) +{ + GEOM::GEOM_Object_var anObj; + + anObj = GEOM::GEOM_IShapesOperations::_narrow( + getOperation() )->MakeWire( myEdgesAndWires ); + + if ( !anObj->_is_nil() ) + objects.push_back( anObj._retn() ); + + return true; } + diff --git a/src/BuildGUI/BuildGUI_WireDlg.h b/src/BuildGUI/BuildGUI_WireDlg.h index 5ef146c4d..4fa20d828 100644 --- a/src/BuildGUI/BuildGUI_WireDlg.h +++ b/src/BuildGUI/BuildGUI_WireDlg.h @@ -32,8 +32,6 @@ #include "GEOMBase_Skeleton.h" #include "DlgRef_1Sel_QTD.h" -#include "BuildGUI.h" - //================================================================================= // class : BuildGUI_WireDlg // purpose : @@ -43,23 +41,27 @@ class BuildGUI_WireDlg : public GEOMBase_Skeleton Q_OBJECT public: - BuildGUI_WireDlg(QWidget* parent = 0, const char* name = 0, BuildGUI* theBuildGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + BuildGUI_WireDlg(QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); ~BuildGUI_WireDlg(); +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& msg ); + virtual bool execute( ObjectList& objects ); + private: void Init(); void enterEvent(QEvent* e); - BuildGUI* myBuildGUI; - - GEOM::GEOM_Gen::ListOfIOR myListShapes; - bool myOkListShapes; /* to check when arguments is defined */ + GEOM::ListOfGO myEdgesAndWires; + bool myOkEdgesAndWires; /* to check when arguments is defined */ DlgRef_1Sel_QTD* GroupPoints; private slots: void ClickOnOk(); - void ClickOnApply(); + bool ClickOnApply(); void ActivateThisDialog(); void SelectionIntoArgument(); void SetEditCurrentArgument(); diff --git a/src/BuildGUI/Makefile.in b/src/BuildGUI/Makefile.in index 3b29f7b59..abf7e06ca 100644 --- a/src/BuildGUI/Makefile.in +++ b/src/BuildGUI/Makefile.in @@ -49,7 +49,6 @@ LIB_SRC = BuildGUI.cxx \ BuildGUI_CompoundDlg.cxx LIB_MOC = \ - BuildGUI.h \ BuildGUI_EdgeDlg.h \ BuildGUI_WireDlg.h \ BuildGUI_FaceDlg.h \ @@ -57,9 +56,9 @@ LIB_MOC = \ BuildGUI_SolidDlg.h \ BuildGUI_CompoundDlg.h -LIB_CLIENT_IDL = +LIB_CLIENT_IDL = SALOME_GenericObj.idl SALOME_Component.idl -LIB_SERVER_IDL = +LIB_SERVER_IDL = # additionnal information to compil and link file diff --git a/src/DisplayGUI/DisplayGUI.cxx b/src/DisplayGUI/DisplayGUI.cxx index 0ef6fcdfe..1f496edb0 100644 --- a/src/DisplayGUI/DisplayGUI.cxx +++ b/src/DisplayGUI/DisplayGUI.cxx @@ -22,41 +22,55 @@ // // // File : DisplayGUI.cxx -// Author : Damien COQUERET +// Author : Vadim SANDLER // Module : GEOM -// $Header: +// $Header$ #include "DisplayGUI.h" +#include "GeometryGUI.h" +#include "GEOM_Displayer.h" #include "QAD_RightFrame.h" -#include "GEOM_AssemblyBuilder.h" +#include "QAD_WaitCursor.h" +#include "QAD_Desktop.h" #include "VTKViewer_ViewFrame.h" +#include "VTKViewer_RenderWindowInteractor.h" #include "OCCViewer_ViewFrame.h" #include "OCCViewer_Viewer3d.h" -#include "SALOMEGUI_ImportOperation.h" #include "SALOME_ListIteratorOfListIO.hxx" +#include "VTKViewer_Prs.h" +#include "OCCViewer_Prs.h" #include -#include "utilities.h" - using namespace std; +DisplayGUI* DisplayGUI::myGUIObject = 0; + +//======================================================================= +// function : DisplayGUI::GetDisplayGUI() +// purpose : Get the only DisplayGUI object [ static ] //======================================================================= -// function : DisplayGUI() +DisplayGUI* DisplayGUI::GetDisplayGUI() +{ + if ( myGUIObject == 0 ) { + // init DisplayGUI only once + myGUIObject = new DisplayGUI(); + } + return myGUIObject; +} + +//======================================================================= +// function : DisplayGUI::DisplayGUI() // purpose : Constructor //======================================================================= -DisplayGUI::DisplayGUI() : - QObject() +DisplayGUI::DisplayGUI() : GEOMGUI() { - myGeomBase = new GEOMBase(); - myGeomGUI = GEOMContext::GetGeomGUI(); - myGeom = myGeomGUI->myComponentGeom; } //======================================================================= -// function : ~DisplayGUI() +// function : DisplayGUI::~DisplayGUI() // purpose : Destructor //======================================================================= DisplayGUI::~DisplayGUI() @@ -65,952 +79,322 @@ DisplayGUI::~DisplayGUI() //======================================================================= -// function : OnGUIEvent() -// purpose : +// function : DisplayGUI::OnGUIEvent() +// purpose : Dispatch menu command //======================================================================= bool DisplayGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) { - DisplayGUI* myDisplayGUI = new DisplayGUI(); + DisplayGUI* myDisplayGUI = GetDisplayGUI(); - switch (theCommandID) + switch (theCommandID) { + case 211: // MENU VIEW - WIREFRAME/SHADING { - case 211: // MENU VIEW - WIREFRAME/SHADING - { - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { - QApplication::setOverrideCursor(waitCursor); - - VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); - - int themode = myRenderInter->GetDisplayMode(); - if(themode==0) { - myRenderInter->SetDisplayMode(1); - QAD_Application::getDesktop()->menuBar()->changeItem(211, tr("GEOM_MEN_WIREFRAME")); - } - else { - myRenderInter->SetDisplayMode(0); - QAD_Application::getDesktop()->menuBar()->changeItem(211, tr("GEOM_MEN_SHADING")); - } - - QApplication::restoreOverrideCursor(); - } - else if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { - QApplication::setOverrideCursor(Qt::waitCursor); - - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - Handle(AIS_InteractiveContext) ic = v3d->getAISContext(); - AIS_DisplayMode mode = (AIS_DisplayMode)ic->DisplayMode(); - AIS_DisplayMode newmode = (mode == AIS_WireFrame ? AIS_Shaded : AIS_WireFrame); - - AIS_ListOfInteractive List; - ic->DisplayedObjects(List); - AIS_ListOfInteractive List1; - ic->ObjectsInCollector(List1); - List.Append(List1); - - AIS_ListIteratorOfListOfInteractive ite(List); - while(ite.More()) { - if(ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) { - Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value()); - ic->SetDisplayMode(aSh,Standard_Integer(newmode),true); - } - ite.Next(); - } - - ic->SetDisplayMode(newmode, Standard_False); - if(newmode == 1) - QAD_Application::getDesktop()->menuBar()->changeItem(211, tr("GEOM_MEN_WIREFRAME")); - else - QAD_Application::getDesktop()->menuBar()->changeItem(211, tr("GEOM_MEN_SHADING")); - - QApplication::restoreOverrideCursor(); - } - break; - } - case 212: // MENU VIEW - DISPLAY ALL - { - myDisplayGUI->OnDisplayAll(); - break; - } - case 213: // MENU VIEW - DISPLAY ONLY - { - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK) - myDisplayGUI->OnVTKDisplayOnly(); - else if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) - myDisplayGUI->OnDisplayOnly(); - break; - } - case 214: // MENU VIEW - ERASE ALL - { - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK) - ((VTKViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor()->EraseAll(); - else if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - Handle(AIS_InteractiveContext) ic = v3d->getAISContext(); - - ic->EraseAll(Standard_True, Standard_False); - ic->Display(v3d->getTrihedron()); - } - break; - } - case 215: // MENU VIEW - ERASE ONLY - { - myDisplayGUI->OnErase(); - break; - } - case 8031: // POPUP VIEWER - WIREFRAME/SHADING - { - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { - // VTK - VTKViewer_RenderWindowInteractor* myRenderInter = ((VTKViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); - - SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection()); - SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); - - QApplication::setOverrideCursor(Qt::waitCursor); - for(;It.More();It.Next()) { - Handle(SALOME_InteractiveObject) IOS = It.Value(); - myRenderInter->SwitchRepresentation(IOS, false); - } - myRenderInter->Render(); - QApplication::restoreOverrideCursor(); - } - else if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { - QApplication::setOverrideCursor(Qt::waitCursor); - SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection()); - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - Handle(AIS_InteractiveContext) ic = v3d->getAISContext(); - SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); - for(;It.More();It.Next()) { - Handle(SALOME_InteractiveObject) IObject = It.Value(); - Standard_Boolean found; - Handle(GEOM_AISShape) Shape = myDisplayGUI->myGeomBase->ConvertIOinGEOMAISShape(IObject, found, true); - if(!Shape.IsNull()) { - AIS_DisplayMode mode = (AIS_DisplayMode)Shape->DisplayMode(); - if(mode == -1) - mode = (AIS_DisplayMode)ic->DisplayMode(); - - ic->SetDisplayMode(Shape, mode == AIS_WireFrame ? AIS_Shaded : AIS_WireFrame, false); - } - } - ic->UpdateCurrentViewer(); - } - QApplication::restoreOverrideCursor(); - break; - } - default: - { - parent->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); - break; - } + myDisplayGUI->InvertDisplayMode(); + int newMode = myDisplayGUI->GetDisplayMode(); + QAD_Application::getDesktop()->menuBar()->changeItem( 211, newMode == 1 ? tr( "GEOM_MEN_WIREFRAME" ) : tr("GEOM_MEN_SHADING") ); + break; + } + case 212: // MENU VIEW - DISPLAY ALL + { + myDisplayGUI->DisplayAll(); + break; + } + case 213: // MENU VIEW - DISPLAY ONLY + { + myDisplayGUI->DisplayOnly(); + break; + } + case 214: // MENU VIEW - ERASE ALL + { + myDisplayGUI->EraseAll(); + break; + } + case 215: // MENU VIEW - ERASE + { + myDisplayGUI->Erase(); + break; + } + case 216: // MENU VIEW - DISPLAY + { + myDisplayGUI->Display(); + break; } + case 80311: // POPUP VIEWER - WIREFRAME + { + myDisplayGUI->ChangeDisplayMode( 0 ); + break; + } + case 80312: // POPUP VIEWER - SHADING + { + myDisplayGUI->ChangeDisplayMode( 1 ); + break; + } + default: + { + parent->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); + break; + } + } return true; } - -//================================================================================= -// function : BuildPresentation() -// purpose : static -//================================================================================= -void DisplayGUI::BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO) +//===================================================================================== +// function : DisplayGUI::DisplayAll() +// purpose : Display all GEOM objects +//===================================================================================== +void DisplayGUI::DisplayAll() { - DisplayGUI* myDisplayGUI = new DisplayGUI(); - + QAD_WaitCursor wc; SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument(); - SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); - - OCCViewer_Viewer3d* v3d; - Handle(AIS_InteractiveContext) ic; - vtkRenderer* Renderer; - - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { - v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - ic = v3d->getAISContext(); - } - else if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { - Renderer = ((VTKViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); - } - else - return; - - if(theIO.IsNull()) - MESSAGE("BuildPresentation(): null SALOME_InteractiveObject passed") - - Standard_Boolean testResult; - GEOM::GEOM_Shape_var myGeomShape = myDisplayGUI->myGeomBase->ConvertIOinGEOMShape(theIO, testResult); - if(!testResult) + SALOMEDS::SComponent_var SC = aStudy->FindComponent( "GEOM" ); + if ( SC->_is_nil() ) return; - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { - // VTK - - SALOMEDS::SObject_var fatherSF = aStudy->FindObjectID(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->entry()); - - SALOMEDS::SObject_var obj = aStudy->FindObjectID(theIO->getEntry()); - - VTKViewer_RenderWindowInteractor* myRenderInter = ((VTKViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); - - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeName_var aName; - SALOMEDS::AttributeIOR_var anIOR; - - if(myRenderInter->isInViewer(theIO)) { - myRenderInter->Display(theIO, false); - } - else { - // Create new actor - if(!obj->_is_nil()) { - if(obj->FindAttribute(anAttr, "AttributeIOR")) { - // this SObject may be GEOM module root SObject - - bool useSubItems = false; - SALOMEDS::ChildIterator_var anIter = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument()->NewChildIterator(obj); - if(myDisplayGUI->myGeom->GetIORFromString(SALOMEDS::AttributeIOR::_narrow(anAttr)->Value())->_is_nil()) { - while (anIter->More() && !useSubItems) { - SALOMEDS::SObject_var subobj = anIter->Value(); - SALOMEDS::GenericAttribute_var aTmpAttr; - if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) { - if (!myDisplayGUI->myGeom->GetIORFromString(SALOMEDS::AttributeIOR::_narrow(aTmpAttr)->Value())->_is_nil()) { - anAttr = aTmpAttr; - obj = subobj; - useSubItems = true; - } - else - anIter->Next(); - } - else - anIter->Next(); - } - } - - while(useSubItems?anIter->More():!anAttr->_is_nil()) { - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - GEOM::GEOM_Shape_var aShape = myDisplayGUI->myGeom->GetIORFromString(anIOR->Value()); - TopoDS_Shape Shape = myDisplayGUI->myGeomGUI->GetShapeReader().GetShape(myDisplayGUI->myGeom,aShape); - - if(obj->FindAttribute(anAttr, "AttributeName")) { - aName = SALOMEDS::AttributeName::_narrow(anAttr); - - vtkRenderer* theRenderer = ((VTKViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); - vtkActorCollection* theAllActors = theRenderer->GetActors(); - theAllActors->InitTraversal(); - vtkActor* actor = (vtkActor*)theAllActors->GetNextActor(); - Handle(SALOME_InteractiveObject) anIObj; - // don't create new study object if it already exists - bool isDisplayed = false; - while(!(actor==NULL)) { - SALOME_Actor* Gactor = SALOME_Actor::SafeDownCast(actor); - if(Gactor!=NULL) { - if(Gactor->hasIO()) { - if(strcmp(Gactor->getIO()->getEntry(),obj->GetID())==0) { - isDisplayed = true; - anIObj = Gactor->getIO(); - if(!anIObj.IsNull()) myRenderInter->Display(anIObj, false); - } - } - } - actor=(vtkActor*)(theAllActors->GetNextActor()); - } - if(!isDisplayed) { - // open transaction - QAD_Operation* op = new SALOMEGUI_ImportOperation( QAD_Application::getDesktop()->getActiveStudy() ); - op->start(); - - SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF); - aStudyBuilder->Addreference(newObj1, obj); - // commit transaction - op->finish(); - - vtkRenderWindow *renWin = theRenderer->GetRenderWindow(); - int themode = myRenderInter->GetDisplayMode(); - - vtkActorCollection* theActors = - GEOM_AssemblyBuilder::BuildActors(Shape,0,themode,Standard_True); - theActors->InitTraversal(); - vtkActor* anActor = (vtkActor*)theActors->GetNextActor(); - while(!(anActor==NULL)) { - GEOM_Actor* GActor = GEOM_Actor::SafeDownCast(anActor); - Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(anIOR->Value(), myDisplayGUI->myGeomGUI->GetFatherior(),"GEOM"); - IO->setEntry(obj->GetID()); - GActor->setIO(IO); - GActor->setName(theIO->getName()); - - theRenderer->AddActor(GActor); - // renWin->Render(); - anActor = (vtkActor*)theActors->GetNextActor(); - } - } - } - // next item iteration - if(useSubItems) { - anIter->Next(); - anAttr = SALOMEDS::GenericAttribute::_nil(); - while(anIter->More() && anAttr->_is_nil()) { - SALOMEDS::SObject_var subobject = anIter->Value(); - SALOMEDS::GenericAttribute_var aTmpAttribute; - if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) { - anAttr = aTmpAttribute; - obj = subobject; - } - else - anIter->Next(); - } - } - else - anAttr = SALOMEDS::GenericAttribute::_nil(); - } - } - } - } - // No viewer update should be done here! - //myRenderInter->Render(); - //QAD_Application::getDesktop()->getActiveStudy()->updateObjBrowser( true ); - } - else if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { - SALOMEDS::SObject_var fatherSF = aStudy->FindObjectID(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->entry()); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeName_var aName; - SALOMEDS::AttributeIOR_var anIOR; - - if(v3d->isInViewer(theIO, true)) { - Standard_Boolean found; - Handle(GEOM_AISShape) aSh = myDisplayGUI->myGeomBase->ConvertIOinGEOMAISShape(theIO, found, true); - if(found) { - ic->Display(aSh, false); - ic->AddOrRemoveCurrentObject(aSh, false); - } - + SALOME_ListIO listIO; + SALOMEDS::ChildIterator_var anIter = aStudy->NewChildIterator( SC ); + anIter->InitEx( true ); + while( anIter->More() ) { + SALOMEDS::SObject_var valSO = anIter->Value(); + SALOMEDS::SObject_var refSO; + if ( !valSO->ReferencedObject( refSO ) ) { + listIO.Append( new SALOME_InteractiveObject( valSO->GetID(), SC->ComponentDataType() ,valSO->GetName()) ); } - else { - SALOMEDS::SObject_var obj = aStudy->FindObjectID(theIO->getEntry()); - if(!obj->_is_nil()) { - MESSAGE("BuildPresentation(): SObject not null") - if(obj->FindAttribute(anAttr, "AttributeIOR")) { - MESSAGE("BuildPresentation(): SObject has IOR") - // this SObject may be GEOM module root SObject - - bool useSubItems = false; - SALOMEDS::ChildIterator_var anIter = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument()->NewChildIterator(obj); - if(myDisplayGUI->myGeom->GetIORFromString(SALOMEDS::AttributeIOR::_narrow(anAttr)->Value())->_is_nil()) { - while(anIter->More() && !useSubItems) { - SALOMEDS::SObject_var subobj = anIter->Value(); - SALOMEDS::GenericAttribute_var aTmpAttr; - if(subobj->FindAttribute(aTmpAttr, "AttributeIOR")) { - if(!myDisplayGUI->myGeom->GetIORFromString(SALOMEDS::AttributeIOR::_narrow(aTmpAttr)->Value())->_is_nil()) { - anAttr = aTmpAttr; - obj = subobj; - useSubItems = true; - } - else - anIter->Next(); - } - else - anIter->Next(); - } - } - - while(useSubItems?anIter->More():!anAttr->_is_nil()) { - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - GEOM::GEOM_Shape_var aShape = myDisplayGUI->myGeom->GetIORFromString(anIOR->Value()); - TopoDS_Shape Shape = myDisplayGUI->myGeomGUI->GetShapeReader().GetShape(myDisplayGUI->myGeom,aShape); - if(Shape.IsNull()) - MESSAGE("BuildPresentation(): TopoDS_Shape is null!") - if(obj->FindAttribute(anAttr, "AttributeName")) { - MESSAGE("BuildPresentation(): SObject has Name") - aName = SALOMEDS::AttributeName::_narrow(anAttr); - // searchin for already displayed objects with the same shape - AIS_ListOfInteractive aDisplayed; - ic->DisplayedObjects(aDisplayed); - AIS_ListIteratorOfListOfInteractive anIObjects(aDisplayed); - Handle(AIS_Shape) anAISShape; - for(;anIObjects.More();anIObjects.Next()) { - anAISShape = Handle(AIS_Shape)::DownCast(anIObjects.Value()); - if(!anAISShape.IsNull()) { - if(anAISShape->Shape().IsSame(Shape)) - break; - anAISShape.Nullify(); - } - } - if(!anAISShape.IsNull()) { - if(!ic->IsDisplayed(anAISShape)) - ic->Display(anAISShape, false); - } - else { - if(!useSubItems) { - // open transaction - QAD_Operation* op = new SALOMEGUI_ImportOperation( QAD_Application::getDesktop()->getActiveStudy() ); - op->start(); - if (fatherSF->_is_nil()) - MESSAGE("BuildPresentation(): fatherSF is nil!") - SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF); - aStudyBuilder->Addreference(newObj1, obj); - // commit transaction - op->finish(); - } - Handle(GEOM_AISShape) aSh = new GEOM_AISShape(Shape, aName->Value()); - aSh->SetShadingColor(myDisplayGUI->myGeomBase->myShadingColor); - aSh->SetInfiniteState(Shape.Infinite()); - Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(anIOR->Value(), myDisplayGUI->myGeomGUI->GetFatherior(), "GEOM"); - IO->setEntry(obj->GetID()); - aSh->setIO(IO); - aSh->setName(aName->Value()); - ic->Display(aSh, false); - if(!useSubItems) - ic->AddOrRemoveCurrentObject(aSh, false); - } - } - // next item iteration - if(useSubItems) { - anIter->Next(); - anAttr=SALOMEDS::GenericAttribute::_nil(); - while (anIter->More() && anAttr->_is_nil()) { - SALOMEDS::SObject_var subobject = anIter->Value(); - SALOMEDS::GenericAttribute_var aTmpAttribute; - if(subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) { - anAttr = aTmpAttribute; - obj = subobject; - } - else - anIter->Next(); - } - } - else - anAttr = SALOMEDS::GenericAttribute::_nil(); - } - } - } - } - // No viewer update should be done here! - //QAD_Application::getDesktop()->getActiveStudy()->updateObjBrowser( true ); - //ic->UpdateCurrentViewer(); + anIter->Next(); } + GEOM_Displayer().Display( listIO, true ); } - //===================================================================================== -// function : OnDisplayAll() -// purpose : +// function : DisplayGUI::EraseAll() +// purpose : Erase all GEOM objects //===================================================================================== -void DisplayGUI::OnDisplayAll(bool onlyPreviousDisplayedObject) +void DisplayGUI::EraseAll() { - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - Handle (AIS_InteractiveContext) myContext = v3d->getAISContext(); - - //myContext->Display(v3d->getTrihedron()); - - if(!onlyPreviousDisplayedObject) { - SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument(); - SALOMEDS::SComponent_var SC = aStudy->FindComponent("GEOM"); - SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator(SC); - for(; it->More();it->Next()) { - SALOMEDS::SObject_var CSO = it->Value(); - SALOMEDS::AttributeIOR_var anIOR; - SALOMEDS::GenericAttribute_var anAttr; - if(CSO->FindAttribute(anAttr, "AttributeIOR")) { - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - Standard_Boolean testResult; - Handle(GEOM_AISShape) aSh = myGeomBase->ConvertIORinGEOMAISShape(anIOR->Value(), testResult); - if(testResult) - myContext->Display(aSh); - else { - GEOM::GEOM_Shape_ptr aShape = myGeom->GetIORFromString(anIOR->Value()); - bool AddInSt = myGeomBase->mySettings_AddInStudy; - myGeomBase->mySettings_AddInStudy = false; - myGeomBase->Display(aShape); - myGeomBase->mySettings_AddInStudy = AddInSt; - } - } - } - } - else { - AIS_ListOfInteractive aListDisplayedObject; - myContext->DisplayedObjects(aListDisplayedObject); - AIS_ListIteratorOfListOfInteractive ite(aListDisplayedObject); - while(ite.More()) { - if(ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) { - Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value()); - if (aSh->hasIO()) { - Handle(GEOM_InteractiveObject) GIO = Handle(GEOM_InteractiveObject)::DownCast(aSh->getIO()); - if (v3d->isInViewer(GIO,true)) - myContext->Display(aSh); - } - } - ite.Next(); - } - } - } - else if (QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { - SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument(); - SALOMEDS::SComponent_var SC = aStudy->FindComponent("GEOM"); - SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator(SC); - for(; it->More();it->Next()) { - SALOMEDS::SObject_var CSO = it->Value(); - SALOMEDS::AttributeIOR_var anIOR; - SALOMEDS::GenericAttribute_var anAttr; - if(CSO->FindAttribute(anAttr, "AttributeIOR")) { - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - Standard_Boolean testResult; - GEOM_Actor* aSh = myGeomBase->ConvertIORinGEOMActor(anIOR->Value(), testResult); - if(testResult) { - Handle(SALOME_InteractiveObject) IObject = aSh->getIO(); - ((VTKViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor()->Display(IObject); - } - else { - GEOM::GEOM_Shape_ptr aShape = myGeom->GetIORFromString(anIOR->Value()); - bool AddInSt = myGeomBase->mySettings_AddInStudy; - myGeomBase->mySettings_AddInStudy = false; - myGeomBase->Display(aShape); - myGeomBase->mySettings_AddInStudy = AddInSt; - } - } - } - } - return; + QAD_WaitCursor wc; + QAD_ViewFrame* vf = QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame(); + if ( vf->getTypeView() == VIEW_OCC || vf->getTypeView() == VIEW_VTK ) + vf->EraseAll(); } - //===================================================================================== -// function : OnVTKDisplayOnly() -// purpose : +// function : DisplayGUI::DisplayOnly() +// purpose : Display selected GEOM objects and erase other //===================================================================================== -void DisplayGUI::OnVTKDisplayOnly() +void DisplayGUI::DisplayOnly() { - QApplication::setOverrideCursor(Qt::waitCursor); - - // Erase all not selected actors - vtkRenderer* aren = ((VTKViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); - vtkActorCollection* theActors = aren->GetActors(); - theActors->InitTraversal(); - vtkActor *ac = theActors->GetNextActor(); - while(!(ac==NULL)) { - if(ac->IsA("SALOME_Actor")) { - SALOME_Actor* anActor = SALOME_Actor::SafeDownCast(ac); - if(!anActor->isHighlighted()) - anActor->VisibilityOff(); - } - ac = theActors->GetNextActor(); - } - - // Display selection - SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument(); - SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); - SALOMEDS::SObject_var fatherSF = aStudy->FindObjectID(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->entry()); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeName_var aName; - SALOMEDS::AttributeIOR_var anIOR; - - SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection()); - SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); - - for(;It.More();It.Next()) { - Handle(SALOME_InteractiveObject) IObject = It.Value(); - SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() ); - - VTKViewer_RenderWindowInteractor* myRenderInter = ((VTKViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); - - if(myRenderInter->isInViewer(IObject)) { - myRenderInter->Display(IObject); - } - else { - // Create new actor - if(!obj->_is_nil()) { - if(!obj->FindAttribute(anAttr, "AttributeIOR")) - break; - // If selected object contains displayable subobjects, then do nothing - SALOMEDS::ChildIterator_var anIter = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument()->NewChildIterator(obj); - SALOMEDS::GenericAttribute_var aTmpAttr; - - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - GEOM::GEOM_Shape_var aShape = myGeom->GetIORFromString(anIOR->Value()); - if(CORBA::is_nil(aShape)) continue; - TopoDS_Shape Shape = myGeomGUI->GetShapeReader().GetShape(myGeom, aShape); - - if(obj->FindAttribute(anAttr, "AttributeName")) { - aName = SALOMEDS::AttributeName::_narrow(anAttr); - // open transaction - QAD_Operation* op = new SALOMEGUI_ImportOperation(QAD_Application::getDesktop()->getActiveStudy()); - op->start(); - - SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF); - aStudyBuilder->Addreference(newObj1, obj); - // commit transaction - op->finish(); - - vtkRenderer* theRenderer = ((VTKViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); - int themode = myRenderInter->GetDisplayMode(); - vtkActorCollection* theActors = GEOM_AssemblyBuilder::BuildActors(Shape, 0, themode, Standard_True); - theActors->InitTraversal(); - vtkActor* anActor = (vtkActor*)theActors->GetNextActor(); - while(!(anActor==NULL)) { - GEOM_Actor* GActor = GEOM_Actor::SafeDownCast(anActor); - GActor->setIO(IObject); - GActor->setName(IObject->getName()); - - theRenderer->AddActor(GActor); - vtkRenderWindow *renWin = ((VTKViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer()->GetRenderWindow(); - renWin->Render(); - anActor = (vtkActor*)theActors->GetNextActor(); - } - } - } - } - } - QAD_Application::getDesktop()->getActiveStudy()->updateObjBrowser(true); - - QApplication::restoreOverrideCursor(); - return; -} - + EraseAll(); + Display(); +} //===================================================================================== -// function : OnDisplayOnly() -// purpose : +// function : DisplayGUI::Display() +// purpose : Display selected GEOM objects //===================================================================================== -void DisplayGUI::OnDisplayOnly() +void DisplayGUI::Display() { - if (QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC) - return; - - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument(); - Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); - - AIS_ListOfInteractive List; - ic->DisplayedObjects(List); - AIS_ListIteratorOfListOfInteractive ite(List); - while(ite.More()) { - if(ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) { - Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value()); - if (!ic->IsSelected( aSh )) { - ic->Erase(aSh, Standard_True, Standard_True); - } - } - ite.Next(); - } - - SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); - SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection()); - - SALOME_ListIteratorOfListIO It1(Sel->StoredIObjects()); - for(;It1.More();It1.Next()) { - Handle(SALOME_InteractiveObject) IObject = It1.Value(); - - SALOMEDS::SObject_var fatherSF = - aStudy->FindObjectID(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->entry()); - if(v3d->isInViewer(IObject, true)) { - AIS_ListOfInteractive List1; - ic->ObjectsInCollector(List1); - AIS_ListIteratorOfListOfInteractive ite1(List1); - while(ite1.More()) { - if(ite1.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) { - Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite1.Value()); - if (aSh->hasIO()) { - Handle(GEOM_InteractiveObject) GIO = Handle(GEOM_InteractiveObject)::DownCast(aSh->getIO()); - if (IObject->isSame(GIO)) { - ic->Display(aSh); - ic->AddOrRemoveCurrentObject(aSh, true); - break; - } - } + QAD_WaitCursor wc; + SALOME_ListIO listIO; + + QAD_Study* anActiveStudy = QAD_Application::getDesktop()->getActiveStudy(); + SALOME_Selection* Sel = SALOME_Selection::Selection( anActiveStudy->getSelection() ); + SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); + for( ;It.More();It.Next() ) { + Handle(SALOME_InteractiveObject) anIObject = It.Value(); + if ( anIObject->hasEntry() ) { + SALOMEDS::SObject_var SO = anActiveStudy->getStudyDocument()->FindObjectID( anIObject->getEntry() ); + if ( !SO->_is_nil() && QString( SO->GetID() ) == QString( SO->GetFatherComponent()->GetID() ) ) { + SALOMEDS::SComponent_var SC = SO->GetFatherComponent(); + // if component is selected + listIO.Clear(); + SALOMEDS::ChildIterator_var anIter = anActiveStudy->getStudyDocument()->NewChildIterator( SO ); + anIter->InitEx( true ); + while( anIter->More() ) { + SALOMEDS::SObject_var valSO = anIter->Value(); + SALOMEDS::SObject_var refSO; + if ( !valSO->ReferencedObject( refSO ) ) { + listIO.Append( new SALOME_InteractiveObject( valSO->GetID(), SC->ComponentDataType() ,valSO->GetName()) ); + } + anIter->Next(); } - ite1.Next(); + break; + } + else { + listIO.Append( anIObject ); } } else { - if (IObject->hasEntry()) { - SALOMEDS::SObject_var obj = aStudy->FindObjectID(IObject->getEntry()); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeName_var aName; - SALOMEDS::AttributeIOR_var anIOR; - if (!obj->_is_nil()) { - if (obj->FindAttribute(anAttr, "AttributeIOR")) { - // this SObject may be GEOM module root SObject - - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - GEOM::GEOM_Shape_var aShape = myGeom->GetIORFromString(anIOR->Value()); - if(CORBA::is_nil(aShape)) continue; - TopoDS_Shape Shape = myGeomGUI->GetShapeReader().GetShape(myGeom, aShape); - - if(obj->FindAttribute(anAttr, "AttributeName")) { - aName = SALOMEDS::AttributeName::_narrow(anAttr); - // open transaction - QAD_Operation* op = new SALOMEGUI_ImportOperation(QAD_Application::getDesktop()->getActiveStudy()); - op->start(); - - SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF); - aStudyBuilder->Addreference(newObj1, obj); - // commit transaction - op->finish(); - } - - Handle(GEOM_AISShape) aSh = new GEOM_AISShape(Shape, aName->Value()); - Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(anIOR->Value(), myGeomGUI->GetFatherior(),"GEOM"); - - IO->setEntry(obj->GetID()); - aSh->setIO(IO); - aSh->setName(aName->Value()); - ic->Display(aSh); - ic->AddOrRemoveCurrentObject(aSh, true); - } - } - } + listIO.Append( anIObject ); } } + GEOM_Displayer().Display( listIO, true ); } //===================================================================================== -// function : OnErase() -// purpose : +// function : DisplayGUI::Erase() +// purpose : Erase selected GEOM objects //===================================================================================== -void DisplayGUI::OnErase() +void DisplayGUI::Erase() { - SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument(); - SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection()); - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { - // VTK - SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); - Handle(SALOME_InteractiveObject) anIObject; - for(;It.More();It.Next()) { - anIObject = It.Value(); - VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); - - if(myRenderInter->isInViewer(anIObject)) { - myRenderInter->Erase(anIObject); - } - else { - SALOMEDS::SObject_var obj = aStudy->FindObjectID(anIObject->getEntry()); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeIOR_var anIOR; - if(!obj->_is_nil()) { - if(obj->FindAttribute(anAttr, "AttributeIOR")) { - // this SObject may be GEOM module root SObject - SALOMEDS::ChildIterator_var anIter = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument()->NewChildIterator(obj); - bool useSubItems = false; - while(anIter->More() && !useSubItems) { - SALOMEDS::SObject_var subobj = anIter->Value(); - SALOMEDS::GenericAttribute_var aTmpAttr; - if(subobj->FindAttribute(aTmpAttr, "AttributeIOR")) { - anAttr = aTmpAttr; - obj = subobj; - useSubItems = true; - } - else - anIter->Next(); - } - - while(useSubItems?anIter->More():!anAttr->_is_nil()) { - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - GEOM::GEOM_Shape_var aShape = myGeom->GetIORFromString(anIOR->Value()); - TopoDS_Shape Shape = myGeomGUI->GetShapeReader().GetShape(myGeom, aShape); - if(obj->FindAttribute(anAttr, "AttributeName")) { - // searchin for already displayed objects with the same shape - vtkRenderer* theRenderer = ((VTKViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); - vtkActorCollection* theAllActors = theRenderer->GetActors(); - theAllActors->InitTraversal(); - vtkActor* actor = (vtkActor*)theAllActors->GetNextActor(); - Handle(SALOME_InteractiveObject) anIObj; - // don't create new study object if it already exists - bool isDisplayed = false; - while(!(actor==NULL)) { - SALOME_Actor* Gactor = SALOME_Actor::SafeDownCast(actor); - if(Gactor!=NULL) { - if(Gactor->hasIO()) { - if(strcmp(Gactor->getIO()->getEntry(),obj->GetID())==0) { - isDisplayed = true; - anIObj = Gactor->getIO(); - if(!anIObj.IsNull()) - myRenderInter->Erase(anIObj); - } - } - } - actor=(vtkActor*)(theAllActors->GetNextActor()); - } - } - if(useSubItems) { - anIter->Next(); - anAttr=SALOMEDS::GenericAttribute::_nil(); - while(anIter->More() && anAttr->_is_nil()) { - SALOMEDS::SObject_var subobject = anIter->Value(); - SALOMEDS::GenericAttribute_var aTmpAttribute; - if(subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) { - anAttr = aTmpAttribute; - obj = subobject; - } - else - anIter->Next(); - } - } - else - anAttr = SALOMEDS::GenericAttribute::_nil(); - } - } + QAD_WaitCursor wc; + SALOME_ListIO listIO; + + QAD_Study* anActiveStudy = QAD_Application::getDesktop()->getActiveStudy(); + SALOME_Selection* Sel = SALOME_Selection::Selection( anActiveStudy->getSelection() ); + SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); + for( ;It.More();It.Next() ) { + Handle(SALOME_InteractiveObject) anIObject = It.Value(); + if ( anIObject->hasEntry() ) { + SALOMEDS::SObject_var SO = anActiveStudy->getStudyDocument()->FindObjectID( anIObject->getEntry() ); + if ( !SO->_is_nil() && QString( SO->GetID() ) == QString( SO->GetFatherComponent()->GetID() ) ) { + SALOMEDS::SComponent_var SC = SO->GetFatherComponent(); + // if component is selected + listIO.Clear(); + SALOMEDS::ChildIterator_var anIter = anActiveStudy->getStudyDocument()->NewChildIterator( SO ); + anIter->InitEx( true ); + while( anIter->More() ) { + SALOMEDS::SObject_var valSO = anIter->Value(); + SALOMEDS::SObject_var refSO; + if ( !valSO->ReferencedObject( refSO ) ) { + listIO.Append( new SALOME_InteractiveObject( valSO->GetID(), SC->ComponentDataType() ,valSO->GetName()) ); + } + anIter->Next(); } + break; } - } - } - else if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { - // OCC - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); - SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); - Handle(SALOME_InteractiveObject) anIObject; - for(;It.More();It.Next()) { - anIObject = It.Value(); - if(v3d->isInViewer(anIObject, true)) { - Standard_Boolean found; - Handle(GEOM_AISShape) aSh = myGeomBase->ConvertIOinGEOMAISShape(anIObject, found, true); - if(found) { - ic->Erase(aSh); - ic->AddOrRemoveCurrentObject(aSh, true); - } - } else { - SALOMEDS::SObject_var obj = aStudy->FindObjectID(anIObject->getEntry()); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeIOR_var anIOR; - if(!obj->_is_nil()) { - if(obj->FindAttribute(anAttr, "AttributeIOR")) { - // this SObject may be GEOM module root SObject - SALOMEDS::ChildIterator_var anIter = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument()->NewChildIterator(obj); - bool useSubItems = false; - while(anIter->More() && !useSubItems) { - SALOMEDS::SObject_var subobj = anIter->Value(); - SALOMEDS::GenericAttribute_var aTmpAttr; - if(subobj->FindAttribute(aTmpAttr, "AttributeIOR")) { - anAttr = aTmpAttr; - obj = subobj; - useSubItems = true; - } - else - anIter->Next(); - } - - while(useSubItems?anIter->More():!anAttr->_is_nil()) { - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - GEOM::GEOM_Shape_var aShape = myGeom->GetIORFromString(anIOR->Value()); - TopoDS_Shape Shape = myGeomGUI->GetShapeReader().GetShape(myGeom, aShape); - if(obj->FindAttribute(anAttr, "AttributeName")) { - // searchin for already displayed objects with the same shape - AIS_ListOfInteractive aDisplayed; - ic->DisplayedObjects(aDisplayed); - AIS_ListIteratorOfListOfInteractive anIObjects(aDisplayed); - Handle(AIS_Shape) anAISShape; - for(;anIObjects.More();anIObjects.Next()) { - anAISShape = Handle(AIS_Shape)::DownCast(anIObjects.Value()); - if(!anAISShape.IsNull()) { - if(anAISShape->Shape().IsSame(Shape)) - break; - anAISShape.Nullify(); - } - } - if(!anAISShape.IsNull()) { - if(ic->IsDisplayed(anAISShape)) - ic->Erase(anAISShape); - } - } - if(useSubItems) { - anIter->Next(); - anAttr=SALOMEDS::GenericAttribute::_nil(); - while(anIter->More() && anAttr->_is_nil()) { - SALOMEDS::SObject_var subobject = anIter->Value(); - SALOMEDS::GenericAttribute_var aTmpAttribute; - if(subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) { - anAttr = aTmpAttribute; - obj = subobject; - } - else - anIter->Next(); - } - } - else - anAttr = SALOMEDS::GenericAttribute::_nil(); - } - } - } + listIO.Append( anIObject ); } } + else { + listIO.Append( anIObject ); + } } + GEOM_Displayer().Erase( listIO, true ); Sel->ClearIObjects(); } - //===================================================================================== -// function : PrepareSubShapeSelection() -// purpose : (localContextId of the method is opened and defined here) +// function : DisplayGUI::SetDisplayMode() +// purpose : Set display mode for the viewer (current viewer if - 0 ) //===================================================================================== -bool DisplayGUI::PrepareSubShapeSelection(const int SubShapeType, Standard_Integer& returnLocalContextId) +void DisplayGUI::SetDisplayMode( const int mode, QAD_ViewFrame* viewFrame ) { - //* Test the type of viewer */ - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC) - return false; - - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); - - /* local context opening */ - //myGeomBase->SetDisplayedObjectList(); - this->OnDisplayOnly(); - - returnLocalContextId = ic->OpenLocalContext(Standard_False, Standard_True, Standard_False, Standard_False); - SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection()); - SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); - for(;It.More();It.Next()) { - Handle(SALOME_InteractiveObject) IObject = It.Value(); - Standard_Boolean found; - Handle(GEOM_AISShape) Shape = myGeomBase->ConvertIOinGEOMAISShape(IObject, found); - if(found && SubShapeType >= Shape->Shape().ShapeType()) { - ic->Load(Shape, (8 - SubShapeType), Standard_True); - ic->HilightWithColor(Shape, Quantity_NOC_RED); + QAD_WaitCursor wc; + if ( !viewFrame ) + viewFrame = QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame(); + if( viewFrame->getTypeView() == VIEW_VTK ) { + VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)viewFrame)->getRWInteractor(); + myRenderInter->SetDisplayMode( mode ); + } + else if( viewFrame->getTypeView() == VIEW_OCC ) { + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)viewFrame)->getViewer(); + Handle(AIS_InteractiveContext) ic = v3d->getAISContext(); + AIS_DisplayMode newmode = (mode == 1 ? AIS_Shaded : AIS_WireFrame); + AIS_ListOfInteractive List; + ic->DisplayedObjects( List ); + AIS_ListOfInteractive List1; + ic->ObjectsInCollector( List1 ); + List.Append( List1 ); + + AIS_ListIteratorOfListOfInteractive ite( List ); + while( ite.More() ) { + if( ite.Value()->IsInstance( STANDARD_TYPE(GEOM_AISShape) ) ) { + Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast( ite.Value() ); + ic->SetDisplayMode( aSh, Standard_Integer( newmode ),true ); + } + ite.Next(); } + + ic->SetDisplayMode( newmode, Standard_False ); } - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_SELECT_SUBSHAPES")); - return true; } - //===================================================================================== -// function : PrepareSubShapeSelectionArgumentShape() -// purpose : ( localContextId of the method is opened and defined here ) +// function : DisplayGUI::GetDisplayMode() +// purpose : Get display mode of the viewer (current viewer if - 0 ) //===================================================================================== -bool DisplayGUI::PrepareSubShapeSelectionArgumentShape(const TopoDS_Shape& aShape,const int SubShapeType, Standard_Integer& returnLocalContextId) +int DisplayGUI::GetDisplayMode( QAD_ViewFrame* viewFrame ) { - //* Test the type of viewer */ - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC) - return false; - - if(aShape.IsNull()) - return false ; - - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); - - /* local context opening */ - //myGeomBase->SetDisplayedObjectList(); - this->OnDisplayOnly(); - - returnLocalContextId = ic->OpenLocalContext(Standard_False, Standard_True, Standard_False, Standard_False) ; - - Handle(GEOM_AISShape) Shape = new GEOM_AISShape(aShape, ""); - ic->Display(Shape, 0, (8 - SubShapeType)); + int dispMode = 0; + if ( !viewFrame ) + viewFrame = QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame(); + if( viewFrame->getTypeView() == VIEW_VTK) { + VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)viewFrame)->getRWInteractor(); + dispMode = myRenderInter->GetDisplayMode(); + } + else if( viewFrame->getTypeView() == VIEW_OCC) { + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)viewFrame)->getViewer(); + Handle(AIS_InteractiveContext) ic = v3d->getAISContext(); + AIS_DisplayMode mode = (AIS_DisplayMode)ic->DisplayMode(); + dispMode = (mode == AIS_WireFrame ? 0 : 1 ); + } + return dispMode; +} - // Not Load(...) but Display(...) - // ic->Load(Shape, (8 - SubShapeType), Standard_True); - ic->HilightWithColor(Shape, Quantity_NOC_RED); - - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_SELECT_SUBSHAPES")); - return true; +//===================================================================================== +// function : DisplayGUI::InvertDisplayMode() +// purpose : Invert display mode ( shadin <-> wireframe ) for the viewer +// (current viewer if = 0 ) +//===================================================================================== +void DisplayGUI::InvertDisplayMode( QAD_ViewFrame* viewFrame ) +{ + SetDisplayMode( 1 - GetDisplayMode( viewFrame ) ); } +//===================================================================================== +// function : DisplayGUI::ChangeDisplayMode() +// purpose : Set display mode for selected objects in the viewer given +// (current viewer if = 0 ) +//===================================================================================== +void DisplayGUI::ChangeDisplayMode( const int mode, QAD_ViewFrame* viewFrame ) +{ + QAD_WaitCursor wc; + if ( !viewFrame ) + viewFrame = QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame(); + SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection()); + if ( viewFrame->getTypeView() == VIEW_VTK ) { + VTKViewer_RenderWindowInteractor* myRenderInter = ((VTKViewer_ViewFrame*)viewFrame)->getRWInteractor(); + SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); + for( ;It.More(); It.Next() ) { + VTKViewer_Prs* vtkPrs = dynamic_cast( viewFrame->CreatePrs( It.Value()->getEntry() ) ); + if ( vtkPrs && !vtkPrs->IsNull() ) { + if ( mode == 0 ) + myRenderInter->ChangeRepresentationToWireframe( vtkPrs->GetObjects() ); + else if ( mode == 1 ) + myRenderInter->ChangeRepresentationToSurface( vtkPrs->GetObjects() ); + } + } + myRenderInter->Render(); + } + else if ( viewFrame->getTypeView() == VIEW_OCC ) { + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)viewFrame)->getViewer(); + Handle(AIS_InteractiveContext) ic = v3d->getAISContext(); + SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); + for( ;It.More(); It.Next() ) { + OCCViewer_Prs* occPrs = dynamic_cast( viewFrame->CreatePrs( It.Value()->getEntry() ) ); + if ( occPrs && !occPrs->IsNull() ) { + AIS_ListOfInteractive shapes; occPrs->GetObjects( shapes ); + AIS_ListIteratorOfListOfInteractive interIter( shapes ); + for ( ; interIter.More(); interIter.Next() ) { + if ( mode == 0 ) + ic->SetDisplayMode( interIter.Value(), AIS_WireFrame, false ); + else if ( mode == 1 ) + ic->SetDisplayMode( interIter.Value(), AIS_Shaded, false ); + } + } + } + ic->UpdateCurrentViewer(); + } +} //===================================================================================== // EXPORTED METHODS //===================================================================================== extern "C" { - bool OnGUIEvent(int theCommandID, QAD_Desktop* parent) - {return DisplayGUI::OnGUIEvent(theCommandID, parent);} - - void BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO) - {return DisplayGUI::BuildPresentation(theIO);} + GEOMGUI* GetLibGUI() + { + return DisplayGUI::GetDisplayGUI(); + } } diff --git a/src/DisplayGUI/DisplayGUI.h b/src/DisplayGUI/DisplayGUI.h index 1c4aef111..bf2b57ac1 100644 --- a/src/DisplayGUI/DisplayGUI.h +++ b/src/DisplayGUI/DisplayGUI.h @@ -24,43 +24,59 @@ // File : DisplayGUI.h // Author : Damien COQUERET // Module : GEOM -// $Header: +// $Header$ #ifndef DISPLAYGUI_H #define DISPLAYGUI_H +#include "GEOMGUI.h" #include "GEOMBase.h" //================================================================================= // class : GEOMBase_Display // purpose : //================================================================================= -class DisplayGUI : public QObject +class QAD_ViewFrame; +class DisplayGUI : public GEOMGUI { - Q_OBJECT /* for QT compatibility */ +protected: + DisplayGUI(); // hide constructor to avoid direct creation public : - DisplayGUI(); ~DisplayGUI(); - static bool OnGUIEvent(int theCommandID, QAD_Desktop* parent); - static void BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO); + // Get the only DisplayGUI object + static DisplayGUI* GetDisplayGUI(); - void OnDisplayAll(bool onlyPreviousDisplayedObject = false); - void OnVTKDisplayOnly(); - void OnDisplayOnly(); - void OnErase(); + // Dispatch menu command + bool OnGUIEvent(int theCommandID, QAD_Desktop* parent); - /* Method opening context for any sub shape selection */ - bool PrepareSubShapeSelection(const int SubShapeType, Standard_Integer& returnLocalContextId); - /* Method opening context for sub shape selection on an argument shape */ - bool PrepareSubShapeSelectionArgumentShape(const TopoDS_Shape& aShape, const int SubShapeType, - Standard_Integer& returnLocalContextId); + // Display all GEOM objects + void DisplayAll(); + // Erase all GEOM objects + void EraseAll(); + // Display selected GEOM objects + void Display(); + // Display selected GEOM objects and erase other + void DisplayOnly(); + // Erase selected GEOM objects + void Erase(); - GEOMBase* myGeomBase; - GEOMContext* myGeomGUI; - GEOM::GEOM_Gen_var myGeom; /* Current Geom Component */ + // DISPLAY MODE methods : 0 - wireframe, 1 - shading + // Set display mode for the viewer (current viewer if - 0 ) + void SetDisplayMode( const int mode, QAD_ViewFrame* viewFrame = 0 ); + // Get display mode of the viewer (current viewer if - 0 ) + int GetDisplayMode( QAD_ViewFrame* viewFrame = 0 ); + // Invert display mode ( shadin <-> wireframe ) for the viewer + // (current viewer if = 0 ) + void InvertDisplayMode( QAD_ViewFrame* viewFrame = 0 ); + // Set display mode for selected objects in the viewer given + // (current viewer if = 0 ) + void ChangeDisplayMode( const int mode, QAD_ViewFrame* viewFrame = 0 ); + +private: + static DisplayGUI* myGUIObject; // the only DisplayGUI object }; #endif diff --git a/src/DisplayGUI/Makefile.in b/src/DisplayGUI/Makefile.in index d1cd6aa6a..8d0958981 100644 --- a/src/DisplayGUI/Makefile.in +++ b/src/DisplayGUI/Makefile.in @@ -42,10 +42,9 @@ EXPORT_HEADERS= DisplayGUI.h LIB_SRC = DisplayGUI.cxx -LIB_MOC = \ - DisplayGUI.h +LIB_MOC = -LIB_CLIENT_IDL = SALOME_Exception.idl +LIB_CLIENT_IDL = SALOME_Exception.idl SALOME_GenericObj.idl LIB_SERVER_IDL = @@ -54,6 +53,6 @@ LIB_SERVER_IDL = CPPFLAGS += $(QT_INCLUDES) $(VTK_INCLUDES) $(OCC_INCLUDES) $(PYTHON_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome CXXFLAGS += -I${KERNEL_ROOT_DIR}/include/salome -LDFLAGS += -lGEOMBase +LDFLAGS += -lGEOMGUI @CONCLUDE@ diff --git a/src/DlgRef/DlgRef_1List1Spin1Btn_QTD.cxx b/src/DlgRef/DlgRef_1List1Spin1Btn_QTD.cxx new file mode 100644 index 000000000..271cd6d1c --- /dev/null +++ b/src/DlgRef/DlgRef_1List1Spin1Btn_QTD.cxx @@ -0,0 +1,73 @@ +/**************************************************************************** +** Form implementation generated from reading ui file 'DlgRef_1List1Spin1Btn_QTD.ui' +** +** Created: Wed Mar 17 11:29:24 2004 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#include "DlgRef_1List1Spin1Btn_QTD.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Constructs a DlgRef_1List1Spin1Btn_QTD which is a child of 'parent', with the + * name 'name' and widget flags set to 'f'. + */ +DlgRef_1List1Spin1Btn_QTD::DlgRef_1List1Spin1Btn_QTD( QWidget* parent, const char* name, WFlags fl ) + : QWidget( parent, name, fl ) +{ + if ( !name ) + setName( "DlgRef_1List1Spin1Btn_QTD" ); + resize( 204, 148 ); + setCaption( trUtf8( "DlgRef_3Sel4Spin2Check_QTD" ) ); + DlgRef_1List1Spin1Btn_QTDLayout = new QGridLayout( this, 1, 1, 11, 6, "DlgRef_1List1Spin1Btn_QTDLayout"); + + GroupBox1 = new QGroupBox( this, "GroupBox1" ); + GroupBox1->setTitle( trUtf8( "" ) ); + GroupBox1->setColumnLayout(0, Qt::Vertical ); + GroupBox1->layout()->setSpacing( 6 ); + GroupBox1->layout()->setMargin( 11 ); + GroupBox1Layout = new QGridLayout( GroupBox1->layout() ); + GroupBox1Layout->setAlignment( Qt::AlignTop ); + QSpacerItem* spacer = new QSpacerItem( 0, 23, QSizePolicy::Minimum, QSizePolicy::Expanding ); + GroupBox1Layout->addItem( spacer, 3, 1 ); + + ListView1 = new QListView( GroupBox1, "ListView1" ); + + GroupBox1Layout->addMultiCellWidget( ListView1, 0, 3, 0, 0 ); + + TextLabel1 = new QLabel( GroupBox1, "TextLabel1" ); + TextLabel1->setText( trUtf8( "TL1" ) ); + + GroupBox1Layout->addWidget( TextLabel1, 0, 1 ); + + SpinBox1 = new QSpinBox( GroupBox1, "SpinBox1" ); + + GroupBox1Layout->addWidget( SpinBox1, 1, 1 ); + + PushButton1 = new QPushButton( GroupBox1, "PushButton1" ); + PushButton1->setText( trUtf8( "" ) ); + + GroupBox1Layout->addWidget( PushButton1, 2, 1 ); + + DlgRef_1List1Spin1Btn_QTDLayout->addWidget( GroupBox1, 0, 0 ); +} + +/* + * Destroys the object and frees any allocated resources + */ +DlgRef_1List1Spin1Btn_QTD::~DlgRef_1List1Spin1Btn_QTD() +{ + // no need to delete child widgets, Qt does it all for us +} + diff --git a/src/DlgRef/DlgRef_1List1Spin1Btn_QTD.h b/src/DlgRef/DlgRef_1List1Spin1Btn_QTD.h new file mode 100644 index 000000000..909db129e --- /dev/null +++ b/src/DlgRef/DlgRef_1List1Spin1Btn_QTD.h @@ -0,0 +1,44 @@ +/**************************************************************************** +** Form interface generated from reading ui file 'DlgRef_1List1Spin1Btn_QTD.ui' +** +** Created: Wed Mar 17 11:29:24 2004 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#ifndef DLGREF_1LIST1SPIN1BTN_QTD_H +#define DLGREF_1LIST1SPIN1BTN_QTD_H + +#include +#include +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QGroupBox; +class QLabel; +class QListView; +class QListViewItem; +class QPushButton; +class QSpinBox; + +class DlgRef_1List1Spin1Btn_QTD : public QWidget +{ + Q_OBJECT + +public: + DlgRef_1List1Spin1Btn_QTD( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + ~DlgRef_1List1Spin1Btn_QTD(); + + QGroupBox* GroupBox1; + QListView* ListView1; + QLabel* TextLabel1; + QSpinBox* SpinBox1; + QPushButton* PushButton1; + + +protected: + QGridLayout* DlgRef_1List1Spin1Btn_QTDLayout; + QGridLayout* GroupBox1Layout; +}; + +#endif // DLGREF_1LIST1SPIN1BTN_QTD_H diff --git a/src/DlgRef/DlgRef_1Sel1Check_QTD.cxx b/src/DlgRef/DlgRef_1Sel1Check_QTD.cxx index 98de50013..7010f4115 100644 --- a/src/DlgRef/DlgRef_1Sel1Check_QTD.cxx +++ b/src/DlgRef/DlgRef_1Sel1Check_QTD.cxx @@ -1,7 +1,7 @@ /**************************************************************************** ** Form implementation generated from reading ui file 'DlgRef_1Sel1Check_QTD.ui' ** -** Created: ven oct 10 11:28:38 2003 +** Created: Thu May 20 11:55:05 2004 ** by: The User Interface Compiler (uic) ** ** WARNING! All changes made in this file will be lost! @@ -9,11 +9,11 @@ #include "DlgRef_1Sel1Check_QTD.h" #include +#include #include #include #include #include -#include #include #include #include @@ -27,7 +27,7 @@ DlgRef_1Sel1Check_QTD::DlgRef_1Sel1Check_QTD( QWidget* parent, const char* name { if ( !name ) setName( "DlgRef_1Sel1Check_QTD" ); - resize( 129, 76 ); + resize( 382, 219 ); setCaption( trUtf8( "DlgRef_1Sel1Check_QTD" ) ); DlgRef_1Sel1Check_QTDLayout = new QGridLayout( this, 1, 1, 0, 6, "DlgRef_1Sel1Check_QTDLayout"); @@ -39,34 +39,38 @@ DlgRef_1Sel1Check_QTD::DlgRef_1Sel1Check_QTD( QWidget* parent, const char* name GroupBox1Layout = new QGridLayout( GroupBox1->layout() ); GroupBox1Layout->setAlignment( Qt::AlignTop ); - Layout1 = new QGridLayout( 0, 1, 1, 0, 6, "Layout1"); + Layout3 = new QGridLayout( 0, 1, 1, 0, 6, "Layout3"); TextLabel1 = new QLabel( GroupBox1, "TextLabel1" ); TextLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel1->sizePolicy().hasHeightForWidth() ) ); TextLabel1->setText( trUtf8( "TL1" ) ); - Layout1->addWidget( TextLabel1, 0, 0 ); - QSpacerItem* spacer = new QSpacerItem( 0, 113, QSizePolicy::Minimum, QSizePolicy::Expanding ); - Layout1->addItem( spacer, 2, 2 ); + Layout3->addWidget( TextLabel1, 0, 0 ); PushButton1 = new QPushButton( GroupBox1, "PushButton1" ); PushButton1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton1->sizePolicy().hasHeightForWidth() ) ); PushButton1->setText( trUtf8( "" ) ); - Layout1->addWidget( PushButton1, 0, 1 ); + Layout3->addWidget( PushButton1, 0, 1 ); - LineEdit1 = new QLineEdit( GroupBox1, "LineEdit1" ); + CheckButton1 = new QCheckBox( GroupBox1, "CheckButton1" ); + CheckButton1->setText( trUtf8( "" ) ); - Layout1->addWidget( LineEdit1, 0, 2 ); + Layout3->addMultiCellWidget( CheckButton1, 1, 1, 0, 2 ); + QSpacerItem* spacer = new QSpacerItem( 0, 16, QSizePolicy::Minimum, QSizePolicy::Expanding ); + Layout3->addItem( spacer, 2, 2 ); - CheckButton1 = new QRadioButton( GroupBox1, "CheckButton1" ); - CheckButton1->setText( trUtf8( "" ) ); + LineEdit1 = new QLineEdit( GroupBox1, "LineEdit1" ); - Layout1->addMultiCellWidget( CheckButton1, 1, 1, 0, 2 ); + Layout3->addWidget( LineEdit1, 0, 2 ); - GroupBox1Layout->addLayout( Layout1, 0, 0 ); + GroupBox1Layout->addLayout( Layout3, 0, 0 ); DlgRef_1Sel1Check_QTDLayout->addWidget( GroupBox1, 0, 0 ); + + // tab order + setTabOrder( PushButton1, LineEdit1 ); + setTabOrder( LineEdit1, CheckButton1 ); } /* diff --git a/src/DlgRef/DlgRef_1Sel1Check_QTD.h b/src/DlgRef/DlgRef_1Sel1Check_QTD.h index 7f083d9ff..4ff71d4bd 100644 --- a/src/DlgRef/DlgRef_1Sel1Check_QTD.h +++ b/src/DlgRef/DlgRef_1Sel1Check_QTD.h @@ -1,7 +1,7 @@ /**************************************************************************** ** Form interface generated from reading ui file 'DlgRef_1Sel1Check_QTD.ui' ** -** Created: ven oct 10 11:28:37 2003 +** Created: Thu May 20 11:55:05 2004 ** by: The User Interface Compiler (uic) ** ** WARNING! All changes made in this file will be lost! @@ -14,11 +14,11 @@ class QVBoxLayout; class QHBoxLayout; class QGridLayout; +class QCheckBox; class QGroupBox; class QLabel; class QLineEdit; class QPushButton; -class QRadioButton; class DlgRef_1Sel1Check_QTD : public QWidget { @@ -31,14 +31,14 @@ public: QGroupBox* GroupBox1; QLabel* TextLabel1; QPushButton* PushButton1; + QCheckBox* CheckButton1; QLineEdit* LineEdit1; - QRadioButton* CheckButton1; protected: QGridLayout* DlgRef_1Sel1Check_QTDLayout; QGridLayout* GroupBox1Layout; - QGridLayout* Layout1; + QGridLayout* Layout3; }; #endif // DLGREF_1SEL1CHECK_QTD_H diff --git a/src/DlgRef/DlgRef_1Sel1Spin1Check_QTD.cxx b/src/DlgRef/DlgRef_1Sel1Spin1Check_QTD.cxx index 12fc89820..86f49fb17 100644 --- a/src/DlgRef/DlgRef_1Sel1Spin1Check_QTD.cxx +++ b/src/DlgRef/DlgRef_1Sel1Spin1Check_QTD.cxx @@ -1,7 +1,7 @@ /**************************************************************************** ** Form implementation generated from reading ui file 'DlgRef_1Sel1Spin1Check_QTD.ui' ** -** Created: lun nov 17 14:16:09 2003 +** Created: Mon May 24 15:59:03 2004 ** by: The User Interface Compiler (uic) ** ** WARNING! All changes made in this file will be lost! @@ -9,11 +9,11 @@ #include "DlgRef_1Sel1Spin1Check_QTD.h" #include +#include #include #include #include #include -#include #include #include #include @@ -28,7 +28,7 @@ DlgRef_1Sel1Spin1Check_QTD::DlgRef_1Sel1Spin1Check_QTD( QWidget* parent, const { if ( !name ) setName( "DlgRef_1Sel1Spin1Check_QTD" ); - resize( 129, 106 ); + resize( 163, 109 ); setCaption( trUtf8( "DlgRef_1Sel1Spin1Check_QTD" ) ); DlgRef_1Sel1Spin1Check_QTDLayout = new QGridLayout( this, 1, 1, 0, 6, "DlgRef_1Sel1Spin1Check_QTDLayout"); @@ -40,21 +40,7 @@ DlgRef_1Sel1Spin1Check_QTD::DlgRef_1Sel1Spin1Check_QTD( QWidget* parent, const GroupBox1Layout = new QGridLayout( GroupBox1->layout() ); GroupBox1Layout->setAlignment( Qt::AlignTop ); - Layout1 = new QGridLayout( 0, 1, 1, 0, 6, "Layout1"); - QSpacerItem* spacer = new QSpacerItem( 0, 120, QSizePolicy::Minimum, QSizePolicy::Expanding ); - Layout1->addItem( spacer, 3, 2 ); - - TextLabel1 = new QLabel( GroupBox1, "TextLabel1" ); - TextLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel1->sizePolicy().hasHeightForWidth() ) ); - TextLabel1->setText( trUtf8( "TL1" ) ); - - Layout1->addWidget( TextLabel1, 0, 0 ); - - PushButton1 = new QPushButton( GroupBox1, "PushButton1" ); - PushButton1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton1->sizePolicy().hasHeightForWidth() ) ); - PushButton1->setText( trUtf8( "" ) ); - - Layout1->addWidget( PushButton1, 0, 1 ); + Layout8 = new QGridLayout( 0, 1, 1, 0, 6, "Layout8"); Layout2 = new QGridLayout( 0, 1, 1, 0, 6, "Layout2"); @@ -69,18 +55,32 @@ DlgRef_1Sel1Spin1Check_QTD::DlgRef_1Sel1Spin1Check_QTD( QWidget* parent, const Layout2->addWidget( TextLabel2, 0, 0 ); - Layout1->addMultiCellLayout( Layout2, 1, 1, 0, 2 ); + Layout8->addMultiCellLayout( Layout2, 1, 1, 0, 2 ); + + TextLabel1 = new QLabel( GroupBox1, "TextLabel1" ); + TextLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel1->sizePolicy().hasHeightForWidth() ) ); + TextLabel1->setText( trUtf8( "TL1" ) ); + + Layout8->addWidget( TextLabel1, 0, 0 ); LineEdit1 = new QLineEdit( GroupBox1, "LineEdit1" ); - Layout1->addWidget( LineEdit1, 0, 2 ); + Layout8->addWidget( LineEdit1, 0, 2 ); + + PushButton1 = new QPushButton( GroupBox1, "PushButton1" ); + PushButton1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton1->sizePolicy().hasHeightForWidth() ) ); + PushButton1->setText( trUtf8( "" ) ); + + Layout8->addWidget( PushButton1, 0, 1 ); - CheckButton1 = new QRadioButton( GroupBox1, "CheckButton1" ); + CheckButton1 = new QCheckBox( GroupBox1, "CheckButton1" ); CheckButton1->setText( trUtf8( "" ) ); - Layout1->addMultiCellWidget( CheckButton1, 2, 2, 0, 2 ); + Layout8->addMultiCellWidget( CheckButton1, 2, 2, 0, 2 ); + QSpacerItem* spacer = new QSpacerItem( 0, 16, QSizePolicy::Minimum, QSizePolicy::Expanding ); + Layout8->addItem( spacer, 3, 2 ); - GroupBox1Layout->addLayout( Layout1, 0, 0 ); + GroupBox1Layout->addLayout( Layout8, 0, 0 ); DlgRef_1Sel1Spin1Check_QTDLayout->addWidget( GroupBox1, 0, 0 ); } diff --git a/src/DlgRef/DlgRef_1Sel1Spin1Check_QTD.h b/src/DlgRef/DlgRef_1Sel1Spin1Check_QTD.h index cf3722b32..a14bb56e6 100644 --- a/src/DlgRef/DlgRef_1Sel1Spin1Check_QTD.h +++ b/src/DlgRef/DlgRef_1Sel1Spin1Check_QTD.h @@ -1,7 +1,7 @@ /**************************************************************************** ** Form interface generated from reading ui file 'DlgRef_1Sel1Spin1Check_QTD.ui' ** -** Created: lun nov 17 14:16:09 2003 +** Created: Mon May 24 15:59:03 2004 ** by: The User Interface Compiler (uic) ** ** WARNING! All changes made in this file will be lost! @@ -14,11 +14,11 @@ class QVBoxLayout; class QHBoxLayout; class QGridLayout; +class QCheckBox; class QGroupBox; class QLabel; class QLineEdit; class QPushButton; -class QRadioButton; class QSpinBox; class DlgRef_1Sel1Spin1Check_QTD : public QWidget @@ -30,18 +30,18 @@ public: ~DlgRef_1Sel1Spin1Check_QTD(); QGroupBox* GroupBox1; - QLabel* TextLabel1; - QPushButton* PushButton1; QSpinBox* SpinBox1; QLabel* TextLabel2; + QLabel* TextLabel1; QLineEdit* LineEdit1; - QRadioButton* CheckButton1; + QPushButton* PushButton1; + QCheckBox* CheckButton1; protected: QGridLayout* DlgRef_1Sel1Spin1Check_QTDLayout; QGridLayout* GroupBox1Layout; - QGridLayout* Layout1; + QGridLayout* Layout8; QGridLayout* Layout2; }; diff --git a/src/DlgRef/DlgRef_1Sel3Check_QTD.cxx b/src/DlgRef/DlgRef_1Sel3Check_QTD.cxx index 3778dd33e..7f35197cc 100644 --- a/src/DlgRef/DlgRef_1Sel3Check_QTD.cxx +++ b/src/DlgRef/DlgRef_1Sel3Check_QTD.cxx @@ -1,7 +1,7 @@ /**************************************************************************** ** Form implementation generated from reading ui file 'DlgRef_1Sel3Check_QTD.ui' ** -** Created: lun nov 17 11:32:21 2003 +** Created: Thu May 20 10:15:08 2004 ** by: The User Interface Compiler (uic) ** ** WARNING! All changes made in this file will be lost! @@ -9,11 +9,11 @@ #include "DlgRef_1Sel3Check_QTD.h" #include +#include #include #include #include #include -#include #include #include #include @@ -27,7 +27,7 @@ DlgRef_1Sel3Check_QTD::DlgRef_1Sel3Check_QTD( QWidget* parent, const char* name { if ( !name ) setName( "DlgRef_1Sel3Check_QTD" ); - resize( 129, 114 ); + resize( 163, 116 ); setCaption( trUtf8( "DlgRef_1Sel3Check_QTD" ) ); DlgRef_1Sel3Check_QTDLayout = new QGridLayout( this, 1, 1, 0, 6, "DlgRef_1Sel3Check_QTDLayout"); @@ -39,44 +39,50 @@ DlgRef_1Sel3Check_QTD::DlgRef_1Sel3Check_QTD( QWidget* parent, const char* name GroupBox1Layout = new QGridLayout( GroupBox1->layout() ); GroupBox1Layout->setAlignment( Qt::AlignTop ); - Layout1 = new QGridLayout( 0, 1, 1, 0, 6, "Layout1"); + Layout6 = new QGridLayout( 0, 1, 1, 0, 6, "Layout6"); + QSpacerItem* spacer = new QSpacerItem( 0, 16, QSizePolicy::Minimum, QSizePolicy::Expanding ); + Layout6->addItem( spacer, 4, 2 ); - CheckButton2 = new QRadioButton( GroupBox1, "CheckButton2" ); - CheckButton2->setText( trUtf8( "" ) ); + LineEdit1 = new QLineEdit( GroupBox1, "LineEdit1" ); - Layout1->addMultiCellWidget( CheckButton2, 2, 2, 0, 2 ); + Layout6->addWidget( LineEdit1, 0, 2 ); - TextLabel1 = new QLabel( GroupBox1, "TextLabel1" ); - TextLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel1->sizePolicy().hasHeightForWidth() ) ); - TextLabel1->setText( trUtf8( "TL1" ) ); + CheckButton2 = new QCheckBox( GroupBox1, "CheckButton2" ); + CheckButton2->setText( trUtf8( "" ) ); - Layout1->addWidget( TextLabel1, 0, 0 ); + Layout6->addMultiCellWidget( CheckButton2, 2, 2, 0, 2 ); - PushButton1 = new QPushButton( GroupBox1, "PushButton1" ); - PushButton1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton1->sizePolicy().hasHeightForWidth() ) ); - PushButton1->setText( trUtf8( "" ) ); + CheckButton1 = new QCheckBox( GroupBox1, "CheckButton1" ); + CheckButton1->setText( trUtf8( "" ) ); - Layout1->addWidget( PushButton1, 0, 1 ); - QSpacerItem* spacer = new QSpacerItem( 0, 60, QSizePolicy::Minimum, QSizePolicy::Expanding ); - Layout1->addItem( spacer, 4, 2 ); + Layout6->addMultiCellWidget( CheckButton1, 1, 1, 0, 2 ); - CheckButton3 = new QRadioButton( GroupBox1, "CheckButton3" ); + CheckButton3 = new QCheckBox( GroupBox1, "CheckButton3" ); CheckButton3->setText( trUtf8( "" ) ); - Layout1->addMultiCellWidget( CheckButton3, 3, 3, 0, 2 ); + Layout6->addMultiCellWidget( CheckButton3, 3, 3, 0, 2 ); - CheckButton1 = new QRadioButton( GroupBox1, "CheckButton1" ); - CheckButton1->setText( trUtf8( "" ) ); + PushButton1 = new QPushButton( GroupBox1, "PushButton1" ); + PushButton1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton1->sizePolicy().hasHeightForWidth() ) ); + PushButton1->setText( trUtf8( "" ) ); - Layout1->addMultiCellWidget( CheckButton1, 1, 1, 0, 2 ); + Layout6->addWidget( PushButton1, 0, 1 ); - LineEdit1 = new QLineEdit( GroupBox1, "LineEdit1" ); + TextLabel1 = new QLabel( GroupBox1, "TextLabel1" ); + TextLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel1->sizePolicy().hasHeightForWidth() ) ); + TextLabel1->setText( trUtf8( "TL1" ) ); - Layout1->addWidget( LineEdit1, 0, 2 ); + Layout6->addWidget( TextLabel1, 0, 0 ); - GroupBox1Layout->addLayout( Layout1, 0, 0 ); + GroupBox1Layout->addLayout( Layout6, 0, 0 ); DlgRef_1Sel3Check_QTDLayout->addWidget( GroupBox1, 0, 0 ); + + // tab order + setTabOrder( PushButton1, LineEdit1 ); + setTabOrder( LineEdit1, CheckButton1 ); + setTabOrder( CheckButton1, CheckButton2 ); + setTabOrder( CheckButton2, CheckButton3 ); } /* diff --git a/src/DlgRef/DlgRef_1Sel3Check_QTD.h b/src/DlgRef/DlgRef_1Sel3Check_QTD.h index 248f7f773..a63e25ea7 100644 --- a/src/DlgRef/DlgRef_1Sel3Check_QTD.h +++ b/src/DlgRef/DlgRef_1Sel3Check_QTD.h @@ -1,7 +1,7 @@ /**************************************************************************** ** Form interface generated from reading ui file 'DlgRef_1Sel3Check_QTD.ui' ** -** Created: lun nov 17 11:32:20 2003 +** Created: Thu May 20 10:15:07 2004 ** by: The User Interface Compiler (uic) ** ** WARNING! All changes made in this file will be lost! @@ -14,11 +14,11 @@ class QVBoxLayout; class QHBoxLayout; class QGridLayout; +class QCheckBox; class QGroupBox; class QLabel; class QLineEdit; class QPushButton; -class QRadioButton; class DlgRef_1Sel3Check_QTD : public QWidget { @@ -29,18 +29,18 @@ public: ~DlgRef_1Sel3Check_QTD(); QGroupBox* GroupBox1; - QRadioButton* CheckButton2; - QLabel* TextLabel1; - QPushButton* PushButton1; - QRadioButton* CheckButton3; - QRadioButton* CheckButton1; QLineEdit* LineEdit1; + QCheckBox* CheckButton2; + QCheckBox* CheckButton1; + QCheckBox* CheckButton3; + QPushButton* PushButton1; + QLabel* TextLabel1; protected: QGridLayout* DlgRef_1Sel3Check_QTDLayout; QGridLayout* GroupBox1Layout; - QGridLayout* Layout1; + QGridLayout* Layout6; }; #endif // DLGREF_1SEL3CHECK_QTD_H diff --git a/src/DlgRef/DlgRef_1Sel_Ext.h b/src/DlgRef/DlgRef_1Sel_Ext.h new file mode 100644 index 000000000..9b995ddcb --- /dev/null +++ b/src/DlgRef/DlgRef_1Sel_Ext.h @@ -0,0 +1,28 @@ +/**************************************************************************** +** Form interface generated from reading ui file 'DlgRef_1Sel_QTD.ui' +** +** Created: lun sep 22 17:38:05 2003 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#ifndef DlgRef_1Sel_Ext_H +#define DlgRef_1Sel_Ext_H + +#include "DlgRef_1Sel_QTD.h" + +class QGridLayout; + +class DlgRef_1Sel_Ext : public DlgRef_1Sel_QTD +{ + Q_OBJECT + +public: + DlgRef_1Sel_Ext( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ) + : DlgRef_1Sel_QTD( parent, name, fl ) {}; + ~DlgRef_1Sel_Ext() {}; + + QGridLayout* getGroupBoxLayout() { return GroupBox1Layout; } +}; + +#endif // DlgRef_1Sel_Ext_H diff --git a/src/DlgRef/DlgRef_2Sel1Spin.cxx b/src/DlgRef/DlgRef_2Sel1Spin.cxx index cb8499e99..b42b334cf 100644 --- a/src/DlgRef/DlgRef_2Sel1Spin.cxx +++ b/src/DlgRef/DlgRef_2Sel1Spin.cxx @@ -31,6 +31,7 @@ #include #include #include +#include /* * Constructs a DlgRef_2Sel1Spin which is a child of 'parent', with the @@ -42,6 +43,10 @@ DlgRef_2Sel1Spin::DlgRef_2Sel1Spin(QWidget* parent, const char* name, WFlags fl SpinBox1->close(TRUE); SpinBox_DX = new DlgRef_SpinBox(GroupBox1, "SpinBox_DX"); Layout2->addWidget(SpinBox_DX, 0, 1); + + // PAL 6532 + PushButton1->setAutoDefault( false ); + PushButton2->setAutoDefault( false ); } diff --git a/src/DlgRef/DlgRef_2Sel1Spin1Check.cxx b/src/DlgRef/DlgRef_2Sel1Spin1Check.cxx deleted file mode 100644 index c4d8c0619..000000000 --- a/src/DlgRef/DlgRef_2Sel1Spin1Check.cxx +++ /dev/null @@ -1,54 +0,0 @@ -// 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 : DlgRef_2Sel1Spin1Check.cxx -// Author : Damien COQUERET -// Module : GEOM -// $Header: - -#include "DlgRef_2Sel1Spin1Check.h" - -#include -#include -#include - -/* - * Constructs a DlgRef_2Sel1Spin which is a child of 'parent', with the - * name 'name' and widget flags set to 'f' - */ -DlgRef_2Sel1Spin1Check::DlgRef_2Sel1Spin1Check(QWidget* parent, const char* name, WFlags fl) - :DlgRef_2Sel1Spin1Check_QTD(parent, name, fl) -{ - SpinBox1->close(TRUE); - SpinBox_DX = new DlgRef_SpinBox(GroupBox1, "SpinBox_DX"); - Layout2->addWidget(SpinBox_DX, 0, 1); -} - - -/* - * Destroys the object and frees any allocated resources - */ -DlgRef_2Sel1Spin1Check::~DlgRef_2Sel1Spin1Check() -{ - // no need to delete child widgets, Qt does it all for us -} diff --git a/src/DlgRef/DlgRef_2Sel1Spin1Check.h b/src/DlgRef/DlgRef_2Sel1Spin1Check.h deleted file mode 100644 index f26c0bfbe..000000000 --- a/src/DlgRef/DlgRef_2Sel1Spin1Check.h +++ /dev/null @@ -1,47 +0,0 @@ -// 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 : DlgRef_2Sel1Spin1Check.h -// Author : Damien COQUERET -// Module : GEOM -// $Header: - -#ifndef DLGREF_2SEL1SPIN1CHECK_H -#define DLGREF_2SEL1SPIN1CHECK_H - -#include "DlgRef_2Sel1Spin1Check_QTD.h" -#include "DlgRef_SpinBox.h" - -class DlgRef_2Sel1Spin1Check : public DlgRef_2Sel1Spin1Check_QTD -{ - Q_OBJECT - -public: - DlgRef_2Sel1Spin1Check(QWidget* parent = 0, const char* name = 0, WFlags fl = 0); - ~DlgRef_2Sel1Spin1Check(); - - DlgRef_SpinBox* SpinBox_DX; - -}; - -#endif // DLGREF_2SEL1SPIN1CHECK_H diff --git a/src/DlgRef/DlgRef_2Sel1Spin1Check_QTD.cxx b/src/DlgRef/DlgRef_2Sel1Spin1Check_QTD.cxx deleted file mode 100644 index 7fa002f40..000000000 --- a/src/DlgRef/DlgRef_2Sel1Spin1Check_QTD.cxx +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************** -** Form implementation generated from reading ui file 'DlgRef_2Sel1Spin1Check_QTD.ui' -** -** Created: mer oct 1 16:20:02 2003 -** by: The User Interface Compiler (uic) -** -** WARNING! All changes made in this file will be lost! -****************************************************************************/ -#include "DlgRef_2Sel1Spin1Check_QTD.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* - * Constructs a DlgRef_2Sel1Spin1Check_QTD which is a child of 'parent', with the - * name 'name' and widget flags set to 'f'. - */ -DlgRef_2Sel1Spin1Check_QTD::DlgRef_2Sel1Spin1Check_QTD( QWidget* parent, const char* name, WFlags fl ) - : QWidget( parent, name, fl ) -{ - if ( !name ) - setName( "DlgRef_2Sel1Spin1Check_QTD" ); - resize( 129, 117 ); - setCaption( trUtf8( "DlgRef_2Sel1Spin1Check_QTD" ) ); - DlgRef_2Sel1Spin1Check_QTDLayout = new QGridLayout( this, 1, 1, 0, 6, "DlgRef_2Sel1Spin1Check_QTDLayout"); - - GroupBox1 = new QGroupBox( this, "GroupBox1" ); - GroupBox1->setTitle( trUtf8( "" ) ); - GroupBox1->setColumnLayout(0, Qt::Vertical ); - GroupBox1->layout()->setSpacing( 6 ); - GroupBox1->layout()->setMargin( 11 ); - GroupBox1Layout = new QGridLayout( GroupBox1->layout() ); - GroupBox1Layout->setAlignment( Qt::AlignTop ); - - Layout1 = new QGridLayout( 0, 1, 1, 0, 6, "Layout1"); - - LineEdit1 = new QLineEdit( GroupBox1, "LineEdit1" ); - - Layout1->addWidget( LineEdit1, 0, 2 ); - - TextLabel1 = new QLabel( GroupBox1, "TextLabel1" ); - TextLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel1->sizePolicy().hasHeightForWidth() ) ); - TextLabel1->setText( trUtf8( "TL1" ) ); - - Layout1->addWidget( TextLabel1, 0, 0 ); - - TextLabel2 = new QLabel( GroupBox1, "TextLabel2" ); - TextLabel2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel2->sizePolicy().hasHeightForWidth() ) ); - TextLabel2->setText( trUtf8( "TL2" ) ); - - Layout1->addWidget( TextLabel2, 1, 0 ); - - LineEdit2 = new QLineEdit( GroupBox1, "LineEdit2" ); - - Layout1->addWidget( LineEdit2, 1, 2 ); - - PushButton1 = new QPushButton( GroupBox1, "PushButton1" ); - PushButton1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton1->sizePolicy().hasHeightForWidth() ) ); - PushButton1->setText( trUtf8( "" ) ); - - Layout1->addWidget( PushButton1, 0, 1 ); - QSpacerItem* spacer = new QSpacerItem( 0, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); - Layout1->addItem( spacer, 3, 2 ); - - PushButton2 = new QPushButton( GroupBox1, "PushButton2" ); - PushButton2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton2->sizePolicy().hasHeightForWidth() ) ); - PushButton2->setText( trUtf8( "" ) ); - - Layout1->addWidget( PushButton2, 1, 1 ); - - Layout2 = new QGridLayout( 0, 1, 1, 0, 6, "Layout2"); - - SpinBox1 = new QSpinBox( GroupBox1, "SpinBox1" ); - SpinBox1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, SpinBox1->sizePolicy().hasHeightForWidth() ) ); - - Layout2->addWidget( SpinBox1, 0, 1 ); - - CheckButton1 = new QRadioButton( GroupBox1, "CheckButton1" ); - CheckButton1->setText( trUtf8( "" ) ); - - Layout2->addWidget( CheckButton1, 0, 2 ); - - TextLabel3 = new QLabel( GroupBox1, "TextLabel3" ); - TextLabel3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel3->sizePolicy().hasHeightForWidth() ) ); - TextLabel3->setText( trUtf8( "TL3" ) ); - - Layout2->addWidget( TextLabel3, 0, 0 ); - - Layout1->addMultiCellLayout( Layout2, 2, 2, 0, 2 ); - - GroupBox1Layout->addLayout( Layout1, 0, 0 ); - - DlgRef_2Sel1Spin1Check_QTDLayout->addWidget( GroupBox1, 0, 0 ); -} - -/* - * Destroys the object and frees any allocated resources - */ -DlgRef_2Sel1Spin1Check_QTD::~DlgRef_2Sel1Spin1Check_QTD() -{ - // no need to delete child widgets, Qt does it all for us -} - diff --git a/src/DlgRef/DlgRef_2Sel1Spin1Check_QTD.h b/src/DlgRef/DlgRef_2Sel1Spin1Check_QTD.h deleted file mode 100644 index cbc33b9c0..000000000 --- a/src/DlgRef/DlgRef_2Sel1Spin1Check_QTD.h +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** Form interface generated from reading ui file 'DlgRef_2Sel1Spin1Check_QTD.ui' -** -** Created: mer oct 1 16:20:02 2003 -** by: The User Interface Compiler (uic) -** -** WARNING! All changes made in this file will be lost! -****************************************************************************/ -#ifndef DLGREF_2SEL1SPIN1CHECK_QTD_H -#define DLGREF_2SEL1SPIN1CHECK_QTD_H - -#include -#include -class QVBoxLayout; -class QHBoxLayout; -class QGridLayout; -class QGroupBox; -class QLabel; -class QLineEdit; -class QPushButton; -class QRadioButton; -class QSpinBox; - -class DlgRef_2Sel1Spin1Check_QTD : public QWidget -{ - Q_OBJECT - -public: - DlgRef_2Sel1Spin1Check_QTD( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); - ~DlgRef_2Sel1Spin1Check_QTD(); - - QGroupBox* GroupBox1; - QLineEdit* LineEdit1; - QLabel* TextLabel1; - QLabel* TextLabel2; - QLineEdit* LineEdit2; - QPushButton* PushButton1; - QPushButton* PushButton2; - QSpinBox* SpinBox1; - QRadioButton* CheckButton1; - QLabel* TextLabel3; - - -protected: - QGridLayout* DlgRef_2Sel1Spin1Check_QTDLayout; - QGridLayout* GroupBox1Layout; - QGridLayout* Layout1; - QGridLayout* Layout2; -}; - -#endif // DLGREF_2SEL1SPIN1CHECK_QTD_H diff --git a/src/DlgRef/DlgRef_2Sel1Spin2Check.cxx b/src/DlgRef/DlgRef_2Sel1Spin2Check.cxx new file mode 100644 index 000000000..717897572 --- /dev/null +++ b/src/DlgRef/DlgRef_2Sel1Spin2Check.cxx @@ -0,0 +1,54 @@ +// 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 : DlgRef_2Sel1Spin2Check.cxx +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +#include "DlgRef_2Sel1Spin2Check.h" + +#include +#include +#include + +/* + * Constructs a DlgRef_2Sel1Spin2Check which is a child of 'parent', with the + * name 'name' and widget flags set to 'f' + */ +DlgRef_2Sel1Spin2Check::DlgRef_2Sel1Spin2Check(QWidget* parent, const char* name, WFlags fl) + :DlgRef_2Sel1Spin2Check_QTD(parent, name, fl) +{ + SpinBox1->close(TRUE); + SpinBox_DX = new DlgRef_SpinBox(GroupBox1, "SpinBox_DX"); + Layout1->addWidget(SpinBox_DX, 2, 2); +} + + +/* + * Destroys the object and frees any allocated resources + */ +DlgRef_2Sel1Spin2Check::~DlgRef_2Sel1Spin2Check() +{ + // no need to delete child widgets, Qt does it all for us +} diff --git a/src/DlgRef/DlgRef_2Sel1Spin2Check.h b/src/DlgRef/DlgRef_2Sel1Spin2Check.h new file mode 100644 index 000000000..89e9d149c --- /dev/null +++ b/src/DlgRef/DlgRef_2Sel1Spin2Check.h @@ -0,0 +1,47 @@ +// 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 : DlgRef_2Sel1Spin2Check.h +// Author : Damien COQUERET +// Module : GEOM +// $Header: + +#ifndef DLGREF_2SEL1SPIN2CHECK_H +#define DLGREF_2SEL1SPIN2CHECK_H + +#include "DlgRef_2Sel1Spin2Check_QTD.h" +#include "DlgRef_SpinBox.h" + +class DlgRef_2Sel1Spin2Check : public DlgRef_2Sel1Spin2Check_QTD +{ + Q_OBJECT + +public: + DlgRef_2Sel1Spin2Check(QWidget* parent = 0, const char* name = 0, WFlags fl = 0); + ~DlgRef_2Sel1Spin2Check(); + + DlgRef_SpinBox* SpinBox_DX; + +}; + +#endif // DLGREF_2SEL1SPIN2CHECK_H diff --git a/src/DlgRef/DlgRef_2Sel1Spin2Check_QTD.cxx b/src/DlgRef/DlgRef_2Sel1Spin2Check_QTD.cxx new file mode 100644 index 000000000..7b54bed10 --- /dev/null +++ b/src/DlgRef/DlgRef_2Sel1Spin2Check_QTD.cxx @@ -0,0 +1,120 @@ +/**************************************************************************** +** Form implementation generated from reading ui file 'DlgRef_2Sel1Spin2Check_QTD.ui' +** +** Created: Fri Aug 13 15:32:26 2004 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#include "DlgRef_2Sel1Spin2Check_QTD.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Constructs a DlgRef_2Sel1Spin2Check_QTD which is a child of 'parent', with the + * name 'name' and widget flags set to 'f'. + */ +DlgRef_2Sel1Spin2Check_QTD::DlgRef_2Sel1Spin2Check_QTD( QWidget* parent, const char* name, WFlags fl ) + : QWidget( parent, name, fl ) +{ + if ( !name ) + setName( "DlgRef_2Sel1Spin2Check_QTD" ); + resize( 256, 139 ); + setCaption( trUtf8( "DlgRef_2Sel1Spin2Check_QTD" ) ); + DlgRef_2Sel1Spin2Check_QTDLayout = new QGridLayout( this, 1, 1, 0, 6, "DlgRef_2Sel1Spin2Check_QTDLayout"); + + GroupBox1 = new QGroupBox( this, "GroupBox1" ); + GroupBox1->setTitle( trUtf8( "" ) ); + GroupBox1->setColumnLayout(0, Qt::Vertical ); + GroupBox1->layout()->setSpacing( 6 ); + GroupBox1->layout()->setMargin( 11 ); + GroupBox1Layout = new QGridLayout( GroupBox1->layout() ); + GroupBox1Layout->setAlignment( Qt::AlignTop ); + + Layout1 = new QGridLayout( 0, 1, 1, 0, 6, "Layout1"); + + TextLabel2 = new QLabel( GroupBox1, "TextLabel2" ); + TextLabel2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel2->sizePolicy().hasHeightForWidth() ) ); + TextLabel2->setText( trUtf8( "TL2" ) ); + + Layout1->addWidget( TextLabel2, 1, 0 ); + + PushButton1 = new QPushButton( GroupBox1, "PushButton1" ); + PushButton1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton1->sizePolicy().hasHeightForWidth() ) ); + PushButton1->setText( trUtf8( "" ) ); + + Layout1->addWidget( PushButton1, 0, 1 ); + + TextLabel3 = new QLabel( GroupBox1, "TextLabel3" ); + TextLabel3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel3->sizePolicy().hasHeightForWidth() ) ); + TextLabel3->setText( trUtf8( "TL3" ) ); + + Layout1->addWidget( TextLabel3, 2, 0 ); + + TextLabel1 = new QLabel( GroupBox1, "TextLabel1" ); + TextLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel1->sizePolicy().hasHeightForWidth() ) ); + TextLabel1->setText( trUtf8( "TL1" ) ); + + Layout1->addWidget( TextLabel1, 0, 0 ); + QSpacerItem* spacer = new QSpacerItem( 0, 316, QSizePolicy::Minimum, QSizePolicy::Expanding ); + Layout1->addItem( spacer, 4, 2 ); + + CheckButton2 = new QCheckBox( GroupBox1, "CheckButton2" ); + CheckButton2->setText( trUtf8( "" ) ); + + Layout1->addWidget( CheckButton2, 2, 3 ); + + LineEdit2 = new QLineEdit( GroupBox1, "LineEdit2" ); + + Layout1->addMultiCellWidget( LineEdit2, 1, 1, 2, 3 ); + + PushButton2 = new QPushButton( GroupBox1, "PushButton2" ); + PushButton2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton2->sizePolicy().hasHeightForWidth() ) ); + PushButton2->setText( trUtf8( "" ) ); + + Layout1->addWidget( PushButton2, 1, 1 ); + + LineEdit1 = new QLineEdit( GroupBox1, "LineEdit1" ); + + Layout1->addMultiCellWidget( LineEdit1, 0, 0, 2, 3 ); + + CheckButton1 = new QCheckBox( GroupBox1, "CheckButton1" ); + CheckButton1->setText( trUtf8( "" ) ); + + Layout1->addMultiCellWidget( CheckButton1, 3, 3, 0, 3 ); + + SpinBox1 = new QSpinBox( GroupBox1, "SpinBox1" ); + SpinBox1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, SpinBox1->sizePolicy().hasHeightForWidth() ) ); + + Layout1->addWidget( SpinBox1, 2, 2 ); + + GroupBox1Layout->addLayout( Layout1, 0, 0 ); + + DlgRef_2Sel1Spin2Check_QTDLayout->addWidget( GroupBox1, 0, 0 ); + + // tab order + setTabOrder( PushButton1, LineEdit1 ); + setTabOrder( LineEdit1, PushButton2 ); + setTabOrder( PushButton2, LineEdit2 ); + setTabOrder( LineEdit2, SpinBox1 ); + setTabOrder( SpinBox1, CheckButton2 ); + setTabOrder( CheckButton2, CheckButton1 ); +} + +/* + * Destroys the object and frees any allocated resources + */ +DlgRef_2Sel1Spin2Check_QTD::~DlgRef_2Sel1Spin2Check_QTD() +{ + // no need to delete child widgets, Qt does it all for us +} + diff --git a/src/DlgRef/DlgRef_2Sel1Spin2Check_QTD.h b/src/DlgRef/DlgRef_2Sel1Spin2Check_QTD.h new file mode 100644 index 000000000..d090065d8 --- /dev/null +++ b/src/DlgRef/DlgRef_2Sel1Spin2Check_QTD.h @@ -0,0 +1,51 @@ +/**************************************************************************** +** Form interface generated from reading ui file 'DlgRef_2Sel1Spin2Check_QTD.ui' +** +** Created: Fri Aug 13 15:32:26 2004 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#ifndef DLGREF_2SEL1SPIN2CHECK_QTD_H +#define DLGREF_2SEL1SPIN2CHECK_QTD_H + +#include +#include +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QCheckBox; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class QSpinBox; + +class DlgRef_2Sel1Spin2Check_QTD : public QWidget +{ + Q_OBJECT + +public: + DlgRef_2Sel1Spin2Check_QTD( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + ~DlgRef_2Sel1Spin2Check_QTD(); + + QGroupBox* GroupBox1; + QLabel* TextLabel2; + QPushButton* PushButton1; + QLabel* TextLabel3; + QLabel* TextLabel1; + QCheckBox* CheckButton2; + QLineEdit* LineEdit2; + QPushButton* PushButton2; + QLineEdit* LineEdit1; + QCheckBox* CheckButton1; + QSpinBox* SpinBox1; + + +protected: + QGridLayout* DlgRef_2Sel1Spin2Check_QTDLayout; + QGridLayout* GroupBox1Layout; + QGridLayout* Layout1; +}; + +#endif // DLGREF_2SEL1SPIN2CHECK_QTD_H diff --git a/src/DlgRef/DlgRef_2Sel1Spin_QTD.cxx b/src/DlgRef/DlgRef_2Sel1Spin_QTD.cxx index 9c27921ac..cc32e36cb 100644 --- a/src/DlgRef/DlgRef_2Sel1Spin_QTD.cxx +++ b/src/DlgRef/DlgRef_2Sel1Spin_QTD.cxx @@ -1,7 +1,7 @@ /**************************************************************************** ** Form implementation generated from reading ui file 'DlgRef_2Sel1Spin_QTD.ui' ** -** Created: mar sep 23 16:05:09 2003 +** Created: Tue Jun 1 16:15:00 2004 ** by: The User Interface Compiler (uic) ** ** WARNING! All changes made in this file will be lost! @@ -27,7 +27,7 @@ DlgRef_2Sel1Spin_QTD::DlgRef_2Sel1Spin_QTD( QWidget* parent, const char* name, { if ( !name ) setName( "DlgRef_2Sel1Spin_QTD" ); - resize( 129, 117 ); + resize( 163, 122 ); setCaption( trUtf8( "DlgRef_2Sel1Spin_QTD" ) ); DlgRef_2Sel1Spin_QTDLayout = new QGridLayout( this, 1, 1, 0, 6, "DlgRef_2Sel1Spin_QTDLayout"); @@ -69,6 +69,8 @@ DlgRef_2Sel1Spin_QTD::DlgRef_2Sel1Spin_QTD( QWidget* parent, const char* name, TextLabel2 = new QLabel( GroupBox1, "TextLabel2" ); TextLabel2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel2->sizePolicy().hasHeightForWidth() ) ); + TextLabel2->setFrameShape( QLabel::NoFrame ); + TextLabel2->setFrameShadow( QLabel::Plain ); TextLabel2->setText( trUtf8( "TL2" ) ); Layout1->addWidget( TextLabel2, 1, 0 ); @@ -93,6 +95,12 @@ DlgRef_2Sel1Spin_QTD::DlgRef_2Sel1Spin_QTD( QWidget* parent, const char* name, GroupBox1Layout->addLayout( Layout1, 0, 0 ); DlgRef_2Sel1Spin_QTDLayout->addWidget( GroupBox1, 0, 0 ); + + // tab order + setTabOrder( PushButton1, LineEdit1 ); + setTabOrder( LineEdit1, PushButton2 ); + setTabOrder( PushButton2, LineEdit2 ); + setTabOrder( LineEdit2, SpinBox1 ); } /* diff --git a/src/DlgRef/DlgRef_2Sel1Spin_QTD.h b/src/DlgRef/DlgRef_2Sel1Spin_QTD.h index 8f1f48985..0d0abfc3c 100644 --- a/src/DlgRef/DlgRef_2Sel1Spin_QTD.h +++ b/src/DlgRef/DlgRef_2Sel1Spin_QTD.h @@ -1,7 +1,7 @@ /**************************************************************************** ** Form interface generated from reading ui file 'DlgRef_2Sel1Spin_QTD.ui' ** -** Created: mar sep 23 16:05:09 2003 +** Created: Tue Jun 1 16:14:59 2004 ** by: The User Interface Compiler (uic) ** ** WARNING! All changes made in this file will be lost! diff --git a/src/DlgRef/DlgRef_2Sel2Spin1Check.cxx b/src/DlgRef/DlgRef_2Sel2Spin1Check.cxx index e996c3cfa..f8ac135da 100644 --- a/src/DlgRef/DlgRef_2Sel2Spin1Check.cxx +++ b/src/DlgRef/DlgRef_2Sel2Spin1Check.cxx @@ -31,6 +31,7 @@ #include #include #include +#include /* * Constructs a DlgRef_2Sel1Spin which is a child of 'parent', with the @@ -45,6 +46,10 @@ DlgRef_2Sel2Spin1Check::DlgRef_2Sel2Spin1Check(QWidget* parent, const char* name SpinBox_DY = new DlgRef_SpinBox(GroupBox1, "SpinBox_DY"); Layout2->addWidget(SpinBox_DX, 0, 1); Layout2->addWidget(SpinBox_DY, 1, 1); + + // PAL 6532 + PushButton1->setAutoDefault( false ); + PushButton2->setAutoDefault( false ); } diff --git a/src/DlgRef/DlgRef_2Sel2Spin1Check_QTD.cxx b/src/DlgRef/DlgRef_2Sel2Spin1Check_QTD.cxx index 22d8dc808..5a1b88e5c 100644 --- a/src/DlgRef/DlgRef_2Sel2Spin1Check_QTD.cxx +++ b/src/DlgRef/DlgRef_2Sel2Spin1Check_QTD.cxx @@ -1,7 +1,7 @@ /**************************************************************************** ** Form implementation generated from reading ui file 'DlgRef_2Sel2Spin1Check_QTD.ui' ** -** Created: ven oct 24 09:53:25 2003 +** Created: Tue Jun 1 16:29:28 2004 ** by: The User Interface Compiler (uic) ** ** WARNING! All changes made in this file will be lost! @@ -9,11 +9,11 @@ #include "DlgRef_2Sel2Spin1Check_QTD.h" #include +#include #include #include #include #include -#include #include #include #include @@ -28,7 +28,7 @@ DlgRef_2Sel2Spin1Check_QTD::DlgRef_2Sel2Spin1Check_QTD( QWidget* parent, const { if ( !name ) setName( "DlgRef_2Sel2Spin1Check_QTD" ); - resize( 129, 164 ); + resize( 163, 170 ); setCaption( trUtf8( "DlgRef_2Sel2Spin1Check_QTD" ) ); DlgRef_2Sel2Spin1Check_QTDLayout = new QGridLayout( this, 1, 1, 0, 6, "DlgRef_2Sel2Spin1Check_QTDLayout"); @@ -48,11 +48,11 @@ DlgRef_2Sel2Spin1Check_QTD::DlgRef_2Sel2Spin1Check_QTD( QWidget* parent, const Layout1->addWidget( TextLabel2, 1, 0 ); - PushButton1 = new QPushButton( GroupBox1, "PushButton1" ); - PushButton1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton1->sizePolicy().hasHeightForWidth() ) ); - PushButton1->setText( trUtf8( "" ) ); + TextLabel1 = new QLabel( GroupBox1, "TextLabel1" ); + TextLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel1->sizePolicy().hasHeightForWidth() ) ); + TextLabel1->setText( trUtf8( "TL1" ) ); - Layout1->addWidget( PushButton1, 0, 1 ); + Layout1->addWidget( TextLabel1, 0, 0 ); Layout2 = new QGridLayout( 0, 1, 1, 0, 6, "Layout2"); @@ -80,36 +80,44 @@ DlgRef_2Sel2Spin1Check_QTD::DlgRef_2Sel2Spin1Check_QTD( QWidget* parent, const Layout1->addMultiCellLayout( Layout2, 2, 2, 0, 2 ); - TextLabel1 = new QLabel( GroupBox1, "TextLabel1" ); - TextLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel1->sizePolicy().hasHeightForWidth() ) ); - TextLabel1->setText( trUtf8( "TL1" ) ); + LineEdit1 = new QLineEdit( GroupBox1, "LineEdit1" ); - Layout1->addWidget( TextLabel1, 0, 0 ); + Layout1->addWidget( LineEdit1, 0, 2 ); + QSpacerItem* spacer = new QSpacerItem( 0, 16, QSizePolicy::Minimum, QSizePolicy::Expanding ); + Layout1->addItem( spacer, 4, 2 ); - PushButton2 = new QPushButton( GroupBox1, "PushButton2" ); - PushButton2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton2->sizePolicy().hasHeightForWidth() ) ); - PushButton2->setText( trUtf8( "" ) ); + CheckButton1 = new QCheckBox( GroupBox1, "CheckButton1" ); + CheckButton1->setText( trUtf8( "" ) ); - Layout1->addWidget( PushButton2, 1, 1 ); - QSpacerItem* spacer = new QSpacerItem( 0, 275, QSizePolicy::Minimum, QSizePolicy::Expanding ); - Layout1->addItem( spacer, 4, 2 ); + Layout1->addMultiCellWidget( CheckButton1, 3, 3, 0, 2 ); LineEdit2 = new QLineEdit( GroupBox1, "LineEdit2" ); Layout1->addWidget( LineEdit2, 1, 2 ); - CheckButton1 = new QRadioButton( GroupBox1, "CheckButton1" ); - CheckButton1->setText( trUtf8( "" ) ); + PushButton2 = new QPushButton( GroupBox1, "PushButton2" ); + PushButton2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton2->sizePolicy().hasHeightForWidth() ) ); + PushButton2->setText( trUtf8( "" ) ); - Layout1->addMultiCellWidget( CheckButton1, 3, 3, 0, 2 ); + Layout1->addWidget( PushButton2, 1, 1 ); - LineEdit1 = new QLineEdit( GroupBox1, "LineEdit1" ); + PushButton1 = new QPushButton( GroupBox1, "PushButton1" ); + PushButton1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton1->sizePolicy().hasHeightForWidth() ) ); + PushButton1->setText( trUtf8( "" ) ); - Layout1->addWidget( LineEdit1, 0, 2 ); + Layout1->addWidget( PushButton1, 0, 1 ); GroupBox1Layout->addLayout( Layout1, 0, 0 ); DlgRef_2Sel2Spin1Check_QTDLayout->addWidget( GroupBox1, 0, 0 ); + + // tab order + setTabOrder( PushButton1, LineEdit1 ); + setTabOrder( LineEdit1, PushButton2 ); + setTabOrder( PushButton2, LineEdit2 ); + setTabOrder( LineEdit2, SpinBox1 ); + setTabOrder( SpinBox1, SpinBox2 ); + setTabOrder( SpinBox2, CheckButton1 ); } /* diff --git a/src/DlgRef/DlgRef_2Sel2Spin1Check_QTD.h b/src/DlgRef/DlgRef_2Sel2Spin1Check_QTD.h index 624e360ed..dda68e4bb 100644 --- a/src/DlgRef/DlgRef_2Sel2Spin1Check_QTD.h +++ b/src/DlgRef/DlgRef_2Sel2Spin1Check_QTD.h @@ -1,7 +1,7 @@ /**************************************************************************** ** Form interface generated from reading ui file 'DlgRef_2Sel2Spin1Check_QTD.ui' ** -** Created: ven oct 24 09:53:25 2003 +** Created: Tue Jun 1 16:29:28 2004 ** by: The User Interface Compiler (uic) ** ** WARNING! All changes made in this file will be lost! @@ -14,11 +14,11 @@ class QVBoxLayout; class QHBoxLayout; class QGridLayout; +class QCheckBox; class QGroupBox; class QLabel; class QLineEdit; class QPushButton; -class QRadioButton; class QSpinBox; class DlgRef_2Sel2Spin1Check_QTD : public QWidget @@ -31,16 +31,16 @@ public: QGroupBox* GroupBox1; QLabel* TextLabel2; - QPushButton* PushButton1; + QLabel* TextLabel1; QSpinBox* SpinBox1; QLabel* TextLabel3; QLabel* TextLabel4; QSpinBox* SpinBox2; - QLabel* TextLabel1; - QPushButton* PushButton2; - QLineEdit* LineEdit2; - QRadioButton* CheckButton1; QLineEdit* LineEdit1; + QCheckBox* CheckButton1; + QLineEdit* LineEdit2; + QPushButton* PushButton2; + QPushButton* PushButton1; protected: diff --git a/src/DlgRef/DlgRef_2Sel4Spin1Check.cxx b/src/DlgRef/DlgRef_2Sel4Spin1Check.cxx index d10c1e50d..2a039dd2b 100644 --- a/src/DlgRef/DlgRef_2Sel4Spin1Check.cxx +++ b/src/DlgRef/DlgRef_2Sel4Spin1Check.cxx @@ -31,6 +31,7 @@ #include #include #include +#include /* * Constructs a DlgRef_2Sel1Spin which is a child of 'parent', with the @@ -51,6 +52,10 @@ DlgRef_2Sel4Spin1Check::DlgRef_2Sel4Spin1Check(QWidget* parent, const char* name Layout2->addWidget(SpinBox_DY1, 1, 1); Layout3->addWidget(SpinBox_DX2, 0, 1); Layout3->addWidget(SpinBox_DY2, 1, 1); + + // PAL 6532 + PushButton1->setAutoDefault( false ); + PushButton2->setAutoDefault( false ); } diff --git a/src/DlgRef/DlgRef_2Sel4Spin1Check_QTD.cxx b/src/DlgRef/DlgRef_2Sel4Spin1Check_QTD.cxx index 508e7c648..a59e6c6df 100644 --- a/src/DlgRef/DlgRef_2Sel4Spin1Check_QTD.cxx +++ b/src/DlgRef/DlgRef_2Sel4Spin1Check_QTD.cxx @@ -1,7 +1,7 @@ /**************************************************************************** ** Form implementation generated from reading ui file 'DlgRef_2Sel4Spin1Check_QTD.ui' ** -** Created: lun oct 27 11:40:44 2003 +** Created: Tue Jun 1 12:38:04 2004 ** by: The User Interface Compiler (uic) ** ** WARNING! All changes made in this file will be lost! @@ -9,11 +9,11 @@ #include "DlgRef_2Sel4Spin1Check_QTD.h" #include +#include #include #include #include #include -#include #include #include #include @@ -28,7 +28,7 @@ DlgRef_2Sel4Spin1Check_QTD::DlgRef_2Sel4Spin1Check_QTD( QWidget* parent, const { if ( !name ) setName( "DlgRef_2Sel4Spin1Check_QTD" ); - resize( 129, 222 ); + resize( 262, 230 ); setCaption( trUtf8( "DlgRef_2Sel4Spin1Check_QTD" ) ); DlgRef_2Sel4Spin1Check_QTDLayout = new QGridLayout( this, 1, 1, 0, 6, "DlgRef_2Sel4Spin1Check_QTDLayout"); @@ -40,17 +40,18 @@ DlgRef_2Sel4Spin1Check_QTD::DlgRef_2Sel4Spin1Check_QTD( QWidget* parent, const GroupBox1Layout = new QGridLayout( GroupBox1->layout() ); GroupBox1Layout->setAlignment( Qt::AlignTop ); - Layout1 = new QGridLayout( 0, 1, 1, 0, 6, "Layout1"); - - LineEdit2 = new QLineEdit( GroupBox1, "LineEdit2" ); - - Layout1->addWidget( LineEdit2, 1, 2 ); + Layout5 = new QGridLayout( 0, 1, 1, 0, 6, "Layout5"); PushButton1 = new QPushButton( GroupBox1, "PushButton1" ); PushButton1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton1->sizePolicy().hasHeightForWidth() ) ); PushButton1->setText( trUtf8( "" ) ); - Layout1->addWidget( PushButton1, 0, 1 ); + Layout5->addWidget( PushButton1, 0, 1 ); + + CheckButton1 = new QCheckBox( GroupBox1, "CheckButton1" ); + CheckButton1->setText( trUtf8( "" ) ); + + Layout5->addMultiCellWidget( CheckButton1, 3, 3, 0, 3 ); Layout2 = new QGridLayout( 0, 1, 1, 0, 6, "Layout2"); @@ -76,7 +77,35 @@ DlgRef_2Sel4Spin1Check_QTD::DlgRef_2Sel4Spin1Check_QTD( QWidget* parent, const Layout2->addWidget( TextLabel4, 1, 0 ); - Layout1->addMultiCellLayout( Layout2, 2, 2, 0, 2 ); + Layout5->addMultiCellLayout( Layout2, 2, 2, 0, 2 ); + + LineEdit2 = new QLineEdit( GroupBox1, "LineEdit2" ); + + Layout5->addWidget( LineEdit2, 1, 2 ); + + TextLabel1 = new QLabel( GroupBox1, "TextLabel1" ); + TextLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel1->sizePolicy().hasHeightForWidth() ) ); + TextLabel1->setText( trUtf8( "TL1" ) ); + + Layout5->addWidget( TextLabel1, 0, 0 ); + + LineEdit1 = new QLineEdit( GroupBox1, "LineEdit1" ); + + Layout5->addWidget( LineEdit1, 0, 2 ); + QSpacerItem* spacer = new QSpacerItem( 0, 16, QSizePolicy::Minimum, QSizePolicy::Expanding ); + Layout5->addItem( spacer, 5, 3 ); + + PushButton2 = new QPushButton( GroupBox1, "PushButton2" ); + PushButton2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton2->sizePolicy().hasHeightForWidth() ) ); + PushButton2->setText( trUtf8( "" ) ); + + Layout5->addWidget( PushButton2, 1, 1 ); + + TextLabel2 = new QLabel( GroupBox1, "TextLabel2" ); + TextLabel2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel2->sizePolicy().hasHeightForWidth() ) ); + TextLabel2->setText( trUtf8( "TL2" ) ); + + Layout5->addWidget( TextLabel2, 1, 0 ); Layout3 = new QGridLayout( 0, 1, 1, 0, 6, "Layout3"); @@ -102,40 +131,21 @@ DlgRef_2Sel4Spin1Check_QTD::DlgRef_2Sel4Spin1Check_QTD( QWidget* parent, const Layout3->addWidget( TextLabel6, 1, 0 ); - Layout1->addMultiCellLayout( Layout3, 4, 4, 0, 2 ); - - PushButton2 = new QPushButton( GroupBox1, "PushButton2" ); - PushButton2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton2->sizePolicy().hasHeightForWidth() ) ); - PushButton2->setText( trUtf8( "" ) ); - - Layout1->addWidget( PushButton2, 1, 1 ); - - TextLabel1 = new QLabel( GroupBox1, "TextLabel1" ); - TextLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel1->sizePolicy().hasHeightForWidth() ) ); - TextLabel1->setText( trUtf8( "TL1" ) ); - - Layout1->addWidget( TextLabel1, 0, 0 ); + Layout5->addMultiCellLayout( Layout3, 4, 4, 0, 2 ); - CheckButton1 = new QRadioButton( GroupBox1, "CheckButton1" ); - CheckButton1->setText( trUtf8( "" ) ); - - Layout1->addMultiCellWidget( CheckButton1, 3, 3, 0, 2 ); - - LineEdit1 = new QLineEdit( GroupBox1, "LineEdit1" ); - - Layout1->addWidget( LineEdit1, 0, 2 ); - - TextLabel2 = new QLabel( GroupBox1, "TextLabel2" ); - TextLabel2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel2->sizePolicy().hasHeightForWidth() ) ); - TextLabel2->setText( trUtf8( "TL2" ) ); - - Layout1->addWidget( TextLabel2, 1, 0 ); - QSpacerItem* spacer = new QSpacerItem( 0, 177, QSizePolicy::Minimum, QSizePolicy::Expanding ); - Layout1->addItem( spacer, 5, 2 ); - - GroupBox1Layout->addLayout( Layout1, 0, 0 ); + GroupBox1Layout->addLayout( Layout5, 0, 0 ); DlgRef_2Sel4Spin1Check_QTDLayout->addWidget( GroupBox1, 0, 0 ); + + // tab order + setTabOrder( PushButton1, LineEdit1 ); + setTabOrder( LineEdit1, PushButton2 ); + setTabOrder( PushButton2, LineEdit2 ); + setTabOrder( LineEdit2, SpinBox1 ); + setTabOrder( SpinBox1, SpinBox2 ); + setTabOrder( SpinBox2, CheckButton1 ); + setTabOrder( CheckButton1, SpinBox3 ); + setTabOrder( SpinBox3, SpinBox4 ); } /* diff --git a/src/DlgRef/DlgRef_2Sel4Spin1Check_QTD.h b/src/DlgRef/DlgRef_2Sel4Spin1Check_QTD.h index afde716e6..57e27f7fc 100644 --- a/src/DlgRef/DlgRef_2Sel4Spin1Check_QTD.h +++ b/src/DlgRef/DlgRef_2Sel4Spin1Check_QTD.h @@ -1,7 +1,7 @@ /**************************************************************************** ** Form interface generated from reading ui file 'DlgRef_2Sel4Spin1Check_QTD.ui' ** -** Created: lun oct 27 11:40:44 2003 +** Created: Tue Jun 1 12:38:04 2004 ** by: The User Interface Compiler (uic) ** ** WARNING! All changes made in this file will be lost! @@ -14,11 +14,11 @@ class QVBoxLayout; class QHBoxLayout; class QGridLayout; +class QCheckBox; class QGroupBox; class QLabel; class QLineEdit; class QPushButton; -class QRadioButton; class QSpinBox; class DlgRef_2Sel4Spin1Check_QTD : public QWidget @@ -30,27 +30,27 @@ public: ~DlgRef_2Sel4Spin1Check_QTD(); QGroupBox* GroupBox1; - QLineEdit* LineEdit2; QPushButton* PushButton1; + QCheckBox* CheckButton1; QLabel* TextLabel3; QSpinBox* SpinBox1; QSpinBox* SpinBox2; QLabel* TextLabel4; + QLineEdit* LineEdit2; + QLabel* TextLabel1; + QLineEdit* LineEdit1; + QPushButton* PushButton2; + QLabel* TextLabel2; QSpinBox* SpinBox4; QLabel* TextLabel5; QSpinBox* SpinBox3; QLabel* TextLabel6; - QPushButton* PushButton2; - QLabel* TextLabel1; - QRadioButton* CheckButton1; - QLineEdit* LineEdit1; - QLabel* TextLabel2; protected: QGridLayout* DlgRef_2Sel4Spin1Check_QTDLayout; QGridLayout* GroupBox1Layout; - QGridLayout* Layout1; + QGridLayout* Layout5; QGridLayout* Layout2; QGridLayout* Layout3; }; diff --git a/src/DlgRef/DlgRef_3Check_QTD.cxx b/src/DlgRef/DlgRef_3Check_QTD.cxx new file mode 100644 index 000000000..1e24399b7 --- /dev/null +++ b/src/DlgRef/DlgRef_3Check_QTD.cxx @@ -0,0 +1,75 @@ +/**************************************************************************** +** Form implementation generated from reading ui file 'DlgRef_3Check_QTD.ui' +** +** Created: Tue Aug 24 11:27:47 2004 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#include "DlgRef_3Check_QTD.h" + +#include +#include +#include +#include +#include +#include +#include + +/* + * Constructs a DlgRef_3Check_QTD which is a child of 'parent', with the + * name 'name' and widget flags set to 'f'. + */ +DlgRef_3Check_QTD::DlgRef_3Check_QTD( QWidget* parent, const char* name, WFlags fl ) + : QWidget( parent, name, fl ) +{ + if ( !name ) + setName( "DlgRef_3Check_QTD" ); + resize( 135, 108 ); + setCaption( trUtf8( "DlgRef_3Check_QTD" ) ); + DlgRef_3Check_QTDLayout = new QGridLayout( this, 1, 1, 0, 6, "DlgRef_3Check_QTDLayout"); + + GroupBox1 = new QButtonGroup( this, "GroupBox1" ); + GroupBox1->setTitle( trUtf8( "" ) ); + GroupBox1->setColumnLayout(0, Qt::Vertical ); + GroupBox1->layout()->setSpacing( 6 ); + GroupBox1->layout()->setMargin( 11 ); + GroupBox1Layout = new QGridLayout( GroupBox1->layout() ); + GroupBox1Layout->setAlignment( Qt::AlignTop ); + + Layout1 = new QGridLayout( 0, 1, 1, 0, 6, "Layout1"); + + RadioButton3 = new QRadioButton( GroupBox1, "RadioButton3" ); + RadioButton3->setText( trUtf8( "RadioButton3" ) ); + + Layout1->addWidget( RadioButton3, 2, 0 ); + + RadioButton1 = new QRadioButton( GroupBox1, "RadioButton1" ); + RadioButton1->setText( trUtf8( "RadioButton1" ) ); + + Layout1->addWidget( RadioButton1, 0, 0 ); + + RadioButton2 = new QRadioButton( GroupBox1, "RadioButton2" ); + RadioButton2->setText( trUtf8( "RadioButton2" ) ); + + Layout1->addWidget( RadioButton2, 1, 0 ); + QSpacerItem* spacer = new QSpacerItem( 0, 91, QSizePolicy::Minimum, QSizePolicy::Expanding ); + Layout1->addItem( spacer, 3, 0 ); + + GroupBox1Layout->addLayout( Layout1, 0, 0 ); + + DlgRef_3Check_QTDLayout->addWidget( GroupBox1, 0, 0 ); + + // tab order + setTabOrder( RadioButton1, RadioButton2 ); + setTabOrder( RadioButton2, RadioButton3 ); +} + +/* + * Destroys the object and frees any allocated resources + */ +DlgRef_3Check_QTD::~DlgRef_3Check_QTD() +{ + // no need to delete child widgets, Qt does it all for us +} + diff --git a/src/DlgRef/DlgRef_3Check_QTD.h b/src/DlgRef/DlgRef_3Check_QTD.h new file mode 100644 index 000000000..a2600b7ed --- /dev/null +++ b/src/DlgRef/DlgRef_3Check_QTD.h @@ -0,0 +1,40 @@ +/**************************************************************************** +** Form interface generated from reading ui file 'DlgRef_3Check_QTD.ui' +** +** Created: Tue Aug 24 11:27:47 2004 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#ifndef DLGREF_3CHECK_QTD_H +#define DLGREF_3CHECK_QTD_H + +#include +#include +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QButtonGroup; +class QRadioButton; + +class DlgRef_3Check_QTD : public QWidget +{ + Q_OBJECT + +public: + DlgRef_3Check_QTD( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + ~DlgRef_3Check_QTD(); + + QButtonGroup* GroupBox1; + QRadioButton* RadioButton3; + QRadioButton* RadioButton1; + QRadioButton* RadioButton2; + + +protected: + QGridLayout* DlgRef_3Check_QTDLayout; + QGridLayout* GroupBox1Layout; + QGridLayout* Layout1; +}; + +#endif // DLGREF_3CHECK_QTD_H diff --git a/src/DlgRef/DlgRef_3Sel1Spin.cxx b/src/DlgRef/DlgRef_3Sel1Spin.cxx new file mode 100644 index 000000000..76de7351e --- /dev/null +++ b/src/DlgRef/DlgRef_3Sel1Spin.cxx @@ -0,0 +1,55 @@ +// 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: DlgRef_3Sel1Spin.cxx +// Created: Thu May 13 12:19:31 2004 +// Author: Alexander SLADKOV +// + + +#include "DlgRef_3Sel1Spin.h" + +//================================================================================= +// class : DlgRef_3Sel1Spin +// purpose : +//================================================================================= +DlgRef_3Sel1Spin::DlgRef_3Sel1Spin( QWidget* parent, const char* name, WFlags fl ) + :DlgRef_3Sel_QTD( parent, name, fl ) +{ + Layout2 = new QGridLayout( 0, 1, 1, 0, 6, "Layout2"); + + TextLabel4 = new QLabel( (QWidget*)GroupBox1, "TextLabel4" ); + TextLabel4->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel3->sizePolicy().hasHeightForWidth() ) ); + Layout2->addWidget( TextLabel4, 0, 0 ); + + SpinBox_DX = new DlgRef_SpinBox( (QWidget*)GroupBox1, "SpinBox_DX" ); + Layout2->addWidget( SpinBox_DX, 0, 1 ); + + Layout1->addMultiCellLayout( Layout2, 3, 3, 0, 2 ); + QSpacerItem* spacer = new QSpacerItem( 0, 16, QSizePolicy::Minimum, QSizePolicy::Expanding ); + Layout1->addItem( spacer, 4, 2 ); +} + +DlgRef_3Sel1Spin::~DlgRef_3Sel1Spin() +{ +} diff --git a/src/DlgRef/DlgRef_3Sel1Spin.h b/src/DlgRef/DlgRef_3Sel1Spin.h new file mode 100644 index 000000000..00135ab7c --- /dev/null +++ b/src/DlgRef/DlgRef_3Sel1Spin.h @@ -0,0 +1,56 @@ +// 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 : DlgRef_3Sel1Spin.h +// Author : Alexander SLADKOV +// Module : GEOM +// $Header$ + +#ifndef DlgRef_3SEL_1SPIN_H +#define DlgRef_3SEL_1SPIN_H + +#include "DlgRef_3Sel_QTD.h" +#include "DlgRef_SpinBox.h" +#include +#include + +//================================================================================= +// class : DlgRef_3Sel1Spin +// purpose : extension of a DlgRef_3Sel_QTD class, 1 additional spin box is added +//================================================================================= +class DlgRef_3Sel1Spin : public DlgRef_3Sel_QTD +{ + Q_OBJECT + + public: + DlgRef_3Sel1Spin( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + ~DlgRef_3Sel1Spin(); + + QLabel* TextLabel4; + DlgRef_SpinBox* SpinBox_DX; + + protected: + QGridLayout* Layout2; +}; + +#endif // DlgRef_3SEL_1SPIN_H diff --git a/src/DlgRef/DlgRef_3Sel3Spin1Check.cxx b/src/DlgRef/DlgRef_3Sel3Spin1Check.cxx new file mode 100644 index 000000000..e8b60c9b9 --- /dev/null +++ b/src/DlgRef/DlgRef_3Sel3Spin1Check.cxx @@ -0,0 +1,114 @@ +// 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 : DlgRef_3Sel3Spin1Check.cxx +// Author : Michael Zorin +// Module : GEOM +// $Header: + +#include +#include +#include +#include +#include +#include +#include +#include + + +/* + * Constructs a DlgRef_3Sel3Spin1Check which is a child of 'parent', with the + * name 'name' and widget flags set to 'f' + */ +DlgRef_3Sel3Spin1Check::DlgRef_3Sel3Spin1Check(QWidget* parent, const char* name, WFlags fl) + :DlgRef_3Sel3Spin1Check_QTD(parent, name, fl) +{ + SpinBox_1->close(TRUE); + SpinBox_2->close(TRUE); + SpinBox_3->close(TRUE); + SpinBox1 = new DlgRef_SpinBox(GroupBox1, "SpinBox_DX"); + SpinBox2 = new DlgRef_SpinBox(GroupBox1, "SpinBox_DY"); + SpinBox3 = new DlgRef_SpinBox(GroupBox1, "SpinBox_DZ"); + Layout1->addWidget(SpinBox1, 3, 2); + Layout1->addWidget(SpinBox2, 4, 2); + Layout1->addWidget(SpinBox3, 5, 2); +} + + +/* + * Destroys the object and frees any allocated resources + */ +DlgRef_3Sel3Spin1Check::~DlgRef_3Sel3Spin1Check() +{ + // no need to delete child widgets, Qt does it all for us +} + +void DlgRef_3Sel3Spin1Check:: ShowRows(int fromRow, int toRow, bool toShow) +{ + typedef void (QWidget::* ShowFun)(); + ShowFun pShowFun; + + if (toShow) + pShowFun = &QWidget::show; + else + pShowFun = &QWidget::hide; + + if (fromRow >= 0 && toRow>=0 && toRow >= fromRow) + { + if ( fromRow == 0) + { + (TextLabel1->*pShowFun)(); + (PushButton1->*pShowFun)(); + (LineEdit1->*pShowFun)(); + } + if ( fromRow <= 1 && 1 <= toRow) + { + (TextLabel2->*pShowFun)(); + (PushButton2->*pShowFun)(); + (LineEdit2->*pShowFun)(); + } + if ( fromRow <= 2 && 2 <= toRow) + { + (TextLabel3->*pShowFun)(); + (PushButton3->*pShowFun)(); + (LineEdit3->*pShowFun)(); + } + if ( fromRow <= 3 && 3 <= toRow) + { + (TextLabel4->*pShowFun)(); + (SpinBox1->*pShowFun)(); + } + if ( fromRow <= 4 && 4 <= toRow) + { + (TextLabel5->*pShowFun)(); + (SpinBox2->*pShowFun)(); + } + if ( fromRow <= 5 && 5 <= toRow) + { + (TextLabel6->*pShowFun)(); + (SpinBox3->*pShowFun)(); + } + if ( fromRow <= 6 && 6 <= toRow) + (CheckBox1->*pShowFun)(); + } +} diff --git a/src/DlgRef/DlgRef_3Sel3Spin1Check.h b/src/DlgRef/DlgRef_3Sel3Spin1Check.h new file mode 100644 index 000000000..ba0a06515 --- /dev/null +++ b/src/DlgRef/DlgRef_3Sel3Spin1Check.h @@ -0,0 +1,51 @@ +// 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 : DlgRef_3Sel3Spin1Check.h +// Author : Michael ZORIN +// Module : GEOM +// $Header: + +#ifndef DLGREF_3SEL3SPIN1CHECK_H +#define DLGREF_3SEL3SPIN1CHECK_H + +#include "DlgRef_3Sel3Spin1Check_QTD.h" +#include "DlgRef_SpinBox.h" + +class DlgRef_3Sel3Spin1Check : public DlgRef_3Sel3Spin1Check_QTD +{ + Q_OBJECT + +public: + DlgRef_3Sel3Spin1Check( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + ~DlgRef_3Sel3Spin1Check(); + + DlgRef_SpinBox* SpinBox1; + DlgRef_SpinBox* SpinBox2; + DlgRef_SpinBox* SpinBox3; + + void ShowRows(int fromRow, int toRow, bool toShow = true); + +}; + +#endif // DLGREF_3SEL3SPIN1CHECK_H diff --git a/src/DlgRef/DlgRef_3Sel3Spin1Check_QTD.cxx b/src/DlgRef/DlgRef_3Sel3Spin1Check_QTD.cxx new file mode 100644 index 000000000..1110add18 --- /dev/null +++ b/src/DlgRef/DlgRef_3Sel3Spin1Check_QTD.cxx @@ -0,0 +1,158 @@ +/**************************************************************************** +** Form implementation generated from reading ui file 'DlgRef_3Sel3Spin1Check_QTD.ui' +** +** Created: Mon Apr 19 16:36:48 2004 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#include "DlgRef_3Sel3Spin1Check_QTD.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Constructs a DlgRef_3Sel3Spin1Check_QTD which is a child of 'parent', with the + * name 'name' and widget flags set to 'f'. + */ +DlgRef_3Sel3Spin1Check_QTD::DlgRef_3Sel3Spin1Check_QTD( QWidget* parent, const char* name, WFlags fl ) + : QWidget( parent, name, fl ) +{ + if ( !name ) + setName( "DlgRef_3Sel3Spin1Check_QTD" ); + resize( 380, 229 ); + setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, 0, 0, sizePolicy().hasHeightForWidth() ) ); + setCaption( trUtf8( "DlgRef_3Sel3Spin1Check_QTD" ) ); + DlgRef_3Sel3Spin1Check_QTDLayout = new QGridLayout( this, 1, 1, 0, 6, "DlgRef_3Sel3Spin1Check_QTDLayout"); + + GroupBox1 = new QGroupBox( this, "GroupBox1" ); + GroupBox1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, 0, 0, GroupBox1->sizePolicy().hasHeightForWidth() ) ); + GroupBox1->setTitle( trUtf8( "" ) ); + GroupBox1->setColumnLayout(0, Qt::Vertical ); + GroupBox1->layout()->setSpacing( 6 ); + GroupBox1->layout()->setMargin( 11 ); + GroupBox1Layout = new QGridLayout( GroupBox1->layout() ); + GroupBox1Layout->setAlignment( Qt::AlignTop ); + + Layout1 = new QGridLayout( 0, 1, 1, 0, 6, "Layout1"); + + SpinBox_2 = new QSpinBox( GroupBox1, "SpinBox_2" ); + SpinBox_2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, SpinBox_2->sizePolicy().hasHeightForWidth() ) ); + + Layout1->addWidget( SpinBox_2, 4, 2 ); + + LineEdit3 = new QLineEdit( GroupBox1, "LineEdit3" ); + + Layout1->addWidget( LineEdit3, 2, 2 ); + + SpinBox_3 = new QSpinBox( GroupBox1, "SpinBox_3" ); + SpinBox_3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, SpinBox_3->sizePolicy().hasHeightForWidth() ) ); + + Layout1->addWidget( SpinBox_3, 5, 2 ); + + TextLabel1 = new QLabel( GroupBox1, "TextLabel1" ); + TextLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel1->sizePolicy().hasHeightForWidth() ) ); + TextLabel1->setText( trUtf8( "TL1" ) ); + + Layout1->addWidget( TextLabel1, 0, 0 ); + + TextLabel3 = new QLabel( GroupBox1, "TextLabel3" ); + TextLabel3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel3->sizePolicy().hasHeightForWidth() ) ); + TextLabel3->setText( trUtf8( "TL3" ) ); + + Layout1->addWidget( TextLabel3, 2, 0 ); + + CheckBox1 = new QCheckBox( GroupBox1, "CheckBox1" ); + CheckBox1->setText( trUtf8( "" ) ); + + Layout1->addMultiCellWidget( CheckBox1, 6, 6, 0, 1 ); + + PushButton1 = new QPushButton( GroupBox1, "PushButton1" ); + PushButton1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton1->sizePolicy().hasHeightForWidth() ) ); + PushButton1->setText( trUtf8( "" ) ); + + Layout1->addWidget( PushButton1, 0, 1 ); + + TextLabel4 = new QLabel( GroupBox1, "TextLabel4" ); + TextLabel4->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel4->sizePolicy().hasHeightForWidth() ) ); + TextLabel4->setText( trUtf8( "TL4" ) ); + + Layout1->addWidget( TextLabel4, 3, 0 ); + + LineEdit2 = new QLineEdit( GroupBox1, "LineEdit2" ); + + Layout1->addWidget( LineEdit2, 1, 2 ); + + PushButton3 = new QPushButton( GroupBox1, "PushButton3" ); + PushButton3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton3->sizePolicy().hasHeightForWidth() ) ); + PushButton3->setText( trUtf8( "" ) ); + + Layout1->addWidget( PushButton3, 2, 1 ); + + TextLabel6 = new QLabel( GroupBox1, "TextLabel6" ); + TextLabel6->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel6->sizePolicy().hasHeightForWidth() ) ); + TextLabel6->setText( trUtf8( "TL6" ) ); + + Layout1->addWidget( TextLabel6, 5, 0 ); + + SpinBox_1 = new QSpinBox( GroupBox1, "SpinBox_1" ); + SpinBox_1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, SpinBox_1->sizePolicy().hasHeightForWidth() ) ); + + Layout1->addWidget( SpinBox_1, 3, 2 ); + + TextLabel5 = new QLabel( GroupBox1, "TextLabel5" ); + TextLabel5->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel5->sizePolicy().hasHeightForWidth() ) ); + TextLabel5->setText( trUtf8( "TL5" ) ); + + Layout1->addWidget( TextLabel5, 4, 0 ); + + TextLabel2 = new QLabel( GroupBox1, "TextLabel2" ); + TextLabel2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel2->sizePolicy().hasHeightForWidth() ) ); + TextLabel2->setText( trUtf8( "TL2" ) ); + + Layout1->addWidget( TextLabel2, 1, 0 ); + + LineEdit1 = new QLineEdit( GroupBox1, "LineEdit1" ); + + Layout1->addWidget( LineEdit1, 0, 2 ); + + PushButton2 = new QPushButton( GroupBox1, "PushButton2" ); + PushButton2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton2->sizePolicy().hasHeightForWidth() ) ); + PushButton2->setText( trUtf8( "" ) ); + + Layout1->addWidget( PushButton2, 1, 1 ); + QSpacerItem* spacer = new QSpacerItem( 0, 250, QSizePolicy::Minimum, QSizePolicy::Expanding ); + Layout1->addItem( spacer, 7, 2 ); + + GroupBox1Layout->addLayout( Layout1, 0, 0 ); + + DlgRef_3Sel3Spin1Check_QTDLayout->addWidget( GroupBox1, 0, 0 ); + + // tab order + setTabOrder( PushButton1, LineEdit1 ); + setTabOrder( LineEdit1, PushButton2 ); + setTabOrder( PushButton2, LineEdit2 ); + setTabOrder( LineEdit2, PushButton3 ); + setTabOrder( PushButton3, LineEdit3 ); + setTabOrder( LineEdit3, SpinBox_1 ); + setTabOrder( SpinBox_1, SpinBox_2 ); + setTabOrder( SpinBox_2, SpinBox_3 ); + setTabOrder( SpinBox_3, CheckBox1 ); +} + +/* + * Destroys the object and frees any allocated resources + */ +DlgRef_3Sel3Spin1Check_QTD::~DlgRef_3Sel3Spin1Check_QTD() +{ + // no need to delete child widgets, Qt does it all for us +} + diff --git a/src/DlgRef/DlgRef_3Sel3Spin1Check_QTD.h b/src/DlgRef/DlgRef_3Sel3Spin1Check_QTD.h new file mode 100644 index 000000000..024549bc7 --- /dev/null +++ b/src/DlgRef/DlgRef_3Sel3Spin1Check_QTD.h @@ -0,0 +1,57 @@ +/**************************************************************************** +** Form interface generated from reading ui file 'DlgRef_3Sel3Spin1Check_QTD.ui' +** +** Created: Mon Apr 19 16:36:48 2004 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#ifndef DLGREF_3SEL3SPIN1CHECK_QTD_H +#define DLGREF_3SEL3SPIN1CHECK_QTD_H + +#include +#include +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QCheckBox; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class QSpinBox; + +class DlgRef_3Sel3Spin1Check_QTD : public QWidget +{ + Q_OBJECT + +public: + DlgRef_3Sel3Spin1Check_QTD( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + ~DlgRef_3Sel3Spin1Check_QTD(); + + QGroupBox* GroupBox1; + QSpinBox* SpinBox_2; + QLineEdit* LineEdit3; + QSpinBox* SpinBox_3; + QLabel* TextLabel1; + QLabel* TextLabel3; + QCheckBox* CheckBox1; + QPushButton* PushButton1; + QLabel* TextLabel4; + QLineEdit* LineEdit2; + QPushButton* PushButton3; + QLabel* TextLabel6; + QSpinBox* SpinBox_1; + QLabel* TextLabel5; + QLabel* TextLabel2; + QLineEdit* LineEdit1; + QPushButton* PushButton2; + + +protected: + QGridLayout* DlgRef_3Sel3Spin1Check_QTDLayout; + QGridLayout* GroupBox1Layout; + QGridLayout* Layout1; +}; + +#endif // DLGREF_3SEL3SPIN1CHECK_QTD_H diff --git a/src/DlgRef/DlgRef_3Sel4Spin2Check.cxx b/src/DlgRef/DlgRef_3Sel4Spin2Check.cxx index 7c343f705..b290b918a 100644 --- a/src/DlgRef/DlgRef_3Sel4Spin2Check.cxx +++ b/src/DlgRef/DlgRef_3Sel4Spin2Check.cxx @@ -31,6 +31,7 @@ #include #include #include +#include /* * Constructs a DlgRef_2Sel1Spin which is a child of 'parent', with the @@ -51,6 +52,11 @@ DlgRef_3Sel4Spin2Check::DlgRef_3Sel4Spin2Check(QWidget* parent, const char* name Layout2->addWidget(SpinBox_DY1, 1, 1); Layout3->addWidget(SpinBox_DX2, 0, 1); Layout3->addWidget(SpinBox_DY2, 1, 1); + + // PAL6532 + PushButton1->setAutoDefault( false ); + PushButton2->setAutoDefault( false ); + PushButton3->setAutoDefault( false ); } diff --git a/src/DlgRef/DlgRef_3Sel4Spin2Check_QTD.cxx b/src/DlgRef/DlgRef_3Sel4Spin2Check_QTD.cxx index 55bee78b8..b79ae4b55 100644 --- a/src/DlgRef/DlgRef_3Sel4Spin2Check_QTD.cxx +++ b/src/DlgRef/DlgRef_3Sel4Spin2Check_QTD.cxx @@ -1,7 +1,7 @@ /**************************************************************************** ** Form implementation generated from reading ui file 'DlgRef_3Sel4Spin2Check_QTD.ui' ** -** Created: ven oct 24 09:53:25 2003 +** Created: Tue Jun 1 16:29:29 2004 ** by: The User Interface Compiler (uic) ** ** WARNING! All changes made in this file will be lost! @@ -9,11 +9,11 @@ #include "DlgRef_3Sel4Spin2Check_QTD.h" #include +#include #include #include #include #include -#include #include #include #include @@ -28,7 +28,7 @@ DlgRef_3Sel4Spin2Check_QTD::DlgRef_3Sel4Spin2Check_QTD( QWidget* parent, const { if ( !name ) setName( "DlgRef_3Sel4Spin2Check_QTD" ); - resize( 129, 271 ); + resize( 269, 281 ); setCaption( trUtf8( "DlgRef_3Sel4Spin2Check_QTD" ) ); DlgRef_3Sel4Spin2Check_QTDLayout = new QGridLayout( this, 1, 1, 0, 6, "DlgRef_3Sel4Spin2Check_QTDLayout"); @@ -42,66 +42,37 @@ DlgRef_3Sel4Spin2Check_QTD::DlgRef_3Sel4Spin2Check_QTD( QWidget* parent, const Layout1 = new QGridLayout( 0, 1, 1, 0, 6, "Layout1"); - TextLabel2 = new QLabel( GroupBox1, "TextLabel2" ); - TextLabel2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel2->sizePolicy().hasHeightForWidth() ) ); - TextLabel2->setText( trUtf8( "TL2" ) ); + CheckButton2 = new QCheckBox( GroupBox1, "CheckButton2" ); + CheckButton2->setText( trUtf8( "" ) ); - Layout1->addWidget( TextLabel2, 1, 0 ); + Layout1->addMultiCellWidget( CheckButton2, 6, 6, 0, 2 ); LineEdit1 = new QLineEdit( GroupBox1, "LineEdit1" ); Layout1->addWidget( LineEdit1, 0, 2 ); - PushButton1 = new QPushButton( GroupBox1, "PushButton1" ); - PushButton1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton1->sizePolicy().hasHeightForWidth() ) ); - PushButton1->setText( trUtf8( "" ) ); - - Layout1->addWidget( PushButton1, 0, 1 ); - - PushButton3 = new QPushButton( GroupBox1, "PushButton3" ); - PushButton3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton3->sizePolicy().hasHeightForWidth() ) ); - PushButton3->setText( trUtf8( "" ) ); - - Layout1->addWidget( PushButton3, 2, 1 ); - QSpacerItem* spacer = new QSpacerItem( 0, 155, QSizePolicy::Minimum, QSizePolicy::Expanding ); - Layout1->addItem( spacer, 7, 2 ); - - Layout2 = new QGridLayout( 0, 1, 1, 0, 6, "Layout2"); - - TextLabel5 = new QLabel( GroupBox1, "TextLabel5" ); - TextLabel5->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel5->sizePolicy().hasHeightForWidth() ) ); - TextLabel5->setText( trUtf8( "TL5" ) ); - - Layout2->addWidget( TextLabel5, 1, 0 ); - - TextLabel4 = new QLabel( GroupBox1, "TextLabel4" ); - TextLabel4->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel4->sizePolicy().hasHeightForWidth() ) ); - TextLabel4->setText( trUtf8( "TL4" ) ); - - Layout2->addWidget( TextLabel4, 0, 0 ); - - SpinBox1 = new QSpinBox( GroupBox1, "SpinBox1" ); - SpinBox1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, SpinBox1->sizePolicy().hasHeightForWidth() ) ); - - Layout2->addWidget( SpinBox1, 0, 1 ); - - SpinBox2 = new QSpinBox( GroupBox1, "SpinBox2" ); - SpinBox2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, SpinBox2->sizePolicy().hasHeightForWidth() ) ); - - Layout2->addWidget( SpinBox2, 1, 1 ); - - Layout1->addMultiCellLayout( Layout2, 3, 3, 0, 2 ); - TextLabel3 = new QLabel( GroupBox1, "TextLabel3" ); TextLabel3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel3->sizePolicy().hasHeightForWidth() ) ); TextLabel3->setText( trUtf8( "TL3" ) ); Layout1->addWidget( TextLabel3, 2, 0 ); + PushButton2 = new QPushButton( GroupBox1, "PushButton2" ); + PushButton2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton2->sizePolicy().hasHeightForWidth() ) ); + PushButton2->setText( trUtf8( "" ) ); + + Layout1->addWidget( PushButton2, 1, 1 ); + LineEdit3 = new QLineEdit( GroupBox1, "LineEdit3" ); Layout1->addWidget( LineEdit3, 2, 2 ); + PushButton1 = new QPushButton( GroupBox1, "PushButton1" ); + PushButton1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton1->sizePolicy().hasHeightForWidth() ) ); + PushButton1->setText( trUtf8( "" ) ); + + Layout1->addWidget( PushButton1, 0, 1 ); + Layout3 = new QGridLayout( 0, 1, 1, 0, 6, "Layout3"); SpinBox4 = new QSpinBox( GroupBox1, "SpinBox4" ); @@ -128,35 +99,77 @@ DlgRef_3Sel4Spin2Check_QTD::DlgRef_3Sel4Spin2Check_QTD( QWidget* parent, const Layout1->addMultiCellLayout( Layout3, 5, 5, 0, 2 ); - CheckButton2 = new QRadioButton( GroupBox1, "CheckButton2" ); - CheckButton2->setText( trUtf8( "" ) ); + CheckButton1 = new QCheckBox( GroupBox1, "CheckButton1" ); + CheckButton1->setText( trUtf8( "" ) ); - Layout1->addMultiCellWidget( CheckButton2, 6, 6, 0, 2 ); + Layout1->addMultiCellWidget( CheckButton1, 4, 4, 0, 2 ); + + PushButton3 = new QPushButton( GroupBox1, "PushButton3" ); + PushButton3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton3->sizePolicy().hasHeightForWidth() ) ); + PushButton3->setText( trUtf8( "" ) ); + + Layout1->addWidget( PushButton3, 2, 1 ); TextLabel1 = new QLabel( GroupBox1, "TextLabel1" ); TextLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel1->sizePolicy().hasHeightForWidth() ) ); TextLabel1->setText( trUtf8( "TL1" ) ); Layout1->addWidget( TextLabel1, 0, 0 ); + QSpacerItem* spacer = new QSpacerItem( 0, 16, QSizePolicy::Minimum, QSizePolicy::Expanding ); + Layout1->addItem( spacer, 7, 2 ); LineEdit2 = new QLineEdit( GroupBox1, "LineEdit2" ); Layout1->addWidget( LineEdit2, 1, 2 ); - PushButton2 = new QPushButton( GroupBox1, "PushButton2" ); - PushButton2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton2->sizePolicy().hasHeightForWidth() ) ); - PushButton2->setText( trUtf8( "" ) ); + Layout2 = new QGridLayout( 0, 1, 1, 0, 6, "Layout2"); - Layout1->addWidget( PushButton2, 1, 1 ); + TextLabel5 = new QLabel( GroupBox1, "TextLabel5" ); + TextLabel5->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel5->sizePolicy().hasHeightForWidth() ) ); + TextLabel5->setText( trUtf8( "TL5" ) ); - CheckButton1 = new QRadioButton( GroupBox1, "CheckButton1" ); - CheckButton1->setText( trUtf8( "" ) ); + Layout2->addWidget( TextLabel5, 1, 0 ); - Layout1->addMultiCellWidget( CheckButton1, 4, 4, 0, 2 ); + TextLabel4 = new QLabel( GroupBox1, "TextLabel4" ); + TextLabel4->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel4->sizePolicy().hasHeightForWidth() ) ); + TextLabel4->setText( trUtf8( "TL4" ) ); + + Layout2->addWidget( TextLabel4, 0, 0 ); + + SpinBox1 = new QSpinBox( GroupBox1, "SpinBox1" ); + SpinBox1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, SpinBox1->sizePolicy().hasHeightForWidth() ) ); + + Layout2->addWidget( SpinBox1, 0, 1 ); + + SpinBox2 = new QSpinBox( GroupBox1, "SpinBox2" ); + SpinBox2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, SpinBox2->sizePolicy().hasHeightForWidth() ) ); + + Layout2->addWidget( SpinBox2, 1, 1 ); + + Layout1->addMultiCellLayout( Layout2, 3, 3, 0, 2 ); + + TextLabel2 = new QLabel( GroupBox1, "TextLabel2" ); + TextLabel2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel2->sizePolicy().hasHeightForWidth() ) ); + TextLabel2->setText( trUtf8( "TL2" ) ); + + Layout1->addWidget( TextLabel2, 1, 0 ); GroupBox1Layout->addLayout( Layout1, 0, 0 ); DlgRef_3Sel4Spin2Check_QTDLayout->addWidget( GroupBox1, 0, 0 ); + + // tab order + setTabOrder( PushButton1, LineEdit1 ); + setTabOrder( LineEdit1, PushButton2 ); + setTabOrder( PushButton2, LineEdit2 ); + setTabOrder( LineEdit2, PushButton3 ); + setTabOrder( PushButton3, LineEdit3 ); + setTabOrder( LineEdit3, SpinBox1 ); + setTabOrder( SpinBox1, SpinBox2 ); + setTabOrder( SpinBox2, CheckButton1 ); + setTabOrder( CheckButton1, SpinBox3 ); + setTabOrder( SpinBox3, SpinBox4 ); + setTabOrder( SpinBox4, CheckButton2 ); } /* diff --git a/src/DlgRef/DlgRef_3Sel4Spin2Check_QTD.h b/src/DlgRef/DlgRef_3Sel4Spin2Check_QTD.h index fb053ced4..ef704cbe4 100644 --- a/src/DlgRef/DlgRef_3Sel4Spin2Check_QTD.h +++ b/src/DlgRef/DlgRef_3Sel4Spin2Check_QTD.h @@ -1,7 +1,7 @@ /**************************************************************************** ** Form interface generated from reading ui file 'DlgRef_3Sel4Spin2Check_QTD.ui' ** -** Created: ven oct 24 09:53:25 2003 +** Created: Tue Jun 1 16:29:29 2004 ** by: The User Interface Compiler (uic) ** ** WARNING! All changes made in this file will be lost! @@ -14,11 +14,11 @@ class QVBoxLayout; class QHBoxLayout; class QGridLayout; +class QCheckBox; class QGroupBox; class QLabel; class QLineEdit; class QPushButton; -class QRadioButton; class QSpinBox; class DlgRef_3Sel4Spin2Check_QTD : public QWidget @@ -30,33 +30,33 @@ public: ~DlgRef_3Sel4Spin2Check_QTD(); QGroupBox* GroupBox1; - QLabel* TextLabel2; + QCheckBox* CheckButton2; QLineEdit* LineEdit1; - QPushButton* PushButton1; - QPushButton* PushButton3; - QLabel* TextLabel5; - QLabel* TextLabel4; - QSpinBox* SpinBox1; - QSpinBox* SpinBox2; QLabel* TextLabel3; + QPushButton* PushButton2; QLineEdit* LineEdit3; + QPushButton* PushButton1; QSpinBox* SpinBox4; QSpinBox* SpinBox3; QLabel* TextLabel7; QLabel* TextLabel6; - QRadioButton* CheckButton2; + QCheckBox* CheckButton1; + QPushButton* PushButton3; QLabel* TextLabel1; QLineEdit* LineEdit2; - QPushButton* PushButton2; - QRadioButton* CheckButton1; + QLabel* TextLabel5; + QLabel* TextLabel4; + QSpinBox* SpinBox1; + QSpinBox* SpinBox2; + QLabel* TextLabel2; protected: QGridLayout* DlgRef_3Sel4Spin2Check_QTDLayout; QGridLayout* GroupBox1Layout; QGridLayout* Layout1; - QGridLayout* Layout2; QGridLayout* Layout3; + QGridLayout* Layout2; }; #endif // DLGREF_3SEL4SPIN2CHECK_QTD_H diff --git a/src/DlgRef/DlgRef_4Sel1List1Check_QTD.cxx b/src/DlgRef/DlgRef_4Sel1List1Check_QTD.cxx new file mode 100644 index 000000000..cd7664335 --- /dev/null +++ b/src/DlgRef/DlgRef_4Sel1List1Check_QTD.cxx @@ -0,0 +1,176 @@ +/**************************************************************************** +** Form implementation generated from reading ui file 'DlgRef_4Sel1List1Check_QTD.ui' +** +** Created: lun oct 27 17:21:04 2003 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#include "DlgRef_4Sel1List1Check_QTD.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Constructs a DlgRef_4Sel1List1Check_QTD which is a child of 'parent', with the + * name 'name' and widget flags set to 'f'. + */ +DlgRef_4Sel1List1Check_QTD::DlgRef_4Sel1List1Check_QTD( QWidget* parent, const char* name, WFlags fl ) + : QWidget( parent, name, fl ) +{ + if ( !name ) + setName( "DlgRef_4Sel1List1Check_QTD" ); + resize( 129, 210 ); + setCaption( trUtf8( "DlgRef_4Sel1List1Check_QTD" ) ); + DlgRef_4Sel1List1Check_QTDLayout = + new QGridLayout( this, 1, 1, 0, 6, "DlgRef_4Sel1List1Check_QTDLayout"); + + GroupBox1 = new QGroupBox( this, "GroupBox1" ); + GroupBox1->setTitle( trUtf8( "" ) ); + GroupBox1->setColumnLayout(0, Qt::Vertical ); + GroupBox1->layout()->setSpacing( 6 ); + GroupBox1->layout()->setMargin( 11 ); + GroupBox1Layout = new QGridLayout( GroupBox1->layout() ); + GroupBox1Layout->setAlignment( Qt::AlignTop ); + + Layout1 = new QGridLayout( 0, 1, 1, 0, 6, "Layout1"); + + TextLabel1 = new QLabel( GroupBox1, "TextLabel1" ); + TextLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel1->sizePolicy().hasHeightForWidth() ) ); + TextLabel1->setText( trUtf8( "TL1" ) ); + + Layout1->addWidget( TextLabel1, 0, 0 ); + + PushButton1 = new QPushButton( GroupBox1, "PushButton1" ); + PushButton1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton1->sizePolicy().hasHeightForWidth() ) ); + PushButton1->setText( trUtf8( "" ) ); + + Layout1->addWidget( PushButton1, 0, 1 ); + + LineEdit1 = new QLineEdit( GroupBox1, "LineEdit1" ); + + Layout1->addWidget( LineEdit1, 0, 2 ); + + + TextLabel2 = new QLabel( GroupBox1, "TextLabel2" ); + TextLabel2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel2->sizePolicy().hasHeightForWidth() ) ); + TextLabel2->setText( trUtf8( "TL2" ) ); + + Layout1->addWidget( TextLabel2, 1, 0 ); + + PushButton2 = new QPushButton( GroupBox1, "PushButton2" ); + PushButton2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton2->sizePolicy().hasHeightForWidth() ) ); + PushButton2->setText( trUtf8( "" ) ); + + Layout1->addWidget( PushButton2, 1, 1 ); + + LineEdit2 = new QLineEdit( GroupBox1, "LineEdit2" ); + + Layout1->addWidget( LineEdit2, 1, 2 ); + + + TextLabel3 = new QLabel( GroupBox1, "TextLabel3" ); + TextLabel3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel3->sizePolicy().hasHeightForWidth() ) ); + TextLabel3->setText( trUtf8( "TL3" ) ); + + Layout1->addMultiCellWidget( TextLabel3, 2, 2, 0, 1 ); + + ComboBox1 = new QComboBox( FALSE, GroupBox1, "ComboBox1" ); + ComboBox1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, ComboBox1->sizePolicy().hasHeightForWidth() ) ); + + Layout1->addWidget( ComboBox1, 2, 2 ); + + + GroupBox1Layout->addLayout( Layout1, 0, 0 ); + + DlgRef_4Sel1List1Check_QTDLayout->addWidget( GroupBox1, 0, 0 ); + + + GroupBox2 = new QGroupBox( this, "GroupBox2" ); + GroupBox2->setTitle( trUtf8( "" ) ); + GroupBox2->setColumnLayout(0, Qt::Vertical ); + GroupBox2->layout()->setSpacing( 6 ); + GroupBox2->layout()->setMargin( 11 ); + GroupBox2Layout = new QGridLayout( GroupBox2->layout() ); + GroupBox2Layout->setAlignment( Qt::AlignTop ); + + Layout2 = new QGridLayout( 0, 1, 1, 0, 6, "Layout2"); + + TextLabel4 = new QLabel( GroupBox2, "TextLabel4" ); + TextLabel4->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel4->sizePolicy().hasHeightForWidth() ) ); + TextLabel4->setText( trUtf8( "TL4" ) ); + + Layout2->addWidget( TextLabel4, 0, 0 ); + QSpacerItem* spacer = new QSpacerItem( 0, 80, QSizePolicy::Minimum, QSizePolicy::Expanding ); + Layout1->addItem( spacer, 5, 2 ); + + PushButton3 = new QPushButton( GroupBox2, "PushButton3" ); + PushButton3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton3->sizePolicy().hasHeightForWidth() ) ); + PushButton3->setText( trUtf8( "" ) ); + + Layout2->addWidget( PushButton3, 0, 1 ); + + LineEdit3 = new QLineEdit( GroupBox2, "LineEdit3" ); + + Layout2->addWidget( LineEdit3, 0, 2 ); + + + TextLabel5 = new QLabel( GroupBox2, "TextLabel5" ); + TextLabel5->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel5->sizePolicy().hasHeightForWidth() ) ); + TextLabel5->setText( trUtf8( "TL5" ) ); + + Layout2->addWidget( TextLabel5, 1, 0 ); + + PushButton4 = new QPushButton( GroupBox2, "PushButton4" ); + PushButton4->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton4->sizePolicy().hasHeightForWidth() ) ); + PushButton4->setText( trUtf8( "" ) ); + + Layout2->addWidget( PushButton4, 1, 1 ); + + LineEdit4 = new QLineEdit( GroupBox2, "LineEdit4" ); + + Layout2->addWidget( LineEdit4, 1, 2 ); + + CheckBox1 = new QCheckBox( GroupBox1, "CheckBox1" ); + CheckBox1->setText( trUtf8( "" ) ); + Layout1->addMultiCellWidget( CheckBox1, 5, 5, 0, 1 ); + + PushButton5 = new QPushButton( GroupBox1, "PushButton5" ); + PushButton5->setText( trUtf8( "" ) ); + Layout1->addWidget( PushButton5, 5, 2 ); + + GroupBox2Layout->addLayout( Layout2, 0, 0 ); + + DlgRef_4Sel1List1Check_QTDLayout->addWidget( GroupBox2, 1, 0 ); + + // tab order + setTabOrder(PushButton1 , LineEdit1); + setTabOrder(LineEdit1 , PushButton2); + setTabOrder(PushButton2 , LineEdit2); + setTabOrder(LineEdit2, ComboBox1); + setTabOrder(ComboBox1, CheckBox1); + setTabOrder(CheckBox1, PushButton5); + setTabOrder(PushButton5, PushButton3); + setTabOrder(PushButton3 , LineEdit3); + setTabOrder(LineEdit3, PushButton4 ); + setTabOrder(PushButton4 , LineEdit4); + +} + +/* + * Destroys the object and frees any allocated resources + */ +DlgRef_4Sel1List1Check_QTD::~DlgRef_4Sel1List1Check_QTD() +{ + // no need to delete child widgets, Qt does it all for us +} + diff --git a/src/DlgRef/DlgRef_4Sel1List1Check_QTD.h b/src/DlgRef/DlgRef_4Sel1List1Check_QTD.h new file mode 100644 index 000000000..d757be902 --- /dev/null +++ b/src/DlgRef/DlgRef_4Sel1List1Check_QTD.h @@ -0,0 +1,60 @@ +/**************************************************************************** +** Form interface generated from reading ui file 'DlgRef_4Sel1List1Check_QTD.ui' +** +** Created: lun oct 27 17:21:03 2003 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#ifndef DLGREF_4SEL1LIST1CHECK_QTD_H +#define DLGREF_4SEL1LIST1CHECK_QTD_H + +#include +#include +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QComboBox; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class QCheckBox; +class QPushButton; + +class DlgRef_4Sel1List1Check_QTD : public QWidget +{ + Q_OBJECT + +public: + DlgRef_4Sel1List1Check_QTD( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + ~DlgRef_4Sel1List1Check_QTD(); + + QGroupBox* GroupBox1; + QGroupBox* GroupBox2; + QLabel* TextLabel1; + QLabel* TextLabel2; + QLabel* TextLabel3; + QLabel* TextLabel4; + QLabel* TextLabel5; + QPushButton* PushButton1; + QPushButton* PushButton2; + QPushButton* PushButton3; + QPushButton* PushButton4; + QLineEdit* LineEdit1; + QLineEdit* LineEdit2; + QLineEdit* LineEdit3; + QLineEdit* LineEdit4; + QComboBox* ComboBox1; + QCheckBox* CheckBox1; + QPushButton* PushButton5; + +protected: + QGridLayout* DlgRef_4Sel1List1Check_QTDLayout; + QGridLayout* GroupBox1Layout; + QGridLayout* GroupBox2Layout; + QGridLayout* Layout1; + QGridLayout* Layout2; +}; + +#endif // DLGREF_4SEL1LIST1CHECK_QTD_H diff --git a/src/DlgRef/DlgRef_6Sel_QTD.cxx b/src/DlgRef/DlgRef_6Sel_QTD.cxx new file mode 100644 index 000000000..238416e69 --- /dev/null +++ b/src/DlgRef/DlgRef_6Sel_QTD.cxx @@ -0,0 +1,152 @@ +/**************************************************************************** +** Form implementation generated from reading ui file 'DlgRef_6Sel_QTD.ui' +** +** Created: Tue Aug 24 18:18:57 2004 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#include "DlgRef_6Sel_QTD.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Constructs a DlgRef_6Sel_QTD which is a child of 'parent', with the + * name 'name' and widget flags set to 'f'. + */ +DlgRef_6Sel_QTD::DlgRef_6Sel_QTD( QWidget* parent, const char* name, WFlags fl ) + : QWidget( parent, name, fl ) +{ + if ( !name ) + setName( "DlgRef_6Sel_QTD" ); + resize( 235, 196 ); + setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)7, 0, 0, sizePolicy().hasHeightForWidth() ) ); + setCaption( trUtf8( "DlgRef_6Sel_QTD" ) ); + DlgRef_6Sel_QTDLayout = new QGridLayout( this, 1, 1, 0, 6, "DlgRef_6Sel_QTDLayout"); + + GroupBox1 = new QGroupBox( this, "GroupBox1" ); + GroupBox1->setTitle( trUtf8( "" ) ); + GroupBox1->setColumnLayout(0, Qt::Vertical ); + GroupBox1->layout()->setSpacing( 6 ); + GroupBox1->layout()->setMargin( 11 ); + GroupBox1Layout = new QGridLayout( GroupBox1->layout() ); + GroupBox1Layout->setAlignment( Qt::AlignTop ); + + Layout1 = new QGridLayout( 0, 1, 1, 0, 6, "Layout1"); + + TextLabel1 = new QLabel( GroupBox1, "TextLabel1" ); + TextLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel1->sizePolicy().hasHeightForWidth() ) ); + TextLabel1->setText( trUtf8( "TL1" ) ); + + Layout1->addWidget( TextLabel1, 0, 0 ); + + TextLabel2 = new QLabel( GroupBox1, "TextLabel2" ); + TextLabel2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel2->sizePolicy().hasHeightForWidth() ) ); + TextLabel2->setText( trUtf8( "TL2" ) ); + + Layout1->addWidget( TextLabel2, 1, 0 ); + + TextLabel3 = new QLabel( GroupBox1, "TextLabel3" ); + TextLabel3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel3->sizePolicy().hasHeightForWidth() ) ); + TextLabel3->setText( trUtf8( "TL3" ) ); + + Layout1->addWidget( TextLabel3, 2, 0 ); + + TextLabel4 = new QLabel( GroupBox1, "TextLabel4" ); + TextLabel4->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel4->sizePolicy().hasHeightForWidth() ) ); + TextLabel4->setText( trUtf8( "TL4" ) ); + + Layout1->addWidget( TextLabel4, 3, 0 ); + + TextLabel5 = new QLabel( GroupBox1, "TextLabel5" ); + TextLabel5->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel5->sizePolicy().hasHeightForWidth() ) ); + TextLabel5->setText( trUtf8( "TL5" ) ); + + Layout1->addWidget( TextLabel5, 4, 0 ); + + TextLabel6 = new QLabel( GroupBox1, "TextLabel6" ); + TextLabel6->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel6->sizePolicy().hasHeightForWidth() ) ); + TextLabel6->setText( trUtf8( "TL6" ) ); + + Layout1->addWidget( TextLabel6, 5, 0 ); + + PushButton1 = new QPushButton( GroupBox1, "PushButton1" ); + PushButton1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton1->sizePolicy().hasHeightForWidth() ) ); + PushButton1->setText( trUtf8( "" ) ); + + Layout1->addWidget( PushButton1, 0, 1 ); + + PushButton2 = new QPushButton( GroupBox1, "PushButton2" ); + PushButton2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton2->sizePolicy().hasHeightForWidth() ) ); + PushButton2->setText( trUtf8( "" ) ); + + Layout1->addWidget( PushButton2, 1, 1 ); + + PushButton3 = new QPushButton( GroupBox1, "PushButton3" ); + PushButton3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton3->sizePolicy().hasHeightForWidth() ) ); + PushButton3->setText( trUtf8( "" ) ); + + Layout1->addWidget( PushButton3, 2, 1 ); + + PushButton4 = new QPushButton( GroupBox1, "PushButton4" ); + PushButton4->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton4->sizePolicy().hasHeightForWidth() ) ); + PushButton4->setText( trUtf8( "" ) ); + + Layout1->addWidget( PushButton4, 3, 1 ); + + PushButton5 = new QPushButton( GroupBox1, "PushButton5" ); + PushButton5->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton5->sizePolicy().hasHeightForWidth() ) ); + PushButton5->setText( trUtf8( "" ) ); + + Layout1->addWidget( PushButton5, 4, 1 ); + + PushButton6 = new QPushButton( GroupBox1, "PushButton6" ); + PushButton6->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton6->sizePolicy().hasHeightForWidth() ) ); + PushButton6->setText( trUtf8( "" ) ); + + Layout1->addWidget( PushButton6, 5, 1 ); + + LineEdit1 = new QLineEdit( GroupBox1, "LineEdit1" ); + + Layout1->addWidget( LineEdit1, 0, 2 ); + + LineEdit2 = new QLineEdit( GroupBox1, "LineEdit2" ); + + Layout1->addWidget( LineEdit2, 1, 2 ); + + LineEdit3 = new QLineEdit( GroupBox1, "LineEdit3" ); + + Layout1->addWidget( LineEdit3, 2, 2 ); + + LineEdit4 = new QLineEdit( GroupBox1, "LineEdit4" ); + + Layout1->addWidget( LineEdit4, 3, 2 ); + + LineEdit5 = new QLineEdit( GroupBox1, "LineEdit5" ); + + Layout1->addWidget( LineEdit5, 4, 2 ); + + LineEdit6 = new QLineEdit( GroupBox1, "LineEdit6" ); + + Layout1->addWidget( LineEdit6, 5, 2 ); + + GroupBox1Layout->addLayout( Layout1, 0, 0 ); + + DlgRef_6Sel_QTDLayout->addWidget( GroupBox1, 0, 0 ); +} + +/* + * Destroys the object and frees any allocated resources + */ +DlgRef_6Sel_QTD::~DlgRef_6Sel_QTD() +{ + // no need to delete child widgets, Qt does it all for us +} + diff --git a/src/DlgRef/DlgRef_6Sel_QTD.h b/src/DlgRef/DlgRef_6Sel_QTD.h new file mode 100644 index 000000000..0231bbb4b --- /dev/null +++ b/src/DlgRef/DlgRef_6Sel_QTD.h @@ -0,0 +1,57 @@ +/**************************************************************************** +** Form interface generated from reading ui file 'DlgRef_6Sel_QTD.ui' +** +** Created: Tue Aug 24 18:18:28 2004 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#ifndef DLGREF_6SEL_QTD_H +#define DLGREF_6SEL_QTD_H + +#include +#include +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; + +class DlgRef_6Sel_QTD : public QWidget +{ + Q_OBJECT + +public: + DlgRef_6Sel_QTD( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + ~DlgRef_6Sel_QTD(); + + QGroupBox* GroupBox1; + QLabel* TextLabel1; + QLabel* TextLabel2; + QLabel* TextLabel3; + QLabel* TextLabel4; + QLabel* TextLabel5; + QLabel* TextLabel6; + QPushButton* PushButton1; + QPushButton* PushButton2; + QPushButton* PushButton3; + QPushButton* PushButton4; + QPushButton* PushButton5; + QPushButton* PushButton6; + QLineEdit* LineEdit1; + QLineEdit* LineEdit2; + QLineEdit* LineEdit3; + QLineEdit* LineEdit4; + QLineEdit* LineEdit5; + QLineEdit* LineEdit6; + + +protected: + QGridLayout* DlgRef_6Sel_QTDLayout; + QGridLayout* GroupBox1Layout; + QGridLayout* Layout1; +}; + +#endif // DLGREF_6SEL_QTD_H diff --git a/src/DlgRef/DlgRef_Skeleton_QTD.cxx b/src/DlgRef/DlgRef_Skeleton_QTD.cxx index 897e3f19c..b612a9a42 100644 --- a/src/DlgRef/DlgRef_Skeleton_QTD.cxx +++ b/src/DlgRef/DlgRef_Skeleton_QTD.cxx @@ -1,7 +1,7 @@ /**************************************************************************** ** Form implementation generated from reading ui file 'DlgRef_Skeleton_QTD.ui' ** -** Created: Fri Apr 16 12:57:26 2004 +** Created: Wed Aug 11 18:42:51 2004 ** by: The User Interface Compiler (uic) ** ** WARNING! All changes made in this file will be lost! @@ -31,7 +31,7 @@ DlgRef_Skeleton_QTD::DlgRef_Skeleton_QTD( QWidget* parent, const char* name, bo { if ( !name ) setName( "DlgRef_Skeleton_QTD" ); - resize( 321, 295 ); + resize( 307, 378 ); setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)7, 0, 0, sizePolicy().hasHeightForWidth() ) ); setCaption( trUtf8( "DlgRef_Skeleton_QTD" ) ); setSizeGripEnabled( TRUE ); @@ -79,7 +79,7 @@ DlgRef_Skeleton_QTD::DlgRef_Skeleton_QTD( QWidget* parent, const char* name, bo GroupConstructors->setColumnLayout(0, Qt::Vertical ); GroupConstructors->layout()->setSpacing( 6 ); GroupConstructors->layout()->setMargin( 11 ); - GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); + GroupConstructorsLayout = new QHBoxLayout( GroupConstructors->layout() ); GroupConstructorsLayout->setAlignment( Qt::AlignTop ); Layout2 = new QHBoxLayout( 0, 0, 6, "Layout2"); @@ -96,7 +96,10 @@ DlgRef_Skeleton_QTD::DlgRef_Skeleton_QTD( QWidget* parent, const char* name, bo RadioButton3->setText( trUtf8( "" ) ); Layout2->addWidget( RadioButton3 ); - GroupConstructorsLayout->addLayout( Layout2, 0, 0 ); + RadioButton4 = new QRadioButton( GroupConstructors, "RadioButton4" ); + RadioButton4->setText( trUtf8( "" ) ); + Layout2->addWidget( RadioButton4 ); + GroupConstructorsLayout->addLayout( Layout2 ); Layout1->addWidget( GroupConstructors, 0, 0 ); diff --git a/src/DlgRef/DlgRef_Skeleton_QTD.h b/src/DlgRef/DlgRef_Skeleton_QTD.h index 38d6d83d6..0ca0df849 100644 --- a/src/DlgRef/DlgRef_Skeleton_QTD.h +++ b/src/DlgRef/DlgRef_Skeleton_QTD.h @@ -1,7 +1,7 @@ /**************************************************************************** ** Form interface generated from reading ui file 'DlgRef_Skeleton_QTD.ui' ** -** Created: Fri Apr 16 12:57:26 2004 +** Created: Wed Aug 11 18:42:51 2004 ** by: The User Interface Compiler (uic) ** ** WARNING! All changes made in this file will be lost! @@ -38,6 +38,7 @@ public: QRadioButton* RadioButton1; QRadioButton* RadioButton2; QRadioButton* RadioButton3; + QRadioButton* RadioButton4; QGroupBox* GroupBoxName; QLineEdit* ResultName; QLabel* NameLabel; @@ -48,7 +49,7 @@ protected: QGridLayout* Layout1; QHBoxLayout* GroupButtonsLayout; QHBoxLayout* Layout3; - QGridLayout* GroupConstructorsLayout; + QHBoxLayout* GroupConstructorsLayout; QHBoxLayout* Layout2; QGridLayout* GroupBoxNameLayout; QGridLayout* Layout66; diff --git a/src/DlgRef/Makefile.in b/src/DlgRef/Makefile.in index c6ed3784e..a986c83f6 100644 --- a/src/DlgRef/Makefile.in +++ b/src/DlgRef/Makefile.in @@ -53,15 +53,18 @@ LIB_SRC = DlgRef_Skeleton_QTD.cxx \ DlgRef_2Sel2Spin_QTD.cxx \ DlgRef_2Sel3Spin_QTD.cxx \ DlgRef_1Sel1Spin1Check_QTD.cxx \ - DlgRef_2Sel1Spin1Check_QTD.cxx \ + DlgRef_2Sel1Spin2Check_QTD.cxx \ DlgRef_2Sel2Spin1Check_QTD.cxx \ DlgRef_2Sel4Spin1Check_QTD.cxx \ DlgRef_3Sel4Spin2Check_QTD.cxx \ DlgRef_4Sel1List_QTD.cxx \ + DlgRef_1List1Spin1Btn_QTD.cxx \ + DlgRef_4Sel1List1Check_QTD.cxx \ DlgRef_1Spin_QTD.cxx \ DlgRef_2Spin_QTD.cxx \ DlgRef_3Spin_QTD.cxx \ DlgRef_3Spin1Check_QTD.cxx \ + DlgRef_3Sel3Spin1Check_QTD.cxx \ DlgRef_SpinBox.cxx \ DlgRef_1Sel1Spin.cxx \ DlgRef_1Sel2Spin.cxx \ @@ -72,14 +75,18 @@ LIB_SRC = DlgRef_Skeleton_QTD.cxx \ DlgRef_2Sel2Spin.cxx \ DlgRef_2Sel3Spin.cxx \ DlgRef_1Sel1Spin1Check.cxx \ - DlgRef_2Sel1Spin1Check.cxx \ + DlgRef_2Sel1Spin2Check.cxx \ DlgRef_2Sel2Spin1Check.cxx \ DlgRef_2Sel4Spin1Check.cxx \ DlgRef_3Sel4Spin2Check.cxx \ + DlgRef_3Sel3Spin1Check.cxx \ DlgRef_1Spin.cxx \ DlgRef_2Spin.cxx \ DlgRef_3Spin.cxx \ - DlgRef_3Spin1Check.cxx + DlgRef_3Spin1Check.cxx \ + DlgRef_3Sel1Spin.cxx \ + DlgRef_3Check_QTD.cxx \ + DlgRef_6Sel_QTD.cxx LIB_MOC = \ DlgRef_Skeleton_QTD.h \ @@ -98,15 +105,18 @@ LIB_MOC = \ DlgRef_2Sel2Spin_QTD.h \ DlgRef_2Sel3Spin_QTD.h \ DlgRef_1Sel1Spin1Check_QTD.h \ - DlgRef_2Sel1Spin1Check_QTD.h \ + DlgRef_2Sel1Spin2Check_QTD.h \ DlgRef_2Sel2Spin1Check_QTD.h \ DlgRef_2Sel4Spin1Check_QTD.h \ DlgRef_3Sel4Spin2Check_QTD.h \ DlgRef_4Sel1List_QTD.h \ + DlgRef_1List1Spin1Btn_QTD.h \ + DlgRef_4Sel1List1Check_QTD.h \ DlgRef_1Spin_QTD.h \ DlgRef_2Spin_QTD.h \ DlgRef_3Spin_QTD.h \ DlgRef_3Spin1Check_QTD.h \ + DlgRef_3Sel3Spin1Check_QTD.h \ DlgRef_SpinBox.h \ DlgRef_1Sel1Spin.h \ DlgRef_1Sel2Spin.h \ @@ -117,14 +127,19 @@ LIB_MOC = \ DlgRef_2Sel2Spin.h \ DlgRef_2Sel3Spin.h \ DlgRef_1Sel1Spin1Check.h \ - DlgRef_2Sel1Spin1Check.h \ + DlgRef_2Sel1Spin2Check.h \ DlgRef_2Sel2Spin1Check.h \ DlgRef_2Sel4Spin1Check.h \ DlgRef_3Sel4Spin2Check.h \ + DlgRef_3Sel3Spin1Check.h \ DlgRef_1Spin.h \ DlgRef_2Spin.h \ DlgRef_3Spin.h \ - DlgRef_3Spin1Check.h + DlgRef_3Spin1Check.h \ + DlgRef_3Sel1Spin.h \ + DlgRef_1Sel_Ext.h \ + DlgRef_3Check_QTD.h \ + DlgRef_6Sel_QTD.h # header files EXPORT_HEADERS= $(LIB_MOC) diff --git a/src/DlgRef/UIFiles/DlgRef_1List1Spin1Btn_QTD.ui b/src/DlgRef/UIFiles/DlgRef_1List1Spin1Btn_QTD.ui new file mode 100644 index 000000000..6366a74a7 --- /dev/null +++ b/src/DlgRef/UIFiles/DlgRef_1List1Spin1Btn_QTD.ui @@ -0,0 +1,93 @@ + +DlgRef_1List1Spin1Btn_QTD + + + DlgRef_1List1Spin1Btn_QTD + + + + 0 + 0 + 204 + 148 + + + + DlgRef_3Sel4Spin2Check_QTD + + + + unnamed + + + 11 + + + 6 + + + + GroupBox1 + + + + + + + unnamed + + + 11 + + + 6 + + + + Spacer1 + + + Vertical + + + Expanding + + + + 0 + 23 + + + + + + ListView1 + + + + + TextLabel1 + + + TL1 + + + + + SpinBox1 + + + + + PushButton1 + + + + + + + + + + + diff --git a/src/DlgRef/UIFiles/DlgRef_1Sel1Check_QTD.ui b/src/DlgRef/UIFiles/DlgRef_1Sel1Check_QTD.ui index 93c1da336..f86081355 100644 --- a/src/DlgRef/UIFiles/DlgRef_1Sel1Check_QTD.ui +++ b/src/DlgRef/UIFiles/DlgRef_1Sel1Check_QTD.ui @@ -8,8 +8,8 @@ 0 0 - 129 - 76 + 382 + 219 @@ -44,7 +44,7 @@ - Layout1 + Layout3 @@ -72,23 +72,6 @@ TL1 - - - Spacer5 - - - Vertical - - - Expanding - - - - 0 - 113 - - - PushButton1 @@ -105,12 +88,7 @@ - - - LineEdit1 - - - + CheckButton1 @@ -118,11 +96,38 @@ + + + Spacer5 + + + Vertical + + + Expanding + + + + 0 + 16 + + + + + + LineEdit1 + + + + PushButton1 + LineEdit1 + CheckButton1 + diff --git a/src/DlgRef/UIFiles/DlgRef_1Sel1Spin1Check_QTD.ui b/src/DlgRef/UIFiles/DlgRef_1Sel1Spin1Check_QTD.ui index 27b1ad9e3..c90e9c67e 100644 --- a/src/DlgRef/UIFiles/DlgRef_1Sel1Spin1Check_QTD.ui +++ b/src/DlgRef/UIFiles/DlgRef_1Sel1Spin1Check_QTD.ui @@ -8,8 +8,8 @@ 0 0 - 129 - 106 + 163 + 109 @@ -44,7 +44,7 @@ - Layout1 + Layout8 @@ -56,55 +56,6 @@ 6 - - - Spacer5 - - - Vertical - - - Expanding - - - - 0 - 120 - - - - - - TextLabel1 - - - - 0 - 0 - 0 - 0 - - - - TL1 - - - - - PushButton1 - - - - 0 - 0 - 0 - 0 - - - - - - Layout2 @@ -150,12 +101,44 @@ + + + TextLabel1 + + + + 0 + 0 + 0 + 0 + + + + TL1 + + LineEdit1 - + + + PushButton1 + + + + 0 + 0 + 0 + 0 + + + + + + + CheckButton1 @@ -163,11 +146,34 @@ + + + Spacer5 + + + Vertical + + + Expanding + + + + 0 + 16 + + + + + PushButton1 + LineEdit1 + SpinBox1 + CheckButton1 + diff --git a/src/DlgRef/UIFiles/DlgRef_1Sel3Check_QTD.ui b/src/DlgRef/UIFiles/DlgRef_1Sel3Check_QTD.ui index 113ad786c..c2e482a23 100644 --- a/src/DlgRef/UIFiles/DlgRef_1Sel3Check_QTD.ui +++ b/src/DlgRef/UIFiles/DlgRef_1Sel3Check_QTD.ui @@ -8,8 +8,8 @@ 0 0 - 129 - 114 + 163 + 116 @@ -44,7 +44,7 @@ - Layout1 + Layout6 @@ -56,7 +56,29 @@ 6 - + + + Spacer5 + + + Vertical + + + Expanding + + + + 0 + 16 + + + + + + LineEdit1 + + + CheckButton2 @@ -64,20 +86,20 @@ - + - TextLabel1 + CheckButton1 - - - 0 - 0 - 0 - 0 - + + + + + + + CheckButton3 - TL1 + @@ -96,42 +118,20 @@ - - - Spacer5 - - - Vertical - - - Expanding - - - - 0 - 60 - - - - + - CheckButton3 - - - + TextLabel1 - - - - CheckButton1 + + + 0 + 0 + 0 + 0 + - - - - - - LineEdit1 + TL1 @@ -140,5 +140,12 @@ + + PushButton1 + LineEdit1 + CheckButton1 + CheckButton2 + CheckButton3 + diff --git a/src/DlgRef/UIFiles/DlgRef_2Sel1Spin1Check_QTD.ui b/src/DlgRef/UIFiles/DlgRef_2Sel1Spin1Check_QTD.ui deleted file mode 100644 index a06de5cb4..000000000 --- a/src/DlgRef/UIFiles/DlgRef_2Sel1Spin1Check_QTD.ui +++ /dev/null @@ -1,210 +0,0 @@ - -DlgRef_2Sel1Spin1Check_QTD - - - DlgRef_2Sel1Spin1Check_QTD - - - - 0 - 0 - 129 - 117 - - - - DlgRef_2Sel1Spin1Check_QTD - - - - unnamed - - - 0 - - - 6 - - - - GroupBox1 - - - - - - - unnamed - - - 11 - - - 6 - - - - Layout1 - - - - unnamed - - - 0 - - - 6 - - - - LineEdit1 - - - - - TextLabel1 - - - - 0 - 0 - 0 - 0 - - - - TL1 - - - - - TextLabel2 - - - - 0 - 0 - 0 - 0 - - - - TL2 - - - - - LineEdit2 - - - - - PushButton1 - - - - 0 - 0 - 0 - 0 - - - - - - - - - Spacer5 - - - Vertical - - - Expanding - - - - 0 - 20 - - - - - - PushButton2 - - - - 0 - 0 - 0 - 0 - - - - - - - - - Layout2 - - - - unnamed - - - 0 - - - 6 - - - - SpinBox1 - - - - 7 - 0 - 0 - 0 - - - - - - CheckButton1 - - - - - - - - TextLabel3 - - - - 0 - 0 - 0 - 0 - - - - TL3 - - - - - - - - - - - - diff --git a/src/DlgRef/UIFiles/DlgRef_2Sel1Spin2Check_QTD.ui b/src/DlgRef/UIFiles/DlgRef_2Sel1Spin2Check_QTD.ui new file mode 100644 index 000000000..a2e4e0ace --- /dev/null +++ b/src/DlgRef/UIFiles/DlgRef_2Sel1Spin2Check_QTD.ui @@ -0,0 +1,211 @@ + +DlgRef_2Sel1Spin2Check_QTD + + + DlgRef_2Sel1Spin2Check_QTD + + + + 0 + 0 + 256 + 139 + + + + DlgRef_2Sel1Spin2Check_QTD + + + + unnamed + + + 0 + + + 6 + + + + GroupBox1 + + + + + + + unnamed + + + 11 + + + 6 + + + + Layout1 + + + + unnamed + + + 0 + + + 6 + + + + TextLabel2 + + + + 0 + 0 + 0 + 0 + + + + TL2 + + + + + PushButton1 + + + + 0 + 0 + 0 + 0 + + + + + + + + + TextLabel3 + + + + 0 + 0 + 0 + 0 + + + + TL3 + + + + + TextLabel1 + + + + 0 + 0 + 0 + 0 + + + + TL1 + + + + + Spacer5 + + + Vertical + + + Expanding + + + + 0 + 316 + + + + + + CheckButton2 + + + + + + + + LineEdit2 + + + + + PushButton2 + + + + 0 + 0 + 0 + 0 + + + + + + + + + LineEdit1 + + + + + CheckButton1 + + + + + + + + SpinBox1 + + + + 7 + 0 + 0 + 0 + + + + + + + + + + + PushButton1 + LineEdit1 + PushButton2 + LineEdit2 + SpinBox1 + CheckButton2 + CheckButton1 + + + diff --git a/src/DlgRef/UIFiles/DlgRef_2Sel1Spin_QTD.ui b/src/DlgRef/UIFiles/DlgRef_2Sel1Spin_QTD.ui index 053cae186..df952819a 100644 --- a/src/DlgRef/UIFiles/DlgRef_2Sel1Spin_QTD.ui +++ b/src/DlgRef/UIFiles/DlgRef_2Sel1Spin_QTD.ui @@ -8,8 +8,8 @@ 0 0 - 129 - 117 + 163 + 122 @@ -126,6 +126,12 @@ 0 + + NoFrame + + + Plain + TL2 @@ -198,5 +204,12 @@ + + PushButton1 + LineEdit1 + PushButton2 + LineEdit2 + SpinBox1 + diff --git a/src/DlgRef/UIFiles/DlgRef_2Sel2Spin1Check_QTD.ui b/src/DlgRef/UIFiles/DlgRef_2Sel2Spin1Check_QTD.ui index e5c699abb..1a97c8724 100644 --- a/src/DlgRef/UIFiles/DlgRef_2Sel2Spin1Check_QTD.ui +++ b/src/DlgRef/UIFiles/DlgRef_2Sel2Spin1Check_QTD.ui @@ -8,8 +8,8 @@ 0 0 - 129 - 164 + 163 + 170 @@ -72,9 +72,9 @@ TL2 - + - PushButton1 + TextLabel1 @@ -85,7 +85,7 @@ - + TL1 @@ -162,36 +162,9 @@ - - - TextLabel1 - - - - 0 - 0 - 0 - 0 - - - - TL1 - - - + - PushButton2 - - - - 0 - 0 - 0 - 0 - - - - + LineEdit1 @@ -207,26 +180,53 @@ 0 - 275 + 16 + + + CheckButton1 + + + + + LineEdit2 - + - CheckButton1 + PushButton2 + + + + 0 + 0 + 0 + 0 + - + - LineEdit1 + PushButton1 + + + + 0 + 0 + 0 + 0 + + + + @@ -235,5 +235,14 @@ + + PushButton1 + LineEdit1 + PushButton2 + LineEdit2 + SpinBox1 + SpinBox2 + CheckButton1 + diff --git a/src/DlgRef/UIFiles/DlgRef_2Sel4Spin1Check_QTD.ui b/src/DlgRef/UIFiles/DlgRef_2Sel4Spin1Check_QTD.ui index 85da96fca..f148e2c89 100644 --- a/src/DlgRef/UIFiles/DlgRef_2Sel4Spin1Check_QTD.ui +++ b/src/DlgRef/UIFiles/DlgRef_2Sel4Spin1Check_QTD.ui @@ -8,8 +8,8 @@ 0 0 - 129 - 222 + 262 + 230 @@ -44,7 +44,7 @@ - Layout1 + Layout5 @@ -56,11 +56,6 @@ 6 - - - LineEdit2 - - PushButton1 @@ -77,6 +72,14 @@ + + + CheckButton1 + + + + + Layout2 @@ -151,6 +154,81 @@ + + + LineEdit2 + + + + + TextLabel1 + + + + 0 + 0 + 0 + 0 + + + + TL1 + + + + + LineEdit1 + + + + + Spacer1 + + + Vertical + + + Expanding + + + + 0 + 16 + + + + + + PushButton2 + + + + 0 + 0 + 0 + 0 + + + + + + + + + TextLabel2 + + + + 0 + 0 + 0 + 0 + + + + TL2 + + Layout3 @@ -225,89 +303,22 @@ - - - PushButton2 - - - - 0 - 0 - 0 - 0 - - - - - - - - - TextLabel1 - - - - 0 - 0 - 0 - 0 - - - - TL1 - - - - - CheckButton1 - - - - - - - - LineEdit1 - - - - - TextLabel2 - - - - 0 - 0 - 0 - 0 - - - - TL2 - - - - - Spacer1 - - - Vertical - - - Expanding - - - - 0 - 177 - - - + + PushButton1 + LineEdit1 + PushButton2 + LineEdit2 + SpinBox1 + SpinBox2 + CheckButton1 + SpinBox3 + SpinBox4 + diff --git a/src/DlgRef/UIFiles/DlgRef_3Check_QTD.ui b/src/DlgRef/UIFiles/DlgRef_3Check_QTD.ui new file mode 100644 index 000000000..9573bb295 --- /dev/null +++ b/src/DlgRef/UIFiles/DlgRef_3Check_QTD.ui @@ -0,0 +1,112 @@ + +DlgRef_3Check_QTD + + + DlgRef_3Check_QTD + + + + 0 + 0 + 135 + 108 + + + + DlgRef_3Check_QTD + + + + unnamed + + + 0 + + + 6 + + + + GroupBox1 + + + + + + + unnamed + + + 11 + + + 6 + + + + Layout1 + + + + unnamed + + + 0 + + + 6 + + + + RadioButton3 + + + RadioButton3 + + + + + RadioButton1 + + + RadioButton1 + + + + + RadioButton2 + + + RadioButton2 + + + + + Spacer1 + + + Vertical + + + Expanding + + + + 0 + 91 + + + + + + + + + + + RadioButton1 + RadioButton2 + RadioButton3 + + + diff --git a/src/DlgRef/UIFiles/DlgRef_3Sel3Spin1Check_QTD.ui b/src/DlgRef/UIFiles/DlgRef_3Sel3Spin1Check_QTD.ui new file mode 100644 index 000000000..c48cc30c3 --- /dev/null +++ b/src/DlgRef/UIFiles/DlgRef_3Sel3Spin1Check_QTD.ui @@ -0,0 +1,317 @@ + +DlgRef_3Sel3Spin1Check_QTD + + + DlgRef_3Sel3Spin1Check_QTD + + + + 0 + 0 + 380 + 229 + + + + + 5 + 5 + 0 + 0 + + + + DlgRef_3Sel3Spin1Check_QTD + + + + unnamed + + + 0 + + + 6 + + + + GroupBox1 + + + + 5 + 5 + 0 + 0 + + + + + + + + unnamed + + + 11 + + + 6 + + + + Layout1 + + + + unnamed + + + 0 + + + 6 + + + + SpinBox_2 + + + + 7 + 0 + 0 + 0 + + + + + + LineEdit3 + + + + + SpinBox_3 + + + + 7 + 0 + 0 + 0 + + + + + + TextLabel1 + + + + 0 + 0 + 0 + 0 + + + + TL1 + + + + + TextLabel3 + + + + 0 + 0 + 0 + 0 + + + + TL3 + + + + + CheckBox1 + + + + + + + + PushButton1 + + + + 0 + 0 + 0 + 0 + + + + + + + + + TextLabel4 + + + + 0 + 0 + 0 + 0 + + + + TL4 + + + + + LineEdit2 + + + + + PushButton3 + + + + 0 + 0 + 0 + 0 + + + + + + + + + TextLabel6 + + + + 0 + 0 + 0 + 0 + + + + TL6 + + + + + SpinBox_1 + + + + 7 + 0 + 0 + 0 + + + + + + TextLabel5 + + + + 0 + 0 + 0 + 0 + + + + TL5 + + + + + TextLabel2 + + + + 0 + 0 + 0 + 0 + + + + TL2 + + + + + LineEdit1 + + + + + PushButton2 + + + + 0 + 0 + 0 + 0 + + + + + + + + + Spacer3 + + + Vertical + + + Expanding + + + + 0 + 250 + + + + + + + + + + + PushButton1 + LineEdit1 + PushButton2 + LineEdit2 + PushButton3 + LineEdit3 + SpinBox_1 + SpinBox_2 + SpinBox_3 + CheckBox1 + + + diff --git a/src/DlgRef/UIFiles/DlgRef_3Sel4Spin2Check_QTD.ui b/src/DlgRef/UIFiles/DlgRef_3Sel4Spin2Check_QTD.ui index 93e8f84d8..441a99a72 100644 --- a/src/DlgRef/UIFiles/DlgRef_3Sel4Spin2Check_QTD.ui +++ b/src/DlgRef/UIFiles/DlgRef_3Sel4Spin2Check_QTD.ui @@ -8,8 +8,8 @@ 0 0 - 129 - 271 + 269 + 281 @@ -56,20 +56,12 @@ 6 - + - TextLabel2 - - - - 0 - 0 - 0 - 0 - + CheckButton2 - TL2 + @@ -77,9 +69,9 @@ LineEdit1 - + - PushButton1 + TextLabel3 @@ -90,12 +82,12 @@ - + TL3 - + - PushButton3 + PushButton2 @@ -109,26 +101,30 @@ - + - Spacer1 + LineEdit3 - - Vertical + + + + PushButton1 - - Expanding + + + 0 + 0 + 0 + 0 + - - - 0 - 155 - + + - - + + - Layout2 + Layout3 @@ -140,69 +136,77 @@ 6 - + - TextLabel5 + SpinBox4 - 0 + 7 0 0 0 - - TL5 - - + - TextLabel4 + SpinBox3 - 0 + 7 0 0 0 - - TL4 - - + - SpinBox1 + TextLabel7 - 7 + 0 0 0 0 + + TL7 + - + - SpinBox2 + TextLabel6 - 7 + 0 0 0 0 + + TL6 + - + - TextLabel3 + CheckButton1 + + + + + + + + PushButton3 @@ -213,17 +217,50 @@ - TL3 + - + - LineEdit3 + TextLabel1 + + + + 0 + 0 + 0 + 0 + + + + TL1 - + - Layout3 + Spacer1 + + + Vertical + + + Expanding + + + + 0 + 16 + + + + + + LineEdit2 + + + + + Layout2 @@ -235,98 +272,69 @@ 6 - + - SpinBox4 + TextLabel5 - 7 + 0 0 0 0 + + TL5 + - + - SpinBox3 + TextLabel4 - 7 + 0 0 0 0 + + TL4 + - + - TextLabel7 + SpinBox1 - 0 + 7 0 0 0 - - TL7 - - + - TextLabel6 + SpinBox2 - 0 + 7 0 0 0 - - TL6 - - - - CheckButton2 - - - - - - - - TextLabel1 - - - - 0 - 0 - 0 - 0 - - - - TL1 - - - - - LineEdit2 - - - + - PushButton2 + TextLabel2 @@ -337,15 +345,7 @@ - - - - - - CheckButton1 - - - + TL2 @@ -354,5 +354,19 @@ + + PushButton1 + LineEdit1 + PushButton2 + LineEdit2 + PushButton3 + LineEdit3 + SpinBox1 + SpinBox2 + CheckButton1 + SpinBox3 + SpinBox4 + CheckButton2 + diff --git a/src/DlgRef/UIFiles/DlgRef_6Sel_QTD.ui b/src/DlgRef/UIFiles/DlgRef_6Sel_QTD.ui new file mode 100644 index 000000000..c5ff40649 --- /dev/null +++ b/src/DlgRef/UIFiles/DlgRef_6Sel_QTD.ui @@ -0,0 +1,296 @@ + +DlgRef_6Sel_QTD + + + DlgRef_6Sel_QTD + + + + 0 + 0 + 235 + 196 + + + + + 5 + 7 + 0 + 0 + + + + DlgRef_6Sel_QTD + + + + unnamed + + + 0 + + + 6 + + + + GroupBox1 + + + + + + + unnamed + + + 11 + + + 6 + + + + Layout1 + + + + unnamed + + + 0 + + + 6 + + + + TextLabel1 + + + + 0 + 0 + 0 + 0 + + + + TL1 + + + + + TextLabel2 + + + + 0 + 0 + 0 + 0 + + + + TL2 + + + + + TextLabel3 + + + + 0 + 0 + 0 + 0 + + + + TL3 + + + + + TextLabel4 + + + + 0 + 0 + 0 + 0 + + + + TL4 + + + + + TextLabel5 + + + + 0 + 0 + 0 + 0 + + + + TL5 + + + + + TextLabel6 + + + + 0 + 0 + 0 + 0 + + + + TL6 + + + + + PushButton1 + + + + 0 + 0 + 0 + 0 + + + + + + + + + PushButton2 + + + + 0 + 0 + 0 + 0 + + + + + + + + + PushButton3 + + + + 0 + 0 + 0 + 0 + + + + + + + + + PushButton4 + + + + 0 + 0 + 0 + 0 + + + + + + + + + PushButton5 + + + + 0 + 0 + 0 + 0 + + + + + + + + + PushButton6 + + + + 0 + 0 + 0 + 0 + + + + + + + + + LineEdit1 + + + + + LineEdit2 + + + + + LineEdit3 + + + + + LineEdit4 + + + + + LineEdit5 + + + + + LineEdit6 + + + + + + + + + + diff --git a/src/DlgRef/UIFiles/DlgRef_Skeleton_QTD.ui b/src/DlgRef/UIFiles/DlgRef_Skeleton_QTD.ui index eed5c27f4..1098d6c46 100644 --- a/src/DlgRef/UIFiles/DlgRef_Skeleton_QTD.ui +++ b/src/DlgRef/UIFiles/DlgRef_Skeleton_QTD.ui @@ -8,8 +8,8 @@ 0 0 - 321 - 295 + 307 + 378 @@ -165,7 +165,7 @@ - + unnamed @@ -175,7 +175,7 @@ 6 - + Layout2 @@ -213,9 +213,17 @@ + + + RadioButton4 + + + + + - + diff --git a/src/DlgRef/UIFiles/ui_to_cxx b/src/DlgRef/UIFiles/ui_to_cxx index d65425f35..b042efa8e 100755 --- a/src/DlgRef/UIFiles/ui_to_cxx +++ b/src/DlgRef/UIFiles/ui_to_cxx @@ -21,8 +21,8 @@ #uic -o DlgRef_1Sel4Spin_QTD.h DlgRef_1Sel4Spin_QTD.ui #uic -o DlgRef_1Sel4Spin_QTD.cxx -impl DlgRef_1Sel4Spin_QTD.h DlgRef_1Sel4Spin_QTD.ui -uic -o DlgRef_1Sel5Spin_QTD.h DlgRef_1Sel5Spin_QTD.ui -uic -o DlgRef_1Sel5Spin_QTD.cxx -impl DlgRef_1Sel5Spin_QTD.h DlgRef_1Sel5Spin_QTD.ui +#uic -o DlgRef_1Sel5Spin_QTD.h DlgRef_1Sel5Spin_QTD.ui +#uic -o DlgRef_1Sel5Spin_QTD.cxx -impl DlgRef_1Sel5Spin_QTD.h DlgRef_1Sel5Spin_QTD.ui #uic -o DlgRef_1Sel1Check_QTD.h DlgRef_1Sel1Check_QTD.ui #uic -o DlgRef_1Sel1Check_QTD.cxx -impl DlgRef_1Sel1Check_QTD.h DlgRef_1Sel1Check_QTD.ui @@ -39,8 +39,8 @@ uic -o DlgRef_1Sel5Spin_QTD.cxx -impl DlgRef_1Sel5Spin_QTD.h DlgRef_1Sel5Spin_QT #uic -o DlgRef_2Sel1Spin_QTD.h DlgRef_2Sel1Spin_QTD.ui #uic -o DlgRef_2Sel1Spin_QTD.cxx -impl DlgRef_2Sel1Spin_QTD.h DlgRef_2Sel1Spin_QTD.ui -#uic -o DlgRef_2Sel1Spin1Check_QTD.h DlgRef_2Sel1Spin1Check_QTD.ui -#uic -o DlgRef_2Sel1Spin1Check_QTD.cxx -impl DlgRef_2Sel1Spin1Check_QTD.h DlgRef_2Sel1Spin1Check_QTD.ui +#uic -o DlgRef_2Sel1Spin2Check_QTD.h DlgRef_2Sel1Spin2Check_QTD.ui +#uic -o DlgRef_2Sel1Spin2Check_QTD.cxx -impl DlgRef_2Sel1Spin2Check_QTD.h DlgRef_2Sel1Spin2Check_QTD.ui #uic -o DlgRef_2Sel2Spin_QTD.h DlgRef_2Sel2Spin_QTD.ui #uic -o DlgRef_2Sel2Spin_QTD.cxx -impl DlgRef_2Sel2Spin_QTD.h DlgRef_2Sel2Spin_QTD.ui @@ -74,3 +74,12 @@ uic -o DlgRef_1Sel5Spin_QTD.cxx -impl DlgRef_1Sel5Spin_QTD.h DlgRef_1Sel5Spin_QT #uic -o DlgRef_3Spin1Check_QTD.h DlgRef_3Spin1Check_QTD.ui #uic -o DlgRef_3Spin1Check_QTD.cxx -impl DlgRef_3Spin1Check_QTD.h DlgRef_3Spin1Check_QTD.ui + +#uic -o DlgRef_3Sel3Spin1Check_QTD.h DlgRef_3Sel3Spin1Check_QTD.ui +#uic -o DlgRef_3Sel3Spin1Check_QTD.cxx -impl DlgRef_3Sel3Spin1Check_QTD.h DlgRef_3Sel3Spin1Check_QTD.ui + +#uic -o DlgRef_6Sel_QTD.h DlgRef_6Sel_QTD.ui +#uic -o DlgRef_6Sel_QTD.cxx -impl DlgRef_6Sel_QTD.h DlgRef_6Sel_QTD.ui + +uic -o DlgRef_3Check_QTD.h DlgRef_3Check_QTD.ui +uic -o DlgRef_3Check_QTD.cxx -impl DlgRef_3Check_QTD.h DlgRef_3Check_QTD.ui diff --git a/src/EntityGUI/EntityGUI.cxx b/src/EntityGUI/EntityGUI.cxx index 049b4fe00..28765de1f 100644 --- a/src/EntityGUI/EntityGUI.cxx +++ b/src/EntityGUI/EntityGUI.cxx @@ -24,12 +24,15 @@ // File : EntityGUI.cxx // Author : Damien COQUERET // Module : GEOM -// $Header: +// $Header$ #include "EntityGUI.h" +#include "GeometryGUI.h" #include "QAD_RightFrame.h" +#include "QAD_Desktop.h" #include "OCCViewer_Viewer3d.h" +#include "OCCViewer_ViewFrame.h" #include "VTKViewer_ViewFrame.h" #include "GEOM_AssemblyBuilder.h" #include "SALOMEGUI_ImportOperation.h" @@ -39,8 +42,6 @@ #include #include -#include "DisplayGUI.h" - #include "EntityGUI_SketcherDlg.h" // Sketcher #include "EntityGUI_SubShapeDlg.h" // Method SUBSHAPE @@ -48,16 +49,29 @@ using namespace std; +EntityGUI* EntityGUI::myGUIObject = 0; + +//======================================================================= +// function : GetEntityGUI() +// purpose : Get the only EntityGUI object [ static ] +//======================================================================= +EntityGUI* EntityGUI::GetEntityGUI() +{ + if ( myGUIObject == 0 ) { + // init EntityGUI only once + myGUIObject = new EntityGUI(); + } + return myGUIObject; +} + //======================================================================= // function : EntityGUI() // purpose : Constructor //======================================================================= -EntityGUI::EntityGUI() : - QObject() +EntityGUI::EntityGUI() : GEOMGUI() { myGeomBase = new GEOMBase(); - myGeomGUI = GEOMContext::GetGeomGUI(); - myGeom = myGeomGUI->myComponentGeom; + myGeom = GEOM::GEOM_Gen::_duplicate( GeometryGUI::GetGeomGUI()->GetGeomGen() ); mySimulationShape1 = new AIS_Shape(TopoDS_Shape()); mySimulationShape2 = new AIS_Shape(TopoDS_Shape()); @@ -79,34 +93,26 @@ EntityGUI::~EntityGUI() //======================================================================= bool EntityGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) { - EntityGUI* myEntityGUI = new EntityGUI(); - myEntityGUI->myGeomGUI->EmitSignalDeactivateDialog(); + GeometryGUI::GetGeomGUI()->EmitSignalDeactivateDialog(); SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection()); + QDialog* aDlg = NULL; switch (theCommandID) - { + { case 404: // SKETCHER - { - ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->onViewTop(); // DCQ : 28/02/2002 - EntityGUI_SketcherDlg* aDlg = new EntityGUI_SketcherDlg(parent, "", myEntityGUI, Sel); - break; - } + GeometryGUI::GetGeomGUI()->ActiveWorkingPlane(); + aDlg = new EntityGUI_SketcherDlg(parent, "", Sel); + break; case 407: // EXPLODE : use ic - { - Handle(AIS_InteractiveContext) ic; - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - ic = v3d->getAISContext(); - } - EntityGUI_SubShapeDlg *aDlg = new EntityGUI_SubShapeDlg(parent, "", myEntityGUI, Sel, ic); - break ; - } + aDlg = new EntityGUI_SubShapeDlg(parent, "", Sel); + break; default: - { - parent->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); - break; - } - } + parent->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); + break; + } + if ( aDlg ) + aDlg->show(); + return true; } @@ -117,6 +123,9 @@ bool EntityGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) //======================================================================= void EntityGUI::OnSketchEnd(const char *Cmd) { + /* QAD_Application::getDesktop()->putInfo("Create sketch functionality is NOT implemented in new GEOM kernel + (no such Corba interface method). Waiting for SRN to create it..."); + try { GEOM::GEOM_Shape_var result = myGeom->MakeSketcher(Cmd); if(result->_is_nil()) { @@ -130,6 +139,7 @@ void EntityGUI::OnSketchEnd(const char *Cmd) catch(const SALOME::SALOME_Exception& S_ex) { QtCatchCorbaException(S_ex); } + */ return; } @@ -185,27 +195,22 @@ void EntityGUI::DisplaySimulationShape(const TopoDS_Shape& S1, const TopoDS_Shap // function : EraseSimulationShape() // purpose : Clears the display of 'mySimulationShape' a pure graphical shape //================================================================================== -void EntityGUI::EraseSimulationShape(int Sh) +void EntityGUI::EraseSimulationShape() { int count = QAD_Application::getDesktop()->getActiveStudy()->getStudyFramesCount(); for(int i = 0; i < count; i++) { if(QAD_Application::getDesktop()->getActiveStudy()->getStudyFrame(i)->getTypeView() == VIEW_OCC) { OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getStudyFrame(i)->getRightFrame()->getViewFrame())->getViewer(); Handle(AIS_InteractiveContext) ic = v3d->getAISContext(); - if(Sh < 1) { - ic->Erase(mySimulationShape1, Standard_True, Standard_False); - ic->ClearPrs(mySimulationShape1); - } - if(Sh <= 1) { - ic->Erase(mySimulationShape2, Standard_True, Standard_False); - ic->ClearPrs(mySimulationShape2); - } + ic->Erase(mySimulationShape1, Standard_True, Standard_False); + ic->ClearPrs(mySimulationShape1); + ic->Erase(mySimulationShape2, Standard_True, Standard_False); + ic->ClearPrs(mySimulationShape2); ic->UpdateCurrentViewer(); } } } - //===================================================================================== // function : SObjectExist() // purpose : @@ -242,6 +247,8 @@ bool EntityGUI::SObjectExist(SALOMEDS::SObject_ptr theFatherObject, const char* //===================================================================================== bool EntityGUI::OnSubShapeGetAll(const TopoDS_Shape& ShapeTopo, const char* ShapeTopoIOR, const int SubShapeType) { + QAD_Application::getDesktop()->putInfo("OnSubShapeGetAll method from EntityGUI should be reimplemented ..."); + /* SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument(); SALOMEDS::SObject_var theObj = aStudy->FindObjectIOR(ShapeTopoIOR); if(theObj->_is_nil()) { @@ -256,8 +263,8 @@ bool EntityGUI::OnSubShapeGetAll(const TopoDS_Shape& ShapeTopo, const char* Shap SALOMEDS::AttributeIOR_var anIOR; SALOMEDS::AttributePixMap_var aPixmap; - /* We create a sub object for each sub shape as attribute of the main object */ - /* Each sub object contains list (length=1) containing its index in the main shape */ + // We create a sub object for each sub shape as attribute of the main object + // Each sub object contains list (length=1) containing its index in the main shape GEOM::GEOM_Shape_var aShape = myGeom->GetIORFromString(ShapeTopoIOR); GEOM::GEOM_Gen::ListOfGeomShapes_var listGeomShapes = new GEOM::GEOM_Gen::ListOfGeomShapes; GEOM::GEOM_Shape_var aResult; @@ -273,7 +280,7 @@ bool EntityGUI::OnSubShapeGetAll(const TopoDS_Shape& ShapeTopo, const char* Shap QtCatchCorbaException(S_ex); } - /* open transaction */ + // open transaction QAD_Operation* op = new SALOMEGUI_ImportOperation(QAD_Application::getDesktop()->getActiveStudy()); op->start(); @@ -289,10 +296,10 @@ bool EntityGUI::OnSubShapeGetAll(const TopoDS_Shape& ShapeTopo, const char* Shap aShape = myGeom->GetIORFromString(aShape->MainName()); } - /* Loop on each sub shape created */ - /* int i = 1 ; /* index for the nameType */ + // Loop on each sub shape created + // int i = 1 ; index for the nameType for(int j=0; jlength(); j++) { - /* Get each sub shape extracted CORBA and OCC */ + // Get each sub shape extracted CORBA and OCC aResult = listGeomShapes[j] ; TopoDS_Shape S = myGeomGUI->GetShapeReader().GetShape(myGeom, aResult); @@ -301,7 +308,7 @@ bool EntityGUI::OnSubShapeGetAll(const TopoDS_Shape& ShapeTopo, const char* Shap return false; } - /* Set the nameType of sub shape */ + // Set the nameType of sub shape char* nameG = (char *)malloc(20); Standard_CString Type; if(myGeomBase->GetShapeTypeString(S, Type)) { @@ -444,11 +451,12 @@ bool EntityGUI::OnSubShapeGetAll(const TopoDS_Shape& ShapeTopo, const char* Shap } } - /* commit transaction */ + // commit transaction op->finish(); QAD_Application::getDesktop()->getActiveStudy()->updateObjBrowser(); QAD_Application::getDesktop()->putInfo (tr("GEOM_PRP_READY")); + */ return true; } @@ -459,184 +467,185 @@ bool EntityGUI::OnSubShapeGetAll(const TopoDS_Shape& ShapeTopo, const char* Shap //===================================================================================== bool EntityGUI::OnSubShapeGetSelected(const TopoDS_Shape& ShapeTopo, const char* ShapeTopoIOR, const int SubShapeType, Standard_Integer& aLocalContextId, bool& myUseLocalContext) { - //* Test the type of viewer */ - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC) - return false; - - SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument(); - SALOMEDS::SObject_var theObj = aStudy->FindObjectIOR(ShapeTopoIOR); - if(theObj->_is_nil()) { - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY")); - return false; - } - - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - Handle(AIS_InteractiveContext) ic = v3d->getAISContext(); + QAD_Application::getDesktop()->putInfo("OnSubShapeGetSelected method from EntityGUI should be reimplemented ..."); + // //* Test the type of viewer */ +// if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC) +// return false; + +// SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument(); +// SALOMEDS::SObject_var theObj = aStudy->FindObjectIOR(ShapeTopoIOR); +// if(theObj->_is_nil()) { +// QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY")); +// return false; +// } + +// OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); +// Handle(AIS_InteractiveContext) ic = v3d->getAISContext(); - if( myUseLocalContext == false ) { - /* local context is from DialogBox */ - MESSAGE("Error : No local context opened for sub shapes method" << endl ) ; - return false ; - } - - GEOM::GEOM_Shape_var aShape = myGeom->GetIORFromString( ShapeTopoIOR ); - TopoDS_Shape mainTopo = myGeomGUI->GetShapeReader().GetShape(myGeom, aShape); - - TopoDS_Shape mainShape; - bool main = false; - while(!main) { - if(aShape->IsMainShape()) { - mainShape = myGeomGUI->GetShapeReader().GetShape(myGeom, aShape); - main = true; - } - else - aShape = myGeom->GetIORFromString(aShape->MainName()); - } - - GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID; - ic->InitSelected(); - int nbSelected = ic->NbSelected(); - ListOfID->length(nbSelected); +// if( myUseLocalContext == false ) { +// /* local context is from DialogBox */ +// MESSAGE("Error : No local context opened for sub shapes method" << endl ) ; +// return false ; +// } + +// GEOM::GEOM_Shape_var aShape = myGeom->GetIORFromString( ShapeTopoIOR ); +// TopoDS_Shape mainTopo = myGeomGUI->GetShapeReader().GetShape(myGeom, aShape); + +// TopoDS_Shape mainShape; +// bool main = false; +// while(!main) { +// if(aShape->IsMainShape()) { +// mainShape = myGeomGUI->GetShapeReader().GetShape(myGeom, aShape); +// main = true; +// } +// else +// aShape = myGeom->GetIORFromString(aShape->MainName()); +// } + +// GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID; +// ic->InitSelected(); +// int nbSelected = ic->NbSelected(); +// ListOfID->length(nbSelected); - TopoDS_Compound compound; - ic->InitSelected(); /* to init again */ - BRep_Builder B; - B.MakeCompound(compound); - - int i = 0; - /* We create a unique compound containing all the sub shapes selected by user as attribute of the main shape */ - /* the compound is homogenous by selection */ - while(ic->MoreSelected()) { - int index = myGeomBase->GetIndex(ic->SelectedShape(), mainShape, SubShapeType); - ListOfID[i] = index; - B.Add(compound, ic->SelectedShape()); - i++; - ic->NextSelected(); - } +// TopoDS_Compound compound; +// ic->InitSelected(); /* to init again */ +// BRep_Builder B; +// B.MakeCompound(compound); + +// int i = 0; +// /* We create a unique compound containing all the sub shapes selected by user as attribute of the main shape */ +// /* the compound is homogenous by selection */ +// while(ic->MoreSelected()) { +// int index = myGeomBase->GetIndex(ic->SelectedShape(), mainShape, SubShapeType); +// ListOfID[i] = index; +// B.Add(compound, ic->SelectedShape()); +// i++; +// ic->NextSelected(); +// } - /* Test if user has selected sub shapes */ - if(ListOfID->length() < 1) - return false; - - GEOM::GEOM_Shape_var aResult; - try { - aResult = myGeom->SubShape(aShape, SubShapeType, ListOfID); - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - - /* local context from DialogBox */ - ic->CloseLocalContext(aLocalContextId); - myUseLocalContext = false ; - - char* nameG = (char *)malloc(20); - Standard_CString Type; - - Handle(GEOM_AISShape) result; - Handle(GEOM_InteractiveObject) IO; - - if(nbSelected == 1) { - TopExp_Explorer Exp (compound, TopAbs_ShapeEnum(SubShapeType)); - if(Exp.More()) { - if(myGeomBase->GetShapeTypeString(Exp.Current(),Type)) { - aResult->NameType(Type); - sprintf (nameG, "%s_%d", Type, myGeomBase->GetIndex( Exp.Current(), mainTopo, SubShapeType)); - } - else { - aResult->NameType(tr("GEOM_SHAPE")); - sprintf (nameG, "%s_%d", tr("GEOM_SHAPE").latin1(), myGeomGUI->myNbGeom++); - } - result = new GEOM_AISShape(Exp.Current(), nameG); - IO = new GEOM_InteractiveObject(aResult->Name(), myGeomGUI->GetFatherior(), "GEOM"); - } - } - else { - if ( myGeomBase->GetShapeTypeString(compound,Type)) { - aResult->NameType(Type); - sprintf (nameG, "%s_%d", Type, myGeomGUI->myNbGeom++); - } else { - aResult->NameType(tr("GEOM_SHAPE")); - sprintf (nameG, "%s_%d", tr("GEOM_SHAPE").latin1(), myGeomGUI->myNbGeom++); - } - result = new GEOM_AISShape(compound, nameG); - IO = new GEOM_InteractiveObject(aResult->Name(), myGeomGUI->GetFatherior(), "GEOM"); - } +// /* Test if user has selected sub shapes */ +// if(ListOfID->length() < 1) +// return false; + +// GEOM::GEOM_Shape_var aResult; +// try { +// aResult = myGeom->SubShape(aShape, SubShapeType, ListOfID); +// } +// catch (const SALOME::SALOME_Exception& S_ex) { +// QtCatchCorbaException(S_ex); +// } + +// /* local context from DialogBox */ +// ic->CloseLocalContext(aLocalContextId); +// myUseLocalContext = false ; + +// char* nameG = (char *)malloc(20); +// Standard_CString Type; + +// Handle(GEOM_AISShape) result; +// Handle(GEOM_InteractiveObject) IO; + +// if(nbSelected == 1) { +// TopExp_Explorer Exp (compound, TopAbs_ShapeEnum(SubShapeType)); +// if(Exp.More()) { +// if(myGeomBase->GetShapeTypeString(Exp.Current(),Type)) { +// aResult->NameType(Type); +// sprintf (nameG, "%s_%d", Type, myGeomBase->GetIndex( Exp.Current(), mainTopo, SubShapeType)); +// } +// else { +// aResult->NameType(tr("GEOM_SHAPE")); +// sprintf (nameG, "%s_%d", tr("GEOM_SHAPE").latin1(), myGeomGUI->myNbGeom++); +// } +// result = new GEOM_AISShape(Exp.Current(), nameG); +// IO = new GEOM_InteractiveObject(aResult->Name(), myGeomGUI->GetFatherior(), "GEOM"); +// } +// } +// else { +// if ( myGeomBase->GetShapeTypeString(compound,Type)) { +// aResult->NameType(Type); +// sprintf (nameG, "%s_%d", Type, myGeomGUI->myNbGeom++); +// } else { +// aResult->NameType(tr("GEOM_SHAPE")); +// sprintf (nameG, "%s_%d", tr("GEOM_SHAPE").latin1(), myGeomGUI->myNbGeom++); +// } +// result = new GEOM_AISShape(compound, nameG); +// IO = new GEOM_InteractiveObject(aResult->Name(), myGeomGUI->GetFatherior(), "GEOM"); +// } - SALOMEDS::SObject_var SO = aStudy->FindObjectIOR(aResult->Name()); +// SALOMEDS::SObject_var SO = aStudy->FindObjectIOR(aResult->Name()); - /* open transaction */ - QAD_Operation* op = new SALOMEGUI_ImportOperation(QAD_Application::getDesktop()->getActiveStudy()); - op->start(); +// /* open transaction */ +// QAD_Operation* op = new SALOMEGUI_ImportOperation(QAD_Application::getDesktop()->getActiveStudy()); +// op->start(); - SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); - SALOMEDS::SObject_var fatherSF = aStudy->FindObjectID(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->entry()); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeName_var aName; - SALOMEDS::AttributeIOR_var anIOR; - SALOMEDS::AttributePixMap_var aPixmap; +// SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); +// SALOMEDS::SObject_var fatherSF = aStudy->FindObjectID(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->entry()); +// SALOMEDS::GenericAttribute_var anAttr; +// SALOMEDS::AttributeName_var aName; +// SALOMEDS::AttributeIOR_var anIOR; +// SALOMEDS::AttributePixMap_var aPixmap; - bool allreadyexist = false; - - if(SO->_is_nil()) { - SALOMEDS::SObject_var newObj = aStudyBuilder->NewObject(theObj); - anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeIOR"); - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - anIOR->SetValue(aResult->Name()); - anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeName"); - aName = SALOMEDS::AttributeName::_narrow(anAttr); - aName->SetValue(result->getName()); +// bool allreadyexist = false; + +// if(SO->_is_nil()) { +// SALOMEDS::SObject_var newObj = aStudyBuilder->NewObject(theObj); +// anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeIOR"); +// anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); +// anIOR->SetValue(aResult->Name()); +// anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeName"); +// aName = SALOMEDS::AttributeName::_narrow(anAttr); +// aName->SetValue(result->getName()); - anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributePixMap"); - aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); - if(result->Shape().ShapeType() == TopAbs_COMPOUND) - aPixmap->SetPixMap("ICON_OBJBROWSER_COMPOUND"); - else if(result->Shape().ShapeType() == TopAbs_COMPSOLID) - aPixmap->SetPixMap("ICON_OBJBROWSER_COMPSOLID"); - else if(result->Shape().ShapeType() == TopAbs_SOLID) - aPixmap->SetPixMap("ICON_OBJBROWSER_SOLID"); - else if(result->Shape().ShapeType() == TopAbs_SHELL) - aPixmap->SetPixMap("ICON_OBJBROWSER_SHELL"); - else if(result->Shape().ShapeType() == TopAbs_FACE) - aPixmap->SetPixMap("ICON_OBJBROWSER_FACE"); - else if(result->Shape().ShapeType() == TopAbs_WIRE) - aPixmap->SetPixMap("ICON_OBJBROWSER_WIRE"); - else if(result->Shape().ShapeType() == TopAbs_EDGE) - aPixmap->SetPixMap("ICON_OBJBROWSER_EDGE"); - else if(result->Shape().ShapeType() == TopAbs_VERTEX) - aPixmap->SetPixMap("ICON_OBJBROWSER_VERTEX"); - - SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF); - aStudyBuilder->Addreference(newObj1, newObj); +// anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributePixMap"); +// aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); +// if(result->Shape().ShapeType() == TopAbs_COMPOUND) +// aPixmap->SetPixMap("ICON_OBJBROWSER_COMPOUND"); +// else if(result->Shape().ShapeType() == TopAbs_COMPSOLID) +// aPixmap->SetPixMap("ICON_OBJBROWSER_COMPSOLID"); +// else if(result->Shape().ShapeType() == TopAbs_SOLID) +// aPixmap->SetPixMap("ICON_OBJBROWSER_SOLID"); +// else if(result->Shape().ShapeType() == TopAbs_SHELL) +// aPixmap->SetPixMap("ICON_OBJBROWSER_SHELL"); +// else if(result->Shape().ShapeType() == TopAbs_FACE) +// aPixmap->SetPixMap("ICON_OBJBROWSER_FACE"); +// else if(result->Shape().ShapeType() == TopAbs_WIRE) +// aPixmap->SetPixMap("ICON_OBJBROWSER_WIRE"); +// else if(result->Shape().ShapeType() == TopAbs_EDGE) +// aPixmap->SetPixMap("ICON_OBJBROWSER_EDGE"); +// else if(result->Shape().ShapeType() == TopAbs_VERTEX) +// aPixmap->SetPixMap("ICON_OBJBROWSER_VERTEX"); + +// SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF); +// aStudyBuilder->Addreference(newObj1, newObj); - IO->setEntry(newObj->GetID()); - aResult->StudyShapeId(newObj->GetID()); - } - else { - allreadyexist = true; - if(!this->SObjectExist(theObj, aResult->Name())) { - SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(theObj); - aStudyBuilder->Addreference(newObj1, SO); +// IO->setEntry(newObj->GetID()); +// aResult->StudyShapeId(newObj->GetID()); +// } +// else { +// allreadyexist = true; +// if(!this->SObjectExist(theObj, aResult->Name())) { +// SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(theObj); +// aStudyBuilder->Addreference(newObj1, SO); - IO->setEntry(SO->GetID()); - aResult->StudyShapeId(SO->GetID()); - } - } +// IO->setEntry(SO->GetID()); +// aResult->StudyShapeId(SO->GetID()); +// } +// } - /* commit transaction */ - op->finish(); +// /* commit transaction */ +// op->finish(); - result->setIO(IO); - result->setName(nameG); +// result->setIO(IO); +// result->setName(nameG); - if(!allreadyexist) - ic->Display(result); +// if(!allreadyexist) +// ic->Display(result); - DisplayGUI* myDisplayGUI = new DisplayGUI(); - myDisplayGUI->OnDisplayAll(true); +// DisplayGUI* myDisplayGUI = new DisplayGUI(); +// myDisplayGUI->OnDisplayAll(true); - QAD_Application::getDesktop()->getActiveStudy()->updateObjBrowser(); - QAD_Application::getDesktop()->putInfo (tr("GEOM_PRP_READY")); +// QAD_Application::getDesktop()->getActiveStudy()->updateObjBrowser(); +// QAD_Application::getDesktop()->putInfo (tr("GEOM_PRP_READY")); return true; } @@ -646,6 +655,8 @@ bool EntityGUI::OnSubShapeGetSelected(const TopoDS_Shape& ShapeTopo, const char* //===================================================================================== extern "C" { - bool OnGUIEvent(int theCommandID, QAD_Desktop* parent) - {return EntityGUI::OnGUIEvent(theCommandID, parent);} + GEOMGUI* GetLibGUI() + { + return EntityGUI::GetEntityGUI(); + } } diff --git a/src/EntityGUI/EntityGUI.h b/src/EntityGUI/EntityGUI.h index 9ecb56744..bc0fdadc4 100644 --- a/src/EntityGUI/EntityGUI.h +++ b/src/EntityGUI/EntityGUI.h @@ -24,31 +24,38 @@ // File : EntityGUI.h // Author : Damien COQUERET // Module : GEOM -// $Header: +// $Header$ #ifndef ENTITYGUI_H #define ENTITYGUI_H +#include "GEOMGUI.h" #include "GEOMBase.h" //================================================================================= // class : EntityGUI // purpose : //================================================================================= -class EntityGUI : public QObject +class EntityGUI : public GEOMGUI { - Q_OBJECT /* for QT compatibility */ +protected: + EntityGUI(); // hide constructor to avoid direct creation public : - EntityGUI(); ~EntityGUI(); - static bool OnGUIEvent(int theCommandID, QAD_Desktop* parent); + // Get the only EntityGUI object + static EntityGUI* GetEntityGUI(); + + bool OnGUIEvent(int theCommandID, QAD_Desktop* parent); void OnSketchEnd(const char *Cmd); void DisplaySimulationShape(const TopoDS_Shape& S1, const TopoDS_Shape& S2); - void EraseSimulationShape(int Sh = 0); + void EraseSimulationShape(); + + void MakeInterpolAndDisplay(GEOM::string_array& listShapesIOR); + void MakeBezierAndDisplay(GEOM::string_array& listShapesIOR); /* Methods for sub shapes explode */ bool SObjectExist(SALOMEDS::SObject_ptr theFatherObject, const char* IOR); @@ -61,9 +68,10 @@ public : Handle(AIS_Shape) mySimulationShape2; GEOMBase* myGeomBase; - GEOMContext* myGeomGUI; GEOM::GEOM_Gen_var myGeom; /* Current Geom Component */ +private: + static EntityGUI* myGUIObject; // the only EntityGUI object }; #endif diff --git a/src/EntityGUI/EntityGUI_1Sel_QTD.cxx b/src/EntityGUI/EntityGUI_1Sel_QTD.cxx index 01584de8f..824a6ecc7 100644 --- a/src/EntityGUI/EntityGUI_1Sel_QTD.cxx +++ b/src/EntityGUI/EntityGUI_1Sel_QTD.cxx @@ -1,7 +1,7 @@ /**************************************************************************** ** Form implementation generated from reading ui file 'EntityGUI_1Sel_QTD.ui' ** -** Created: Fri Apr 30 11:23:36 2004 +** Created: Thu Aug 12 19:03:19 2004 ** by: The User Interface Compiler (uic) ** ** WARNING! All changes made in this file will be lost! @@ -26,7 +26,7 @@ EntityGUI_1Sel_QTD::EntityGUI_1Sel_QTD( QWidget* parent, const char* name, WFla { if ( !name ) setName( "EntityGUI_1Sel_QTD" ); - resize( 245, 110 ); + resize( 329, 112 ); setCaption( trUtf8( "EntityGUI_1Sel_QTD" ) ); EntityGUI_1Sel_QTDLayout = new QGridLayout( this, 1, 1, 0, 6, "EntityGUI_1Sel_QTDLayout"); @@ -38,23 +38,32 @@ EntityGUI_1Sel_QTD::EntityGUI_1Sel_QTD( QWidget* parent, const char* name, WFla GroupBox1Layout = new QGridLayout( GroupBox1->layout() ); GroupBox1Layout->setAlignment( Qt::AlignTop ); + Layout4 = new QGridLayout( 0, 1, 1, 0, 6, "Layout4"); + Layout3 = new QGridLayout( 0, 1, 1, 0, 6, "Layout3"); + QSpacerItem* spacer = new QSpacerItem( 0, 163, QSizePolicy::Minimum, QSizePolicy::Expanding ); + Layout3->addItem( spacer, 2, 0 ); + + buttonApply = new QPushButton( GroupBox1, "buttonApply" ); + buttonApply->setText( trUtf8( "Create" ) ); + + Layout3->addWidget( buttonApply, 0, 0 ); Layout2 = new QGridLayout( 0, 1, 1, 0, 6, "Layout2"); + buttonRedo = new QPushButton( GroupBox1, "buttonRedo" ); + buttonRedo->setText( trUtf8( "Redo" ) ); + + Layout2->addWidget( buttonRedo, 0, 1 ); + buttonUndo = new QPushButton( GroupBox1, "buttonUndo" ); buttonUndo->setText( trUtf8( "Undo" ) ); - Layout2->addWidget( buttonUndo, 1, 0 ); - - buttonApply = new QPushButton( GroupBox1, "buttonApply" ); - buttonApply->setText( trUtf8( "Create" ) ); + Layout2->addWidget( buttonUndo, 0, 0 ); - Layout2->addWidget( buttonApply, 0, 0 ); - QSpacerItem* spacer = new QSpacerItem( 0, 51, QSizePolicy::Minimum, QSizePolicy::Expanding ); - Layout2->addItem( spacer, 2, 0 ); + Layout3->addLayout( Layout2, 1, 0 ); - Layout3->addLayout( Layout2, 0, 1 ); + Layout4->addLayout( Layout3, 0, 1 ); Layout1 = new QGridLayout( 0, 1, 1, 0, 6, "Layout1"); @@ -73,13 +82,13 @@ EntityGUI_1Sel_QTD::EntityGUI_1Sel_QTD( QWidget* parent, const char* name, WFla Layout1->addWidget( PushButton1, 0, 1 ); LineEdit1 = new QLineEdit( GroupBox1, "LineEdit1" ); - LineEdit1->setFocusPolicy( QLineEdit::NoFocus ); + LineEdit1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, 0, 0, LineEdit1->sizePolicy().hasHeightForWidth() ) ); Layout1->addWidget( LineEdit1, 0, 2 ); - Layout3->addLayout( Layout1, 0, 0 ); + Layout4->addLayout( Layout1, 0, 0 ); - GroupBox1Layout->addLayout( Layout3, 0, 0 ); + GroupBox1Layout->addLayout( Layout4, 0, 0 ); EntityGUI_1Sel_QTDLayout->addWidget( GroupBox1, 0, 0 ); } diff --git a/src/EntityGUI/EntityGUI_1Sel_QTD.h b/src/EntityGUI/EntityGUI_1Sel_QTD.h index 915cda9c4..36e13768e 100644 --- a/src/EntityGUI/EntityGUI_1Sel_QTD.h +++ b/src/EntityGUI/EntityGUI_1Sel_QTD.h @@ -1,7 +1,7 @@ /**************************************************************************** ** Form interface generated from reading ui file 'EntityGUI_1Sel_QTD.ui' ** -** Created: Fri Apr 30 11:23:32 2004 +** Created: Fri Jul 30 16:06:00 2004 ** by: The User Interface Compiler (uic) ** ** WARNING! All changes made in this file will be lost! @@ -28,8 +28,9 @@ public: ~EntityGUI_1Sel_QTD(); QGroupBox* GroupBox1; - QPushButton* buttonUndo; QPushButton* buttonApply; + QPushButton* buttonRedo; + QPushButton* buttonUndo; QLabel* TextLabel1; QPushButton* PushButton1; QLineEdit* LineEdit1; @@ -38,6 +39,7 @@ public: protected: QGridLayout* EntityGUI_1Sel_QTDLayout; QGridLayout* GroupBox1Layout; + QGridLayout* Layout4; QGridLayout* Layout3; QGridLayout* Layout2; QGridLayout* Layout1; diff --git a/src/EntityGUI/EntityGUI_1Spin_QTD.cxx b/src/EntityGUI/EntityGUI_1Spin_QTD.cxx index 20f21d295..b96c0e18a 100644 --- a/src/EntityGUI/EntityGUI_1Spin_QTD.cxx +++ b/src/EntityGUI/EntityGUI_1Spin_QTD.cxx @@ -1,7 +1,7 @@ /**************************************************************************** ** Form implementation generated from reading ui file 'EntityGUI_1Spin_QTD.ui' ** -** Created: ven déc 12 11:17:10 2003 +** Created: Fri Jul 30 16:05:59 2004 ** by: The User Interface Compiler (uic) ** ** WARNING! All changes made in this file will be lost! @@ -26,7 +26,7 @@ EntityGUI_1Spin_QTD::EntityGUI_1Spin_QTD( QWidget* parent, const char* name, WF { if ( !name ) setName( "EntityGUI_1Spin_QTD" ); - resize( 154, 96 ); + resize( 255, 112 ); setCaption( trUtf8( "EntityGUI_1Spin_QTD" ) ); EntityGUI_1Spin_QTDLayout = new QGridLayout( this, 1, 1, 0, 6, "EntityGUI_1Spin_QTDLayout"); @@ -38,23 +38,7 @@ EntityGUI_1Spin_QTD::EntityGUI_1Spin_QTD( QWidget* parent, const char* name, WF GroupBox1Layout = new QGridLayout( GroupBox1->layout() ); GroupBox1Layout->setAlignment( Qt::AlignTop ); - Layout3 = new QGridLayout( 0, 1, 1, 0, 6, "Layout3"); - - Layout2 = new QGridLayout( 0, 1, 1, 0, 6, "Layout2"); - - buttonUndo = new QPushButton( GroupBox1, "buttonUndo" ); - buttonUndo->setText( trUtf8( "Undo" ) ); - - Layout2->addWidget( buttonUndo, 1, 0 ); - - buttonApply = new QPushButton( GroupBox1, "buttonApply" ); - buttonApply->setText( trUtf8( "Create" ) ); - - Layout2->addWidget( buttonApply, 0, 0 ); - QSpacerItem* spacer = new QSpacerItem( 0, 51, QSizePolicy::Minimum, QSizePolicy::Expanding ); - Layout2->addItem( spacer, 2, 0 ); - - Layout3->addLayout( Layout2, 0, 1 ); + Layout4 = new QGridLayout( 0, 1, 1, 0, 6, "Layout4"); Layout1 = new QGridLayout( 0, 1, 1, 0, 6, "Layout1"); @@ -68,12 +52,37 @@ EntityGUI_1Spin_QTD::EntityGUI_1Spin_QTD( QWidget* parent, const char* name, WF SpinBox1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, SpinBox1->sizePolicy().hasHeightForWidth() ) ); Layout1->addWidget( SpinBox1, 0, 1 ); - QSpacerItem* spacer_2 = new QSpacerItem( 0, 82, QSizePolicy::Minimum, QSizePolicy::Expanding ); - Layout1->addItem( spacer_2, 3, 1 ); + QSpacerItem* spacer = new QSpacerItem( 0, 82, QSizePolicy::Minimum, QSizePolicy::Expanding ); + Layout1->addItem( spacer, 3, 1 ); + + Layout4->addLayout( Layout1, 0, 0 ); + + Layout3 = new QGridLayout( 0, 1, 1, 0, 6, "Layout3"); + + Layout2 = new QGridLayout( 0, 1, 1, 0, 6, "Layout2"); + + buttonRedo = new QPushButton( GroupBox1, "buttonRedo" ); + buttonRedo->setText( trUtf8( "Redo" ) ); + + Layout2->addWidget( buttonRedo, 0, 1 ); + + buttonUndo = new QPushButton( GroupBox1, "buttonUndo" ); + buttonUndo->setText( trUtf8( "Undo" ) ); + + Layout2->addWidget( buttonUndo, 0, 0 ); + + Layout3->addLayout( Layout2, 1, 0 ); + + buttonApply = new QPushButton( GroupBox1, "buttonApply" ); + buttonApply->setText( trUtf8( "Create" ) ); + + Layout3->addWidget( buttonApply, 0, 0 ); + QSpacerItem* spacer_2 = new QSpacerItem( 0, 40, QSizePolicy::Minimum, QSizePolicy::Expanding ); + Layout3->addItem( spacer_2, 2, 0 ); - Layout3->addLayout( Layout1, 0, 0 ); + Layout4->addLayout( Layout3, 0, 1 ); - GroupBox1Layout->addLayout( Layout3, 0, 0 ); + GroupBox1Layout->addLayout( Layout4, 0, 0 ); EntityGUI_1Spin_QTDLayout->addWidget( GroupBox1, 0, 0 ); } diff --git a/src/EntityGUI/EntityGUI_1Spin_QTD.h b/src/EntityGUI/EntityGUI_1Spin_QTD.h index b44238263..9e5498776 100644 --- a/src/EntityGUI/EntityGUI_1Spin_QTD.h +++ b/src/EntityGUI/EntityGUI_1Spin_QTD.h @@ -1,7 +1,7 @@ /**************************************************************************** ** Form interface generated from reading ui file 'EntityGUI_1Spin_QTD.ui' ** -** Created: ven déc 12 11:17:10 2003 +** Created: Fri Jul 30 16:05:59 2004 ** by: The User Interface Compiler (uic) ** ** WARNING! All changes made in this file will be lost! @@ -28,18 +28,20 @@ public: ~EntityGUI_1Spin_QTD(); QGroupBox* GroupBox1; - QPushButton* buttonUndo; - QPushButton* buttonApply; QLabel* TextLabel1; QSpinBox* SpinBox1; + QPushButton* buttonRedo; + QPushButton* buttonUndo; + QPushButton* buttonApply; protected: QGridLayout* EntityGUI_1Spin_QTDLayout; QGridLayout* GroupBox1Layout; + QGridLayout* Layout4; + QGridLayout* Layout1; QGridLayout* Layout3; QGridLayout* Layout2; - QGridLayout* Layout1; }; #endif // ENTITYGUI_1SPIN_QTD_H diff --git a/src/EntityGUI/EntityGUI_2Spin_QTD.cxx b/src/EntityGUI/EntityGUI_2Spin_QTD.cxx index a01f2a783..a742db393 100644 --- a/src/EntityGUI/EntityGUI_2Spin_QTD.cxx +++ b/src/EntityGUI/EntityGUI_2Spin_QTD.cxx @@ -1,7 +1,7 @@ /**************************************************************************** ** Form implementation generated from reading ui file 'EntityGUI_2Spin_QTD.ui' ** -** Created: ven déc 12 11:17:11 2003 +** Created: Fri Jul 30 16:06:00 2004 ** by: The User Interface Compiler (uic) ** ** WARNING! All changes made in this file will be lost! @@ -26,7 +26,7 @@ EntityGUI_2Spin_QTD::EntityGUI_2Spin_QTD( QWidget* parent, const char* name, WF { if ( !name ) setName( "EntityGUI_2Spin_QTD" ); - resize( 154, 96 ); + resize( 255, 112 ); setCaption( trUtf8( "EntityGUI_2Spin_QTD" ) ); EntityGUI_2Spin_QTDLayout = new QGridLayout( this, 1, 1, 0, 6, "EntityGUI_2Spin_QTDLayout"); @@ -38,23 +38,7 @@ EntityGUI_2Spin_QTD::EntityGUI_2Spin_QTD( QWidget* parent, const char* name, WF GroupBox1Layout = new QGridLayout( GroupBox1->layout() ); GroupBox1Layout->setAlignment( Qt::AlignTop ); - Layout3 = new QGridLayout( 0, 1, 1, 0, 6, "Layout3"); - - Layout2 = new QGridLayout( 0, 1, 1, 0, 6, "Layout2"); - - buttonUndo = new QPushButton( GroupBox1, "buttonUndo" ); - buttonUndo->setText( trUtf8( "Undo" ) ); - - Layout2->addWidget( buttonUndo, 1, 0 ); - - buttonApply = new QPushButton( GroupBox1, "buttonApply" ); - buttonApply->setText( trUtf8( "Create" ) ); - - Layout2->addWidget( buttonApply, 0, 0 ); - QSpacerItem* spacer = new QSpacerItem( 0, 51, QSizePolicy::Minimum, QSizePolicy::Expanding ); - Layout2->addItem( spacer, 2, 0 ); - - Layout3->addLayout( Layout2, 0, 1 ); + Layout4 = new QGridLayout( 0, 1, 1, 0, 6, "Layout4"); Layout1 = new QGridLayout( 0, 1, 1, 0, 6, "Layout1"); @@ -79,12 +63,37 @@ EntityGUI_2Spin_QTD::EntityGUI_2Spin_QTD( QWidget* parent, const char* name, WF SpinBox2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, SpinBox2->sizePolicy().hasHeightForWidth() ) ); Layout1->addWidget( SpinBox2, 1, 1 ); - QSpacerItem* spacer_2 = new QSpacerItem( 0, 82, QSizePolicy::Minimum, QSizePolicy::Expanding ); - Layout1->addItem( spacer_2, 3, 1 ); + QSpacerItem* spacer = new QSpacerItem( 0, 82, QSizePolicy::Minimum, QSizePolicy::Expanding ); + Layout1->addItem( spacer, 3, 1 ); + + Layout4->addLayout( Layout1, 0, 0 ); + + Layout3 = new QGridLayout( 0, 1, 1, 0, 6, "Layout3"); + QSpacerItem* spacer_2 = new QSpacerItem( 0, 51, QSizePolicy::Minimum, QSizePolicy::Expanding ); + Layout3->addItem( spacer_2, 2, 0 ); + + Layout2 = new QGridLayout( 0, 1, 1, 0, 6, "Layout2"); + + buttonUndo = new QPushButton( GroupBox1, "buttonUndo" ); + buttonUndo->setText( trUtf8( "Undo" ) ); + + Layout2->addWidget( buttonUndo, 0, 0 ); + + buttonRedo = new QPushButton( GroupBox1, "buttonRedo" ); + buttonRedo->setText( trUtf8( "Redo" ) ); + + Layout2->addWidget( buttonRedo, 0, 1 ); + + Layout3->addLayout( Layout2, 1, 0 ); + + buttonApply = new QPushButton( GroupBox1, "buttonApply" ); + buttonApply->setText( trUtf8( "Create" ) ); + + Layout3->addWidget( buttonApply, 0, 0 ); - Layout3->addLayout( Layout1, 0, 0 ); + Layout4->addLayout( Layout3, 0, 1 ); - GroupBox1Layout->addLayout( Layout3, 0, 0 ); + GroupBox1Layout->addLayout( Layout4, 0, 0 ); EntityGUI_2Spin_QTDLayout->addWidget( GroupBox1, 0, 0 ); } diff --git a/src/EntityGUI/EntityGUI_2Spin_QTD.h b/src/EntityGUI/EntityGUI_2Spin_QTD.h index 4827aa86c..8c23b2326 100644 --- a/src/EntityGUI/EntityGUI_2Spin_QTD.h +++ b/src/EntityGUI/EntityGUI_2Spin_QTD.h @@ -1,7 +1,7 @@ /**************************************************************************** ** Form interface generated from reading ui file 'EntityGUI_2Spin_QTD.ui' ** -** Created: ven déc 12 11:17:10 2003 +** Created: Fri Jul 30 16:06:00 2004 ** by: The User Interface Compiler (uic) ** ** WARNING! All changes made in this file will be lost! @@ -28,20 +28,22 @@ public: ~EntityGUI_2Spin_QTD(); QGroupBox* GroupBox1; - QPushButton* buttonUndo; - QPushButton* buttonApply; QLabel* TextLabel2; QLabel* TextLabel1; QSpinBox* SpinBox1; QSpinBox* SpinBox2; + QPushButton* buttonUndo; + QPushButton* buttonRedo; + QPushButton* buttonApply; protected: QGridLayout* EntityGUI_2Spin_QTDLayout; QGridLayout* GroupBox1Layout; + QGridLayout* Layout4; + QGridLayout* Layout1; QGridLayout* Layout3; QGridLayout* Layout2; - QGridLayout* Layout1; }; #endif // ENTITYGUI_2SPIN_QTD_H diff --git a/src/EntityGUI/EntityGUI_3Spin_QTD.cxx b/src/EntityGUI/EntityGUI_3Spin_QTD.cxx index 8fa505304..9a2dd4795 100644 --- a/src/EntityGUI/EntityGUI_3Spin_QTD.cxx +++ b/src/EntityGUI/EntityGUI_3Spin_QTD.cxx @@ -1,7 +1,7 @@ /**************************************************************************** ** Form implementation generated from reading ui file 'EntityGUI_3Spin_QTD.ui' ** -** Created: ven déc 12 11:17:11 2003 +** Created: Fri Jul 30 16:06:00 2004 ** by: The User Interface Compiler (uic) ** ** WARNING! All changes made in this file will be lost! @@ -26,7 +26,7 @@ EntityGUI_3Spin_QTD::EntityGUI_3Spin_QTD( QWidget* parent, const char* name, WF { if ( !name ) setName( "EntityGUI_3Spin_QTD" ); - resize( 154, 120 ); + resize( 255, 125 ); setCaption( trUtf8( "EntityGUI_3Spin_QTD" ) ); EntityGUI_3Spin_QTDLayout = new QGridLayout( this, 1, 1, 0, 6, "EntityGUI_3Spin_QTDLayout"); @@ -38,23 +38,32 @@ EntityGUI_3Spin_QTD::EntityGUI_3Spin_QTD( QWidget* parent, const char* name, WF GroupBox1Layout = new QGridLayout( GroupBox1->layout() ); GroupBox1Layout->setAlignment( Qt::AlignTop ); + Layout4 = new QGridLayout( 0, 1, 1, 0, 6, "Layout4"); + Layout3 = new QGridLayout( 0, 1, 1, 0, 6, "Layout3"); + buttonApply = new QPushButton( GroupBox1, "buttonApply" ); + buttonApply->setText( trUtf8( "Create" ) ); + + Layout3->addWidget( buttonApply, 0, 0 ); + QSpacerItem* spacer = new QSpacerItem( 0, 121, QSizePolicy::Minimum, QSizePolicy::Expanding ); + Layout3->addItem( spacer, 2, 0 ); + Layout2 = new QGridLayout( 0, 1, 1, 0, 6, "Layout2"); buttonUndo = new QPushButton( GroupBox1, "buttonUndo" ); buttonUndo->setText( trUtf8( "Undo" ) ); - Layout2->addWidget( buttonUndo, 1, 0 ); + Layout2->addWidget( buttonUndo, 0, 0 ); - buttonApply = new QPushButton( GroupBox1, "buttonApply" ); - buttonApply->setText( trUtf8( "Create" ) ); + buttonRedo = new QPushButton( GroupBox1, "buttonRedo" ); + buttonRedo->setText( trUtf8( "Redo" ) ); + + Layout2->addWidget( buttonRedo, 0, 1 ); - Layout2->addWidget( buttonApply, 0, 0 ); - QSpacerItem* spacer = new QSpacerItem( 0, 51, QSizePolicy::Minimum, QSizePolicy::Expanding ); - Layout2->addItem( spacer, 2, 0 ); + Layout3->addLayout( Layout2, 1, 0 ); - Layout3->addLayout( Layout2, 0, 1 ); + Layout4->addLayout( Layout3, 0, 1 ); Layout1 = new QGridLayout( 0, 1, 1, 0, 6, "Layout1"); @@ -93,9 +102,9 @@ EntityGUI_3Spin_QTD::EntityGUI_3Spin_QTD( QWidget* parent, const char* name, WF Layout1->addWidget( SpinBox3, 2, 1 ); - Layout3->addLayout( Layout1, 0, 0 ); + Layout4->addLayout( Layout1, 0, 0 ); - GroupBox1Layout->addLayout( Layout3, 0, 0 ); + GroupBox1Layout->addLayout( Layout4, 0, 0 ); EntityGUI_3Spin_QTDLayout->addWidget( GroupBox1, 0, 0 ); } diff --git a/src/EntityGUI/EntityGUI_3Spin_QTD.h b/src/EntityGUI/EntityGUI_3Spin_QTD.h index 1efc3a5c1..314ca5796 100644 --- a/src/EntityGUI/EntityGUI_3Spin_QTD.h +++ b/src/EntityGUI/EntityGUI_3Spin_QTD.h @@ -1,7 +1,7 @@ /**************************************************************************** ** Form interface generated from reading ui file 'EntityGUI_3Spin_QTD.ui' ** -** Created: ven déc 12 11:17:11 2003 +** Created: Fri Jul 30 16:06:00 2004 ** by: The User Interface Compiler (uic) ** ** WARNING! All changes made in this file will be lost! @@ -28,8 +28,9 @@ public: ~EntityGUI_3Spin_QTD(); QGroupBox* GroupBox1; - QPushButton* buttonUndo; QPushButton* buttonApply; + QPushButton* buttonUndo; + QPushButton* buttonRedo; QLabel* TextLabel2; QLabel* TextLabel1; QSpinBox* SpinBox1; @@ -41,6 +42,7 @@ public: protected: QGridLayout* EntityGUI_3Spin_QTDLayout; QGridLayout* GroupBox1Layout; + QGridLayout* Layout4; QGridLayout* Layout3; QGridLayout* Layout2; QGridLayout* Layout1; diff --git a/src/EntityGUI/EntityGUI_4Spin_QTD.cxx b/src/EntityGUI/EntityGUI_4Spin_QTD.cxx index 428da7dfb..d449befc7 100644 --- a/src/EntityGUI/EntityGUI_4Spin_QTD.cxx +++ b/src/EntityGUI/EntityGUI_4Spin_QTD.cxx @@ -1,7 +1,7 @@ /**************************************************************************** ** Form implementation generated from reading ui file 'EntityGUI_4Spin_QTD.ui' ** -** Created: Fri Apr 30 10:56:21 2004 +** Created: Fri Jul 30 16:06:00 2004 ** by: The User Interface Compiler (uic) ** ** WARNING! All changes made in this file will be lost! @@ -26,7 +26,7 @@ EntityGUI_4Spin_QTD::EntityGUI_4Spin_QTD( QWidget* parent, const char* name, WF { if ( !name ) setName( "EntityGUI_4Spin_QTD" ); - resize( 176, 154 ); + resize( 255, 154 ); setCaption( trUtf8( "EntityGUI_4Spin_QTD" ) ); EntityGUI_4Spin_QTDLayout = new QGridLayout( this, 1, 1, 0, 6, "EntityGUI_4Spin_QTDLayout"); @@ -38,23 +38,32 @@ EntityGUI_4Spin_QTD::EntityGUI_4Spin_QTD( QWidget* parent, const char* name, WF GroupBox1Layout = new QGridLayout( GroupBox1->layout() ); GroupBox1Layout->setAlignment( Qt::AlignTop ); + Layout4 = new QGridLayout( 0, 1, 1, 0, 6, "Layout4"); + Layout3 = new QGridLayout( 0, 1, 1, 0, 6, "Layout3"); Layout2 = new QGridLayout( 0, 1, 1, 0, 6, "Layout2"); + buttonRedo = new QPushButton( GroupBox1, "buttonRedo" ); + buttonRedo->setText( trUtf8( "Redo" ) ); + + Layout2->addWidget( buttonRedo, 0, 1 ); + buttonUndo = new QPushButton( GroupBox1, "buttonUndo" ); buttonUndo->setText( trUtf8( "Undo" ) ); - Layout2->addWidget( buttonUndo, 1, 0 ); + Layout2->addWidget( buttonUndo, 0, 0 ); + + Layout3->addLayout( Layout2, 1, 0 ); + QSpacerItem* spacer = new QSpacerItem( 0, 45, QSizePolicy::Minimum, QSizePolicy::Expanding ); + Layout3->addItem( spacer, 2, 0 ); buttonApply = new QPushButton( GroupBox1, "buttonApply" ); buttonApply->setText( trUtf8( "Create" ) ); - Layout2->addWidget( buttonApply, 0, 0 ); - QSpacerItem* spacer = new QSpacerItem( 0, 51, QSizePolicy::Minimum, QSizePolicy::Expanding ); - Layout2->addItem( spacer, 2, 0 ); + Layout3->addWidget( buttonApply, 0, 0 ); - Layout3->addLayout( Layout2, 0, 1 ); + Layout4->addLayout( Layout3, 0, 1 ); Layout1 = new QGridLayout( 0, 1, 1, 0, 6, "Layout1"); @@ -104,18 +113,11 @@ EntityGUI_4Spin_QTD::EntityGUI_4Spin_QTD( QWidget* parent, const char* name, WF Layout1->addWidget( TextLabel4, 3, 0 ); - Layout3->addLayout( Layout1, 0, 0 ); + Layout4->addLayout( Layout1, 0, 0 ); - GroupBox1Layout->addLayout( Layout3, 0, 0 ); + GroupBox1Layout->addLayout( Layout4, 0, 0 ); EntityGUI_4Spin_QTDLayout->addWidget( GroupBox1, 0, 0 ); - - // tab order - setTabOrder( buttonUndo, buttonApply ); - setTabOrder( buttonApply, SpinBox1 ); - setTabOrder( SpinBox1, SpinBox2 ); - setTabOrder( SpinBox2, SpinBox3 ); - setTabOrder( SpinBox3, SpinBox4 ); } /* diff --git a/src/EntityGUI/EntityGUI_4Spin_QTD.h b/src/EntityGUI/EntityGUI_4Spin_QTD.h index 4aa37176d..13d983fd4 100644 --- a/src/EntityGUI/EntityGUI_4Spin_QTD.h +++ b/src/EntityGUI/EntityGUI_4Spin_QTD.h @@ -1,7 +1,7 @@ /**************************************************************************** ** Form interface generated from reading ui file 'EntityGUI_4Spin_QTD.ui' ** -** Created: Fri Apr 30 10:56:17 2004 +** Created: Fri Jul 30 16:06:00 2004 ** by: The User Interface Compiler (uic) ** ** WARNING! All changes made in this file will be lost! @@ -28,6 +28,7 @@ public: ~EntityGUI_4Spin_QTD(); QGroupBox* GroupBox1; + QPushButton* buttonRedo; QPushButton* buttonUndo; QPushButton* buttonApply; QSpinBox* SpinBox3; @@ -43,6 +44,7 @@ public: protected: QGridLayout* EntityGUI_4Spin_QTDLayout; QGridLayout* GroupBox1Layout; + QGridLayout* Layout4; QGridLayout* Layout3; QGridLayout* Layout2; QGridLayout* Layout1; diff --git a/src/EntityGUI/EntityGUI_SketcherDlg.cxx b/src/EntityGUI/EntityGUI_SketcherDlg.cxx index d91c24544..bd150b1ad 100644 --- a/src/EntityGUI/EntityGUI_SketcherDlg.cxx +++ b/src/EntityGUI/EntityGUI_SketcherDlg.cxx @@ -26,16 +26,28 @@ // Module : GEOM // $Header: -using namespace std; #include "EntityGUI_SketcherDlg.h" #include "Sketcher_Profile.hxx" -#include "utilities.h" +#include "GEOM_Displayer.h" +#include "QAD_Config.h" +#include "QAD_Desktop.h" +#include "QAD_MessageBox.h" + +#include #include #include +#include #include +#include +#include +#include -#include +#include "GEOMImpl_Types.hxx" + +#include "utilities.h" + +using namespace std; //================================================================================= // class : EntityGUI_SketcherDlg() @@ -44,21 +56,25 @@ using namespace std; // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -EntityGUI_SketcherDlg::EntityGUI_SketcherDlg(QWidget* parent, const char* name, EntityGUI* theEntityGUI, SALOME_Selection* Sel, bool modal, WFlags fl) - :EntityGUI_Skeleton_QTD(parent, name, modal, fl) +EntityGUI_SketcherDlg::EntityGUI_SketcherDlg(QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl) +:EntityGUI_Skeleton_QTD(parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose), GEOMBase_Helper(), myIsAllAdded( false ) { - if (!name) - setName("EntityGUI_SketcherDlg"); + mySelection = Sel; + GeometryGUI::GetGeomGUI()->SetActiveDialogBox(this); + + if ( !name ) setName("EntityGUI_SketcherDlg"); buttonCancel->setText(tr("GEOM_BUT_CANCEL")); buttonEnd->setText(tr("GEOM_BUT_END_SKETCH")); buttonClose->setText(tr("GEOM_BUT_CLOSE_SKETCH")); - GroupVal->close(TRUE); + + GroupVal->close(TRUE); GroupDest2->close(TRUE); GroupDest3->close(TRUE); - resize(0, 0); QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_UNDO"))); + QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_REDO"))); setCaption(tr("GEOM_SKETCHER_TITLE")); @@ -93,29 +109,35 @@ EntityGUI_SketcherDlg::EntityGUI_SketcherDlg(QWidget* parent, const char* name, Group1Sel = new EntityGUI_1Sel_QTD(this, "Group1Sel"); Group1Sel->TextLabel1->setText(tr("GEOM_SKETCHER_POINT2")); Group1Sel->GroupBox1->setTitle(tr("GEOM_SKETCHER_VALUES")); - Group1Sel->buttonUndo->setText(tr("GEOM_SKETCHER_UNDO")); Group1Sel->buttonApply->setText(tr("GEOM_SKETCHER_APPLY")); Group1Sel->PushButton1->setPixmap(image0); + Group1Sel->buttonUndo->setPixmap(image1); + Group1Sel->buttonRedo->setPixmap(image2); + Group1Sel->LineEdit1->setReadOnly( true ); Group1Spin = new EntityGUI_1Spin(this, "Group1Spin"); Group1Spin->GroupBox1->setTitle(tr("GEOM_SKETCHER_VALUES")); - Group1Spin->buttonUndo->setText(tr("GEOM_SKETCHER_UNDO")); Group1Spin->buttonApply->setText(tr("GEOM_SKETCHER_APPLY")); + Group1Spin->buttonUndo->setPixmap(image1); + Group1Spin->buttonRedo->setPixmap(image2); Group2Spin = new EntityGUI_2Spin(this, "Group2Spin"); Group2Spin->GroupBox1->setTitle(tr("GEOM_SKETCHER_VALUES")); - Group2Spin->buttonUndo->setText(tr("GEOM_SKETCHER_UNDO")); Group2Spin->buttonApply->setText(tr("GEOM_SKETCHER_APPLY")); + Group2Spin->buttonUndo->setPixmap(image1); + Group2Spin->buttonRedo->setPixmap(image2); Group3Spin = new EntityGUI_3Spin(this, "Group3Spin"); Group3Spin->GroupBox1->setTitle(tr("GEOM_SKETCHER_VALUES")); - Group3Spin->buttonUndo->setText(tr("GEOM_SKETCHER_UNDO")); Group3Spin->buttonApply->setText(tr("GEOM_SKETCHER_APPLY")); + Group3Spin->buttonUndo->setPixmap(image1); + Group3Spin->buttonRedo->setPixmap(image2); Group4Spin = new EntityGUI_4Spin(this, "Group4Spin"); Group4Spin->GroupBox1->setTitle(tr("GEOM_SKETCHER_VALUES")); - Group4Spin->buttonUndo->setText(tr("GEOM_SKETCHER_UNDO")); Group4Spin->buttonApply->setText(tr("GEOM_SKETCHER_APPLY")); + Group4Spin->buttonUndo->setPixmap(image1); + Group4Spin->buttonRedo->setPixmap(image2); Layout5->addMultiCellWidget(GroupPt, 1, 1, 0, 1); Layout5->addWidget(GroupD1, 1, 0); @@ -128,38 +150,26 @@ EntityGUI_SketcherDlg::EntityGUI_SketcherDlg(QWidget* parent, const char* name, Layout1->addWidget(Group4Spin, 2, 0); /***************************************************************/ - mySelection = Sel; - mySimulationTopoDs1.Nullify(); - mySimulationTopoDs2.Nullify(); - myEntityGUI = theEntityGUI; - - /* Get setting of step value from file configuration */ - QString St = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep"); - step = St.toDouble(); - - myGeomBase = new GEOMBase(); - myGeomGUI = GEOMContext::GetGeomGUI(); - myGeomGUI->SetActiveDialogBox((QDialog*)this); - myGeom = myGeomGUI->myComponentGeom; - - myVertexFilter = new GEOM_ShapeTypeFilter(TopAbs_VERTEX, myGeom); - mySelection->AddFilter(myVertexFilter); - /* signals and slots connections */ connect(buttonEnd, SIGNAL(clicked()), this, SLOT(ClickOnEnd())); - connect(buttonClose, SIGNAL(clicked()), this, SLOT(ClickOnClose())); + connect(buttonClose, SIGNAL(clicked()), this, SLOT(ClickOnEnd())); connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel())); connect(Group1Sel->buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); connect(Group1Sel->buttonUndo, SIGNAL(clicked()), this, SLOT(ClickOnUndo())); + connect(Group1Sel->buttonRedo, SIGNAL(clicked()), this, SLOT(ClickOnRedo())); connect(Group1Spin->buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); connect(Group1Spin->buttonUndo, SIGNAL(clicked()), this, SLOT(ClickOnUndo())); + connect(Group1Spin->buttonRedo, SIGNAL(clicked()), this, SLOT(ClickOnRedo())); connect(Group2Spin->buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); connect(Group2Spin->buttonUndo, SIGNAL(clicked()), this, SLOT(ClickOnUndo())); + connect(Group2Spin->buttonRedo, SIGNAL(clicked()), this, SLOT(ClickOnRedo())); connect(Group3Spin->buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); connect(Group3Spin->buttonUndo, SIGNAL(clicked()), this, SLOT(ClickOnUndo())); + connect(Group3Spin->buttonRedo, SIGNAL(clicked()), this, SLOT(ClickOnRedo())); connect(Group4Spin->buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); connect(Group4Spin->buttonUndo, SIGNAL(clicked()), this, SLOT(ClickOnUndo())); + connect(Group4Spin->buttonRedo, SIGNAL(clicked()), this, SLOT(ClickOnRedo())); connect(GroupConstructors, SIGNAL(clicked(int)), this, SLOT(TypeClicked(int))); connect(GroupDest1, SIGNAL(clicked(int)), this, SLOT(DestClicked(int))); @@ -181,27 +191,21 @@ EntityGUI_SketcherDlg::EntityGUI_SketcherDlg(QWidget* parent, const char* name, connect(Group4Spin->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); connect(Group4Spin->SpinBox_DS, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group1Spin->SpinBox_DX, SLOT(SetStep(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group2Spin->SpinBox_DX, SLOT(SetStep(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group2Spin->SpinBox_DY, SLOT(SetStep(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group3Spin->SpinBox_DX, SLOT(SetStep(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group3Spin->SpinBox_DY, SLOT(SetStep(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group3Spin->SpinBox_DZ, SLOT(SetStep(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group4Spin->SpinBox_DX, SLOT(SetStep(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group4Spin->SpinBox_DY, SLOT(SetStep(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group4Spin->SpinBox_DZ, SLOT(SetStep(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group4Spin->SpinBox_DS, SLOT(SetStep(double))); - - connect(myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog())); - connect(myGeomGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel())); - - /* Move widget on the botton right corner of main widget */ -// int x, y; -// myGeomBase->DefineDlgPosition( this, x, y ); - - myEntityGUI = theEntityGUI; - this->Init(); - this->show(); + connect(GeometryGUI::GetGeomGUI(), SIGNAL(SignalDefaultStepValueChanged(double)), Group1Spin->SpinBox_DX, SLOT(SetStep(double))); + connect(GeometryGUI::GetGeomGUI(), SIGNAL(SignalDefaultStepValueChanged(double)), Group2Spin->SpinBox_DX, SLOT(SetStep(double))); + connect(GeometryGUI::GetGeomGUI(), SIGNAL(SignalDefaultStepValueChanged(double)), Group2Spin->SpinBox_DY, SLOT(SetStep(double))); + connect(GeometryGUI::GetGeomGUI(), SIGNAL(SignalDefaultStepValueChanged(double)), Group3Spin->SpinBox_DX, SLOT(SetStep(double))); + connect(GeometryGUI::GetGeomGUI(), SIGNAL(SignalDefaultStepValueChanged(double)), Group3Spin->SpinBox_DY, SLOT(SetStep(double))); + connect(GeometryGUI::GetGeomGUI(), SIGNAL(SignalDefaultStepValueChanged(double)), Group3Spin->SpinBox_DZ, SLOT(SetStep(double))); + connect(GeometryGUI::GetGeomGUI(), SIGNAL(SignalDefaultStepValueChanged(double)), Group4Spin->SpinBox_DX, SLOT(SetStep(double))); + connect(GeometryGUI::GetGeomGUI(), SIGNAL(SignalDefaultStepValueChanged(double)), Group4Spin->SpinBox_DY, SLOT(SetStep(double))); + connect(GeometryGUI::GetGeomGUI(), SIGNAL(SignalDefaultStepValueChanged(double)), Group4Spin->SpinBox_DZ, SLOT(SetStep(double))); + connect(GeometryGUI::GetGeomGUI(), SIGNAL(SignalDefaultStepValueChanged(double)), Group4Spin->SpinBox_DS, SLOT(SetStep(double))); + + connect(GeometryGUI::GetGeomGUI(), SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog())); + connect(GeometryGUI::GetGeomGUI(), SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel())); + + Init(); } @@ -211,8 +215,7 @@ EntityGUI_SketcherDlg::EntityGUI_SketcherDlg(QWidget* parent, const char* name, //================================================================================= EntityGUI_SketcherDlg::~EntityGUI_SketcherDlg() { - // no need to delete child widgets, Qt does it all for us - this->destroy(TRUE, TRUE); + GeometryGUI::GetGeomGUI()->SetActiveDialogBox( 0 ); } @@ -224,66 +227,56 @@ void EntityGUI_SketcherDlg::Init() { /* init variables */ myEditCurrentArgument = Group1Sel->LineEdit1; + myCommand.append( "Sketcher" ); + myUndoCommand.append( "Sketcher" ); - /* min, max, step and decimals for spin boxes */ - Group1Spin->SpinBox_DX->RangeStepAndValidator(-999.999, 999.999, step, 3); - Group2Spin->SpinBox_DX->RangeStepAndValidator(-999.999, 999.999, step, 3); - Group2Spin->SpinBox_DY->RangeStepAndValidator(-999.999, 999.999, step, 3); - Group3Spin->SpinBox_DX->RangeStepAndValidator(-999.999, 999.999, step, 3); - Group3Spin->SpinBox_DY->RangeStepAndValidator(-999.999, 999.999, step, 3); - Group3Spin->SpinBox_DZ->RangeStepAndValidator(-999.999, 999.999, step, 3); - Group4Spin->SpinBox_DX->RangeStepAndValidator(-999.999, 999.999, 0.1, 3); - Group4Spin->SpinBox_DY->RangeStepAndValidator(-999.999, 999.999, 0.1, 3); - Group4Spin->SpinBox_DZ->RangeStepAndValidator(-999.999, 999.999, step, 3); - Group4Spin->SpinBox_DS->RangeStepAndValidator(-999.999, 999.999, 5., 3); - - Group1Spin->SpinBox_DX->SetValue(0.0); - Group2Spin->SpinBox_DX->SetValue(0.0); - Group2Spin->SpinBox_DY->SetValue(0.0); - Group3Spin->SpinBox_DX->SetValue(0.0); - Group3Spin->SpinBox_DY->SetValue(0.0); - Group3Spin->SpinBox_DZ->SetValue(0.0); - Group4Spin->SpinBox_DX->SetValue(0.0); - Group4Spin->SpinBox_DY->SetValue(0.0); - Group4Spin->SpinBox_DZ->SetValue(0.0); - Group4Spin->SpinBox_DS->SetValue(0.0); - - /* displays Dialog */ - Group1Sel->buttonUndo->setEnabled(false); - Group1Spin->buttonUndo->setEnabled(false); - Group2Spin->buttonUndo->setEnabled(false); - Group3Spin->buttonUndo->setEnabled(false); - Group4Spin->buttonUndo->setEnabled(false); - - RadioButton1->setChecked(true); + mySketchState = FIRST_POINT; + globalSelection( GEOM_POINT ); - myLastOp = 0; myLastX1 = 0.0; myLastY1 = 0.0; myLastX2 = 0.0; myLastY2 = 0.0; - mySketchState = FIRST_POINT; - this->TypeClicked(0); + /* Get setting of step value from file configuration */ + QString St = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep"); + double step = St.toDouble(); + + /* min, max, step and decimals for spin boxes */ + Group1Spin->SpinBox_DX->RangeStepAndValidator(-999999.999, 999999.999, step, 3); + Group2Spin->SpinBox_DX->RangeStepAndValidator(-999999.999, 999999.999, step, 3); + Group2Spin->SpinBox_DY->RangeStepAndValidator(-999999.999, 999999.999, step, 3); + Group3Spin->SpinBox_DX->RangeStepAndValidator(-999999.999, 999999.999, step, 3); + Group3Spin->SpinBox_DY->RangeStepAndValidator(-999999.999, 999999.999, step, 3); + Group3Spin->SpinBox_DZ->RangeStepAndValidator(-999999.999, 999999.999, step, 3); + Group4Spin->SpinBox_DX->RangeStepAndValidator(-999999.999, 999999.999, 0.1, 3); + Group4Spin->SpinBox_DY->RangeStepAndValidator(-999999.999, 999999.999, 0.1, 3); + Group4Spin->SpinBox_DZ->RangeStepAndValidator(-999999.999, 999999.999, step, 3); + Group4Spin->SpinBox_DS->RangeStepAndValidator(-999999.999, 999999.999, 5., 3); + + /* displays Dialog */ + GroupConstructors->setEnabled(false); + GroupDest1->setEnabled(false); + setEnabledUndo(false); + setEnabledRedo(false); + + RadioButton1->setChecked(true); - return; + resize( 0, 0 ); + TypeClicked(0); + + GEOMBase_Helper::displayPreview(); } //================================================================================= // function : InitClick() -// purpose : +// purpose : //================================================================================= void EntityGUI_SketcherDlg::InitClick() { disconnect(mySelection, 0, this, 0); - Group2Spin->SpinBox_DX->RangeStepAndValidator(-999.999, 999.999, step, 3); - Group2Spin->SpinBox_DY->RangeStepAndValidator(-999.999, 999.999, step, 3); - Group3Spin->SpinBox_DX->RangeStepAndValidator(-999.999, 999.999, step, 3); - Group3Spin->SpinBox_DY->RangeStepAndValidator(-999.999, 999.999, step, 3); - Group3Spin->SpinBox_DZ->RangeStepAndValidator(-999.999, 999.999, step, 3); - Group1Sel->hide(); Group1Spin->hide(); Group2Spin->hide(); @@ -291,8 +284,6 @@ void EntityGUI_SketcherDlg::InitClick() Group4Spin->hide(); resize(0, 0); - - return; } @@ -303,19 +294,20 @@ void EntityGUI_SketcherDlg::InitClick() void EntityGUI_SketcherDlg::TypeClicked(int constructorId) { myConstructorId = constructorId; - if(myConstructorId == 0) { // SEGMENT + if ( myConstructorId == 0 ) // SEGMENT + { GroupD2->setEnabled(true); RB_Dest1->setEnabled(true); RB_Dest1->setChecked(true); - this->DestClicked(1); + DestClicked(1); } - else if(myConstructorId == 1) { // ARC + else if ( myConstructorId == 1 ) // ARC + { GroupD2->setEnabled(false); RB_Dest1->setEnabled(false); RB_Dest2->setChecked(true); - this->DestClicked(0); + DestClicked(0); } - return; } @@ -323,24 +315,25 @@ void EntityGUI_SketcherDlg::TypeClicked(int constructorId) // function : DestClicked() // purpose : Radio button management //================================================================================= -void EntityGUI_SketcherDlg::DestClicked(int constructorId) +void EntityGUI_SketcherDlg::DestClicked( int constructorId ) { GroupPt->hide(); GroupD1->hide(); GroupD2->hide(); - if(constructorId == 1) { // Point + if ( constructorId == 1 ) + { // Point GroupPt->RB_Point1->setChecked(true); GroupPt->show(); - this->PointClicked(1); // XY + PointClicked(1); // XY } - else if(constructorId == 0) { // Direction + else if ( constructorId == 0 ) + { // Direction GroupD1->RB_Dir11->setChecked(true); GroupD1->show(); GroupD2->show(); - this->Dir1Clicked(2); // Angle + Dir1Clicked(2); // Angle } - return; } @@ -350,11 +343,15 @@ void EntityGUI_SketcherDlg::DestClicked(int constructorId) //================================================================================= void EntityGUI_SketcherDlg::PointClicked(int constructorId) { - this->InitClick(); + InitClick(); - if(myConstructorId == 0) { // SEGMENT - if(constructorId == 1) { // XY + if ( myConstructorId == 0 ) + { // SEGMENT + if ( constructorId == 1 ) + { // XY mySketchType = PT_ABS; + Group2Spin->SpinBox_DX->RangeStepAndValidator(-999999.999, 999999.999, 100., 3); + Group2Spin->SpinBox_DY->RangeStepAndValidator(-999999.999, 999999.999, 100., 3); Group2Spin->TextLabel1->setText(tr("GEOM_SKETCHER_X2")); Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_Y2")); myX = 0.0; @@ -363,10 +360,14 @@ void EntityGUI_SketcherDlg::PointClicked(int constructorId) Group2Spin->SpinBox_DY->SetValue(myY); Group2Spin->show(); Group2Spin->buttonApply->setFocus(); - this->MakeSimulationAndDisplay(); + + GEOMBase_Helper::displayPreview(); } - else if(constructorId == 0) { // DXDY + else if ( constructorId == 0 ) + { // DXDY mySketchType = PT_RELATIVE; + Group2Spin->SpinBox_DX->RangeStepAndValidator(-999999.999, 999999.999, 100., 3); + Group2Spin->SpinBox_DY->RangeStepAndValidator(-999999.999, 999999.999, 100., 3); Group2Spin->TextLabel1->setText(tr("GEOM_SKETCHER_DX2")); Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_DY2")); myDX = 0.0; @@ -375,19 +376,19 @@ void EntityGUI_SketcherDlg::PointClicked(int constructorId) Group2Spin->SpinBox_DY->SetValue(myDY); Group2Spin->show(); Group2Spin->buttonApply->setFocus(); - this->MakeSimulationAndDisplay(); + + GEOMBase_Helper::displayPreview(); } - else if(constructorId == 2) { // Selection + else if ( constructorId == 2 ) + { // Selection mySketchType = PT_SEL; myEditCurrentArgument = Group1Sel->LineEdit1; connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); Group1Sel->show(); Group1Sel->buttonApply->setFocus(); - this->SelectionIntoArgument(); + SelectionIntoArgument(); } } - - return; } @@ -399,8 +400,7 @@ void EntityGUI_SketcherDlg::Dir1Clicked(int constructorId) { myConstructorDirId = constructorId; GroupD2->RB_Dir21->setChecked(true); - this->Dir2Clicked(2); - return; + Dir2Clicked(2); } @@ -410,79 +410,95 @@ void EntityGUI_SketcherDlg::Dir1Clicked(int constructorId) //================================================================================= void EntityGUI_SketcherDlg::Dir2Clicked(int constructorId) { - this->InitClick(); + InitClick(); myAngle = 0.0; - if(myConstructorId == 0) { // SEGMENT + if ( myConstructorId == 0 ) + { // SEGMENT myX = 0.0; myY = 0.0; myLength = 100.0; - if(myConstructorDirId == 2) { // Angle - Group2Spin->SpinBox_DX->RangeStepAndValidator(-999.999, 999.999, 5., 3); + if ( myConstructorDirId == 2 ) + { // Angle + Group2Spin->SpinBox_DX->RangeStepAndValidator(-999999.999, 999999.999, 5., 3); + Group2Spin->SpinBox_DY->RangeStepAndValidator(-999999.999, 999999.999, 100., 3); Group2Spin->TextLabel1->setText(tr("GEOM_SKETCHER_ANGLE2")); Group2Spin->SpinBox_DX->SetValue(myAngle); Group2Spin->buttonApply->setFocus(); Group2Spin->show(); - if(constructorId == 2) { // Length - mySketchType = DIR_ANGLE_LENGTH; - Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_LENGTH2")); - Group2Spin->SpinBox_DY->SetValue(myLength); + if ( constructorId == 2 ) + { // Length + mySketchType = DIR_ANGLE_LENGTH; + Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_LENGTH2")); + Group2Spin->SpinBox_DY->SetValue(myLength); } - else if(constructorId == 0) { // X - mySketchType = DIR_ANGLE_X; - Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_X3")); - Group2Spin->SpinBox_DY->SetValue(myX); + else if ( constructorId == 0 ) + { // X + mySketchType = DIR_ANGLE_X; + Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_X3")); + Group2Spin->SpinBox_DY->SetValue(myX); } - else if(constructorId == 1) { // Y - mySketchType = DIR_ANGLE_Y; - Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_Y3")); - Group2Spin->SpinBox_DY->SetValue(myY); + else if ( constructorId == 1 ) + { // Y + mySketchType = DIR_ANGLE_Y; + Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_Y3")); + Group2Spin->SpinBox_DY->SetValue(myY); } - } - else if(myConstructorDirId == 0) { // Perpendicular + } + else if ( myConstructorDirId == 0 ) + { // Perpendicular Group1Spin->show(); Group1Spin->buttonApply->setFocus(); - if(constructorId == 2) { // Length - mySketchType = DIR_PER_LENGTH; - Group1Spin->TextLabel1->setText(tr("GEOM_SKETCHER_LENGTH2")); - Group1Spin->SpinBox_DX->SetValue(myLength); + if ( constructorId == 2 ) + { // Length + mySketchType = DIR_PER_LENGTH; + Group1Spin->TextLabel1->setText(tr("GEOM_SKETCHER_LENGTH2")); + Group1Spin->SpinBox_DX->SetValue(myLength); } - else if(constructorId == 0) { // X - mySketchType = DIR_PER_X; - Group1Spin->TextLabel1->setText(tr("GEOM_SKETCHER_X3")); - Group1Spin->SpinBox_DX->SetValue(myX); + else if ( constructorId == 0 ) + { // X + mySketchType = DIR_PER_X; + Group1Spin->TextLabel1->setText(tr("GEOM_SKETCHER_X3")); + Group1Spin->SpinBox_DX->SetValue(myX); } - else if(constructorId == 1) { // Y - mySketchType = DIR_PER_Y; - Group1Spin->TextLabel1->setText(tr("GEOM_SKETCHER_Y3")); - Group1Spin->SpinBox_DX->SetValue(myY); + else if ( constructorId == 1 ) + { // Y + mySketchType = DIR_PER_Y; + Group1Spin->TextLabel1->setText(tr("GEOM_SKETCHER_Y3")); + Group1Spin->SpinBox_DX->SetValue(myY); } } - else if(myConstructorDirId == 1) { // Tangent + else if ( myConstructorDirId == 1 ) + { // Tangent Group1Spin->show(); Group1Spin->buttonApply->setFocus(); - if(constructorId == 2) { // Length - mySketchType = DIR_TAN_LENGTH; - Group1Spin->TextLabel1->setText(tr("GEOM_SKETCHER_LENGTH2")); - Group1Spin->SpinBox_DX->SetValue(myLength); + if ( constructorId == 2 ) + { // Length + mySketchType = DIR_TAN_LENGTH; + Group1Spin->TextLabel1->setText(tr("GEOM_SKETCHER_LENGTH2")); + Group1Spin->SpinBox_DX->SetValue(myLength); } - else if(constructorId == 0) { // X - mySketchType = DIR_TAN_X; - Group1Spin->TextLabel1->setText(tr("GEOM_SKETCHER_X3")); - Group1Spin->SpinBox_DX->SetValue(myX); + else if ( constructorId == 0 ) + { // X + mySketchType = DIR_TAN_X; + Group1Spin->TextLabel1->setText(tr("GEOM_SKETCHER_X3")); + Group1Spin->SpinBox_DX->SetValue(myX); } - else if(constructorId == 1) { // Y - mySketchType = DIR_TAN_Y; - Group1Spin->TextLabel1->setText(tr("GEOM_SKETCHER_Y3")); - Group1Spin->SpinBox_DX->SetValue(myY); + else if ( constructorId == 1 ) + { // Y + mySketchType = DIR_TAN_Y; + Group1Spin->TextLabel1->setText(tr("GEOM_SKETCHER_Y3")); + Group1Spin->SpinBox_DX->SetValue(myY); } } - else if(myConstructorDirId == 3) { // DXDY - Group3Spin->SpinBox_DX->RangeStepAndValidator(-999.999, 999.999, 0.1, 3); - Group3Spin->SpinBox_DY->RangeStepAndValidator(-999.999, 999.999, 0.1, 3); + else if ( myConstructorDirId == 3 ) + { // DXDY + Group3Spin->SpinBox_DX->RangeStepAndValidator(-999999.999, 999999.999, 0.1, 3); + Group3Spin->SpinBox_DY->RangeStepAndValidator(-999999.999, 999999.999, 0.1, 3); + Group3Spin->SpinBox_DZ->RangeStepAndValidator(-999999.999, 999999.999, 100., 3); Group3Spin->TextLabel1->setText(tr("GEOM_SKETCHER_VX2")); Group3Spin->TextLabel2->setText(tr("GEOM_SKETCHER_VY2")); myDX = 0.0; @@ -492,92 +508,106 @@ void EntityGUI_SketcherDlg::Dir2Clicked(int constructorId) Group3Spin->show(); Group3Spin->buttonApply->setFocus(); - if(constructorId == 2) { // Length - mySketchType = DIR_DXDY_LENGTH; - Group3Spin->TextLabel3->setText(tr("GEOM_SKETCHER_LENGTH2")); - Group3Spin->SpinBox_DZ->SetValue(myLength); + if ( constructorId == 2 ) + { // Length + mySketchType = DIR_DXDY_LENGTH; + Group3Spin->TextLabel3->setText(tr("GEOM_SKETCHER_LENGTH2")); + Group3Spin->SpinBox_DZ->SetValue(myLength); } - else if(constructorId == 0) { // X - mySketchType = DIR_DXDY_X; - Group3Spin->TextLabel3->setText(tr("GEOM_SKETCHER_X3")); - Group3Spin->SpinBox_DZ->SetValue(myX); + else if ( constructorId == 0 ) + { // X + mySketchType = DIR_DXDY_X; + Group3Spin->TextLabel3->setText(tr("GEOM_SKETCHER_X3")); + Group3Spin->SpinBox_DZ->SetValue(myX); } - else if(constructorId == 1) { // Y - mySketchType = DIR_DXDY_Y; - Group3Spin->TextLabel3->setText(tr("GEOM_SKETCHER_Y3")); - Group3Spin->SpinBox_DZ->SetValue(myY); + else if ( constructorId == 1 ) + { // Y + mySketchType = DIR_DXDY_Y; + Group3Spin->TextLabel3->setText(tr("GEOM_SKETCHER_Y3")); + Group3Spin->SpinBox_DZ->SetValue(myY); } } } - else if(myConstructorId == 1) { // ARC - if(myConstructorDirId == 2) { // Angle - if(constructorId == 2) { // Length - mySketchType = DIR_ANGLE_LENGTH; - Group3Spin->SpinBox_DX->RangeStepAndValidator(-999.999, 999.999, 5., 3); - Group3Spin->SpinBox_DZ->RangeStepAndValidator(-999.999, 999.999, 5., 3); - Group3Spin->TextLabel1->setText(tr("GEOM_SKETCHER_ANGLE2")); - Group3Spin->TextLabel2->setText(tr("GEOM_SKETCHER_RADIUS2")); - Group3Spin->TextLabel3->setText(tr("GEOM_SKETCHER_ANGLE2")); - Group3Spin->SpinBox_DX->SetValue(myAngle); - myRadius = 100.0; - Group3Spin->SpinBox_DY->SetValue(myRadius); - myLength = 30.0; - Group3Spin->SpinBox_DZ->SetValue(myLength); - Group3Spin->show(); - Group3Spin->buttonApply->setFocus(); + else if ( myConstructorId == 1 ) + { // ARC + if ( myConstructorDirId == 2 ) + { // Angle + if ( constructorId == 2 ) + { // Length + mySketchType = DIR_ANGLE_LENGTH; + Group3Spin->SpinBox_DX->RangeStepAndValidator(-999999.999, 999999.999, 5., 3); + Group3Spin->SpinBox_DY->RangeStepAndValidator(-999999.999, 999999.999, 100., 3); + Group3Spin->SpinBox_DZ->RangeStepAndValidator(-999999.999, 999999.999, 5., 3); + Group3Spin->TextLabel1->setText(tr("GEOM_SKETCHER_ANGLE2")); + Group3Spin->TextLabel2->setText(tr("GEOM_SKETCHER_RADIUS2")); + Group3Spin->TextLabel3->setText(tr("GEOM_SKETCHER_ANGLE2")); + Group3Spin->SpinBox_DX->SetValue(myAngle); + myRadius = 100.0; + Group3Spin->SpinBox_DY->SetValue(myRadius); + myLength = 30.0; + Group3Spin->SpinBox_DZ->SetValue(myLength); + Group3Spin->show(); + Group3Spin->buttonApply->setFocus(); } } - else if(myConstructorDirId == 0) { // Perpendicular - if(constructorId == 2) { // Length - mySketchType = DIR_PER_LENGTH; - Group2Spin->SpinBox_DY->RangeStepAndValidator(-999.999, 999.999, 5., 3); - Group2Spin->TextLabel1->setText(tr("GEOM_SKETCHER_RADIUS2")); - Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_ANGLE2")); - myRadius = 100.0; - Group2Spin->SpinBox_DX->SetValue(myRadius); - myLength = 30.0; - Group2Spin->SpinBox_DY->SetValue(myLength); - Group2Spin->show(); - Group2Spin->buttonApply->setFocus(); + else if ( myConstructorDirId == 0 ) + { // Perpendicular + if ( constructorId == 2 ) + { // Length + mySketchType = DIR_PER_LENGTH; + Group2Spin->SpinBox_DY->RangeStepAndValidator(-999999.999, 999999.999, 100., 3); + Group2Spin->SpinBox_DY->RangeStepAndValidator(-999999.999, 999999.999, 5., 3); + Group2Spin->TextLabel1->setText(tr("GEOM_SKETCHER_RADIUS2")); + Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_ANGLE2")); + myRadius = 100.0; + Group2Spin->SpinBox_DX->SetValue(myRadius); + myLength = 30.0; + Group2Spin->SpinBox_DY->SetValue(myLength); + Group2Spin->show(); + Group2Spin->buttonApply->setFocus(); } } - else if(myConstructorDirId == 1) { // Tangent - if(constructorId == 2) { // Length - mySketchType = DIR_TAN_LENGTH; - Group2Spin->SpinBox_DY->RangeStepAndValidator(-999.999, 999.999, 5., 3); - Group2Spin->TextLabel1->setText(tr("GEOM_SKETCHER_RADIUS2")); - Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_ANGLE2")); - myRadius = 100.0; - Group2Spin->SpinBox_DX->SetValue(myRadius); - myLength = 30.0; - Group2Spin->SpinBox_DY->SetValue(myLength); - Group2Spin->show(); - Group2Spin->buttonApply->setFocus(); + else if ( myConstructorDirId == 1 ) + { // Tangent + if ( constructorId == 2 ) + { // Length + mySketchType = DIR_TAN_LENGTH; + Group2Spin->SpinBox_DY->RangeStepAndValidator(-999999.999, 999999.999, 100., 3); + Group2Spin->SpinBox_DY->RangeStepAndValidator(-999999.999, 999999.999, 5., 3); + Group2Spin->TextLabel1->setText(tr("GEOM_SKETCHER_RADIUS2")); + Group2Spin->TextLabel2->setText(tr("GEOM_SKETCHER_ANGLE2")); + myRadius = 100.0; + Group2Spin->SpinBox_DX->SetValue(myRadius); + myLength = 30.0; + Group2Spin->SpinBox_DY->SetValue(myLength); + Group2Spin->show(); + Group2Spin->buttonApply->setFocus(); } } - else if(myConstructorDirId == 3) { // DXDY - if(constructorId == 2) { // Length - mySketchType = DIR_DXDY_LENGTH; - Group4Spin->TextLabel1->setText(tr("GEOM_SKETCHER_VX2")); - Group4Spin->TextLabel2->setText(tr("GEOM_SKETCHER_VY2")); - Group4Spin->TextLabel3->setText(tr("GEOM_SKETCHER_RADIUS2")); - Group4Spin->TextLabel4->setText(tr("GEOM_SKETCHER_ANGLE2")); - myDX = 0.0; - Group4Spin->SpinBox_DX->SetValue(myDX); - myDY = 0.0; - Group4Spin->SpinBox_DY->SetValue(myDY); - myRadius = 100.0; - Group4Spin->SpinBox_DZ->SetValue(myRadius); - myLength = 30.0; - Group4Spin->SpinBox_DS->SetValue(myLength); - Group4Spin->show(); - Group4Spin->buttonApply->setFocus(); + else if ( myConstructorDirId == 3 ) + { // DXDY + if ( constructorId == 2 ) + { // Length + mySketchType = DIR_DXDY_LENGTH; + Group4Spin->TextLabel1->setText(tr("GEOM_SKETCHER_VX2")); + Group4Spin->TextLabel2->setText(tr("GEOM_SKETCHER_VY2")); + Group4Spin->TextLabel3->setText(tr("GEOM_SKETCHER_RADIUS2")); + Group4Spin->TextLabel4->setText(tr("GEOM_SKETCHER_ANGLE2")); + myDX = 0.0; + Group4Spin->SpinBox_DX->SetValue(myDX); + myDY = 0.0; + Group4Spin->SpinBox_DY->SetValue(myDY); + myRadius = 100.0; + Group4Spin->SpinBox_DZ->SetValue(myRadius); + myLength = 30.0; + Group4Spin->SpinBox_DS->SetValue(myLength); + Group4Spin->show(); + Group4Spin->buttonApply->setFocus(); } } } - this->MakeSimulationAndDisplay(); - return; + GEOMBase_Helper::displayPreview(); } @@ -587,106 +617,141 @@ void EntityGUI_SketcherDlg::Dir2Clicked(int constructorId) //================================================================================= void EntityGUI_SketcherDlg::ClickOnCancel() { - QAD_Application::getDesktop()->putInfo(tr("")); - myEntityGUI->EraseSimulationShape(); - mySimulationTopoDs1.Nullify(); - mySimulationTopoDs2.Nullify(); - - mySelection->ClearFilters(); - disconnect(mySelection, 0, this, 0); - - reject(); - return; + close(); } //================================================================================= // function : ClickOnEnd() -// purpose : +// purpose : connected to buttonEnd AND buttonClose //================================================================================= void EntityGUI_SketcherDlg::ClickOnEnd() { - if(mySketchState != FIRST_POINT && mySketchState != SECOND_POINT) - myEntityGUI->OnSketchEnd(myCommand.ascii()); + if ( sender() == buttonClose ) + { + // Verify validity of commands + if ( myCommand.count() <= 2 ) + { + QAD_MessageBox::error1( QAD_Application::getDesktop(), + tr( "GEOM_ERROR_STATUS" ), tr( "CANNOT_CLOSE" ), tr( "BUT_OK" ) ); + return; + } + + QString Command = myCommand.join( "" ) + GetNewCommand(); + Sketcher_Profile aProfile (Command.ascii()); + + Command = myCommand.join( "" ); + aProfile = Sketcher_Profile(Command.ascii()); + TopoDS_Shape myShape; + if ( aProfile.IsDone() ) + myShape = aProfile.GetShape(); + + if(myShape.ShapeType() != TopAbs_VERTEX) + myCommand.append( ":WW" ); + } + else + myIsAllAdded = true; - this->ClickOnCancel(); - return; + if( myCommand.size() > 2 ) + if( !onAccept() ) + return; + + close(); } +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +bool EntityGUI_SketcherDlg::ClickOnApply() +{ + myCommand.append( GetNewCommand() ); + mySketchState = NEXT_POINT; + + myUndoCommand.clear(); + myUndoCommand.append( "Sketcher" ); + + GroupConstructors->setEnabled(true); + GroupDest1->setEnabled(true); + setEnabledUndo(true); + setEnabledRedo(false); + + GEOMBase_Helper::displayPreview(); + + return true; +} //================================================================================= -// function : ClickOnClose() +// function : ClickOnUndo() // purpose : //================================================================================= -void EntityGUI_SketcherDlg::ClickOnClose() +void EntityGUI_SketcherDlg::ClickOnUndo() { - if(mySketchState != FIRST_POINT && mySketchState != SECOND_POINT) { - myCommand = myCommand + ":WW"; - myEntityGUI->OnSketchEnd(myCommand.ascii()); + myUndoCommand.append( myCommand.last() ); + myCommand.pop_back(); + + if(myCommand.count() == 1) { + mySketchState = FIRST_POINT; + + RadioButton1->setChecked(true); + TypeClicked(0); + + GroupConstructors->setEnabled(false); + GroupDest1->setEnabled(false); + setEnabledUndo(false); } - this->ClickOnCancel(); - return; -} + setEnabledRedo(true); + GEOMBase_Helper::displayPreview(); +} //================================================================================= -// function : ClickOnApply() +// function : ClickOnRedo() // purpose : //================================================================================= -void EntityGUI_SketcherDlg::ClickOnApply() +void EntityGUI_SketcherDlg::ClickOnRedo() { - if(mySketchState == FIRST_POINT) { - mySketchState = SECOND_POINT; - myLastX2 = myLastX1; - myLastY2 = myLastY1; - } - else { - if(mySketchState != SECOND_POINT) { - Group1Sel->buttonUndo->setEnabled(true); - Group1Spin->buttonUndo->setEnabled(true); - Group2Spin->buttonUndo->setEnabled(true); - Group3Spin->buttonUndo->setEnabled(true); - Group4Spin->buttonUndo->setEnabled(true); - } + myCommand.append( myUndoCommand.last() ); + myUndoCommand.pop_back(); - QString myNewCommand = this->GetNewCommand(); - QString myCommandTemp = myCommand + myNewCommand; + mySketchState = NEXT_POINT; - Sketcher_Profile aProfile (myCommandTemp.ascii()); + GroupConstructors->setEnabled(true); + GroupDest1->setEnabled(true); + setEnabledUndo(true); - if(aProfile.IsDone()) { - myLastCommand = myCommand; - myCommand = myCommandTemp; - myLastX2 = myLastX1; - myLastY2 = myLastY1; - mySketchState = NEXT_POINT; - } - } + if(myUndoCommand.count() == 1) + setEnabledRedo(false); - myLastOp = myConstructorId; - this->MakeSimulationAndDisplay(); - return; + GEOMBase_Helper::displayPreview(); } - //================================================================================= -// function : ClickOnUndo() +// function : setEnabledUndo() // purpose : //================================================================================= -void EntityGUI_SketcherDlg::ClickOnUndo() +void EntityGUI_SketcherDlg::setEnabledUndo(bool value) { - Group1Sel->buttonUndo->setEnabled(false); - Group1Spin->buttonUndo->setEnabled(false); - Group2Spin->buttonUndo->setEnabled(false); - Group3Spin->buttonUndo->setEnabled(false); - Group4Spin->buttonUndo->setEnabled(false); - - myCommand = myLastCommand; - this->MakeSimulationAndDisplay(); - return; + Group1Sel->buttonUndo->setEnabled(value); + Group1Spin->buttonUndo->setEnabled(value); + Group2Spin->buttonUndo->setEnabled(value); + Group3Spin->buttonUndo->setEnabled(value); + Group4Spin->buttonUndo->setEnabled(value); } +//================================================================================= +// function : setEnabledRedo() +// purpose : +//================================================================================= +void EntityGUI_SketcherDlg::setEnabledRedo(bool value) +{ + Group1Sel->buttonRedo->setEnabled(value); + Group1Spin->buttonRedo->setEnabled(value); + Group2Spin->buttonRedo->setEnabled(value); + Group3Spin->buttonRedo->setEnabled(value); + Group4Spin->buttonRedo->setEnabled(value); +} //================================================================================= // function : SelectionIntoArgument() @@ -694,40 +759,36 @@ void EntityGUI_SketcherDlg::ClickOnUndo() //================================================================================= void EntityGUI_SketcherDlg::SelectionIntoArgument() { - myEntityGUI->EraseSimulationShape(1); //Juste Shape2!! - - Group1Sel->buttonApply->setEnabled(false); - Group1Sel->buttonApply->setFocus(); - myEditCurrentArgument->setText(""); - QString aString = ""; - - myX = 0.0; - myY = 0.0; - - int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString); - if(nbSel != 1) - return; - - /* nbSel == 1 */ - TopoDS_Shape S; - gp_Pnt myPoint1; - Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); - - if(!myGeomBase->GetTopoFromSelection(mySelection, S)) - return; - - if(myEditCurrentArgument == Group1Sel->LineEdit1 && myGeomBase->VertexToPoint(S, myPoint1)) { - myX = myPoint1.X(); - myY = myPoint1.Y(); - Group1Sel->LineEdit1->setText(aString); - - Group1Sel->buttonApply->setEnabled(true); - Group1Sel->buttonApply->setFocus(); - this->MakeSimulationAndDisplay(); + myX = myLastX1; + myY = myLastY1; + + int nbSel = mySelection->IObjectCount(); + if ( nbSel == 1 && myEditCurrentArgument == Group1Sel->LineEdit1 ) + { + Standard_Boolean aRes = Standard_False; + GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( mySelection->firstIObject(), aRes ); + if ( !CORBA::is_nil( aSelectedObject ) && aRes ) { + TopoDS_Shape aShape; + if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_VERTEX ) ) { + gp_Trsf aTrans; + gp_Ax3 aWPlane = GeometryGUI::GetGeomGUI()->GetWorkingPlane(); + + aTrans.SetTransformation(aWPlane); + BRepBuilderAPI_Transform aTransformation(aShape, aTrans, Standard_False); + aShape = aTransformation.Shape(); + + gp_Pnt aPnt; + if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) { + myX = aPnt.X(); + myY = aPnt.Y(); + Group1Sel->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) ); + } + } + } } - return; + GEOMBase_Helper::displayPreview(); } @@ -737,16 +798,12 @@ void EntityGUI_SketcherDlg::SelectionIntoArgument() //================================================================================= void EntityGUI_SketcherDlg::SetEditCurrentArgument() { - QPushButton* send = (QPushButton*)sender(); - - mySelection->ClearFilters(); - if(send == Group1Sel->PushButton1) { - //Group1Sel->LineEdit1->setFocus(); + if ( sender() == Group1Sel->PushButton1 ) + { myEditCurrentArgument = Group1Sel->LineEdit1; + myEditCurrentArgument->setFocus(); } - mySelection->AddFilter(myVertexFilter); - this->SelectionIntoArgument(); - return; + SelectionIntoArgument(); } @@ -756,15 +813,18 @@ void EntityGUI_SketcherDlg::SetEditCurrentArgument() //================================================================================= void EntityGUI_SketcherDlg::LineEditReturnPressed() { - /* User name of object input management */ - /* If successfull the selection is changed and signal emitted... */ - /* so SelectionIntoArgument() is automatically called. */ - const QString objectUserName = myEditCurrentArgument->text(); - QWidget* thisWidget = (QWidget*)this; - if(myGeomBase->SelectionByNameInDialogs(thisWidget, objectUserName, mySelection)) - myEditCurrentArgument->setText(objectUserName); - - return; + if ( sender() == Group1Sel->LineEdit1 ) + { + myEditCurrentArgument = Group1Sel->LineEdit1; + + /* User name of object input management */ + /* If successfull the selection is changed and signal emitted... */ + /* so SelectionIntoArgument() is automatically called. */ + const QString objectUserName = myEditCurrentArgument->text(); + QWidget* thisWidget = (QWidget*)this; + if(GEOMBase::SelectionByNameInDialogs(thisWidget, objectUserName, mySelection)) + myEditCurrentArgument->setText(objectUserName); + } } @@ -774,12 +834,12 @@ void EntityGUI_SketcherDlg::LineEditReturnPressed() //================================================================================= void EntityGUI_SketcherDlg::DeactivateActiveDialog() { - this->setEnabled(false); - mySelection->ClearFilters(); + GeometryGUI::GetGeomGUI()->SetState( -1 ); + + setEnabled( false ); + globalSelection(); disconnect(mySelection, 0, this, 0); - myEntityGUI->EraseSimulationShape(); - myGeomGUI->SetActiveDialogBox(0); - return; + GeometryGUI::GetGeomGUI()->SetActiveDialogBox(0); } @@ -789,15 +849,19 @@ void EntityGUI_SketcherDlg::DeactivateActiveDialog() //================================================================================= void EntityGUI_SketcherDlg::ActivateThisDialog() { - /* Emit a signal to deactivate the active dialog */ - myGeomGUI->EmitSignalDeactivateDialog(); - this->setEnabled(true); - myGeomGUI->SetActiveDialogBox((QDialog*)this); + GeometryGUI::GetGeomGUI()->EmitSignalDeactivateDialog(); + setEnabled(true); + GeometryGUI::GetGeomGUI()->SetActiveDialogBox((QDialog*)this); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - mySelection->AddFilter(myVertexFilter); - myEntityGUI->DisplaySimulationShape(mySimulationTopoDs1, mySimulationTopoDs2); - return; + GeometryGUI::GetGeomGUI()->SetState( 0 ); + globalSelection( GEOM_POINT ); + + myEditCurrentArgument = Group1Sel->LineEdit1; + myEditCurrentArgument->setFocus(); + + GEOMBase_Helper::displayPreview(); } @@ -807,10 +871,8 @@ void EntityGUI_SketcherDlg::ActivateThisDialog() //================================================================================= void EntityGUI_SketcherDlg::enterEvent(QEvent* e) { - if(GroupConstructors->isEnabled()) - return; - this->ActivateThisDialog(); - return; + if ( !GroupConstructors->isEnabled()) + ActivateThisDialog(); } @@ -820,9 +882,9 @@ void EntityGUI_SketcherDlg::enterEvent(QEvent* e) //================================================================================= void EntityGUI_SketcherDlg::closeEvent(QCloseEvent* e) { - /* same than click on cancel button */ - this->ClickOnCancel(); - return; + GeometryGUI::GetGeomGUI()->SetState( -1 ); + disconnect(mySelection, 0, this, 0); + QDialog::closeEvent( e ); } @@ -836,137 +898,157 @@ void EntityGUI_SketcherDlg::ValueChangedInSpinBox(double newValue) Standard_Real vx, vy, vz, vs; vx = vy = vz = vs = 0.0; - if(send == Group1Spin->SpinBox_DX) { + if ( send == Group1Spin->SpinBox_DX) + { vx = newValue; - Group1Spin->buttonApply->setFocus(); } - else if(send == Group2Spin->SpinBox_DX) { + else if ( send == Group2Spin->SpinBox_DX ) + { vx = newValue; vy = Group2Spin->SpinBox_DY->GetValue(); - Group2Spin->buttonApply->setFocus(); } - else if(send == Group2Spin->SpinBox_DY) { + else if ( send == Group2Spin->SpinBox_DY) + { vx = Group2Spin->SpinBox_DX->GetValue(); vy = newValue; - Group2Spin->buttonApply->setFocus(); } - else if(send == Group3Spin->SpinBox_DX) { + else if ( send == Group3Spin->SpinBox_DX) + { vx = newValue; vy = Group3Spin->SpinBox_DY->GetValue(); vz = Group3Spin->SpinBox_DZ->GetValue(); - Group3Spin->buttonApply->setFocus(); } - else if(send == Group3Spin->SpinBox_DY) { + else if ( send == Group3Spin->SpinBox_DY) + { vx = Group3Spin->SpinBox_DX->GetValue(); vy = newValue; vz = Group3Spin->SpinBox_DZ->GetValue(); - Group3Spin->buttonApply->setFocus(); } - else if(send == Group3Spin->SpinBox_DZ) { + else if ( send == Group3Spin->SpinBox_DZ) + { vx = Group3Spin->SpinBox_DX->GetValue(); vy = Group3Spin->SpinBox_DY->GetValue(); vz = newValue; - Group3Spin->buttonApply->setFocus(); } - else if(send == Group4Spin->SpinBox_DX) { + else if ( send == Group4Spin->SpinBox_DX) + { vx = newValue; vy = Group4Spin->SpinBox_DY->GetValue(); vz = Group4Spin->SpinBox_DZ->GetValue(); vs = Group4Spin->SpinBox_DS->GetValue(); - Group4Spin->buttonApply->setFocus(); } - else if(send == Group4Spin->SpinBox_DY) { + else if ( send == Group4Spin->SpinBox_DY) + { vx = Group4Spin->SpinBox_DX->GetValue(); vy = newValue; vz = Group4Spin->SpinBox_DZ->GetValue(); vs = Group4Spin->SpinBox_DS->GetValue(); - Group4Spin->buttonApply->setFocus(); } - else if(send == Group4Spin->SpinBox_DZ) { + else if ( send == Group4Spin->SpinBox_DZ) + { vx = Group4Spin->SpinBox_DX->GetValue(); vy = Group4Spin->SpinBox_DY->GetValue(); vz = newValue; vs = Group4Spin->SpinBox_DS->GetValue(); - Group4Spin->buttonApply->setFocus(); } - else if(send == Group4Spin->SpinBox_DS) { + else if ( send == Group4Spin->SpinBox_DS) + { vx = Group4Spin->SpinBox_DX->GetValue(); vy = Group4Spin->SpinBox_DY->GetValue(); vz = Group4Spin->SpinBox_DZ->GetValue(); vs = newValue; - Group4Spin->buttonApply->setFocus(); } - if(myConstructorId == 0) { // SEGMENT - if(mySketchType == PT_ABS) { + if ( myConstructorId == 0 ) + { // SEGMENT + if ( mySketchType == PT_ABS) + { myX = vx; myY = vy; } - else if(mySketchType == PT_RELATIVE) { + else if ( mySketchType == PT_RELATIVE) + { myDX = vx; myDY = vy; } - else if(mySketchType == DIR_ANGLE_LENGTH) { + else if ( mySketchType == DIR_ANGLE_LENGTH) + { myAngle = vx; myLength = vy; } - else if(mySketchType == DIR_ANGLE_X) { + else if ( mySketchType == DIR_ANGLE_X) + { myAngle = vx; myX = vy; } - else if(mySketchType == DIR_ANGLE_Y) { + else if ( mySketchType == DIR_ANGLE_Y) + { myAngle = vx; myY = vy; } - else if(mySketchType == DIR_PER_LENGTH) { + else if ( mySketchType == DIR_PER_LENGTH) + { myLength = vx; } - else if(mySketchType == DIR_PER_X) { + else if ( mySketchType == DIR_PER_X) + { myX = vx; } - else if(mySketchType == DIR_PER_Y) { + else if ( mySketchType == DIR_PER_Y) + { myY = vx; } - else if(mySketchType == DIR_TAN_LENGTH) { + else if ( mySketchType == DIR_TAN_LENGTH) + { myLength = vx; } - else if(mySketchType == DIR_TAN_X) { + else if ( mySketchType == DIR_TAN_X) + { myX = vx; } - else if(mySketchType == DIR_TAN_Y) { + else if ( mySketchType == DIR_TAN_Y) + { myY = vx; } - else if(mySketchType == DIR_DXDY_LENGTH) { + else if ( mySketchType == DIR_DXDY_LENGTH) + { myDX = vx; myDY = vy; myLength = vz; } - else if(mySketchType == DIR_DXDY_X) { + else if ( mySketchType == DIR_DXDY_X) + { myDX = vx; myDY = vy; myX = vz; } - else if(mySketchType == DIR_DXDY_Y) { + else if ( mySketchType == DIR_DXDY_Y) + { myDX = vx; myDY = vy; myY = vz; } } - else if(myConstructorId == 1) { // ARC - if(mySketchType == DIR_ANGLE_LENGTH) { + else if ( myConstructorId == 1 ) + { // ARC + if ( mySketchType == DIR_ANGLE_LENGTH) + { myAngle = vx; myRadius = vy; myLength = vz; } - else if(mySketchType == DIR_PER_LENGTH) { + else if ( mySketchType == DIR_PER_LENGTH) + { myRadius = vx; myLength = vy; } - else if(mySketchType == DIR_TAN_LENGTH) { + else if ( mySketchType == DIR_TAN_LENGTH) + { myRadius = vx; myLength = vy; } - else if(mySketchType == DIR_DXDY_LENGTH) { + else if ( mySketchType == DIR_DXDY_LENGTH) + { myDX = vx; myDY = vy; myRadius = vz; @@ -974,83 +1056,101 @@ void EntityGUI_SketcherDlg::ValueChangedInSpinBox(double newValue) } } - this->MakeSimulationAndDisplay(); - return; + GEOMBase_Helper::displayPreview(); } //================================================================================= // function : GetNewCommand() -// purpose : +// purpose : Build the new command with context //================================================================================= QString EntityGUI_SketcherDlg::GetNewCommand() { - QString myNewCommand = ""; - if(mySketchState == FIRST_POINT) + QString myNewCommand = ":"; + if ( mySketchState == FIRST_POINT ) { + if ( mySketchType == PT_ABS || mySketchType == PT_SEL) + myNewCommand = myNewCommand + "F " + QString::number(myX) + " " + QString::number(myY); + if ( mySketchType == PT_RELATIVE) + myNewCommand = myNewCommand + "F " + QString::number(myDX) + " " + QString::number(myDY); return myNewCommand; + } - myNewCommand = ":"; - if(myConstructorId == 0) { // SEGMENT - if(mySketchType == PT_ABS || mySketchType == PT_SEL) + if ( myConstructorId == 0 ) + { // SEGMENT + if ( mySketchType == PT_ABS || mySketchType == PT_SEL) myNewCommand = myNewCommand + "TT " + QString::number(myX) + " " + QString::number(myY); - if(mySketchType == PT_RELATIVE) + if ( mySketchType == PT_RELATIVE) myNewCommand = myNewCommand + "T " + QString::number(myDX) + " " + QString::number(myDY); - if(mySketchType == DIR_ANGLE_LENGTH) { + if ( mySketchType == DIR_ANGLE_LENGTH) + { myNewCommand = myNewCommand + "R " + QString::number(myAngle); myNewCommand = myNewCommand + ":" + "L " + QString::number(myLength); } - if(mySketchType == DIR_ANGLE_X) { + if ( mySketchType == DIR_ANGLE_X) + { myNewCommand = myNewCommand + "R " + QString::number(myAngle); myNewCommand = myNewCommand + ":" + "IX " + QString::number(myX); } - if(mySketchType == DIR_ANGLE_Y) { + if ( mySketchType == DIR_ANGLE_Y) + { myNewCommand = myNewCommand + "R " + QString::number(myAngle); myNewCommand = myNewCommand + ":" + "IY " + QString::number(myY); } - if(mySketchType == DIR_PER_LENGTH) { + if ( mySketchType == DIR_PER_LENGTH) + { myNewCommand = myNewCommand + "R " + QString::number(90.0); myNewCommand = myNewCommand + ":" + "L " + QString::number(myLength); } - if(mySketchType == DIR_PER_X) { + if ( mySketchType == DIR_PER_X) + { myNewCommand = myNewCommand + "R " + QString::number(90.0); myNewCommand = myNewCommand + ":" + "IX " + QString::number(myX); } - if(mySketchType == DIR_PER_Y) { + if ( mySketchType == DIR_PER_Y) + { myNewCommand = myNewCommand + "R " + QString::number(90.0); myNewCommand = myNewCommand + ":" + "IY " + QString::number(myY); } - if(mySketchType == DIR_TAN_LENGTH) + if ( mySketchType == DIR_TAN_LENGTH) myNewCommand = myNewCommand + "L " + QString::number(myLength); - if(mySketchType == DIR_TAN_X) + if ( mySketchType == DIR_TAN_X) myNewCommand = myNewCommand + "IX " + QString::number(myX); - if(mySketchType == DIR_TAN_Y) + if ( mySketchType == DIR_TAN_Y) myNewCommand = myNewCommand + "IY " + QString::number(myY); - if(mySketchType == DIR_DXDY_LENGTH) { + if ( mySketchType == DIR_DXDY_LENGTH) + { myNewCommand = myNewCommand + "D " + QString::number(myDX) + " " + QString::number(myDY); myNewCommand = myNewCommand + ":" + "L " + QString::number(myLength); } - if(mySketchType == DIR_DXDY_X) { + if ( mySketchType == DIR_DXDY_X) + { myNewCommand = myNewCommand + "D " + QString::number(myDX) + " " + QString::number(myDY); myNewCommand = myNewCommand + ":" + "IX " + QString::number(myX); } - if(mySketchType == DIR_DXDY_Y) { + if ( mySketchType == DIR_DXDY_Y) + { myNewCommand = myNewCommand + "D " + QString::number(myDX) + " " + QString::number(myDY); myNewCommand = myNewCommand + ":" + "IY " + QString::number(myY); } } - else if(myConstructorId == 1) { // ARC - if(mySketchType == DIR_ANGLE_LENGTH) { + else if ( myConstructorId == 1 ) + { // ARC + if ( mySketchType == DIR_ANGLE_LENGTH) + { myNewCommand = myNewCommand + "R " + QString::number(myAngle); myNewCommand = myNewCommand + ":" + "C " + QString::number(myRadius) + " " + QString::number(myLength); } - if(mySketchType == DIR_PER_LENGTH) { + if ( mySketchType == DIR_PER_LENGTH) + { myNewCommand = myNewCommand + "R " + QString::number(90.0); myNewCommand = myNewCommand + ":" + "C " + QString::number(myRadius) + " " + QString::number(myLength); } - if(mySketchType == DIR_TAN_LENGTH) { + if ( mySketchType == DIR_TAN_LENGTH) + { myNewCommand = myNewCommand + "C " + QString::number(myRadius) + " " + QString::number(myLength); } - if(mySketchType == DIR_DXDY_LENGTH) { + if ( mySketchType == DIR_DXDY_LENGTH) + { myNewCommand = myNewCommand + "D " + QString::number(myDX) + " " + QString::number(myDY); myNewCommand = myNewCommand + ":" + "C " + QString::number(myRadius) + " " + QString::number(myLength); } @@ -1058,111 +1158,267 @@ QString EntityGUI_SketcherDlg::GetNewCommand() return myNewCommand; } - //================================================================================= -// function : MakeSimulationAndDisplay() +// function : createOperation // purpose : //================================================================================= -void EntityGUI_SketcherDlg::MakeSimulationAndDisplay() +GEOM::GEOM_IOperations_ptr EntityGUI_SketcherDlg::createOperation() { - myEntityGUI->EraseSimulationShape(); - mySimulationTopoDs1.Nullify(); - mySimulationTopoDs2.Nullify(); - - try { - if(mySketchState == FIRST_POINT) { - myCommand = "Sketch "; - myCommand = myCommand + ":" + "F " + QString::number(myX) + " " + QString::number(myY); - - myLastX1 = myX; - myLastY1 = myY; - - } + return getGeomEngine()->GetICurvesOperations( getStudyId() ); +} - Sketcher_Profile aProfile1 (myCommand.ascii()); +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool EntityGUI_SketcherDlg::isValid( QString& msg ) +{ + return true; +} - if(aProfile1.IsDone()) { - myShape = aProfile1.GetShape(); - mySimulationTopoDs1 = myShape; +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool EntityGUI_SketcherDlg::execute( ObjectList& objects ) +{ + if(mySketchState == FIRST_POINT) { + myLastX2 = myX; + myLastY2 = myY; + } + else { + //Test if the current point is the same as the last one + TopoDS_Shape myShape1, myShape2; + + //Last Shape + QString Command1 = myCommand.join( "" ); + Sketcher_Profile aProfile1 (Command1.ascii()); + if(aProfile1.IsDone()) + myShape1 = aProfile1.GetShape(); + + //Current Shape + QString Command2 = Command1 + GetNewCommand(); + Sketcher_Profile aProfile2 (Command2.ascii()); + if(aProfile2.IsDone()) + myShape2 = aProfile2.GetShape(); + + if(myShape2.IsNull()) { + //the current point is the same as the last one + myLastX2 = myLastX1; + myLastY2 = myLastY1; } - - if(mySketchState != FIRST_POINT) { - if(mySketchState == SECOND_POINT) { - gp_Pnt pt = BRep_Tool::Pnt(TopoDS::Vertex(myShape)); + else { + TopoDS_Vertex V1, V2; + gp_Pnt pt; + if(myShape1.ShapeType() == TopAbs_VERTEX) { + //the last shape is the first point + pt = BRep_Tool::Pnt(TopoDS::Vertex(myShape1)); myLastX1 = pt.X(); myLastY1 = pt.Y(); } else { - TopoDS_Vertex V1, V2; - TopExp::Vertices(TopoDS::Wire(myShape), V1, V2); - gp_Pnt pt = BRep_Tool::Pnt(V2); + TopExp::Vertices(TopoDS::Wire(myShape1), V1, V2); + pt = BRep_Tool::Pnt(V2); myLastX1 = pt.X(); myLastY1 = pt.Y(); - if(myLastOp == 1) { // ARC - myLastDir = aProfile1.GetLastDir(); - myLastX2 = myLastX1 - myLastDir.X(); - myLastY2 = myLastY1 - myLastDir.Y(); - } - } - QString myNewCommand = "Sketch "; - myNewCommand = myNewCommand + ":" + "F " + QString::number(myLastX1) + " " + QString::number(myLastY1); - if(mySketchState != SECOND_POINT && !((myLastX1 - myLastX2) == 0 && (myLastY1 - myLastY2) == 0)) - myNewCommand = myNewCommand + ":" + "D " + QString::number(myLastX1 - myLastX2) + " " + QString::number(myLastY1 - myLastY2); - myNewCommand = myNewCommand + this->GetNewCommand(); - Sketcher_Profile aProfile2 (myNewCommand.ascii()); - if(aProfile2.IsDone()) - mySimulationTopoDs2 = aProfile2.GetShape(); - - if ( mySimulationTopoDs2.IsNull() ) { - if ( Group1Sel->isVisible() ) { - Group1Sel->buttonApply->setEnabled(false); - Group1Sel->buttonApply->setFocus(); - } - if ( Group1Spin->isVisible() ) { - Group1Spin->buttonApply->setEnabled(false); - Group1Spin->buttonApply->setFocus(); - } - if ( Group2Spin->isVisible() ) { - Group2Spin->buttonApply->setEnabled(false); - Group2Spin->buttonApply->setFocus(); - } - if ( Group3Spin->isVisible() ) { - Group3Spin->buttonApply->setEnabled(false); - Group3Spin->buttonApply->setFocus(); - } - if ( Group4Spin->isVisible() ) { - Group4Spin->buttonApply->setEnabled(false); - Group4Spin->buttonApply->setFocus(); - } - } else { - if ( Group1Sel->isVisible() ) { - Group1Sel->buttonApply->setEnabled(true); - Group1Sel->buttonApply->setFocus(); - } - if ( Group1Spin->isVisible() ) { - Group1Spin->buttonApply->setEnabled(true); - Group1Spin->buttonApply->setFocus(); - } - if ( Group2Spin->isVisible() ) { - Group2Spin->buttonApply->setEnabled(true); - Group2Spin->buttonApply->setFocus(); - } - if ( Group3Spin->isVisible() ) { - Group3Spin->buttonApply->setEnabled(true); - Group3Spin->buttonApply->setFocus(); - } - if ( Group4Spin->isVisible() ) { - Group4Spin->buttonApply->setEnabled(true); - Group4Spin->buttonApply->setFocus(); - } } + TopExp::Vertices(TopoDS::Wire(myShape2), V1, V2); + pt = BRep_Tool::Pnt(V2); + myLastX2 = pt.X(); + myLastY2 = pt.Y(); } + } - myEntityGUI->DisplaySimulationShape(mySimulationTopoDs1, mySimulationTopoDs2); + QString cmd; + if( ( mySketchState != FIRST_POINT && myLastX1 == myLastX2 && myLastY1 == myLastY2 ) || myIsAllAdded ) { + cmd = myCommand.join( "" ); + + if ( Group1Sel->isVisible() ) { + Group1Sel->buttonApply->setEnabled(false); + Group1Sel->buttonApply->setFocus(); + } + if ( Group1Spin->isVisible() ) { + Group1Spin->buttonApply->setEnabled(false); + Group1Spin->buttonApply->setFocus(); + } + if ( Group2Spin->isVisible() ) { + Group2Spin->buttonApply->setEnabled(false); + Group2Spin->buttonApply->setFocus(); + } + if ( Group3Spin->isVisible() ) { + Group3Spin->buttonApply->setEnabled(false); + Group3Spin->buttonApply->setFocus(); + } + if ( Group4Spin->isVisible() ) { + Group4Spin->buttonApply->setEnabled(false); + Group4Spin->buttonApply->setFocus(); + } } - catch(Standard_Failure) { - MESSAGE("Exception catched in MakeSimulationAndDisplay"); + else { + cmd = myCommand.join( "" ) + GetNewCommand(); + + if ( Group1Sel->isVisible() ) { + Group1Sel->buttonApply->setEnabled(true); + Group1Sel->buttonApply->setFocus(); + } + if ( Group1Spin->isVisible() ) { + Group1Spin->buttonApply->setEnabled(true); + Group1Spin->buttonApply->setFocus(); + } + if ( Group2Spin->isVisible() ) { + Group2Spin->buttonApply->setEnabled(true); + Group2Spin->buttonApply->setFocus(); + } + if ( Group3Spin->isVisible() ) { + Group3Spin->buttonApply->setEnabled(true); + Group3Spin->buttonApply->setFocus(); + } + if ( Group4Spin->isVisible() ) { + Group4Spin->buttonApply->setEnabled(true); + Group4Spin->buttonApply->setFocus(); + } + } + + gp_Ax3 myWPlane = GeometryGUI::GetGeomGUI()->GetWorkingPlane(); + GEOM::ListOfDouble_var WPlane = new GEOM::ListOfDouble; + WPlane->length(9); + WPlane[0] = myWPlane.Location().X(); + WPlane[1] = myWPlane.Location().Y(); + WPlane[2] = myWPlane.Location().Z(); + + WPlane[3] = myWPlane.Direction().X(); + WPlane[4] = myWPlane.Direction().Y(); + WPlane[5] = myWPlane.Direction().Z(); + + WPlane[6] = myWPlane.XDirection().X(); + WPlane[7] = myWPlane.XDirection().Y(); + WPlane[8] = myWPlane.XDirection().Z(); + + GEOM::GEOM_Object_var anObj = GEOM::GEOM_ICurvesOperations::_narrow( getOperation() )->MakeSketcher( cmd.latin1(), WPlane ); + + if ( !anObj->_is_nil() ) + objects.push_back( anObj._retn() ); + + return true; +} + +//================================================================ +// Function : displayPreview +// Purpose : Method for displaying preview of resulting shape +// Redefined from GEOMBase_Helper. +//================================================================ +void EntityGUI_SketcherDlg::displayPreview( GEOM::GEOM_Object_ptr object, + const bool append, + const bool activate, + const bool update, + const double lineWidth ) +{ + // Set color for preview shape + getDisplayer()->SetColor( Quantity_NOC_RED ); + + // set width of displayed shape + getDisplayer()->SetWidth( lineWidth ); + + // Disable activation of selection + getDisplayer()->SetToActivate( activate ); + + // Make a reference to GEOM_Object + getDisplayer()->SetName( GeometryGUI::GetORB()->object_to_string( object ) ); + + // Create wire from applayed object + TopoDS_Shape anApplyedWire, aLastSegment; + if ( !createShapes( object, anApplyedWire, aLastSegment ) ) return; + + // Build prs + SALOME_Prs* aPrs = getDisplayer()->BuildPrs( anApplyedWire ); + if ( aPrs != 0 && !aPrs->IsNull() ) + GEOMBase_Helper::displayPreview( aPrs, append, update ); + + getDisplayer()->SetColor( Quantity_NOC_VIOLET ); + aPrs = getDisplayer()->BuildPrs( aLastSegment ); + if ( aPrs != 0 && !aPrs->IsNull() ) + GEOMBase_Helper::displayPreview( aPrs, append, update ); + + getDisplayer()->UnsetName(); + + // Enable activation of displayed objects + getDisplayer()->SetToActivate( true ); +} + +//================================================================ +// Function : createShapes +// Purpose : Create applyed wire, and last segment from entry object +//================================================================ +bool EntityGUI_SketcherDlg::createShapes( GEOM::GEOM_Object_ptr theObject, + TopoDS_Shape& theApplyedWire, + TopoDS_Shape& theLastSegment ) +{ + TopoDS_Shape aShape; + if ( !GEOMBase::GetShape( theObject, aShape ) || + aShape.ShapeType() != TopAbs_WIRE && aShape.ShapeType() != TopAbs_VERTEX ) + return false; + + if ( Group1Sel->isVisible() && !Group1Sel->buttonApply->isEnabled() || + Group1Spin->isVisible() && !Group1Spin->buttonApply->isEnabled() || + Group2Spin->isVisible() && !Group2Spin->buttonApply->isEnabled() || + Group3Spin->isVisible() && !Group3Spin->buttonApply->isEnabled() || + Group4Spin->isVisible() && !Group4Spin->buttonApply->isEnabled() ) + { + theApplyedWire = aShape; + return true; } - return; + + BRepBuilderAPI_MakeWire aBuilder; + TopExp_Explorer anExp( aShape, TopAbs_EDGE ); + while( 1 ) + { + TopoDS_Shape anEdge = anExp.Current(); + anExp.Next(); + if ( anExp.More() ) // i.e. non-last edge + aBuilder.Add( TopoDS::Edge( anEdge ) ); + else + { + theLastSegment = anEdge; + break; + } + } + + if ( aBuilder.IsDone() ) + theApplyedWire = aBuilder.Shape(); + + return true; } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/EntityGUI/EntityGUI_SketcherDlg.h b/src/EntityGUI/EntityGUI_SketcherDlg.h index 2da62fe81..d7c287d79 100644 --- a/src/EntityGUI/EntityGUI_SketcherDlg.h +++ b/src/EntityGUI/EntityGUI_SketcherDlg.h @@ -29,6 +29,8 @@ #ifndef ENTITYGUI_SKETCHERDLG_H #define ENTITYGUI_SKETCHERDLG_H +#include "GEOMBase_Helper.h" + #include "EntityGUI_Skeleton_QTD.h" #include "EntityGUI_Point_QTD.h" #include "EntityGUI_Dir1_QTD.h" @@ -41,6 +43,7 @@ #include "EntityGUI_4Spin.h" #include "EntityGUI.h" +#include "GeometryGUI.h" #include "GEOM_ShapeTypeFilter.hxx" @@ -57,56 +60,48 @@ // class : EntityGUI_Dlg // purpose : //================================================================================= -class EntityGUI_SketcherDlg : public EntityGUI_Skeleton_QTD +class EntityGUI_SketcherDlg : public EntityGUI_Skeleton_QTD, public GEOMBase_Helper { Q_OBJECT public: - EntityGUI_SketcherDlg(QWidget* parent = 0, const char* name = 0, EntityGUI* theEntityGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + EntityGUI_SketcherDlg(QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); ~EntityGUI_SketcherDlg(); +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& ); + virtual bool execute( ObjectList& objects ); + + void closeEvent( QCloseEvent* e ); + private : void Init(); void enterEvent(QEvent* e); - void closeEvent(QCloseEvent* e); void InitClick(); - void MakeSimulationAndDisplay(); - QString GetNewCommand(); + void setEnabledUndo(bool value); + void setEnabledRedo(bool value); - EntityGUI* myEntityGUI; + QString GetNewCommand(); - double step; int myConstructorId; int myConstructorDirId; int mySketchType; int mySketchState; - Handle(GEOM_ShapeTypeFilter) myVertexFilter; - TopoDS_Shape mySimulationTopoDs1; /* Shape used for simulation display */ - TopoDS_Shape mySimulationTopoDs2; /* Shape used for simulation display */ + bool myIsAllAdded; + QLineEdit* myEditCurrentArgument; /* Current LineEdit */ SALOME_Selection* mySelection; /* User shape selection */ - GEOM::GEOM_Gen_var myGeom; /* Current GeomI object */ - GEOMBase* myGeomBase; - GEOMContext* myGeomGUI; /* Current GeomGUI object */ - - int myLastOp; - QString myCommand; - QString myLastCommand; - TopoDS_Shape myShape; - gp_Dir myLastDir; - - Standard_Real myX; - Standard_Real myY; - Standard_Real myDX; - Standard_Real myDY; - Standard_Real myLastX1; - Standard_Real myLastY1; - Standard_Real myLastX2; - Standard_Real myLastY2; - Standard_Real myLength; - Standard_Real myAngle; - Standard_Real myRadius; + + QStringList myCommand; + QStringList myUndoCommand; + + Standard_Real myX, myY, myDX, myDY; + Standard_Real myLength, myAngle, myRadius; + Standard_Real myLastX1, myLastY1; + Standard_Real myLastX2, myLastY2; EntityGUI_Point_QTD* GroupPt; EntityGUI_Dir1_QTD* GroupD1; @@ -118,7 +113,7 @@ private : EntityGUI_3Spin* Group3Spin; EntityGUI_4Spin* Group4Spin; - enum SketchState {FIRST_POINT, SECOND_POINT, NEXT_POINT}; + enum SketchState {FIRST_POINT, NEXT_POINT}; enum SketchType {PT_ABS, PT_RELATIVE, PT_SEL, DIR_ANGLE_LENGTH, DIR_ANGLE_X, DIR_ANGLE_Y, @@ -126,12 +121,21 @@ private : DIR_TAN_LENGTH, DIR_TAN_X, DIR_TAN_Y, DIR_DXDY_LENGTH, DIR_DXDY_X, DIR_DXDY_Y}; + virtual void displayPreview ( GEOM::GEOM_Object_ptr obj, + const bool append = false, + const bool activate = false, + const bool update = true, + const double lineWidth = -1 ); + + bool createShapes( GEOM::GEOM_Object_ptr theObject, + TopoDS_Shape& theApplyedWire, + TopoDS_Shape& theLastSegment ); private slots: void ClickOnEnd(); - void ClickOnClose(); void ClickOnCancel(); - void ClickOnApply(); + bool ClickOnApply(); void ClickOnUndo(); + void ClickOnRedo(); void LineEditReturnPressed(); void SelectionIntoArgument(); void SetEditCurrentArgument(); diff --git a/src/EntityGUI/EntityGUI_SubShapeDlg.cxx b/src/EntityGUI/EntityGUI_SubShapeDlg.cxx index b782a2bd2..ff6304c63 100644 --- a/src/EntityGUI/EntityGUI_SubShapeDlg.cxx +++ b/src/EntityGUI/EntityGUI_SubShapeDlg.cxx @@ -26,27 +26,29 @@ // Module : GEOM // $Header$ -using namespace std; #include "EntityGUI_SubShapeDlg.h" +#include "GEOM_Displayer.h" -#include "DisplayGUI.h" #include "QAD_RightFrame.h" -#include "OCCViewer_Viewer3d.h" +#include "QAD_Desktop.h" +#include "SALOME_ListIteratorOfListIO.hxx" +#include +#include #include #include #include //================================================================================= -// class : EntityGUI_SubShapeDlg() +// class : EntityGUI_SubShapeDlg // purpose : Constructs a EntityGUI_SubShapeDlg 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. //================================================================================= -EntityGUI_SubShapeDlg::EntityGUI_SubShapeDlg(QWidget* parent, const char* name, EntityGUI* theEntityGUI, SALOME_Selection* Sel, Handle(AIS_InteractiveContext) ic, bool modal, WFlags fl) - :GEOMBase_Skeleton(parent, name, Sel, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) +EntityGUI_SubShapeDlg::EntityGUI_SubShapeDlg(QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl) + :GEOMBase_Skeleton(parent, name, Sel, modal, fl) { QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_SUBSHAPE"))); QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); @@ -65,13 +67,12 @@ EntityGUI_SubShapeDlg::EntityGUI_SubShapeDlg(QWidget* parent, const char* name, GroupPoints->TextLabel2->setText(tr("GEOM_SUBSHAPE_TYPE")); GroupPoints->CheckButton1->setText(tr("GEOM_SUBSHAPE_SELECT")); GroupPoints->PushButton1->setPixmap(image1); + GroupPoints->LineEdit1->setReadOnly( true ); Layout1->addWidget(GroupPoints, 1, 0); /***************************************************************/ - /* Initialisations */ - myEntityGUI = theEntityGUI; - Init(ic); + Init(); } @@ -81,7 +82,6 @@ EntityGUI_SubShapeDlg::EntityGUI_SubShapeDlg(QWidget* parent, const char* name, //================================================================================= EntityGUI_SubShapeDlg::~EntityGUI_SubShapeDlg() { - // no need to delete child widgets, Qt does it all for us } @@ -89,15 +89,13 @@ EntityGUI_SubShapeDlg::~EntityGUI_SubShapeDlg() // function : Init() // purpose : //================================================================================= -void EntityGUI_SubShapeDlg::Init(Handle(AIS_InteractiveContext) ic) +void EntityGUI_SubShapeDlg::Init() { /* init variables */ myEditCurrentArgument = GroupPoints->LineEdit1; + myObject = GEOM::GEOM_Object::_nil(); myWithShape = true; - myAbort = myOkShape = myUseLocalContext = false; - myIC = ic; - myLocalContextId = -1; /* type for sub shape selection */ GroupPoints->ComboBox1->insertItem("Compound"); @@ -110,9 +108,6 @@ void EntityGUI_SubShapeDlg::Init(Handle(AIS_InteractiveContext) ic) GroupPoints->ComboBox1->insertItem("Vertex"); GroupPoints->ComboBox1->insertItem("Shape"); - myShapeType = GroupPoints->ComboBox1->currentItem(); - myOkSelectSubMode = GroupPoints->CheckButton1->isChecked(); - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_OCC) GroupPoints->CheckButton1->setEnabled(false); @@ -128,15 +123,13 @@ void EntityGUI_SubShapeDlg::Init(Handle(AIS_InteractiveContext) ic) connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); connect(GroupPoints->ComboBox1, SIGNAL(activated(int)), this, SLOT(ComboTextChanged())); - connect(GroupPoints->CheckButton1, SIGNAL(stateChanged(int)), this, SLOT(AllOrNotAll())); + connect(GroupPoints->CheckButton1, SIGNAL(stateChanged(int)), this, SLOT(SubShapeToggled())); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - /* displays Dialog */ - GroupPoints->show(); - this->show(); + updateButtonState(); - return; + SelectionIntoArgument(); } @@ -146,15 +139,8 @@ void EntityGUI_SubShapeDlg::Init(Handle(AIS_InteractiveContext) ic) //================================================================================= void EntityGUI_SubShapeDlg::ClickOnOk() { - this->ClickOnApply(); - - /* User has aborted or not operation of explode all with many sub shapes */ - if(myAbort == false) - this->ClickOnCancel(); - else - myAbort = false; - - return; + if ( ClickOnApply() ) + ClickOnCancel(); } @@ -162,65 +148,26 @@ void EntityGUI_SubShapeDlg::ClickOnOk() // function : ClickOnApply() // purpose : //================================================================================= -void EntityGUI_SubShapeDlg::ClickOnApply() +bool EntityGUI_SubShapeDlg::ClickOnApply() { QAD_Application::getDesktop()->putInfo(tr("")); - bool testResult = false; - myAbort = false; /* Not aborted by default */ /* Explode all sub shapes */ - if(myOkShape && !myOkSelectSubMode) { + if( isAllSubShapes() ) { /* More than 30 subshapes : ask confirmation */ - unsigned int nb = NumberOfSubShapes(myShape, myShapeType); + unsigned int nb = NumberOfSubShapes(myShape, shapeType()); if(nb > 30) { const QString caption = tr("GEOM_CONFIRM"); const QString text = tr("GEOM_CONFIRM_INFO").arg(nb); const QString button0 = tr("GEOM_BUT_EXPLODE"); const QString button1 = tr("GEOM_BUT_CANCEL"); - - if(QMessageBox::warning(this, caption, text, button0, button1) == 0) - testResult = myEntityGUI->OnSubShapeGetAll(myShape, myShapeIOR, myShapeType); - else - myAbort = true; /* aborted */ - } - else - testResult = myEntityGUI->OnSubShapeGetAll(myShape, myShapeIOR, myShapeType); - } - /* explode only selected sub shapes */ - else if(myOkShape && myOkSelectSubMode) - testResult = myEntityGUI->OnSubShapeGetSelected(myShape, myShapeIOR, myShapeType, myLocalContextId, myUseLocalContext); - if(!testResult) { - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_ABORT")); - myAbort = true; - } - else - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); - - /* Reset all arguments and local context to allow user a new selection ...*/ - //this->ResetStateOfDialog(); - return; -} - - -//================================================================================= -// function : ClickOnCancel() -// purpose : -//================================================================================= -void EntityGUI_SubShapeDlg::ClickOnCancel() -{ - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - myIC = v3d->getAISContext(); - if(myUseLocalContext) { - myIC->CloseLocalContext(myLocalContextId); - myUseLocalContext = false; + if(QMessageBox::warning(this, caption, text, button0, button1) != 0) + return false; /* aborted */ } - DisplayGUI* myDisplayGUI = new DisplayGUI(); - myDisplayGUI->OnDisplayAll(true); } - GEOMBase_Skeleton::ClickOnCancel(); - return; + + return onAccept(); } @@ -231,98 +178,107 @@ void EntityGUI_SubShapeDlg::ClickOnCancel() //================================================================================= void EntityGUI_SubShapeDlg::SelectionIntoArgument() { - myEditCurrentArgument->setText(""); - this->ResetStateOfDialog(); + if ( !isAllSubShapes() ) + return; + + ResetStateOfDialog(); + QString aString = ""; /* name of selection */ - int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString); - if(nbSel != 1) { - myOkShape = false; + int nbSel = GEOMBase::GetNameOfSelectedIObjects( mySelection, aString, true ); + if( nbSel != 1 ) return; - } - - /* nbSel == 1 */ + TopoDS_Shape S; Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); - if(!myGeomBase->GetTopoFromSelection(mySelection, S)) + if ( !IO->hasEntry() ) + { + QAD_Application::getDesktop()->putInfo( tr( "GEOM_PRP_SHAPE_IN_STUDY" ) ); + updateButtonState(); return; - - if(!IO->hasEntry()) { - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY")); + } + + if ( !myGeomBase->GetTopoFromSelection( mySelection, S ) || + S.IsNull() || + S.ShapeType() == TopAbs_VERTEX ) + { + updateButtonState(); return; } - if(!S.IsNull() && S.ShapeType() != TopAbs_VERTEX) { - if(IO->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject))) { - Handle(GEOM_InteractiveObject) GIObject = Handle(GEOM_InteractiveObject)::DownCast( IO ); - myShapeIOR = GIObject->getIOR(); /* the Geom IOR string of selection */ - myEditCurrentArgument->setText(aString); - myShape = S; - myOkShape = true; - } - else { - SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument(); - SALOMEDS::SObject_var obj = aStudy->FindObjectID(IO->getEntry()); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeIOR_var anIOR; - if(!obj->_is_nil()) { - if(obj->FindAttribute(anAttr, "AttributeIOR")) { - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - myShapeIOR = anIOR->Value(); - myOkShape = true; - myShape = S; - GroupPoints->LineEdit1->setText(aString); - } - } - } - - int SelectedShapeType = GroupPoints->ComboBox1->currentItem(); - int count = GroupPoints->ComboBox1->count(); - if(myWithShape) - count = count - 1; + Standard_Boolean testResult; + myObject = GEOMBase::ConvertIOinGEOMObject( IO, testResult ); + if ( !testResult || myObject->_is_nil() ) + { + updateButtonState(); + return; + } + + myShape = S; + GroupPoints->LineEdit1->setText( aString ); + + + int SelectedShapeType = GroupPoints->ComboBox1->currentItem(); + int count = GroupPoints->ComboBox1->count(); + + if ( myWithShape ) + count = count - 1; - int i = 0; - while(i <= myShape.ShapeType()) { - GroupPoints->ComboBox1->removeItem(0); + int i = 0; + // Solving PAL5590 + if ( myShape.ShapeType() == TopAbs_COMPOUND ) { + unsigned int nb = NumberOfSubShapes(myShape, TopAbs_COMPOUND); + if (nb > 0) i++; - } + } + while ( i <= myShape.ShapeType()) + { + GroupPoints->ComboBox1->removeItem( 0 ); + i++; + } - if(myShape.ShapeType()==TopAbs_COMPOUND) { - if(myWithShape == false) { - GroupPoints->ComboBox1->insertItem("Shape"); - myWithShape = true; - } + if ( myShape.ShapeType() == TopAbs_COMPOUND ) + { + if ( myWithShape == false ) + { + GroupPoints->ComboBox1->insertItem( "Shape" ); + myWithShape = true; } - else { - if(myWithShape == true) { - GroupPoints->ComboBox1->removeItem(GroupPoints->ComboBox1->count() - 1); - myWithShape = false; - } + } + else + { + if ( myWithShape == true ) + { + GroupPoints->ComboBox1->removeItem( GroupPoints->ComboBox1->count() - 1 ); + myWithShape = false; } - - int count1 = GroupPoints->ComboBox1->count(); - if(myWithShape) - count1 = count1 - 1; - - if(SelectedShapeType > myShape.ShapeType()) { - if(SelectedShapeType == 8) { - if(myShape.ShapeType() != TopAbs_COMPOUND) { - GroupPoints->ComboBox1->setCurrentItem(0); - myShapeType = 8 - count1; - } - } - else { - GroupPoints->ComboBox1->setCurrentItem(count1 - count + SelectedShapeType); - myShapeType = 8 - count1 + GroupPoints->ComboBox1->currentItem(); + } + + int count1 = GroupPoints->ComboBox1->count(); + if ( myWithShape ) + count1 = count1 - 1; + + if ( SelectedShapeType > myShape.ShapeType() ) + { + if ( SelectedShapeType == 8 ) + { + if ( myShape.ShapeType() != TopAbs_COMPOUND ) + { + GroupPoints->ComboBox1->setCurrentItem( 0 ); + ComboTextChanged(); } - } - else { - GroupPoints->ComboBox1->setCurrentItem(0); - myShapeType = 8 - count1; - } + } + else + GroupPoints->ComboBox1->setCurrentItem(count1 - count + SelectedShapeType); + } + else + { + GroupPoints->ComboBox1->setCurrentItem( 0 ); + ComboTextChanged(); } - return; + + updateButtonState(); } @@ -332,15 +288,12 @@ void EntityGUI_SubShapeDlg::SelectionIntoArgument() //================================================================================= void EntityGUI_SubShapeDlg::SetEditCurrentArgument() { - QPushButton* send = (QPushButton*)sender(); - - if(send == GroupPoints->PushButton1) { - GroupPoints->LineEdit1->setFocus(); - myEditCurrentArgument = GroupPoints->LineEdit1; - } - this->SelectionIntoArgument(); - - return; + GroupPoints->LineEdit1->setFocus(); + myEditCurrentArgument = GroupPoints->LineEdit1; + + GroupPoints->CheckButton1->setChecked( FALSE ); + SubShapeToggled(); + SelectionIntoArgument(); } @@ -352,12 +305,11 @@ void EntityGUI_SubShapeDlg::LineEditReturnPressed() { QLineEdit* send = (QLineEdit*)sender(); if(send == GroupPoints->LineEdit1) - myEditCurrentArgument = GroupPoints->LineEdit1; + SetEditCurrentArgument(); else return; GEOMBase_Skeleton::LineEditReturnPressed(); - return; } @@ -368,10 +320,8 @@ void EntityGUI_SubShapeDlg::LineEditReturnPressed() void EntityGUI_SubShapeDlg::DeactivateActiveDialog() { if(GroupConstructors->isEnabled()) { - this->ResetStateOfDialog(); GEOMBase_Skeleton::DeactivateActiveDialog(); } - return; } @@ -383,11 +333,8 @@ void EntityGUI_SubShapeDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) - GroupPoints->CheckButton1->setEnabled(true); - else - GroupPoints->CheckButton1->setEnabled(false); - return; + SubShapeToggled(); + updateButtonState(); } @@ -399,37 +346,22 @@ void EntityGUI_SubShapeDlg::enterEvent(QEvent* e) { if(GroupConstructors->isEnabled()) return; - this->ActivateThisDialog(); - return; -} - - -//================================================================================= -// function : closeEvent() -// purpose : -//================================================================================= -void EntityGUI_SubShapeDlg::closeEvent(QCloseEvent* e) -{ - /* same than click on cancel button */ - this->ClickOnCancel(); - return; + ActivateThisDialog(); } - //================================================================================= // function : ResetStateOfDialog() // purpose : Completely reset the state of method including local context //================================================================================= void EntityGUI_SubShapeDlg::ResetStateOfDialog() { - if(myAbort == true) { - myOkShape = false; - myEditCurrentArgument->setText(""); - } + myObject = GEOM::GEOM_Object::_nil(); + myShape.Nullify(); + myEditCurrentArgument->setText(""); int SelectedShapeType = GroupPoints->ComboBox1->currentItem(); int count = GroupPoints->ComboBox1->count(); - if(myWithShape) + if ( myWithShape ) count = count - 1; /* type for sub shape selection */ @@ -443,130 +375,210 @@ void EntityGUI_SubShapeDlg::ResetStateOfDialog() GroupPoints->ComboBox1->insertItem("Edge"); GroupPoints->ComboBox1->insertItem("Vertex"); GroupPoints->ComboBox1->insertItem("Shape"); - myWithShape=true; - GroupPoints->ComboBox1->setCurrentItem(8 - count + SelectedShapeType); - myOkSelectSubMode = false; - - /* unpress buttons : due to abort box*/ - buttonApply->setDown(FALSE); - buttonOk->setDown(FALSE); - GroupPoints->CheckButton1->setChecked(FALSE); - - /* Close its local contact if opened */ - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - myIC = v3d->getAISContext(); - if(myUseLocalContext) { - myIC->CloseLocalContext(myLocalContextId); - myUseLocalContext = false; - } - DisplayGUI* myDisplayGUI = new DisplayGUI(); - myDisplayGUI->OnDisplayAll(true); - } - return; + + myWithShape = true; + + GroupPoints->ComboBox1->setCurrentItem( 8 - count + SelectedShapeType ); + ComboTextChanged(); + + updateButtonState(); } //================================================================================= -// function : AllOrNotAll() +// function : SubShapeToggled() // purpose : Allow user selection of all or only selected sub shapes // : Called when 'CheckButton1' state change //================================================================================= -void EntityGUI_SubShapeDlg::AllOrNotAll() +void EntityGUI_SubShapeDlg::SubShapeToggled() { - /* No sub shape selection if main shape not selected */ - if(!myOkShape) { - this->ResetStateOfDialog(); - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_SELECT_FIRST")); - return; - } - - if(myShapeType ==TopAbs_SHAPE && myShape.ShapeType()==TopAbs_COMPOUND) { - /* Select sub shapes mode not checked */ - myOkSelectSubMode = false; - GroupPoints->CheckButton1->setChecked( FALSE ); - //no meaning to allow user selection for type = shape - //TODO - add another message - //QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_SELECT_FIRST")) ; - return; - } + if ( isAllSubShapes() ) + globalSelection( GEOM_ALLSHAPES ); + else + localSelection( myObject, shapeType() ); +} - myOkSelectSubMode = GroupPoints->CheckButton1->isChecked(); - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - myIC = v3d->getAISContext(); +//================================================================================= +// function : ComboTextChanged() +// purpose : +//================================================================================= +void EntityGUI_SubShapeDlg::ComboTextChanged() +{ + /* Select sub shapes mode not checked */ + updateButtonState(); + SubShapeToggled(); +} + - if(myUseLocalContext) { - myIC->CloseLocalContext(myLocalContextId); - myUseLocalContext = false; +//================================================================================= +// function : NumberOfSubShapes() +// purpose : +//================================================================================= +unsigned int EntityGUI_SubShapeDlg::NumberOfSubShapes (const TopoDS_Shape& S, + const int shapeType) const +{ + if (S.IsNull()) + return 0; + + unsigned int index = 0; + TopTools_MapOfShape M; + + if (S.ShapeType() == TopAbs_COMPOUND && + (TopAbs_ShapeEnum(shapeType) == TopAbs_SHAPE || + TopAbs_ShapeEnum(shapeType) == TopAbs_COMPSOLID || + TopAbs_ShapeEnum(shapeType) == TopAbs_COMPOUND)) { + TopoDS_Iterator It (S, Standard_True, Standard_True); + for (; It.More(); It.Next()) { + if (M.Add(It.Value())) { + if (TopAbs_ShapeEnum(shapeType) == TopAbs_SHAPE || + TopAbs_ShapeEnum(shapeType) == It.Value().ShapeType()) { + index++; + } + } + } + } else { + TopExp_Explorer Exp (S, TopAbs_ShapeEnum(shapeType)); + for (; Exp.More(); Exp.Next()) { + if (M.Add(Exp.Current())) { + index++; + } } - DisplayGUI* myDisplayGUI = new DisplayGUI(); - myDisplayGUI->OnDisplayAll(true); - } - else { - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_NOT_FOR_VTK_VIEWER")); - return; } - if(myOkShape && myOkSelectSubMode) { - /* local context is defined into the method */ - DisplayGUI* myDisplayGUI = new DisplayGUI(); - myDisplayGUI->PrepareSubShapeSelection(myShapeType, myLocalContextId); - myUseLocalContext = true; - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_SELECT_FACE")); + M.Clear(); + return index; +} + +//================================================================================= +// function : updateButtonState +// purpose : +//================================================================================= +void EntityGUI_SubShapeDlg::updateButtonState() +{ + if ( QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_OCC || + myObject->_is_nil() || shapeType() == TopAbs_SHAPE || shapeType() == TopAbs_COMPOUND ) { + GroupPoints->CheckButton1->setChecked( FALSE ); + GroupPoints->CheckButton1->setEnabled( FALSE ); } - return; + else + GroupPoints->CheckButton1->setEnabled( TRUE ); } +//================================================================================= +// function : isAllSubShapes +// purpose : +//================================================================================= +bool EntityGUI_SubShapeDlg::isAllSubShapes() const +{ + return !GroupPoints->CheckButton1->isChecked() || !GroupPoints->CheckButton1->isEnabled(); +} //================================================================================= -// function : ComboTextChanged() -// purpose : +// function : shapeType +// purpose : //================================================================================= -void EntityGUI_SubShapeDlg::ComboTextChanged() +int EntityGUI_SubShapeDlg::shapeType() const { - if(myOkShape) - myShapeType = GroupPoints->ComboBox1->currentItem() + myShape.ShapeType() + 1; - else - myShapeType = GroupPoints->ComboBox1->currentItem(); + int type = GroupPoints->ComboBox1->currentItem(); - /* Select sub shapes mode not checked */ - GroupPoints->CheckButton1->setChecked(FALSE); - myOkSelectSubMode = FALSE; + if (myObject->_is_nil()) + return type; - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - myIC = v3d->getAISContext(); + // Solving PAL5590 + type += myShape.ShapeType() + 1; + if (myShape.ShapeType() == TopAbs_COMPOUND && + NumberOfSubShapes(myShape, TopAbs_COMPOUND) > 0) { + type--; + } + + return type; +} + +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr EntityGUI_SubShapeDlg::createOperation() +{ + return getGeomEngine()->GetIShapesOperations( getStudyId() ); +} - if(myUseLocalContext) { - myIC->CloseLocalContext(myLocalContextId); - myUseLocalContext = false; +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool EntityGUI_SubShapeDlg::isValid( QString& msg ) +{ + bool isOk = false; + if ( !myObject->_is_nil() ) { + if ( isAllSubShapes() ) + isOk = true; + else if ( mySelection->IObjectCount() == 1 ) { + Standard_Boolean aResult = Standard_False; + GEOM::GEOM_Object_var anObj = + GEOMBase::ConvertIOinGEOMObject( mySelection->firstIObject(), aResult ); + + if ( aResult && !anObj->_is_nil() ) { + TColStd_IndexedMapOfInteger aMapIndex; + mySelection->GetIndex( mySelection->firstIObject(), aMapIndex ); + isOk = aMapIndex.Extent() > 0; + if ( !isOk ) + msg += tr( "NO_SUBSHAPES_SELECTED" ); + } } - DisplayGUI* myDisplayGUI = new DisplayGUI(); - myDisplayGUI->OnDisplayAll(true); } - return; + return isOk; } - //================================================================================= -// function : NumberOfSubShapes() +// function : execute // purpose : //================================================================================= -unsigned int EntityGUI_SubShapeDlg::NumberOfSubShapes(const TopoDS_Shape& S, const int shapeType) +bool EntityGUI_SubShapeDlg::execute( ObjectList& objects ) { - if(S.IsNull()) - return 0; + GEOM::ListOfGO_var aList = GEOM::GEOM_IShapesOperations::_narrow( + getOperation() )->MakeExplode( myObject, shapeType(), false ); + + if ( !aList->length() ) + return false; - unsigned int index = 0; - TopExp_Explorer Exp(S, TopAbs_ShapeEnum(shapeType)); - TopTools_MapOfShape M; - while(Exp.More()) { - if(M.Add(Exp.Current())) - index++; - Exp.Next(); + // Throw away sub-shapes not selected by user if not in preview mode + // and manual selection is active + if ( !isAllSubShapes() ) + { + if ( mySelection->IObjectCount() == 1 ) { + Standard_Boolean aResult = Standard_False; + GEOM::GEOM_Object_var anObj = + GEOMBase::ConvertIOinGEOMObject( mySelection->firstIObject(), aResult ); + + if ( aResult && !anObj->_is_nil() ) { + TColStd_IndexedMapOfInteger aMapIndex; + mySelection->GetIndex( mySelection->firstIObject(), aMapIndex ); + + GEOM::GEOM_ILocalOperations_var aLocOp = + getGeomEngine()->GetILocalOperations( getStudyId() ); + + for ( int i = 0, n = aList->length(); i < n; i++ ) + if ( aMapIndex.Contains( aLocOp->GetSubShapeIndex( myObject, aList[i] ) ) ) + objects.push_back( GEOM::GEOM_Object::_duplicate( aList[i] ) ); + } + } } - M.Clear(); - return index; + else + for ( int i = 0, n = aList->length(); i < n; i++ ) + objects.push_back( GEOM::GEOM_Object::_duplicate( aList[i] ) ); + + return objects.size(); } + +//================================================================ +// Function : getFather +// Purpose : Get father object for object to be added in study +// ( called with addInStudy method ) +//================================================================ +GEOM::GEOM_Object_ptr EntityGUI_SubShapeDlg::getFather( GEOM::GEOM_Object_ptr ) +{ + return myObject; +} + diff --git a/src/EntityGUI/EntityGUI_SubShapeDlg.h b/src/EntityGUI/EntityGUI_SubShapeDlg.h index cd85ce051..3baba6c6c 100644 --- a/src/EntityGUI/EntityGUI_SubShapeDlg.h +++ b/src/EntityGUI/EntityGUI_SubShapeDlg.h @@ -32,7 +32,6 @@ #include "GEOMBase_Skeleton.h" #include "DlgRef_1Sel1Check1List_QTD.h" -#include "EntityGUI.h" //================================================================================= // class : EntityGUI_SubShapeDlg @@ -43,47 +42,52 @@ class EntityGUI_SubShapeDlg : public GEOMBase_Skeleton Q_OBJECT public: - EntityGUI_SubShapeDlg(QWidget* parent = 0, const char* name = 0, EntityGUI* theEntityGUI = 0, SALOME_Selection* Sel = 0, Handle(AIS_InteractiveContext) ic = 0, bool modal = FALSE, WFlags fl = 0); - ~EntityGUI_SubShapeDlg(); + EntityGUI_SubShapeDlg( QWidget* parent = 0, + const char* name = 0, + SALOME_Selection* Sel = 0, + bool modal = FALSE, + WFlags fl = 0 ); + ~EntityGUI_SubShapeDlg(); -private : - void Init(Handle(AIS_InteractiveContext) ic); - void enterEvent(QEvent* e); - void closeEvent(QCloseEvent* e); +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 ); - void ResetStateOfDialog(); - unsigned int NumberOfSubShapes(const TopoDS_Shape& S, const int shapeType); +private slots: + void ClickOnOk(); + bool ClickOnApply(); + void ActivateThisDialog(); + void DeactivateActiveDialog(); + void LineEditReturnPressed(); + void SelectionIntoArgument(); + void SetEditCurrentArgument(); + void SubShapeToggled(); + void ComboTextChanged(); - EntityGUI* myEntityGUI; +private : + void Init(); + void enterEvent( QEvent* e ); - /* Interactive and local context management see also : bool myUseLocalContext() */ - Handle(AIS_InteractiveContext) myIC; /* Interactive context */ - Standard_Integer myLocalContextId; /* identify a local context used by this method */ - bool myUseLocalContext; /* true when this method as opened a local context */ + void ResetStateOfDialog(); + unsigned int NumberOfSubShapes (const TopoDS_Shape& S, + const int shapeType) const; - TopoDS_Shape myShape; - bool myOkShape; - char* myShapeIOR; - int myShapeType; + void updateButtonState(); + bool isAllSubShapes() const; + int shapeType() const; - bool myWithShape; /* check if Shape item exists */ - bool myOkSelectSubMode; /* true = sub mode selection activated */ - bool myAbort; /* Indicate if sub Shape All has been aborted by user */ - - DlgRef_1Sel1Check1List_QTD* GroupPoints; +private: -private slots: - void ClickOnOk(); - void ClickOnApply(); - void ClickOnCancel(); - void ActivateThisDialog(); - void DeactivateActiveDialog(); - void LineEditReturnPressed(); - void SelectionIntoArgument(); - void SetEditCurrentArgument(); - void AllOrNotAll(); - void ComboTextChanged(); + TopoDS_Shape myShape; + GEOM::GEOM_Object_var myObject; + bool myWithShape; + + DlgRef_1Sel1Check1List_QTD* GroupPoints; + ObjectList myResult; }; #endif // DIALOGBOX_SUBSHAPE_H diff --git a/src/EntityGUI/Makefile.in b/src/EntityGUI/Makefile.in index 2f22e88c2..2fd741ec5 100644 --- a/src/EntityGUI/Makefile.in +++ b/src/EntityGUI/Makefile.in @@ -58,7 +58,6 @@ LIB_SRC = EntityGUI.cxx \ EntityGUI_SubShapeDlg.cxx LIB_MOC = \ - EntityGUI.h \ EntityGUI_Skeleton_QTD.h \ EntityGUI_Point_QTD.h \ EntityGUI_Dir1_QTD.h \ @@ -75,15 +74,15 @@ LIB_MOC = \ EntityGUI_SketcherDlg.h \ EntityGUI_SubShapeDlg.h -LIB_CLIENT_IDL = +LIB_CLIENT_IDL = SALOME_GenericObj.idl SALOME_Component.idl -LIB_SERVER_IDL = +LIB_SERVER_IDL = # additionnal information to compil and link file CPPFLAGS += $(QT_INCLUDES) $(OCC_INCLUDES) $(VTK_INCLUDES) $(PYTHON_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome CXXFLAGS += -I${KERNEL_ROOT_DIR}/include/salome -LDFLAGS += -lGEOMFiltersSelection -lDisplayGUI -lGEOMSketcher +LDFLAGS += -lGEOMFiltersSelection -lGEOMSketcher -lGEOMBase -lGEOMGUI @CONCLUDE@ diff --git a/src/EntityGUI/UIFiles/EntityGUI_1Sel_QTD.ui b/src/EntityGUI/UIFiles/EntityGUI_1Sel_QTD.ui new file mode 100644 index 000000000..c88df1ae6 --- /dev/null +++ b/src/EntityGUI/UIFiles/EntityGUI_1Sel_QTD.ui @@ -0,0 +1,218 @@ + +EntityGUI_1Sel_QTD + + + EntityGUI_1Sel_QTD + + + + 0 + 0 + 329 + 112 + + + + EntityGUI_1Sel_QTD + + + + unnamed + + + 0 + + + 6 + + + + GroupBox1 + + + Values + + + + unnamed + + + 11 + + + 6 + + + + Layout4 + + + + unnamed + + + 0 + + + 6 + + + + Layout3 + + + + unnamed + + + 0 + + + 6 + + + + Spacer5 + + + Vertical + + + Expanding + + + + 0 + 163 + + + + + + buttonApply + + + Create + + + + + Layout2 + + + + unnamed + + + 0 + + + 6 + + + + buttonRedo + + + Redo + + + + + buttonUndo + + + Undo + + + + + + + + + Layout1 + + + + unnamed + + + 0 + + + 6 + + + + TextLabel1 + + + + 0 + 0 + 0 + 0 + + + + TL1 + + + + + Spacer1 + + + Vertical + + + Expanding + + + + 0 + 180 + + + + + + PushButton1 + + + + 0 + 0 + 0 + 0 + + + + + + + + + LineEdit1 + + + + 3 + 0 + 0 + 0 + + + + + + + + + + + + + + diff --git a/src/EntityGUI/UIFiles/EntityGUI_1Spin_QTD.ui b/src/EntityGUI/UIFiles/EntityGUI_1Spin_QTD.ui new file mode 100644 index 000000000..e1d0a7151 --- /dev/null +++ b/src/EntityGUI/UIFiles/EntityGUI_1Spin_QTD.ui @@ -0,0 +1,201 @@ + +EntityGUI_1Spin_QTD + + + EntityGUI_1Spin_QTD + + + + 0 + 0 + 255 + 112 + + + + EntityGUI_1Spin_QTD + + + + unnamed + + + 0 + + + 6 + + + + GroupBox1 + + + Values + + + + unnamed + + + 11 + + + 6 + + + + Layout4 + + + + unnamed + + + 0 + + + 6 + + + + Layout1 + + + + unnamed + + + 0 + + + 6 + + + + TextLabel1 + + + + 0 + 0 + 0 + 0 + + + + TL1 + + + + + SpinBox1 + + + + 7 + 0 + 0 + 0 + + + + + + Spacer1 + + + Vertical + + + Expanding + + + + 0 + 82 + + + + + + + + Layout3 + + + + unnamed + + + 0 + + + 6 + + + + Layout2 + + + + unnamed + + + 0 + + + 6 + + + + buttonRedo + + + Redo + + + + + buttonUndo + + + Undo + + + + + + + buttonApply + + + Create + + + + + Spacer5 + + + Vertical + + + Expanding + + + + 0 + 40 + + + + + + + + + + + + + diff --git a/src/EntityGUI/UIFiles/EntityGUI_2Spin_QTD.ui b/src/EntityGUI/UIFiles/EntityGUI_2Spin_QTD.ui new file mode 100644 index 000000000..938383c07 --- /dev/null +++ b/src/EntityGUI/UIFiles/EntityGUI_2Spin_QTD.ui @@ -0,0 +1,230 @@ + +EntityGUI_2Spin_QTD + + + EntityGUI_2Spin_QTD + + + + 0 + 0 + 255 + 112 + + + + EntityGUI_2Spin_QTD + + + + unnamed + + + 0 + + + 6 + + + + GroupBox1 + + + Values + + + + unnamed + + + 11 + + + 6 + + + + Layout4 + + + + unnamed + + + 0 + + + 6 + + + + Layout1 + + + + unnamed + + + 0 + + + 6 + + + + TextLabel2 + + + + 0 + 0 + 0 + 0 + + + + TL2 + + + + + TextLabel1 + + + + 0 + 0 + 0 + 0 + + + + TL1 + + + + + SpinBox1 + + + + 7 + 0 + 0 + 0 + + + + + + SpinBox2 + + + + 7 + 0 + 0 + 0 + + + + + + Spacer1 + + + Vertical + + + Expanding + + + + 0 + 82 + + + + + + + + Layout3 + + + + unnamed + + + 0 + + + 6 + + + + Spacer5 + + + Vertical + + + Expanding + + + + 0 + 51 + + + + + + Layout2 + + + + unnamed + + + 0 + + + 6 + + + + buttonUndo + + + Undo + + + + + buttonRedo + + + Redo + + + + + + + buttonApply + + + Create + + + + + + + + + + + + diff --git a/src/EntityGUI/UIFiles/EntityGUI_3Spin_QTD.ui b/src/EntityGUI/UIFiles/EntityGUI_3Spin_QTD.ui new file mode 100644 index 000000000..c094d5791 --- /dev/null +++ b/src/EntityGUI/UIFiles/EntityGUI_3Spin_QTD.ui @@ -0,0 +1,259 @@ + +EntityGUI_3Spin_QTD + + + EntityGUI_3Spin_QTD + + + + 0 + 0 + 255 + 125 + + + + EntityGUI_3Spin_QTD + + + + unnamed + + + 0 + + + 6 + + + + GroupBox1 + + + Values + + + + unnamed + + + 11 + + + 6 + + + + Layout4 + + + + unnamed + + + 0 + + + 6 + + + + Layout3 + + + + unnamed + + + 0 + + + 6 + + + + buttonApply + + + Create + + + + + Spacer5 + + + Vertical + + + Expanding + + + + 0 + 121 + + + + + + Layout2 + + + + unnamed + + + 0 + + + 6 + + + + buttonUndo + + + Undo + + + + + buttonRedo + + + Redo + + + + + + + + + Layout1 + + + + unnamed + + + 0 + + + 6 + + + + TextLabel2 + + + + 0 + 0 + 0 + 0 + + + + TL2 + + + + + TextLabel1 + + + + 0 + 0 + 0 + 0 + + + + TL1 + + + + + SpinBox1 + + + + 7 + 0 + 0 + 0 + + + + + + SpinBox2 + + + + 7 + 0 + 0 + 0 + + + + + + TextLabel3 + + + + 0 + 0 + 0 + 0 + + + + TL3 + + + + + Spacer1 + + + Vertical + + + Expanding + + + + 0 + 82 + + + + + + SpinBox3 + + + + 7 + 0 + 0 + 0 + + + + + + + + + + + + + diff --git a/src/EntityGUI/UIFiles/EntityGUI_4Spin_QTD.ui b/src/EntityGUI/UIFiles/EntityGUI_4Spin_QTD.ui new file mode 100644 index 000000000..956ce0d1b --- /dev/null +++ b/src/EntityGUI/UIFiles/EntityGUI_4Spin_QTD.ui @@ -0,0 +1,288 @@ + +EntityGUI_4Spin_QTD + + + EntityGUI_4Spin_QTD + + + + 0 + 0 + 255 + 154 + + + + EntityGUI_4Spin_QTD + + + + unnamed + + + 0 + + + 6 + + + + GroupBox1 + + + Values + + + + unnamed + + + 11 + + + 6 + + + + Layout4 + + + + unnamed + + + 0 + + + 6 + + + + Layout3 + + + + unnamed + + + 0 + + + 6 + + + + Layout2 + + + + unnamed + + + 0 + + + 6 + + + + buttonRedo + + + Redo + + + + + buttonUndo + + + Undo + + + + + + + Spacer5 + + + Vertical + + + Expanding + + + + 0 + 45 + + + + + + buttonApply + + + Create + + + + + + + Layout1 + + + + unnamed + + + 0 + + + 6 + + + + SpinBox3 + + + + 7 + 0 + 0 + 0 + + + + + + SpinBox2 + + + + 7 + 0 + 0 + 0 + + + + + + TextLabel2 + + + + 0 + 0 + 0 + 0 + + + + TL2 + + + + + Spacer1 + + + Vertical + + + Expanding + + + + 0 + 70 + + + + + + SpinBox4 + + + + 7 + 0 + 0 + 0 + + + + + + TextLabel3 + + + + 0 + 0 + 0 + 0 + + + + TL3 + + + + + SpinBox1 + + + + 7 + 0 + 0 + 0 + + + + + + TextLabel1 + + + + 0 + 0 + 0 + 0 + + + + TL1 + + + + + TextLabel4 + + + + 0 + 0 + 0 + 0 + + + + TL4 + + + + + + + + + + + + diff --git a/src/EntityGUI/UIFiles/EntityGUI_Dir1_QTD.ui b/src/EntityGUI/UIFiles/EntityGUI_Dir1_QTD.ui new file mode 100644 index 000000000..59f644641 --- /dev/null +++ b/src/EntityGUI/UIFiles/EntityGUI_Dir1_QTD.ui @@ -0,0 +1,112 @@ + +EntityGUI_Dir1_QTD + + + EntityGUI_Dir1_QTD + + + + 0 + 0 + 131 + 123 + + + + EntityGUI_Dir1_QTD + + + + unnamed + + + 0 + + + 6 + + + + GroupDir1 + + + + 7 + 0 + 0 + 0 + + + + Direction + + + + unnamed + + + 11 + + + 6 + + + + Layout1 + + + + unnamed + + + 0 + + + 6 + + + + RB_Dir12 + + + Perpendicular + + + + + RB_Dir13 + + + Tangent + + + + + RB_Dir11 + + + Angle + + + + + RB_Dir14 + + + VX-VY + + + + + + + + + + RB_Dir11 + RB_Dir12 + RB_Dir13 + RB_Dir14 + + + diff --git a/src/EntityGUI/UIFiles/EntityGUI_Dir2_QTD.ui b/src/EntityGUI/UIFiles/EntityGUI_Dir2_QTD.ui new file mode 100644 index 000000000..617d3c3f6 --- /dev/null +++ b/src/EntityGUI/UIFiles/EntityGUI_Dir2_QTD.ui @@ -0,0 +1,120 @@ + +EntityGUI_Dir2_QTD + + + EntityGUI_Dir2_QTD + + + + 0 + 0 + 124 + 106 + + + + EntityGUI_Dir2_QTD + + + + unnamed + + + 0 + + + 6 + + + + GroupDir2 + + + + 7 + 7 + 0 + 0 + + + + Direction + + + + unnamed + + + 11 + + + 6 + + + + Layout1 + + + + unnamed + + + 0 + + + 6 + + + + RB_Dir22 + + + X + + + + + RB_Dir23 + + + Y + + + + + Spacer4 + + + Vertical + + + Expanding + + + + 0 + 20 + + + + + + RB_Dir21 + + + Length + + + + + + + + + + RB_Dir21 + RB_Dir22 + RB_Dir23 + + + diff --git a/src/EntityGUI/UIFiles/EntityGUI_Point_QTD.ui b/src/EntityGUI/UIFiles/EntityGUI_Point_QTD.ui new file mode 100644 index 000000000..8e0bd22ad --- /dev/null +++ b/src/EntityGUI/UIFiles/EntityGUI_Point_QTD.ui @@ -0,0 +1,103 @@ + +EntityGUI_Point_QTD + + + EntityGUI_Point_QTD + + + + 0 + 0 + 124 + 106 + + + + EntityGUI_Point_QTD + + + + unnamed + + + 0 + + + 6 + + + + GroupPoint + + + + 7 + 0 + 0 + 0 + + + + Point + + + + unnamed + + + 11 + + + 6 + + + + Layout1 + + + + unnamed + + + 0 + + + 6 + + + + RB_Point2 + + + Relative + + + + + RB_Point1 + + + Absolute + + + + + RB_Point3 + + + Selection + + + + + + + + + + RB_Point1 + RB_Point2 + RB_Point3 + + + diff --git a/src/EntityGUI/UIFiles/EntityGUI_Skeleton_QTD.ui b/src/EntityGUI/UIFiles/EntityGUI_Skeleton_QTD.ui new file mode 100644 index 000000000..1a27ca107 --- /dev/null +++ b/src/EntityGUI/UIFiles/EntityGUI_Skeleton_QTD.ui @@ -0,0 +1,379 @@ + +EntityGUI_Skeleton_QTD + + + EntityGUI_Skeleton_QTD + + + + 0 + 0 + 317 + 276 + + + + + 5 + 7 + 0 + 0 + + + + EntityGUI_Skeleton_QTD + + + + unnamed + + + 11 + + + 6 + + + + Layout1 + + + + unnamed + + + 0 + + + 6 + + + + GroupVal + + + + 7 + 7 + 0 + 0 + + + + + + + + + GroupConstructors + + + + 5 + 0 + 0 + 0 + + + + Element Type + + + + unnamed + + + 11 + + + 6 + + + + Layout2 + + + + unnamed + + + 0 + + + 6 + + + + RadioButton1 + + + Segment + + + + + RadioButton2 + + + Arc + + + + + + + + + GroupDest + + + + 7 + 0 + 0 + 0 + + + + Destination + + + + unnamed + + + 11 + + + 6 + + + + Layout5 + + + + unnamed + + + 0 + + + 6 + + + + GroupDest1 + + + + 7 + 0 + 0 + 0 + + + + Type + + + + unnamed + + + 11 + + + 6 + + + + Layout4 + + + + unnamed + + + 0 + + + 6 + + + + RB_Dest2 + + + Direction + + + + + RB_Dest1 + + + Point + + + + + + + + + GroupDest2 + + + + 7 + 7 + 0 + 0 + + + + + + + + unnamed + + + 11 + + + 6 + + + + + + GroupDest3 + + + + 7 + 7 + 0 + 0 + + + + + + + + unnamed + + + 11 + + + 6 + + + + + + + + + + GroupButtons + + + + 7 + 0 + 0 + 0 + + + + + + + + unnamed + + + 11 + + + 6 + + + + Layout3 + + + + unnamed + + + 0 + + + 6 + + + + buttonEnd + + + End Sketch + + + + + buttonClose + + + Close Sketch + + + + + Spacer1 + + + Horizontal + + + Expanding + + + + 91 + 0 + + + + + + buttonCancel + + + &Cancel + + + + + + + + + + + + RadioButton1 + RadioButton2 + RB_Dest1 + RB_Dest2 + buttonEnd + buttonClose + buttonCancel + + + diff --git a/src/EntityGUI/UIFiles/ui_to_cxx b/src/EntityGUI/UIFiles/ui_to_cxx new file mode 100755 index 000000000..e370f446a --- /dev/null +++ b/src/EntityGUI/UIFiles/ui_to_cxx @@ -0,0 +1,28 @@ +#!/bin/sh + +uic -o EntityGUI_Skeleton_QTD.h EntityGUI_Skeleton_QTD.ui +uic -o EntityGUI_Skeleton_QTD.cxx -impl EntityGUI_Skeleton_QTD.h EntityGUI_Skeleton_QTD.ui + +uic -o EntityGUI_Point_QTD.h EntityGUI_Point_QTD.ui +uic -o EntityGUI_Point_QTD.cxx -impl EntityGUI_Point_QTD.h EntityGUI_Point_QTD.ui + +uic -o EntityGUI_Dir1_QTD.h EntityGUI_Dir1_QTD.ui +uic -o EntityGUI_Dir1_QTD.cxx -impl EntityGUI_Dir1_QTD.h EntityGUI_Dir1_QTD.ui + +uic -o EntityGUI_Dir2_QTD.h EntityGUI_Dir2_QTD.ui +uic -o EntityGUI_Dir2_QTD.cxx -impl EntityGUI_Dir2_QTD.h EntityGUI_Dir2_QTD.ui + +uic -o EntityGUI_1Spin_QTD.h EntityGUI_1Spin_QTD.ui +uic -o EntityGUI_1Spin_QTD.cxx -impl EntityGUI_1Spin_QTD.h EntityGUI_1Spin_QTD.ui + +uic -o EntityGUI_2Spin_QTD.h EntityGUI_2Spin_QTD.ui +uic -o EntityGUI_2Spin_QTD.cxx -impl EntityGUI_2Spin_QTD.h EntityGUI_2Spin_QTD.ui + +uic -o EntityGUI_3Spin_QTD.h EntityGUI_3Spin_QTD.ui +uic -o EntityGUI_3Spin_QTD.cxx -impl EntityGUI_3Spin_QTD.h EntityGUI_3Spin_QTD.ui + +uic -o EntityGUI_4Spin_QTD.h EntityGUI_4Spin_QTD.ui +uic -o EntityGUI_4Spin_QTD.cxx -impl EntityGUI_4Spin_QTD.h EntityGUI_4Spin_QTD.ui + +uic -o EntityGUI_1Sel_QTD.h EntityGUI_1Sel_QTD.ui +uic -o EntityGUI_1Sel_QTD.cxx -impl EntityGUI_1Sel_QTD.h EntityGUI_1Sel_QTD.ui diff --git a/src/GEOM/GEOM_Application.cxx b/src/GEOM/GEOM_Application.cxx new file mode 100644 index 000000000..24a3f1899 --- /dev/null +++ b/src/GEOM/GEOM_Application.cxx @@ -0,0 +1,39 @@ + +using namespace std; +#include "GEOM_Application.ixx" + +//======================================================================= +//function : GEOM_Application +//purpose : +//======================================================================= + +GEOM_Application::GEOM_Application() +{ +} + + +//======================================================================= +//function : Formats +//purpose : +//======================================================================= + +void GEOM_Application::Formats(TColStd_SequenceOfExtendedString& Formats) +{ + Formats.Append(TCollection_ExtendedString ("SALOME_GEOM")); +} + + +//======================================================================= +//function : ResourcesName +//purpose : +//======================================================================= + +Standard_CString GEOM_Application::ResourcesName() +{ + return Standard_CString ("GEOMDS_Resources"); +} + + + + + diff --git a/src/GEOM/GEOM_Application.hxx b/src/GEOM/GEOM_Application.hxx new file mode 100644 index 000000000..cf866a881 --- /dev/null +++ b/src/GEOM/GEOM_Application.hxx @@ -0,0 +1,89 @@ +// File : GEOM_Application.hxx +// Module : GEOM + +#ifndef _GEOM_Application_HeaderFile +#define _GEOM_Application_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Handle_GEOM_Application_HeaderFile +#include +#endif + +#ifndef _TDocStd_Application_HeaderFile +#include +#endif +#ifndef _Standard_CString_HeaderFile +#include +#endif +class TColStd_SequenceOfExtendedString; + + +class GEOM_Application : public TDocStd_Application { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + // Methods PUBLIC + // +Standard_EXPORT GEOM_Application(); +Standard_EXPORT virtual void Formats(TColStd_SequenceOfExtendedString& Formats) ; +Standard_EXPORT Standard_CString ResourcesName() ; +Standard_EXPORT ~GEOM_Application(); + + + + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& GEOM_Application_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 + // + + +}; + + + + + +// other inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/GEOM/GEOM_Application.ixx b/src/GEOM/GEOM_Application.ixx new file mode 100644 index 000000000..77f5bf9fc --- /dev/null +++ b/src/GEOM/GEOM_Application.ixx @@ -0,0 +1,63 @@ +// File : GEOM_Application.ixx +// Module : GEOM + +#include "GEOM_Application.jxx" + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +GEOM_Application::~GEOM_Application() {} + + + +Standard_EXPORT Handle_Standard_Type& GEOM_Application_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TDocStd_Application); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TDocStd_Application); + static Handle_Standard_Type aType2 = STANDARD_TYPE(CDF_Application); + if ( aType2.IsNull()) aType2 = STANDARD_TYPE(CDF_Application); + static Handle_Standard_Type aType3 = STANDARD_TYPE(CDM_Application); + if ( aType3.IsNull()) aType3 = STANDARD_TYPE(CDM_Application); + static Handle_Standard_Type aType4 = STANDARD_TYPE(Standard_Transient); + if ( aType4.IsNull()) aType4 = STANDARD_TYPE(Standard_Transient); + + + static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,aType4,NULL}; + static Handle_Standard_Type _aType = new Standard_Type("GEOM_Application", + sizeof(GEOM_Application), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + +// DownCast method +// allow safe downcasting + + +const Handle(GEOM_Application) Handle(GEOM_Application)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOM_Application) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOM_Application))) { + _anOtherObject = Handle(GEOM_Application)((Handle(GEOM_Application)&)AnObject); + } + } + + return _anOtherObject ; +} + + +const Handle(Standard_Type)& GEOM_Application::DynamicType() const +{ + return STANDARD_TYPE(GEOM_Application) ; +} +Standard_Boolean GEOM_Application::IsKind(const Handle(Standard_Type)& AType) const +{ + return (STANDARD_TYPE(GEOM_Application) == AType || TDocStd_Application::IsKind(AType)); +} +Handle_GEOM_Application::~Handle_GEOM_Application() {} diff --git a/src/GEOM/GEOM_Application.jxx b/src/GEOM/GEOM_Application.jxx new file mode 100644 index 000000000..948f69196 --- /dev/null +++ b/src/GEOM/GEOM_Application.jxx @@ -0,0 +1,9 @@ +// File : GEOM_Application.jxx +// Module : GEOM + +#ifndef _TColStd_SequenceOfExtendedString_HeaderFile +#include +#endif +#ifndef _GEOM_Application_HeaderFile +#include "GEOM_Application.hxx" +#endif diff --git a/src/GEOM/GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient.hxx b/src/GEOM/GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient.hxx new file mode 100644 index 000000000..dc78bfb92 --- /dev/null +++ b/src/GEOM/GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient.hxx @@ -0,0 +1,86 @@ + +#ifndef _GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient_HeaderFile +#define _GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient_HeaderFile + +#ifndef _TCollection_BasicMapIterator_HeaderFile +#include +#endif +#ifndef _Handle_Standard_Transient_HeaderFile +#include +#endif +#ifndef _Handle_GEOM_DataMapNodeOfDataMapOfAsciiStringTransient_HeaderFile +#include +#endif +class Standard_NoSuchObject; +class TCollection_AsciiString; +class Standard_Transient; +class GEOM_DataMapOfAsciiStringTransient; +class GEOM_DataMapNodeOfDataMapOfAsciiStringTransient; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient : public TCollection_BasicMapIterator { + +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 GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient(); +Standard_EXPORT GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient(const GEOM_DataMapOfAsciiStringTransient& aMap); +Standard_EXPORT void Initialize(const GEOM_DataMapOfAsciiStringTransient& aMap) ; +Standard_EXPORT const TCollection_AsciiString& Key() const; +Standard_EXPORT const Handle_Standard_Transient& Value() const; + + + + + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // + + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/GEOM/GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient_0.cxx b/src/GEOM/GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient_0.cxx new file mode 100644 index 000000000..5ef372f1d --- /dev/null +++ b/src/GEOM/GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient_0.cxx @@ -0,0 +1,36 @@ + +#include + +#ifndef _Standard_NoSuchObject_HeaderFile +#include +#endif +#ifndef _TCollection_AsciiString_HeaderFile +#include +#endif +#ifndef _Standard_Transient_HeaderFile +#include +#endif +#ifndef _GEOM_DataMapOfAsciiStringTransient_HeaderFile +#include +#endif +#ifndef _GEOM_DataMapNodeOfDataMapOfAsciiStringTransient_HeaderFile +#include +#endif + + +#define TheKey TCollection_AsciiString +#define TheKey_hxx +#define TheItem Handle_Standard_Transient +#define TheItem_hxx +#define Hasher TCollection_AsciiString +#define Hasher_hxx +#define TCollection_DataMapNode GEOM_DataMapNodeOfDataMapOfAsciiStringTransient +#define TCollection_DataMapNode_hxx +#define TCollection_DataMapIterator GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient +#define TCollection_DataMapIterator_hxx +#define Handle_TCollection_DataMapNode Handle_GEOM_DataMapNodeOfDataMapOfAsciiStringTransient +#define TCollection_DataMapNode_Type_() GEOM_DataMapNodeOfDataMapOfAsciiStringTransient_Type_() +#define TCollection_DataMap GEOM_DataMapOfAsciiStringTransient +#define TCollection_DataMap_hxx +#include + diff --git a/src/GEOM/GEOM_DataMapNodeOfDataMapOfAsciiStringTransient.hxx b/src/GEOM/GEOM_DataMapNodeOfDataMapOfAsciiStringTransient.hxx new file mode 100644 index 000000000..fb095128d --- /dev/null +++ b/src/GEOM/GEOM_DataMapNodeOfDataMapOfAsciiStringTransient.hxx @@ -0,0 +1,123 @@ + +#ifndef _GEOM_DataMapNodeOfDataMapOfAsciiStringTransient_HeaderFile +#define _GEOM_DataMapNodeOfDataMapOfAsciiStringTransient_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Handle_GEOM_DataMapNodeOfDataMapOfAsciiStringTransient_HeaderFile +#include +#endif + +#ifndef _TCollection_AsciiString_HeaderFile +#include +#endif +#ifndef _Handle_Standard_Transient_HeaderFile +#include +#endif +#ifndef _TCollection_MapNode_HeaderFile +#include +#endif +#ifndef _TCollection_MapNodePtr_HeaderFile +#include +#endif +class Standard_Transient; +class TCollection_AsciiString; +class GEOM_DataMapOfAsciiStringTransient; +class GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient; + + +class GEOM_DataMapNodeOfDataMapOfAsciiStringTransient : 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 + // +GEOM_DataMapNodeOfDataMapOfAsciiStringTransient(const TCollection_AsciiString& K,const Handle(Standard_Transient)& I,const TCollection_MapNodePtr& n); + TCollection_AsciiString& Key() const; + Handle_Standard_Transient& Value() const; +Standard_EXPORT ~GEOM_DataMapNodeOfDataMapOfAsciiStringTransient(); + + + + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& GEOM_DataMapNodeOfDataMapOfAsciiStringTransient_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 + // +TCollection_AsciiString myKey; +Handle_Standard_Transient myValue; + + +}; + +#define TheKey TCollection_AsciiString +#define TheKey_hxx +#define TheItem Handle_Standard_Transient +#define TheItem_hxx +#define Hasher TCollection_AsciiString +#define Hasher_hxx +#define TCollection_DataMapNode GEOM_DataMapNodeOfDataMapOfAsciiStringTransient +#define TCollection_DataMapNode_hxx +#define TCollection_DataMapIterator GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient +#define TCollection_DataMapIterator_hxx +#define Handle_TCollection_DataMapNode Handle_GEOM_DataMapNodeOfDataMapOfAsciiStringTransient +#define TCollection_DataMapNode_Type_() GEOM_DataMapNodeOfDataMapOfAsciiStringTransient_Type_() +#define TCollection_DataMap GEOM_DataMapOfAsciiStringTransient +#define TCollection_DataMap_hxx + +#include + +#undef TheKey +#undef TheKey_hxx +#undef TheItem +#undef TheItem_hxx +#undef Hasher +#undef Hasher_hxx +#undef TCollection_DataMapNode +#undef TCollection_DataMapNode_hxx +#undef TCollection_DataMapIterator +#undef TCollection_DataMapIterator_hxx +#undef Handle_TCollection_DataMapNode +#undef TCollection_DataMapNode_Type_ +#undef TCollection_DataMap +#undef TCollection_DataMap_hxx + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/GEOM/GEOM_DataMapNodeOfDataMapOfAsciiStringTransient_0.cxx b/src/GEOM/GEOM_DataMapNodeOfDataMapOfAsciiStringTransient_0.cxx new file mode 100644 index 000000000..1836c2e0f --- /dev/null +++ b/src/GEOM/GEOM_DataMapNodeOfDataMapOfAsciiStringTransient_0.cxx @@ -0,0 +1,85 @@ + +#include + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _Standard_Transient_HeaderFile +#include +#endif +#ifndef _TCollection_AsciiString_HeaderFile +#include +#endif +#ifndef _GEOM_DataMapOfAsciiStringTransient_HeaderFile +#include +#endif +#ifndef _GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient_HeaderFile +#include +#endif +GEOM_DataMapNodeOfDataMapOfAsciiStringTransient::~GEOM_DataMapNodeOfDataMapOfAsciiStringTransient() {} + + + +Standard_EXPORT Handle_Standard_Type& GEOM_DataMapNodeOfDataMapOfAsciiStringTransient_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("GEOM_DataMapNodeOfDataMapOfAsciiStringTransient", + sizeof(GEOM_DataMapNodeOfDataMapOfAsciiStringTransient), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + + +// DownCast method +// allow safe downcasting +// +const Handle(GEOM_DataMapNodeOfDataMapOfAsciiStringTransient) Handle(GEOM_DataMapNodeOfDataMapOfAsciiStringTransient)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOM_DataMapNodeOfDataMapOfAsciiStringTransient) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOM_DataMapNodeOfDataMapOfAsciiStringTransient))) { + _anOtherObject = Handle(GEOM_DataMapNodeOfDataMapOfAsciiStringTransient)((Handle(GEOM_DataMapNodeOfDataMapOfAsciiStringTransient)&)AnObject); + } + } + + return _anOtherObject ; +} +const Handle(Standard_Type)& GEOM_DataMapNodeOfDataMapOfAsciiStringTransient::DynamicType() const +{ + return STANDARD_TYPE(GEOM_DataMapNodeOfDataMapOfAsciiStringTransient) ; +} +Standard_Boolean GEOM_DataMapNodeOfDataMapOfAsciiStringTransient::IsKind(const Handle(Standard_Type)& AType) const +{ + return (STANDARD_TYPE(GEOM_DataMapNodeOfDataMapOfAsciiStringTransient) == AType || TCollection_MapNode::IsKind(AType)); +} +Handle_GEOM_DataMapNodeOfDataMapOfAsciiStringTransient::~Handle_GEOM_DataMapNodeOfDataMapOfAsciiStringTransient() {} +#define TheKey TCollection_AsciiString +#define TheKey_hxx +#define TheItem Handle_Standard_Transient +#define TheItem_hxx +#define Hasher TCollection_AsciiString +#define Hasher_hxx +#define TCollection_DataMapNode GEOM_DataMapNodeOfDataMapOfAsciiStringTransient +#define TCollection_DataMapNode_hxx +#define TCollection_DataMapIterator GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient +#define TCollection_DataMapIterator_hxx +#define Handle_TCollection_DataMapNode Handle_GEOM_DataMapNodeOfDataMapOfAsciiStringTransient +#define TCollection_DataMapNode_Type_() GEOM_DataMapNodeOfDataMapOfAsciiStringTransient_Type_() +#define TCollection_DataMap GEOM_DataMapOfAsciiStringTransient +#define TCollection_DataMap_hxx +#include + diff --git a/src/GEOM/GEOM_DataMapOfAsciiStringTransient.hxx b/src/GEOM/GEOM_DataMapOfAsciiStringTransient.hxx new file mode 100644 index 000000000..2225272fc --- /dev/null +++ b/src/GEOM/GEOM_DataMapOfAsciiStringTransient.hxx @@ -0,0 +1,118 @@ + +#ifndef _GEOM_DataMapOfAsciiStringTransient_HeaderFile +#define _GEOM_DataMapOfAsciiStringTransient_HeaderFile + +#ifndef _TCollection_BasicMap_HeaderFile +#include +#endif +#ifndef _Handle_Standard_Transient_HeaderFile +#include +#endif +#ifndef _Handle_GEOM_DataMapNodeOfDataMapOfAsciiStringTransient_HeaderFile +#include +#endif +#ifndef _Standard_Integer_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +class Standard_DomainError; +class Standard_NoSuchObject; +class TCollection_AsciiString; +class Standard_Transient; +class GEOM_DataMapNodeOfDataMapOfAsciiStringTransient; +class GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class GEOM_DataMapOfAsciiStringTransient : public TCollection_BasicMap { + +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 GEOM_DataMapOfAsciiStringTransient(const Standard_Integer NbBuckets = 1); +Standard_EXPORT GEOM_DataMapOfAsciiStringTransient& Assign(const GEOM_DataMapOfAsciiStringTransient& Other) ; + GEOM_DataMapOfAsciiStringTransient& operator =(const GEOM_DataMapOfAsciiStringTransient& Other) +{ + return Assign(Other); +} + +Standard_EXPORT void ReSize(const Standard_Integer NbBuckets) ; +Standard_EXPORT void Clear() ; +~GEOM_DataMapOfAsciiStringTransient() +{ + Clear(); +} + +Standard_EXPORT Standard_Boolean Bind(const TCollection_AsciiString& K,const Handle(Standard_Transient)& I) ; +Standard_EXPORT Standard_Boolean IsBound(const TCollection_AsciiString& K) const; +Standard_EXPORT Standard_Boolean UnBind(const TCollection_AsciiString& K) ; +Standard_EXPORT const Handle_Standard_Transient& Find(const TCollection_AsciiString& K) const; + const Handle_Standard_Transient& operator()(const TCollection_AsciiString& K) const +{ + return Find(K); +} + +Standard_EXPORT Handle_Standard_Transient& ChangeFind(const TCollection_AsciiString& K) ; + Handle_Standard_Transient& operator()(const TCollection_AsciiString& K) +{ + return ChangeFind(K); +} + + + + + + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // +Standard_EXPORT GEOM_DataMapOfAsciiStringTransient(const GEOM_DataMapOfAsciiStringTransient& Other); + + + // Fields PRIVATE + // + + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/GEOM/GEOM_DataMapOfAsciiStringTransient_0.cxx b/src/GEOM/GEOM_DataMapOfAsciiStringTransient_0.cxx new file mode 100644 index 000000000..fbb69911d --- /dev/null +++ b/src/GEOM/GEOM_DataMapOfAsciiStringTransient_0.cxx @@ -0,0 +1,39 @@ + +#include + +#ifndef _Standard_DomainError_HeaderFile +#include +#endif +#ifndef _Standard_NoSuchObject_HeaderFile +#include +#endif +#ifndef _TCollection_AsciiString_HeaderFile +#include +#endif +#ifndef _Standard_Transient_HeaderFile +#include +#endif +#ifndef _GEOM_DataMapNodeOfDataMapOfAsciiStringTransient_HeaderFile +#include +#endif +#ifndef _GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient_HeaderFile +#include +#endif + + +#define TheKey TCollection_AsciiString +#define TheKey_hxx +#define TheItem Handle_Standard_Transient +#define TheItem_hxx +#define Hasher TCollection_AsciiString +#define Hasher_hxx +#define TCollection_DataMapNode GEOM_DataMapNodeOfDataMapOfAsciiStringTransient +#define TCollection_DataMapNode_hxx +#define TCollection_DataMapIterator GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient +#define TCollection_DataMapIterator_hxx +#define Handle_TCollection_DataMapNode Handle_GEOM_DataMapNodeOfDataMapOfAsciiStringTransient +#define TCollection_DataMapNode_Type_() GEOM_DataMapNodeOfDataMapOfAsciiStringTransient_Type_() +#define TCollection_DataMap GEOM_DataMapOfAsciiStringTransient +#define TCollection_DataMap_hxx +#include + diff --git a/src/GEOM/GEOM_Engine.cxx b/src/GEOM/GEOM_Engine.cxx new file mode 100644 index 000000000..46726dcea --- /dev/null +++ b/src/GEOM/GEOM_Engine.cxx @@ -0,0 +1,312 @@ +#include "GEOM_Engine.hxx" + +#include "GEOM_Solver.hxx" +#include "GEOM_Function.hxx" +#include "GEOM_ISubShape.hxx" +#include "GEOM_SubShapeDriver.hxx" +#include "GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient.hxx" + +#include "utilities.h" + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + +#include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC + +static GEOM_Engine* TheEngine = NULL; + +static TCollection_AsciiString BuildIDFromObject(Handle(GEOM_Object)& theObject) +{ + TCollection_AsciiString anID(theObject->GetDocID()), anEntry; + TDF_Tool::Entry(theObject->GetEntry(), anEntry); + anID+=(TCollection_AsciiString("_")+anEntry); + return anID; +} + +static TCollection_AsciiString BuildID(Standard_Integer theDocID, char* theEntry) +{ + TCollection_AsciiString anID(theDocID); + anID+=(TCollection_AsciiString("_")+theEntry); + return anID; +} + +static Standard_Integer ExtractDocID(TCollection_AsciiString& theID) +{ + TCollection_AsciiString aDocID = theID.Token("_"); + if(aDocID.Length() < 1) return -1; + return aDocID.IntegerValue(); +} + +//============================================================================= +/*! + * GetEngine + */ +//============================================================================= +GEOM_Engine* GEOM_Engine::GetEngine() { return TheEngine; } + + +//============================================================================= +/*! + * SetEngine + */ +//============================================================================= +void GEOM_Engine::SetEngine(GEOM_Engine* theEngine) { TheEngine = theEngine; } + +//============================================================================= +/*! + * Constructor + */ +//============================================================================= +GEOM_Engine::GEOM_Engine() +{ + TFunction_DriverTable::Get()->AddDriver(GEOM_Object::GetSubShapeID(), new GEOM_SubShapeDriver()); + + _OCAFApp = new GEOM_Application(); + _UndoLimit = 10; +} + +//============================================================================= +/*! + * GetDocument + */ +//============================================================================= +Handle(TDocStd_Document) GEOM_Engine::GetDocument(int theDocID) +{ + Handle(TDocStd_Document) aDoc; + if(!_mapIDDocument.IsBound(theDocID)) { + _OCAFApp->NewDocument("SALOME_GEOM", aDoc); + aDoc->SetUndoLimit(_UndoLimit); + _mapIDDocument.Bind(theDocID, aDoc); + TDataStd_Integer::Set(aDoc->Main(), theDocID); + } + + return Handle(TDocStd_Document)::DownCast(_mapIDDocument(theDocID)); +} + +//============================================================================= +/*! + * GetDocID + */ +//============================================================================= +int GEOM_Engine::GetDocID(Handle(TDocStd_Document) theDocument) +{ + if(theDocument.IsNull()) return -1; + for(Interface_DataMapIteratorOfDataMapOfIntegerTransient anItr(_mapIDDocument); anItr.More(); anItr.Next()) + if(anItr.Value() == theDocument) return anItr.Key(); + + return -1; + +} + +//============================================================================= +/*! + * GetObject + */ +//============================================================================= +Handle(GEOM_Object) GEOM_Engine::GetObject(int theDocID, char* theEntry) +{ + TCollection_AsciiString anID = BuildID(theDocID, theEntry); + if(_objects.IsBound(anID)) return Handle(GEOM_Object)::DownCast(_objects(anID)); + + TDF_Label aLabel; + Handle(TDocStd_Document) aDoc = GetDocument(theDocID); + TDF_Tool::Label(aDoc->Main().Data(), theEntry, aLabel, Standard_True); + Handle(GEOM_Object) anObject = new GEOM_Object(aLabel); + + _objects.Bind(anID, anObject); + + return anObject; +} + +//============================================================================= +/*! + * AddObject + */ +//============================================================================= +Handle(GEOM_Object) GEOM_Engine::AddObject(int theDocID, int theType) +{ + Handle(TDocStd_Document) aDoc = GetDocument(theDocID); + Handle(TDataStd_TreeNode) aRoot = TDataStd_TreeNode::Set(aDoc->Main()); + + TDF_Label aChild = TDF_TagSource::NewChild(aDoc->Main()); + Handle(GEOM_Object) anObject = new GEOM_Object(aChild, theType); + + //Put an object in the map of created objects + TCollection_AsciiString anID = BuildIDFromObject(anObject); + if(_objects.IsBound(anID)) _objects.UnBind(anID); + _objects.Bind(anID, anObject); + + return anObject; +} + +//============================================================================= +/*! + * AddSubShape + */ +//============================================================================= +Handle(GEOM_Object) GEOM_Engine::AddSubShape(Handle(GEOM_Object) theMainShape, Handle(TColStd_HArray1OfInteger) theIndices) +{ + if(theMainShape.IsNull() || theIndices.IsNull()) return NULL; + + Handle(TDocStd_Document) aDoc = GetDocument(theMainShape->GetDocID()); + Handle(TDataStd_TreeNode) aRoot = TDataStd_TreeNode::Set(aDoc->Main()); + + TDF_Label aChild = TDF_TagSource::NewChild(aDoc->Main()); + + Handle(GEOM_Function) aMainShape = theMainShape->GetLastFunction(); + Handle(GEOM_Object) anObject = new GEOM_Object(aChild, 28); //28 is SUBSHAPE type + Handle(GEOM_Function) aFunction = anObject->AddFunction(GEOM_Object::GetSubShapeID(), 1); + + GEOM_ISubShape aSSI(aFunction); + aSSI.SetMainShape(aMainShape); + aSSI.SetIndices(theIndices); + + try { + GEOM_Solver aSolver (GEOM_Engine::GetEngine()); + if (!aSolver.ComputeFunction(aFunction)) { + MESSAGE("GEOM_Engine::AddSubShape Error: Can't build a sub shape"); + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + MESSAGE("GEOM_Engine::AddSubShape Error: " << aFail->GetMessageString()); + return NULL; + } + + //Put an object in the map of created objects + TCollection_AsciiString anID = BuildIDFromObject(anObject); + if(_objects.IsBound(anID)) _objects.UnBind(anID); + _objects.Bind(anID, anObject); + + TCollection_AsciiString anEntry, aDescr(""); + TDF_Tool::Entry(anObject->GetEntry(), anEntry); + aDescr += anEntry; + aDescr += " = geom.AddSubShape("; + TDF_Tool::Entry(theMainShape->GetEntry(), anEntry); + aDescr += (anEntry+", "); + aDescr += (", ["); + for(Standard_Integer i=theIndices->Lower(); i<=theIndices->Upper(); i++) { + aDescr += (TCollection_AsciiString(theIndices->Value(i))+", "); + } + aDescr.Trunc(aDescr.Length()-1); + aDescr += "])"; + aFunction->SetDescription(aDescr); + + return anObject; +} + +//============================================================================= +/*! + * RemoveObject + */ +//============================================================================= +bool GEOM_Engine::RemoveObject(Handle(GEOM_Object) theObject) +{ + if(!theObject) return false; + + //Remove an object from the map of available objects + TCollection_AsciiString anID = BuildIDFromObject(theObject); + if(_objects.IsBound(anID)) _objects.UnBind(anID); + + TDF_Label aLabel = theObject->GetEntry(); + aLabel.ForgetAllAttributes(Standard_True); + + theObject.Nullify(); + + return true; +} + +//============================================================================= +/*! + * Undo + */ +//============================================================================= +void GEOM_Engine::Undo(int theDocID) +{ + GetDocument(theDocID)->Undo(); +} + +//============================================================================= +/*! + * Redo + */ +//============================================================================= +void GEOM_Engine::Redo(int theDocID) +{ + GetDocument(theDocID)->Redo(); +} + +//============================================================================= +/*! + * Save + */ +//============================================================================= +bool GEOM_Engine::Save(int theDocID, char* theFileName) +{ + if(!_mapIDDocument.IsBound(theDocID)) return false; + Handle(TDocStd_Document) aDoc = Handle(TDocStd_Document)::DownCast(_mapIDDocument(theDocID)); + + _OCAFApp->SaveAs(aDoc, theFileName); + + return true; +} + +//============================================================================= +/*! + * Load + */ +//============================================================================= +bool GEOM_Engine::Load(int theDocID, char* theFileName) +{ + Handle(TDocStd_Document) aDoc; + if(_OCAFApp->Open(theFileName, aDoc) != CDF_RS_OK) return false; + + aDoc->SetUndoLimit(_UndoLimit); + + if(_mapIDDocument.IsBound(theDocID)) _mapIDDocument.UnBind(theDocID); + _mapIDDocument.Bind(theDocID, aDoc); + + TDataStd_Integer::Set(aDoc->Main(), theDocID); + + return true; +} + +//============================================================================= +/*! + * Close + */ +//============================================================================= +void GEOM_Engine::Close(int theDocID) +{ + if(_mapIDDocument.IsBound(theDocID)) { + Handle(TDocStd_Document) aDoc = Handle(TDocStd_Document)::DownCast(_mapIDDocument(theDocID)); + + //Remove all GEOM Objects associated to the given document + TColStd_SequenceOfAsciiString aSeq; + GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient It(_objects); + for(; It.More(); It.Next()) { + TCollection_AsciiString anObjID(It.Key()); + Standard_Integer anID = ExtractDocID(anObjID); + if(theDocID == anID) aSeq.Append(It.Key()); + } + for(Standard_Integer i=1; i<=aSeq.Length(); i++) _objects.UnBind(aSeq.Value(i)); + + _mapIDDocument.UnBind(theDocID); + _OCAFApp->Close(aDoc); + aDoc.Nullify(); + } +} diff --git a/src/GEOM/GEOM_Engine.hxx b/src/GEOM/GEOM_Engine.hxx new file mode 100644 index 000000000..3db976f6e --- /dev/null +++ b/src/GEOM/GEOM_Engine.hxx @@ -0,0 +1,74 @@ + +#ifndef _GEOM_Engine_HXX_ +#define _GEOM_Engine_HXX_ + +#include "GEOM_Application.hxx" +#include +#include +#include +#include "GEOM_Object.hxx" +#include +#include + +#include "GEOM_DataMapOfAsciiStringTransient.hxx" + +class GEOM_Engine +{ + public: + GEOM_Engine(); + ~GEOM_Engine() { _mapIDDocument.Clear(); _objects.Clear(); } + + //Retuns the engine + static GEOM_Engine* GetEngine(); + + //Returns the OCAF document by its ID, if document doesn't exists it will be created + Handle(TDocStd_Document) GetDocument(int theDocID); + + //Returns the ID of the given OCAF document + int GetDocID(Handle(TDocStd_Document) theDocument); + + //Returns the OCAF appliaction + Handle(TDocStd_Application) GetApplication() { return _OCAFApp; } + + //Returns a pointer to GEOM_Object defined by a document and the entry + Handle(GEOM_Object) GetObject(int theDocID, char* theEntry); + + //Adds a new object of the type theType in the OCAF document + Handle(GEOM_Object) AddObject(int theDocID, int theType); + + //Removes the object from the OCAF document + bool RemoveObject(Handle(GEOM_Object) theObject); + + //Saves the OCAF document with ID = theDocID with file with name theFileName + bool Save(int theDocID, char* theFileName); + + //Loads the OCAF document into the application and assigns to it an ID = theDocID + bool Load(int theDocID, char* theFileName); + + //Closes the document with ID = theDocID + void Close(int theDocID); + + //Sets the number of Undos (default value = 10) + void SetUndoLimit(int theLimit) { _UndoLimit = theLimit; } + + //Applies an Undo to document with ID = theDocID + void Undo(int theDocID); + + //Applies an Redo to document with ID = theDocID + void Redo(int theDocID); + + //Adds a new sub shape object of the MainShape object + Handle(GEOM_Object) AddSubShape(Handle(GEOM_Object) theMainShape, Handle(TColStd_HArray1OfInteger) theIndices); + + protected: + static void SetEngine(GEOM_Engine* theEngine); + + private: + + Handle(GEOM_Application) _OCAFApp; + Interface_DataMapOfIntegerTransient _mapIDDocument; + int _UndoLimit; + GEOM_DataMapOfAsciiStringTransient _objects; +}; + +#endif diff --git a/src/GEOM/GEOM_Function.cxx b/src/GEOM/GEOM_Function.cxx new file mode 100644 index 000000000..e11f8cf7b --- /dev/null +++ b/src/GEOM/GEOM_Function.cxx @@ -0,0 +1,631 @@ +using namespace std; + +#include "GEOM_Function.hxx" +#include "GEOM_Object.hxx" +#include "GEOM_Solver.hxx" + +#include "utilities.h" + +#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 + +#define ARGUMENT_LABEL 1 +#define RESULT_LABEL 2 +#define DESCRIPTION_LABEL 3 +#define ARGUMENTS _label.FindChild((ARGUMENT_LABEL)) +#define ARGUMENT(thePosition) _label.FindChild((ARGUMENT_LABEL)).FindChild((thePosition)) +#define SUB_ARGUMENT(thePos1, thePos2) _label.FindChild((ARGUMENT_LABEL)).FindChild((thePos1)).FindChild((thePos2)) + +//======================================================================= +//function : GetFunctionTreeID +//purpose : +//======================================================================= +const Standard_GUID& GEOM_Function::GetFunctionTreeID() +{ + static Standard_GUID aFunctionTreeID("FF1BBB00-5D14-4df2-980B-3A668264EA16"); + return aFunctionTreeID; +} + + +//======================================================================= +//function : GetDependencyID +//purpose : +//======================================================================= +const Standard_GUID& GEOM_Function::GetDependencyID() +{ + static Standard_GUID aDependencyID("E2620650-2354-41bd-8C2C-210CFCD00948"); + return aDependencyID; +} + +//============================================================================= +/*! + * GetFunction: + */ +//============================================================================= +Handle(GEOM_Function) GEOM_Function::GetFunction(const TDF_Label& theEntry) +{ + if(!theEntry.IsAttribute(TFunction_Function::GetID())) return NULL; + + return new GEOM_Function(theEntry); +} + +//============================================================================= +/*! + * Constructor: + */ +//============================================================================= +GEOM_Function::GEOM_Function(const TDF_Label& theEntry, const Standard_GUID& theGUID, int theType) +: _label(theEntry) +{ + TFunction_Function::Set(theEntry, theGUID); + TDataStd_Integer::Set(theEntry, theType); + + //Add function to a function tree + Handle(TDocStd_Document) aDoc = TDocStd_Owner::GetDocument(theEntry.Data()); + Handle(TDataStd_TreeNode) aRoot, aNode; + if(!aDoc->Main().FindAttribute(GetFunctionTreeID(), aRoot)) + aRoot = TDataStd_TreeNode::Set(aDoc->Main(), GetFunctionTreeID()); + + aNode = TDataStd_TreeNode::Set(theEntry, GetFunctionTreeID()); + aRoot->Append(aNode); +} + +//============================================================================= +/*! + * GetOwner + */ +//============================================================================= +TDF_Label GEOM_Function::GetOwnerEntry() +{ + TDF_Label aFather = _label.Father(); + while(!aFather.IsRoot()) { + if(aFather.IsAttribute(GEOM_Object::GetObjectID())) return aFather; + aFather = aFather.Father(); + } + + return TDF_Label(); +} + +//============================================================================= +/*! + * GetType + */ +//============================================================================= +int GEOM_Function::GetType() +{ + _isDone = false; + Handle(TDataStd_Integer) aType; + if(!_label.FindAttribute(TDataStd_Integer::GetID(), aType)) return 0; + _isDone = true; + return aType->Get(); +} + +//============================================================================= +/*! + * GetValue + */ +//============================================================================= +TopoDS_Shape GEOM_Function::GetValue() +{ + _isDone = false; + + TopoDS_Shape aShape; + TDF_Label aLabel = GetOwnerEntry(); + if(aLabel.IsRoot()) return aShape; + Handle(GEOM_Object) anObject = GEOM_Object::GetObject(aLabel); + if(anObject.IsNull()) return aShape; + if(!anObject->IsMainShape()) { + try { + GEOM_Solver aSolver(GEOM_Engine::GetEngine()); + if (!aSolver.ComputeFunction(this)) { + MESSAGE("GEOM_Object::GetValue Error : Can't build a sub shape"); + return aShape; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + MESSAGE("GEOM_Function::GetValue Error: " << aFail->GetMessageString()); + return aShape; + } + } + + TDF_Label aResultLabel = _label.FindChild(RESULT_LABEL); + Handle(TNaming_NamedShape) aNS; + if(!aResultLabel.FindAttribute(TNaming_NamedShape::GetID(), aNS)) return aShape; + + aShape = aNS->Get(); + + _isDone = true; + return aShape; +} + +//============================================================================= +/*! + * GetValue + */ +//============================================================================= +void GEOM_Function::SetValue(TopoDS_Shape& theShape) +{ + _isDone = false; + TDF_Label aResultLabel = _label.FindChild(RESULT_LABEL); + TNaming_Builder aBuilder(aResultLabel); + + aBuilder.Generated(theShape); + + _isDone = true; +} + +//============================================================================= +/*! + * GetDriverGUID + */ +//============================================================================= +Standard_GUID GEOM_Function::GetDriverGUID() +{ + Handle(TFunction_Function) aFunction; + if(!_label.FindAttribute(TFunction_Function::GetID(), aFunction)) { + return TDF::LowestID(); + } + + return aFunction->GetDriverGUID(); +} + +//============================================================================= +/*! + * GetDescription + */ +//============================================================================= +TCollection_AsciiString GEOM_Function::GetDescription() +{ + Handle(TDataStd_Comment) aComment; + TDF_Label aChild = _label.FindChild(DESCRIPTION_LABEL); + if(!aChild.FindAttribute(TDataStd_Comment::GetID(), aComment)) return TCollection_AsciiString(); + TCollection_AsciiString aDescr(aComment->Get()); + return aDescr; +} + +//============================================================================= +/*! + * SetDescription + */ +//============================================================================= +void GEOM_Function::SetDescription(TCollection_AsciiString& theDescription) +{ + TDF_Label aChild = _label.FindChild(DESCRIPTION_LABEL); + Handle(TDataStd_Comment) aComment = TDataStd_Comment::Set(aChild, TCollection_ExtendedString(theDescription)); +} + +//============================================================================= +/*! + * SetReal + */ +//============================================================================= +void GEOM_Function::SetReal(int thePosition, double theValue) +{ + _isDone = false; + if(thePosition <= 0) return; + TDF_Label anArgLabel = ARGUMENT(thePosition); + TDataStd_Real::Set(anArgLabel, theValue); + _isDone = true; +} + +//============================================================================= +/*! + * SetRealArray + */ +//============================================================================= +void GEOM_Function::SetRealArray (int thePosition, + const Handle(TColStd_HArray1OfReal)& theArray) +{ + _isDone = false; + if(thePosition <= 0) return; + TDF_Label anArgLabel = ARGUMENT(thePosition); + Handle(TDataStd_RealArray) anAttr = + TDataStd_RealArray::Set(anArgLabel, theArray->Lower(), theArray->Upper()); + anAttr->ChangeArray(theArray); + _isDone = true; +} + +//============================================================================= +/*! + * GetReal + */ +//============================================================================= +double GEOM_Function::GetReal(int thePosition) +{ + _isDone = false; + if(thePosition <= 0) return 0.0; + Handle(TDataStd_Real) aReal; + TDF_Label anArgLabel = ARGUMENT(thePosition); + if(!anArgLabel.FindAttribute(TDataStd_Real::GetID(), aReal)) return 0.0; + + _isDone = true; + return aReal->Get(); +} + +//============================================================================= +/*! + * GetRealArray + */ +//============================================================================= +Handle(TColStd_HArray1OfReal) GEOM_Function::GetRealArray(int thePosition) +{ + _isDone = false; + if(thePosition <= 0) return NULL; + Handle(TDataStd_RealArray) aRealArray; + TDF_Label anArgLabel = ARGUMENT(thePosition); + if(!anArgLabel.FindAttribute(TDataStd_RealArray::GetID(), aRealArray)) return NULL; + + _isDone = true; + return aRealArray->Array(); +} + +//============================================================================= +/*! + * SetInteger + */ +//============================================================================= +void GEOM_Function::SetInteger(int thePosition, int theValue) +{ + _isDone = false; + if(thePosition <= 0) return; + TDF_Label anArgLabel = ARGUMENT(thePosition); + TDataStd_Integer::Set(anArgLabel, theValue); + _isDone = true; +} + +//============================================================================= +/*! + * SetIntegerArray + */ +//============================================================================= +void GEOM_Function::SetIntegerArray (int thePosition, + const Handle(TColStd_HArray1OfInteger)& theArray) +{ + _isDone = false; + if(thePosition <= 0) return; + TDF_Label anArgLabel = ARGUMENT(thePosition); + Handle(TDataStd_IntegerArray) anAttr = + TDataStd_IntegerArray::Set(anArgLabel, theArray->Lower(), theArray->Upper()); + anAttr->ChangeArray(theArray); + _isDone = true; +} + +//============================================================================= +/*! + * GetInteger + */ +//============================================================================= +int GEOM_Function::GetInteger(int thePosition) +{ + _isDone = false; + if(thePosition <= 0) return 0; + Handle(TDataStd_Integer) anInteger; + TDF_Label anArgLabel = ARGUMENT(thePosition); + if(!anArgLabel.FindAttribute(TDataStd_Integer::GetID(), anInteger)) return 0; + + _isDone = true; + return anInteger->Get(); +} + +//============================================================================= +/*! + * GetIntegerArray + */ +//============================================================================= +Handle(TColStd_HArray1OfInteger) GEOM_Function::GetIntegerArray(int thePosition) +{ + _isDone = false; + if(thePosition <= 0) return 0; + Handle(TDataStd_IntegerArray) anIntegerArray; + TDF_Label anArgLabel = ARGUMENT(thePosition); + if(!anArgLabel.FindAttribute(TDataStd_IntegerArray::GetID(), anIntegerArray)) return 0; + + _isDone = true; + return anIntegerArray->Array(); +} + +//============================================================================= +/*! + * SetString + */ +//============================================================================= +void GEOM_Function::SetString(int thePosition, const TCollection_AsciiString& theValue) +{ + _isDone = false; + if(thePosition <= 0) return; + TDF_Label anArgLabel = ARGUMENT(thePosition); + TDataStd_Comment::Set(anArgLabel, theValue); + _isDone = true; +} + +//============================================================================= +/*! + * GetString + */ +//============================================================================= +TCollection_AsciiString GEOM_Function::GetString(int thePosition) +{ + _isDone = false; + TCollection_AsciiString aRes; + if(thePosition <= 0) return aRes; + Handle(TDataStd_Comment) aString; + TDF_Label anArgLabel = ARGUMENT(thePosition); + if(!anArgLabel.FindAttribute(TDataStd_Comment::GetID(), aString)) return aRes; + + _isDone = true; + aRes = TCollection_AsciiString(aString->Get()); + return aRes; +} + +//============================================================================= +/*! + * SetReference + */ +//============================================================================= +void GEOM_Function::SetReference(int thePosition, Handle(GEOM_Function) theReference) +{ + _isDone = false; + if(thePosition <= 0) return; + if(theReference.IsNull()) return; + TDF_Label anArgLabel = ARGUMENT(thePosition); + TDF_Reference::Set(anArgLabel, theReference->GetEntry()); + TDataStd_UAttribute::Set(anArgLabel, GetDependencyID()); + _isDone = true; + return; +} + +//============================================================================= +/*! + * GetReference + */ +//============================================================================= +Handle(GEOM_Function) GEOM_Function::GetReference(int thePosition) +{ + _isDone = false; + if(thePosition <= 0) return NULL; + TDF_Label anArgLabel = ARGUMENT(thePosition); + Handle(TDF_Reference) aRef; + if(!anArgLabel.FindAttribute(TDF_Reference::GetID(), aRef)) return NULL; + + _isDone = true; + return GetFunction(aRef->Get()); +} + + +//============================================================================= +/*! + * SetStringArray + */ +//============================================================================= +void GEOM_Function::SetStringArray(int thePosition, const Handle(TColStd_HArray1OfExtendedString)& theArray) +{ + _isDone = false; + if(thePosition <= 0 || theArray.IsNull()) return; + TDF_Label anArgLabel = ARGUMENT(thePosition); + + Handle(TDataStd_ExtStringArray) anArray = new TDataStd_ExtStringArray; + anArray->ChangeArray(theArray); + anArgLabel.AddAttribute(anArray); + + _isDone = true; +} + + +//============================================================================= +/*! + * GetStringArray + */ +//============================================================================= +Handle(TColStd_HArray1OfExtendedString) GEOM_Function::GetStringArray(int thePosition) +{ + _isDone = false; + if(thePosition <= 0) return NULL; + TDF_Label anArgLabel = ARGUMENT(thePosition); + Handle(TDataStd_ExtStringArray) anArray; + if(!anArgLabel.FindAttribute(TDataStd_ExtStringArray::GetID(), anArray)) return NULL; + + _isDone = true; + return anArray->Array(); +} + +//======================================================================= +//function : GetReferencesTreeID +//purpose : +//======================================================================= +const Standard_GUID& GEOM_Function::GetReferencesTreeID() +{ + static Standard_GUID aReferencesTreeID("FF1BBB10-5D14-4df2-980B-3A668264EA16"); + return aReferencesTreeID; +} + +//============================================================================= +/*! + * SetReferenceList + */ +//============================================================================= +void GEOM_Function::SetReferenceList (int thePosition, + const Handle(TColStd_HSequenceOfTransient)& theRefList) +{ + _isDone = false; + if(thePosition <= 0) return; + + // parent label for the list of references + TDF_Label anArgLabel = ARGUMENT(thePosition); + anArgLabel.ForgetAllAttributes(); + + // set TreeNode on the parent label + Handle(TDataStd_TreeNode) aRoot, aNode; + aRoot = TDataStd_TreeNode::Set(anArgLabel, GetReferencesTreeID()); + + // store references on sub-labels of the parent label + Handle(GEOM_Function) aFunc; + Standard_Integer ind, len = theRefList->Length(); + for (ind = 1; ind <= len; ind++) { + aFunc = Handle(GEOM_Function)::DownCast(theRefList->Value(ind)); + if (aFunc.IsNull()) continue; + TDF_Label anArgLabel_i = SUB_ARGUMENT(thePosition, ind); + TDF_Reference::Set(anArgLabel_i, aFunc->GetEntry()); + TDataStd_UAttribute::Set(anArgLabel_i, GetDependencyID()); + + // set TreeNode on the child label + aNode = TDataStd_TreeNode::Set(anArgLabel_i, GetReferencesTreeID()); + aRoot->Append(aNode); + } + + _isDone = true; + return; +} + +//============================================================================= +/*! + * GetReferenceList + */ +//============================================================================= +Handle(TColStd_HSequenceOfTransient) GEOM_Function::GetReferenceList(int thePosition) +{ + Handle(TColStd_HSequenceOfTransient) aResult = new TColStd_HSequenceOfTransient; + _isDone = false; + if(thePosition <= 0) return aResult; + + // parent label for the list of references + TDF_Label anArgLabel = ARGUMENT(thePosition); + Handle(TDF_Reference) aRef; + + // get TreeNode on the parent label + Handle(TDataStd_TreeNode) aRoot, aNode; + if(!anArgLabel.FindAttribute(GetReferencesTreeID(), aRoot)) + return aResult; + + // get references, stored on sub-labels of the parent label + TDF_Label aLabel_i; + TDataStd_ChildNodeIterator anIter (aRoot); + for (; anIter.More(); anIter.Next()) { + aNode = anIter.Value(); + aLabel_i = aNode->Label(); + if (!aLabel_i.FindAttribute(TDF_Reference::GetID(), aRef)) continue; + Handle(GEOM_Function) aFunc_i = GetFunction(aRef->Get()); + if (aFunc_i.IsNull()) continue; + aResult->Append(aFunc_i); + } + + _isDone = true; + return aResult; +} + +//============================================================================= +/*! + * SetShape + */ +//============================================================================= +void GEOM_Function::SetShape(int thePosition, const TopoDS_Shape& theShape) +{ + _isDone = false; + if(thePosition <= 0 || theShape.IsNull()) return; + + TDF_Label anArgLabel = ARGUMENT(thePosition); + TNaming_Builder aBuilder(anArgLabel); + aBuilder.Generated(theShape); + + _isDone = true; + return; +} + +//============================================================================= +/*! + * GetShape + */ +//============================================================================= +TopoDS_Shape GEOM_Function::GetShape(int thePosition) +{ + _isDone = false; + TopoDS_Shape aShape; + if(thePosition <= 0) return aShape; + + TDF_Label anArgLabel = ARGUMENT(thePosition); + Handle(TNaming_NamedShape) aNS; + if(!anArgLabel.FindAttribute(TNaming_NamedShape::GetID(), aNS)) return aShape; + + aShape = aNS->Get(); + _isDone = true; + return aShape; +} + + +//============================================================================= +/*! + * GetDependency + */ +//============================================================================= +void GEOM_Function::GetDependency(TDF_LabelSequence& theSeq) +{ + TDF_ChildIterator anIterator(ARGUMENTS, Standard_True); + for(; anIterator.More(); anIterator.Next()) { + if(anIterator.Value().IsAttribute(GetDependencyID())) theSeq.Append(anIterator.Value()); + } +} + +//======================================================================= +//function : GEOM_Function_Type_ +//purpose : +//======================================================================= +Standard_EXPORT Handle_Standard_Type& GEOM_Function_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("GEOM_Function", + sizeof(GEOM_Function), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + +//======================================================================= +//function : DownCast +//purpose : +//======================================================================= + +const Handle(GEOM_Function) Handle(GEOM_Function)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOM_Function) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOM_Function))) { + _anOtherObject = Handle(GEOM_Function)((Handle(GEOM_Function)&)AnObject); + } + } + + return _anOtherObject ; +} diff --git a/src/GEOM/GEOM_Function.hxx b/src/GEOM/GEOM_Function.hxx new file mode 100644 index 000000000..be5c192f1 --- /dev/null +++ b/src/GEOM/GEOM_Function.hxx @@ -0,0 +1,243 @@ + +#ifndef _GEOM_Function_HeaderFile +#define _GEOM_Function_HeaderFile + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Handle_MMgt_TShared_HeaderFile +#include +#endif +#ifndef _MMgt_TShared_HeaderFile +#include +#endif +#ifndef _Standard_GUID_HeaderFile +#include +#endif +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif +#ifndef _TDF_Label_HeaderFile +#include +#endif +#ifndef _TDF_LabelSequence_HeaderFile +#include +#endif +#ifndef _TColStd_HArray1OfExtendedString_HeaderFile +#include +#endif + +class Handle_TColStd_HArray1OfReal; +class Handle_TColStd_HArray1OfInteger; +class Handle_TColStd_HSequenceOfTransient; +class Handle_TColStd_HArray1OfExtendedString; + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(MMgt_TShared); +class GEOM_Function; + +#include + + +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOM_Function); + +class Handle(GEOM_Function) : public Handle(MMgt_TShared) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + Handle(GEOM_Function)():Handle(MMgt_TShared)() {} + Handle(GEOM_Function)(const Handle(GEOM_Function)& aHandle) : Handle(MMgt_TShared)(aHandle) + { + } + + Handle(GEOM_Function)(const GEOM_Function* anItem) : Handle(MMgt_TShared)((MMgt_TShared *)anItem) + { + } + + Handle(GEOM_Function)& operator=(const Handle(GEOM_Function)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOM_Function)& operator=(const GEOM_Function* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOM_Function* operator->() + { + return (GEOM_Function *)ControlAccess(); + } + + GEOM_Function* operator->() const + { + return (GEOM_Function *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOM_Function)() {}; + + Standard_EXPORT static const Handle(GEOM_Function) DownCast(const Handle(Standard_Transient)& AnObject); +}; + +class GEOM_Function : public MMgt_TShared +{ + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& GEOM_Function_Type_(); + Standard_EXPORT const Handle(Standard_Type)& DynamicType() const { return STANDARD_TYPE(GEOM_Function) ; } + Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const { return (STANDARD_TYPE(GEOM_Function) == AType || MMgt_TShared::IsKind(AType)); } + + +private: + GEOM_Function(const TDF_Label& theEntry) { _label = theEntry; } + +public: + + //Returns a GUID for a function tree + static const Standard_GUID& GetFunctionTreeID(); + + //Returns the ID which is associated with a reference to another function + static const Standard_GUID& GetDependencyID(); + + //Finds and returns a function located on a label theEntry + static Handle(GEOM_Function) GetFunction(const TDF_Label& theEntry); + + + GEOM_Function(const TDF_Label& theEntry, const Standard_GUID& theGUID, int theType); + ~GEOM_Function() {;} + + TDF_Label GetOwnerEntry(); + + //Access to properties + + //Returns a result of the function built by the function Driver + TopoDS_Shape GetValue(); + + //Sets the function result + void SetValue(TopoDS_Shape& theShape); + + //Returns a function entry in the OCAF document + TDF_Label& GetEntry() { return _label; } + + //Returns the type of the function + int GetType(); + + //Returns a function Driver GUID + Standard_GUID GetDriverGUID(); + + //Returns aPython description of the function + TCollection_AsciiString GetDescription(); + + //Sets aPython description of the function + void SetDescription(TCollection_AsciiString& theDescription); + + //Access to arguments + + //Sets a real argument at position thePosition + void SetReal(int thePosition, double theValue); + + //Returns a real argument at position thePosition + double GetReal(int thePosition); + + //Sets a real array argument at position thePosition + void SetRealArray(int thePosition, const Handle(TColStd_HArray1OfReal)& theArray); + + //Returns a real array argument at position thePosition + Handle(TColStd_HArray1OfReal) GetRealArray(int thePosition); + + //Sets an integer argument at position thePosition + void SetInteger(int thePosition, int theValue); + + //Returns an integer argument at position thePosition + int GetInteger(int thePosition); + + //Sets an integer array argument at position thePosition + void SetIntegerArray(int thePosition, const Handle(TColStd_HArray1OfInteger)& theArray); + + //Returns an integer array argument at position thePosition + Handle(TColStd_HArray1OfInteger) GetIntegerArray(int thePosition); + + //Sets a reference to other function argument at position thePosition + void SetReference(int thePosition, Handle(GEOM_Function) theReference); + + //Sets a string argument at position thePosition + void SetString(int thePosition, const TCollection_AsciiString& theValue); + + //Returns a string argument at position thePosition + TCollection_AsciiString GetString(int thePosition); + + //Returns a reference to other function argument at position thePosition + Handle(GEOM_Function) GetReference(int thePosition); + + //Set an array of ExtendedString + void SetStringArray(int thePosition, const Handle(TColStd_HArray1OfExtendedString)& theArray); + + //Returns the array of ExtendedString + Handle(TColStd_HArray1OfExtendedString) GetStringArray(int thePosition); + + //Returns a GUID for a references tree + static const Standard_GUID& GetReferencesTreeID(); + + //Sets a list of references to other function arguments at position thePosition + void SetReferenceList (int thePosition, + const Handle(TColStd_HSequenceOfTransient)& theRefList); + + //Returns a list of references to other function arguments at position thePosition + Handle(TColStd_HSequenceOfTransient) GetReferenceList (int thePosition); + + //Sets a TopoDS_Shape argument at position thePosition + void SetShape(int thePosition, const TopoDS_Shape& theShape); + + //Returns a TopoDS_Shape argument at position thePosition + TopoDS_Shape GetShape(int thePosition); + + //Returns true if the last method succided + bool IsDone() { return _isDone; } + + //Returns a sequence of the external dependencies of this function + void GetDependency(TDF_LabelSequence& theSeq); + +private: + + + TDF_Label _label; + bool _isDone; +}; + +#endif diff --git a/src/GEOM/GEOM_Gen_i.cc b/src/GEOM/GEOM_Gen_i.cc index aec7970cd..1175cafe8 100644 --- a/src/GEOM/GEOM_Gen_i.cc +++ b/src/GEOM/GEOM_Gen_i.cc @@ -212,7 +212,7 @@ char* GEOM_Gen_i::IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject, { GEOM::GEOM_Shape_var aShape = GEOM::GEOM_Shape::_narrow(_orb->string_to_object(IORString)); if (!CORBA::is_nil(aShape)) { - return CORBA::string_dup(aShape->ShapeId()); + return aShape->ShapeId(); } return 0; } @@ -458,16 +458,16 @@ SALOMEDS::TMPFile* GEOM_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent, bool isMultiFile) { SALOMEDS::TMPFile_var aStreamFile; // Get a temporary directory to store a file - TCollection_AsciiString aTmpDir = (isMultiFile)?TCollection_AsciiString((char*)theURL):SALOMEDS_Tool::GetTmpDir(); + TCollection_AsciiString aTmpDir = (isMultiFile)?TCollection_AsciiString((char*)theURL):(char*)SALOMEDS_Tool::GetTmpDir().c_str(); // Create a list to store names of created files SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames; aSeq->length(1); // Prepare a file name to open TCollection_AsciiString aNameWithExt(""); if (isMultiFile) - aNameWithExt = TCollection_AsciiString(SALOMEDS_Tool::GetNameFromPath(theComponent->GetStudy()->URL())); + aNameWithExt = TCollection_AsciiString((char*)SALOMEDS_Tool::GetNameFromPath(theComponent->GetStudy()->URL()).c_str()); aNameWithExt += TCollection_AsciiString("_GEOM.sgd"); - aSeq[0] = CORBA::string_dup(aNameWithExt.ToCString()); + aSeq[0] = aNameWithExt.ToCString(); // Build a full file name of temporary file TCollection_AsciiString aFullName = aTmpDir + aNameWithExt; // Save GEOM component in this file @@ -499,7 +499,7 @@ CORBA::Boolean GEOM_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent, } // Get a temporary directory for a file - TCollection_AsciiString aTmpDir = isMultiFile?TCollection_AsciiString((char*)theURL):SALOMEDS_Tool::GetTmpDir(); + TCollection_AsciiString aTmpDir = isMultiFile?TCollection_AsciiString((char*)theURL):(char*)SALOMEDS_Tool::GetTmpDir().c_str(); // Conver the byte stream theStream to a file and place it in tmp directory SALOMEDS::ListOfFileNames_var aSeq = SALOMEDS_Tool::PutStreamToFiles(theStream, aTmpDir.ToCString(), @@ -508,7 +508,7 @@ CORBA::Boolean GEOM_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent, // Prepare a file name to open TCollection_AsciiString aNameWithExt(""); if (isMultiFile) - aNameWithExt = TCollection_AsciiString(SALOMEDS_Tool::GetNameFromPath(theComponent->GetStudy()->URL())); + aNameWithExt = TCollection_AsciiString((char*)SALOMEDS_Tool::GetNameFromPath(theComponent->GetStudy()->URL()).c_str()); aNameWithExt += TCollection_AsciiString("_GEOM.sgd"); TCollection_AsciiString aFullName = aTmpDir + aNameWithExt; @@ -597,7 +597,7 @@ void GEOM_Gen_i::Close(SALOMEDS::SComponent_ptr theComponent) // Handle(TDocStd_Document) anEmptyDoc; // if (aDoc->Main().Root().FindAttribute(TDocStd_Owner::GetID(), anOwner)) { // anOwner->SetDocument(anEmptyDoc); -// cout<<"********** Nullify owner of document"<Close(aDoc); myStudyIDToDoc.UnBind(anID); // remove document from GEOM documents data map @@ -661,7 +661,7 @@ SALOMEDS::TMPFile* GEOM_Gen_i::CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA:: CORBA::Boolean GEOM_Gen_i::CanPaste(const char* theComponentName, CORBA::Long theObjectID) { // The Geometry component can paste only objects copied by Geometry component // and with the object type = 1 -// cout<<"********** GEOM_Gen_i::CanPaste ("<Name(), myCurrentOCAFDoc) ; - result->ShapeId(entry) ; - } - return result; - } +// function : MakeSketcher() +// purpose : Make a wire from a list containing many points +//================================================================================= +GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakeSketcher( const char *Cmd ) + throw (SALOME::SALOME_Exception) +{ + GEOM::GEOM_Shape_var result ; + TopoDS_Shape tds ; + try { + Sketcher_Profile aProfile (Cmd); + if(aProfile.IsDone()) + tds = aProfile.GetShape(); + } + catch(Standard_Failure) { + THROW_SALOME_CORBA_EXCEPTION("Exception catched in GEOM_Gen_i::MakeSketcher", SALOME::BAD_PARAM); + } + + if (tds.IsNull()) { + THROW_SALOME_CORBA_EXCEPTION("MakeSketcher aborted : null shape", SALOME::BAD_PARAM); + } + else { + result = CreateObject(tds); + const char *entry = InsertInLabel(tds, result->Name(), myCurrentOCAFDoc) ; + result->ShapeId(entry) ; + } + return result; +} + + + +//================================================================================= +// function : MakeBezier() +// purpose : Make a wire from a list containing many points +//================================================================================= +GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakeBezier( const GEOM::GEOM_Gen::ListOfIOR& ListShapes ) + throw (SALOME::SALOME_Exception) +{ + GEOM::GEOM_Shape_var result; + TopoDS_Shape tds, Shape; + TColgp_Array1OfPnt CurvePoints(1, ListShapes.length()); + + try { + for(unsigned int i = 0; i < ListShapes.length(); i++) { + GEOM::GEOM_Shape_var aShape = GetIORFromString(ListShapes[i]); + Shape = GetTopoShape(aShape); + if(Shape.IsNull()) { + THROW_SALOME_CORBA_EXCEPTION("MakeBezier aborted : null shape during operation", SALOME::BAD_PARAM); + } + if(Shape.ShapeType() == TopAbs_VERTEX) { + const gp_Pnt& P = BRep_Tool::Pnt(TopoDS::Vertex(Shape)); + CurvePoints.SetValue(i + 1, P); + } + } + Handle(Geom_BezierCurve) GBC = new Geom_BezierCurve(CurvePoints); + tds = BRepBuilderAPI_MakeEdge(GBC); + } + catch(Standard_Failure) { + THROW_SALOME_CORBA_EXCEPTION("Exception catched in GEOM_Gen_i::MakeBezier", SALOME::BAD_PARAM); + } + + if( tds.IsNull() ) { + THROW_SALOME_CORBA_EXCEPTION("Make Bezier operation aborted : null result", SALOME::BAD_PARAM); + } + else { + result = CreateObject(tds); + InsertInLabelMoreArguments(tds, result, ListShapes, myCurrentOCAFDoc); + } + return result; +} + + +//================================================================================= +// function : MakeInterpol() +// purpose : Make a wire from a list containing many points +//================================================================================= +GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakeInterpol( const GEOM::GEOM_Gen::ListOfIOR& ListShapes ) + throw (SALOME::SALOME_Exception) +{ + GEOM::GEOM_Shape_var result; + TopoDS_Shape tds, Shape; + TColgp_Array1OfPnt CurvePoints(1, ListShapes.length()); + + try { + for(unsigned int i = 0; i < ListShapes.length(); i++) { + GEOM::GEOM_Shape_var aShape = GetIORFromString(ListShapes[i]); + Shape = GetTopoShape(aShape); + if(Shape.IsNull()) { + THROW_SALOME_CORBA_EXCEPTION("MakeBSpline aborted : null shape during operation", SALOME::BAD_PARAM); + } + if(Shape.ShapeType() == TopAbs_VERTEX) { + const gp_Pnt& P = BRep_Tool::Pnt(TopoDS::Vertex(Shape)); + CurvePoints.SetValue(i + 1, P); + } + } + GeomAPI_PointsToBSpline GBC(CurvePoints); + tds = BRepBuilderAPI_MakeEdge(GBC); + } + catch(Standard_Failure) { + THROW_SALOME_CORBA_EXCEPTION("Exception catched in GEOM_Gen_i::MakeBSpline", SALOME::BAD_PARAM); + } + + if( tds.IsNull() ) { + THROW_SALOME_CORBA_EXCEPTION("Make BSpline operation aborted : null result", SALOME::BAD_PARAM); + } + else { + result = CreateObject(tds) ; + InsertInLabelMoreArguments(tds, result, ListShapes, myCurrentOCAFDoc) ; + } + return result; +} //================================================================================= // function : MakeTranslation() diff --git a/src/GEOM/GEOM_Gen_i.hh b/src/GEOM/GEOM_Gen_i.hh deleted file mode 100644 index ff910b897..000000000 --- a/src/GEOM/GEOM_Gen_i.hh +++ /dev/null @@ -1,617 +0,0 @@ -// GEOM GEOM : implementaion of GEOM_Gen.idl and GEOM_Shape.idl -// -// 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 : GEOM_GEN_i.h file -// Author : Lucien PIGNOLONI -// Module : GEOM -// $Header$ - -#ifndef __GEOM_GEN_I_H__ -#define __GEOM_GEN_I_H__ - -// standard C++ headers -#include -#include "GEOMDS_DataMapOfIntegerTransient.hxx" -#include "GEOMDS_Application.hxx" -#include -#include -#include -#include -#include -#include - -// IDL headers -#include -#include CORBA_SERVER_HEADER(GEOM_Gen) -#include CORBA_SERVER_HEADER(GEOM_Shape) -#include CORBA_SERVER_HEADER(SALOMEDS) - -#include "SALOME_Component_i.hxx" -#include "GEOM_Shape_i.hh" - -#include "SALOME_NamingService.hxx" -#include - -#include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC - - -//===================================================================== -// GEOM_Gen_i : class definition -//===================================================================== -class GEOM_Gen_i: public POA_GEOM::GEOM_Gen, - public Engines_Component_i -{ - private: - - SALOME_NamingService * name_service; - char * _name; - Handle(GEOMDS_Application) myOCAFApp; /* geom/OCAF Application */ - Handle(TDocStd_Document) myCurrentOCAFDoc; /* Current geom/OCAF Document */ - GEOMDS_DataMapOfIntegerTransient myStudyIDToDoc; /* Map to bind a Study to a Document */ - - int myStudyID; - - GEOM::GEOM_Shape_ptr CreateObject(TopoDS_Shape& tds) ; - - GEOM::GEOM_Shape_ptr CreateSubObject(const TopoDS_Shape& SubShape, - const GEOM::GEOM_Shape_ptr MainShape, - const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfID); - // Create and insert(!) SubShape of MainShape - - GEOM::GEOM_Shape_ptr GEOM_Gen_i::SubShapesOne( GEOM::GEOM_Shape_ptr shape, - const TopAbs_ShapeEnum ShapeType, - const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfID, - const Standard_Boolean sorted=Standard_False) - throw (SALOME::SALOME_Exception); - // return all listed subshapes as one shape - - GEOM::GEOM_Gen::ListOfGeomShapes* SubShapesAll(GEOM::GEOM_Shape_ptr shape, - const TopAbs_ShapeEnum type, - const Standard_Boolean sorted=Standard_False) - throw (SALOME::SALOME_Exception); - // return all subshapes by type - - TopoDS_Face FindSameFace(const TopoDS_Shape& aShape, - const TopoDS_Face& F, - double tol3d); - TopoDS_Edge FindSameEdge(const TopoDS_Face& newFace, - TopoDS_Edge& Eold, - double tol3d); - - public: - //-----------------------------------------------------------------------// - // Constructor / Destructor // - //-----------------------------------------------------------------------// - // constructor to be called for servant creation. - GEOM_Gen_i(); - GEOM_Gen_i(CORBA::ORB_ptr orb, - PortableServer::POA_ptr poa, - PortableServer::ObjectId * contId, - const char *instanceName, - const char *interfaceName); - - // destructor, doing nothing (for now) - virtual ~GEOM_Gen_i(); - - // generic method to be put in a super class - void register_name(char * name); - - //-----------------------------------------------------------------------// - // Studies Management // - //-----------------------------------------------------------------------// - void GetCurrentStudy (CORBA::Long StudyID); - - CORBA::Short NbLabels(); - - // inherited methods from SALOMEDS::Driver - SALOMEDS::TMPFile* Save(SALOMEDS::SComponent_ptr theComponent, - const char* theURL, - bool isMultiFile); - - SALOMEDS::TMPFile* SaveASCII(SALOMEDS::SComponent_ptr theComponent, - const char* theURL, - bool isMultiFile); - - CORBA::Boolean Load(SALOMEDS::SComponent_ptr theComponent, - const SALOMEDS::TMPFile& theStream, - const char* theURL, - bool isMultiFile); - - CORBA::Boolean LoadASCII(SALOMEDS::SComponent_ptr theComponent, - const SALOMEDS::TMPFile& theStream, - const char* theURL, - bool isMultiFile); - - void Close(SALOMEDS::SComponent_ptr theComponent); - char* ComponentDataType(); - - - char* IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject, - const char* IORString, - CORBA::Boolean isMultiFile, - CORBA::Boolean isASCII); - char* LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject, - const char* aLocalPersistentID, - CORBA::Boolean isMultiFile, - CORBA::Boolean isASCII); - - bool CanPublishInStudy(CORBA::Object_ptr theIOR); - SALOMEDS::SObject_ptr PublishInStudy(SALOMEDS::Study_ptr theStudy, - SALOMEDS::SObject_ptr theSObject, - CORBA::Object_ptr theObject, - const char* theName) throw (SALOME::SALOME_Exception) ; - - CORBA::Boolean CanCopy(SALOMEDS::SObject_ptr theObject); - SALOMEDS::TMPFile* CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID); - CORBA::Boolean CanPaste(const char* theComponentName, CORBA::Long theObjectID); - SALOMEDS::SObject_ptr PasteInto(const SALOMEDS::TMPFile& theStream, - CORBA::Long theObjectID, - SALOMEDS::SObject_ptr theObject); - - //-----------------------------------------------------------------------// - // Shapes Management // - //-----------------------------------------------------------------------// - const char* InsertInLabel(TopoDS_Shape S, - const char *nameIor, - Handle(TDocStd_Document) OCAFDoc) ; - - const char* InsertInLabelDependentShape(TopoDS_Shape S, - const char *nameIor, - GEOM::GEOM_Shape_ptr mainshape_ptr, - Handle(TDocStd_Document) OCAFDoc) ; - - void InsertInLabelOneArgument(TopoDS_Shape main_topo, - GEOM::GEOM_Shape_ptr shape_ptr, - TopoDS_Shape result_topo, - GEOM::GEOM_Shape_ptr result, - Handle(TDocStd_Document) OCAFDoc) ; - - void InsertInLabelMoreArguments(TopoDS_Shape main_topo, - GEOM::GEOM_Shape_ptr result, - const GEOM::GEOM_Gen::ListOfIOR& ListShapes, - Handle(TDocStd_Document) OCAFDoc) ; - - // Methods used by SuppressFaces - int SuppressFacesGlue( const TopoDS_Shape& S, - const TopTools_MapOfShape& mapFaces, - TopoDS_Shape& aCompoundOfShells ) throw (SALOME::SALOME_Exception) ; - - // various services - int GetIndexTopology( const TopoDS_Shape& subshape, - const TopoDS_Shape& mainShape ) ; - - bool GetShapeFromIndex( const TopoDS_Shape& aShape, - const TopAbs_ShapeEnum aType, - const int index, - TopoDS_Shape& tds) ; - - GEOM::GEOM_Shape::ListOfSubShapeID* IndexOfFacesOfSubShell( const TopoDS_Shape& S, - const TopoDS_Shape subShell ) - throw (SALOME::SALOME_Exception) ; - - bool ListOfIDIntoMapOfShapes( const TopoDS_Shape& S, - const GEOM::GEOM_Shape::ListOfSubShapeID& L, - const int subShapeType, - TopTools_MapOfShape& aMap ) ; - - bool ListOfIDIntoSequenceOfShapes( const TopoDS_Shape& S, - const GEOM::GEOM_Shape::ListOfSubShapeID& L, - const int subShapeType, - TopTools_SequenceOfShape& aSequenceOfShapes ) ; - - // Returns a TopoDS_Shape from a GEOM::GEOM_Shape_ptr - TopoDS_Shape GetTopoShape(GEOM::GEOM_Shape_ptr shape_ptr) ; - - // Define a sequence of shapes from 'listShapes' and return its length - int SequenceOfShapeFromListOfGeomShape( const GEOM::GEOM_Gen::ListOfGeomShapes& listShapes, - TopTools_SequenceOfShape& SS ) ; - - // Get a string representing a shape ref IOR - const char* GetStringFromIOR(GEOM::GEOM_Shape_var shapeIOR); - - // Return the shape ref represented by a string of IOR - GEOM::GEOM_Shape_ptr GetIORFromString(const char* stringIOR); - - GEOM::GEOM_Gen::ListOfIOR* GetReferencedObjects(GEOM::GEOM_Shape_ptr shape); - GEOM::GEOM_Gen::ListOfIOR* GetObjects(GEOM::GEOM_Shape_ptr shape); - - - //-----------------------------------------------------------------------// - // Internal structure of shapes // - //-----------------------------------------------------------------------// - // Explode SubShape - GEOM::GEOM_Shape_ptr SubShape(GEOM::GEOM_Shape_ptr shape, - CORBA::Short ShapeType, - const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfID) - throw (SALOME::SALOME_Exception) ; - - // Explode SubShape in predictable order - GEOM::GEOM_Shape_ptr SubShapeSorted(GEOM::GEOM_Shape_ptr shape, - CORBA::Short ShapeType, - const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfID) - throw (SALOME::SALOME_Exception) ; - - // Explode SubShape - GEOM::GEOM_Gen::ListOfGeomShapes* SubShapeAll(GEOM::GEOM_Shape_ptr shape, - CORBA::Short ShapeType) - throw (SALOME::SALOME_Exception) ; - - // Explode SubShape in predictable order for TUI or GUI - GEOM::GEOM_Gen::ListOfGeomShapes* SubShapeAllSorted(GEOM::GEOM_Shape_ptr shape, - CORBA::Short ShapeType) - throw (SALOME::SALOME_Exception) ; - - // Suppress faces in a shape - GEOM::GEOM_Gen::ListOfGeomShapes* SuppressFaces( GEOM::GEOM_Shape_ptr shape, - const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfID ) - throw (SALOME::SALOME_Exception) ; - - // Suppress one or more holes in a face or shell independant topology - GEOM::GEOM_Shape_ptr SuppressHolesInFaceOrShell( GEOM::GEOM_Shape_ptr shapeFaceShell, - const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdWires) - throw (SALOME::SALOME_Exception) ; - - // Suppress a single hole in a topology (face) shell or solid with/without hole traversing - GEOM::GEOM_Shape_ptr SuppressHole( GEOM::GEOM_Shape_ptr shape, - const GEOM::GEOM_Shape::ListOfSubShapeID& ListIdFace, - const GEOM::GEOM_Shape::ListOfSubShapeID& ListIdWire, - const GEOM::GEOM_Shape::ListOfSubShapeID& ListIdEndFace ) - throw (SALOME::SALOME_Exception) ; - - bool RebuildFaceRemovingHoles( const TopoDS_Face& aFace, - const TopTools_MapOfShape& mapHoles, - TopoDS_Shape& resultFace ) ; - - void SuppressHoleSubRoutine( const TopoDS_Shape& mainShape, - const TopoDS_Face& aFace, - const TopTools_SequenceOfShape& SSedgesOfWire, - const TopTools_IndexedDataMapOfShapeListOfShape& aMapEdgesFaces, - const TopTools_MapOfShape& MSfaces, - TopTools_MapOfShape& MSfacesSuppress, - const Standard_Boolean withEndFace, - const TopoDS_Face& endFace, - TopTools_MapOfShape& MSwireEndEdges ) - throw (SALOME::SALOME_Exception ) ; - - bool BuildShapeHoleNotTraversing( const TopoDS_Shape& aShape, - const TopoDS_Face& aFace, - const TopoDS_Wire& aWire, - const TopTools_MapOfShape& MFSuppress, - TopoDS_Shape& resultTds ) - throw (SALOME::SALOME_Exception) ; - - bool BuildShapeHoleTraversing( const TopoDS_Shape& aShape, - const TopoDS_Face& aFace, - const TopoDS_Wire& aWire, - const TopTools_MapOfShape& MFSuppress, - const TopoDS_Face& endFace, - const TopoDS_Wire& endWire, - TopoDS_Shape& resultTds ) - throw (SALOME::SALOME_Exception) ; - - bool FindCompareWireHoleOnFace( const TopoDS_Face& F, - const TopTools_MapOfShape& MSwireEdges, - TopoDS_Wire& aFoundWire ) ; - - bool IsShapeInSequence( const TopTools_SequenceOfShape& SS, const TopoDS_Shape& aShape ) ; - - void FreeEdgesFromMapOfFace(const TopTools_MapOfShape& MSfaces, TopTools_MapOfShape& MS ) ; - - void MapRemoveSequence( const TopTools_MapOfShape& MS, - const TopTools_SequenceOfShape& SSRemove, - TopTools_SequenceOfShape& ST) ; - - bool BuildShellWithFaceCompound( const TopoDS_Compound Comp, - TopoDS_Shell& resultShell ) ; - - //-----------------------------------------------------------------------// - // Basic structures // - //-----------------------------------------------------------------------// - GEOM::PointStruct MakePointStruct(CORBA::Double x, - CORBA::Double y, - CORBA::Double z) ; - GEOM::DirStruct MakeDirection(const GEOM::PointStruct& p) ; - - GEOM::AxisStruct MakeAxisStruct(CORBA::Double x, - CORBA::Double y, - CORBA::Double z, - CORBA::Double vx, - CORBA::Double vy, - CORBA::Double vz) ; - - //----------------------------------------------------------------------// - // Boolean Operations // - //----------------------------------------------------------------------// - GEOM::GEOM_Shape_ptr MakeBoolean(GEOM::GEOM_Shape_ptr shape1, - GEOM::GEOM_Shape_ptr shape2, - CORBA::Long operation) - throw (SALOME::SALOME_Exception) ; - GEOM::GEOM_Shape_ptr MakeFuse(GEOM::GEOM_Shape_ptr shape1, - GEOM::GEOM_Shape_ptr shape2) - throw (SALOME::SALOME_Exception) ; - - //----------------------------------------------------------------------// - // Advanced Operations // - //----------------------------------------------------------------------// - GEOM::GEOM_Shape_ptr Partition(const GEOM::GEOM_Gen::ListOfIOR& ListShapes, - const GEOM::GEOM_Gen::ListOfIOR& ListTools, - const GEOM::GEOM_Gen::ListOfIOR& ListKeepInside, - const GEOM::GEOM_Gen::ListOfIOR& ListRemoveInside, - const CORBA::Short Limit) - throw (SALOME::SALOME_Exception) ; - - // Filling a surface with section curves - GEOM::GEOM_Shape_ptr MakeFilling(GEOM::GEOM_Shape_ptr shape, - CORBA::Short mindeg, - CORBA::Short maxdeg, - CORBA::Double tol3d, - CORBA::Double tol2d, - CORBA::Short nbiter) - throw (SALOME::SALOME_Exception) ; - // Sewing of shapes - GEOM::GEOM_Shape_ptr MakeSewing(const GEOM::GEOM_Gen::ListOfIOR& ListShapes, - CORBA::Double precision) - throw (SALOME::SALOME_Exception) ; - - GEOM::GEOM_Shape_ptr MakeSewingShape( GEOM::GEOM_Shape_ptr aShape, - CORBA::Double precision ) - throw (SALOME::SALOME_Exception); - - GEOM::GEOM_Shape_ptr MakeGlueFaces(GEOM::GEOM_Shape_ptr myShape, - double tol3d) - throw (SALOME::SALOME_Exception); - - // Change the orientation of a (new) shape - GEOM::GEOM_Shape_ptr OrientationChange(GEOM::GEOM_Shape_ptr shape) - throw (SALOME::SALOME_Exception) ; - - GEOM::GEOM_Shape_ptr MakePlacedBox(CORBA::Double x1, CORBA::Double y1, CORBA::Double z1, - CORBA::Double delta1, CORBA::Double delta2, CORBA::Double delta3) - throw (SALOME::SALOME_Exception) ; - - GEOM::GEOM_Shape_ptr MakePanel(GEOM::GEOM_Shape_ptr shape, - CORBA::Short directiontype, - CORBA::Double delta) - throw (SALOME::SALOME_Exception) ; - - //---------------------------------------------------------------------// - // Transformations Operations // - //---------------------------------------------------------------------// - // Copy - GEOM::GEOM_Shape_ptr MakeCopy( GEOM::GEOM_Shape_ptr shape) - throw (SALOME::SALOME_Exception) ; - - // Translation - GEOM::GEOM_Shape_ptr MakeTranslation( GEOM::GEOM_Shape_ptr shape, - CORBA::Double x, - CORBA::Double y, - CORBA::Double z) - throw (SALOME::SALOME_Exception) ; - // Rotation - GEOM::GEOM_Shape_ptr MakeRotation( GEOM::GEOM_Shape_ptr shape, - const GEOM::AxisStruct& axis, - CORBA::Double angle) - throw (SALOME::SALOME_Exception) ; - // Create a shape using a scale factor - GEOM::GEOM_Shape_ptr MakeScaleTransform(GEOM::GEOM_Shape_ptr shape, - const GEOM::PointStruct& theCenterOfScale, - CORBA::Double factor) - throw (SALOME::SALOME_Exception) ; - // Mirror of a shape by a plane - GEOM::GEOM_Shape_ptr MakeMirrorByPlane(GEOM::GEOM_Shape_ptr shape, - GEOM::GEOM_Shape_ptr shapePlane) - throw (SALOME::SALOME_Exception) ; - - // Shape by revolution of another around an axis - GEOM::GEOM_Shape_ptr MakeRevolution(GEOM::GEOM_Shape_ptr shape, - const GEOM::AxisStruct& axis, - CORBA::Double angle) - throw (SALOME::SALOME_Exception) ; - - // Create a prism with a base shape along a vector P1 to P2 - GEOM::GEOM_Shape_ptr MakePrism(GEOM::GEOM_Shape_ptr baseShape, - const GEOM::PointStruct& P1, - const GEOM::PointStruct& P2) - throw (SALOME::SALOME_Exception) ; - // Create a shape by sweeping a baseShape along a pathShape - GEOM::GEOM_Shape_ptr MakePipe(GEOM::GEOM_Shape_ptr pathShape, - GEOM::GEOM_Shape_ptr baseShape) - throw (SALOME::SALOME_Exception) ; - - //---------------------------------------------------------------------// - // Patterns Operations // - //---------------------------------------------------------------------// - - // Multi Translation 1D - GEOM::GEOM_Shape_ptr MakeMultiTranslation1D( GEOM::GEOM_Shape_ptr shape, - const GEOM::DirStruct& dir, - CORBA::Double step, - CORBA::Short nbtimes) - throw (SALOME::SALOME_Exception) ; - - // Multi Translation 2D - GEOM::GEOM_Shape_ptr MakeMultiTranslation2D( GEOM::GEOM_Shape_ptr shape, - const GEOM::DirStruct& dir1, - CORBA::Double step1, - CORBA::Short nbtimes1, - const GEOM::DirStruct& dir2, - CORBA::Double step2, - CORBA::Short nbtimes2) - throw (SALOME::SALOME_Exception) ; - - // Multi Rotation 1D - GEOM::GEOM_Shape_ptr MakeMultiRotation1D( GEOM::GEOM_Shape_ptr shape, - const GEOM::DirStruct& dir, - const GEOM::PointStruct& loc, - CORBA::Short nbtimes) - throw (SALOME::SALOME_Exception) ; - - // Multi Rotation 2D - GEOM::GEOM_Shape_ptr MakeMultiRotation2D( GEOM::GEOM_Shape_ptr shape, - const GEOM::DirStruct& dir, - const GEOM::PointStruct& loc, - CORBA::Double ang, - CORBA::Short nbtimes1, - CORBA::Double step, - CORBA::Short nbtimes2) - throw (SALOME::SALOME_Exception) ; - - //--------------------------------------------------------------------// - // Primitives Construction // - //--------------------------------------------------------------------// - GEOM::GEOM_Shape_ptr MakeBox(CORBA::Double x1, - CORBA::Double y1, - CORBA::Double z1, - CORBA::Double x2, - CORBA::Double y2, - CORBA::Double z2) - throw (SALOME::SALOME_Exception) ; - GEOM::GEOM_Shape_ptr MakeSphere(CORBA::Double x1, - CORBA::Double y1, - CORBA::Double z1, - CORBA::Double radius) - throw (SALOME::SALOME_Exception) ; - GEOM::GEOM_Shape_ptr MakeCylinder(const GEOM::PointStruct& pstruct, - const GEOM::DirStruct& dstruct, - CORBA::Double radius, - CORBA::Double height) - throw (SALOME::SALOME_Exception) ; - GEOM::GEOM_Shape_ptr MakeTorus(const GEOM::PointStruct& pstruct, - const GEOM::DirStruct& dstruct, - CORBA::Double major_radius, - CORBA::Double minor_radius) - throw (SALOME::SALOME_Exception) ; - GEOM::GEOM_Shape_ptr MakeCone(const GEOM::PointStruct& pstruct, - const GEOM::DirStruct& dstruct, - CORBA::Double radius1, - CORBA::Double radius2, - CORBA::Double height) - throw (SALOME::SALOME_Exception) ; - - //-------------------------------------------------------------------// - // Import/Export // - //-------------------------------------------------------------------// - GEOM::GEOM_Shape_ptr ImportIGES(const char* filename) throw (SALOME::SALOME_Exception) ; - GEOM::GEOM_Shape_ptr ImportBREP(const char* filename) throw (SALOME::SALOME_Exception) ; - GEOM::GEOM_Shape_ptr ImportSTEP(const char* filename) throw (SALOME::SALOME_Exception) ; - - void ExportIGES(const char* filename,GEOM::GEOM_Shape_ptr theShape) throw (SALOME::SALOME_Exception) ; - void ExportBREP(const char* filename,GEOM::GEOM_Shape_ptr theShape) throw (SALOME::SALOME_Exception) ; - void ExportSTEP(const char* filename,GEOM::GEOM_Shape_ptr theShape) throw (SALOME::SALOME_Exception) ; - //-------------------------------------------------------------------// - // Fillet and Chamfer construction // - //-------------------------------------------------------------------// - GEOM::GEOM_Shape_ptr MakeFillet (GEOM::GEOM_Shape_ptr shape, - CORBA::Double radius, - CORBA::Short ShapeType, - const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfID) - throw (SALOME::SALOME_Exception) ; - - GEOM::GEOM_Shape_ptr MakeChamfer(GEOM::GEOM_Shape_ptr shape, - CORBA::Double d1, - CORBA::Double d2, - CORBA::Short ShapeType, - const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfID) - throw (SALOME::SALOME_Exception) ; - - //-------------------------------------------------------------------// - // Mesures Construction // - //-------------------------------------------------------------------// - GEOM::GEOM_Shape_ptr MakeCDG(GEOM::GEOM_Shape_ptr shape) - throw (SALOME::SALOME_Exception) ; - - //-------------------------------------------------------------------// - // Check Shape // - //-------------------------------------------------------------------// - CORBA::Boolean CheckShape(GEOM::GEOM_Shape_ptr shape) - throw (SALOME::SALOME_Exception) ; - - //-------------------------------------------------------------------// - // Primitives Construction // - //-------------------------------------------------------------------// - GEOM::GEOM_Shape_ptr MakeVertex(CORBA::Double x, - CORBA::Double y, - CORBA::Double z) - throw (SALOME::SALOME_Exception) ; - GEOM::GEOM_Shape_ptr MakeVector(const GEOM::PointStruct& pstruct1, - const GEOM::PointStruct& pstruct2) - throw (SALOME::SALOME_Exception) ; - GEOM::GEOM_Shape_ptr MakeLine (const GEOM::PointStruct& pstruct, - const GEOM::DirStruct& dstruc) - throw (SALOME::SALOME_Exception) ; - GEOM::GEOM_Shape_ptr MakePlane (const GEOM::PointStruct& pstruct, - const GEOM::DirStruct& dstruc, - CORBA::Double trimsize) - throw (SALOME::SALOME_Exception) ; - GEOM::GEOM_Shape_ptr MakeCircle(const GEOM::PointStruct& pstruct, - const GEOM::DirStruct& dstruct, - CORBA::Double radius) - throw (SALOME::SALOME_Exception) ; - GEOM::GEOM_Shape_ptr MakeEllipse(const GEOM::PointStruct& pstruct, - const GEOM::DirStruct& dstruct, - CORBA::Double radius_major, - CORBA::Double radiusminus ) - throw (SALOME::SALOME_Exception) ; - GEOM::GEOM_Shape_ptr MakeArc (const GEOM::PointStruct& pInit, - const GEOM::PointStruct& pCircle, - const GEOM::PointStruct& pEnd) - throw (SALOME::SALOME_Exception) ; - - //-------------------------------------------------------------------// - // Specific method Sketcher // - //-------------------------------------------------------------------// - GEOM::GEOM_Shape_ptr MakeSketcher (const char* Cmd) - throw (SALOME::SALOME_Exception) ; - - //-------------------------------------------------------------------// - - GEOM::GEOM_Shape_ptr MakeCompound (const GEOM::GEOM_Gen::ListOfIOR& ListShapes) - throw (SALOME::SALOME_Exception) ; - GEOM::GEOM_Shape_ptr MakeWire (const GEOM::GEOM_Gen::ListOfIOR& ListShapes) - throw (SALOME::SALOME_Exception) ; - GEOM::GEOM_Shape_ptr MakeEdge (const GEOM::PointStruct& pstruct1, - const GEOM::PointStruct& pstruct2) - throw (SALOME::SALOME_Exception) ; - GEOM::GEOM_Shape_ptr MakeFace (GEOM::GEOM_Shape_ptr wire, CORBA::Boolean wantplanarface) - throw (SALOME::SALOME_Exception) ; - GEOM::GEOM_Shape_ptr MakeFaces (const GEOM::GEOM_Gen::ListOfIOR& ListShapes, - CORBA::Boolean wantplanarface) - throw (SALOME::SALOME_Exception) ; - GEOM::GEOM_Shape_ptr MakeShell (const GEOM::GEOM_Gen::ListOfIOR& ListShapes) - throw (SALOME::SALOME_Exception) ; - GEOM::GEOM_Shape_ptr MakeSolid (const GEOM::GEOM_Gen::ListOfIOR& ListShapes) - throw (SALOME::SALOME_Exception) ; - - - //-------------------------------------------------------------------// - // Speciic method Archimede // - //-------------------------------------------------------------------// - GEOM::GEOM_Shape_ptr Archimede(GEOM::GEOM_Shape_ptr aShape, - CORBA::Double aWeight, - CORBA::Double aWaterDensity, - CORBA::Double aMeshingDeflection) - throw (SALOME::SALOME_Exception) ; - -}; - -#endif diff --git a/src/GEOM/GEOM_IOperations.cxx b/src/GEOM/GEOM_IOperations.cxx new file mode 100644 index 000000000..e851ce116 --- /dev/null +++ b/src/GEOM/GEOM_IOperations.cxx @@ -0,0 +1,84 @@ +using namespace std; + +#include "GEOM_IOperations.hxx" + +#include "utilities.h" +#include "OpUtil.hxx" +#include "Utils_ExceptHandlers.hxx" + +#include +#include +#include + +//============================================================================= +/*! + * default constructor: + */ +//============================================================================= + +GEOM_IOperations::GEOM_IOperations(GEOM_Engine* theEngine, int theDocID) +: _engine(theEngine), _docID(theDocID) +{ + _solver = new GEOM_Solver(theEngine); +} + +//============================================================================= +/*! + * destructor + */ +//============================================================================= + +GEOM_IOperations::~GEOM_IOperations() +{ + delete _solver; + MESSAGE("GEOM_IOperations::~GEOM_IOperations"); +} + + +//============================================================================= +/*! + * StartOperation + */ +//============================================================================= +void GEOM_IOperations::StartOperation() +{ + Handle(TDocStd_Document) aDoc = _engine->GetDocument(_docID); + if(aDoc->GetUndoLimit() > 0) + aDoc->NewCommand(); +} + + //============================================================================= + /*! + * FinishOperation + */ +//============================================================================= +void GEOM_IOperations::FinishOperation() +{ + Handle(TDocStd_Document) aDoc = _engine->GetDocument(_docID); + if(aDoc->GetUndoLimit() > 0) + aDoc->CommitCommand(); +} + +//============================================================================= +/*! + * AbortOperation + */ +//============================================================================= +void GEOM_IOperations::AbortOperation() +{ + Handle(TDocStd_Document) aDoc = _engine->GetDocument(_docID); + aDoc->AbortCommand(); +} + + +//============================================================================= +/*! + * IsDone + */ +//============================================================================= +bool GEOM_IOperations::IsDone() +{ + return (_errorCode == OK); +} + + diff --git a/src/GEOM/GEOM_IOperations.hxx b/src/GEOM/GEOM_IOperations.hxx new file mode 100644 index 000000000..a14614c1b --- /dev/null +++ b/src/GEOM/GEOM_IOperations.hxx @@ -0,0 +1,66 @@ + +#ifndef _GEOM_IOperations_HXX_ +#define _GEOM_IOperations_HXX_ + +#include "GEOM_Engine.hxx" +#include +#include +#include "GEOM_Object.hxx" +#include "GEOM_Solver.hxx" + +#define OK "PAL_NO_ERROR" +#define KO "PAL_NOT_DONE_ERROR" +#define ALREADY_PRESENT "PAL_ELEMENT_ALREADY_PRESENT" +#define NOT_EXISTS "PAL_ELEMENT_DOES_NOT_EXISTS" +#define INVALID_TYPE "INVALID_TYPE_OF_ELEMENT" + +class GEOM_IOperations +{ + public: + GEOM_IOperations(GEOM_Engine* theEngine, int theDocID); + ~GEOM_IOperations(); + + //Starts a new operation (opens a tansaction) + void StartOperation(); + + //Finishes the previously started operation (closes the transaction) + void FinishOperation(); + + //Aborts the operation + void AbortOperation(); + + //Returns true if the last operation succided + bool IsDone(); + + //Sets Not done error code + void SetNotDone() { _errorCode = KO; } + + //Sets an error code of the operation + void SetErrorCode(const TCollection_AsciiString& theErrorCode) { + _errorCode = theErrorCode; + } + + //Returns an error code of the last operatioin + char* GetErrorCode() { + return _errorCode.ToCString(); + } + + //Returns a pointer to GEOM_Engine which this operation interface is associated + GEOM_Engine* GetEngine() { return _engine; } + + //Return a pointer to Solver associated with this operation interface + GEOM_Solver* GetSolver() { return _solver; } + + //Returns an ID of the OCAF document where this operation stores the data + int GetDocID() { return _docID; } + + private: + + TCollection_AsciiString _errorCode; + GEOM_Engine* _engine; + GEOM_Solver* _solver; + int _docID; + +}; + +#endif diff --git a/src/GEOM/GEOM_ISubShape.hxx b/src/GEOM/GEOM_ISubShape.hxx new file mode 100644 index 000000000..7ddf8919c --- /dev/null +++ b/src/GEOM/GEOM_ISubShape.hxx @@ -0,0 +1,34 @@ +// NOTE: This is an intreface to a function for the Shapes +// (Wire, Face, Shell, Solid and Compound) creation. + + +#include "GEOM_Function.hxx" + +#include "TColStd_HSequenceOfTransient.hxx" +#include "TColStd_HArray1OfInteger.hxx" + +#define SHAPE_ARG_MAIN_SHAPE 1 +#define SHAPE_ARG_INDICES 2 +#define SHAPE_ARG_SORTED 3 + +class GEOM_ISubShape +{ + public: + + GEOM_ISubShape(Handle(GEOM_Function) theFunction): _func(theFunction) {} + + void SetMainShape(Handle(GEOM_Function) theRefBase) + { _func->SetReference(SHAPE_ARG_MAIN_SHAPE, theRefBase); } + + Handle(GEOM_Function) GetMainShape() { return _func->GetReference(SHAPE_ARG_MAIN_SHAPE); } + + void SetIndices(const Handle(TColStd_HArray1OfInteger)& theIndices) + { _func->SetIntegerArray(SHAPE_ARG_INDICES, theIndices); } + + Handle(TColStd_HArray1OfInteger) GetIndices() + { return _func->GetIntegerArray(SHAPE_ARG_INDICES); } + + private: + + Handle(GEOM_Function) _func; +}; diff --git a/src/GEOM/GEOM_Object.cxx b/src/GEOM/GEOM_Object.cxx new file mode 100644 index 000000000..0fbfacbc7 --- /dev/null +++ b/src/GEOM/GEOM_Object.cxx @@ -0,0 +1,404 @@ +using namespace std; + +#include "GEOM_Object.hxx" +#include "GEOM_Engine.hxx" +#include "GEOM_Solver.hxx" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define TYPE 2 +#define FUNCTION_LABEL(theNb) (_label.FindChild(1).FindChild((theNb))) +#define FREE_LABEL 3 + +//======================================================================= +//function : GetObjectID +//purpose : +//======================================================================= +const Standard_GUID& GEOM_Object::GetObjectID() +{ + static Standard_GUID anObjectID("FF1BBB01-5D14-4df2-980B-3A668264EA16"); + return anObjectID; +} + +//======================================================================= +//function : GetSubShapeID +//purpose : +//======================================================================= +const Standard_GUID& GEOM_Object::GetSubShapeID() +{ + static Standard_GUID anObjectID("FF1BBB68-5D14-4df2-980B-3A668264EA16"); + return anObjectID; +} + +//============================================================================= +/*! + * GetObject + */ +//============================================================================= +Handle(GEOM_Object) GEOM_Object::GetObject(TDF_Label& theLabel) +{ + if (!theLabel.IsAttribute(GetObjectID())) return NULL; + + TCollection_AsciiString anEntry; + TDF_Tool::Entry(theLabel, anEntry); + + Handle(TDocStd_Document) aDoc = TDocStd_Owner::GetDocument(theLabel.Data()); + if(aDoc.IsNull()) return NULL; + + Handle(TDataStd_Integer) anID; + if(!aDoc->Main().FindAttribute(TDataStd_Integer::GetID(), anID)) return NULL; + + + GEOM_Engine* anEngine= GEOM_Engine::GetEngine(); + if(anEngine == NULL) return NULL; + return anEngine->GetObject(anID->Get(), anEntry.ToCString()); +} + +//============================================================================= +/*! + * GetReferencedObject + */ +//============================================================================= +Handle(GEOM_Object) GEOM_Object::GetReferencedObject(TDF_Label& theLabel) +{ + Handle(TDF_Reference) aRef; + if (!theLabel.FindAttribute(TDF_Reference::GetID(), aRef)) return NULL; + + // Get TreeNode of a referenced function + Handle(TDataStd_TreeNode) aT, aFather; + if (!TDataStd_TreeNode::Find(aRef->Get(), aT)) return NULL; + + // Get TreeNode of Object of the referenced function + aFather = aT->Father(); + if (aFather.IsNull()) return NULL; + + // Get label of the referenced object + TDF_Label aLabel = aFather->Label(); + + + return GEOM_Object::GetObject(aLabel); +} + +//============================================================================= +/*! + * Constructor: private + */ +//============================================================================= +GEOM_Object::GEOM_Object(TDF_Label& theEntry) +: _label(theEntry), _ior("") +{ + if(!theEntry.FindAttribute(TDataStd_TreeNode::GetDefaultTreeID(), _root)) + _root = TDataStd_TreeNode::Set(theEntry); +} + +//============================================================================= +/*! + * Constructor: public + */ +//============================================================================= +GEOM_Object::GEOM_Object(TDF_Label& theEntry, int theType) +: _label(theEntry), _ior("") +{ + theEntry.ForgetAllAttributes(Standard_True); + + if(!theEntry.FindAttribute(TDataStd_TreeNode::GetDefaultTreeID(), _root)) + _root = TDataStd_TreeNode::Set(theEntry); + + TDataStd_Integer::Set(theEntry.FindChild(TYPE), theType); + + TDataStd_UAttribute::Set(theEntry, GetObjectID()); +} + +//============================================================================= +/*! + * GetType + */ +//============================================================================= +int GEOM_Object::GetType() +{ + Handle(TDataStd_Integer) aType; + if(!_label.FindChild(TYPE).FindAttribute(TDataStd_Integer::GetID(), aType)) return -1; + + return aType->Get(); +} + +//============================================================================= +/*! + * SetType + */ +//============================================================================= +void GEOM_Object::SetType(int theType) +{ + TDataStd_Integer::Set(_label.FindChild(TYPE), theType); + return; +} + + +//============================================================================= +/*! + * GetDocID + */ +//============================================================================= +int GEOM_Object::GetDocID() +{ + Handle(TDocStd_Document) aDoc = TDocStd_Owner::GetDocument(_label.Data()); + if(aDoc.IsNull()) return -1; + + Handle(TDataStd_Integer) anID; + if(!aDoc->Main().FindAttribute(TDataStd_Integer::GetID(), anID)) return -1; + + return anID->Get(); +} + + +//============================================================================= +/*! + * GetValue + */ +//============================================================================= +TopoDS_Shape GEOM_Object::GetValue() +{ + TopoDS_Shape aShape; + + Handle(GEOM_Function) aFunction = GetLastFunction(); + + if (!aFunction.IsNull()) + aShape = aFunction->GetValue(); + + return aShape; +} + +//============================================================================= +/*! + * SetName + */ +//============================================================================= +void GEOM_Object::SetName(const char* theName) +{ + TDataStd_Name::Set(_label, (char*)theName); +} + +//============================================================================= +/*! + * GetName + */ +//============================================================================= +char* GEOM_Object::GetName() +{ + Handle(TDataStd_Name) aNameAttr; + if(!_label.FindAttribute(TDataStd_Name::GetID(), aNameAttr)) return NULL; + + TCollection_AsciiString aName(aNameAttr->Get()); + return aName.ToCString(); +} + +//============================================================================= +/*! + * SetAuxData + */ +//============================================================================= +void GEOM_Object::SetAuxData(const char* theData) +{ + TDataStd_Comment::Set(_label, (char*)theData); +} + +//============================================================================= +/*! + * GetAuxData + */ +//============================================================================= +char* GEOM_Object::GetAuxData() +{ + Handle(TDataStd_Comment) aCommentAttr; + if(!_label.FindAttribute(TDataStd_Comment::GetID(), aCommentAttr)) return NULL; + + TCollection_AsciiString aData(aCommentAttr->Get()); + return aData.ToCString(); +} + + +//============================================================================= +/*! + * IsSubShape + */ +//============================================================================= +bool GEOM_Object::IsMainShape() +{ + Handle(GEOM_Function) aFunction = GetFunction(1); + if(aFunction == NULL || aFunction->GetDriverGUID() != GetSubShapeID()) return true; + return false; +} + + +//============================================================================= +/*! + * AddFunction + */ +//============================================================================= +Handle(GEOM_Function) GEOM_Object::AddFunction(const Standard_GUID& theGUID, int theFunctionType) +{ + Standard_Integer nb = GetNbFunctions(); + if(nb == 1 && theGUID == GetSubShapeID()) return NULL; //It's impossible to add a function to sub shape + nb++; + TDF_Label aChild = FUNCTION_LABEL(nb); + + Handle(TDataStd_TreeNode) aNode = TDataStd_TreeNode::Set(aChild); + _root->Append(aNode); + + Handle(GEOM_Function) aFunction = new GEOM_Function(aChild, theGUID, theFunctionType); + + return aFunction; + +} + +//============================================================================= +/*! + * GetNbFunctions + */ +//============================================================================= +int GEOM_Object::GetNbFunctions() +{ + Standard_Integer nb = 0; + for(TDataStd_ChildNodeIterator CI(_root); CI.More(); CI.Next()) nb++; + return nb; +} + +//============================================================================= +/*! + * GetFunction + */ +//============================================================================= +Handle(GEOM_Function) GEOM_Object::GetFunction(int theFunctionNumber) +{ + TDF_Label aChild = FUNCTION_LABEL(theFunctionNumber); + return GEOM_Function::GetFunction(aChild); +} + +//============================================================================= +/*! + * GetlastFunction + */ +//============================================================================= +Handle(GEOM_Function) GEOM_Object::GetLastFunction() +{ + Standard_Integer nb = GetNbFunctions(); + if(nb) return GetFunction(nb); + + return NULL; +} + + +//============================================================================= +/*! + * GetAllDependency + */ +//============================================================================= +Handle(TColStd_HSequenceOfTransient) GEOM_Object::GetAllDependency() +{ + Handle(TColStd_HSequenceOfTransient) anArray; + TDF_LabelSequence aSeq; + Standard_Integer nb = GetNbFunctions(); + if(nb == 0) return anArray; + for(Standard_Integer i=1; i<=nb; i++) { + Handle(GEOM_Function) aFunction = GetFunction(i); + if(aFunction.IsNull()) continue; + aFunction->GetDependency(aSeq); + } + + Standard_Integer aLength = aSeq.Length(); + if(aLength > 0) { + anArray = new TColStd_HSequenceOfTransient; + for(Standard_Integer j =1; j<=aLength; j++) + anArray->Append(GetReferencedObject(aSeq(j))); + } + + return anArray; +} + +//============================================================================= +/*! + * GetLastDependency + */ +//============================================================================= +Handle(TColStd_HSequenceOfTransient) GEOM_Object::GetLastDependency() +{ + Handle(TColStd_HSequenceOfTransient) anArray; + Handle(GEOM_Function) aFunction = GetLastFunction(); + if (aFunction.IsNull()) return anArray; + + TDF_LabelSequence aSeq; + aFunction->GetDependency(aSeq); + Standard_Integer aLength = aSeq.Length(); + if (aLength > 0) { + anArray = new TColStd_HSequenceOfTransient; + for (Standard_Integer i = 1; i <= aLength; i++) + anArray->Append(GetReferencedObject(aSeq(i))); + } + + return anArray; +} + +//============================================================================= +/*! + * GetFreeLabel + */ +//============================================================================= +TDF_Label GEOM_Object::GetFreeLabel() +{ + return _label.FindChild(FREE_LABEL); +} + +//======================================================================= +//function : GEOM_Object_Type_ +//purpose : +//======================================================================= +Standard_EXPORT Handle_Standard_Type& GEOM_Object_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("GEOM_Object", + sizeof(GEOM_Object), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + return _aType; +} + +//======================================================================= +//function : DownCast +//purpose : +//======================================================================= + +const Handle(GEOM_Object) Handle(GEOM_Object)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOM_Object) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOM_Object))) { + _anOtherObject = Handle(GEOM_Object)((Handle(GEOM_Object)&)AnObject); + } + } + + return _anOtherObject ; +} + + diff --git a/src/GEOM/GEOM_Object.hxx b/src/GEOM/GEOM_Object.hxx new file mode 100644 index 000000000..0d1571d71 --- /dev/null +++ b/src/GEOM/GEOM_Object.hxx @@ -0,0 +1,237 @@ +#ifndef _GEOM_Object_HeaderFile +#define _GEOM_Object_HeaderFile + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Handle_MMgt_TShared_HeaderFile +#include +#endif +#ifndef _MMgt_TShared_HeaderFile +#include +#endif +#ifndef _Standard_GUID_HeaderFile +#include +#endif +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif +#ifndef _TDF_Label_HeaderFile +#include +#endif +#ifndef _TColStd_HSequenceOfTransient_HeaderFile +#include +#endif +#ifndef _TCollection_AsciiString_HeaderFile +#include +#endif + +class Handle_TColStd_HSequenceOfTransient; +class Standard_Transient; +class Handle_Standard_Type; +class Handle(MMgt_TShared); +class GEOM_Object; + + +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOM_Object); + +class Handle(GEOM_Object) : public Handle(MMgt_TShared) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + Handle(GEOM_Object)():Handle(MMgt_TShared)() {} + Handle(GEOM_Object)(const Handle(GEOM_Object)& aHandle) : Handle(MMgt_TShared)(aHandle) + { + } + + Handle(GEOM_Object)(const GEOM_Object* anItem) : Handle(MMgt_TShared)((MMgt_TShared *)anItem) + { + } + + Handle(GEOM_Object)& operator=(const Handle(GEOM_Object)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOM_Object)& operator=(const GEOM_Object* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOM_Object* operator->() + { + return (GEOM_Object *)ControlAccess(); + } + + GEOM_Object* operator->() const + { + return (GEOM_Object *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOM_Object)() {}; + + Standard_EXPORT static const Handle(GEOM_Object) DownCast(const Handle(Standard_Transient)& AnObject); +}; + + + +#include +#include +#include "GEOM_Function.hxx" +#include "GEOM_Engine.hxx" + + +class GEOM_Object : public MMgt_TShared +{ + friend class GEOM_Engine; + + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& GEOM_Object_Type_(); + Standard_EXPORT const Handle(Standard_Type)& DynamicType() const { return STANDARD_TYPE(GEOM_Object) ; } + Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const { return (STANDARD_TYPE(GEOM_Object) == AType || MMgt_TShared::IsKind(AType)); } + + private: + GEOM_Object(TDF_Label& theLabel); + + public: + GEOM_Object(TDF_Label& theEntry, int theType); + ~GEOM_Object() {;} + + //Finds a GEOM_Object on the label theLabel + static Handle(GEOM_Object) GetObject(TDF_Label& theLabel); + + //Finds a GEOM_Object by a reference, stored on the label theLabel + static Handle(GEOM_Object) GetReferencedObject(TDF_Label& theLabel); + + //Returns a GEOM_Object common GUID + static const Standard_GUID& GetObjectID(); + + //Returns a GUID associated with a sub shape object + static const Standard_GUID& GetSubShapeID(); + + //########################################################### + //Access to properties + //########################################################### + + //Returns a TreeNode that presents a root of a function tree for this GEOM_Object + Handle(TDataStd_TreeNode) GetRootNode() { return _root; } + + //Returns a label of this GEOM_Object + TDF_Label GetEntry() { return _label; } + + //Returns a type of this GEOM_Object (GEOM_POINT, GEOM_VECTOR...) + int GetType(); + + //Sets the type of this GEOM_Object + void SetType(int theType); + + //Returns an ID of the OCAF document where this GEOM_Object is stored + int GetDocID(); + + //Returns a value (as TopoDS_Shape) of this GEOM_Object + TopoDS_Shape GetValue(); + + //Sets a name of this GEOM_Object + void SetName(const char* theName); + + //Returns a name of this GEOM_Object + char* GetName(); + + //Sets an auxiliary data + void SetAuxData(const char* theData); + + //Returns an auxiliary data + char* GetAuxData(); + + //########################################################### + // Sub shape methods + //########################################################### + + //Returns false if the object is a sub shape of another object + bool IsMainShape(); + + //########################################################### + // CORBA related methods + //########################################################### + + //Sets an IOR of CORBA GEOM_Object_i which refers to this object + void SetIOR(TCollection_AsciiString& theIOR) { _ior = theIOR; } + + //Returns an IOR of CORBA GEOM_Object_i which refers to this object + TCollection_AsciiString GetIOR() { return _ior; } + + //########################################################### + //Functions methods + //########################################################### + + //Adds a function with a driver GUID = theGUID and a type theFunctionType to the function tree of this GEOM_Object + Handle(GEOM_Function) AddFunction(const Standard_GUID& theGUID, int theFunctionType); + + //Returns a number of functions of this GEOM_Object + int GetNbFunctions(); + + //Returns a function with given number theFunctionNumber + Handle(GEOM_Function) GetFunction(int theFunctionNumber); + + //Return the last function of this GEOM_Object + Handle(GEOM_Function) GetLastFunction(); + + //Returns all dependencies of the object + Handle(TColStd_HSequenceOfTransient) GetAllDependency(); + + //Returns the dependencies of the last function + Handle(TColStd_HSequenceOfTransient) GetLastDependency(); + + //########################################################### + // Internal methods + //########################################################### + + //Returns a label which could be used to store some additional data + TDF_Label GetFreeLabel(); + + + private: + + Handle(TDataStd_TreeNode) _root; + TDF_Label _label; + TCollection_AsciiString _ior; +}; + +#endif diff --git a/src/GEOM/GEOM_Shape_i.cc b/src/GEOM/GEOM_Shape_i.cc deleted file mode 100644 index bd2110d50..000000000 --- a/src/GEOM/GEOM_Shape_i.cc +++ /dev/null @@ -1,260 +0,0 @@ -// GEOM GEOM : implementaion of GEOM_Gen.idl and GEOM_Shape.idl -// -// 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 : GEOM_Shape_i.cc -// Author : Lucien PIGNOLONI -// Module : GEOM -// $Header$ - -#include -#include - -#include -#include - -#include "GEOM_Shape_i.hh" -#include "SALOME_NamingService.hxx" - -using namespace std; - - -//================================================================================= -// function : GEOM_Shape_i() constructor (no arguments) -// purpose : for what now ? -//================================================================================= -GEOM_Shape_i::GEOM_Shape_i() { } - - - -//================================================================================= -// function : constructor -// purpose : constructor for servant creation -//================================================================================= -GEOM_Shape_i::GEOM_Shape_i(TopoDS_Shape geom, - CORBA::ORB_ptr orb, - GEOM::GEOM_Gen_ptr engine, - const GEOM::GEOM_Shape::ListOfSubShapeID& index, - GEOM::shape_type sht, - bool ismain) { - _geom = geom; - _orb = orb; - _engine = engine; - _shapetype = sht ; - _ismain = ismain; - _index = index ; - - _shapeid = ""; - _studyshapeid = ""; - - _name = ""; - _mainname =""; - _nametype =""; - -} - - - -//================================================================================= -// function : destructor -// purpose : deleting the internal geometry structure -//================================================================================= -GEOM_Shape_i::~GEOM_Shape_i() { delete &_geom; } - - -//================================================================================= -// function : Name (set method) -// purpose : to set the attribute 'name' of this shape. -// : WARNING : Register to naming service actually removed ! -//================================================================================= -void GEOM_Shape_i::Name(const char* name) { - _name = CORBA::string_dup(name); - GEOM::GEOM_Shape_ptr g = GEOM::GEOM_Shape::_narrow(_this()); - - // Removed declaration of shapes to naming service - //SALOME_NamingService * ns = new SALOME_NamingService(_orb); - //ns->Register(g, _name); -} - - -//================================================================================= -// function : Name (get method) -// purpose : to get the attribute 'name' of this shape -//================================================================================= -char* GEOM_Shape_i::Name() { return CORBA::string_dup(_name); } - -//================================================================================= -// function : MainName (set method) -// purpose : to set the attribute 'name' of this mainshape. -//================================================================================= -void GEOM_Shape_i::MainName(const char* name) { - _mainname = CORBA::string_dup(name); -} - - -//================================================================================= -// function : MainName (get method) -// purpose : to get the attribute 'name' of this shape -//================================================================================= -char* GEOM_Shape_i::MainName() { return CORBA::string_dup(_mainname); } - -//================================================================================= -// function : IsMainShape (get method) -// purpose : return 'true' if this is a main shape (not a sub shape) -//================================================================================= -bool GEOM_Shape_i::IsMainShape() { return _ismain ; } - - -//================================================================================= -// function : IsMainShape (set method) -// purpose : to set the property 'ismain' true or false of this shape -//================================================================================= -void GEOM_Shape_i::IsMainShape(const bool abool) { _ismain = abool ; } - - -//================================================================================= -// function : ShapeId -// purpose : to get the id of this shape from GEOM (OCAF entry) -//================================================================================= -char* GEOM_Shape_i::ShapeId() { return CORBA::string_dup(_shapeid) ; } - - -//================================================================================= -// function : ShapeId (set method) -// purpose : to set the id of this shape in GEOM/OCAF doc -//================================================================================= -void GEOM_Shape_i::ShapeId(const char * shapeid) { _shapeid = CORBA::string_dup(shapeid) ; } - - - -//================================================================================= -// function : StudyShapeId (get method) -// purpose : to get the id of this shape from the study document (OCAF entry) -//================================================================================= -char* GEOM_Shape_i::StudyShapeId() { return CORBA::string_dup(_studyshapeid) ; } - - -//================================================================================= -// function : StudyShapeId (set method) -// purpose : to set the id of this shape in the Study document (OCAF entry) -//================================================================================= -void GEOM_Shape_i::StudyShapeId(const char * studyshapeid) -{ _studyshapeid = CORBA::string_dup(studyshapeid) ; } - - - -//================================================================================= -// function : Index (get method) -// purpose : to get the index of this sub shape in its main shape -//================================================================================= -GEOM::GEOM_Shape::ListOfSubShapeID* GEOM_Shape_i::Index() { - unsigned int _length = _index.length(); - GEOM::GEOM_Shape::ListOfSubShapeID_var _list = new GEOM::GEOM_Shape::ListOfSubShapeID; - _list->length(_length); - - for (unsigned int ind = 0; ind < _length; ind++) { - _list[ind] = _index[ind]; - } - - return _list._retn() ; -} - - -//================================================================================= -// function : Index (set method) -// purpose : to set the index of this sub shape (in a main shape) -//================================================================================= -void GEOM_Shape_i::Index(const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfSubShapeID) -{ _index = ListOfSubShapeID ; } - - -//================================================================================= -// function : ShapeType (get method) -// purpose : to get the topological type of this shape as defined in enum of IDL file -//================================================================================= -GEOM::shape_type GEOM_Shape_i::ShapeType() { return _shapetype ; } - - -//================================================================================= -// function : SetType (set method) -// purpose : to set the topological type of this shape (see GetType) -//================================================================================= -void GEOM_Shape_i::ShapeType(GEOM::shape_type sht) { _shapetype = sht ; } - - -//================================================================================= -// function : NameType (set method) -// purpose : to set the attribute 'nametype' of this shape. -//================================================================================= -void GEOM_Shape_i::NameType(const char* name) { -} - -//================================================================================= -// function : NameType (get method) -// purpose : to get the attribute 'nametype' of this shape -//================================================================================= -char* GEOM_Shape_i::NameType() { return CORBA::string_dup(_nametype); } - -//================================================================================= -// function : GetShapeStream -// Transfer resulting shape to client as sequence of bytes -//client can extract shape from stream using BrepTools::Read function -//================================================================================= -GEOM::GEOM_Shape::TMPFile* GEOM_Shape_i::GetShapeStream() -{ - ostrstream streamShape; - //Write TopoDS_Shape in ASCII format to the stream - BRepTools::Write(_geom, streamShape); - //Returns the number of bytes that have been stored in the stream's buffer. - int size = streamShape.pcount(); - char* buf = new char [size]; - //Get pointer on internal character array in ostrstream - char* valueOfStream = streamShape.str(); - //Create copy of ostrstream content - memcpy(buf, valueOfStream, size); - //Allow automatic deletion of ostrstream content - streamShape.rdbuf()->freeze(0); - - CORBA::Octet* OctetBuf = (CORBA::Octet*)buf; - GEOM::GEOM_Shape::TMPFile_var SeqFile = new GEOM::GEOM_Shape::TMPFile(size,size,OctetBuf,1); - return SeqFile._retn(); - -} - -//======================================================================= -//function : Engine -//purpose : return generator engine -//======================================================================= - -GEOM::GEOM_Gen_ptr GEOM_Shape_i::Engine() -{ - return _engine; -} - -//======================================================================= -//function : getShape -//purpose : return the TopoDS_Shape when client and servant are colocated, be careful -//======================================================================= - -long GEOM_Shape_i::getShape() { - return((long)(&_geom)); -} diff --git a/src/GEOM/GEOM_Shape_i.hh b/src/GEOM/GEOM_Shape_i.hh deleted file mode 100644 index bf114b937..000000000 --- a/src/GEOM/GEOM_Shape_i.hh +++ /dev/null @@ -1,119 +0,0 @@ -// GEOM GEOM : implementaion of GEOM_Gen.idl and GEOM_Shape.idl -// -// 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 : GEOM_Shape_i.hh -// Author : Lucien PIGNOLONI -// Module : GEOM -// $Header$ - -#ifndef __GEOM_SHAPE_I_H__ -#define __GEOM_SHAPE_I_H__ - -// SALOME config header -#include - -// Standard C++ headers -#include - -// IDL headers -#include CORBA_SERVER_HEADER(GEOM_Gen) -#include CORBA_SERVER_HEADER(GEOM_Shape) - -// Cascade headers -#include -#include -#include -#include -#include -#include - - -//===================================================================== -// GEOM_Shape_i : class definition -//===================================================================== -class GEOM_Shape_i: public POA_GEOM::GEOM_Shape, - public PortableServer::RefCountServantBase { -private: - - TopoDS_Shape _geom; - CORBA::ORB_ptr _orb; - GEOM::GEOM_Gen_ptr _engine; - - GEOM::shape_type _shapetype ; // enum defined in the IDL file (Occ topol. type of a shape) - bool _ismain; - GEOM::GEOM_Shape::ListOfSubShapeID _index; - char* _name; - char* _mainname; - char* _shapeid; - char* _studyshapeid; // exists only if added in the study document - char* _nametype; - - -public: - - // no-arg constructor, doing nothing (for now ?) - GEOM_Shape_i(); - - // constructor to be called for servant creation - GEOM_Shape_i(TopoDS_Shape geom, - CORBA::ORB_ptr orb, - GEOM::GEOM_Gen_ptr engine, - const GEOM::GEOM_Shape::ListOfSubShapeID& index, - GEOM::shape_type sht = GEOM::SHAPE, - bool ismain = true); - - // destructor deleting the internal geometry structure - ~GEOM_Shape_i(); - - char* Name(); - void Name(const char* name); - - char* MainName(); - void MainName(const char* name); - - char* NameType(); - void NameType(const char* name); - - bool IsMainShape(); - void IsMainShape(const bool abool); - - char* ShapeId(); - void ShapeId(const char* shapeid); - - char* StudyShapeId(); - void StudyShapeId(const char* studyshapeid); - - GEOM::GEOM_Shape::ListOfSubShapeID* Index(); - void Index(const GEOM::GEOM_Shape::ListOfSubShapeID&); - - GEOM::shape_type ShapeType(); - void ShapeType(GEOM::shape_type sht); - - GEOM::GEOM_Shape::TMPFile* GetShapeStream(); - - GEOM::GEOM_Gen_ptr Engine(); - - long getShape(); -}; - -#endif diff --git a/src/GEOM/GEOM_Solver.cxx b/src/GEOM/GEOM_Solver.cxx new file mode 100644 index 000000000..bdecce3cd --- /dev/null +++ b/src/GEOM/GEOM_Solver.cxx @@ -0,0 +1,50 @@ + +#include "GEOM_Solver.hxx" +#include +#include +#include +#include +#include +#include "GEOM_Function.hxx" +#include + +//============================================================================= +/*! + * Update + */ +//============================================================================= +bool GEOM_Solver::Update(int theDocID, TDF_LabelSequence& theSeq) +{ + return false; +} + +//============================================================================= +/*! + * UpdateObject + */ +//============================================================================= +bool GEOM_Solver::UpdateObject(Handle(GEOM_Object) theObject, TDF_LabelSequence& theSeq) +{ + return false; +} + +//============================================================================= +/*! + * ComputeFunction + */ +//============================================================================= +bool GEOM_Solver::ComputeFunction(Handle(GEOM_Function) theFunction) +{ + if(theFunction == NULL) return false; + Standard_GUID aGUID = theFunction->GetDriverGUID(); + + Handle(TFunction_Driver) aDriver; + if(!TFunction_DriverTable::Get()->FindDriver(aGUID, aDriver)) return false; + + aDriver->Init(theFunction->GetEntry()); + + TFunction_Logbook aLog; + if(aDriver->Execute(aLog) == 0) return false; + + return true; +} diff --git a/src/GEOM/GEOM_Solver.hxx b/src/GEOM/GEOM_Solver.hxx new file mode 100644 index 000000000..215402f2b --- /dev/null +++ b/src/GEOM/GEOM_Solver.hxx @@ -0,0 +1,34 @@ + +#ifndef _GEOM_Solver_HXX_ +#define _GEOM_Solver_HXX_ + +#include "GEOM_Engine.hxx" +#include "GEOM_Object.hxx" +#include "GEOM_Function.hxx" + +#include + +class GEOM_Solver +{ + public: + GEOM_Solver(GEOM_Engine* theEngine) :_engine(theEngine) {} + ~GEOM_Solver() {} + + //Update the values of all GEOM_Object in the document theDocID, theSeq will contain a list of touched labels + //Note: not Implemented + bool Update(int theDocID, TDF_LabelSequence& theSeq); + + //Updates a value of theObject, theSeq will contain a list of touched labels + //Note: not implemented + bool UpdateObject(Handle(GEOM_Object) theObject, TDF_LabelSequence& theSeq); + + //Recomputes a function + bool ComputeFunction(Handle(GEOM_Function) theFunction); + + private: + + GEOM_Engine* _engine; + +}; + +#endif diff --git a/src/GEOM/GEOM_SubShapeDriver.cxx b/src/GEOM/GEOM_SubShapeDriver.cxx new file mode 100644 index 000000000..9e6564752 --- /dev/null +++ b/src/GEOM/GEOM_SubShapeDriver.cxx @@ -0,0 +1,150 @@ + +using namespace std; +#include "GEOM_SubShapeDriver.hxx" +#include "GEOM_ISubShape.hxx" +#include "GEOM_Function.hxx" +#include "GEOM_Object.hxx" + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + + +//======================================================================= +//function : GEOM_SubShapeDriver +//purpose : +//======================================================================= +GEOM_SubShapeDriver::GEOM_SubShapeDriver() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer GEOM_SubShapeDriver::Execute(TFunction_Logbook& log) const +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); + + GEOM_ISubShape aCI (aFunction); + + TDF_Label aLabel = aCI.GetMainShape()->GetOwnerEntry(); + if (aLabel.IsRoot()) return 0; + Handle(GEOM_Object) anObj = GEOM_Object::GetObject(aLabel); + if (anObj.IsNull()) return 0; + TopoDS_Shape aMainShape = anObj->GetValue(); + if (aMainShape.IsNull()) return 0; + + Handle(TColStd_HArray1OfInteger) anIndices = aCI.GetIndices(); + if (anIndices.IsNull() || anIndices->Length() <= 0) return 0; + + BRep_Builder B; + TopoDS_Compound aCompound; + TopoDS_Shape aShape; + + if (anIndices->Length() == 1 && anIndices->Value(1) == -1) { //The empty subshape + B.MakeCompound(aCompound); + aShape = aCompound; + + } else { + + TopTools_IndexedMapOfShape aMapOfShapes; + TopExp::MapShapes(aMainShape, aMapOfShapes); + + if (anIndices->Length() > 1) { + + B.MakeCompound(aCompound); + + for (int i = anIndices->Lower(); i<= anIndices->Upper(); i++) { + if (aMapOfShapes.Extent() < anIndices->Value(i)) + Standard_NullObject::Raise("GEOM_SubShapeDriver::Execute: Index is out of range"); + TopoDS_Shape aSubShape = aMapOfShapes.FindKey(anIndices->Value(i)); + if (aSubShape.IsNull()) continue; + B.Add(aCompound,aSubShape); + } + + aShape = aCompound; + + } else { + + if (aMapOfShapes.Extent() < anIndices->Value(1)) + Standard_NullObject::Raise("GEOM_SubShapeDriver::Execute: Index is out of range"); + aShape = aMapOfShapes.FindKey(anIndices->Value(1)); + } + } + + if (aShape.IsNull()) return 0; + + aFunction->SetValue(aShape); + + log.SetTouched(Label()); + + return 1; +} + + +//======================================================================= +//function : GEOM_SubShapeDriver_Type_ +//purpose : +//======================================================================= +Standard_EXPORT Handle_Standard_Type& GEOM_SubShapeDriver_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); + 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("GEOM_SubShapeDriver", + sizeof(GEOM_SubShapeDriver), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + +//======================================================================= +//function : DownCast +//purpose : +//======================================================================= +const Handle(GEOM_SubShapeDriver) Handle(GEOM_SubShapeDriver)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOM_SubShapeDriver) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOM_SubShapeDriver))) { + _anOtherObject = Handle(GEOM_SubShapeDriver)((Handle(GEOM_SubShapeDriver)&)AnObject); + } + } + + return _anOtherObject ; +} diff --git a/src/GEOM/GEOM_SubShapeDriver.hxx b/src/GEOM/GEOM_SubShapeDriver.hxx new file mode 100644 index 000000000..a1f9b331e --- /dev/null +++ b/src/GEOM/GEOM_SubShapeDriver.hxx @@ -0,0 +1,139 @@ +// File : GEOMImpl_ShapeDriver.ixx +// Module : GEOM + +#ifndef _GEOM_SubShapeDriver_HeaderFile +#define _GEOM_SubShapeDriver_HeaderFile + +#ifndef _TColStd_SequenceOfExtendedString_HeaderFile +#include +#endif +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_GUID_HeaderFile +#include +#endif + +#ifndef _Handle_TFunction_Driver_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TFunction_Driver); +class GEOM_SubShapeDriver; + +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOM_SubShapeDriver); + +class Handle(GEOM_SubShapeDriver) : public Handle(TFunction_Driver) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + Handle(GEOM_SubShapeDriver)():Handle(TFunction_Driver)() {} + Handle(GEOM_SubShapeDriver)(const Handle(GEOM_SubShapeDriver)& aHandle) : Handle(TFunction_Driver)(aHandle) + { + } + + Handle(GEOM_SubShapeDriver)(const GEOM_SubShapeDriver* anItem) : Handle(TFunction_Driver)((TFunction_Driver *)anItem) + { + } + + Handle(GEOM_SubShapeDriver)& operator=(const Handle(GEOM_SubShapeDriver)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOM_SubShapeDriver)& operator=(const GEOM_SubShapeDriver* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOM_SubShapeDriver* operator->() + { + return (GEOM_SubShapeDriver *)ControlAccess(); + } + + GEOM_SubShapeDriver* operator->() const + { + return (GEOM_SubShapeDriver *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOM_SubShapeDriver)() {}; + + Standard_EXPORT static const Handle(GEOM_SubShapeDriver) DownCast(const Handle(Standard_Transient)& AnObject); +}; + +#ifndef _TFunction_Driver_HeaderFile +#include +#endif +#ifndef _TFunction_Logbook_HeaderFile +#include +#endif +#ifndef _Standard_CString_HeaderFile +#include +#endif + +class TColStd_SequenceOfExtendedString; + + +class GEOM_SubShapeDriver : public TFunction_Driver { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + // Methods PUBLIC + // +Standard_EXPORT GEOM_SubShapeDriver(); +Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; +Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {} +Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const { return Standard_True; } +Standard_EXPORT static const Standard_GUID& GetID(); +Standard_EXPORT ~GEOM_SubShapeDriver() {}; + + + // Type management + // +Standard_EXPORT friend Handle_Standard_Type& GEOM_SubShapeDriver_Type_(); +Standard_EXPORT const Handle(Standard_Type)& DynamicType() const { return STANDARD_TYPE(GEOM_SubShapeDriver) ; } +Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const { return (STANDARD_TYPE(GEOM_SubShapeDriver) == AType || TFunction_Driver::IsKind(AType)); } + + +}; + +#endif diff --git a/src/GEOM/Handle_GEOM_Application.hxx b/src/GEOM/Handle_GEOM_Application.hxx new file mode 100644 index 000000000..f1dfa9edc --- /dev/null +++ b/src/GEOM/Handle_GEOM_Application.hxx @@ -0,0 +1,77 @@ +// File : Handle_GEOM_Application.hxx +// Module : GEOM + +#ifndef _Handle_GEOM_Application_HeaderFile +#define _Handle_GEOM_Application_HeaderFile + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Handle_TDocStd_Application_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TDocStd_Application); +class GEOM_Application; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(SimpleOCAF_Application); + +class Handle(GEOM_Application) : public Handle(TDocStd_Application) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + Handle(GEOM_Application)():Handle(TDocStd_Application)() {} + Handle(GEOM_Application)(const Handle(GEOM_Application)& aHandle) : Handle(TDocStd_Application)(aHandle) + { + } + + Handle(GEOM_Application)(const GEOM_Application* anItem) : Handle(TDocStd_Application)((TDocStd_Application *)anItem) + { + } + + Handle(GEOM_Application)& operator=(const Handle(GEOM_Application)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOM_Application)& operator=(const GEOM_Application* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOM_Application* operator->() + { + return (GEOM_Application *)ControlAccess(); + } + + GEOM_Application* operator->() const + { + return (GEOM_Application *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOM_Application)(); + + Standard_EXPORT static const Handle(GEOM_Application) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/GEOM/Handle_GEOM_DataMapNodeOfDataMapOfAsciiStringTransient.hxx b/src/GEOM/Handle_GEOM_DataMapNodeOfDataMapOfAsciiStringTransient.hxx new file mode 100644 index 000000000..f93d44766 --- /dev/null +++ b/src/GEOM/Handle_GEOM_DataMapNodeOfDataMapOfAsciiStringTransient.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_GEOM_DataMapNodeOfDataMapOfAsciiStringTransient_HeaderFile +#define _Handle_GEOM_DataMapNodeOfDataMapOfAsciiStringTransient_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 GEOM_DataMapNodeOfDataMapOfAsciiStringTransient; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOM_DataMapNodeOfDataMapOfAsciiStringTransient); + +class Handle(GEOM_DataMapNodeOfDataMapOfAsciiStringTransient) : 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(GEOM_DataMapNodeOfDataMapOfAsciiStringTransient)():Handle(TCollection_MapNode)() {} + Handle(GEOM_DataMapNodeOfDataMapOfAsciiStringTransient)(const Handle(GEOM_DataMapNodeOfDataMapOfAsciiStringTransient)& aHandle) : Handle(TCollection_MapNode)(aHandle) + { + } + + Handle(GEOM_DataMapNodeOfDataMapOfAsciiStringTransient)(const GEOM_DataMapNodeOfDataMapOfAsciiStringTransient* anItem) : Handle(TCollection_MapNode)((TCollection_MapNode *)anItem) + { + } + + Handle(GEOM_DataMapNodeOfDataMapOfAsciiStringTransient)& operator=(const Handle(GEOM_DataMapNodeOfDataMapOfAsciiStringTransient)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOM_DataMapNodeOfDataMapOfAsciiStringTransient)& operator=(const GEOM_DataMapNodeOfDataMapOfAsciiStringTransient* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOM_DataMapNodeOfDataMapOfAsciiStringTransient* operator->() + { + return (GEOM_DataMapNodeOfDataMapOfAsciiStringTransient *)ControlAccess(); + } + + GEOM_DataMapNodeOfDataMapOfAsciiStringTransient* operator->() const + { + return (GEOM_DataMapNodeOfDataMapOfAsciiStringTransient *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOM_DataMapNodeOfDataMapOfAsciiStringTransient)(); + + Standard_EXPORT static const Handle(GEOM_DataMapNodeOfDataMapOfAsciiStringTransient) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/GEOM/Makefile.in b/src/GEOM/Makefile.in index a15b57b8b..d61a7fa10 100644 --- a/src/GEOM/Makefile.in +++ b/src/GEOM/Makefile.in @@ -1,30 +1,3 @@ -# GEOM GEOM : implementaion of GEOM_Gen.idl and GEOM_Shape.idl -# -# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -# -# -# -# File : Makefile.in -# Author : Patrick GOLDBRONN (CEA) -# Module : GEOM -# $Header$ top_srcdir=@top_srcdir@ top_builddir=../.. @@ -36,22 +9,44 @@ VPATH=.:@srcdir@:@top_srcdir@/idl # Libraries targets -LIB = libGEOMEngine.la -LIB_SRC = GEOM_Shape_i.cc GEOM_Gen_i.cc -LIB_SERVER_IDL = SALOME_Component.idl SALOMEDS.idl SALOME_Exception.idl GEOM_Gen.idl GEOM_Shape.idl +LIB = libGEOMbasic.la +LIB_SRC = GEOM_Application.cxx \ + GEOM_Engine.cxx \ + GEOM_Function.cxx \ + GEOM_Object.cxx \ + GEOM_IOperations.cxx \ + GEOM_Solver.cxx \ + GEOM_SubShapeDriver.cxx \ + GEOM_DataMapNodeOfDataMapOfAsciiStringTransient_0.cxx \ + GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient_0.cxx \ + GEOM_DataMapOfAsciiStringTransient_0.cxx + +LIB_CLIENT_IDL = +LIB_SERVER_IDL = # Executables targets -BIN = -BIN_SRC = +BIN = +BIN_SRC = BIN_CLIENT_IDL = -BIN_SERVER_IDL = - -EXPORT_HEADERS = +BIN_SERVER_IDL = + +# header files +EXPORT_HEADERS= GEOM_Application.hxx \ + Handle_GEOM_Application.hxx \ + GEOM_Engine.hxx \ + GEOM_Function.hxx \ + GEOM_Object.hxx \ + GEOM_IOperations.hxx \ + GEOM_ISubShape.hxx \ + GEOM_Solver.hxx \ + GEOM_DataMapOfAsciiStringTransient.hxx \ + Handle_GEOM_DataMapNodeOfDataMapOfAsciiStringTransient.hxx # additionnal information to compil and link file -CPPFLAGS += $(OCC_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome +CPPFLAGS += $(OCC_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome $(BOOST_CPPFLAGS) CXXFLAGS += $(OCC_CXXFLAGS) -I${KERNEL_ROOT_DIR}/include/salome -LDFLAGS += -lGEOMDS -lTOOLSDS -lSalomeNS -lSalomeContainer -lGEOMPartition -lGEOMArchimede $(CAS_LDPATH) -lTKIGES -lTKSTEP -lTKFillet -lTKOffset -lGEOMSketcher -L${KERNEL_ROOT_DIR}/lib/salome +LDFLAGS += -L${KERNEL_ROOT_DIR}/lib/salome $(CAS_LDPATH) -lTKCAF + # additional file to be cleaned MOSTLYCLEAN = diff --git a/src/GEOM/geom.cxx b/src/GEOM/geom.cxx index 37707e720..81517451a 100644 --- a/src/GEOM/geom.cxx +++ b/src/GEOM/geom.cxx @@ -1,4 +1,4 @@ -// GEOM GEOM : implementaion of GEOM_Gen.idl and GEOM_Shape.idl +// GEOM GEOM : implementaion of GEOM_Gen.idl // // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS diff --git a/src/GEOMBase/GEOMBase.cxx b/src/GEOMBase/GEOMBase.cxx index 9e7925e68..878cf93e9 100644 --- a/src/GEOMBase/GEOMBase.cxx +++ b/src/GEOMBase/GEOMBase.cxx @@ -24,27 +24,36 @@ // File : GEOMBase.cxx // Author : Damien COQUERET // Module : GEOM -// $Header: +// $Header$ -using namespace std; #include "GEOMBase.h" +#include "GeometryGUI.h" +#include "GEOMBase_aParameterDlg.h" //// SALOME Includes -# include "Utils_ORB_INIT.hxx" -# include "Utils_SINGLETON.hxx" +#include "Utils_ORB_INIT.hxx" +#include "Utils_SINGLETON.hxx" +#include "QAD_Config.h" +#include "QAD_Desktop.h" #include "QAD_RightFrame.h" #include "QAD_MessageBox.h" #include "QAD_Resource.h" +#include "QAD_MessageBox.h" +#include "SALOME_Selection.h" #include "GEOM_AssemblyBuilder.h" +#include "GEOM_Actor.h" #include "VTKViewer_ViewFrame.h" +#include "VTKViewer_RenderWindowInteractor.h" #include "OCCViewer_ViewPort3d.h" #include "OCCViewer_Viewer3d.h" +#include "OCCViewer_ViewFrame.h" #include "SALOME_ListIteratorOfListIO.hxx" +#include "GEOM_AISTrihedron.hxx" #include "SALOMEGUI_ImportOperation.h" -#include "SALOMEGUI_NameDlg.h" +#include "SALOMEGUI_NameDlg.h" // // Open CASCADE Includes #include @@ -54,6 +63,7 @@ using namespace std; #include #include +#include #include #include @@ -62,68 +72,24 @@ using namespace std; #include #include #include +#include #include -// // QT Includes -#include +#include +#include +#include -#include "GEOMBase_aParameterDlg.h" - -//================================================================================= -// class : CustomItem -// purpose : Set Font to a text. -//================================================================================= -class CustomItem : public QCustomMenuItem -{ -public: - CustomItem(const QString& s, const QFont& f) - :string(s), font(f){}; - ~CustomItem(){} - - void paint(QPainter* p, const QColorGroup& /*cg*/, bool /*act*/, - bool /*enabled*/, int x, int y, int w, int h) - { - p->setFont(font); - p->drawText(x, y, w, h, AlignHCenter | AlignVCenter | ShowPrefix | DontClip, string); - } - - QSize sizeHint() - { - return QFontMetrics(font).size(AlignHCenter | AlignVCenter | ShowPrefix | DontClip, string); - } - -private: - QString string; - QFont font; - -}; +#include "GEOMImpl_Types.hxx" +using namespace std; //======================================================================= // function : GEOMBase() // purpose : Constructor //======================================================================= -GEOMBase::GEOMBase() : - QObject() +GEOMBase::GEOMBase() { - myGeomGUI = GEOMContext::GetGeomGUI(); - myGeom = myGeomGUI->myComponentGeom; - - /* Shading Color */ - QString SCr = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorRed"); - QString SCg = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorGreen"); - QString SCb = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorBlue"); - if(!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty()) - myShadingColor = Quantity_Color(SCr.toInt()/255., SCg.toInt()/255., SCb.toInt()/255., Quantity_TOC_RGB); - else - myShadingColor = Quantity_Color(Quantity_NOC_GOLDENROD); - - QString AddInStudy = QAD_CONFIG->getSetting("Geometry:SettingsAddInStudy"); - if(!AddInStudy.isEmpty()) - mySettings_AddInStudy = AddInStudy.toInt(); - else - mySettings_AddInStudy = 1; } @@ -135,654 +101,6 @@ GEOMBase::~GEOMBase() { } - -//================================================================================= -// function : CustomPopup() -// purpose : [static] -//================================================================================= -bool GEOMBase::CustomPopup(QAD_Desktop* parent, QPopupMenu* popup, const QString& theContext, - const QString& theParent, const QString& theObject) -{ - GEOMBase* myGeomBase = new GEOMBase(); - QAD_Study* ActiveStudy = parent->getActiveStudy(); - - /* Deactivate any non modal dialog box to get the neutral point */ - myGeomBase->myGeomGUI->EmitSignalDeactivateDialog(); - - SALOME_Selection* Sel = SALOME_Selection::Selection(ActiveStudy->getSelection()); - int nbSel = Sel->IObjectCount(); - - if((nbSel == 0)) - return false; - - if(ActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)ActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - Handle(AIS_InteractiveContext) ic = v3d->getAISContext(); - if(theParent.compare("Viewer") == 0) { - if(theObject.compare("Component") == 0) { - popup->removeItem(QAD_DisplayOnly_Popup_ID); - return true; - } - else { - QFont f = QApplication::font(); - f.setBold(TRUE); - if(nbSel == 1) { - Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject(); - popup->removeItem(QAD_TopLabel_Popup_ID); - popup->insertItem(new CustomItem (QString(IObject->getName()), f), QAD_TopLabel_Popup_ID, 0); - if(IObject->hasEntry()) - popup->setItemEnabled(804, false); //Add in Study Menu - else - popup->setItemEnabled(804, true); //Add in Study Menu - - if(IObject->IsKind(STANDARD_TYPE(GEOM_InteractiveObject))) { - Standard_Boolean found; - Handle(GEOM_AISShape) Result = myGeomBase->ConvertIOinGEOMAISShape(IObject, found, true); - - if(found) { - if(Result->DisplayMode() == 1) - popup->changeItem(8031, tr("GEOM_MEN_WIREFRAME")); //Shading/Wireframe Menu - else - popup->changeItem(8031, tr("GEOM_MEN_SHADING")); //Shading/Wireframe Menu - } - } - - if(!(v3d->isInViewer(IObject) && v3d->isVisible(IObject))) - popup->removeItem(QAD_Erase_Popup_ID); - else - popup->removeItem(QAD_Display_Popup_ID); - } - else { - popup->removeItem(QAD_DisplayOnly_Popup_ID); - popup->removeItem(QAD_TopLabel_Popup_ID); - popup->insertItem(new CustomItem (tr("GEOM_MEN_POPUP_NAME").arg(nbSel), f), QAD_TopLabel_Popup_ID, 0); - popup->setItemEnabled(804, false); //Add in Study Menu - } - } - return true; - } - else if(theParent.compare("ObjectBrowser") == 0) { - popup->removeItem(QAD_TopLabel_Popup_ID); - int id = popup->idAt(0); // separator - if(id < 0) - popup->removeItem(id); - - // checking for GEOM label in the selected list - SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); - Handle(SALOME_InteractiveObject) anIObject; - - bool useSubItems = false; - bool needOpen = false; - bool needDisplay = false; - bool needErase = false; - SALOMEDS::GenericAttribute_var aTmpAttr; - for(;It.More();It.Next()) { - anIObject = It.Value(); - if(!anIObject->hasEntry()) - continue; - - if(v3d->isInViewer(anIObject) && v3d->isVisible(anIObject)) - needErase = true; - else - needDisplay = true; - SALOMEDS::SObject_var obj = ActiveStudy->getStudyDocument()->FindObjectID(anIObject->getEntry()); - if(!obj->_is_nil()) { - if (strcmp(obj->GetFatherComponent()->GetName(), "GEOM")) continue; - GEOM::GEOM_Shape_var aShape; - if(obj->FindAttribute(aTmpAttr, "AttributeIOR")) { - char *str = SALOMEDS::AttributeIOR::_narrow(aTmpAttr)->Value(); - if(str && strlen(str)) - aShape = myGeomBase->myGeom->GetIORFromString(str); - } - else if(obj->FindAttribute(aTmpAttr, "AttributePersistentRef")) - needOpen = true; - - if(aShape->_is_nil()) { - SALOMEDS::ChildIterator_var anIter = ActiveStudy->getStudyDocument()->NewChildIterator(obj); - while(anIter->More()) { - SALOMEDS::SObject_var subobj = anIter->Value(); - if(subobj->FindAttribute(aTmpAttr, "AttributeIOR")) { - useSubItems = true; - needErase = true; - needDisplay = true; - } - else if(subobj->FindAttribute(aTmpAttr, "AttributePersistentRef")) { - needOpen = true; - useSubItems = true; - } - anIter->Next(); - } - } - } - } - // remove useless popup items - if(nbSel != 1) - popup->removeItem(901); // rename - if(useSubItems) - popup->removeItem(QAD_DisplayOnly_Popup_ID); // display only - - if(!needOpen) { - int index = popup->indexOf(9024); // open - popup->removeItem(9024); - popup->removeItemAt(index); // separator under Open - - if (!needDisplay) - popup->removeItem(QAD_Display_Popup_ID); - if (!needErase) - popup->removeItem(QAD_Erase_Popup_ID); - - if(!needDisplay && !needErase) { - int id = popup->idAt(popup->count()-1); // last item - popup->removeItem(id); // separator - } - } - else { - popup->removeItem(QAD_DisplayOnly_Popup_ID); // display only - popup->removeItem(QAD_Display_Popup_ID); - popup->removeItem(QAD_Erase_Popup_ID); - if (nbSel != 1) { - int id = popup->idAt(popup->count()-1); // last item - popup->removeItem(id); // separator - } - } - return true; - } - } - else if(ActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { - // MESSAGE ( " CUSTOM POPUP VIEWER VTK ") - if((theParent.compare("Viewer") == 0)) { - popup->setItemEnabled(8034, false); //Isos Menu - if(theObject.compare("Component") == 0) { - popup->removeItem(QAD_DisplayOnly_Popup_ID); - return true; - } - - //int id = popup->idAt(0); - QFont f = QApplication::font(); - f.setBold(TRUE); - - if(nbSel == 1) { - Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject(); - popup->removeItem(QAD_TopLabel_Popup_ID); - popup->insertItem(new CustomItem (QString(IObject->getName()), f), QAD_TopLabel_Popup_ID, 0); - if(IObject->hasEntry()) { - popup->setItemEnabled(804, false); //Add in Study Menu - SALOMEDS::Study_var aStudy = ActiveStudy->getStudyDocument(); - SALOMEDS::SObject_var SO = aStudy->FindObjectID(IObject->getEntry()); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeIOR_var anIOR; - if(!SO->_is_nil()) { - if(SO->FindAttribute(anAttr, "AttributeIOR")) { - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - Standard_Boolean found; - GEOM_Actor* Result = myGeomBase->ConvertIORinGEOMActor(anIOR->Value(), found, true); - if(found) { - if(Result->getDisplayMode() == 1) - popup->changeItem(8031, tr("GEOM_MEN_WIREFRAME")); //Shading/Wireframe Menu - else - popup->changeItem(8031, tr("GEOM_MEN_SHADING")); //Shading/Wireframe Menu - - if(!Result->GetVisibility()) - popup->removeItem(QAD_Erase_Popup_ID); - else - popup->removeItem(QAD_Display_Popup_ID); - } - else - popup->removeItem(QAD_Erase_Popup_ID); - } - } - } - else - popup->setItemEnabled(804, true); //Add in Study Menu - } - else { - popup->removeItem(QAD_DisplayOnly_Popup_ID); - popup->removeItem(QAD_TopLabel_Popup_ID); - popup->insertItem( new CustomItem (tr("GEOM_MEN_POPUP_NAME").arg(nbSel), f), QAD_TopLabel_Popup_ID, 0); - popup->setItemEnabled(804, false); //Add in Study Menu - } - return true; - } - else if(theParent.compare("ObjectBrowser") == 0) { - popup->removeItem(QAD_TopLabel_Popup_ID); - int id = popup->idAt(0); // separator - if(id < 0) - popup->removeItem(id); - - // checking for GEOM label in the selected list - SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); - Handle(SALOME_InteractiveObject) anIObject; - - bool useSubItems = false; - bool needOpen = false; - bool needDisplay = false; - bool needErase = false; - SALOMEDS::GenericAttribute_var aTmpAttr; - VTKViewer_RenderWindowInteractor* myRenderInter = ((VTKViewer_ViewFrame*)ActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); - for(;It.More();It.Next()) { - anIObject = It.Value(); - if(!anIObject->hasEntry()) - continue; - - if(myRenderInter->isInViewer(anIObject) && myRenderInter->isVisible(anIObject)) - needErase = true; - else - needDisplay = true; - - SALOMEDS::SObject_var obj = ActiveStudy->getStudyDocument()->FindObjectID(anIObject->getEntry()); - if(!obj->_is_nil()) { - if (strcmp(obj->GetFatherComponent()->GetName(), "GEOM")) continue; - GEOM::GEOM_Shape_var aShape; - if(obj->FindAttribute(aTmpAttr, "AttributeIOR")) { - char *str = SALOMEDS::AttributeIOR::_narrow(aTmpAttr)->Value(); - if(str && strlen(str)) - aShape = myGeomBase->myGeom->GetIORFromString(str); - } - else if(obj->FindAttribute(aTmpAttr, "AttributePersistentRef")) - needOpen = true; - - if(aShape->_is_nil()) { - SALOMEDS::ChildIterator_var anIter = ActiveStudy->getStudyDocument()->NewChildIterator(obj); - while(anIter->More()) { - SALOMEDS::SObject_var subobj = anIter->Value(); - if(subobj->FindAttribute(aTmpAttr, "AttributeIOR")) { - useSubItems = true; - needDisplay = true; - needErase = true; - } - else if(subobj->FindAttribute(aTmpAttr, "AttributePersistentRef")) { - needOpen = true; - useSubItems = true; - } - anIter->Next(); - } - } - } - } - // remove useless popup items - if(nbSel != 1) - popup->removeItem(901); // rename - if(useSubItems) - popup->removeItem(QAD_DisplayOnly_Popup_ID); // display only - - if(!needOpen) { - int index = popup->indexOf(9024); // open - popup->removeItem(9024); - popup->removeItemAt(index); // separator under Open - - if(!needDisplay) - popup->removeItem(QAD_Display_Popup_ID); - if(!needErase) - popup->removeItem(QAD_Erase_Popup_ID); - if(!needDisplay && !needErase) { - int id = popup->idAt(popup->count()-1); // last item - popup->removeItem(id); // separator - } - } - else { - popup->removeItem(QAD_DisplayOnly_Popup_ID); // display only - popup->removeItem(QAD_Display_Popup_ID); - popup->removeItem(QAD_Erase_Popup_ID); - if(nbSel!=1) { - int id = popup->idAt(popup->count()-1); // last item - popup->removeItem(id); // separator - } - } - return true; - } - } - else { // other viewer types not supported. - while(1) { - int id = popup->idAt(0); - if(id <= QAD_TopLabel_Popup_ID && id != -1) - popup->removeItemAt(0); - else - break; - } - popup->removeItem(QAD_DisplayOnly_Popup_ID); - popup->removeItem(QAD_Display_Popup_ID); - popup->removeItem(QAD_Erase_Popup_ID); - int id = popup->idAt(popup->count() - 1); // last item - if(id < 0 && id != -1) - popup->removeItem(id); // separator - return false; - } - return false; -} - - -//===================================================================================== -// function : Display() -// purpose : Displays a CORBA shape -//===================================================================================== -bool GEOMBase::Display(GEOM::GEOM_Shape_ptr aShape, Standard_CString name) -{ - // MESSAGE ( "GEOMBase::Display init ") - Handle(GEOM_InteractiveObject) IO; - SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection()); - Sel->ClearIObjects(); - - if(aShape->_is_nil()) { - QAD_MessageBox::warn1 (QAD_Application::getDesktop(), tr("GEOM_WRN_WARNING"), tr("GEOM_PRP_ABORT"), tr("GEOM_BUT_OK")); - return false; - } - - TopoDS_Shape shape = myGeomGUI->GetShapeReader().GetShape(myGeom, aShape); - if(shape.IsNull()) - return false; - - SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument(); - SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeName_var aName; - SALOMEDS::AttributePixMap_var aPixmap; - - SALOMEDS::SComponent_var father = aStudy->FindComponent("GEOM"); - int aLocked = false; - if(father->_is_nil()) { - QAD_Operation* op = new SALOMEGUI_ImportOperation(QAD_Application::getDesktop()->getActiveStudy()); - op->start(); - aLocked = aStudy->GetProperties()->IsLocked(); - if(aLocked) - aStudy->GetProperties()->SetLocked(false); - father = aStudyBuilder->NewComponent("GEOM"); - anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributeName"); - aName = SALOMEDS::AttributeName::_narrow(anAttr); - aName->SetValue(QAD_Application::getDesktop()->getComponentUserName("GEOM")); - anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributePixMap"); - aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); - aPixmap->SetPixMap("ICON_OBJBROWSER_Geometry"); - aStudyBuilder->DefineComponentInstance(father, myGeom); - QAD_Application::getDesktop()->getActiveStudy()->updateObjBrowser(); - if(aLocked) - aStudy->GetProperties()->SetLocked(true); - op->finish(); - } - - father->ComponentIOR(myGeomGUI->GetFatherior()); - - TCollection_AsciiString nameG(""); - Standard_CString Type; - if(TCollection_AsciiString(name).IsEqual(Standard_CString(""))) { - if(TCollection_AsciiString(aShape->NameType()).IsEqual(Standard_CString(""))) { - Standard_CString type; - GetShapeTypeString(shape,type); - aShape->NameType(type); - nameG += TCollection_AsciiString(type) + TCollection_AsciiString("_") + TCollection_AsciiString(myGeomGUI->myNbGeom++) + TCollection_AsciiString("\0"); - } - else - nameG += TCollection_AsciiString(aShape->NameType()) + TCollection_AsciiString("_") + TCollection_AsciiString(myGeomGUI->myNbGeom++) + TCollection_AsciiString("\0"); - } - else - nameG = TCollection_AsciiString(name); - - // VTK - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { - VTKViewer_RenderWindowInteractor* myRenderInter = ((VTKViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); - - vtkRenderer *theRenderer = ((VTKViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); - int themode = myRenderInter->GetDisplayMode(); - - vtkActorCollection* theActors = GEOM_AssemblyBuilder::BuildActors(shape, 0, themode, Standard_True); - theActors->InitTraversal(); - vtkActor* anActor = (vtkActor*)theActors->GetNextActor(); - - IO = new GEOM_InteractiveObject(aShape->Name(), myGeomGUI->GetFatherior(), "GEOM"); - while(!(anActor==NULL)) { - GEOM_Actor* GActor = GEOM_Actor::SafeDownCast(anActor); - GActor->setIO(IO); - GActor->setName(nameG.ToCString()); - - theRenderer->AddActor(GActor); - anActor = (vtkActor*)theActors->GetNextActor(); - } - } - // OCC - else if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - Handle(AIS_InteractiveContext) ic = v3d->getAISContext(); - Handle(GEOM_AISShape) theResult = new GEOM_AISShape(shape, nameG.ToCString()); - theResult->SetInfiniteState(shape.Infinite()); - theResult->SetShadingColor(myShadingColor); - IO = new GEOM_InteractiveObject(aShape->Name(), myGeomGUI->GetFatherior(), "GEOM"); - theResult->setIO(IO); - theResult->setName(nameG.ToCString()); - - /* Precaution : close any local context to permit the display */ - if(ic->HasOpenedContext()) - ic->CloseAllContexts(); - - ic->Display(theResult); - } - - // DCQ Sel->AddIObject(IO, false); - QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame()->Repaint(); - if(mySettings_AddInStudy) - AddInStudy(false, IO); - - return true; -} - - -//===================================================================================== -// function : AddInStudy() -// purpose : anIOShape or a selected shape -//===================================================================================== -bool GEOMBase::AddInStudy(bool selection, const Handle(SALOME_InteractiveObject)& anIO) -{ - SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection()); - if (!(!mySettings_AddInStudy || selection)) { - Sel->ClearIObjects(); - } - - SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument(); - SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeName_var aName; - SALOMEDS::AttributePixMap_var aPixmap; - SALOMEDS::AttributeIOR_var anIOR; - SALOMEDS::AttributeSelectable_var aSelAttr; - - SALOMEDS::SComponent_var father = aStudy->FindComponent("GEOM"); - int aLocked = false; - if(father->_is_nil()) { - QAD_Operation* op = new SALOMEGUI_ImportOperation(QAD_Application::getDesktop()->getActiveStudy()); - op->start(); - aLocked = aStudy->GetProperties()->IsLocked(); - if(aLocked) - aStudy->GetProperties()->SetLocked(false); - father = aStudyBuilder->NewComponent("GEOM"); - anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributeName"); - aName = SALOMEDS::AttributeName::_narrow(anAttr); - aName->SetValue( QAD_Application::getDesktop()->getComponentUserName("GEOM")); - anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributePixMap"); - aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); - aPixmap->SetPixMap("ICON_OBJBROWSER_Geometry"); - aStudyBuilder->DefineComponentInstance(father, myGeom); - if (aLocked) - aStudy->GetProperties()->SetLocked(true); - op->finish(); - } - - father->ComponentIOR(myGeomGUI->GetFatherior()); - - SALOMEDS::SObject_var fatherSF = aStudy->FindObjectID(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->entry()); - - Handle(GEOM_AISShape) GAISShape; - GEOM_Actor* GActor; - Handle(GEOM_InteractiveObject) GIO; - bool found = false; - - // VTK - if (QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { - vtkRenderer *Renderer = ((VTKViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); - - vtkActorCollection* theActors = Renderer->GetActors(); - theActors->InitTraversal(); - vtkActor *ac = theActors->GetNextActor(); - while(!(ac==NULL)) { - if(ac->IsA("GEOM_Actor")) { - GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(ac); - if(anActor->hasIO()) { - Handle(SALOME_InteractiveObject) IO = anActor->getIO(); - if(IO->IsKind(STANDARD_TYPE(GEOM_InteractiveObject))) { - GIO = Handle(GEOM_InteractiveObject)::DownCast(IO); - if(anIO->isSame(GIO)) { - found = true; - GActor = anActor; - break; - } - } - } - } - ac = theActors->GetNextActor(); - } - - if(!found) - return false; - } - // OCC - else if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); - - AIS_ListOfInteractive List; - ic->DisplayedObjects(List); - AIS_ListIteratorOfListOfInteractive ite(List); - while(ite.More()) { - if(ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) { - Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value()); - if(aSh->hasIO()) { - Handle(SALOME_InteractiveObject) IO = aSh->getIO(); - if ( IO->IsKind(STANDARD_TYPE(GEOM_InteractiveObject))) { - GIO = Handle(GEOM_InteractiveObject)::DownCast(IO); - if(anIO->isSame(GIO)) { - found = true; - GAISShape = aSh; - break; - } - } - } - } - ite.Next(); - } - - if(!found) - return false; - } - - if(!mySettings_AddInStudy || selection) { - QString Name = SALOMEGUI_NameDlg::getName(QAD_Application::getDesktop(), anIO->getName()); - if(!Name.isEmpty()) { - // VTK - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { - char* aCopy = CORBA::string_dup(Name.latin1()); - GActor->setName(aCopy); - delete(aCopy); - } - // OCC - else if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { - char* aCopy = CORBA::string_dup(Name.latin1()); - GAISShape->setName(aCopy); - delete(aCopy); - } - } - else - return false; - } - - // open transaction - QAD_Operation* op = new SALOMEGUI_ImportOperation(QAD_Application::getDesktop()->getActiveStudy()); - op->start(); - - SALOMEDS::SObject_var newObj = aStudyBuilder->NewObject(father); - - GEOM::GEOM_Shape_var aShape = myGeom->GetIORFromString(GIO->getIOR()); - - /* For the shape inserted into the study we set its field 'studyshapeid' */ - /* so the shape will contain its corresponding entry in the study Ocaf doc. */ - aShape->StudyShapeId(newObj->GetID()); - - GIO->setEntry(newObj->GetID()); - - anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeIOR"); - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - anIOR->SetValue(aShape->Name()); - - anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeName"); - aName = SALOMEDS::AttributeName::_narrow(anAttr); - - anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributePixMap"); - aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); - if(aShape->ShapeType() == GEOM::COMPOUND) - aPixmap->SetPixMap("ICON_OBJBROWSER_COMPOUND"); - else if(aShape->ShapeType() == GEOM::COMPSOLID) - aPixmap->SetPixMap("ICON_OBJBROWSER_COMPSOLID"); - else if(aShape->ShapeType() == GEOM::SOLID) - aPixmap->SetPixMap("ICON_OBJBROWSER_SOLID"); - else if(aShape->ShapeType() == GEOM::SHELL) - aPixmap->SetPixMap("ICON_OBJBROWSER_SHELL"); - else if(aShape->ShapeType() == GEOM::FACE) - aPixmap->SetPixMap("ICON_OBJBROWSER_FACE"); - else if(aShape->ShapeType() == GEOM::WIRE) - aPixmap->SetPixMap("ICON_OBJBROWSER_WIRE"); - else if(aShape->ShapeType() == GEOM::EDGE) - aPixmap->SetPixMap("ICON_OBJBROWSER_EDGE"); - else if(aShape->ShapeType() == GEOM::VERTEX) - aPixmap->SetPixMap("ICON_OBJBROWSER_VERTEX"); - - // VTK - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { - GActor->setIO(GIO); - aName->SetValue(GActor->getName()); - } - // OCC - else if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { - GAISShape->setIO(GIO); - aName->SetValue(GAISShape->getName()); - } - - SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF); - aStudyBuilder->Addreference(newObj1,newObj); - - GEOM::GEOM_Gen::ListOfIOR_var listIOR = new GEOM::GEOM_Gen::ListOfIOR; - listIOR = myGeom->GetReferencedObjects(aShape); - - if(listIOR->length()>0) { - SALOMEDS::SObject_var Arguments = aStudyBuilder->NewObject(newObj); - anAttr = aStudyBuilder->FindOrCreateAttribute(Arguments, "AttributeName"); - aName = SALOMEDS::AttributeName::_narrow(anAttr); - aName->SetValue(tr("GEOM_ARGUMENTS")); - anAttr = aStudyBuilder->FindOrCreateAttribute(Arguments, "AttributeSelectable"); - aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr); - aSelAttr->SetSelectable(false); - - bool ObjectReferenced = false; - for (unsigned int ind = 0; ind < listIOR->length();ind++) { - SALOMEDS::SObject_var theObj = aStudy->FindObjectIOR(listIOR[ind]); - - if(!theObj->_is_nil()) { - SALOMEDS::SObject_var RefObject = aStudyBuilder->NewObject(Arguments); - aStudyBuilder->Addreference(RefObject, theObj); - ObjectReferenced = true; - } - } - - if(!ObjectReferenced) - aStudyBuilder->RemoveObject(Arguments); - } - op->finish(); - - if(!mySettings_AddInStudy || selection) - QAD_Application::getDesktop()->getActiveStudy()->updateObjBrowser(); - else { - QAD_Application::getDesktop()->getActiveStudy()->updateObjBrowser(false); - // DCQ Sel->AddIObject(GIO); - } - return true; -} - - //===================================================================================== // function : GetShapeFromIOR() // purpose : exist also as static method ! @@ -792,14 +110,15 @@ TopoDS_Shape GEOMBase::GetShapeFromIOR(QString IOR) TopoDS_Shape result; if(IOR.stripWhiteSpace().isEmpty()) return result; - ORB_INIT &init = *SINGLETON_::Instance(); - CORBA::ORB_var& _orb = init.orb() ; - CORBA::Object_var obj = _orb->string_to_object((char*)(IOR.latin1())); + + CORBA::Object_var obj = GeometryGUI::GetORB()->string_to_object((char*)(IOR.latin1())); if(CORBA::is_nil(obj)) return result; - GEOM::GEOM_Shape_var aShape = myGeom->GetIORFromString(IOR); - if(!aShape->_is_nil()) - result = myGeomGUI->GetShapeReader().GetShape(myGeom, aShape); + GEOM::GEOM_Object_var GeomObject = GEOM::GEOM_Object::_narrow( obj ); + if (GeomObject->_is_nil()) + return result; + + result = GeometryGUI::GetGeomGUI()->GetShapeReader().GetShape(GeometryGUI::GetGeomGUI()->GetGeomGen(), GeomObject); return result; } @@ -808,42 +127,16 @@ TopoDS_Shape GEOMBase::GetShapeFromIOR(QString IOR) // function : GetIndex() // purpose : Get the index of a sub shape in a main shape : index start at 1 //===================================================================================== -int GEOMBase::GetIndex(const TopoDS_Shape& subshape, const TopoDS_Shape& shape, int /*ShapeType*/) -{ - if(shape.IsNull() || subshape.IsNull()) - return -1; - - int index = 1; - if(subshape.ShapeType() == TopAbs_COMPOUND) { - TopoDS_Iterator it; - TopTools_ListOfShape CL; - CL.Append(shape); - TopTools_ListIteratorOfListOfShape itC; - for(itC.Initialize(CL); itC.More(); itC.Next()) { - for(it.Initialize(itC.Value()); it.More(); it.Next()) { - if(it.Value().ShapeType() == TopAbs_COMPOUND) { - if(it.Value().IsSame(subshape)) - return index; - else - index++; - CL.Append(it.Value()); - } - } - } - } - else { - TopExp_Explorer Exp(shape, subshape.ShapeType()); - TopTools_MapOfShape M; - while(Exp.More()) { - if(M.Add(Exp.Current())) { - if(Exp.Current().IsSame(subshape)) - return index; - index++; - } - Exp.Next(); - } - } - return -1; +int GEOMBase::GetIndex(const TopoDS_Shape& subshape, const TopoDS_Shape& shape, int /*ShapeType*/) +{ + if(shape.IsNull() || subshape.IsNull()) + return -1; + + TopTools_IndexedMapOfShape anIndices; + TopExp::MapShapes(shape, anIndices); + if(anIndices.Contains(subshape)) return anIndices.FindIndex(subshape); + + return -1; } @@ -851,11 +144,11 @@ int GEOMBase::GetIndex(const TopoDS_Shape& subshape, const TopoDS_Shape& shape, // function : GetTopoFromSelection() // purpose : Define tds from a single selection and retuen true //======================================================================= -bool GEOMBase::GetTopoFromSelection(SALOME_Selection *Sel, TopoDS_Shape& tds) +bool GEOMBase::GetTopoFromSelection(SALOME_Selection *Sel, TopoDS_Shape& tds) { if(Sel->IObjectCount() != 1) return false; - + Handle(SALOME_InteractiveObject) IO = Sel->firstIObject(); /* case SObject */ if(IO->hasEntry()) { @@ -866,7 +159,7 @@ bool GEOMBase::GetTopoFromSelection(SALOME_Selection *Sel, TopoDS_Shape& tds) if(!obj->_is_nil()) { if(obj->FindAttribute(anAttr, "AttributeIOR")) { anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - tds = this->GetShapeFromIOR(anIOR->Value()); + tds = GetShapeFromIOR(anIOR->Value()); if(tds.IsNull()) return false; else @@ -875,36 +168,42 @@ bool GEOMBase::GetTopoFromSelection(SALOME_Selection *Sel, TopoDS_Shape& tds) } } - if(IO->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject))) { - Standard_CString ior = ""; - Handle(GEOM_InteractiveObject) GIObject = Handle(GEOM_InteractiveObject)::DownCast(IO); - ior = GIObject->getIOR(); - tds = this->GetShapeFromIOR(ior); - if(tds.IsNull()) - return false; - else - return true; - } - return false; } - //======================================================================= // function : GetNameOfSelectedIObjects() // purpose : Define the name geom++ or other name of mono or multi sel. //======================================================================= -int GEOMBase::GetNameOfSelectedIObjects(SALOME_Selection* Sel, QString& aName) +int GEOMBase::GetNameOfSelectedIObjects( SALOME_Selection* theSel, + QString& theName, + const bool theShapesOnly ) { - int nbSel = Sel->IObjectCount(); - if(nbSel == 1) { - Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject(); - aName = IObject->getName(); - } - else { - aName = tr("%1_objects").arg(nbSel); + if ( !theShapesOnly ) + { + int nbSel = theSel->IObjectCount(); + if ( nbSel == 1 ) + { + Handle(SALOME_InteractiveObject) anIObj = theSel->firstIObject(); + theName = anIObj->getName(); + } + else + theName = QObject::tr("%1_objects").arg(nbSel); + + return nbSel; + } + else + { + QStringList aNames; + GEOM::ListOfGO anObjs; + ConvertListOfIOInListOfGO( theSel->StoredIObjects(), anObjs, theShapesOnly ); + if ( anObjs.length() == 1 ) + theName = GetName( anObjs[ 0 ] ); + else + theName = QString( "%1_objects" ).arg( anObjs.length() ); + + return anObjs.length(); } - return nbSel; } @@ -922,55 +221,55 @@ bool GEOMBase::GetShapeTypeString(const TopoDS_Shape& aShape, Standard_CString& { case TopAbs_COMPOUND: { - aTypeString = CORBA::string_dup(tr("GEOM_COMPOUND")); + aTypeString = CORBA::string_dup(QObject::tr("GEOM_COMPOUND")); return true; } case TopAbs_COMPSOLID: { - aTypeString = CORBA::string_dup(tr("GEOM_COMPOUNDSOLID")) ; + aTypeString = CORBA::string_dup(QObject::tr("GEOM_COMPOUNDSOLID")) ; return true ; } case TopAbs_SOLID: { - aTypeString = CORBA::string_dup(tr("GEOM_SOLID")) ; + aTypeString = CORBA::string_dup(QObject::tr("GEOM_SOLID")) ; return true ; } case TopAbs_SHELL: { - aTypeString = CORBA::string_dup(tr("GEOM_SHELL")) ; + aTypeString = CORBA::string_dup(QObject::tr("GEOM_SHELL")) ; return true ; } case TopAbs_FACE: - { + { BRepAdaptor_Surface surf(TopoDS::Face(aShape)); if(surf.GetType() == GeomAbs_Plane) { - aTypeString = CORBA::string_dup(tr("GEOM_PLANE")); + aTypeString = CORBA::string_dup(QObject::tr("GEOM_PLANE")); return true; } else if(surf.GetType() == GeomAbs_Cylinder) { - aTypeString = CORBA::string_dup(tr("GEOM_SURFCYLINDER")); + aTypeString = CORBA::string_dup(QObject::tr("GEOM_SURFCYLINDER")); return true; } else if(surf.GetType() == GeomAbs_Sphere) { - aTypeString = CORBA::string_dup(tr("GEOM_SURFSPHERE")); + aTypeString = CORBA::string_dup(QObject::tr("GEOM_SURFSPHERE")); return true ; } else if(surf.GetType() == GeomAbs_Torus) { - aTypeString = CORBA::string_dup(tr("GEOM_SURFTORUS")); + aTypeString = CORBA::string_dup(QObject::tr("GEOM_SURFTORUS")); return true ; } else if(surf.GetType() == GeomAbs_Cone) { - aTypeString = CORBA::string_dup(tr("GEOM_SURFCONE")); + aTypeString = CORBA::string_dup(QObject::tr("GEOM_SURFCONE")); return true ; } else { - aTypeString = CORBA::string_dup(tr("GEOM_FACE")); + aTypeString = CORBA::string_dup(QObject::tr("GEOM_FACE")); return true; } } case TopAbs_WIRE: { - aTypeString = CORBA::string_dup(tr("GEOM_WIRE")); + aTypeString = CORBA::string_dup(QObject::tr("GEOM_WIRE")); return true; } case TopAbs_EDGE: @@ -978,31 +277,31 @@ bool GEOMBase::GetShapeTypeString(const TopoDS_Shape& aShape, Standard_CString& BRepAdaptor_Curve curv(TopoDS::Edge(aShape)); if(curv.GetType() == GeomAbs_Line) { if((Abs(curv.FirstParameter()) >= 1E6) || (Abs(curv.LastParameter()) >= 1E6)) - aTypeString = CORBA::string_dup(tr("GEOM_LINE")); + aTypeString = CORBA::string_dup(QObject::tr("GEOM_LINE")); else - aTypeString = CORBA::string_dup(tr("GEOM_EDGE")); + aTypeString = CORBA::string_dup(QObject::tr("GEOM_EDGE")); return true; } else if(curv.GetType() == GeomAbs_Circle) { if(curv.IsClosed()) - aTypeString = CORBA::string_dup(tr("GEOM_CIRCLE")); + aTypeString = CORBA::string_dup(QObject::tr("GEOM_CIRCLE")); else - aTypeString = CORBA::string_dup(tr("GEOM_ARC")); + aTypeString = CORBA::string_dup(QObject::tr("GEOM_ARC")); return true; - } + } else { - aTypeString = CORBA::string_dup(tr("GEOM_EDGE")); + aTypeString = CORBA::string_dup(QObject::tr("GEOM_EDGE")); return true; } } case TopAbs_VERTEX: { - aTypeString = CORBA::string_dup(tr("GEOM_VERTEX")); + aTypeString = CORBA::string_dup(QObject::tr("GEOM_VERTEX")); return true; } case TopAbs_SHAPE: { - aTypeString = CORBA::string_dup(tr("GEOM_SHAPE")); + aTypeString = CORBA::string_dup(QObject::tr("GEOM_SHAPE")); return true; } } @@ -1018,6 +317,12 @@ Handle(GEOM_AISShape) GEOMBase::ConvertIORinGEOMAISShape(const char * IOR, Stand { Handle(GEOM_AISShape) resultShape; testResult = false; + + SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument(); + SALOMEDS::SObject_var anObj = aStudy->FindObjectIOR( IOR ); + if ( anObj->_is_nil() ) + return resultShape; + int nbSf = QAD_Application::getDesktop()->getActiveStudy()->getStudyFramesCount(); for(int i = 0; i < nbSf; i++) { QAD_StudyFrame* sf = QAD_Application::getDesktop()->getActiveStudy()->getStudyFrame(i); @@ -1036,26 +341,19 @@ Handle(GEOM_AISShape) GEOMBase::ConvertIORinGEOMAISShape(const char * IOR, Stand if(ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) { Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value()); if(aSh->hasIO()) { - Handle(GEOM_InteractiveObject) GIO = Handle(GEOM_InteractiveObject)::DownCast(aSh->getIO()); - Standard_CString theIOR = GIO->getIOR(); - if(strcmp(IOR, theIOR) == 0) { - if(onlyInActiveView) { - if(sf == QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()) { - testResult = true; - resultShape = aSh; - return resultShape; - } - } - else { + Handle(SALOME_InteractiveObject) GIO = Handle(SALOME_InteractiveObject)::DownCast(aSh->getIO()); + if(GIO->hasEntry() && strcmp(GIO->getEntry(), anObj->GetID()) == 0) { + if(!onlyInActiveView || + sf == QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()) { testResult = true; resultShape = aSh; - return resultShape; + return resultShape; } } } } ite.Next(); - } + } } } return resultShape; @@ -1068,6 +366,13 @@ Handle(GEOM_AISShape) GEOMBase::ConvertIORinGEOMAISShape(const char * IOR, Stand //======================================================================= GEOM_Actor* GEOMBase::ConvertIORinGEOMActor(const char* IOR, Standard_Boolean& testResult, bool onlyInActiveView) { + testResult = false; + + SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument(); + SALOMEDS::SObject_var anObj = aStudy->FindObjectIOR( IOR ); + if ( anObj->_is_nil() ) + return GEOM_Actor::New(); + int nbSf = QAD_Application::getDesktop()->getActiveStudy()->getStudyFramesCount(); for(int i = 0; i < nbSf; i++) { QAD_StudyFrame* sf = QAD_Application::getDesktop()->getActiveStudy()->getStudyFrame(i); @@ -1080,16 +385,10 @@ GEOM_Actor* GEOMBase::ConvertIORinGEOMActor(const char* IOR, Standard_Boolean& t if( ac->IsA("GEOM_Actor")) { GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(ac); if(anActor->hasIO()) { - Handle(GEOM_InteractiveObject) GIO = Handle(GEOM_InteractiveObject)::DownCast(anActor->getIO()); - Standard_CString theIOR = GIO->getIOR(); - if(strcmp(IOR, theIOR) == 0) { - if(onlyInActiveView) { - if(sf == QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()) { - testResult = true; - return anActor; - } - } - else { + Handle(SALOME_InteractiveObject) GIO = Handle(SALOME_InteractiveObject)::DownCast(anActor->getIO()); + if(GIO->hasEntry() && strcmp(GIO->getEntry(), anObj->GetID()) == 0) { + if(!onlyInActiveView || + sf == QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()) { testResult = true; return anActor; } @@ -1104,6 +403,57 @@ GEOM_Actor* GEOMBase::ConvertIORinGEOMActor(const char* IOR, Standard_Boolean& t return GEOM_Actor::New(); } +//======================================================================= +// function : GetAIS() +// purpose : +//======================================================================= +Handle(AIS_InteractiveObject) GEOMBase::GetAIS( const Handle(SALOME_InteractiveObject)& theIO, + const bool isOnlyInActiveView ) +{ + if ( theIO.IsNull() || !theIO->hasEntry() ) + return Handle(AIS_InteractiveObject)(); + + int nbSf = QAD_Application::getDesktop()->getActiveStudy()->getStudyFramesCount(); + + for ( int i = 0; i < nbSf; i++ ) + { + QAD_StudyFrame* aStudyFrame = + QAD_Application::getDesktop()->getActiveStudy()->getStudyFrame( i ); + + if ( aStudyFrame->getTypeView() != VIEW_OCC ) + continue; + + OCCViewer_Viewer3d* v3d = + ((OCCViewer_ViewFrame*)aStudyFrame->getRightFrame()->getViewFrame())->getViewer(); + + Handle(AIS_InteractiveContext) anIC = v3d->getAISContext(); + + AIS_ListOfInteractive aList; + anIC->DisplayedObjects( aList ); + anIC->ObjectsInCollector( aList ); + + AIS_ListIteratorOfListOfInteractive anIter( aList ); + for ( ; anIter.More(); anIter.Next() ) + { + Handle(SALOME_InteractiveObject) anObj = + Handle(SALOME_InteractiveObject)::DownCast( anIter.Value()->GetOwner() ); + + if( !anObj.IsNull() && strcmp( anObj->getEntry(), theIO->getEntry() ) == 0 ) + { + if( isOnlyInActiveView ) + { + if ( aStudyFrame == QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame() ) + return anIter.Value(); + } + else + return anIter.Value(); + } + } + } + + return Handle(AIS_InteractiveObject)(); +} + //======================================================================= // function : ConvertIOinGEOMAISShape() @@ -1112,6 +462,13 @@ GEOM_Actor* GEOMBase::ConvertIORinGEOMActor(const char* IOR, Standard_Boolean& t Handle(GEOM_AISShape) GEOMBase::ConvertIOinGEOMAISShape(const Handle(SALOME_InteractiveObject)& IO, Standard_Boolean& testResult, bool onlyInActiveView) { Handle(GEOM_AISShape) res; + + if ( !IO->hasEntry() ) + { + testResult = false; + return res; + } + int nbSf = QAD_Application::getDesktop()->getActiveStudy()->getStudyFramesCount(); for(int i = 0; i < nbSf; i++) { QAD_StudyFrame* sf = QAD_Application::getDesktop()->getActiveStudy()->getStudyFrame(i); @@ -1126,26 +483,32 @@ Handle(GEOM_AISShape) GEOMBase::ConvertIOinGEOMAISShape(const Handle(SALOME_Inte List.Append(List1); AIS_ListIteratorOfListOfInteractive ite(List); - while(ite.More()) { - if(ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) { - Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value()); - if(aSh->hasIO()) { - Handle(GEOM_InteractiveObject) GIO = Handle(GEOM_InteractiveObject)::DownCast(aSh->getIO()); - if(GIO->isSame(IO)) { - if(onlyInActiveView) { - if(sf == QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()) { - testResult = true; - return aSh; - } - } - else { - testResult = true; - return aSh; - } - } - } - } - ite.Next(); + while(ite.More()) + { + if(ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) + { + Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value()); + if( aSh->hasIO() ) + { + if( strcmp( aSh->getIO()->getEntry(), IO->getEntry() ) == 0 ) + { + if(onlyInActiveView) + { + if(sf == QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()) + { + testResult = true; + return aSh; + } + } + else + { + testResult = true; + return aSh; + } + } + } + } + ite.Next(); } } } @@ -1158,9 +521,9 @@ Handle(GEOM_AISShape) GEOMBase::ConvertIOinGEOMAISShape(const Handle(SALOME_Inte // function : ConvertIOinGEOMShape() // purpose : //======================================================================= -GEOM::GEOM_Shape_ptr GEOMBase::ConvertIOinGEOMShape(const Handle(SALOME_InteractiveObject)& IO, Standard_Boolean& testResult) +GEOM::GEOM_Object_ptr GEOMBase::ConvertIOinGEOMShape(const Handle(SALOME_InteractiveObject)& IO, Standard_Boolean& testResult) { - GEOM::GEOM_Shape_var aShape; + GEOM::GEOM_Object_var aShape; testResult = false; /* case SObject */ @@ -1172,24 +535,14 @@ GEOM::GEOM_Shape_ptr GEOMBase::ConvertIOinGEOMShape(const Handle(SALOME_Interact if(!obj->_is_nil()) { if(obj->FindAttribute(anAttr, "AttributeIOR")) { anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - aShape = myGeom->GetIORFromString(anIOR->Value()); + aShape = GeometryGUI::GetGeomGUI()->GetGeomGen()->GetIORFromString(anIOR->Value()); if(!CORBA::is_nil(aShape)) testResult = true; return aShape._retn(); } } } - /* case Graphical Object */ - if(IO->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject))) { - Handle(GEOM_InteractiveObject) GIObject = Handle(GEOM_InteractiveObject)::DownCast(IO); - Standard_CString ior = GIObject->getIOR(); - - aShape = myGeom->GetIORFromString(ior); - if(!CORBA::is_nil(aShape)) - testResult = true; - return aShape._retn(); - } - return aShape._retn(); + return GEOM::GEOM_Object::_nil(); } @@ -1197,7 +550,7 @@ GEOM::GEOM_Shape_ptr GEOMBase::ConvertIOinGEOMShape(const Handle(SALOME_Interact // function : ConvertListOfIOInListOfIOR() // purpose : //======================================================================= -void GEOMBase::ConvertListOfIOInListOfIOR(const SALOME_ListIO& aList, GEOM::GEOM_Gen::ListOfIOR& listIOR) +void GEOMBase::ConvertListOfIOInListOfIOR(const SALOME_ListIO& aList, GEOM::string_array& listIOR) { int nbSel = aList.Extent(); listIOR.length(nbSel); @@ -1216,93 +569,69 @@ void GEOMBase::ConvertListOfIOInListOfIOR(const SALOME_ListIO& aList, GEOM::GEOM CORBA::ORB_var& _orb = init.orb(); CORBA::String_var theValue = anIOR->Value(); CORBA::Object_var theObj = _orb->string_to_object(theValue); - if(theObj->_is_a("IDL:GEOM/GEOM_Shape:1.0")) { + if(theObj->_is_a("IDL:GEOM/GEOM_Object:1.0")) { listIOR[j] = CORBA::string_dup(theValue); j++; } } } - else if(IObject->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject))) { - Handle(GEOM_InteractiveObject) GIObject = Handle(GEOM_InteractiveObject)::DownCast(IObject); - Standard_CString ior = GIObject->getIOR(); - listIOR[j] = CORBA::string_dup(ior); - j++; - } } listIOR.length(j); } -//================================================================================ -// function : SetDisplayedObjectList() -// purpose : -//================================================================================ -// void GEOMBase::SetDisplayedObjectList() -// { -// if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC) -// return; - -// OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); -// myGeomGUI->GetListDisplayedObject().Clear(); - -// Handle (AIS_InteractiveContext) aContext = v3d->getAISContext(); -// aContext->DisplayedObjects(myGeomGUI->GetListDisplayedObject()); -// } - - -//===================================================================================== -// function : DisplaySimulationShape() -// purpose : Displays 'this->mySimulationShape' a pure graphical shape from a TopoDS_Shape -//===================================================================================== -void GEOMBase::DisplaySimulationShape(const TopoDS_Shape& S) -{ - if(S.IsNull()) - return; - - //NRI DEBUG : 14/02/2002 - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC) - return; - - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - Handle(AIS_InteractiveContext) ic = v3d->getAISContext(); - try { - /* erase any previous */ - ic->Erase(mySimulationShape, Standard_True, Standard_False); - ic->ClearPrs(mySimulationShape); - mySimulationShape = new AIS_Shape(TopoDS_Shape()); - mySimulationShape->Set(S); - mySimulationShape->SetColor(Quantity_NOC_VIOLET); - ic->Deactivate(mySimulationShape); - ic->Display(mySimulationShape, Standard_False); - ic->UpdateCurrentViewer(); +//======================================================================= +// function : ConvertIOinGEOMObject() +// purpose : +//======================================================================= +GEOM::GEOM_Object_ptr GEOMBase::ConvertIOinGEOMObject( const Handle(SALOME_InteractiveObject)& theIO, + Standard_Boolean& theResult ) +{ + theResult = Standard_False; + GEOM::GEOM_Object_var aReturnObject; + if ( !theIO.IsNull() ) + { + const char* anEntry = theIO->getEntry(); + SALOMEDS::SObject_var aSObj = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument()->FindObjectID( anEntry ); + if ( !CORBA::is_nil( aSObj ) ) + { + aReturnObject = GEOM::GEOM_Object::_narrow( aSObj->GetObject() ); + theResult = !CORBA::is_nil( aReturnObject ); + } } - catch(Standard_Failure) { - MESSAGE("Exception catched in GEOMBase::DisplaySimulationShape "); - } - mySimulationShape->UnsetColor(); - return; + return aReturnObject._retn(); } -//================================================================================== -// function : EraseSimulationShape() -// purpose : Clears the display of 'mySimulationShape' a pure graphical shape -//================================================================================== -void GEOMBase::EraseSimulationShape() +//======================================================================= +// function : ConvertListOfIOInListOfGO() +// purpose : +//======================================================================= +void GEOMBase::ConvertListOfIOInListOfGO( const SALOME_ListIO& theList, + GEOM::ListOfGO& theListGO, + const bool theShapesOnly ) { - int count = QAD_Application::getDesktop()->getActiveStudy()->getStudyFramesCount(); - for(int i = 0; i < count; i++) { - if(QAD_Application::getDesktop()->getActiveStudy()->getStudyFrame(i)->getTypeView() == VIEW_OCC) { - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getStudyFrame(i)->getRightFrame()->getViewFrame())->getViewer(); - Handle(AIS_InteractiveContext) ic = v3d->getAISContext(); - ic->Erase(mySimulationShape, Standard_True, Standard_False); - ic->ClearPrs(mySimulationShape); - ic->UpdateCurrentViewer(); - } + int nbSel = theList.Extent(); + theListGO.length( nbSel ); + SALOME_ListIteratorOfListIO anIter( theList ); + SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument(); + int j = 0; + for ( int i=0; anIter.More(); anIter.Next(), i++ ) + { + Handle(SALOME_InteractiveObject) anIObj = anIter.Value(); + SALOMEDS::SObject_var aSObj = aStudy->FindObjectID( anIObj->getEntry() ); + + if ( !aSObj->_is_nil() ) + { + GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow(aSObj->GetObject()); + if ( !CORBA::is_nil( aGeomObj ) && ( !theShapesOnly || IsShape( aGeomObj ) ) ) + theListGO[ j++ ] = aGeomObj; + } } + + theListGO.length( j ); } - //================================================================================= // function : CreateArrowForLinearEdge() // purpose : Create a cone topology to be used to display an arrow in the middle @@ -1443,18 +772,18 @@ bool GEOMBase::SelectionByNameInDialogs(QWidget* aWidget, const QString& objectU listSO = ST->FindObjectByName(objectUserName, "GEOM"); if(listSO->length() < 1) { - const QString caption = tr("GEOM_WRN_WARNING"); - const QString text = tr("GEOM_NAME_INCORRECT"); - const QString button0 = tr("GEOM_BUT_OK"); - QMessageBox::warning(aWidget, caption, text, button0); + const QString caption = QObject::tr("GEOM_WRN_WARNING"); + const QString text = QObject::tr("GEOM_NAME_INCORRECT"); + const QString button0 = QObject::tr("GEOM_BUT_OK"); + QAD_MessageBox::error1(aWidget, caption, text, button0); return false; } /* More than one object with same name */ if(listSO->length() > 1) { - const QString caption = tr("GEOM_WRN_WARNING"); - const QString text = tr("GEOM_IDENTICAL_NAMES_SELECT_BY_MOUSE"); - const QString button0 = tr("GEOM_BUT_OK") ; - QMessageBox::warning(aWidget, caption, text, button0) ; + const QString caption = QObject::tr("GEOM_WRN_WARNING"); + const QString text = QObject::tr("GEOM_IDENTICAL_NAMES_SELECT_BY_MOUSE"); + const QString button0 = QObject::tr("GEOM_BUT_OK") ; + QAD_MessageBox::error1(aWidget, caption, text, button0) ; return false; } @@ -1487,6 +816,11 @@ bool GEOMBase::DefineDlgPosition(QWidget* aDlg, int& x, int& y) return true; } + +//======================================================================= +// function : GetDefaultName() +// purpose : Generates default names +//======================================================================= QString GEOMBase::GetDefaultName(const QString& theOperation) { SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument(); @@ -1505,12 +839,128 @@ QString GEOMBase::GetDefaultName(const QString& theOperation) } -//===================================================================================== -// EXPORTED METHODS -//===================================================================================== -extern "C" +//======================================================================= +// function : ShowErrorMessage() +// purpose : Shows message box with error code and comment +//======================================================================= +void GEOMBase::ShowErrorMessage(const char* theErrorCode, const char* theComment) +{ + QString anErrorCode(theErrorCode); + QString aComment(theComment); + + QString aText = ""; + if (!anErrorCode.isEmpty()) + aText.append("\n" + QObject::tr(anErrorCode)); + if (!aComment.isEmpty()) + aText.append("\n" + QString(theComment)); + + QAD_MessageBox::error1( QAD_Application::getDesktop(), QObject::tr( "GEOM_ERROR" ), + QObject::tr("GEOM_PRP_ABORT") + aText, "OK" ); +} + + +//======================================================================= +// function : GetObjectFromIOR() +// purpose : returns a GEOM_Object by given IOR (string) +//======================================================================= +GEOM::GEOM_Object_ptr GEOMBase::GetObjectFromIOR( const char* theIOR ) +{ + GEOM::GEOM_Object_var anObject; + if ( theIOR == NULL || strlen( theIOR ) == 0 ) + return anObject._retn(); // returning nil object + + anObject = GEOM::GEOM_Object::_narrow( GeometryGUI::GetORB()->string_to_object( theIOR ) ); + return anObject._retn(); +} + +//======================================================================= +// function : GetIORFromObject() +// purpose : returns IOR of a given GEOM_Object +//======================================================================= +char* GEOMBase::GetIORFromObject( const GEOM::GEOM_Object_ptr& theObject ) +{ + if ( CORBA::is_nil( theObject ) ) + return NULL; + + return GeometryGUI::GetORB()->object_to_string( theObject ); +} + +//======================================================================= +// function : GetShape() +// purpose : returns a TopoDS_Shape stored in GEOM_Object +//======================================================================= +bool GEOMBase::GetShape( const GEOM::GEOM_Object_ptr& theObject, TopoDS_Shape& theShape, const TopAbs_ShapeEnum theType ) +{ + if ( !CORBA::is_nil( theObject ) ) + { + TopoDS_Shape aTopoDSShape = GEOM_Client().GetShape( GeometryGUI::GetGeomGUI()->GetGeomGen(), theObject ); + if ( !aTopoDSShape.IsNull() && ( theType == TopAbs_SHAPE || theType == aTopoDSShape.ShapeType() ) ) + { + theShape = aTopoDSShape; + return true; + } + } + return false; +} + +//======================================================================= +// function : GetName() +// purpose : Get name of object +//======================================================================= +const char* GEOMBase::GetName( GEOM::GEOM_Object_ptr theObj ) +{ + QAD_Study* aStudy = QAD_Application::getDesktop()->getActiveStudy(); + + if ( aStudy ) + { + string anIOR = GeometryGUI::GetORB()->object_to_string( theObj ); + if ( anIOR != "" ) + { + SALOMEDS::SObject_var aSObj = aStudy->getStudyDocument()->FindObjectIOR( anIOR.c_str() ); + SALOMEDS::GenericAttribute_var anAttr; + + if ( !aSObj->_is_nil() && aSObj->FindAttribute( anAttr, "AttributeName") ) + { + SALOMEDS::AttributeName_var aNameAttr = SALOMEDS::AttributeName::_narrow( anAttr ); + return aNameAttr->Value(); + } + } + } + + return ""; +} + +bool GEOMBase::IsShape( GEOM::GEOM_Object_ptr theObj ) { - bool CustomPopup(QAD_Desktop* parent, QPopupMenu* popup, const QString & theContext, - const QString & theParent, const QString & theObject) - {return GEOMBase::CustomPopup(parent, popup, theContext, theParent, theObject);} + return !theObj->_is_nil() && theObj->IsShape(); } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/GEOMBase/GEOMBase.h b/src/GEOMBase/GEOMBase.h index b6de381c5..3a829a819 100644 --- a/src/GEOMBase/GEOMBase.h +++ b/src/GEOMBase/GEOMBase.h @@ -24,102 +24,115 @@ // File : GEOMBase.h // Author : Damien COQUERET // Module : GEOM -// $Header: +// $Header$ #ifndef GEOMBASE_H #define GEOMBASE_H -#include "GEOMContext.h" - // SALOME Includes -#include "QAD_Config.h" -#include "SALOME_Selection.h" -#include "GEOM_Actor.h" #include "GEOM_AISShape.hxx" -#include "GEOM_InteractiveObject.hxx" - -// Open CASCADE Includes -#include // IDL Headers #include #include CORBA_SERVER_HEADER(SALOMEDS) #include CORBA_SERVER_HEADER(SALOMEDS_Attributes) +#include CORBA_SERVER_HEADER(GEOM_Gen) + +// QT Includes +#include + +class GEOM_Actor; +class SALOME_Selection; +class SALOME_ListIO; +class QAD_Desktop; +class TColStd_MapOfInteger; + +class QWidget; //================================================================================= // class : GEOMBase // purpose : //================================================================================= -class GEOMBase : public QObject +class GEOMBase { - Q_OBJECT /* for QT compatibility */ - public : GEOMBase(); ~GEOMBase(); - static bool CustomPopup(QAD_Desktop* parent, QPopupMenu* popup, const QString& theContext, - const QString& theParent, const QString& theObject); - - bool Display(GEOM::GEOM_Shape_ptr aShape, Standard_CString name = ""); - bool AddInStudy(bool selection = false, const Handle(SALOME_InteractiveObject)& anIO = 0); + // SAN -- TO BE REMOVED !!! + static bool Display( GEOM::GEOM_Object_ptr ) {return false;} + static bool AddInStudy( GEOM::GEOM_Object_ptr ) {return false;} + static void DisplaySimulationShape(const TopoDS_Shape& S) {}; + static void EraseSimulationShape() {}; + // SAN -- TO BE REMOVED !!! /* Selection and objects management */ - int GetIndex(const TopoDS_Shape& subshape, const TopoDS_Shape& shape, int ShapeType); - TopoDS_Shape GetShapeFromIOR(QString IOR); - bool GetTopoFromSelection(SALOME_Selection *Sel, TopoDS_Shape& tds); - int GetNameOfSelectedIObjects(SALOME_Selection* Sel, QString& aName); - bool GetShapeTypeString(const TopoDS_Shape& aShape, Standard_CString& aTypeString); + static int GetIndex(const TopoDS_Shape& subshape, const TopoDS_Shape& shape, int ShapeType); + static TopoDS_Shape GetShapeFromIOR(QString IOR); + static bool GetShape( const GEOM::GEOM_Object_ptr&, TopoDS_Shape&, const TopAbs_ShapeEnum = TopAbs_SHAPE ); + static bool GetTopoFromSelection(SALOME_Selection *Sel, TopoDS_Shape& tds); + static int GetNameOfSelectedIObjects(SALOME_Selection* Sel, QString& aName, const bool theShapesOnly = false ); + static bool GetShapeTypeString(const TopoDS_Shape& aShape, Standard_CString& aTypeString); /* Convertions */ - GEOM::GEOM_Shape_ptr ConvertIOinGEOMShape(const Handle(SALOME_InteractiveObject)& IO, + static GEOM::GEOM_Object_ptr ConvertIOinGEOMShape(const Handle(SALOME_InteractiveObject)& IO, Standard_Boolean& testResult); - Handle(GEOM_AISShape) ConvertIOinGEOMAISShape(const Handle(SALOME_InteractiveObject)& IO, + static Handle(GEOM_AISShape) ConvertIOinGEOMAISShape(const Handle(SALOME_InteractiveObject)& IO, Standard_Boolean& testResult, - bool onlyInActiveView = false); - void ConvertListOfIOInListOfIOR(const SALOME_ListIO& aList, - GEOM::GEOM_Gen::ListOfIOR& listIOR); + bool onlyInActiveView = false); - Handle(GEOM_AISShape) ConvertIORinGEOMAISShape(const char * IOR, + static Handle(AIS_InteractiveObject) GetAIS( const Handle(SALOME_InteractiveObject)& theIO, + const bool isOnlyInActiveView = false ); + static void ConvertListOfIOInListOfIOR(const SALOME_ListIO& aList, + GEOM::string_array& listIOR); + + static Handle(GEOM_AISShape) ConvertIORinGEOMAISShape(const char * IOR, Standard_Boolean& testResult, bool onlyInActiveView = false); - GEOM_Actor* ConvertIORinGEOMActor(const char * IOR, Standard_Boolean& testResult, + static GEOM_Actor* ConvertIORinGEOMActor(const char * IOR, Standard_Boolean& testResult, bool onlyInActiveView = false); + static GEOM::GEOM_Object_ptr ConvertIOinGEOMObject(const Handle(SALOME_InteractiveObject)& IO, + Standard_Boolean& testResult); + + static void ConvertListOfIOInListOfGO( const SALOME_ListIO& aList, + GEOM::ListOfGO& listGO, + const bool theShapesOnly = false ); + + static GEOM::GEOM_Object_ptr GetObjectFromIOR( const char* theIOR ); + + static char* GetIORFromObject( const GEOM::GEOM_Object_ptr& theObject ); + /* Geometry */ - bool VertexToPoint(const TopoDS_Shape& S, gp_Pnt& P); + static bool VertexToPoint(const TopoDS_Shape& S, gp_Pnt& P); /* Used just by Plane and Prism */ - bool LinearEdgeExtremities(const TopoDS_Shape& S, gp_Pnt& P1, gp_Pnt& P2); - void GetBipointDxDyDz(gp_Pnt P1, gp_Pnt P2, double& dx, double& dy, double& dz); + static bool LinearEdgeExtremities(const TopoDS_Shape& S, gp_Pnt& P1, gp_Pnt& P2); + static void GetBipointDxDyDz(gp_Pnt P1, gp_Pnt P2, double& dx, double& dy, double& dz); /* User dialog 1 parameter returned */ - double Parameter(Standard_Boolean& res, + static double Parameter(Standard_Boolean& res, const char* aValue1 = 0, const char* aTitle1 = 0, const char* aTitle = 0, const double bottom = -1E6, const double top = +1E6, const int decimals = 6); - //void SetDisplayedObjectList(); - /* Simulation management */ - bool CreateArrowForLinearEdge(const TopoDS_Shape& tds, TopoDS_Shape& ArrowCone); - void DisplaySimulationShape(const TopoDS_Shape& S); - void EraseSimulationShape(); + static bool CreateArrowForLinearEdge(const TopoDS_Shape& tds, TopoDS_Shape& ArrowCone); - /* Method used by dialog boxes called when used has entered a name of object in a LineEdit */ - bool SelectionByNameInDialogs(QWidget* aWidget, const QString& userObjectName, SALOME_Selection *Sel); - bool DefineDlgPosition(QWidget* aDlg, int& x, int& y); + /* Generates default names */ + static bool SelectionByNameInDialogs(QWidget* aWidget, const QString& userObjectName, SALOME_Selection *Sel); + /* Shows message box with error code */ + static bool DefineDlgPosition(QWidget* aDlg, int& x, int& y); /* This method generates default names for results of geometrical operations */ static QString GetDefaultName(const QString& theOperation); + /* Shows message box with error code and comment */ + static void ShowErrorMessage(const char* theErrorCode, const char* theComment = 0); - GEOMContext* myGeomGUI; - GEOM::GEOM_Gen_var myGeom; /* Current Geom Component */ - - Quantity_Color myShadingColor; - Handle(AIS_Shape) mySimulationShape; /* AIS shape used only during topo/geom simulations */ - bool mySettings_AddInStudy; + /* Gets name of object */ + static const char* GetName( GEOM::GEOM_Object_ptr ); + static bool IsShape( GEOM::GEOM_Object_ptr theObj ); }; #endif diff --git a/src/GEOMBase/GEOMBase_Helper.cxx b/src/GEOMBase/GEOMBase_Helper.cxx new file mode 100755 index 000000000..5bb5d91e8 --- /dev/null +++ b/src/GEOMBase/GEOMBase_Helper.cxx @@ -0,0 +1,863 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2004 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org or email : webmaster.salome@opencascade.org +// +// +// +// File : GEOMBase_Helper.cxx +// Author : Sergey ANIKIN +// Module : GEOM +// $Header$ + +#include "GEOMBase_Helper.h" +#include "GEOMBase.h" +#include "GEOM_Operation.h" +#include "GeometryGUI.h" +#include "GEOM_Displayer.h" +#include "GEOMImpl_Types.hxx" +#include "QAD_Study.h" +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "QAD_MessageBox.h" +#include "QAD_ViewFrame.h" +#include "QAD_RightFrame.h" +#include "QAD_WaitCursor.h" +#include "SALOMEGUI_QtCatchCorbaException.hxx" + +#include +#include + +using namespace std; + +//================================================================ +// Function : getActiveView +// Purpose : Get active study frame, returns 0 if no open study frame +//================================================================ +static QAD_ViewFrame* getActiveView() +{ + QAD_Study* activeStudy = QAD_Application::getDesktop()->getActiveStudy(); + if ( activeStudy ) { + QAD_StudyFrame* sf = activeStudy->getActiveStudyFrame(); + if ( sf ) { + return sf->getRightFrame()->getViewFrame(); + } + } + return 0; +} + + +//================================================================ +// Function : getGeomEngine +// Purpose : Static method +//================================================================ +GEOM::GEOM_Gen_ptr GEOMBase_Helper::getGeomEngine() +{ + Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM"); + return GEOM::GEOM_Gen::_narrow(comp); +} + +//================================================================ +// Function : GEOMBase_Helper +// Purpose : +//================================================================ +GEOMBase_Helper::GEOMBase_Helper() + : myViewFrame( 0 ), myDisplayer( 0 ), myCommand( 0 ), isPreview( false ) +{ +} + +//================================================================ +// Function : ~GEOMBase_Helper +// Purpose : +//================================================================ +GEOMBase_Helper::~GEOMBase_Helper() +{ + if ( myPreview.size() ) + erasePreview(); + if ( hasCommand() ) + abortCommand(); + + globalSelection( GEOM_ALLOBJECTS, true ); + + delete myDisplayer; +} + +//================================================================ +// Function : display +// Purpose : +//================================================================ +void GEOMBase_Helper::display( const ObjectList& objList, const bool updateView ) +{ + ObjectList::const_iterator it; + for ( it = objList.begin(); it != objList.end(); it++ ) { + display( *it, false ); + } + if ( !objList.empty() && updateView ) + getDisplayer()->UpdateViewer(); +} + +//================================================================ +// Function : display +// Purpose : Display object. +// Important : Object must be already in study +//================================================================ +void GEOMBase_Helper::display( GEOM::GEOM_Object_ptr object, const bool updateView ) +{ + // Unset color of shape ( this color may be set during preview displaying ) + // Default color will be used + getDisplayer()->UnsetColor(); + getDisplayer()->UnsetWidth(); + + // Enable activisation of selection + getDisplayer()->SetToActivate( true ); + + // Display object + getDisplayer()->Display( object, updateView ); +} + +//================================================================ +// Function : erase +// Purpose : +//================================================================ +void GEOMBase_Helper::erase( const ObjectList& objList, const bool updateView ) +{ + ObjectList::const_iterator it = objList.begin(); + for ( ; it != objList.end(); it++ ) { + erase( *it, false ); + } + if ( !objList.empty() && updateView ) + getDisplayer()->UpdateViewer(); +} + +//================================================================ +// Function : erase +// Purpose : +//================================================================ +void GEOMBase_Helper::erase( GEOM::GEOM_Object_ptr object, const bool updateView ) +{ + if ( !object->_is_nil() ) { + string entry = getEntry( object ); + getDisplayer()->Erase( new SALOME_InteractiveObject( + entry.c_str(), "GEOM", strdup( GEOMBase::GetName( object ) ) ), true, updateView ); + } +} + +//================================================================ +// Function : redisplay +// Purpose : +//================================================================ +void GEOMBase_Helper::redisplay( const ObjectList& objList, + const bool withChildren, + const bool updateView ) +{ + ObjectList::const_iterator it = objList.begin(); + for ( ; it != objList.end(); it++ ) { + redisplay( *it, withChildren, false ); + } + if ( !objList.empty() && updateView ) + getDisplayer()->UpdateViewer(); +} + +//================================================================ +// Function : redisplay +// Purpose : +//================================================================ +void GEOMBase_Helper::redisplay( GEOM::GEOM_Object_ptr object, + const bool withChildren, + const bool updateView ) +{ + if ( !object->_is_nil() ) { + // Unset color of shape ( this color may be set during preview displaying ) + // Default color will be used + getDisplayer()->UnsetColor(); + getDisplayer()->UnsetWidth(); + + // Enable activisation of selection + getDisplayer()->SetToActivate( true ); + + string entry = getEntry( object ); + getDisplayer()->Redisplay( new SALOME_InteractiveObject( entry.c_str(), "GEOM", strdup( GEOMBase::GetName( object ) ) ), false ); + } + + if ( withChildren ) { + QAD_Study* aDoc = getStudy(); + if ( aDoc && !CORBA::is_nil( aDoc->getStudyDocument() ) ) { + SALOMEDS::Study_var aStudy = aDoc->getStudyDocument(); + SALOMEDS::SObject_var aSObj = aStudy->FindObjectIOR( GeometryGUI::GetORB()->object_to_string( object ) ); + if ( !CORBA::is_nil( aSObj ) ) { + SALOMEDS::ChildIterator_var anIt = aStudy->NewChildIterator( aSObj ); + for ( anIt->InitEx( true ); anIt->More(); anIt->Next() ) { + GEOM::GEOM_Object_var aChild = GEOM::GEOM_Object::_narrow( anIt->Value()->GetObject() ); + if ( !CORBA::is_nil( aChild ) ) { + if ( !aChild->_is_nil() ) { + string entry = getEntry( aChild ); + getDisplayer()->Redisplay( new SALOME_InteractiveObject( + entry.c_str(), "GEOM", strdup( GEOMBase::GetName( aChild ) ) ), false ); + } + } + } + } + } + } + + if ( updateView ) + getDisplayer()->UpdateViewer(); +} + +//================================================================ +// Function : displayPreview +// Purpose : Method for displaying preview based on execute() results +//================================================================ +void GEOMBase_Helper::displayPreview( const bool activate, + const bool update, + const bool toRemoveFromEngine, + const double lineWidth ) +{ + isPreview = true; + QString msg; + if ( !isValid( msg ) ) + { + erasePreview( update ); + isPreview = false; + return; + } + + erasePreview( false ); + + try { + QAD_WaitCursor wc; + ObjectList objects; + if ( !execute( objects ) || !getOperation()->IsDone() ) { + wc.stop(); + } + else { + for ( ObjectList::iterator it = objects.begin(); it != objects.end(); ++it ) + { + displayPreview( *it, true, activate, false, lineWidth ); + if ( toRemoveFromEngine ) + getGeomEngine()->RemoveObject( *it ); + } + } + } + catch( const SALOME::SALOME_Exception& e ) { + QtCatchCorbaException( e ); + } + + isPreview = false; + + if ( update ) + updateViewer(); +} + +//================================================================ +// Function : displayPreview +// Purpose : Method for displaying preview of resulting shape +//================================================================ +void GEOMBase_Helper::displayPreview( GEOM::GEOM_Object_ptr object, + const bool append, + const bool activate, + const bool update, + const double lineWidth ) +{ + // Set color for preview shape + getDisplayer()->SetColor( Quantity_NOC_VIOLET ); + + // set width of displayed shape + getDisplayer()->SetWidth( lineWidth ); + + // Disable activation of selection + getDisplayer()->SetToActivate( activate ); + + // Make a reference to GEOM_Object + getDisplayer()->SetName( GeometryGUI::GetORB()->object_to_string( object ) ); + + // Build prs + SALOME_Prs* aPrs = getDisplayer()->BuildPrs( object ); + if ( aPrs == 0 || aPrs->IsNull() ) + return; + + // Display prs + displayPreview( aPrs, append, update ); + + getDisplayer()->UnsetName(); + + // Enable activation of displayed objects + getDisplayer()->SetToActivate( true ); +} + +//================================================================ +// Function : displayPreview +// Purpose : Method for displaying arbitrary preview objects (not limited to shapes) +//================================================================ +void GEOMBase_Helper::displayPreview( const SALOME_Prs* prs, + const bool append, + const bool update ) +{ + if ( !append ) + erasePreview( false ); + + // remember current view frame to make correct erase preview later + myViewFrame = getActiveView(); + + if ( myViewFrame == 0 ) + return; + + // Display prs + ( (SALOME_View*)myViewFrame )->Display( prs ); + + // Add prs to the preview list + myPreview.push_back( (SALOME_Prs*)prs ); + + // Update viewer + if ( update ) + myViewFrame->Repaint(); +} + +//================================================================ +// Function : erasePreview +// Purpose : +//================================================================ +void GEOMBase_Helper::erasePreview( const bool update ) +{ + // check view frame where the preview was displayed + bool vfOK = checkViewFrame() && myViewFrame; + // Iterate through presentations and delete them + for ( PrsList::iterator anIter = myPreview.begin(); anIter != myPreview.end(); ++anIter ) { + if ( vfOK ) + ( (SALOME_View*)myViewFrame )->Erase( *anIter, true ); + delete *anIter; + } + myPreview.clear(); + + // Update viewer + if ( update ) + updateViewer(); +} + +//================================================================ +// Function : localSelection +// Purpose : Activate selection of objects of a given type +// IMPORTANT : Works after localSelection( ... ) method call only +//================================================================ +void GEOMBase_Helper::activate( const int theType ) +{ + SALOMEDS::Study_var aStudy = getStudy()->getStudyDocument(); + SALOMEDS::SComponent_var aGeom = aStudy->FindComponent( "GEOM" ); + if ( aGeom->_is_nil() ) + return; + + SALOME_ListIO aList; + SALOMEDS::ChildIterator_var anIter = aStudy->NewChildIterator( aGeom ); + for ( ; anIter->More(); anIter->Next() ) + { + SALOMEDS::SObject_var aSO = anIter->Value(); + if ( !aSO->_is_nil() ) + { + SALOMEDS::SObject_var aRefSO; + if ( !aSO->ReferencedObject( aRefSO ) ) + { + GEOM::GEOM_Object_var anObj = GEOM::GEOM_Object::_narrow( aSO->GetObject() ); + if ( !anObj->_is_nil() && anObj->GetType() == theType ) + aList.Append( new SALOME_InteractiveObject( aSO->GetID(), "GEOM", aSO->GetName()) ); + } + } + } + + myDisplayer->LocalSelection( aList, 0 ); +} + +//================================================================ +// Function : localSelection +// Purpose : Activate selection of subshapes in accordance with mode +// theMode is from TopAbs_ShapeEnum +//================================================================ +void GEOMBase_Helper::localSelection( const ObjectList& theObjs, const int theMode ) +{ + SALOME_ListIO aListOfIO; + + ObjectList::const_iterator anIter = theObjs.begin(); + for ( ; anIter != theObjs.end(); ++anIter ) + { + GEOM::GEOM_Object_ptr anObj = *anIter; + if ( anObj->_is_nil() ) + continue; + string aEntry = getEntry( anObj ); + if ( aEntry != "" ) + aListOfIO.Append( new SALOME_InteractiveObject( + aEntry.c_str(), "GEOM", strdup( GEOMBase::GetName( anObj ) ) ) ); + } + + myDisplayer->LocalSelection( aListOfIO, theMode ); +} + +//================================================================ +// Function : localSelection +// Purpose : Activate selection of subshapes in accordance with mode +// theMode is from TopAbs_ShapeEnum +//================================================================ +void GEOMBase_Helper::localSelection( GEOM::GEOM_Object_ptr obj, const int mode ) +{ + // If object is null local selection for all objects is activated + if ( obj->_is_nil() ) { + myDisplayer->LocalSelection( Handle(SALOME_InteractiveObject)(), mode ); + return; + } + + ObjectList objList; + objList.push_back( obj ); + localSelection( objList, mode ); +} + + +//================================================================ +// Function : globalSelection +// Purpose : Activate selection of subshapes. Set selection filters +// in accordance with mode. theMode is from GEOMImpl_Types +//================================================================ +void GEOMBase_Helper::globalSelection( const int theMode, const bool update ) +{ + myDisplayer->GlobalSelection( theMode, update ); +} + +//================================================================ +// Function : globalSelection +// Purpose : Activate selection of subshapes. Set selection filters +// in accordance with mode. theMode is from GEOMImpl_Types +//================================================================ +void GEOMBase_Helper::globalSelection( const TColStd_MapOfInteger& theModes, + const bool update ) +{ + myDisplayer->GlobalSelection( theModes, update ); +} + +//================================================================ +// Function : addInStudy +// Purpose : Add object in study +//================================================================ +void GEOMBase_Helper::addInStudy( GEOM::GEOM_Object_ptr theObj, const char* theName ) +{ + if ( !hasCommand() ) + return; + + SALOMEDS::Study_var aStudy = getStudy()->getStudyDocument(); + if ( aStudy->_is_nil() || theObj->_is_nil() ) + return; + + GEOM::GEOM_Object_ptr aFatherObj = getFather( theObj ); + + GeometryGUI::GetGeomGUI()->GetGeomGen()->AddInStudy( aStudy, theObj, theName, aFatherObj ); +} + +//================================================================ +// Function : updateObjBrowser +// Purpose : Update object browser +//================================================================ +void GEOMBase_Helper::updateObjBrowser() const +{ + getStudy()->updateObjBrowser(); +} + +//================================================================ +// Function : updateViewer +// Purpose : Update active 3D view +//================================================================ +void GEOMBase_Helper::updateViewer() +{ + getDisplayer()->UpdateViewer(); +} + +//================================================================ +// Function : getStudyId +// Purpose : Get study Id +//================================================================ +int GEOMBase_Helper::getStudyId() const +{ + int anId = -1; + if ( getStudy() ) + anId = getStudy()->getStudyId(); + return anId; +} + +//================================================================ +// Function : getStudy +// Purpose : Returns the active study. It is recommended to use +// this method instead of direct desktop->getActiveStudy() calls +//================================================================ +QAD_Study* GEOMBase_Helper::getStudy() const +{ + // Probably, it would be better to rememeber the active study in helper... + return QAD_Application::getDesktop()->getActiveStudy(); +} + +//================================================================ +// Function : getEntry +// Purpose : +//================================================================ +char* GEOMBase_Helper::getEntry( GEOM::GEOM_Object_ptr object ) const +{ + QAD_Study* study = getStudy(); + if ( study ) { + string IOR = GEOMBase::GetIORFromObject( object); + if ( IOR != "" ) { + SALOMEDS::SObject_var SO = study->getStudyDocument()->FindObjectIOR( IOR.c_str() ); + if ( !SO->_is_nil() ) { + return SO->GetID(); + } + } + } + return ""; +} + +//================================================================ +// Function : getDisplayer +// Purpose : +//================================================================ +GEOM_Displayer* GEOMBase_Helper::getDisplayer() +{ + if ( !myDisplayer ) + myDisplayer = new GEOM_Displayer(); + return myDisplayer; +} + +//================================================================ +// Function : clearShapeBuffer +// Purpose : +//================================================================ +void GEOMBase_Helper::clearShapeBuffer( 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 : openCommand +// Purpose : +//================================================================ +bool GEOMBase_Helper::openCommand() +{ + bool res = false; + if ( !getStudy() || hasCommand() ) + return res; + + GEOM::GEOM_IOperations_var anOp = GEOM::GEOM_IOperations::_narrow( getOperation() ); + if ( !anOp->_is_nil() ) { + myCommand = new GEOM_Operation( getStudy(), anOp.in() ); + myCommand->start(); + res = true; + } + + return res; +} + +//================================================================ +// Function : abortCommand +// Purpose : +//================================================================ +bool GEOMBase_Helper::abortCommand() +{ + if ( !hasCommand() ) + return false; + + myCommand->abort(); + myCommand = 0; + + return true; +} + +//================================================================ +// Function : commitCommand +// Purpose : +//================================================================ +bool GEOMBase_Helper::commitCommand( const char* ) +{ + if ( !hasCommand() ) + return false; + + myCommand->finish(); + myCommand = 0; + + return true; +} + +//================================================================ +// Function : hasCommand +// Purpose : +//================================================================ +bool GEOMBase_Helper::hasCommand() const +{ + return (bool)myCommand; +} + +//================================================================ +// Function : getOperation +// Purpose : +//================================================================ +GEOM::GEOM_IOperations_ptr GEOMBase_Helper::getOperation() +{ + if ( myOperation->_is_nil() ) + myOperation = createOperation(); + + return myOperation; +} + + + +//================================================================ +// Function : checkViewFrame +// Purpose : +//================================================================ +bool GEOMBase_Helper::checkViewFrame() +{ + if ( myViewFrame ){ + QListIterator it( QAD_Application::getDesktop()->getActiveApp()->getStudies() ); + for ( ; it.current(); ++it ) { + QListIterator it1( it.current()->getStudyFrames() ); + for ( ; it1.current(); ++it1 ) { + if ( myViewFrame == it1.current()->getRightFrame()->getViewFrame() ) + return true; + } + } + } + myViewFrame = 0; + return false; +} + +//================================================================ +// 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 GEOMBase_Helper::onAccept( 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; + if ( !execute( objects ) || !getOperation()->IsDone() ) { + 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 + clearShapeBuffer( *it ); + withChildren = true; + redisplay( *it, withChildren, false ); + } + } + + if ( nbObjs ) { + commitCommand(); + updateObjBrowser(); + QAD_Application::getDesktop()->putInfo( QObject::tr("GEOM_PRP_DONE") ); + } + else + abortCommand(); + } + } + } + catch( const SALOME::SALOME_Exception& e ) { + QtCatchCorbaException( e ); + abortCommand(); + } + + updateViewer(); + + return true; +} + + +//================================================================ +// Function : showError +// Purpose : Shows a message box with infromation about an error taken from getOperation()->GetErrorCode() +//================================================================ +void GEOMBase_Helper::showError() +{ + QString msg; + if ( !getOperation()->_is_nil() ) + msg = QObject::tr( getOperation()->GetErrorCode() ); + + if ( msg.isEmpty() ) + msg = QObject::tr( "GEOM_PRP_ABORT" ); + + QAD_MessageBox::error1( QAD_Application::getDesktop(), + QObject::tr( "GEOM_ERROR_STATUS" ), + msg, + QObject::tr( "BUT_OK" ) ); +} + +//================================================================ +// Function : showError +// Purpose : Shows a error message followed by +//================================================================ +void GEOMBase_Helper::showError( const QString& msg ) +{ + QString str( QObject::tr( "GEOM_INCORRECT_INPUT" ) ); + if ( !msg.isEmpty() ) + str += "\n" + msg; + QAD_MessageBox::error1( QAD_Application::getDesktop(), QObject::tr( "GEOM_ERROR" ), str, QObject::tr( "BUT_OK" ) ); +} + +////////////////////////////////////////////////////////////////// +// Virtual methods to be redefined in dialogs +////////////////////////////////////////////////////////////////// + +//================================================================ +// Function : createOperation +// Purpose : Redefine this method to return proper IOperation reference +//================================================================ +GEOM::GEOM_IOperations_ptr GEOMBase_Helper::createOperation() +{ + GEOM::GEOM_IOperations_var aNilOp; + return aNilOp._retn(); +} + +//================================================================ +// Function : isValid +// Purpose : Called by onAccept(). Redefine this method to check validity of user input in dialog boxes. +//================================================================ +bool GEOMBase_Helper::isValid( QString& ) +{ + return true; +} + +//================================================================ +// Function : execute +// Purpose : This method is called by onAccept(). +// It should perform the required operation and put all new or modified objects into +// argument.Should return if some error occurs during its execution. +//================================================================ +bool GEOMBase_Helper::execute( ObjectList& objects ) +{ + return false; +} + +//================================================================ +// Function : getFather +// Purpose : This method is called by addInStudy(). It should return a father object +// for or a nil reference if should be published +// as a top-level object. +//================================================================ +GEOM::GEOM_Object_ptr GEOMBase_Helper::getFather( GEOM::GEOM_Object_ptr theObj ) +{ + return GEOM::GEOM_Object::_nil(); +} + +//================================================================ +// Function : getNewObjectName +// Purpose : Redefine this method to return proper name for a new object +//================================================================ +const char* GEOMBase_Helper::getNewObjectName() const +{ + return ""; +} + +//================================================================ +// Function : getPrefix +// Purpose : Get prefix for name of created object +//================================================================ +QString GEOMBase_Helper::getPrefix( GEOM::GEOM_Object_ptr theObj ) const +{ + if ( !myPrefix.isEmpty() || theObj->_is_nil() ) + return myPrefix; + + TopoDS_Shape aShape; + if ( !GEOMBase::GetShape( theObj, aShape ) ) + return ""; + + long aType = aShape.ShapeType(); + + switch ( aType ) + { + case TopAbs_VERTEX : return QObject::tr( "GEOM_VERTEX" ); + case TopAbs_EDGE : return QObject::tr( "GEOM_EDGE" ); + case TopAbs_WIRE : return QObject::tr( "GEOM_WIRE" ); + case TopAbs_FACE : return QObject::tr( "GEOM_FACE" ); + case TopAbs_SHELL : return QObject::tr( "GEOM_SHELL" ); + case TopAbs_SOLID : return QObject::tr( "GEOM_SOLID" ); + case TopAbs_COMPSOLID: return QObject::tr( "GEOM_COMPOUNDSOLID" ); + case TopAbs_COMPOUND : return QObject::tr( "GEOM_COMPOUND" ); + default : return ""; + } +} + + diff --git a/src/GEOMBase/GEOMBase_Helper.h b/src/GEOMBase/GEOMBase_Helper.h new file mode 100755 index 000000000..64dbd4d22 --- /dev/null +++ b/src/GEOMBase/GEOMBase_Helper.h @@ -0,0 +1,175 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2004 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org or email : webmaster.salome@opencascade.org +// +// +// +// File : GEOMBase_Helper.h +// Author : Sergey ANIKIN +// Module : GEOM +// $Header$ + +#ifndef GEOMBASE_HELPER_H +#define GEOMBASE_HELPER_H + +#include "GEOM_Displayer.h" +#include "SALOME_Prs.h" +#include +#include CORBA_CLIENT_HEADER(GEOM_Gen) + +#include + +#include + +typedef std::list ObjectList; + +class GEOM_Operation; +class QAD_Study; +class TopoDS_Shape; +class QAD_ViewFrame; +class TColStd_MapOfInteger; + +//================================================================ +// Class : GEOMBase_Helper +// Description : Helper class for dialog box development, can be used as +// the second base class for dialog boxes. Contains convenient methods +// performing common operations (display/erase, selection activation, +// publication in a study, transaction management) +//================================================================ +class GEOMBase_Helper +{ +public: + GEOMBase_Helper(); + virtual ~GEOMBase_Helper(); + +protected: + static GEOM::GEOM_Gen_ptr getGeomEngine(); + + void display ( const ObjectList&, const bool = true ); + void display ( GEOM::GEOM_Object_ptr, const bool = true ); + void erase ( const ObjectList&, const bool = true ); + void erase ( GEOM::GEOM_Object_ptr, const bool = true ); + void redisplay ( const ObjectList&, const bool = true, const bool = true ); + void redisplay ( GEOM::GEOM_Object_ptr, const bool = true, const bool = true ); + + virtual void displayPreview ( const bool activate = false, + const bool update = true, + const bool toRemoveFromEngine = true, + const double lineWidth = -1 ); + // This is the easiest way to show preview. It is based on execute() method. + // It removes temporary GEOM::GEOM_Objects automatically. + + virtual void displayPreview ( GEOM::GEOM_Object_ptr obj, + const bool append = false, + const bool activate = false, + const bool update = true, + const double lineWidth = -1 ); + void displayPreview ( const SALOME_Prs* prs, + const bool append = false, + const bool = true ); + void erasePreview ( const bool = true ); + + void localSelection( const ObjectList&, const int ); + void localSelection( GEOM::GEOM_Object_ptr, const int ); + void activate( const int ); + void globalSelection( const int = GEOM_ALLOBJECTS, const bool = false ); + void globalSelection( const TColStd_MapOfInteger&, const bool = false ); + void updateViewer (); + + void prepareSelection( const ObjectList&, const int ); + void prepareSelection( GEOM::GEOM_Object_ptr, const int ); + + void addInStudy ( GEOM::GEOM_Object_ptr, const char* theName ); + + bool openCommand (); + bool abortCommand (); + bool commitCommand ( const char* = 0 ); + bool hasCommand () const; + + void updateObjBrowser() const; + int getStudyId () const; + QAD_Study* getStudy () const; + bool checkViewFrame (); + + bool onAccept( const bool publish = true, const bool useTransaction = true ); + // This method should be called from "OK" button handler. + // == true means that objects returned by execute() + // should be published in a study. + + void showError(); + // Shows a message box with infromation about an error taken from getOperation()->GetErrorCode() + void showError( const QString& msg ); + // Shows a error message followed by + + GEOM::GEOM_IOperations_ptr getOperation(); + // If is nil --> calls createOperation() and put the result + // into and returns it; + // otherwise, simply returns + + inline void setPrefix( const QString& prefix ) { myPrefix = prefix; } + QString getPrefix( GEOM::GEOM_Object_ptr = GEOM::GEOM_Object::_nil() ) const; + + //////////////////////////////////////////////////////////////////////////// + // Virtual methods, to be redefined in dialog classes + //////////////////////////////////////////////////////////////////////////// + + virtual GEOM::GEOM_IOperations_ptr createOperation(); + // This method should be redefined in dialog boxes so as to return + // proper GEOM_IOperation interface. + // Returns nil reference by default + + virtual bool isValid( QString& msg ); + // Called by onAccept(). Redefine this method to check validity of user input in dialog boxes. + + virtual bool execute( ObjectList& objects ); + // This method is called by onAccept(). + // It should perform the required operation and put all new or modified objects into + // argument.Should return if some error occurs during its execution. + + virtual GEOM::GEOM_Object_ptr getFather( GEOM::GEOM_Object_ptr theObj ); + // This method is called by addInStudy(). It should return a father object + // for or a nil reference if should be published + // as a top-level object. + + virtual const char* getNewObjectName() const; + + void SetIsPreview(const bool thePreview) {isPreview = thePreview;} + bool IsPreview() {return isPreview;} + + GEOM_Displayer* getDisplayer(); + +private: + char* getEntry ( GEOM::GEOM_Object_ptr ) const; + void clearShapeBuffer( GEOM::GEOM_Object_ptr ); + +private: + typedef std::list PrsList; + + PrsList myPreview; + GEOM_Displayer* myDisplayer; + GEOM_Operation* myCommand; + GEOM::GEOM_IOperations_var myOperation; + QAD_ViewFrame* myViewFrame; + QString myPrefix; + bool isPreview; + +}; + +#endif diff --git a/src/GEOMBase/GEOMBase_Skeleton.cxx b/src/GEOMBase/GEOMBase_Skeleton.cxx index 85b4f326f..5d2c7fb53 100644 --- a/src/GEOMBase/GEOMBase_Skeleton.cxx +++ b/src/GEOMBase/GEOMBase_Skeleton.cxx @@ -24,10 +24,14 @@ // File : GEOMBase_Skeleton.cxx // Author : Damien COQUERET // Module : GEOM -// $Header: +// $Header$ using namespace std; #include "GEOMBase_Skeleton.h" +#include "GeometryGUI.h" +#include "SALOME_Selection.h" + +#include //================================================================================= // class : GEOMBase_Skeleton() @@ -37,7 +41,7 @@ using namespace std; // TRUE to construct a modal dialog. //================================================================================= GEOMBase_Skeleton::GEOMBase_Skeleton(QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl) - :DlgRef_Skeleton_QTD(parent, name, modal, fl) +:DlgRef_Skeleton_QTD(parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ), GEOMBase_Helper() { if (!name) setName("GEOMBase_Skeleton"); @@ -59,8 +63,7 @@ GEOMBase_Skeleton::GEOMBase_Skeleton(QWidget* parent, const char* name, SALOME_S //================================================================================= GEOMBase_Skeleton::~GEOMBase_Skeleton() { - // no need to delete child widgets, Qt does it all for us - this->destroy(TRUE, TRUE); + myGeomGUI->SetActiveDialogBox( 0 ); } @@ -70,14 +73,13 @@ GEOMBase_Skeleton::~GEOMBase_Skeleton() //================================================================================= void GEOMBase_Skeleton::Init(SALOME_Selection* Sel) { + myGeomGUI = GeometryGUI::GetGeomGUI(); + /* init variables */ mySelection = Sel; - mySimulationTopoDs.Nullify(); - myGeomBase = new GEOMBase(); - myGeomGUI = GEOMContext::GetGeomGUI(); - myGeomGUI->SetActiveDialogBox((QDialog*)this); - myGeom = myGeomGUI->myComponentGeom; + myGeomBase = new GEOMBase(); // SAN -- TO BE REMOVED !!! + myGeomGUI->SetActiveDialogBox(this); /* signals and slots connections */ connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel())); @@ -90,6 +92,7 @@ void GEOMBase_Skeleton::Init(SALOME_Selection* Sel) /* displays Dialog */ RadioButton1->setChecked(TRUE); + RadioButton4->hide(); return; } @@ -101,16 +104,7 @@ void GEOMBase_Skeleton::Init(SALOME_Selection* Sel) //================================================================================= void GEOMBase_Skeleton::ClickOnCancel() { - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); - - mySelection->ClearFilters(); - disconnect(mySelection, 0, this, 0); - - //myGeomGUI->ResetState(); - reject(); - - return; + close(); } @@ -125,7 +119,7 @@ void GEOMBase_Skeleton::LineEditReturnPressed() /* so SelectionIntoArgument() is automatically called. */ const QString objectUserName = myEditCurrentArgument->text(); QWidget* thisWidget = (QWidget*)this; - if(myGeomBase->SelectionByNameInDialogs(thisWidget, objectUserName, mySelection)) + if(GEOMBase::SelectionByNameInDialogs(thisWidget, objectUserName, mySelection)) myEditCurrentArgument->setText(objectUserName); return; @@ -139,11 +133,10 @@ void GEOMBase_Skeleton::LineEditReturnPressed() void GEOMBase_Skeleton::DeactivateActiveDialog() { this->setEnabled(false); - mySelection->ClearFilters(); + globalSelection(); //myGeomGUI->ResetState(); disconnect(mySelection, 0, this, 0); - myGeomBase->EraseSimulationShape(); - myGeomGUI->SetActiveDialogBox(0); + GeometryGUI::GetGeomGUI()->SetActiveDialogBox(0); return; } @@ -155,20 +148,50 @@ void GEOMBase_Skeleton::DeactivateActiveDialog() void GEOMBase_Skeleton::ActivateThisDialog() { /* Emit a signal to deactivate the active dialog */ - myGeomGUI->EmitSignalDeactivateDialog(); + GeometryGUI::GetGeomGUI()->EmitSignalDeactivateDialog(); this->setEnabled(true); - myGeomGUI->SetActiveDialogBox((QDialog*)this); + GeometryGUI::GetGeomGUI()->SetActiveDialogBox((QDialog*)this); return; } //================================================================================= // function : closeEvent() -// purpose : +// purpose : same than click on cancel button //================================================================================= void GEOMBase_Skeleton::closeEvent(QCloseEvent* e) { - /* same than click on cancel button */ - this->ClickOnCancel(); - return; + disconnect(mySelection, 0, this, 0); + QDialog::closeEvent( e ); +} + +//================================================================================= +// function : initName() +// purpose : initialize the Name field with a string "thePrefix_X" (Vertex_3) +//================================================================================= +void GEOMBase_Skeleton::initName( const char* thePrefix ) +{ + if ( thePrefix ) + setPrefix( thePrefix ); + ResultName->setText( GEOMBase::GetDefaultName( getPrefix() ) ); +} + +//================================================================================= +// function : getNewObjectName() +// purpose : returns contents of Name field +//================================================================================= +const char* GEOMBase_Skeleton::getNewObjectName() const +{ + return ResultName->text(); +} + +//================================================================================= +// function : getConstructorId() +// purpose : +//================================================================================= +int GEOMBase_Skeleton::getConstructorId() const +{ + if ( GroupConstructors != NULL && GroupConstructors->selected() != NULL ) + return GroupConstructors->id( GroupConstructors->selected() ); + return -1; } diff --git a/src/GEOMBase/GEOMBase_Skeleton.h b/src/GEOMBase/GEOMBase_Skeleton.h index cfeb6ea45..30d30ec24 100644 --- a/src/GEOMBase/GEOMBase_Skeleton.h +++ b/src/GEOMBase/GEOMBase_Skeleton.h @@ -24,7 +24,7 @@ // File : GEOMBase_Skeleton.h // Author : Damine COQUERET // Module : GEOM -// $Header: +// $Header$ #ifndef GEOMBASE_SKELETON_H #define GEOMBASE_SKELETON_H @@ -32,16 +32,18 @@ #include "DlgRef_Skeleton_QTD.h" #include "GEOMBase.h" +#include "GEOMBase_Helper.h" +#include "GeometryGUI.h" #include #include #include #include +#include #include #include -#include -class GEOMBase_Skeleton : public DlgRef_Skeleton_QTD +class GEOMBase_Skeleton : public DlgRef_Skeleton_QTD, public GEOMBase_Helper { Q_OBJECT @@ -55,12 +57,14 @@ private : protected: void closeEvent(QCloseEvent* e); - TopoDS_Shape mySimulationTopoDs; /* Shape used for simulation display */ + void initName( const char* thePrefix = 0 ); // initialize "Name" field with a string "thePrefix_X" (Vertex_3) + const char* getNewObjectName() const; // returns contents of "Name" field + int getConstructorId() const; // returns id of a selected "constructor" radio button or '-1' in case of error + QLineEdit* myEditCurrentArgument; /* Current LineEdit */ SALOME_Selection* mySelection; /* User shape selection */ - GEOM::GEOM_Gen_var myGeom; /* Current GeomI object */ - GEOMBase* myGeomBase; - GEOMContext* myGeomGUI; /* Current GeomGUI object */ + GEOMBase* myGeomBase; // SAN -- TO BE REMOVED !!! + GeometryGUI* myGeomGUI; /* reference GEOM GUI */ protected slots: void ClickOnCancel(); diff --git a/src/GEOMBase/GEOM_Operation.cxx b/src/GEOMBase/GEOM_Operation.cxx new file mode 100644 index 000000000..a1804d491 --- /dev/null +++ b/src/GEOMBase/GEOM_Operation.cxx @@ -0,0 +1,122 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2004 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org or email : webmaster.salome@opencascade.org +// +// +// +// File : GEOM_Operation.cxx +// Author : Sergey ANIKIN +// Module : GEOM +// $Header$ + +#include "GEOM_Operation.h" + +#include "SALOMEGUI_QtCatchCorbaException.hxx" + +//================================================================ +// Function : GEOM_Operation +// Purpose : +//================================================================ +GEOM_Operation::GEOM_Operation( QAD_Study* doc, GEOM::GEOM_IOperations_ptr oper ) +: QAD_Operation( doc ) +{ + myIOperation = GEOM::GEOM_IOperations::_narrow( oper ); +} + +//================================================================ +// Function : ~GEOM_Operation +// Purpose : +//================================================================ +GEOM_Operation::~GEOM_Operation() +{ +} + +//================================================================ +// Function : onStartOperation() +// Purpose : Opens an internal transaction in GEOM engine +//================================================================ +void GEOM_Operation::onStartOperation() +{ + QAD_Operation::onStartOperation(); + + if ( !myIOperation->_is_nil() ) { + try { + myIOperation->StartOperation(); + } + catch( const SALOME::SALOME_Exception& e ) { + QtCatchCorbaException( e ); + } + } +} + +//================================================================ +// Function : onFinishOperation +// Purpose : Commits an internal transaction in GEOM engine +//================================================================ +void GEOM_Operation::onFinishOperation() +{ + QAD_Operation::onFinishOperation(); + + if ( !myIOperation->_is_nil() ) { + try { + myIOperation->FinishOperation(); + } + catch( const SALOME::SALOME_Exception& e ) { + QtCatchCorbaException( e ); + } + } +} + +//================================================================ +// Function : onSuspendOperation +// Purpose : +//================================================================ +void GEOM_Operation::onSuspendOperation() +{ + QAD_Operation::onSuspendOperation(); +} + +//================================================================ +// Function : onResumeOperation +// Purpose : +//================================================================ +void GEOM_Operation::onResumeOperation() +{ + QAD_Operation::onResumeOperation(); +} + +//================================================================ +// Function : onAbortOperation +// Purpose : Aborts an internal transaction in GEOM engine +//================================================================ +void GEOM_Operation::onAbortOperation() +{ + QAD_Operation::onAbortOperation(); + + if ( !myIOperation->_is_nil() ) { + try { + myIOperation->AbortOperation(); + } + catch( const SALOME::SALOME_Exception& e ) { + QtCatchCorbaException( e ); + } + } +} + diff --git a/src/GEOMBase/GEOM_Operation.h b/src/GEOMBase/GEOM_Operation.h new file mode 100644 index 000000000..8c051e011 --- /dev/null +++ b/src/GEOMBase/GEOM_Operation.h @@ -0,0 +1,54 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2004 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org or email : webmaster.salome@opencascade.org +// +// +// +// File : GEOM_Operation.h +// Author : Sergey ANIKIN +// Module : GEOM +// $Header$ + +#ifndef GEOM_OPERATION_H +#define GEOM_OPERATION_H + +#include "QAD_Operation.h" +#include +#include CORBA_CLIENT_HEADER(GEOM_Gen) + +class GEOM_Operation : public QAD_Operation +{ +public: + GEOM_Operation( QAD_Study*, GEOM::GEOM_IOperations_ptr ); + virtual ~GEOM_Operation(); + +protected: + // Reimplemented from QAD_Operation + virtual void onStartOperation(); + virtual void onFinishOperation(); + virtual void onSuspendOperation(); + virtual void onResumeOperation(); + virtual void onAbortOperation(); + +private: + GEOM::GEOM_IOperations_var myIOperation; +}; + +#endif diff --git a/src/GEOMBase/Makefile.in b/src/GEOMBase/Makefile.in index 42082e5fe..9dff7f68d 100644 --- a/src/GEOMBase/Makefile.in +++ b/src/GEOMBase/Makefile.in @@ -39,20 +39,25 @@ LIB = libGEOMBase.la # header files EXPORT_HEADERS= GEOMBase.h \ - GEOMBase_Skeleton.h + GEOMBase_Skeleton.h \ + GEOMBase_Helper.h \ + GEOM_Operation.h LIB_SRC = GEOMBase.cxx \ GEOMBase_Skeleton.cxx \ - GEOMBase_aParameterDlg.cxx + GEOMBase_aParameterDlg.cxx \ + GEOMBase_Helper.cxx \ + GEOM_Operation.cxx LIB_MOC = \ - GEOMBase.h \ GEOMBase_Skeleton.h \ GEOMBase_aParameterDlg.h LIB_CLIENT_IDL = SALOME_Exception.idl \ SALOMEDS.idl \ - SALOMEDS_Attributes.idl + SALOMEDS_Attributes.idl \ + SALOME_GenericObj.idl \ + GEOM_Gen.idl LIB_SERVER_IDL = @@ -61,6 +66,6 @@ LIB_SERVER_IDL = CPPFLAGS += $(QT_INCLUDES) $(VTK_INCLUDES) $(OCC_INCLUDES) $(PYTHON_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome CXXFLAGS += -I${KERNEL_ROOT_DIR}/include/salome -LDFLAGS += -lDlgRef -lGEOMContext +LDFLAGS += -lDlgRef -lGEOMGUI @CONCLUDE@ diff --git a/src/GEOMClient/GEOM_Client.cxx b/src/GEOMClient/GEOM_Client.cxx index 8c1345ff4..b18299bff 100644 --- a/src/GEOMClient/GEOM_Client.cxx +++ b/src/GEOMClient/GEOM_Client.cxx @@ -29,8 +29,10 @@ using namespace std; #include "GEOM_Client.hxx" #include +#include "OpUtil.hxx" #include "utilities.h" +#include CORBA_SERVER_HEADER(SALOMEDS) #include CORBA_SERVER_HEADER(GEOM_Gen) #include @@ -39,38 +41,34 @@ using namespace std; #include #include #include +#include #include -#include -#include -#include -#include -#include - +#include #include #define HST_CLIENT_LEN 256 + //======================================================================= // function : Load() // purpose : //======================================================================= -TopoDS_Shape GEOM_Client::Load( GEOM::GEOM_Gen_ptr geom, GEOM::GEOM_Shape_ptr aShape ) +TopoDS_Shape GEOM_Client::Load( GEOM::GEOM_Gen_ptr geom, GEOM::GEOM_Object_ptr aShape ) { - char hst_client[HST_CLIENT_LEN]; - gethostname(hst_client, HST_CLIENT_LEN); + string hst_client = GetHostname(); Engines::Container_var ctn_server = geom->GetContainerRef(); long pid_server = ctn_server->getPID(); - - if ( (pid_client==pid_server) && (strcmp(hst_client, ctn_server->getHostName())==0) ) { + + if ( (pid_client==pid_server) && (strcmp(hst_client.c_str(), ctn_server->getHostName())==0) ) { TopoDS_Shape* S = (TopoDS_Shape*)(aShape->getShape()); return(*S); } else { /* get sequence of bytes of resulting brep shape from GEOM server */ TopoDS_Shape S; - GEOM::GEOM_Shape::TMPFile_var SeqFile = aShape->GetShapeStream(); + SALOMEDS::TMPFile_var SeqFile = aShape->GetShapeStream(); int sizebuf = SeqFile->length(); char* buf; buf = (char*) &SeqFile[0]; @@ -88,7 +86,7 @@ TopoDS_Shape GEOM_Client::Load( GEOM::GEOM_Gen_ptr geom, GEOM::GEOM_Shape_ptr aS //======================================================================= GEOM_Client::GEOM_Client() { - pid_client = (-1); + pid_client = (long)getpid(); } //======================================================================= @@ -115,6 +113,20 @@ Standard_Integer GEOM_Client::Find( const TCollection_AsciiString& IOR, TopoDS_S return 0; } +//======================================================================= +// function : Find() +// purpose : +//======================================================================= +Standard_Integer GEOM_Client::Find( const TopoDS_Shape& S, TCollection_AsciiString& IOR ) +{ + for ( Standard_Integer i = 1; i<= myShapes.Length(); i++ ) { + if (myShapes.Value(i) == S) { + IOR = myIORs.Value(i); + return i; + } + } + return 0; +} //======================================================================= // function : Bind() @@ -130,13 +142,13 @@ void GEOM_Client::Bind( const TCollection_AsciiString& IOR, const TopoDS_Shape& // function : RemoveShapeFromBuffer() // purpose : Remove shape from Client Buffer //======================================================================= -void GEOM_Client::RemoveShapeFromBuffer( const TCollection_AsciiString& shapeIOR ) +void GEOM_Client::RemoveShapeFromBuffer( const TCollection_AsciiString& IOR) { if( myIORs.IsEmpty() ) return ; TopoDS_Shape S ; - Standard_Integer anIndex = Find( shapeIOR, S ) ; + Standard_Integer anIndex = Find( IOR, S ) ; if( anIndex != 0 ) { myIORs.Remove(anIndex) ; myShapes.Remove(anIndex) ; @@ -173,105 +185,46 @@ unsigned int GEOM_Client::BufferLength() // purpose : //======================================================================= -TopoDS_Shape GEOM_Client::GetShape( GEOM::GEOM_Gen_ptr geom, GEOM::GEOM_Shape_ptr aShape ) +TopoDS_Shape GEOM_Client::GetShape( GEOM::GEOM_Gen_ptr geom, GEOM::GEOM_Object_ptr aShape ) { - TopoDS_Shape S; - TCollection_AsciiString IOR(aShape->Name()); - Standard_Integer anIndex = Find(IOR, S); + TCollection_AsciiString IOR = geom->GetStringFromIOR(aShape); + Standard_Integer anIndex = Find(IOR, S); - BRep_Builder B; - - if (anIndex !=0 ) { - return S ; - } + if (anIndex !=0 ) return S ; /******* in case of a MAIN GEOM::SHAPE ********/ if (aShape->IsMainShape()) { S = Load(geom, aShape); - Bind(IOR,S); + Bind(IOR, S); return S; } /******* in case of SUB GEOM::SHAPE ***********/ // Load and Explore the Main Shape - TopoDS_Shape MainShape = GetShape (geom, geom->GetIORFromString(aShape->MainName())); - GEOM::GEOM_Shape::ListOfSubShapeID_var list = aShape->Index(); + TopoDS_Shape aMainShape = GetShape (geom, aShape->GetMainShape()); + GEOM::ListOfLong_var list = aShape->GetSubShapeIndices(); + + TopTools_IndexedMapOfShape anIndices; + TopExp::MapShapes(aMainShape, anIndices); - Standard_Integer j = 1; - TopExp_Explorer exp; - TopAbs_ShapeEnum ShapeType = TopAbs_ShapeEnum(aShape->ShapeType()); - /* Case of only one subshape */ if (list->length() == 1) { - if (ShapeType == TopAbs_COMPOUND) - { - TopoDS_Iterator it; - TopTools_ListOfShape CL; - CL.Append( MainShape ); - TopTools_ListIteratorOfListOfShape itC; - for (itC.Initialize( CL ); itC.More(); itC.Next()) - { - for (it.Initialize( itC.Value() ); it.More(); it.Next()) - { - if ( it.Value().ShapeType() == TopAbs_COMPOUND) - { - if (j == list[0]) - { - S = it.Value(); - Bind(IOR, S); - return S; - } - j++; - CL.Append( it.Value() ); - } - } - } - } - else - { - TopTools_MapOfShape M; - for (exp.Init(MainShape, ShapeType); exp.More(); exp.Next()) { - if ( M.Add(exp.Current()) ) - { - if (j == list[0]) - { - S = exp.Current(); - Bind(IOR, S); - return S; - } - j++; - } - } - } + S = anIndices.FindKey(list[0]); } - - /* Case of a compound containing two or more sub shapes (not a main shape compound !) */ - - /* Warning : the compound when representing sub shapes must be explored in a sub type */ - /* that is NOT ShapeType=aShape->ShapeType()= TopAbs_COMPOUND ! */ - /* We have to retrieve the exact sub type of shapes contained in the compound first ! */ - TopoDS_Iterator it ; - TopAbs_ShapeEnum exactSubType ; - S = Load( geom, aShape ); - it.Initialize( S, true, true ) ; - it.More(); - exactSubType = it.Value().ShapeType() ; + else { + BRep_Builder B; + TopoDS_Compound aCompound; + B.MakeCompound(aCompound); + for(int i=0; ilength(); i++) { + TopoDS_Shape aSubShape = anIndices.FindKey(list[i]); + B.Add(aCompound, aSubShape); + } - TColStd_MapOfInteger MapIndex; - Standard_Integer nbSS = list->length(); - TopoDS_Compound Comp; - B.MakeCompound(Comp); - - for (Standard_Integer i=1; i<=nbSS; i++) - MapIndex.Add(list[i-1]); - - for (exp.Init(MainShape, exactSubType), j=1; exp.More() ; exp.Next(), j++) { - if ( MapIndex.Contains(j) ) { - B.Add( Comp, exp.Current() ); - } - } - Bind(IOR, Comp); - return Comp; + S = aCompound; + } + Bind(IOR, S); + return S; } + diff --git a/src/GEOMClient/GEOM_Client.hxx b/src/GEOMClient/GEOM_Client.hxx index 0dbaddd63..0dd255d35 100644 --- a/src/GEOMClient/GEOM_Client.hxx +++ b/src/GEOMClient/GEOM_Client.hxx @@ -30,7 +30,6 @@ #define _GEOM_Client_HeaderFile #include -#include CORBA_SERVER_HEADER(GEOM_Shape) #include CORBA_SERVER_HEADER(GEOM_Gen) # #ifndef _TColStd_SequenceOfAsciiString_HeaderFile @@ -76,13 +75,14 @@ public: // Standard_EXPORT GEOM_Client(); Standard_EXPORT GEOM_Client(Engines::Container_ptr client); - Standard_EXPORT Standard_Integer Find( const TCollection_AsciiString& ShapeIOR, TopoDS_Shape& S ) ; - Standard_EXPORT void Bind( const TCollection_AsciiString& ShapeIOR, const TopoDS_Shape& S ) ; - Standard_EXPORT TopoDS_Shape GetShape( GEOM::GEOM_Gen_ptr geom, GEOM::GEOM_Shape_ptr aShape ); - Standard_EXPORT void RemoveShapeFromBuffer( const TCollection_AsciiString& shapeIOR ) ; + Standard_EXPORT Standard_Integer Find( const TCollection_AsciiString& IOR, TopoDS_Shape& S ) ; + Standard_EXPORT Standard_Integer Find( const TopoDS_Shape& S, TCollection_AsciiString& IOR ) ; + Standard_EXPORT void Bind( const TCollection_AsciiString& IOR, const TopoDS_Shape& S ) ; + Standard_EXPORT TopoDS_Shape GetShape( GEOM::GEOM_Gen_ptr geom, GEOM::GEOM_Object_ptr aShape ); + Standard_EXPORT void RemoveShapeFromBuffer( const TCollection_AsciiString& IOR ) ; Standard_EXPORT void ClearClientBuffer() ; Standard_EXPORT unsigned int BufferLength() ; - TopoDS_Shape Load( GEOM::GEOM_Gen_ptr geom, GEOM::GEOM_Shape_ptr aShape); + TopoDS_Shape Load( GEOM::GEOM_Gen_ptr geom, GEOM::GEOM_Object_ptr aShape); private: // Fields PRIVATE diff --git a/src/GEOMClient/Makefile.in b/src/GEOMClient/Makefile.in index 32db3e220..19a402639 100644 --- a/src/GEOMClient/Makefile.in +++ b/src/GEOMClient/Makefile.in @@ -42,7 +42,9 @@ EXPORT_HEADERS = \ LIB = libGEOMClient.la LIB_SRC = GEOM_Client.cxx -LIB_SERVER_IDL = SALOME_Component.idl SALOMEDS.idl SALOME_Exception.idl GEOM_Shape.idl GEOM_Gen.idl +LIB_SERVER_IDL = \ + SALOME_Component.idl SALOMEDS.idl SALOME_Exception.idl SALOME_GenericObj.idl \ + GEOM_Gen.idl # Executables targets BIN = diff --git a/src/GEOMDS/GEOMDS.cdl b/src/GEOMDS/GEOMDS.cdl deleted file mode 100644 index 0e727a942..000000000 --- a/src/GEOMDS/GEOMDS.cdl +++ /dev/null @@ -1,53 +0,0 @@ --- GEOM GEOMDS : implementation of Geometry component data structure and Geometry documents management --- --- 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 : GEOMDS.cdl --- Author : Yves FRICAUD --- Module : GEOM - -package GEOMDS - - ---Purpose: - -uses - TDF, - TDocStd, - TDataStd, - TColStd, - TopoDS, - TCollection, - TNaming - - -is - class Application; - class Commands; - class Explorer; - - - class DataMapOfIntegerTransient instantiates DataMap from -TCollection(Integer from Standard, Transient from Standard, MapIntegerHasher -from TColStd); - -end GEOMDS; - diff --git a/src/GEOMDS/GEOMDS_Application.cdl b/src/GEOMDS/GEOMDS_Application.cdl deleted file mode 100644 index de1ec2bbc..000000000 --- a/src/GEOMDS/GEOMDS_Application.cdl +++ /dev/null @@ -1,49 +0,0 @@ --- GEOM GEOMDS : implementation of Geometry component data structure and Geometry documents management --- --- 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 : GEOMDS_Application.cdl --- Author : Yves FRICAUD --- Module : GEOM - -class Application from GEOMDS inherits Application from TDocStd - - ---Purpose: - -uses - Label from TDF, - SequenceOfExtendedString from TColStd, - CString from Standard, - Document from TDocStd - - -is - - Create - returns mutable Application from GEOMDS; - - Formats(me: mutable; Formats: out SequenceOfExtendedString from TColStd) - is redefined; - - ResourcesName (me: mutable) returns CString from Standard; - -end Application; diff --git a/src/GEOMDS/GEOMDS_Application.cxx b/src/GEOMDS/GEOMDS_Application.cxx deleted file mode 100644 index 7308742db..000000000 --- a/src/GEOMDS/GEOMDS_Application.cxx +++ /dev/null @@ -1,66 +0,0 @@ -// GEOM GEOMDS : implementation of Geometry component data structure and Geometry documents management -// -// 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 : GEOMDS_Application.cxx -// Author : Yves FRICAUD -// Module : GEOM -// $Header$ - -using namespace std; -#include "GEOMDS_Application.ixx" - -//======================================================================= -//function : GEOMDS_Application -//purpose : -//======================================================================= - -GEOMDS_Application::GEOMDS_Application() -{ -} - - -//======================================================================= -//function : Formats -//purpose : -//======================================================================= - -void GEOMDS_Application::Formats(TColStd_SequenceOfExtendedString& Formats) -{ - Formats.Append(TCollection_ExtendedString ("SALOME_GEOM")); -} - - -//======================================================================= -//function : ResourcesName -//purpose : -//======================================================================= - -Standard_CString GEOMDS_Application::ResourcesName() -{ - return Standard_CString ("GEOMDS_Resources"); -} - - - - - diff --git a/src/GEOMDS/GEOMDS_Application.hxx b/src/GEOMDS/GEOMDS_Application.hxx deleted file mode 100644 index bc5fa691c..000000000 --- a/src/GEOMDS/GEOMDS_Application.hxx +++ /dev/null @@ -1,112 +0,0 @@ -// GEOM GEOMDS : implementation of Geometry component data structure and Geometry documents management -// -// 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 : GEOMDS_Application.hxx -// Module : GEOM - -#ifndef _GEOMDS_Application_HeaderFile -#define _GEOMDS_Application_HeaderFile - -#ifndef _Standard_HeaderFile -#include -#endif -#ifndef _Handle_GEOMDS_Application_HeaderFile -#include -#endif - -#ifndef _TDocStd_Application_HeaderFile -#include -#endif -#ifndef _Standard_CString_HeaderFile -#include -#endif -class TColStd_SequenceOfExtendedString; - - -class GEOMDS_Application : public TDocStd_Application { - -public: - - inline void* operator new(size_t,void* anAddress) - { - return anAddress; - } - inline void* operator new(size_t size) - { - return Standard::Allocate(size); - } - inline void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } -// inline void operator delete(void *anAddress, size_t size) -// { -// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); -// } - // Methods PUBLIC - // -Standard_EXPORT GEOMDS_Application(); -Standard_EXPORT virtual void Formats(TColStd_SequenceOfExtendedString& Formats) ; -Standard_EXPORT Standard_CString ResourcesName() ; -Standard_EXPORT ~GEOMDS_Application(); - - - - - // Type management - // - Standard_EXPORT friend Handle_Standard_Type& GEOMDS_Application_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 - // - - -}; - - - - - -// other inline functions and methods (like "C++: function call" methods) -// - - -#endif diff --git a/src/GEOMDS/GEOMDS_Application.ixx b/src/GEOMDS/GEOMDS_Application.ixx deleted file mode 100644 index c94573fb8..000000000 --- a/src/GEOMDS/GEOMDS_Application.ixx +++ /dev/null @@ -1,86 +0,0 @@ -// GEOM GEOMDS : implementation of Geometry component data structure and Geometry documents management -// -// 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 : GEOMDS_Application.ixx -// Module : GEOM - -#include "GEOMDS_Application.jxx" - -#ifndef _Standard_TypeMismatch_HeaderFile -#include -#endif - -GEOMDS_Application::~GEOMDS_Application() {} - - - -Standard_EXPORT Handle_Standard_Type& GEOMDS_Application_Type_() -{ - - static Handle_Standard_Type aType1 = STANDARD_TYPE(TDocStd_Application); - if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TDocStd_Application); - static Handle_Standard_Type aType2 = STANDARD_TYPE(CDF_Application); - if ( aType2.IsNull()) aType2 = STANDARD_TYPE(CDF_Application); - static Handle_Standard_Type aType3 = STANDARD_TYPE(CDM_Application); - if ( aType3.IsNull()) aType3 = STANDARD_TYPE(CDM_Application); - static Handle_Standard_Type aType4 = STANDARD_TYPE(Standard_Transient); - if ( aType4.IsNull()) aType4 = STANDARD_TYPE(Standard_Transient); - - - static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,aType4,NULL}; - static Handle_Standard_Type _aType = new Standard_Type("GEOMDS_Application", - sizeof(GEOMDS_Application), - 1, - (Standard_Address)_Ancestors, - (Standard_Address)NULL); - - return _aType; -} - -// DownCast method -// allow safe downcasting - - -const Handle(GEOMDS_Application) Handle(GEOMDS_Application)::DownCast(const Handle(Standard_Transient)& AnObject) -{ - Handle(GEOMDS_Application) _anOtherObject; - - if (!AnObject.IsNull()) { - if (AnObject->IsKind(STANDARD_TYPE(GEOMDS_Application))) { - _anOtherObject = Handle(GEOMDS_Application)((Handle(GEOMDS_Application)&)AnObject); - } - } - - return _anOtherObject ; -} - - -const Handle(Standard_Type)& GEOMDS_Application::DynamicType() const -{ - return STANDARD_TYPE(GEOMDS_Application) ; -} -Standard_Boolean GEOMDS_Application::IsKind(const Handle(Standard_Type)& AType) const -{ - return (STANDARD_TYPE(GEOMDS_Application) == AType || TDocStd_Application::IsKind(AType)); -} -Handle_GEOMDS_Application::~Handle_GEOMDS_Application() {} \ No newline at end of file diff --git a/src/GEOMDS/GEOMDS_Application.jxx b/src/GEOMDS/GEOMDS_Application.jxx deleted file mode 100644 index 936d0a158..000000000 --- a/src/GEOMDS/GEOMDS_Application.jxx +++ /dev/null @@ -1,32 +0,0 @@ -// GEOM GEOMDS : implementation of Geometry component data structure and Geometry documents management -// -// 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 : GEOMDS_Application.jxx -// Module : GEOM - -#ifndef _TColStd_SequenceOfExtendedString_HeaderFile -#include -#endif -#ifndef _GEOMDS_Application_HeaderFile -#include "GEOMDS_Application.hxx" -#endif diff --git a/src/GEOMDS/GEOMDS_Commands.cdl b/src/GEOMDS/GEOMDS_Commands.cdl deleted file mode 100644 index a4a2f8f06..000000000 --- a/src/GEOMDS/GEOMDS_Commands.cdl +++ /dev/null @@ -1,46 +0,0 @@ --- GEOM GEOMDS : implementation of Geometry component data structure and Geometry documents management --- --- 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 : GEOMDS_Commands.cdl --- Author : Yves FRICAUD --- Module : GEOM - -class Commands from GEOMDS - - ---Purpose: - -uses - Label from TDF, - Shape from TopoDS, - ExtendedString from TCollection - -is - Create ( Main : Label from TDF) returns Commands from GEOMDS; - - AddShape(me : in out; S : Shape from TopoDS; - Name : ExtendedString from TCollection) - returns Label from TDF; - -fields - myLab : Label from TDF; -end Commands; diff --git a/src/GEOMDS/GEOMDS_Commands.hxx b/src/GEOMDS/GEOMDS_Commands.hxx deleted file mode 100644 index 0e2403920..000000000 --- a/src/GEOMDS/GEOMDS_Commands.hxx +++ /dev/null @@ -1,150 +0,0 @@ -// GEOM GEOMDS : implementation of Geometry component data structure and Geometry documents management -// -// 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 : GeomDS_Commands.hxx -// Author : Yves FRICAUD/Lucien PIGNOLONI -// Module : GEOM -// $Header$ - -#ifndef _GEOMDS_Commands_HeaderFile -#define _GEOMDS_Commands_HeaderFile - -#ifndef _TDF_Label_HeaderFile -#include -#endif -class TDF_Label; -class TopoDS_Shape; -class TCollection_ExtendedString; - - -#ifndef _Standard_HeaderFile -#include -#endif -#ifndef _Standard_Macro_HeaderFile -#include -#endif - - - -//============================================================================ -// class : GEOMDS_Commands -// purpose : -//============================================================================ -class GEOMDS_Commands { - -public: - - inline void* operator new(size_t,void* anAddress) - { - return anAddress; - } - inline void* operator new(size_t size) - { - return Standard::Allocate(size); - } - inline void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } - // inline void operator delete(void *anAddress, size_t size) - // { - // if (anAddress) Standard::Free((Standard_Address&)anAddress,size); - // } - // Methods PUBLIC - // - - // used for specific entities - enum GEOMDS_ConstructiveType { VECTOR, LINE, PLANE } ; - - // Methods to add or create items in the data structure - Standard_EXPORT GEOMDS_Commands(const TDF_Label& Main); - Standard_EXPORT TDF_Label AddShape(const TopoDS_Shape& S, - const TCollection_ExtendedString& Name) ; - - Standard_EXPORT TDF_Label Generated(const TopoDS_Shape& S, - const TCollection_ExtendedString& Name) ; - Standard_EXPORT TDF_Label Generated(const TopoDS_Shape& S1, - const TopoDS_Shape& S2, - const TCollection_ExtendedString& Name) ; - - /* Shapes construction */ - Standard_EXPORT TDF_Label AddIndependentShape(const TopoDS_Shape& S, - const TCollection_AsciiString& nameIOR) ; - Standard_EXPORT TDF_Label AddDependentShape(const TopoDS_Shape& S, - const TCollection_AsciiString& nameIOR, - const TDF_Label& mainLab) ; - Standard_EXPORT TDF_Label AddConstructiveElement(const TopoDS_Shape& S, - const TCollection_ExtendedString& nameIOR, - const GEOMDS_ConstructiveType& aType); - - Standard_EXPORT Standard_Boolean AddIORNameAttribute(const TDF_Label& aLabel, - const TCollection_ExtendedString& nameIOR) ; - - /* Shapes query */ - - Standard_EXPORT Standard_Boolean IsConstructiveElement(const TDF_Label& aLabel) ; - - Standard_EXPORT Standard_Boolean IsConstructiveElement(const TDF_Label& aLabel, - TopoDS_Shape& returnTopo, - GEOMDS_ConstructiveType& returnType) ; - - Standard_EXPORT Standard_Boolean GetShape(const TDF_Label& aLabel, - TopoDS_Shape& returnTopo) ; - - Standard_EXPORT Standard_Boolean IsDependentShape(const TDF_Label& aLabel) ; - - Standard_EXPORT Standard_Boolean GetMainShapeLabel(const TDF_Label& aLabel, - TDF_Label& returnMainLabel) ; - - Standard_EXPORT Standard_Boolean ClearAllIOR(const TDF_Label& aLabel) ; - - Standard_EXPORT Standard_Boolean HasIOR(const TDF_Label& aLabel) ; - - Standard_EXPORT Standard_Boolean ReturnNameIOR(const TDF_Label& aLabel, - TCollection_ExtendedString& returnNameIOR) ; - -protected: - - // Methods PROTECTED - // - - // Fields PROTECTED - // - -private: - - // Methods PRIVATE - // - - // Fields PRIVATE - // - - TDF_Label myLab; - -}; - -// other inline functions and methods (like "C++: function call" methods) -// - - -#endif diff --git a/src/GEOMDS/GEOMDS_Commands.ixx b/src/GEOMDS/GEOMDS_Commands.ixx deleted file mode 100644 index 09d333363..000000000 --- a/src/GEOMDS/GEOMDS_Commands.ixx +++ /dev/null @@ -1,31 +0,0 @@ -// GEOM GEOMDS : implementation of Geometry component data structure and Geometry documents management -// -// 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 : GEOMDS_Commands.ixx -// Module : GEOM - -#include "GEOMDS_Commands.jxx" - - - - diff --git a/src/GEOMDS/GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient.hxx b/src/GEOMDS/GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient.hxx deleted file mode 100644 index b391e99fa..000000000 --- a/src/GEOMDS/GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient.hxx +++ /dev/null @@ -1,118 +0,0 @@ -// GEOM GEOMDS : implementation of Geometry component data structure and Geometry documents management -// -// 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 : GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient.hxx -// Module : GEOM - -#ifndef _GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient_HeaderFile -#define _GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient_HeaderFile - -#ifndef _TCollection_BasicMapIterator_HeaderFile -#include -#endif -#ifndef _Standard_Integer_HeaderFile -#include -#endif -#ifndef _Handle_Standard_Transient_HeaderFile -#include -#endif -#ifndef _Handle_GEOMDS_DataMapNodeOfDataMapOfIntegerTransient_HeaderFile -#include "Handle_GEOMDS_DataMapNodeOfDataMapOfIntegerTransient.hxx" -#endif -class Standard_NoSuchObject; -class Standard_Transient; -class TColStd_MapIntegerHasher; -class GEOMDS_DataMapOfIntegerTransient; -class GEOMDS_DataMapNodeOfDataMapOfIntegerTransient; - - -#ifndef _Standard_HeaderFile -#include -#endif -#ifndef _Standard_Macro_HeaderFile -#include -#endif - -class GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient : public TCollection_BasicMapIterator { - -public: - - inline void* operator new(size_t,void* anAddress) - { - return anAddress; - } - inline void* operator new(size_t size) - { - return Standard::Allocate(size); - } - inline void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } -// inline void operator delete(void *anAddress, size_t size) -// { -// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); -// } - // Methods PUBLIC - // -Standard_EXPORT GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient(); -Standard_EXPORT GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient(const GEOMDS_DataMapOfIntegerTransient& aMap); -Standard_EXPORT void Initialize(const GEOMDS_DataMapOfIntegerTransient& aMap) ; -Standard_EXPORT const Standard_Integer& Key() const; -Standard_EXPORT const Handle_Standard_Transient& Value() const; - - - - - -protected: - - // Methods PROTECTED - // - - - // Fields PROTECTED - // - - -private: - - // Methods PRIVATE - // - - - // Fields PRIVATE - // - - -}; - - - - - -// other inline functions and methods (like "C++: function call" methods) -// - - -#endif diff --git a/src/GEOMDS/GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient_0.cxx b/src/GEOMDS/GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient_0.cxx deleted file mode 100644 index 24cb9de3d..000000000 --- a/src/GEOMDS/GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient_0.cxx +++ /dev/null @@ -1,62 +0,0 @@ -// GEOM GEOMDS : implementation of Geometry component data structure and Geometry documents management -// -// 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 : GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient_0.cxx -// Module : GEOM - -using namespace std; -#include "GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient.hxx" - -#ifndef _Standard_NoSuchObject_HeaderFile -#include -#endif -#ifndef _Standard_Transient_HeaderFile -#include -#endif -#ifndef _TColStd_MapIntegerHasher_HeaderFile -#include -#endif -#ifndef _GEOMDS_DataMapOfIntegerTransient_HeaderFile -#include "GEOMDS_DataMapOfIntegerTransient.hxx" -#endif -#ifndef _GEOMDS_DataMapNodeOfDataMapOfIntegerTransient_HeaderFile -#include "GEOMDS_DataMapNodeOfDataMapOfIntegerTransient.hxx" -#endif - - -#define TheKey Standard_Integer -#define TheKey_hxx -#define TheItem Handle_Standard_Transient -#define TheItem_hxx -#define Hasher TColStd_MapIntegerHasher -#define Hasher_hxx -#define TCollection_DataMapNode GEOMDS_DataMapNodeOfDataMapOfIntegerTransient -#define TCollection_DataMapNode_hxx -#define TCollection_DataMapIterator GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient -#define TCollection_DataMapIterator_hxx -#define Handle_TCollection_DataMapNode Handle_GEOMDS_DataMapNodeOfDataMapOfIntegerTransient -#define TCollection_DataMapNode_Type_() GEOMDS_DataMapNodeOfDataMapOfIntegerTransient_Type_() -#define TCollection_DataMap GEOMDS_DataMapOfIntegerTransient -#define TCollection_DataMap_hxx -#include - diff --git a/src/GEOMDS/GEOMDS_DataMapNodeOfDataMapOfIntegerTransient.hxx b/src/GEOMDS/GEOMDS_DataMapNodeOfDataMapOfIntegerTransient.hxx deleted file mode 100644 index 437a40015..000000000 --- a/src/GEOMDS/GEOMDS_DataMapNodeOfDataMapOfIntegerTransient.hxx +++ /dev/null @@ -1,152 +0,0 @@ -// GEOM GEOMDS : implementation of Geometry component data structure and Geometry documents management -// -// 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 : GEOMDS_DataMapNodeOfDataMapOfIntegerTransient.hxx -// Module : GEOM - -#ifndef _GEOMDS_DataMapNodeOfDataMapOfIntegerTransient_HeaderFile -#define _GEOMDS_DataMapNodeOfDataMapOfIntegerTransient_HeaderFile - -#ifndef _Standard_HeaderFile -#include -#endif -#ifndef _Handle_GEOMDS_DataMapNodeOfDataMapOfIntegerTransient_HeaderFile -#include "Handle_GEOMDS_DataMapNodeOfDataMapOfIntegerTransient.hxx" -#endif - -#ifndef _Standard_Integer_HeaderFile -#include -#endif -#ifndef _Handle_Standard_Transient_HeaderFile -#include -#endif -#ifndef _TCollection_MapNode_HeaderFile -#include -#endif -#ifndef _TCollection_MapNodePtr_HeaderFile -#include -#endif -class Standard_Transient; -class TColStd_MapIntegerHasher; -class GEOMDS_DataMapOfIntegerTransient; -class GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient; - - -class GEOMDS_DataMapNodeOfDataMapOfIntegerTransient : public TCollection_MapNode { - -public: - - inline void* operator new(size_t,void* anAddress) - { - return anAddress; - } - inline void* operator new(size_t size) - { - return Standard::Allocate(size); - } - inline void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } -// inline void operator delete(void *anAddress, size_t size) -// { -// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); -// } - // Methods PUBLIC - // -Standard_EXPORT inline GEOMDS_DataMapNodeOfDataMapOfIntegerTransient(const Standard_Integer& K,const Handle(Standard_Transient)& I,const TCollection_MapNodePtr& n); -Standard_EXPORT inline Standard_Integer& Key() const; -Standard_EXPORT inline Handle_Standard_Transient& Value() const; -Standard_EXPORT ~GEOMDS_DataMapNodeOfDataMapOfIntegerTransient(); - - - - - // Type management - // - Standard_EXPORT friend Handle_Standard_Type& GEOMDS_DataMapNodeOfDataMapOfIntegerTransient_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_Integer myKey; -Handle_Standard_Transient myValue; - - -}; - -#define TheKey Standard_Integer -#define TheKey_hxx -#define TheItem Handle_Standard_Transient -#define TheItem_hxx -#define Hasher TColStd_MapIntegerHasher -#define Hasher_hxx -#define TCollection_DataMapNode GEOMDS_DataMapNodeOfDataMapOfIntegerTransient -#define TCollection_DataMapNode_hxx -#define TCollection_DataMapIterator GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient -#define TCollection_DataMapIterator_hxx -#define Handle_TCollection_DataMapNode Handle_GEOMDS_DataMapNodeOfDataMapOfIntegerTransient -#define TCollection_DataMapNode_Type_() GEOMDS_DataMapNodeOfDataMapOfIntegerTransient_Type_() -#define TCollection_DataMap GEOMDS_DataMapOfIntegerTransient -#define TCollection_DataMap_hxx - -#include - -#undef TheKey -#undef TheKey_hxx -#undef TheItem -#undef TheItem_hxx -#undef Hasher -#undef Hasher_hxx -#undef TCollection_DataMapNode -#undef TCollection_DataMapNode_hxx -#undef TCollection_DataMapIterator -#undef TCollection_DataMapIterator_hxx -#undef Handle_TCollection_DataMapNode -#undef TCollection_DataMapNode_Type_ -#undef TCollection_DataMap -#undef TCollection_DataMap_hxx - - -// other inline functions and methods (like "C++: function call" methods) -// - - -#endif diff --git a/src/GEOMDS/GEOMDS_DataMapNodeOfDataMapOfIntegerTransient_0.cxx b/src/GEOMDS/GEOMDS_DataMapNodeOfDataMapOfIntegerTransient_0.cxx deleted file mode 100644 index 12f74127c..000000000 --- a/src/GEOMDS/GEOMDS_DataMapNodeOfDataMapOfIntegerTransient_0.cxx +++ /dev/null @@ -1,111 +0,0 @@ -// GEOM GEOMDS : implementation of Geometry component data structure and Geometry documents management -// -// 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 : GEOMDS_DataMapNodeOfDataMapOfIntegerTransient_0.cxx -// Module : GEOM - -using namespace std; -#include "GEOMDS_DataMapNodeOfDataMapOfIntegerTransient.hxx" - -#ifndef _Standard_TypeMismatch_HeaderFile -#include -#endif - -#ifndef _Standard_Transient_HeaderFile -#include -#endif -#ifndef _TColStd_MapIntegerHasher_HeaderFile -#include -#endif -#ifndef _GEOMDS_DataMapOfIntegerTransient_HeaderFile -#include "GEOMDS_DataMapOfIntegerTransient.hxx" -#endif -#ifndef _GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient_HeaderFile -#include "GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient.hxx" -#endif -GEOMDS_DataMapNodeOfDataMapOfIntegerTransient::~GEOMDS_DataMapNodeOfDataMapOfIntegerTransient() {} - - - -Standard_EXPORT Handle_Standard_Type& GEOMDS_DataMapNodeOfDataMapOfIntegerTransient_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("GEOMDS_DataMapNodeOfDataMapOfIntegerTransient", - sizeof(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient), - 1, - (Standard_Address)_Ancestors, - (Standard_Address)NULL); - - return _aType; -} - - -// DownCast method -// allow safe downcasting -// -const Handle(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient) Handle(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient)::DownCast(const Handle(Standard_Transient)& AnObject) -{ - Handle(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient) _anOtherObject; - - if (!AnObject.IsNull()) { - if (AnObject->IsKind(STANDARD_TYPE(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient))) { - _anOtherObject = Handle(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient)((Handle(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient)&)AnObject); - } - } - - return _anOtherObject ; -} -const Handle(Standard_Type)& GEOMDS_DataMapNodeOfDataMapOfIntegerTransient::DynamicType() const -{ - return STANDARD_TYPE(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient) ; -} -Standard_Boolean GEOMDS_DataMapNodeOfDataMapOfIntegerTransient::IsKind(const Handle(Standard_Type)& AType) const -{ - return (STANDARD_TYPE(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient) == AType || TCollection_MapNode::IsKind(AType)); -} -Handle_GEOMDS_DataMapNodeOfDataMapOfIntegerTransient::~Handle_GEOMDS_DataMapNodeOfDataMapOfIntegerTransient() {} -#define TheKey Standard_Integer -#define TheKey_hxx -#define TheItem Handle_Standard_Transient -#define TheItem_hxx -#define Hasher TColStd_MapIntegerHasher -#define Hasher_hxx -#define TCollection_DataMapNode GEOMDS_DataMapNodeOfDataMapOfIntegerTransient -#define TCollection_DataMapNode_hxx -#define TCollection_DataMapIterator GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient -#define TCollection_DataMapIterator_hxx -#define Handle_TCollection_DataMapNode Handle_GEOMDS_DataMapNodeOfDataMapOfIntegerTransient -#define TCollection_DataMapNode_Type_() GEOMDS_DataMapNodeOfDataMapOfIntegerTransient_Type_() -#define TCollection_DataMap GEOMDS_DataMapOfIntegerTransient -#define TCollection_DataMap_hxx -#include - diff --git a/src/GEOMDS/GEOMDS_DataMapOfIntegerTransient.hxx b/src/GEOMDS/GEOMDS_DataMapOfIntegerTransient.hxx deleted file mode 100644 index 52fb4b920..000000000 --- a/src/GEOMDS/GEOMDS_DataMapOfIntegerTransient.hxx +++ /dev/null @@ -1,140 +0,0 @@ -// GEOM GEOMDS : implementation of Geometry component data structure and Geometry documents management -// -// 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 : GEOMDS_DataMapOfIntegerTransient.hxx -// Module : GEOM - -#ifndef _GEOMDS_DataMapOfIntegerTransient_HeaderFile -#define _GEOMDS_DataMapOfIntegerTransient_HeaderFile - -#ifndef _TCollection_BasicMap_HeaderFile -#include -#endif -#ifndef _Standard_Integer_HeaderFile -#include -#endif -#ifndef _Handle_Standard_Transient_HeaderFile -#include -#endif -#ifndef _Handle_GEOMDS_DataMapNodeOfDataMapOfIntegerTransient_HeaderFile -#include "Handle_GEOMDS_DataMapNodeOfDataMapOfIntegerTransient.hxx" -#endif -#ifndef _Standard_Boolean_HeaderFile -#include -#endif -class Standard_DomainError; -class Standard_NoSuchObject; -class Standard_Transient; -class TColStd_MapIntegerHasher; -class GEOMDS_DataMapNodeOfDataMapOfIntegerTransient; -class GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient; - - -#ifndef _Standard_HeaderFile -#include -#endif -#ifndef _Standard_Macro_HeaderFile -#include -#endif - -class GEOMDS_DataMapOfIntegerTransient : public TCollection_BasicMap { - -public: - - inline void* operator new(size_t,void* anAddress) - { - return anAddress; - } - inline void* operator new(size_t size) - { - return Standard::Allocate(size); - } - inline void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } -// inline void operator delete(void *anAddress, size_t size) -// { -// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); -// } - // Methods PUBLIC - // -Standard_EXPORT GEOMDS_DataMapOfIntegerTransient(const Standard_Integer NbBuckets = 1); -Standard_EXPORT GEOMDS_DataMapOfIntegerTransient& Assign(const GEOMDS_DataMapOfIntegerTransient& Other) ; -GEOMDS_DataMapOfIntegerTransient& operator =(const GEOMDS_DataMapOfIntegerTransient& Other) -{ - return Assign(Other); -} - -Standard_EXPORT void ReSize(const Standard_Integer NbBuckets) ; -Standard_EXPORT void Clear() ; -~GEOMDS_DataMapOfIntegerTransient() -{ - Clear(); -} - -Standard_EXPORT Standard_Boolean Bind(const Standard_Integer& K,const Handle(Standard_Transient)& I) ; -Standard_EXPORT Standard_Boolean IsBound(const Standard_Integer& K) const; -Standard_EXPORT Standard_Boolean UnBind(const Standard_Integer& K) ; -Standard_EXPORT const Handle_Standard_Transient& Find(const Standard_Integer& K) const; - const Handle_Standard_Transient& operator()(const Standard_Integer& K) const -{ - return Find(K); -} - -Standard_EXPORT Handle_Standard_Transient& ChangeFind(const Standard_Integer& K) ; - Handle_Standard_Transient& operator()(const Standard_Integer& K) -{ - return ChangeFind(K); -} - - -protected: - - // Methods PROTECTED - // - - - // Fields PROTECTED - // - - -private: - - // Methods PRIVATE - // - Standard_EXPORT GEOMDS_DataMapOfIntegerTransient(const GEOMDS_DataMapOfIntegerTransient& Other); - - -// Fields PRIVATE -// - - -}; - - -// other inline functions and methods (like "C++: function call" methods) -// - - -#endif diff --git a/src/GEOMDS/GEOMDS_DataMapOfIntegerTransient_0.cxx b/src/GEOMDS/GEOMDS_DataMapOfIntegerTransient_0.cxx deleted file mode 100644 index da4ed5f16..000000000 --- a/src/GEOMDS/GEOMDS_DataMapOfIntegerTransient_0.cxx +++ /dev/null @@ -1,65 +0,0 @@ -// GEOM GEOMDS : implementation of Geometry component data structure and Geometry documents management -// -// 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 : GEOMDS_DataMapOfIntegerTransient_0.cxx -// Module : GEOM - -using namespace std; -#include "GEOMDS_DataMapOfIntegerTransient.hxx" - -#ifndef _Standard_DomainError_HeaderFile -#include -#endif -#ifndef _Standard_NoSuchObject_HeaderFile -#include -#endif -#ifndef _Standard_Transient_HeaderFile -#include -#endif -#ifndef _TColStd_MapIntegerHasher_HeaderFile -#include -#endif -#ifndef _GEOMDS_DataMapNodeOfDataMapOfIntegerTransient_HeaderFile -#include "GEOMDS_DataMapNodeOfDataMapOfIntegerTransient.hxx" -#endif -#ifndef _GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient_HeaderFile -#include "GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient.hxx" -#endif - - -#define TheKey Standard_Integer -#define TheKey_hxx -#define TheItem Handle_Standard_Transient -#define TheItem_hxx -#define Hasher TColStd_MapIntegerHasher -#define Hasher_hxx -#define TCollection_DataMapNode GEOMDS_DataMapNodeOfDataMapOfIntegerTransient -#define TCollection_DataMapNode_hxx -#define TCollection_DataMapIterator GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient -#define TCollection_DataMapIterator_hxx -#define Handle_TCollection_DataMapNode Handle_GEOMDS_DataMapNodeOfDataMapOfIntegerTransient -#define TCollection_DataMapNode_Type_() GEOMDS_DataMapNodeOfDataMapOfIntegerTransient_Type_() -#define TCollection_DataMap GEOMDS_DataMapOfIntegerTransient -#define TCollection_DataMap_hxx -#include - diff --git a/src/GEOMDS/GEOMDS_Explorer.cdl b/src/GEOMDS/GEOMDS_Explorer.cdl deleted file mode 100644 index eb737cf95..000000000 --- a/src/GEOMDS/GEOMDS_Explorer.cdl +++ /dev/null @@ -1,52 +0,0 @@ --- GEOM GEOMDS : implementation of Geometry component data structure and Geometry documents management --- --- 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 : GEOMDS_Explorer.cdl --- Author : Yves FRICAUD --- Module : GEOM - -class Explorer from GEOMDS - - ---Purpose: - -uses - ChildIterator from TDF, - Label from TDF, - ExtendedString from TCollection, - Shape from TopoDS - - -is - Create ( Main : Label from TDF) returns Explorer from GEOMDS; - - More(me : in out) returns Boolean from Standard; - - Next(me : in out); - - Shape(me)returns Shape from TopoDS; - - Name(me) returns ExtendedString from TCollection; - -fields - myChildIterator : ChildIterator from TDF; -end Explorer; diff --git a/src/GEOMDS/GEOMDS_Explorer.cxx b/src/GEOMDS/GEOMDS_Explorer.cxx deleted file mode 100644 index 8a40ff226..000000000 --- a/src/GEOMDS/GEOMDS_Explorer.cxx +++ /dev/null @@ -1,126 +0,0 @@ -// GEOM GEOMDS : implementation of Geometry component data structure and Geometry documents management -// -// 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 : GEOMDS_Explorer.cxx -// Author : Yves FRICAUD -// Module : GEOM -// $Header$ - -using namespace std; -#include "GEOMDS_Explorer.ixx" - -#include -#include -#include - - -//======================================================================= -//function : GEOMDS_Explorer -//purpose : -//======================================================================= - -GEOMDS_Explorer::GEOMDS_Explorer(const TDF_Label& Main) : myChildIterator(Main) -{ -} - - -//======================================================================= -//function : const; -//purpose : -//======================================================================= - -Standard_Boolean GEOMDS_Explorer::More() -{ - if (!myChildIterator.More()) - return 0; - Handle(TDataStd_Name) Att; - Handle(TNaming_NamedShape) NS; - TDF_Label L = myChildIterator.Value(); - if (( L.FindAttribute(TDataStd_Name::GetID(),Att) ) || - (L.FindAttribute(TNaming_NamedShape::GetID(),NS)) - ) - return 1; - // myChildIterator.Next(); - // More(); - return 0; - /* - if (!myChildIterator.More()) - return 0; - TDF_Label L = myChildIterator.Value(); - Handle(TNaming_NamedShape) NS; - for (TDF_ChildIterator it2(L); it2.More(); it2.Next()) { - TDF_Label L2 = it2.Value(); - if (L2.FindAttribute(TNaming_NamedShape::GetID(),NS)) { - return 1; - } - myChildIterator.Next(); - } - return 0; - */ -} - - -//======================================================================= -//function : Next -//purpose : -//======================================================================= - -void GEOMDS_Explorer::Next() -{ - myChildIterator.Next(); -} - - -//======================================================================= -//function : Shape -//purpose : -//======================================================================= - -TopoDS_Shape GEOMDS_Explorer::Shape() const -{ - Handle(TNaming_NamedShape) NS; - TDF_Label L = myChildIterator.Value(); - L.FindAttribute(TNaming_NamedShape::GetID(),NS); - TopoDS_Shape S = TNaming_Tool::GetShape(NS); - return S; -} - -//======================================================================= -//function : Name -//purpose : -//======================================================================= - -TCollection_ExtendedString GEOMDS_Explorer::Name() const -{ - TDF_Label L = myChildIterator.Value(); - Handle(TDataStd_Name) Att; - if ( L.FindAttribute(TDataStd_Name::GetID(),Att) ) - //L.FindAttribute(TDataStd_Name::GetID(),Att); - return Att->Get(); - else - return TCollection_ExtendedString(); -} - - - - diff --git a/src/GEOMDS/GEOMDS_Explorer.hxx b/src/GEOMDS/GEOMDS_Explorer.hxx deleted file mode 100644 index 29ce10bc9..000000000 --- a/src/GEOMDS/GEOMDS_Explorer.hxx +++ /dev/null @@ -1,101 +0,0 @@ -// GEOM GEOMDS : implementation of Geometry component data structure and Geometry documents management -// -// 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 : GEOMDS_Explorer.hxx -// Module : GEOM - -#ifndef _GEOMDS_Explorer_HeaderFile -#define _GEOMDS_Explorer_HeaderFile - -#ifndef _TDF_ChildIterator_HeaderFile -#include -#endif -#ifndef _Standard_Boolean_HeaderFile -#include -#endif -class TDF_Label; -class TopoDS_Shape; -class TCollection_ExtendedString; - - -#ifndef _Standard_HeaderFile -#include -#endif -#ifndef _Standard_Macro_HeaderFile -#include -#endif - -class GEOMDS_Explorer { - -public: - - inline void* operator new(size_t,void* anAddress) - { - return anAddress; - } - inline void* operator new(size_t size) - { - return Standard::Allocate(size); - } - inline void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } -// inline void operator delete(void *anAddress, size_t size) -// { -// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); -// } - // Methods PUBLIC - // -Standard_EXPORT GEOMDS_Explorer(const TDF_Label& Main); -Standard_EXPORT Standard_Boolean More() ; -Standard_EXPORT void Next() ; -Standard_EXPORT TopoDS_Shape Shape() const; -Standard_EXPORT TCollection_ExtendedString Name() const; - -protected: - - // Methods PROTECTED - // - - // Fields PROTECTED - // - - -private: - - // Methods PRIVATE - // - - // Fields PRIVATE - // -TDF_ChildIterator myChildIterator; - - -}; - - -// other inline functions and methods (like "C++: function call" methods) -// - -#endif diff --git a/src/GEOMDS/GEOMDS_Explorer.ixx b/src/GEOMDS/GEOMDS_Explorer.ixx deleted file mode 100644 index cd182b147..000000000 --- a/src/GEOMDS/GEOMDS_Explorer.ixx +++ /dev/null @@ -1,31 +0,0 @@ -// GEOM GEOMDS : implementation of Geometry component data structure and Geometry documents management -// -// 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 : GEOMDS_Explorer.ixx -// Module : GEOM - -#include "GEOMDS_Explorer.jxx" - - - - diff --git a/src/GEOMDS/GEOMDS_Explorer.jxx b/src/GEOMDS/GEOMDS_Explorer.jxx deleted file mode 100644 index 3a0770d28..000000000 --- a/src/GEOMDS/GEOMDS_Explorer.jxx +++ /dev/null @@ -1,38 +0,0 @@ -// GEOM GEOMDS : implementation of Geometry component data structure and Geometry documents management -// -// 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 : GEOMDS_Explorer.jxx -// Module : GEOM - -#ifndef _TDF_Label_HeaderFile -#include -#endif -#ifndef _TopoDS_Shape_HeaderFile -#include -#endif -#ifndef _TCollection_ExtendedString_HeaderFile -#include -#endif -#ifndef _GEOMDS_Explorer_HeaderFile -#include "GEOMDS_Explorer.hxx" -#endif diff --git a/src/GEOMDS/Handle_GEOMDS_Application.hxx b/src/GEOMDS/Handle_GEOMDS_Application.hxx deleted file mode 100644 index 418b10298..000000000 --- a/src/GEOMDS/Handle_GEOMDS_Application.hxx +++ /dev/null @@ -1,100 +0,0 @@ -// GEOM GEOMDS : implementation of Geometry component data structure and Geometry documents management -// -// 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 : Handle_GEOMDS_Application.hxx -// Module : GEOM - -#ifndef _Handle_GEOMDS_Application_HeaderFile -#define _Handle_GEOMDS_Application_HeaderFile - -#ifndef _Standard_Macro_HeaderFile -#include -#endif -#ifndef _Standard_HeaderFile -#include -#endif - -#ifndef _Handle_TDocStd_Application_HeaderFile -#include -#endif - -class Standard_Transient; -class Handle_Standard_Type; -class Handle(TDocStd_Application); -class GEOMDS_Application; -Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(SimpleOCAF_Application); - -class Handle(GEOMDS_Application) : public Handle(TDocStd_Application) { - public: - inline void* operator new(size_t,void* anAddress) - { - return anAddress; - } - inline void* operator new(size_t size) - { - return Standard::Allocate(size); - } - inline void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } -// inline void operator delete(void *anAddress, size_t size) -// { -// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); -// } - Handle(GEOMDS_Application)():Handle(TDocStd_Application)() {} - Handle(GEOMDS_Application)(const Handle(GEOMDS_Application)& aHandle) : Handle(TDocStd_Application)(aHandle) - { - } - - Handle(GEOMDS_Application)(const GEOMDS_Application* anItem) : Handle(TDocStd_Application)((TDocStd_Application *)anItem) - { - } - - Handle(GEOMDS_Application)& operator=(const Handle(GEOMDS_Application)& aHandle) - { - Assign(aHandle.Access()); - return *this; - } - - Handle(GEOMDS_Application)& operator=(const GEOMDS_Application* anItem) - { - Assign((Standard_Transient *)anItem); - return *this; - } - - GEOMDS_Application* operator->() - { - return (GEOMDS_Application *)ControlAccess(); - } - - GEOMDS_Application* operator->() const - { - return (GEOMDS_Application *)ControlAccess(); - } - - Standard_EXPORT ~Handle(GEOMDS_Application)(); - - Standard_EXPORT static const Handle(GEOMDS_Application) DownCast(const Handle(Standard_Transient)& AnObject); -}; -#endif diff --git a/src/GEOMDS/Handle_GEOMDS_DataMapNodeOfDataMapOfIntegerTransient.hxx b/src/GEOMDS/Handle_GEOMDS_DataMapNodeOfDataMapOfIntegerTransient.hxx deleted file mode 100644 index 911d6a490..000000000 --- a/src/GEOMDS/Handle_GEOMDS_DataMapNodeOfDataMapOfIntegerTransient.hxx +++ /dev/null @@ -1,100 +0,0 @@ -// GEOM GEOMDS : implementation of Geometry component data structure and Geometry documents management -// -// 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 : Handle_GEOMDS_DataMapNodeOfDataMapOfIntegerTransient.hxx -// Module : GEOM - -#ifndef _Handle_GEOMDS_DataMapNodeOfDataMapOfIntegerTransient_HeaderFile -#define _Handle_GEOMDS_DataMapNodeOfDataMapOfIntegerTransient_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 GEOMDS_DataMapNodeOfDataMapOfIntegerTransient; -Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient); - -class Handle(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient) : public Handle(TCollection_MapNode) { - public: - inline void* operator new(size_t,void* anAddress) - { - return anAddress; - } - inline void* operator new(size_t size) - { - return Standard::Allocate(size); - } - inline void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } -// inline void operator delete(void *anAddress, size_t size) -// { -// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); -// } - Handle(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient)():Handle(TCollection_MapNode)() {} - Handle(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient)(const Handle(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient)& aHandle) : Handle(TCollection_MapNode)(aHandle) - { - } - - Handle(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient)(const GEOMDS_DataMapNodeOfDataMapOfIntegerTransient* anItem) : Handle(TCollection_MapNode)((TCollection_MapNode *)anItem) - { - } - - Handle(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient)& operator=(const Handle(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient)& aHandle) - { - Assign(aHandle.Access()); - return *this; - } - - Handle(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient)& operator=(const GEOMDS_DataMapNodeOfDataMapOfIntegerTransient* anItem) - { - Assign((Standard_Transient *)anItem); - return *this; - } - - GEOMDS_DataMapNodeOfDataMapOfIntegerTransient* operator->() - { - return (GEOMDS_DataMapNodeOfDataMapOfIntegerTransient *)ControlAccess(); - } - - GEOMDS_DataMapNodeOfDataMapOfIntegerTransient* operator->() const - { - return (GEOMDS_DataMapNodeOfDataMapOfIntegerTransient *)ControlAccess(); - } - - Standard_EXPORT ~Handle(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient)(); - - Standard_EXPORT static const Handle(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient) DownCast(const Handle(Standard_Transient)& AnObject); -}; -#endif diff --git a/src/GEOMDS/Makefile.in b/src/GEOMDS/Makefile.in deleted file mode 100644 index b58244fd1..000000000 --- a/src/GEOMDS/Makefile.in +++ /dev/null @@ -1,74 +0,0 @@ -# GEOM GEOMDS : implementation of Geometry component data structure and Geometry documents management -# -# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -# -# -# -# File : Makefile.in -# Author : Patrick GOLDBRONN (CEA) -# Module : GEOM -# $Header$ - -top_srcdir=@top_srcdir@ -top_builddir=../.. -srcdir=@srcdir@ -VPATH=.:@srcdir@:@top_srcdir@/idl - - -@COMMENCE@ - -# Libraries targets - -LIB = libGEOMDS.la -LIB_SRC = GEOMDS_Application.cxx \ - GEOMDS_Commands.cxx \ - GEOMDS_Explorer.cxx \ - GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient_0.cxx \ - GEOMDS_DataMapNodeOfDataMapOfIntegerTransient_0.cxx \ - GEOMDS_DataMapOfIntegerTransient_0.cxx -LIB_CLIENT_IDL = -LIB_SERVER_IDL = - -# Executables targets -BIN = -BIN_SRC = -BIN_CLIENT_IDL = -BIN_SERVER_IDL = - -# header files -EXPORT_HEADERS= GEOMDS_Application.hxx \ - GEOMDS_DataMapOfIntegerTransient.hxx \ - Handle_GEOMDS_DataMapNodeOfDataMapOfIntegerTransient.hxx \ - Handle_GEOMDS_Application.hxx \ - GEOMDS_Commands.hxx \ - GEOMDS_Explorer.hxx - -# additionnal information to compil and link file -CPPFLAGS += $(OCC_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome -CXXFLAGS += $(OCC_CXXFLAGS) -I${KERNEL_ROOT_DIR}/include/salome -LDFLAGS += $(CAS_LDPATH) -lTKCAF - -# additional file to be cleaned -MOSTLYCLEAN = -CLEAN = -DISTCLEAN = - -@CONCLUDE@ - diff --git a/src/GEOMFiltersSelection/GEOM_EdgeFilter.cxx b/src/GEOMFiltersSelection/GEOM_EdgeFilter.cxx index e61d3d30f..94729c71d 100644 --- a/src/GEOMFiltersSelection/GEOM_EdgeFilter.cxx +++ b/src/GEOMFiltersSelection/GEOM_EdgeFilter.cxx @@ -28,107 +28,39 @@ using namespace std; #include "GEOM_EdgeFilter.ixx" -#include "GEOM_Client.hxx" -#include "SALOME_InteractiveObject.hxx" -#include "GEOM_InteractiveObject.hxx" -#include "GEOM_ShapeTypeFilter.hxx" -#include "SALOME_TypeFilter.hxx" - -#include "utilities.h" -#include "QAD_Application.h" -#include "QAD_Desktop.h" -#include "QAD_Study.h" - -// Open CASCADE Includes #include #include #include -#include - - -static GEOM_Client ShapeReader; -/*! - enumeration TypeOfEdge is AnyEdge,Line,Circle; -*/ -GEOM_EdgeFilter::GEOM_EdgeFilter(const StdSelect_TypeOfEdge Edge, - GEOM::GEOM_Gen_ptr geom) +//======================================================================= +// function : IsShapeOk +// purpose : enumeration TypeOfEdge is AnyEdge,Line,Circle; +//======================================================================= +GEOM_EdgeFilter::GEOM_EdgeFilter( const StdSelect_TypeOfEdge theKind ) +: GEOM_ShapeTypeFilter( TopAbs_EDGE ) { - myKind = Edge; - myComponentGeom = GEOM::GEOM_Gen::_narrow(geom); + myKind = theKind; } -Standard_Boolean GEOM_EdgeFilter::IsOk(const Handle(SALOME_InteractiveObject)& anObj) const +//======================================================================= +// function : IsShapeOk +// purpose : +//======================================================================= +Standard_Boolean GEOM_EdgeFilter::IsShapeOk( const TopoDS_Shape& theShape ) const { - Handle(SALOME_TypeFilter) GeomFilter = new SALOME_TypeFilter( "GEOM" ); - if ( !GeomFilter->IsOk(anObj) ) - return false; - - Handle(GEOM_ShapeTypeFilter) GeomShapeTypeFilter = new GEOM_ShapeTypeFilter( TopAbs_EDGE, myComponentGeom ); - if ( !GeomShapeTypeFilter->IsOk(anObj) ) - return false; - - if ( anObj->hasEntry() ) { - QAD_Study* ActiveStudy = QAD_Application::getDesktop()->getActiveStudy(); - SALOMEDS::Study_var aStudy = ActiveStudy->getStudyDocument(); - SALOMEDS::SObject_var obj = aStudy->FindObjectID( anObj->getEntry() ); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeIOR_var anIOR; - if ( !obj->_is_nil() ) { - if (obj->FindAttribute(anAttr, "AttributeIOR")) { - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( anIOR->Value() ); - if ( aShape->_is_nil() ) - return false; - - TopoDS_Shape Shape = ShapeReader.GetShape( myComponentGeom, aShape ); - if ( Shape.IsNull() ) - return false; - - switch (myKind) { - case StdSelect_AnyEdge: - return Standard_True; - case StdSelect_Line: - { - BRepAdaptor_Curve curv(TopoDS::Edge(Shape)); - return (curv.GetType() == GeomAbs_Line); - } - break; - case StdSelect_Circle: - BRepAdaptor_Curve curv(TopoDS::Edge(Shape)); - return (curv.GetType() == GeomAbs_Circle); - } - } - } - } - - if ( anObj->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject)) ) { - Handle(GEOM_InteractiveObject) GObject = - Handle(GEOM_InteractiveObject)::DownCast(anObj); - - GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( GObject->getIOR() ); - if ( aShape->_is_nil() ) - return false; - - TopoDS_Shape Shape = ShapeReader.GetShape( myComponentGeom, aShape ); - if ( Shape.IsNull() ) - return false; - - switch (myKind) { - case StdSelect_AnyEdge: - return Standard_True; - case StdSelect_Line: - { - BRepAdaptor_Curve curv(TopoDS::Edge(Shape)); - return (curv.GetType() == GeomAbs_Line); - } - break; - case StdSelect_Circle: - BRepAdaptor_Curve curv(TopoDS::Edge(Shape)); - return (curv.GetType() == GeomAbs_Circle); + if ( !theShape.IsNull() && theShape.ShapeType() == TopAbs_EDGE ) + { + BRepAdaptor_Curve aCurve( TopoDS::Edge( theShape ) ); + GeomAbs_CurveType aType = aCurve.GetType(); + + switch ( myKind ) + { + case StdSelect_AnyEdge: return Standard_True; + case StdSelect_Line: return ( aType == GeomAbs_Line ); + case StdSelect_Circle: return ( aType == GeomAbs_Circle ); } } - return false; + return Standard_False; } diff --git a/src/GEOMFiltersSelection/GEOM_EdgeFilter.hxx b/src/GEOMFiltersSelection/GEOM_EdgeFilter.hxx index a464cdae9..ea4428983 100644 --- a/src/GEOMFiltersSelection/GEOM_EdgeFilter.hxx +++ b/src/GEOMFiltersSelection/GEOM_EdgeFilter.hxx @@ -32,21 +32,18 @@ #endif #include "SALOME_InteractiveObject.hxx" -#include "SALOME_Filter.hxx" +#include "GEOM_ShapeTypeFilter.hxx" // IDL Headers #include -#include CORBA_SERVER_HEADER(GEOM_Shape) #include CORBA_SERVER_HEADER(GEOM_Gen) #include CORBA_SERVER_HEADER(SALOMEDS_Attributes) // Open CASCADE Includes #include -#include -#include #include -class GEOM_EdgeFilter : public SALOME_Filter { +class GEOM_EdgeFilter : public GEOM_ShapeTypeFilter { public: @@ -68,31 +65,25 @@ public: // } // Methods PUBLIC // -Standard_EXPORT GEOM_EdgeFilter(const StdSelect_TypeOfEdge Edge, - GEOM::GEOM_Gen_ptr geom); - -Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SALOME_InteractiveObject)& anobj) const; +Standard_EXPORT GEOM_EdgeFilter( const StdSelect_TypeOfEdge Edge ); Standard_EXPORT ~GEOM_EdgeFilter(); - - // Type management // Standard_EXPORT friend Handle_Standard_Type& GEOM_EdgeFilter_Type_(); Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; - Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; + Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; protected: // Methods PROTECTED // - + Standard_EXPORT virtual Standard_Boolean IsShapeOk(const TopoDS_Shape& theShape ) const; // Fields PROTECTED // StdSelect_TypeOfEdge myKind; -GEOM::GEOM_Gen_var myComponentGeom; private: diff --git a/src/GEOMFiltersSelection/GEOM_EdgeFilter.ixx b/src/GEOMFiltersSelection/GEOM_EdgeFilter.ixx index 9e028014b..275670b55 100644 --- a/src/GEOMFiltersSelection/GEOM_EdgeFilter.ixx +++ b/src/GEOMFiltersSelection/GEOM_EdgeFilter.ixx @@ -37,8 +37,8 @@ GEOM_EdgeFilter::~GEOM_EdgeFilter() {} Standard_EXPORT Handle_Standard_Type& GEOM_EdgeFilter_Type_() { - static Handle_Standard_Type aType1 = STANDARD_TYPE(SALOME_Filter); - if ( aType1.IsNull()) aType1 = STANDARD_TYPE(SALOME_Filter); + static Handle_Standard_Type aType1 = STANDARD_TYPE(GEOM_ShapeTypeFilter); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(GEOM_ShapeTypeFilter); 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); @@ -77,7 +77,7 @@ const Handle(Standard_Type)& GEOM_EdgeFilter::DynamicType() const } Standard_Boolean GEOM_EdgeFilter::IsKind(const Handle(Standard_Type)& AType) const { - return (STANDARD_TYPE(GEOM_EdgeFilter) == AType || SALOME_Filter::IsKind(AType)); + return (STANDARD_TYPE(GEOM_EdgeFilter) == AType || GEOM_ShapeTypeFilter::IsKind(AType)); } Handle_GEOM_EdgeFilter::~Handle_GEOM_EdgeFilter() {} diff --git a/src/GEOMFiltersSelection/GEOM_FaceFilter.cxx b/src/GEOMFiltersSelection/GEOM_FaceFilter.cxx index aca4648e4..5fbaf1743 100644 --- a/src/GEOMFiltersSelection/GEOM_FaceFilter.cxx +++ b/src/GEOMFiltersSelection/GEOM_FaceFilter.cxx @@ -28,157 +28,47 @@ using namespace std; #include "GEOM_FaceFilter.ixx" -#include "GEOM_Client.hxx" -#include "SALOME_InteractiveObject.hxx" -#include "GEOM_InteractiveObject.hxx" -#include "GEOM_ShapeTypeFilter.hxx" -#include "SALOME_TypeFilter.hxx" - -#include "utilities.h" -#include "QAD_Application.h" -#include "QAD_Desktop.h" -#include "QAD_Study.h" - -// Open CASCADE Includes #include #include -#include #include -#include -static GEOM_Client ShapeReader; - -/*! - enumeration TypeOfFace is AnyFace,Plane,Cylinder,Sphere,Torus,Revol,Cone; -*/ -GEOM_FaceFilter::GEOM_FaceFilter(const StdSelect_TypeOfFace Face, - GEOM::GEOM_Gen_ptr geom) +//======================================================================= +// function : IsShapeOk +// purpose : enumeration TypeOfFace is AnyFace,Plane,Cylinder,Sphere,Torus,Revol,Cone; +//======================================================================= +GEOM_FaceFilter::GEOM_FaceFilter( const StdSelect_TypeOfFace theKind ) +: GEOM_ShapeTypeFilter( TopAbs_FACE ) { - myKind = Face; - myComponentGeom = GEOM::GEOM_Gen::_narrow(geom); + myKind = theKind; } -Standard_Boolean GEOM_FaceFilter::IsOk(const Handle(SALOME_InteractiveObject)& anObj) const +//======================================================================= +// function : IsShapeOk +// purpose : +//======================================================================= +Standard_Boolean GEOM_FaceFilter::IsShapeOk( const TopoDS_Shape& theShape ) const { - Handle(SALOME_TypeFilter) GeomFilter = new SALOME_TypeFilter( "GEOM" ); - if ( !GeomFilter->IsOk(anObj) ) - return false; - - Handle(GEOM_ShapeTypeFilter) GeomShapeTypeFilter = new GEOM_ShapeTypeFilter( TopAbs_FACE, myComponentGeom ); - if ( !GeomShapeTypeFilter->IsOk(anObj) ) - return false; - - if ( anObj->hasEntry() ) { - QAD_Study* ActiveStudy = QAD_Application::getDesktop()->getActiveStudy(); - SALOMEDS::Study_var aStudy = ActiveStudy->getStudyDocument(); - SALOMEDS::SObject_var obj = aStudy->FindObjectID( anObj->getEntry() ); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeIOR_var anIOR; - if ( !obj->_is_nil() ) { - if (obj->FindAttribute(anAttr, "AttributeIOR")) { - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( anIOR->Value() ); - if ( aShape->_is_nil() ) - return false; - - TopoDS_Shape Shape = ShapeReader.GetShape( myComponentGeom, aShape ); - if ( Shape.IsNull() ) - return false; - - switch (myKind) { - case StdSelect_AnyFace: - return Standard_True; - case StdSelect_Plane: - { - BRepAdaptor_Surface surf(TopoDS::Face(Shape)); - return (surf.GetType() == GeomAbs_Plane); - } - case StdSelect_Cylinder: - { - BRepAdaptor_Surface surf(TopoDS::Face(Shape)); - return (surf.GetType() == GeomAbs_Cylinder); - } - case StdSelect_Sphere: - { - BRepAdaptor_Surface surf(TopoDS::Face(Shape)); - return (surf.GetType() == GeomAbs_Sphere); - } - case StdSelect_Torus: - { - BRepAdaptor_Surface surf(TopoDS::Face(Shape)); - return ( surf.GetType() == GeomAbs_Torus); - } - case StdSelect_Revol: - { - BRepAdaptor_Surface surf(TopoDS::Face(Shape)); - return ( surf.GetType() == GeomAbs_Cylinder || - surf.GetType() == GeomAbs_Cone || - surf.GetType() == GeomAbs_Torus || - surf.GetType() == GeomAbs_Sphere || - surf.GetType() == GeomAbs_SurfaceOfRevolution ); - } - case StdSelect_Cone: // en attendant la liberation du cdl, on l'utilise pour Cone - { - BRepAdaptor_Surface surf(TopoDS::Face(Shape)); - return (surf.GetType() == GeomAbs_Cone); - } - } - } - } - } - - if ( anObj->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject)) ) { - Handle(GEOM_InteractiveObject) GObject = - Handle(GEOM_InteractiveObject)::DownCast(anObj); - - GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( GObject->getIOR() ); - if ( aShape->_is_nil() ) - return false; - - TopoDS_Shape Shape = ShapeReader.GetShape( myComponentGeom, aShape ); - if ( Shape.IsNull() ) - return false; - - switch (myKind) { - case StdSelect_AnyFace: - return Standard_True; - case StdSelect_Plane: - { - BRepAdaptor_Surface surf(TopoDS::Face(Shape)); - return (surf.GetType() == GeomAbs_Plane); - } - case StdSelect_Cylinder: - { - BRepAdaptor_Surface surf(TopoDS::Face(Shape)); - return (surf.GetType() == GeomAbs_Cylinder); - } - case StdSelect_Sphere: - { - BRepAdaptor_Surface surf(TopoDS::Face(Shape)); - return (surf.GetType() == GeomAbs_Sphere); - } - case StdSelect_Torus: - { - BRepAdaptor_Surface surf(TopoDS::Face(Shape)); - return ( surf.GetType() == GeomAbs_Torus); - } - case StdSelect_Revol: - { - BRepAdaptor_Surface surf(TopoDS::Face(Shape)); - return ( surf.GetType() == GeomAbs_Cylinder || - surf.GetType() == GeomAbs_Cone || - surf.GetType() == GeomAbs_Torus || - surf.GetType() == GeomAbs_Sphere || - surf.GetType() == GeomAbs_SurfaceOfRevolution ); - } - case StdSelect_Cone: // en attendant la liberation du cdl, on l'utilise pour Cone - { - BRepAdaptor_Surface surf(TopoDS::Face(Shape)); - return (surf.GetType() == GeomAbs_Cone); - } + if ( !theShape.IsNull() && theShape.ShapeType() == TopAbs_FACE ) + { + BRepAdaptor_Surface aSurf( TopoDS::Face( theShape ) ); + GeomAbs_SurfaceType aType = aSurf.GetType(); + + switch ( myKind ) + { + case StdSelect_AnyFace: return Standard_True; + case StdSelect_Plane: return ( aType == GeomAbs_Plane ); + case StdSelect_Cylinder: return ( aType == GeomAbs_Cylinder); + case StdSelect_Sphere: return ( aType == GeomAbs_Sphere); + case StdSelect_Torus: return ( aType == GeomAbs_Torus); + case StdSelect_Revol: return ( aType == GeomAbs_Cylinder || + aType == GeomAbs_Cone || + aType == GeomAbs_Torus || + aType == GeomAbs_Sphere || + aType == GeomAbs_SurfaceOfRevolution ); + case StdSelect_Cone: return ( aType == GeomAbs_Cone); } } - return false; + return Standard_False; } diff --git a/src/GEOMFiltersSelection/GEOM_FaceFilter.hxx b/src/GEOMFiltersSelection/GEOM_FaceFilter.hxx index d81e27413..de6e94893 100644 --- a/src/GEOMFiltersSelection/GEOM_FaceFilter.hxx +++ b/src/GEOMFiltersSelection/GEOM_FaceFilter.hxx @@ -31,22 +31,18 @@ #include "Handle_GEOM_FaceFilter.hxx" #endif -#include "SALOME_InteractiveObject.hxx" -#include "SALOME_Filter.hxx" +#include "GEOM_ShapeTypeFilter.hxx" // IDL Headers #include -#include CORBA_SERVER_HEADER(GEOM_Shape) #include CORBA_SERVER_HEADER(GEOM_Gen) #include CORBA_SERVER_HEADER(SALOMEDS_Attributes) // Open CASCADE Includes #include -#include -#include #include -class GEOM_FaceFilter : public SALOME_Filter { +class GEOM_FaceFilter : public GEOM_ShapeTypeFilter { public: @@ -68,10 +64,7 @@ public: // } // Methods PUBLIC // -Standard_EXPORT GEOM_FaceFilter(const StdSelect_TypeOfFace Face, - GEOM::GEOM_Gen_ptr geom); - -Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SALOME_InteractiveObject)& anobj) const; +Standard_EXPORT GEOM_FaceFilter( const StdSelect_TypeOfFace Face ); Standard_EXPORT ~GEOM_FaceFilter(); @@ -81,18 +74,18 @@ Standard_EXPORT ~GEOM_FaceFilter(); // Standard_EXPORT friend Handle_Standard_Type& GEOM_FaceFilter_Type_(); Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; - Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; + Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; protected: // Methods PROTECTED // + Standard_EXPORT virtual Standard_Boolean IsShapeOk(const TopoDS_Shape& theShape ) const; // Fields PROTECTED // StdSelect_TypeOfFace myKind; -GEOM::GEOM_Gen_var myComponentGeom; private: diff --git a/src/GEOMFiltersSelection/GEOM_FaceFilter.ixx b/src/GEOMFiltersSelection/GEOM_FaceFilter.ixx index f6404a0d3..4f81dc83b 100644 --- a/src/GEOMFiltersSelection/GEOM_FaceFilter.ixx +++ b/src/GEOMFiltersSelection/GEOM_FaceFilter.ixx @@ -37,8 +37,8 @@ GEOM_FaceFilter::~GEOM_FaceFilter() {} Standard_EXPORT Handle_Standard_Type& GEOM_FaceFilter_Type_() { - static Handle_Standard_Type aType1 = STANDARD_TYPE(SALOME_Filter); - if ( aType1.IsNull()) aType1 = STANDARD_TYPE(SALOME_Filter); + static Handle_Standard_Type aType1 = STANDARD_TYPE(GEOM_ShapeTypeFilter); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(GEOM_ShapeTypeFilter); 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); @@ -77,7 +77,7 @@ const Handle(Standard_Type)& GEOM_FaceFilter::DynamicType() const } Standard_Boolean GEOM_FaceFilter::IsKind(const Handle(Standard_Type)& AType) const { - return (STANDARD_TYPE(GEOM_FaceFilter) == AType || SALOME_Filter::IsKind(AType)); + return (STANDARD_TYPE(GEOM_FaceFilter) == AType || GEOM_ShapeTypeFilter::IsKind(AType)); } Handle_GEOM_FaceFilter::~Handle_GEOM_FaceFilter() {} diff --git a/src/GEOMFiltersSelection/GEOM_LogicalFilter.cxx b/src/GEOMFiltersSelection/GEOM_LogicalFilter.cxx new file mode 100644 index 000000000..39c11dfbb --- /dev/null +++ b/src/GEOMFiltersSelection/GEOM_LogicalFilter.cxx @@ -0,0 +1,161 @@ +// SALOME SALOMEGUI : implementation of desktop and GUI kernel +// +// 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 : GEOM_LogicalFilter.cxx +// Author : Sergey LITONIN +// Module : GEOM + +#include "GEOM_LogicalFilter.hxx" + +/* + Class : GEOM_LogicalFilter + Description : Filter for combaining several filters with logical operation (OR or AND) +*/ + +IMPLEMENT_STANDARD_HANDLE( GEOM_LogicalFilter, SALOME_Filter ) +IMPLEMENT_STANDARD_RTTIEXT( GEOM_LogicalFilter, SALOME_Filter ) + +//======================================================================= +// name : GEOM_LogicalFilter::GEOM_LogicalFilter +// Purpose : Constructor +//======================================================================= +GEOM_LogicalFilter::GEOM_LogicalFilter( const GEOM_ListOfFilter& theFilters, + const int theLogOp ) +{ + myFilters = theFilters; + myLogOp = theLogOp; +} + +//======================================================================= +// name : GEOM_LogicalFilter::GEOM_LogicalFilter +// Purpose : Constructor +//======================================================================= +GEOM_LogicalFilter::GEOM_LogicalFilter( const Handle(SALOME_Filter)& theFilter, + const int theLogOp ) +{ + myFilters.Append( theFilter ); + myLogOp = theLogOp; +} + +//======================================================================= +// name : GEOM_LogicalFilter::~GEOM_LogicalFilter +// Purpose : Destructor +//======================================================================= +GEOM_LogicalFilter::~GEOM_LogicalFilter() +{ +} + +//======================================================================= +// name : GEOM_LogicalFilter::IsOk +// Purpose : Verify validity of entry object +//======================================================================= +Standard_Boolean GEOM_LogicalFilter::IsOk( const Handle(SALOME_InteractiveObject)& theIO ) const +{ + GEOM_ListOfFilter::Iterator anIter( myFilters ); + for ( ; anIter.More(); anIter.Next() ) + { + Handle(SALOME_Filter) aFilter = anIter.Value(); + if ( !aFilter.IsNull() ) + { + if ( myLogOp == LO_OR && anIter.Value()->IsOk( theIO ) ) + return true; + if ( myLogOp == LO_AND && !anIter.Value()->IsOk( theIO ) ) + return false; + if ( myLogOp == LO_NOT ) + return !anIter.Value()->IsOk( theIO ); + } + } + + return myLogOp == LO_OR ? false : true; +} + +//======================================================================= +// name : GEOM_LogicalFilter::SetFilters +// Purpose : Set new list of filters. Old wilters are removed +//======================================================================= +void GEOM_LogicalFilter::SetFilters( const GEOM_ListOfFilter& theFilters ) +{ + myFilters = theFilters; +} + +//======================================================================= +// name : GEOM_LogicalFilter::SetLogOp +// Purpose : Set logical operation +//======================================================================= +void GEOM_LogicalFilter::SetLogOp( const int theLogOp ) +{ + myLogOp = theLogOp; +} + +//======================================================================= +// name : GEOM_LogicalFilter::GetFilters +// Purpose : Get list of filters +//======================================================================= +const GEOM_ListOfFilter& GEOM_LogicalFilter::GetFilters() const +{ + return myFilters; +} + +//======================================================================= +// name : GEOM_LogicalFilter::GetLogOp +// Purpose : Get logical operation +//======================================================================= +int GEOM_LogicalFilter::GetLogOp() const +{ + return myLogOp; +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/GEOMFiltersSelection/GEOM_LogicalFilter.hxx b/src/GEOMFiltersSelection/GEOM_LogicalFilter.hxx new file mode 100644 index 000000000..aa9fbdccf --- /dev/null +++ b/src/GEOMFiltersSelection/GEOM_LogicalFilter.hxx @@ -0,0 +1,103 @@ +// SALOME SALOMEGUI : implementation of desktop and GUI kernel +// +// 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 : GEOM_LogicalFilter.hxx +// Author : Sergey LITONIN +// Module : GEOM + +#ifndef _GEOM_LogicalFilter_HeaderFile +#define _GEOM_LogicalFilter_HeaderFile + +#include "SALOME_Filter.hxx" + +#include +#include +#include + +DEFINE_STANDARD_HANDLE( GEOM_LogicalFilter, SALOME_Filter ) + +DEFINE_BASECOLLECTION( GEOM_FilterColl, Handle(SALOME_Filter) ) +DEFINE_LIST( GEOM_ListOfFilter, GEOM_FilterColl, Handle(SALOME_Filter) ) + + +/* + Class : GEOM_LogicalFilter + Description : Filter for combaining several filters with logical operation (OR or AND) +*/ + +class GEOM_LogicalFilter : public SALOME_Filter +{ +public: + + enum { LO_OR, LO_AND, LO_NOT, LO_UNDEFINED }; + +public: + + GEOM_LogicalFilter( const GEOM_ListOfFilter&, const int ); + GEOM_LogicalFilter( const Handle(SALOME_Filter)&, const int ); + + + virtual ~GEOM_LogicalFilter(); + virtual Standard_Boolean IsOk( const Handle(SALOME_InteractiveObject)& ) const; + + void SetFilters( const GEOM_ListOfFilter& ); + void SetLogOp( const int ); + const GEOM_ListOfFilter& GetFilters() const; + int GetLogOp() const; + +private: + + GEOM_ListOfFilter myFilters; + int myLogOp; + +public: + DEFINE_STANDARD_RTTI( GEOM_LogicalFilter ) +}; + +#endif + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/GEOMFiltersSelection/GEOM_PreviewFilter.cxx b/src/GEOMFiltersSelection/GEOM_PreviewFilter.cxx new file mode 100644 index 000000000..e9766b88e --- /dev/null +++ b/src/GEOMFiltersSelection/GEOM_PreviewFilter.cxx @@ -0,0 +1,42 @@ +// GEOM GEOMFiltersSelection : filter selector for the viewer +// +// 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 : GEOM_PreviewFilter.cxx +// Author : Sergey ANIKIN +// Module : GEOM +// $Header$ + +#include "GEOM_PreviewFilter.ixx" +#include "SALOME_InteractiveObject.hxx" + +using namespace std; + +GEOM_PreviewFilter::GEOM_PreviewFilter() +{ +} + +Standard_Boolean GEOM_PreviewFilter::IsOk(const Handle(SALOME_InteractiveObject)& anObj) const +{ + return ( !anObj.IsNull() && anObj->hasEntry() && strstr( anObj->getEntry(), "TEMP" ) ); +} + diff --git a/src/GEOMFiltersSelection/GEOM_PreviewFilter.hxx b/src/GEOMFiltersSelection/GEOM_PreviewFilter.hxx new file mode 100644 index 000000000..e27701ca6 --- /dev/null +++ b/src/GEOMFiltersSelection/GEOM_PreviewFilter.hxx @@ -0,0 +1,102 @@ +// GEOM GEOMFiltersSelection : filter selector for the viewer +// +// Copyright (C) 2004 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org or email : webmaster.salome@opencascade.org +// +// +// +// File : GEOM_PreviewFilter.hxx +// Module : GEOM + +#ifndef _GEOM_PreviewFilter_HeaderFile +#define _GEOM_PreviewFilter_HeaderFile + +#ifndef _Handle_GEOM_PreviewFilter_HeaderFile +#include "Handle_GEOM_PreviewFilter.hxx" +#endif + +#include "SALOME_InteractiveObject.hxx" +#include "SALOME_Filter.hxx" + +// IDL Headers + + +// Open CASCADE Includes +#include + +class GEOM_PreviewFilter : public SALOME_Filter { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + // Methods PUBLIC + // +Standard_EXPORT GEOM_PreviewFilter(); +Standard_EXPORT ~GEOM_PreviewFilter(); + +Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SALOME_InteractiveObject)& anobj) const; + + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& GEOM_PreviewFilter_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 + // + + +}; + + + + + +// other inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/GEOMFiltersSelection/GEOM_PreviewFilter.ixx b/src/GEOMFiltersSelection/GEOM_PreviewFilter.ixx new file mode 100644 index 000000000..6ec1aef97 --- /dev/null +++ b/src/GEOMFiltersSelection/GEOM_PreviewFilter.ixx @@ -0,0 +1,83 @@ +// GEOM GEOMFiltersSelection : filter selector for the viewer +// +// Copyright (C) 2004 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org or email : webmaster.salome@opencascade.org +// +// +// +// File : GEOM_PreviewFilter.ixx +// Module : GEOM + +#include "GEOM_PreviewFilter.jxx" + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +GEOM_PreviewFilter::~GEOM_PreviewFilter() {} + + + +Standard_EXPORT Handle_Standard_Type& GEOM_PreviewFilter_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(SALOME_Filter); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(SALOME_Filter); + 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("GEOM_PreviewFilter", + sizeof(GEOM_PreviewFilter), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + + +// DownCast method +// allow safe downcasting +// +const Handle(GEOM_PreviewFilter) Handle(GEOM_PreviewFilter)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOM_PreviewFilter) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOM_PreviewFilter))) { + _anOtherObject = Handle(GEOM_PreviewFilter)((Handle(GEOM_PreviewFilter)&)AnObject); + } + } + + return _anOtherObject ; +} +const Handle(Standard_Type)& GEOM_PreviewFilter::DynamicType() const +{ + return STANDARD_TYPE(GEOM_PreviewFilter) ; +} +Standard_Boolean GEOM_PreviewFilter::IsKind(const Handle(Standard_Type)& AType) const +{ + return (STANDARD_TYPE(GEOM_PreviewFilter) == AType || SALOME_Filter::IsKind(AType)); +} +Handle_GEOM_PreviewFilter::~Handle_GEOM_PreviewFilter() {} + diff --git a/src/GEOMFiltersSelection/GEOM_PreviewFilter.jxx b/src/GEOMFiltersSelection/GEOM_PreviewFilter.jxx new file mode 100644 index 000000000..bd82eff74 --- /dev/null +++ b/src/GEOMFiltersSelection/GEOM_PreviewFilter.jxx @@ -0,0 +1,29 @@ +// GEOM GEOMFiltersSelection : filter selector for the viewer +// +// Copyright (C) 2004 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org or email : webmaster.salome@opencascade.org +// +// +// +// File : GEOM_PreviewFilter.jxx +// Module : GEOM + +#ifndef _GEOM_PreviewFilter_HeaderFile +#include "GEOM_PreviewFilter.hxx" +#endif diff --git a/src/GEOMFiltersSelection/GEOM_ShapeTypeFilter.cxx b/src/GEOMFiltersSelection/GEOM_ShapeTypeFilter.cxx index 6ca272b01..9d98cc998 100644 --- a/src/GEOMFiltersSelection/GEOM_ShapeTypeFilter.cxx +++ b/src/GEOMFiltersSelection/GEOM_ShapeTypeFilter.cxx @@ -28,82 +28,137 @@ using namespace std; #include "GEOM_ShapeTypeFilter.ixx" -#include "GEOM_Client.hxx" - #include "SALOME_InteractiveObject.hxx" -#include "GEOM_InteractiveObject.hxx" -#include "SALOME_TypeFilter.hxx" - -#include "utilities.h" +#include "GEOM_Client.hxx" #include "QAD_Application.h" #include "QAD_Desktop.h" -#include "QAD_Study.h" +#include "utilities.h" -static GEOM_Client ShapeReader; +#include -GEOM_ShapeTypeFilter::GEOM_ShapeTypeFilter(TopAbs_ShapeEnum ShapeType, - GEOM::GEOM_Gen_ptr geom) +//======================================================================= +// function : getShape() +// purpose : returns a TopoDS_Shape stored in GEOM_Object +//======================================================================= +static bool getShape( const GEOM::GEOM_Object_ptr& theObject, TopoDS_Shape& theShape ) { - myKind = ShapeType; - myComponentGeom = GEOM::GEOM_Gen::_narrow(geom); + if ( !CORBA::is_nil( theObject ) ) + { + Engines::Component_var comp = QAD_Application::getDesktop()->getEngine( "FactoryServer", "GEOM" ); + GEOM::GEOM_Gen_var myGeom = GEOM::GEOM_Gen::_narrow( comp ); + TopoDS_Shape aTopoDSShape = GEOM_Client().GetShape( myGeom, theObject ); + + if ( !aTopoDSShape.IsNull() ) + { + theShape = aTopoDSShape; + return true; + } + } + return false; } -Standard_Boolean GEOM_ShapeTypeFilter::IsOk(const Handle(SALOME_InteractiveObject)& anObj) const +//======================================================================= +// function : ConvertIOinGEOMObject() +// purpose : +//======================================================================= +static GEOM::GEOM_Object_ptr convertIOinGEOMObject( + const Handle(SALOME_InteractiveObject)& theIO, Standard_Boolean& theResult ) { - Handle(SALOME_TypeFilter) GeomFilter = new SALOME_TypeFilter( "GEOM" ); - if ( !GeomFilter->IsOk(anObj) ) - return false; - if ( anObj->hasEntry() ) { - QAD_Study* ActiveStudy = QAD_Application::getDesktop()->getActiveStudy(); - SALOMEDS::Study_var aStudy = ActiveStudy->getStudyDocument(); - SALOMEDS::SObject_var obj = aStudy->FindObjectID( anObj->getEntry() ); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeIOR_var anIOR; - if ( !obj->_is_nil() ) { - if (obj->FindAttribute(anAttr, "AttributeIOR")) { - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( anIOR->Value() ); - if ( aShape->_is_nil() ) - return false; - - TopoDS_Shape Shape = ShapeReader.GetShape( myComponentGeom, aShape ); - if ( Shape.IsNull() ) - return false; - - MESSAGE ( " myKind = " << myKind ); - MESSAGE ( " Shape.ShapeType = " << Shape.ShapeType() ); - if ( myKind == TopAbs_SHAPE ) - return true; - - if ( Shape.ShapeType() == myKind ) - return true; - else - return false; - } + theResult = Standard_False; + GEOM::GEOM_Object_var aReturnObject; + if ( !theIO.IsNull() ) + { + const char* anEntry = theIO->getEntry(); + SALOMEDS::SObject_var aSObj = + QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument()->FindObjectID( anEntry ); + if ( !CORBA::is_nil( aSObj ) ) + { + aReturnObject = GEOM::GEOM_Object::_narrow( aSObj->GetObject() ); + theResult = !CORBA::is_nil( aReturnObject ); } } - - if ( anObj->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject)) ) { - Handle(GEOM_InteractiveObject) GObject = - Handle(GEOM_InteractiveObject)::DownCast(anObj); - - GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( GObject->getIOR() ); - if ( aShape->_is_nil() ) - return false; - - TopoDS_Shape Shape = ShapeReader.GetShape( myComponentGeom, aShape ); - if ( Shape.IsNull() ) - return false; - - MESSAGE ( " myKind = " << myKind ); - MESSAGE ( " Shape.ShapeType = " << Shape.ShapeType() ); - if ( myKind == TopAbs_SHAPE ) - return true; - - if ( Shape.ShapeType() == myKind ) - return true; - else - return false; - } - return false; + return aReturnObject._retn(); +} + +//======================================================================= +// function : ShapeTypeFilter +// purpose : +//======================================================================= +GEOM_ShapeTypeFilter::GEOM_ShapeTypeFilter( const TopAbs_ShapeEnum theShapeType, + const bool theIsAll ) +{ + myIsAll = theIsAll; + myShapeTypes.Add( theShapeType ); + myTypeFilter = new SALOME_TypeFilter( "GEOM" ); +} + +//======================================================================= +// function : ShapeTypeFilter +// purpose : +//======================================================================= +GEOM_ShapeTypeFilter::GEOM_ShapeTypeFilter( const TColStd_MapOfInteger& theShapeTypes, + const bool theIsAll ) +{ + myIsAll = theIsAll; + myShapeTypes = theShapeTypes; + myTypeFilter = new SALOME_TypeFilter( "GEOM" ); +} + +//======================================================================= +// function : IsOk +// purpose : +//======================================================================= +Standard_Boolean GEOM_ShapeTypeFilter::IsOk( + const Handle(SALOME_InteractiveObject)& anObj ) const +{ + if ( !myTypeFilter->IsOk(anObj) ) + return Standard_False; + + Standard_Boolean aResult = Standard_False; + GEOM::GEOM_Object_ptr aGeomObj = convertIOinGEOMObject( anObj, aResult ); + if ( !CORBA::is_nil( aGeomObj ) && aResult && aGeomObj->IsShape() ) + { + if ( myIsAll ) + return true; + TopoDS_Shape aShape; + if ( getShape( aGeomObj, aShape ) ) + { + if ( myShapeTypes.Contains( aShape.ShapeType() ) ) + return IsShapeOk( aShape ); + } + } + return Standard_False; +} + +//======================================================================= +// function : IsShapeOk +// purpose : +//======================================================================= +Standard_Boolean GEOM_ShapeTypeFilter::IsShapeOk( const TopoDS_Shape& ) const +{ + return Standard_True; } + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/GEOMFiltersSelection/GEOM_ShapeTypeFilter.hxx b/src/GEOMFiltersSelection/GEOM_ShapeTypeFilter.hxx index ffbc4e115..1d9df8e6d 100644 --- a/src/GEOMFiltersSelection/GEOM_ShapeTypeFilter.hxx +++ b/src/GEOMFiltersSelection/GEOM_ShapeTypeFilter.hxx @@ -33,10 +33,10 @@ #include "SALOME_InteractiveObject.hxx" #include "SALOME_Filter.hxx" +#include "SALOME_TypeFilter.hxx" // IDL Headers #include -#include CORBA_SERVER_HEADER(GEOM_Shape) #include CORBA_SERVER_HEADER(GEOM_Gen) #include CORBA_SERVER_HEADER(SALOMEDS_Attributes) @@ -44,8 +44,10 @@ #include #include #include +#include -class GEOM_ShapeTypeFilter : public SALOME_Filter { +class GEOM_ShapeTypeFilter : public SALOME_Filter +{ public: @@ -61,45 +63,38 @@ public: { if (anAddress) Standard::Free((Standard_Address&)anAddress); } -// inline void operator delete(void *anAddress, size_t size) -// { -// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); -// } // Methods PUBLIC - // -Standard_EXPORT GEOM_ShapeTypeFilter(TopAbs_ShapeEnum ShapeType, - GEOM::GEOM_Gen_ptr geom); -Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SALOME_InteractiveObject)& anobj) const; + // +Standard_EXPORT GEOM_ShapeTypeFilter( const TopAbs_ShapeEnum theShapeType, + const bool theIsAll = false ); +Standard_EXPORT GEOM_ShapeTypeFilter( const TColStd_MapOfInteger& theShapeTypes, + const bool theIsAll = false ); Standard_EXPORT ~GEOM_ShapeTypeFilter(); - +Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SALOME_InteractiveObject)& anobj) const; // Type management // Standard_EXPORT friend Handle_Standard_Type& GEOM_ShapeTypeFilter_Type_(); Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; - Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; + Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; protected: // Methods PROTECTED - // + // + Standard_EXPORT virtual Standard_Boolean IsShapeOk(const TopoDS_Shape& theShape ) const; // Fields PROTECTED // -TopAbs_ShapeEnum myKind; -GEOM::GEOM_Gen_var myComponentGeom; +TColStd_MapOfInteger myShapeTypes; +Handle(SALOME_TypeFilter) myTypeFilter; private: - // Methods PRIVATE - // - - - // Fields PRIVATE - // + bool myIsAll; }; diff --git a/src/GEOMFiltersSelection/GEOM_TypeFilter.cxx b/src/GEOMFiltersSelection/GEOM_TypeFilter.cxx new file mode 100644 index 000000000..26df6985e --- /dev/null +++ b/src/GEOMFiltersSelection/GEOM_TypeFilter.cxx @@ -0,0 +1,145 @@ +// GEOM GEOMGUI : Implementation of selection filters for GEOM module +// +// 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 : GEOM_TypeFilter.cxx +// Author : Sergey LITONIN +// Module : GEOM + +#include "GEOM_TypeFilter.hxx" +#include "SALOME_InteractiveObject.hxx" +#include "GEOM_Client.hxx" +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "utilities.h" + +static GEOM::GEOM_Object_ptr convertIOinGEOMObject( + const Handle(SALOME_InteractiveObject)& theIO, Standard_Boolean& theResult ) +{ + theResult = Standard_False; + GEOM::GEOM_Object_var aReturnObject; + if ( !theIO.IsNull() ) + { + const char* anEntry = theIO->getEntry(); + SALOMEDS::SObject_var aSObj = + QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument()->FindObjectID( anEntry ); + if ( !CORBA::is_nil( aSObj ) ) + { + aReturnObject = GEOM::GEOM_Object::_narrow( aSObj->GetObject() ); + theResult = !CORBA::is_nil( aReturnObject ); + } + } + return aReturnObject._retn(); +} + +/* + Class : GEOM_TypeFilter + Description : Filter for combaining several filters with logical operation (OR or AND) +*/ + +IMPLEMENT_STANDARD_HANDLE( GEOM_TypeFilter, SALOME_TypeFilter ) +IMPLEMENT_STANDARD_RTTIEXT( GEOM_TypeFilter, SALOME_TypeFilter ) + +//======================================================================= +// name : GEOM_TypeFilter::GEOM_TypeFilter +// Purpose : Constructor +//======================================================================= +GEOM_TypeFilter::GEOM_TypeFilter( const int theType ) +: SALOME_TypeFilter( "GEOM" ) +{ + myType = theType; +} + +//======================================================================= +// name : GEOM_TypeFilter::~GEOM_TypeFilter +// Purpose : Destructor +//======================================================================= +GEOM_TypeFilter::~GEOM_TypeFilter() +{ +} + +//======================================================================= +// name : GEOM_TypeFilter::IsOk +// Purpose : Verify validity of entry object +//======================================================================= +Standard_Boolean GEOM_TypeFilter::IsOk( const Handle(SALOME_InteractiveObject)& theIO ) const +{ + if ( SALOME_TypeFilter::IsOk( theIO ) ) + { + Standard_Boolean aTestRes = Standard_False; + GEOM::GEOM_Object_var anObj = convertIOinGEOMObject( theIO, aTestRes ); + if ( aTestRes && !anObj->_is_nil() ) + return anObj->GetType() == myType; + } + + return false; +} + +//======================================================================= +// name : GEOM_TypeFilter::SetType +// Purpose : Set type of object +//======================================================================= +void GEOM_TypeFilter::SetType( const int theType ) +{ + myType = theType; +} + +//======================================================================= +// name : GEOM_TypeFilter::GetType +// Purpose : Get type of object +//======================================================================= +int GEOM_TypeFilter::GetType() const +{ + return myType; +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/GEOMFiltersSelection/GEOM_TypeFilter.hxx b/src/GEOMFiltersSelection/GEOM_TypeFilter.hxx new file mode 100644 index 000000000..e9c0b6e57 --- /dev/null +++ b/src/GEOMFiltersSelection/GEOM_TypeFilter.hxx @@ -0,0 +1,90 @@ +// GEOM GEOMGUI : Implementation of selection filters for GEOM module +// +// 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 : GEOM_TypeFilter.hxx +// Author : Sergey LITONIN +// Module : GEOM + +#ifndef _GEOM_TypeFilter_HeaderFile +#define _GEOM_TypeFilter_HeaderFile + +#include "SALOME_TypeFilter.hxx" + +#include + +DEFINE_STANDARD_HANDLE( GEOM_TypeFilter, SALOME_TypeFilter ) + +/* + Class : GEOM_TypeFilter + Description : Filter for verifyimg type of geom object ( GEOM_POINT, GEOM_MARKER and so on ) +*/ + +class GEOM_TypeFilter : public SALOME_TypeFilter +{ + +public: + + GEOM_TypeFilter( const int ); + + + virtual ~GEOM_TypeFilter(); + virtual Standard_Boolean IsOk( const Handle(SALOME_InteractiveObject)& ) const; + + void SetType( const int ); + int GetType() const; + +private: + + int myType; + +public: + DEFINE_STANDARD_RTTI( GEOM_TypeFilter ) +}; + +#endif + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/GEOMFiltersSelection/Handle_GEOM_EdgeFilter.hxx b/src/GEOMFiltersSelection/Handle_GEOM_EdgeFilter.hxx index 6c8dd9c28..581ddb235 100644 --- a/src/GEOMFiltersSelection/Handle_GEOM_EdgeFilter.hxx +++ b/src/GEOMFiltersSelection/Handle_GEOM_EdgeFilter.hxx @@ -34,17 +34,17 @@ #include #endif -#ifndef _Handle_SALOME_Filter_HeaderFile -#include "Handle_SALOME_Filter.hxx" +#ifndef _Handle_GEOM_ShapeTypeFilter_HeaderFile +#include "Handle_GEOM_ShapeTypeFilter.hxx" #endif class Standard_Transient; class Handle_Standard_Type; -class Handle(SALOME_Filter); +class Handle(GEOM_ShapeTypeFilter); class GEOM_EdgeFilter; Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOM_EdgeFilter); -class Handle(GEOM_EdgeFilter) : public Handle(SALOME_Filter) { +class Handle(GEOM_EdgeFilter) : public Handle(GEOM_ShapeTypeFilter) { public: inline void* operator new(size_t,void* anAddress) { @@ -62,12 +62,12 @@ class Handle(GEOM_EdgeFilter) : public Handle(SALOME_Filter) { // { // if (anAddress) Standard::Free((Standard_Address&)anAddress,size); // } - Handle(GEOM_EdgeFilter)():Handle(SALOME_Filter)() {} - Handle(GEOM_EdgeFilter)(const Handle(GEOM_EdgeFilter)& aHandle) : Handle(SALOME_Filter)(aHandle) + Handle(GEOM_EdgeFilter)():Handle(GEOM_ShapeTypeFilter)() {} + Handle(GEOM_EdgeFilter)(const Handle(GEOM_EdgeFilter)& aHandle) : Handle(GEOM_ShapeTypeFilter)(aHandle) { } - Handle(GEOM_EdgeFilter)(const GEOM_EdgeFilter* anItem) : Handle(SALOME_Filter)((SALOME_Filter *)anItem) + Handle(GEOM_EdgeFilter)(const GEOM_EdgeFilter* anItem) : Handle(GEOM_ShapeTypeFilter)((GEOM_ShapeTypeFilter *)anItem) { } diff --git a/src/GEOMFiltersSelection/Handle_GEOM_FaceFilter.hxx b/src/GEOMFiltersSelection/Handle_GEOM_FaceFilter.hxx index 3acc213ac..49ae830d7 100644 --- a/src/GEOMFiltersSelection/Handle_GEOM_FaceFilter.hxx +++ b/src/GEOMFiltersSelection/Handle_GEOM_FaceFilter.hxx @@ -34,17 +34,17 @@ #include #endif -#ifndef _Handle_SALOME_Filter_HeaderFile -#include "Handle_SALOME_Filter.hxx" +#ifndef _Handle_GEOM_ShapeTypeFilter_HeaderFile +#include "Handle_GEOM_ShapeTypeFilter.hxx" #endif class Standard_Transient; class Handle_Standard_Type; -class Handle(SALOME_Filter); +class Handle(GEOM_ShapeTypeFilter); class GEOM_FaceFilter; Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOM_FaceFilter); -class Handle(GEOM_FaceFilter) : public Handle(SALOME_Filter) { +class Handle(GEOM_FaceFilter) : public Handle(GEOM_ShapeTypeFilter) { public: inline void* operator new(size_t,void* anAddress) { @@ -62,12 +62,12 @@ class Handle(GEOM_FaceFilter) : public Handle(SALOME_Filter) { // { // if (anAddress) Standard::Free((Standard_Address&)anAddress,size); // } - Handle(GEOM_FaceFilter)():Handle(SALOME_Filter)() {} - Handle(GEOM_FaceFilter)(const Handle(GEOM_FaceFilter)& aHandle) : Handle(SALOME_Filter)(aHandle) + Handle(GEOM_FaceFilter)():Handle(GEOM_ShapeTypeFilter)() {} + Handle(GEOM_FaceFilter)(const Handle(GEOM_FaceFilter)& aHandle) : Handle(GEOM_ShapeTypeFilter)(aHandle) { } - Handle(GEOM_FaceFilter)(const GEOM_FaceFilter* anItem) : Handle(SALOME_Filter)((SALOME_Filter *)anItem) + Handle(GEOM_FaceFilter)(const GEOM_FaceFilter* anItem) : Handle(GEOM_ShapeTypeFilter)((GEOM_ShapeTypeFilter *)anItem) { } diff --git a/src/GEOMFiltersSelection/Handle_GEOM_PreviewFilter.hxx b/src/GEOMFiltersSelection/Handle_GEOM_PreviewFilter.hxx new file mode 100644 index 000000000..cb8285ee5 --- /dev/null +++ b/src/GEOMFiltersSelection/Handle_GEOM_PreviewFilter.hxx @@ -0,0 +1,100 @@ +// GEOM GEOMFiltersSelection : filter selector for the viewer +// +// Copyright (C) 2004 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org or email : webmaster.salome@opencascade.org +// +// +// +// File : Handle_GEOM_PreviewFilter +// Module : GEOM + +#ifndef _Handle_GEOM_PreviewFilter_HeaderFile +#define _Handle_GEOM_PreviewFilter_HeaderFile + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Handle_SALOME_Filter_HeaderFile +#include "Handle_SALOME_Filter.hxx" +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(SALOME_Filter); +class GEOM_PreviewFilter; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOM_PreviewFilter); + +class Handle(GEOM_PreviewFilter) : public Handle(SALOME_Filter) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + Handle(GEOM_PreviewFilter)():Handle(SALOME_Filter)() {} + Handle(GEOM_PreviewFilter)(const Handle(GEOM_PreviewFilter)& aHandle) : Handle(SALOME_Filter)(aHandle) + { + } + + Handle(GEOM_PreviewFilter)(const GEOM_PreviewFilter* anItem) : Handle(SALOME_Filter)((SALOME_Filter *)anItem) + { + } + + Handle(GEOM_PreviewFilter)& operator=(const Handle(GEOM_PreviewFilter)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOM_PreviewFilter)& operator=(const GEOM_PreviewFilter* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOM_PreviewFilter* operator->() + { + return (GEOM_PreviewFilter *)ControlAccess(); + } + + GEOM_PreviewFilter* operator->() const + { + return (GEOM_PreviewFilter *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOM_PreviewFilter)(); + + Standard_EXPORT static const Handle(GEOM_PreviewFilter) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/GEOMFiltersSelection/Makefile.in b/src/GEOMFiltersSelection/Makefile.in index 851695357..7857d21cf 100644 --- a/src/GEOMFiltersSelection/Makefile.in +++ b/src/GEOMFiltersSelection/Makefile.in @@ -39,9 +39,12 @@ VPATH=.:@srcdir@:@top_srcdir@/idl LIB = libGEOMFiltersSelection.la LIB_SRC = GEOM_ShapeTypeFilter.cxx \ GEOM_FaceFilter.cxx \ - GEOM_EdgeFilter.cxx + GEOM_EdgeFilter.cxx \ + GEOM_PreviewFilter.cxx \ + GEOM_LogicalFilter.cxx \ + GEOM_TypeFilter.cxx -LIB_CLIENT_IDL = SALOME_Component.idl SALOMEDS.idl SALOMEDS_Attributes.idl SALOME_Exception.idl GEOM_Shape.idl GEOM_Gen.idl +LIB_CLIENT_IDL = SALOME_Component.idl SALOMEDS.idl SALOMEDS_Attributes.idl SALOME_Exception.idl GEOM_Gen.idl SALOME_GenericObj.idl # header files EXPORT_HEADERS= GEOM_ShapeTypeFilter.hxx \ @@ -49,7 +52,11 @@ EXPORT_HEADERS= GEOM_ShapeTypeFilter.hxx \ GEOM_FaceFilter.hxx \ Handle_GEOM_FaceFilter.hxx \ GEOM_EdgeFilter.hxx \ - Handle_GEOM_EdgeFilter.hxx + Handle_GEOM_EdgeFilter.hxx \ + GEOM_TypeFilter.hxx \ + GEOM_LogicalFilter.hxx \ + GEOM_PreviewFilter.hxx \ + Handle_GEOM_PreviewFilter.hxx # additionnal information to compil and link file CPPFLAGS += $(OCC_INCLUDES) $(QT_INCLUDES) $(PYTHON_INCLUDES) $(VTK_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome diff --git a/src/GEOMGUI/GEOMGUI.cxx b/src/GEOMGUI/GEOMGUI.cxx new file mode 100644 index 000000000..815927875 --- /dev/null +++ b/src/GEOMGUI/GEOMGUI.cxx @@ -0,0 +1,115 @@ +// 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 : GEOMGUI.cxx +// Author : Vadim SANDLER +// Module : GEOM +// $Header$ + +#include "GEOMGUI.h" + +#include "QAD_Desktop.h" +#include "QAD_StudyFrame.h" +#include "QAD_Application.h" +#include + +//================================================================================= +// class : GEOMGUI::GEOMGUI +// purpose : Constructor +//================================================================================= +GEOMGUI::GEOMGUI( QObject* parent ) : + QObject ( parent ) +{ +} + +//================================================================================= +// class : GEOMGUI::GEOMGUI +// purpose : Destructor +//================================================================================= +GEOMGUI::~GEOMGUI() +{ +} + +//================================================================================= +// class : GEOMGUI::OnGUIEvent +// purpose : Main/popup menu events processing +//================================================================================= +bool GEOMGUI::OnGUIEvent( int /*theCommandID*/, QAD_Desktop* /*parent*/ ) +{ + return TRUE; +} + +//================================================================================= +// class : GEOMGUI::OnMousePress +// purpose : Mouse press event processing. Should return FALSE to let the event +// be processed further. +//================================================================================= +bool GEOMGUI::OnMousePress( QMouseEvent* /*pe*/, QAD_Desktop* /*parent*/, QAD_StudyFrame* /*studyFrame*/ ) +{ + return FALSE; +} + +//================================================================================= +// class : GEOMGUI::OnMouseMove +// purpose : Mouse move event processing +//================================================================================= +bool GEOMGUI::OnMouseMove( QMouseEvent* /*pe*/, QAD_Desktop* /*parent*/, QAD_StudyFrame* /*studyFrame*/ ) +{ + return TRUE; +} + +//================================================================================= +// class : GEOMGUI::OnKeyPress +// purpose : Key press event processing +//================================================================================= +bool GEOMGUI::OnKeyPress( QKeyEvent* /*pe*/, QAD_Desktop* /*parent*/, QAD_StudyFrame* /*studyFrame*/ ) +{ + return TRUE; +} + +//================================================================================= +// class : GEOMGUI::SetSettings +// purpose : Called when GEOM component is activated +//================================================================================= +bool GEOMGUI::SetSettings( QAD_Desktop* /*parent*/ ) +{ + return TRUE; +} + +//================================================================================= +// class : GEOMGUI::Deactivate +// purpose : Called when GEOM component is deactivated +//================================================================================= +void GEOMGUI::Deactivate() +{ +} + +//================================================================================= +// class : GEOMGUI::ActiveStudyChanged +// purpose : Called when active study changed +//================================================================================= +bool GEOMGUI::ActiveStudyChanged( QAD_Desktop* /*parent*/ ) +{ + return TRUE; +} + diff --git a/src/GEOMGUI/GEOMGUI.h b/src/GEOMGUI/GEOMGUI.h new file mode 100644 index 000000000..bd0520027 --- /dev/null +++ b/src/GEOMGUI/GEOMGUI.h @@ -0,0 +1,62 @@ +// 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 : GEOMGUI.h +// Author : Vadim SANDLER +// Module : GEOM +// $Header$ + +#if !defined( __GEOMGUI_H ) +#define __GEOMGUI_H + +#include + +class QAD_Desktop; +class QAD_StudyFrame; +class QMouseEvent; +class QKeyEvent; + +//================================================================================= +// class : GEOMGUI +// purpose : Base class for all geometry GUI subclasses +//================================================================================= +class GEOMGUI : public QObject +{ +public : + // Constructor + GEOMGUI( QObject* parent = 0 ); + // Destructor + virtual ~GEOMGUI(); + + // Each of this methods can be redifined by descendants + virtual bool OnGUIEvent( int theCommandID, QAD_Desktop* parent ); + virtual bool OnMousePress( QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame ); + virtual bool OnMouseMove( QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame ); + virtual bool OnKeyPress( QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame ); + virtual bool SetSettings( QAD_Desktop* parent ); + virtual void Deactivate(); + virtual bool ActiveStudyChanged( QAD_Desktop* parent ); +}; + +#endif // __GEOMGUI_H + diff --git a/src/GEOMGUI/GEOM_Displayer.cxx b/src/GEOMGUI/GEOM_Displayer.cxx new file mode 100644 index 000000000..f518e4ecb --- /dev/null +++ b/src/GEOMGUI/GEOM_Displayer.cxx @@ -0,0 +1,1074 @@ +// 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 : GEOM_Displayer.cxx +// Author : Vadim SANDLER +// Module : GEOM +// $Header$ + +#include "GEOM_Displayer.h" +#include "GEOM_ShapeTypeFilter.hxx" +#include "GEOM_TypeFilter.hxx" +#include "QAD_Desktop.h" +#include "QAD_Application.h" +#include "QAD_Study.h" +#include "QAD_StudyFrame.h" +#include "QAD_RightFrame.h" +#include "QAD_ViewFrame.h" +#include "QAD_Config.h" +#include "SALOME_ListIteratorOfListIO.hxx" +#include "OCCViewer_Prs.h" +#include "OCCViewer_ViewFrame.h" +#include "OCCViewer_Viewer3d.h" +#include "VTKViewer_Prs.h" +#include "VTKViewer_ViewFrame.h" +#include "GEOMImpl_Types.hxx" +#include "TColStd_MapOfInteger.hxx" +#include "TColStd_MapIteratorOfMapOfInteger.hxx" +#include "GEOM_EdgeFilter.hxx" +#include "GEOM_FaceFilter.hxx" +#include "GEOM_PreviewFilter.hxx" +#include "GEOM_LogicalFilter.hxx" +#include "GEOM_AssemblyBuilder.h" +#include "GEOM_Actor.h" +#include "GEOM_AISTrihedron.hxx" +#include "GEOM_VTKTrihedron.hxx" + +#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes) + +#include "GeometryGUI.h" +#include "GEOM_AISShape.hxx" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +using namespace std; + +//================================================================ +// Function : getActiveStudy +// Purpose : Get active study, returns 0 if no open study frame +//================================================================ +static inline QAD_Study* getActiveStudy() +{ + QAD_Desktop* desktop = QAD_Application::getDesktop(); + if ( desktop ) { + QAD_Application* app = desktop->getActiveApp(); + if ( app ) + return app->getActiveStudy(); + } + return 0; +} + +//================================================================ +// Function : getTopAbsMode +// Purpose : Get TopAbs_ShapeEnum value corresponding to the +// one from GEOMImpl_Types.h +//================================================================ +static inline int getTopAbsMode( const int implType ) +{ + switch ( implType ) + { + case GEOM_COMPOUND : return TopAbs_COMPOUND; + case GEOM_SOLID : return TopAbs_SOLID; + case GEOM_SHELL : return TopAbs_SHELL; + case GEOM_FACE : return TopAbs_FACE; + case GEOM_WIRE : return TopAbs_WIRE; + case GEOM_EDGE : return TopAbs_EDGE; + case GEOM_POINT : return TopAbs_VERTEX; + default : return -1; + } +} + +//================================================================ +// Function : getTopAbsMode +// Purpose : Get filter corresponding to the type of object +// from GEOMImpl_Types.h +//================================================================ +static inline Handle(SALOME_Filter) getFilter( const int theMode ) +{ + Handle(SALOME_Filter) aFilter; + + int aTopAbsMode = getTopAbsMode( theMode ); + if ( aTopAbsMode != -1 ) + aFilter = new GEOM_ShapeTypeFilter( ( TopAbs_ShapeEnum )aTopAbsMode ); + else + switch ( theMode ) + { + case GEOM_LINE : aFilter = new GEOM_EdgeFilter( StdSelect_Line ); break; + case GEOM_CIRCLE : aFilter = new GEOM_EdgeFilter( StdSelect_Circle ); break; + + case GEOM_PLANE : aFilter = new GEOM_FaceFilter( StdSelect_Plane ); break; + case GEOM_CYLINDER : aFilter = new GEOM_FaceFilter( StdSelect_Cylinder ); break; + case GEOM_SPHERE : aFilter = new GEOM_FaceFilter( StdSelect_Sphere ); break; + case GEOM_TORUS : aFilter = new GEOM_FaceFilter( StdSelect_Torus ); break; + case GEOM_REVOLUTION: aFilter = new GEOM_FaceFilter( StdSelect_Revol ); break; + case GEOM_CONE : aFilter = new GEOM_FaceFilter( StdSelect_Cone ); break; + + case GEOM_PREVIEW : aFilter = new GEOM_PreviewFilter(); break; + + case GEOM_ALLSHAPES : aFilter = new GEOM_ShapeTypeFilter( -1, true ); break; + case GEOM_ALLGEOM : aFilter = new SALOME_TypeFilter( "GEOM" ); break; + + default : aFilter = new GEOM_TypeFilter( theMode ); break; + } + + return aFilter; +} + +//================================================================ +// Function : getEntry +// Purpose : +//================================================================ +static char* getEntry( GEOM::GEOM_Object_ptr object ) +{ + QAD_Study* study = getActiveStudy(); + if ( study ) { + string IOR = GeometryGUI::GetORB()->object_to_string( object ); + if ( IOR != "" ) { + SALOMEDS::SObject_var SO = study->getStudyDocument()->FindObjectIOR( IOR.c_str() ); + if ( !SO->_is_nil() ) { + return SO->GetID(); + } + } + } + return ""; +} + +//================================================================ +// Function : getName +// Purpose : +//================================================================ +static const char* getName( GEOM::GEOM_Object_ptr theObj ) +{ + QAD_Study* aStudy = QAD_Application::getDesktop()->getActiveStudy(); + + if ( aStudy ) + { + string anIOR = GeometryGUI::GetORB()->object_to_string( theObj ); + if ( anIOR != "" ) + { + SALOMEDS::SObject_var aSObj = aStudy->getStudyDocument()->FindObjectIOR( anIOR.c_str() ); + SALOMEDS::GenericAttribute_var anAttr; + + if ( !aSObj->_is_nil() && aSObj->FindAttribute( anAttr, "AttributeName") ) + { + SALOMEDS::AttributeName_var aNameAttr = SALOMEDS::AttributeName::_narrow( anAttr ); + return aNameAttr->Value(); + } + } + } + + return ""; +} + +//================================================================= +/*! + * GEOM_Displayer::GEOM_Displayer + * Constructor + */ +//================================================================= +GEOM_Displayer::GEOM_Displayer() +{ + /* Shading Color */ + QString SCr = QAD_CONFIG->getSetting( "Geometry:SettingsShadingColorRed" ); + QString SCg = QAD_CONFIG->getSetting( "Geometry:SettingsShadingColorGreen" ); + QString SCb = QAD_CONFIG->getSetting( "Geometry:SettingsShadingColorBlue" ); + if ( !SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty() ) + myShadingColor = Quantity_Color( + SCr.toInt()/255., SCg.toInt()/255., SCb.toInt()/255., Quantity_TOC_RGB ); + else + myShadingColor = Quantity_Color( Quantity_NOC_GOLDENROD ); + + myColor = -1; + // This color is used for shape displaying. If it is equal -1 then + // default color is used. + + myWidth = -1; + myType = -1; + + myToActivate = true; + // This parameter is used for activisation/deactivisation of objects to be displayed + + myViewFrame = 0; +} + +//================================================================= +/*! + * GEOM_Displayer::~GEOM_Displayer + * Destructor + */ +//================================================================= +GEOM_Displayer::~GEOM_Displayer() +{ +} + +//================================================================= +/*! + * GetActiveView + * Get active study frame, returns 0 if no open study frame + */ +//================================================================= +QAD_ViewFrame* GEOM_Displayer::GetActiveView() +{ + QAD_Study* activeStudy = getActiveStudy(); + if ( activeStudy ) + { + QAD_StudyFrame* sf = activeStudy->getActiveStudyFrame(); + if ( sf ) + { + return sf->getRightFrame()->getViewFrame(); + } + } + return 0; +} + +//================================================================= +/*! + * GEOM_Displayer::Display + * Display interactive object in the current viewer + */ +//================================================================= +void GEOM_Displayer::Display( const Handle(SALOME_InteractiveObject)& theIO, const bool updateViewer, + QAD_ViewFrame* theViewFrame ) +{ + QAD_ViewFrame* vf = theViewFrame; + if ( !vf ) + vf = GetActiveView(); + + if ( vf ) + { + if ( vf->inherits( "VTKViewer_ViewFrame" ) ) + { + SALOME_Prs* prs = vf->CreatePrs( !theIO.IsNull() ? theIO->getEntry() : 0 ); + ((SALOME_View*)vf)->Erase( prs, true ); + delete prs; + } + + SALOME_Prs* prs = buildPresentation( theIO, vf ); + + if ( prs ) + { + vf->BeforeDisplay( this ); + ((SALOME_View*)vf)->Display( prs ); + vf->AfterDisplay( this ); + + if ( updateViewer ) + vf->Repaint(); + + delete prs; // delete presentation because displayer is its owner + } + } +} + +//================================================================= +/*! + * GEOM_Displayer::Display + * This overloaded Display() method can be useful for operations + * not using dialog boxes. + */ +//================================================================= +void GEOM_Displayer::Display( GEOM::GEOM_Object_ptr theObj, const bool updateViewer ) +{ + if ( theObj->_is_nil() ) + return; + + string entry = getEntry( theObj ); + if ( entry != "" ) { + Display( new SALOME_InteractiveObject( + entry.c_str(), "GEOM", strdup( getName( theObj ) ) ), updateViewer ); + } +} + +//================================================================= +/*! + * GEOM_Displayer::Erase + * Erase interactive object in the current viewer + */ +//================================================================= +void GEOM_Displayer::Erase( const Handle(SALOME_InteractiveObject)& theIO, + const bool forced, + const bool updateViewer, + QAD_ViewFrame* theViewFrame ) +{ + if ( theIO.IsNull() ) + return; + + QAD_ViewFrame* vf = theViewFrame; + if ( !vf ) + vf = GetActiveView(); + + if ( vf ) { + SALOME_Prs* prs = vf->CreatePrs( theIO->getEntry() ); + if ( prs ) { + ((SALOME_View*)vf)->Erase( prs, forced ); + if ( updateViewer ) + vf->Repaint(); + delete prs; // delete presentation because displayer is its owner + } + } +} + +//================================================================= +/*! + * GEOM_Displayer::Erase + * Erase geometry object in the current viewer + */ +//================================================================= +void GEOM_Displayer::Erase( GEOM::GEOM_Object_ptr theObj, + const bool forced, + const bool updateViewer ) +{ + string entry = getEntry( theObj ); + if ( entry != "" ) + { + Erase( new SALOME_InteractiveObject( + entry.c_str(), "GEOM", strdup( getName( theObj ) ) ), forced, updateViewer ); + } +} + +//================================================================= +/*! + * GEOM_Displayer::Redisplay + * Redisplay (erase and then display again) interactive object + * in the current viewer + */ +//================================================================= +void GEOM_Displayer::Redisplay( const Handle(SALOME_InteractiveObject)& theIO, + const bool updateViewer ) +{ + // Remove the object permanently ( == true) + + QAD_Study* activeStudy = getActiveStudy(); + if ( !activeStudy ) + return; + + int aNbFrames = activeStudy->getStudyFramesCount(); + for (int i = 0; i < aNbFrames; i++) + { + QAD_StudyFrame* sf = activeStudy->getStudyFrame(i); + if ( !sf ) + continue; + + QAD_ViewFrame* vf = sf->getRightFrame()->getViewFrame(); + if ( !vf ) + continue; + + if ( vf->isVisible(theIO) || vf == GetActiveView() ) + { + Erase( theIO, true, false, vf ); + Display( theIO, updateViewer, vf ); + } + } +} + +//================================================================= +/*! + * GEOM_Displayer::Display + * Calls Display() method for each object in the given list + */ +//================================================================= +void GEOM_Displayer::Display( const SALOME_ListIO& theIOList, const bool updateViewer ) +{ + SALOME_ListIteratorOfListIO Iter( theIOList ); + for ( ; Iter.More(); Iter.Next() ) { + Display( Iter.Value(), false ); + } + if ( updateViewer ) + UpdateViewer(); +} + +//================================================================= +/*! + * GEOM_Displayer::Erase + * Calls Erase() method for each object in the given list + */ +//================================================================= +void GEOM_Displayer::Erase( const SALOME_ListIO& theIOList, + const bool forced, + const bool updateViewer ) +{ + SALOME_ListIteratorOfListIO Iter( theIOList ); + for ( ; Iter.More(); Iter.Next() ) + Erase( Iter.Value(), forced, false ); + + if ( updateViewer ) + UpdateViewer(); +} + +//================================================================= +/*! + * GEOM_Displayer::Redisplay + * Calls Redisplay() method for each object in the given list + */ +//================================================================= +void GEOM_Displayer::Redisplay( const SALOME_ListIO& theIOList, const bool updateViewer ) +{ + SALOME_ListIteratorOfListIO Iter( theIOList ); + for ( ; Iter.More(); Iter.Next() ) { + Redisplay( Iter.Value(), false ); + } + if ( updateViewer ) + UpdateViewer(); +} + +//================================================================= +/*! + * GEOM_Displayer::UpdateViewer + * Update current viewer + */ +//================================================================= +void GEOM_Displayer::UpdateViewer() +{ + QAD_ViewFrame* vf = GetActiveView(); + if ( vf ) + vf->Repaint(); +} + +//================================================================= +/*! + * GEOM_Displayer::Update + * Update OCC presentaion + * [ Reimplemented from SALOME_Displayer ] + */ +//================================================================= +void GEOM_Displayer::Update( SALOME_OCCPrs* prs ) +{ + OCCViewer_Prs* occPrs = dynamic_cast( prs ); + if ( !occPrs ) + return; + + OCCViewer_ViewFrame* vf = dynamic_cast( myViewFrame ); + if ( !vf ) + return; + + if ( myType == GEOM_MARKER && !myShape.IsNull() && myShape.ShapeType() == TopAbs_FACE ) + { + TopoDS_Face aFace = TopoDS::Face( myShape ); + Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast( BRep_Tool::Surface( aFace ) ); + if ( !aPlane.IsNull() ) + { + gp_Ax3 aPos = aPlane->Pln().Position(); + Handle(Geom_Axis2Placement) aPlc = new Geom_Axis2Placement( aPos.Ax2() ); + + Handle(GEOM_AISTrihedron) aTrh; + + if ( occPrs->IsNull() ) + { + aTrh = new GEOM_AISTrihedron( aPlc ); + + if ( HasColor() ) + aTrh->SetColor( (Quantity_NameOfColor)GetColor() ); + + if ( HasWidth() ) + aTrh->SetWidth( GetWidth() ); + + if ( !myIO.IsNull() ) + { + aTrh->setIO( myIO ); + aTrh->SetOwner( myIO ); + } + + occPrs->AddObject( aTrh ); + } + else + { + AIS_ListOfInteractive aList; + occPrs->GetObjects( aList ); + AIS_ListIteratorOfListOfInteractive anIter( aList ); + for ( ; anIter.More(); anIter.Next() ) + { + aTrh = Handle(GEOM_AISTrihedron)::DownCast( anIter.Value() ); + if ( !aTrh.IsNull() ) + { + aTrh->SetComponent( aPlc ); + aTrh->SetToUpdate(); + } + } + } + + occPrs->SetToActivate( ToActivate() ); + } + } + else + { + // if presentation is empty we try to create new one + if ( occPrs->IsNull() ) + { + if ( !myShape.IsNull() ) + { + Handle(GEOM_AISShape) AISShape = new GEOM_AISShape( myShape, "" ); + // Temporary staff: vertex must be infinite for correct visualization + AISShape->SetInfiniteState( myShape.Infinite() || myShape.ShapeType() == TopAbs_VERTEX ); + + // Setup shape properties here ..., e.g. display mode, color, transparency, etc + AISShape->SetShadingColor( myShadingColor ); + if ( HasColor() ) + { + if ( myShape.ShapeType() == TopAbs_VERTEX ) + { + AISShape->SetColor( (Quantity_NameOfColor)GetColor() ); + Handle(Prs3d_PointAspect) anAspect = AISShape->Attributes()->PointAspect(); + anAspect->SetColor( (Quantity_NameOfColor)GetColor() ); + AISShape->Attributes()->SetPointAspect( anAspect ); + } + else + AISShape->SetColor( (Quantity_NameOfColor)GetColor() ); + } + + if ( HasWidth() ) + AISShape->SetWidth( GetWidth() ); + + if ( !myIO.IsNull() ) + { + AISShape->setIO( myIO ); + AISShape->SetOwner( myIO ); + } + else if ( !myName.empty() ) + { + // Workaround to allow selection of temporary objects + static int tempId = 0; + char buf[50]; + sprintf( buf, "TEMP_%d", tempId++ ); + Handle( SALOME_InteractiveObject ) anObj = + new SALOME_InteractiveObject( buf, "GEOM", myName.c_str() ); + AISShape->setIO( anObj ); + AISShape->SetOwner( anObj ); + } + // AISShape->SetName(???); ??? necessary to set name ??? + occPrs->AddObject( AISShape ); + + // In accordance with ToActivate() value object will be activated/deactivated + // when it will be displayed + occPrs->SetToActivate( ToActivate() ); + } + } + // if presentation is found -> set again shape for it + else + { + if ( !myShape.IsNull() ) + { + AIS_ListOfInteractive IOList; + occPrs->GetObjects( IOList ); + AIS_ListIteratorOfListOfInteractive Iter( IOList ); + for ( ; Iter.More(); Iter.Next() ) + { + Handle(GEOM_AISShape) AISShape = Handle(GEOM_AISShape)::DownCast( Iter.Value() ); + if ( AISShape.IsNull() ) + continue; + if ( AISShape->Shape() != myShape ) + { + AISShape->Set( myShape ); + AISShape->UpdateSelection(); + AISShape->SetToUpdate(); + } + if ( !myIO.IsNull() ) + { + AISShape->setIO( myIO ); + AISShape->SetOwner( myIO ); + } + } + } + } + } +} + +//================================================================= +/*! + * GEOM_Displayer::Update + * Update VTK presentaion + * [ Reimplemented from SALOME_Displayer ] + */ +//================================================================= +void GEOM_Displayer::Update( SALOME_VTKPrs* prs ) +{ + VTKViewer_Prs* vtkPrs = dynamic_cast( prs ); + if ( !vtkPrs || myShape.IsNull() ) + return; + + vtkActorCollection* theActors = 0; + + if ( myType == GEOM_MARKER && !myShape.IsNull() && myShape.ShapeType() == TopAbs_FACE ) + { + myToActivate = false; + GEOM_VTKTrihedron* aTrh = GEOM_VTKTrihedron::New(); + + if ( HasColor() ) + { + Quantity_Color aColor( (Quantity_NameOfColor)GetColor() ); + aTrh->SetColor( aColor.Red(), aColor.Green(), aColor.Blue() ); + } + + Handle(Geom_Plane) aPlane = + Handle(Geom_Plane)::DownCast( BRep_Tool::Surface( TopoDS::Face( myShape ) ) ); + if ( aPlane.IsNull() ) + return; + + gp_Ax2 anAx2 = aPlane->Pln().Position().Ax2(); + aTrh->SetPlacement( new Geom_Axis2Placement( anAx2 ) ); + + if ( VTKViewer_ViewFrame* vf = dynamic_cast( GetActiveView() ) ) + aTrh->SetSize( 0.5 * vf->GetTrihedronSize() ); + + vtkPrs->AddObject( aTrh ); + + theActors = vtkActorCollection::New(); + theActors->AddItem( aTrh ); + } + else + theActors = GEOM_AssemblyBuilder::BuildActors( myShape, 0, 0, Standard_True ); + + theActors->InitTraversal(); + + vtkActor* anActor = (vtkActor*)theActors->GetNextActor(); + + vtkProperty* aProp = 0; + + if ( HasColor() || HasWidth() ) + { + aProp = vtkProperty::New(); + aProp->SetRepresentationToWireframe(); + } + + if ( HasColor() ) + { + Quantity_Color aColor( (Quantity_NameOfColor)GetColor() ); + aProp->SetColor( aColor.Red(), aColor.Green(), aColor.Blue() ); + } + + if ( HasWidth() ) + { + aProp->SetLineWidth( GetWidth() ); + } + + while ( anActor != NULL ) + { + SALOME_Actor* GActor = SALOME_Actor::SafeDownCast( anActor ); + + GActor->setIO( myIO ); + + if ( aProp ) + { + GActor->SetProperty( aProp ); + GActor->SetPreviewProperty( aProp ); + + GEOM_Actor* aGeomGActor = GEOM_Actor::SafeDownCast( anActor ); + if ( aGeomGActor != 0 ) + { + aGeomGActor->SetShadingProperty( aProp ); + aGeomGActor->SetWireframeProperty( aProp ); + } + } + + if ( myToActivate ) + GActor->PickableOn(); + else + GActor->PickableOff(); + + vtkPrs->AddObject( GActor ); + + anActor = (vtkActor*)theActors->GetNextActor(); + } + + if ( aProp ) + aProp->Delete(); + + theActors->Delete(); +} + +//================================================================= +/*! + * GEOM_Displayer::BuildPrs + * Build presentation accordint to the current viewer type + */ +//================================================================= +SALOME_Prs* GEOM_Displayer::BuildPrs( GEOM::GEOM_Object_ptr theObj ) +{ + if ( theObj->_is_nil() ) + return 0; + + GeometryGUI* geomGUI = GeometryGUI::GetGeomGUI(); + + myViewFrame = GetActiveView(); + if ( myViewFrame == 0 ) + return 0; + + SALOME_Prs* aPrs = myViewFrame->CreatePrs(); + if ( aPrs == 0 ) + return 0; + + internalReset(); + setShape( geomGUI->GetShapeReader().GetShape( geomGUI->GetGeomGen(), theObj ) ); + myType = theObj->GetType(); + + // Update presentation + UpdatePrs( aPrs ); + + return aPrs; +} + +//================================================================= +/*! + * GEOM_Displayer::BuildPrs + * Build presentation accordint to the current viewer type + */ +//================================================================= +SALOME_Prs* GEOM_Displayer::BuildPrs( const TopoDS_Shape& theShape ) +{ + myViewFrame = GetActiveView(); + if ( theShape.IsNull() || myViewFrame == 0 ) + return 0; + + SALOME_Prs* aPrs = myViewFrame->CreatePrs(); + if ( aPrs == 0 ) + return 0; + + internalReset(); + setShape( theShape ); + myType = -1; + + UpdatePrs( aPrs ); + + return aPrs; +} + +//================================================================= +/*! + * GEOM_Displayer::buildPresentation + * Builds/finds object's presentation for the current viewer + * Calls corresponding Update() method by means of double dispatch + * [ internal ] + */ +//================================================================= +SALOME_Prs* GEOM_Displayer::buildPresentation( const Handle(SALOME_InteractiveObject)& theIO, + QAD_ViewFrame* theViewFrame ) +{ + SALOME_Prs* prs = 0; + internalReset(); + + GeometryGUI* geomGUI = GeometryGUI::GetGeomGUI(); + + myViewFrame = theViewFrame; // no dynamic_cast here to use double dispatch + if ( !myViewFrame ) + myViewFrame = GetActiveView(); + + if ( myViewFrame ) { + prs = myViewFrame->CreatePrs( !theIO.IsNull() ? theIO->getEntry() : 0 ); + if ( prs ) { + if ( !theIO.IsNull() ) { + // set interactive object + setIO( theIO ); + // Find SOBject (because shape should be published previously) + SALOMEDS::SObject_var SO = getActiveStudy()->getStudyDocument()->FindObjectID( theIO->getEntry() ); + if ( !SO->_is_nil() ) { + // get CORBA reference to data object + CORBA::Object_var object = SO->GetObject(); + if ( !CORBA::is_nil( object ) ) { + // downcast to GEOM object + GEOM::GEOM_Object_var GeomObject = GEOM::GEOM_Object::_narrow( object ); + if ( !GeomObject->_is_nil() ) { + // finally set shape + setShape( geomGUI->GetShapeReader().GetShape( geomGUI->GetGeomGen(), GeomObject ) ); + myType = GeomObject->GetType(); + } + } + } + } + UpdatePrs( prs ); // Update presentation by using of the double dispatch + } + } + return prs; +} + +//================================================================= +/*! + * GEOM_Displayer::internalReset + * Resets internal data + * [internal] + */ +//================================================================= +void GEOM_Displayer::internalReset() +{ + myIO.Nullify(); + myShape.Nullify(); +} + +//================================================================= +/*! + * GEOM_Displayer::LocalSelection + * Activate selection of CAD shapes with activisation of selection + * of their sub-shapes (with opened local context for OCC viewer) + */ +//================================================================= +void GEOM_Displayer::LocalSelection( const Handle(SALOME_InteractiveObject)& theIO, const int theMode ) +{ + // remove all filters from selection + SALOME_Selection* aSel = SALOME_Selection::Selection( + QAD_Application::getDesktop()->getActiveStudy()->getSelection() ); + + aSel->ClearFilters(); + + QAD_ViewFrame* vf = GetActiveView(); + if ( vf ) + { + SALOME_Prs* prs = vf->CreatePrs( theIO.IsNull() ? 0 : theIO->getEntry() ); + ((SALOME_View*)vf)->LocalSelection( prs, theMode ); + delete prs; // delete presentation because displayer is its owner + } +} + +//================================================================= +/*! + * GEOM_Displayer::globalSelection + * Activate selection of CAD shapes without activisation of selection + * of their sub-shapes (without opened local context for OCC viewer) + */ +//================================================================= +void GEOM_Displayer::GlobalSelection( const int theMode, const bool update ) +{ + TColStd_MapOfInteger aModes; + aModes.Add( theMode ); + GlobalSelection( aModes, update ); +} + +//================================================================= +/*! + * GEOM_Displayer::globalSelection + * Activate selection of CAD shapes without activisation of selection + * of their sub-shapes (without opened local context for OCC viewer) + */ +//================================================================= +void GEOM_Displayer::GlobalSelection( const TColStd_MapOfInteger& theModes, + const bool update ) +{ + QAD_ViewFrame* vf = GetActiveView(); + if ( vf == 0 ) + return; + + // Close local context + vf->GlobalSelection( update ); + + // Set selection filters in accordance with current mode + SALOME_Selection* aSel = SALOME_Selection::Selection( + QAD_Application::getDesktop()->getActiveStudy()->getSelection() ); + + // Remove from selection temporary objects if necessary + if ( !theModes.Contains( GEOM_PREVIEW ) ) + clearTemporary( aSel ); + + aSel->ClearIndex(); + + aSel->ClearFilters(); + + if ( theModes.Contains( GEOM_ALLOBJECTS ) ) + return; + + Handle(SALOME_Filter) aFilter; + if ( theModes.Extent() == 1 ) + { + int aMode = TColStd_MapIteratorOfMapOfInteger( theModes ).Key(); + aFilter = getFilter( aMode ); + } + else if ( theModes.Extent() > 1 ) + { + TColStd_MapOfInteger aTopAbsModes; + TColStd_MapIteratorOfMapOfInteger anIter( theModes ); + GEOM_ListOfFilter aListOfFilters; + for ( ; anIter.More(); anIter.Next() ) + { + Handle(SALOME_Filter) aFilter = getFilter( anIter.Key() ); + if ( !aFilter.IsNull() ) + aListOfFilters.Append( aFilter ); + } + + aFilter = new GEOM_LogicalFilter( aListOfFilters, GEOM_LogicalFilter::LO_OR ); + } + else + return; + + if ( !aFilter.IsNull() ) + aSel->AddFilter( aFilter ); +} + +//================================================================= +/*! + * GEOM_Displayer::LocalSelection + * Activate selection of CAD shapes with activisation of selection + * of their sub-shapes (with opened local context for OCC viewer) + */ +//================================================================= +void GEOM_Displayer::LocalSelection( const SALOME_ListIO& theIOList, const int theMode ) +{ + SALOME_ListIteratorOfListIO Iter( theIOList ); + for ( ; Iter.More(); Iter.Next() ) + LocalSelection( Iter.Value(), theMode ); +} + +//================================================================= +/*! + * GEOM_Displayer::BeforeDisplay + * Called before displaying of pars. Close local context + * [ Reimplemented from SALOME_Displayer ] + */ +//================================================================= +void GEOM_Displayer::BeforeDisplay( SALOME_View* v, const SALOME_OCCViewType& ) +{ + OCCViewer_ViewFrame* vf = dynamic_cast( v ); + if ( vf ) + { + Handle(AIS_InteractiveContext) ic = vf->getViewer()->getAISContext(); + if ( !ic.IsNull() ) + { + if ( ic->HasOpenedContext() ) + ic->CloseAllContexts(); + } + } +} + +void GEOM_Displayer::AfterDisplay( SALOME_View*, const SALOME_OCCViewType& ) +{ +} + + +//================================================================= +/*! + * GEOM_Displayer::SetColor + * Set color for shape displaying. If it is equal -1 then default color is used. + * Available values are from Quantity_NameOfColor enumeration + */ +//================================================================= +void GEOM_Displayer::SetColor( const int color ) +{ + myColor = color; +} + +int GEOM_Displayer::GetColor() const +{ + return myColor; +} + +bool GEOM_Displayer::HasColor() const +{ + return myColor != -1; +} + +void GEOM_Displayer::UnsetColor() +{ + myColor = -1; +} + +//================================================================= +/*! + * GEOM_Displayer::SetWidth + * Set width of shape displaying. If it is equal -1 then default width is used. + */ +//================================================================= +void GEOM_Displayer::SetWidth( const double width ) +{ + myWidth = width; +} + +double GEOM_Displayer::GetWidth() const +{ + return myWidth; +} + +bool GEOM_Displayer::HasWidth() const +{ + return myWidth != -1; +} + +void GEOM_Displayer::UnsetWidth() +{ + myWidth = -1; +} + +//================================================================= +/*! + * GEOM_Displayer::SetToActivate + * This method is used for activisation/deactivisation of objects to be displayed + */ +//================================================================= +void GEOM_Displayer::SetToActivate( const bool toActivate ) +{ + myToActivate = toActivate; +} +bool GEOM_Displayer::ToActivate() const +{ + return myToActivate; +} + +//================================================================= +/*! + * GEOM_Displayer::clearTemporary + * Removes from selection temporary objects + */ +//================================================================= +void GEOM_Displayer::clearTemporary( SALOME_Selection* theSel ) +{ + SALOME_ListIO toBeRemoved; + SALOME_ListIteratorOfListIO anIter( theSel->StoredIObjects() ); + for ( ; anIter.More(); anIter.Next() ) + { + Handle(SALOME_InteractiveObject) anIO = anIter.Value(); + if ( anIO->hasEntry() && ( strncmp( anIO->getEntry(), "TEMP_", 5 ) == 0 ) ) + toBeRemoved.Append( anIO ); + } + + SALOME_ListIteratorOfListIO anIter2( toBeRemoved ); + for ( ; anIter2.More(); anIter2.Next() ) + theSel->RemoveIObject( anIter2.Value(), false ); +} + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/GEOMGUI/GEOM_Displayer.h b/src/GEOMGUI/GEOM_Displayer.h new file mode 100644 index 000000000..45a1e4f41 --- /dev/null +++ b/src/GEOMGUI/GEOM_Displayer.h @@ -0,0 +1,173 @@ +// 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 : GEOM_Displayer.h +// Author : Vadim SANDLER +// Module : GEOM +// $Header$ + +#if !defined (__GEOM_DISPLAYER_H) +#define __GEOM_DISPLAYER_H + +#include "SALOME_Prs.h" +#include "SALOME_InteractiveObject.hxx" +#include "SALOME_ListIO.hxx" +#include +#include + +#include + +#include +#include CORBA_CLIENT_HEADER(GEOM_Gen) + +#define GEOM_ALLOBJECTS -1 // Selection of all objects is activated +#define GEOM_PREVIEW -2 // Definition for preview selection +#define GEOM_ALLSHAPES -3 // Selection of all shapes is activated +#define GEOM_ALLGEOM -4 // Selection of all geom objects is activated + +typedef std::list ObjectList; + +class TColStd_MapOfInteger; +class QAD_ViewFrame; +class SALOME_Selection; + +class GEOM_Displayer : public SALOME_Displayer +{ + +public: + /* Constructor */ + GEOM_Displayer(); + /* Destructor */ + virtual ~GEOM_Displayer(); + + /* Display/Erase object methods */ + + void Display ( const Handle(SALOME_InteractiveObject)& theIO, + const bool updateViewer = true, + QAD_ViewFrame* theViewFrame = 0 ); + + // This overloaded Display() method can be useful for operations + // not using dialog boxes. + void Display ( GEOM::GEOM_Object_ptr theObj, + const bool updateViewer = true ); + + void Redisplay ( const Handle(SALOME_InteractiveObject)& theIO, + const bool updateViewer = true ); + + void Erase ( const Handle(SALOME_InteractiveObject)& theIO, + const bool forced = false, + const bool updateViewer = true, + QAD_ViewFrame* theViewFrame = 0 ); + + void Erase ( GEOM::GEOM_Object_ptr theObj, + const bool forced = false, + const bool updateViewer = true ); + + /* Display/Erase list of objects methods */ + + void Display ( const SALOME_ListIO& theIOList, + const bool updateViewer = true ); + + void Erase ( const SALOME_ListIO& theIOList, + const bool forced = false, + const bool updateViewer = true ); + + void Redisplay ( const SALOME_ListIO& theIOList, + const bool updateViewer = true ); + + /* Update current viewer */ + void UpdateViewer(); + + /* build presentation accordint to the current viewer type*/ + SALOME_Prs* BuildPrs ( GEOM::GEOM_Object_ptr ); + SALOME_Prs* BuildPrs ( const TopoDS_Shape& ); + + /* Set color for shape displaying. If it is equal -1 then default color is used. + Available values are from Quantity_NameOfColor enumeration */ + void SetColor ( const int ); + void UnsetColor(); + int GetColor () const; + bool HasColor () const; + + /* Set width for shape displaying. If it is equal -1 then default width is used. */ + void SetWidth ( const double ); + void UnsetWidth(); + double GetWidth () const; + bool HasWidth () const; + + + /* Sets name - for temporary objects only */ + void SetName( const char* theName ) { myName = theName; } + void UnsetName() { myName = ""; } + + /* Reimplemented from SALOME_Displayer */ + virtual void Update( SALOME_OCCPrs* ); + virtual void Update( SALOME_VTKPrs* ); + virtual void BeforeDisplay( SALOME_View*, const SALOME_OCCViewType& ); + virtual void AfterDisplay ( SALOME_View*, const SALOME_OCCViewType& ); + + /* This methos is used for activisation/deactivisation of objects to be displayed*/ + void SetToActivate( const bool ); + bool ToActivate() const; + + /* Activate/Deactivate selection*/ + void LocalSelection( const Handle(SALOME_InteractiveObject)&, const int ); + void LocalSelection( const SALOME_ListIO& theIOList, const int ); + void GlobalSelection( const int = GEOM_ALLOBJECTS, const bool = false ); + void GlobalSelection( const TColStd_MapOfInteger&, const bool = false ); + + static QAD_ViewFrame* GetActiveView(); + +protected: + /* internal methods */ + /* Builds presentation accordint to the current viewer type */ + SALOME_Prs* buildPresentation( const Handle(SALOME_InteractiveObject)& theIO, + QAD_ViewFrame* theViewFrame = 0 ); + + /* Sets interactive object */ + void setIO( const Handle(SALOME_InteractiveObject)& theIO ) { myIO = theIO; } + + /* Sets shape */ + void setShape( const TopoDS_Shape& theShape ) { myShape = theShape; } + + /* Resets internal data */ + void internalReset(); + + void clearTemporary( SALOME_Selection* ); + +protected: + Handle(SALOME_InteractiveObject) myIO; + TopoDS_Shape myShape; + string myName; + int myType; + QAD_ViewFrame* myViewFrame; + + // Attributes + Quantity_Color myShadingColor; + int myColor; + double myWidth; + bool myToActivate; +}; + +#endif // __GEOM_DISPLAYER_H + diff --git a/src/GEOMGUI/GEOM_icons.po b/src/GEOMGUI/GEOM_icons.po new file mode 100644 index 000000000..97e439650 --- /dev/null +++ b/src/GEOMGUI/GEOM_icons.po @@ -0,0 +1,488 @@ +# This is a Qt message file in .po format. Each msgid starts with +# a scope. This scope should *NOT* be translated - eg. translating +# from French to English, "Foo::Bar" would be translated to "Pub", +# not "Foo::Pub". +msgid "" +msgstr "" +"Project-Id-Version: PROJECT VERSION\n" +"POT-Creation-Date: 2001-06-14 09:11:49 PM CEST\n" +"PO-Revision-Date: 2003-09-22 16:39+0200\n" +"Last-Translator: FULLNAME \n" +"Content-Type: text/plain; charset=iso-8859-1\n" + +#Select +msgid "ICON_SELECT" +msgstr "select1.png" + +#: QAD_ObjectBrowser.cxx:140 +msgid "ICON_OBJBROWSER_Geometry" +msgstr "geometry.png" + +#: QAD_ObjectBrowser.cxx:140 +msgid "ICON_OBJBROWSER_COMPOUND" +msgstr "tree_compound.png" + +#: QAD_ObjectBrowser.cxx:140 +msgid "ICON_OBJBROWSER_COMPSOLID" +msgstr "tree_compsolid.png" + +#: QAD_ObjectBrowser.cxx:140 +msgid "ICON_OBJBROWSER_EDGE" +msgstr "tree_edge.png" + +#: QAD_ObjectBrowser.cxx:140 +msgid "ICON_OBJBROWSER_FACE" +msgstr "tree_face.png" + +#: QAD_ObjectBrowser.cxx:140 +msgid "ICON_OBJBROWSER_SHAPE" +msgstr "tree_shape.png" + +#: QAD_ObjectBrowser.cxx:140 +msgid "ICON_OBJBROWSER_SHELL" +msgstr "tree_shell.png" + +#: QAD_ObjectBrowser.cxx:140 +msgid "ICON_OBJBROWSER_SOLID" +msgstr "tree_solid.png" + +#: QAD_ObjectBrowser.cxx:140 +msgid "ICON_OBJBROWSER_VERTEX" +msgstr "tree_vertex.png" + +#: QAD_ObjectBrowser.cxx:140 +msgid "ICON_OBJBROWSER_WIRE" +msgstr "tree_wire.png" + +#: QAD_ObjectBrowser.cxx:140 +msgid "ICON_OBJBROWSER_BLOCK" +msgstr "tree_block.png" + +#BoxDlg +msgid "ICON_DLG_BOX_2P" +msgstr "box2points.png" + +#BoxDlg +msgid "ICON_DLG_BOX_DXYZ" +msgstr "boxdxyz.png" + +#CylinderDlg +msgid "ICON_DLG_CYLINDER_PV" +msgstr "cylinderpointvector.png" + +#CylinderDlg +msgid "ICON_DLG_CYLINDER_DXYZ" +msgstr "cylinderdxyz.png" + +#SphereDlg +msgid "ICON_DLG_SPHERE_P" +msgstr "spherepoint.png" + +#SphereDlg +msgid "ICON_DLG_SPHERE_DXYZ" +msgstr "spheredxyz.png" + +#torusDlg +msgid "ICON_DLG_TORUS_PV" +msgstr "toruspointvector.png" + +#ConeDlg +msgid "ICON_DLG_CONE_PV" +msgstr "conepointvector.png" + +#torusDlg +msgid "ICON_DLG_TORUS_DXYZ" +msgstr "torusdxyz.png" + +#ConeDlg +msgid "ICON_DLG_CONE_DXYZ" +msgstr "conedxyz.png" + +#LineDlg +msgid "ICON_DLG_LINE_2P" +msgstr "line2points.png" + +#LineDlg +msgid "ICON_DLG_LINE_EDGE" +msgstr "lineedge.png" + +#LineDlg +msgid "ICON_DLG_LINE_PV" +msgstr "linepointvector.png" + +#CircleDlg +msgid "ICON_DLG_CIRCLE_PV" +msgstr "circlepointvector.png" + +#VectorDlg +msgid "ICON_DLG_VECTOR_2P" +msgstr "vector2points.png" + +#vectorDlg +msgid "ICON_DLG_VECTOR_DXYZ" +msgstr "vectordxyz.png" + +#PlaneDlg +msgid "ICON_DLG_PLANE_DXYZ" +msgstr "planedxyz.png" + +#PlaneDlg +msgid "ICON_DLG_PLANE_FACE" +msgstr "planeface.png" + +#PlaneDlg +msgid "ICON_DLG_PLANE_PV" +msgstr "planepointvector.png" + +#WorkingPlaneDlg +msgid "ICON_DLG_WPLANE_FACE" +msgstr "planeworkingface.png" + +#WorkingPlaneDlg +msgid "ICON_DLG_WPLANE_VECTOR" +msgstr "planeworkingvector.png" + +#WorkingPlaneDlg +msgid "ICON_DLG_WPLANE_ORIGIN" +msgstr "planeworkingorigin.png" + +#PointDlg +msgid "ICON_DLG_POINT" +msgstr "point2.png" + +#PointDlg +msgid "ICON_DLG_POINT_REF" +msgstr "point3.png" + +#PoinDlg +msgid "ICON_DLG_POINT_EDGE" +msgstr "pointonedge.png" + +#ArcDlg +msgid "ICON_DLG_ARC" +msgstr "arc.png" + +#ArchimedeDlg +msgid "ICON_DLG_ARCHIMEDE" +msgstr "archimede.png" + +#PartitionDlg +msgid "ICON_DLG_PARTITION" +msgstr "partition.png" + +#PartitionDlg +msgid "ICON_DLG_PARTITION_KEEP_FACES" +msgstr "partitionkeep.png" + +#PartitionDlg +msgid "ICON_DLG_PARTITION_PLANE" +msgstr "partitionplane.png" + +#CenterMassDlg +msgid "ICON_DLG_CENTERMASS" +msgstr "centergravity.png" + +#BoundingBoxDlg +msgid "ICON_DLG_BOUNDING_BOX" +msgstr "bounding.png" + +#CommonDlg +msgid "ICON_DLG_COMMON" +msgstr "common.png" + +#CompoundDlg +msgid "ICON_DLG_BUILD_COMPOUND" +msgstr "build_compound.png" + +#CutDlg +msgid "ICON_DLG_CUT" +msgstr "cut.png" + +#EdgeDlg +msgid "ICON_DLG_BUILD_EDGE" +msgstr "build_edge.png" + +#FaceDlg +msgid "ICON_DLG_BUILD_FACE" +msgstr "build_face.png" + +#ShellDlg +msgid "ICON_DLG_BUILD_SHELL" +msgstr "build_shell.png" + +#SolidDlg +msgid "ICON_DLG_BUILD_SOLID" +msgstr "build_solid.png" + +#WireDlg +msgid "ICON_DLG_BUILD_WIRE" +msgstr "build_wire.png" + +#FillingDlg +msgid "ICON_DLG_FILLING" +msgstr "filling.png" + +#FuseDlg +msgid "ICON_DLG_FUSE" +msgstr "fuse.png" + +#InertiaDlg +msgid "ICON_DLG_INERTIA" +msgstr "axisinertia.png" + +#ToleranceDlg +msgid "ICON_DLG_TOLERANCE" +msgstr "tolerance.png" + +#BasicPropertiesDlg +msgid "ICON_DLG_BASICPROPERTIES" +msgstr "basicproperties.png" + +#WhatisDlg +msgid "ICON_DLG_WHATIS" +msgstr "whatis.png" + +#MinDistDlg +msgid "ICON_DLG_MINDIST" +msgstr "mindist.png" + +#MirrorDlg (MZN: add icons for point and axe) +msgid "ICON_DLG_MIRROR_POINT" +msgstr "mirrorPoint.png" + +msgid "ICON_DLG_MIRROR_AXE" +msgstr "mirrorAxe.png" + +msgid "ICON_DLG_MIRROR_PLANE" +msgstr "mirrorPlane.png" + +#TranslationDlg +msgid "ICON_DLG_TRANSLATION_DXYZ" +msgstr "translationDxyz.png" + +#TranslationDlg +msgid "ICON_DLG_TRANSLATION_POINTS" +msgstr "translationPoints.png" + +#TranslationDlg +msgid "ICON_DLG_TRANSLATION_VECTOR" +msgstr "translationVector.png" + +#RotationDlg +msgid "ICON_DLG_ROTATION" +msgstr "rotate.png" + +#ScaleDlg +msgid "ICON_DLG_SCALE" +msgstr "scale.png" + +#OffsetDlg +msgid "ICON_DLG_OFFSET" +msgstr "offset.png" + +#OrientationDlg +msgid "ICON_DLG_DIVIDE_EDGE" +msgstr "pointonedge.png" + +#SewingDlg +msgid "ICON_DLG_SEWING" +msgstr "sewing.png" + +#PipeDlg +msgid "ICON_DLG_PIPE" +msgstr "pipe.png" + +#PrismDlg +msgid "ICON_DLG_PRISM" +msgstr "prism.png" + +#RevolutionDlg +msgid "ICON_DLG_REVOL" +msgstr "revol.png" + +#SectionDlg +msgid "ICON_DLG_SECTION" +msgstr "section.png" + +#SubShapeDlg +msgid "ICON_DLG_SUBSHAPE" +msgstr "subshape.png" + +#FilletDlg +msgid "ICON_DLG_FILLET" +msgstr "fillet.png" + +#ChamferDlg +msgid "ICON_DLG_CHAMFER" +msgstr "chamfer.png" + +#FilletDlg +msgid "ICON_DLG_FILLET_ALL" +msgstr "filletall.png" + +#ChamferDlg +msgid "ICON_DLG_CHAMFER_ALL" +msgstr "chamferall.png" + +#FilletDlg +msgid "ICON_DLG_FILLET_EDGE" +msgstr "filletedge.png" + +#ChamferDlg +msgid "ICON_DLG_CHAMFER_EDGE" +msgstr "chamferedge.png" + +#FilletDlg +msgid "ICON_DLG_FILLET_FACE" +msgstr "filletface.png" + +#ChamferDlg +msgid "ICON_DLG_CHAMFER_FACE" +msgstr "chamferface.png" + +#ChamferDlg +msgid "ICON_DLG_CHECKSHAPE" +msgstr "check.png" + +#SupressFaceDlg +msgid "ICON_DLG_SUPRESS_FACE" +msgstr "supressface.png" + +msgid "ICON_DLG_CLOSECONTOUR" +msgstr "closecontour.png" + +#SupressHoleDlg +msgid "ICON_DLG_SUPRESS_HOLE" +msgstr "supresshole.png" + +#SupressHoleDlg +msgid "ICON_DLG_SUPRESS_HOLE_FACE_SHELL" +msgstr "supressHolesOnFaceShell.png" + +#MultiTranslationDlg +msgid "ICON_DLG_MULTITRANSLATION_SIMPLE" +msgstr "multitranslationsimple.png" + +#MultiTranslationDlg +msgid "ICON_DLG_MULTITRANSLATION" +msgstr "multitranslation.png" + +#MultiTranslationDlg +msgid "ICON_DLG_MULTITRANSLATION_DOUBLE" +msgstr "multitranslationdouble.png" + +#MultiRotationDlg +msgid "ICON_DLG_MULTIROTATION_SIMPLE" +msgstr "multirotationsimple.png" + +#MultiRotationDlg +msgid "ICON_DLG_MULTIROTATION" +msgstr "multirotation.png" + +#MultiRotationDlg +msgid "ICON_DLG_MULTIROTATION_DOUBLE" +msgstr "multirotationdouble.png" + +#EllipseDlg +msgid "ICON_DLG_ELLIPSE_PV" +msgstr "ellipsepointvector.png" + +#SplineDlg +msgid "ICON_DLG_SPLINE" +msgstr "spline.png" + +#SplineDlg +msgid "ICON_DLG_BEZIER" +msgstr "bezier.png" + +#SplineDlg +msgid "ICON_DLG_INTERPOL" +msgstr "interpol.png" + +msgid "ICON_DLG_CIRCLE_PNTS" +msgstr "circle3points.png" + +msgid "ICON_DLG_PLANE_3PNTS" +msgstr "plane3points.png" + +msgid "ICON_DLG_POLYLINE" +msgstr "polyline.png" + +msgid "ICON_DLG_SUPPRESS_INT_WIRES" +msgstr "suppressintwires.png" + +msgid "ICON_DLG_ADD_POINT_ON_EDGE" +msgstr "pointonedge.png" + +msgid "ICON_DLG_SUPPRESS_HOLES" +msgstr "supressHolesOnFaceShell.png" + +msgid "ICON_MARKER" +msgstr "marker.png" + +msgid "ICON_MARKER2" +msgstr "marker2.png" + +msgid "ICON_MARKER3" +msgstr "marker3.png" + +msgid "ICON_DLG_POSITION" +msgstr "position.png" + +msgid "ICON_DLG_POSITION2" +msgstr "position2.png" + +msgid "ICON_DLG_UNDO" +msgstr "undo.png" + +msgid "ICON_DLG_REDO" +msgstr "redo.png" + +msgid "ICON_OBJBROWSER_GROUP_PNT" +msgstr "tree_group_vertex.png" + +msgid "ICON_OBJBROWSER_GROUP_EDGE" +msgstr "tree_group_edge.png" + +msgid "ICON_OBJBROWSER_GROUP_FACE" +msgstr "tree_group_face.png" + +msgid "ICON_OBJBROWSER_GROUP_SOLID" +msgstr "tree_group_solid.png" + +msgid "ICON_OBJBROWSER_LCS" +msgstr "tree_lcs.png" + +msgid "ICON_DLG_SHAPEPROCESS" +msgstr "shapeprocess.png" + +#BlocksGUI_BlockDlg +msgid "ICON_DLG_BLOCK_2F" +msgstr "block_2f.png" + +msgid "ICON_DLG_BLOCK_6F" +msgstr "block_6f.png" + +#BlocksGUI_ExplodeDlg +msgid "ICON_DLG_BLOCK_EXPLODE" +msgstr "subblock.png" + +#BlocksGUI_TrsfDlg +msgid "ICON_DLG_BLOCK_MULTITRSF_SIMPLE" +msgstr "block_multitrsf_simple.png" + +msgid "ICON_DLG_BLOCK_MULTITRSF_DOUBLE" +msgstr "block_multitrsf_double.png" + +#BlocksGUI_QuadFaceDlg +msgid "ICON_DLG_QUAD_FACE_4_VERT" +msgstr "block_face_4v.png" + +msgid "ICON_DLG_QUAD_FACE_2_EDGE" +msgstr "block_face_2e.png" + +msgid "ICON_DLG_QUAD_FACE_4_EDGE" +msgstr "block_face_4e.png" + +msgid "ICON_DLG_GLUE_FACES" +msgstr "glue.png" diff --git a/src/GEOMGUI/GEOM_msg_en.po b/src/GEOMGUI/GEOM_msg_en.po new file mode 100644 index 000000000..30092d5de --- /dev/null +++ b/src/GEOMGUI/GEOM_msg_en.po @@ -0,0 +1,1932 @@ +# This is a Qt message file in .po format. Each msgid starts with +# a scope. This scope should *NOT* be translated - eg. translating +# from French to English, "Foo::Bar" would be translated to "Pub", +# not "Foo::Pub". +msgid "" +msgstr "" +"Project-Id-Version: PROJECT VERSION\n" +"POT-Creation-Date: 2002-03-19 09:35:48 AM CET\n" +"PO-Revision-Date: 2003-10-27 17:32+0100\n" +"Last-Translator: FULLNAME \n" +"Content-Type: text/plain; charset=iso-8859-1\n" + +# +#============================================================================== +# + +#Button Apply +msgid "GEOM_BUT_APPLY" +msgstr "&Apply" + +#Button Close +msgid "GEOM_BUT_CLOSE" +msgstr "&Close" + +#Button Cancel +msgid "GEOM_BUT_CANCEL" +msgstr "&Cancel" + +#Button Ok +msgid "GEOM_BUT_OK" +msgstr "&Ok" + +#Button Yes +msgid "GEOM_BUT_YES" +msgstr "&Yes" + +#Button No +msgid "GEOM_BUT_NO" +msgstr "&No" + +#Button Help +msgid "GEOM_BUT_HELP" +msgstr "&Help" + +#Button Explode +msgid "GEOM_BUT_EXPLODE" +msgstr "&Explode" + +# +#============================================================================== +# + +#: GeometryGUI.cxx:563 +msgid "GEOM_INF_LOADED" +msgstr "File %1 loaded." + +# +#============================================================================== +# + +#: GeometryGUI.cxx:3069 +msgid "GEOM_PRP_COMMAND" +msgstr "No command associated with this id = %1." + +#: GeometryGUI.cxx:4977 +msgid "GEOM_PRP_ABORT" +msgstr "Operation aborted" + +#: GeometryGUI.cxx:5058 +msgid "GEOM_PRP_DONE" +msgstr "Operation done" + +#: GeometryGUI.cxx:3717 +msgid "GEOM_PRP_LOADING" +msgstr "Loading %1 ..." + +#: GeometryGUI.cxx:1412 +msgid "GEOM_PRP_NULLSHAPE" +msgstr "Error, null or inappropriate shape !" + +#: GeometryGUI.cxx:5072 +msgid "GEOM_PRP_READY" +msgstr "Ready" + +#: GeometryGUI.cxx:1690 +msgid "GEOM_PRP_SELECT_SUBSHAPES" +msgstr "Select Sub Shapes" + +msgid "GEOM_CONFIRM" +msgstr "Confirm operation" + +msgid "GEOM_CONFIRM_INFO" +msgstr "Shape contains %1 sub shapes !" + + +msgid "GEOM_PRP_NOT_FOR_VTK_VIEWER" +msgstr "Not allowed in VTK viewer" + +#: GeometryGUI.cxx:1690 +msgid "GEOM_PRP_SHAPE_IN_STUDY" +msgstr "Main shape must be in the study before" + +#: GeometryGUI.cxx:1690 +msgid "GEOM_PRP_SELECT_EDGE" +msgstr "Select edges and click on Apply" + +#: GeometryGUI.cxx:1690 +msgid "GEOM_PRP_SELECT_FACE" +msgstr "Select faces to suppress and click on Ok/Apply" + +#: GeometryGUI.cxx:1690 +msgid "GEOM_PRP_SELECT_FIRST" +msgstr "Select main shape first" + +#: GeometryGUI.cxx:1690 +msgid "GEOM_PRP_MIN_DIST" +msgstr "Min Distance not computed" + +msgid "GEOM_STUDY_LOCKED" +msgstr "The active study is locked and therefore cannot be modified" + +# +#============================================================================== +# + +#: GeometryGUI.cxx:3698 +msgid "GEOM_MEN_ALL_FILES" +msgstr "All Files ( * )" + +#: GeometryGUI.cxx:4389 +msgid "GEOM_MEN_ANGLE" +msgstr "Angle :" + +#: GeometryGUI.cxx:3941 +msgid "GEOM_MEN_COMPONENT" +msgstr "Geometry" + +#: GeometryGUI.cxx:4389 +msgid "GEOM_MEN_ENTER_ANGLE" +msgstr "Enter An Angle In Degrees" + +#: GeometryGUI.cxx:3758 +msgid "GEOM_MEN_EXPORT" +msgstr "Export" + +#: GeometryGUI.cxx:3648 +msgid "GEOM_MEN_IMPORT" +msgstr "Import" + +#: GeometryGUI.cxx:3763 +msgid "GEOM_MEN_LOAD_SCRIPT" +msgstr "PYTHON Files ( *.py )" + +#: GeometryGUI.cxx:2931 +msgid "GEOM_MEN_ISOS" +msgstr "Select Number Of Isos" + +#: GeometryGUI.cxx:4278 +msgid "GEOM_MEN_POPUP_NAME" +msgstr "%1 Objects" + +#: GeometryGUI.cxx:4414 +msgid "GEOM_MEN_SKETCHER_X" +msgstr "Enter a length to set X" + +#: GeometryGUI.cxx:4438 +msgid "GEOM_MEN_SKETCHER_Y" +msgstr "Enter a length to set Y" + +#: GeometryGUI.cxx:2898 +msgid "GEOM_MEN_TRANSPARENCY" +msgstr "Transparency" + +#: GeometryGUI.cxx:4413 +msgid "GEOM_MEN_X" +msgstr "X :" + +#: GeometryGUI.cxx:4437 +msgid "GEOM_MEN_Y" +msgstr "Y :" + +#: GeometryGUI_NbIsosDlg.cxx:36 +msgid "GEOM_MEN_ISOU" +msgstr "Isos u :" + +#: GeometryGUI_NbIsosDlg.cxx:53 +msgid "GEOM_MEN_ISOV" +msgstr "Isos v :" + +#: GeometryGUI_TransparencyDlg.cxx:31 +msgid "GEOM_MEN_TRANSPARENCY_LABEL" +msgstr "Transparency :" + +msgid "GEOM_MEN_STEP_LABEL" +msgstr "Step :" + +msgid "GEOM_IDENTICAL_NAMES_SELECT_BY_MOUSE" +msgstr "Identical names : select by mouse !" + +msgid "GEOM_NAME_INCORRECT" +msgstr "Object name not found" + +msgid "GEOM_INCORRECT_INPUT" +msgstr "Incorrect input data!" + +# +#============================================================================== +# + +#: GeometryGUI.cxx:892 +msgid "GEOM_WRN_RADIUS_NULL" +msgstr "Radius is null" + +#: GeometryGUI.cxx:3854 +msgid "GEOM_WRN_WARNING" +msgstr "Warning" + +#: GeometryGUI.cxx:3854 +msgid "GEOM_REALLY_DELETE" +msgstr "Do you really want to delete object(s) ?" + +# +#============================================================================== +# + +#Object +msgid "GEOM_OBJECT" +msgstr "Object" + +#Main object +msgid "GEOM_MAIN_OBJECT" +msgstr "Main Object" + +#Tool object +msgid "GEOM_TOOL_OBJECT" +msgstr "Tool Object" + +#Base Object +msgid "GEOM_BASE_OBJECT" +msgstr "Base Object" + +#Path Object +msgid "GEOM_PATH_OBJECT" +msgstr "Path Object" + +#Objects +msgid "GEOM_OBJECTS" +msgstr "Objects" + +#Object i +msgid "GEOM_OBJECT_I" +msgstr "Object %1" + +#Object and result +msgid "GEOM_OBJECT_RESULT" +msgstr "Object And Result" + +#Point +msgid "GEOM_POINT" +msgstr "Point" + +#Base point +msgid "GEOM_BASE_POINT" +msgstr "Base Point" + +#Center Point +msgid "GEOM_CENTER_POINT" +msgstr "Center Point" + +#Diagonal Points +msgid "GEOM_DIAGONAL_POINTS" +msgstr "Diagonal Points" + +#Central Point +msgid "GEOM_CENTRAL_POINT" +msgstr "Central Point" + +#Points +msgid "GEOM_POINTS" +msgstr "Points" + +#Point i +msgid "GEOM_POINT_I" +msgstr "Point %1" + +#Arguments +msgid "GEOM_ARGUMENTS" +msgstr "Arguments" + +#Center +msgid "GEOM_CENTER" +msgstr "Center" + +#Radius +msgid "GEOM_RADIUS" +msgstr "Radius :" + +#Radius i +msgid "GEOM_RADIUS_I" +msgstr "Radius %1 :" + +#Height +msgid "GEOM_HEIGHT" +msgstr "Height :" + +#Length +msgid "GEOM_LENGTH" +msgstr "Length is :" + +#Weight +msgid "GEOM_WEIGHT" +msgstr "Weight :" + +#Coordinates +msgid "GEOM_COORDINATES" +msgstr "Coordinates" + +#Coor. +msgid "GEOM_COOR" +msgstr "Coord. :" + +#Reverse +msgid "GEOM_REVERSE" +msgstr "Reverse" + +#Reverse U +msgid "GEOM_REVERSE_U" +msgstr "Reverse U" + +#Reverse V +msgid "GEOM_REVERSE_V" +msgstr "Reverse V" + +#Angle +msgid "GEOM_ANGLE" +msgstr "Angle :" + +#Axis +msgid "GEOM_AXIS" +msgstr "Axis" + +#Matrix +msgid "GEOM_MATRIX" +msgstr "Matrix :" + +#Vector Length +msgid "GEOM_VECTOR_LENGTH" +msgstr "Vector Length :" + +#Reverse Vector +msgid "GEOM_REVERSE_VECTOR" +msgstr "Reverse Vector" + +#Point Mirror +msgid "GEOM_POINT_MIRROR" +msgstr "Point Mirror" + +#Axe Mirror +msgid "GEOM_AXE_MIRROR" +msgstr "Axe Mirror" + +#Plane Mirror +msgid "GEOM_PLANE_MIRROR" +msgstr "Plane Mirror" + +#Face Selection +msgid "GEOM_FACE_SELECTION" +msgstr "Face Selection" + +#Base +msgid "GEOM_BASE" +msgstr "Base" + +#Water Density +msgid "GEOM_WATER_DENSITY" +msgstr "Water Density :" + +#Meshing Deflection +msgid "GEOM_MESHING_DEFLECTION" +msgstr "Meshing Deflect. :" + +#Dimensions +msgid "GEOM_DIMENSIONS" +msgstr "Dimensions" + +#Precision +msgid "GEOM_PRECISION" +msgstr "Precision :" + +#Selection +msgid "GEOM_SELECTION" +msgstr "Selection" + +#Nb. Times +msgid "GEOM_NB_TIMES" +msgstr "Nb. Times :" + +#Nb. Times U +msgid "GEOM_NB_TIMES_U" +msgstr "Nb. Times U :" + +#Nb. Times V +msgid "GEOM_NB_TIMES_V" +msgstr "Nb. Times V :" + +#Step +msgid "GEOM_STEP" +msgstr "Step :" + +#Step V +msgid "GEOM_STEP_V" +msgstr "Step V :" + +#Step U +msgid "GEOM_STEP_U" +msgstr "Step U :" + +# +#============================================================================== +# + +#Partition +msgid "GEOM_PARTITION" +msgstr "Partition" + +#Half-space partition +msgid "GEOM_PARTITION_HALFSPACE" +msgstr "Half-space partition" + +#Tolerance +msgid "GEOM_TOLERANCE" +msgstr "Tolerance" + +#Orientation +msgid "GEOM_ORIENTATION" +msgstr "Orientation" + +#Pipe +msgid "GEOM_PIPE" +msgstr "Pipe" + +#Revolution +msgid "GEOM_REVOLUTION" +msgstr "Revolution" + +#Rotation +msgid "GEOM_ROTATION" +msgstr "Rotation" + +#Archimede +msgid "GEOM_ARCHIMEDE" +msgstr "Archimede" + +#Common +msgid "GEOM_COMMON" +msgstr "Common" + +#Cut +msgid "GEOM_CUT" +msgstr "Cut" + +#Distance +msgid "GEOM_DISTANCE" +msgstr "Distance" + +#Filling +msgid "GEOM_FILLING" +msgstr "Filling" + +#Fuse +msgid "GEOM_FUSE" +msgstr "Fuse" + +#Scale +msgid "GEOM_SCALE" +msgstr "Scale" + +#Position +msgid "GEOM_POSITION" +msgstr "Location" + +#Offset +msgid "GEOM_OFFSET" +msgstr "Offset" + +#Section +msgid "GEOM_SECTION" +msgstr "Section" + +#Sewing +msgid "GEOM_SEWING" +msgstr "Sewing" + +#Translation +msgid "GEOM_TRANSLATION" +msgstr "Translation" + +#Working Plane +msgid "GEOM_WPLANE" +msgstr "Working Plane" + +#Mirror +msgid "GEOM_MIRROR" +msgstr "Mirror" + +#Prism +msgid "GEOM_PRISM" +msgstr "Prism" + +#Sub Shapes +msgid "GEOM_SUB_SHAPE" +msgstr "Sub Shapes" + +#Supress Face +msgid "GEOM_SUPRESSFACE" +msgstr "Supress Face" + +#Fillet +msgid "GEOM_FILLET" +msgstr "Fillet" + +#Chamfer +msgid "GEOM_CHAMFER" +msgstr "Chamfer" + +#Check Shape +msgid "GEOM_CHECK_SHAPE" +msgstr "Check Shape" + +#Whatis +msgid "GEOM_WHATIS" +msgstr "Whatis" + +#Bounding Box +msgid "GEOM_BNDBOX" +msgstr "Bounding Box" + +#Center Of Mass +msgid "GEOM_CMASS" +msgstr "Center Of Mass" + +#Basic Properties +msgid "GEOM_PROPERTIES" +msgstr "Basic Properties" + +#Multi-Translation +msgid "GEOM_MULTITRANSLATION" +msgstr "Multi-Translation" + +#Multi-Rotation +msgid "GEOM_MULTIROTATION" +msgstr "Multi-Rotation" + +# +#============================================================================== +# + +#Arc +msgid "GEOM_ARC" +msgstr "Arc" + +#Box +msgid "GEOM_BOX" +msgstr "Box" + +#Circle +msgid "GEOM_CIRCLE" +msgstr "Circle" + +#Ellipse +msgid "GEOM_ELLIPSE" +msgstr "Ellipse" + +msgid "GEOM_ELLIPSE_TITLE" +msgstr "Ellipse Construction" + +#Radius major +msgid "GEOM_RADIUS_MAJOR" +msgstr "Major radius :" + +#Radius minor +msgid "GEOM_RADIUS_MINOR" +msgstr "Minor radius :" + +#Compound +msgid "GEOM_COMPOUND" +msgstr "Compound" + +#CompSolid +msgid "GEOM_COMPOUNDSOLID" +msgstr "CompSolid" + +#Cone +msgid "GEOM_CONE" +msgstr "Cone" + +#Cylinder +msgid "GEOM_CYLINDER" +msgstr "Cylinder" + +#Edge +msgid "GEOM_EDGE" +msgstr "Edge" + +#Face +msgid "GEOM_FACE" +msgstr "Face" + +#Faces +msgid "GEOM_FACES" +msgstr "Faces" + +#Line +msgid "GEOM_LINE" +msgstr "Line" + +#Plane +msgid "GEOM_PLANE" +msgstr "Plane" + +#Shape +msgid "GEOM_SHAPE" +msgstr "Shape" + +#Shell +msgid "GEOM_SHELL" +msgstr "Shell" + +#Shells +msgid "GEOM_SHELLS" +msgstr "Shells" + +#Solid +msgid "GEOM_SOLID" +msgstr "Solid" + +#Sphere +msgid "GEOM_SPHERE" +msgstr "Sphere" + +#Conical Face +msgid "GEOM_SURFCONE" +msgstr "Conical Face" + +#Cylindrical Face +msgid "GEOM_SURFCYLINDER" +msgstr "Cylindrical Face" + +#Spherical Face +msgid "GEOM_SURFSPHERE" +msgstr "Spherical Face" + +#Toroidal Face +msgid "GEOM_SURFTORUS" +msgstr "Toroidal Face" + +#Torus +msgid "GEOM_TORUS" +msgstr "Torus" + +#Vector +msgid "GEOM_VECTOR" +msgstr "Vector" + +#Vector U +msgid "GEOM_VECTOR_U" +msgstr "Vector U" + +#Vector V +msgid "GEOM_VECTOR_V" +msgstr "Vector V" + +#Vertex +msgid "GEOM_VERTEX" +msgstr "Vertex" + +#Wire +msgid "GEOM_WIRE" +msgstr "Wire" + +#Wire(s) +msgid "GEOM_WIRES" +msgstr "Wire(s)" + +#Wires +msgid "GEOM_WIREZ" +msgstr "Wires" + +msgid "GEOM_IMPORT" +msgstr "Imported_Shape" + +#Parameter +msgid "GEOM_PARAMETER" +msgstr "Parameter :" + +# +#============================================================================== +# + +#Min +msgid "GEOM_MIN" +msgstr "Min :" + +#Max +msgid "GEOM_MAX" +msgstr "Max :" + +#X +msgid "GEOM_X" +msgstr "X :" + +#Y +msgid "GEOM_Y" +msgstr "Y :" + +#Z +msgid "GEOM_Z" +msgstr "Z :" + +#DX +msgid "GEOM_DX" +msgstr "Dx :" + +#DY +msgid "GEOM_DY" +msgstr "Dy :" + +#DZ +msgid "GEOM_DZ" +msgstr "Dz :" + +#D1 +msgid "GEOM_D1" +msgstr "D1 :" + +#D2 +msgid "GEOM_D2" +msgstr "D2 :" + +# +#============================================================================== +# + +#: GeometryGUI.cxx +msgid "GEOM_STEP_TITLE" +msgstr "Step value for GUI constructions" + +#: GeometryGUI_ArcDlg.cxx:45 +msgid "GEOM_ARC_TITLE" +msgstr "Arc Construction" + +#: GeometryGUI_ArchimedeDlg.cxx:55 +msgid "GEOM_ARCHIMEDE_TITLE" +msgstr "Archimede Construction" + +#: GeometryGUI_BndBoxDlg.cxx:59 +msgid "GEOM_BNDBOX_TITLE" +msgstr "Bounding Box Informations" + +#: GeometryGUI_BndBoxDlg.cxx:82 +msgid "GEOM_BNDBOX_OBJDIM" +msgstr "Object And Its Dimensions" + +#: GeometryGUI_BoxDlg.cxx:50 +msgid "GEOM_BOX_TITLE" +msgstr "Box Construction" + +#: GeometryGUI_BoxDlg.cxx:50 +msgid "GEOM_BOX_OBJ" +msgstr "Dimensions At Origin" + +#: GeometryGUI_ChamferDlg.cxx:58 +msgid "GEOM_CHAMFER_TITLE" +msgstr "Chamfer Construction" + +#: GeometryGUI_ChamferDlg.cxx:58 +msgid "GEOM_CHAMFER_ALL" +msgstr "Chamfer On Whole Shape" + +#: GeometryGUI_ChamferDlg.cxx:58 +msgid "GEOM_CHAMFER_EDGES" +msgstr "Chamfer On Edges From Shape" + +#: GeometryGUI_ChamferDlg.cxx:58 +msgid "GEOM_CHAMFER_FACES" +msgstr "Chamfer On Faces From Shape" + +#: GeometryGUI_CircleDlg.cxx:48 +msgid "GEOM_CIRCLE_TITLE" +msgstr "Circle Construction" + +#: GeometryGUI_CenterMassDlg.cxx:77 +msgid "GEOM_CMASS_TITLE" +msgstr "Center Of Mass Construction" + +msgid "GEOM_PLANE_SIZE" +msgstr "Size of plane :" + +#: GeometryGUI_CommonDlg.cxx:47 +msgid "GEOM_COMMON_TITLE" +msgstr "BOOLEAN : Common Of Two Objects" + +#: GeometryGUI_CompoundDlg.cxx:44 +msgid "GEOM_COMPOUND_TITLE" +msgstr "Create A Compound" + +#: GeometryGUI_ConeDlg.cxx:49 +msgid "GEOM_CONE_TITLE" +msgstr "Cone Construction" + +#: GeometryGUI_CutDlg.cxx:48 +msgid "GEOM_CUT_TITLE" +msgstr "BOOLEAN : Cut Of Two Objects" +# +#: GeometryGUI_CylinderDlg.cxx:47 +msgid "GEOM_CYLINDER_TITLE" +msgstr "Cylinder Construction" + +#: GeometryGUI_CheckShape.cxx:60 +msgid "GEOM_CHECK_TITLE" +msgstr "Check Shape Informations" + +#: GeometryGUI_CheckShape.cxx:83 +msgid "GEOM_CHECK_INFOS" +msgstr "Object And Its Topological Informations" + +#: GeometryGUI_DistanceDlg.cxx:57 +msgid "GEOM_MINDIST_TITLE" +msgstr "Minimun Distance Between Two Objects" + +#: GeometryGUI_DistanceDlg.cxx:57 +msgid "GEOM_MINDIST_OBJ" +msgstr "Objects And Results" + +#: GeometryGUI_EdgeDlg.cxx:47 +msgid "GEOM_EDGE_TITLE" +msgstr "Create An Edge" + +#: GeometryGUI_FilletDlg.cxx:58 +msgid "GEOM_FILLET_TITLE" +msgstr "Fillet Construction" + +#: GeometryGUI_FilletDlg.cxx:58 +msgid "GEOM_FILLET_ALL" +msgstr "Fillet On Whole Shape" + +#: GeometryGUI_FilletDlg.cxx:58 +msgid "GEOM_FILLET_EDGES" +msgstr "Fillet On Edges From Shape" + +#: GeometryGUI_FilletDlg.cxx:58 +msgid "GEOM_FILLET_FACES" +msgstr "Fillet On Faces From Shape" + +#: GeometryGUI_FaceDlg.cxx:49 +msgid "GEOM_FACE_TITLE" +msgstr "Create A Face" + +#: GeometryGUI_FaceDlg.cxx:78 +msgid "GEOM_FACE_FFW" +msgstr "Face from a wire" + +#: GeometryGUI_FaceDlg.cxx:103 +msgid "GEOM_FACE_OPT" +msgstr "Try to create a planar face" + +#: GeometryGUI_FillingDlg.cxx:53 +msgid "GEOM_FILLING_TITLE" +msgstr "Filling Surface With Curves" + +#: GeometryGUI_FillingDlg.cxx:112 +msgid "GEOM_FILLING_ARG" +msgstr "Arguments And Parameters" + +#: GeometryGUI_FillingDlg.cxx:128 +msgid "GEOM_FILLING_MIN_DEG" +msgstr "Min deg" + +#: GeometryGUI_FillingDlg.cxx:142 +msgid "GEOM_FILLING_MAX_DEG" +msgstr "Max deg" + +#: GeometryGUI_FillingDlg.cxx:150 +msgid "GEOM_FILLING_TOL_2D" +msgstr "Tol. 2D :" + +#: GeometryGUI_FillingDlg.cxx:170 +msgid "GEOM_FILLING_COMPOUND" +msgstr "Curves Comp." + +#: GeometryGUI_FillingDlg.cxx:184 +msgid "GEOM_FILLING_TOL_3D" +msgstr "Tol. 3D :" + +#: GeometryGUI_FillingDlg.cxx:192 +msgid "GEOM_FILLING_NB_ITER" +msgstr "Nb. Iter :" + +#: GeometryGUI_FuseDlg.cxx:48 +msgid "GEOM_FUSE_TITLE" +msgstr "BOOLEAN : Fuse Two Objects" + +#: GeometryGUI_InertiaDlg.cxx:42 +msgid "GEOM_INERTIA_TITLE" +msgstr "Calculs Of Inertia" + +#: GeometryGUI_InertiaDlg.cxx:50 +msgid "GEOM_INERTIA_CONSTR" +msgstr "Matrix And Moments Of Inertia" + +#: GeometryGUI_InertiaDlg.cxx:100 +msgid "GEOM_INERTIA_I" +msgstr "%1:1 :" + +#: GeometryGUI_InertiaDlg.cxx:182 +msgid "GEOM_INERTIA_IXYZ" +msgstr "IX & IY & IZ :" + +#: GeometryGUI_LineDlg.cxx:50 +msgid "GEOM_LINE_TITLE" +msgstr "Line Construction" + +#: GeometryGUI_MaxToleranceDlg.cxx:53 +msgid "GEOM_TOLERANCE_TITLE" +msgstr "Maximum Tolerance" + +#: GeometryGUI_MaxToleranceDlg.cxx:84 +msgid "GEOM_TOLERANCE_CONSTR" +msgstr "Object And Its Tolerances" + +#: GeometryGUI_MaxToleranceDlg.cxx:121 +msgid "GEOM_TOLERANCE_FACE" +msgstr "Face :" + +#: GeometryGUI_MaxToleranceDlg.cxx:138 +msgid "GEOM_TOLERANCE_EDGE" +msgstr "Edge :" + +#: GeometryGUI_MaxToleranceDlg.cxx:155 +msgid "GEOM_TOLERANCE_VERTEX" +msgstr "Vertex :" + +#: GeometryGUI_MirrorDlg.cxx:52 +msgid "GEOM_MIRROR_TITLE" +msgstr "Mirror An Object" + +#: GeometryGUI_OrientationDlg.cxx:46 +msgid "GEOM_ORIENTATION_TITLE" +msgstr "Change Orientation" + +#: GeometryGUI_OrientationDlg.cxx:134 +msgid "GEOM_ORIENTATION_OPT" +msgstr "Reverse orientation with normal vectors simulation" + +#: GeometryGUI_PartitionDlg.cxx:45 +msgid "GEOM_PARTITION_TITLE" +msgstr "Partition Of Object With Tool" + +#: GeometryGUI_PartitionDlg.cxx:45 +msgid "GEOM_KEEP_OBJECT" +msgstr "Keep Object" + +#: GeometryGUI_PartitionDlg.cxx:45 +msgid "GEOM_PARTITION_ORIENTATION" +msgstr "Change Orientation" + +#: GeometryGUI_PartitionDlg.cxx:45 +msgid "SUPPRESS_RESULT" +msgstr "Suppress Result" + +msgid "GEOM_REMOVE_WEBS" +msgstr "Remove webs" + +msgid "GEOM_SET_MATERIALS" +msgstr "Set materials" + +#: OperationGUI_MaterialDlg.cxx:45 +msgid "GEOM_MATERIAL_TITLE" +msgstr "Define materials for Dominant Fuse" + +msgid "GEOM_MATERIAL_SHAPE" +msgstr "Shapes" + +msgid "GEOM_MATERIAL_MATERIAL" +msgstr "Material" + +msgid "GEOM_MATERIAL_ID" +msgstr "Material ID:" + +msgid "GEOM_MATERIAL_SET" +msgstr "<< Set" + +#: GeometryGUI_PipeDlg.cxx:47 +msgid "GEOM_PIPE_TITLE" +msgstr "Pipe Construction" + +#: GeometryGUI_PointDlg.cxx:52 +msgid "GEOM_POINT_TITLE" +msgstr "Point Construction" + +#: GeometryGUI_PlaneDlg.cxx:60 +msgid "GEOM_PLANE_TITLE" +msgstr "Plane Construction" + +#: GeometryGUI_PlaneDlg.cxx:172 +msgid "GEOM_PLANE_PVC" +msgstr "Point + Coordinate Vector" + +#: GeometryGUI_PlaneDlg.cxx:133 +msgid "GEOM_PLANE_PV" +msgstr "Point + Vector" + +#: GeometryGUI_PrismDlg.cxx:54 +msgid "GEOM_PRISM_TITLE" +msgstr "Prism Construction" + +#: GeometryGUI_PrismDlg.cxx:83 +msgid "GEOM_PRISM_BSV" +msgstr "Base Shape + Vector" + +#: GeometryGUI_PropertiesDlg.cxx:56 +msgid "GEOM_PROPERTIES_TITLE" +msgstr "Basic Properties Informations" + +#: GeometryGUI_PropertiesDlg.cxx:78 +msgid "GEOM_PROPERTIES_CONSTR" +msgstr "Object And Its Properties" + +#: GeometryGUI_PropertiesDlg.cxx:114 +msgid "GEOM_PROPERTIES_SURFACE" +msgstr "Surface is :" + +#: GeometryGUI_PropertiesDlg.cxx:120 +msgid "GEOM_PROPERTIES_VOLUME" +msgstr "Volume is :" + +#: GeometryGUI_RevolDlg.cxx:49 +msgid "GEOM_REVOLUTION_TITLE" +msgstr "Construction By Revolution" + +#: GeometryGUI_RotationDlg.cxx:51 +msgid "GEOM_ROTATION_TITLE" +msgstr "Rotation Of An Object" + +#: GeometryGUI_ScaleDlg.cxx:52 +msgid "GEOM_SCALE_TITLE" +msgstr "Scale An Object" + +#: GeometryGUI_PositionDlg.cxx:52 +msgid "GEOM_POSITION_TITLE" +msgstr "Modify the Location of an Object" + +#: GeometryGUI_PositionDlg.cxx:52 +msgid "GEOM_START_LCS" +msgstr "Start LCS" + +#: GeometryGUI_PositionDlg.cxx:52 +msgid "GEOM_END_LCS" +msgstr "End LCS" + +#: GeometryGUI_OffsetDlg.cxx:53 +msgid "GEOM_OFFSET_TITLE" +msgstr "Offset Surface" + +#: GeometryGUI_ScaleDlg.cxx:117 +msgid "GEOM_SCALE_FACTOR" +msgstr "Scale Factor :" + +#: GeometryGUI_SectionDlg.cxx:50 +msgid "GEOM_SECTION_TITLE" +msgstr "BOOLEAN : Section Of Two Objects" + +#: GeometryGUI_SewingDlg.cxx:48 +msgid "GEOM_SEWING_TITLE" +msgstr "Topological sewing" + +#: GeometryGUI_ShellDlg.cxx:53 +msgid "GEOM_SHELL_TITLE" +msgstr "Shell Construction" + +#: GeometryGUI_SolidDlg.cxx:74 +msgid "GEOM_SOLID_TITLE" +msgstr "Solid Construction" + +#: GeometryGUI_SphereDlg.cxx:50 +msgid "GEOM_SPHERE_TITLE" +msgstr "Sphere Construction" + +#: GeometryGUI_SphereDlg.cxx:113 +msgid "GEOM_SPHERE_CR" +msgstr "Center + Radius" + +#: GeometryGUI_SphereDlg.cxx:146 +msgid "GEOM_SPHERE_RO" +msgstr "Radius At Origin" + +#: GeometryGUI_SubShapeDlg.cxx:55 +msgid "GEOM_SUBSHAPE_TITLE" +msgstr "Sub Shapes Selection" + +#: GeometryGUI_SubShapeDlg.cxx:131 +msgid "GEOM_SUBSHAPE_TYPE" +msgstr "Sub Shapes Type :" + +#: GeometryGUI_SubShapeDlg.cxx:137 +msgid "GEOM_SUBSHAPE_SELECT" +msgstr "Select Sub Shapes" + +msgid "EntityGUI_SubShapeDlg::NO_SUBSHAPES_SELECTED" +msgstr "Please, select one or more sub-shapes" + +#: GeometryGUI_TorusDlg.cxx:51 +msgid "GEOM_TORUS_TITLE" +msgstr "Torus Construction" + +#: GeometryGUI_SuppressFacesDlg.cxx:103 +msgid "GEOM_SUPRESSFACE_TITLE" +msgstr "Suppress Faces In An Object" + +#: GeometryGUI_SuppressFacesDlg.cxx:164 +msgid "GEOM_SUPRESSFACE_SELECT" +msgstr "Select Faces To Suppress" + +#: GeometryGUI_TranslationDlg.cxx:78 +msgid "GEOM_TRANSLATION_COOR" +msgstr "Translation With Coordinates" + +msgid "GEOM_TRANSPARENCY_TITLE" +msgstr "Transparency" + +msgid "GEOM_TRANSPARENCY_OPAQUE" +msgstr "Opaque" + +msgid "GEOM_TRANSPARENCY_TRANSPARENT" +msgstr "Transparent" + +msgid "GEOM_SUPPRESSHOLE_TITLE" +msgstr "Suppress holes" + +msgid "GEOM_SUPPRESSHOLE_SELECTFACE" +msgstr "Select the face with hole" + +msgid "GEOM_SUPPRESSHOLE_SELECTWIRE" +msgstr "Select wire on face" + +msgid "GEOM_SUPPRESSHOLE_SELECTFACE_END" +msgstr "Select end face (if hole traversing)" + +msgid "GEOM_SUPPRESSHOLE_SELECTWIRE_END" +msgstr "Select end wire (if hole traversing)" + +msgid "GEOM_SUPPRESSHOLE_FACE_SHELL" +msgstr "Face or shell" + +msgid "GEOM_SUPPRESSHOLE_SELECT_HOLES_ON_FACE" +msgstr "Select hole(s) on the face" + +#: GeometryGUI_TranslationDlg.cxx:56 +msgid "GEOM_TRANSLATION_TITLE" +msgstr "Translation Of An Object" + +#: GeometryGUI_VectorDlg.cxx:54 +msgid "GEOM_VECTOR_TITLE" +msgstr "Vector Construction" + +#: GeometryGUI_WhatisDlg.cxx:63 +msgid "GEOM_WHATIS_TITLE" +msgstr "Whatis Informations" + +#: GeometryGUI_WhatisDlg.cxx:86 +msgid "GEOM_WHATIS_OBJECT" +msgstr "Object And Its Topological Informations" + +#: GeometryGUI_WireDlg.cxx:46 +msgid "GEOM_WIRE_TITLE" +msgstr "Create A Wire" + +#: GeometryGUI_WireDlg.cxx:103 +msgid "GEOM_WIRE_CONNECT" +msgstr "Wire creation from wires/edges connected" + +#: GeometryGUI_WorkingPlaneDlg.cxx:50 +msgid "GEOM_WPLANE_TITLE" +msgstr "Working Plane Selection" + +#: GeometryGUI_WorkingPlaneDlg.cxx:107 +msgid "GEOM_WPLANE_FACE" +msgstr "Plane Or Planar Face" + +#: GeometryGUI_WorkingPlaneDlg.cxx:107 +msgid "GEOM_WPLANE_VECTOR" +msgstr "Select 2 vectors" + +#: GeometryGUI_WorkingPlaneDlg.cxx:107 +msgid "GEOM_WPLANE_VX" +msgstr "Vector X" + +#: GeometryGUI_WorkingPlaneDlg.cxx:107 +msgid "GEOM_WPLANE_VZ" +msgstr "Vector Z" + +#: GeometryGUI_WorkingPlaneDlg.cxx:107 +msgid "GEOM_WPLANE_ORIGIN" +msgstr "Select a plane" + +#: GeometryGUI_WorkingPlaneDlg.cxx:107 +msgid "GEOM_WPLANE_OYZ" +msgstr "OYZ" + +#: GeometryGUI_WorkingPlaneDlg.cxx:107 +msgid "GEOM_WPLANE_OZX" +msgstr "OZX" + +#: GeometryGUI_WorkingPlaneDlg.cxx:107 +msgid "GEOM_WPLANE_OXY" +msgstr "OXY" + +#: GeometryGUI_multiTranslationDlg.cxx:107 +msgid "GEOM_MULTITRANSLATION_TITLE" +msgstr "Multi-Translation" + +#: GeometryGUI_multiTranslationDlg.cxx:107 +msgid "GEOM_MULTITRANSLATION_SIMPLE" +msgstr "Multi Translation Simple" + +#: GeometryGUI_multiTranslationDlg.cxx:107 +msgid "GEOM_MULTITRANSLATION_DOUBLE" +msgstr "Multi Translation Double" + +#: GeometryGUI_multiRotationDlg.cxx:107 +msgid "GEOM_MULTIROTATION_TITLE" +msgstr "Multi-Rotation" + +#: GeometryGUI_multiRotationDlg.cxx:107 +msgid "GEOM_MULTIROTATION_SIMPLE" +msgstr "Multi Rotation Simple" + +#: GeometryGUI_multiRotationDlg.cxx:107 +msgid "GEOM_MULTIROTATION_DOUBLE" +msgstr "Multi Rotation Double" + +msgid "GEOM_PARAM_POINT" +msgstr "Parametric point" + +msgid "GEOM_REF_POINT" +msgstr "Point with reference" + +# +#============================================================================== +# + +#: GeometryGUI.cxx:4613 +msgid "GEOM_MEN_WIREFRAME" +msgstr "Wireframe" + +#: GeometryGUI.cxx:4613 +msgid "GEOM_MEN_SHADING" +msgstr "\nShading" + +msgid "GEOM_RECONSTRUCTION_LIMIT" +msgstr "Reconstruction Limit" + +msgid "GEOM_SUPPRESS_RESULT" +msgstr "Suppress Result" + +msgid "GEOM_SUPPRESS_RESULT_INSIDE" +msgstr "Inside" + +msgid "GEOM_SUPPRESS_RESULT_OUTSIDE" +msgstr "Outside" + +msgid "GEOM_RECONSTRUCTION_LIMIT_SHAPE" +msgstr "Shape" +msgid "GEOM_RECONSTRUCTION_LIMIT_SOLID" +msgstr "Solid" +msgid "GEOM_RECONSTRUCTION_LIMIT_SHELL" +msgstr "Shell" +msgid "GEOM_RECONSTRUCTION_LIMIT_FACE" +msgstr "Face" +msgid "GEOM_RECONSTRUCTION_LIMIT_WIRE" +msgstr "Wire" +msgid "GEOM_RECONSTRUCTION_LIMIT_EDGE" +msgstr "Edge" +msgid "GEOM_RECONSTRUCTION_LIMIT_VERTEX" +msgstr "Vertex" + +msgid "GEOM_SPLINE_TITLE" +msgstr "Spline Construction" +msgid "GEOM_SPLINE" +msgstr "Spline" +msgid "GEOM_BEZIER" +msgstr "Bezier" +msgid "GEOM_INTERPOL" +msgstr "Interpolation" + +# +#============================================================================== +# + +msgid "GEOM_SKETCHER_EL" +msgstr "Element Type" + +msgid "GEOM_BUT_CLOSE_SKETCH" +msgstr "Sketch Closure" + +msgid "GEOM_BUT_END_SKETCH" +msgstr "Sketch Validation" + +msgid "GEOM_SKETCHER_TITLE" +msgstr "Sketch Construction" + +msgid "GEOM_SKETCHER_POINT" +msgstr "Point" + +msgid "GEOM_SKETCHER_SEGMENT" +msgstr "Segment" + +msgid "GEOM_SKETCHER_ARC" +msgstr "Arc" + +msgid "GEOM_SKETCHER_DIR" +msgstr "Direction" + +msgid "GEOM_SKETCHER_POINT2" +msgstr "Point :" + +msgid "GEOM_SKETCHER_DEST" +msgstr "Destination" + +msgid "GEOM_SKETCHER_ABS" +msgstr "Absolute" + +msgid "GEOM_SKETCHER_REL" +msgstr "Relative" + +msgid "GEOM_SKETCHER_SEL" +msgstr "Selection" + +msgid "GEOM_SKETCHER_ANGLE" +msgstr "Angle" + +msgid "GEOM_SKETCHER_PER" +msgstr "Perpendicular" + +msgid "GEOM_SKETCHER_TAN" +msgstr "Tangent" + +msgid "GEOM_SKETCHER_VXVY" +msgstr "VX-VY" + +msgid "GEOM_SKETCHER_LENGTH" +msgstr "Length" + +msgid "GEOM_SKETCHER_X" +msgstr "X" + +msgid "GEOM_SKETCHER_Y" +msgstr "Y" + +msgid "GEOM_SKETCHER_X2" +msgstr "X :" + +msgid "GEOM_SKETCHER_Y2" +msgstr "Y :" + +msgid "GEOM_SKETCHER_X3" +msgstr "Abs. X :" + +msgid "GEOM_SKETCHER_Y3" +msgstr "Abs. Y :" + +msgid "GEOM_SKETCHER_DX2" +msgstr "DX :" + +msgid "GEOM_SKETCHER_DY2" +msgstr "DY :" + +msgid "GEOM_SKETCHER_VX2" +msgstr "VX :" + +msgid "GEOM_SKETCHER_VY2" +msgstr "VY :" + +msgid "GEOM_SKETCHER_LENGTH2" +msgstr "Length :" + +msgid "GEOM_SKETCHER_ANGLE2" +msgstr "Angle :" + +msgid "GEOM_SKETCHER_RADIUS2" +msgstr "Radius :" + +msgid "GEOM_SKETCHER_UNDO" +msgstr "Undo" + +msgid "GEOM_SKETCHER_APPLY" +msgstr "Apply" + +msgid "GEOM_SKETCHER_VALUES" +msgstr "Values" + +msgid "GEOM_SKETCHER_TYPE" +msgstr "Type" + +msgid "EntityGUI_SketcherDlg::CANNOT_CLOSE" +msgstr "It is impossible to close sketch\nNumber of sketch points too small" + +msgid "GEOM_FILLET_ABORT" +msgstr "Fillet can't be computed with radius %1" + +msgid "GEOM_CHAMFER_ABORT" +msgstr "Chamfer can't be computed with %1 and %2" + +msgid "GEOM_3_POINTS" +msgstr "3 points" + +msgid "GEOM_POINT1" +msgstr "Point 1" + +msgid "GEOM_POINT2" +msgstr "Point 2" + +msgid "GEOM_POINT3" +msgstr "Point 3" + +msgid "GEOM_CREATE_COPY" +msgstr "Create a copy" + +msgid "GEOM_CREATE_SINGLE_SOLID" +msgstr "Create a single solid" + +msgid "GEOM_ERROR" +msgstr "Error" + +msgid "GEOM_ERROR_STATUS" +msgstr "Operation status" + +msgid "GEOM_ELLIPSE_ERROR_1" +msgstr "Error creating ellipse. Reason: minor radius is greater than major radius." + +msgid "GEOM_CURVE" +msgstr "Curve" + +msgid "GEOM_POLYLINE" +msgstr "Polyline" + +msgid "GEOM_NODES" +msgstr "Nodes" + +msgid "GEOM_CURVE_TITLE" +msgstr "Curve Construction" + +# ShapeProcessDlg.cxx +msgid "GEOM_SHAPEPROCESS_TITLE" +msgstr "Shape Processing" + +msgid "GEOM_SHAPES" +msgstr "Shapes" + +msgid "GEOM_SELECTED_OBJECTS" +msgstr "Selected objects" + +msgid "GEOM_OPERATIONS" +msgstr "Operations" + +msgid "GEOM_PARAMETERS" +msgstr "Parameters" + +msgid "GEOM_FixShape" +msgstr "FixShape" + +msgid "GEOM_FixFaceSize" +msgstr "FixFaceSize" + +msgid "GEOM_DropSmallEdges" +msgstr "DropSmallEdges" + +msgid "GEOM_SplitAngle" +msgstr "SplitAngle" + +msgid "GEOM_SplitClosedFaces" +msgstr "SplitClosedFaces" + +msgid "GEOM_SplitContinuity" +msgstr "SplitContinuity" + +msgid "GEOM_BSplineRestriction" +msgstr "BSplineRestriction" + +msgid "GEOM_ToBezier" +msgstr "ToBezier" + +msgid "GEOM_SameParameter" +msgstr "SameParameter" + +msgid "GEOM_3D_TOLERANCE" +msgstr "3D tolerance" + +msgid "GEOM_MAX_3D_TOLERANCE" +msgstr "Max 3D tolerance" + +msgid "GEOM_MAX_TOLERANCE" +msgstr "Max tolerance" + +msgid "GEOM_ANGLE_1" +msgstr "Angle" + +msgid "GEOM_NUM_SPLIT_POINTS" +msgstr "Number of splitting points" + +msgid "GEOM_SURFACE_CONTINUTY" +msgstr "Surface continuty" + +msgid "GEOM_CURVE_CONTINUTY" +msgstr "Curve continuty" + +msgid "GEOM_SURFACE_MODE" +msgstr "Surface mode" + +msgid "GEOM_3D_CURVE_MODE" +msgstr "3D curve mode" + +msgid "GEOM_2D_CURVE_MODE" +msgstr "2D curve mode" + +msgid "GEOM_2D_TOLERANCE" +msgstr "2D tolerance" + +msgid "GEOM_REQUIRED_DEGREE" +msgstr "Required degree" + +msgid "GEOM_REQUIRED_NUM_SEGMENTS" +msgstr "Required number of segments" + +msgid "GEOM_3D_CONTINUTY" +msgstr "3D continuty" + +msgid "GEOM_2D_CONTINUTY" +msgstr "2D continuty" + +msgid "GEOM_CLOSECONTOUR_TITLE" +msgstr "Close contour" + +msgid "GEOM_ERR_LIB_NOT_FOUND" +msgstr "GUI library corresponding to the user action can not be found or loaded" + +msgid "OperationGUI_ChamferDlg::FACE_1" +msgstr "Face 1" + +msgid "OperationGUI_ChamferDlg::FACE_2" +msgstr "Face 2" + +msgid "OperationGUI_ChamferDlg::SELECTED_FACES" +msgstr "Selected faces" + +msgid "OperationGUI_ChamferDlg::D" +msgstr "D" + +msgid "OperationGUI_FilletDlg::SELECTED_EDGES" +msgstr "Selected edges" + +msgid "OperationGUI_FilletDlg::SELECTED_FACES" +msgstr "Selected faces" + +msgid "GEOM_REMOVE_INTERNAL_WIRES_TITLE" +msgstr "Suppress internal wires" + +msgid "GEOM_INTERNAL_WIRES" +msgstr "Internal wires" + +msgid "GEOM_SELECTED_FACE" +msgstr "Selected face" + +msgid "GEOM_REMOVE_ALL_INT_WIRES" +msgstr "Remove all internal wires" + +msgid "GEOM_REMOVE_HOLES_TITLE" +msgstr "Suppress holes" + +msgid "GEOM_SELECTED_SHAPE" +msgstr "Selected shape" + +msgid "GEOM_REMOVE_ALL_HOLES" +msgstr "Remove all holes" + +msgid "GEOM_HOLES" +msgstr "Holes" + +msgid "GEOM_WIRES_TO_REMOVE" +msgstr "Wires to remove" + +msgid "GEOM_DETECT" +msgstr "Detect" + +msgid "GEOM_FREE_BOUNDARIES" +msgstr "Free boundaries" + +msgid "GEOM_BY_PARAMETER" +msgstr "By parameter" + +msgid "GEOM_BY_LENGTH" +msgstr "By length" + +msgid "GEOM_DIVIDE_EDGE_TITLE" +msgstr "Addition of point" + +msgid "GEOM_ADD_POINT" +msgstr "Add point" + +msgid "GEOM_VALUE" +msgstr "Value" + +msgid "GEOM_MARKER_TITLE" +msgstr "Create marker" + +msgid "GEOM_MARKER" +msgstr "Marker" + +msgid "GEOM_TRIHEDRON" +msgstr "Trihedron" + +msgid "GEOM_FREE_BOUNDS_MSG" +msgstr "Number of free boundaries detected: %1 (%2 closed, %3 open)" + +msgid "GEOM_FREE_BOUNDS_ERROR" +msgstr "Object is not selected" + +msgid "GEOM_FREE_BOUNDS_TLT" +msgstr "Free boundary detection" + +msgid "RepairGUI_FreeBoundDlg::CAPTION" +msgstr "Check free boundaries" + +msgid "RepairGUI_FreeBoundDlg::FREE_BOUND" +msgstr "Free boundaries" + +msgid "RepairGUI_FreeBoundDlg::NUMBER_CLOSED" +msgstr "Number of closed free boundaries: " + +msgid "RepairGUI_FreeBoundDlg::NUMBER_OPEN" +msgstr "Number of open free boundaries: " + +msgid "RepairGUI_ShapeProcessDlg::ERROR_NO_OPERATORS" +msgstr "Please, select at least one Shape Process operation to proceed." + +msgid "RepairGUI_ShapeProcessDlg::ERROR_NO_OBJECTS" +msgstr "Please, select a geometrical object for Shape Processing." + +msgid "MeasureGUI_PointDlg::POINT" +msgstr "Point" + +msgid "MeasureGUI_PointDlg::X" +msgstr "X" + +msgid "MeasureGUI_PointDlg::Y" +msgstr "Y" + +msgid "MeasureGUI_PointDlg::Z" +msgstr "Z" + +msgid "MeasureGUI_PointDlg::CAPTION" +msgstr "Point Coordinates" + +msgid "MeasureGUI_PointDlg::COORDINATES" +msgstr "Point and its coordinates" + +msgid "GroupGUI_GroupDlg::CREATE_GROUP_TITLE" +msgstr "Create Group" + +msgid "GroupGUI_GroupDlg::EDIT_GROUP_TITLE" +msgstr "Edit Group" + +msgid "GroupGUI_GroupDlg::SHAPE_TYPE" +msgstr "Shape Type" + +msgid "GroupGUI_GroupDlg::GROUP_NAME" +msgstr "Group Name" + +msgid "GroupGUI_GroupDlg::MAIN_SUB_SHAPES" +msgstr "Main Shape And Sub-Shapes" + +msgid "GroupGUI_GroupDlg::MAIN_SHAPE" +msgstr "Main Shape" + +msgid "GroupGUI_GroupDlg::SELECT_SUB_SHAPES" +msgstr "Select Sub-Shapes" + +msgid "GroupGUI_GroupDlg::SELECT_ALL" +msgstr "Select All" + +msgid "GroupGUI_GroupDlg::ADD" +msgstr "Add" + +msgid "GroupGUI_GroupDlg::REMOVE" +msgstr "Remove" + +msgid "GroupGUI_GroupDlg::GROUP_PREFIX" +msgstr "Group" + +msgid "GroupGUI_GroupDlg::EMPTY_NAME" +msgstr "Please, specify a non-empty group name" + +msgid "GroupGUI_GroupDlg::NO_MAIN_OBJ" +msgstr "Please, select a main shape" + +msgid "GroupGUI_GroupDlg::NO_GROUP" +msgstr "Please, select a group to edit" + +msgid "GroupGUI_GroupDlg::EMPTY_LIST" +msgstr "Please, select one or more sub-shapes to put into the group" + +msgid "GroupGUI::NO_GROUP" +msgstr "Please, select a group to edit" + +msgid "_S_" +msgstr "(s)" + +### BlocksGUI ### + +msgid "WRN_NOT_IMPLEMENTED" +msgstr "Sorry, this functionality is not yet implemented" + +### BlocksGUI_TrsfDlg ### + +msgid "BlocksGUI_TrsfDlg::FACE_1" +msgstr "Face 1" + +msgid "BlocksGUI_TrsfDlg::FACE_2" +msgstr "Face 2" + +msgid "BlocksGUI_TrsfDlg::FACE_1U" +msgstr "Face 1 U" + +msgid "BlocksGUI_TrsfDlg::FACE_2U" +msgstr "Face 2 U" + +msgid "BlocksGUI_TrsfDlg::FACE_1V" +msgstr "Face 1 V" + +msgid "BlocksGUI_TrsfDlg::FACE_2V" +msgstr "Face 2 V" + +msgid "GEOM_BLOCK_MULTITRSF_TITLE" +msgstr "Block Multi-Transformation" + +msgid "GEOM_BLOCK_MULTITRSF" +msgstr "Block Multi-Transformation" + +msgid "GEOM_BLOCK_MULTITRSF_SIMPLE" +msgstr "Multi-Transformation Simple" + +msgid "GEOM_BLOCK_MULTITRSF_DOUBLE" +msgstr "Multi-Transformation Double" + +### BlocksGUI_QuadFaceDlg ### + +msgid "BlocksGUI_QuadFaceDlg::VERTEX_1" +msgstr "Vertex 1" + +msgid "BlocksGUI_QuadFaceDlg::VERTEX_2" +msgstr "Vertex 2" + +msgid "BlocksGUI_QuadFaceDlg::VERTEX_3" +msgstr "Vertex 3" + +msgid "BlocksGUI_QuadFaceDlg::VERTEX_4" +msgstr "Vertex 4" + +msgid "BlocksGUI_QuadFaceDlg::EDGE_1" +msgstr "Edge 1" + +msgid "BlocksGUI_QuadFaceDlg::EDGE_2" +msgstr "Edge 2" + +msgid "BlocksGUI_QuadFaceDlg::EDGE_3" +msgstr "Edge 3" + +msgid "BlocksGUI_QuadFaceDlg::EDGE_4" +msgstr "Edge 4" + +msgid "GEOM_QUAD_FACE_TITLE" +msgstr "Quadrangle Face Construction" + +msgid "GEOM_QUAD_FACE" +msgstr "Quadrangle Face" + +### BlocksGUI_BlockDlg ### + +msgid "BlocksGUI_BlockDlg::FACE_1" +msgstr "Face 1" + +msgid "BlocksGUI_BlockDlg::FACE_2" +msgstr "Face 2" + +msgid "BlocksGUI_BlockDlg::FACE_3" +msgstr "Face 3" + +msgid "BlocksGUI_BlockDlg::FACE_4" +msgstr "Face 4" + +msgid "BlocksGUI_BlockDlg::FACE_5" +msgstr "Face 5" + +msgid "BlocksGUI_BlockDlg::FACE_6" +msgstr "Face 6" + +msgid "GEOM_BLOCK_TITLE" +msgstr "Hexahedral Solid Construction" + +msgid "GEOM_BLOCK" +msgstr "Hexahedral Solid" + +#============================================================================== + +msgid "BasicGUI_MarkerDlg::CAPTION" +msgstr "Local CS Construction" + +msgid "BasicGUI_MarkerDlg::LOCALCS" +msgstr "Local coordinate system" + +msgid "BasicGUI_MarkerDlg::ORIGIN" +msgstr "Coordinates of origin" + +msgid "BasicGUI_MarkerDlg::XDIR" +msgstr "X axis direction" + +msgid "BasicGUI_MarkerDlg::YDIR" +msgstr "Y axis direction" + +msgid "BasicGUI_MarkerDlg::DX" +msgstr "Dx" + +msgid "BasicGUI_MarkerDlg::DY" +msgstr "Dy" + +msgid "BasicGUI_MarkerDlg::DZ" +msgstr "Dz" + +msgid "BasicGUI_MarkerDlg::LCS_NAME" +msgstr "LocalCS" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +======= + +### BlocksGUI_ExplodeDlg ### + +msgid "BlocksGUI_ExplodeDlg::NB_FACES_MIN" +msgstr "Min. nb. faces" + +msgid "BlocksGUI_ExplodeDlg::NB_FACES_MAX" +msgstr "Max. nb. faces" + +msgid "GEOM_BLOCK_EXPLODE_TITLE" +msgstr "Sub Blocks Selection" + +msgid "GEOM_BLOCK_EXPLODE" +msgstr "Sub Blocks" + +msgid "GEOM_NB_BLOCKS_NO_OTHERS" +msgstr "There are %1 specified blocks and NO other solids" + +msgid "GEOM_NB_BLOCKS_SOME_OTHERS" +msgstr "There are %1 specified blocks and some other solids" + +msgid "ShHealOper_NotError_msg" +msgstr "Shape Healing algorithm has done no modification of the original shape" + +msgid "ShHealOper_InvalidParameters_msg" +msgstr "Incorrect parameters for Shape Healing algorithm" + +msgid "ShHealOper_ErrorExecution_msg" +msgstr "Shape Healing algorithm failed" + +msgid "GEOM_GLUE_TITLE" +msgstr "Glue faces" + +msgid "GEOM_GLUE" +msgstr "Glue" + +### New object names for RepairGUI ### +msgid "SEWING_NEW_OBJ_NAME" +msgstr "Sewing" + +msgid "DEVIDE_EDGE_NEW_OBJECT_NAME" +msgstr "NewObject" + +msgid "CLOSE_CONTOUR_NEW_OBJ_NAME" +msgstr "CloseContour" + +msgid "REMOVE_HOLES_NEW_OBJ_NAME" +msgstr "SupressHoles" + +msgid "GLUE_NEW_OBJ_NAME" +msgstr "Glue" + +msgid "REMOVE_INT_WIRES_NEW_OBJ_NAME" +msgstr "RemoveIntWires" + +msgid "PROCESS_SHAPE_NEW_OBJ_NAME" +msgstr "ProcessShape" + +msgid "SUPRESS_FACE_NEW_OBJ_NAME" +msgstr "SupressFaces" +### diff --git a/src/GEOMGUI/GEOM_msg_fr.po b/src/GEOMGUI/GEOM_msg_fr.po new file mode 100644 index 000000000..e56d06af5 --- /dev/null +++ b/src/GEOMGUI/GEOM_msg_fr.po @@ -0,0 +1,1350 @@ +# This is a Qt message file in .po format. Each msgid starts with +# a scope. This scope should *NOT* be translated - eg. translating +# from French to English, "Foo::Bar" would be translated to "Pub", +# not "Foo::Pub". +msgid "" +msgstr "" +"Project-Id-Version: PROJECT VERSION\n" +"POT-Creation-Date: 2002-03-19 09:35:48 AM CET\n" +"PO-Revision-Date: YYYY-MM-DD\n" +"Last-Translator: FULLNAME \n" +"Content-Type: text/plain; charset=iso-8859-1\n" + +# +#============================================================================== +# + +#Button Apply +msgid "GEOM_BUT_APPLY" +msgstr "&Appliquer" + +#Button Close +msgid "GEOM_BUT_CLOSE" +msgstr "&Fermer" + +#Button Cancel +msgid "GEOM_BUT_CANCEL" +msgstr "&Annuler" + +#Button Ok +msgid "GEOM_BUT_OK" +msgstr "&Ok" + +#Button Yes +msgid "GEOM_BUT_YES" +msgstr "&Oui" + +#Button No +msgid "GEOM_BUT_NO" +msgstr "&Non" + +#Button Help +msgid "GEOM_BUT_HELP" +msgstr "&Aide" + + +#Button Explode +msgid "GEOM_BUT_EXPLODE" +msgstr "&Exploser" + +# +#============================================================================== +# + +#: GeometryGUI.cxx:563 +msgid "GEOM_INF_LOADED" +msgstr "Le fichier %1 est chargé." + +# +#============================================================================== +# + +#: GeometryGUI.cxx:3069 +msgid "GEOM_PRP_COMMAND" +msgstr "Pas de commande associée à l'id = %1." + +#: GeometryGUI.cxx:4977 +msgid "GEOM_PRP_ABORT" +msgstr "L'opération a echoué" + +#: GeometryGUI.cxx:5058 +msgid "GEOM_PRP_DONE" +msgstr "Opération effectuée" + +#: GeometryGUI.cxx:3717 +msgid "GEOM_PRP_LOADING" +msgstr "Chargement de %1 ..." + +#: GeometryGUI.cxx:1412 +msgid "GEOM_PRP_NULLSHAPE" +msgstr "Erreur, objet inconsistant ou inapproprié !" + +#: GeometryGUI.cxx:5072 +msgid "GEOM_PRP_READY" +msgstr "Prêt..." + +#: GeometryGUI.cxx:1690 +msgid "GEOM_PRP_SELECT_SUBSHAPES" +msgstr "Selection de sous objets" + +msgid "GEOM_CONFIRM" +msgstr "Confirmer cette operation" + +msgid "GEOM_CONFIRM_INFO" +msgstr "L'objet contient %1 sous objets" + + +msgid "GEOM_PRP_NOT_FOR_VTK_VIEWER" +msgstr "Non permis dans viewer VTK" + +#: GeometryGUI.cxx:1690 +msgid "GEOM_PRP_SHAPE_IN_STUDY" +msgstr "La shape principale doit etre avant dans l'etude" + +#: GeometryGUI.cxx:1690 +msgid "GEOM_PRP_SELECT_EDGE" +msgstr "Selectionner les edges et clicker sur Apply" + +#: GeometryGUI.cxx:1690 +msgid "GEOM_PRP_SELECT_FACE" +msgstr "Select les faces a supprimer et clicker sur Ok/Apply" + +#: GeometryGUI.cxx:1690 +msgid "GEOM_PRP_SELECT_FIRST" +msgstr "Selectionner la shape principale en premier" + +#: GeometryGUI.cxx:1690 +msgid "GEOM_PRP_MIN_DIST" +msgstr "Min Distance non calculer" + +# +#============================================================================== +# + +#: GeometryGUI.cxx:3698 +msgid "GEOM_MEN_ALL_FILES" +msgstr "Tous fichiers ( * )" + +#: GeometryGUI.cxx:4389 +msgid "GEOM_MEN_ANGLE" +msgstr "Angle :" + +#: GeometryGUI.cxx:3941 +msgid "GEOM_MEN_COMPONENT" +msgstr "Géometrie" + +#: GeometryGUI.cxx:4389 +msgid "GEOM_MEN_ENTER_ANGLE" +msgstr "Saisir un angle en degrés" + +#: GeometryGUI.cxx:3758 +msgid "GEOM_MEN_EXPORT" +msgstr "Exporter" + +#: GeometryGUI.cxx:3648 +msgid "GEOM_MEN_IMPORT" +msgstr "Importer" + +#: GeometryGUI.cxx:3763 +msgid "GEOM_MEN_LOAD_SCRIPT" +msgstr "Fichiers PYTHON ( *.py )" + +#: GeometryGUI.cxx:2931 +msgid "GEOM_MEN_ISOS" +msgstr "Choisir un nombre d'isos" + +#: GeometryGUI.cxx:4278 +msgid "GEOM_MEN_POPUP_NAME" +msgstr "%1 Objets" + +#: GeometryGUI.cxx:4414 +msgid "GEOM_MEN_SKETCHER_X" +msgstr "Saisir une longueur pour fixer X" + +#: GeometryGUI.cxx:4438 +msgid "GEOM_MEN_SKETCHER_Y" +msgstr "Saisir une longueur pour fixer Y" + +#: GeometryGUI.cxx:2898 +msgid "GEOM_MEN_TRANSPARENCY" +msgstr "Transparence" + +#: GeometryGUI.cxx:4413 +msgid "GEOM_MEN_X" +msgstr "X :" + +#: GeometryGUI.cxx:4437 +msgid "GEOM_MEN_Y" +msgstr "Y :" + +#: GeometryGUI_NbIsosDlg.cxx:36 +msgid "GEOM_MEN_ISOU" +msgstr "Isos u :" + +#: GeometryGUI_NbIsosDlg.cxx:53 +msgid "GEOM_MEN_ISOV" +msgstr "Isos v :" + +#: GeometryGUI_TransparencyDlg.cxx:31 +msgid "GEOM_MEN_TRANSPARENCY_LABEL" +msgstr "Transparence :" + +msgid "GEOM_MEN_STEP_LABEL" +msgstr "Increment" + +msgid "GEOM_IDENTICAL_NAMES_SELECT_BY_MOUSE" +msgstr "Noms identiques : selectionner avec la souris !" + +msgid "GEOM_NAME_INCORRECT" +msgstr "Le nom saisi n'existe pas" + + + +# +#============================================================================== +# + +#: GeometryGUI.cxx:892 +msgid "GEOM_WRN_RADIUS_NULL" +msgstr "Le rayon est nul" + +#: GeometryGUI.cxx:3854 +msgid "GEOM_WRN_WARNING" +msgstr "Avertissement" + +#: GeometryGUI.cxx:3854 +msgid "GEOM_REALLY_DELETE" +msgstr "Voulez-vous supprimer l'object(s) ?" + +# +#============================================================================== +# + +#Object +msgid "GEOM_OBJECT" +msgstr "Objet" + +#Main object +msgid "GEOM_MAIN_OBJECT" +msgstr "Objet Principal" + +#Tool object +msgid "GEOM_TOOL_OBJECT" +msgstr "Objet Outil" + +#Base Object +msgid "GEOM_BASE_OBJECT" +msgstr "Objet De Base" + +#Path Object +msgid "GEOM_PATH_OBJECT" +msgstr "Objet Chemin" + +#Objects +msgid "GEOM_OBJECTS" +msgstr "Objets" + +#Object i +msgid "GEOM_OBJECT_I" +msgstr "Objet %1" + +#Object and result +msgid "GEOM_OBJECT_RESULT" +msgstr "Objet Et Résultat" + +#Point +msgid "GEOM_POINT" +msgstr "Point" + +#Base point +msgid "GEOM_BASE_POINT" +msgstr "Point De Base" + +#Center Point +msgid "GEOM_CENTER_POINT" +msgstr "Point Centre" + +#Diagonal Points +msgid "GEOM_DIAGONAL_POINTS" +msgstr "Points Diagonaux" + +#Central Point +msgid "GEOM_CENTRAL_POINT" +msgstr "Point Central" + +#Points +msgid "GEOM_POINTS" +msgstr "Points" + +#Point i +msgid "GEOM_POINT_I" +msgstr "Point %1" + +#Arguments +msgid "GEOM_ARGUMENTS" +msgstr "Arguments" + +#Center +msgid "GEOM_CENTER" +msgstr "Centre" + +#Radius +msgid "GEOM_RADIUS" +msgstr "Rayon" + +#Radius i +msgid "GEOM_RADIUS_I" +msgstr "Rayon %1" + +#Height +msgid "GEOM_HEIGHT" +msgstr "Hauteur" + +#Length +msgid "GEOM_LENGTH" +msgstr "Longueur :" + +#Weight +msgid "GEOM_WEIGHT" +msgstr "poids" + +#Coordinates +msgid "GEOM_COORDINATES" +msgstr "Coordonnées" + +#Coor. +msgid "GEOM_COOR" +msgstr "Coord. :" + +#Reverse +msgid "GEOM_REVERSE" +msgstr "Renverser" + +#Reverse U +msgid "GEOM_REVERSE_U" +msgstr "Renverser U" + +#Reverse V +msgid "GEOM_REVERSE_V" +msgstr "Reverser V" + +#Angle +msgid "GEOM_ANGLE" +msgstr "Angle :" + +#Axis +msgid "GEOM_AXIS" +msgstr "Axe" + +#Matrix +msgid "GEOM_MATRIX" +msgstr "Matrice :" + +#Vector Length +msgid "GEOM_VECTOR_LENGTH" +msgstr "Longueur Du Vecteur :" + +#Reverse Vector +msgid "GEOM_REVERSE_VECTOR" +msgstr "Renverser Le Vecteur" + +#Point Mirror +msgid "GEOM_POINT_MIRROR" +msgstr "Point Miroir" + +#Axe Mirror +msgid "GEOM_AXE_MIRROR" +msgstr "Axe Miroir" + +#Plane Mirror +msgid "GEOM_PLANE_MIRROR" +msgstr "Plan Miroir" + +#Face Selection +msgid "GEOM_FACE_SELECTION" +msgstr "Selection de Face" + +#Base +msgid "GEOM_BASE" +msgstr "Base" + +#Water Density +msgid "GEOM_WATER_DENSITY" +msgstr "Densité de l'eau :" + +#Meshing Deflection +msgid "GEOM_MESHING_DEFLECTION" +msgstr "Déflection Du Maillage :" + +#Dimensions +msgid "GEOM_DIMENSIONS" +msgstr "Dimensions" + +#Precision +msgid "GEOM_PRECISION" +msgstr "Précision :" + +#Selection +msgid "GEOM_SELECTION" +msgstr "Sélection" + +#Nb. Times +msgid "GEOM_NB_TIMES" +msgstr "Nb. Fois :" + +#Nb. Times U +msgid "GEOM_NB_TIMES_U" +msgstr "Nb. Fois U :" + +#Nb. Times V +msgid "GEOM_NB_TIMES_V" +msgstr "Nb. Fois V :" + +#Step +msgid "GEOM_STEP" +msgstr "Pas :" + +#Step V +msgid "GEOM_STEP_V" +msgstr "Pas V :" + +#Step U +msgid "GEOM_STEP_U" +msgstr "Pas U :" + +# +#============================================================================== +# + +#Partition +msgid "GEOM_PARTITION" +msgstr "Partition" + +#Half-space partition +msgid "GEOM_PARTITION_HALFSPACE" +msgstr "Half-space partition" + +#Tolerance +msgid "GEOM_TOLERANCE" +msgstr "Tolérance" + +#Orientation +msgid "GEOM_ORIENTATION" +msgstr "Orientation" + +#Pipe +msgid "GEOM_PIPE" +msgstr "Pipe" + +#Revolution +msgid "GEOM_REVOLUTION" +msgstr "Révolution" + +#Rotation +msgid "GEOM_ROTATION" +msgstr "Rotation" + +#Archimede +msgid "GEOM_ARCHIMEDE" +msgstr "Archimède" + +#Common +msgid "GEOM_COMMON" +msgstr "Joindre" + +#Cut +msgid "GEOM_CUT" +msgstr "Couper" + +#Distance +msgid "GEOM_DISTANCE" +msgstr "Distance" + +#Filling +msgid "GEOM_FILLING" +msgstr "Surface Par Courbes" + +#Fuse +msgid "GEOM_FUSE" +msgstr "Fusionner" + +#Scale +msgid "GEOM_SCALE" +msgstr "Echelle" + +#Section +msgid "GEOM_SECTION" +msgstr "Section" + +#Sewing +msgid "GEOM_SEWING" +msgstr "Coudre" + +#Translation +msgid "GEOM_TRANSLATION" +msgstr "Translation" + +#Working Plane +msgid "GEOM_WPLANE" +msgstr "Plan de Travail" + +#Mirror +msgid "GEOM_MIRROR" +msgstr "Miroir" + +#Prism +msgid "GEOM_PRISM" +msgstr "Extrusion" + +#Sub Shapes +msgid "GEOM_SUB_SHAPE" +msgstr "Sous Shapes" + +#Supress Face +msgid "GEOM_SUPRESSFACE" +msgstr "Supression de Face" + +#Fillet +msgid "GEOM_FILLET" +msgstr "Conge" + +#Chamfer +msgid "GEOM_CHAMFER" +msgstr "Chanfrein" + +#Check Shape +msgid "GEOM_CHECK_SHAPE" +msgstr "Check Shape" + +#Whatis +msgid "GEOM_WHATIS" +msgstr "Whatis" + +#Bounding Box +msgid "GEOM_BNDBOX" +msgstr "Boite Anglobante" + +#Center Of Mass +msgid "GEOM_CMASS" +msgstr "Centre de Masse" + +#Basic Properties +msgid "GEOM_PROPERTIES" +msgstr "Basiques Proprietes" + +#Multi-Translation +msgid "GEOM_MULTITRANSLATION" +msgstr "Multi-Translation" + +#Multi-Rotation +msgid "GEOM_MULTIROTATION" +msgstr "Multi-Rotation" + +# +#============================================================================== +# + +#Arc +msgid "GEOM_ARC" +msgstr "Arc" + +#Box +msgid "GEOM_BOX" +msgstr "Boite" + +#Circle +msgid "GEOM_CIRCLE" +msgstr "Cercle" + +#Ellipse +msgid "GEOM_ELLIPSE" +msgstr "Ellipse" + +msgid "GEOM_ELLIPSE_TITLE" +msgstr "Construction d'Ellipses" + +#Radius major +msgid "GEOM_RADIUS_MAJOR" +msgstr "Rayon max. :" + +#Radius minor +msgid "GEOM_RADIUS_MINOR" +msgstr "Rayon min. :" + +#Compound +msgid "GEOM_COMPOUND" +msgstr "Compound" + +#CompSolid +msgid "GEOM_COMPOUNDSOLID" +msgstr "CompSolid" + +#Cone +msgid "GEOM_CONE" +msgstr "Cone" + +#Cylinder +msgid "GEOM_CYLINDER" +msgstr "Cylindre" + +#Edge +msgid "GEOM_EDGE" +msgstr "Edge" + +#Face +msgid "GEOM_FACE" +msgstr "Face" + +#Faces +msgid "GEOM_FACES" +msgstr "Faces" + +#Line +msgid "GEOM_LINE" +msgstr "Ligne" + +#Plane +msgid "GEOM_PLANE" +msgstr "Plan" + +#Shape +msgid "GEOM_SHAPE" +msgstr "Shape" + +#Shell +msgid "GEOM_SHELL" +msgstr "Shell" + +#Shells +msgid "GEOM_SHELLS" +msgstr "Shells" + +#Solid +msgid "GEOM_SOLID" +msgstr "Solide" + +#Sphere +msgid "GEOM_SPHERE" +msgstr "Sphère" + +#Conical Face +msgid "GEOM_SURFCONE" +msgstr "Face Conique" + +#Cylindrical Face +msgid "GEOM_SURFCYLINDER" +msgstr "Face Cylindrique" + +#Spherical Face +msgid "GEOM_SURFSPHERE" +msgstr "Face Sphèrique" + +#Toroidal Face +msgid "GEOM_SURFTORUS" +msgstr "Face Toroique" + +#Torus +msgid "GEOM_TORUS" +msgstr "Tore" + +#Vector +msgid "GEOM_VECTOR" +msgstr "Vecteur" + +#Vector U +msgid "GEOM_VECTOR_U" +msgstr "Vecteur U" + +#Vector V +msgid "GEOM_VECTOR_V" +msgstr "Vecteur V" + +#Vertex +msgid "GEOM_VERTEX" +msgstr "Vertex" + +#Wire +msgid "GEOM_WIRE" +msgstr "Wire" + +#Wire(s) +msgid "GEOM_WIRES" +msgstr "Wire(s)" + +#Parameter +msgid "GEOM_PARAMETER" +msgstr "Paramètre :" + + +# +#============================================================================== +# + +#Min +msgid "GEOM_MIN" +msgstr "Min :" + +#Max +msgid "GEOM_MAX" +msgstr "Max :" + +#X +msgid "GEOM_X" +msgstr "X :" + +#Y +msgid "GEOM_Y" +msgstr "Y :" + +#Z +msgid "GEOM_Z" +msgstr "Z :" + +#DX +msgid "GEOM_DX" +msgstr "Dx :" + +#DY +msgid "GEOM_DY" +msgstr "Dy :" + +#DZ +msgid "GEOM_DZ" +msgstr "Dz :" + +#D1 +msgid "GEOM_D1" +msgstr "D1 :" + +#D2 +msgid "GEOM_D2" +msgstr "D2 :" + +# +#============================================================================== +# + +#: GeometryGUI.cxx +msgid "GEOM_STEP_TITLE" +msgstr "Increment par défaut lors des constructions" + +#: GeometryGUI_ArcDlg.cxx:45 +msgid "GEOM_ARC_TITLE" +msgstr "Construction d'un Arc" + +#: GeometryGUI_ArchimedeDlg.cxx:55 +msgid "GEOM_ARCHIMEDE_TITLE" +msgstr "Construction d'Archimède" + +#: GeometryGUI_BndBoxDlg.cxx:59 +msgid "GEOM_BNDBOX_TITLE" +msgstr "Boite Englobante" + +#: GeometryGUI_BndBoxDlg.cxx:82 +msgid "GEOM_BNDBOX_OBJDIM" +msgstr "Objet and ses dimensions" + +#: GeometryGUI_BoxDlg.cxx:50 +msgid "GEOM_BOX_TITLE" +msgstr "Construction d'une Boite" + +#: GeometryGUI_BoxDlg.cxx:50 +msgid "GEOM_BOX_OBJ" +msgstr "Dimensions A l'Origine" + +#: GeometryGUI_ChamferDlg.cxx:58 +msgid "GEOM_CHAMFER_TITLE" +msgstr "Construction d'un Chanfrein" + +#: GeometryGUI_ChamferDlg.cxx:58 +msgid "GEOM_CHAMFER_ALL" +msgstr "Chanfrein sur toute la Shape" + +#: GeometryGUI_ChamferDlg.cxx:58 +msgid "GEOM_CHAMFER_EDGES" +msgstr "Chanfrein sur Edges de la Shape" + +#: GeometryGUI_ChamferDlg.cxx:58 +msgid "GEOM_CHAMFER_FACES" +msgstr "Chanfrein sur Faces de la Shape" + +#: GeometryGUI_CircleDlg.cxx:48 +msgid "GEOM_CIRCLE_TITLE" +msgstr "Construction d'un Cercle" + +#: GeometryGUI_CenterMassDlg.cxx:77 +msgid "GEOM_CMASS_TITLE" +msgstr "Centre De Gravité" + +msgid "GEOM_PLANE_SIZE" +msgstr "Taille du plan :" + +#: GeometryGUI_CommonDlg.cxx:47 +msgid "GEOM_COMMON_TITLE" +msgstr "BOOLEEN : Jonction De Deux Objets" + +#: GeometryGUI_CompoundDlg.cxx:44 +msgid "GEOM_COMPOUND_TITLE" +msgstr "Création d'un Compound" + +#: GeometryGUI_ConeDlg.cxx:49 +msgid "GEOM_CONE_TITLE" +msgstr "Construction d'un Cone" + +#: GeometryGUI_CutDlg.cxx:48 +msgid "GEOM_CUT_TITLE" +msgstr "BOOLEEN : Couper Deux Objets" +# +#: GeometryGUI_CylinderDlg.cxx:47 +msgid "GEOM_CYLINDER_TITLE" +msgstr "Construction d'un Cylindre" + +#: GeometryGUI_CheckShape.cxx:60 +msgid "GEOM_CHECK_TITLE" +msgstr "Check Shape" + +#: GeometryGUI_CheckShape.cxx:83 +msgid "GEOM_CHECK_INFOS" +msgstr "Objet et ses Informations Topologiques" + +#: GeometryGUI_DistanceDlg.cxx:57 +msgid "GEOM_MINDIST_TITLE" +msgstr "Distance Minimale entre Deux Objets" + +#: GeometryGUI_DistanceDlg.cxx:57 +msgid "GEOM_MINDIST_OBJ" +msgstr "Objets Et Resultats" + +#: GeometryGUI_EdgeDlg.cxx:47 +msgid "GEOM_EDGE_TITLE" +msgstr "Création d'un Edge" + +#: GeometryGUI_FilletDlg.cxx:58 +msgid "GEOM_FILLET_TITLE" +msgstr "Construction d'un Congé" + +#: GeometryGUI_FilletDlg.cxx:58 +msgid "GEOM_FILLET_ALL" +msgstr "Congé sur toute la Shape" + +#: GeometryGUI_FilletDlg.cxx:58 +msgid "GEOM_FILLET_EDGES" +msgstr "Congé sur Edges de la Shape" + +#: GeometryGUI_FilletDlg.cxx:58 +msgid "GEOM_FILLET_FACES" +msgstr "Congé sur Faces de la Shape" + +#: GeometryGUI_FaceDlg.cxx:49 +msgid "GEOM_FACE_TITLE" +msgstr "Création d'une Face" + +#: GeometryGUI_FaceDlg.cxx:78 +msgid "GEOM_FACE_FFW" +msgstr "Face a partir d'un wire" + +#: GeometryGUI_FaceDlg.cxx:103 +msgid "GEOM_FACE_OPT" +msgstr "Création d'une Face plane" + +#: GeometryGUI_FillingDlg.cxx:53 +msgid "GEOM_FILLING_TITLE" +msgstr "Surface Par Courbes" + +#: GeometryGUI_FillingDlg.cxx:112 +msgid "GEOM_FILLING_ARG" +msgstr "Argument Et Parametres" + +#: GeometryGUI_FillingDlg.cxx:128 +msgid "GEOM_FILLING_MIN_DEG" +msgstr "Min. Deg" + +#: GeometryGUI_FillingDlg.cxx:142 +msgid "GEOM_FILLING_MAX_DEG" +msgstr "Max. Deg" + +#: GeometryGUI_FillingDlg.cxx:150 +msgid "GEOM_FILLING_TOL_2D" +msgstr "Tol. 2D" + +#: GeometryGUI_FillingDlg.cxx:170 +msgid "GEOM_FILLING_COMPOUND" +msgstr "Compound de Courbes" + +#: GeometryGUI_FillingDlg.cxx:184 +msgid "GEOM_FILLING_TOL_3D" +msgstr "Tol. 3D" + +#: GeometryGUI_FillingDlg.cxx:192 +msgid "GEOM_FILLING_NB_ITER" +msgstr "Nb. Iter" + +#: GeometryGUI_FuseDlg.cxx:48 +msgid "GEOM_FUSE_TITLE" +msgstr "BOOLEEN : Fusionner deux Objets" + +#: GeometryGUI_InertiaDlg.cxx:42 +msgid "GEOM_INERTIA_TITLE" +msgstr "Calculs d'Inertie" + +#: GeometryGUI_InertiaDlg.cxx:50 +msgid "GEOM_INERTIA_CONSTR" +msgstr "Matrice Et Moments d'Inertie" + +#: GeometryGUI_InertiaDlg.cxx:100 +msgid "GEOM_INERTIA_I" +msgstr "%1:1" + +#: GeometryGUI_InertiaDlg.cxx:182 +msgid "GEOM_INERTIA_IXYZ" +msgstr "IX & IY & IZ" + +#: GeometryGUI_LineDlg.cxx:50 +msgid "GEOM_LINE_TITLE" +msgstr "Construction d'une Ligne" + +#: GeometryGUI_MaxToleranceDlg.cxx:53 +msgid "GEOM_TOLERANCE_TITLE" +msgstr "Tolerance Maximale" + +#: GeometryGUI_MaxToleranceDlg.cxx:84 +msgid "GEOM_TOLERANCE_CONSTR" +msgstr "Object et ses Tolerances" + +#: GeometryGUI_MaxToleranceDlg.cxx:121 +msgid "GEOM_TOLERANCE_FACE" +msgstr "Face :" + +#: GeometryGUI_MaxToleranceDlg.cxx:138 +msgid "GEOM_TOLERANCE_EDGE" +msgstr "Edge :" + +#: GeometryGUI_MaxToleranceDlg.cxx:155 +msgid "GEOM_TOLERANCE_VERTEX" +msgstr "Vertex :" + +#: GeometryGUI_MirrorDlg.cxx:52 +msgid "GEOM_MIRROR_TITLE" +msgstr "Methode Miroir" + +#: GeometryGUI_OrientationDlg.cxx:46 +msgid "GEOM_ORIENTATION_TITLE" +msgstr "Changer l'Orientation" + +#: GeometryGUI_OrientationDlg.cxx:134 +msgid "GEOM_ORIENTATION_OPT" +msgstr "Renverser l'orientation avec une simulation de vecteur normal" + +#: GeometryGUI_PartitionDlg.cxx:45 +msgid "GEOM_PARTITION_TITLE" +msgstr "Partition d'Objects Avec Outils" + +#: GeometryGUI_PartitionDlg.cxx:45 +msgid "GEOM_KEEP_OBJECT" +msgstr "Objet garde" + +#: GeometryGUI_PartitionDlg.cxx:45 +msgid "GEOM_PARTITION_ORIENTATION" +msgstr "Change l'orientation" + +#: GeometryGUI_PartitionDlg.cxx:45 +msgid "SUPPRESS_RESULT" +msgstr "Suppress Result" + +msgid "GEOM_REMOVE_WEBS" +msgstr "Remove webs" + +msgid "GEOM_SET_MATERIALS" +msgstr "Set materials" + +#: OperationGUI_MaterialDlg.cxx:45 +msgid "GEOM_MATERIAL_TITLE" +msgstr "Define materials for Dominant Fuse" + +msgid "GEOM_MATERIAL_SHAPE" +msgstr "Shapes" + +msgid "GEOM_MATERIAL_MATERIAL" +msgstr "Material" + +msgid "GEOM_MATERIAL_ID" +msgstr "Material ID:" + +msgid "GEOM_MATERIAL_SET" +msgstr "<< Set" + +#: GeometryGUI_PipeDlg.cxx:47 +msgid "GEOM_PIPE_TITLE" +msgstr "Construction d'une Pipe" + +#: GeometryGUI_PointDlg.cxx:52 +msgid "GEOM_POINT_TITLE" +msgstr "Construction d'un Point" + +#: GeometryGUI_PlaneDlg.cxx:60 +msgid "GEOM_PLANE_TITLE" +msgstr "Construction d'un Plan" + +#: GeometryGUI_PlaneDlg.cxx:172 +msgid "GEOM_PLANE_PVC" +msgstr "Point + Vecteur Coordonnes" + +#: GeometryGUI_PlaneDlg.cxx:133 +msgid "GEOM_PLANE_PV" +msgstr "Point + Vecteur" + +#: GeometryGUI_PrismDlg.cxx:54 +msgid "GEOM_PRISM_TITLE" +msgstr "Extruder une Shape de base" + +#: GeometryGUI_PrismDlg.cxx:83 +msgid "GEOM_PRISM_BSV" +msgstr "Shape de base + Vecteur" + +#: GeometryGUI_PropertiesDlg.cxx:56 +msgid "GEOM_PROPERTIES_TITLE" +msgstr "Proprietes Basiques" + +#: GeometryGUI_PropertiesDlg.cxx:78 +msgid "GEOM_PROPERTIES_CONSTR" +msgstr "Objet et ses Proprietes" + +#: GeometryGUI_PropertiesDlg.cxx:114 +msgid "GEOM_PROPERTIES_SURFACE" +msgstr "Surface :" + +#: GeometryGUI_PropertiesDlg.cxx:120 +msgid "GEOM_PROPERTIES_VOLUME" +msgstr "Volume :" + +#: GeometryGUI_RevolDlg.cxx:49 +msgid "GEOM_REVOLUTION_TITLE" +msgstr "Construction Par Revolution" + +#: GeometryGUI_RotationDlg.cxx:51 +msgid "GEOM_ROTATION_TITLE" +msgstr "Rotation d'un Objet" + +#: GeometryGUI_ScaleDlg.cxx:52 +msgid "GEOM_SCALE_TITLE" +msgstr "Echelle d'un Objet" + +#: GeometryGUI_ScaleDlg.cxx:117 +msgid "GEOM_SCALE_FACTOR" +msgstr "Facteur d'echelle" + +#: GeometryGUI_SectionDlg.cxx:50 +msgid "GEOM_SECTION_TITLE" +msgstr "BOOLEEN : Section De Deux Objets" + +#: GeometryGUI_SewingDlg.cxx:48 +msgid "GEOM_SEWING_TITLE" +msgstr "Coudre des Topologies" + +#: GeometryGUI_ShellDlg.cxx:53 +msgid "GEOM_SHELL_TITLE" +msgstr "Construction d'une Shell" + +#: GeometryGUI_SolidDlg.cxx:74 +msgid "GEOM_SOLID_TITLE" +msgstr "Construction d'un Solid" + +#: GeometryGUI_SphereDlg.cxx:50 +msgid "GEOM_SPHERE_TITLE" +msgstr "Construction d'une Sphere" + +#: GeometryGUI_SphereDlg.cxx:113 +msgid "GEOM_SPHERE_CR" +msgstr "Centre + rayon" + +#: GeometryGUI_SphereDlg.cxx:146 +msgid "GEOM_SPHERE_RO" +msgstr "Rayon a l'origine" + +#: GeometryGUI_SubShapeDlg.cxx:55 +msgid "GEOM_SUBSHAPE_TITLE" +msgstr "Selection de Sous Shapes" + +#: GeometryGUI_SubShapeDlg.cxx:131 +msgid "GEOM_SUBSHAPE_TYPE" +msgstr "Type de Sous Shapes" + +#: GeometryGUI_SubShapeDlg.cxx:137 +msgid "GEOM_SUBSHAPE_SELECT" +msgstr "Selectionner de Sous Shapes" + +#: GeometryGUI_TorusDlg.cxx:51 +msgid "GEOM_TORUS_TITLE" +msgstr "Constructiond'un Tore" + +#: GeometryGUI_SuppressFacesDlg.cxx:103 +msgid "GEOM_SUPRESSFACE_TITLE" +msgstr "Supprimer des Faces dans un Objet" + +#: GeometryGUI_SuppressFacesDlg.cxx:164 +msgid "GEOM_SUPRESSFACE_SELECT" +msgstr "Selectionner les Faces a Supprimer" + +#: GeometryGUI_TranslationDlg.cxx:78 +msgid "GEOM_TRANSLATION_COOR" +msgstr "Translation Avec Coordonnees" + +msgid "GEOM_TRANSPARENCY_TITLE" +msgstr "Transparence" + +msgid "GEOM_TRANSPARENCY_OPAQUE" +msgstr "Opaque" + +msgid "GEOM_TRANSPARENCY_TRANSPARENT" +msgstr "Transparent" + +msgid "GEOM_SUPPRESSHOLE_TITLE" +msgstr "Suppression de trous" + +msgid "GEOM_SUPPRESSHOLE_SELECTFACE" +msgstr "Selection de la face initiale" + +msgid "GEOM_SUPPRESSHOLE_SELECTWIRE" +msgstr "Selection du contour/trou sur la face" + +msgid "GEOM_SUPPRESSHOLE_SELECTFACE_END" +msgstr "Selection de la face terminale (si trou traversant)" + +msgid "GEOM_SUPPRESSHOLE_SELECTWIRE_END" +msgstr "Selection de contour final (si trou traversant)" + +msgid "GEOM_SUPPRESSHOLE_FACE_SHELL" +msgstr "Face ou shell" + +msgid "GEOM_SUPPRESSHOLE_SELECT_HOLES_ON_FACE" +msgstr "Selection de trou(s) sur la face" + +#: GeometryGUI_TranslationDlg.cxx:56 +msgid "GEOM_TRANSLATION_TITLE" +msgstr "Translation d'un Objet" + +#: GeometryGUI_VectorDlg.cxx:54 +msgid "GEOM_VECTOR_TITLE" +msgstr "Construction d'un Vecteur" + +#: GeometryGUI_WhatisDlg.cxx:63 +msgid "GEOM_WHATIS_TITLE" +msgstr "Whatis" + +#: GeometryGUI_WhatisDlg.cxx:86 +msgid "GEOM_WHATIS_OBJECT" +msgstr "Objet et ses Informations Topologiques" + +#: GeometryGUI_WireDlg.cxx:46 +msgid "GEOM_WIRE_TITLE" +msgstr "Creer un Wire" + +#: GeometryGUI_WireDlg.cxx:103 +msgid "GEOM_WIRE_CONNECT" +msgstr "Creation d'un Wire a partir de wires/edges connectes" + +#: GeometryGUI_WorkingPlaneDlg.cxx:50 +msgid "GEOM_WPLANE_TITLE" +msgstr "plan de travail" + +#: GeometryGUI_WorkingPlaneDlg.cxx:107 +msgid "GEOM_WPLANE_FACE" +msgstr "Plan Ou Face plane" + +#: GeometryGUI_multiTranslationDlg.cxx:107 +msgid "GEOM_MULTITRANSLATION_TITLE" +msgstr "Multi-Translation" + +#: GeometryGUI_multiTranslationDlg.cxx:107 +msgid "GEOM_MULTITRANSLATION_SIMPLE" +msgstr "Multi Translation Simple" + +#: GeometryGUI_multiTranslationDlg.cxx:107 +msgid "GEOM_MULTITRANSLATION_DOUBLE" +msgstr "Multi Translation Double" + +#: GeometryGUI_multiRotationDlg.cxx:107 +msgid "GEOM_MULTIROTATION_TITLE" +msgstr "Multi-Rotation" + +#: GeometryGUI_multiRotationDlg.cxx:107 +msgid "GEOM_MULTIROTATION_SIMPLE" +msgstr "Multi Rotation Simple" + +#: GeometryGUI_multiRotationDlg.cxx:107 +msgid "GEOM_MULTIROTATION_DOUBLE" +msgstr "Multi Rotation Double" + +msgid "GEOM_PARAM_POINT" +msgstr "Point paramétrique" + +# +#============================================================================== +# + +#: GeometryGUI.cxx:4613 +msgid "GEOM_MEN_WIREFRAME" +msgstr "Filaire" + +#: GeometryGUI.cxx:4613 +msgid "GEOM_MEN_SHADING" +msgstr "Ombré" + +msgid "GEOM_RECONSTRUCTION_LIMIT" +msgstr "Limite de Reconstruction" + +msgid "GEOM_SUPPRESS_RESULT" +msgstr "Supprimer le Resultat" + +msgid "GEOM_SUPPRESS_RESULT_INSIDE" +msgstr "Intérieur" + +msgid "GEOM_SUPPRESS_RESULT_OUTSIDE" +msgstr "Extérieur" + +msgid "GEOM_RECONSTRUCTION_LIMIT_SHAPE" +msgstr "Shape" +msgid "GEOM_RECONSTRUCTION_LIMIT_SOLID" +msgstr "Solid" +msgid "GEOM_RECONSTRUCTION_LIMIT_SHELL" +msgstr "Shell" +msgid "GEOM_RECONSTRUCTION_LIMIT_FACE" +msgstr "Face" +msgid "GEOM_RECONSTRUCTION_LIMIT_WIRE" +msgstr "Wire" +msgid "GEOM_RECONSTRUCTION_LIMIT_EDGE" +msgstr "Edge" +msgid "GEOM_RECONSTRUCTION_LIMIT_VERTEX" +msgstr "Vertex" + +msgid "GEOM_SPLINE_TITLE" +msgstr "Construction de Splines" +msgid "GEOM_SPLINE" +msgstr "Spline" +msgid "GEOM_BEZIER" +msgstr "Bezier" +msgid "GEOM_INTERPOL" +msgstr "Interpolation" + +# +#============================================================================== +# + +msgid "GEOM_SKETCHER_EL" +msgstr "Type d'Element" + +msgid "GEOM_BUT_CLOSE_SKETCH" +msgstr "Fermer Sketch" + +msgid "GEOM_BUT_END_SKETCH" +msgstr "Terminer Sketch" + +msgid "GEOM_SKETCHER_TITLE" +msgstr "Construction de Sketch" + +msgid "GEOM_SKETCHER_POINT" +msgstr "Point" + +msgid "GEOM_SKETCHER_SEGMENT" +msgstr "Sègment" + +msgid "GEOM_SKETCHER_ARC" +msgstr "Arc" + +msgid "GEOM_SKETCHER_DIR" +msgstr "Direction" + +msgid "GEOM_SKETCHER_POINT2" +msgstr "Point :" + +msgid "GEOM_SKETCHER_DEST" +msgstr "Destination" + +msgid "GEOM_SKETCHER_ABS" +msgstr "Absolu" + +msgid "GEOM_SKETCHER_REL" +msgstr "Relative" + +msgid "GEOM_SKETCHER_SEL" +msgstr "Sélection" + +msgid "GEOM_SKETCHER_ANGLE" +msgstr "Angle" + +msgid "GEOM_SKETCHER_PER" +msgstr "Perpendiculaire" + +msgid "GEOM_SKETCHER_TAN" +msgstr "Tangent" + +msgid "GEOM_SKETCHER_VXVY" +msgstr "VX-VY" + +msgid "GEOM_SKETCHER_LENGTH" +msgstr "Longueur" + +msgid "GEOM_SKETCHER_X" +msgstr "X" + +msgid "GEOM_SKETCHER_Y" +msgstr "Y" + +msgid "GEOM_SKETCHER_X2" +msgstr "X :" + +msgid "GEOM_SKETCHER_Y2" +msgstr "Y :" + +msgid "GEOM_SKETCHER_X3" +msgstr "Abs. X :" + +msgid "GEOM_SKETCHER_Y3" +msgstr "Abs. Y :" + +msgid "GEOM_SKETCHER_DX2" +msgstr "DX :" + +msgid "GEOM_SKETCHER_DY2" +msgstr "DY :" + +msgid "GEOM_SKETCHER_VX2" +msgstr "VX :" + +msgid "GEOM_SKETCHER_VY2" +msgstr "VY :" + +msgid "GEOM_SKETCHER_LENGTH2" +msgstr "Longueur :" + +msgid "GEOM_SKETCHER_ANGLE2" +msgstr "Angle :" + +msgid "GEOM_SKETCHER_RADIUS2" +msgstr "Radius :" + +msgid "GEOM_SKETCHER_UNDO" +msgstr "Undo" + +msgid "GEOM_SKETCHER_APPLY" +msgstr "Appliquer" + +msgid "GEOM_SKETCHER_VALUES" +msgstr "Valeurs" + +msgid "GEOM_SKETCHER_TYPE" +msgstr "Type" + +msgid "GEOM_FILLET_ABORT" +msgstr "Le congé ne peut-être realisé avec un rayon de %1 " + +msgid "GEOM_CHAMFER_ABORT" +msgstr "Le chanfrein ne peut-être realisé avec %1 et %2 " + +#MZN: to be translated +msgid "GEOM_CREATE_COPY" +msgstr "Create a copy" + +#MZN: to be translated +msgid "GEOM_CREATE_SINGLE_SOLID" +msgstr "Create a single solid" diff --git a/src/GEOMGUI/GeometryGUI.cxx b/src/GEOMGUI/GeometryGUI.cxx index fd961ec3d..7f26db05c 100644 --- a/src/GEOMGUI/GeometryGUI.cxx +++ b/src/GEOMGUI/GeometryGUI.cxx @@ -1,23 +1,23 @@ // 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 +// 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 // // // @@ -28,273 +28,464 @@ #include "GeometryGUI.h" -// Open CASCADE Includes -#include -#include - // SALOME Includes +#include "Utils_ORB_INIT.hxx" +#include "Utils_SINGLETON.hxx" + +#include "QAD_Desktop.h" +#include "QAD_Application.h" #include "QAD_RightFrame.h" #include "QAD_Config.h" +#include "QAD_Tools.h" +#include "QAD_MessageBox.h" +#include "QAD_Resource.h" +#include "SALOMEGUI_Desktop.h" #include "OCCViewer_Viewer3d.h" +#include "OCCViewer_ViewFrame.h" #include "OCCViewer_ViewPort3d.h" +#include "OCCViewer_Prs.h" + #include "VTKViewer_ViewFrame.h" +#include "VTKViewer_RenderWindowInteractor.h" #include "VTKViewer_InteractorStyleSALOME.h" +#include "VTKViewer_Prs.h" +#include "SALOME_Actor.h" #include "SALOME_Selection.h" +#include "SALOME_ListIteratorOfListIO.hxx" +#include "GEOM_AISShape.hxx" +#include "GEOM_Displayer.h" + +#include "GEOMImpl_Types.hxx" + +// External includes +#include +#include +#include +#include + +#include "utilities.h" + +#include +#include using namespace std; -/* The object itself created in the static method 'GetOrCreateGEOMBase()' */ -static GEOMContext* GeomGUI = 0; +extern "C" { + Standard_EXPORT SALOMEGUI* GetComponentGUI() { + return GeometryGUI::GetGeomGUI(); + } +} -typedef bool OGE(int, QAD_Desktop*); -typedef bool OMP(QMouseEvent*, QAD_Desktop*, QAD_StudyFrame*); -typedef void BP(const Handle(SALOME_InteractiveObject)&); -typedef bool CP(QAD_Desktop*, QPopupMenu*, const QString&, - const QString&, const QString&); +//================================================================================= +// class : CustomItem +// purpose : Set Font to a text. +//================================================================================= +class CustomItem : public QCustomMenuItem +{ +public: + CustomItem(const QString& s, const QFont& f) : myString(s), myFont(f) {} + ~CustomItem() {} + + void paint(QPainter* p, const QColorGroup& cg, bool act, bool /*enabled*/, int x, int y, int w, int h) + { + if ( !act ) { + p->fillRect( x, y+1, w, h-2, cg.mid() ); + p->drawRect( x, y+1, w, h-2 ); + } + else { + p->fillRect( x, y+1, w, h-2, cg.midlight() ); + QPen oldPen = p->pen(); + p->setPen( cg.mid() ); + p->drawRect( x, y+1, w, h-2 ); + p->setPen( oldPen ); + } + p->setFont( myFont ); + p->drawText( x, y, w, h, AlignHCenter | AlignVCenter | ShowPrefix | DontClip, myString ); + } + + QSize sizeHint() + { + return QFontMetrics( myFont ).size( AlignHCenter | AlignVCenter | ShowPrefix | DontClip, myString ); + } + +private: + QString myString; + QFont myFont; + +}; + +//======================================================================= +// function : GeometryGUI::GetGeomGUI() +// purpose : Gets the only object of GeometryGUI [ static ] +//======================================================================= +GeometryGUI* GeometryGUI::GetGeomGUI() +{ + static GeometryGUI myContext; + return &myContext; +} + +//======================================================================= +// function : GetORB +// purpose : Returns a reference to ORB [ static ] +//======================================================================= +CORBA::ORB_var GeometryGUI::GetORB() +{ + ORB_INIT& init = *SINGLETON_::Instance(); + return init.orb(); +} //======================================================================= -// function : GeometryGUI() +// function : GeometryGUI::GeometryGUI() // purpose : Constructor //======================================================================= -GeometryGUI::GeometryGUI( const QString& theName, QObject* theParent ) : - SALOMEGUI( theName, theParent ) -{} +GeometryGUI::GeometryGUI() : + SALOMEGUI() +{ + QAD_Desktop* desktop = QAD_Application::getDesktop(); + Engines::Component_var comp = desktop->getEngine( "FactoryServer", "GEOM" ); + + myComponentGeom = GEOM::GEOM_Gen::_narrow( comp ); + myState = -1; + myActiveDialogBox = 0; + myFatherior = ""; + gp_Pnt origin = gp_Pnt(0., 0., 0.); + gp_Dir direction = gp_Dir(0., 0., 1.); + myWorkingPlane = gp_Ax3(origin, direction); +} //======================================================================= -// function : ~GeometryGUI() +// function : GeometryGUI::~GeometryGUI() // purpose : Destructor //======================================================================= GeometryGUI::~GeometryGUI() { } - //======================================================================= -// function : GetOrCreateGEOMBase() -// purpose : Gets or create an object 'GEOMBase' with initialisations -// : Returns 'GeomGUI' as a pointer +// function : GeometryGUI::getLibrary() +// purpose : get or load GUI library by name [ internal ] //======================================================================= -GEOMContext* GeometryGUI::GetOrCreateGeometryGUI(QAD_Desktop* desktop) +typedef GEOMGUI* (*LibraryGUI)(); +GEOMGUI* GeometryGUI::getLibrary( const QString& libraryName ) { - GeomGUI = GeomGUI->GetOrCreateGeomGUI(desktop); - return GeomGUI; + if ( !myGUIMap.contains( libraryName ) ) { + // try to load library if it is not loaded yet + QCString libs; + if( ( libs = getenv( "LD_LIBRARY_PATH" ) ) ) { + QStringList dirList = QStringList::split( ":", libs, false ); // skip empty entries + for( int i = dirList.count()-1; i >= 0; i-- ) { + QString dir = dirList[ i ]; + QFileInfo fi( QAD_Tools::addSlash( dirList[ i ] ) + libraryName ); + if( fi.exists() ) { + OSD_SharedLibrary aSharedLibrary( (char*)fi.fileName().latin1() ); + bool res = aSharedLibrary.DlOpen( OSD_RTLD_LAZY ); + if( !res ) { + MESSAGE( "Can't open library : " << aSharedLibrary.DlError() ); + continue; // continue search further + } + OSD_Function osdF = aSharedLibrary.DlSymb( "GetLibGUI" ); + if ( osdF != NULL ) { + LibraryGUI func = (GEOMGUI* (*) ())osdF; + GEOMGUI* libGUI = (*func)(); + if ( libGUI ) { + myGUIMap[ libraryName ] = libGUI; + break; // found and loaded! + } + } + } + } + } + } + if ( myGUIMap.contains( libraryName ) ) + // library is successfully loaded + return myGUIMap[ libraryName ]; + return 0; } - //======================================================================= -// function : OnGUIEvent() [static] -// purpose : manage all events on GUI +// function : GeometryGUI::ActiveWorkingPlane() +// purpose : Activate Working Plane View //======================================================================= -bool GeometryGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) +void GeometryGUI::ActiveWorkingPlane() { - GeometryGUI::GetOrCreateGeometryGUI(parent); + gp_Dir DZ = myWorkingPlane.Direction(); + gp_Dir DY = myWorkingPlane.YDirection(); - QMenuBar* Mb = QAD_Application::getDesktop()->getMainMenuBar(); - bool ViewOCC; + if( QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { + OCCViewer_ViewPort* vp = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewPort(); + Handle(V3d_View) view3d = ((OCCViewer_ViewPort3d*)vp)->getView(); - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) - ViewOCC = true; - else if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK) - ViewOCC = false; - else - return false; + view3d->SetProj(DZ.X(), DZ.Y(), DZ.Z()); + view3d->SetUp(DY.X(), DY.Y(), DY.Z()); + + ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->onViewFitAll(); + } + else if( QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { + vtkRenderer* myRenderer = ((VTKViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); - Mb->setItemEnabled(404, ViewOCC);//SKETCHER + vtkCamera* camera = myRenderer->GetActiveCamera(); + camera->SetPosition(DZ.X(), DZ.Y(), DZ.Z()); + camera->SetViewUp(DY.X(), DY.Y(), DY.Z()); + camera->SetFocalPoint(0,0,0); - Mb->setItemEnabled(603, ViewOCC);//SuppressFace - Mb->setItemEnabled(604, ViewOCC);//SuppressHole - - Mb->setItemEnabled(413, ViewOCC);// ShadingColor Settings - Mb->setItemEnabled(414, ViewOCC);// Isos Settings - - if(theCommandID == 111 || // MENU FILE - IMPORT BREP - theCommandID == 112 || // MENU FILE - IMPORT IGES - theCommandID == 113 || // MENU FILE - IMPORT STEP - theCommandID == 121 || // MENU FILE - EXPORT BREP - theCommandID == 122 || // MENU FILE - EXPORT IGES - theCommandID == 123 || // MENU FILE - EXPORT STEP - theCommandID == 31 || // MENU EDIT - COPY - theCommandID == 33 || // MENU EDIT - DELETE - theCommandID == 411 || // MENU SETTINGS - ADD IN STUDY - theCommandID == 412 || // MENU SETTINGS - SHADING COLOR - theCommandID == 413 || // MENU SETTINGS - ISOS - theCommandID == 414 || // MENU SETTINGS - STEP VALUE FOR SPIN BOXES - theCommandID == 5103 || // MENU TOOLS - CHECK GEOMETRY - theCommandID == 5104 || // MENU TOOLS - LOAD SCRIPT - theCommandID == 8032 || // POPUP VIEWER - COLOR - theCommandID == 8033 || // POPUP VIEWER - TRANSPARENCY - theCommandID == 8034 || // POPUP VIEWER - ISOS - theCommandID == 804 || // POPUP VIEWER - ADD IN STUDY - theCommandID == 901 || // OBJECT BROWSER - RENAME - theCommandID == 9024) { // OBJECT BROWSER - OPEN - if(!GeomGUI->LoadLibrary("libGEOMToolsGUI.so")) - return false; - } - else if(theCommandID == 211 || // MENU VIEW - WIREFRAME/SHADING - theCommandID == 212 || // MENU VIEW - DISPLAY ALL - theCommandID == 213 || // MENU VIEW - DISPLAY ONLY - theCommandID == 214 || // MENU VIEW - ERASE ALL - theCommandID == 215 || // MENU VIEW - ERASE ONLY - theCommandID == 8031) { // POPUP VIEWER - WIREFRAME/SHADING - if(!GeomGUI->LoadLibrary("libDisplayGUI.so")) - return false; - } - else if(theCommandID == 4011 || // MENU BASIC - POINT - theCommandID == 4012 || // MENU BASIC - LINE - theCommandID == 4013 || // MENU BASIC - CIRCLE - theCommandID == 4014 || // MENU BASIC - ELLIPSE - theCommandID == 4015 || // MENU BASIC - ARC - theCommandID == 4016 || // MENU BASIC - VECTOR - theCommandID == 4017 || // MENU BASIC - PLANE - theCommandID == 4018) { // MENU BASIC - WPLANE - if(!GeomGUI->LoadLibrary("libBasicGUI.so")) - return false; - } - else if(theCommandID == 4021 || // MENU PRIMITIVE - BOX - theCommandID == 4022 || // MENU PRIMITIVE - CYLINDER - theCommandID == 4023 || // MENU PRIMITIVE - SPHERE - theCommandID == 4024 || // MENU PRIMITIVE - TORUS - theCommandID == 4025) { // MENU PRIMITIVE - CONE - if(!GeomGUI->LoadLibrary("libPrimitiveGUI.so")) - return false; - } - else if(theCommandID == 4031 || // MENU GENERATION - PRISM - theCommandID == 4032 || // MENU GENERATION - REVOLUTION - theCommandID == 4033 || // MENU GENERATION - FILLING - theCommandID == 4034) { // MENU GENERATION - PIPE - if(!GeomGUI->LoadLibrary("libGenerationGUI.so")) - return false; - } - else if(theCommandID == 404 || // MENU ENTITY - SKETCHER - theCommandID == 407) { // MENU ENTITY - EXPLODE - if(!GeomGUI->LoadLibrary("libEntityGUI.so")) - return false; - } - else if(theCommandID == 4081 || // MENU BUILD - EDGE - theCommandID == 4082 || // MENU BUILD - WIRE - theCommandID == 4083 || // MENU BUILD - FACE - theCommandID == 4084 || // MENU BUILD - SHELL - theCommandID == 4085 || // MENU BUILD - SOLID - theCommandID == 4086) { // MENU BUILD - COMPUND - if(!GeomGUI->LoadLibrary("libBuildGUI.so")) - return false; - } - else if(theCommandID == 5011 || // MENU BOOLEAN - FUSE - theCommandID == 5012 || // MENU BOOLEAN - COMMON - theCommandID == 5013 || // MENU BOOLEAN - CUT - theCommandID == 5014) { // MENU BOOLEAN - SECTION - if(!GeomGUI->LoadLibrary("libBooleanGUI.so")) - return false; - } - else if(theCommandID == 5021 || // MENU TRANSFORMATION - TRANSLATION - theCommandID == 5022 || // MENU TRANSFORMATION - ROTATION - theCommandID == 5023 || // MENU TRANSFORMATION - MIRROR - theCommandID == 5024 || // MENU TRANSFORMATION - SCALE - theCommandID == 5025 || // MENU TRANSFORMATION - MULTI-TRANSLATION - theCommandID == 5026) { // MENU TRANSFORMATION - MULTI-ROTATION - if(!GeomGUI->LoadLibrary("libTransformationGUI.so")) - return false; - } - else if(theCommandID == 503 || // MENU OPERATION - PARTITION - theCommandID == 504 || // MENU OPERATION - ARCHIMEDE - theCommandID == 505 || // MENU OPERATION - FILLET - theCommandID == 506) { // MENU OPERATION - CHAMFER - if(!GeomGUI->LoadLibrary("libOperationGUI.so")) - return false; - } - else if(theCommandID == 601 || // MENU REPAIR - SEWING - theCommandID == 602 || // MENU REPAIR - ORIENTATION - theCommandID == 603 || // MENU REPAIR - SUPPRESS FACES - theCommandID == 604) { // MENU REPAIR - SUPPRESS HOLE - if(!GeomGUI->LoadLibrary("libRepairGUI.so")) - return false; - } - 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 - if(!GeomGUI->LoadLibrary("libMeasureGUI.so")) - return false; + ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->onViewFitAll(); } - else + +} + +//======================================================================= +// function : GeometryGUI::SetActiveDialogBox() +// purpose : Set active dialog box +//======================================================================= +void GeometryGUI::SetActiveDialogBox( QDialog* aDlg ) +{ + myActiveDialogBox = (QDialog*)aDlg; +} + +//======================================================================= +// function : GeometryGUI::EmitSignalDeactivateDialog() +// purpose : Emit a signal to deactivate the active dialog Box +//======================================================================= +void GeometryGUI::EmitSignalDeactivateDialog() +{ + emit SignalDeactivateActiveDialog(); +} + +//======================================================================= +// function : GeometryGUI::EmitSignalCloseAllDialogs() +// purpose : Emit a signal to close all non modal dialogs box +//======================================================================= +void GeometryGUI::EmitSignalCloseAllDialogs() +{ + emit SignalCloseAllDialogs(); +} + +//======================================================================= +// function : GeometryGUI::EmitSignalDefaultStepValueChanged() +// purpose : Emit a signal to inform that default real spin box step has +// been changed +//======================================================================= +void GeometryGUI::EmitSignalDefaultStepValueChanged(double newVal) +{ + emit SignalDefaultStepValueChanged(newVal); +} + +//======================================================================= +// function : GeometryGUI::OnGUIEvent() +// purpose : manage all events on GUI [static] +//======================================================================= +bool GeometryGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) +{ + GeometryGUI* geomGUI = GeometryGUI::GetGeomGUI(); + + // get main menu + QMenuBar* Mb = parent->getMainMenuBar(); + // check if current viewframe is of OCC type + bool ViewOCC = parent->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC; + // if current viewframe is not of OCC and not of VTK type - return immediately + if( !ViewOCC && parent->getActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK) return false; - //Load Function OnGUIEvent - OSD_Function osdF = GeomGUI->myGUILibrary.DlSymb("OnGUIEvent"); - OGE (*f1) = NULL; - if(osdF != NULL) { - f1 = (bool (*) (int, QAD_Desktop*)) osdF; - (*f1)(theCommandID, parent); + // disable non-OCC viewframe menu commands + //Mb->setItemEnabled( 404, ViewOCC ); // SKETCHER + Mb->setItemEnabled( 603, ViewOCC ); // SuppressFace + Mb->setItemEnabled( 604, ViewOCC ); // SuppressHole + Mb->setItemEnabled( 606, ViewOCC ); // CloseContour + Mb->setItemEnabled( 607, ViewOCC ); // RemoveInternalWires + Mb->setItemEnabled( 608, ViewOCC ); // AddPointOnEdge + //Mb->setItemEnabled( 609, ViewOCC ); // Free boundaries + Mb->setItemEnabled( 413, ViewOCC ); // Isos Settings + + Mb->setItemEnabled( 800, ViewOCC ); // Create Group + Mb->setItemEnabled( 801, ViewOCC ); // Edit Group + + Mb->setItemEnabled(9998, ViewOCC ); // MENU BLOCKS - MULTI-TRANSFORMATION + + GEOMGUI* library = 0; + // try to get-or-load corresponding GUI library + if( theCommandID == 111 || // MENU FILE - IMPORT BREP + theCommandID == 112 || // MENU FILE - IMPORT IGES + theCommandID == 113 || // MENU FILE - IMPORT STEP + theCommandID == 121 || // MENU FILE - EXPORT BREP + theCommandID == 122 || // MENU FILE - EXPORT IGES + theCommandID == 123 || // MENU FILE - EXPORT STEP + theCommandID == 31 || // MENU EDIT - COPY + theCommandID == 33 || // MENU EDIT - DELETE + theCommandID == 411 || // MENU SETTINGS - ADD IN STUDY + theCommandID == 412 || // MENU SETTINGS - SHADING COLOR + theCommandID == 413 || // MENU SETTINGS - ISOS + theCommandID == 414 || // MENU SETTINGS - STEP VALUE FOR SPIN BOXES + theCommandID == 5103 || // MENU TOOLS - CHECK GEOMETRY + theCommandID == 5104 || // MENU TOOLS - LOAD SCRIPT + theCommandID == 8032 || // POPUP VIEWER - COLOR + theCommandID == 8033 || // POPUP VIEWER - TRANSPARENCY + theCommandID == 8034 || // POPUP VIEWER - ISOS + theCommandID == 804 || // POPUP VIEWER - ADD IN STUDY + theCommandID == 901 || // OBJECT BROWSER - RENAME + theCommandID == 9024 ) { // OBJECT BROWSER - OPEN + library = geomGUI->getLibrary( "libGEOMToolsGUI.so" ); + } + else if( theCommandID == 211 || // MENU VIEW - WIREFRAME/SHADING + theCommandID == 212 || // MENU VIEW - DISPLAY ALL + theCommandID == 213 || // MENU VIEW - DISPLAY ONLY + theCommandID == 214 || // MENU VIEW - ERASE ALL + theCommandID == 215 || // MENU VIEW - ERASE + theCommandID == 216 || // MENU VIEW - DISPLAY + theCommandID == 80311 || // POPUP VIEWER - WIREFRAME + theCommandID == 80312 ) { // POPUP VIEWER - SHADING + library = geomGUI->getLibrary( "libDisplayGUI.so" ); + } + else if( theCommandID == 4011 || // MENU BASIC - POINT + theCommandID == 4012 || // MENU BASIC - LINE + theCommandID == 4013 || // MENU BASIC - CIRCLE + theCommandID == 4014 || // MENU BASIC - ELLIPSE + theCommandID == 4015 || // MENU BASIC - ARC + theCommandID == 4016 || // MENU BASIC - VECTOR + theCommandID == 4017 || // MENU BASIC - PLANE + theCommandID == 4018 || // MENU BASIC - WPLANE + theCommandID == 4019 || // MENU BASIC - CURVE + theCommandID == 4020 ) { // MENU BASIC - REPAIR + library = geomGUI->getLibrary( "libBasicGUI.so" ); + } + else if( theCommandID == 4021 || // MENU PRIMITIVE - BOX + theCommandID == 4022 || // MENU PRIMITIVE - CYLINDER + theCommandID == 4023 || // MENU PRIMITIVE - SPHERE + theCommandID == 4024 || // MENU PRIMITIVE - TORUS + theCommandID == 4025 ) { // MENU PRIMITIVE - CONE + library = geomGUI->getLibrary( "libPrimitiveGUI.so" ); + } + else if( theCommandID == 4031 || // MENU GENERATION - PRISM + theCommandID == 4032 || // MENU GENERATION - REVOLUTION + theCommandID == 4033 || // MENU GENERATION - FILLING + theCommandID == 4034 ) { // MENU GENERATION - PIPE + library = geomGUI->getLibrary( "libGenerationGUI.so" ); + } + else if( theCommandID == 404 || // MENU ENTITY - SKETCHER + theCommandID == 407 ) { // MENU ENTITY - EXPLODE + library = geomGUI->getLibrary( "libEntityGUI.so" ); + } + else if( theCommandID == 4081 || // MENU BUILD - EDGE + theCommandID == 4082 || // MENU BUILD - WIRE + theCommandID == 4083 || // MENU BUILD - FACE + theCommandID == 4084 || // MENU BUILD - SHELL + theCommandID == 4085 || // MENU BUILD - SOLID + theCommandID == 4086 ) { // MENU BUILD - COMPUND + library = geomGUI->getLibrary( "libBuildGUI.so" ); + } + else if( theCommandID == 5011 || // MENU BOOLEAN - FUSE + theCommandID == 5012 || // MENU BOOLEAN - COMMON + theCommandID == 5013 || // MENU BOOLEAN - CUT + theCommandID == 5014 ) { // MENU BOOLEAN - SECTION + library = geomGUI->getLibrary( "libBooleanGUI.so" ); + } + else if( theCommandID == 5021 || // MENU TRANSFORMATION - TRANSLATION + theCommandID == 5022 || // MENU TRANSFORMATION - ROTATION + theCommandID == 5023 || // MENU TRANSFORMATION - LOCATION + theCommandID == 5024 || // MENU TRANSFORMATION - MIRROR + theCommandID == 5025 || // MENU TRANSFORMATION - SCALE + theCommandID == 5026 || // MENU TRANSFORMATION - OFFSET + theCommandID == 5027 || // MENU TRANSFORMATION - MULTI-TRANSLATION + theCommandID == 5028 ) { // MENU TRANSFORMATION - MULTI-ROTATION + library = geomGUI->getLibrary( "libTransformationGUI.so" ); + } + else if( theCommandID == 503 || // MENU OPERATION - PARTITION + theCommandID == 504 || // MENU OPERATION - ARCHIMEDE + theCommandID == 505 || // MENU OPERATION - FILLET + theCommandID == 506 || // MENU OPERATION - CHAMFER + theCommandID == 507 ) { // MENU OPERATION - CLIPPING RANGE + library = geomGUI->getLibrary( "libOperationGUI.so" ); + } + else if( theCommandID == 601 || // MENU REPAIR - SEWING + theCommandID == 603 || // MENU REPAIR - SUPPRESS FACES + theCommandID == 604 || // MENU REPAIR - SUPPRESS HOLE + theCommandID == 605 || // MENU REPAIR - SHAPE PROCESSING + theCommandID == 606 || // MENU REPAIR - CLOSE CONTOUR + theCommandID == 607 || // MENU REPAIR - REMOVE INTERNAL WIRES + theCommandID == 608 || // MENU REPAIR - ADD POINT ON EDGE + theCommandID == 609 || // MENU REPAIR - FREE BOUNDARIES + 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 + theCommandID == 708 ) { // MENU MEASURE - POINT COORDINATES + library = geomGUI->getLibrary( "libMeasureGUI.so" ); + } + else if( theCommandID == 800 || // MENU GROUP - CREATE + 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 + theCommandID == 9995 ) { // MENU BLOCKS - EXPLODE ON BLOCKS + library = geomGUI->getLibrary( "libBlocksGUI.so" ); } - else - return false; - return true; + // call method of corresponding GUI library + if ( library ) { + return library->OnGUIEvent( theCommandID, parent ); + } + else { + QAD_MessageBox::error1( parent, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_LIB_NOT_FOUND" ), tr( "GEOM_BUT_OK" ) ); + } + return false; } //================================================================================= -// function : OnKeyPress() -// purpose : [static] +// function : GeometryGUI::OnKeyPress() +// purpose : Called when any key is pressed by user [static] //================================================================================= bool GeometryGUI::OnKeyPress(QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame) { - GeometryGUI::GetOrCreateGeometryGUI(parent); - - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC) - return false; - else - return true; + GeometryGUI* geomGUI = GeometryGUI::GetGeomGUI(); + GUIMap::Iterator it; + bool bOk = true; + for ( it = geomGUI->myGUIMap.begin(); it != geomGUI->myGUIMap.end(); ++it ) + bOk = bOk && it.data()->OnKeyPress( pe, parent, studyFrame ); + return bOk; } //================================================================================= -// function : OnMouseMove() -// purpose : [static] manage mouse events +// function : GeometryGUI::OnMouseMove() +// purpose : Manages mouse move events [static] //================================================================================= bool GeometryGUI::OnMouseMove(QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame) { - GeometryGUI::GetOrCreateGeometryGUI(parent); - - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC) - return false; - else - return true; + GeometryGUI* geomGUI = GeometryGUI::GetGeomGUI(); + GUIMap::Iterator it; + bool bOk = true; + for ( it = geomGUI->myGUIMap.begin(); it != geomGUI->myGUIMap.end(); ++it ) + bOk = bOk && it.data()->OnMouseMove( pe, parent, studyFrame ); + return bOk; } //================================================================================= -// function : 0nMousePress() -// purpose : [static] manage mouse events +// function : GeometryGUI::0nMousePress() +// purpose : Manage mouse press events [static] //================================================================================= bool GeometryGUI::OnMousePress(QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame) { - GeometryGUI::GetOrCreateGeometryGUI(parent); - - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC) - return false; - - if(GeomGUI->myState == 0) { - if(!GeomGUI->LoadLibrary("libBasicGUI.so")) - return false; - - //Load Function OnMousePress - OSD_Function osdF = GeomGUI->myGUILibrary.DlSymb("OnMousePress"); - OMP (*f1) = NULL; - if(osdF != NULL) { - f1 = (bool (*) (QMouseEvent*, QAD_Desktop*, QAD_StudyFrame*)) osdF; - (*f1)(pe, parent, studyFrame); - } - } - - return false; + GeometryGUI* geomGUI = GeometryGUI::GetGeomGUI(); + GUIMap::Iterator it; + // OnMousePress() should return false if this event should be processed further + // (see OCCViewer_Viewer3d::onMousePress() for explanation) + bool processed = false; + for ( it = geomGUI->myGUIMap.begin(); it != geomGUI->myGUIMap.end(); ++it ) + processed = processed || it.data()->OnMousePress( pe, parent, studyFrame ); + return processed; } static void UpdateVtkSelection(QAD_Desktop* parent) @@ -321,60 +512,60 @@ static void UpdateVtkSelection(QAD_Desktop* parent) } } - //================================================================================= -// function : SetSettings() -// purpose : [static] +// function : GeometryGUI::SetSettings() +// purpose : Called when GEOM module is activated [static] //================================================================================= bool GeometryGUI::SetSettings(QAD_Desktop* parent) { - GeometryGUI::GetOrCreateGeometryGUI(parent); - QMenuBar* Mb = QAD_Application::getDesktop()->getMainMenuBar(); - QAD_Study* ActiveStudy = parent->getActiveStudy(); + GeometryGUI* geomGUI = GetGeomGUI(); + QMenuBar* Mb = parent->getMainMenuBar(); + QAD_Study* ActiveStudy = parent->getActiveStudy(); + + /* Wireframe or Shading */ int DisplayMode = 0; bool ViewOCC = false; - if(ActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { + if ( ActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)ActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); Handle(AIS_InteractiveContext) ic = v3d->getAISContext(); DisplayMode = ic->DisplayMode(); ViewOCC = true; } - else if(ActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { + else if (ActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { VTKViewer_RenderWindowInteractor* myRenderInter = ((VTKViewer_ViewFrame*)ActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); DisplayMode = myRenderInter->GetDisplayMode(); } - if(DisplayMode == 1) - Mb->changeItem(211, tr("GEOM_MEN_WIREFRAME")); + if( DisplayMode == 1 ) + Mb->changeItem( 211, tr( "GEOM_MEN_WIREFRAME" ) ); else - Mb->changeItem(211, tr("GEOM_MEN_SHADING")); + Mb->changeItem( 211, tr( "GEOM_MEN_SHADING" ) ); - /* Add in Study */ + /* Add in Study - !!!ALWAYS TRUE!!! */ /////// VSR : TO BE REMOVED QString AddInStudy = QAD_CONFIG->getSetting("Geometry:SettingsAddInStudy"); int Settings_AddInStudy; - if(!AddInStudy.isEmpty()) + /*if(!AddInStudy.isEmpty()) Settings_AddInStudy = AddInStudy.toInt(); else - Settings_AddInStudy = 1; + */ + Settings_AddInStudy = 1; Mb->setItemChecked(411, Settings_AddInStudy); - /* step value */ QString S = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep"); if(S.isEmpty()) QAD_CONFIG->addSetting("Geometry:SettingsGeomStep", "100"); - /* isos */ int count = ActiveStudy->getStudyFramesCount(); for(int i = 0; i < count; i++) { if(ActiveStudy->getStudyFrame(i)->getTypeView() == VIEW_OCC) { OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)ActiveStudy->getStudyFrame(i)->getRightFrame()->getViewFrame())->getViewer(); Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); - + QString IsoU = QAD_CONFIG->getSetting("Geometry:SettingsIsoU"); QString IsoV = QAD_CONFIG->getSetting("Geometry:SettingsIsoV"); if(!IsoU.isEmpty()) @@ -384,156 +575,412 @@ bool GeometryGUI::SetSettings(QAD_Desktop* parent) } } - Mb->setItemEnabled(404, ViewOCC);//SKETCHER + //Mb->setItemEnabled(404, ViewOCC); // SKETCHER + Mb->setItemEnabled(603, ViewOCC); // SuppressFace + Mb->setItemEnabled(604, ViewOCC); // SuppressHole + Mb->setItemEnabled(606, ViewOCC); // CloseContour + Mb->setItemEnabled(607, ViewOCC); // RemoveInternalWires + Mb->setItemEnabled(608, ViewOCC); // AddPointOnEdge +// Mb->setItemEnabled(609, ViewOCC); // Free boundaries + Mb->setItemEnabled(413, ViewOCC); // Isos Settings - Mb->setItemEnabled(603, ViewOCC);//SuppressFace - Mb->setItemEnabled(604, ViewOCC);//SuppressHole - - Mb->setItemEnabled(413, ViewOCC);// ShadingColor Settings - Mb->setItemEnabled(414, ViewOCC);// Isos Settings + Mb->setItemEnabled( 800, ViewOCC ); // Create Group + Mb->setItemEnabled( 801, ViewOCC ); // Edit Group + Mb->setItemEnabled(9998, ViewOCC); // MENU BLOCKS - MULTI-TRANSFORMATION + + // PAL5356: update VTK selection ::UpdateVtkSelection(parent); - - return true; + bool bOk = true; + GUIMap::Iterator it; + for ( it = geomGUI->myGUIMap.begin(); it != geomGUI->myGUIMap.end(); ++it ) + bOk = bOk && it.data()->SetSettings( parent ); + + // MZN: Enable/disable "Clipping range" menu item(from GEOM_CLIPPING variable) + if (getenv( "GEOM_CLIPPING" ) == NULL) + { + QMenuItem* mi = Mb->findItem(50); + if (mi && mi->popup()) + mi->popup()->removeItem(507); + } + + return bOk; } +//======================================================================= +// function : GeometryGUI::Deactivate() +// purpose : Called when GEOM module is deactivated [ static ] +//======================================================================= +void GeometryGUI::Deactivate() +{ + GeometryGUI* geomGUI = GetGeomGUI(); + GetGeomGUI()->EmitSignalCloseAllDialogs(); + GUIMap::Iterator it; + for ( it = geomGUI->myGUIMap.begin(); it != geomGUI->myGUIMap.end(); ++it ) + it.data()->Deactivate(); +} //================================================================================= -// function : DefinePopup() -// purpose : [static] +// function : GeometryGUI::DefinePopup() +// purpose : Called from desktop to define popup menu [static] //================================================================================= -void GeometryGUI::DefinePopup(QString & theContext, QString & theParent, QString & theObject) +void GeometryGUI::DefinePopup(QString& theContext, QString& theParent, QString& theObject) { - GeometryGUI::GetOrCreateGeometryGUI(QAD_Application::getDesktop()); - + GeometryGUI* geomGUI = GetGeomGUI(); QAD_Study* ActiveStudy = QAD_Application::getDesktop()->getActiveStudy(); - SALOME_Selection* Sel = SALOME_Selection::Selection(ActiveStudy->getSelection()); - theObject = ""; + SALOME_Selection* Sel = SALOME_Selection::Selection(ActiveStudy->getSelection()); + + theObject = ""; theContext = ""; - if((theParent.compare("Viewer") == 0)) { - if(Sel->IObjectCount() == 0) + if ( theParent == "Viewer" ) { + if ( Sel->IObjectCount() == 0 ) theContext = "NothingSelected"; } - if(Sel->IObjectCount() == 1) { + if ( Sel->IObjectCount() == 1 ) { Handle(SALOME_InteractiveObject) IO = Sel->firstIObject(); - if(IO->hasEntry()) { - SALOMEDS::SObject_var sobj = ActiveStudy->getStudyDocument()->FindObjectID(IO->getEntry()); - if(!sobj->_is_nil()) { + if( IO->hasEntry() ) { + SALOMEDS::SObject_var sobj = ActiveStudy->getStudyDocument()->FindObjectID( IO->getEntry() ); + if ( !sobj->_is_nil() ) { SALOMEDS::SComponent_var scomp = sobj->GetFatherComponent(); - if(strcmp(scomp->GetID(), IO->getEntry()) == 0) { + if ( !strcmp(scomp->GetID(), IO->getEntry() ) ) { // component is selected theObject = "Component"; } + else { + GEOM::GEOM_Object_var aGObj = GEOM::GEOM_Object::_narrow( sobj->GetObject() ); + if ( !CORBA::is_nil( aGObj ) ) { + switch( aGObj->GetType() ) { + case GEOM_GROUP: + theObject = "Group"; + break; + default: + theObject = "Shape"; + break; + } + } + } } } } - - return; } - //================================================================================= -// function : CustomPopup() -// purpose : [static] +// function : GeometryGUI::CustomPopup() +// purpose : Called from desktop to create popup menu [static] //================================================================================= bool GeometryGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* popup, const QString& theContext, const QString& theParent, const QString& theObject) { - GeometryGUI::GetOrCreateGeometryGUI(parent); + GeometryGUI* geomGUI = GetGeomGUI(); + + // Deactivate any non modal dialog box to get the neutral point + geomGUI->EmitSignalDeactivateDialog(); + QAD_Study* anActiveStudy = parent->getActiveStudy(); + QAD_StudyFrame* aStudyFrame = anActiveStudy->getActiveStudyFrame(); + QAD_ViewFrame* aViewFrame = aStudyFrame->getRightFrame()->getViewFrame(); + SALOME_Selection* Sel = SALOME_Selection::Selection(anActiveStudy->getSelection()); + QString parentComponent = ((SALOMEGUI_Desktop*)parent)->getComponentFromSelection(); + bool isOCCViewer = aViewFrame->getTypeView() == VIEW_OCC; + bool isVTKViewer = aViewFrame->getTypeView() == VIEW_VTK; + int aDisplayMode = 0; + QString objectName; + + if ( aViewFrame->getTypeView() == VIEW_OCC ) + aDisplayMode = ((OCCViewer_ViewFrame*)aViewFrame)->getViewer()->getAISContext()->DisplayMode(); + else if ( aViewFrame->getTypeView() == VIEW_VTK ) + aDisplayMode = ((VTKViewer_ViewFrame*)aViewFrame)->getRWInteractor()->GetDisplayMode(); + + int nbSel = Sel->IObjectCount(); + + if( nbSel == 0 ) { + ////// NOTHING SELECTED + popup->clear(); + } + else if ( nbSel == 1 ) { + ////// SINGLE OBJECT SELECTION + if ( parentComponent != parent->getActiveComponent() ) { + ////// selected object does not belong to GEOM module: + // remove all commands except Display/Erase... + while ( 1 ) { + int id = popup->idAt( 0 ); + if ( id <= QAD_TopLabel_Popup_ID ) + popup->removeItemAt( 0 ); + else + break; + } + } + else { + ////// selected object belong to the GEOM module + // get interactive object + Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject(); + objectName = IObject->getName(); + // if object has entry get SObject + SALOMEDS::SObject_var SO; + if ( IObject->hasEntry() ) + SO = anActiveStudy->getStudyDocument()->FindObjectID( IObject->getEntry() ); + + if ( theObject == "Component" ) { + ////// menu for component + popup->removeItem( QAD_DisplayOnly_Popup_ID ); + if ( !isOCCViewer && !isVTKViewer ) { + popup->removeItem( QAD_Display_Popup_ID ); + popup->removeItem( QAD_Erase_Popup_ID ); + } + } + else { + ////// not component (should be shape) + if ( IObject->hasEntry() ) /////// VSR : TO BE REMOVED + popup->removeItem( 804 ); // "Add in Study" + + // Here could be analysis of the geom shape's type + // ... // + + SALOMEDS::GenericAttribute_var aTmpAttr; + if( SO->_is_nil() || SO->GetFatherComponent()->FindAttribute( aTmpAttr, "AttributeIOR") ) + popup->removeItem( 9024 ); // "Open" /////// VSR : TO BE REMOVED + + if ( !isOCCViewer && theParent == "ObjectBrowser" ) { + if ( theObject == "Shape" ) + popup->removeItem( 800 ); // Create Group + else if ( theObject == "Group" ) + popup->removeItem( 801 ); // Edit Group + } - if(!GeomGUI->LoadLibrary("libGEOMBase.so")) - return false; + if ( isOCCViewer || isVTKViewer ) { + ////// current viewer is OCC or VTK + SALOME_Prs* prs = aViewFrame->CreatePrs( IObject->getEntry() ); + if ( aViewFrame->isVisible( IObject ) ) { + ////// object is already displayed in the viewer + popup->removeItem( QAD_Display_Popup_ID ); + if ( isOCCViewer ) { + ////// OCC viewer only + OCCViewer_Prs* occPrs = dynamic_cast( prs ); + if ( occPrs && !occPrs->IsNull() ) { + AIS_ListOfInteractive ioList; + occPrs->GetObjects( ioList ); + QMenuItem* mi = popup->findItem( 803 ); + if ( mi && mi->popup() ) { + if ( ioList.First()->DisplayMode() == 0 ) + mi->popup()->setItemChecked( 80311, true ); // "Wireframe" + else if ( ioList.First()->DisplayMode() == 1 ) + mi->popup()->setItemChecked( 80312, true ); // "Shading" + else if ( ioList.First()->DisplayMode() < 0 ) + mi->popup()->setItemChecked( aDisplayMode == 0 ? 80311 : 80312 , true ); // "Wireframe" or "Shading" + } + } + } + else { + ////// VTK viewer only + popup->removeItem( 8034 ); // "Isos" + VTKViewer_Prs* vtkPrs = dynamic_cast( prs ); + if ( vtkPrs && !vtkPrs->IsNull() ) { + vtkActorCollection* actorList = vtkPrs->GetObjects(); + actorList->InitTraversal(); + SALOME_Actor* ac = SALOME_Actor::SafeDownCast( actorList->GetNextActor() ); + QMenuItem* mi = popup->findItem( 803 ); + if ( ac && mi && mi->popup() ) { + if ( ac->getDisplayMode() == 0 ) + mi->popup()->setItemChecked( 80311, true ); // "Wireframe" + else if ( ac->getDisplayMode() == 1 ) + mi->popup()->setItemChecked( 80312, true ); // "Shading" + else + mi->popup()->setItemChecked( aDisplayMode == 0 ? 80311 : 80312 , true ); // "Wireframe" or "Shading" + } + } + } + } + else { + ////// object is not yet displayed in the viewer + popup->removeItem( 803 ); // "Display Mode" + popup->removeItem( 8032 ); // "Color" + popup->removeItem( 8033 ); // "Transparency" + popup->removeItem( 8034 ); // "Isos" + popup->removeItem( QAD_Erase_Popup_ID ); + } + delete prs; + } + else { + ////// other viewer type (neither OCC nor VTK) + popup->removeItem( 803 ); // "Display Mode" + popup->removeItem( 8032 ); // "Color" + popup->removeItem( 8033 ); // "Transparency" + popup->removeItem( 8034 ); // "Isos" + popup->removeItem( QAD_Display_Popup_ID ); + popup->removeItem( QAD_DisplayOnly_Popup_ID ); + popup->removeItem( QAD_Erase_Popup_ID ); + } + } + } + } + else { + ////// MULTIPLE SELECTION + if ( parentComponent != parent->getActiveComponent() ) { + ////// not GEOM module objects or objects belong to different modules + // remove all commands except Display/Erase... + while ( 1 ) { + int id = popup->idAt( 0 ); + if ( id <= QAD_TopLabel_Popup_ID ) + popup->removeItemAt( 0 ); + else + break; + } + if ( parentComponent.isNull() ) { + ////// objects belong to different modules + popup->removeItem(QAD_Display_Popup_ID); + popup->removeItem(QAD_DisplayOnly_Popup_ID); + popup->removeItem(QAD_Erase_Popup_ID); + } + else { + objectName = tr( "GEOM_MEN_POPUP_NAME" ).arg( nbSel ); + } + } + else { + ////// all selected objects belong to GEOM module + popup->removeItem( 901 ); // "Rename" + + SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); + bool isComponent = false; + bool needOpen = false; + bool needDisplay = false; + bool needErase = false; + int needToPublish = 0; + + for( ;It.More();It.Next() ) { + Handle(SALOME_InteractiveObject) anIObject = It.Value(); + + if ( aViewFrame->isVisible( anIObject ) ) + needErase = true; + else + needDisplay = true; + + if( anIObject->hasEntry() ) { + needToPublish = -1; /////// VSR : TO BE REMOVED + SALOMEDS::SObject_var obj = anActiveStudy->getStudyDocument()->FindObjectID( anIObject->getEntry() ); + SALOMEDS::GenericAttribute_var aTmpAttr; + if ( !obj->_is_nil() && !obj->GetFatherComponent()->FindAttribute( aTmpAttr, "AttributeIOR" ) ) + needOpen = true; /////// VSR : TO BE REMOVED + if ( !obj->_is_nil() && QString( obj->GetID() ) == QString( obj->GetFatherComponent()->GetID() ) ) + isComponent = true; + } + else { + if ( needToPublish != -1 ) needToPublish = 1; + } + } + if( needOpen || ( !isOCCViewer && !isVTKViewer ) ) { + ////// Data is not loaded yet or current viewer is neither OCC nor VTK + popup->removeItem( 803 ); // "Display Mode" + popup->removeItem( 8032 ); // "Color" + popup->removeItem( 8033 ); // "Transparency" + popup->removeItem( 8034 ); // "Isos" + popup->removeItem( 804 ); // "Add in Study" + popup->removeItem( QAD_DisplayOnly_Popup_ID ); + popup->removeItem( QAD_Display_Popup_ID ); + popup->removeItem( QAD_Erase_Popup_ID ); + } + else { + popup->removeItem( 9024 ); // "Open" + if ( needToPublish <= 0 ) + popup->removeItem( 804 ); // "Add in Study" + + if( isComponent ) { + popup->removeItem( 803 ); // "Display Mode" + popup->removeItem( 8032 ); // "Color" + popup->removeItem( 8033 ); // "Transparency" + popup->removeItem( 8034 ); // "Isos" + popup->removeItem( QAD_DisplayOnly_Popup_ID ); + } + + if ( !needDisplay ) + popup->removeItem( QAD_Display_Popup_ID ); + if ( !needErase ) + popup->removeItem( QAD_Erase_Popup_ID ); + if ( !isOCCViewer ) + popup->removeItem( 8034 ); // "Isos" + } + } + } - //Load Function BuildPresentation - OSD_Function osdF = GeomGUI->myGUILibrary.DlSymb("CustomPopup"); - CP (*f1) = NULL; - if(osdF != NULL) { - f1 = (bool (*) (QAD_Desktop*, QPopupMenu*, const QString&, - const QString&, const QString&)) osdF; - (*f1)(parent, popup, theContext, theParent, theObject); + // check popup for unnecessary separators + QAD_Tools::checkPopup( popup ); + // find popup menu's TopLabel item (with title) + int topItem = popup->indexOf( QAD_TopLabel_Popup_ID ); + if ( topItem >= 0 ) { + // remove popup menu's title item + popup->removeItem( QAD_TopLabel_Popup_ID ); + if ( theParent == "Viewer" && !objectName.isEmpty() && popup->count() > 0 ) { + // set bold font for popup menu's title + QFont f = QApplication::font(); f.setBold( TRUE ); + popup->removeItem( QAD_TopLabel_Popup_ID ); + popup->insertItem( new CustomItem( objectName, f ), QAD_TopLabel_Popup_ID, topItem ); + } } - else - return false; - return true; + return false; } - //================================================================================= -// function : activeStudyChanged() +// function : GeometryGUI::ActiveStudyChanged() // purpose : static //================================================================================= bool GeometryGUI::ActiveStudyChanged(QAD_Desktop* parent) { - GeometryGUI::GetOrCreateGeometryGUI(parent); + GeometryGUI* geomGUI = GetGeomGUI(); + QAD_Study* ActiveStudy = parent->getActiveStudy(); + QMenuBar* Mb = QAD_Application::getDesktop()->getMainMenuBar(); + int DisplayMode = 0; + bool ViewOCC = false; - if(GeomGUI != 0) { - QMenuBar* Mb = QAD_Application::getDesktop()->getMainMenuBar(); - bool ViewOCC = false; - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) - ViewOCC = true; + if( ActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)ActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + Handle(AIS_InteractiveContext) ic = v3d->getAISContext(); + DisplayMode = ic->DisplayMode(); + ViewOCC = true; + } + else if( ActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { + VTKViewer_RenderWindowInteractor* myRenderInter = ((VTKViewer_ViewFrame*)ActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); + DisplayMode = myRenderInter->GetDisplayMode(); + } - Mb->setItemEnabled(404, ViewOCC);//SKETCHER + if( DisplayMode == 1 ) + Mb->changeItem( 211, tr( "GEOM_MEN_WIREFRAME" ) ); + else + Mb->changeItem( 211, tr( "GEOM_MEN_SHADING" ) ); - Mb->setItemEnabled(603, ViewOCC);//SuppressFace - Mb->setItemEnabled(604, ViewOCC);//SuppressHole - - Mb->setItemEnabled(413, ViewOCC);// ShadingColor Settings - Mb->setItemEnabled(414, ViewOCC);// Isos Settings + //Mb->setItemEnabled( 404, ViewOCC ); // SKETCHER + Mb->setItemEnabled( 603, ViewOCC ); // SuppressFace + Mb->setItemEnabled( 604, ViewOCC ); // SuppressHole + Mb->setItemEnabled( 606, ViewOCC ); // CloseContour + Mb->setItemEnabled( 413, ViewOCC ); // Isos Settings + Mb->setItemEnabled(9998, ViewOCC ); // MENU BLOCKS - MULTI-TRANSFORMATION - GeomGUI->EmitSignalCloseAllDialogs(); - GeomGUI = 0; - } + geomGUI->EmitSignalCloseAllDialogs(); // PAL5356: update VTK selection - ::UpdateVtkSelection(parent); + ::UpdateVtkSelection( parent ); - return true; + bool bOk = true; + GUIMap::Iterator it; + for ( it = geomGUI->myGUIMap.begin(); it != geomGUI->myGUIMap.end(); ++it ) + bOk = bOk && it.data()->ActiveStudyChanged( parent ); + return bOk; } - //======================================================================= -// function : BuildPresentation() +// function : GeometryGUI::BuildPresentation() // purpose : static //======================================================================= -void GeometryGUI::BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO) +void GeometryGUI::BuildPresentation( const Handle(SALOME_InteractiveObject)& theIO, + QAD_ViewFrame* theViewFrame ) { - GeometryGUI::GetOrCreateGeometryGUI(QAD_Application::getDesktop()); - - if(!GeomGUI->LoadLibrary("libDisplayGUI.so")) - return; - - //Load Function BuildPresentation - OSD_Function osdF = GeomGUI->myGUILibrary.DlSymb("BuildPresentation"); - BP (*f1) = NULL; - if(osdF != NULL) { - f1 = (void (*) (const Handle(SALOME_InteractiveObject)&)) osdF; - (*f1)(theIO); - } - return; + GEOM_Displayer().Display( theIO, false, theViewFrame ); } - void GeometryGUI::SupportedViewType(int* buffer, int bufferSize) { if(!buffer || !bufferSize) return; buffer[0] = (int)VIEW_OCC; if (--bufferSize) buffer[1] = (int)VIEW_VTK; } - -void GeometryGUI::Deactivate() -{ - if ( GeomGUI ) - GeomGUI->EmitSignalCloseAllDialogs(); -} - -static GeometryGUI aGUI(""); -extern "C" -{ - Standard_EXPORT SALOMEGUI* GetComponentGUI() { - return &aGUI; - } -} diff --git a/src/GEOMGUI/GeometryGUI.h b/src/GEOMGUI/GeometryGUI.h index 06649f622..255c46f12 100644 --- a/src/GEOMGUI/GeometryGUI.h +++ b/src/GEOMGUI/GeometryGUI.h @@ -30,7 +30,18 @@ #define GEOMETRYGUI_H #include "SALOMEGUI.h" -#include "GEOMContext.h" + +#include "GEOMGUI.h" +#include "GEOM_Client.hxx" +#include "SALOME_InteractiveObject.hxx" +#include + +#include "gp_Ax3.hxx" + +typedef QMap GUIMap; + +class QDialog; +class QPopupMenu; //================================================================================= // class : GeometryGUI @@ -38,27 +49,74 @@ //================================================================================= class GeometryGUI : public SALOMEGUI { - Q_OBJECT /* for QT compatibility */ + Q_OBJECT; + +protected: + // Constructor + GeometryGUI(); // hide constructor to avoid direct creation + // get or load GUI library by name + GEOMGUI* getLibrary( const QString& libraryName ); -public : - GeometryGUI( const QString& name = "", QObject* parent = 0 ); +public: + // Destructor ~GeometryGUI(); + + // Get the only GeometryGUI object + static GeometryGUI* GetGeomGUI(); + + static CORBA::ORB_var GetORB(); + + GEOM::GEOM_Gen_ptr GetGeomGen() { return myComponentGeom; } + GEOM_Client& GetShapeReader() { return myShapeReader; } + Standard_CString& GetFatherior() { return myFatherior; } + void SetState( const int state ) { myState = state; } + int GetState() const { return myState; } - static GEOMContext* GetOrCreateGeometryGUI(QAD_Desktop* desktop); - - /* Managed by IAPP */ + // Get active dialog box + QDialog* GetActiveDialogBox(){ return myActiveDialogBox; } + // Set active dialog box + void SetActiveDialogBox( QDialog* aDlg ); + + // Non modal dialog boxes management + void EmitSignalDeactivateDialog(); + void EmitSignalCloseAllDialogs(); + void EmitSignalDefaultStepValueChanged( double newVal ); + + // The following methods are called from IAPP virtual bool OnGUIEvent(int theCommandID, QAD_Desktop* parent); virtual bool OnMousePress(QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame); virtual bool OnMouseMove(QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame); virtual bool OnKeyPress(QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame); virtual bool SetSettings(QAD_Desktop* parent); virtual bool ActiveStudyChanged(QAD_Desktop* parent); - virtual void BuildPresentation(const Handle(SALOME_InteractiveObject)&); + virtual void Deactivate(); + virtual void BuildPresentation( const Handle(SALOME_InteractiveObject)&, + QAD_ViewFrame* = 0 ); + virtual void SupportedViewType (int* buffer, int bufferSize); virtual void DefinePopup(QString & theContext, QString & theParent, QString & theObject); virtual bool CustomPopup(QAD_Desktop* parent, QPopupMenu* popup, const QString& theContext, const QString& theParent, const QString& theObject); - virtual void SupportedViewType (int* buffer, int bufferSize); - virtual void Deactivate (); + + // The Working Plane management + void SetWorkingPlane(gp_Ax3 WorkingPlane) { myWorkingPlane = WorkingPlane; }; + gp_Ax3 GetWorkingPlane() { return myWorkingPlane; }; + void ActiveWorkingPlane(); + +signals : + void SignalDeactivateActiveDialog(); + void SignalCloseAllDialogs(); + void SignalDefaultStepValueChanged( double newVal ); + +private: + static GeometryGUI* myContext; // the only GeometryGUI object + + GUIMap myGUIMap; // GUI libraries map + QDialog* myActiveDialogBox; // active dialog box + GEOM_Client myShapeReader; // geom shape reader + Standard_CString myFatherior; + GEOM::GEOM_Gen_var myComponentGeom; // GEOM engine + int myState; // identify a method + gp_Ax3 myWorkingPlane; }; #endif diff --git a/src/GEOMGUI/GeometryGUI_Swig.cxx b/src/GEOMGUI/GeometryGUI_Swig.cxx index bb7159bbb..ead4659da 100644 --- a/src/GEOMGUI/GeometryGUI_Swig.cxx +++ b/src/GEOMGUI/GeometryGUI_Swig.cxx @@ -26,9 +26,8 @@ // Module : GEOM // $Header$ -using namespace std; #include "GeometryGUI_Swig.hxx" -#include "utilities.h" +#include "SALOMEGUI_Swig.hxx" #include "QAD_Application.h" #include "QAD_Desktop.h" @@ -38,6 +37,7 @@ using namespace std; #include "SALOMEGUI_ImportOperation.h" #include "OCCViewer_Viewer3d.h" +#include "OCCViewer_ViewFrame.h" #include #include #include @@ -51,6 +51,8 @@ using namespace std; #include #include +#include "SALOME_Event.hxx" + #include "VTKViewer_RenderWindowInteractor.h" #include "VTKViewer_ViewFrame.h" @@ -60,8 +62,18 @@ using namespace std; #include "GEOM_AssemblyBuilder.h" #include "GEOM_InteractiveObject.hxx" +#include "utilities.h" + +using namespace std; + static GEOM_Client ShapeReader; + +template inline TViewFrame* GetFrame(QAD_Study* theStudy){ + return dynamic_cast(SALOME::GetViewFrame(theStudy)); +} + + GEOM_Swig::GEOM_Swig() { // MESSAGE("Constructeur"); @@ -82,27 +94,29 @@ void GEOM_Swig::createAndDisplayGO(const char* Entry) Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM"); GEOM::GEOM_Gen_var Geom = GEOM::GEOM_Gen::_narrow(comp); - Standard_CString Fatherior = ""; + CORBA::String_var aFatherIOR; SALOMEDS::SComponent_var father = aStudy->FindComponent("GEOM"); aStudyBuilder->DefineComponentInstance( father, Geom ); - father->ComponentIOR( Fatherior ); + father->ComponentIOR(aFatherIOR); SALOMEDS::SObject_var fatherSF = aStudy->FindObjectID(ActiveStudy->getActiveStudyFrame()->entry()); SALOMEDS::SObject_var obj = aStudy->FindObjectID(Entry); SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeName_var aName; SALOMEDS::AttributeIOR_var anIOR; // Create new actor if ( !obj->FindAttribute(anAttr, "AttributeIOR")) return; anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - GEOM::GEOM_Shape_var aShape = Geom->GetIORFromString(anIOR->Value()); + CORBA::String_var anIORValue = anIOR->Value(); + + GEOM::GEOM_Object_var aShape = Geom->GetIORFromString(anIORValue); TopoDS_Shape Shape = ShapeReader.GetShape(Geom,aShape); if ( !obj->_is_nil() ) { if (obj->FindAttribute(anAttr, "AttributeName")) { - aName = SALOMEDS::AttributeName::_narrow(anAttr); + SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr); + CORBA::String_var aNameValue = aName->Value(); // open transaction QAD_Operation* op = new SALOMEGUI_ImportOperation( ActiveStudy ); op->start(); @@ -112,60 +126,65 @@ void GEOM_Swig::createAndDisplayGO(const char* Entry) // commit transaction op->finish(); - if ( ActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { // VTK - //vtkQGLRenderWindowInteractor* myRenderInter = ActiveStudy->getActiveStudyFrame()->getRightFrame()->getVTKView()->getRWInteractor(); - VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)ActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); - int themode = myRenderInter->GetDisplayMode(); + Handle(GEOM_InteractiveObject) anIO = new GEOM_InteractiveObject(const_cast(anIORValue.in()), + const_cast(aFatherIOR.in()), + "GEOM", + const_cast(obj->GetID())); - vtkActorCollection* theActors = - GEOM_AssemblyBuilder::BuildActors(Shape,0,themode,Standard_True); - theActors->InitTraversal(); - vtkActor* anActor = (vtkActor*)theActors->GetNextActor(); - while(!(anActor==NULL)) { - GEOM_Actor* GActor = GEOM_Actor::SafeDownCast( anActor ); - Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(anIOR->Value(), - Fatherior, - "GEOM"); - IO->setEntry(obj->GetID()); - GActor->setIO( IO ); - GActor->setName( aName->Value() ); - - myRenderInter->Display(GActor); - anActor = (vtkActor*)theActors->GetNextActor(); - } - myRenderInter->Update(); - } - else if ( ActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) // OCC - { - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)ActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - // QAD_Viewer3d* v3d = ActiveStudy->getActiveStudyFrame()->getViewerOCC(); - Handle(AIS_InteractiveContext) ic = v3d->getAISContext(); - Handle(GEOM_AISShape) aSh = new GEOM_AISShape(Shape, aName->Value()); - Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(anIOR->Value(), - Fatherior, - "GEOM"); - - IO->setEntry(obj->GetID()); - aSh->setIO( IO ); - aSh->setName( aName->Value() ); - ic->Display (aSh); - ic->AddOrRemoveCurrentObject(aSh, true); - } + class TEvent: public SALOME_Event{ + QAD_Study* myStudy; + TopoDS_Shape myShape; + Handle(SALOME_InteractiveObject) myIO; + const char* myName; + public: + TEvent(QAD_Study* theStudy, TopoDS_Shape theShape, + const Handle(SALOME_InteractiveObject)& theIO, + const char* theName): + myStudy(theStudy), myShape(theShape), + myIO(theIO), myName(theName) + {} + virtual void Execute(){ + if(VTKViewer_ViewFrame* aViewFrame = GetFrame(myStudy)){ + VTKViewer_RenderWindowInteractor* myRenderInter= aViewFrame->getRWInteractor(); + int aMode = myRenderInter->GetDisplayMode(); + + vtkActorCollection* theActors = GEOM_AssemblyBuilder::BuildActors(myShape,0,aMode,true); + theActors->InitTraversal(); + while(vtkActor* anActor = theActors->GetNextActor()){ + GEOM_Actor* GActor = GEOM_Actor::SafeDownCast(anActor); + GActor->setName(const_cast(myName)); + GActor->setIO(myIO); + myRenderInter->Display(GActor); + } + myRenderInter->Update(); + }else if(OCCViewer_ViewFrame* aViewFrame = GetFrame(myStudy)){ + Handle(AIS_InteractiveContext) ic = aViewFrame->getViewer()->getAISContext(); + Handle(GEOM_AISShape) aSh = new GEOM_AISShape(myShape,const_cast(myName)); + aSh->setName(const_cast(myName)); + aSh->setIO(myIO); + + ic->Display(aSh); + ic->AddOrRemoveCurrentObject(aSh,true); + } + myStudy->updateObjBrowser(true); + } + }; + ProcessVoidEvent(new TEvent(ActiveStudy,Shape,anIO,aNameValue.in())); } } - ActiveStudy->updateObjBrowser( true ); } + int GEOM_Swig::getIndexTopology(const char* SubIOR, const char* IOR) { Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM"); GEOM::GEOM_Gen_var Geom = GEOM::GEOM_Gen::_narrow(comp); - GEOM::GEOM_Shape_var aMainShape = Geom->GetIORFromString(IOR); - TopoDS_Shape shape = ShapeReader.GetShape(Geom, aMainShape); + GEOM::GEOM_Object_var aMainShape = Geom->GetIORFromString(IOR); + TopoDS_Shape shape = ShapeReader.GetShape(Geom, aMainShape); - GEOM::GEOM_Shape_var aSubShape = Geom->GetIORFromString(SubIOR); - TopoDS_Shape subshape = ShapeReader.GetShape(Geom, aSubShape); + GEOM::GEOM_Object_var aSubShape = Geom->GetIORFromString(SubIOR); + TopoDS_Shape subshape = ShapeReader.GetShape(Geom, aSubShape); int index = 1; if(subshape.ShapeType() == TopAbs_COMPOUND) { @@ -205,7 +224,7 @@ const char* GEOM_Swig::getShapeTypeString(const char* IOR) Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM"); GEOM::GEOM_Gen_var Geom = GEOM::GEOM_Gen::_narrow(comp); - GEOM::GEOM_Shape_var aShape = Geom->GetIORFromString(IOR); + GEOM::GEOM_Object_var aShape = Geom->GetIORFromString(IOR); TopoDS_Shape shape = ShapeReader.GetShape(Geom, aShape); if( shape.IsNull() ) { @@ -273,13 +292,14 @@ const char* GEOM_Swig::getShapeTypeIcon(const char* IOR) Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM"); GEOM::GEOM_Gen_var Geom = GEOM::GEOM_Gen::_narrow(comp); - GEOM::GEOM_Shape_var aShape = Geom->GetIORFromString(IOR); + GEOM::GEOM_Object_var aShape = Geom->GetIORFromString(IOR); + TopoDS_Shape shape = ShapeReader.GetShape(Geom, aShape); - if( aShape->_is_nil() ) { + if( shape.IsNull() ) { return "None" ; } - switch (aShape->ShapeType() ) + switch (shape.ShapeType() ) { case TopAbs_COMPOUND: { return "ICON_OBJBROWSER_COMPOUND" ;} @@ -301,61 +321,87 @@ const char* GEOM_Swig::getShapeTypeIcon(const char* IOR) return "None"; } -void GEOM_Swig::setDisplayMode(const char* Entry, int mode) +void GEOM_Swig::setDisplayMode(const char* theEntry, int theMode) { - QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy(); - Handle(SALOME_InteractiveObject) IO = - myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->FindIObject( Entry ); - - if ( myStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { // VTK - VTKViewer_RenderWindowInteractor* myRenderInter = - ((VTKViewer_ViewFrame*)myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); - - myRenderInter->SwitchRepresentation(IO, mode); - myRenderInter->Update(); - } - else if ( myStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) // OCC - { - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - v3d->SwitchRepresentation(IO, mode); + QAD_Study* aStudy = QAD_Application::getDesktop()->getActiveStudy(); + Handle(SALOME_InteractiveObject) anIO = SALOME::FindIObject(aStudy,theEntry); + + class TEvent: public SALOME_Event{ + QAD_Study* myStudy; + Handle(SALOME_InteractiveObject) myIO; + int myParam; + public: + TEvent(QAD_Study* theStudy, const Handle(SALOME_InteractiveObject)& theIO, int theParam): + myStudy(theStudy), myIO(theIO), myParam(theParam) + {} + virtual void Execute(){ + if(VTKViewer_ViewFrame* aViewFrame = GetFrame(myStudy)){ + VTKViewer_RenderWindowInteractor* myRenderInter= aViewFrame->getRWInteractor(); + myRenderInter->SetDisplayMode(myIO,myParam); + myRenderInter->Update(); + }else if(OCCViewer_ViewFrame* aViewFrame = GetFrame(myStudy)){ + OCCViewer_Viewer3d* v3d = aViewFrame->getViewer(); + v3d->SwitchRepresentation(myIO,myParam); + } } + }; + + ProcessVoidEvent(new TEvent(aStudy,anIO,theMode)); } -void GEOM_Swig::setColor(const char* Entry, int red, int green, int blue) +void GEOM_Swig::setColor(const char* theEntry, int red, int green, int blue) { - QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy(); - QColor c = QColor (red, green, blue); - Handle(SALOME_InteractiveObject) IO = - myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->FindIObject( Entry ); - - if ( myStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { // VTK - VTKViewer_RenderWindowInteractor* myRenderInter = - ((VTKViewer_ViewFrame*)myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); - myRenderInter->SetColor(IO,c); - myRenderInter->Update(); - } - else if ( myStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) // OCC - { - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - v3d->SetColor(IO,c); + QAD_Study* aStudy = QAD_Application::getDesktop()->getActiveStudy(); + Handle(SALOME_InteractiveObject) anIO = SALOME::FindIObject(aStudy,theEntry); + QColor aColor(red,green,blue); + + class TEvent: public SALOME_Event{ + QAD_Study* myStudy; + Handle(SALOME_InteractiveObject) myIO; + QColor myParam; + public: + TEvent(QAD_Study* theStudy, const Handle(SALOME_InteractiveObject)& theIO, const QColor& theParam): + myStudy(theStudy), myIO(theIO), myParam(theParam) + {} + virtual void Execute(){ + if(VTKViewer_ViewFrame* aViewFrame = GetFrame(myStudy)){ + VTKViewer_RenderWindowInteractor* myRenderInter= aViewFrame->getRWInteractor(); + myRenderInter->SetColor(myIO,myParam); + myRenderInter->Update(); + }else if(OCCViewer_ViewFrame* aViewFrame = GetFrame(myStudy)){ + OCCViewer_Viewer3d* v3d = aViewFrame->getViewer(); + v3d->SetColor(myIO,myParam); + } } + }; + + ProcessVoidEvent(new TEvent(aStudy,anIO,aColor)); } -void GEOM_Swig::setTransparency(const char* Entry, float transp) +void GEOM_Swig::setTransparency(const char* theEntry, float transp) { - QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy(); - Handle(SALOME_InteractiveObject) IO = - myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->FindIObject( Entry ); - - if ( myStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { // VTK - VTKViewer_RenderWindowInteractor* myRenderInter = - ((VTKViewer_ViewFrame*)myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); - myRenderInter->SetTransparency(IO,transp); - myRenderInter->Update(); - } - else if ( myStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) // OCC - { - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - v3d->SetTransparency(IO,transp); + QAD_Study* aStudy = QAD_Application::getDesktop()->getActiveStudy(); + Handle(SALOME_InteractiveObject) anIO = SALOME::FindIObject(aStudy,theEntry); + + class TEvent: public SALOME_Event{ + QAD_Study* myStudy; + Handle(SALOME_InteractiveObject) myIO; + float myParam; + public: + TEvent(QAD_Study* theStudy, const Handle(SALOME_InteractiveObject)& theIO, float theParam): + myStudy(theStudy), myIO(theIO), myParam(theParam) + {} + virtual void Execute(){ + if(VTKViewer_ViewFrame* aViewFrame = GetFrame(myStudy)){ + VTKViewer_RenderWindowInteractor* myRenderInter= aViewFrame->getRWInteractor(); + myRenderInter->SetTransparency(myIO,myParam); + myRenderInter->Update(); + }else if(OCCViewer_ViewFrame* aViewFrame = GetFrame(myStudy)){ + OCCViewer_Viewer3d* v3d = aViewFrame->getViewer(); + v3d->SetTransparency(myIO,myParam); + } } + }; + + ProcessVoidEvent(new TEvent(aStudy,anIO,transp)); } diff --git a/src/GEOMGUI/Makefile.in b/src/GEOMGUI/Makefile.in index 9576c2d35..bd17ccd48 100644 --- a/src/GEOMGUI/Makefile.in +++ b/src/GEOMGUI/Makefile.in @@ -34,29 +34,41 @@ VPATH=.:@srcdir@:@top_srcdir@/idl @COMMENCE@ +# ressources files +PO_FILES = \ + GEOM_icons.po \ + GEOM_msg_en.po \ + GEOM_msg_fr.po + # header files -EXPORT_HEADERS= GeometryGUI_Swig.hxx \ - GeometryGUI_Swig.i +EXPORT_HEADERS= GeometryGUI.h \ + GEOMGUI.h \ + GeometryGUI_Swig.hxx \ + GeometryGUI_Swig.i \ + GEOM_Displayer.h # Libraries targets LIB = libGEOMGUI.la LIB_SRC = GeometryGUI.cxx \ - GeometryGUI_Swig.cxx + GeometryGUI_Swig.cxx \ + GEOM_Displayer.cxx \ + GEOMGUI.cxx LIB_MOC = \ GeometryGUI.h \ LIB_CLIENT_IDL = SALOME_Exception.idl \ SALOMEDS.idl \ - SALOMEDS_Attributes.idl + SALOMEDS_Attributes.idl \ + SALOME_GenericObj.idl -LIB_SERVER_IDL = +LIB_SERVER_IDL = # additionnal information to compil and link file CPPFLAGS += $(QT_INCLUDES) $(VTK_INCLUDES) $(OCC_INCLUDES) $(PYTHON_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome CXXFLAGS += -I${KERNEL_ROOT_DIR}/include/salome -LDFLAGS += -lGEOMContext +LDFLAGS += -L$(KERNEL_ROOT_DIR)/lib/salome -lOCCViewer -lVTKViewer -lSalomeGUI -lGEOMClient -lGEOMObject -lGEOMFiltersSelection @CONCLUDE@ diff --git a/src/GEOMImpl/GEOMImpl_ArcDriver.cxx b/src/GEOMImpl/GEOMImpl_ArcDriver.cxx new file mode 100644 index 000000000..2e8b5d7ec --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_ArcDriver.cxx @@ -0,0 +1,132 @@ + +using namespace std; +#include "GEOMImpl_ArcDriver.hxx" +#include "GEOMImpl_IArc.hxx" +#include "GEOMImpl_Types.hxx" +#include "GEOM_Function.hxx" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& GEOMImpl_ArcDriver::GetID() +{ + static Standard_GUID aArcDriver("FF1BBB35-5D14-4df2-980B-3A668264EA16"); + return aArcDriver; +} + + +//======================================================================= +//function : GEOMImpl_ArcDriver +//purpose : +//======================================================================= +GEOMImpl_ArcDriver::GEOMImpl_ArcDriver() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_ArcDriver::Execute(TFunction_Logbook& log) const +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); + + GEOMImpl_IArc aCI (aFunction); + Standard_Integer aType = aFunction->GetType(); + + TopoDS_Shape aShape; + + if (aType == CIRC_ARC_THREE_PNT) { + Handle(GEOM_Function) aRefPoint1 = aCI.GetPoint1(); + Handle(GEOM_Function) aRefPoint2 = aCI.GetPoint2(); + Handle(GEOM_Function) aRefPoint3 = aCI.GetPoint3(); + TopoDS_Shape aShapePnt1 = aRefPoint1->GetValue(); + TopoDS_Shape aShapePnt2 = aRefPoint2->GetValue(); + TopoDS_Shape aShapePnt3 = aRefPoint3->GetValue(); + if (aShapePnt1.ShapeType() == TopAbs_VERTEX && + aShapePnt2.ShapeType() == TopAbs_VERTEX && + aShapePnt3.ShapeType() == TopAbs_VERTEX) { + gp_Pnt aP1 = BRep_Tool::Pnt(TopoDS::Vertex(aShapePnt1)); + gp_Pnt aP2 = BRep_Tool::Pnt(TopoDS::Vertex(aShapePnt2)); + gp_Pnt aP3 = BRep_Tool::Pnt(TopoDS::Vertex(aShapePnt3)); + if (aP1.Distance(aP2) < gp::Resolution() || + aP1.Distance(aP3) < gp::Resolution() || + aP2.Distance(aP3) < gp::Resolution()) + Standard_ConstructionError::Raise("Arc creation aborted: coincident points given"); + if (gp_Vec(aP1, aP2).IsParallel(gp_Vec(aP1, aP3), Precision::Angular())) + Standard_ConstructionError::Raise("Arc creation aborted: points lay on one line"); + GC_MakeArcOfCircle arc (aP1, aP2, aP3); + aShape = BRepBuilderAPI_MakeEdge(arc).Edge(); + } + } else { + } + + if (aShape.IsNull()) return 0; + + aFunction->SetValue(aShape); + + log.SetTouched(Label()); + + return 1; +} + + +//======================================================================= +//function : GEOMImpl_ArcDriver_Type_ +//purpose : +//======================================================================= +Standard_EXPORT Handle_Standard_Type& GEOMImpl_ArcDriver_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); + 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("GEOMImpl_ArcDriver", + sizeof(GEOMImpl_ArcDriver), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + +//======================================================================= +//function : DownCast +//purpose : +//======================================================================= +const Handle(GEOMImpl_ArcDriver) Handle(GEOMImpl_ArcDriver)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOMImpl_ArcDriver) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_ArcDriver))) { + _anOtherObject = Handle(GEOMImpl_ArcDriver)((Handle(GEOMImpl_ArcDriver)&)AnObject); + } + } + + return _anOtherObject ; +} diff --git a/src/GEOMImpl/GEOMImpl_ArcDriver.hxx b/src/GEOMImpl/GEOMImpl_ArcDriver.hxx new file mode 100644 index 000000000..95cee034a --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_ArcDriver.hxx @@ -0,0 +1,139 @@ +// File : GEOMImpl_ArcDriver.ixx +// Module : GEOMImpl + +#ifndef _GEOMImpl_ArcDriver_HeaderFile +#define _GEOMImpl_ArcDriver_HeaderFile + +#ifndef _TColStd_SequenceOfExtendedString_HeaderFile +#include +#endif +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_GUID_HeaderFile +#include +#endif + +#ifndef _Handle_TFunction_Driver_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TFunction_Driver); +class GEOMImpl_ArcDriver; + +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMImpl_ArcDriver); + +class Handle(GEOMImpl_ArcDriver) : public Handle(TFunction_Driver) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + Handle(GEOMImpl_ArcDriver)():Handle(TFunction_Driver)() {} + Handle(GEOMImpl_ArcDriver)(const Handle(GEOMImpl_ArcDriver)& aHandle) : Handle(TFunction_Driver)(aHandle) + { + } + + Handle(GEOMImpl_ArcDriver)(const GEOMImpl_ArcDriver* anItem) : Handle(TFunction_Driver)((TFunction_Driver *)anItem) + { + } + + Handle(GEOMImpl_ArcDriver)& operator=(const Handle(GEOMImpl_ArcDriver)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOMImpl_ArcDriver)& operator=(const GEOMImpl_ArcDriver* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOMImpl_ArcDriver* operator->() + { + return (GEOMImpl_ArcDriver *)ControlAccess(); + } + + GEOMImpl_ArcDriver* operator->() const + { + return (GEOMImpl_ArcDriver *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOMImpl_ArcDriver)() {}; + + Standard_EXPORT static const Handle(GEOMImpl_ArcDriver) DownCast(const Handle(Standard_Transient)& AnObject); +}; + +#ifndef _TFunction_Driver_HeaderFile +#include +#endif +#ifndef _TFunction_Logbook_HeaderFile +#include +#endif +#ifndef _Standard_CString_HeaderFile +#include +#endif + +class TColStd_SequenceOfExtendedString; + + +class GEOMImpl_ArcDriver : public TFunction_Driver { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + // Methods PUBLIC + // +Standard_EXPORT GEOMImpl_ArcDriver(); +Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; +Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {} +Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const { return Standard_True; } +Standard_EXPORT static const Standard_GUID& GetID(); +Standard_EXPORT ~GEOMImpl_ArcDriver() {}; + + + // Type management + // +Standard_EXPORT friend Handle_Standard_Type& GEOMImpl_ArcDriver_Type_(); +Standard_EXPORT const Handle(Standard_Type)& DynamicType() const { return STANDARD_TYPE(GEOMImpl_ArcDriver) ; } +Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const { return (STANDARD_TYPE(GEOMImpl_ArcDriver) == AType || TFunction_Driver::IsKind(AType)); } + + +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_ArchimedeDriver.cxx b/src/GEOMImpl/GEOMImpl_ArchimedeDriver.cxx new file mode 100644 index 000000000..05114c950 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_ArchimedeDriver.cxx @@ -0,0 +1,168 @@ + +#include "GEOMImpl_ArchimedeDriver.hxx" +#include "GEOMImpl_IArchimede.hxx" +#include "GEOMImpl_Types.hxx" + +#include "Archimede_VolumeSection.hxx" + +#include + +#include + +#include +#include + +#include +#include +#include + +#include +#include + +#include + +using namespace std; + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& GEOMImpl_ArchimedeDriver::GetID() +{ + static Standard_GUID aArchimedeDriver("FF1BBB59-5D14-4df2-980B-3A668264EA16"); + return aArchimedeDriver; +} + + +//======================================================================= +//function : GEOMImpl_ArchimedeDriver +//purpose : +//======================================================================= + +GEOMImpl_ArchimedeDriver::GEOMImpl_ArchimedeDriver() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_ArchimedeDriver::Execute(TFunction_Logbook& log) const +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); + + Standard_Integer aType = aFunction->GetType(); + if (aType != ARCHIMEDE_TYPE) return 0; + + GEOMImpl_IArchimede IA (aFunction); + + Handle(GEOM_Function) aShapeFunction = IA.GetBasicShape(); + if (aShapeFunction.IsNull()) return 0; + TopoDS_Shape shape = aShapeFunction->GetValue(); + if(shape.IsNull()) return 0; + + Standard_Real aWaterDensity = IA.GetDensity(); + Standard_Real aWeight = IA.GetWeight(); + Standard_Real aMeshingDeflection = IA.GetDeflection(); + + double cste = -1; + if (aWaterDensity != 0.) + cste = aWeight/aWaterDensity; + else + return 0; + + gp_Dir direct (0.0, 0.0, 1.0); + gp_Pnt PosPlan (0.0, 0.0, 0.0); + Geom_Plane PP (PosPlan, direct); + Handle(Geom_Plane) P = Handle(Geom_Plane)::DownCast(PP.Copy()); + + gp_Dir Zdirection (0.0, 0.0, 1.0); + VolumeSection VOL (shape, aMeshingDeflection); + VOL.SetPlane(P); + Handle(Geom_RectangularTrimmedSurface) SurfaceTrimmee; + + if (Zdirection.IsEqual(direct, Precision::Angular()) == Standard_False) { + VOL.MakeRotation(direct); + } + + VOL.CenterOfGravity(); + SurfaceTrimmee = VOL.TrimSurf(); + Standard_Real Cote = VOL.Archimede(cste, aMeshingDeflection); + + if (Cote == -1) { + double Zmin,Zmax; + VOL.getZ(Zmin,Zmax); + double volume = VOL.CalculateVolume(Zmax) * aWaterDensity; + + char msg[100] = ""; + sprintf(msg, "shape sinks to the bottom : Weigth max = %.1f", volume); + + StdFail_NotDone::Raise(msg); + } + + SurfaceTrimmee = VOL.AjustePlan(SurfaceTrimmee,Cote,PosPlan); + if (Zdirection.IsEqual(direct,Precision::Angular()) == Standard_False) { + SurfaceTrimmee = VOL.InvMakeRotation(direct,SurfaceTrimmee); + } + + Standard_Real u1,u2,v1,v2; + SurfaceTrimmee->Bounds(u1,u2,v1,v2); + TopoDS_Face tirant = BRepBuilderAPI_MakeFace(SurfaceTrimmee, u1, u2, v1, v2); + + if (tirant.IsNull()) { + StdFail_NotDone::Raise("Failed to build secant face"); + } + + aFunction->SetValue(tirant); + + log.SetTouched(Label()); + + return 1; +} + + +//======================================================================= +//function : GEOMImpl_ArchimedeDriver_Type_ +//purpose : +//======================================================================= +Standard_EXPORT Handle_Standard_Type& GEOMImpl_ArchimedeDriver_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); + 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("GEOMImpl_ArchimedeDriver", + sizeof(GEOMImpl_ArchimedeDriver), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + +//======================================================================= +//function : DownCast +//purpose : +//======================================================================= + +const Handle(GEOMImpl_ArchimedeDriver) Handle(GEOMImpl_ArchimedeDriver)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOMImpl_ArchimedeDriver) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_ArchimedeDriver))) { + _anOtherObject = Handle(GEOMImpl_ArchimedeDriver)((Handle(GEOMImpl_ArchimedeDriver)&)AnObject); + } + } + + return _anOtherObject ; +} + + diff --git a/src/GEOMImpl/GEOMImpl_ArchimedeDriver.hxx b/src/GEOMImpl/GEOMImpl_ArchimedeDriver.hxx new file mode 100644 index 000000000..ba2fcfb29 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_ArchimedeDriver.hxx @@ -0,0 +1,139 @@ +// File : GEOMImpl_ArchimedeDriver.hxx +// Module : GEOMImpl + +#ifndef _GEOMImpl_ArchimedeDriver_HeaderFile +#define _GEOMImpl_ArchimedeDriver_HeaderFile + +#ifndef _TColStd_SequenceOfExtendedString_HeaderFile +#include +#endif +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_GUID_HeaderFile +#include +#endif + +#ifndef _Handle_TFunction_Driver_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TFunction_Driver); +class GEOMImpl_ArchimedeDriver; + +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMImpl_ArchimedeDriver); + +class Handle(GEOMImpl_ArchimedeDriver) : public Handle(TFunction_Driver) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + Handle(GEOMImpl_ArchimedeDriver)():Handle(TFunction_Driver)() {} + Handle(GEOMImpl_ArchimedeDriver)(const Handle(GEOMImpl_ArchimedeDriver)& aHandle) : Handle(TFunction_Driver)(aHandle) + { + } + + Handle(GEOMImpl_ArchimedeDriver)(const GEOMImpl_ArchimedeDriver* anItem) : Handle(TFunction_Driver)((TFunction_Driver *)anItem) + { + } + + Handle(GEOMImpl_ArchimedeDriver)& operator=(const Handle(GEOMImpl_ArchimedeDriver)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOMImpl_ArchimedeDriver)& operator=(const GEOMImpl_ArchimedeDriver* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOMImpl_ArchimedeDriver* operator->() + { + return (GEOMImpl_ArchimedeDriver *)ControlAccess(); + } + + GEOMImpl_ArchimedeDriver* operator->() const + { + return (GEOMImpl_ArchimedeDriver *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOMImpl_ArchimedeDriver)() {}; + + Standard_EXPORT static const Handle(GEOMImpl_ArchimedeDriver) DownCast(const Handle(Standard_Transient)& AnObject); +}; + +#ifndef _TFunction_Driver_HeaderFile +#include +#endif +#ifndef _TFunction_Logbook_HeaderFile +#include +#endif +#ifndef _Standard_CString_HeaderFile +#include +#endif + +class TColStd_SequenceOfExtendedString; + + +class GEOMImpl_ArchimedeDriver : public TFunction_Driver { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + // Methods PUBLIC + // +Standard_EXPORT GEOMImpl_ArchimedeDriver(); +Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; +Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {} +Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const { return Standard_True; } +Standard_EXPORT static const Standard_GUID& GetID(); +Standard_EXPORT ~GEOMImpl_ArchimedeDriver() {}; + + + // Type management + // +Standard_EXPORT friend Handle_Standard_Type& GEOMImpl_ArchimedeDriver_Type_(); +Standard_EXPORT const Handle(Standard_Type)& DynamicType() const { return STANDARD_TYPE(GEOMImpl_ArchimedeDriver) ; } +Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const { return (STANDARD_TYPE(GEOMImpl_ArchimedeDriver) == AType || TFunction_Driver::IsKind(AType)); } + + +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_Block6Explorer.cxx b/src/GEOMImpl/GEOMImpl_Block6Explorer.cxx new file mode 100644 index 000000000..71987a990 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_Block6Explorer.cxx @@ -0,0 +1,1213 @@ +using namespace std; + +#include + +#include "GEOMImpl_Block6Explorer.hxx" + +#include "utilities.h" + +#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 + +#define NBFACES 6 +#define NBEDGES 12 +#define NBVERTS 8 + +static Standard_Integer mod4 (Standard_Integer nb) +{ + if (nb <= 0) return nb + 4; + if (nb > 4) return nb - 4; + return nb; +} + +static Standard_Integer edge_id (const Standard_Integer theFaceID, + const Standard_Integer theEdgeNB) +{ + static Standard_Integer edge_ids[NBFACES][4] = { + { 1, 2, 3, 4 }, // face 1 + { 5, 6, 7, 8 }, // face 2 + { 9, 5, 10, 1 }, // face 3 + { 12, 7, 11, 3 }, // face 4 + { 4, 12, 8, 9 }, // face 5 + { 2, 11, 6, 10 } }; // face 6 + + return edge_ids[theFaceID - 1][theEdgeNB - 1]; +} + +static Standard_Integer side_edge_id (const Standard_Integer theEdgeNB) +{ + static Standard_Integer side_edge_ids[4] = {9, 10, 11, 12}; + + return side_edge_ids[theEdgeNB - 1]; +} + +static Standard_Integer vertex_id (const Standard_Integer theFaceID, + const Standard_Integer theVertexNB) +{ + static Standard_Integer vertex_ids[NBFACES][4] = { + { 1, 2, 3, 4 }, // face 1 + { 5, 6, 7, 8 }, // face 2 + { 1, 5, 6, 2 }, // face 3 + { 4, 8, 7, 3 }, // face 4 + { 1, 4, 8, 5 }, // face 5 + { 2, 3, 7, 6 } }; // face 6 + + return vertex_ids[theFaceID - 1][theVertexNB - 1]; +} + +static Standard_Integer vertex_id_edge (const Standard_Integer theEdgeID, // [1,12] + const Standard_Integer theVertexNB) // [1,2] +{ + static Standard_Integer vertex_ids_edge[NBEDGES][2] = { + {1, 2}, // edge 1 + {2, 3}, // edge 2 + {3, 4}, // edge 3 + {4, 1}, // edge 4 + {5, 6}, // edge 5 + {6, 7}, // edge 6 + {7, 8}, // edge 7 + {8, 5}, // edge 8 + {1, 5}, // edge 9 + {2, 6}, // edge 10 + {3, 7}, // edge 11 + {4, 8} }; // edge 12 + + return vertex_ids_edge[theEdgeID - 1][theVertexNB - 1]; +} + +static Standard_Integer face_id_edges (const Standard_Integer theEdge1ID, // [1,12] + const Standard_Integer theEdge2ID) // [1,12] +{ + static Standard_Integer face_ids_edges[NBEDGES][NBEDGES] = { + // 1 2 3 4 5 6 7 8 9 10 11 12 + { 0, 1, 1, 1, 3, 0, 0, 0, 3, 3, 0, 0 }, // edge 1 + { 1, 0, 1, 1, 0, 6, 0, 0, 0, 6, 6, 0 }, // edge 2 + { 1, 1, 0, 1, 0, 0, 4, 0, 0, 0, 4, 4 }, // edge 3 + { 1, 1, 1, 0, 0, 0, 0, 5, 5, 0, 0, 5 }, // edge 4 + { 3, 0, 0, 0, 0, 2, 2, 2, 3, 3, 0, 0 }, // edge 5 + { 0, 6, 0, 0, 2, 0, 2, 2, 0, 6, 6, 0 }, // edge 6 + { 0, 0, 4, 0, 2, 2, 0, 2, 0, 0, 4, 4 }, // edge 7 + { 0, 0, 0, 5, 2, 2, 2, 0, 5, 0, 0, 5 }, // edge 8 + { 3, 0, 0, 5, 3, 0, 0, 5, 0, 3, 0, 5 }, // edge 9 + { 3, 6, 0, 0, 3, 6, 0, 0, 3, 0, 6, 0 }, // edge 10 + { 0, 6, 4, 0, 0, 6, 4, 0, 0, 6, 0, 4 }, // edge 11 + { 0, 0, 4, 5, 0, 0, 4, 5, 5, 0, 4, 0 } }; // edge 12 + + return face_ids_edges[theEdge1ID - 1][theEdge2ID - 1]; +} + +static Standard_Integer edge_id_vertices (const Standard_Integer theVertex1ID, // [1,8] + const Standard_Integer theVertex2ID) // [1,8] +{ + static Standard_Integer edge_ids_vertices[NBVERTS][NBVERTS] = { + // 1 2 3 4 5 6 7 8 + { 0, 1, 0, 4, 9, 0, 0, 0}, // vertex 1 + { 1, 0, 2, 0, 0, 10, 0, 0}, // vertex 2 + { 0, 2, 0, 3, 0, 0, 11, 0}, // vertex 3 + { 4, 0, 3, 0, 0, 0, 0, 12}, // vertex 4 + { 9, 0, 0, 0, 0, 5, 0, 8}, // vertex 5 + { 0, 10, 0, 0, 5, 0, 6, 0}, // vertex 6 + { 0, 0, 11, 0, 0, 6, 0, 7}, // vertex 7 + { 0, 0, 0, 12, 8, 0, 7, 0} }; // vertex 8 + + return edge_ids_vertices[theVertex1ID - 1][theVertex2ID - 1]; +} + +static Standard_Integer edge_id_faces (const Standard_Integer theFace1ID, // [1,6] + const Standard_Integer theFace2ID) // [1,6] +{ + static Standard_Integer edge_ids_faces[NBFACES][NBFACES] = { + // 1 2 3 4 5 6 + { 0, 0, 1, 3, 4, 2 }, // face 1 + { 0, 0, 5, 7, 8, 6 }, // face 2 + { 1, 5, 0, 0, 9, 10 }, // face 3 + { 3, 7, 0, 0, 12, 11 }, // face 4 + { 4, 8, 9, 12, 0, 0 }, // face 5 + { 2, 6, 10, 11, 0, 0 } }; // face 6 + + return edge_ids_faces[theFace1ID - 1][theFace2ID - 1]; +} + +//======================================================================= +//function : GEOMImpl_Block6Explorer +//purpose : Constructor +//======================================================================= +GEOMImpl_Block6Explorer::GEOMImpl_Block6Explorer () + : myFaces(1,NBFACES), myEdges(1,NBEDGES), myVertices(1,NBVERTS) +{ +} + +//======================================================================= +//function : GetVertex +//purpose : +//======================================================================= +TopoDS_Shape GEOMImpl_Block6Explorer::GetVertex (const Standard_Integer theVertexID) +{ + TopoDS_Shape aNullShape; + if (theVertexID < 1 || theVertexID > NBVERTS) return aNullShape; + return myVertices(theVertexID); +} + +//======================================================================= +//function : GetVertexID +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_Block6Explorer::GetVertexID (const TopoDS_Shape& theVertex) +{ + for (Standard_Integer id = 1; id <= NBVERTS; id++) { + if (theVertex.IsSame(myVertices(id))) return id; + } + Standard_NoSuchObject::Raise("The Vertex does not belong to the Block"); + return 0; +} + +//======================================================================= +//function : GetVertexID +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_Block6Explorer::GetVertexID (const Standard_Integer theFaceID, + const Standard_Integer theVertexNB) +{ + return vertex_id(theFaceID, theVertexNB); +} + +//======================================================================= +//function : GetVertexOnEdgeID +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_Block6Explorer::GetVertexOnEdgeID + (const Standard_Integer theEdgeID, + const Standard_Integer theVertexNB) +{ + return vertex_id_edge(theEdgeID, theVertexNB); +} + +//======================================================================= +//function : GetEdge +//purpose : +//======================================================================= +TopoDS_Shape GEOMImpl_Block6Explorer::GetEdge (const Standard_Integer theEdgeID, + const Standard_Boolean doMake) +{ + TopoDS_Shape aNullShape; + if (theEdgeID < 1 || theEdgeID > NBEDGES) return aNullShape; + if (myEdges(theEdgeID).IsNull() && doMake) { + // Create the required edge as a linear segment between + // corresponding vertices and put it in the Block's edges + BRepBuilderAPI_MakeEdge ME (TopoDS::Vertex(myVertices(vertex_id_edge(theEdgeID, 1))), + TopoDS::Vertex(myVertices(vertex_id_edge(theEdgeID, 2)))); + if (!ME.IsDone()) { + Standard_ConstructionError::Raise("Edge construction failed"); + } + myEdges(theEdgeID) = ME.Shape(); + } + + return myEdges(theEdgeID); +} + +//======================================================================= +//function : GetEdgeID +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_Block6Explorer::GetEdgeID (const TopoDS_Shape& theEdge) +{ + for (Standard_Integer id = 1; id <= NBEDGES; id++) { + if (theEdge.IsSame(myEdges(id))) return id; + } + Standard_NoSuchObject::Raise("The Edge does not belong to the Block"); + return 0; +} + +//======================================================================= +//function : GetEdgeID +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_Block6Explorer::GetEdgeID (const Standard_Integer theFaceID, + const Standard_Integer theEdgeNB) +{ + return edge_id(theFaceID, theEdgeNB); +} + +//======================================================================= +//function : FindEdgeID +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_Block6Explorer::FindEdgeID (const Standard_Integer theVertex1ID, + const Standard_Integer theVertex2ID) +{ + return edge_id_vertices(theVertex1ID, theVertex2ID); +} + +//======================================================================= +//function : FindCommonEdgeID +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_Block6Explorer::FindCommonEdgeID + (const Standard_Integer theFace1ID, + const Standard_Integer theFace2ID) +{ + return edge_id_faces(theFace1ID, theFace2ID); +} + +//======================================================================= +//function : GetFace +//purpose : +//======================================================================= +TopoDS_Shape GEOMImpl_Block6Explorer::GetFace (const Standard_Integer theFaceID, + const Standard_Boolean doMake) +{ + TopoDS_Shape aNullShape; + if (theFaceID < 1 || theFaceID > NBFACES) return aNullShape; + + if (myFaces(theFaceID).IsNull() && doMake) { + + // Create the required face between + // corresponding edges and put it in the Block's faces + + TopoDS_Shape E1 = GetEdge(edge_id(theFaceID, 1), doMake); + TopoDS_Shape E2 = GetEdge(edge_id(theFaceID, 2), doMake); + TopoDS_Shape E3 = GetEdge(edge_id(theFaceID, 3), doMake); + TopoDS_Shape E4 = GetEdge(edge_id(theFaceID, 4), doMake); + + BRepBuilderAPI_MakeWire MW (TopoDS::Edge(E1), + TopoDS::Edge(E2), + TopoDS::Edge(E3), + TopoDS::Edge(E4)); + if (!MW.IsDone()) { + Standard_ConstructionError::Raise("Wire construction failed"); + } + TopoDS_Shape aFace; + MakeFace(MW, Standard_False, aFace); + if (aFace.IsNull()) { + Standard_ConstructionError::Raise("Face construction failed"); + } + myFaces(theFaceID) = aFace; + } + + return myFaces(theFaceID); +} + +//======================================================================= +//function : GetFaceID +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_Block6Explorer::GetFaceID (const TopoDS_Shape& theFace) +{ + for (Standard_Integer id = 1; id <= NBFACES; id++) { + if (theFace.IsSame(myFaces(id))) return id; + } + Standard_NoSuchObject::Raise("The Face does not belong to the Block"); + return 0; +} + +//======================================================================= +//function : FindFaceID +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_Block6Explorer::FindFaceID (const Standard_Integer theEdge1ID, + const Standard_Integer theEdge2ID) +{ + return face_id_edges(theEdge1ID, theEdge2ID); +} + +//======================================================================= +//function : GetOppositeFaceID +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_Block6Explorer::GetOppositeFaceID (const Standard_Integer theFaceID) +{ + Standard_Integer opp_face_id[NBFACES + 1] = { + 0, + 2, // to 1 face + 1, // to 2 face + 4, // to 3 face + 3, // to 4 face + 6, // to 5 face + 5}; // to 6 face + + return opp_face_id[theFaceID]; +} + +//======================================================================= +//function : IsSimilarFaces +//purpose : +//======================================================================= +Standard_Boolean GEOMImpl_Block6Explorer::IsSimilarFaces (const Standard_Integer theFace1ID, + const Standard_Integer theFace2ID, + const gp_Trsf theTransformation) +{ + Standard_Integer common_edge_id = FindCommonEdgeID(theFace1ID, theFace2ID); + + if (common_edge_id == 0) { // opposite faces + for (Standard_Integer id = 1; id <= 4; id++) { + TopoDS_Shape E1 = GetEdge(edge_id(theFace1ID, id)); + TopoDS_Shape E2 = GetEdge(edge_id(theFace2ID, id)); + + BRepBuilderAPI_Transform aTrsf (E1, theTransformation, Standard_False); + if (!IsSimilarEdges(aTrsf.Shape(), E2)) + return Standard_False; + } + } else { // the faces have common edge + TopTools_Array1OfShape aVerts1 (1,4); + TopTools_Array1OfShape aVerts2 (1,4); + + Standard_Integer common_vertex1 = GetVertexOnEdgeID(common_edge_id, 1); + Standard_Integer common_vertex2 = GetVertexOnEdgeID(common_edge_id, 2); + aVerts1(1) = myVertices(common_vertex1); + aVerts1(2) = myVertices(common_vertex2); + aVerts2(1) = myVertices(common_vertex1); + aVerts2(2) = myVertices(common_vertex2); + + Standard_Integer not_common_v11 = 0, not_common_v12 = 0; + Standard_Integer vnb, vid; + for (vnb = 1; vnb <= 4; vnb++) { + vid = GetVertexID(theFace1ID, vnb); + if (vid != common_vertex1 && FindEdgeID(vid, common_vertex1) == 0) { + not_common_v12 = vid; + } else { + if (vid != common_vertex2 && FindEdgeID(vid, common_vertex2) == 0) { + not_common_v11 = vid; + } + } + } + + Standard_Integer not_common_v21 = 0, not_common_v22 = 0; + for (vnb = 1; vnb <= 4; vnb++) { + vid = GetVertexID(theFace2ID, vnb); + if (vid != common_vertex1 && FindEdgeID(vid, common_vertex1) == 0) { + not_common_v22 = vid; + } else { + if (vid != common_vertex2 && FindEdgeID(vid, common_vertex2) == 0) { + not_common_v21 = vid; + } + } + } + aVerts1(3) = myVertices(not_common_v11); + aVerts1(4) = myVertices(not_common_v12); + aVerts2(3) = myVertices(not_common_v21); + aVerts2(4) = myVertices(not_common_v22); + + for (Standard_Integer id = 1; id <= 4; id++) { + BRepBuilderAPI_Transform aTrsf (aVerts1(id), theTransformation, Standard_False); + TopoDS_Vertex V1 = TopoDS::Vertex(aTrsf.Shape()); + TopoDS_Vertex V2 = TopoDS::Vertex(aVerts2(id)); + if (!BRepTools::Compare(V1, V2)) { + return Standard_False; + } + } + } + + return Standard_True; +} + +//============ Initialization methods =================================== + +//======================================================================= +//function : InitByBlock +//purpose : +//======================================================================= +void GEOMImpl_Block6Explorer::InitByBlock (const TopoDS_Shape& theBlock) +{ + // 1. Find any one face of the block + TopExp_Explorer faces (theBlock, TopAbs_FACE); + if (!faces.More()) { + Standard_ConstructionError::Raise("The block has no faces"); + } + TopoDS_Shape aFirstFace = faces.Current(); + + // 2. Store all elements of the block relatively aFirstFace + InitByBlockAndFace(theBlock, aFirstFace); +} + +//======================================================================= +//function : InitByBlockAndFace +//purpose : +//======================================================================= +void GEOMImpl_Block6Explorer::InitByBlockAndFace (const TopoDS_Shape& theBlock, + const TopoDS_Shape& theFace) +{ + myFaces(1) = theFace; + + // 2. Get wire of the first face + TopExp_Explorer wires (myFaces(1), TopAbs_WIRE); + if (!wires.More()) { + Standard_ConstructionError::Raise("A face of the block has no wires"); + } + TopoDS_Shape aWire = wires.Current(); + wires.Next(); + if (wires.More()) { + Standard_ConstructionError::Raise("A face of the block has more than one wires"); + } + + // 3. Explore wire to init edges and vertices of the first face + BRepTools_WireExplorer aWE (TopoDS::Wire(aWire), TopoDS::Face(myFaces(1))); + Standard_Integer nb = 1; + for (; aWE.More(); aWE.Next(), nb++) { + if (nb > 4) { + Standard_ConstructionError::Raise("A face of the block has more than four edges"); + } + myEdges(edge_id(1, nb)) = aWE.Current(); + myVertices(vertex_id(1, nb)) = aWE.CurrentVertex(); + } + if (nb < 5) { + Standard_ConstructionError::Raise("A face of the block has less than four edges"); + } + + // 2. Store all other elements of the block + InitByBlockAndVertices (theBlock, + myVertices(vertex_id(1,1)), + myVertices(vertex_id(1,2)), + myVertices(vertex_id(1,3))); +} + +//======================================================================= +//function : InitByBlockAndEdges +//purpose : +//======================================================================= +void GEOMImpl_Block6Explorer::InitByBlockAndEdges (const TopoDS_Shape& theBlock, + const TopoDS_Shape& theEdge1, + const TopoDS_Shape& theEdge3) +{ + // 1. Store vertices and edges of the first face + + // 1.1. Store two given edges + myEdges(edge_id(1, 1)) = theEdge1; + myEdges(edge_id(1, 3)) = theEdge3; + + // 1.2. Find and store the first face + TopTools_IndexedDataMapOfShapeListOfShape MEF; + MapShapesAndAncestors(theBlock, TopAbs_EDGE, TopAbs_FACE, MEF); + if (MEF.Extent() != NBEDGES) { + Standard_TypeMismatch::Raise("Block has wrong number of edges"); + } + const TopTools_ListOfShape& aFacesOfE1 = MEF.FindFromKey(theEdge1); + const TopTools_ListOfShape& aFacesOfE3 = MEF.FindFromKey(theEdge3); + + Standard_Boolean isFound = Standard_False; + TopTools_ListIteratorOfListOfShape anIterF1 (aFacesOfE1); + for (; anIterF1.More() && !isFound; anIterF1.Next()) { + + TopTools_ListIteratorOfListOfShape anIterF3 (aFacesOfE3); + for (; anIterF3.More() && !isFound; anIterF3.Next()) { + + if (anIterF1.Value().IsSame(anIterF3.Value())) { + isFound = Standard_True; + + // Store the face, defined by two opposite edges + myFaces(1) = anIterF1.Value(); + } + } + } + if (!isFound) { + Standard_ConstructionError::Raise + ("Edges 1 and 2 do not belong to one face of the block"); + } + + // 1.3. Make vertices of the first edge the first and the + // second vertices of the first face. Order is free. + TopoDS_Edge E = TopoDS::Edge(theEdge1); + TopoDS_Vertex V1, V2; + TopExp::Vertices(E, V1, V2, Standard_True); + myVertices(vertex_id(1,1)) = V1; + myVertices(vertex_id(1,2)) = V2; + + // Init maps vertex->list_of_edges for the face + TopTools_IndexedDataMapOfShapeListOfShape M1; + MapShapesAndAncestors(myFaces(1), TopAbs_VERTEX, TopAbs_EDGE, M1); + if (M1.Extent() != 4) { + Standard_TypeMismatch::Raise("The first face of block has wrong number of vertices"); + } + + // 1.4. Find and store others elements of the first face + + // edges of the first vertex + TopoDS_Shape E1_f = M1.FindFromKey(V1).First(); + TopoDS_Shape E1_l = M1.FindFromKey(V1).Last(); + + if (E1_f.IsSame(theEdge1)) { + myEdges(edge_id(1, 4)) = E1_l; + } else { + myEdges(edge_id(1, 4)) = E1_f; + } + + // fourth vertex + TopoDS_Edge E4 = TopoDS::Edge(myEdges(edge_id(1, 4))); + TopoDS_Vertex V41, V42; + TopExp::Vertices(E4, V41, V42, Standard_True); + if (V41.IsSame(V1)) { + myVertices(vertex_id(1,4)) = V42; + } else { + myVertices(vertex_id(1,4)) = V41; + } + + // edges of the second vertex + TopoDS_Shape E2_f = M1.FindFromKey(V2).First(); + TopoDS_Shape E2_l = M1.FindFromKey(V2).Last(); + + if (E2_f.IsSame(theEdge1)) { + myEdges(edge_id(1, 2)) = E2_l; + } else { + myEdges(edge_id(1, 2)) = E2_f; + } + + // fird vertex + TopoDS_Edge E2 = TopoDS::Edge(myEdges(edge_id(1, 2))); + TopoDS_Vertex V21, V22; + TopExp::Vertices(E2, V21, V22, Standard_True); + if (V21.IsSame(V2)) { + myVertices(vertex_id(1,3)) = V22; + } else { + myVertices(vertex_id(1,3)) = V21; + } + + // 2. Store all other elements of the block + InitByBlockAndVertices (theBlock, + myVertices(vertex_id(1,1)), + myVertices(vertex_id(1,2)), + myVertices(vertex_id(1,3))); +} + +//======================================================================= +//function : InitByBlockAndVertices +//purpose : +//======================================================================= +void GEOMImpl_Block6Explorer::InitByBlockAndVertices (const TopoDS_Shape& theBlock, + const TopoDS_Shape& theVertex1, + const TopoDS_Shape& theVertex2, + const TopoDS_Shape& theVertex3) +{ + // Here we suppose, that vertices are ordered, i.e. exists edge between + // theVertex1 and theVertex2 and edge between theVertex2 and theVertex3 + + // 1. Store vertices and edges of the first face. + // If the first face is initialized, it means, that this + // method is called from another initialization method, and all + // vertices and edges of the first face are also initialized + if (myFaces(1).IsNull()) { + + // 1.1. Store first three vertices + myVertices(vertex_id(1, 1)) = theVertex1; + myVertices(vertex_id(1, 2)) = theVertex2; + myVertices(vertex_id(1, 3)) = theVertex3; + + // 1.2. Find and store the first face + TopTools_IndexedDataMapOfShapeListOfShape MVF; + MapShapesAndAncestors(theBlock, TopAbs_VERTEX, TopAbs_FACE, MVF); + if (MVF.Extent() != NBVERTS) { + Standard_TypeMismatch::Raise("Block has wrong number of vertices"); + } + const TopTools_ListOfShape& aFacesOfV1 = MVF.FindFromKey(theVertex1); + const TopTools_ListOfShape& aFacesOfV3 = MVF.FindFromKey(theVertex3); + + Standard_Boolean isFound = Standard_False; + TopTools_ListIteratorOfListOfShape anIterF1 (aFacesOfV1); + for (; anIterF1.More() && !isFound; anIterF1.Next()) { + + TopTools_ListIteratorOfListOfShape anIterF3 (aFacesOfV3); + for (; anIterF3.More() && !isFound; anIterF3.Next()) { + + if (anIterF1.Value().IsSame(anIterF3.Value())) { + isFound = Standard_True; + + // Store the face, defined by two opposite vertices + myFaces(1) = anIterF1.Value(); + } + } + } + if (!isFound) { + Standard_ConstructionError::Raise + ("Vertices 1 and 3 do not belong to one face of the block"); + } + + // Init maps vertex->list_of_edges for the face + TopTools_IndexedDataMapOfShapeListOfShape M1; + MapShapesAndAncestors(myFaces(1), TopAbs_VERTEX, TopAbs_EDGE, M1); + if (M1.Extent() != 4) { + Standard_TypeMismatch::Raise("The first face of block has wrong number of vertices"); + } + + // 1.3. Find and store edges and last vertex of the first face + const TopTools_ListOfShape& anEdgesOfV1 = M1.FindFromKey(theVertex1); + const TopTools_ListOfShape& anEdgesOfV2 = M1.FindFromKey(theVertex2); + const TopTools_ListOfShape& anEdgesOfV3 = M1.FindFromKey(theVertex3); + + TopTools_ListIteratorOfListOfShape anIterE2 (anEdgesOfV2); + for (; anIterE2.More(); anIterE2.Next()) { + + TopTools_ListIteratorOfListOfShape anIterE1 (anEdgesOfV1); + for (; anIterE1.More(); anIterE1.Next()) { + + if (anIterE1.Value().IsSame(anIterE2.Value())) { + // Store the first edge, defined by two vertices + myEdges(edge_id(1,1)) = anIterE1.Value(); + + } else { + // Store the last edge + myEdges(edge_id(1,4)) = anIterE1.Value(); + + // Find and store the last vertex + TopoDS_Edge E = TopoDS::Edge(myEdges(4)); + TopoDS_Vertex V1, V2; + TopExp::Vertices(E, V1, V2, Standard_True); + + if (V1.IsSame(theVertex1)) { + myVertices(vertex_id(1,4)) = V2; + } else { + myVertices(vertex_id(1,4)) = V1; + } + } + } + + TopTools_ListIteratorOfListOfShape anIterE3 (anEdgesOfV3); + for (; anIterE3.More(); anIterE3.Next()) { + + if (anIterE3.Value().IsSame(anIterE2.Value())) { + // Store the second edge, defined by two vertices + myEdges(edge_id(1,2)) = anIterE3.Value(); + + } else { + // Store the fird edge + myEdges(edge_id(1,3)) = anIterE3.Value(); + } + } + } + } + + // Init map vertex->list_of_edges for the block + TopTools_IndexedDataMapOfShapeListOfShape MB; + MapShapesAndAncestors(theBlock, TopAbs_VERTEX, TopAbs_EDGE, MB); + if (MB.Extent() != NBVERTS) { + Standard_TypeMismatch::Raise("Block has wrong number of vertices"); + } + + // 2. Store edges, linking the first face with the second one + // and vertices of the second face + TopTools_IndexedMapOfShape aFaceEdges; + TopExp::MapShapes(myFaces(1), TopAbs_EDGE, aFaceEdges); + + for (Standard_Integer i = 1; i <= 4; i++) { + // Get i-th vertex of the face 1 + TopoDS_Shape Vi = myVertices(vertex_id(1, i)); + if (!MB.Contains(Vi)) { + Standard_ConstructionError::Raise("Face does not belong to the block"); + } + + // Get list of block's edges, sharing this Vertex + const TopTools_ListOfShape& anEdgesOfVi = MB.FindFromKey(Vi); + TopTools_ListIteratorOfListOfShape anEdgesIter (anEdgesOfVi); + + // Get Edge (from the List), not belonging to the face 1 + Standard_Boolean isFound = Standard_False; + for (; anEdgesIter.More() && !isFound; anEdgesIter.Next()) { + if (!aFaceEdges.Contains(anEdgesIter.Value())) { + isFound = Standard_True; + + // Store the linking edge + TopoDS_Shape aLinkEdge = anEdgesIter.Value(); + myEdges(side_edge_id(i)) = aLinkEdge; + + // Get another vertex of the linking edge + TopoDS_Edge E = TopoDS::Edge(aLinkEdge); + TopoDS_Vertex V1, V2; + TopExp::Vertices(E, V1, V2, Standard_True); + + // Store the i-th vertex of the second (opposite to the first) face + if (V1.IsSame(Vi)) { + myVertices(vertex_id(2, i)) = V2; + } else { + myVertices(vertex_id(2, i)) = V1; + } + } + } + } + + // 3. Store edges of the second (opposite to the first) face + for (Standard_Integer i = 1; i <= 4; i++) { + // Get i-th and (i+1)-th vertices of the face 2 + TopoDS_Shape Vi = myVertices(vertex_id(2, i)); + TopoDS_Shape Vj = myVertices(vertex_id(2, mod4(i + 1))); + + // Get list of block's edges, sharing Vi + const TopTools_ListOfShape& anEdgesOfVi = MB.FindFromKey(Vi); + // Get list of block's edges, sharing Vj + const TopTools_ListOfShape& anEdgesOfVj = MB.FindFromKey(Vj); + + // Get Edge (from the List), linking this vertex with the next one + Standard_Boolean isFound = Standard_False; + TopTools_ListIteratorOfListOfShape anEdgesIteri (anEdgesOfVi); + for (; anEdgesIteri.More() && !isFound; anEdgesIteri.Next()) { + + TopTools_ListIteratorOfListOfShape anEdgesIterj (anEdgesOfVj); + for (; anEdgesIterj.More() && !isFound; anEdgesIterj.Next()) { + + if (anEdgesIteri.Value().IsSame(anEdgesIterj.Value())) { + isFound = Standard_True; + + // Store the linking edge + myEdges(edge_id(2, i)) = anEdgesIteri.Value(); + } + } + } + } + + // 4. Store faces of the block + TopTools_IndexedDataMapOfShapeListOfShape MBE; + MapShapesAndAncestors(theBlock, TopAbs_EDGE, TopAbs_FACE, MBE); + if (MBE.Extent() != NBEDGES) { + Standard_TypeMismatch::Raise("Block has wrong number of edges"); + } + + for (Standard_Integer i = 2; i <= NBFACES; i++) { + TopoDS_Shape Ei1 = myEdges(edge_id(i, 1)); + TopoDS_Shape Ei2 = myEdges(edge_id(i, 2)); + const TopTools_ListOfShape& aFacesOfEi1 = MBE.FindFromKey(Ei1); + const TopTools_ListOfShape& aFacesOfEi2 = MBE.FindFromKey(Ei2); + + Standard_Boolean isFound = Standard_False; + TopTools_ListIteratorOfListOfShape anIterEi1 (aFacesOfEi1); + for (; anIterEi1.More() && !isFound; anIterEi1.Next()) { + + TopTools_ListIteratorOfListOfShape anIterEi2 (aFacesOfEi2); + for (; anIterEi2.More() && !isFound; anIterEi2.Next()) { + + if (anIterEi1.Value().IsSame(anIterEi2.Value())) { + isFound = Standard_True; + + // Store the face, defined by two edges + myFaces(i) = anIterEi1.Value(); + } + } + } + } +} + +//======================================================================= +//function : InitByTwoFaces +//purpose : +//======================================================================= +void GEOMImpl_Block6Explorer::InitByTwoFaces (const TopoDS_Shape& theFace1, + const TopoDS_Shape& theFace2) +{ + if (theFace1.IsSame(theFace2)) { + Standard_ConstructionError::Raise("The faces must be different"); + } + + // Add two given faces in the structure + myFaces(1) = theFace1; + myFaces(2) = theFace2; + + // Step 1. Order vertices (and edges) + + // 1.1. Ordered vertices and edges of the first face we put in + + // Get wire of the first face + TopExp_Explorer wires1 (myFaces(1), TopAbs_WIRE); + if (!wires1.More()) { + Standard_ConstructionError::Raise("A face for the block has no wires"); + } + TopoDS_Shape aWire1 = wires1.Current(); + wires1.Next(); + if (wires1.More()) { + Standard_ConstructionError::Raise("A face for the block has more than one wire"); + } + + BRepTools_WireExplorer aWE1 (TopoDS::Wire(aWire1), TopoDS::Face(myFaces(1))); + Standard_Integer nb; + for (nb = 1; aWE1.More(); aWE1.Next(), nb++) { + if (nb > 4) { + Standard_ConstructionError::Raise("A face for the block has more than four edges"); + } + myEdges(edge_id(1, nb)) = aWE1.Current(); + myVertices(vertex_id(1, nb)) = aWE1.CurrentVertex(); + } + if (nb < 5) { + Standard_ConstructionError::Raise("A face for the block has less than four edges"); + } + + // 1.2. Ordered vertices and edges of the second face we temporarily store + // in arrays, to find for them rigth location in on the Step 2. + + // declare arrays + TopTools_Array1OfShape aVertis2(1,4); // ordered vertices of the second face + TopTools_Array1OfShape anEdges2(1,4); // anEdges2(i) links aVertis2(i) and aVertis2(i+1) + + // Get wire of the second face + TopExp_Explorer wires2 (myFaces(2), TopAbs_WIRE); + if (!wires2.More()) { + Standard_ConstructionError::Raise("A face for the block has no wires"); + } + TopoDS_Shape aWire2 = wires2.Current(); + wires2.Next(); + if (wires2.More()) { + Standard_ConstructionError::Raise("A face for the block has more than one wire"); + } + + BRepTools_WireExplorer aWE2 (TopoDS::Wire(aWire2), TopoDS::Face(myFaces(2))); + for (nb = 1; aWE2.More(); aWE2.Next(), nb++) { + if (nb > 4) { + Standard_ConstructionError::Raise("A face for the block has more than four edges"); + } + anEdges2(nb) = aWE2.Current(); + aVertis2(nb) = aWE2.CurrentVertex(); + } + if (nb < 5) { + Standard_ConstructionError::Raise("A face for the block has less than four edges"); + } + + // Step 2. Find right place in for the , + // so as to minimize common length of linking edges + // between face 1 and face 2. + // Each linking edge (of four) will link vertices of the + // faces 1 and 2 with equal local numbers. + // The right place is defined by: + // - vertex , which will become the first vertex + // of the second face + // - orientation of relatively their future location + // in (s_min = 1 if direct, s_min = -1 if reversed) + Standard_Integer i_min = 0, s_min = 0; + + TColgp_Array1OfPnt aPnts1 (1,4); // points of the first face + aPnts1(1) = BRep_Tool::Pnt(TopoDS::Vertex(myVertices(vertex_id(1, 1)))); + aPnts1(2) = BRep_Tool::Pnt(TopoDS::Vertex(myVertices(vertex_id(1, 2)))); + aPnts1(3) = BRep_Tool::Pnt(TopoDS::Vertex(myVertices(vertex_id(1, 3)))); + aPnts1(4) = BRep_Tool::Pnt(TopoDS::Vertex(myVertices(vertex_id(1, 4)))); + + TColgp_Array1OfPnt aPnts2 (1,4); // points of the second face + aPnts2(1) = BRep_Tool::Pnt(TopoDS::Vertex(aVertis2(1))); + aPnts2(2) = BRep_Tool::Pnt(TopoDS::Vertex(aVertis2(2))); + aPnts2(3) = BRep_Tool::Pnt(TopoDS::Vertex(aVertis2(3))); + aPnts2(4) = BRep_Tool::Pnt(TopoDS::Vertex(aVertis2(4))); + + Standard_Real Dist_min = RealLast(); + // try all possible locations to find the best (with minimum sum distance) + for (Standard_Integer i = 1; i <= 4; i++) { + // try direct orientation + Standard_Real Dist_plus = aPnts1(1).Distance(aPnts2(i)) + + aPnts1(2).Distance(aPnts2(mod4(i + 1))) + + aPnts1(3).Distance(aPnts2(mod4(i + 2))) + + aPnts1(4).Distance(aPnts2(mod4(i + 3))); + if (Dist_plus < Dist_min) { + Dist_min = Dist_plus; + i_min = i; + s_min = 1; + } + + // try reversed orientation + Standard_Real Dist_minus = aPnts1(1).Distance(aPnts2(i)) + + aPnts1(2).Distance(aPnts2(mod4(i - 1))) + + aPnts1(3).Distance(aPnts2(mod4(i - 2))) + + aPnts1(4).Distance(aPnts2(mod4(i - 3))); + if (Dist_minus < Dist_min) { + Dist_min = Dist_minus; + i_min = i; + s_min = - 1; + } + } + + // 3. Put vertices and edges of the second face to they + // permanent location in and + for (Standard_Integer i = 1; i <= 4; i++) { + Standard_Integer nb = mod4(i_min + s_min*(i - 1)); + + if (aPnts1(i).Distance(aPnts2(nb)) < Precision::Confusion()) { + Standard_ConstructionError::Raise("The faces are too close"); + } + + myVertices(vertex_id(2, i)) = aVertis2(nb); + + if (s_min == -1) nb = mod4(nb - 1); + myEdges(edge_id(2, i)) = anEdges2(nb); + } + + // 4. Generate side surface + if (!aWire1.Closed() || !aWire2.Closed()) { + // BRepOffsetAPI_ThruSections is not applicable on not closed wires + GetFace(3, Standard_True); + GetFace(4, Standard_True); + GetFace(5, Standard_True); + GetFace(6, Standard_True); + } else { + // try to build faces on native surfaces of edges or planar + Standard_Boolean tryThru = Standard_False; + for (Standard_Integer i = 3; i <= 6 && !tryThru; i++) { + Standard_Boolean doMake = Standard_True; + TopoDS_Shape E1 = GetEdge(edge_id(i, 1), doMake); + TopoDS_Shape E2 = GetEdge(edge_id(i, 2), doMake); + TopoDS_Shape E3 = GetEdge(edge_id(i, 3), doMake); + TopoDS_Shape E4 = GetEdge(edge_id(i, 4), doMake); + + BRepBuilderAPI_MakeWire MW (TopoDS::Edge(E1), + TopoDS::Edge(E2), + TopoDS::Edge(E3), + TopoDS::Edge(E4)); + if (!MW.IsDone()) { + Standard_ConstructionError::Raise("Wire construction failed"); + } + + BRepBuilderAPI_MakeFace MF (MW, Standard_False); + if (MF.IsDone()) { + myFaces(i) = MF.Shape(); + } else { + tryThru = Standard_True; + } + } + + // Build side surface by ThruSections algorithm + if (tryThru) { + BRepOffsetAPI_ThruSections THS; + THS.AddWire(TopoDS::Wire(aWire1)); + THS.AddWire(TopoDS::Wire(aWire2)); + THS.Build(); + if (!THS.IsDone()) { + StdFail_NotDone::Raise("Side surface generation failed"); + } + for (Standard_Integer i = 1; i <= 4; i++) { + // fill face + myFaces(i+2) = THS.GeneratedFace(myEdges(i)); + + // fill edge + Standard_Integer ee = side_edge_id(i); + TopTools_IndexedDataMapOfShapeListOfShape MVE; + MapShapesAndAncestors(myFaces(i+2), TopAbs_VERTEX, TopAbs_EDGE, MVE); + FindEdge(myEdges(ee), + myVertices(vertex_id_edge(ee, 1)), + myVertices(vertex_id_edge(ee, 2)), + MVE); + } + } + } +} + +//======================================================================= +//function : MapShapesAndAncestors +//purpose : +//======================================================================= +void GEOMImpl_Block6Explorer::MapShapesAndAncestors (const TopoDS_Shape& S, + const TopAbs_ShapeEnum TS, + const TopAbs_ShapeEnum TA, + TopTools_IndexedDataMapOfShapeListOfShape& M) +{ + TopTools_ListOfShape empty; + TopTools_MapOfShape mapA; + + // visit ancestors + TopExp_Explorer exa (S,TA); + for (; exa.More(); exa.Next()) { + // visit shapes + const TopoDS_Shape& anc = exa.Current(); + if (mapA.Add(anc)) { + TopExp_Explorer exs (anc,TS); + TopTools_MapOfShape mapS; + for (; exs.More(); exs.Next()) { + if (mapS.Add(exs.Current())) { + Standard_Integer index = M.FindIndex(exs.Current()); + if (index == 0) index = M.Add(exs.Current(),empty); + M(index).Append(anc); + } + } + } + } + + // visit shapes not under ancestors + TopExp_Explorer ex (S,TS,TA); + for (; ex.More(); ex.Next()) { + Standard_Integer index = M.FindIndex(ex.Current()); + if (index == 0) index = M.Add(ex.Current(),empty); + } +} + +//======================================================================= +//function : IsSimilarEdges +//purpose : +//======================================================================= +Standard_Boolean GEOMImpl_Block6Explorer::IsSimilarEdges (const TopoDS_Shape& E1, + const TopoDS_Shape& E2) +{ + TopoDS_Edge E1e = TopoDS::Edge(E1); + TopoDS_Edge E2e = TopoDS::Edge(E2); + TopoDS_Vertex V11, V12, V21, V22; + TopExp::Vertices(E1e, V11, V12, Standard_True); + TopExp::Vertices(E2e, V21, V22, Standard_True); + if (BRepTools::Compare(V11, V21) && BRepTools::Compare(V12, V22)) + return Standard_True; + if (BRepTools::Compare(V11, V22) && BRepTools::Compare(V12, V21)) + return Standard_True; + + return Standard_False; +} + +//======================================================================= +//function : FindEdge +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_Block6Explorer::FindEdge + (TopoDS_Shape& theResult, + const TopoDS_Shape& V1, + const TopoDS_Shape& V2, + const TopTools_IndexedDataMapOfShapeListOfShape& MVE, + const Standard_Boolean findAll) +{ + Standard_Integer isFound = 0; + + const TopTools_ListOfShape& anEdgesOfV1 = MVE.FindFromKey(V1); + const TopTools_ListOfShape& anEdgesOfV2 = MVE.FindFromKey(V2); + + TopTools_ListIteratorOfListOfShape it1 (anEdgesOfV1); + for (; it1.More(); it1.Next()) { + TopTools_ListIteratorOfListOfShape it2 (anEdgesOfV2); + for (; it2.More(); it2.Next()) { + if (it1.Value().IsSame(it2.Value())) { + isFound++; + theResult = it1.Value(); + if (!findAll) return isFound; + } + } + } + + return isFound; +} + +//======================================================================= +//function : FindFace +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_Block6Explorer::FindFace + (TopoDS_Shape& theResult, + const TopoDS_Shape& V1, + const TopoDS_Shape& V2, + const TopoDS_Shape& V3, + const TopoDS_Shape& V4, + const TopTools_IndexedDataMapOfShapeListOfShape& MVF, + const Standard_Boolean findAll) +{ + Standard_Integer isFound = Standard_False; + + const TopTools_ListOfShape& aFacesOfV1 = MVF.FindFromKey(V1); + const TopTools_ListOfShape& aFacesOfV2 = MVF.FindFromKey(V2); + const TopTools_ListOfShape& aFacesOfV3 = MVF.FindFromKey(V3); + const TopTools_ListOfShape& aFacesOfV4 = MVF.FindFromKey(V4); + + TopTools_ListIteratorOfListOfShape it1 (aFacesOfV1); + for (; it1.More(); it1.Next()) { + TopTools_ListIteratorOfListOfShape it2 (aFacesOfV2); + for (; it2.More(); it2.Next()) { + if (it1.Value().IsSame(it2.Value())) { + TopTools_ListIteratorOfListOfShape it3 (aFacesOfV3); + for (; it3.More(); it3.Next()) { + if (it1.Value().IsSame(it3.Value())) { + TopTools_ListIteratorOfListOfShape it4 (aFacesOfV4); + for (; it4.More(); it4.Next()) { + if (it1.Value().IsSame(it4.Value())) { + isFound++; + theResult = it1.Value(); + if (!findAll) return isFound; + } + } + } + } + } + } + } + + return isFound; +} + +//======================================================================= +//function : MakeFace +//purpose : +//======================================================================= +void GEOMImpl_Block6Explorer::MakeFace (const TopoDS_Wire& theWire, + const Standard_Boolean isPlanarWanted, + TopoDS_Shape& theResult) +{ + // try to build face on plane or on any surface under the edges of the wire + BRepBuilderAPI_MakeFace MK (theWire, isPlanarWanted); + if (MK.IsDone()) { + theResult = MK.Shape(); + return; + } + + // try to construct filling surface + if (!isPlanarWanted) { + BRepOffsetAPI_MakeFilling MF; + + Standard_Integer nbEdges = 0; + BRepTools_WireExplorer aWE (theWire); + for (; aWE.More(); aWE.Next(), nbEdges++) { + MF.Add(TopoDS::Edge(aWE.Current()), GeomAbs_C0); + } + + MF.Build(); + if (MF.IsDone()) { + // Result of filling + TopoDS_Shape aFace = MF.Shape(); + + // Update tolerance + Standard_Real aTol = MF.G0Error(); + + TColgp_Array1OfPnt aPnts (1,nbEdges); // points of the given wire + aWE = BRepTools_WireExplorer(theWire); + Standard_Integer vi = 1; + for (; aWE.More() && vi <= nbEdges; aWE.Next(), vi++) { + aPnts(vi) = BRep_Tool::Pnt(TopoDS::Vertex(aWE.CurrentVertex())); + } + + // Find maximum deviation in vertices + TopExp_Explorer exp (aFace, TopAbs_VERTEX); + TopTools_MapOfShape mapShape; + for (; exp.More(); exp.Next()) { + if (mapShape.Add(exp.Current())) { + TopoDS_Vertex aV = TopoDS::Vertex(exp.Current()); + Standard_Real aTolV = BRep_Tool::Tolerance(aV); + gp_Pnt aP = BRep_Tool::Pnt(aV); + Standard_Real min_dist = aP.Distance(aPnts(1)); + for (vi = 2; vi <= nbEdges; vi++) { + min_dist = Min(min_dist, aP.Distance(aPnts(vi))); + } + aTol = Max(aTol, aTolV); + aTol = Max(aTol, min_dist); + } + } + + if ((*((Handle(BRep_TFace)*)&aFace.TShape()))->Tolerance() < aTol) { + (*((Handle(BRep_TFace)*)&aFace.TShape()))->Tolerance(aTol); + } + theResult = aFace; + } + } +} diff --git a/src/GEOMImpl/GEOMImpl_Block6Explorer.hxx b/src/GEOMImpl/GEOMImpl_Block6Explorer.hxx new file mode 100644 index 000000000..d7d09c1bc --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_Block6Explorer.hxx @@ -0,0 +1,207 @@ +// File : GEOMImpl_Block6Explorer.hxx +// Module : GEOMImpl + +#ifndef GEOMImpl_Block6Explorer_HeaderFile +#define GEOMImpl_Block6Explorer_HeaderFile + +#include +#include +#include +#include +#include + + // Class GEOMImpl_Block6Explorer gives easy and fast access to a certain sub-elements of hexahedral solid + // Each face can be accessed by its global ID [1-6] + // Each edge can be accessed by its global ID [1-12] or by its local NB [1-4] inside certain face + // Each vertex can be accessed by its global ID [1-8] or by its local NB [1-4] inside certain face + // Numeration of the sub-shapes is defined in constructors, see they comments + // + // face 2 face 4 | 4 face 2 face | + // | / | \ | | + // \|/ |/_ | _\| \|/ | + // ' ' | ' ' | + // 8_______7__7 | 7__7_______8 | + // /| /| | |\ |\ | + // 8 12 6 11 | 11 6 12 8 | + // / | / | | | \ | \ | + // 5/______5__6/ | | | \6__5______\5 | + // face 5 ---> | | | | <--- 6 face | face 6 ---> | | | | <--- 5 face | + // | |__3__|____| | |____|__3__| | | + // | /4 | /3 | 3\ | 4\ | | + // | / | / | \ | \ | | + // 9 4 10 2 | 2 10 4 9 | + // |/__1______|/ | \|______1__\| | + // 1 2 | 2 1 | + // _. . | . ._ | + // /| /|\ | /|\ |\ | + // / | | | \ | + // 3 face 1 face | face 1 face 3 | + // | | + // Picture 1 (right orientation) | Picture 2 (left orientation) | + // | + // For the moment, the orientation of numbering is not controlled + + // Faces: 1 - bottom, 2 - top, 3 - front, 4 - back, 5 - left (right), 6 - right (left) + + // + // 4_______3__3 2 ______2__3 + // / / | | + // 4 2 1 3 + // / / | | + // 1/______1__2/ | | + // | | + // | __4______| + // face 2 face 4 1 4 + // | / + // \|/ |/_ + // ' ' + // 3 8_______7__7 3 + // /| /| /| /| + // 3 2 8 12 6 11 3 2 + // / | / | / | / | + // 4/ | 5/______5__6/ | 4/ | + // | | face 5 ---> | | | | <--- 6 face | | + // | | | |__3__|____| | | + // | /2 | /4 | /3 | /2 + // | / | / | / | / + // 4 1 9 4 10 2 4 1 + // |/ |/__1______|/ |/ + // 1 1 2 1 + // _. . + // /| /|\ + // / | + // 2 ______2__3 3 face 1 face + // | | + // | | __3_______ + // | | /4 /3 + // | | / / + // 1 3 4 2 + // | __4______| /__1______ / + // 1 4 1 2 + // + // Picture 3 (On periferal pictures the local + // numeration of edges and vertices is shown) + +class GEOMImpl_Block6Explorer +{ + public: + // ---------- PUBLIC METHODS ---------- + + GEOMImpl_Block6Explorer (); + // Constructor. + + // Initialization by existing solid, + // sub-elements regulate numeration + + void InitByBlock (const TopoDS_Shape& theBlock); + // Init by hexahedral solid. First face, edge and vertex is defined randomly + + void InitByBlockAndFace (const TopoDS_Shape& theBlock, + const TopoDS_Shape& theFace); + // Constructor from hexahedral solid, making theFace the first face. + // First edge and vertex is defined randomly from theFace entities + + void InitByBlockAndEdges (const TopoDS_Shape& theBlock, + const TopoDS_Shape& theEdge1, + const TopoDS_Shape& theEdge2); + // Init by hexahedral solid, making theEdge1 the first, theEdge2 the fird. + // First vertex is defined randomly from theEdge1 vertices + // (Picture 1 and Picture 2 shows two possible cases) + + void InitByBlockAndVertices (const TopoDS_Shape& theBlock, + const TopoDS_Shape& theVertex1, + const TopoDS_Shape& theVertex2, + const TopoDS_Shape& theVertex3); + // Init by hexahedral solid, making theVertex1 the first, + // theVertex2 the second and theVertex3 the fird vertices. + + // Initialization by parts of solid to be built + + void InitByTwoFaces (const TopoDS_Shape& theFace1, + const TopoDS_Shape& theFace2); + // Init by two faces. TheFace1 will be the first, + // theFace2 will be the second. + // First edge and vertex is defined randomly from theFace1 entities. + + // Access to vertices + TopoDS_Shape GetVertex (const Standard_Integer theVertexID); // [1-8] + + Standard_Integer GetVertexID (const TopoDS_Shape& theVertex); + + Standard_Integer GetVertexID (const Standard_Integer theFaceID, // [1-6] + const Standard_Integer theVertexNB); // [1-4] + + Standard_Integer GetVertexOnEdgeID (const Standard_Integer theEdgeID, // [1-12] + const Standard_Integer theVertexNB); // [1-2] + + // Access to edges + TopoDS_Shape GetEdge (const Standard_Integer theEdgeID, // [1-12] + const Standard_Boolean doMake = Standard_False); + + Standard_Integer GetEdgeID (const TopoDS_Shape& theEdge); + + Standard_Integer GetEdgeID (const Standard_Integer theFaceID, // [1-6] + const Standard_Integer theEdgeNB); // [1-4] + + Standard_Integer FindEdgeID (const Standard_Integer theVertex1ID, + const Standard_Integer theVertex2ID); + + Standard_Integer FindCommonEdgeID (const Standard_Integer theFace1ID, + const Standard_Integer theFace2ID); + + // Access to faces + TopoDS_Shape GetFace (const Standard_Integer theFaceID, // [1-6] + const Standard_Boolean doMake = Standard_False); + + Standard_Integer GetFaceID (const TopoDS_Shape& theFace); + + Standard_Integer FindFaceID (const Standard_Integer theEdge1ID, + const Standard_Integer theEdge2ID); + + Standard_Integer GetOppositeFaceID (const Standard_Integer theFaceID); + + // Check Block + Standard_Boolean IsSimilarFaces (const Standard_Integer theFace1ID, + const Standard_Integer theFace2ID, + const gp_Trsf theTransformation); + // returns true, if theFace1, transformed + // by theTransformation, coincides with theFace2 + public: + // ---------- STATIC PUBLIC METHODS ---------- + static void MapShapesAndAncestors (const TopoDS_Shape& S, + const TopAbs_ShapeEnum TS, + const TopAbs_ShapeEnum TA, + TopTools_IndexedDataMapOfShapeListOfShape& M); + + static Standard_Boolean IsSimilarEdges (const TopoDS_Shape& E1, + const TopoDS_Shape& E2); + + static Standard_Integer FindEdge (TopoDS_Shape& theResult, + const TopoDS_Shape& V1, + const TopoDS_Shape& V2, + const TopTools_IndexedDataMapOfShapeListOfShape& MVE, + const Standard_Boolean findAll = Standard_False); + // returns number of found edges + + static Standard_Integer FindFace (TopoDS_Shape& theResult, + const TopoDS_Shape& V1, + const TopoDS_Shape& V2, + const TopoDS_Shape& V3, + const TopoDS_Shape& V4, + const TopTools_IndexedDataMapOfShapeListOfShape& MVF, + const Standard_Boolean findAll = Standard_False); + // returns number of found faces + + static void MakeFace (const TopoDS_Wire& theWire, + const Standard_Boolean isPlanarWanted, + TopoDS_Shape& theResult); + + private: + // ---------- PRIVATE FIELDS ---------- + + TopTools_Array1OfShape myFaces; + TopTools_Array1OfShape myEdges; + TopTools_Array1OfShape myVertices; +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_BlockDriver.cxx b/src/GEOMImpl/GEOMImpl_BlockDriver.cxx new file mode 100644 index 000000000..27073e439 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_BlockDriver.cxx @@ -0,0 +1,920 @@ + +using namespace std; + +#include + +#include "GEOMImpl_BlockDriver.hxx" +#include "GEOMImpl_IBlocks.hxx" +#include "GEOMImpl_IBlockTrsf.hxx" +#include "GEOMImpl_GlueDriver.hxx" +#include "GEOMImpl_Types.hxx" +#include "GEOMImpl_ILocalOperations.hxx" +#include "GEOMImpl_Block6Explorer.hxx" +#include "GEOM_Function.hxx" + +#include "ShHealOper_Sewing.hxx" +#include "NMTAlgo_Splitter1.hxx" + +#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 + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& GEOMImpl_BlockDriver::GetID() +{ + static Standard_GUID aBlockDriver("FF1BBB67-5D14-4df2-980B-3A668264EA16"); + return aBlockDriver; +} + + +//======================================================================= +//function : GEOMImpl_BlockDriver +//purpose : +//======================================================================= +GEOMImpl_BlockDriver::GEOMImpl_BlockDriver() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_BlockDriver::Execute(TFunction_Logbook& log) const +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); + + Standard_Integer aType = aFunction->GetType(); + + TopoDS_Shape aShape; + BRep_Builder B; + + Standard_Real prec = Precision::Confusion(); + + Standard_Integer aNbSub = 0; + if (aType == BLOCK_COMPOUND_GLUE) { + + aNbSub = 1; + + } else if (aType == BLOCK_FACE_TWO_EDGES || + aType == BLOCK_TWO_FACES) { + + aNbSub = 2; + + } else if (aType == BLOCK_FACE_FOUR_PNT || + aType == BLOCK_FACE_FOUR_EDGES) { + + aNbSub = 4; + + } else if (aType == BLOCK_SIX_FACES) { + + aNbSub = 6; + + } else { + } + + if (aNbSub > 0) { + GEOMImpl_IBlocks aCI (aFunction); + Handle(TColStd_HSequenceOfTransient) aShapes = aCI.GetShapes(); + Standard_Integer nbshapes = aShapes->Length(); + + if (nbshapes != aNbSub) { + Standard_TypeMismatch::Raise + ("Number of elements for object construction does not correspond to the used constructor"); + } + + TopTools_Array1OfShape anArgs (1, aNbSub); + Standard_Integer argi; + for (argi = 1; argi <= aNbSub; argi++) { + Handle(GEOM_Function) aRef = Handle(GEOM_Function)::DownCast(aShapes->Value(argi)); + TopoDS_Shape anArg = aRef->GetValue(); + if (anArg.IsNull()) { + Standard_NullObject::Raise("Null shape is given as argument"); + } + anArgs(argi) = anArg; + } + + if (aType == BLOCK_FACE_FOUR_EDGES) { + + // Make face from four edges + if (anArgs(1).ShapeType() != TopAbs_EDGE || anArgs(2).ShapeType() != TopAbs_EDGE || + anArgs(3).ShapeType() != TopAbs_EDGE || anArgs(4).ShapeType() != TopAbs_EDGE) { + Standard_TypeMismatch::Raise("Shape for face construction is not an edge"); + } + + // count corner vertices + TopTools_MapOfShape aVertMap; + for (Standard_Integer ii = 1; ii <= 4; ii++) { + TopoDS_Edge anEdge = TopoDS::Edge(anArgs(ii)); + TopoDS_Vertex V1, V2; + TopExp::Vertices(anEdge, V1, V2, Standard_True); + if (V1.IsNull() || V2.IsNull()) { + Standard_NullObject::Raise("Bad edge for face construction: vertex is not defined"); + } + if (BRepTools::Compare(V1,V2)) { + Standard_ConstructionError::Raise("Edge ends are too close"); + } + Standard_Boolean isCoin1 = Standard_False, isCoin2 = Standard_False; + TopTools_MapIteratorOfMapOfShape anIter (aVertMap); + for (; anIter.More(); anIter.Next()) { + TopoDS_Vertex V = TopoDS::Vertex(anIter.Key()); + if (BRepTools::Compare(V,V1)) isCoin1 = Standard_True; + if (BRepTools::Compare(V,V2)) isCoin2 = Standard_True; + } + if (!isCoin1) aVertMap.Add(V1); + if (!isCoin2) aVertMap.Add(V2); + } + if (aVertMap.Extent() != 4) { + Standard_ConstructionError::Raise("The edges must form a closed wire"); + } + + TopoDS_Edge anEdge1 = TopoDS::Edge(anArgs(1)); + TopoDS_Edge anEdge2 = TopoDS::Edge(anArgs(2)); + TopoDS_Edge anEdge3 = TopoDS::Edge(anArgs(3)); + TopoDS_Edge anEdge4 = TopoDS::Edge(anArgs(4)); + + // check, if anEdge1 has common/coincident vertex with anEdge2, + Standard_Boolean isConnected12 = Standard_False; + TopoDS_Vertex V11, V12, V21, V22; + TopExp::Vertices(anEdge1, V11, V12, Standard_True); + TopExp::Vertices(anEdge2, V21, V22, Standard_True); + if (BRepTools::Compare(V11,V21) || BRepTools::Compare(V11,V22) || + BRepTools::Compare(V12,V21) || BRepTools::Compare(V12,V22)) { + // the edges have common vertex + isConnected12 = Standard_True; + } + + // build wire in right order, corresponding to edges connexity + BRepBuilderAPI_MakeWire MW; + if (isConnected12) + MW = BRepBuilderAPI_MakeWire(anEdge1, anEdge2, anEdge3, anEdge4); + else + MW = BRepBuilderAPI_MakeWire(anEdge1, anEdge3, anEdge2, anEdge4); + + if (!MW.IsDone()) { + Standard_ConstructionError::Raise + ("Impossible to build a connected wire from the given edges"); + } + TopoDS_Wire aWire = MW; + if (!aWire.Closed()) { + Standard_ConstructionError::Raise + ("Impossible to build a closed wire from the given edges"); + } + + // try to build face on the wire + GEOMImpl_Block6Explorer::MakeFace(aWire, Standard_False, aShape); + if (aShape.IsNull()) { + Standard_ConstructionError::Raise("Face construction failed"); + } + + } else if (aType == BLOCK_FACE_TWO_EDGES) { + + // Make face from two opposite edges + if (anArgs(1).ShapeType() != TopAbs_EDGE || + anArgs(2).ShapeType() != TopAbs_EDGE) { + Standard_TypeMismatch::Raise("Shape for face construction is not an edge"); + } + + TopoDS_Edge anEdge1 = TopoDS::Edge(anArgs(1)); + TopoDS_Edge anEdge2 = TopoDS::Edge(anArgs(2)); + + if (anEdge1.IsSame(anEdge2)) { + Standard_ConstructionError::Raise("The edges must be different"); + } + + // create two edges, linking ends of the given edges + TopoDS_Vertex V11, V12, V21, V22; + TopExp::Vertices(anEdge1, V11, V12, Standard_True); + TopExp::Vertices(anEdge2, V21, V22, Standard_True); + if (V11.IsNull() || V12.IsNull() || + V21.IsNull() || V22.IsNull()) { + Standard_NullObject::Raise("Bad edge for face construction: vertex is not defined"); + } + gp_Pnt P11 = BRep_Tool::Pnt(V11); + gp_Pnt P12 = BRep_Tool::Pnt(V12); + gp_Pnt P21 = BRep_Tool::Pnt(V21); + gp_Pnt P22 = BRep_Tool::Pnt(V22); + + if (P11.Distance(P21) < prec || P12.Distance(P22) < prec || + P11.Distance(P22) < prec || P12.Distance(P21) < prec) { + Standard_ConstructionError::Raise("Given edges have too close ends"); + } + + Standard_Real per11 = P11.Distance(P21) + P12.Distance(P22); + Standard_Real per12 = P11.Distance(P22) + P12.Distance(P21); + + TopoDS_Edge anEdge3; + TopoDS_Edge anEdge4; + if (per11 < per12) { + anEdge3 = BRepBuilderAPI_MakeEdge(V11, V21); + anEdge4 = BRepBuilderAPI_MakeEdge(V12, V22); + } else { + anEdge3 = BRepBuilderAPI_MakeEdge(V11, V22); + anEdge4 = BRepBuilderAPI_MakeEdge(V12, V21); + } + + // build a wire + BRepBuilderAPI_MakeWire MW (anEdge1, anEdge3, anEdge2, anEdge4); + if (!MW.IsDone()) { + Standard_ConstructionError::Raise("Wire construction failed"); + } + + // try to build face on the wire + GEOMImpl_Block6Explorer::MakeFace(MW, Standard_False, aShape); + if (aShape.IsNull()) { + Standard_ConstructionError::Raise("Face construction failed"); + } + + } else if (aType == BLOCK_FACE_FOUR_PNT) { + + // Make face from four corner vertices + if (anArgs(1).ShapeType() != TopAbs_VERTEX || + anArgs(2).ShapeType() != TopAbs_VERTEX || + anArgs(3).ShapeType() != TopAbs_VERTEX || + anArgs(4).ShapeType() != TopAbs_VERTEX) { + Standard_TypeMismatch::Raise("Shape for face construction is not a vertex"); + } + + TopoDS_Vertex V1 = TopoDS::Vertex(anArgs(1)); + TopoDS_Vertex V2 = TopoDS::Vertex(anArgs(2)); + TopoDS_Vertex V3 = TopoDS::Vertex(anArgs(3)); + TopoDS_Vertex V4 = TopoDS::Vertex(anArgs(4)); + + gp_Pnt P1 = BRep_Tool::Pnt(V1); + gp_Pnt P2 = BRep_Tool::Pnt(V2); + gp_Pnt P3 = BRep_Tool::Pnt(V3); + gp_Pnt P4 = BRep_Tool::Pnt(V4); + + if (P1.Distance(P2) < prec || P1.Distance(P3) < prec || + P1.Distance(P4) < prec || P2.Distance(P3) < prec || + P2.Distance(P4) < prec || P3.Distance(P4) < prec) { + Standard_ConstructionError::Raise("Four not coincident points must be given"); + } + + // calculate perimeters + Standard_Real per1234 = P1.Distance(P2) + P2.Distance(P3) + + P3.Distance(P4) + P4.Distance(P1); + Standard_Real per1243 = P1.Distance(P2) + P2.Distance(P4) + + P4.Distance(P3) + P3.Distance(P1); + Standard_Real per1324 = P1.Distance(P3) + P3.Distance(P2) + + P2.Distance(P4) + P4.Distance(P1); + + // order vertices + if (per1243 < per1234 && per1243 < per1324) { + TopoDS_Vertex Vtmp = V3; + V3 = V4; + V4 = Vtmp; + } else if (per1324 < per1234 && per1324 < per1243) { + TopoDS_Vertex Vtmp = V3; + V3 = V2; + V2 = Vtmp; + } else { + } + + // build wire + BRepBuilderAPI_MakePolygon aMkPoly (V1, V2, V3, V4, Standard_True); + if (!aMkPoly.IsDone()) { + Standard_ConstructionError::Raise("Polygon construction failed"); + } + + // try to build face on the wire + GEOMImpl_Block6Explorer::MakeFace(aMkPoly, Standard_False, aShape); + if (aShape.IsNull()) { + Standard_ConstructionError::Raise("Face construction failed"); + } + + } else if (aType == BLOCK_SIX_FACES || aType == BLOCK_TWO_FACES) { + + BRepTools_Quilt Glue; + + if (aType == BLOCK_SIX_FACES) { + + // Make block (hexahedral solid) from six faces + for (Standard_Integer ind = 1; ind <= nbshapes; ind++) { + if (anArgs(ind).ShapeType() != TopAbs_FACE) { + Standard_TypeMismatch::Raise("Shape for block construction is not a face"); + } + Glue.Add(anArgs(ind)); + } + + } else { + + // Make block (hexahedral solid) from two opposite faces + if (anArgs(1).ShapeType() != TopAbs_FACE || + anArgs(2).ShapeType() != TopAbs_FACE) { + Standard_TypeMismatch::Raise("Shape for block construction is not a face"); + } + + // Get wires of the given faces + TopExp_Explorer wires1 (anArgs(1), TopAbs_WIRE); + TopExp_Explorer wires2 (anArgs(2), TopAbs_WIRE); + if (!wires1.More() || !wires2.More()) { + Standard_ConstructionError::Raise("A face for the block has no wires"); + } + TopoDS_Shape aWire1 = wires1.Current(); + TopoDS_Shape aWire2 = wires2.Current(); + wires1.Next(); + wires2.Next(); + if (wires1.More() || wires2.More()) { + Standard_ConstructionError::Raise("A face for the block has more than one wire"); + } + + GEOMImpl_Block6Explorer aBlockTool; + aBlockTool.InitByTwoFaces(anArgs(1), anArgs(2)); + + // Construct the linking faces and add them in the gluing tool + Glue.Add(anArgs(1)); + Glue.Add(aBlockTool.GetFace(3, Standard_True)); + Glue.Add(aBlockTool.GetFace(4, Standard_True)); + Glue.Add(aBlockTool.GetFace(5, Standard_True)); + Glue.Add(aBlockTool.GetFace(6, Standard_True)); + Glue.Add(anArgs(2)); + } + + TopExp_Explorer exp (Glue.Shells(), TopAbs_SHELL); + Standard_Integer ish = 0; + TopTools_MapOfShape mapShape; + for (; exp.More(); exp.Next()) { + if (mapShape.Add(exp.Current())) { + aShape = exp.Current(); + ish++; + } + } + + if (ish > 1) { + aShape = Glue.Shells(); + Standard_Real aTol = prec; // Precision::Confusion() + TopExp_Explorer expF (aShape, TopAbs_FACE); + TopTools_MapOfShape mapF; + TopoDS_Shell Shell; + B.MakeShell(Shell); + for (; expF.More(); expF.Next()) { + if (mapF.Add(expF.Current())) { + B.Add(Shell, expF.Current()); + Standard_Real aToler = BRep_Tool::Tolerance(TopoDS::Face(expF.Current())); + if (aToler > aTol) + aTol = aToler; + } + } + ShHealOper_Sewing aHealer (Shell, aTol); + if (aHealer.Perform()) + aShape = aHealer.GetResultShape(); + else + Standard_ConstructionError::Raise + ("Impossible to build a connected shell on the given faces"); + } + + if (aType == BLOCK_SIX_FACES) { + if (!aShape.Closed()) { + Standard_ConstructionError::Raise + ("Impossible to build a closed shell on the given faces"); + } + } + + TopoDS_Solid Sol; + B.MakeSolid(Sol); + B.Add(Sol, aShape); + BRepClass3d_SolidClassifier SC (Sol); + SC.PerformInfinitePoint(prec); + if (SC.State() == TopAbs_IN) { + B.MakeSolid(Sol); + B.Add(Sol, aShape.Reversed()); + } + aShape = Sol; + BRepLib::SameParameter(aShape, 1.E-5, Standard_True); + + } else if (aType == BLOCK_COMPOUND_GLUE) { + + // Make blocks compound from a compound + if (anArgs(1).ShapeType() != TopAbs_COMPOUND && + anArgs(2).ShapeType() != TopAbs_COMPSOLID) { + Standard_TypeMismatch::Raise("Not a compound given"); + } + + TopoDS_Shape aCompound = anArgs(1); + + // Glue coincident faces and edges (with Partition algorithm). + NMTAlgo_Splitter1 PS; + PS.AddShape(aCompound); + PS.Compute(); + PS.SetRemoveWebs(Standard_False); +// PS.Build(aCompound.ShapeType()); + PS.Build(TopAbs_SOLID); + + aShape = PS.Shape(); + } else { + } + + } else { // Multi-transformations + + 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"); + } + + // 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 (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 (aFace1.ShapeType() != TopAbs_FACE) { + Standard_TypeMismatch::Raise("Sub-shape with given Id is not a face"); + } + + 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"); + } + } + + Standard_Integer aNbIter = aCI.GetNbIterU(); + + MultiTransformate1D(aBlock, aFace1, aFace2, aNbIter, aMulti); + + } 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(); + + 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 (aFace1U.ShapeType() != TopAbs_FACE || + aFace1V.ShapeType() != TopAbs_FACE) { + Standard_TypeMismatch::Raise("Sub-shape with given Id is not a face"); + } + + 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 (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(); + + MultiTransformate2D(aBlock, + aFace1U, aFace2U, aNbIterU, + aFace1V, aFace2V, aNbIterV, aMulti); + + } else { + return 0; + } + + if (aMulti.IsNull()) { + StdFail_NotDone::Raise("Multi-transformation failed"); + return 0; + } + + // Glue faces of the multi-block + aShape = GEOMImpl_GlueDriver::GlueFaces(aMulti, aTol); + } + + if (aShape.IsNull()) return 0; + + aFunction->SetValue(aShape); + + log.SetTouched(Label()); + + return 1; +} + +//======================================================================= +//function : MultiTransformate1D +//purpose : +//======================================================================= +void GEOMImpl_BlockDriver::MultiTransformate1D (const TopoDS_Shape& theBlock, + const TopoDS_Shape& theFace1, + const TopoDS_Shape& theFace2, + const Standard_Integer theNbIter, + TopoDS_Shape& theResult) const +{ + // Construct Tool, where will be the first face, + // and a face, opposite to , will be the second face + GEOMImpl_Block6Explorer aBlockTool; + aBlockTool.InitByBlockAndFace(theBlock, theFace1); + + // Find IDs of the faces + Standard_Integer dir_face1 = 1, dir_face2 = 2; + if (!theFace2.IsNull()) { + dir_face2 = aBlockTool.GetFaceID(theFace2); + } + + // Find three pairs of points + Standard_Integer v11_id = 0, v12_id = 0, v13_id = 0; // vertices of the first face + Standard_Integer v21_id = 0, v22_id = 0, v23_id = 0; // vertices of the second face + + if (dir_face2 == 2) { // is opposite to + + // We will take vertices with equal local numbers on the faces, + // as the Block6Explorer gives equal local numbers + // to the linked vertices on the opposite faces, + // i.e. v1* is linked with the v2* by an edge: + + // _________ + // /|v23 /| + // / | / | dir_face1 - bottom + // / | / | + // /________ / | dir_face2 - top + // |v21 | |v22 | + // | |____|____| + // | / v13 | / + // | / | / + // | / | / + // |/________|/ + // v11 v12 + + v11_id = aBlockTool.GetVertexID(dir_face1, 1); + v12_id = aBlockTool.GetVertexID(dir_face1, 2); + v13_id = aBlockTool.GetVertexID(dir_face1, 4); + + v21_id = aBlockTool.GetVertexID(dir_face2, 1); + v22_id = aBlockTool.GetVertexID(dir_face2, 2); + v23_id = aBlockTool.GetVertexID(dir_face2, 4); + + } else { + + // _________ + // /| /| + // / | / | dir_face1 - bottom + // / | / | + // /________ / | dir_face2 - right (for example) + // | | |v23 | + // | |____|____| + // | / | /v12 = v22 (common_vertex2) + // | / | / + // | / | / + // |/________|/ + // v13 v11 = v21 (common_vertex1) + + Standard_Integer common_edge_id = aBlockTool.FindCommonEdgeID(dir_face1, dir_face2); + Standard_Integer common_vertex1 = aBlockTool.GetVertexOnEdgeID(common_edge_id, 1); + Standard_Integer common_vertex2 = aBlockTool.GetVertexOnEdgeID(common_edge_id, 2); + + Standard_Integer not_common_v1 = 0; + Standard_Integer vid = 1; + Standard_Boolean isFound = Standard_False; + while (!isFound && vid <= 4) { + not_common_v1 = aBlockTool.GetVertexID(dir_face1, vid); + isFound = (not_common_v1 != common_vertex2 && + aBlockTool.FindEdgeID(not_common_v1, common_vertex1) != 0); + vid++; + } + + Standard_Integer not_common_v2 = 0; + vid = 1; + isFound = Standard_False; + while (!isFound && vid <= 4) { + not_common_v2 = aBlockTool.GetVertexID(dir_face2, vid); + isFound = (not_common_v2 != common_vertex2 && + aBlockTool.FindEdgeID(not_common_v2, common_vertex1) != 0); + vid++; + } + + v11_id = common_vertex1; + v12_id = common_vertex2; + v13_id = not_common_v1; + + v21_id = common_vertex1; + v22_id = common_vertex2; + v23_id = not_common_v2; + } + + // Construct a transformation operator + TopoDS_Vertex V11 = TopoDS::Vertex(aBlockTool.GetVertex(v11_id)); + TopoDS_Vertex V12 = TopoDS::Vertex(aBlockTool.GetVertex(v12_id)); + TopoDS_Vertex V13 = TopoDS::Vertex(aBlockTool.GetVertex(v13_id)); + + TopoDS_Vertex V21 = TopoDS::Vertex(aBlockTool.GetVertex(v21_id)); + TopoDS_Vertex V22 = TopoDS::Vertex(aBlockTool.GetVertex(v22_id)); + TopoDS_Vertex V23 = TopoDS::Vertex(aBlockTool.GetVertex(v23_id)); + + // Axes of the first direction face + gp_Pnt P1 = BRep_Tool::Pnt(V11); + gp_Vec VecN1 (P1, BRep_Tool::Pnt(V12)); + gp_Vec VecX1 (P1, BRep_Tool::Pnt(V13)); + gp_Ax3 Ax1 (P1, VecN1, VecX1); + + // Axes of the second direction face + gp_Pnt P2 = BRep_Tool::Pnt(V21); + gp_Vec VecN2 (P2, BRep_Tool::Pnt(V22)); + gp_Vec VecX2 (P2, BRep_Tool::Pnt(V23)); + gp_Ax3 Ax2 (P2, VecN2, VecX2); + + gp_Trsf aTrsf; + aTrsf.SetDisplacement(Ax1, Ax2); + + // Check, that is similar to . + // Actually, we need only to check right position of one + // vertex, not involved into the transformation construction. + if (!aBlockTool.IsSimilarFaces(dir_face1, dir_face2, aTrsf)) { + Standard_ConstructionError::Raise("The direction faces are not similar"); + } + + // Perform multi-transformation + TopoDS_Compound aCompound; + BRep_Builder B; + B.MakeCompound(aCompound); + + TopoDS_Shape aPrevShape = theBlock; + for (Standard_Integer i = 0; i < theNbIter; i++) { + B.Add(aCompound, aPrevShape); + BRepBuilderAPI_Transform aTransformation (aPrevShape, aTrsf, Standard_False); + aPrevShape = aTransformation.Shape(); + } + theResult = aCompound; +} + +//======================================================================= +//function : MultiTransformate2D +//purpose : +//======================================================================= +void GEOMImpl_BlockDriver::MultiTransformate2D (const TopoDS_Shape& theBlock, + const TopoDS_Shape& theFace1U, + const TopoDS_Shape& theFace2U, + const Standard_Integer theNbIterU, + const TopoDS_Shape& theFace1V, + const TopoDS_Shape& theFace2V, + const Standard_Integer theNbIterV, + TopoDS_Shape& theResult) const +{ + // Construct Tool, where will be the first face, + // and a face, opposite to , will be the second face + GEOMImpl_Block6Explorer aBlockTool; + aBlockTool.InitByBlockAndFace(theBlock, theFace1U); + + gp_Trsf aTrsfU, aTrsfV; + gp_Ax3 Ax1V, Ax2V; + for (Standard_Integer uv = 1; uv <= 2; uv++) { + // U transformation + TopoDS_Shape theFace1 = theFace1U; + TopoDS_Shape theFace2 = theFace2U; + if (uv == 2) { + // V transformation + theFace1 = theFace1V; + theFace2 = theFace2V; + } + + // Find IDs of the faces + Standard_Integer dir_face1 = aBlockTool.GetFaceID(theFace1); + Standard_Integer dir_face2 = 0; + Standard_Integer opp_face1 = aBlockTool.GetOppositeFaceID(dir_face1); + if (theFace2.IsNull()) { + dir_face2 = opp_face1; + } else { + dir_face2 = aBlockTool.GetFaceID(theFace2); + } + + // Find three pairs of points + Standard_Integer v11_id = 0, v12_id = 0, v13_id = 0; // vertices of the first face + Standard_Integer v21_id = 0, v22_id = 0, v23_id = 0; // vertices of the second face + + if (dir_face2 == opp_face1) { // is opposite to + + // We will take vertices with equal local numbers on the faces, + // as the Block6Explorer gives equal local numbers + // to the linked vertices on the opposite faces, + // i.e. v1* is linked with the v2* by an edge: + + v11_id = aBlockTool.GetVertexID(dir_face1, 1); + v12_id = aBlockTool.GetVertexID(dir_face1, 2); + v13_id = aBlockTool.GetVertexID(dir_face1, 4); + + v21_id = aBlockTool.GetVertexID(dir_face2, 1); + v22_id = aBlockTool.GetVertexID(dir_face2, 2); + v23_id = aBlockTool.GetVertexID(dir_face2, 4); + + } else { + + Standard_Integer common_edge_id = aBlockTool.FindCommonEdgeID(dir_face1, dir_face2); + Standard_Integer common_vertex1 = aBlockTool.GetVertexOnEdgeID(common_edge_id, 1); + Standard_Integer common_vertex2 = aBlockTool.GetVertexOnEdgeID(common_edge_id, 2); + + Standard_Integer not_common_v1 = 0; + Standard_Integer vid = 1; + Standard_Boolean isFound = Standard_False; + while (!isFound && vid <= 4) { + not_common_v1 = aBlockTool.GetVertexID(dir_face1, vid); + isFound = (not_common_v1 != common_vertex2 && + aBlockTool.FindEdgeID(not_common_v1, common_vertex1) != 0); + vid++; + } + + Standard_Integer not_common_v2 = 0; + vid = 1; + isFound = Standard_False; + while (!isFound && vid <= 4) { + not_common_v2 = aBlockTool.GetVertexID(dir_face2, vid); + isFound = (not_common_v2 != common_vertex2 && + aBlockTool.FindEdgeID(not_common_v2, common_vertex1) != 0); + vid++; + } + + v11_id = common_vertex1; + v12_id = common_vertex2; + v13_id = not_common_v1; + + v21_id = common_vertex1; + v22_id = common_vertex2; + v23_id = not_common_v2; + } + + // Construct a transformation operator + TopoDS_Vertex V11 = TopoDS::Vertex(aBlockTool.GetVertex(v11_id)); + TopoDS_Vertex V12 = TopoDS::Vertex(aBlockTool.GetVertex(v12_id)); + TopoDS_Vertex V13 = TopoDS::Vertex(aBlockTool.GetVertex(v13_id)); + + TopoDS_Vertex V21 = TopoDS::Vertex(aBlockTool.GetVertex(v21_id)); + TopoDS_Vertex V22 = TopoDS::Vertex(aBlockTool.GetVertex(v22_id)); + TopoDS_Vertex V23 = TopoDS::Vertex(aBlockTool.GetVertex(v23_id)); + + // Axes of the first direction face + gp_Pnt P1 = BRep_Tool::Pnt(V11); + gp_Vec VecN1 (P1, BRep_Tool::Pnt(V12)); + gp_Vec VecX1 (P1, BRep_Tool::Pnt(V13)); + gp_Ax3 Ax1 (P1, VecN1, VecX1); + + // Axes of the second direction face + gp_Pnt P2 = BRep_Tool::Pnt(V21); + gp_Vec VecN2 (P2, BRep_Tool::Pnt(V22)); + gp_Vec VecX2 (P2, BRep_Tool::Pnt(V23)); + gp_Ax3 Ax2 (P2, VecN2, VecX2); + + gp_Trsf aTrsf; + aTrsf.SetDisplacement(Ax1, Ax2); + if (uv == 1) { + aTrsfU = aTrsf; + } else { + aTrsfV = aTrsf; + Ax1V = Ax1; + Ax2V = Ax2; + } + + // Check, that is similar to . + // Actually, we need only to check right position of one + // vertex, not involved into the transformation construction. + if (!aBlockTool.IsSimilarFaces(dir_face1, dir_face2, aTrsf)) { + Standard_ConstructionError::Raise("The direction faces are not similar"); + } + } + + // Perform multi-transformation + TopoDS_Compound aCompound; + BRep_Builder B; + B.MakeCompound(aCompound); + + TopoDS_Shape aPrevShapeU = theBlock; + for (int i = 0; i < theNbIterU; i++) { + TopoDS_Shape aPrevShapeV = aPrevShapeU; + for (int j = 0; j < theNbIterV; j++) { + B.Add(aCompound, aPrevShapeV); + BRepBuilderAPI_Transform aTransformationV (aPrevShapeV, aTrsfV, Standard_False); + aPrevShapeV = aTransformationV.Shape(); + } + BRepBuilderAPI_Transform aTransformationU (aPrevShapeU, aTrsfU, Standard_False); + aPrevShapeU = aTransformationU.Shape(); + // Correction of the second transformation according to the first transformation + Ax1V.Transform(aTrsfU); + Ax2V.Transform(aTrsfU); + aTrsfV.SetDisplacement(Ax1V, Ax2V); + // Correction done + } + theResult = aCompound; +} + +//======================================================================= +//function : GEOMImpl_BlockDriver_Type_ +//purpose : +//======================================================================= +Standard_EXPORT Handle_Standard_Type& GEOMImpl_BlockDriver_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); + 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("GEOMImpl_BlockDriver", + sizeof(GEOMImpl_BlockDriver), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + +//======================================================================= +//function : DownCast +//purpose : +//======================================================================= +const Handle(GEOMImpl_BlockDriver) Handle(GEOMImpl_BlockDriver)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOMImpl_BlockDriver) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_BlockDriver))) { + _anOtherObject = Handle(GEOMImpl_BlockDriver)((Handle(GEOMImpl_BlockDriver)&)AnObject); + } + } + + return _anOtherObject ; +} diff --git a/src/GEOMImpl/GEOMImpl_BlockDriver.hxx b/src/GEOMImpl/GEOMImpl_BlockDriver.hxx new file mode 100644 index 000000000..8d78a468d --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_BlockDriver.hxx @@ -0,0 +1,155 @@ +// File : GEOMImpl_BlockDriver.ixx +// Module : GEOMImpl + +#ifndef _GEOMImpl_BlockDriver_HeaderFile +#define _GEOMImpl_BlockDriver_HeaderFile + +#ifndef _TColStd_SequenceOfExtendedString_HeaderFile +#include +#endif +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_GUID_HeaderFile +#include +#endif + +#ifndef _Handle_TFunction_Driver_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TFunction_Driver); +class GEOMImpl_BlockDriver; + +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMImpl_BlockDriver); + +class Handle(GEOMImpl_BlockDriver) : public Handle(TFunction_Driver) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + Handle(GEOMImpl_BlockDriver)():Handle(TFunction_Driver)() {} + Handle(GEOMImpl_BlockDriver)(const Handle(GEOMImpl_BlockDriver)& aHandle) : Handle(TFunction_Driver)(aHandle) + { + } + + Handle(GEOMImpl_BlockDriver)(const GEOMImpl_BlockDriver* anItem) : Handle(TFunction_Driver)((TFunction_Driver *)anItem) + { + } + + Handle(GEOMImpl_BlockDriver)& operator=(const Handle(GEOMImpl_BlockDriver)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOMImpl_BlockDriver)& operator=(const GEOMImpl_BlockDriver* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOMImpl_BlockDriver* operator->() + { + return (GEOMImpl_BlockDriver *)ControlAccess(); + } + + GEOMImpl_BlockDriver* operator->() const + { + return (GEOMImpl_BlockDriver *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOMImpl_BlockDriver)() {}; + + Standard_EXPORT static const Handle(GEOMImpl_BlockDriver) DownCast(const Handle(Standard_Transient)& AnObject); +}; + +#ifndef _TFunction_Driver_HeaderFile +#include +#endif +#ifndef _TFunction_Logbook_HeaderFile +#include +#endif +#ifndef _Standard_CString_HeaderFile +#include +#endif +#include + +class TColStd_SequenceOfExtendedString; + + +class GEOMImpl_BlockDriver : public TFunction_Driver { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + // Methods PUBLIC + // +Standard_EXPORT GEOMImpl_BlockDriver(); +Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; +Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {} +Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const { return Standard_True; } +Standard_EXPORT static const Standard_GUID& GetID(); +Standard_EXPORT ~GEOMImpl_BlockDriver() {}; + + + // Type management + // +Standard_EXPORT friend Handle_Standard_Type& GEOMImpl_BlockDriver_Type_(); +Standard_EXPORT const Handle(Standard_Type)& DynamicType() const { return STANDARD_TYPE(GEOMImpl_BlockDriver) ; } +Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const { return (STANDARD_TYPE(GEOMImpl_BlockDriver) == AType || TFunction_Driver::IsKind(AType)); } + +private: + void MultiTransformate1D (const TopoDS_Shape& theBlock, + const TopoDS_Shape& theFace1, + const TopoDS_Shape& theFace2, + const Standard_Integer theNbIter, + TopoDS_Shape& theResult) const; + + void MultiTransformate2D (const TopoDS_Shape& theBlock, + const TopoDS_Shape& theFace1U, + const TopoDS_Shape& theFace2U, + const Standard_Integer theNbIterU, + const TopoDS_Shape& theFace1V, + const TopoDS_Shape& theFace2V, + const Standard_Integer theNbIterV, + TopoDS_Shape& theResult) const; + +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_BooleanDriver.cxx b/src/GEOMImpl/GEOMImpl_BooleanDriver.cxx new file mode 100644 index 000000000..32599b5a3 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_BooleanDriver.cxx @@ -0,0 +1,138 @@ + +using namespace std; +#include "GEOMImpl_BooleanDriver.hxx" +#include "GEOMImpl_IBoolean.hxx" +#include "GEOMImpl_Types.hxx" +#include "GEOM_Function.hxx" + +#include +#include +#include +#include +#include +#include + +#include +#include + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& GEOMImpl_BooleanDriver::GetID() +{ + static Standard_GUID aBooleanDriver("FF1BBB21-5D14-4df2-980B-3A668264EA16"); + return aBooleanDriver; +} + + +//======================================================================= +//function : GEOMImpl_BooleanDriver +//purpose : +//======================================================================= +GEOMImpl_BooleanDriver::GEOMImpl_BooleanDriver() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_BooleanDriver::Execute(TFunction_Logbook& log) const +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); + + GEOMImpl_IBoolean aCI (aFunction); + Standard_Integer aType = aFunction->GetType(); + + TopoDS_Shape aShape; + + Handle(GEOM_Function) aRefShape1 = aCI.GetShape1(); + Handle(GEOM_Function) aRefShape2 = aCI.GetShape2(); + TopoDS_Shape aShape1 = aRefShape1->GetValue(); + TopoDS_Shape aShape2 = aRefShape2->GetValue(); + if (!aShape1.IsNull() && !aShape2.IsNull()) { + if (aType == BOOLEAN_COMMON) { + BRepAlgoAPI_Common BO (aShape1, aShape2); +// BO.Build(); + if (!BO.IsDone()) { + StdFail_NotDone::Raise("Requested boolean operation can not be performed on the given shapes"); + } + aShape = BO.Shape(); + } else if (aType == BOOLEAN_CUT) { + BRepAlgoAPI_Cut BO (aShape1, aShape2); + if (!BO.IsDone()) { + StdFail_NotDone::Raise("Requested boolean operation can not be performed on the given shapes"); + } + aShape = BO.Shape(); + } else if (aType == BOOLEAN_FUSE) { + BRepAlgoAPI_Fuse BO (aShape1, aShape2); + if (!BO.IsDone()) { + StdFail_NotDone::Raise("Requested boolean operation can not be performed on the given shapes"); + } + aShape = BO.Shape(); + } else if (aType == BOOLEAN_SECTION) { + BRepAlgoAPI_Section BO (aShape1, aShape2); + if (!BO.IsDone()) { + StdFail_NotDone::Raise("Requested boolean operation can not be performed on the given shapes"); + } + aShape = BO.Shape(); + } else { + } + } + + if (aShape.IsNull()) return 0; + if (!BRepAlgo::IsValid(aShape)) { + Standard_ConstructionError::Raise("Boolean aborted : non valid shape result"); + } + + aFunction->SetValue(aShape); + + log.SetTouched(Label()); + + return 1; +} + + +//======================================================================= +//function : GEOMImpl_BooleanDriver_Type_ +//purpose : +//======================================================================= +Standard_EXPORT Handle_Standard_Type& GEOMImpl_BooleanDriver_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); + 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("GEOMImpl_BooleanDriver", + sizeof(GEOMImpl_BooleanDriver), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + +//======================================================================= +//function : DownCast +//purpose : +//======================================================================= +const Handle(GEOMImpl_BooleanDriver) Handle(GEOMImpl_BooleanDriver)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOMImpl_BooleanDriver) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_BooleanDriver))) { + _anOtherObject = Handle(GEOMImpl_BooleanDriver)((Handle(GEOMImpl_BooleanDriver)&)AnObject); + } + } + + return _anOtherObject ; +} diff --git a/src/GEOMImpl/GEOMImpl_BooleanDriver.hxx b/src/GEOMImpl/GEOMImpl_BooleanDriver.hxx new file mode 100644 index 000000000..72163fbf8 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_BooleanDriver.hxx @@ -0,0 +1,139 @@ +// File : GEOMImpl_BooleanDriver.ixx +// Module : GEOMImpl + +#ifndef _GEOMImpl_BooleanDriver_HeaderFile +#define _GEOMImpl_BooleanDriver_HeaderFile + +#ifndef _TColStd_SequenceOfExtendedString_HeaderFile +#include +#endif +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_GUID_HeaderFile +#include +#endif + +#ifndef _Handle_TFunction_Driver_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TFunction_Driver); +class GEOMImpl_BooleanDriver; + +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMImpl_BooleanDriver); + +class Handle(GEOMImpl_BooleanDriver) : public Handle(TFunction_Driver) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + Handle(GEOMImpl_BooleanDriver)():Handle(TFunction_Driver)() {} + Handle(GEOMImpl_BooleanDriver)(const Handle(GEOMImpl_BooleanDriver)& aHandle) : Handle(TFunction_Driver)(aHandle) + { + } + + Handle(GEOMImpl_BooleanDriver)(const GEOMImpl_BooleanDriver* anItem) : Handle(TFunction_Driver)((TFunction_Driver *)anItem) + { + } + + Handle(GEOMImpl_BooleanDriver)& operator=(const Handle(GEOMImpl_BooleanDriver)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOMImpl_BooleanDriver)& operator=(const GEOMImpl_BooleanDriver* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOMImpl_BooleanDriver* operator->() + { + return (GEOMImpl_BooleanDriver *)ControlAccess(); + } + + GEOMImpl_BooleanDriver* operator->() const + { + return (GEOMImpl_BooleanDriver *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOMImpl_BooleanDriver)() {}; + + Standard_EXPORT static const Handle(GEOMImpl_BooleanDriver) DownCast(const Handle(Standard_Transient)& AnObject); +}; + +#ifndef _TFunction_Driver_HeaderFile +#include +#endif +#ifndef _TFunction_Logbook_HeaderFile +#include +#endif +#ifndef _Standard_CString_HeaderFile +#include +#endif + +class TColStd_SequenceOfExtendedString; + + +class GEOMImpl_BooleanDriver : public TFunction_Driver { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + // Methods PUBLIC + // +Standard_EXPORT GEOMImpl_BooleanDriver(); +Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; +Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {} +Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const { return Standard_True; } +Standard_EXPORT static const Standard_GUID& GetID(); +Standard_EXPORT ~GEOMImpl_BooleanDriver() {}; + + + // Type management + // +Standard_EXPORT friend Handle_Standard_Type& GEOMImpl_BooleanDriver_Type_(); +Standard_EXPORT const Handle(Standard_Type)& DynamicType() const { return STANDARD_TYPE(GEOMImpl_BooleanDriver) ; } +Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const { return (STANDARD_TYPE(GEOMImpl_BooleanDriver) == AType || TFunction_Driver::IsKind(AType)); } + + +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_BoxDriver.cxx b/src/GEOMImpl/GEOMImpl_BoxDriver.cxx new file mode 100644 index 000000000..f89ccf678 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_BoxDriver.cxx @@ -0,0 +1,131 @@ + +using namespace std; +#include "GEOMImpl_BoxDriver.hxx" +#include "GEOMImpl_IBox.hxx" +#include "GEOMImpl_Types.hxx" +#include "GEOM_Function.hxx" + +#include +#include +#include +#include +#include +#include +#include + +#include + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& GEOMImpl_BoxDriver::GetID() +{ + static Standard_GUID aBoxDriver("FF1BBB13-5D14-4df2-980B-3A668264EA16"); + return aBoxDriver; +} + + +//======================================================================= +//function : GEOMImpl_BoxDriver +//purpose : +//======================================================================= +GEOMImpl_BoxDriver::GEOMImpl_BoxDriver() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_BoxDriver::Execute(TFunction_Logbook& log) const +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); + + GEOMImpl_IBox aBI (aFunction); + Standard_Integer aType = aFunction->GetType(); + + TopoDS_Shape aShape; + + if (aType == BOX_DX_DY_DZ) { + BRepPrimAPI_MakeBox MB (aBI.GetDX(), aBI.GetDY(), aBI.GetDZ()); + MB.Build(); + + if (!MB.IsDone()) { + StdFail_NotDone::Raise("Box with the given dimensions can not be computed"); + } + aShape = MB.Shape(); + } + else if (aType == BOX_TWO_PNT) { + Handle(GEOM_Function) aRefPoint1 = aBI.GetRef1(); + Handle(GEOM_Function) aRefPoint2 = aBI.GetRef2(); + TopoDS_Shape aShape1 = aRefPoint1->GetValue(); + TopoDS_Shape aShape2 = aRefPoint2->GetValue(); + if (aShape1.ShapeType() == TopAbs_VERTEX && + aShape2.ShapeType() == TopAbs_VERTEX) { + gp_Pnt P1 = BRep_Tool::Pnt(TopoDS::Vertex(aShape1)); + gp_Pnt P2 = BRep_Tool::Pnt(TopoDS::Vertex(aShape2)); + BRepPrimAPI_MakeBox MB (P1,P2); + MB.Build(); + + if (!MB.IsDone()) { + StdFail_NotDone::Raise("Box can not be computed from the given point"); + } + aShape = MB.Shape(); + } + } + else { + } + + if (aShape.IsNull()) return 0; + + aFunction->SetValue(aShape); + + log.SetTouched(Label()); + + return 1; +} + + +//======================================================================= +//function : GEOMImpl_BoxDriver_Type_ +//purpose : +//======================================================================= +Standard_EXPORT Handle_Standard_Type& GEOMImpl_BoxDriver_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); + 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("GEOMImpl_BoxDriver", + sizeof(GEOMImpl_BoxDriver), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + +//======================================================================= +//function : DownCast +//purpose : +//======================================================================= +const Handle(GEOMImpl_BoxDriver) Handle(GEOMImpl_BoxDriver)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOMImpl_BoxDriver) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_BoxDriver))) { + _anOtherObject = Handle(GEOMImpl_BoxDriver)((Handle(GEOMImpl_BoxDriver)&)AnObject); + } + } + + return _anOtherObject ; +} diff --git a/src/GEOMImpl/GEOMImpl_BoxDriver.hxx b/src/GEOMImpl/GEOMImpl_BoxDriver.hxx new file mode 100644 index 000000000..104bff796 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_BoxDriver.hxx @@ -0,0 +1,139 @@ +// File : GEOMImpl_BoxDriver.ixx +// Module : GEOMImpl + +#ifndef _GEOMImpl_BoxDriver_HeaderFile +#define _GEOMImpl_BoxDriver_HeaderFile + +#ifndef _TColStd_SequenceOfExtendedString_HeaderFile +#include +#endif +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_GUID_HeaderFile +#include +#endif + +#ifndef _Handle_TFunction_Driver_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TFunction_Driver); +class GEOMImpl_BoxDriver; + +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMImpl_BoxDriver); + +class Handle(GEOMImpl_BoxDriver) : public Handle(TFunction_Driver) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + Handle(GEOMImpl_BoxDriver)():Handle(TFunction_Driver)() {} + Handle(GEOMImpl_BoxDriver)(const Handle(GEOMImpl_BoxDriver)& aHandle) : Handle(TFunction_Driver)(aHandle) + { + } + + Handle(GEOMImpl_BoxDriver)(const GEOMImpl_BoxDriver* anItem) : Handle(TFunction_Driver)((TFunction_Driver *)anItem) + { + } + + Handle(GEOMImpl_BoxDriver)& operator=(const Handle(GEOMImpl_BoxDriver)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOMImpl_BoxDriver)& operator=(const GEOMImpl_BoxDriver* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOMImpl_BoxDriver* operator->() + { + return (GEOMImpl_BoxDriver *)ControlAccess(); + } + + GEOMImpl_BoxDriver* operator->() const + { + return (GEOMImpl_BoxDriver *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOMImpl_BoxDriver)() {}; + + Standard_EXPORT static const Handle(GEOMImpl_BoxDriver) DownCast(const Handle(Standard_Transient)& AnObject); +}; + +#ifndef _TFunction_Driver_HeaderFile +#include +#endif +#ifndef _TFunction_Logbook_HeaderFile +#include +#endif +#ifndef _Standard_CString_HeaderFile +#include +#endif + +class TColStd_SequenceOfExtendedString; + + +class GEOMImpl_BoxDriver : public TFunction_Driver { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + // Methods PUBLIC + // +Standard_EXPORT GEOMImpl_BoxDriver(); +Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; +Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {} +Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const { return Standard_True; } +Standard_EXPORT static const Standard_GUID& GetID(); +Standard_EXPORT ~GEOMImpl_BoxDriver() {}; + + + // Type management + // +Standard_EXPORT friend Handle_Standard_Type& GEOMImpl_BoxDriver_Type_(); +Standard_EXPORT const Handle(Standard_Type)& DynamicType() const { return STANDARD_TYPE(GEOMImpl_BoxDriver) ; } +Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const { return (STANDARD_TYPE(GEOMImpl_BoxDriver) == AType || TFunction_Driver::IsKind(AType)); } + + +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_ChamferDriver.cxx b/src/GEOMImpl/GEOMImpl_ChamferDriver.cxx new file mode 100644 index 000000000..d28ed4633 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_ChamferDriver.cxx @@ -0,0 +1,228 @@ + +using namespace std; +#include "GEOMImpl_ChamferDriver.hxx" +#include "GEOMImpl_IChamfer.hxx" +#include "GEOMImpl_Types.hxx" +#include "GEOMImpl_ILocalOperations.hxx" +#include "GEOM_Function.hxx" +#include "GEOMImpl_Block6Explorer.hxx" + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& GEOMImpl_ChamferDriver::GetID() +{ + static Standard_GUID aChamferDriver("FF1BBB42-5D14-4df2-980B-3A668264EA16"); + return aChamferDriver; +} + + +//======================================================================= +//function : GEOMImpl_ChamferDriver +//purpose : +//======================================================================= +GEOMImpl_ChamferDriver::GEOMImpl_ChamferDriver() +{ +} + +//======================================================================= +//function : isGoodForChamfer +//purpose : +//======================================================================= +static Standard_Boolean isGoodForChamfer (const TopoDS_Shape& theShape) +{ + if (theShape.ShapeType() == TopAbs_SHELL || + theShape.ShapeType() == TopAbs_SOLID || + theShape.ShapeType() == TopAbs_COMPSOLID) { + return Standard_True; + } + + if (theShape.ShapeType() == TopAbs_COMPOUND) { + TopTools_MapOfShape mapShape; + TopoDS_Iterator It (theShape, Standard_False, Standard_False); + for (; It.More(); It.Next()) { + if (mapShape.Add(It.Value())) { + if (!isGoodForChamfer(It.Value())) { + return Standard_False; + } + } + } + return Standard_True; + } + + return Standard_False; +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_ChamferDriver::Execute(TFunction_Logbook& log) const +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); + + GEOMImpl_IChamfer aCI (aFunction); + Standard_Integer aType = aFunction->GetType(); + + TopoDS_Shape aShape; + + Handle(GEOM_Function) aRefShape = aCI.GetShape(); + TopoDS_Shape aShapeBase = aRefShape->GetValue(); + + // Check the shape type. It have to be shell + // or solid, or compsolid, or compound of these shapes. + if (!isGoodForChamfer(aShapeBase)) { + StdFail_NotDone::Raise + ("Wrong shape. Must be shell or solid, or compsolid or compound of these shapes"); + } + + BRepFilletAPI_MakeChamfer fill (aShapeBase); + + if (aType == CHAMFER_SHAPE_ALL) { + // symmetric chamfer on all edges + double aD = aCI.GetD(); + TopTools_IndexedDataMapOfShapeListOfShape M; + GEOMImpl_Block6Explorer::MapShapesAndAncestors(aShapeBase, TopAbs_EDGE, TopAbs_FACE, M); + for (int i = 1; i <= M.Extent(); i++) { + TopoDS_Edge E = TopoDS::Edge(M.FindKey(i)); + TopoDS_Face F = TopoDS::Face(M.FindFromIndex(i).First()); + if (!BRepTools::IsReallyClosed(E, F) && + !BRep_Tool::Degenerated(E) && + M.FindFromIndex(i).Extent() == 2) + fill.Add(aD, E, F); + } + } else if (aType == CHAMFER_SHAPE_EDGE) { + // chamfer on edges, common to two faces, with D1 on the first face + double aD1 = aCI.GetD1(); + double aD2 = aCI.GetD2(); + TopoDS_Shape aFace1, aFace2; + if (GEOMImpl_ILocalOperations::GetSubShape(aShapeBase, aCI.GetFace1(), aFace1) && + GEOMImpl_ILocalOperations::GetSubShape(aShapeBase, aCI.GetFace2(), aFace2)) { + TopoDS_Face F = TopoDS::Face(aFace1); + + // fill map of edges of the second face + TopTools_MapOfShape aMap; + TopExp_Explorer Exp2 (aFace2, TopAbs_EDGE); + for (; Exp2.More(); Exp2.Next()) { + aMap.Add(Exp2.Current()); + } + + // find edges of the first face, common with the second face + TopExp_Explorer Exp (aFace1, TopAbs_EDGE); + for (; Exp.More(); Exp.Next()) { + if (aMap.Contains(Exp.Current())) { + TopoDS_Edge E = TopoDS::Edge(Exp.Current()); + if (!BRepTools::IsReallyClosed(E, F) && !BRep_Tool::Degenerated(E)) + fill.Add(aD1, aD2, E, F); + } + } + } + } else if (aType == CHAMFER_SHAPE_FACES) { + // chamfer on all edges of the selected faces, with D1 on the selected face + // (on first selected face, if the edge belongs to two selected faces) + double aD1 = aCI.GetD1(); + double aD2 = aCI.GetD2(); + int aLen = aCI.GetLength(); + int ind = 1; + TopTools_MapOfShape aMap; + TopTools_IndexedDataMapOfShapeListOfShape M; + GEOMImpl_Block6Explorer::MapShapesAndAncestors(aShapeBase, TopAbs_EDGE, TopAbs_FACE, M); + for (; ind <= aLen; ind++) + { + TopoDS_Shape aShapeFace; + if (GEOMImpl_ILocalOperations::GetSubShape + (aShapeBase, aCI.GetFace(ind), aShapeFace)) { + TopoDS_Face F = TopoDS::Face(aShapeFace); + TopExp_Explorer Exp (F, TopAbs_EDGE); + for (; Exp.More(); Exp.Next()) { + if (!aMap.Contains(Exp.Current())) { + TopoDS_Edge E = TopoDS::Edge(Exp.Current()); + if (!BRepTools::IsReallyClosed(E, F) && + !BRep_Tool::Degenerated(E) && + M.FindFromKey(E).Extent() == 2) + fill.Add(aD1, aD2, E, F); + } + } + } + } + } else { + } + + fill.Build(); + if (!fill.IsDone()) { + StdFail_NotDone::Raise("Chamfer can not be computed on the given shape with the given parameters"); + } + aShape = fill.Shape(); + + if (aShape.IsNull()) return 0; + + aFunction->SetValue(aShape); + + log.SetTouched(Label()); + + return 1; +} + + +//======================================================================= +//function : GEOMImpl_ChamferDriver_Type_ +//purpose : +//======================================================================= +Standard_EXPORT Handle_Standard_Type& GEOMImpl_ChamferDriver_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); + 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("GEOMImpl_ChamferDriver", + sizeof(GEOMImpl_ChamferDriver), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + +//======================================================================= +//function : DownCast +//purpose : +//======================================================================= +const Handle(GEOMImpl_ChamferDriver) Handle(GEOMImpl_ChamferDriver)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOMImpl_ChamferDriver) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_ChamferDriver))) { + _anOtherObject = Handle(GEOMImpl_ChamferDriver)((Handle(GEOMImpl_ChamferDriver)&)AnObject); + } + } + + return _anOtherObject ; +} diff --git a/src/GEOMImpl/GEOMImpl_ChamferDriver.hxx b/src/GEOMImpl/GEOMImpl_ChamferDriver.hxx new file mode 100644 index 000000000..72e2ef480 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_ChamferDriver.hxx @@ -0,0 +1,139 @@ +// File : GEOMImpl_ChamferDriver.ixx +// Module : GEOMImpl + +#ifndef _GEOMImpl_ChamferDriver_HeaderFile +#define _GEOMImpl_ChamferDriver_HeaderFile + +#ifndef _TColStd_SequenceOfExtendedString_HeaderFile +#include +#endif +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_GUID_HeaderFile +#include +#endif + +#ifndef _Handle_TFunction_Driver_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TFunction_Driver); +class GEOMImpl_ChamferDriver; + +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMImpl_ChamferDriver); + +class Handle(GEOMImpl_ChamferDriver) : public Handle(TFunction_Driver) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + Handle(GEOMImpl_ChamferDriver)():Handle(TFunction_Driver)() {} + Handle(GEOMImpl_ChamferDriver)(const Handle(GEOMImpl_ChamferDriver)& aHandle) : Handle(TFunction_Driver)(aHandle) + { + } + + Handle(GEOMImpl_ChamferDriver)(const GEOMImpl_ChamferDriver* anItem) : Handle(TFunction_Driver)((TFunction_Driver *)anItem) + { + } + + Handle(GEOMImpl_ChamferDriver)& operator=(const Handle(GEOMImpl_ChamferDriver)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOMImpl_ChamferDriver)& operator=(const GEOMImpl_ChamferDriver* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOMImpl_ChamferDriver* operator->() + { + return (GEOMImpl_ChamferDriver *)ControlAccess(); + } + + GEOMImpl_ChamferDriver* operator->() const + { + return (GEOMImpl_ChamferDriver *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOMImpl_ChamferDriver)() {}; + + Standard_EXPORT static const Handle(GEOMImpl_ChamferDriver) DownCast(const Handle(Standard_Transient)& AnObject); +}; + +#ifndef _TFunction_Driver_HeaderFile +#include +#endif +#ifndef _TFunction_Logbook_HeaderFile +#include +#endif +#ifndef _Standard_CString_HeaderFile +#include +#endif + +class TColStd_SequenceOfExtendedString; + + +class GEOMImpl_ChamferDriver : public TFunction_Driver { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + // Methods PUBLIC + // +Standard_EXPORT GEOMImpl_ChamferDriver(); +Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; +Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {} +Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const { return Standard_True; } +Standard_EXPORT static const Standard_GUID& GetID(); +Standard_EXPORT ~GEOMImpl_ChamferDriver() {}; + + + // Type management + // +Standard_EXPORT friend Handle_Standard_Type& GEOMImpl_ChamferDriver_Type_(); +Standard_EXPORT const Handle(Standard_Type)& DynamicType() const { return STANDARD_TYPE(GEOMImpl_ChamferDriver) ; } +Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const { return (STANDARD_TYPE(GEOMImpl_ChamferDriver) == AType || TFunction_Driver::IsKind(AType)); } + + +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_CircleDriver.cxx b/src/GEOMImpl/GEOMImpl_CircleDriver.cxx new file mode 100644 index 000000000..caa7ac4c3 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_CircleDriver.cxx @@ -0,0 +1,154 @@ + +using namespace std; +#include "GEOMImpl_CircleDriver.hxx" +#include "GEOMImpl_ICircle.hxx" +#include "GEOMImpl_Types.hxx" +#include "GEOM_Function.hxx" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& GEOMImpl_CircleDriver::GetID() +{ + static Standard_GUID aCircleDriver("FF1BBB32-5D14-4df2-980B-3A668264EA16"); + return aCircleDriver; +} + + +//======================================================================= +//function : GEOMImpl_CircleDriver +//purpose : +//======================================================================= +GEOMImpl_CircleDriver::GEOMImpl_CircleDriver() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_CircleDriver::Execute(TFunction_Logbook& log) const +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); + + GEOMImpl_ICircle aCI (aFunction); + Standard_Integer aType = aFunction->GetType(); + + TopoDS_Shape aShape; + + if (aType == CIRCLE_PNT_VEC_R) { + Handle(GEOM_Function) aRefPoint = aCI.GetCenter(); + Handle(GEOM_Function) aRefVector = aCI.GetVector(); + TopoDS_Shape aShapePnt = aRefPoint->GetValue(); + TopoDS_Shape aShapeVec = aRefVector->GetValue(); + if (aShapePnt.ShapeType() == TopAbs_VERTEX && + aShapeVec.ShapeType() == TopAbs_EDGE) { + gp_Pnt aP = BRep_Tool::Pnt(TopoDS::Vertex(aShapePnt)); + TopoDS_Edge anE = TopoDS::Edge(aShapeVec); + TopoDS_Vertex V1, V2; + TopExp::Vertices(anE, V1, V2, Standard_True); + if (!V1.IsNull() && !V2.IsNull()) { + gp_Vec aV (BRep_Tool::Pnt(V1), BRep_Tool::Pnt(V2)); + gp_Ax2 anAxes (aP, aV); + gp_Circ aCirc (anAxes, aCI.GetRadius()); + aShape = BRepBuilderAPI_MakeEdge(aCirc).Edge(); + } + } + } + else if (aType == CIRCLE_THREE_PNT) { + Handle(GEOM_Function) aRefPoint1 = aCI.GetPoint1(); + Handle(GEOM_Function) aRefPoint2 = aCI.GetPoint2(); + Handle(GEOM_Function) aRefPoint3 = aCI.GetPoint3(); + TopoDS_Shape aShapePnt1 = aRefPoint1->GetValue(); + TopoDS_Shape aShapePnt2 = aRefPoint2->GetValue(); + TopoDS_Shape aShapePnt3 = aRefPoint3->GetValue(); + if (aShapePnt1.ShapeType() == TopAbs_VERTEX && + aShapePnt2.ShapeType() == TopAbs_VERTEX && + aShapePnt3.ShapeType() == TopAbs_VERTEX) { + gp_Pnt aP1 = BRep_Tool::Pnt(TopoDS::Vertex(aShapePnt1)); + gp_Pnt aP2 = BRep_Tool::Pnt(TopoDS::Vertex(aShapePnt2)); + gp_Pnt aP3 = BRep_Tool::Pnt(TopoDS::Vertex(aShapePnt3)); + if (aP1.Distance(aP2) < gp::Resolution() || + aP1.Distance(aP3) < gp::Resolution() || + aP2.Distance(aP3) < gp::Resolution()) + Standard_ConstructionError::Raise("Circle creation aborted: coincident points given"); + if (gp_Vec(aP1, aP2).IsParallel(gp_Vec(aP1, aP3), Precision::Angular())) + Standard_ConstructionError::Raise("Circle creation aborted: points lay on one line"); + Handle(Geom_Circle) aCirc = GC_MakeCircle(aP1, aP2, aP3).Value(); + aShape = BRepBuilderAPI_MakeEdge(aCirc).Edge(); + } + } + else { + } + + if (aShape.IsNull()) return 0; + + aFunction->SetValue(aShape); + + log.SetTouched(Label()); + + return 1; +} + + +//======================================================================= +//function : GEOMImpl_CircleDriver_Type_ +//purpose : +//======================================================================= +Standard_EXPORT Handle_Standard_Type& GEOMImpl_CircleDriver_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); + 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("GEOMImpl_CircleDriver", + sizeof(GEOMImpl_CircleDriver), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + +//======================================================================= +//function : DownCast +//purpose : +//======================================================================= +const Handle(GEOMImpl_CircleDriver) Handle(GEOMImpl_CircleDriver)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOMImpl_CircleDriver) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_CircleDriver))) { + _anOtherObject = Handle(GEOMImpl_CircleDriver)((Handle(GEOMImpl_CircleDriver)&)AnObject); + } + } + + return _anOtherObject ; +} diff --git a/src/GEOMImpl/GEOMImpl_CircleDriver.hxx b/src/GEOMImpl/GEOMImpl_CircleDriver.hxx new file mode 100644 index 000000000..f28cadc01 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_CircleDriver.hxx @@ -0,0 +1,139 @@ +// File : GEOMImpl_CircleDriver.ixx +// Module : GEOMImpl + +#ifndef _GEOMImpl_CircleDriver_HeaderFile +#define _GEOMImpl_CircleDriver_HeaderFile + +#ifndef _TColStd_SequenceOfExtendedString_HeaderFile +#include +#endif +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_GUID_HeaderFile +#include +#endif + +#ifndef _Handle_TFunction_Driver_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TFunction_Driver); +class GEOMImpl_CircleDriver; + +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMImpl_CircleDriver); + +class Handle(GEOMImpl_CircleDriver) : public Handle(TFunction_Driver) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + Handle(GEOMImpl_CircleDriver)():Handle(TFunction_Driver)() {} + Handle(GEOMImpl_CircleDriver)(const Handle(GEOMImpl_CircleDriver)& aHandle) : Handle(TFunction_Driver)(aHandle) + { + } + + Handle(GEOMImpl_CircleDriver)(const GEOMImpl_CircleDriver* anItem) : Handle(TFunction_Driver)((TFunction_Driver *)anItem) + { + } + + Handle(GEOMImpl_CircleDriver)& operator=(const Handle(GEOMImpl_CircleDriver)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOMImpl_CircleDriver)& operator=(const GEOMImpl_CircleDriver* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOMImpl_CircleDriver* operator->() + { + return (GEOMImpl_CircleDriver *)ControlAccess(); + } + + GEOMImpl_CircleDriver* operator->() const + { + return (GEOMImpl_CircleDriver *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOMImpl_CircleDriver)() {}; + + Standard_EXPORT static const Handle(GEOMImpl_CircleDriver) DownCast(const Handle(Standard_Transient)& AnObject); +}; + +#ifndef _TFunction_Driver_HeaderFile +#include +#endif +#ifndef _TFunction_Logbook_HeaderFile +#include +#endif +#ifndef _Standard_CString_HeaderFile +#include +#endif + +class TColStd_SequenceOfExtendedString; + + +class GEOMImpl_CircleDriver : public TFunction_Driver { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + // Methods PUBLIC + // +Standard_EXPORT GEOMImpl_CircleDriver(); +Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; +Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {} +Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const { return Standard_True; } +Standard_EXPORT static const Standard_GUID& GetID(); +Standard_EXPORT ~GEOMImpl_CircleDriver() {}; + + + // Type management + // +Standard_EXPORT friend Handle_Standard_Type& GEOMImpl_CircleDriver_Type_(); +Standard_EXPORT const Handle(Standard_Type)& DynamicType() const { return STANDARD_TYPE(GEOMImpl_CircleDriver) ; } +Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const { return (STANDARD_TYPE(GEOMImpl_CircleDriver) == AType || TFunction_Driver::IsKind(AType)); } + + +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_ConeDriver.cxx b/src/GEOMImpl/GEOMImpl_ConeDriver.cxx new file mode 100644 index 000000000..a4486bf98 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_ConeDriver.cxx @@ -0,0 +1,165 @@ + +using namespace std; +#include "GEOMImpl_ConeDriver.hxx" +#include "GEOMImpl_ICone.hxx" +#include "GEOMImpl_Types.hxx" +#include "GEOM_Function.hxx" + +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& GEOMImpl_ConeDriver::GetID() +{ + static Standard_GUID aConeDriver("FF1BBB15-5D14-4df2-980B-3A668264EA16"); + return aConeDriver; +} + + +//======================================================================= +//function : GEOMImpl_ConeDriver +//purpose : +//======================================================================= +GEOMImpl_ConeDriver::GEOMImpl_ConeDriver() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_ConeDriver::Execute(TFunction_Logbook& log) const +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); + + GEOMImpl_ICone aCI (aFunction); + Standard_Integer aType = aFunction->GetType(); + + gp_Pnt aP; + gp_Vec aV; + + Standard_Real aR1 = aCI.GetR1(); + Standard_Real aR2 = aCI.GetR2(); + + if (aType == CONE_R1_R2_H) { + aP = gp::Origin(); + aV = gp::DZ(); + + } else if (aType == CONE_PNT_VEC_R1_R2_H) { + Handle(GEOM_Function) aRefPoint = aCI.GetPoint(); + Handle(GEOM_Function) aRefVector = aCI.GetVector(); + TopoDS_Shape aShapePnt = aRefPoint->GetValue(); + TopoDS_Shape aShapeVec = aRefVector->GetValue(); + if (aShapePnt.IsNull() || aShapeVec.IsNull()) { + Standard_NullObject::Raise + ("Cone creation aborted: point or vector is not defined"); + } + if (aShapePnt.ShapeType() != TopAbs_VERTEX || + aShapeVec.ShapeType() != TopAbs_EDGE) { + Standard_TypeMismatch::Raise + ("Cone creation aborted: point or vector shapes has wrong type"); + } + + aP = BRep_Tool::Pnt(TopoDS::Vertex(aShapePnt)); + + TopoDS_Edge anE = TopoDS::Edge(aShapeVec); + TopoDS_Vertex V1, V2; + TopExp::Vertices(anE, V1, V2, Standard_True); + if (V1.IsNull() || V2.IsNull()) { + Standard_NullObject::Raise + ("Cylinder creation aborted: vector is not defined"); + } + aV = gp_Vec(BRep_Tool::Pnt(V1), BRep_Tool::Pnt(V2)); + + } else { + return 0; + } + + if (aCI.GetH() < 0.0) aV.Reverse(); + gp_Ax2 anAxes (aP, aV); + + TopoDS_Shape aShape; + // Cone does not work if same radius + if (fabs(aR1 - aR2) <= Precision::Confusion()) { + BRepPrimAPI_MakeCylinder MC (anAxes, (aR1 + aR2)/2.0, Abs(aCI.GetH())); + MC.Build(); + if (!MC.IsDone()) { + StdFail_NotDone::Raise("Cylinder can't be computed from the given parameters"); + } + aShape = MC.Shape(); + } else { + BRepPrimAPI_MakeCone MC (anAxes, aCI.GetR1(), aCI.GetR2(), Abs(aCI.GetH())); + MC.Build(); + if (!MC.IsDone()) { + StdFail_NotDone::Raise("Cylinder can't be computed from the given parameters"); + } + aShape = MC.Shape(); + } + if (aShape.IsNull()) return 0; + + log.SetTouched(Label()); + + aFunction->SetValue(aShape); + return 1; +} + + +//======================================================================= +//function : GEOMImpl_ConeDriver_Type_ +//purpose : +//======================================================================= +Standard_EXPORT Handle_Standard_Type& GEOMImpl_ConeDriver_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); + 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("GEOMImpl_ConeDriver", + sizeof(GEOMImpl_ConeDriver), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + +//======================================================================= +//function : DownCast +//purpose : +//======================================================================= +const Handle(GEOMImpl_ConeDriver) Handle(GEOMImpl_ConeDriver)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOMImpl_ConeDriver) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_ConeDriver))) { + _anOtherObject = Handle(GEOMImpl_ConeDriver)((Handle(GEOMImpl_ConeDriver)&)AnObject); + } + } + + return _anOtherObject ; +} diff --git a/src/GEOMImpl/GEOMImpl_ConeDriver.hxx b/src/GEOMImpl/GEOMImpl_ConeDriver.hxx new file mode 100644 index 000000000..86332dc75 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_ConeDriver.hxx @@ -0,0 +1,139 @@ +// File : GEOMImpl_ConeDriver.ixx +// Module : GEOMImpl + +#ifndef _GEOMImpl_ConeDriver_HeaderFile +#define _GEOMImpl_ConeDriver_HeaderFile + +#ifndef _TColStd_SequenceOfExtendedString_HeaderFile +#include +#endif +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_GUID_HeaderFile +#include +#endif + +#ifndef _Handle_TFunction_Driver_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TFunction_Driver); +class GEOMImpl_ConeDriver; + +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMImpl_ConeDriver); + +class Handle(GEOMImpl_ConeDriver) : public Handle(TFunction_Driver) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + Handle(GEOMImpl_ConeDriver)():Handle(TFunction_Driver)() {} + Handle(GEOMImpl_ConeDriver)(const Handle(GEOMImpl_ConeDriver)& aHandle) : Handle(TFunction_Driver)(aHandle) + { + } + + Handle(GEOMImpl_ConeDriver)(const GEOMImpl_ConeDriver* anItem) : Handle(TFunction_Driver)((TFunction_Driver *)anItem) + { + } + + Handle(GEOMImpl_ConeDriver)& operator=(const Handle(GEOMImpl_ConeDriver)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOMImpl_ConeDriver)& operator=(const GEOMImpl_ConeDriver* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOMImpl_ConeDriver* operator->() + { + return (GEOMImpl_ConeDriver *)ControlAccess(); + } + + GEOMImpl_ConeDriver* operator->() const + { + return (GEOMImpl_ConeDriver *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOMImpl_ConeDriver)() {}; + + Standard_EXPORT static const Handle(GEOMImpl_ConeDriver) DownCast(const Handle(Standard_Transient)& AnObject); +}; + +#ifndef _TFunction_Driver_HeaderFile +#include +#endif +#ifndef _TFunction_Logbook_HeaderFile +#include +#endif +#ifndef _Standard_CString_HeaderFile +#include +#endif + +class TColStd_SequenceOfExtendedString; + + +class GEOMImpl_ConeDriver : public TFunction_Driver { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + // Methods PUBLIC + // +Standard_EXPORT GEOMImpl_ConeDriver(); +Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; +Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {} +Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const { return Standard_True; } +Standard_EXPORT static const Standard_GUID& GetID(); +Standard_EXPORT ~GEOMImpl_ConeDriver() {}; + + + // Type management + // +Standard_EXPORT friend Handle_Standard_Type& GEOMImpl_ConeDriver_Type_(); +Standard_EXPORT const Handle(Standard_Type)& DynamicType() const { return STANDARD_TYPE(GEOMImpl_ConeDriver) ; } +Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const { return (STANDARD_TYPE(GEOMImpl_ConeDriver) == AType || TFunction_Driver::IsKind(AType)); } + + +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_CopyDriver.cxx b/src/GEOMImpl/GEOMImpl_CopyDriver.cxx new file mode 100644 index 000000000..8eb25b407 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_CopyDriver.cxx @@ -0,0 +1,114 @@ + +using namespace std; +#include "GEOMImpl_CopyDriver.hxx" +#include "GEOMImpl_ICopy.hxx" +#include "GEOMImpl_Types.hxx" +#include "GEOM_Function.hxx" + +#include +#include +#include +#include +#include +#include +#include +#include + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& GEOMImpl_CopyDriver::GetID() +{ + static Standard_GUID aCopyDriver("FF1BBB53-5D14-4df2-980B-3A668264EA16"); + return aCopyDriver; +} + + +//======================================================================= +//function : GEOMImpl_CopyDriver +//purpose : +//======================================================================= +GEOMImpl_CopyDriver::GEOMImpl_CopyDriver() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_CopyDriver::Execute(TFunction_Logbook& log) const +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); + + Standard_Integer aType = aFunction->GetType(); + + GEOMImpl_ICopy aCI (aFunction); + TopoDS_Shape aCopy; + + if(aType == COPY_WITH_REF) { + + Handle(GEOM_Function) aRefFunction = aCI.GetOriginal(); + if (aRefFunction.IsNull()) return 0; + TopoDS_Shape anOriginal = aRefFunction->GetValue(); + + TColStd_IndexedDataMapOfTransientTransient aMap; + + TNaming_CopyShape::CopyTool(anOriginal, aMap, aCopy); + } + else if(aType == COPY_WITHOUT_REF) { + aCopy = aFunction->GetValue(); + } + + if (aCopy.IsNull()) return 0; + + aFunction->SetValue(aCopy); + + log.SetTouched(Label()); + + return 1; +} + + +//======================================================================= +//function : GEOMImpl_CopyDriver_Type_ +//purpose : +//======================================================================= +Standard_EXPORT Handle_Standard_Type& GEOMImpl_CopyDriver_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); + 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("GEOMImpl_CopyDriver", + sizeof(GEOMImpl_CopyDriver), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + +//======================================================================= +//function : DownCast +//purpose : +//======================================================================= +const Handle(GEOMImpl_CopyDriver) Handle(GEOMImpl_CopyDriver)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOMImpl_CopyDriver) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_CopyDriver))) { + _anOtherObject = Handle(GEOMImpl_CopyDriver)((Handle(GEOMImpl_CopyDriver)&)AnObject); + } + } + + return _anOtherObject ; +} diff --git a/src/GEOMImpl/GEOMImpl_CopyDriver.hxx b/src/GEOMImpl/GEOMImpl_CopyDriver.hxx new file mode 100644 index 000000000..5fab4d5cb --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_CopyDriver.hxx @@ -0,0 +1,139 @@ +// File : GEOMImpl_CopyDriver.ixx +// Module : GEOMImpl + +#ifndef _GEOMImpl_CopyDriver_HeaderFile +#define _GEOMImpl_CopyDriver_HeaderFile + +#ifndef _TColStd_SequenceOfExtendedString_HeaderFile +#include +#endif +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_GUID_HeaderFile +#include +#endif + +#ifndef _Handle_TFunction_Driver_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TFunction_Driver); +class GEOMImpl_CopyDriver; + +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMImpl_CopyDriver); + +class Handle(GEOMImpl_CopyDriver) : public Handle(TFunction_Driver) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + Handle(GEOMImpl_CopyDriver)():Handle(TFunction_Driver)() {} + Handle(GEOMImpl_CopyDriver)(const Handle(GEOMImpl_CopyDriver)& aHandle) : Handle(TFunction_Driver)(aHandle) + { + } + + Handle(GEOMImpl_CopyDriver)(const GEOMImpl_CopyDriver* anItem) : Handle(TFunction_Driver)((TFunction_Driver *)anItem) + { + } + + Handle(GEOMImpl_CopyDriver)& operator=(const Handle(GEOMImpl_CopyDriver)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOMImpl_CopyDriver)& operator=(const GEOMImpl_CopyDriver* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOMImpl_CopyDriver* operator->() + { + return (GEOMImpl_CopyDriver *)ControlAccess(); + } + + GEOMImpl_CopyDriver* operator->() const + { + return (GEOMImpl_CopyDriver *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOMImpl_CopyDriver)() {}; + + Standard_EXPORT static const Handle(GEOMImpl_CopyDriver) DownCast(const Handle(Standard_Transient)& AnObject); +}; + +#ifndef _TFunction_Driver_HeaderFile +#include +#endif +#ifndef _TFunction_Logbook_HeaderFile +#include +#endif +#ifndef _Standard_CString_HeaderFile +#include +#endif + +class TColStd_SequenceOfExtendedString; + + +class GEOMImpl_CopyDriver : public TFunction_Driver { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + // Methods PUBLIC + // +Standard_EXPORT GEOMImpl_CopyDriver(); +Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; +Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {} +Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const { return Standard_True; } +Standard_EXPORT static const Standard_GUID& GetID(); +Standard_EXPORT ~GEOMImpl_CopyDriver() {}; + + + // Type management + // +Standard_EXPORT friend Handle_Standard_Type& GEOMImpl_CopyDriver_Type_(); +Standard_EXPORT const Handle(Standard_Type)& DynamicType() const { return STANDARD_TYPE(GEOMImpl_CopyDriver) ; } +Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const { return (STANDARD_TYPE(GEOMImpl_CopyDriver) == AType || TFunction_Driver::IsKind(AType)); } + + +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_CylinderDriver.cxx b/src/GEOMImpl/GEOMImpl_CylinderDriver.cxx new file mode 100644 index 000000000..7706ebef6 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_CylinderDriver.cxx @@ -0,0 +1,148 @@ + +using namespace std; +#include "GEOMImpl_CylinderDriver.hxx" +#include "GEOMImpl_ICylinder.hxx" +#include "GEOMImpl_Types.hxx" +#include "GEOM_Function.hxx" + +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& GEOMImpl_CylinderDriver::GetID() +{ + static Standard_GUID aCylinderDriver("FF1BBB14-5D14-4df2-980B-3A668264EA16"); + return aCylinderDriver; +} + + +//======================================================================= +//function : GEOMImpl_CylinderDriver +//purpose : +//======================================================================= +GEOMImpl_CylinderDriver::GEOMImpl_CylinderDriver() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_CylinderDriver::Execute(TFunction_Logbook& log) const +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); + + GEOMImpl_ICylinder aCI (aFunction); + Standard_Integer aType = aFunction->GetType(); + + gp_Pnt aP; + gp_Vec aV; + + if (aType == CYLINDER_R_H) { + aP = gp::Origin(); + aV = gp::DZ(); + } + else if (aType == CYLINDER_PNT_VEC_R_H) { + Handle(GEOM_Function) aRefPoint = aCI.GetPoint(); + Handle(GEOM_Function) aRefVector = aCI.GetVector(); + TopoDS_Shape aShapePnt = aRefPoint->GetValue(); + TopoDS_Shape aShapeVec = aRefVector->GetValue(); + if (aShapePnt.IsNull() || aShapeVec.IsNull()) { + Standard_NullObject::Raise("Cylinder creation aborted: point or vector is not defined"); + } + if (aShapePnt.ShapeType() != TopAbs_VERTEX || + aShapeVec.ShapeType() != TopAbs_EDGE) { + Standard_TypeMismatch::Raise("Cylinder creation aborted: point or vector shapes has wrong type"); + } + + aP = BRep_Tool::Pnt(TopoDS::Vertex(aShapePnt)); + + TopoDS_Edge anE = TopoDS::Edge(aShapeVec); + TopoDS_Vertex V1, V2; + TopExp::Vertices(anE, V1, V2, Standard_True); + if (V1.IsNull() || V2.IsNull()) { + Standard_NullObject::Raise("Cylinder creation aborted: vector is not defined"); + } + aV = gp_Vec(BRep_Tool::Pnt(V1), BRep_Tool::Pnt(V2)); + } + else { + return 0; + } + + if (aCI.GetH() < 0.0) aV.Reverse(); + gp_Ax2 anAxes (aP, aV); + + BRepPrimAPI_MakeCylinder MC (anAxes, aCI.GetR(), Abs(aCI.GetH())); + MC.Build(); + if (!MC.IsDone()) { + StdFail_NotDone::Raise("Cylinder can't be computed from the given parameters"); + } + + TopoDS_Shape aShape = MC.Shape(); + if (aShape.IsNull()) return 0; + + aFunction->SetValue(aShape); + + log.SetTouched(Label()); + + return 1; +} + + +//======================================================================= +//function : GEOMImpl_CylinderDriver_Type_ +//purpose : +//======================================================================= +Standard_EXPORT Handle_Standard_Type& GEOMImpl_CylinderDriver_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); + 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("GEOMImpl_CylinderDriver", + sizeof(GEOMImpl_CylinderDriver), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + +//======================================================================= +//function : DownCast +//purpose : +//======================================================================= +const Handle(GEOMImpl_CylinderDriver) Handle(GEOMImpl_CylinderDriver)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOMImpl_CylinderDriver) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_CylinderDriver))) { + _anOtherObject = Handle(GEOMImpl_CylinderDriver)((Handle(GEOMImpl_CylinderDriver)&)AnObject); + } + } + + return _anOtherObject ; +} diff --git a/src/GEOMImpl/GEOMImpl_CylinderDriver.hxx b/src/GEOMImpl/GEOMImpl_CylinderDriver.hxx new file mode 100644 index 000000000..20a5778ed --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_CylinderDriver.hxx @@ -0,0 +1,139 @@ +// File : GEOMImpl_CylinderDriver.ixx +// Module : GEOMImpl + +#ifndef _GEOMImpl_CylinderDriver_HeaderFile +#define _GEOMImpl_CylinderDriver_HeaderFile + +#ifndef _TColStd_SequenceOfExtendedString_HeaderFile +#include +#endif +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_GUID_HeaderFile +#include +#endif + +#ifndef _Handle_TFunction_Driver_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TFunction_Driver); +class GEOMImpl_CylinderDriver; + +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMImpl_CylinderDriver); + +class Handle(GEOMImpl_CylinderDriver) : public Handle(TFunction_Driver) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + Handle(GEOMImpl_CylinderDriver)():Handle(TFunction_Driver)() {} + Handle(GEOMImpl_CylinderDriver)(const Handle(GEOMImpl_CylinderDriver)& aHandle) : Handle(TFunction_Driver)(aHandle) + { + } + + Handle(GEOMImpl_CylinderDriver)(const GEOMImpl_CylinderDriver* anItem) : Handle(TFunction_Driver)((TFunction_Driver *)anItem) + { + } + + Handle(GEOMImpl_CylinderDriver)& operator=(const Handle(GEOMImpl_CylinderDriver)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOMImpl_CylinderDriver)& operator=(const GEOMImpl_CylinderDriver* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOMImpl_CylinderDriver* operator->() + { + return (GEOMImpl_CylinderDriver *)ControlAccess(); + } + + GEOMImpl_CylinderDriver* operator->() const + { + return (GEOMImpl_CylinderDriver *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOMImpl_CylinderDriver)() {}; + + Standard_EXPORT static const Handle(GEOMImpl_CylinderDriver) DownCast(const Handle(Standard_Transient)& AnObject); +}; + +#ifndef _TFunction_Driver_HeaderFile +#include +#endif +#ifndef _TFunction_Logbook_HeaderFile +#include +#endif +#ifndef _Standard_CString_HeaderFile +#include +#endif + +class TColStd_SequenceOfExtendedString; + + +class GEOMImpl_CylinderDriver : public TFunction_Driver { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + // Methods PUBLIC + // +Standard_EXPORT GEOMImpl_CylinderDriver(); +Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; +Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {} +Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const { return Standard_True; } +Standard_EXPORT static const Standard_GUID& GetID(); +Standard_EXPORT ~GEOMImpl_CylinderDriver() {}; + + + // Type management + // +Standard_EXPORT friend Handle_Standard_Type& GEOMImpl_CylinderDriver_Type_(); +Standard_EXPORT const Handle(Standard_Type)& DynamicType() const { return STANDARD_TYPE(GEOMImpl_CylinderDriver) ; } +Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const { return (STANDARD_TYPE(GEOMImpl_CylinderDriver) == AType || TFunction_Driver::IsKind(AType)); } + + +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_EllipseDriver.cxx b/src/GEOMImpl/GEOMImpl_EllipseDriver.cxx new file mode 100644 index 000000000..e21f90c59 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_EllipseDriver.cxx @@ -0,0 +1,124 @@ + +using namespace std; +#include "GEOMImpl_EllipseDriver.hxx" +#include "GEOMImpl_IEllipse.hxx" +#include "GEOMImpl_Types.hxx" +#include "GEOM_Function.hxx" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& GEOMImpl_EllipseDriver::GetID() +{ + static Standard_GUID aEllipseDriver("FF1BBB34-5D14-4df2-980B-3A668264EA16"); + return aEllipseDriver; +} + + +//======================================================================= +//function : GEOMImpl_EllipseDriver +//purpose : +//======================================================================= +GEOMImpl_EllipseDriver::GEOMImpl_EllipseDriver() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_EllipseDriver::Execute(TFunction_Logbook& log) const +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); + + GEOMImpl_IEllipse aCI (aFunction); + Standard_Integer aType = aFunction->GetType(); + + TopoDS_Shape aShape; + + if (aType == ELLIPSE_PNT_VEC_RR) { + Handle(GEOM_Function) aRefPoint = aCI.GetCenter(); + Handle(GEOM_Function) aRefVector = aCI.GetVector(); + TopoDS_Shape aShapePnt = aRefPoint->GetValue(); + TopoDS_Shape aShapeVec = aRefVector->GetValue(); + if (aShapePnt.ShapeType() == TopAbs_VERTEX && + aShapeVec.ShapeType() == TopAbs_EDGE) { + gp_Pnt aP = BRep_Tool::Pnt(TopoDS::Vertex(aShapePnt)); + TopoDS_Edge anE = TopoDS::Edge(aShapeVec); + TopoDS_Vertex V1, V2; + TopExp::Vertices(anE, V1, V2, Standard_True); + if (!V1.IsNull() && !V2.IsNull()) { + gp_Vec aV (BRep_Tool::Pnt(V1), BRep_Tool::Pnt(V2)); + gp_Ax2 anAxes (aP, aV); + gp_Elips anEll (anAxes, aCI.GetRMajor(), aCI.GetRMinor()); + aShape = BRepBuilderAPI_MakeEdge(anEll).Edge(); + } + } + } else { + } + + if (aShape.IsNull()) return 0; + + aFunction->SetValue(aShape); + + log.SetTouched(Label()); + + return 1; +} + + +//======================================================================= +//function : GEOMImpl_EllipseDriver_Type_ +//purpose : +//======================================================================= +Standard_EXPORT Handle_Standard_Type& GEOMImpl_EllipseDriver_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); + 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("GEOMImpl_EllipseDriver", + sizeof(GEOMImpl_EllipseDriver), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + +//======================================================================= +//function : DownCast +//purpose : +//======================================================================= +const Handle(GEOMImpl_EllipseDriver) Handle(GEOMImpl_EllipseDriver)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOMImpl_EllipseDriver) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_EllipseDriver))) { + _anOtherObject = Handle(GEOMImpl_EllipseDriver)((Handle(GEOMImpl_EllipseDriver)&)AnObject); + } + } + + return _anOtherObject ; +} diff --git a/src/GEOMImpl/GEOMImpl_EllipseDriver.hxx b/src/GEOMImpl/GEOMImpl_EllipseDriver.hxx new file mode 100644 index 000000000..9fcc9e293 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_EllipseDriver.hxx @@ -0,0 +1,139 @@ +// File : GEOMImpl_EllipseDriver.ixx +// Module : GEOMImpl + +#ifndef _GEOMImpl_EllipseDriver_HeaderFile +#define _GEOMImpl_EllipseDriver_HeaderFile + +#ifndef _TColStd_SequenceOfExtendedString_HeaderFile +#include +#endif +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_GUID_HeaderFile +#include +#endif + +#ifndef _Handle_TFunction_Driver_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TFunction_Driver); +class GEOMImpl_EllipseDriver; + +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMImpl_EllipseDriver); + +class Handle(GEOMImpl_EllipseDriver) : public Handle(TFunction_Driver) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + Handle(GEOMImpl_EllipseDriver)():Handle(TFunction_Driver)() {} + Handle(GEOMImpl_EllipseDriver)(const Handle(GEOMImpl_EllipseDriver)& aHandle) : Handle(TFunction_Driver)(aHandle) + { + } + + Handle(GEOMImpl_EllipseDriver)(const GEOMImpl_EllipseDriver* anItem) : Handle(TFunction_Driver)((TFunction_Driver *)anItem) + { + } + + Handle(GEOMImpl_EllipseDriver)& operator=(const Handle(GEOMImpl_EllipseDriver)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOMImpl_EllipseDriver)& operator=(const GEOMImpl_EllipseDriver* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOMImpl_EllipseDriver* operator->() + { + return (GEOMImpl_EllipseDriver *)ControlAccess(); + } + + GEOMImpl_EllipseDriver* operator->() const + { + return (GEOMImpl_EllipseDriver *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOMImpl_EllipseDriver)() {}; + + Standard_EXPORT static const Handle(GEOMImpl_EllipseDriver) DownCast(const Handle(Standard_Transient)& AnObject); +}; + +#ifndef _TFunction_Driver_HeaderFile +#include +#endif +#ifndef _TFunction_Logbook_HeaderFile +#include +#endif +#ifndef _Standard_CString_HeaderFile +#include +#endif + +class TColStd_SequenceOfExtendedString; + + +class GEOMImpl_EllipseDriver : public TFunction_Driver { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + // Methods PUBLIC + // +Standard_EXPORT GEOMImpl_EllipseDriver(); +Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; +Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {} +Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const { return Standard_True; } +Standard_EXPORT static const Standard_GUID& GetID(); +Standard_EXPORT ~GEOMImpl_EllipseDriver() {}; + + + // Type management + // +Standard_EXPORT friend Handle_Standard_Type& GEOMImpl_EllipseDriver_Type_(); +Standard_EXPORT const Handle(Standard_Type)& DynamicType() const { return STANDARD_TYPE(GEOMImpl_EllipseDriver) ; } +Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const { return (STANDARD_TYPE(GEOMImpl_EllipseDriver) == AType || TFunction_Driver::IsKind(AType)); } + + +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_ExportDriver.cxx b/src/GEOMImpl/GEOMImpl_ExportDriver.cxx new file mode 100644 index 000000000..21f8c4639 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_ExportDriver.cxx @@ -0,0 +1,139 @@ + +using namespace std; +#include "GEOMImpl_ExportDriver.hxx" +#include "GEOMImpl_IImportExport.hxx" +#include "GEOMImpl_Types.hxx" +#include "GEOM_Function.hxx" + +#include +#include + +#include + +#ifdef WNT +#include +#else +#include +#endif + +#ifdef WNT +#define LibHandle HMODULE +#define LoadLib( name ) LoadLibrary( name ) +#define GetProc GetProcAddress +#define UnLoadLib( handle ) FreeLibrary( handle ); +#else +#define LibHandle void* +#define LoadLib( name ) dlopen( name, RTLD_LAZY ) +#define GetProc dlsym +#define UnLoadLib( handle ) dlclose( handle ); +#endif + +typedef int (*funcPoint)(const TopoDS_Shape&, const TCollection_AsciiString&); + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& GEOMImpl_ExportDriver::GetID() +{ + static Standard_GUID aExportDriver("FF1BBB58-5D14-4df2-980B-3A668264EA16"); + return aExportDriver; +} + + +//======================================================================= +//function : GEOMImpl_ExportDriver +//purpose : +//======================================================================= +GEOMImpl_ExportDriver::GEOMImpl_ExportDriver() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_ExportDriver::Execute(TFunction_Logbook& log) const +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); + + GEOMImpl_IImportExport aCI (aFunction); + + // retrieve the being exported shape + TopoDS_Shape aShape; + Handle(GEOM_Function) aRefFunction = aCI.GetOriginal(); + if (aRefFunction.IsNull()) return 0; + aShape = aRefFunction->GetValue(); + if (aShape.IsNull()) return 0; + // !!! set the result of function to be used by next operations + aFunction->SetValue(aShape); + + // retrieve the file and format names + TCollection_AsciiString aFileName = aCI.GetFileName(); + TCollection_AsciiString aLibName = aCI.GetPluginName(); + if (aFileName.IsEmpty() || aLibName.IsEmpty()) + return 0; + + // load plugin library + LibHandle anExportLib = LoadLib( aLibName.ToCString() ); + funcPoint fp = 0; + if ( anExportLib ) + fp = (funcPoint)GetProc( anExportLib, "Export" ); + + if ( !fp ) + return 0; + + // perform the export + int res = fp( aShape, aFileName ); + + // unload plugin library + UnLoadLib( anExportLib ); + if ( res ) + log.SetTouched(Label()); + + return res; +} + + +//======================================================================= +//function : GEOMImpl_ExportDriver_Type_ +//purpose : +//======================================================================= +Standard_EXPORT Handle_Standard_Type& GEOMImpl_ExportDriver_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); + 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("GEOMImpl_ExportDriver", + sizeof(GEOMImpl_ExportDriver), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + +//======================================================================= +//function : DownCast +//purpose : +//======================================================================= +const Handle(GEOMImpl_ExportDriver) Handle(GEOMImpl_ExportDriver)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOMImpl_ExportDriver) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_ExportDriver))) { + _anOtherObject = Handle(GEOMImpl_ExportDriver)((Handle(GEOMImpl_ExportDriver)&)AnObject); + } + } + + return _anOtherObject ; +} diff --git a/src/GEOMImpl/GEOMImpl_ExportDriver.hxx b/src/GEOMImpl/GEOMImpl_ExportDriver.hxx new file mode 100644 index 000000000..795e5258d --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_ExportDriver.hxx @@ -0,0 +1,139 @@ +// File : GEOMImpl_ExportDriver.ixx +// Module : GEOMImpl + +#ifndef _GEOMImpl_ExportDriver_HeaderFile +#define _GEOMImpl_ExportDriver_HeaderFile + +#ifndef _TColStd_SequenceOfExtendedString_HeaderFile +#include +#endif +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_GUID_HeaderFile +#include +#endif + +#ifndef _Handle_TFunction_Driver_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TFunction_Driver); +class GEOMImpl_ExportDriver; + +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMImpl_ExportDriver); + +class Handle(GEOMImpl_ExportDriver) : public Handle(TFunction_Driver) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + Handle(GEOMImpl_ExportDriver)():Handle(TFunction_Driver)() {} + Handle(GEOMImpl_ExportDriver)(const Handle(GEOMImpl_ExportDriver)& aHandle) : Handle(TFunction_Driver)(aHandle) + { + } + + Handle(GEOMImpl_ExportDriver)(const GEOMImpl_ExportDriver* anItem) : Handle(TFunction_Driver)((TFunction_Driver *)anItem) + { + } + + Handle(GEOMImpl_ExportDriver)& operator=(const Handle(GEOMImpl_ExportDriver)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOMImpl_ExportDriver)& operator=(const GEOMImpl_ExportDriver* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOMImpl_ExportDriver* operator->() + { + return (GEOMImpl_ExportDriver *)ControlAccess(); + } + + GEOMImpl_ExportDriver* operator->() const + { + return (GEOMImpl_ExportDriver *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOMImpl_ExportDriver)() {}; + + Standard_EXPORT static const Handle(GEOMImpl_ExportDriver) DownCast(const Handle(Standard_Transient)& AnObject); +}; + +#ifndef _TFunction_Driver_HeaderFile +#include +#endif +#ifndef _TFunction_Logbook_HeaderFile +#include +#endif +#ifndef _Standard_CString_HeaderFile +#include +#endif + +class TColStd_SequenceOfExtendedString; + + +class GEOMImpl_ExportDriver : public TFunction_Driver { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + // Methods PUBLIC + // +Standard_EXPORT GEOMImpl_ExportDriver(); +Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; +Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {} +Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const { return Standard_True; } +Standard_EXPORT static const Standard_GUID& GetID(); +Standard_EXPORT ~GEOMImpl_ExportDriver() {}; + + + // Type management + // +Standard_EXPORT friend Handle_Standard_Type& GEOMImpl_ExportDriver_Type_(); +Standard_EXPORT const Handle(Standard_Type)& DynamicType() const { return STANDARD_TYPE(GEOMImpl_ExportDriver) ; } +Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const { return (STANDARD_TYPE(GEOMImpl_ExportDriver) == AType || TFunction_Driver::IsKind(AType)); } + + +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_FilletDriver.cxx b/src/GEOMImpl/GEOMImpl_FilletDriver.cxx new file mode 100644 index 000000000..78a6df186 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_FilletDriver.cxx @@ -0,0 +1,157 @@ + +using namespace std; +#include "GEOMImpl_FilletDriver.hxx" +#include "GEOMImpl_IFillet.hxx" +#include "GEOMImpl_Types.hxx" +#include "GEOMImpl_ILocalOperations.hxx" +#include "GEOM_Function.hxx" + +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& GEOMImpl_FilletDriver::GetID() +{ + static Standard_GUID aFilletDriver("FF1BBB41-5D14-4df2-980B-3A668264EA16"); + return aFilletDriver; +} + + +//======================================================================= +//function : GEOMImpl_FilletDriver +//purpose : +//======================================================================= +GEOMImpl_FilletDriver::GEOMImpl_FilletDriver() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_FilletDriver::Execute(TFunction_Logbook& log) const +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); + + GEOMImpl_IFillet aCI (aFunction); + Standard_Integer aType = aFunction->GetType(); + + TopoDS_Shape aShape; + + Handle(GEOM_Function) aRefShape = aCI.GetShape(); + TopoDS_Shape aShapeBase = aRefShape->GetValue(); + BRepFilletAPI_MakeFillet fill (aShapeBase); + + if (aType == FILLET_SHAPE_ALL) { + TopExp_Explorer Exp (aShapeBase, TopAbs_EDGE); + for (; Exp.More(); Exp.Next()) { + TopoDS_Edge E = TopoDS::Edge(Exp.Current()); + fill.Add(E); + } + } else if (aType == FILLET_SHAPE_EDGES) { + int aLen = aCI.GetLength(); + int ind = 1; + for (; ind <= aLen; ind++) { + TopoDS_Shape aShapeEdge; + if (GEOMImpl_ILocalOperations::GetSubShape + (aShapeBase, aCI.GetEdge(ind), aShapeEdge)) { + fill.Add(TopoDS::Edge(aShapeEdge)); + } + } + } else if (aType == FILLET_SHAPE_FACES) { + int aLen = aCI.GetLength(); + int ind = 1; + for (; ind <= aLen; ind++) { + TopoDS_Shape aShapeFace; + if (GEOMImpl_ILocalOperations::GetSubShape + (aShapeBase, aCI.GetFace(ind), aShapeFace)) { + TopExp_Explorer Exp (aShapeFace, TopAbs_EDGE); + for (; Exp.More(); Exp.Next()) { + fill.Add(TopoDS::Edge(Exp.Current())); + } + } + } + } else { + } + + for (int i = 1; i <= fill.NbContours(); i++) { + fill.SetRadius(aCI.GetR(), i, i); + } + fill.Build(); + if (!fill.IsDone()) { + StdFail_NotDone::Raise("Fillet can't be computed on the given shape with the given radius"); + } + aShape = fill.Shape(); + + if (aShape.IsNull()) return 0; + + // Check shape validity + BRepCheck_Analyzer ana (aShape, false); + if (!ana.IsValid()) { + StdFail_NotDone::Raise("Fillet algorithm have produced an invalid shape result"); + } + + aFunction->SetValue(aShape); + + log.SetTouched(Label()); + + return 1; +} + + +//======================================================================= +//function : GEOMImpl_FilletDriver_Type_ +//purpose : +//======================================================================= +Standard_EXPORT Handle_Standard_Type& GEOMImpl_FilletDriver_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); + 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("GEOMImpl_FilletDriver", + sizeof(GEOMImpl_FilletDriver), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + +//======================================================================= +//function : DownCast +//purpose : +//======================================================================= +const Handle(GEOMImpl_FilletDriver) Handle(GEOMImpl_FilletDriver)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOMImpl_FilletDriver) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_FilletDriver))) { + _anOtherObject = Handle(GEOMImpl_FilletDriver)((Handle(GEOMImpl_FilletDriver)&)AnObject); + } + } + + return _anOtherObject ; +} diff --git a/src/GEOMImpl/GEOMImpl_FilletDriver.hxx b/src/GEOMImpl/GEOMImpl_FilletDriver.hxx new file mode 100644 index 000000000..c6a3f9e0b --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_FilletDriver.hxx @@ -0,0 +1,139 @@ +// File : GEOMImpl_FilletDriver.ixx +// Module : GEOMImpl + +#ifndef _GEOMImpl_FilletDriver_HeaderFile +#define _GEOMImpl_FilletDriver_HeaderFile + +#ifndef _TColStd_SequenceOfExtendedString_HeaderFile +#include +#endif +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_GUID_HeaderFile +#include +#endif + +#ifndef _Handle_TFunction_Driver_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TFunction_Driver); +class GEOMImpl_FilletDriver; + +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMImpl_FilletDriver); + +class Handle(GEOMImpl_FilletDriver) : public Handle(TFunction_Driver) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + Handle(GEOMImpl_FilletDriver)():Handle(TFunction_Driver)() {} + Handle(GEOMImpl_FilletDriver)(const Handle(GEOMImpl_FilletDriver)& aHandle) : Handle(TFunction_Driver)(aHandle) + { + } + + Handle(GEOMImpl_FilletDriver)(const GEOMImpl_FilletDriver* anItem) : Handle(TFunction_Driver)((TFunction_Driver *)anItem) + { + } + + Handle(GEOMImpl_FilletDriver)& operator=(const Handle(GEOMImpl_FilletDriver)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOMImpl_FilletDriver)& operator=(const GEOMImpl_FilletDriver* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOMImpl_FilletDriver* operator->() + { + return (GEOMImpl_FilletDriver *)ControlAccess(); + } + + GEOMImpl_FilletDriver* operator->() const + { + return (GEOMImpl_FilletDriver *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOMImpl_FilletDriver)() {}; + + Standard_EXPORT static const Handle(GEOMImpl_FilletDriver) DownCast(const Handle(Standard_Transient)& AnObject); +}; + +#ifndef _TFunction_Driver_HeaderFile +#include +#endif +#ifndef _TFunction_Logbook_HeaderFile +#include +#endif +#ifndef _Standard_CString_HeaderFile +#include +#endif + +class TColStd_SequenceOfExtendedString; + + +class GEOMImpl_FilletDriver : public TFunction_Driver { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + // Methods PUBLIC + // +Standard_EXPORT GEOMImpl_FilletDriver(); +Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; +Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {} +Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const { return Standard_True; } +Standard_EXPORT static const Standard_GUID& GetID(); +Standard_EXPORT ~GEOMImpl_FilletDriver() {}; + + + // Type management + // +Standard_EXPORT friend Handle_Standard_Type& GEOMImpl_FilletDriver_Type_(); +Standard_EXPORT const Handle(Standard_Type)& DynamicType() const { return STANDARD_TYPE(GEOMImpl_FilletDriver) ; } +Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const { return (STANDARD_TYPE(GEOMImpl_FilletDriver) == AType || TFunction_Driver::IsKind(AType)); } + + +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_FillingDriver.cxx b/src/GEOMImpl/GEOMImpl_FillingDriver.cxx new file mode 100644 index 000000000..0a5bdedf6 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_FillingDriver.cxx @@ -0,0 +1,167 @@ + +using namespace std; + +#include "GEOMImpl_FillingDriver.hxx" +#include "GEOM_Function.hxx" +#include "GEOMImpl_IFilling.hxx" +#include "GEOMImpl_Types.hxx" + +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& GEOMImpl_FillingDriver::GetID() +{ + static Standard_GUID aFillingDriver ("FF1BBB62-5D14-4df2-980B-3A668264EA16"); + return aFillingDriver; +} + + +//======================================================================= +//function : GEOMImpl_FillingDriver +//purpose : +//======================================================================= + +GEOMImpl_FillingDriver::GEOMImpl_FillingDriver() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_FillingDriver::Execute(TFunction_Logbook& log) const +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); + if (aFunction.IsNull()) return 0; + + if (aFunction->GetType() != BASIC_FILLING) return 0; + + GEOMImpl_IFilling IF (aFunction); + Handle(GEOM_Function) aShapeFunction = IF.GetShape(); + if (aShapeFunction.IsNull()) return 0; + TopoDS_Shape aShape = aShapeFunction->GetValue(); + if (aShape.IsNull() || aShape.ShapeType() != TopAbs_COMPOUND) return 0; + + Standard_Integer mindeg = IF.GetMinDeg(); + Standard_Integer maxdeg = IF.GetMaxDeg(); + Standard_Real tol3d = IF.GetTol2D(); + Standard_Real tol2d = IF.GetTol3D(); + Standard_Integer nbiter = IF.GetNbIter(); + + if (mindeg > maxdeg) { + Standard_RangeError::Raise("Minimal degree can not be more than maximal degree"); + } + + /* we verify the contents of the shape */ + TopExp_Explorer Ex; + TopoDS_Shape Scurrent; + Standard_Real First, Last; + Handle(Geom_Curve) C; + GeomFill_SectionGenerator Section; + + Standard_Integer i = 0; + for (Ex.Init(aShape, TopAbs_EDGE); Ex.More(); Ex.Next()) { + Scurrent = Ex.Current() ; + if (Scurrent.IsNull() || Scurrent.ShapeType() != TopAbs_EDGE) return 0; + C = BRep_Tool::Curve(TopoDS::Edge(Scurrent), First, Last); + C = new Geom_TrimmedCurve(C, First, Last); + Section.AddCurve(C); + i++; + } + + /* a 'tolerance' is used to compare 2 knots : see GeomFill_Generator.cdl */ + Section.Perform(Precision::Confusion()); + Handle(GeomFill_Line) Line = new GeomFill_Line(i); + + GeomFill_AppSurf App (mindeg, maxdeg, tol3d, tol2d, nbiter); /* user parameters */ + App.Perform(Line, Section); + + if (!App.IsDone()) return 0; + Standard_Integer UDegree, VDegree, NbUPoles, NbVPoles, NbUKnots, NbVKnots; + App.SurfShape(UDegree, VDegree, NbUPoles, NbVPoles, NbUKnots, NbVKnots); + Handle(Geom_BSplineSurface) GBS = new Geom_BSplineSurface + (App.SurfPoles(), App.SurfWeights(), App.SurfUKnots(), App.SurfVKnots(), + App.SurfUMults(), App.SurfVMults(), App.UDegree(), App.VDegree()); + + if (GBS.IsNull()) return 0; + aShape = BRepBuilderAPI_MakeFace(GBS); + + /* We test the validity of resulting shape */ + if (!BRepAlgo::IsValid((aShape))) { + Standard_ConstructionError::Raise("Algorithm have produced an invalid shape result"); + return 0; + } + + aFunction->SetValue(aShape); + + log.SetTouched(Label()); + return 1; +} + + +//======================================================================= +//function : GEOMImpl_FillingDriver_Type_ +//purpose : +//======================================================================= +Standard_EXPORT Handle_Standard_Type& GEOMImpl_FillingDriver_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); + 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("GEOMImpl_FillingDriver", + sizeof(GEOMImpl_FillingDriver), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + +//======================================================================= +//function : DownCast +//purpose : +//======================================================================= + +const Handle(GEOMImpl_FillingDriver) Handle(GEOMImpl_FillingDriver)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOMImpl_FillingDriver) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_FillingDriver))) { + _anOtherObject = Handle(GEOMImpl_FillingDriver)((Handle(GEOMImpl_FillingDriver)&)AnObject); + } + } + + return _anOtherObject ; +} + + diff --git a/src/GEOMImpl/GEOMImpl_FillingDriver.hxx b/src/GEOMImpl/GEOMImpl_FillingDriver.hxx new file mode 100644 index 000000000..89ac7ce98 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_FillingDriver.hxx @@ -0,0 +1,139 @@ +// File : GEOMImpl_FillingDriver.hxx +// Module : GEOMImpl + +#ifndef _GEOMImpl_FillingDriver_HeaderFile +#define _GEOMImpl_FillingDriver_HeaderFile + +#ifndef _TColStd_SequenceOfExtendedString_HeaderFile +#include +#endif +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_GUID_HeaderFile +#include +#endif + +#ifndef _Handle_TFunction_Driver_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TFunction_Driver); +class GEOMImpl_FillingDriver; + +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMImpl_FillingDriver); + +class Handle(GEOMImpl_FillingDriver) : public Handle(TFunction_Driver) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + Handle(GEOMImpl_FillingDriver)():Handle(TFunction_Driver)() {} + Handle(GEOMImpl_FillingDriver)(const Handle(GEOMImpl_FillingDriver)& aHandle) : Handle(TFunction_Driver)(aHandle) + { + } + + Handle(GEOMImpl_FillingDriver)(const GEOMImpl_FillingDriver* anItem) : Handle(TFunction_Driver)((TFunction_Driver *)anItem) + { + } + + Handle(GEOMImpl_FillingDriver)& operator=(const Handle(GEOMImpl_FillingDriver)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOMImpl_FillingDriver)& operator=(const GEOMImpl_FillingDriver* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOMImpl_FillingDriver* operator->() + { + return (GEOMImpl_FillingDriver *)ControlAccess(); + } + + GEOMImpl_FillingDriver* operator->() const + { + return (GEOMImpl_FillingDriver *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOMImpl_FillingDriver)() {}; + + Standard_EXPORT static const Handle(GEOMImpl_FillingDriver) DownCast(const Handle(Standard_Transient)& AnObject); +}; + +#ifndef _TFunction_Driver_HeaderFile +#include +#endif +#ifndef _TFunction_Logbook_HeaderFile +#include +#endif +#ifndef _Standard_CString_HeaderFile +#include +#endif + +class TColStd_SequenceOfExtendedString; + + +class GEOMImpl_FillingDriver : public TFunction_Driver { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + // Methods PUBLIC + // +Standard_EXPORT GEOMImpl_FillingDriver(); +Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; +Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {} +Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const { return Standard_True; } +Standard_EXPORT static const Standard_GUID& GetID(); +Standard_EXPORT ~GEOMImpl_FillingDriver() {}; + + + // Type management + // +Standard_EXPORT friend Handle_Standard_Type& GEOMImpl_FillingDriver_Type_(); +Standard_EXPORT const Handle(Standard_Type)& DynamicType() const { return STANDARD_TYPE(GEOMImpl_FillingDriver) ; } +Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const { return (STANDARD_TYPE(GEOMImpl_FillingDriver) == AType || TFunction_Driver::IsKind(AType)); } + + +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_Gen.cxx b/src/GEOMImpl/GEOMImpl_Gen.cxx new file mode 100644 index 000000000..124c0499c --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_Gen.cxx @@ -0,0 +1,352 @@ +using namespace std; + +#include "GEOMImpl_Gen.hxx" + +#include "utilities.h" +#include "OpUtil.hxx" +#include "Utils_ExceptHandlers.hxx" + +#include +#include + +#include "GEOMImpl_PointDriver.hxx" +#include "GEOMImpl_VectorDriver.hxx" +#include "GEOMImpl_LineDriver.hxx" +#include "GEOMImpl_PlaneDriver.hxx" +#include "GEOMImpl_MarkerDriver.hxx" +#include "GEOMImpl_ArcDriver.hxx" +#include "GEOMImpl_CircleDriver.hxx" +#include "GEOMImpl_EllipseDriver.hxx" +#include "GEOMImpl_PolylineDriver.hxx" +#include "GEOMImpl_SplineDriver.hxx" +#include "GEOMImpl_SketcherDriver.hxx" +#include "GEOMImpl_BoxDriver.hxx" +#include "GEOMImpl_ConeDriver.hxx" +#include "GEOMImpl_CylinderDriver.hxx" +#include "GEOMImpl_PrismDriver.hxx" +#include "GEOMImpl_PipeDriver.hxx" +#include "GEOMImpl_RevolutionDriver.hxx" +#include "GEOMImpl_ShapeDriver.hxx" +#include "GEOMImpl_BlockDriver.hxx" +#include "GEOMImpl_SphereDriver.hxx" +#include "GEOMImpl_TorusDriver.hxx" +#include "GEOMImpl_BooleanDriver.hxx" +#include "GEOMImpl_ChamferDriver.hxx" +#include "GEOMImpl_FilletDriver.hxx" +#include "GEOMImpl_TranslateDriver.hxx" +#include "GEOMImpl_RotateDriver.hxx" +#include "GEOMImpl_MirrorDriver.hxx" +#include "GEOMImpl_OffsetDriver.hxx" +#include "GEOMImpl_ScaleDriver.hxx" +#include "GEOMImpl_PositionDriver.hxx" +#include "GEOMImpl_PartitionDriver.hxx" +#include "GEOMImpl_CopyDriver.hxx" +#include "GEOMImpl_ExportDriver.hxx" +#include "GEOMImpl_ImportDriver.hxx" +#include "GEOMImpl_ArchimedeDriver.hxx" +#include "GEOMImpl_HealingDriver.hxx" +#include "GEOMImpl_FillingDriver.hxx" +#include "GEOMImpl_GlueDriver.hxx" +#include "GEOMImpl_MeasureDriver.hxx" + +//============================================================================= +/*! + * default constructor: + */ +//============================================================================= + +GEOMImpl_Gen::GEOMImpl_Gen() +{ + MESSAGE("GEOMImpl_Gen::GEOMImpl_Gen"); + _mapOfBasicOperations.clear(); + + // Basic elements + TFunction_DriverTable::Get()->AddDriver(GEOMImpl_PointDriver::GetID(), new GEOMImpl_PointDriver()); + TFunction_DriverTable::Get()->AddDriver(GEOMImpl_VectorDriver::GetID(), new GEOMImpl_VectorDriver()); + TFunction_DriverTable::Get()->AddDriver(GEOMImpl_LineDriver::GetID(), new GEOMImpl_LineDriver()); + TFunction_DriverTable::Get()->AddDriver(GEOMImpl_PlaneDriver::GetID(), new GEOMImpl_PlaneDriver()); + TFunction_DriverTable::Get()->AddDriver(GEOMImpl_MarkerDriver::GetID(), new GEOMImpl_MarkerDriver()); + + // Curves + TFunction_DriverTable::Get()->AddDriver(GEOMImpl_ArcDriver::GetID(), new GEOMImpl_ArcDriver()); + TFunction_DriverTable::Get()->AddDriver(GEOMImpl_CircleDriver::GetID(), new GEOMImpl_CircleDriver()); + TFunction_DriverTable::Get()->AddDriver(GEOMImpl_EllipseDriver::GetID(), new GEOMImpl_EllipseDriver()); + TFunction_DriverTable::Get()->AddDriver(GEOMImpl_PolylineDriver::GetID(), new GEOMImpl_PolylineDriver()); + TFunction_DriverTable::Get()->AddDriver(GEOMImpl_SplineDriver::GetID(), new GEOMImpl_SplineDriver()); + TFunction_DriverTable::Get()->AddDriver(GEOMImpl_SketcherDriver::GetID(), new GEOMImpl_SketcherDriver()); + + // 3D Primitives + TFunction_DriverTable::Get()->AddDriver(GEOMImpl_BoxDriver::GetID(), new GEOMImpl_BoxDriver()); + TFunction_DriverTable::Get()->AddDriver(GEOMImpl_ConeDriver::GetID(), new GEOMImpl_ConeDriver()); + TFunction_DriverTable::Get()->AddDriver(GEOMImpl_CylinderDriver::GetID(), new GEOMImpl_CylinderDriver()); + TFunction_DriverTable::Get()->AddDriver(GEOMImpl_PrismDriver::GetID(), new GEOMImpl_PrismDriver()); + TFunction_DriverTable::Get()->AddDriver(GEOMImpl_PipeDriver::GetID(), new GEOMImpl_PipeDriver()); + TFunction_DriverTable::Get()->AddDriver(GEOMImpl_RevolutionDriver::GetID(), new GEOMImpl_RevolutionDriver()); + TFunction_DriverTable::Get()->AddDriver(GEOMImpl_SphereDriver::GetID(), new GEOMImpl_SphereDriver()); + TFunction_DriverTable::Get()->AddDriver(GEOMImpl_TorusDriver::GetID(), new GEOMImpl_TorusDriver()); + TFunction_DriverTable::Get()->AddDriver(GEOMImpl_FillingDriver::GetID(), new GEOMImpl_FillingDriver()); + + // Shapes Operations + TFunction_DriverTable::Get()->AddDriver(GEOMImpl_ShapeDriver::GetID(), new GEOMImpl_ShapeDriver()); + TFunction_DriverTable::Get()->AddDriver(GEOMImpl_GlueDriver::GetID(), new GEOMImpl_GlueDriver()); + + // Blocks Operations + TFunction_DriverTable::Get()->AddDriver(GEOMImpl_BlockDriver::GetID(), new GEOMImpl_BlockDriver()); + + // Boolean Operations, Partition + TFunction_DriverTable::Get()->AddDriver(GEOMImpl_BooleanDriver::GetID(), new GEOMImpl_BooleanDriver()); + TFunction_DriverTable::Get()->AddDriver(GEOMImpl_PartitionDriver::GetID(), new GEOMImpl_PartitionDriver()); + + // Local Operations + TFunction_DriverTable::Get()->AddDriver(GEOMImpl_ChamferDriver::GetID(), new GEOMImpl_ChamferDriver()); + TFunction_DriverTable::Get()->AddDriver(GEOMImpl_FilletDriver::GetID(), new GEOMImpl_FilletDriver()); + TFunction_DriverTable::Get()->AddDriver(GEOMImpl_ArchimedeDriver::GetID(), new GEOMImpl_ArchimedeDriver()); + + // Geometrical Transformations, Offset, Scale + TFunction_DriverTable::Get()->AddDriver(GEOMImpl_TranslateDriver::GetID(), new GEOMImpl_TranslateDriver()); + TFunction_DriverTable::Get()->AddDriver(GEOMImpl_RotateDriver::GetID(), new GEOMImpl_RotateDriver()); + TFunction_DriverTable::Get()->AddDriver(GEOMImpl_MirrorDriver::GetID(), new GEOMImpl_MirrorDriver()); + TFunction_DriverTable::Get()->AddDriver(GEOMImpl_OffsetDriver::GetID(), new GEOMImpl_OffsetDriver()); + TFunction_DriverTable::Get()->AddDriver(GEOMImpl_ScaleDriver::GetID(), new GEOMImpl_ScaleDriver()); + TFunction_DriverTable::Get()->AddDriver(GEOMImpl_PositionDriver::GetID(), new GEOMImpl_PositionDriver()); + + // Insert Operations (Copy, Import/Export) + TFunction_DriverTable::Get()->AddDriver(GEOMImpl_CopyDriver::GetID(), new GEOMImpl_CopyDriver()); + TFunction_DriverTable::Get()->AddDriver(GEOMImpl_ImportDriver::GetID(), new GEOMImpl_ImportDriver()); + TFunction_DriverTable::Get()->AddDriver(GEOMImpl_ExportDriver::GetID(), new GEOMImpl_ExportDriver()); + + // Shape Healing + TFunction_DriverTable::Get()->AddDriver(GEOMImpl_HealingDriver::GetID(), new GEOMImpl_HealingDriver()); + + // Measurements + TFunction_DriverTable::Get()->AddDriver(GEOMImpl_MeasureDriver::GetID(), new GEOMImpl_MeasureDriver()); + + SetEngine(this); +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +GEOMImpl_Gen::~GEOMImpl_Gen() +{ + MESSAGE("GEOMImpl_Gen::~GEOMImpl_Gen"); + + std::map::iterator aBasicIter = _mapOfBasicOperations.begin(); + for (; aBasicIter != _mapOfBasicOperations.end(); aBasicIter++) + delete (*aBasicIter).second; + + std::map::iterator aTransformIter = _mapOfTransformOperations.begin(); + for (; aTransformIter != _mapOfTransformOperations.end(); aTransformIter++) + delete (*aTransformIter).second; + + std::map::iterator a3DPrimIter = _mapOf3DPrimOperations.begin(); + for (; a3DPrimIter != _mapOf3DPrimOperations.end(); a3DPrimIter++) + delete (*a3DPrimIter).second; + + std::map::iterator aShapesIter = _mapOfShapesOperations.begin(); + for (; aShapesIter != _mapOfShapesOperations.end(); aShapesIter++) + delete (*aShapesIter).second; + + std::map::iterator aBlocksIter = _mapOfBlocksOperations.begin(); + for (; aBlocksIter != _mapOfBlocksOperations.end(); aBlocksIter++) + delete (*aBlocksIter).second; + + std::map::iterator aBooleanIter = _mapOfBooleanOperations.begin(); + for (; aBooleanIter != _mapOfBooleanOperations.end(); aBooleanIter++) + delete (*aBooleanIter).second; + + std::map::iterator aHealingIter = _mapOfHealingOperations.begin(); + for (; aHealingIter != _mapOfHealingOperations.end(); aHealingIter++) + delete (*aHealingIter).second; + + std::map::iterator aCurvesIter = _mapOfCurvesOperations.begin(); + for (; aCurvesIter != _mapOfCurvesOperations.end(); aCurvesIter++) + delete (*aCurvesIter).second; + + std::map::iterator aLocalIter = _mapOfLocalOperations.begin(); + for (; aLocalIter != _mapOfLocalOperations.end(); aLocalIter++) + delete (*aLocalIter).second; + + std::map::iterator aInsertIter = _mapOfInsertOperations.begin(); + for (; aInsertIter != _mapOfInsertOperations.end(); aInsertIter++) + delete (*aInsertIter).second; + + std::map::iterator aMeasureIter = _mapOfMeasureOperations.begin(); + for (; aMeasureIter != _mapOfMeasureOperations.end(); aMeasureIter++) + delete (*aMeasureIter).second; + + std::map::iterator aGroupIter = _mapOfGroupOperations.begin(); + for (; aGroupIter != _mapOfGroupOperations.end(); aGroupIter++) + delete (*aGroupIter).second; +} + +//============================================================================= +/*! + * GetIBasicOperations + */ +//============================================================================= +GEOMImpl_IBasicOperations* GEOMImpl_Gen::GetIBasicOperations(int theDocID) +{ + if(_mapOfBasicOperations.find(theDocID) == _mapOfBasicOperations.end()) { + _mapOfBasicOperations[theDocID] = new GEOMImpl_IBasicOperations(this, theDocID); + } + + return _mapOfBasicOperations[theDocID]; +} + +//============================================================================= +/*! + * GetITransformOperations + */ +//============================================================================= +GEOMImpl_ITransformOperations* GEOMImpl_Gen::GetITransformOperations(int theDocID) +{ + if(_mapOfTransformOperations.find(theDocID) == _mapOfTransformOperations.end()) { + _mapOfTransformOperations[theDocID] = new GEOMImpl_ITransformOperations(this, theDocID); + } + + return _mapOfTransformOperations[theDocID]; +} + +//============================================================================= +/*! + * GetIBooleanOperations + */ +//============================================================================= +GEOMImpl_IBooleanOperations* GEOMImpl_Gen::GetIBooleanOperations(int theDocID) +{ + if(_mapOfBooleanOperations.find(theDocID) == _mapOfBooleanOperations.end()) { + _mapOfBooleanOperations[theDocID] = new GEOMImpl_IBooleanOperations(this, theDocID); + } + + return _mapOfBooleanOperations[theDocID]; +} + +//============================================================================= +/*! + * GetIHealingOperations + */ +//============================================================================= +GEOMImpl_IHealingOperations* GEOMImpl_Gen::GetIHealingOperations(int theDocID) +{ + if(_mapOfHealingOperations.find(theDocID) == _mapOfHealingOperations.end()) { + _mapOfHealingOperations[theDocID] = new GEOMImpl_IHealingOperations(this, theDocID); + } + + return _mapOfHealingOperations[theDocID]; +} + +//============================================================================= +/*! + * GetI3DPrimOperations + */ +//============================================================================= +GEOMImpl_I3DPrimOperations* GEOMImpl_Gen::GetI3DPrimOperations(int theDocID) +{ + if(_mapOf3DPrimOperations.find(theDocID) == _mapOf3DPrimOperations.end()) { + _mapOf3DPrimOperations[theDocID] = new GEOMImpl_I3DPrimOperations(this, theDocID); + } + + return _mapOf3DPrimOperations[theDocID]; +} + +//============================================================================= +/*! + * GetIShapesOperations + */ +//============================================================================= +GEOMImpl_IShapesOperations* GEOMImpl_Gen::GetIShapesOperations(int theDocID) +{ + if(_mapOfShapesOperations.find(theDocID) == _mapOfShapesOperations.end()) { + _mapOfShapesOperations[theDocID] = new GEOMImpl_IShapesOperations(this, theDocID); + } + + return _mapOfShapesOperations[theDocID]; +} + +//============================================================================= +/*! + * GetIBlocksOperations + */ +//============================================================================= +GEOMImpl_IBlocksOperations* GEOMImpl_Gen::GetIBlocksOperations(int theDocID) +{ + if(_mapOfBlocksOperations.find(theDocID) == _mapOfBlocksOperations.end()) { + _mapOfBlocksOperations[theDocID] = new GEOMImpl_IBlocksOperations(this, theDocID); + } + + return _mapOfBlocksOperations[theDocID]; +} + +//============================================================================= +/*! + * GetICurvesOperations + */ +//============================================================================= +GEOMImpl_ICurvesOperations* GEOMImpl_Gen::GetICurvesOperations(int theDocID) +{ + if(_mapOfCurvesOperations.find(theDocID) == _mapOfCurvesOperations.end()) { + _mapOfCurvesOperations[theDocID] = new GEOMImpl_ICurvesOperations(this, theDocID); + } + + return _mapOfCurvesOperations[theDocID]; +} + +//============================================================================= +/*! + * GetILocalOperations + */ +//============================================================================= +GEOMImpl_ILocalOperations* GEOMImpl_Gen::GetILocalOperations(int theDocID) +{ + if(_mapOfLocalOperations.find(theDocID) == _mapOfLocalOperations.end()) { + _mapOfLocalOperations[theDocID] = new GEOMImpl_ILocalOperations(this, theDocID); + } + + return _mapOfLocalOperations[theDocID]; +} + +//============================================================================= +/*! + * GetIInsertOperations + */ +//============================================================================= +GEOMImpl_IInsertOperations* GEOMImpl_Gen::GetIInsertOperations(int theDocID) +{ + if(_mapOfInsertOperations.find(theDocID) == _mapOfInsertOperations.end()) { + _mapOfInsertOperations[theDocID] = new GEOMImpl_IInsertOperations(this, theDocID); + } + + return _mapOfInsertOperations[theDocID]; +} + +//============================================================================= +/*! + * GetIMeasureOperations + */ +//============================================================================= +GEOMImpl_IMeasureOperations* GEOMImpl_Gen::GetIMeasureOperations(int theDocID) +{ + if(_mapOfMeasureOperations.find(theDocID) == _mapOfMeasureOperations.end()) { + _mapOfMeasureOperations[theDocID] = new GEOMImpl_IMeasureOperations(this, theDocID); + } + + return _mapOfMeasureOperations[theDocID]; +} + +//============================================================================= +/*! + * GetIGroupOperations + */ +//============================================================================= +GEOMImpl_IGroupOperations* GEOMImpl_Gen::GetIGroupOperations(int theDocID) +{ + if(_mapOfGroupOperations.find(theDocID) == _mapOfGroupOperations.end()) { + _mapOfGroupOperations[theDocID] = new GEOMImpl_IGroupOperations(this, theDocID); + } + + return _mapOfGroupOperations[theDocID]; +} diff --git a/src/GEOMImpl/GEOMImpl_Gen.hxx b/src/GEOMImpl/GEOMImpl_Gen.hxx new file mode 100644 index 000000000..255b4f54e --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_Gen.hxx @@ -0,0 +1,67 @@ + +#ifndef _GEOMImpl_GEN_HXX_ +#define _GEOMImpl_GEN_HXX_ + +#include + +#include "GEOMImpl_IBasicOperations.hxx" +#include "GEOMImpl_ITransformOperations.hxx" +#include "GEOMImpl_I3DPrimOperations.hxx" +#include "GEOMImpl_IShapesOperations.hxx" +#include "GEOMImpl_IBlocksOperations.hxx" +#include "GEOMImpl_IBooleanOperations.hxx" +#include "GEOMImpl_IHealingOperations.hxx" +#include "GEOMImpl_ICurvesOperations.hxx" +#include "GEOMImpl_ILocalOperations.hxx" +#include "GEOMImpl_IInsertOperations.hxx" +#include "GEOMImpl_IMeasureOperations.hxx" +#include "GEOMImpl_IGroupOperations.hxx" +#include "GEOM_Engine.hxx" + +class GEOMImpl_Gen : public GEOM_Engine +{ + public: + GEOMImpl_Gen(); + ~GEOMImpl_Gen(); + + GEOMImpl_IBasicOperations* GetIBasicOperations(int theDocID); + + GEOMImpl_ITransformOperations* GetITransformOperations(int theDocID); + + GEOMImpl_I3DPrimOperations* GetI3DPrimOperations(int theDocID); + + GEOMImpl_IShapesOperations* GetIShapesOperations(int theDocID); + + GEOMImpl_IBlocksOperations* GetIBlocksOperations(int theDocID); + + GEOMImpl_IMeasureOperations* GetIMeasureOperations(int theDocID); + + GEOMImpl_IBooleanOperations* GetIBooleanOperations(int theDocID); + + GEOMImpl_ICurvesOperations* GetICurvesOperations(int theDocID); + + GEOMImpl_ILocalOperations* GetILocalOperations(int theDocID); + + GEOMImpl_IInsertOperations* GetIInsertOperations(int theDocID); + + GEOMImpl_IHealingOperations* GetIHealingOperations(int theDocID); + + GEOMImpl_IGroupOperations* GetIGroupOperations(int theDocID); + + private: + + std::map _mapOfBasicOperations; + std::map _mapOfTransformOperations; + std::map _mapOf3DPrimOperations; + std::map _mapOfShapesOperations; + std::map _mapOfBlocksOperations; + std::map _mapOfBooleanOperations; + std::map _mapOfHealingOperations; + std::map _mapOfCurvesOperations; + std::map _mapOfLocalOperations; + std::map _mapOfInsertOperations; + std::map _mapOfMeasureOperations; + std::map _mapOfGroupOperations; +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_GlueDriver.cxx b/src/GEOMImpl/GEOMImpl_GlueDriver.cxx new file mode 100644 index 000000000..e41b48ccb --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_GlueDriver.cxx @@ -0,0 +1,388 @@ + +using namespace std; +#include "GEOMImpl_GlueDriver.hxx" +#include "GEOMImpl_IGlue.hxx" +#include "GEOMImpl_Types.hxx" +#include "GEOM_Function.hxx" + +#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 : GetID +//purpose : +//======================================================================= +const Standard_GUID& GEOMImpl_GlueDriver::GetID() +{ + static Standard_GUID aGlueDriver("FF1BBB63-5D14-4df2-980B-3A668264EA16"); + return aGlueDriver; +} + + +//======================================================================= +//function : GEOMImpl_GlueDriver +//purpose : +//======================================================================= +GEOMImpl_GlueDriver::GEOMImpl_GlueDriver() +{ +} + +//======================================================================= +//function : FindSameFace +//purpose : for GLUE_FACES +//======================================================================= +static TopoDS_Face FindSameFace (const TopoDS_Shape& aShape, + const TopoDS_Face& F, + const double tol3d) +{ + TopoDS_Face aFace; + bool isSame = false; + for (TopExp_Explorer exf (aShape, TopAbs_FACE); exf.More(); exf.Next()) { + // test a face + int nbFound = 0; + aFace = TopoDS::Face(exf.Current()); + TopTools_ListOfShape liste1; + TopTools_ListOfShape liste2; + for (TopExp_Explorer exp (aFace, TopAbs_VERTEX); exp.More(); exp.Next()) { + const TopoDS_Vertex& V = TopoDS::Vertex(exp.Current()); + liste1.Append(V); + } + for (TopExp_Explorer exp (F, TopAbs_VERTEX); exp.More(); exp.Next()) { + const TopoDS_Vertex& V = TopoDS::Vertex(exp.Current()); + liste2.Append(V); + } + isSame = false; + if (liste1.Extent() == liste2.Extent()) + { + TopTools_ListIteratorOfListOfShape it1 (liste1); + isSame = true; + for (; it1.More(); it1.Next()) + { + bool foundSamePoint = false; + gp_Pnt P1 = BRep_Tool::Pnt(TopoDS::Vertex(it1.Value())); + TopTools_ListIteratorOfListOfShape it2 (liste2); + for (; it2.More(); it2.Next()) { + gp_Pnt P2 = BRep_Tool::Pnt(TopoDS::Vertex(it2.Value())); + double d = P1.Distance(P2); + if (d < tol3d) { + nbFound++; + // found Same Point : P1 + foundSamePoint = true; + break; + } + } + isSame = isSame && foundSamePoint; + if (! isSame) break; // a vertex does not correspond : not same face + } + } + if (isSame) { + // Found Same Face + break; // a face corresponding to F is found + } + } + if (!isSame) aFace.Nullify(); // return null face + return aFace; +} + +//======================================================================= +//function : FindSameEdge +//purpose : for GLUE_FACES +//======================================================================= +static TopoDS_Edge FindSameEdge (const TopoDS_Face& nf, + TopoDS_Edge& Eold, + const double tol3d) +{ + TopoDS_Face newFace = TopoDS::Face(nf.Oriented(TopAbs_REVERSED)); + TopoDS_Vertex VFirst, VLast; + TopExp::Vertices(Eold, VFirst, VLast); + gp_Pnt Pf = BRep_Tool::Pnt(VFirst); + gp_Pnt Pl = BRep_Tool::Pnt(VLast); + TopoDS_Edge Enew; + for (TopExp_Explorer ee (newFace, TopAbs_EDGE); ee.More(); ee.Next()) { + const TopoDS_Edge& E = TopoDS::Edge(ee.Current()); + TopoDS_Vertex VFn, VLn; + TopExp::Vertices(E, VFn, VLn); + gp_Pnt Pfn = BRep_Tool::Pnt(VFn); + gp_Pnt Pln = BRep_Tool::Pnt(VLn); + double dff = Pf.Distance(Pfn); + double dfl = Pf.Distance(Pln); + double dlf = Pl.Distance(Pfn); + double dll = Pl.Distance(Pln); + if ((dff < tol3d) && (dll 0) && shellAdded) { + shellAdded = false; + its.Initialize(shellList); + for (; its.More(); its.Next()) { + S = TopoDS::Shell(its.Value()); + + // compare tolerance with shape's size + Bnd_Box aBox; + BRepBndLib::Add(S, aBox); + Standard_Real Xmin, Ymin, Zmin, Xmax, Ymax, Zmax; + aBox.Get(Xmin, Ymin, Zmin, Xmax, Ymax, Zmax); + Standard_Real aTolerance = theTolerance; + if (aBox.IsXThin(100. * aTolerance)) + aTolerance = 0.01 * (Xmax - Xmin); + if (aBox.IsYThin(100. * aTolerance)) + aTolerance = 0.01 * (Ymax - Ymin); + if (aBox.IsZThin(100. * aTolerance)) + aTolerance = 0.01 * (Zmax - Zmin); + if (theTolerance > aTolerance) + bigTolerance = true; + + bool isConnected = false; + TopTools_ListOfShape newEdges; // common edges from new compound + TopTools_ListOfShape oldEdges; // common edges from face to add + TopoDS_Compound CFN; + TopoDS_Compound CFO; + bu.MakeCompound(CFN); // empty compound for new faces + bu.MakeCompound(CFO); // empty compound for old faces + + for (TopExp_Explorer exp (S, TopAbs_FACE); exp.More(); exp.Next()) { + // try to find corresponding face in new compound + TopoDS_Face F = TopoDS::Face(exp.Current()); + TopoDS_Face newFace = FindSameFace(C,F,aTolerance); + if (! newFace.IsNull()) + { + // face found + isConnected = true; + bu.Add(CFN, newFace); // common faces from new compound + for (TopExp_Explorer ee (F, TopAbs_EDGE); ee.More(); ee.Next()) { + // find edge pair + TopoDS_Edge Eold = TopoDS::Edge(ee.Current()); + TopoDS_Edge Enew = FindSameEdge(newFace, Eold, aTolerance); + if (Enew.IsNull()) { + Standard_ConstructionError::Raise("Glue aborted : no same edge in same face"); + } + oldEdges.Append(Eold); + newEdges.Append(Enew); + } + } else { + bu.Add(CFO, F); // not common faces from shell to add + } + } + if (isConnected) { + // some faces found + shellAdded = true; + BRepTools_Quilt glue; + glue.Add(CFN); + TopTools_ListIteratorOfListOfShape ito (oldEdges); + TopTools_ListIteratorOfListOfShape itn (newEdges); + for (; ito.More(); ito.Next()) { + // bind + glue.Bind(TopoDS::Edge(ito.Value()), TopoDS::Edge(itn.Value())); + itn.Next(); + } + glue.Add(CFO); + TopoDS_Compound newc = TopoDS::Compound(glue.Shells()); + for (TopExp_Explorer exs (newc, TopAbs_SHELL); exs.More(); exs.Next()) { + TopoDS_Shell NS = TopoDS::Shell(exs.Current()); + bu.Add(C, NS); + } + shellList.Remove(its); + // remove shell from list + break; + } + } + } + + if (shellList.Extent() > 0) { + TCollection_AsciiString aMsg + ("Some shapes can not be glued with others, because they are too far from them."); + if (bigTolerance) { + aMsg += "\n\nWarning: The tolerance is too big for some sub-shapes, 1% of sub-shape size is given instead."; + } + Standard_ConstructionError::Raise(aMsg.ToCString()); + } + + TopExp_Explorer exp (C, TopAbs_SHELL); + Standard_Integer ish = 0; + TopoDS_Compound Res; + TopoDS_Solid Sol; + BRep_Builder B; + B.MakeCompound(Res); + + for (; exp.More(); exp.Next()) { + TopoDS_Shape Sh = exp.Current(); + B.MakeSolid(Sol); + B.Add(Sol,Sh); + BRepClass3d_SolidClassifier SC(Sol); + SC.PerformInfinitePoint(1.E-6); // cf. BRepFill_Confusion() - BRepFill_Evolved.cxx + if (SC.State() == TopAbs_IN) { + B.MakeSolid(Sol); + B.Add(Sol,Sh.Reversed()); + } + B.Add(Res,Sol); + ish++; + } + if (ish == 1) { + aShape = Sol; + } else { + aShape = Res; + } + + BRepLib::SameParameter(aShape, 1.E-5, Standard_True); + return aShape; +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_GlueDriver::Execute(TFunction_Logbook& log) const +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); + + GEOMImpl_IGlue aCI (aFunction); + Standard_Integer aType = aFunction->GetType(); + + TopoDS_Shape aShape; + + if (aType == GLUE_FACES) { + Handle(GEOM_Function) aRefBase = aCI.GetBase(); + TopoDS_Shape aShapeBase = aRefBase->GetValue(); + if (aShapeBase.IsNull()) { + Standard_NullObject::Raise("Shape for gluing is null"); + } + + Standard_Real tol3d = aCI.GetTolerance(); + aShape = GlueFaces(aShapeBase, tol3d); + + } else { + } + + if (aShape.IsNull()) return 0; + + aFunction->SetValue(aShape); + + log.SetTouched(Label()); + + return 1; +} + + +//======================================================================= +//function : GEOMImpl_GlueDriver_Type_ +//purpose : +//======================================================================= +Standard_EXPORT Handle_Standard_Type& GEOMImpl_GlueDriver_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); + 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("GEOMImpl_GlueDriver", + sizeof(GEOMImpl_GlueDriver), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + +//======================================================================= +//function : DownCast +//purpose : +//======================================================================= +const Handle(GEOMImpl_GlueDriver) Handle(GEOMImpl_GlueDriver)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOMImpl_GlueDriver) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_GlueDriver))) { + _anOtherObject = Handle(GEOMImpl_GlueDriver)((Handle(GEOMImpl_GlueDriver)&)AnObject); + } + } + + return _anOtherObject ; +} diff --git a/src/GEOMImpl/GEOMImpl_GlueDriver.hxx b/src/GEOMImpl/GEOMImpl_GlueDriver.hxx new file mode 100644 index 000000000..489f6a11c --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_GlueDriver.hxx @@ -0,0 +1,142 @@ +// File : GEOMImpl_GlueDriver.ixx +// Module : GEOMImpl + +#ifndef _GEOMImpl_GlueDriver_HeaderFile +#define _GEOMImpl_GlueDriver_HeaderFile + +#ifndef _TColStd_SequenceOfExtendedString_HeaderFile +#include +#endif +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_GUID_HeaderFile +#include +#endif + +#ifndef _Handle_TFunction_Driver_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TFunction_Driver); +class GEOMImpl_GlueDriver; + +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMImpl_GlueDriver); + +class Handle(GEOMImpl_GlueDriver) : public Handle(TFunction_Driver) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + Handle(GEOMImpl_GlueDriver)():Handle(TFunction_Driver)() {} + Handle(GEOMImpl_GlueDriver)(const Handle(GEOMImpl_GlueDriver)& aHandle) : Handle(TFunction_Driver)(aHandle) + { + } + + Handle(GEOMImpl_GlueDriver)(const GEOMImpl_GlueDriver* anItem) : Handle(TFunction_Driver)((TFunction_Driver *)anItem) + { + } + + Handle(GEOMImpl_GlueDriver)& operator=(const Handle(GEOMImpl_GlueDriver)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOMImpl_GlueDriver)& operator=(const GEOMImpl_GlueDriver* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOMImpl_GlueDriver* operator->() + { + return (GEOMImpl_GlueDriver *)ControlAccess(); + } + + GEOMImpl_GlueDriver* operator->() const + { + return (GEOMImpl_GlueDriver *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOMImpl_GlueDriver)() {}; + + Standard_EXPORT static const Handle(GEOMImpl_GlueDriver) DownCast(const Handle(Standard_Transient)& AnObject); +}; + +#ifndef _TFunction_Driver_HeaderFile +#include +#endif +#ifndef _TFunction_Logbook_HeaderFile +#include +#endif +#ifndef _Standard_CString_HeaderFile +#include +#endif +#include + +class TColStd_SequenceOfExtendedString; + + +class GEOMImpl_GlueDriver : public TFunction_Driver { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + // Methods PUBLIC + // +Standard_EXPORT GEOMImpl_GlueDriver(); +Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; +Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {} +Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const { return Standard_True; } +Standard_EXPORT static const Standard_GUID& GetID(); +Standard_EXPORT ~GEOMImpl_GlueDriver() {}; + +Standard_EXPORT static TopoDS_Shape GlueFaces (const TopoDS_Shape& theShape, + const Standard_Real theTolerance); + + // Type management + // +Standard_EXPORT friend Handle_Standard_Type& GEOMImpl_GlueDriver_Type_(); +Standard_EXPORT const Handle(Standard_Type)& DynamicType() const { return STANDARD_TYPE(GEOMImpl_GlueDriver) ; } +Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const { return (STANDARD_TYPE(GEOMImpl_GlueDriver) == AType || TFunction_Driver::IsKind(AType)); } + + +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_HealingDriver.cxx b/src/GEOMImpl/GEOMImpl_HealingDriver.cxx new file mode 100644 index 000000000..a1b1d8bda --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_HealingDriver.cxx @@ -0,0 +1,405 @@ + +using namespace std; +#include "GEOMImpl_HealingDriver.hxx" +#include "GEOMImpl_Types.hxx" +#include "GEOMImpl_IHealing.hxx" +#include "GEOM_Function.hxx" + +#include "ShHealOper_ShapeProcess.hxx" +#include "ShHealOper_RemoveFace.hxx" +#include "ShHealOper_CloseContour.hxx" +#include "ShHealOper_RemoveInternalWires.hxx" +#include "ShHealOper_FillHoles.hxx" +#include "ShHealOper_Sewing.hxx" +#include "ShHealOper_EdgeDivide.hxx" + +#include +#include +#include + +#include + +//======================================================================= +//function : raiseNotDoneExeption +//purpose : global function: forms error message and raises exeption +//======================================================================= +void raiseNotDoneExeption( const int theErrorStatus ) +{ + switch ( theErrorStatus ) + { + case ShHealOper_NotError: StdFail_NotDone::Raise( "ShHealOper_NotError_msg" ); + case ShHealOper_InvalidParameters: StdFail_NotDone::Raise( "ShHealOper_InvalidParameters_msg" ); + case ShHealOper_ErrorExecution: + default: StdFail_NotDone::Raise( "ShHealOper_ErrorExecution_msg" ); + } +} + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& GEOMImpl_HealingDriver::GetID() +{ + static Standard_GUID aHealingDriver("FF1BBB61-5D14-4df2-980B-3A668264EA16"); + return aHealingDriver; +} + + +//======================================================================= +//function : GEOMImpl_HealingDriver +//purpose : +//======================================================================= + +GEOMImpl_HealingDriver::GEOMImpl_HealingDriver() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_HealingDriver::Execute(TFunction_Logbook& log) const +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); + + if (aFunction.IsNull()) return 0; + + GEOMImpl_IHealing HI (aFunction); + Standard_Integer aType = aFunction->GetType(); + Handle(GEOM_Function) anOriginalFunction = HI.GetOriginal(); + if (anOriginalFunction.IsNull()) return 0; + TopoDS_Shape aShape, anOriginalShape = anOriginalFunction->GetValue(); + if (anOriginalShape.IsNull()) return 0; + + switch (aType) + { + case SHAPE_PROCESS: + ShapeProcess(&HI, anOriginalShape, aShape); + break; + case SUPPRESS_FACES: + SuppressFaces(&HI, anOriginalShape, aShape); + break; + case CLOSE_CONTOUR: + CloseContour(&HI, anOriginalShape, aShape); + break; + case REMOVE_INT_WIRES: + RemoveIntWires(&HI, anOriginalShape, aShape); + break; + case FILL_HOLES: + RemoveHoles(&HI, anOriginalShape, aShape); + break; + case SEWING: + Sew(&HI, anOriginalShape, aShape); + break; + case DIVIDE_EDGE: + AddPointOnEdge(&HI, anOriginalShape, aShape); + break; + default: + return 0; + } + + if (aShape.IsNull()) + raiseNotDoneExeption( ShHealOper_ErrorExecution ); + + aFunction->SetValue(aShape); + + log.SetTouched(Label()); + return 1; +} + +//======================================================================= +//function : ShapeProcess +//purpose : +//======================================================================= +Standard_Boolean GEOMImpl_HealingDriver::ShapeProcess (GEOMImpl_IHealing* theHI, + const TopoDS_Shape& theOriginalShape, + TopoDS_Shape& theOutShape) const +{ + Handle(TColStd_HArray1OfExtendedString) anOperators = theHI->GetOperators(); + Handle(TColStd_HArray1OfExtendedString) aParams = theHI->GetParameters(); + Handle(TColStd_HArray1OfExtendedString) aValues = theHI->GetValues(); + + if (anOperators.IsNull() || anOperators->Length() <= 0) + return Standard_False; + + Standard_Integer nbParams = 0, nbValues = 0; + if (!aParams.IsNull()) { + nbParams = aParams->Length(); + } + if (!aValues.IsNull()) { + nbValues = aValues->Length(); + } + if (nbParams != nbValues) + return Standard_False; + + ShHealOper_ShapeProcess aHealer; + TColStd_SequenceOfAsciiString anOperatorsAS, aParamsAS, aValuesAS; + int i; + for (i = 1; i <= anOperators->Length(); i++) + anOperatorsAS.Append(TCollection_AsciiString(anOperators->Value(i))); + + aHealer.SetOperators(anOperatorsAS); + + for (i = 1; i <= nbParams; i++) { + aHealer.SetParameter(TCollection_AsciiString(aParams->Value(i)), + TCollection_AsciiString(aValues->Value(i))); + } + + aHealer.Perform(theOriginalShape, theOutShape); + + if (!aHealer.isDone()) + raiseNotDoneExeption( ShHealOper_NotError ); + + return Standard_True; +} + +//======================================================================= +//function : SupressFaces +//purpose : +//======================================================================= +Standard_Boolean GEOMImpl_HealingDriver::SuppressFaces (GEOMImpl_IHealing* theHI, + const TopoDS_Shape& theOriginalShape, + TopoDS_Shape& theOutShape) const +{ + Handle(TColStd_HArray1OfInteger) aFaces = theHI->GetFaces(); + + ShHealOper_RemoveFace aHealer (theOriginalShape); + + Standard_Boolean aResult = Standard_False; + if (aFaces.IsNull()) // remove all faces + { + aResult = aHealer.Perform(); + } else { + TopTools_SequenceOfShape aShapesFaces; + TopTools_IndexedMapOfShape aShapes; + TopExp::MapShapes(theOriginalShape, aShapes); + for (int i = 1; i <= aFaces->Length(); i++) { + int indexOfFace = aFaces->Value(i); + TopoDS_Shape aFace = aShapes.FindKey(indexOfFace); + aShapesFaces.Append(aFace); + } + + aResult = aHealer.Perform(aShapesFaces); + } + + if ( aResult ) + theOutShape = aHealer.GetResultShape(); + else + raiseNotDoneExeption( aHealer.GetErrorStatus() ); + + return aResult; +} + +//======================================================================= +//function : CloseContour +//purpose : +//======================================================================= +Standard_Boolean GEOMImpl_HealingDriver::CloseContour (GEOMImpl_IHealing* theHI, + const TopoDS_Shape& theOriginalShape, + TopoDS_Shape& theOutShape) const +{ + Standard_Boolean isByVertex = theHI->GetIsCommonVertex(); + Handle(TColStd_HArray1OfInteger) aWires = theHI->GetWires(); + + ShHealOper_CloseContour aHealer (theOriginalShape); + + Standard_Boolean aResult = Standard_False; + if ( aWires.IsNull() ) { + if ( theOriginalShape.ShapeType() == TopAbs_WIRE ) + aResult = aHealer.Perform(TopoDS::Wire(theOriginalShape), isByVertex, !isByVertex); + } + else { + TopTools_SequenceOfShape aShapesWires; + TopTools_IndexedMapOfShape aShapes; + TopExp::MapShapes(theOriginalShape, aShapes); + for (int i = 1; i <= aWires->Length(); i++) { + int indexOfWire = aWires->Value(i); + TopoDS_Shape aWire = aShapes.FindKey(indexOfWire); + aShapesWires.Append(aWire); + } + + aResult = aHealer.Perform( aShapesWires, isByVertex, !isByVertex ); + } + + if (aResult) + theOutShape = aHealer.GetResultShape(); + else + raiseNotDoneExeption( aHealer.GetErrorStatus() ); + + return aResult; +} + +//======================================================================= +//function : RemoveIntWires +//purpose : +//======================================================================= +Standard_Boolean GEOMImpl_HealingDriver::RemoveIntWires (GEOMImpl_IHealing* theHI, + const TopoDS_Shape& theOriginalShape, + TopoDS_Shape& theOutShape) const +{ + Handle(TColStd_HArray1OfInteger) aWires = theHI->GetWires(); + + ShHealOper_RemoveInternalWires aHealer(theOriginalShape); + + Standard_Boolean aResult = Standard_False; + if (aWires.IsNull()) { // remove all faces + aResult = aHealer.Remove(); + } else { + TopTools_SequenceOfShape aShapesWires; + TopTools_IndexedMapOfShape aShapes; + TopExp::MapShapes(theOriginalShape, aShapes); + for (int i = 1; i <= aWires->Length(); i++) { + int indexOfWire = aWires->Value(i); + TopoDS_Shape aWire = aShapes.FindKey(indexOfWire); + aShapesWires.Append(aWire); + } + + aResult = aHealer.Remove(aShapesWires); + } + + if (aResult) + theOutShape = aHealer.GetResultShape(); + else + raiseNotDoneExeption( aHealer.GetErrorStatus() ); + + return aResult; +} + +//======================================================================= +//function : RemoveHoles +//purpose : +//======================================================================= +Standard_Boolean GEOMImpl_HealingDriver::RemoveHoles (GEOMImpl_IHealing* theHI, + const TopoDS_Shape& theOriginalShape, + TopoDS_Shape& theOutShape) const +{ + Handle(TColStd_HArray1OfInteger) aWires = theHI->GetWires(); + + ShHealOper_FillHoles aHealer (theOriginalShape); + + Standard_Boolean aResult = Standard_False; + if (aWires.IsNull()) { // remove all faces + aResult = aHealer.Fill(); + } else { + TopTools_SequenceOfShape aShapesWires; + TopTools_IndexedMapOfShape aShapes; + TopExp::MapShapes(theOriginalShape, aShapes); + for (int i = 1; i <= aWires->Length(); i++) { + int indexOfWire = aWires->Value(i); + TopoDS_Shape aWire = aShapes.FindKey(indexOfWire); + aShapesWires.Append(aWire); + } + + aResult = aHealer.Fill(aShapesWires); + } + + if (aResult) + theOutShape = aHealer.GetResultShape(); + else + raiseNotDoneExeption( aHealer.GetErrorStatus() ); + + return aResult; +} + +//======================================================================= +//function : Sew +//purpose : +//======================================================================= +Standard_Boolean GEOMImpl_HealingDriver::Sew (GEOMImpl_IHealing* theHI, + const TopoDS_Shape& theOriginalShape, + TopoDS_Shape& theOutShape) const +{ + Standard_Real aTol = theHI->GetTolerance(); + + ShHealOper_Sewing aHealer (theOriginalShape, aTol); + + Standard_Boolean aResult = aHealer.Perform(); + + if (aResult) + theOutShape = aHealer.GetResultShape(); + else + raiseNotDoneExeption( aHealer.GetErrorStatus() ); + + return aResult; +} + +//======================================================================= +//function : AddPointOnEdge +//purpose : +//======================================================================= +Standard_Boolean GEOMImpl_HealingDriver::AddPointOnEdge (GEOMImpl_IHealing* theHI, + const TopoDS_Shape& theOriginalShape, + TopoDS_Shape& theOutShape) const +{ + Standard_Boolean isByParameter = theHI->GetIsByParameter(); + Standard_Integer anIndex = theHI->GetIndex(); + Standard_Real aValue = theHI->GetDevideEdgeValue(); + + ShHealOper_EdgeDivide aHealer (theOriginalShape); + + Standard_Boolean aResult = Standard_False; + if (anIndex == -1) { // apply algorythm for the whole shape which is EDGE + if (theOriginalShape.ShapeType() == TopAbs_EDGE) + aResult = aHealer.Perform(TopoDS::Edge(theOriginalShape), aValue, isByParameter); + } else { + TopTools_IndexedMapOfShape aShapes; + TopExp::MapShapes(theOriginalShape, aShapes); + TopoDS_Shape aEdgeShape = aShapes.FindKey(anIndex); + if (aEdgeShape.ShapeType() == TopAbs_EDGE) + aResult = aHealer.Perform(TopoDS::Edge(aEdgeShape), aValue, isByParameter); + } + + if (aResult) + theOutShape = aHealer.GetResultShape(); + else + raiseNotDoneExeption( aHealer.GetErrorStatus() ); + + return aResult; +} + + +//======================================================================= +//function : GEOMImpl_HealingDriver_Type_ +//purpose : +//======================================================================= +Standard_EXPORT Handle_Standard_Type& GEOMImpl_HealingDriver_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); + 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("GEOMImpl_HealingDriver", + sizeof(GEOMImpl_HealingDriver), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + +//======================================================================= +//function : DownCast +//purpose : +//======================================================================= + +const Handle(GEOMImpl_HealingDriver) Handle(GEOMImpl_HealingDriver)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOMImpl_HealingDriver) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_HealingDriver))) { + _anOtherObject = Handle(GEOMImpl_HealingDriver)((Handle(GEOMImpl_HealingDriver)&)AnObject); + } + } + + return _anOtherObject ; +} + + diff --git a/src/GEOMImpl/GEOMImpl_HealingDriver.hxx b/src/GEOMImpl/GEOMImpl_HealingDriver.hxx new file mode 100644 index 000000000..97390d632 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_HealingDriver.hxx @@ -0,0 +1,152 @@ +// File : GEOMImpl_HealingDriver.hxx +// Module : GEOMImpl + +#ifndef _GEOMImpl_HealingDriver_HeaderFile +#define _GEOMImpl_HealingDriver_HeaderFile + +#ifndef _TColStd_SequenceOfExtendedString_HeaderFile +#include +#endif +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_GUID_HeaderFile +#include +#endif + +#ifndef _Handle_TFunction_Driver_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TFunction_Driver); +class GEOMImpl_HealingDriver; + +class GEOMImpl_IHealing; +#include + +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMImpl_HealingDriver); + +class Handle(GEOMImpl_HealingDriver) : public Handle(TFunction_Driver) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + Handle(GEOMImpl_HealingDriver)():Handle(TFunction_Driver)() {} + Handle(GEOMImpl_HealingDriver)(const Handle(GEOMImpl_HealingDriver)& aHandle) : Handle(TFunction_Driver)(aHandle) + { + } + + Handle(GEOMImpl_HealingDriver)(const GEOMImpl_HealingDriver* anItem) : Handle(TFunction_Driver)((TFunction_Driver *)anItem) + { + } + + Handle(GEOMImpl_HealingDriver)& operator=(const Handle(GEOMImpl_HealingDriver)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOMImpl_HealingDriver)& operator=(const GEOMImpl_HealingDriver* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOMImpl_HealingDriver* operator->() + { + return (GEOMImpl_HealingDriver *)ControlAccess(); + } + + GEOMImpl_HealingDriver* operator->() const + { + return (GEOMImpl_HealingDriver *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOMImpl_HealingDriver)() {}; + + Standard_EXPORT static const Handle(GEOMImpl_HealingDriver) DownCast(const Handle(Standard_Transient)& AnObject); +}; + +#ifndef _TFunction_Driver_HeaderFile +#include +#endif +#ifndef _TFunction_Logbook_HeaderFile +#include +#endif +#ifndef _Standard_CString_HeaderFile +#include +#endif + +class TColStd_SequenceOfExtendedString; + + +class GEOMImpl_HealingDriver : public TFunction_Driver { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + // Methods PUBLIC + // +Standard_EXPORT GEOMImpl_HealingDriver(); +Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; +Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {} +Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const { return Standard_True; } +Standard_EXPORT static const Standard_GUID& GetID(); +Standard_EXPORT ~GEOMImpl_HealingDriver() {}; + + + // Type management + // +Standard_EXPORT friend Handle_Standard_Type& GEOMImpl_HealingDriver_Type_(); +Standard_EXPORT const Handle(Standard_Type)& DynamicType() const { return STANDARD_TYPE(GEOMImpl_HealingDriver) ; } +Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const { return (STANDARD_TYPE(GEOMImpl_HealingDriver) == AType || TFunction_Driver::IsKind(AType)); } + +private: +Standard_Boolean ShapeProcess ( GEOMImpl_IHealing*, const TopoDS_Shape&, TopoDS_Shape& ) const; +Standard_Boolean SuppressFaces ( GEOMImpl_IHealing*, const TopoDS_Shape&, TopoDS_Shape& ) const; +Standard_Boolean CloseContour ( GEOMImpl_IHealing*, const TopoDS_Shape&, TopoDS_Shape& ) const; +Standard_Boolean RemoveIntWires( GEOMImpl_IHealing*, const TopoDS_Shape&, TopoDS_Shape& ) const; +Standard_Boolean RemoveHoles ( GEOMImpl_IHealing*, const TopoDS_Shape&, TopoDS_Shape& ) const; +Standard_Boolean Sew ( GEOMImpl_IHealing*, const TopoDS_Shape&, TopoDS_Shape& ) const; +Standard_Boolean AddPointOnEdge( GEOMImpl_IHealing*, const TopoDS_Shape&, TopoDS_Shape& ) const; + + + +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx new file mode 100644 index 000000000..56eb0762b --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx @@ -0,0 +1,1039 @@ +using namespace std; + +#include "GEOMImpl_I3DPrimOperations.hxx" + +#include "utilities.h" +#include "OpUtil.hxx" +#include "Utils_ExceptHandlers.hxx" + +#include +#include +#include +#include + +#include "GEOM_Function.hxx" +#include "GEOMImpl_Types.hxx" + +#include "GEOMImpl_BoxDriver.hxx" +#include "GEOMImpl_CylinderDriver.hxx" +#include "GEOMImpl_ConeDriver.hxx" +#include "GEOMImpl_SphereDriver.hxx" +#include "GEOMImpl_TorusDriver.hxx" +#include "GEOMImpl_PrismDriver.hxx" +#include "GEOMImpl_PipeDriver.hxx" +#include "GEOMImpl_RevolutionDriver.hxx" +#include "GEOMImpl_ShapeDriver.hxx" +#include "GEOMImpl_FillingDriver.hxx" + +#include "GEOMImpl_IBox.hxx" +#include "GEOMImpl_ICylinder.hxx" +#include "GEOMImpl_ICone.hxx" +#include "GEOMImpl_ISphere.hxx" +#include "GEOMImpl_ITorus.hxx" +#include "GEOMImpl_IPrism.hxx" +#include "GEOMImpl_IPipe.hxx" +#include "GEOMImpl_IRevolution.hxx" +#include "GEOMImpl_IShapes.hxx" +#include "GEOMImpl_IFilling.hxx" + +#include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC + +//============================================================================= +/*! + * constructor: + */ +//============================================================================= +GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations (GEOM_Engine* theEngine, int theDocID) +: GEOM_IOperations(theEngine, theDocID) +{ + MESSAGE("GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations"); +} + +//============================================================================= +/*! + * destructor + */ +//============================================================================= +GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations() +{ + MESSAGE("GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations"); +} + + +//============================================================================= +/*! + * MakeBoxDXDYDZ + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxDXDYDZ (double theDX, double theDY, double theDZ) +{ + SetErrorCode(KO); + + //Add a new Box object + Handle(GEOM_Object) aBox = GetEngine()->AddObject(GetDocID(), GEOM_BOX); + + //Add a new Box function with DX_DY_DZ parameters + Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_DX_DY_DZ); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return NULL; + + GEOMImpl_IBox aBI (aFunction); + + aBI.SetDX(theDX); + aBI.SetDY(theDY); + aBI.SetDZ(theDZ); + + //Compute the box value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Box driver failed"); + 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(aBox->GetEntry(), anEntry); + aDescr += anEntry; + aDescr += " = I3DPrimOperations.MakeBoxDXDYDZ("; + aDescr += (TCollection_AsciiString(theDX)+", "); + aDescr += (TCollection_AsciiString(theDY)+", "); + aDescr += (TCollection_AsciiString(theDZ)+")"); + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aBox; +} + + +//============================================================================= +/*! + * MakeBoxTwoPnt + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxTwoPnt (Handle(GEOM_Object) thePnt1, + Handle(GEOM_Object) thePnt2) +{ + SetErrorCode(KO); + + if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL; + + //Add a new Box object + Handle(GEOM_Object) aBox = GetEngine()->AddObject(GetDocID(), GEOM_BOX); + + //Add a new Box function for creation a box relatively to two points + Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_TWO_PNT); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return aBox; + + GEOMImpl_IBox aBI (aFunction); + + Handle(GEOM_Function) aRefFunction1 = thePnt1->GetLastFunction(); + Handle(GEOM_Function) aRefFunction2 = thePnt2->GetLastFunction(); + + if (aRefFunction1.IsNull() || aRefFunction2.IsNull()) return aBox; + + aBI.SetRef1(aRefFunction1); + aBI.SetRef2(aRefFunction2); + + //Compute the Box value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Box driver failed"); + 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(aBox->GetEntry(), anEntry); + aDescr += anEntry; + aDescr += " = I3DPrimOperations.MakeBoxTwoPnt("; + TDF_Tool::Entry(thePnt1->GetEntry(), anEntry); + aDescr += (anEntry+", "); + TDF_Tool::Entry(thePnt2->GetEntry(), anEntry); + aDescr += (anEntry+")"); + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aBox; +} + + +//============================================================================= +/*! + * MakeCylinderRH + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderRH (double theR, double theH) +{ + SetErrorCode(KO); + + //Add a new Cylinder object + Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER); + + //Add a new Cylinder function with R and H parameters + Handle(GEOM_Function) aFunction = aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_R_H); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL; + + GEOMImpl_ICylinder aCI (aFunction); + + aCI.SetR(theR); + aCI.SetH(theH); + + //Compute the Cylinder value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Cylinder driver failed"); + 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(aCylinder->GetEntry(), anEntry); + aDescr += anEntry; + aDescr += " = I3DPrimOperations.MakeCylinderRH("; + aDescr += (TCollection_AsciiString(theR)+", "); + aDescr += (TCollection_AsciiString(theH)+")"); + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aCylinder; +} + + +//============================================================================= +/*! + * MakeCylinderPntVecRH + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderPntVecRH (Handle(GEOM_Object) thePnt, + Handle(GEOM_Object) theVec, + double theR, double theH) +{ + SetErrorCode(KO); + + if (thePnt.IsNull() || theVec.IsNull()) return NULL; + + //Add a new Cylinder object + Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER); + + //Add a new Cylinder function for creation a cylinder relatively to point and vector + Handle(GEOM_Function) aFunction = + aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_PNT_VEC_R_H); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL; + + GEOMImpl_ICylinder aCI (aFunction); + + Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction(); + Handle(GEOM_Function) aRefVec = theVec->GetLastFunction(); + + if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL; + + aCI.SetPoint(aRefPnt); + aCI.SetVector(aRefVec); + aCI.SetR(theR); + aCI.SetH(theH); + + //Compute the Cylinder value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Cylinder driver failed"); + 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(aCylinder->GetEntry(), anEntry); + aDescr += anEntry; + aDescr += " = I3DPrimOperations.MakeCylinderPntVecRH("; + TDF_Tool::Entry(thePnt->GetEntry(), anEntry); + aDescr += (anEntry+", "); + TDF_Tool::Entry(theVec->GetEntry(), anEntry); + aDescr += (anEntry+", "); + aDescr += (TCollection_AsciiString(theR)+", "); + aDescr += (TCollection_AsciiString(theH)+")"); + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aCylinder; +} + + +//============================================================================= +/*! + * MakeConeR1R2H + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConeR1R2H (double theR1, double theR2, + double theH) +{ + SetErrorCode(KO); + + //Add a new Cone object + Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE); + + //Add a new Cone function with R and H parameters + Handle(GEOM_Function) aFunction = + aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_R1_R2_H); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL; + + GEOMImpl_ICone aCI (aFunction); + + aCI.SetR1(theR1); + aCI.SetR2(theR2); + aCI.SetH(theH); + + //Compute the Cone value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Cone driver failed"); + 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(aCone->GetEntry(), anEntry); + aDescr += anEntry; + aDescr += " = I3DPrimOperations.MakeConeR1R2H("; + aDescr += (TCollection_AsciiString(theR1)+", "); + aDescr += (TCollection_AsciiString(theR2)+", "); + aDescr += (TCollection_AsciiString(theH)+")"); + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aCone; +} + + +//============================================================================= +/*! + * MakeConePntVecR1R2H + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConePntVecR1R2H (Handle(GEOM_Object) thePnt, + Handle(GEOM_Object) theVec, + double theR1, double theR2, + double theH) +{ + SetErrorCode(KO); + + if (thePnt.IsNull() || theVec.IsNull()) return NULL; + + //Add a new Cone object + Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE); + + //Add a new Cone function for creation a cone relatively to point and vector + Handle(GEOM_Function) aFunction = + aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_PNT_VEC_R1_R2_H); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL; + + GEOMImpl_ICone aCI (aFunction); + + Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction(); + Handle(GEOM_Function) aRefVec = theVec->GetLastFunction(); + + if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL; + + aCI.SetPoint(aRefPnt); + aCI.SetVector(aRefVec); + aCI.SetR1(theR1); + aCI.SetR2(theR2); + aCI.SetH(theH); + + //Compute the Cone value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Cone driver failed"); + 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(aCone->GetEntry(), anEntry); + aDescr += anEntry; + aDescr += " = I3DPrimOperations.MakeConePntVecR1R2H("; + TDF_Tool::Entry(thePnt->GetEntry(), anEntry); + aDescr += (anEntry+", "); + TDF_Tool::Entry(theVec->GetEntry(), anEntry); + aDescr += (anEntry+", "); + aDescr += (TCollection_AsciiString(theR1)+", "); + aDescr += (TCollection_AsciiString(theR2)+", "); + aDescr += (TCollection_AsciiString(theH)+")"); + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aCone; +} + + +//============================================================================= +/*! + * MakeSphereR + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSphereR (double theR) +{ + SetErrorCode(KO); + + //Add a new Sphere object + Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE); + + //Add a new Sphere function with R parameter + Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_R); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL; + + GEOMImpl_ISphere aCI (aFunction); + + aCI.SetR(theR); + + //Compute the Sphere value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Sphere driver failed"); + 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(aSphere->GetEntry(), anEntry); + aDescr += anEntry; + aDescr += " = I3DPrimOperations.MakeSphereR("; + aDescr += (TCollection_AsciiString(theR)+")"); + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aSphere; +} + + +//============================================================================= +/*! + * MakeSpherePntR + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSpherePntR (Handle(GEOM_Object) thePnt, + double theR) +{ + SetErrorCode(KO); + + if (thePnt.IsNull()) return NULL; + + //Add a new Point object + Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE); + + //Add a new Sphere function for creation a sphere relatively to point + Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_PNT_R); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL; + + GEOMImpl_ISphere aCI (aFunction); + + Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction(); + + if (aRefPnt.IsNull()) return NULL; + + aCI.SetPoint(aRefPnt); + aCI.SetR(theR); + + //Compute the Sphere value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Sphere driver failed"); + 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(aSphere->GetEntry(), anEntry); + aDescr += anEntry; + aDescr += " = I3DPrimOperations.MakeSpherePntR("; + TDF_Tool::Entry(thePnt->GetEntry(), anEntry); + aDescr += (anEntry+", "); + aDescr += (TCollection_AsciiString(theR)+")"); + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aSphere; +} + + +//============================================================================= +/*! + * MakeTorusRR + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusRR + (double theRMajor, double theRMinor) +{ + SetErrorCode(KO); + + //Add a new Torus object + Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS); + + //Add a new Torus function + Handle(GEOM_Function) aFunction = + anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_RR); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL; + + GEOMImpl_ITorus aCI (aFunction); + + aCI.SetRMajor(theRMajor); + aCI.SetRMinor(theRMinor); + + //Compute the Torus value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Torus driver failed"); + 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(anEll->GetEntry(), anEntry); + aDescr += anEntry; + aDescr += " = ICurvesOperations.MakeTorusRR("; + aDescr += (TCollection_AsciiString(theRMajor)+", "); + aDescr += (TCollection_AsciiString(theRMinor)+")"); + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return anEll; +} + +//============================================================================= +/*! + * MakeTorusPntVecRR + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusPntVecRR + (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec, + double theRMajor, double theRMinor) +{ + SetErrorCode(KO); + + if (thePnt.IsNull() || theVec.IsNull()) return NULL; + + //Add a new Torus object + Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS); + + //Add a new Torus function + Handle(GEOM_Function) aFunction = + anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_PNT_VEC_RR); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL; + + GEOMImpl_ITorus aCI (aFunction); + + Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction(); + Handle(GEOM_Function) aRefVec = theVec->GetLastFunction(); + + if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL; + + aCI.SetCenter(aRefPnt); + aCI.SetVector(aRefVec); + aCI.SetRMajor(theRMajor); + aCI.SetRMinor(theRMinor); + + //Compute the Torus value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Torus driver failed"); + 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(anEll->GetEntry(), anEntry); + aDescr += anEntry; + aDescr += " = ICurvesOperations.MakeTorusPntVecRR("; + TDF_Tool::Entry(thePnt->GetEntry(), anEntry); + aDescr += (anEntry+", "); + TDF_Tool::Entry(theVec->GetEntry(), anEntry); + aDescr += (anEntry+", "); + aDescr += (TCollection_AsciiString(theRMajor)+", "); + aDescr += (TCollection_AsciiString(theRMinor)+")"); + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return anEll; +} + + +//============================================================================= +/*! + * MakePrismVecH + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH (Handle(GEOM_Object) theBase, + Handle(GEOM_Object) theVec, + double theH) +{ + SetErrorCode(KO); + + if (theBase.IsNull() || theVec.IsNull()) return NULL; + + //Add a new Prism object + Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM); + + //Add a new Prism function for creation a Prism relatively to vector + Handle(GEOM_Function) aFunction = + aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL; + + GEOMImpl_IPrism aCI (aFunction); + + Handle(GEOM_Function) aRefBase = theBase->GetLastFunction(); + Handle(GEOM_Function) aRefVec = theVec->GetLastFunction(); + + if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL; + + aCI.SetBase(aRefBase); + aCI.SetVector(aRefVec); + aCI.SetH(theH); + + //Compute the Prism value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Prism driver failed"); + 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(aPrism->GetEntry(), anEntry); + aDescr += anEntry; + aDescr += " = I3DPrimOperations.MakePrismVecH("; + TDF_Tool::Entry(theBase->GetEntry(), anEntry); + aDescr += (anEntry+", "); + TDF_Tool::Entry(theVec->GetEntry(), anEntry); + aDescr += (anEntry+", "); + aDescr += (TCollection_AsciiString(theH)+")"); + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aPrism; +} + +//============================================================================= +/*! + * MakePrismTwoPnt + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt + (Handle(GEOM_Object) theBase, + Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2) +{ + SetErrorCode(KO); + + if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL; + + //Add a new Prism object + Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM); + + //Add a new Prism function for creation a Prism relatively to two points + Handle(GEOM_Function) aFunction = + aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL; + + GEOMImpl_IPrism aCI (aFunction); + + Handle(GEOM_Function) aRefBase = theBase->GetLastFunction(); + Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction(); + Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction(); + + if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL; + + aCI.SetBase(aRefBase); + aCI.SetFirstPoint(aRefPnt1); + aCI.SetLastPoint(aRefPnt2); + + //Compute the Prism value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Prism driver failed"); + 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(aPrism->GetEntry(), anEntry); + aDescr += anEntry; + aDescr += " = I3DPrimOperations.MakePrismVecH("; + TDF_Tool::Entry(theBase->GetEntry(), anEntry); + aDescr += (anEntry+", "); + TDF_Tool::Entry(thePoint1->GetEntry(), anEntry); + aDescr += (anEntry+", "); + TDF_Tool::Entry(thePoint2->GetEntry(), anEntry); + aDescr += (anEntry+")"); + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aPrism; +} + + +//============================================================================= +/*! + * MakePipe + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipe (Handle(GEOM_Object) theBase, + Handle(GEOM_Object) thePath) +{ + SetErrorCode(KO); + + if (theBase.IsNull() || thePath.IsNull()) return NULL; + + //Add a new Pipe object + Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE); + + //Add a new Pipe function + Handle(GEOM_Function) aFunction = + aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BASE_PATH); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL; + + GEOMImpl_IPipe aCI (aFunction); + + Handle(GEOM_Function) aRefBase = theBase->GetLastFunction(); + Handle(GEOM_Function) aRefPath = thePath->GetLastFunction(); + + if (aRefBase.IsNull() || aRefPath.IsNull()) return NULL; + + aCI.SetBase(aRefBase); + aCI.SetPath(aRefPath); + + //Compute the Pipe value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Pipe driver failed"); + 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(aPipe->GetEntry(), anEntry); + aDescr += (anEntry + " = I3DPrimOperations.MakePipe("); + TDF_Tool::Entry(theBase->GetEntry(), anEntry); + aDescr += (anEntry + ", "); + TDF_Tool::Entry(thePath->GetEntry(), anEntry); + aDescr += (anEntry + ")"); + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aPipe; +} + + +//============================================================================= +/*! + * MakeRevolutionAxisAngle + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle (Handle(GEOM_Object) theBase, + Handle(GEOM_Object) theAxis, + double theAngle) +{ + SetErrorCode(KO); + + if (theBase.IsNull() || theAxis.IsNull()) return NULL; + + //Add a new Revolution object + Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GetDocID(), GEOM_REVOLUTION); + + //Add a new Revolution function for creation a revolution relatively to axis + Handle(GEOM_Function) aFunction = + aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL; + + GEOMImpl_IRevolution aCI (aFunction); + + Handle(GEOM_Function) aRefBase = theBase->GetLastFunction(); + Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction(); + + if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL; + + aCI.SetBase(aRefBase); + aCI.SetAxis(aRefAxis); + aCI.SetAngle(theAngle); + + //Compute the Revolution value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Revolution driver failed"); + 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(aRevolution->GetEntry(), anEntry); + aDescr += anEntry; + aDescr += " = I3DPrimOperations.MakeRevolutionAxisAngle("; + TDF_Tool::Entry(theBase->GetEntry(), anEntry); + aDescr += (anEntry+", "); + TDF_Tool::Entry(theAxis->GetEntry(), anEntry); + aDescr += (anEntry+", "); + aDescr += (TCollection_AsciiString(theAngle)+")"); + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aRevolution; +} + + +//============================================================================= +/*! + * MakeSolidShell + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSolidShell (Handle(GEOM_Object) theShell) +{ + SetErrorCode(KO); + + if (theShell.IsNull()) return NULL; + + //Add a new Solid object + Handle(GEOM_Object) aSolid = GetEngine()->AddObject(GetDocID(), GEOM_SOLID); + + //Add a new Solid function for creation a solid from a shell + Handle(GEOM_Function) aFunction = + aSolid->AddFunction(GEOMImpl_ShapeDriver::GetID(), SOLID_SHELL); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_ShapeDriver::GetID()) return NULL; + + GEOMImpl_IShapes aCI (aFunction); + + Handle(GEOM_Function) aRefShell = theShell->GetLastFunction(); + + if (aRefShell.IsNull()) return NULL; + + aCI.SetBase(aRefShell); + + //Compute the Solid value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Solid driver failed"); + 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(aSolid->GetEntry(), anEntry); + aDescr += anEntry; + aDescr += " = I3DPrimOperations.MakeSolidShell("; + TDF_Tool::Entry(theShell->GetEntry(), anEntry); + aDescr += (anEntry+")"); + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aSolid; +} + +//============================================================================= +/*! + * MakeFilling + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFilling (Handle(GEOM_Object) theShape, int theMinDeg, int theMaxDeg, double theTol2D, double theTol3D, int theNbIter) +{ + SetErrorCode(KO); + + if (theShape.IsNull()) return NULL; + + //Add a new Filling object + Handle(GEOM_Object) aFilling = GetEngine()->AddObject(GetDocID(), GEOM_FILLING); + + //Add a new Filling function for creation a filling from a compound + Handle(GEOM_Function) aFunction = aFilling->AddFunction(GEOMImpl_FillingDriver::GetID(), BASIC_FILLING); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_FillingDriver::GetID()) return NULL; + + GEOMImpl_IFilling aFI (aFunction); + + Handle(GEOM_Function) aRefShape = theShape->GetLastFunction(); + + if (aRefShape.IsNull()) return NULL; + + aFI.SetShape(aRefShape); + aFI.SetMinDeg(theMinDeg); + aFI.SetMaxDeg(theMaxDeg); + aFI.SetTol2D(theTol2D); + aFI.SetTol3D(theTol3D); + aFI.SetNbIter(theNbIter); + + //Compute the Solid value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Fiiling driver failed"); + 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(aFilling->GetEntry(), anEntry); + aDescr += anEntry; + aDescr += " = ICurvesOperations.MakeFilling("; + TDF_Tool::Entry(theShape->GetEntry(), anEntry); + aDescr += (anEntry+", "); + aDescr += (TCollection_AsciiString(theMinDeg)+", "); + aDescr += (TCollection_AsciiString(theMaxDeg)+", "); + aDescr += (TCollection_AsciiString(theTol2D)+", "); + aDescr += (TCollection_AsciiString(theTol3D)+", "); + aDescr += (TCollection_AsciiString(theNbIter)+")"); + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aFilling; +} diff --git a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx new file mode 100644 index 000000000..5e43a2d55 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx @@ -0,0 +1,59 @@ + +#ifndef _GEOMImpl_I3DPrimOperations_HXX_ +#define _GEOMImpl_I3DPrimOperations_HXX_ + +#include "Utils_SALOME_Exception.hxx" +#include "GEOM_IOperations.hxx" +#include "GEOM_Engine.hxx" +#include "GEOM_Object.hxx" +#include + +class GEOMImpl_I3DPrimOperations : public GEOM_IOperations { + public: + GEOMImpl_I3DPrimOperations(GEOM_Engine* theEngine, int theDocID); + ~GEOMImpl_I3DPrimOperations(); + + Handle(GEOM_Object) MakeBoxDXDYDZ (double theDX, double theDY, double theDZ); + Handle(GEOM_Object) MakeBoxTwoPnt (Handle(GEOM_Object) thePnt1, + Handle(GEOM_Object) thePnt2); + + Handle(GEOM_Object) MakeCylinderRH (double theR, double theH); + Handle(GEOM_Object) MakeCylinderPntVecRH (Handle(GEOM_Object) thePnt, + Handle(GEOM_Object) theVec, + double theR, double theH); + + Handle(GEOM_Object) MakeConeR1R2H (double theR1, double theR2, double theH); + Handle(GEOM_Object) MakeConePntVecR1R2H (Handle(GEOM_Object) thePnt, + Handle(GEOM_Object) theVec, + double theR1, double theR2, double theH); + + Handle(GEOM_Object) MakeSphereR (double theR); + Handle(GEOM_Object) MakeSpherePntR (Handle(GEOM_Object) thePnt, double theR); + + Handle(GEOM_Object) MakeTorusRR (double theRMajor, double theRMinor); + + Handle(GEOM_Object) MakeTorusPntVecRR (Handle(GEOM_Object) thePnt, + Handle(GEOM_Object) theVec, + double theRMajor, double theRMinor); + + Handle(GEOM_Object) MakePrismVecH (Handle(GEOM_Object) theBase, + Handle(GEOM_Object) theVec, double theH); + + Handle(GEOM_Object) MakePrismTwoPnt (Handle(GEOM_Object) theBase, + Handle(GEOM_Object) thePoint1, + Handle(GEOM_Object) thePoint2); + + Handle(GEOM_Object) MakePipe (Handle(GEOM_Object) theBase, + Handle(GEOM_Object) thePath); + + Handle(GEOM_Object) MakeRevolutionAxisAngle (Handle(GEOM_Object) theBase, + Handle(GEOM_Object) theAxis, + double theAngle); + + Handle(GEOM_Object) MakeSolidShell (Handle(GEOM_Object) theShell); + + Handle(GEOM_Object) MakeFilling (Handle(GEOM_Object) theShape, int theMinDeg, int theMaxDeg, double theTol2D, double theTol3D, int theNbIter); + +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_IArc.hxx b/src/GEOMImpl/GEOMImpl_IArc.hxx new file mode 100644 index 000000000..0c8c75d5e --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_IArc.hxx @@ -0,0 +1,27 @@ +//NOTE: This is an intreface to a function for the Arc creation. + + +#include "GEOM_Function.hxx" + +#define ARC_ARG_PI 1 +#define ARC_ARG_PC 2 +#define ARC_ARG_PE 3 + +class GEOMImpl_IArc +{ + public: + + GEOMImpl_IArc(Handle(GEOM_Function) theFunction): _func(theFunction) {} + + void SetPoint1(Handle(GEOM_Function) theP) { _func->SetReference(ARC_ARG_PI, theP); } + void SetPoint2(Handle(GEOM_Function) theP) { _func->SetReference(ARC_ARG_PC, theP); } + void SetPoint3(Handle(GEOM_Function) theP) { _func->SetReference(ARC_ARG_PE, theP); } + + Handle(GEOM_Function) GetPoint1() { return _func->GetReference(ARC_ARG_PI); } + Handle(GEOM_Function) GetPoint2() { return _func->GetReference(ARC_ARG_PC); } + Handle(GEOM_Function) GetPoint3() { return _func->GetReference(ARC_ARG_PE); } + + private: + + Handle(GEOM_Function) _func; +}; diff --git a/src/GEOMImpl/GEOMImpl_IArchimede.hxx b/src/GEOMImpl/GEOMImpl_IArchimede.hxx new file mode 100644 index 000000000..0b298a03a --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_IArchimede.hxx @@ -0,0 +1,36 @@ +//NOTE: This is an intreface to a function for the Archimede operation. + + +#include "GEOM_Function.hxx" + +#define ARG_WEIGHT 1 +#define ARG_DENSITY 2 +#define ARG_DEFLECT 3 +#define ARG_SHAPE 4 + +class GEOMImpl_IArchimede +{ + public: + + GEOMImpl_IArchimede(Handle(GEOM_Function) theFunction): _func(theFunction) {} + + void SetWeight(Standard_Real theWeight) { _func->SetReal(ARG_WEIGHT, theWeight); } + + Standard_Real GetWeight() { return _func->GetReal(ARG_WEIGHT); } + + void SetDensity(Standard_Real theDensity) { _func->SetReal(ARG_DENSITY, theDensity); } + + Standard_Real GetDensity() { return _func->GetReal(ARG_DENSITY); } + + void SetDeflection(Standard_Real theDeflection) { _func->SetReal(ARG_DEFLECT, theDeflection); } + + Standard_Real GetDeflection() { return _func->GetReal(ARG_DEFLECT); } + + void SetBasicShape(Handle(GEOM_Function) theShape) { _func->SetReference(ARG_SHAPE, theShape); } + + Handle(GEOM_Function) GetBasicShape() { return _func->GetReference(ARG_SHAPE); } + + private: + + Handle(GEOM_Function) _func; +}; diff --git a/src/GEOMImpl/GEOMImpl_IBasicOperations.cxx b/src/GEOMImpl/GEOMImpl_IBasicOperations.cxx new file mode 100644 index 000000000..a0225ef9c --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_IBasicOperations.cxx @@ -0,0 +1,704 @@ +using namespace std; + +#include "GEOMImpl_IBasicOperations.hxx" + +#include "utilities.h" +#include "OpUtil.hxx" +#include "Utils_ExceptHandlers.hxx" + +#include +#include +#include +#include + +#include "GEOM_Function.hxx" + +#include "GEOMImpl_PointDriver.hxx" +#include "GEOMImpl_VectorDriver.hxx" +#include "GEOMImpl_LineDriver.hxx" +#include "GEOMImpl_PlaneDriver.hxx" +#include "GEOMImpl_MarkerDriver.hxx" + +#include "GEOMImpl_IPoint.hxx" +#include "GEOMImpl_IVector.hxx" +#include "GEOMImpl_ILine.hxx" +#include "GEOMImpl_IPlane.hxx" +#include "GEOMImpl_IMarker.hxx" + +#include "GEOMImpl_Types.hxx" + +#include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC + +//============================================================================= +/*! + * constructor: + */ +//============================================================================= +GEOMImpl_IBasicOperations::GEOMImpl_IBasicOperations(GEOM_Engine* theEngine, int theDocID) +: GEOM_IOperations(theEngine, theDocID) +{ + MESSAGE("GEOMImpl_IBasicOperations::GEOMImpl_IBasicOperations"); +} + +//============================================================================= +/*! + * destructor + */ +//============================================================================= +GEOMImpl_IBasicOperations::~GEOMImpl_IBasicOperations() +{ + MESSAGE("GEOMImpl_IBasicOperations::~GEOMImpl_IBasicOperations"); +} + + +//============================================================================= +/*! + * MakePointXYZ + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointXYZ + (double theX, double theY, double theZ) +{ + SetErrorCode(KO); + + //Add a new Point object + Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GetDocID(), GEOM_POINT); + + //Add a new Point function with XYZ parameters + Handle(GEOM_Function) aFunction = + aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), POINT_XYZ); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL; + + GEOMImpl_IPoint aPI(aFunction); + + aPI.SetX(theX); + aPI.SetY(theY); + aPI.SetZ(theZ); + + //Compute the point value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Point driver failed"); + 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(aPoint->GetEntry(), anEntry); + aDescr += (anEntry+" = IBasicOperations.MakePointXYZ("); + aDescr += (TCollection_AsciiString(theX)+", "); + aDescr += (TCollection_AsciiString(theY)+", "); + aDescr += (TCollection_AsciiString(theZ)+")"); + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aPoint; +} + +//============================================================================= +/*! + * MakePointWithReference + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointWithReference + (Handle(GEOM_Object) theReference, double theX, double theY, double theZ) +{ + SetErrorCode(KO); + + if (theReference.IsNull()) return NULL; + + //Add a new Point object + Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GetDocID(), GEOM_POINT); + + //Add a new Point function for creation a point relativley another point + Handle(GEOM_Function) aFunction = aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), POINT_XYZ_REF); + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL; + + GEOMImpl_IPoint aPI(aFunction); + + Handle(GEOM_Function) aRefFunction = theReference->GetLastFunction(); + if (aRefFunction.IsNull()) return NULL; + + aPI.SetRef(aRefFunction); + aPI.SetX(theX); + aPI.SetY(theY); + aPI.SetZ(theZ); + + //Compute the point value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Point driver failed"); + 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(aPoint->GetEntry(), anEntry); + aDescr += (anEntry+" = IBasicOperations.MakePointReference("); + TDF_Tool::Entry(theReference->GetEntry(), anEntry); + aDescr += (anEntry+", "); + aDescr += (TCollection_AsciiString(theX)+", "); + aDescr += (TCollection_AsciiString(theY)+", "); + aDescr += (TCollection_AsciiString(theZ)+")"); + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aPoint; +} + +//============================================================================= +/*! + * MakePointOnCurve + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnCurve + (Handle(GEOM_Object) theCurve, double theParameter) +{ + SetErrorCode(KO); + + if (theCurve.IsNull()) return NULL; + + //Add a new Point object + Handle(GEOM_Object) aPoint = GetEngine()->AddObject(GetDocID(), GEOM_POINT); + + //Add a new Point function for creation a point relativley another point + Handle(GEOM_Function) aFunction = aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), POINT_CURVE_PAR); + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_PointDriver::GetID()) return NULL; + + GEOMImpl_IPoint aPI (aFunction); + + Handle(GEOM_Function) aRefFunction = theCurve->GetLastFunction(); + if (aRefFunction.IsNull()) return NULL; + + aPI.SetCurve(aRefFunction); + aPI.SetParameter(theParameter); + + //Compute the point value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Point driver failed"); + 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(aPoint->GetEntry(), anEntry); + aDescr += (anEntry+" = IBasicOperations.MakePointReference("); + TDF_Tool::Entry(theCurve->GetEntry(), anEntry); + aDescr += (anEntry+", "); + aDescr += (TCollection_AsciiString(theParameter)+")"); + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aPoint; +} + + +//============================================================================= +/*! + * MakeVectorDXDYDZ + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeVectorDXDYDZ + (double theDX, double theDY, double theDZ) +{ + SetErrorCode(KO); + + //Add a new Vector object + Handle(GEOM_Object) aVector = GetEngine()->AddObject(GetDocID(), GEOM_VECTOR); + + //Add a new Vector function with DXDYDZ parameters + Handle(GEOM_Function) aFunction = + aVector->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_DX_DY_DZ); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL; + + GEOMImpl_IVector aPI (aFunction); + + aPI.SetDX(theDX); + aPI.SetDY(theDY); + aPI.SetDZ(theDZ); + + //Compute the Vector value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Vector driver failed"); + 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(aVector->GetEntry(), anEntry); + aDescr += (anEntry+" = IBasicOperations.MakeVectorDXDYDZ("); + aDescr += (TCollection_AsciiString(theDX)+", "); + aDescr += (TCollection_AsciiString(theDY)+", "); + aDescr += (TCollection_AsciiString(theDZ)+")"); + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aVector; +} + +//============================================================================= +/*! + * MakeVectorTwoPnt + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeVectorTwoPnt + (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2) +{ + SetErrorCode(KO); + + if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL; + + //Add a new Vector object + Handle(GEOM_Object) aVector = GetEngine()->AddObject(GetDocID(), GEOM_VECTOR); + + //Add a new Vector function + Handle(GEOM_Function) aFunction = + aVector->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_TWO_PNT); + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL; + + GEOMImpl_IVector aPI (aFunction); + + Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction(); + Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction(); + if (aRef1.IsNull() || aRef2.IsNull()) return NULL; + + aPI.SetPoint1(aRef1); + aPI.SetPoint2(aRef2); + + //Compute the Vector value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Vector driver failed"); + 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(aVector->GetEntry(), anEntry); + aDescr += (anEntry+" = IBasicOperations.MakeVectorTwoPnt("); + TDF_Tool::Entry(thePnt1->GetEntry(), anEntry); + aDescr += (anEntry+", "); + TDF_Tool::Entry(thePnt2->GetEntry(), anEntry); + aDescr += (anEntry+")"); + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aVector; +} + + +//============================================================================= +/*! + * MakeLine + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLine + (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theDir) +{ + SetErrorCode(KO); + + if (thePnt.IsNull() || theDir.IsNull()) return NULL; + + //Add a new Line object + Handle(GEOM_Object) aLine = GetEngine()->AddObject(GetDocID(), GEOM_LINE); + + //Add a new Line function + Handle(GEOM_Function) aFunction = + aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_PNT_DIR); + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL; + + GEOMImpl_ILine aPI (aFunction); + + Handle(GEOM_Function) aRef1 = thePnt->GetLastFunction(); + Handle(GEOM_Function) aRef2 = theDir->GetLastFunction(); + if (aRef1.IsNull() || aRef2.IsNull()) return NULL; + + aPI.SetPoint1(aRef1); + aPI.SetPoint2(aRef2); + + //Compute the Line value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Line driver failed"); + 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(aLine->GetEntry(), anEntry); + aDescr += (anEntry+" = IBasicOperations.MakeLine("); + TDF_Tool::Entry(thePnt->GetEntry(), anEntry); + aDescr += (anEntry+", "); + TDF_Tool::Entry(theDir->GetEntry(), anEntry); + aDescr += (anEntry+")"); + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aLine; +} + +//============================================================================= +/*! + * MakeLineTwoPnt + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeLineTwoPnt + (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2) +{ + SetErrorCode(KO); + + if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL; + + //Add a new Line object + Handle(GEOM_Object) aLine = GetEngine()->AddObject(GetDocID(), GEOM_LINE); + + //Add a new Line function + Handle(GEOM_Function) aFunction = + aLine->AddFunction(GEOMImpl_LineDriver::GetID(), LINE_TWO_PNT); + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_LineDriver::GetID()) return NULL; + + GEOMImpl_ILine aPI (aFunction); + + Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction(); + Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction(); + if (aRef1.IsNull() || aRef2.IsNull()) return NULL; + + aPI.SetPoint1(aRef1); + aPI.SetPoint2(aRef2); + + //Compute the Line value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Line driver failed"); + 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(aLine->GetEntry(), anEntry); + aDescr += (anEntry+" = IBasicOperations.MakeLineTwoPnt("); + TDF_Tool::Entry(thePnt1->GetEntry(), anEntry); + aDescr += (anEntry+", "); + TDF_Tool::Entry(thePnt2->GetEntry(), anEntry); + aDescr += (anEntry+")"); + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aLine; +} + + +//============================================================================= +/*! + * MakePlaneThreePnt + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneThreePnt + (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2, + Handle(GEOM_Object) thePnt3, double theSize) +{ + SetErrorCode(KO); + + if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL; + + //Add a new Plane object + Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE); + + //Add a new Plane function + Handle(GEOM_Function) aFunction = + aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_THREE_PNT); + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL; + + GEOMImpl_IPlane aPI (aFunction); + + Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction(); + Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction(); + Handle(GEOM_Function) aRef3 = thePnt3->GetLastFunction(); + if (aRef1.IsNull() || aRef2.IsNull() || aRef3.IsNull()) return NULL; + + aPI.SetPoint1(aRef1); + aPI.SetPoint2(aRef2); + aPI.SetPoint3(aRef3); + aPI.SetSize(theSize); + + //Compute the Plane value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Plane driver failed"); + 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(aPlane->GetEntry(), anEntry); + aDescr += (anEntry+" = IBasicOperations.MakePlaneThreePnt("); + TDF_Tool::Entry(thePnt1->GetEntry(), anEntry); + aDescr += (anEntry+", "); + TDF_Tool::Entry(thePnt2->GetEntry(), anEntry); + aDescr += (anEntry+", "); + TDF_Tool::Entry(thePnt3->GetEntry(), anEntry); + aDescr += (anEntry+", "); + aDescr += TCollection_AsciiString(theSize) + ")"; + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aPlane; +} + +//============================================================================= +/*! + * MakePlanePntVec + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlanePntVec + (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec, + double theSize) +{ + SetErrorCode(KO); + + if (thePnt.IsNull() || theVec.IsNull()) return NULL; + + //Add a new Plane object + Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE); + + //Add a new Plane function + Handle(GEOM_Function) aFunction = + aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_PNT_VEC); + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL; + + GEOMImpl_IPlane aPI (aFunction); + + Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction(); + Handle(GEOM_Function) aRefVec = theVec->GetLastFunction(); + if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL; + + aPI.SetPoint(aRefPnt); + aPI.SetVector(aRefVec); + aPI.SetSize(theSize); + + //Compute the Plane value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Plane driver failed"); + 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(aPlane->GetEntry(), anEntry); + aDescr += (anEntry+" = IBasicOperations.MakePlanePntVec("); + TDF_Tool::Entry(thePnt->GetEntry(), anEntry); + aDescr += (anEntry+", "); + TDF_Tool::Entry(theVec->GetEntry(), anEntry); + aDescr += (anEntry+", "); + aDescr += TCollection_AsciiString(theSize) + ")"; + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aPlane; +} + +//============================================================================= +/*! + * MakePlaneFace + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePlaneFace + (Handle(GEOM_Object) theFace, double theSize) +{ + SetErrorCode(KO); + + if (theFace.IsNull()) return NULL; + + //Add a new Plane object + Handle(GEOM_Object) aPlane = GetEngine()->AddObject(GetDocID(), GEOM_PLANE); + + //Add a new Plane function + Handle(GEOM_Function) aFunction = + aPlane->AddFunction(GEOMImpl_PlaneDriver::GetID(), PLANE_FACE); + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_PlaneDriver::GetID()) return NULL; + + GEOMImpl_IPlane aPI (aFunction); + + Handle(GEOM_Function) aRef = theFace->GetLastFunction(); + if (aRef.IsNull()) return NULL; + + aPI.SetFace(aRef); + aPI.SetSize(theSize); + + //Compute the Plane value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Plane driver failed"); + 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(aPlane->GetEntry(), anEntry); + aDescr += (anEntry+" = IBasicOperations.MakePlaneFace("); + TDF_Tool::Entry(theFace->GetEntry(), anEntry); + aDescr += (anEntry+", "); + aDescr += TCollection_AsciiString(theSize) + ")"; + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aPlane; +} + + +//============================================================================= +/*! + * MakeMarker + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarker + (double theOX, double theOY, double theOZ, + double theXDX, double theXDY, double theXDZ, + double theYDX, double theYDY, double theYDZ) +{ + SetErrorCode(KO); + + //Add a new Marker object + Handle(GEOM_Object) aMarker = GetEngine()->AddObject(GetDocID(), GEOM_MARKER); + + //Add a new Marker function + Handle(GEOM_Function) aFunction = + aMarker->AddFunction(GEOMImpl_MarkerDriver::GetID(), MARKER_CS); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_MarkerDriver::GetID()) return NULL; + + GEOMImpl_IMarker aPI(aFunction); + + aPI.SetOrigin(theOX, theOY, theOZ); + aPI.SetXDir(theXDX, theXDY, theXDZ); + aPI.SetYDir(theYDX, theYDY, theYDZ); + + //Compute the marker value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Marker driver failed"); + 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(aMarker->GetEntry(), anEntry); + aDescr += anEntry + " = IBasicOperations.MakeMarker("; + aDescr += TCollection_AsciiString(theOX) + ", "; + aDescr += TCollection_AsciiString(theOY) + ", "; + aDescr += TCollection_AsciiString(theOZ) + ", "; + aDescr += TCollection_AsciiString(theXDX) + ", "; + aDescr += TCollection_AsciiString(theXDY) + ", "; + aDescr += TCollection_AsciiString(theXDZ) + ", "; + aDescr += TCollection_AsciiString(theYDX) + ", "; + aDescr += TCollection_AsciiString(theYDY) + ", "; + aDescr += TCollection_AsciiString(theYDZ) + ")"; + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aMarker; +} diff --git a/src/GEOMImpl/GEOMImpl_IBasicOperations.hxx b/src/GEOMImpl/GEOMImpl_IBasicOperations.hxx new file mode 100644 index 000000000..da601f7b4 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_IBasicOperations.hxx @@ -0,0 +1,56 @@ + +#ifndef _GEOMImpl_IBasicOperations_HXX_ +#define _GEOMImpl_IBasicOperations_HXX_ + +#include "Utils_SALOME_Exception.hxx" +#include "GEOM_IOperations.hxx" +#include "GEOM_Engine.hxx" +#include "GEOM_Object.hxx" +#include + +class GEOMImpl_IBasicOperations : public GEOM_IOperations { + public: + GEOMImpl_IBasicOperations(GEOM_Engine* theEngine, int theDocID); + ~GEOMImpl_IBasicOperations(); + + // Point + Handle(GEOM_Object) MakePointXYZ (double theX, double theY, double theZ); + + Handle(GEOM_Object) MakePointWithReference (Handle(GEOM_Object) theReference, + double theX, double theY, double theZ); + + Handle(GEOM_Object) MakePointOnCurve (Handle(GEOM_Object) theCurve, + double theParameter); + + // Vector + Handle(GEOM_Object) MakeVectorDXDYDZ (double theDX, double theDY, double theDZ); + + Handle(GEOM_Object) MakeVectorTwoPnt (Handle(GEOM_Object) thePnt1, + Handle(GEOM_Object) thePnt2); + + // Line + Handle(GEOM_Object) MakeLineTwoPnt (Handle(GEOM_Object) thePnt1, + Handle(GEOM_Object) thePnt2); + + Handle(GEOM_Object) MakeLine (Handle(GEOM_Object) thePnt, + Handle(GEOM_Object) theDir); + + // Plane + Handle(GEOM_Object) MakePlaneThreePnt (Handle(GEOM_Object) thePnt1, + Handle(GEOM_Object) thePnt2, + Handle(GEOM_Object) thePnt3, + double theSize); + + Handle(GEOM_Object) MakePlanePntVec (Handle(GEOM_Object) thePnt, + Handle(GEOM_Object) theVec, + double theSize); + + Handle(GEOM_Object) MakePlaneFace (Handle(GEOM_Object) theFace, double theSize); + + // Marker + Handle(GEOM_Object) MakeMarker (double theOX, double theOY, double theOZ, + double theXDX, double theXDY, double theXDZ, + double theYDX, double theYDY, double theYDZ); +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_IBlockTrsf.hxx b/src/GEOMImpl/GEOMImpl_IBlockTrsf.hxx new file mode 100644 index 000000000..205f7405c --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_IBlockTrsf.hxx @@ -0,0 +1,42 @@ +//NOTE: This is an interface to a function for the Blocks Multi-Transformations. + + +#include "GEOM_Function.hxx" + +#define TRSF_ORIGIN 1 + +#define TRSF_FACE_1_U 2 +#define TRSF_FACE_2_U 3 +#define TRSF_NBITER_U 4 +#define TRSF_FACE_1_V 5 +#define TRSF_FACE_2_V 6 +#define TRSF_NBITER_V 7 + +class GEOMImpl_IBlockTrsf +{ + public: + + GEOMImpl_IBlockTrsf (Handle(GEOM_Function) theFunction): _func(theFunction) {} + + void SetOriginal (Handle(GEOM_Function) theOriginal) { _func->SetReference(TRSF_ORIGIN, theOriginal); } + + Handle(GEOM_Function) GetOriginal() { return _func->GetReference(TRSF_ORIGIN); } + + void SetFace1U (int theFaceId) { _func->SetInteger(TRSF_FACE_1_U, theFaceId); } + void SetFace2U (int theFaceId) { _func->SetInteger(TRSF_FACE_2_U, theFaceId); } + void SetFace1V (int theFaceId) { _func->SetInteger(TRSF_FACE_1_V, theFaceId); } + void SetFace2V (int theFaceId) { _func->SetInteger(TRSF_FACE_2_V, theFaceId); } + void SetNbIterU (int theNbIter) { _func->SetInteger(TRSF_NBITER_U, theNbIter); } + void SetNbIterV (int theNbIter) { _func->SetInteger(TRSF_NBITER_V, theNbIter); } + + int GetFace1U () { return _func->GetInteger(TRSF_FACE_1_U); } + int GetFace2U () { return _func->GetInteger(TRSF_FACE_2_U); } + int GetFace1V () { return _func->GetInteger(TRSF_FACE_1_V); } + int GetFace2V () { return _func->GetInteger(TRSF_FACE_2_V); } + int GetNbIterU() { return _func->GetInteger(TRSF_NBITER_U); } + int GetNbIterV() { return _func->GetInteger(TRSF_NBITER_V); } + + private: + + Handle(GEOM_Function) _func; +}; diff --git a/src/GEOMImpl/GEOMImpl_IBlocks.hxx b/src/GEOMImpl/GEOMImpl_IBlocks.hxx new file mode 100644 index 000000000..a98c9d32b --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_IBlocks.hxx @@ -0,0 +1,26 @@ +// NOTE: This is an interface to a function for the Blocks +// creation and transformation. + + +#include "GEOM_Function.hxx" + +#include "TColStd_HSequenceOfTransient.hxx" + +#define BLOCK_ARG_SHAPES 1 // Arguments for creation of block or face of block + +class GEOMImpl_IBlocks +{ + public: + + GEOMImpl_IBlocks(Handle(GEOM_Function) theFunction): _func(theFunction) {} + + void SetShapes(const Handle(TColStd_HSequenceOfTransient)& theShapes) + { _func->SetReferenceList(BLOCK_ARG_SHAPES, theShapes); } + + Handle(TColStd_HSequenceOfTransient) GetShapes() + { return _func->GetReferenceList(BLOCK_ARG_SHAPES); } + + private: + + Handle(GEOM_Function) _func; +}; diff --git a/src/GEOMImpl/GEOMImpl_IBlocksOperations.cxx b/src/GEOMImpl/GEOMImpl_IBlocksOperations.cxx new file mode 100644 index 000000000..9b7aedc80 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_IBlocksOperations.cxx @@ -0,0 +1,2694 @@ +using namespace std; + +#include "GEOMImpl_IBlocksOperations.hxx" + +#include "GEOMImpl_Types.hxx" + +#include "GEOMImpl_BlockDriver.hxx" +#include "GEOMImpl_IBlocks.hxx" +#include "GEOMImpl_IBlockTrsf.hxx" +#include "GEOMImpl_CopyDriver.hxx" +#include "GEOMImpl_Block6Explorer.hxx" + +#include "GEOM_Function.hxx" + +#include "utilities.h" +#include "OpUtil.hxx" +#include "Utils_ExceptHandlers.hxx" + +#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 + +//============================================================================= +/*! + * constructor: + */ +//============================================================================= +GEOMImpl_IBlocksOperations::GEOMImpl_IBlocksOperations (GEOM_Engine* theEngine, int theDocID) +: GEOM_IOperations(theEngine, theDocID) +{ + MESSAGE("GEOMImpl_IBlocksOperations::GEOMImpl_IBlocksOperations"); +} + +//============================================================================= +/*! + * destructor + */ +//============================================================================= +GEOMImpl_IBlocksOperations::~GEOMImpl_IBlocksOperations() +{ + MESSAGE("GEOMImpl_IBlocksOperations::~GEOMImpl_IBlocksOperations"); +} + + +//============================================================================= +/*! + * MakeQuad + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IBlocksOperations::MakeQuad + (Handle(GEOM_Object) theEdge1, Handle(GEOM_Object) theEdge2, + Handle(GEOM_Object) theEdge3, Handle(GEOM_Object) theEdge4) +{ + SetErrorCode(KO); + + if (theEdge1.IsNull() || theEdge2.IsNull() || + theEdge3.IsNull() || theEdge4.IsNull()) return NULL; + + //Add a new Face object + Handle(GEOM_Object) aFace = GetEngine()->AddObject(GetDocID(), GEOM_FACE); + + //Add a new Face function + Handle(GEOM_Function) aFunction = + aFace->AddFunction(GEOMImpl_BlockDriver::GetID(), BLOCK_FACE_FOUR_EDGES); + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_BlockDriver::GetID()) return NULL; + + GEOMImpl_IBlocks aPI (aFunction); + + Handle(GEOM_Function) aRef1 = theEdge1->GetLastFunction(); + Handle(GEOM_Function) aRef2 = theEdge2->GetLastFunction(); + Handle(GEOM_Function) aRef3 = theEdge3->GetLastFunction(); + Handle(GEOM_Function) aRef4 = theEdge4->GetLastFunction(); + if (aRef1.IsNull() || aRef2.IsNull() || + aRef3.IsNull() || aRef4.IsNull()) return NULL; + + Handle(TColStd_HSequenceOfTransient) aShapesSeq = new TColStd_HSequenceOfTransient; + aShapesSeq->Append(aRef1); + aShapesSeq->Append(aRef2); + aShapesSeq->Append(aRef3); + aShapesSeq->Append(aRef4); + + aPI.SetShapes(aShapesSeq); + + //Compute the Face value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Block driver failed to compute a face"); + 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(aFace->GetEntry(), anEntry); + aDescr += anEntry + " = IBlocksOperations.MakeQuad("; + TDF_Tool::Entry(theEdge1->GetEntry(), anEntry); + aDescr += anEntry + ", "; + TDF_Tool::Entry(theEdge2->GetEntry(), anEntry); + aDescr += anEntry + ", "; + TDF_Tool::Entry(theEdge3->GetEntry(), anEntry); + aDescr += anEntry + ", "; + TDF_Tool::Entry(theEdge4->GetEntry(), anEntry); + aDescr += anEntry + ")"; + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aFace; +} + +//============================================================================= +/*! + * MakeQuad2Edges + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IBlocksOperations::MakeQuad2Edges + (Handle(GEOM_Object) theEdge1, Handle(GEOM_Object) theEdge2) +{ + SetErrorCode(KO); + + if (theEdge1.IsNull() || theEdge2.IsNull()) return NULL; + + //Add a new Face object + Handle(GEOM_Object) aFace = GetEngine()->AddObject(GetDocID(), GEOM_FACE); + + //Add a new Face function + Handle(GEOM_Function) aFunction = + aFace->AddFunction(GEOMImpl_BlockDriver::GetID(), BLOCK_FACE_TWO_EDGES); + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_BlockDriver::GetID()) return NULL; + + GEOMImpl_IBlocks aPI (aFunction); + + Handle(GEOM_Function) aRef1 = theEdge1->GetLastFunction(); + Handle(GEOM_Function) aRef2 = theEdge2->GetLastFunction(); + if (aRef1.IsNull() || aRef2.IsNull()) return NULL; + + Handle(TColStd_HSequenceOfTransient) aShapesSeq = new TColStd_HSequenceOfTransient; + aShapesSeq->Append(aRef1); + aShapesSeq->Append(aRef2); + + aPI.SetShapes(aShapesSeq); + + //Compute the Face value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Block driver failed to compute a face"); + 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(aFace->GetEntry(), anEntry); + aDescr += anEntry + " = IBlocksOperations.MakeQuad2Edges("; + TDF_Tool::Entry(theEdge1->GetEntry(), anEntry); + aDescr += anEntry + ", "; + TDF_Tool::Entry(theEdge2->GetEntry(), anEntry); + aDescr += anEntry + ")"; + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aFace; +} + +//============================================================================= +/*! + * MakeQuad4Vertices + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IBlocksOperations::MakeQuad4Vertices + (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2, + Handle(GEOM_Object) thePnt3, Handle(GEOM_Object) thePnt4) +{ + SetErrorCode(KO); + + if (thePnt1.IsNull() || thePnt2.IsNull() || + thePnt3.IsNull() || thePnt4.IsNull()) return NULL; + + //Add a new Face object + Handle(GEOM_Object) aFace = GetEngine()->AddObject(GetDocID(), GEOM_FACE); + + //Add a new Face function + Handle(GEOM_Function) aFunction = + aFace->AddFunction(GEOMImpl_BlockDriver::GetID(), BLOCK_FACE_FOUR_PNT); + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_BlockDriver::GetID()) return NULL; + + GEOMImpl_IBlocks aPI (aFunction); + + Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction(); + Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction(); + Handle(GEOM_Function) aRef3 = thePnt3->GetLastFunction(); + Handle(GEOM_Function) aRef4 = thePnt4->GetLastFunction(); + if (aRef1.IsNull() || aRef2.IsNull() || + aRef3.IsNull() || aRef4.IsNull()) return NULL; + + Handle(TColStd_HSequenceOfTransient) aShapesSeq = new TColStd_HSequenceOfTransient; + aShapesSeq->Append(aRef1); + aShapesSeq->Append(aRef2); + aShapesSeq->Append(aRef3); + aShapesSeq->Append(aRef4); + + aPI.SetShapes(aShapesSeq); + + //Compute the Face value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Block driver failed to compute a face"); + 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(aFace->GetEntry(), anEntry); + aDescr += anEntry + " = IBlocksOperations.MakeQuad4Vertices("; + TDF_Tool::Entry(thePnt1->GetEntry(), anEntry); + aDescr += anEntry + ", "; + TDF_Tool::Entry(thePnt2->GetEntry(), anEntry); + aDescr += anEntry + ", "; + TDF_Tool::Entry(thePnt3->GetEntry(), anEntry); + aDescr += anEntry + ", "; + TDF_Tool::Entry(thePnt4->GetEntry(), anEntry); + aDescr += anEntry + ")"; + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aFace; +} + +//============================================================================= +/*! + * MakeHexa + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IBlocksOperations::MakeHexa + (Handle(GEOM_Object) theFace1, Handle(GEOM_Object) theFace2, + Handle(GEOM_Object) theFace3, Handle(GEOM_Object) theFace4, + Handle(GEOM_Object) theFace5, Handle(GEOM_Object) theFace6) +{ + SetErrorCode(KO); + + if (theFace1.IsNull() || theFace2.IsNull() || + theFace3.IsNull() || theFace4.IsNull() || + theFace5.IsNull() || theFace6.IsNull()) return NULL; + + //Add a new Solid object + Handle(GEOM_Object) aBlock = GetEngine()->AddObject(GetDocID(), GEOM_BLOCK); + + //Add a new Block function + Handle(GEOM_Function) aFunction = + aBlock->AddFunction(GEOMImpl_BlockDriver::GetID(), BLOCK_SIX_FACES); + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_BlockDriver::GetID()) return NULL; + + GEOMImpl_IBlocks aPI (aFunction); + + Handle(GEOM_Function) aRef1 = theFace1->GetLastFunction(); + Handle(GEOM_Function) aRef2 = theFace2->GetLastFunction(); + Handle(GEOM_Function) aRef3 = theFace3->GetLastFunction(); + Handle(GEOM_Function) aRef4 = theFace4->GetLastFunction(); + Handle(GEOM_Function) aRef5 = theFace5->GetLastFunction(); + Handle(GEOM_Function) aRef6 = theFace6->GetLastFunction(); + if (aRef1.IsNull() || aRef2.IsNull() || + aRef3.IsNull() || aRef4.IsNull() || + aRef5.IsNull() || aRef6.IsNull()) return NULL; + + Handle(TColStd_HSequenceOfTransient) aShapesSeq = new TColStd_HSequenceOfTransient; + aShapesSeq->Append(aRef1); + aShapesSeq->Append(aRef2); + aShapesSeq->Append(aRef3); + aShapesSeq->Append(aRef4); + aShapesSeq->Append(aRef5); + aShapesSeq->Append(aRef6); + + aPI.SetShapes(aShapesSeq); + + //Compute the Block value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Block driver failed to compute a block"); + 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(aBlock->GetEntry(), anEntry); + aDescr += anEntry + " = IBlocksOperations.MakeHexa("; + TDF_Tool::Entry(theFace1->GetEntry(), anEntry); + aDescr += anEntry + ", "; + TDF_Tool::Entry(theFace2->GetEntry(), anEntry); + aDescr += anEntry + ", "; + TDF_Tool::Entry(theFace3->GetEntry(), anEntry); + aDescr += anEntry + ", "; + TDF_Tool::Entry(theFace4->GetEntry(), anEntry); + aDescr += anEntry + ", "; + TDF_Tool::Entry(theFace5->GetEntry(), anEntry); + aDescr += anEntry + ", "; + TDF_Tool::Entry(theFace6->GetEntry(), anEntry); + aDescr += anEntry + ")"; + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aBlock; +} + +//============================================================================= +/*! + * MakeHexa2Faces + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IBlocksOperations::MakeHexa2Faces + (Handle(GEOM_Object) theFace1, Handle(GEOM_Object) theFace2) +{ + SetErrorCode(KO); + + if (theFace1.IsNull() || theFace2.IsNull()) return NULL; + + //Add a new Solid object + Handle(GEOM_Object) aBlock = GetEngine()->AddObject(GetDocID(), GEOM_BLOCK); + + //Add a new Block function + Handle(GEOM_Function) aFunction = + aBlock->AddFunction(GEOMImpl_BlockDriver::GetID(), BLOCK_TWO_FACES); + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_BlockDriver::GetID()) return NULL; + + GEOMImpl_IBlocks aPI (aFunction); + + Handle(GEOM_Function) aRef1 = theFace1->GetLastFunction(); + Handle(GEOM_Function) aRef2 = theFace2->GetLastFunction(); + if (aRef1.IsNull() || aRef2.IsNull()) return NULL; + + Handle(TColStd_HSequenceOfTransient) aShapesSeq = new TColStd_HSequenceOfTransient; + aShapesSeq->Append(aRef1); + aShapesSeq->Append(aRef2); + + aPI.SetShapes(aShapesSeq); + + //Compute the Block value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Block driver failed to compute a block"); + 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(aBlock->GetEntry(), anEntry); + aDescr += anEntry + " = IBlocksOperations.MakeHexa2Faces("; + TDF_Tool::Entry(theFace1->GetEntry(), anEntry); + aDescr += anEntry + ", "; + TDF_Tool::Entry(theFace2->GetEntry(), anEntry); + aDescr += anEntry + ")"; + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aBlock; +} + +//============================================================================= +/*! + * MakeBlockCompound + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IBlocksOperations::MakeBlockCompound + (Handle(GEOM_Object) theCompound) +{ + SetErrorCode(KO); + + if (theCompound.IsNull()) return NULL; + + //Add a new object + Handle(GEOM_Object) aBlockComp = GetEngine()->AddObject(GetDocID(), GEOM_COMPOUND); + + //Add a new BlocksComp function + Handle(GEOM_Function) aFunction = + aBlockComp->AddFunction(GEOMImpl_BlockDriver::GetID(), BLOCK_COMPOUND_GLUE); + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_BlockDriver::GetID()) return NULL; + + GEOMImpl_IBlocks aPI (aFunction); + + Handle(GEOM_Function) aRef1 = theCompound->GetLastFunction(); + if (aRef1.IsNull()) return NULL; + + Handle(TColStd_HSequenceOfTransient) aShapesSeq = new TColStd_HSequenceOfTransient; + aShapesSeq->Append(aRef1); + + aPI.SetShapes(aShapesSeq); + + //Compute the Blocks Compound value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Block driver failed to compute a 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(aBlockComp->GetEntry(), anEntry); + aDescr += anEntry + " = IBlocksOperations.MakeBlockCompound("; + TDF_Tool::Entry(theCompound->GetEntry(), anEntry); + aDescr += anEntry + ")"; + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aBlockComp; +} + +//============================================================================= +/*! + * GetEdge + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetPoint + (Handle(GEOM_Object) theShape, + const Standard_Real theX, + const Standard_Real theY, + const Standard_Real theZ, + const Standard_Real theEpsilon) +{ + SetErrorCode(KO); + + //New Point object + Handle(GEOM_Object) aResult; + + // Arguments + if (theShape.IsNull()) return NULL; + + TopoDS_Shape aBlockOrComp = theShape->GetValue(); + if (aBlockOrComp.IsNull()) { + SetErrorCode("Block or compound is null"); + return NULL; + } + if (aBlockOrComp.ShapeType() != TopAbs_SOLID && + aBlockOrComp.ShapeType() != TopAbs_COMPOUND && + aBlockOrComp.ShapeType() != TopAbs_COMPSOLID) { + SetErrorCode("Shape is neither a block, nor a compound of blocks"); + return NULL; + } + + //Compute the Vertex value + gp_Pnt P (theX, theY, theZ); + Standard_Real eps = Max(theEpsilon, Precision::Confusion()); + + TopoDS_Shape V; + Standard_Integer isFound = 0; + TopTools_MapOfShape mapShape; + TopExp_Explorer exp (aBlockOrComp, TopAbs_VERTEX); + + for (; exp.More(); exp.Next()) { + if (mapShape.Add(exp.Current())) { + TopoDS_Vertex aVi = TopoDS::Vertex(exp.Current()); + gp_Pnt aPi = BRep_Tool::Pnt(aVi); + if (aPi.Distance(P) < eps) { + V = aVi; + isFound++; + } + } + } + + if (isFound == 0) { + SetErrorCode("Vertex has not been found"); + return NULL; + } else if (isFound > 1) { + SetErrorCode("Multiple vertices found by the given coordinates and epsilon"); + return NULL; + } else { + TopTools_IndexedMapOfShape anIndices; + TopExp::MapShapes(aBlockOrComp, anIndices); + Handle(TColStd_HArray1OfInteger) anArray = new TColStd_HArray1OfInteger(1,1); + anArray->SetValue(1, anIndices.FindIndex(V)); + aResult = GetEngine()->AddSubShape(theShape, anArray); + } + + //The GetPoint() doesn't change object so no new function is required. + Handle(GEOM_Function) aFunction = theShape->GetLastFunction(); + + //Make a Python command + TCollection_AsciiString anEntry, aDescr; + TDF_Tool::Entry(aResult->GetEntry(), anEntry); + aDescr += anEntry + " = IBlocksOperations.GetPoint("; + TDF_Tool::Entry(theShape->GetEntry(), anEntry); + aDescr += anEntry + ", "; + aDescr += TCollection_AsciiString(theX) + ", "; + aDescr += TCollection_AsciiString(theY) + ", "; + aDescr += TCollection_AsciiString(theZ) + ", "; + aDescr += TCollection_AsciiString(theEpsilon) + ")"; + + TCollection_AsciiString aNewDescr = aFunction->GetDescription() + "\n"; + aNewDescr += aDescr; + aFunction->SetDescription(aNewDescr); + + SetErrorCode(OK); + return aResult; +} + +//============================================================================= +/*! + * GetEdge + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetEdge + (Handle(GEOM_Object) theShape, + Handle(GEOM_Object) thePoint1, + Handle(GEOM_Object) thePoint2) +{ + SetErrorCode(KO); + + //New Edge object + Handle(GEOM_Object) aResult; + + // Arguments + if (theShape.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL; + + TopoDS_Shape aBlockOrComp = theShape->GetValue(); + if (aBlockOrComp.IsNull()) { + SetErrorCode("Block or compound is null"); + return NULL; + } + if (aBlockOrComp.ShapeType() != TopAbs_SOLID && + aBlockOrComp.ShapeType() != TopAbs_COMPOUND && + aBlockOrComp.ShapeType() != TopAbs_COMPSOLID) { + SetErrorCode("Shape is neither a block, nor a compound of blocks"); + return NULL; + } + + TopoDS_Shape anArg1 = thePoint1->GetValue(); + TopoDS_Shape anArg2 = thePoint2->GetValue(); + if (anArg1.IsNull() || anArg2.IsNull()) { + SetErrorCode("Null shape is given as argument"); + return NULL; + } + if (anArg1.ShapeType() != TopAbs_VERTEX || + anArg2.ShapeType() != TopAbs_VERTEX) { + SetErrorCode("Element for edge identification is not a vertex"); + return NULL; + } + + //Compute the Edge value + try { + TopTools_IndexedDataMapOfShapeListOfShape MVE; + GEOMImpl_Block6Explorer::MapShapesAndAncestors + (aBlockOrComp, TopAbs_VERTEX, TopAbs_EDGE, MVE); + + TopoDS_Shape V1,V2; + Standard_Integer ish, ext = MVE.Extent(); + + if (MVE.Contains(anArg1)) { + V1 = anArg1; + } else { + for (ish = 1; ish <= ext; ish++) { + TopoDS_Shape aShi = MVE.FindKey(ish); + if (BRepTools::Compare(TopoDS::Vertex(anArg1), TopoDS::Vertex(aShi))) { + V1 = aShi; + break; + } + } + } + + if (MVE.Contains(anArg2)) { + V2 = anArg2; + } else { + for (ish = 1; ish <= ext; ish++) { + TopoDS_Shape aShi = MVE.FindKey(ish); + if (BRepTools::Compare(TopoDS::Vertex(anArg2), TopoDS::Vertex(aShi))) { + V2 = aShi; + break; + } + } + } + + if (V1.IsNull() || V2.IsNull()) { + SetErrorCode("The given vertex does not belong to the shape"); + return NULL; + } + + TopoDS_Shape anEdge; + Standard_Integer isFound = + GEOMImpl_Block6Explorer::FindEdge(anEdge, V1, V2, MVE, Standard_True); + if (isFound == 0) { + SetErrorCode("The given vertices do not belong to one edge of the given shape"); + return NULL; + } else if (isFound > 1) { + SetErrorCode("Multiple edges found by the given vertices of the shape"); + return NULL; + } else { + TopTools_IndexedMapOfShape anIndices; + TopExp::MapShapes(aBlockOrComp, anIndices); + Handle(TColStd_HArray1OfInteger) anArray = new TColStd_HArray1OfInteger(1,1); + anArray->SetValue(1, anIndices.FindIndex(anEdge)); + aResult = GetEngine()->AddSubShape(theShape, anArray); + } + } catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //The GetEdge() doesn't change object so no new function is required. + Handle(GEOM_Function) aFunction = theShape->GetLastFunction(); + + //Make a Python command + TCollection_AsciiString anEntry, aDescr; + TDF_Tool::Entry(aResult->GetEntry(), anEntry); + aDescr += anEntry + " = IBlocksOperations.GetEdge("; + TDF_Tool::Entry(theShape->GetEntry(), anEntry); + aDescr += anEntry + ", "; + TDF_Tool::Entry(thePoint1->GetEntry(), anEntry); + aDescr += anEntry + ", "; + TDF_Tool::Entry(thePoint2->GetEntry(), anEntry); + aDescr += anEntry + ")"; + + TCollection_AsciiString aNewDescr = aFunction->GetDescription() + "\n"; + aNewDescr += aDescr; + aFunction->SetDescription(aNewDescr); + + SetErrorCode(OK); + return aResult; +} + +//============================================================================= +/*! + * GetEdgeNearPoint + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetEdgeNearPoint + (Handle(GEOM_Object) theShape, + Handle(GEOM_Object) thePoint) +{ + SetErrorCode(KO); + + //New object + Handle(GEOM_Object) aResult; + + // Arguments + if (theShape.IsNull() || thePoint.IsNull()) return NULL; + + TopoDS_Shape aBlockOrComp = theShape->GetValue(); + if (aBlockOrComp.IsNull()) { + SetErrorCode("Block or compound is null"); + return NULL; + } + if (aBlockOrComp.ShapeType() != TopAbs_SOLID && + aBlockOrComp.ShapeType() != TopAbs_COMPOUND && + aBlockOrComp.ShapeType() != TopAbs_COMPSOLID) { + SetErrorCode("Shape is neither a block, nor a compound of blocks"); + return NULL; + } + + TopoDS_Shape anArg = thePoint->GetValue(); + if (anArg.IsNull()) { + SetErrorCode("Null shape is given as argument"); + return NULL; + } + if (anArg.ShapeType() != TopAbs_VERTEX) { + SetErrorCode("Element for edge identification is not a vertex"); + return NULL; + } + + //Compute the Edge value + try { + TopoDS_Shape aShape; + + TopoDS_Vertex aVert = TopoDS::Vertex(anArg); + + // 1. Explode blocks on edges + TopTools_MapOfShape mapShape; + Standard_Integer nbEdges = 0; + TopExp_Explorer exp (aBlockOrComp, TopAbs_EDGE); + for (; exp.More(); exp.Next()) { + if (mapShape.Add(exp.Current())) { + nbEdges++; + } + } + + mapShape.Clear(); + Standard_Integer ind = 1; + TopTools_Array1OfShape anEdges (1, nbEdges); + TColStd_Array1OfReal aDistances (1, nbEdges); + for (exp.Init(aBlockOrComp, TopAbs_EDGE); exp.More(); exp.Next()) { + if (mapShape.Add(exp.Current())) { + TopoDS_Shape anEdge = exp.Current(); + anEdges(ind) = anEdge; + + // 2. Classify the point relatively each edge + BRepExtrema_DistShapeShape aDistTool (aVert, anEdges(ind)); + if (!aDistTool.IsDone()) { + SetErrorCode("Can not find a distance from the given point to one of edges"); + return NULL; + } + aDistances(ind) = aDistTool.Value(); + ind++; + } + } + + // 3. Define edge, having minimum distance to the point + Standard_Real nearest = RealLast(), nbFound = 0; + Standard_Real prec = Precision::Confusion(); + for (ind = 1; ind <= nbEdges; ind++) { + if (Abs(aDistances(ind) - nearest) < prec) { + nbFound++; + } else if (aDistances(ind) < nearest) { + nearest = aDistances(ind); + aShape = anEdges(ind); + nbFound = 1; + } else { + } + } + if (nbFound > 1) { + SetErrorCode("Multiple edges near the given point are found"); + return NULL; + } else if (nbFound == 0) { + SetErrorCode("There are no edges near the given point"); + return NULL; + } else { + TopTools_IndexedMapOfShape anIndices; + TopExp::MapShapes(aBlockOrComp, anIndices); + Handle(TColStd_HArray1OfInteger) anArray = new TColStd_HArray1OfInteger(1,1); + anArray->SetValue(1, anIndices.FindIndex(aShape)); + aResult = GetEngine()->AddSubShape(theShape, anArray); + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //The GetEdgeNearPoint() doesn't change object so no new function is required. + Handle(GEOM_Function) aFunction = theShape->GetLastFunction(); + + //Make a Python command + TCollection_AsciiString anEntry, aDescr; + TDF_Tool::Entry(aResult->GetEntry(), anEntry); + aDescr += anEntry + " = IBlocksOperations.GetEdgeNearPoint("; + TDF_Tool::Entry(theShape->GetEntry(), anEntry); + aDescr += anEntry + ", "; + TDF_Tool::Entry(thePoint->GetEntry(), anEntry); + aDescr += anEntry + ")"; + + TCollection_AsciiString aNewDescr = aFunction->GetDescription() + "\n"; + aNewDescr += aDescr; + aFunction->SetDescription(aNewDescr); + + SetErrorCode(OK); + return aResult; +} + +//============================================================================= +/*! + * GetFaceByPoints + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetFaceByPoints + (Handle(GEOM_Object) theShape, + Handle(GEOM_Object) thePoint1, + Handle(GEOM_Object) thePoint2, + Handle(GEOM_Object) thePoint3, + Handle(GEOM_Object) thePoint4) +{ + SetErrorCode(KO); + + //New object + Handle(GEOM_Object) aResult; + + // Arguments + if (theShape.IsNull() || + thePoint1.IsNull() || thePoint2.IsNull() || + thePoint3.IsNull() || thePoint4.IsNull()) return NULL; + + TopoDS_Shape aBlockOrComp = theShape->GetValue(); + if (aBlockOrComp.IsNull()) { + SetErrorCode("Block or compound is null"); + return NULL; + } + if (aBlockOrComp.ShapeType() != TopAbs_SOLID && + aBlockOrComp.ShapeType() != TopAbs_COMPOUND && + aBlockOrComp.ShapeType() != TopAbs_COMPSOLID) { + SetErrorCode("Shape is neither a block, nor a compound of blocks"); + return NULL; + } + + TopoDS_Shape anArg1 = thePoint1->GetValue(); + TopoDS_Shape anArg2 = thePoint2->GetValue(); + TopoDS_Shape anArg3 = thePoint3->GetValue(); + TopoDS_Shape anArg4 = thePoint4->GetValue(); + if (anArg1.IsNull() || anArg2.IsNull() || + anArg3.IsNull() || anArg4.IsNull()) { + SetErrorCode("Null shape is given as argument"); + return NULL; + } + if (anArg1.ShapeType() != TopAbs_VERTEX || + anArg2.ShapeType() != TopAbs_VERTEX || + anArg3.ShapeType() != TopAbs_VERTEX || + anArg4.ShapeType() != TopAbs_VERTEX) { + SetErrorCode("Element for face identification is not a vertex"); + return NULL; + } + + //Compute the Face value + try { + TopoDS_Shape aShape; + + TopTools_IndexedDataMapOfShapeListOfShape MVF; + GEOMImpl_Block6Explorer::MapShapesAndAncestors(aBlockOrComp, TopAbs_VERTEX, TopAbs_FACE, MVF); + + TopoDS_Shape V1,V2,V3,V4; + Standard_Integer ish, ext = MVF.Extent(); + + if (MVF.Contains(anArg1)) { + V1 = anArg1; + } else { + for (ish = 1; ish <= ext; ish++) { + TopoDS_Shape aShi = MVF.FindKey(ish); + if (BRepTools::Compare(TopoDS::Vertex(anArg1), TopoDS::Vertex(aShi))) { + V1 = aShi; + break; + } + } + } + + if (MVF.Contains(anArg2)) { + V2 = anArg2; + } else { + for (ish = 1; ish <= ext; ish++) { + TopoDS_Shape aShi = MVF.FindKey(ish); + if (BRepTools::Compare(TopoDS::Vertex(anArg2), TopoDS::Vertex(aShi))) { + V2 = aShi; + break; + } + } + } + + if (MVF.Contains(anArg3)) { + V3 = anArg3; + } else { + for (ish = 1; ish <= ext; ish++) { + TopoDS_Shape aShi = MVF.FindKey(ish); + if (BRepTools::Compare(TopoDS::Vertex(anArg3), TopoDS::Vertex(aShi))) { + V3 = aShi; + break; + } + } + } + + if (MVF.Contains(anArg4)) { + V4 = anArg4; + } else { + for (ish = 1; ish <= ext; ish++) { + TopoDS_Shape aShi = MVF.FindKey(ish); + if (BRepTools::Compare(TopoDS::Vertex(anArg4), TopoDS::Vertex(aShi))) { + V4 = aShi; + break; + } + } + } + + if (V1.IsNull() || V2.IsNull() || V3.IsNull() || V4.IsNull()) { + SetErrorCode("The given vertex does not belong to the shape"); + return NULL; + } + + Standard_Integer isFound = + GEOMImpl_Block6Explorer::FindFace(aShape, V1, V2, V3, V4, MVF, Standard_True); + if (isFound == 0) { + SetErrorCode("The given vertices do not belong to one face of the given shape"); + return NULL; + } else if (isFound > 1) { + SetErrorCode("The given vertices belong to several faces of the given shape"); + return NULL; + } else { + TopTools_IndexedMapOfShape anIndices; + TopExp::MapShapes(aBlockOrComp, anIndices); + Handle(TColStd_HArray1OfInteger) anArray = new TColStd_HArray1OfInteger(1,1); + anArray->SetValue(1, anIndices.FindIndex(aShape)); + aResult = GetEngine()->AddSubShape(theShape, anArray); + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //The GetFaceByPoints() doesn't change object so no new function is required. + Handle(GEOM_Function) aFunction = theShape->GetLastFunction(); + + //Make a Python command + TCollection_AsciiString anEntry, aDescr; + TDF_Tool::Entry(aResult->GetEntry(), anEntry); + aDescr += anEntry + " = IBlocksOperations.GetFaceByPoints("; + TDF_Tool::Entry(theShape->GetEntry(), anEntry); + aDescr += anEntry + ", "; + TDF_Tool::Entry(thePoint1->GetEntry(), anEntry); + aDescr += anEntry + ", "; + TDF_Tool::Entry(thePoint2->GetEntry(), anEntry); + aDescr += anEntry + ", "; + TDF_Tool::Entry(thePoint3->GetEntry(), anEntry); + aDescr += anEntry + ", "; + TDF_Tool::Entry(thePoint4->GetEntry(), anEntry); + aDescr += anEntry + ")"; + + TCollection_AsciiString aNewDescr = aFunction->GetDescription() + "\n"; + aNewDescr += aDescr; + aFunction->SetDescription(aNewDescr); + + SetErrorCode(OK); + return aResult; +} + +//============================================================================= +/*! + * GetFaceByEdges + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetFaceByEdges + (Handle(GEOM_Object) theShape, + Handle(GEOM_Object) theEdge1, + Handle(GEOM_Object) theEdge2) +{ + SetErrorCode(KO); + + //New object + Handle(GEOM_Object) aResult; + + // Arguments + if (theShape.IsNull() || theEdge1.IsNull() || theEdge2.IsNull()) return NULL; + + TopoDS_Shape aBlockOrComp = theShape->GetValue(); + if (aBlockOrComp.IsNull()) { + SetErrorCode("Block or compound is null"); + return NULL; + } + if (aBlockOrComp.ShapeType() != TopAbs_SOLID && + aBlockOrComp.ShapeType() != TopAbs_COMPOUND && + aBlockOrComp.ShapeType() != TopAbs_COMPSOLID) { + SetErrorCode("Shape is neither a block, nor a compound of blocks"); + return NULL; + } + + TopoDS_Shape anArg1 = theEdge1->GetValue(); + TopoDS_Shape anArg2 = theEdge2->GetValue(); + if (anArg1.IsNull() || anArg2.IsNull()) { + SetErrorCode("Null shape is given as argument"); + return NULL; + } + if (anArg1.ShapeType() != TopAbs_EDGE || + anArg2.ShapeType() != TopAbs_EDGE) { + SetErrorCode("Element for face identification is not an edge"); + return NULL; + } + + //Compute the Face value + try { + TopoDS_Shape aShape; + + TopTools_IndexedDataMapOfShapeListOfShape MEF; + GEOMImpl_Block6Explorer::MapShapesAndAncestors(aBlockOrComp, TopAbs_EDGE, TopAbs_FACE, MEF); + + TopoDS_Shape E1,E2; + Standard_Integer ish, ext = MEF.Extent(); + + if (MEF.Contains(anArg1)) { + E1 = anArg1; + } else { + for (ish = 1; ish <= ext; ish++) { + TopoDS_Shape aShi = MEF.FindKey(ish); + if (GEOMImpl_Block6Explorer::IsSimilarEdges(anArg1, aShi)) { + E1 = aShi; + } + } + } + + if (MEF.Contains(anArg2)) { + E2 = anArg2; + } else { + for (ish = 1; ish <= ext; ish++) { + TopoDS_Shape aShi = MEF.FindKey(ish); + if (GEOMImpl_Block6Explorer::IsSimilarEdges(anArg2, aShi)) { + E2 = aShi; + } + } + } + + if (E1.IsNull() || E2.IsNull()) { + SetErrorCode("The given edge does not belong to the shape"); + return NULL; + } + + const TopTools_ListOfShape& aFacesOfE1 = MEF.FindFromKey(E1); + const TopTools_ListOfShape& aFacesOfE2 = MEF.FindFromKey(E2); + + Standard_Integer isFound = 0; + TopTools_ListIteratorOfListOfShape anIterF1 (aFacesOfE1); + for (; anIterF1.More(); anIterF1.Next()) { + + TopTools_ListIteratorOfListOfShape anIterF2 (aFacesOfE2); + for (; anIterF2.More(); anIterF2.Next()) { + + if (anIterF1.Value().IsSame(anIterF2.Value())) { + isFound++; + + // Store the face, defined by two edges + aShape = anIterF1.Value(); + } + } + } + if (isFound == 0) { + SetErrorCode("The given edges do not belong to one face of the given shape"); + return NULL; + } else if (isFound > 1) { + SetErrorCode("The given edges belong to several faces of the given shape"); + return NULL; + } else { + TopTools_IndexedMapOfShape anIndices; + TopExp::MapShapes(aBlockOrComp, anIndices); + Handle(TColStd_HArray1OfInteger) anArray = new TColStd_HArray1OfInteger(1,1); + anArray->SetValue(1, anIndices.FindIndex(aShape)); + aResult = GetEngine()->AddSubShape(theShape, anArray); + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //The GetFaceByEdges() doesn't change object so no new function is required. + Handle(GEOM_Function) aFunction = theShape->GetLastFunction(); + + //Make a Python command + TCollection_AsciiString anEntry, aDescr; + TDF_Tool::Entry(aResult->GetEntry(), anEntry); + aDescr += anEntry + " = IBlocksOperations.GetFaceByEdges("; + TDF_Tool::Entry(theShape->GetEntry(), anEntry); + aDescr += anEntry + ", "; + TDF_Tool::Entry(theEdge1->GetEntry(), anEntry); + aDescr += anEntry + ", "; + TDF_Tool::Entry(theEdge2->GetEntry(), anEntry); + aDescr += anEntry + ")"; + + TCollection_AsciiString aNewDescr = aFunction->GetDescription() + "\n"; + aNewDescr += aDescr; + aFunction->SetDescription(aNewDescr); + + SetErrorCode(OK); + return aResult; +} + +//============================================================================= +/*! + * GetOppositeFace + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetOppositeFace + (Handle(GEOM_Object) theShape, + Handle(GEOM_Object) theFace) +{ + SetErrorCode(KO); + + //New object + Handle(GEOM_Object) aResult; + + // Arguments + if (theShape.IsNull() || theFace.IsNull()) return NULL; + + TopoDS_Shape aBlockOrComp = theShape->GetValue(); + if (aBlockOrComp.IsNull()) { + SetErrorCode("Block is null"); + return NULL; + } + if (aBlockOrComp.ShapeType() != TopAbs_SOLID) { + SetErrorCode("Shape is not a block"); + return NULL; + } + + TopoDS_Shape anArg = theFace->GetValue(); + if (anArg.IsNull()) { + SetErrorCode("Null shape is given as argument"); + return NULL; + } + if (anArg.ShapeType() != TopAbs_FACE) { + SetErrorCode("Element for face identification is not a face"); + return NULL; + } + + //Compute the Face value + try { + TopoDS_Shape aShape; + + GEOMImpl_Block6Explorer aBlockTool; + aBlockTool.InitByBlockAndFace(aBlockOrComp, anArg); + aShape = aBlockTool.GetFace(2); + + TopTools_IndexedMapOfShape anIndices; + TopExp::MapShapes(aBlockOrComp, anIndices); + Handle(TColStd_HArray1OfInteger) anArray = new TColStd_HArray1OfInteger(1,1); + anArray->SetValue(1, anIndices.FindIndex(aShape)); + aResult = GetEngine()->AddSubShape(theShape, anArray); + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //The GetOppositeFace() doesn't change object so no new function is required. + Handle(GEOM_Function) aFunction = theShape->GetLastFunction(); + + //Make a Python command + TCollection_AsciiString anEntry, aDescr; + TDF_Tool::Entry(aResult->GetEntry(), anEntry); + aDescr += anEntry + " = IBlocksOperations.GetOppositeFace("; + TDF_Tool::Entry(theShape->GetEntry(), anEntry); + aDescr += anEntry + ", "; + TDF_Tool::Entry(theFace->GetEntry(), anEntry); + aDescr += anEntry + ")"; + + TCollection_AsciiString aNewDescr = aFunction->GetDescription() + "\n"; + aNewDescr += aDescr; + aFunction->SetDescription(aNewDescr); + + SetErrorCode(OK); + return aResult; +} + +//============================================================================= +/*! + * GetFaceNearPoint + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetFaceNearPoint + (Handle(GEOM_Object) theShape, + Handle(GEOM_Object) thePoint) +{ + SetErrorCode(KO); + + //New object + Handle(GEOM_Object) aResult; + + // Arguments + if (theShape.IsNull() || thePoint.IsNull()) return NULL; + + TopoDS_Shape aBlockOrComp = theShape->GetValue(); + if (aBlockOrComp.IsNull()) { + SetErrorCode("Block or compound is null"); + return NULL; + } + if (aBlockOrComp.ShapeType() != TopAbs_SOLID && + aBlockOrComp.ShapeType() != TopAbs_COMPOUND && + aBlockOrComp.ShapeType() != TopAbs_COMPSOLID) { + SetErrorCode("Shape is neither a block, nor a compound of blocks"); + return NULL; + } + + TopoDS_Shape anArg = thePoint->GetValue(); + if (anArg.IsNull()) { + SetErrorCode("Null shape is given as argument"); + return NULL; + } + if (anArg.ShapeType() != TopAbs_VERTEX) { + SetErrorCode("Element for face identification is not a vertex"); + return NULL; + } + + //Compute the Face value + try { + TopoDS_Shape aShape; + + TopoDS_Vertex aVert = TopoDS::Vertex(anArg); + gp_Pnt aPnt = BRep_Tool::Pnt(aVert); + + // 1. Explode blocks on faces + TopTools_MapOfShape mapShape; + Standard_Integer nbFaces = 0; + TopExp_Explorer exp (aBlockOrComp, TopAbs_FACE); + for (; exp.More(); exp.Next()) { + if (mapShape.Add(exp.Current())) { + nbFaces++; + } + } + + 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; + } + 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 { + } + } + if (nbFound > 1) { + if (nearest == 0) { + // The point is on boundary of some faces and there are + // no faces, having the point inside + SetErrorCode("Multiple faces near the given point are found"); + return NULL; + + } else if (nearest == 1) { + // 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 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); + } + } + } + } + } + + if (nbFound == 0) { + SetErrorCode("There are no faces near the given point"); + return NULL; + } else { + TopTools_IndexedMapOfShape anIndices; + TopExp::MapShapes(aBlockOrComp, anIndices); + Handle(TColStd_HArray1OfInteger) anArray = new TColStd_HArray1OfInteger(1,1); + anArray->SetValue(1, anIndices.FindIndex(aShape)); + aResult = GetEngine()->AddSubShape(theShape, anArray); + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //The GetFaceNearPoint() doesn't change object so no new function is required. + Handle(GEOM_Function) aFunction = theShape->GetLastFunction(); + + //Make a Python command + TCollection_AsciiString anEntry, aDescr; + TDF_Tool::Entry(aResult->GetEntry(), anEntry); + aDescr += anEntry + " = IBlocksOperations.GetFaceNearPoint("; + TDF_Tool::Entry(theShape->GetEntry(), anEntry); + aDescr += anEntry + ", "; + TDF_Tool::Entry(thePoint->GetEntry(), anEntry); + aDescr += anEntry + ")"; + + TCollection_AsciiString aNewDescr = aFunction->GetDescription() + "\n"; + aNewDescr += aDescr; + aFunction->SetDescription(aNewDescr); + + SetErrorCode(OK); + return aResult; +} + +//============================================================================= +/*! + * GetFaceByNormale + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetFaceByNormale + (Handle(GEOM_Object) theShape, + Handle(GEOM_Object) theVector) +{ + SetErrorCode(KO); + + //New object + Handle(GEOM_Object) aResult; + + // Arguments + if (theShape.IsNull() || theVector.IsNull()) return NULL; + + TopoDS_Shape aBlockOrComp = theShape->GetValue(); + if (aBlockOrComp.IsNull()) { + SetErrorCode("Block or compound is null"); + return NULL; + } + if (aBlockOrComp.ShapeType() != TopAbs_SOLID && + aBlockOrComp.ShapeType() != TopAbs_COMPOUND && + aBlockOrComp.ShapeType() != TopAbs_COMPSOLID) { + SetErrorCode("Shape is neither a block, nor a compound of blocks"); + return NULL; + } + + TopoDS_Shape anArg = theVector->GetValue(); + if (anArg.IsNull()) { + SetErrorCode("Null shape is given as argument"); + return NULL; + } + if (anArg.ShapeType() != TopAbs_EDGE) { + SetErrorCode("Element for normale identification is not an edge"); + return NULL; + } + + //Compute the Face value + try { + TopoDS_Shape aShape; + + TopoDS_Edge anEdge = TopoDS::Edge(anArg); + TopoDS_Vertex V1, V2; + TopExp::Vertices(anEdge, V1, V2, Standard_True); + gp_Pnt P1 = BRep_Tool::Pnt(V1); + gp_Pnt P2 = BRep_Tool::Pnt(V2); + gp_Vec aVec (P1, P2); + if (aVec.Magnitude() < Precision::Confusion()) { + SetErrorCode("Vector with null magnitude is given"); + return NULL; + } + + Standard_Real minAngle = RealLast(); + TopTools_MapOfShape mapShape; + TopExp_Explorer exp (aBlockOrComp, TopAbs_FACE); + for (; exp.More(); exp.Next()) { + if (mapShape.Add(exp.Current())) { + TopoDS_Face aFace = TopoDS::Face(exp.Current()); + BRepAdaptor_Surface SF (aFace); + + Standard_Real u, v, x; + + // find a point on the surface to get normal direction in + u = SF.FirstUParameter(); + x = SF.LastUParameter(); + if (Precision::IsInfinite(u)) { + u = (Precision::IsInfinite(x)) ? 0. : x; + } else if (!Precision::IsInfinite(x)) { + u = (u+x) / 2.; + } + + v = SF.FirstVParameter(); + x = SF.LastVParameter(); + if (Precision::IsInfinite(v)) { + v = (Precision::IsInfinite(x)) ? 0. : x; + } else if (!Precision::IsInfinite(x)) { + v = (v+x) / 2.; + } + + // compute the normal direction + gp_Vec Vec1,Vec2; + SF.D1(u,v,P1,Vec1,Vec2); + gp_Vec V = Vec1.Crossed(Vec2); + x = V.Magnitude(); + if (V.Magnitude() < Precision::Confusion()) { + SetErrorCode("Normal vector of a face has null magnitude"); + return NULL; + } + + // consider the face orientation + if (aFace.Orientation() == TopAbs_REVERSED || + aFace.Orientation() == TopAbs_INTERNAL) { + V = - V; + } + + // compute the angle and compare with the minimal one + Standard_Real anAngle = aVec.Angle(V); + if (anAngle < minAngle) { + minAngle = anAngle; + aShape = aFace; + } + } + } + + if (aShape.IsNull()) { + SetErrorCode("Failed to find a face by the given normale"); + return NULL; + } else { + TopTools_IndexedMapOfShape anIndices; + TopExp::MapShapes(aBlockOrComp, anIndices); + Handle(TColStd_HArray1OfInteger) anArray = new TColStd_HArray1OfInteger(1,1); + anArray->SetValue(1, anIndices.FindIndex(aShape)); + aResult = GetEngine()->AddSubShape(theShape, anArray); + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //The GetFaceByNormale() doesn't change object so no new function is required. + Handle(GEOM_Function) aFunction = theShape->GetLastFunction(); + + //Make a Python command + TCollection_AsciiString anEntry, aDescr; + TDF_Tool::Entry(aResult->GetEntry(), anEntry); + aDescr += anEntry + " = IBlocksOperations.GetFaceByNormale("; + TDF_Tool::Entry(theShape->GetEntry(), anEntry); + aDescr += anEntry + ", "; + TDF_Tool::Entry(theVector->GetEntry(), anEntry); + aDescr += anEntry + ")"; + + TCollection_AsciiString aNewDescr = aFunction->GetDescription() + "\n"; + aNewDescr += aDescr; + aFunction->SetDescription(aNewDescr); + + SetErrorCode(OK); + return aResult; +} + +//============================================================================= +/*! + * IsCompoundOfBlocks + */ +//============================================================================= +Standard_Boolean GEOMImpl_IBlocksOperations::IsCompoundOfBlocks + (Handle(GEOM_Object) theCompound, + const Standard_Integer theMinNbFaces, + const Standard_Integer theMaxNbFaces, + Standard_Integer& theNbBlocks) +{ + SetErrorCode(KO); + Standard_Boolean isCompOfBlocks = Standard_False; + theNbBlocks = 0; + + if (theCompound.IsNull()) return isCompOfBlocks; + TopoDS_Shape aBlockOrComp = theCompound->GetValue(); + + //Check + isCompOfBlocks = Standard_True; + try { + TopTools_MapOfShape mapShape; + TopExp_Explorer exp (aBlockOrComp, TopAbs_SOLID); + for (; exp.More(); exp.Next()) { + if (mapShape.Add(exp.Current())) { + TopoDS_Shape aSolid = exp.Current(); + + TopTools_MapOfShape mapFaces; + TopExp_Explorer expF (aSolid, TopAbs_FACE); + Standard_Integer nbFaces = 0; + for (; expF.More(); expF.Next()) { + if (mapFaces.Add(expF.Current())) { + nbFaces++; + if (nbFaces > theMaxNbFaces) { + isCompOfBlocks = Standard_False; + break; + } + } + } + if (nbFaces < theMinNbFaces || theMaxNbFaces < nbFaces) { + isCompOfBlocks = Standard_False; + } else { + theNbBlocks++; + } + } + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return isCompOfBlocks; + } + + SetErrorCode(OK); + return isCompOfBlocks; +} + +//============================================================================= +/*! + * Set of functions, used by CheckCompoundOfBlocks() method + */ +//============================================================================= +void AddBlocksFrom (const TopoDS_Shape& theShape, + TopTools_ListOfShape& BLO, + TopTools_ListOfShape& NOT) +{ + 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); + } + } + break; + case TopAbs_SOLID: + { + TopTools_MapOfShape mapFaces; + TopExp_Explorer expF (theShape, TopAbs_FACE); + Standard_Integer nbFaces = 0; + Standard_Integer nbEdges = 0; + for (; expF.More(); expF.Next()) { + if (mapFaces.Add(expF.Current())) { + nbFaces++; + if (nbFaces > 6) break; + + // Check number of edges in the face + TopoDS_Shape aF = expF.Current(); + TopExp_Explorer expE (aF, TopAbs_EDGE); + nbEdges = 0; + for (; expE.More(); expE.Next()) { + nbEdges++; + if (nbEdges > 4) break; + } + if (nbEdges != 4) break; + } + } + if (nbFaces == 6 && nbEdges == 4) { + BLO.Append(theShape); + } else { + NOT.Append(theShape); + } + } + break; + default: + NOT.Append(theShape); + } +} + +#define REL_NOT_CONNECTED 0 +#define REL_OK 1 +#define REL_NOT_GLUED 2 +#define REL_COLLISION_VV 3 +#define REL_COLLISION_FF 4 +#define REL_COLLISION_EE 5 +#define REL_UNKNOWN 6 + +Standard_Integer BlocksRelation (const TopoDS_Shape& theBlock1, + const TopoDS_Shape& theBlock2) +{ + // Compare bounding boxes before calling BRepExtrema_DistShapeShape + Standard_Real Xmin1, Ymin1, Zmin1, Xmax1, Ymax1, Zmax1; + Standard_Real Xmin2, Ymin2, Zmin2, Xmax2, Ymax2, Zmax2; + 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()) { + return REL_UNKNOWN; + } + + if (dst.Value() > Precision::Confusion()) { + return REL_NOT_CONNECTED; + } + + if (dst.InnerSolution()) { + return REL_COLLISION_VV; + } + + Standard_Integer nbSol = dst.NbSolution(); + Standard_Integer relation = REL_OK; + Standard_Integer nbVerts = 0; + Standard_Integer nbEdges = 0; + Standard_Integer sol = 1; + for (; sol <= nbSol; sol++) { + BRepExtrema_SupportType supp1 = dst.SupportTypeShape1(sol); + BRepExtrema_SupportType supp2 = dst.SupportTypeShape2(sol); + if (supp1 == BRepExtrema_IsVertex && supp2 == BRepExtrema_IsVertex) { + nbVerts++; + } else if (supp1 == BRepExtrema_IsInFace || supp2 == BRepExtrema_IsInFace) { + return REL_COLLISION_FF; + } else if (supp1 == BRepExtrema_IsOnEdge && supp2 == BRepExtrema_IsOnEdge) { + nbEdges++; + } else if ((supp1 == BRepExtrema_IsOnEdge && supp2 == BRepExtrema_IsVertex) || + (supp2 == BRepExtrema_IsOnEdge && supp1 == BRepExtrema_IsVertex)) { + relation = REL_COLLISION_EE; + } else { + } + } + + if (relation != REL_OK) { + return relation; + } + + TColStd_Array1OfInteger vertSol (1, nbVerts); + TopTools_Array1OfShape V1 (1, nbVerts); + TopTools_Array1OfShape V2 (1, nbVerts); + Standard_Integer ivs = 0; + for (sol = 1; sol <= nbSol; sol++) { + if (dst.SupportTypeShape1(sol) == BRepExtrema_IsVertex && + dst.SupportTypeShape2(sol) == BRepExtrema_IsVertex) { + TopoDS_Vertex Vcur = TopoDS::Vertex(dst.SupportOnShape1(sol)); + // Check, that this vertex is far enough from other solution vertices. + Standard_Integer ii = 1; + for (; ii <= ivs; ii++) { + if (BRepTools::Compare(TopoDS::Vertex(V1(ii)), Vcur)) { + continue; + } + } + ivs++; + vertSol(ivs) = sol; + V1(ivs) = Vcur; + V2(ivs) = dst.SupportOnShape2(sol); + } + } + + // As we deal only with quadrangles, + // 2, 3 or 4 vertex solutions can be found. + if (ivs <= 1) { + if (nbEdges > 0) { + return REL_COLLISION_FF; + } + return REL_NOT_CONNECTED; + } + if (ivs > 4) { + return REL_UNKNOWN; + } + + // Check sharing of coincident entities. + if (ivs == 2 || ivs == 3) { + // Map vertices and edges of the blocks + TopTools_IndexedDataMapOfShapeListOfShape MVE1, MVE2; + GEOMImpl_Block6Explorer::MapShapesAndAncestors + (theBlock1, TopAbs_VERTEX, TopAbs_EDGE, MVE1); + GEOMImpl_Block6Explorer::MapShapesAndAncestors + (theBlock2, TopAbs_VERTEX, TopAbs_EDGE, MVE2); + + if (ivs == 2) { + // Find common edge + TopoDS_Shape anEdge1, anEdge2; + GEOMImpl_Block6Explorer::FindEdge(anEdge1, V1(1), V1(2), MVE1); + if (anEdge1.IsNull()) return REL_UNKNOWN; + + GEOMImpl_Block6Explorer::FindEdge(anEdge2, V2(1), V2(2), MVE2); + if (anEdge2.IsNull()) return REL_UNKNOWN; + + if (!anEdge1.IsSame(anEdge2)) return REL_NOT_GLUED; + + } else { // ivs == 3 + // Find common edges + Standard_Integer e1_v1 = 1; + Standard_Integer e1_v2 = 2; + Standard_Integer e2_v1 = 3; + Standard_Integer e2_v2 = 1; + + TopoDS_Shape anEdge11, anEdge12; + GEOMImpl_Block6Explorer::FindEdge(anEdge11, V1(e1_v1), V1(e1_v2), MVE1); + if (anEdge11.IsNull()) { + e1_v2 = 3; + e2_v1 = 2; + GEOMImpl_Block6Explorer::FindEdge(anEdge11, V1(e1_v1), V1(e1_v2), MVE1); + if (anEdge11.IsNull()) return REL_UNKNOWN; + } + GEOMImpl_Block6Explorer::FindEdge(anEdge12, V1(e2_v1), V1(e2_v2), MVE1); + if (anEdge12.IsNull()) { + e2_v2 = 5 - e2_v1; + GEOMImpl_Block6Explorer::FindEdge(anEdge12, V1(e2_v1), V1(e2_v2), MVE1); + if (anEdge12.IsNull()) return REL_UNKNOWN; + } + + TopoDS_Shape anEdge21, anEdge22; + GEOMImpl_Block6Explorer::FindEdge(anEdge21, V2(e1_v1), V2(e1_v2), MVE2); + if (anEdge21.IsNull()) return REL_UNKNOWN; + GEOMImpl_Block6Explorer::FindEdge(anEdge22, V2(e2_v1), V2(e2_v2), MVE2); + if (anEdge22.IsNull()) return REL_UNKNOWN; + + // Check of edges coincidence (with some precision) have to be done here + // if (!anEdge11.IsEqual(anEdge21)) return REL_UNKNOWN; + // if (!anEdge12.IsEqual(anEdge22)) return REL_UNKNOWN; + + // Check of edges sharing + if (!anEdge11.IsSame(anEdge21)) return REL_NOT_GLUED; + if (!anEdge12.IsSame(anEdge22)) return REL_NOT_GLUED; + } + } + + if (ivs == 4) { + // Map vertices and faces of the blocks + TopTools_IndexedDataMapOfShapeListOfShape MVF1, MVF2; + GEOMImpl_Block6Explorer::MapShapesAndAncestors + (theBlock1, TopAbs_VERTEX, TopAbs_FACE, MVF1); + GEOMImpl_Block6Explorer::MapShapesAndAncestors + (theBlock2, TopAbs_VERTEX, TopAbs_FACE, MVF2); + + TopoDS_Shape aFace1, aFace2; + GEOMImpl_Block6Explorer::FindFace(aFace1, V1(1), V1(2), V1(3), V1(4), MVF1); + if (aFace1.IsNull()) return REL_UNKNOWN; + GEOMImpl_Block6Explorer::FindFace(aFace2, V2(1), V2(2), V2(3), V2(4), MVF2); + if (aFace2.IsNull()) return REL_UNKNOWN; + + // Check of faces coincidence (with some precision) have to be done here + // if (!aFace1.IsEqual(aFace2)) return REL_UNKNOWN; + + // Check of faces sharing + if (!aFace1.IsSame(aFace2)) return REL_NOT_GLUED; + } + + return REL_OK; +} + +void FindConnected (const Standard_Integer theBlockIndex, + const TColStd_Array2OfInteger& theRelations, + TColStd_MapOfInteger& theProcessedMap, + TColStd_MapOfInteger& theConnectedMap) +{ + theConnectedMap.Add(theBlockIndex); + theProcessedMap.Add(theBlockIndex); + + Standard_Integer nbBlocks = theRelations.ColLength(); + Standard_Integer col = 1; + for (; col <= nbBlocks; col++) { + if (theRelations(theBlockIndex, col) == REL_OK || + theRelations(theBlockIndex, col) == REL_NOT_GLUED) { + if (!theProcessedMap.Contains(col)) { + FindConnected(col, theRelations, theProcessedMap, theConnectedMap); + } + } + } +} + +Standard_Boolean HasAnyConnection (const Standard_Integer theBlockIndex, + const TColStd_MapOfInteger& theWith, + const TColStd_Array2OfInteger& theRelations, + TColStd_MapOfInteger& theProcessedMap) +{ + theProcessedMap.Add(theBlockIndex); + + Standard_Integer nbBlocks = theRelations.ColLength(); + Standard_Integer col = 1; + for (; col <= nbBlocks; col++) { + if (theRelations(theBlockIndex, col) != REL_NOT_CONNECTED) { + if (!theProcessedMap.Contains(col)) { + if (theWith.Contains(col)) + return Standard_True; + if (HasAnyConnection(col, theWith, theRelations, theProcessedMap)) + return Standard_True; + } + } + } + + return Standard_False; +} + +//============================================================================= +/*! + * 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. Report non-blocks + TopTools_ListOfShape NOT; // Not blocks + TopTools_ListOfShape BLO; // All blocks from the given compound + AddBlocksFrom(aBlockOrComp, BLO, NOT); + + 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())); + } + 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; + } + + // Convert list of blocks into array for easy and fast access + Standard_Integer ibl = 1; + TopTools_Array1OfShape aBlocks (1, nbBlocks); + TopTools_ListIteratorOfListOfShape BLOit (BLO); + for (; BLOit.More(); BLOit.Next(), ibl++) { + aBlocks.SetValue(ibl, BLOit.Value()); + } + + // 2. Find relations between all blocks, + // report connection errors (NOT_GLUED and INVALID_CONNECTION) + TColStd_Array2OfInteger aRelations (1, nbBlocks, 1, nbBlocks); + aRelations.Init(REL_NOT_CONNECTED); + + Standard_Integer row = 1; + for (row = 1; row <= nbBlocks; row++) { + TopoDS_Shape aBlock = aBlocks.Value(row); + + Standard_Integer col = row + 1; + for (; col <= nbBlocks; col++) { + Standard_Integer aRel = BlocksRelation(aBlock, aBlocks.Value(col)); + if (aRel != REL_NOT_CONNECTED) { + aRelations.SetValue(row, col, aRel); + aRelations.SetValue(col, row, aRel); + if (aRel == REL_NOT_GLUED) { + // report connection error + isCompOfBlocks = Standard_False; + BCError anErr; + anErr.error = NOT_GLUED; + anErr.incriminated.push_back(anIndices.FindIndex(aBlocks.Value(row))); + anErr.incriminated.push_back(anIndices.FindIndex(aBlocks.Value(col))); + theErrors.push_back(anErr); + } else if (aRel == REL_COLLISION_VV || + aRel == REL_COLLISION_FF || + aRel == REL_COLLISION_EE || + aRel == REL_UNKNOWN) { + // report connection error + isCompOfBlocks = Standard_False; + BCError anErr; + anErr.error = INVALID_CONNECTION; + anErr.incriminated.push_back(anIndices.FindIndex(aBlocks.Value(row))); + anErr.incriminated.push_back(anIndices.FindIndex(aBlocks.Value(col))); + theErrors.push_back(anErr); + } else { + } + } + } + } + + // 3. Find largest set of connected (good connection or not glued) blocks + TColStd_MapOfInteger aProcessedMap; + TColStd_MapOfInteger aLargestSet; + TColStd_MapOfInteger aCurrentSet; + for (ibl = 1; ibl <= nbBlocks; ibl++) { + if (!aProcessedMap.Contains(ibl)) { + FindConnected(ibl, aRelations, aProcessedMap, aCurrentSet); + if (aCurrentSet.Extent() > aLargestSet.Extent()) { + aLargestSet = aCurrentSet; + } + } + } + + // 4. 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(aBlocks.Value(ibl))); + } + } + } + if (hasIsolated) { + isCompOfBlocks = Standard_False; + theErrors.push_back(anErr); + } + + SetErrorCode(OK); + return isCompOfBlocks; +} + +//============================================================================= +/*! + * PrintBCErrors + */ +//============================================================================= +TCollection_AsciiString GEOMImpl_IBlocksOperations::PrintBCErrors + (Handle(GEOM_Object) theCompound, + const list& theErrors) +{ + TCollection_AsciiString aDescr; + + list::const_iterator errIt = theErrors.begin(); + int i = 0; + for (; errIt != theErrors.end(); i++, errIt++) { + BCError errStruct = *errIt; + + switch (errStruct.error) { + case NOT_BLOCK: + aDescr += "\nNot a Blocks: "; + break; + case INVALID_CONNECTION: + aDescr += "\nInvalid connection between two blocks: "; + break; + case NOT_CONNECTED: + aDescr += "\nBlocks, not connected with main body: "; + break; + case NOT_GLUED: + aDescr += "\nNot glued blocks: "; + break; + default: + break; + } + + list sshList = errStruct.incriminated; + list::iterator sshIt = sshList.begin(); + int jj = 0; + for (; sshIt != sshList.end(); jj++, sshIt++) { + if (jj > 0) + aDescr += ", "; + aDescr += TCollection_AsciiString(*sshIt); + } + } + + return aDescr; +} + +//============================================================================= +/*! + * ExplodeCompoundOfBlocks + */ +//============================================================================= +Handle(TColStd_HSequenceOfTransient) GEOMImpl_IBlocksOperations::ExplodeCompoundOfBlocks + (Handle(GEOM_Object) theCompound, + const Standard_Integer theMinNbFaces, + const Standard_Integer theMaxNbFaces) +{ + SetErrorCode(KO); + + if (theCompound.IsNull()) return NULL; + TopoDS_Shape aBlockOrComp = theCompound->GetValue(); + if (aBlockOrComp.IsNull()) return NULL; + + Handle(TColStd_HSequenceOfTransient) aBlocks = new TColStd_HSequenceOfTransient; + Handle(GEOM_Object) anObj; + Handle(GEOM_Function) aFunction; + + TopTools_MapOfShape mapShape; + TCollection_AsciiString anAsciiList = "[", anEntry; + + // Map shapes + TopTools_IndexedMapOfShape anIndices; + TopExp::MapShapes(aBlockOrComp, anIndices); + Handle(TColStd_HArray1OfInteger) anArray; + + // Explode + try { + TopExp_Explorer exp (aBlockOrComp, TopAbs_SOLID); + for (; exp.More(); exp.Next()) { + if (mapShape.Add(exp.Current())) { + TopoDS_Shape aSolid = exp.Current(); + + TopTools_MapOfShape mapFaces; + TopExp_Explorer expF (aSolid, TopAbs_FACE); + Standard_Integer nbFaces = 0; + for (; expF.More(); expF.Next()) { + if (mapFaces.Add(expF.Current())) { + nbFaces++; + } + } + + if (theMinNbFaces <= nbFaces && nbFaces <= theMaxNbFaces) { + anArray = new TColStd_HArray1OfInteger(1,1); + anArray->SetValue(1, anIndices.FindIndex(aSolid)); + anObj = GetEngine()->AddSubShape(theCompound, anArray); + aBlocks->Append(anObj); + + //Make a Python command + TDF_Tool::Entry(anObj->GetEntry(), anEntry); + anAsciiList += anEntry; + anAsciiList += ","; + } + } + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return aBlocks; + } + + if (aBlocks->IsEmpty()) { + SetErrorCode("There are no specified blocks in the given shape"); + return aBlocks; + } + + anAsciiList.Trunc(anAsciiList.Length() - 1); + anAsciiList += "]"; + + //The explode doesn't change object so no new function is required. + aFunction = theCompound->GetLastFunction(); + + //Make a Python command + TCollection_AsciiString aDescr (anAsciiList); + aDescr += " = IBlocksOperations.ExplodeCompoundOfBlocks("; + TDF_Tool::Entry(theCompound->GetEntry(), anEntry); + aDescr += anEntry + ", "; + aDescr += TCollection_AsciiString(theMinNbFaces) + ", "; + aDescr += TCollection_AsciiString(theMaxNbFaces) + ")"; + + TCollection_AsciiString aNewDescr = aFunction->GetDescription() + "\n"; + aNewDescr += aDescr; + aFunction->SetDescription(aNewDescr); + + SetErrorCode(OK); + return aBlocks; +} + +//============================================================================= +/*! + * GetBlockNearPoint + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetBlockNearPoint + (Handle(GEOM_Object) theCompound, + Handle(GEOM_Object) thePoint) +{ + SetErrorCode(KO); + + //New object + Handle(GEOM_Object) aResult; + + // Arguments + if (theCompound.IsNull() || thePoint.IsNull()) return NULL; + + TopoDS_Shape aBlockOrComp = theCompound->GetValue(); + if (aBlockOrComp.IsNull()) { + SetErrorCode("Compound is null"); + return NULL; + } + if (aBlockOrComp.ShapeType() != TopAbs_COMPOUND && + aBlockOrComp.ShapeType() != TopAbs_COMPSOLID) { + SetErrorCode("Shape is neither a block, nor a compound of blocks"); + return NULL; + } + + TopoDS_Shape anArg = thePoint->GetValue(); + if (anArg.IsNull()) { + SetErrorCode("Null shape is given as argument"); + return NULL; + } + if (anArg.ShapeType() != TopAbs_VERTEX) { + SetErrorCode("Element 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); + + // 1. Explode compound on blocks + TopTools_MapOfShape mapShape; + Standard_Integer nbSolids = 0; + TopExp_Explorer exp (aBlockOrComp, TopAbs_SOLID); + for (; exp.More(); exp.Next()) { + if (mapShape.Add(exp.Current())) { + nbSolids++; + } + } + + 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; + + // 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; + } + 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 { + } + } + if (nbFound > 1) { + if (nearest == 0) { + // The point is on boundary of some blocks and there are + // no blocks, having the point inside their volume + SetErrorCode("Multiple blocks near the given point are found"); + return NULL; + + } else if (nearest == 1) { + // The point is outside some blocks and there are + // 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)); + if (!aDistTool.IsDone()) { + SetErrorCode("Can not find a distance from the given point to one of blocks"); + return NULL; + } + Standard_Real aDist = aDistTool.Value(); + if (aDist < minDist) { + minDist = aDist; + aShape = aSolids(ind); + } + } + } + } 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); + } + } + } + } + } + + if (nbFound == 0) { + SetErrorCode("There are no blocks near the given point"); + return NULL; + } else { + TopTools_IndexedMapOfShape anIndices; + TopExp::MapShapes(aBlockOrComp, anIndices); + Handle(TColStd_HArray1OfInteger) anArray = new TColStd_HArray1OfInteger(1,1); + anArray->SetValue(1, anIndices.FindIndex(aShape)); + aResult = GetEngine()->AddSubShape(theCompound, anArray); + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //The GetBlockNearPoint() doesn't change object so no new function is required. + Handle(GEOM_Function) aFunction = theCompound->GetLastFunction(); + + //Make a Python command + TCollection_AsciiString anEntry, aDescr; + TDF_Tool::Entry(aResult->GetEntry(), anEntry); + aDescr += anEntry + " = IBlocksOperations.GetBlockNearPoint("; + TDF_Tool::Entry(theCompound->GetEntry(), anEntry); + aDescr += anEntry + ", "; + TDF_Tool::Entry(thePoint->GetEntry(), anEntry); + aDescr += anEntry + ")"; + + TCollection_AsciiString aNewDescr = aFunction->GetDescription() + "\n"; + aNewDescr += aDescr; + aFunction->SetDescription(aNewDescr); + + SetErrorCode(OK); + return aResult; +} + +//============================================================================= +/*! + * GetBlockByParts + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetBlockByParts + (Handle(GEOM_Object) theCompound, + const Handle(TColStd_HSequenceOfTransient)& theParts) +{ + SetErrorCode(KO); + + Handle(GEOM_Object) aResult; + + if (theCompound.IsNull() || theParts.IsNull()) return NULL; + TopoDS_Shape aBlockOrComp = theCompound->GetValue(); + if (aBlockOrComp.IsNull()) return NULL; + + //Get the parts + Standard_Integer argi, aLen = theParts->Length(); + TopTools_Array1OfShape anArgs (1, aLen); + TCollection_AsciiString anEntry, aPartsDescr; + for (argi = 1; argi <= aLen; argi++) { + Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(theParts->Value(argi)); + Handle(GEOM_Function) aRef = anObj->GetLastFunction(); + if (aRef.IsNull()) return NULL; + + TopoDS_Shape anArg = aRef->GetValue(); + if (anArg.IsNull()) { + SetErrorCode("Null shape is given as argument"); + return NULL; + } + anArgs(argi) = anArg; + + // For Python command + TDF_Tool::Entry(anObj->GetEntry(), anEntry); + if (argi > 1) aPartsDescr += ", "; + aPartsDescr += anEntry; + } + + //Compute the Block value + try { + // 1. Explode compound on solids + TopTools_MapOfShape mapShape; + Standard_Integer nbSolids = 0; + TopExp_Explorer exp (aBlockOrComp, TopAbs_SOLID); + for (; exp.More(); exp.Next()) { + if (mapShape.Add(exp.Current())) { + nbSolids++; + } + } + + mapShape.Clear(); + Standard_Integer ind = 1; + TopTools_Array1OfShape aSolids (1, nbSolids); + TColStd_Array1OfInteger aNbParts (1, nbSolids); + for (exp.Init(aBlockOrComp, TopAbs_SOLID); exp.More(); exp.Next(), ind++) { + if (mapShape.Add(exp.Current())) { + TopoDS_Shape aSolid = exp.Current(); + aSolids(ind) = aSolid; + aNbParts(ind) = 0; + + // 2. Define quantity of parts, contained in each solid + TopTools_IndexedMapOfShape aSubShapes; + TopExp::MapShapes(aSolid, aSubShapes); + for (argi = 1; argi <= aLen; argi++) { + if (aSubShapes.Contains(anArgs(argi))) { + aNbParts(ind)++; + } + } + } + } + + // 3. Define solid, containing maximum quantity of parts + Standard_Integer maxNb = 0, nbFound = 0; + TopoDS_Shape aShape; + for (ind = 1; ind <= nbSolids; ind++) { + if (aNbParts(ind) > maxNb) { + maxNb = aNbParts(ind); + aShape = aSolids(ind); + nbFound = 1; + } else if (aNbParts(ind) == maxNb) { + nbFound++; + } else { + } + } + if (nbFound > 1) { + SetErrorCode("Multiple blocks, containing maximum quantity of the given parts, are found"); + return NULL; + } else if (nbFound == 0) { + SetErrorCode("There are no blocks, containing the given parts"); + return NULL; + } else { + TopTools_IndexedMapOfShape anIndices; + TopExp::MapShapes(aBlockOrComp, anIndices); + Handle(TColStd_HArray1OfInteger) anArray = new TColStd_HArray1OfInteger(1,1); + anArray->SetValue(1, anIndices.FindIndex(aShape)); + aResult = GetEngine()->AddSubShape(theCompound, anArray); + } + } catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //The GetBlockByParts() doesn't change object so no new function is required. + Handle(GEOM_Function) aFunction = theCompound->GetLastFunction(); + + //Make a Python command + TDF_Tool::Entry(aResult->GetEntry(), anEntry); + TCollection_AsciiString aDescr (anEntry); + aDescr += " = IBlocksOperations.GetBlockByParts("; + TDF_Tool::Entry(theCompound->GetEntry(), anEntry); + aDescr += anEntry + ", ["; + aDescr += aPartsDescr + "])"; + + TCollection_AsciiString aNewDescr = aFunction->GetDescription() + "\n"; + aNewDescr += aDescr; + aFunction->SetDescription(aNewDescr); + + SetErrorCode(OK); + return aResult; +} + +//============================================================================= +/*! + * GetBlocksByParts + */ +//============================================================================= +Handle(TColStd_HSequenceOfTransient) GEOMImpl_IBlocksOperations::GetBlocksByParts + (Handle(GEOM_Object) theCompound, + const Handle(TColStd_HSequenceOfTransient)& theParts) +{ + SetErrorCode(KO); + + if (theCompound.IsNull() || theParts.IsNull()) return NULL; + TopoDS_Shape aBlockOrComp = theCompound->GetValue(); + if (aBlockOrComp.IsNull()) return NULL; + + Handle(TColStd_HSequenceOfTransient) aBlocks = new TColStd_HSequenceOfTransient; + Handle(GEOM_Object) anObj; + Handle(GEOM_Function) aFunction; + + //Get the parts + Standard_Integer argi, aLen = theParts->Length(); + TopTools_Array1OfShape anArgs (1, aLen); + TCollection_AsciiString anEntry, aPartsDescr, anAsciiList = "["; + for (argi = 1; argi <= aLen; argi++) { + Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(theParts->Value(argi)); + Handle(GEOM_Function) aRef = anObj->GetLastFunction(); + if (aRef.IsNull()) return NULL; + + TopoDS_Shape anArg = aRef->GetValue(); + if (anArg.IsNull()) { + SetErrorCode("Null shape is given as argument"); + return NULL; + } + anArgs(argi) = anArg; + + // For Python command + TDF_Tool::Entry(anObj->GetEntry(), anEntry); + if (argi > 1) aPartsDescr += ", "; + aPartsDescr += anEntry; + } + + //Get the Blocks + try { + TopTools_MapOfShape mapShape; + Standard_Integer nbSolids = 0; + TopExp_Explorer exp (aBlockOrComp, TopAbs_SOLID); + for (; exp.More(); exp.Next()) { + if (mapShape.Add(exp.Current())) { + nbSolids++; + } + } + + mapShape.Clear(); + Standard_Integer ind = 1; + TopTools_Array1OfShape aSolids (1, nbSolids); + TColStd_Array1OfInteger aNbParts (1, nbSolids); + for (exp.Init(aBlockOrComp, TopAbs_SOLID); exp.More(); exp.Next(), ind++) { + if (mapShape.Add(exp.Current())) { + TopoDS_Shape aSolid = exp.Current(); + aSolids(ind) = aSolid; + aNbParts(ind) = 0; + + // 2. Define quantity of parts, contained in each solid + TopTools_IndexedMapOfShape aSubShapes; + TopExp::MapShapes(aSolid, aSubShapes); + for (argi = 1; argi <= aLen; argi++) { + if (aSubShapes.Contains(anArgs(argi))) { + aNbParts(ind)++; + } + } + } + } + + // 3. Define solid, containing maximum quantity of parts + Standard_Integer maxNb = 0, nbFound = 0; + for (ind = 1; ind <= nbSolids; ind++) { + if (aNbParts(ind) > maxNb) { + maxNb = aNbParts(ind); + nbFound = 1; + } else if (aNbParts(ind) == maxNb) { + nbFound++; + } else { + } + } + if (nbFound == 0) { + SetErrorCode("There are no blocks, containing the given parts"); + return NULL; + } + + // Map shapes + TopTools_IndexedMapOfShape anIndices; + TopExp::MapShapes(aBlockOrComp, anIndices); + Handle(TColStd_HArray1OfInteger) anArray; + + for (ind = 1; ind <= nbSolids; ind++) { + if (aNbParts(ind) == maxNb) { + anArray = new TColStd_HArray1OfInteger(1,1); + anArray->SetValue(1, anIndices.FindIndex(aSolids(ind))); + anObj = GetEngine()->AddSubShape(theCompound, anArray); + aBlocks->Append(anObj); + + //Make a Python command + TDF_Tool::Entry(anObj->GetEntry(), anEntry); + anAsciiList += anEntry; + anAsciiList += ","; + } + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + anAsciiList.Trunc(anAsciiList.Length() - 1); + anAsciiList += "]"; + + //The GetBlocksByParts() doesn't change object so no new function is required. + aFunction = theCompound->GetLastFunction(); + + //Make a Python command + TCollection_AsciiString aDescr (anAsciiList); + aDescr += " = IBlocksOperations.GetBlocksByParts("; + TDF_Tool::Entry(theCompound->GetEntry(), anEntry); + aDescr += anEntry + ", ["; + aDescr += aPartsDescr + "])"; + + TCollection_AsciiString aNewDescr = aFunction->GetDescription() + "\n"; + aNewDescr += aDescr; + aFunction->SetDescription(aNewDescr); + + SetErrorCode(OK); + return aBlocks; +} + +//============================================================================= +/*! + * MakeMultiTransformation1D + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IBlocksOperations::MakeMultiTransformation1D + (Handle(GEOM_Object) theObject, + const Standard_Integer theDirFace1, + const Standard_Integer theDirFace2, + const Standard_Integer theNbTimes) +{ + 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 moved + + //Add a new Copy object + Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), GEOM_COPY); + + //Add a translate function + Handle(GEOM_Function) aFunction = + aCopy->AddFunction(GEOMImpl_BlockDriver::GetID(), BLOCK_MULTI_TRANSFORM_1D); + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_BlockDriver::GetID()) return NULL; + + GEOMImpl_IBlockTrsf aTI (aFunction); + aTI.SetOriginal(aLastFunction); + aTI.SetFace1U(theDirFace1); + aTI.SetFace2U(theDirFace2); + aTI.SetNbIterU(theNbTimes); + + //Compute the transformation + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Block driver failed to make multi-transformation"); + 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.MakeMultiTransformation1D("; + TDF_Tool::Entry(theObject->GetEntry(), anEntry); + aDescr += anEntry + ", "; + aDescr += TCollection_AsciiString(theDirFace1) + ", "; + aDescr += TCollection_AsciiString(theDirFace2) + ", "; + aDescr += TCollection_AsciiString(theNbTimes) + ") "; + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aCopy; +} + +//============================================================================= +/*! + * MakeMultiTransformation2D + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IBlocksOperations::MakeMultiTransformation2D + (Handle(GEOM_Object) theObject, + const Standard_Integer theDirFace1U, + const Standard_Integer theDirFace2U, + const Standard_Integer theNbTimesU, + const Standard_Integer theDirFace1V, + const Standard_Integer theDirFace2V, + const Standard_Integer theNbTimesV) +{ + 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 moved + + //Add a new Copy object + Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), GEOM_COPY); + + //Add a translate function + Handle(GEOM_Function) aFunction = + aCopy->AddFunction(GEOMImpl_BlockDriver::GetID(), BLOCK_MULTI_TRANSFORM_2D); + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_BlockDriver::GetID()) return NULL; + + GEOMImpl_IBlockTrsf aTI (aFunction); + aTI.SetOriginal(aLastFunction); + aTI.SetFace1U(theDirFace1U); + aTI.SetFace2U(theDirFace2U); + aTI.SetNbIterU(theNbTimesU); + aTI.SetFace1V(theDirFace1V); + aTI.SetFace2V(theDirFace2V); + aTI.SetNbIterV(theNbTimesV); + + //Compute the transformation + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Block driver failed to make multi-transformation"); + 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.MakeMultiTransformation2D("; + TDF_Tool::Entry(theObject->GetEntry(), anEntry); + aDescr += anEntry + ", "; + aDescr += TCollection_AsciiString(theDirFace1U) + ", "; + aDescr += TCollection_AsciiString(theDirFace2U) + ", "; + aDescr += TCollection_AsciiString(theNbTimesU) + ", "; + aDescr += TCollection_AsciiString(theDirFace1V) + ", "; + aDescr += TCollection_AsciiString(theDirFace2V) + ", "; + aDescr += TCollection_AsciiString(theNbTimesV) + ") "; + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aCopy; +} diff --git a/src/GEOMImpl/GEOMImpl_IBlocksOperations.hxx b/src/GEOMImpl/GEOMImpl_IBlocksOperations.hxx new file mode 100644 index 000000000..1ea16a053 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_IBlocksOperations.hxx @@ -0,0 +1,136 @@ + +#ifndef _GEOMImpl_IBlocksOperations_HXX_ +#define _GEOMImpl_IBlocksOperations_HXX_ + +#include "GEOM_IOperations.hxx" + +#include +#include + +#include + +class GEOM_Engine; +class Handle(GEOM_Object); +class Handle(TColStd_HArray1OfInteger); + +class GEOMImpl_IBlocksOperations : public GEOM_IOperations { + public: + GEOMImpl_IBlocksOperations(GEOM_Engine* theEngine, int theDocID); + ~GEOMImpl_IBlocksOperations(); + + // Creation of blocks and block faces + Handle(GEOM_Object) MakeQuad (Handle(GEOM_Object) theEdge1, + Handle(GEOM_Object) theEdge2, + Handle(GEOM_Object) theEdge3, + Handle(GEOM_Object) theEdge4); + + Handle(GEOM_Object) MakeQuad2Edges (Handle(GEOM_Object) theEdge1, + Handle(GEOM_Object) theEdge2); + + Handle(GEOM_Object) MakeQuad4Vertices (Handle(GEOM_Object) thePoint1, + Handle(GEOM_Object) thePoint2, + Handle(GEOM_Object) thePoint3, + Handle(GEOM_Object) thePoint4); + + Handle(GEOM_Object) MakeHexa (Handle(GEOM_Object) theFace1, + Handle(GEOM_Object) theFace2, + Handle(GEOM_Object) theFace3, + Handle(GEOM_Object) theFace4, + Handle(GEOM_Object) theFace5, + Handle(GEOM_Object) theFace6); + + Handle(GEOM_Object) MakeHexa2Faces (Handle(GEOM_Object) theFace1, + Handle(GEOM_Object) theFace2); + + Handle(GEOM_Object) MakeBlockCompound (Handle(GEOM_Object) theCompound); + + // Extract elements of blocks and blocks compounds + Handle(GEOM_Object) GetPoint (Handle(GEOM_Object) theShape, + const Standard_Real theX, + const Standard_Real theY, + const Standard_Real theZ, + const Standard_Real theEpsilon); + + Handle(GEOM_Object) GetEdge (Handle(GEOM_Object) theShape, + Handle(GEOM_Object) thePoint1, + Handle(GEOM_Object) thePoint2); + + Handle(GEOM_Object) GetEdgeNearPoint (Handle(GEOM_Object) theBlock, + Handle(GEOM_Object) thePoint); + + Handle(GEOM_Object) GetFaceByPoints (Handle(GEOM_Object) theShape, + Handle(GEOM_Object) thePoint1, + Handle(GEOM_Object) thePoint2, + Handle(GEOM_Object) thePoint3, + Handle(GEOM_Object) thePoint4); + + Handle(GEOM_Object) GetFaceByEdges (Handle(GEOM_Object) theShape, + Handle(GEOM_Object) theEdge1, + Handle(GEOM_Object) theEdge2); + + Handle(GEOM_Object) GetOppositeFace (Handle(GEOM_Object) theBlock, + Handle(GEOM_Object) theFace); + + Handle(GEOM_Object) GetFaceNearPoint (Handle(GEOM_Object) theBlock, + Handle(GEOM_Object) thePoint); + + Handle(GEOM_Object) GetFaceByNormale (Handle(GEOM_Object) theBlock, + Handle(GEOM_Object) theVector); + + // Check blocks compounds + Standard_Boolean IsCompoundOfBlocks (Handle(GEOM_Object) theCompound, + const Standard_Integer theMinNbFaces, + const Standard_Integer theMaxNbFaces, + Standard_Integer& theNbBlocks); + + enum BCErrorType { + NOT_BLOCK, + INVALID_CONNECTION, + NOT_CONNECTED, + NOT_GLUED + }; + + struct BCError { + BCErrorType error; + list incriminated; + }; + + Standard_Boolean CheckCompoundOfBlocks (Handle(GEOM_Object) theCompound, + list& theErrors); + + TCollection_AsciiString PrintBCErrors (Handle(GEOM_Object) theCompound, + const list& theErrors); + + // Extract blocks from blocks compounds + Handle(TColStd_HSequenceOfTransient) ExplodeCompoundOfBlocks + (Handle(GEOM_Object) theCompound, + const Standard_Integer theMinNbFaces, + const Standard_Integer theMaxNbFaces); + + Handle(GEOM_Object) GetBlockNearPoint (Handle(GEOM_Object) theCompound, + Handle(GEOM_Object) thePoint); + + Handle(GEOM_Object) GetBlockByParts + (Handle(GEOM_Object) theCompound, + const Handle(TColStd_HSequenceOfTransient)& theParts); + + Handle(TColStd_HSequenceOfTransient) GetBlocksByParts + (Handle(GEOM_Object) theCompound, + const Handle(TColStd_HSequenceOfTransient)& theParts); + + // Operations on blocks with gluing of result + Handle(GEOM_Object) MakeMultiTransformation1D (Handle(GEOM_Object) theBlock, + const Standard_Integer theDirFace1, + const Standard_Integer theDirFace2, + const Standard_Integer theNbTimes); + + Handle(GEOM_Object) MakeMultiTransformation2D (Handle(GEOM_Object) theBlock, + const Standard_Integer theDirFace1U, + const Standard_Integer theDirFace2U, + const Standard_Integer theNbTimesU, + const Standard_Integer theDirFace1V, + const Standard_Integer theDirFace2V, + const Standard_Integer theNbTimesV); +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_IBoolean.hxx b/src/GEOMImpl/GEOMImpl_IBoolean.hxx new file mode 100644 index 000000000..8668bf9b8 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_IBoolean.hxx @@ -0,0 +1,24 @@ +//NOTE: This is an intreface to a function for the Common, Cut and Fuse creation. + + +#include "GEOM_Function.hxx" + +#define BOOL_ARG_SHAPE1 1 +#define BOOL_ARG_SHAPE2 2 + +class GEOMImpl_IBoolean +{ + public: + + GEOMImpl_IBoolean(Handle(GEOM_Function) theFunction): _func(theFunction) {} + + void SetShape1(Handle(GEOM_Function) theRef) { _func->SetReference(BOOL_ARG_SHAPE1, theRef); } + void SetShape2(Handle(GEOM_Function) theRef) { _func->SetReference(BOOL_ARG_SHAPE2, theRef); } + + Handle(GEOM_Function) GetShape1() { return _func->GetReference(BOOL_ARG_SHAPE1); } + Handle(GEOM_Function) GetShape2() { return _func->GetReference(BOOL_ARG_SHAPE2); } + + private: + + Handle(GEOM_Function) _func; +}; diff --git a/src/GEOMImpl/GEOMImpl_IBooleanOperations.cxx b/src/GEOMImpl/GEOMImpl_IBooleanOperations.cxx new file mode 100644 index 000000000..ad6fba6f4 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_IBooleanOperations.cxx @@ -0,0 +1,351 @@ +using namespace std; + +#include "GEOMImpl_IBooleanOperations.hxx" + +#include "GEOM_Function.hxx" +#include "GEOMImpl_Types.hxx" + +#include "GEOMImpl_BooleanDriver.hxx" +#include "GEOMImpl_IBoolean.hxx" + +#include "GEOMImpl_PartitionDriver.hxx" +#include "GEOMImpl_IPartition.hxx" + +#include + +#include "utilities.h" + +#include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC + +//============================================================================= +/*! + * constructor: + */ +//============================================================================= +GEOMImpl_IBooleanOperations::GEOMImpl_IBooleanOperations (GEOM_Engine* theEngine, int theDocID) +: GEOM_IOperations(theEngine, theDocID) +{ + MESSAGE("GEOMImpl_IBooleanOperations::GEOMImpl_IBooleanOperations"); +} + +//============================================================================= +/*! + * destructor + */ +//============================================================================= +GEOMImpl_IBooleanOperations::~GEOMImpl_IBooleanOperations() +{ + MESSAGE("GEOMImpl_IBooleanOperations::~GEOMImpl_IBooleanOperations"); +} + + +//============================================================================= +/*! + * MakeBoolean + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakeBoolean (Handle(GEOM_Object) theShape1, + Handle(GEOM_Object) theShape2, + Standard_Integer theOp) +{ + SetErrorCode(KO); + + if (theShape1.IsNull() || theShape2.IsNull()) return NULL; + + //Add a new Boolean object + Handle(GEOM_Object) aBool = GetEngine()->AddObject(GetDocID(), GEOM_BOOLEAN); + + //Add a new Boolean function + Handle(GEOM_Function) aFunction; + if (theOp == 1) { + aFunction = aBool->AddFunction(GEOMImpl_BooleanDriver::GetID(), BOOLEAN_COMMON); + } else if (theOp == 2) { + aFunction = aBool->AddFunction(GEOMImpl_BooleanDriver::GetID(), BOOLEAN_CUT); + } else if (theOp == 3) { + aFunction = aBool->AddFunction(GEOMImpl_BooleanDriver::GetID(), BOOLEAN_FUSE); + } else if (theOp == 4) { + aFunction = aBool->AddFunction(GEOMImpl_BooleanDriver::GetID(), BOOLEAN_SECTION); + } else { + } + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_BooleanDriver::GetID()) return NULL; + + GEOMImpl_IBoolean aCI (aFunction); + + Handle(GEOM_Function) aRef1 = theShape1->GetLastFunction(); + Handle(GEOM_Function) aRef2 = theShape2->GetLastFunction(); + + if (aRef1.IsNull() || aRef2.IsNull()) return NULL; + + aCI.SetShape1(aRef1); + aCI.SetShape2(aRef2); + + //Compute the Boolean value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Boolean driver failed"); + 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(aBool->GetEntry(), anEntry); + aDescr += anEntry; + aDescr += " = IBooleanOperations.MakeBoolean("; + TDF_Tool::Entry(theShape1->GetEntry(), anEntry); + aDescr += (anEntry+", "); + TDF_Tool::Entry(theShape2->GetEntry(), anEntry); + aDescr += (anEntry+", "); + aDescr += (TCollection_AsciiString(theOp)+")"); + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aBool; +} + +//============================================================================= +/*! + * MakePartition + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakePartition + (const Handle(TColStd_HSequenceOfTransient)& theShapes, + const Handle(TColStd_HSequenceOfTransient)& theTools, + const Handle(TColStd_HSequenceOfTransient)& theKeepIns, + const Handle(TColStd_HSequenceOfTransient)& theRemoveIns, + const Standard_Integer theLimit, + const Standard_Boolean theRemoveWebs, + const Handle(TColStd_HArray1OfInteger)& theMaterials) +{ + SetErrorCode(KO); + + //Add a new Partition object + Handle(GEOM_Object) aPartition = GetEngine()->AddObject(GetDocID(), GEOM_PARTITION); + + //Add a new Partition function + Handle(GEOM_Function) aFunction = + aPartition->AddFunction(GEOMImpl_PartitionDriver::GetID(), PARTITION_PARTITION); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_PartitionDriver::GetID()) return NULL; + + GEOMImpl_IPartition aCI (aFunction); + +// int aLen = theShapes.size(); +// aCI.SetLength(aLen); + + Handle(TColStd_HSequenceOfTransient) aShapesSeq = new TColStd_HSequenceOfTransient; + Handle(TColStd_HSequenceOfTransient) aToolsSeq = new TColStd_HSequenceOfTransient; + Handle(TColStd_HSequenceOfTransient) aKeepInsSeq = new TColStd_HSequenceOfTransient; + Handle(TColStd_HSequenceOfTransient) aRemInsSeq = new TColStd_HSequenceOfTransient; + + Standard_Integer ind, aLen; + TCollection_AsciiString anEntry; + TCollection_AsciiString aShapesDescr, aToolsDescr, aKeepInsDescr, aRemoveInsDescr; + + // Shapes + aLen = theShapes->Length(); + for (ind = 1; ind <= aLen; ind++) { + Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(theShapes->Value(ind)); + Handle(GEOM_Function) aRefSh = anObj->GetLastFunction(); + if (aRefSh.IsNull()) { + SetErrorCode("NULL shape for Partition"); + return NULL; + } + aShapesSeq->Append(aRefSh); + + // For Python command + TDF_Tool::Entry(anObj->GetEntry(), anEntry); + if (ind > 1) aShapesDescr += ", "; + aShapesDescr += anEntry; + } + aCI.SetShapes(aShapesSeq); + + // Tools + aLen = theTools->Length(); + for (ind = 1; ind <= aLen; ind++) { + Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(theTools->Value(ind)); + Handle(GEOM_Function) aRefSh = anObj->GetLastFunction(); + if (aRefSh.IsNull()) { + SetErrorCode("NULL tool shape for Partition"); + return NULL; + } + aToolsSeq->Append(aRefSh); + + // For Python command + TDF_Tool::Entry(anObj->GetEntry(), anEntry); + if (ind > 1) aToolsDescr += ", "; + aToolsDescr += anEntry; + } + aCI.SetTools(aToolsSeq); + + // Keep Inside + aLen = theKeepIns->Length(); + for (ind = 1; ind <= aLen; ind++) { + Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(theKeepIns->Value(ind)); + Handle(GEOM_Function) aRefSh = anObj->GetLastFunction(); + if (aRefSh.IsNull()) { + SetErrorCode("NULL shape for Partition"); + return NULL; + } + aKeepInsSeq->Append(aRefSh); + + // For Python command + TDF_Tool::Entry(anObj->GetEntry(), anEntry); + if (ind > 1) aKeepInsDescr += ", "; + aKeepInsDescr += anEntry; + } + aCI.SetKeepIns(aKeepInsSeq); + + // Remove Inside + aLen = theRemoveIns->Length(); + for (ind = 1; ind <= aLen; ind++) { + Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(theRemoveIns->Value(ind)); + Handle(GEOM_Function) aRefSh = anObj->GetLastFunction(); + if (aRefSh.IsNull()) { + SetErrorCode("NULL shape for Partition"); + return NULL; + } + aRemInsSeq->Append(aRefSh); + + // For Python command + TDF_Tool::Entry(anObj->GetEntry(), anEntry); + if (ind > 1) aRemoveInsDescr += ", "; + aRemoveInsDescr += anEntry; + } + aCI.SetRemoveIns(aRemInsSeq); + + // Limit + aCI.SetLimit(theLimit); + + // Materials + if (theRemoveWebs) { + if (theMaterials.IsNull()) { + Handle(TColStd_HArray1OfInteger) aMaterials = + new TColStd_HArray1OfInteger (1, aShapesSeq->Length()); + aCI.SetMaterials(aMaterials); + } else { + aCI.SetMaterials(theMaterials); + } + } + + //Compute the Partition + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Partition driver failed"); + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + TCollection_AsciiString aDescr; + TDF_Tool::Entry(aPartition->GetEntry(), anEntry); + aDescr += anEntry; + aDescr += " = IBooleanOperations.MakePartition(["; + // Shapes + aDescr += aShapesDescr + "], ["; + // Tools + aDescr += aToolsDescr + "], ["; + // Keep Ins + aDescr += aKeepInsDescr + "], ["; + // Remove Ins + aDescr += aRemoveInsDescr + "], "; + // Limit + aDescr += TCollection_AsciiString(theLimit) + ", "; + // Remove Webs + if (theRemoveWebs) aDescr += "1, ["; + else aDescr += "0, ["; + // Materials + if (theMaterials->Length() > 0) { + int i = theMaterials->Lower(); + aDescr += TCollection_AsciiString(theMaterials->Value(i)); + i++; + for (; i <= theMaterials->Upper(); i++) { + aDescr += ", "; + aDescr += TCollection_AsciiString(theMaterials->Value(i)); + } + } + aDescr += "])"; + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aPartition; +} + +//============================================================================= +/*! + * MakeHalfPartition + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IBooleanOperations::MakeHalfPartition + (Handle(GEOM_Object) theShape, Handle(GEOM_Object) thePlane) +{ + SetErrorCode(KO); + + if (theShape.IsNull() || thePlane.IsNull()) return NULL; + + //Add a new Boolean object + Handle(GEOM_Object) aPart = GetEngine()->AddObject(GetDocID(), GEOM_BOOLEAN); + + //Add a new Partition function + Handle(GEOM_Function) aFunction = + aPart->AddFunction(GEOMImpl_PartitionDriver::GetID(), PARTITION_HALF); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_PartitionDriver::GetID()) return NULL; + + GEOMImpl_IPartition aCI (aFunction); + + Handle(GEOM_Function) aRef1 = theShape->GetLastFunction(); + Handle(GEOM_Function) aRef2 = thePlane->GetLastFunction(); + + if (aRef1.IsNull() || aRef2.IsNull()) return NULL; + + aCI.SetShape(aRef1); + aCI.SetPlane(aRef2); + + //Compute the Partition value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Partition driver failed"); + 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(aPart->GetEntry(), anEntry); + aDescr += anEntry; + aDescr += " = IBooleanOperations.MakePartition("; + TDF_Tool::Entry(theShape->GetEntry(), anEntry); + aDescr += (anEntry+", "); + TDF_Tool::Entry(thePlane->GetEntry(), anEntry); + aDescr += (anEntry+")"); + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aPart; +} diff --git a/src/GEOMImpl/GEOMImpl_IBooleanOperations.hxx b/src/GEOMImpl/GEOMImpl_IBooleanOperations.hxx new file mode 100644 index 000000000..baebc89e0 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_IBooleanOperations.hxx @@ -0,0 +1,36 @@ + +#ifndef _GEOMImpl_IBooleanOperations_HXX_ +#define _GEOMImpl_IBooleanOperations_HXX_ + +#include "GEOM_IOperations.hxx" + +//#include "TColStd_HSequenceOfTransient.hxx" + +#include "list" + +class GEOM_Engine; +class Handle(GEOM_Object); +class Handle(TColStd_HArray1OfInteger); + +class GEOMImpl_IBooleanOperations : public GEOM_IOperations { + public: + GEOMImpl_IBooleanOperations(GEOM_Engine* theEngine, int theDocID); + ~GEOMImpl_IBooleanOperations(); + + Handle(GEOM_Object) MakeBoolean (Handle(GEOM_Object) theShape1, + Handle(GEOM_Object) theShape2, + Standard_Integer theOp); + + Handle(GEOM_Object) MakePartition (const Handle(TColStd_HSequenceOfTransient)& theShapes, + const Handle(TColStd_HSequenceOfTransient)& theTools, + const Handle(TColStd_HSequenceOfTransient)& theKeepInside, + const Handle(TColStd_HSequenceOfTransient)& theRemoveInside, + const Standard_Integer theLimit, + const Standard_Boolean theRemoveWebs, + const Handle(TColStd_HArray1OfInteger)& theMaterials); + + Handle(GEOM_Object) MakeHalfPartition (Handle(GEOM_Object) theShape, + Handle(GEOM_Object) thePlane); +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_IBox.hxx b/src/GEOMImpl/GEOMImpl_IBox.hxx new file mode 100644 index 000000000..45a33b5b3 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_IBox.hxx @@ -0,0 +1,41 @@ +//NOTE: This is an intreface to a function for the Box creation. + + +#include "GEOM_Function.hxx" + +#define BOX_ARG_DX 1 +#define BOX_ARG_DY 2 +#define BOX_ARG_DZ 3 +#define BOX_ARG_REF1 4 +#define BOX_ARG_REF2 5 + +class GEOMImpl_IBox +{ + public: + + GEOMImpl_IBox(Handle(GEOM_Function) theFunction): _func(theFunction) {} + + void SetDX(double theX) { _func->SetReal(BOX_ARG_DX, theX); } + + double GetDX() { return _func->GetReal(BOX_ARG_DX); } + + void SetDY(double theY) { _func->SetReal(BOX_ARG_DY, theY); } + + double GetDY() { return _func->GetReal(BOX_ARG_DY); } + + void SetDZ(double theZ) { _func->SetReal(BOX_ARG_DZ, theZ); } + + double GetDZ() { return _func->GetReal(BOX_ARG_DZ); } + + void SetRef1(Handle(GEOM_Function) theRefPoint1) { _func->SetReference(BOX_ARG_REF1, theRefPoint1); } + + Handle(GEOM_Function) GetRef1() { return _func->GetReference(BOX_ARG_REF1); } + + void SetRef2(Handle(GEOM_Function) theRefPoint2) { _func->SetReference(BOX_ARG_REF2, theRefPoint2); } + + Handle(GEOM_Function) GetRef2() { return _func->GetReference(BOX_ARG_REF2); } + + private: + + Handle(GEOM_Function) _func; +}; diff --git a/src/GEOMImpl/GEOMImpl_IChamfer.hxx b/src/GEOMImpl/GEOMImpl_IChamfer.hxx new file mode 100644 index 000000000..c2b0d4efd --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_IChamfer.hxx @@ -0,0 +1,48 @@ +//NOTE: This is an interface to a function for the Chamfer and creation. + + +#include "GEOM_Function.hxx" + +#define CHAM_ARG_SH 1 +#define CHAM_ARG_D1 2 +#define CHAM_ARG_D2 3 +#define CHAM_ARG_LENG 4 +#define CHAM_ARG_LAST 4 + +class GEOMImpl_IChamfer +{ + public: + + GEOMImpl_IChamfer(Handle(GEOM_Function) theFunction): _func(theFunction) {} + + void SetShape(Handle(GEOM_Function) theRef) { _func->SetReference(CHAM_ARG_SH, theRef); } + + Handle(GEOM_Function) GetShape() { return _func->GetReference(CHAM_ARG_SH); } + + void SetD (double theD) { _func->SetReal(CHAM_ARG_D1, theD); } + void SetD1(double theD) { _func->SetReal(CHAM_ARG_D1, theD); } + void SetD2(double theD) { _func->SetReal(CHAM_ARG_D2, theD); } + + double GetD () { return _func->GetReal(CHAM_ARG_D1); } + double GetD1() { return _func->GetReal(CHAM_ARG_D1); } + double GetD2() { return _func->GetReal(CHAM_ARG_D2); } + + void SetLength(int theLen) { _func->SetInteger(CHAM_ARG_LENG, theLen); } + + int GetLength() { return _func->GetInteger(CHAM_ARG_LENG); } + + void SetFace(int theInd, int theFace) + { _func->SetInteger(CHAM_ARG_LAST + theInd, theFace); } + void SetFace1(int theFace) + { _func->SetInteger(CHAM_ARG_LAST + 1, theFace); } + void SetFace2(int theFace) + { _func->SetInteger(CHAM_ARG_LAST + 2, theFace); } + + int GetFace(int theInd) { return _func->GetInteger(CHAM_ARG_LAST + theInd); } + int GetFace1() { return _func->GetInteger(CHAM_ARG_LAST + 1); } + int GetFace2() { return _func->GetInteger(CHAM_ARG_LAST + 2); } + + private: + + Handle(GEOM_Function) _func; +}; diff --git a/src/GEOMImpl/GEOMImpl_ICircle.hxx b/src/GEOMImpl/GEOMImpl_ICircle.hxx new file mode 100644 index 000000000..3f7e0b925 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_ICircle.hxx @@ -0,0 +1,41 @@ +//NOTE: This is an intreface to a function for the Circle creation. + + +#include "GEOM_Function.hxx" + +#define CIRC_ARG_P1 1 +#define CIRC_ARG_P2 2 +#define CIRC_ARG_P3 3 + +#define CIRC_ARG_CC 4 +#define CIRC_ARG_VV 5 +#define CIRC_ARG_RR 6 + +class GEOMImpl_ICircle +{ + public: + + GEOMImpl_ICircle(Handle(GEOM_Function) theFunction): _func(theFunction) {} + + void SetPoint1(Handle(GEOM_Function) theP) { _func->SetReference(CIRC_ARG_P1, theP); } + void SetPoint2(Handle(GEOM_Function) theP) { _func->SetReference(CIRC_ARG_P2, theP); } + void SetPoint3(Handle(GEOM_Function) theP) { _func->SetReference(CIRC_ARG_P3, theP); } + + void SetCenter(Handle(GEOM_Function) theP) { _func->SetReference(CIRC_ARG_CC, theP); } + void SetVector(Handle(GEOM_Function) theV) { _func->SetReference(CIRC_ARG_VV, theV); } + + void SetRadius(double theR) { _func->SetReal(CIRC_ARG_RR, theR); } + + Handle(GEOM_Function) GetPoint1() { return _func->GetReference(CIRC_ARG_P1); } + Handle(GEOM_Function) GetPoint2() { return _func->GetReference(CIRC_ARG_P2); } + Handle(GEOM_Function) GetPoint3() { return _func->GetReference(CIRC_ARG_P3); } + + Handle(GEOM_Function) GetCenter() { return _func->GetReference(CIRC_ARG_CC); } + Handle(GEOM_Function) GetVector() { return _func->GetReference(CIRC_ARG_VV); } + + double GetRadius() { return _func->GetReal(CIRC_ARG_RR); } + + private: + + Handle(GEOM_Function) _func; +}; diff --git a/src/GEOMImpl/GEOMImpl_ICone.hxx b/src/GEOMImpl/GEOMImpl_ICone.hxx new file mode 100644 index 000000000..cd622eb47 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_ICone.hxx @@ -0,0 +1,41 @@ +//NOTE: This is an intreface to a function for the Cone creation. + + +#include "GEOM_Function.hxx" + +#define CONE_ARG_R1 1 +#define CONE_ARG_R2 2 +#define CONE_ARG_H 3 +#define CONE_ARG_PNT 4 +#define CONE_ARG_VEC 5 + +class GEOMImpl_ICone +{ + public: + + GEOMImpl_ICone(Handle(GEOM_Function) theFunction): _func(theFunction) {} + + void SetR1(double theR) { _func->SetReal(CONE_ARG_R1, theR); } + + double GetR1() { return _func->GetReal(CONE_ARG_R1); } + + void SetR2(double theR) { _func->SetReal(CONE_ARG_R2, theR); } + + double GetR2() { return _func->GetReal(CONE_ARG_R2); } + + void SetH(double theH) { _func->SetReal(CONE_ARG_H, theH); } + + double GetH() { return _func->GetReal(CONE_ARG_H); } + + void SetPoint(Handle(GEOM_Function) theRefPoint) { _func->SetReference(CONE_ARG_PNT, theRefPoint); } + + Handle(GEOM_Function) GetPoint() { return _func->GetReference(CONE_ARG_PNT); } + + void SetVector(Handle(GEOM_Function) theRefVector) { _func->SetReference(CONE_ARG_VEC, theRefVector); } + + Handle(GEOM_Function) GetVector() { return _func->GetReference(CONE_ARG_VEC); } + + private: + + Handle(GEOM_Function) _func; +}; diff --git a/src/GEOMImpl/GEOMImpl_ICopy.hxx b/src/GEOMImpl/GEOMImpl_ICopy.hxx new file mode 100644 index 000000000..fad03bbde --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_ICopy.hxx @@ -0,0 +1,21 @@ +//NOTE: This is an intreface to a function for the Copy operation. + + +#include "GEOM_Function.hxx" + +#define COPY_ARG_REF 1 + +class GEOMImpl_ICopy +{ + public: + + GEOMImpl_ICopy(Handle(GEOM_Function) theFunction): _func(theFunction) {} + + void SetOriginal(Handle(GEOM_Function) theOriginal) { _func->SetReference(COPY_ARG_REF, theOriginal); } + + Handle(GEOM_Function) GetOriginal() { return _func->GetReference(COPY_ARG_REF); } + + private: + + Handle(GEOM_Function) _func; +}; diff --git a/src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx b/src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx new file mode 100644 index 000000000..2bf1dfc6e --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx @@ -0,0 +1,596 @@ +using namespace std; + +#include "GEOMImpl_ICurvesOperations.hxx" + +#include "GEOM_Function.hxx" +#include "GEOMImpl_Types.hxx" + +#include "GEOMImpl_PolylineDriver.hxx" +#include "GEOMImpl_CircleDriver.hxx" +#include "GEOMImpl_SplineDriver.hxx" +#include "GEOMImpl_EllipseDriver.hxx" +#include "GEOMImpl_ArcDriver.hxx" +#include "GEOMImpl_SketcherDriver.hxx" + +#include "GEOMImpl_IPolyline.hxx" +#include "GEOMImpl_ICircle.hxx" +#include "GEOMImpl_ISpline.hxx" +#include "GEOMImpl_IEllipse.hxx" +#include "GEOMImpl_IArc.hxx" +#include "GEOMImpl_ISketcher.hxx" + +#include "utilities.h" + +#include + +#include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC + +//============================================================================= +/*! + * constructor: + */ +//============================================================================= +GEOMImpl_ICurvesOperations::GEOMImpl_ICurvesOperations (GEOM_Engine* theEngine, int theDocID) +: GEOM_IOperations(theEngine, theDocID) +{ + MESSAGE("GEOMImpl_ICurvesOperations::GEOMImpl_ICurvesOperations"); +} + +//============================================================================= +/*! + * destructor + */ +//============================================================================= +GEOMImpl_ICurvesOperations::~GEOMImpl_ICurvesOperations() +{ + MESSAGE("GEOMImpl_ICurvesOperations::~GEOMImpl_ICurvesOperations"); +} + + +//============================================================================= +/*! + * MakePolyline + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakePolyline (list thePoints) +{ + SetErrorCode(KO); + + //Add a new Polyline object + Handle(GEOM_Object) aPolyline = GetEngine()->AddObject(GetDocID(), GEOM_POLYLINE); + + //Add a new Polyline function for creation a polyline relatively to points set + Handle(GEOM_Function) aFunction = + aPolyline->AddFunction(GEOMImpl_PolylineDriver::GetID(), POLYLINE_POINTS); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_PolylineDriver::GetID()) return NULL; + + GEOMImpl_IPolyline aCI (aFunction); + + int aLen = thePoints.size(); + aCI.SetLength(aLen); + + int ind = 1; + list::iterator it = thePoints.begin(); + for (; it != thePoints.end(); it++, ind++) { + Handle(GEOM_Function) aRefPnt = (*it)->GetLastFunction(); + if (aRefPnt.IsNull()) { + SetErrorCode("NULL point for Polyline"); + return NULL; + } + aCI.SetPoint(ind, aRefPnt); + } + + //Compute the Polyline value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Polyline driver failed"); + 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(aPolyline->GetEntry(), anEntry); + aDescr += anEntry; + aDescr += " = ICurvesOperations.MakePolyline(["; + it = thePoints.begin(); + TDF_Tool::Entry((*it)->GetEntry(), anEntry); + it++; + aDescr += (anEntry+", "); + for (; it != thePoints.end(); it++) { + aDescr += ", "; + TDF_Tool::Entry((*it)->GetEntry(), anEntry); + aDescr += anEntry; + } + aDescr += "])"; + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aPolyline; +} + +//============================================================================= +/*! + * MakeCircleThreePnt + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCircleThreePnt (Handle(GEOM_Object) thePnt1, + Handle(GEOM_Object) thePnt2, + Handle(GEOM_Object) thePnt3) +{ + SetErrorCode(KO); + + if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL; + + //Add a new Circle object + Handle(GEOM_Object) aCircle = GetEngine()->AddObject(GetDocID(), GEOM_CIRCLE); + + //Add a new Circle function for creation a circle relatively to three points + Handle(GEOM_Function) aFunction = + aCircle->AddFunction(GEOMImpl_CircleDriver::GetID(), CIRCLE_THREE_PNT); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_CircleDriver::GetID()) return NULL; + + GEOMImpl_ICircle aCI (aFunction); + + Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction(); + Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction(); + Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction(); + + if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL; + + aCI.SetPoint1(aRefPnt1); + aCI.SetPoint2(aRefPnt2); + aCI.SetPoint3(aRefPnt3); + + //Compute the Circle value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Circle driver failed"); + 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(aCircle->GetEntry(), anEntry); + aDescr += anEntry; + aDescr += " = ICurvesOperations.MakeCircleThreePnt("; + TDF_Tool::Entry(thePnt1->GetEntry(), anEntry); + aDescr += (anEntry+", "); + TDF_Tool::Entry(thePnt2->GetEntry(), anEntry); + aDescr += (anEntry+", "); + TDF_Tool::Entry(thePnt3->GetEntry(), anEntry); + aDescr += (anEntry+")"); + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aCircle; +} + +//============================================================================= +/*! + * MakeCirclePntVecR + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCirclePntVecR + (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec, double theR) +{ + SetErrorCode(KO); + + if (thePnt.IsNull() || theVec.IsNull()) return NULL; + + //Add a new Circle object + Handle(GEOM_Object) aCircle = GetEngine()->AddObject(GetDocID(), GEOM_CIRCLE); + + //Add a new Circle function for creation a circle relatively to point and vector + Handle(GEOM_Function) aFunction = + aCircle->AddFunction(GEOMImpl_CircleDriver::GetID(), CIRCLE_PNT_VEC_R); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_CircleDriver::GetID()) return NULL; + + GEOMImpl_ICircle aCI (aFunction); + + Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction(); + Handle(GEOM_Function) aRefVec = theVec->GetLastFunction(); + + if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL; + + aCI.SetCenter(aRefPnt); + aCI.SetVector(aRefVec); + aCI.SetRadius(theR); + + //Compute the Circle value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Circle driver failed"); + 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(aCircle->GetEntry(), anEntry); + aDescr += anEntry; + aDescr += " = ICurvesOperations.MakeCirclePntVecR("; + TDF_Tool::Entry(thePnt->GetEntry(), anEntry); + aDescr += (anEntry+", "); + TDF_Tool::Entry(theVec->GetEntry(), anEntry); + aDescr += (anEntry+", "); + aDescr += (TCollection_AsciiString(theR)+")"); + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aCircle; +} + +//============================================================================= +/*! + * MakeEllipse + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeEllipse + (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec, + double theRMajor, double theRMinor) +{ + SetErrorCode(KO); + + if (thePnt.IsNull() || theVec.IsNull()) return NULL; + + //Add a new Ellipse object + Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_ELLIPSE); + + //Add a new Ellipse function + Handle(GEOM_Function) aFunction = + anEll->AddFunction(GEOMImpl_EllipseDriver::GetID(), ELLIPSE_PNT_VEC_RR); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_EllipseDriver::GetID()) return NULL; + + GEOMImpl_IEllipse aCI (aFunction); + + Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction(); + Handle(GEOM_Function) aRefVec = theVec->GetLastFunction(); + + if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL; + + aCI.SetCenter(aRefPnt); + aCI.SetVector(aRefVec); + aCI.SetRMajor(theRMajor); + aCI.SetRMinor(theRMinor); + + //Compute the Ellipse value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Ellipse driver failed"); + 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(anEll->GetEntry(), anEntry); + aDescr += anEntry; + aDescr += " = ICurvesOperations.MakeEllipse("; + TDF_Tool::Entry(thePnt->GetEntry(), anEntry); + aDescr += (anEntry+", "); + TDF_Tool::Entry(theVec->GetEntry(), anEntry); + aDescr += (anEntry+", "); + aDescr += (TCollection_AsciiString(theRMajor)+", "); + aDescr += (TCollection_AsciiString(theRMinor)+")"); + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return anEll; +} + +//============================================================================= +/*! + * MakeArc + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeArc (Handle(GEOM_Object) thePnt1, + Handle(GEOM_Object) thePnt2, + Handle(GEOM_Object) thePnt3) +{ + SetErrorCode(KO); + + if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL; + + //Add a new Circle Arc object + Handle(GEOM_Object) anArc = GetEngine()->AddObject(GetDocID(), GEOM_CIRC_ARC); + + //Add a new Circle Arc function + Handle(GEOM_Function) aFunction = + anArc->AddFunction(GEOMImpl_ArcDriver::GetID(), CIRC_ARC_THREE_PNT); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_ArcDriver::GetID()) return NULL; + + GEOMImpl_IArc aCI (aFunction); + + Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction(); + Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction(); + Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction(); + + if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL; + + aCI.SetPoint1(aRefPnt1); + aCI.SetPoint2(aRefPnt2); + aCI.SetPoint3(aRefPnt3); + + //Compute the Arc value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Arc driver failed"); + 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(anArc->GetEntry(), anEntry); + aDescr += anEntry; + aDescr += " = ICurvesOperations.MakeArc("; + TDF_Tool::Entry(thePnt1->GetEntry(), anEntry); + aDescr += (anEntry+", "); + TDF_Tool::Entry(thePnt2->GetEntry(), anEntry); + aDescr += (anEntry+", "); + TDF_Tool::Entry(thePnt3->GetEntry(), anEntry); + aDescr += (anEntry+")"); + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return anArc; +} + +//============================================================================= +/*! + * MakeSplineBezier + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineBezier + (list thePoints) +{ + SetErrorCode(KO); + + //Add a new Spline object + Handle(GEOM_Object) aSpline = GetEngine()->AddObject(GetDocID(), GEOM_SPLINE); + + //Add a new Spline function for creation a bezier curve relatively to points set + Handle(GEOM_Function) aFunction = + aSpline->AddFunction(GEOMImpl_SplineDriver::GetID(), SPLINE_BEZIER); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_SplineDriver::GetID()) return NULL; + + GEOMImpl_ISpline aCI (aFunction); + + int aLen = thePoints.size(); + aCI.SetLength(aLen); + + int ind = 1; + list::iterator it = thePoints.begin(); + for (; it != thePoints.end(); it++, ind++) { + Handle(GEOM_Function) aRefPnt = (*it)->GetLastFunction(); + + if (aRefPnt.IsNull()) return NULL; + + aCI.SetPoint(ind, aRefPnt); + } + + //Compute the Spline value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Spline driver failed"); + 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(aSpline->GetEntry(), anEntry); + aDescr += anEntry; + aDescr += " = ICurvesOperations.MakeSplineBezier(["; + it = thePoints.begin(); + TDF_Tool::Entry((*it)->GetEntry(), anEntry); + it++; + aDescr += (anEntry+", "); + for (; it != thePoints.end(); it++) { + aDescr += ", "; + TDF_Tool::Entry((*it)->GetEntry(), anEntry); + aDescr += anEntry; + } + aDescr += "])"; + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aSpline; +} + +//============================================================================= +/*! + * MakeSplineInterpolation + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineInterpolation + (list thePoints) +{ + SetErrorCode(KO); + + //Add a new Spline object + Handle(GEOM_Object) aSpline = GetEngine()->AddObject(GetDocID(), GEOM_SPLINE); + + //Add a new Spline function for creation a bezier curve relatively to points set + Handle(GEOM_Function) aFunction = + aSpline->AddFunction(GEOMImpl_SplineDriver::GetID(), SPLINE_INTERPOLATION); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_SplineDriver::GetID()) return NULL; + + GEOMImpl_ISpline aCI (aFunction); + + int aLen = thePoints.size(); + aCI.SetLength(aLen); + + int ind = 1; + list::iterator it = thePoints.begin(); + for (; it != thePoints.end(); it++, ind++) { + Handle(GEOM_Function) aRefPnt = (*it)->GetLastFunction(); + + if (aRefPnt.IsNull()) return NULL; + + aCI.SetPoint(ind, aRefPnt); + } + + //Compute the Spline value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Spline driver failed"); + 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(aSpline->GetEntry(), anEntry); + aDescr += anEntry; + aDescr += " = ICurvesOperations.MakeSplineInterpolation(["; + it = thePoints.begin(); + TDF_Tool::Entry((*it)->GetEntry(), anEntry); + it++; + aDescr += (anEntry+", "); + for (; it != thePoints.end(); it++) { + aDescr += ", "; + TDF_Tool::Entry((*it)->GetEntry(), anEntry); + aDescr += anEntry; + } + aDescr += "])"; + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aSpline; +} + +//============================================================================= +/*! + * MakeSketcher + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcher (const char* theCommand, + list theWorkingPlane) +{ + SetErrorCode(KO); + + if (!theCommand) return NULL; + if (strcmp(theCommand, "") == 0) return NULL; + + //Add a new Sketcher object + Handle(GEOM_Object) aSketcher = GetEngine()->AddObject(GetDocID(), GEOM_SKETCHER); + + //Add a new Sketcher function + Handle(GEOM_Function) aFunction = + aSketcher->AddFunction(GEOMImpl_SketcherDriver::GetID(), SKETCHER_COMMAND); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_SketcherDriver::GetID()) return NULL; + + GEOMImpl_ISketcher aCI (aFunction); + + TCollection_AsciiString aCommand ((char*) theCommand); + aCI.SetCommand(aCommand); + + int ind = 1; + list::iterator it = theWorkingPlane.begin(); + for (; it != theWorkingPlane.end(); it++, ind++) + aCI.SetWorkingPlane(ind, *it); + + //Compute the Sketcher value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Sketcher driver failed"); + 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(aSketcher->GetEntry(), anEntry); + aDescr += anEntry; + aDescr += " = ICurvesOperations.MakeSketcher("; + aDescr += aCommand+", ["; + + it = theWorkingPlane.begin(); + aDescr += TCollection_AsciiString(*it); + it++; + for (; it != theWorkingPlane.end(); it++) { + aDescr += ", "; + aDescr += TCollection_AsciiString(*it); + } + + aDescr += "])"; + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aSketcher; +} diff --git a/src/GEOMImpl/GEOMImpl_ICurvesOperations.hxx b/src/GEOMImpl/GEOMImpl_ICurvesOperations.hxx new file mode 100644 index 000000000..0c52cc7ec --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_ICurvesOperations.hxx @@ -0,0 +1,40 @@ +using namespace std; + +#ifndef _GEOMImpl_ICurvesOperations_HXX_ +#define _GEOMImpl_ICurvesOperations_HXX_ + +#include "GEOM_IOperations.hxx" + +#include + +class GEOM_Engine; +class Handle(GEOM_Object); + +class GEOMImpl_ICurvesOperations : public GEOM_IOperations { + public: + GEOMImpl_ICurvesOperations(GEOM_Engine* theEngine, int theDocID); + ~GEOMImpl_ICurvesOperations(); + + Handle(GEOM_Object) MakePolyline (list thePoints); + + Handle(GEOM_Object) MakeCircleThreePnt (Handle(GEOM_Object) thePnt1, + Handle(GEOM_Object) thePnt2, + Handle(GEOM_Object) thePnt3); + Handle(GEOM_Object) MakeCirclePntVecR (Handle(GEOM_Object) thePnt, + Handle(GEOM_Object) theVec, double theR); + + Handle(GEOM_Object) MakeEllipse (Handle(GEOM_Object) thePnt, + Handle(GEOM_Object) theVec, + double theRMajor, double theRMinor); + + Handle(GEOM_Object) MakeArc (Handle(GEOM_Object) thePnt1, + Handle(GEOM_Object) thePnt2, + Handle(GEOM_Object) thePnt3); + + Handle(GEOM_Object) MakeSplineBezier (list thePoints); + Handle(GEOM_Object) MakeSplineInterpolation (list thePoints); + + Handle(GEOM_Object) MakeSketcher (const char* theCommand, list theWorkingPlane); +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_ICylinder.hxx b/src/GEOMImpl/GEOMImpl_ICylinder.hxx new file mode 100644 index 000000000..4a76fd860 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_ICylinder.hxx @@ -0,0 +1,36 @@ +//NOTE: This is an intreface to a function for the Cylinder creation. + + +#include "GEOM_Function.hxx" + +#define CYL_ARG_R 1 +#define CYL_ARG_H 2 +#define CYL_ARG_PNT 3 +#define CYL_ARG_VEC 4 + +class GEOMImpl_ICylinder +{ + public: + + GEOMImpl_ICylinder(Handle(GEOM_Function) theFunction): _func(theFunction) {} + + void SetR(double theR) { _func->SetReal(CYL_ARG_R, theR); } + + double GetR() { return _func->GetReal(CYL_ARG_R); } + + void SetH(double theH) { _func->SetReal(CYL_ARG_H, theH); } + + double GetH() { return _func->GetReal(CYL_ARG_H); } + + void SetPoint(Handle(GEOM_Function) theRefPoint) { _func->SetReference(CYL_ARG_PNT, theRefPoint); } + + Handle(GEOM_Function) GetPoint() { return _func->GetReference(CYL_ARG_PNT); } + + void SetVector(Handle(GEOM_Function) theRefVector) { _func->SetReference(CYL_ARG_VEC, theRefVector); } + + Handle(GEOM_Function) GetVector() { return _func->GetReference(CYL_ARG_VEC); } + + private: + + Handle(GEOM_Function) _func; +}; diff --git a/src/GEOMImpl/GEOMImpl_IEllipse.hxx b/src/GEOMImpl/GEOMImpl_IEllipse.hxx new file mode 100644 index 000000000..b3f06595a --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_IEllipse.hxx @@ -0,0 +1,32 @@ +//NOTE: This is an intreface to a function for the Ellipse creation. + + +#include "GEOM_Function.hxx" + +#define ELLIPS_ARG_CC 1 +#define ELLIPS_ARG_VV 2 +#define ELLIPS_ARG_RMAJ 3 +#define ELLIPS_ARG_RMIN 4 + +class GEOMImpl_IEllipse +{ + public: + + GEOMImpl_IEllipse(Handle(GEOM_Function) theFunction): _func(theFunction) {} + + void SetCenter(Handle(GEOM_Function) theP) { _func->SetReference(ELLIPS_ARG_CC, theP); } + void SetVector(Handle(GEOM_Function) theV) { _func->SetReference(ELLIPS_ARG_VV, theV); } + + void SetRMajor(double theR) { _func->SetReal(ELLIPS_ARG_RMAJ, theR); } + void SetRMinor(double theR) { _func->SetReal(ELLIPS_ARG_RMIN, theR); } + + Handle(GEOM_Function) GetCenter() { return _func->GetReference(ELLIPS_ARG_CC); } + Handle(GEOM_Function) GetVector() { return _func->GetReference(ELLIPS_ARG_VV); } + + double GetRMajor() { return _func->GetReal(ELLIPS_ARG_RMAJ); } + double GetRMinor() { return _func->GetReal(ELLIPS_ARG_RMIN); } + + private: + + Handle(GEOM_Function) _func; +}; diff --git a/src/GEOMImpl/GEOMImpl_IFillet.hxx b/src/GEOMImpl/GEOMImpl_IFillet.hxx new file mode 100644 index 000000000..9f6d3b9bd --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_IFillet.hxx @@ -0,0 +1,40 @@ +//NOTE: This is an interface to a function for the Fillet and creation. + + +#include "GEOM_Function.hxx" + +#define FILLET_ARG_SH 1 +#define FILLET_ARG_R 2 +#define FILLET_ARG_LENG 3 +#define FILLET_ARG_LAST 3 + +class GEOMImpl_IFillet +{ + public: + + GEOMImpl_IFillet(Handle(GEOM_Function) theFunction): _func(theFunction) {} + + void SetShape(Handle(GEOM_Function) theRef) { _func->SetReference(FILLET_ARG_SH, theRef); } + + Handle(GEOM_Function) GetShape() { return _func->GetReference(FILLET_ARG_SH); } + + void SetR(double theR) { _func->SetReal(FILLET_ARG_R, theR); } + + double GetR() { return _func->GetReal(FILLET_ARG_R); } + + void SetLength(int theLen) { _func->SetInteger(FILLET_ARG_LENG, theLen); } + + int GetLength() { return _func->GetInteger(FILLET_ARG_LENG); } + + void SetEdge(int theInd, int theEdge) + { _func->SetInteger(FILLET_ARG_LAST + theInd, theEdge); } + void SetFace(int theInd, int theFace) + { _func->SetInteger(FILLET_ARG_LAST + theInd, theFace); } + + int GetEdge(int theInd) { return _func->GetInteger(FILLET_ARG_LAST + theInd); } + int GetFace(int theInd) { return _func->GetInteger(FILLET_ARG_LAST + theInd); } + + private: + + Handle(GEOM_Function) _func; +}; diff --git a/src/GEOMImpl/GEOMImpl_IFilling.hxx b/src/GEOMImpl/GEOMImpl_IFilling.hxx new file mode 100644 index 000000000..e9ab36a27 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_IFilling.hxx @@ -0,0 +1,37 @@ +//NOTE: This is an intreface to a function for the Filling operation. + + +#include "GEOM_Function.hxx" + +#define FILL_ARG_MINDEG 1 +#define FILL_ARG_MAXDEG 2 +#define FILL_ARG_TOL2D 3 +#define FILL_ARG_TOL3D 4 +#define FILL_ARG_SHAPE 5 +#define FILL_ARG_NBITER 6 + +class GEOMImpl_IFilling +{ + public: + + GEOMImpl_IFilling(Handle(GEOM_Function) theFunction): _func(theFunction) {} + + void SetTol2D(double theTol2D) { _func->SetReal(FILL_ARG_TOL2D, theTol2D); } + void SetTol3D(double theTol3D) { _func->SetReal(FILL_ARG_TOL3D, theTol3D); } + double GetTol2D() { return _func->GetReal(FILL_ARG_TOL2D); } + double GetTol3D() { return _func->GetReal(FILL_ARG_TOL3D); } + + void SetMinDeg(int theMinDeg) { _func->SetInteger(FILL_ARG_MINDEG, theMinDeg); } + void SetMaxDeg(int theMaxDeg) { _func->SetInteger(FILL_ARG_MAXDEG, theMaxDeg); } + int GetMinDeg() { return _func->GetInteger(FILL_ARG_MINDEG); } + int GetMaxDeg() { return _func->GetInteger(FILL_ARG_MAXDEG); } + void SetNbIter(int theNbIter) { _func->SetInteger(FILL_ARG_NBITER, theNbIter); } + int GetNbIter() { return _func->GetInteger(FILL_ARG_NBITER); } + + void SetShape(Handle(GEOM_Function) theShape) { _func->SetReference(FILL_ARG_SHAPE, theShape); } + Handle(GEOM_Function) GetShape() { return _func->GetReference(FILL_ARG_SHAPE); } + + private: + + Handle(GEOM_Function) _func; +}; diff --git a/src/GEOMImpl/GEOMImpl_IGlue.hxx b/src/GEOMImpl/GEOMImpl_IGlue.hxx new file mode 100644 index 000000000..1cf51c9f5 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_IGlue.hxx @@ -0,0 +1,28 @@ +// NOTE: This is an interface to a function for the Glueing of faces + + +#include "GEOM_Function.hxx" + +#define GLUE_ARG_BASE 1 +#define GLUE_ARG_TOLER 2 + +class GEOMImpl_IGlue +{ + public: + + GEOMImpl_IGlue(Handle(GEOM_Function) theFunction): _func(theFunction) {} + + void SetBase(Handle(GEOM_Function) theRefBase) + { _func->SetReference(GLUE_ARG_BASE, theRefBase); } + + Handle(GEOM_Function) GetBase() { return _func->GetReference(GLUE_ARG_BASE); } + + void SetTolerance(const Standard_Real theTolerance) + { _func->SetReal(GLUE_ARG_TOLER, theTolerance); } + + Standard_Real GetTolerance() { return _func->GetReal(GLUE_ARG_TOLER); } + + private: + + Handle(GEOM_Function) _func; +}; diff --git a/src/GEOMImpl/GEOMImpl_IGroupOperations.cxx b/src/GEOMImpl/GEOMImpl_IGroupOperations.cxx new file mode 100644 index 000000000..ce66c20d6 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_IGroupOperations.cxx @@ -0,0 +1,252 @@ +using namespace std; + +#include "GEOMImpl_IGroupOperations.hxx" + +#include "utilities.h" +#include "OpUtil.hxx" +#include "Utils_ExceptHandlers.hxx" + +#include +#include +#include +#include +#include + +#include "GEOM_Function.hxx" +#include "GEOMImpl_Types.hxx" +#include "GEOM_ISubShape.hxx" + +#include +#include +#include + +#include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC + +//============================================================================= +/*! + * constructor: + */ +//============================================================================= +GEOMImpl_IGroupOperations::GEOMImpl_IGroupOperations (GEOM_Engine* theEngine, int theDocID) +: GEOM_IOperations(theEngine, theDocID) +{ + MESSAGE("GEOMImpl_IGroupOperations::GEOMImpl_IGroupOperations"); +} + +//============================================================================= +/*! + * destructor + */ +//============================================================================= +GEOMImpl_IGroupOperations::~GEOMImpl_IGroupOperations() +{ + MESSAGE("GEOMImpl_IGroupOperations::~GEOMImpl_IGroupOperations"); +} + + +//============================================================================= +/*! + * CreateGroup + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IGroupOperations::CreateGroup(Handle(GEOM_Object) theMainShape, TopAbs_ShapeEnum theShapeType) +{ + SetErrorCode(KO); + + Handle(TColStd_HArray1OfInteger) anArray = new TColStd_HArray1OfInteger(1,1); + anArray->SetValue(1, -1); + + //Add a new Fillet object + Handle(GEOM_Object) aGroup = GetEngine()->AddSubShape(theMainShape, 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 + " = IGroupOperations.CreateGroup("; + TDF_Tool::Entry(theMainShape->GetEntry(), anEntry); + aDescr += (anEntry+", "); + aDescr += (TCollection_AsciiString((int)theShapeType)+")"); + + Handle(GEOM_Function) aFunction = aGroup->GetFunction(1); + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aGroup; +} + +//============================================================================= +/*! + * AddObject + */ +//============================================================================= +void GEOMImpl_IGroupOperations::AddObject(Handle(GEOM_Object) theGroup, int theSubShapeID) +{ + SetErrorCode(KO); + if(theGroup.IsNull()) return; + + Handle(GEOM_Function) aFunction = theGroup->GetFunction(1); + if(aFunction.IsNull()) return; + + GEOM_ISubShape aSSI(aFunction); + Handle(TColStd_HArray1OfInteger) aSeq = aSSI.GetIndices(); + if(aSeq.IsNull()) return; + if(aSeq->Length() == 1 && aSeq->Value(1) == -1) { + aSeq->SetValue(1, theSubShapeID); + } + else { + Standard_Integer aLength = aSeq->Length(); + Handle(TColStd_HArray1OfInteger) aNewSeq = new TColStd_HArray1OfInteger(1, aLength+1); + for(Standard_Integer i = 1; i<=aLength; i++) { + aNewSeq->SetValue(i, aSeq->Value(i)); + if(aSeq->Value(i) == theSubShapeID) { + SetErrorCode(ALREADY_PRESENT); + return; // + } + } + aNewSeq->SetValue(aLength+1, theSubShapeID); + aSSI.SetIndices(aNewSeq); + } + + SetErrorCode(OK); + return; +} + +//============================================================================= +/*! + * RemoveObject + */ +//============================================================================= +void GEOMImpl_IGroupOperations::RemoveObject(Handle(GEOM_Object) theGroup, int theSubShapeID) +{ + SetErrorCode(KO); + if(theGroup.IsNull()) return; + + + Handle(GEOM_Function) aFunction = theGroup->GetFunction(1); + if(aFunction.IsNull()) return; + + + GEOM_ISubShape aSSI(aFunction); + Handle(TColStd_HArray1OfInteger) aSeq = aSSI.GetIndices(); + if(aSeq.IsNull()) return; + if(aSeq->Length() == 1 && aSeq->Value(1) == -1) { + SetErrorCode(NOT_EXISTS); + return; + } + else { + Handle(TColStd_HArray1OfInteger) aNewSeq; + Standard_Integer aLength = aSeq->Length(); + if(aLength == 1) { + if(aSeq->Value(1) != theSubShapeID) { + SetErrorCode(NOT_EXISTS); + return; + } + aNewSeq = new TColStd_HArray1OfInteger(1,1); + aNewSeq->SetValue(1, -1); + } + else { + aNewSeq = new TColStd_HArray1OfInteger(1, aLength-1); + Standard_Boolean isFound = Standard_False; + for(Standard_Integer i = 1, k=1; i<=aLength; i++) { + if(i == aLength && !isFound) { + SetErrorCode(NOT_EXISTS); + return; + } + if(aSeq->Value(i) == theSubShapeID) { + isFound = Standard_True; + continue; + } + aNewSeq->SetValue(k, aSeq->Value(i)); + k++; + } + + if(!isFound) { + SetErrorCode(NOT_EXISTS); + return; + } + } + + aSSI.SetIndices(aNewSeq); + } + + + SetErrorCode(OK); + return; +} + +//============================================================================= +/*! + * GetType + */ +//============================================================================= +TopAbs_ShapeEnum GEOMImpl_IGroupOperations::GetType(Handle(GEOM_Object) theGroup) +{ + SetErrorCode(KO); + + TDF_Label aFreeLabel = theGroup->GetFreeLabel(); + Handle(TDataStd_Integer) anAttrib; + if(!aFreeLabel.FindAttribute(TDataStd_Integer::GetID(), anAttrib)) return TopAbs_SHAPE; + + SetErrorCode(OK); + return (TopAbs_ShapeEnum) anAttrib->Get(); +} + +//============================================================================= +/*! + * GetMainShape + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IGroupOperations::GetMainShape(Handle(GEOM_Object) theGroup) +{ + SetErrorCode(KO); + + if(theGroup.IsNull()) return NULL; + + Handle(GEOM_Function) aFunction = theGroup->GetFunction(1); + if(aFunction.IsNull()) return NULL; + + GEOM_ISubShape aSSI(aFunction); + aFunction = aSSI.GetMainShape(); + if(aFunction.IsNull()) return NULL; + + TDF_Label aLabel = aFunction->GetOwnerEntry(); + Handle(GEOM_Object) aMainShape = GEOM_Object::GetObject(aLabel); + if(aMainShape.IsNull()) return NULL; + + SetErrorCode(OK); + return aMainShape; +} + +//============================================================================= +/*! + * GetObjects + */ +//============================================================================= +Handle(TColStd_HArray1OfInteger) GEOMImpl_IGroupOperations::GetObjects(Handle(GEOM_Object) theGroup) +{ + SetErrorCode(KO); + + if(theGroup.IsNull()) return NULL; + + Handle(GEOM_Function) aFunction = theGroup->GetFunction(1); + if(aFunction.IsNull()) return NULL; + + GEOM_ISubShape aSSI(aFunction); + Handle(TColStd_HArray1OfInteger) aSeq = aSSI.GetIndices(); + if(aSeq.IsNull()) return NULL; + + if(aSeq->Length() == 1 && aSeq->Value(1) == -1) { + SetErrorCode(OK); + return NULL; + } + + SetErrorCode(OK); + return aSeq; +} diff --git a/src/GEOMImpl/GEOMImpl_IGroupOperations.hxx b/src/GEOMImpl/GEOMImpl_IGroupOperations.hxx new file mode 100644 index 000000000..c17db5f17 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_IGroupOperations.hxx @@ -0,0 +1,32 @@ + +#ifndef _GEOMImpl_IGroupOperations_HXX_ +#define _GEOMImpl_IGroupOperations_HXX_ + +#include "Utils_SALOME_Exception.hxx" +#include "GEOM_IOperations.hxx" +#include "GEOM_Engine.hxx" +#include "GEOM_Object.hxx" +#include +#include +#include + +class GEOMImpl_IGroupOperations : public GEOM_IOperations { + public: + GEOMImpl_IGroupOperations(GEOM_Engine* theEngine, int theDocID); + ~GEOMImpl_IGroupOperations(); + + Handle(GEOM_Object) CreateGroup(Handle(GEOM_Object) theMainShape, TopAbs_ShapeEnum theShapeType); + + void AddObject(Handle(GEOM_Object) theGroup, int theSubShapeID); + + void RemoveObject(Handle(GEOM_Object) theGroup, int theSubShapeID); + + TopAbs_ShapeEnum GetType(Handle(GEOM_Object) theGroup); + + Handle(GEOM_Object) GetMainShape(Handle(GEOM_Object) theGroup); + + Handle(TColStd_HArray1OfInteger) GetObjects(Handle(GEOM_Object) theGroup); + +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_IHealing.hxx b/src/GEOMImpl/GEOMImpl_IHealing.hxx new file mode 100755 index 000000000..e6d486c14 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_IHealing.hxx @@ -0,0 +1,61 @@ +//NOTE: This is an intreface to a function for the Healing creation. + + +#include "GEOM_Function.hxx" + +#include +#include + +#define ARG_SHAPE_PROCESS_OPERATORS 1 +#define ARG_SHAPE_PROCESS_PARAMS 2 +#define ARG_SHAPE_PROCESS_VALUES 3 +#define ARG_ORIGINAL 4 +#define ARG_LIST_ARGUMENTS 5 +#define ARG_IS_COMMON_VERTEX 6 +#define ARG_TOLERANCE 7 +#define ARG_DEV_EDGE_VALUE 8 +#define ARG_IS_BY_PARAMETER 9 +#define ARG_SUBSHAPE_INDEX 10 + + +class GEOMImpl_IHealing +{ +public: + GEOMImpl_IHealing(Handle(GEOM_Function) theFunction): _func(theFunction) {} + + void SetOperators( const Handle(TColStd_HArray1OfExtendedString)& arr ) { if ( !arr.IsNull() ) _func->SetStringArray(ARG_SHAPE_PROCESS_OPERATORS, arr); } + Handle(TColStd_HArray1OfExtendedString) GetOperators() { return _func->GetStringArray(ARG_SHAPE_PROCESS_OPERATORS); } + + void SetParameters( const Handle(TColStd_HArray1OfExtendedString)& arr ) { if ( !arr.IsNull() ) _func->SetStringArray(ARG_SHAPE_PROCESS_PARAMS, arr); } + Handle(TColStd_HArray1OfExtendedString) GetParameters() { return _func->GetStringArray(ARG_SHAPE_PROCESS_PARAMS); } + + void SetValues( const Handle(TColStd_HArray1OfExtendedString)& arr ) { if ( !arr.IsNull() ) _func->SetStringArray(ARG_SHAPE_PROCESS_VALUES, arr); } + Handle(TColStd_HArray1OfExtendedString) GetValues() { return _func->GetStringArray(ARG_SHAPE_PROCESS_VALUES); } + + void SetOriginal( Handle(GEOM_Function)& f ) { _func->SetReference(ARG_ORIGINAL, f); } + Handle(GEOM_Function) GetOriginal() { return _func->GetReference(ARG_ORIGINAL); } + + void SetFaces( const Handle(TColStd_HArray1OfInteger)& arr ) { if ( !arr.IsNull() ) _func->SetIntegerArray(ARG_LIST_ARGUMENTS, arr); } + Handle(TColStd_HArray1OfInteger) GetFaces() { return _func->GetIntegerArray(ARG_LIST_ARGUMENTS); } + + void SetWires( const Handle(TColStd_HArray1OfInteger)& arr ) { if ( !arr.IsNull() ) _func->SetIntegerArray(ARG_LIST_ARGUMENTS, arr); } + Handle(TColStd_HArray1OfInteger) GetWires() { return _func->GetIntegerArray(ARG_LIST_ARGUMENTS); } + + void SetIsCommonVertex( Standard_Boolean val ) { _func->SetInteger(ARG_IS_COMMON_VERTEX, val ? 1 : 0 ); } + Standard_Boolean GetIsCommonVertex() { return (_func->GetInteger(ARG_IS_COMMON_VERTEX) != 0 ); } + + void SetIsByParameter( Standard_Boolean val ) { _func->SetInteger(ARG_IS_BY_PARAMETER, val ? 1 : 0 ); } + Standard_Boolean GetIsByParameter() { return (_func->GetInteger(ARG_IS_BY_PARAMETER) != 0 ); } + + void SetTolerance( Standard_Real val ) { _func->SetReal(ARG_TOLERANCE, val); } + Standard_Real GetTolerance() { return _func->GetReal(ARG_TOLERANCE); } + + void SetDevideEdgeValue( Standard_Real val ) { _func->SetReal(ARG_DEV_EDGE_VALUE, val); } + Standard_Real GetDevideEdgeValue() { return _func->GetReal(ARG_DEV_EDGE_VALUE); } + + void SetIndex( Standard_Integer val ) { _func->SetInteger(ARG_SUBSHAPE_INDEX, val); } + Standard_Integer GetIndex() { return _func->GetInteger(ARG_SUBSHAPE_INDEX); } + +private: + Handle(GEOM_Function) _func; +}; diff --git a/src/GEOMImpl/GEOMImpl_IHealingOperations.cxx b/src/GEOMImpl/GEOMImpl_IHealingOperations.cxx new file mode 100644 index 000000000..15852e313 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_IHealingOperations.cxx @@ -0,0 +1,638 @@ +using namespace std; + +#include "GEOMImpl_IHealingOperations.hxx" + +#include "GEOMImpl_HealingDriver.hxx" +#include "GEOMImpl_Types.hxx" +#include "GEOMImpl_IHealing.hxx" +#include "GEOMImpl_CopyDriver.hxx" + +#include "ShHealOper_ShapeProcess.hxx" + +#include "utilities.h" +#include "OpUtil.hxx" +#include "Utils_ExceptHandlers.hxx" + +#include + +#include +#include + +#include +#include +#include + +#include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC + + +//============================================================================= +/*! + * constructor: + */ +//============================================================================= + +GEOMImpl_IHealingOperations::GEOMImpl_IHealingOperations (GEOM_Engine* theEngine, int theDocID) +: GEOM_IOperations(theEngine, theDocID) +{ + MESSAGE("GEOMImpl_IHealingOperations::GEOMImpl_IHealingOperations"); +} + +//============================================================================= +/*! + * destructor + */ +//============================================================================= + +GEOMImpl_IHealingOperations::~GEOMImpl_IHealingOperations() +{ + MESSAGE("GEOMImpl_IHealingOperations::~GEOMImpl_IHealingOperations"); +} + + +//============================================================================= +/*! + * ShapeProcess + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IHealingOperations::ShapeProcess (Handle(GEOM_Object) theObject, + const Handle(TColStd_HArray1OfExtendedString)& theOperators, + const Handle(TColStd_HArray1OfExtendedString)& theParams, + const Handle(TColStd_HArray1OfExtendedString)& theValues) +{ + // set error code, check parameters + SetErrorCode(KO); + + if (theObject.IsNull()) + return NULL; + + if (theOperators.IsNull() || theOperators->Length() <= 0) { + SetErrorCode("No operators requested"); + return NULL; + } + + Standard_Integer nbParams = 0, nbValues = 0; + if (!theParams.IsNull()) { + nbParams = theParams->Length(); + } + if (!theValues.IsNull()) { + nbValues = theValues->Length(); + } + + if (nbParams != nbValues) { + SetErrorCode("Number of parameter values must be equal to the number of parameters"); + return NULL; + } + + Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction(); + if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed + + // Add a new object + Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY ); + + //Add the function + aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), SHAPE_PROCESS); + + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL; + + // prepare "data container" class IHealing + GEOMImpl_IHealing HI(aFunction); + HI.SetOriginal(aLastFunction); + HI.SetOperators( theOperators ); + if (nbParams > 0) { + HI.SetParameters( theParams ); + HI.SetValues( theValues ); + } + + //Compute the translation + try + { + if (!GetSolver()->ComputeFunction(aFunction)) + { + SetErrorCode("Shape Healing algorithm failed"); + return NULL; + } + } + catch (Standard_Failure) + { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + // ... + // ... missing ... + + SetErrorCode(OK); + return aNewObject; +} + +//============================================================================= +/*! + * ShapeProcess + */ +//============================================================================= +void GEOMImpl_IHealingOperations::GetShapeProcessParameters (list& theOperations, + list& theParams, + list& theValues) +{ + ShHealOper_ShapeProcess aHealer; + TColStd_SequenceOfAsciiString anOperators; + int nbOperatorErrors( 0 ), nbParamValueErrors( 0 ); + if ( aHealer.GetOperators( anOperators ) ) + { + for ( Standard_Integer i = 1; i <= anOperators.Length(); i++ ) + { + string anOperation = anOperators.Value( i ).ToCString(); + theOperations.push_back( anOperation ); + list aParams, aValues; + if ( GetParameters( anOperation, aParams ) ) + { + for ( list::iterator it = aParams.begin(); it != aParams.end(); ++it ) + { + TCollection_AsciiString aParam( (Standard_CString)(*it).c_str() ); + TCollection_AsciiString aValue; + if ( aHealer.GetParameter( aParam, aValue ) ) + { + theParams.push_back( aParam.ToCString() ); + theValues.push_back( aValue.ToCString() ); + } + else + nbParamValueErrors++; + } + } + else + nbOperatorErrors++; + } + } + else + { + SetErrorCode("ERROR retrieving operators (GEOMImpl_IHealingOperations)"); + } + + if (nbOperatorErrors || nbParamValueErrors) { + TCollection_AsciiString aMsg ("ERRORS retrieving ShapeProcess parameters (GEOMImpl_IHealingOperations): nbOperatorErrors = "); + aMsg += TCollection_AsciiString(nbOperatorErrors); + aMsg += " ,nbParamValueErrors = "; + aMsg += TCollection_AsciiString(nbParamValueErrors); + MESSAGE(aMsg.ToCString()); + } +} + +//============================================================================= +/*! + * GetParameters + */ +//============================================================================= +bool GEOMImpl_IHealingOperations::GetParameters (const string theOperation, + list& theParams) +{ + if ( theOperation == "SplitAngle" ) { + theParams.push_back( "SplitAngle.Angle" ); + theParams.push_back( "SplitAngle.MaxTolerance" ); + + } else if ( theOperation == "SplitClosedFaces" ) { + theParams.push_back( "SplitClosedFaces.NbSplitPoints" ); + + } else if ( theOperation == "FixFaceSize" ) { + theParams.push_back( "FixFaceSize.Tolerance" ); + + } else if( theOperation == "DropSmallEdges" ) { + theParams.push_back( "DropSmallEdges.Tolerance3d" ); + + } else if( theOperation == "BSplineRestriction" ) { + theParams.push_back( "BSplineRestriction.SurfaceMode" ); + theParams.push_back( "BSplineRestriction.Curve3dMode" ); + theParams.push_back( "BSplineRestriction.Curve2dMode" ); + theParams.push_back( "BSplineRestriction.Tolerance3d" ); + theParams.push_back( "BSplineRestriction.Tolerance2d" ); + theParams.push_back( "BSplineRestriction.RequiredDegree" ); + theParams.push_back( "BSplineRestriction.RequiredNbSegments" ); + theParams.push_back( "BSplineRestriction.Continuity3d" ); + theParams.push_back( "BSplineRestriction.Continuity2d" ); + + } else if( theOperation == "SplitContinuity" ) { + theParams.push_back( "SplitContinuity.Tolerance3d" ); + theParams.push_back( "SplitContinuity.SurfaceContinuity" ); + theParams.push_back( "SplitContinuity.CurveContinuity" ); + + } else if( theOperation == "ToBezier" ) { + theParams.push_back( "ToBezier.SurfaceMode" ); + theParams.push_back( "ToBezier.Curve3dMode" ); + theParams.push_back( "ToBezier.Curve2dMode" ); + theParams.push_back( "ToBezier.MaxTolerance" ); + + } else if( theOperation == "SameParameter" ) { + theParams.push_back( "SameParameter.Tolerance3d" ); + + } else if( theOperation == "FixShape" ) { + theParams.push_back( "FixShape.Tolerance3d" ); + theParams.push_back( "FixShape.MaxTolerance3d" ); + + } else { + return false; + } + + return true; +} + +//============================================================================= +/*! + * SuppressFaces + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IHealingOperations::SuppressFaces (Handle(GEOM_Object) theObject, + const Handle(TColStd_HArray1OfInteger)& theFaces) +{ + // set error code, check parameters + SetErrorCode(KO); + + if ( theObject.IsNull() ) // if theFaces.IsNull() - it's OK, it means that ALL faces must be removed.. + return NULL; + + Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction(); + if(aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed + + // Add a new object + Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY ); + + //Add the function + aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), SUPPRESS_FACES); + + if(aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if(aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL; + + // prepare "data container" class IHealing + GEOMImpl_IHealing HI(aFunction); + HI.SetFaces( theFaces ); + HI.SetOriginal( aLastFunction ); + + //Compute the translation + try + { + if (!GetSolver()->ComputeFunction(aFunction)) + { + SetErrorCode("Healing driver failed"); + return NULL; + } + } + catch (Standard_Failure) + { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + // ... + // ... missing ... + + SetErrorCode(OK); + return aNewObject; +} + + +//============================================================================= +/*! + * CloseContour + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IHealingOperations::CloseContour (Handle(GEOM_Object) theObject, + const Handle(TColStd_HArray1OfInteger)& theWires, + bool isCommonVertex) +{ + // set error code, check parameters + SetErrorCode(KO); + + if (theObject.IsNull()) + return NULL; + + Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction(); + if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed + + // Add a new object + Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY ); + + //Add the function + aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), CLOSE_CONTOUR); + + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if(aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL; + + // prepare "data container" class IHealing + GEOMImpl_IHealing HI(aFunction); + HI.SetWires( theWires ); + HI.SetIsCommonVertex( isCommonVertex ); + HI.SetOriginal( aLastFunction ); + + //Compute the translation + try + { + if (!GetSolver()->ComputeFunction(aFunction)) + { + SetErrorCode("Healing driver failed"); + return NULL; + } + } + catch (Standard_Failure) + { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + // ... + // ... missing ... + + SetErrorCode(OK); + return aNewObject; +} + +//============================================================================= +/*! + * RemoveIntWires + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IHealingOperations::RemoveIntWires (Handle(GEOM_Object) theObject, + const Handle(TColStd_HArray1OfInteger)& theWires) +{ + // set error code, check parameters + SetErrorCode(KO); + + if (theObject.IsNull()) // if theWires is NULL it's OK, it means that ALL wires must be removed + return NULL; + + Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction(); + if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed + + // Add a new object + Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY ); + + //Add the function + aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), REMOVE_INT_WIRES); + + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL; + + // prepare "data container" class IHealing + GEOMImpl_IHealing HI(aFunction); + HI.SetWires( theWires ); + HI.SetOriginal( aLastFunction ); + + //Compute the translation + try + { + if (!GetSolver()->ComputeFunction(aFunction)) + { + SetErrorCode("Healing driver failed"); + return NULL; + } + } + catch (Standard_Failure) + { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + // ... + // ... missing ... + + SetErrorCode(OK); + return aNewObject; +} + +//============================================================================= +/*! + * FillHoles + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IHealingOperations::FillHoles (Handle(GEOM_Object) theObject, + const Handle(TColStd_HArray1OfInteger)& theWires) +{ + // set error code, check parameters + SetErrorCode(KO); + + if (theObject.IsNull()) // if theWires is NULL it's OK, it means that ALL holes must be removed + return NULL; + + Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction(); + if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed + + // Add a new object + Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY ); + + //Add the function + aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), FILL_HOLES); + + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL; + + // prepare "data container" class IHealing + GEOMImpl_IHealing HI(aFunction); + HI.SetWires( theWires ); + HI.SetOriginal( aLastFunction ); + + //Compute the translation + try + { + if (!GetSolver()->ComputeFunction(aFunction)) + { + SetErrorCode("Healing driver failed"); + return NULL; + } + } + catch (Standard_Failure) + { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + // ... + // ... missing ... + + SetErrorCode(OK); + return aNewObject; +} + +//============================================================================= +/*! + * Sew + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IHealingOperations::Sew (Handle(GEOM_Object) theObject, + double theTolerance) +{ + // set error code, check parameters + SetErrorCode(KO); + + if (theObject.IsNull()) + return NULL; + + Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction(); + if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed + + // Add a new object + Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY ); + + //Add the function + aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), SEWING); + + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL; + + // prepare "data container" class IHealing + GEOMImpl_IHealing HI(aFunction); + HI.SetTolerance( theTolerance ); + HI.SetOriginal( aLastFunction ); + + //Compute the translation + try + { + if (!GetSolver()->ComputeFunction(aFunction)) + { + SetErrorCode("Healing driver failed"); + return NULL; + } + } + catch (Standard_Failure) + { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + // ... + // ... missing ... + + SetErrorCode(OK); + return aNewObject; +} + +//============================================================================= +/*! + * DivideEdge + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IHealingOperations::DivideEdge (Handle(GEOM_Object) theObject, + int theIndex, + double theValue, + bool isByParameter) +{ + // set error code, check parameters + SetErrorCode(KO); + + if (theObject.IsNull()) + return NULL; + + Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction(); + if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed + + // Add a new object + Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY ); + + //Add the function + aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), DIVIDE_EDGE); + + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL; + + // prepare "data container" class IHealing + GEOMImpl_IHealing HI(aFunction); + HI.SetIndex( theIndex ); + HI.SetDevideEdgeValue( theValue ); + HI.SetIsByParameter( isByParameter ); + HI.SetOriginal( aLastFunction ); + + //Compute the translation + try + { + if (!GetSolver()->ComputeFunction(aFunction)) + { + SetErrorCode("Healing driver failed"); + return NULL; + } + } + catch (Standard_Failure) + { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + // ... + // ... missing ... + + SetErrorCode(OK); + return aNewObject; +} + +//============================================================================= +/*! + * GetFreeBoundary + */ +//============================================================================= +bool GEOMImpl_IHealingOperations::GetFreeBoundary (Handle(GEOM_Object) theObject, + Handle(TColStd_HSequenceOfTransient)& theClosed, + Handle(TColStd_HSequenceOfTransient)& theOpen ) +{ + // set error code, check parameters + SetErrorCode(KO); + + if ( theObject.IsNull() || theClosed.IsNull() || theOpen.IsNull() ) + return false; + + TopoDS_Shape aShape = theObject->GetValue(); + if ( aShape.IsNull() ) + return false; + + // get free boundary shapes + ShapeAnalysis_FreeBounds anAnalizer( aShape ); + TopoDS_Compound aClosed = anAnalizer.GetClosedWires(); + TopoDS_Compound anOpen = anAnalizer.GetOpenWires(); + + // iterate through shapes and append them to the return sequence + Handle(GEOM_Object) anObj; + Handle(GEOM_Function) aFunction; + TopExp_Explorer anExp; + for ( anExp.Init( aClosed, TopAbs_WIRE ); anExp.More(); anExp.Next() ) + { + anObj = GetEngine()->AddObject( GetDocID(), GEOM_FREE_BOUNDS ); + aFunction = anObj->AddFunction( GEOMImpl_CopyDriver::GetID(), COPY_WITHOUT_REF ); + TopoDS_Shape aValueShape = anExp.Current(); + aFunction->SetValue( aValueShape ); + theClosed->Append(anObj); + } + for ( anExp.Init( anOpen, TopAbs_WIRE ); anExp.More(); anExp.Next() ) + { + anObj = GetEngine()->AddObject( GetDocID(), GEOM_FREE_BOUNDS ); + aFunction = anObj->AddFunction( GEOMImpl_CopyDriver::GetID(), COPY_WITHOUT_REF ); + TopoDS_Shape aValueShape = anExp.Current(); + aFunction->SetValue( aValueShape ); + theOpen->Append(anObj); + } + + SetErrorCode(OK); + return true; +} diff --git a/src/GEOMImpl/GEOMImpl_IHealingOperations.hxx b/src/GEOMImpl/GEOMImpl_IHealingOperations.hxx new file mode 100644 index 000000000..b167bcd0d --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_IHealingOperations.hxx @@ -0,0 +1,62 @@ + +#ifndef _GEOMImpl_IHealingOperations_HXX_ +#define _GEOMImpl_IHealingOperations_HXX_ + +#include "GEOM_IOperations.hxx" +#include "GEOM_Engine.hxx" +#include "GEOM_Object.hxx" + +#include +#include + +#include + +class GEOMImpl_IHealingOperations : public GEOM_IOperations { + public: + GEOMImpl_IHealingOperations(GEOM_Engine* theEngine, int theDocID); + ~GEOMImpl_IHealingOperations(); + + // Apply Shape Processing to the selected Object + Handle(GEOM_Object) ShapeProcess( Handle(GEOM_Object) theObject, + const Handle(TColStd_HArray1OfExtendedString)& theOperations, + const Handle(TColStd_HArray1OfExtendedString)& theParams, + const Handle(TColStd_HArray1OfExtendedString)& theValues ); + + // Retrieve default Shape Process parameters (from resource file) + void GetShapeProcessParameters( list& theOperations, + list& theParams, + list& theValues ); + + // returns all parameters that are valid for the given operation (Shape Process operator) + static bool GetParameters( const string theOperation, list& theParams ); + + Handle(GEOM_Object) SuppressFaces( Handle(GEOM_Object) theObject, + const Handle(TColStd_HArray1OfInteger)& theFaces); + + Handle(GEOM_Object) CloseContour( Handle(GEOM_Object) theObject, + const Handle(TColStd_HArray1OfInteger)& theWires, + bool isCommonVertex ); + + Handle(GEOM_Object) RemoveIntWires( Handle(GEOM_Object) theObject, + const Handle(TColStd_HArray1OfInteger)& theWires); + + Handle(GEOM_Object) FillHoles( Handle(GEOM_Object) theObject, + const Handle(TColStd_HArray1OfInteger)& theWires); + + Handle(GEOM_Object) Sew( Handle(GEOM_Object) theObject, + double theTolerance ); + + Handle(GEOM_Object) DivideEdge( Handle(GEOM_Object) theObject, + int theIndex, + double theValue, + bool isByParameter ); + + // this function does not use Function-Driver mechanism, it just computes the free + // boundary edges and returns them in the sequence. It is called just for information reasons + // and it's not intended for history/undo/redo/etc.. + bool GetFreeBoundary ( Handle(GEOM_Object) theObject, + Handle(TColStd_HSequenceOfTransient)& theOutClosedWires, + Handle(TColStd_HSequenceOfTransient)& theOutOpenWires ); +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_IImportExport.hxx b/src/GEOMImpl/GEOMImpl_IImportExport.hxx new file mode 100644 index 000000000..d70a033a9 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_IImportExport.hxx @@ -0,0 +1,32 @@ +//NOTE: This is an intreface to a function for the Import Export operation. + + +#include "GEOM_Function.hxx" + +#define EXP_ARG_REF 1 +#define EXP_ARG_FILE 2 +#define EXP_ARG_PLUG 3 + +class GEOMImpl_IImportExport +{ + public: + + GEOMImpl_IImportExport(Handle(GEOM_Function) theFunction): _func(theFunction) {} + + void SetOriginal(Handle(GEOM_Function) theOriginal) { _func->SetReference(EXP_ARG_REF, theOriginal); } + + Handle(GEOM_Function) GetOriginal() { return _func->GetReference(EXP_ARG_REF); } + + void SetFileName(const TCollection_AsciiString& theFileName) { _func->SetString(EXP_ARG_FILE, theFileName); } + + TCollection_AsciiString GetFileName() { return _func->GetString(EXP_ARG_FILE); } + + void SetPluginName(const TCollection_AsciiString& theFormatName) + { _func->SetString(EXP_ARG_PLUG, theFormatName); } + + TCollection_AsciiString GetPluginName() { return _func->GetString(EXP_ARG_PLUG); } + + private: + + Handle(GEOM_Function) _func; +}; diff --git a/src/GEOMImpl/GEOMImpl_IInsertOperations.cxx b/src/GEOMImpl/GEOMImpl_IInsertOperations.cxx new file mode 100644 index 000000000..520eba58f --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_IInsertOperations.cxx @@ -0,0 +1,393 @@ +using namespace std; + +#include "GEOMImpl_IInsertOperations.hxx" + +#include "utilities.h" +#include "OpUtil.hxx" +#include "Utils_ExceptHandlers.hxx" + +#include +#include +#include +#include + +#include "GEOM_Function.hxx" + +#include "GEOMImpl_CopyDriver.hxx" +#include "GEOMImpl_ExportDriver.hxx" +#include "GEOMImpl_ImportDriver.hxx" + +#include "GEOMImpl_ICopy.hxx" +#include "GEOMImpl_IImportExport.hxx" + +#include "GEOMImpl_Types.hxx" + +#include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC + +//============================================================================= +/*! + * constructor: + */ +//============================================================================= + +GEOMImpl_IInsertOperations::GEOMImpl_IInsertOperations(GEOM_Engine* theEngine, int theDocID) +: GEOM_IOperations(theEngine, theDocID) +{ + MESSAGE("GEOMImpl_IInsertOperations::GEOMImpl_IInsertOperations"); +} + +//============================================================================= +/*! + * destructor + */ +//============================================================================= + +GEOMImpl_IInsertOperations::~GEOMImpl_IInsertOperations() +{ + MESSAGE("GEOMImpl_IInsertOperations::~GEOMImpl_IInsertOperations"); +} + + + +//============================================================================= +/*! + * MakeCopy + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IInsertOperations::MakeCopy(Handle(GEOM_Object) theOriginal) +{ + SetErrorCode(KO); + + if (theOriginal.IsNull()) return NULL; + + //Add a new Copy object + Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), GEOM_COPY); + + //Add a Copy function for creation a copy object + Handle(GEOM_Function) aFunction = aCopy->AddFunction(GEOMImpl_CopyDriver::GetID(), COPY_WITH_REF); + + //Check if the function is set correctly + if(aFunction->GetDriverGUID() != GEOMImpl_CopyDriver::GetID()) return NULL; + + GEOMImpl_ICopy aCI(aFunction); + + Handle(GEOM_Function) aRefFunction = theOriginal->GetLastFunction(); + if (aRefFunction.IsNull()) return NULL; + + aCI.SetOriginal(aRefFunction); + + //Compute the Copy value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Copy driver failed"); + 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+" = IInsertOperations.MakeCopy("); + TDF_Tool::Entry(theOriginal->GetEntry(), anEntry); + aDescr += (anEntry+")"); + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aCopy; +} + +//============================================================================= +/*! + * Export + */ +//============================================================================= +void GEOMImpl_IInsertOperations::Export + (const Handle(GEOM_Object) theOriginal, + const char* theFileName, + const char* theFormatName) +{ + SetErrorCode(KO); + + if (theOriginal.IsNull()) return; + + Handle(GEOM_Function) aRefFunction = theOriginal->GetLastFunction(); + if (aRefFunction.IsNull()) return; //There is no function which creates an object to be exported + + //Add an Export function + Handle(GEOM_Function) aFunction = theOriginal->AddFunction(GEOMImpl_ExportDriver::GetID(), EXPORT_SHAPE); + if (aFunction.IsNull()) return; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_ExportDriver::GetID()) return; + + //Set parameters + GEOMImpl_IImportExport aCI (aFunction); + aCI.SetOriginal(aRefFunction); + char* aFileName = (char*)theFileName; + aCI.SetFileName(aFileName); + + char* aFormatName = (char*)theFormatName; + Handle(TCollection_HAsciiString) aHLibName; + if (!IsSupported(Standard_False, aFormatName, aHLibName)) { + return; + } + TCollection_AsciiString aLibName = aHLibName->String(); + aCI.SetPluginName(aLibName); + + //Perform the Export + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Export driver failed"); + return; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return; + } + + //Make a Python command + TCollection_AsciiString anEntry, aDescr; + aDescr = "IInsertOperations.Export("; + TDF_Tool::Entry(theOriginal->GetEntry(), anEntry); + aDescr += (anEntry + ", "); + aDescr += (TCollection_AsciiString(aFileName) + ", "); + aDescr += (TCollection_AsciiString(aFormatName) + ")"); + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); +} + +//============================================================================= +/*! + * Import + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IInsertOperations::Import + (const char* theFileName, + const char* theFormatName) +{ + SetErrorCode(KO); + + if (!theFileName || !theFormatName) return NULL; + + //Add a new result object + Handle(GEOM_Object) result = GetEngine()->AddObject(GetDocID(), GEOM_IMPORT); + + //Add an Import function + Handle(GEOM_Function) aFunction = result->AddFunction(GEOMImpl_ImportDriver::GetID(), IMPORT_SHAPE); + if (aFunction.IsNull()) return result; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_ImportDriver::GetID()) return result; + + //Set parameters + GEOMImpl_IImportExport aCI (aFunction); + char* aFileName = (char*)theFileName; + aCI.SetFileName(aFileName); + + char* aFormatName = (char*)theFormatName; + Handle(TCollection_HAsciiString) aHLibName; + if (!IsSupported(Standard_True, aFormatName, aHLibName)) { + return result; + } + TCollection_AsciiString aLibName = aHLibName->String(); + aCI.SetPluginName(aLibName); + + //Perform the Import + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Import driver failed"); + 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(result->GetEntry(), anEntry); + aDescr += (anEntry + " = IInsertOperations.Import("); + aDescr += (TCollection_AsciiString(aFileName) + ", "); + aDescr += (TCollection_AsciiString(aFormatName) + ")"); + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return result; +} + +//============================================================================= +/*! + * ImportTranslators + */ +//============================================================================= +Standard_Boolean GEOMImpl_IInsertOperations::ImportTranslators + (Handle(TColStd_HSequenceOfAsciiString)& theFormats, + Handle(TColStd_HSequenceOfAsciiString)& thePatterns) +{ + if (theFormats.IsNull()) + theFormats = new TColStd_HSequenceOfAsciiString; + else + theFormats->Clear(); + + if (thePatterns.IsNull()) + thePatterns = new TColStd_HSequenceOfAsciiString; + else + thePatterns->Clear(); + + if (!InitResMgr()) return Standard_False; + + // Read Import formats list + if (myResMgr->Find("Import")) { + TCollection_AsciiString aFormats (myResMgr->Value("Import")); + TCollection_AsciiString aToken = aFormats.Token("| \t", 1); + int i = 1; + for (; !aToken.IsEmpty(); aToken = aFormats.Token("| \t", ++i)) { + theFormats->Append(aToken); + } + } + + // Read Patterns for each supported format + int j = 1, len = theFormats->Length(); + for (; j <= len; j++) { + TCollection_AsciiString aPattern; + TCollection_AsciiString aKey (theFormats->Value(j)); + aKey += ".Pattern"; + if (myResMgr->Find(aKey.ToCString())) + aPattern = myResMgr->Value(aKey.ToCString()); + else { + aPattern = theFormats->Value(j); + aPattern += " Files ( *.* )"; + } + thePatterns->Append(aPattern); + } + + return (!theFormats->IsEmpty()); +} + +//============================================================================= +/*! + * ExportTranslators + */ +//============================================================================= +Standard_Boolean GEOMImpl_IInsertOperations::ExportTranslators + (Handle(TColStd_HSequenceOfAsciiString)& theFormats, + Handle(TColStd_HSequenceOfAsciiString)& thePatterns) +{ + if (theFormats.IsNull()) + theFormats = new TColStd_HSequenceOfAsciiString; + else + theFormats->Clear(); + + if (thePatterns.IsNull()) + thePatterns = new TColStd_HSequenceOfAsciiString; + else + thePatterns->Clear(); + + if (!InitResMgr()) return Standard_False; + + // Read Export formats list + if (myResMgr->Find("Export")) { + TCollection_AsciiString aFormats (myResMgr->Value("Export")); + TCollection_AsciiString aToken = aFormats.Token("| \t", 1); + int i = 1; + for (; !aToken.IsEmpty(); aToken = aFormats.Token("| \t", ++i)) { + theFormats->Append(aToken); + } + } + + // Read Patterns for each supported format + int j = 1, len = theFormats->Length(); + for (; j <= len; j++) { + TCollection_AsciiString aPattern; + TCollection_AsciiString aKey (theFormats->Value(j)); + aKey += ".Pattern"; + if (myResMgr->Find(aKey.ToCString())) + aPattern = myResMgr->Value(aKey.ToCString()); + else { + aPattern = theFormats->Value(j); + aPattern += " Files ( *.* )"; + } + thePatterns->Append(aPattern); + } + + return (!theFormats->IsEmpty()); +} + +//============================================================================= +/*! + * IsSupported + */ +//============================================================================= +Standard_Boolean GEOMImpl_IInsertOperations::IsSupported + (const Standard_Boolean isImport, + const TCollection_AsciiString theFormat, + Handle(TCollection_HAsciiString)& theLibName) +{ + if (!InitResMgr()) return Standard_False; + + // Import/Export mode + Standard_CString aMode; + if (isImport) aMode = "Import"; + else aMode = "Export"; + + // Read supported formats for the certain mode + if (myResMgr->Find(aMode)) { + TCollection_AsciiString aFormats (myResMgr->Value(aMode)); + if (aFormats.Search(theFormat) > -1) { + // Read library name for the supported format + TCollection_AsciiString aKey (theFormat); + aKey += "."; + aKey += aMode; + if (myResMgr->Find(aKey.ToCString())) { + TCollection_AsciiString aLibName (myResMgr->Value(aKey.ToCString())); + theLibName = new TCollection_HAsciiString (aLibName); + return Standard_True; + } + } + } + + return Standard_False; +} + +//============================================================================= +/*! + * InitResMgr + */ +//============================================================================= +Standard_Boolean GEOMImpl_IInsertOperations::InitResMgr() +{ + if (myResMgr.IsNull()) { + // Initialize the Resource Manager + TCollection_AsciiString aResDir (getenv("GEOM_ROOT_DIR")); +#ifdef WNT + aResDir += "\\share\\salome\\resources"; +#else + aResDir += "/share/salome/resources"; +#endif + TCollection_AsciiString aUserResDir (getenv("HOME")); +#ifdef WNT + aUserResDir += "\\.salome\\resources"; +#else + aUserResDir += "/.salome/resources"; +#endif + myResMgr = new Resource_Manager ("ImportExport", aResDir, aUserResDir, Standard_True); + } + + if (myResMgr->Find("Import") || myResMgr->Find("Export")) + return Standard_True; + + return Standard_False; +} diff --git a/src/GEOMImpl/GEOMImpl_IInsertOperations.hxx b/src/GEOMImpl/GEOMImpl_IInsertOperations.hxx new file mode 100644 index 000000000..953cf3e79 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_IInsertOperations.hxx @@ -0,0 +1,45 @@ + +#ifndef _GEOMImpl_IInsertOperations_HXX_ +#define _GEOMImpl_IInsertOperations_HXX_ + +#include "Utils_SALOME_Exception.hxx" +#include "GEOM_IOperations.hxx" +#include "GEOM_Engine.hxx" +#include "GEOM_Object.hxx" +#include +#include +#include +#include + +class GEOMImpl_IInsertOperations : public GEOM_IOperations { + public: + GEOMImpl_IInsertOperations(GEOM_Engine* theEngine, int theDocID); + ~GEOMImpl_IInsertOperations(); + + + Handle(GEOM_Object) MakeCopy (Handle(GEOM_Object) theOriginal); + + Handle(GEOM_Object) Import (const char* theFileName, const char* theFormatType); + + void Export (const Handle(GEOM_Object) theOriginal, + const char* theFileName, + const char* theFormatType); + + Standard_Boolean ImportTranslators (Handle(TColStd_HSequenceOfAsciiString)& theFormats, + Handle(TColStd_HSequenceOfAsciiString)& thePatterns); + + Standard_Boolean ExportTranslators (Handle(TColStd_HSequenceOfAsciiString)& theFormats, + Handle(TColStd_HSequenceOfAsciiString)& thePatterns); + + Standard_Boolean IsSupported (const Standard_Boolean isImport, + const TCollection_AsciiString theFormat, + Handle(TCollection_HAsciiString)& theLibName); + + private: + Standard_Boolean InitResMgr (); + + private: + Handle(Resource_Manager) myResMgr; +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_ILine.hxx b/src/GEOMImpl/GEOMImpl_ILine.hxx new file mode 100644 index 000000000..7834a5746 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_ILine.hxx @@ -0,0 +1,24 @@ +//NOTE: This is an intreface to a function for the vector creation. + + +#include "GEOM_Function.hxx" + +#define LINE_ARG_PNT1 1 +#define LINE_ARG_PNT2 2 + +class GEOMImpl_ILine +{ + public: + + GEOMImpl_ILine(Handle(GEOM_Function) theFunction): _func(theFunction) {} + + void SetPoint1(Handle(GEOM_Function) theRef) { _func->SetReference(LINE_ARG_PNT1, theRef); } + void SetPoint2(Handle(GEOM_Function) theRef) { _func->SetReference(LINE_ARG_PNT2, theRef); } + + Handle(GEOM_Function) GetPoint1() { return _func->GetReference(LINE_ARG_PNT1); } + Handle(GEOM_Function) GetPoint2() { return _func->GetReference(LINE_ARG_PNT2); } + + private: + + Handle(GEOM_Function) _func; +}; diff --git a/src/GEOMImpl/GEOMImpl_ILocalOperations.cxx b/src/GEOMImpl/GEOMImpl_ILocalOperations.cxx new file mode 100644 index 000000000..5df5db458 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_ILocalOperations.cxx @@ -0,0 +1,554 @@ +using namespace std; + +#include "GEOMImpl_ILocalOperations.hxx" + +#include "GEOM_Function.hxx" +#include "GEOMImpl_Types.hxx" + +#include "GEOMImpl_FilletDriver.hxx" +#include "GEOMImpl_ChamferDriver.hxx" + +#include "GEOMImpl_IFillet.hxx" +#include "GEOMImpl_IChamfer.hxx" + +#include "GEOMImpl_IArchimede.hxx" +#include "GEOMImpl_ArchimedeDriver.hxx" + +#include "utilities.h" +#include "OpUtil.hxx" +#include "Utils_ExceptHandlers.hxx" + +#include +#include +#include +#include + +#include +#include +#include + +#include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC + +//============================================================================= +/*! + * constructor: + */ +//============================================================================= +GEOMImpl_ILocalOperations::GEOMImpl_ILocalOperations (GEOM_Engine* theEngine, int theDocID) +: GEOM_IOperations(theEngine, theDocID) +{ + MESSAGE("GEOMImpl_ILocalOperations::GEOMImpl_ILocalOperations"); +} + +//============================================================================= +/*! + * destructor + */ +//============================================================================= +GEOMImpl_ILocalOperations::~GEOMImpl_ILocalOperations() +{ + MESSAGE("GEOMImpl_ILocalOperations::~GEOMImpl_ILocalOperations"); +} + + +//============================================================================= +/*! + * MakeFilletAll + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletAll + (Handle(GEOM_Object) theShape, double theR) +{ + SetErrorCode(KO); + + //Add a new Fillet object + Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET); + + //Add a new Fillet function + Handle(GEOM_Function) aFunction = + aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_ALL); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL; + + GEOMImpl_IFillet aCI (aFunction); + + Handle(GEOM_Function) aRefShape = theShape->GetLastFunction(); + if (aRefShape.IsNull()) return NULL; + + aCI.SetShape(aRefShape); + aCI.SetR(theR); + + //Compute the Fillet value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Fillet driver failed"); + 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(aFillet->GetEntry(), anEntry); + aDescr = anEntry + " = ILocalOperations.MakeFilletAll("; + TDF_Tool::Entry(theShape->GetEntry(), anEntry); + aDescr += (anEntry+", "); + aDescr += (TCollection_AsciiString(theR)+")"); + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aFillet; +} + +//============================================================================= +/*! + * MakeFilletEdges + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletEdges + (Handle(GEOM_Object) theShape, double theR, list theEdges) +{ + SetErrorCode(KO); + + //Add a new Fillet object + Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET); + + //Add a new Fillet function + Handle(GEOM_Function) aFunction = + aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_EDGES); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL; + + GEOMImpl_IFillet aCI (aFunction); + + Handle(GEOM_Function) aRefShape = theShape->GetLastFunction(); + if (aRefShape.IsNull()) return NULL; + + aCI.SetShape(aRefShape); + aCI.SetR(theR); + int aLen = theEdges.size(); + aCI.SetLength(aLen); + + int ind = 1; + list::iterator it = theEdges.begin(); + for (; it != theEdges.end(); it++, ind++) { + aCI.SetEdge(ind, (*it)); + } + + //Compute the Fillet value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Fillet driver failed"); + 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(aFillet->GetEntry(), anEntry); + aDescr = anEntry + " = ILocalOperations.MakeFilletEdges("; + TDF_Tool::Entry(theShape->GetEntry(), anEntry); + aDescr += (anEntry+", "); + aDescr += (TCollection_AsciiString(theR)+", ["); + it = theEdges.begin(); + aDescr += (TCollection_AsciiString(*it)+", "); + it++; + for (; it != theEdges.end(); it++) { + aDescr += ", "; + aDescr += TCollection_AsciiString(*it); + } + aDescr += "])"; + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aFillet; +} + +//============================================================================= +/*! + * MakeFilletFaces + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletFaces + (Handle(GEOM_Object) theShape, double theR, list theFaces) +{ + SetErrorCode(KO); + + //Add a new Fillet object + Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET); + + //Add a new Fillet function + Handle(GEOM_Function) aFunction = + aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_FACES); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL; + + GEOMImpl_IFillet aCI (aFunction); + + Handle(GEOM_Function) aRefShape = theShape->GetLastFunction(); + if (aRefShape.IsNull()) return NULL; + + aCI.SetShape(aRefShape); + aCI.SetR(theR); + int aLen = theFaces.size(); + aCI.SetLength(aLen); + + int ind = 1; + list::iterator it = theFaces.begin(); + for (; it != theFaces.end(); it++, ind++) { + aCI.SetFace(ind, (*it)); + } + + //Compute the Fillet value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Fillet driver failed"); + 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(aFillet->GetEntry(), anEntry); + aDescr = anEntry + " = ILocalOperations.MakeFilletFaces("; + TDF_Tool::Entry(theShape->GetEntry(), anEntry); + aDescr += (anEntry+", "); + aDescr += (TCollection_AsciiString(theR)+", ["); + it = theFaces.begin(); + aDescr += (TCollection_AsciiString(*it)+", "); + it++; + for (; it != theFaces.end(); it++) { + aDescr += ", "; + aDescr += TCollection_AsciiString(*it); + } + aDescr += "])"; + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aFillet; +} + +//============================================================================= +/*! + * MakeChamferAll + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferAll (Handle(GEOM_Object) theShape, double theD) +{ + SetErrorCode(KO); + + //Add a new Chamfer object + Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER); + + //Add a new Chamfer function + Handle(GEOM_Function) aFunction = + aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_ALL); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL; + + GEOMImpl_IChamfer aCI (aFunction); + + Handle(GEOM_Function) aRefShape = theShape->GetLastFunction(); + if (aRefShape.IsNull()) return NULL; + + aCI.SetShape(aRefShape); + aCI.SetD(theD); + + //Compute the Chamfer value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Chamfer driver failed"); + 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(aChamfer->GetEntry(), anEntry); + aDescr += anEntry; + aDescr += " = ILocalOperations.MakeChamferAll("; + TDF_Tool::Entry(theShape->GetEntry(), anEntry); + aDescr += (anEntry+", "); + aDescr += (TCollection_AsciiString(theD)+")"); + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aChamfer; +} + +//============================================================================= +/*! + * MakeChamferEdge + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdge + (Handle(GEOM_Object) theShape, double theD1, double theD2, + int theFace1, int theFace2) +{ + SetErrorCode(KO); + + //Add a new Chamfer object + Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER); + + //Add a new Chamfer function + Handle(GEOM_Function) aFunction = + aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGE); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL; + + GEOMImpl_IChamfer aCI (aFunction); + + Handle(GEOM_Function) aRefShape = theShape->GetLastFunction(); + if (aRefShape.IsNull()) return NULL; + + aCI.SetShape(aRefShape); + aCI.SetD1(theD1); + aCI.SetD2(theD2); + aCI.SetFace1(theFace1); + aCI.SetFace2(theFace2); + + //Compute the Chamfer value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Chamfer driver failed"); + 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(aChamfer->GetEntry(), anEntry); + aDescr += anEntry; + aDescr += " = ILocalOperations.MakeChamferEdge("; + TDF_Tool::Entry(theShape->GetEntry(), anEntry); + aDescr += (anEntry+", "); + aDescr += (TCollection_AsciiString(theD1)+", "); + aDescr += (TCollection_AsciiString(theD2)+", "); + aDescr += (TCollection_AsciiString(theFace1)+", "); + aDescr += (TCollection_AsciiString(theFace2)+")"); + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aChamfer; +} + +//============================================================================= +/*! + * MakeChamferFaces + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferFaces + (Handle(GEOM_Object) theShape, double theD1, double theD2, + list theFaces) +{ + SetErrorCode(KO); + + //Add a new Chamfer object + Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER); + + //Add a new Chamfer function + Handle(GEOM_Function) aFunction = + aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_FACES); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL; + + GEOMImpl_IChamfer aCI (aFunction); + + Handle(GEOM_Function) aRefShape = theShape->GetLastFunction(); + if (aRefShape.IsNull()) return NULL; + + aCI.SetShape(aRefShape); + aCI.SetD1(theD1); + aCI.SetD2(theD2); + int aLen = theFaces.size(); + aCI.SetLength(aLen); + + int ind = 1; + list::iterator it = theFaces.begin(); + for (; it != theFaces.end(); it++, ind++) { + aCI.SetFace(ind, (*it)); + } + + //Compute the Chamfer value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Chamfer driver failed"); + 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(aChamfer->GetEntry(), anEntry); + aDescr += anEntry; + aDescr += " = ILocalOperations.MakeChamferFaces("; + TDF_Tool::Entry(theShape->GetEntry(), anEntry); + aDescr += (anEntry+", "); + aDescr += (TCollection_AsciiString(theD1)+", "); + aDescr += (TCollection_AsciiString(theD2)+", ["); + it = theFaces.begin(); + aDescr += (TCollection_AsciiString(*it)+", "); + it++; + for (; it != theFaces.end(); it++) { + aDescr += ", "; + aDescr += TCollection_AsciiString(*it); + } + aDescr += "])"; + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aChamfer; +} + +//============================================================================= +/*! + * Archimede + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeArchimede (Handle(GEOM_Object) theShape, + double theWeight, + double theWaterDensity, + double theMeshingDeflection) +{ + SetErrorCode(KO); + + //Add a new Archimede object + Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_ARCHIMEDE); + + //Add a new Archimede function + Handle(GEOM_Function) aFunction = aChamfer->AddFunction(GEOMImpl_ArchimedeDriver::GetID(), ARCHIMEDE_TYPE); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_ArchimedeDriver::GetID()) return NULL; + + GEOMImpl_IArchimede aAI (aFunction); + + Handle(GEOM_Function) aRefShape = theShape->GetLastFunction(); + if (aRefShape.IsNull()) return NULL; + + aAI.SetBasicShape(aRefShape); + aAI.SetWeight(theWeight); + aAI.SetDensity(theWaterDensity); + aAI.SetDeflection(theMeshingDeflection); + + //Compute the Archimede value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Archimede driver failed"); + 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(aChamfer->GetEntry(), anEntry); + aDescr += anEntry; + aDescr += " = ILocalOperations.MakeArchimede("; + TDF_Tool::Entry(theShape->GetEntry(), anEntry); + aDescr += (anEntry+", "); + aDescr += (TCollection_AsciiString(theWeight)+", "); + aDescr += (TCollection_AsciiString(theWaterDensity)+", "); + aDescr += (TCollection_AsciiString(theMeshingDeflection)+")"); + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aChamfer; +} + +//============================================================================= +/*! + * GetSubShape + */ +//============================================================================= +bool GEOMImpl_ILocalOperations::GetSubShape (const TopoDS_Shape& theShape, const int theIndex, + TopoDS_Shape& theSubShape) +{ + if (theShape.IsNull() || theIndex < 1) + return false; + + TopTools_IndexedMapOfShape anIndices; + TopExp::MapShapes(theShape, anIndices); + if (theIndex > anIndices.Extent()) return false; + theSubShape = anIndices.FindKey(theIndex); + + return true; +} + +//============================================================================= +/*! + * GetSubShapeIndex + */ +//============================================================================= +Standard_Integer GEOMImpl_ILocalOperations::GetSubShapeIndex (Handle(GEOM_Object) theShape, + Handle(GEOM_Object) theSubShape) +{ + SetErrorCode(KO); + + TopoDS_Shape aShape = theShape->GetValue(); + TopoDS_Shape aSubShape = theSubShape->GetValue(); + + if (aShape.IsNull() || aSubShape.IsNull()) return -1; + + TopTools_IndexedMapOfShape anIndices; + TopExp::MapShapes(aShape, anIndices); + if (anIndices.Contains(aSubShape)) { + SetErrorCode(OK); + return anIndices.FindIndex(aSubShape); + } + + return -1; +} diff --git a/src/GEOMImpl/GEOMImpl_ILocalOperations.hxx b/src/GEOMImpl/GEOMImpl_ILocalOperations.hxx new file mode 100644 index 000000000..8b1110810 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_ILocalOperations.hxx @@ -0,0 +1,44 @@ + +#ifndef _GEOMImpl_ILocalOperations_HXX_ +#define _GEOMImpl_ILocalOperations_HXX_ + +#include "Utils_SALOME_Exception.hxx" +#include "GEOM_IOperations.hxx" +#include "GEOM_Engine.hxx" +#include "GEOM_Object.hxx" +#include + +#include + +class GEOMImpl_ILocalOperations : public GEOM_IOperations { + public: + GEOMImpl_ILocalOperations(GEOM_Engine* theEngine, int theDocID); + ~GEOMImpl_ILocalOperations(); + + Handle(GEOM_Object) MakeFilletAll (Handle(GEOM_Object) theShape, double theR); + Handle(GEOM_Object) MakeFilletEdges (Handle(GEOM_Object) theShape, double theR, + list theEdges); + Handle(GEOM_Object) MakeFilletFaces (Handle(GEOM_Object) theShape, double theR, + list theFaces); + + Handle(GEOM_Object) MakeChamferAll (Handle(GEOM_Object) theShape, double theD); + Handle(GEOM_Object) MakeChamferEdge (Handle(GEOM_Object) theShape, + double theD1, double theD2, + int theFace1, int theFace2); + Handle(GEOM_Object) MakeChamferFaces (Handle(GEOM_Object) theShape, + double theD1, double theD2, + list theFaces); + + Handle(GEOM_Object) MakeArchimede (Handle(GEOM_Object) theShape, + double theWeight, double theWaterDensity, + double theMeshingDeflection); + + Standard_Integer GetSubShapeIndex (Handle(GEOM_Object) theShape, + Handle(GEOM_Object) theSubShape); + + static bool GetSubShape (const TopoDS_Shape& theShape, + const int theIndex, + TopoDS_Shape& theSubShape); +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_IMarker.hxx b/src/GEOMImpl/GEOMImpl_IMarker.hxx new file mode 100644 index 000000000..a29e01c62 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_IMarker.hxx @@ -0,0 +1,69 @@ +//NOTE: This is an interface to a function for the local coordinate system creation. + + +#include "GEOM_Function.hxx" + +#define CS_ARG_O_X 1 +#define CS_ARG_O_Y 2 +#define CS_ARG_O_Z 3 + +#define CS_ARG_X_DX 4 +#define CS_ARG_X_DY 5 +#define CS_ARG_X_DZ 6 + +#define CS_ARG_Y_DX 7 +#define CS_ARG_Y_DY 8 +#define CS_ARG_Y_DZ 9 + +class GEOMImpl_IMarker +{ + public: + + GEOMImpl_IMarker(Handle(GEOM_Function) theFunction): _func(theFunction) {} + + void SetOrigin (const double theX, const double theY, const double theZ) + { + _func->SetReal(CS_ARG_O_X, theX); + _func->SetReal(CS_ARG_O_Y, theY); + _func->SetReal(CS_ARG_O_Z, theZ); + } + + void SetXDir (const double theDX, const double theDY, const double theDZ) + { + _func->SetReal(CS_ARG_X_DX, theDX); + _func->SetReal(CS_ARG_X_DY, theDY); + _func->SetReal(CS_ARG_X_DZ, theDZ); + } + + void SetYDir (const double theDX, const double theDY, const double theDZ) + { + _func->SetReal(CS_ARG_Y_DX, theDX); + _func->SetReal(CS_ARG_Y_DY, theDY); + _func->SetReal(CS_ARG_Y_DZ, theDZ); + } + + void GetOrigin (double& theX, double& theY, double& theZ) + { + theX = _func->GetReal(CS_ARG_O_X); + theY = _func->GetReal(CS_ARG_O_Y); + theZ = _func->GetReal(CS_ARG_O_Z); + } + + void GetXDir (double& theDX, double& theDY, double& theDZ) + { + theDX = _func->GetReal(CS_ARG_X_DX); + theDY = _func->GetReal(CS_ARG_X_DY); + theDZ = _func->GetReal(CS_ARG_X_DZ); + } + + void GetYDir (double& theDX, double& theDY, double& theDZ) + { + theDX = _func->GetReal(CS_ARG_Y_DX); + theDY = _func->GetReal(CS_ARG_Y_DY); + theDZ = _func->GetReal(CS_ARG_Y_DZ); + } + + private: + + Handle(GEOM_Function) _func; +}; diff --git a/src/GEOMImpl/GEOMImpl_IMeasure.hxx b/src/GEOMImpl/GEOMImpl_IMeasure.hxx new file mode 100644 index 000000000..f5b07cc77 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_IMeasure.hxx @@ -0,0 +1,22 @@ +// NOTE: This is an interface to a functions for the Measurement + + +#include "GEOM_Function.hxx" + +#define MEASURE_ARG_BASE 1 + +class GEOMImpl_IMeasure +{ + public: + + GEOMImpl_IMeasure(Handle(GEOM_Function) theFunction): _func(theFunction) {} + + void SetBase(Handle(GEOM_Function) theRefBase) + { _func->SetReference(MEASURE_ARG_BASE, theRefBase); } + + Handle(GEOM_Function) GetBase() { return _func->GetReference(MEASURE_ARG_BASE); } + + private: + + Handle(GEOM_Function) _func; +}; diff --git a/src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx b/src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx new file mode 100644 index 000000000..c6c4f1c00 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx @@ -0,0 +1,911 @@ +using namespace std; + +#include "GEOMImpl_IMeasureOperations.hxx" + +#include "GEOMImpl_Types.hxx" +#include "GEOMImpl_MeasureDriver.hxx" +#include "GEOMImpl_IMeasure.hxx" + +#include "GEOM_Function.hxx" + +#include "utilities.h" +#include "OpUtil.hxx" +#include "Utils_ExceptHandlers.hxx" + +#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 + +//============================================================================= +/*! + * constructor: + */ +//============================================================================= +GEOMImpl_IMeasureOperations::GEOMImpl_IMeasureOperations (GEOM_Engine* theEngine, int theDocID) +: GEOM_IOperations(theEngine, theDocID) +{ + MESSAGE("GEOMImpl_IMeasureOperations::GEOMImpl_IMeasureOperations"); +} + +//============================================================================= +/*! + * destructor + */ +//============================================================================= +GEOMImpl_IMeasureOperations::~GEOMImpl_IMeasureOperations() +{ + MESSAGE("GEOMImpl_IMeasureOperations::~GEOMImpl_IMeasureOperations"); +} + + +//============================================================================= +/*! + * GetCentreOfMass + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IMeasureOperations::GetCentreOfMass + (Handle(GEOM_Object) theShape) +{ + SetErrorCode(KO); + + if (theShape.IsNull()) return NULL; + + //Add a new CentreOfMass object + Handle(GEOM_Object) aCDG = GetEngine()->AddObject(GetDocID(), GEOM_CDG); + + //Add a new CentreOfMass function + Handle(GEOM_Function) aFunction = + aCDG->AddFunction(GEOMImpl_MeasureDriver::GetID(), CDG_MEASURE); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_MeasureDriver::GetID()) return NULL; + + GEOMImpl_IMeasure aCI (aFunction); + + Handle(GEOM_Function) aRefShape = theShape->GetLastFunction(); + if (aRefShape.IsNull()) return NULL; + + aCI.SetBase(aRefShape); + + //Compute the CentreOfMass value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Measure driver failed to compute centre of mass"); + 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(aCDG->GetEntry(), anEntry); + aDescr += anEntry + " = IMeasureOperations.MakeCentreOfMass("; + TDF_Tool::Entry(theShape->GetEntry(), anEntry); + aDescr += anEntry + ")"; + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aCDG; +} + +//============================================================================= +/*! + * GetBasicProperties + */ +//============================================================================= +void GEOMImpl_IMeasureOperations::GetBasicProperties (Handle(GEOM_Object) theShape, + Standard_Real& theLength, + Standard_Real& theSurfArea, + Standard_Real& theVolume) +{ + SetErrorCode(KO); + + if (theShape.IsNull()) return; + + Handle(GEOM_Function) aRefShape = theShape->GetLastFunction(); + if (aRefShape.IsNull()) return; + + TopoDS_Shape aShape = aRefShape->GetValue(); + if (aShape.IsNull()) { + SetErrorCode("The Objects has NULL Shape"); + return; + } + + //Compute the parameters + GProp_GProps LProps, SProps; + try { + BRepGProp::LinearProperties(aShape, LProps); + theLength = LProps.Mass(); + + BRepGProp::SurfaceProperties(aShape, SProps); + theSurfArea = SProps.Mass(); + + theVolume = 0.0; + if (aShape.ShapeType() < TopAbs_SHELL) { + for (TopExp_Explorer Exp (aShape, TopAbs_SOLID); Exp.More(); Exp.Next()) { + GProp_GProps VProps; + BRepGProp::VolumeProperties(Exp.Current(), VProps); + theVolume += VProps.Mass(); + } + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return; + } + + SetErrorCode(OK); +} + +//============================================================================= +/*! + * GetInertia + */ +//============================================================================= +void GEOMImpl_IMeasureOperations::GetInertia + (Handle(GEOM_Object) theShape, + Standard_Real& I11, Standard_Real& I12, Standard_Real& I13, + Standard_Real& I21, Standard_Real& I22, Standard_Real& I23, + Standard_Real& I31, Standard_Real& I32, Standard_Real& I33, + Standard_Real& Ix , Standard_Real& Iy , Standard_Real& Iz) +{ + SetErrorCode(KO); + + if (theShape.IsNull()) return; + + Handle(GEOM_Function) aRefShape = theShape->GetLastFunction(); + if (aRefShape.IsNull()) return; + + TopoDS_Shape aShape = aRefShape->GetValue(); + if (aShape.IsNull()) { + SetErrorCode("The Objects has NULL Shape"); + return; + } + + //Compute the parameters + GProp_GProps System; + + try { + if (aShape.ShapeType() == TopAbs_VERTEX || + aShape.ShapeType() == TopAbs_EDGE || + aShape.ShapeType() == TopAbs_WIRE) { + BRepGProp::LinearProperties(aShape, System); + } else if (aShape.ShapeType() == TopAbs_FACE || + aShape.ShapeType() == TopAbs_SHELL) { + BRepGProp::SurfaceProperties(aShape, System); + } else { + BRepGProp::VolumeProperties(aShape, System); + } + gp_Mat I = System.MatrixOfInertia(); + + I11 = I(1,1); + I12 = I(1,2); + I13 = I(1,3); + + I21 = I(2,1); + I22 = I(2,2); + I23 = I(2,3); + + I31 = I(3,1); + I32 = I(3,2); + I33 = I(3,3); + + GProp_PrincipalProps Pr = System.PrincipalProperties(); + Pr.Moments(Ix,Iy,Iz); + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return; + } + + SetErrorCode(OK); +} + +//============================================================================= +/*! + * GetBoundingBox + */ +//============================================================================= +void GEOMImpl_IMeasureOperations::GetBoundingBox + (Handle(GEOM_Object) theShape, + Standard_Real& Xmin, Standard_Real& Xmax, + Standard_Real& Ymin, Standard_Real& Ymax, + Standard_Real& Zmin, Standard_Real& Zmax) +{ + SetErrorCode(KO); + + if (theShape.IsNull()) return; + + Handle(GEOM_Function) aRefShape = theShape->GetLastFunction(); + if (aRefShape.IsNull()) return; + + TopoDS_Shape aShape = aRefShape->GetValue(); + if (aShape.IsNull()) { + SetErrorCode("The Objects has NULL Shape"); + return; + } + + //Compute the parameters + Bnd_Box B; + + try { + BRepBndLib::Add(aShape, B); + B.Get(Xmin, Ymin, Zmin, Xmax, Ymax, Zmax); + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return; + } + + SetErrorCode(OK); +} + +//============================================================================= +/*! + * GetTolerance + */ +//============================================================================= +void GEOMImpl_IMeasureOperations::GetTolerance + (Handle(GEOM_Object) theShape, + Standard_Real& FaceMin, Standard_Real& FaceMax, + Standard_Real& EdgeMin, Standard_Real& EdgeMax, + Standard_Real& VertMin, Standard_Real& VertMax) +{ + SetErrorCode(KO); + + if (theShape.IsNull()) return; + + Handle(GEOM_Function) aRefShape = theShape->GetLastFunction(); + if (aRefShape.IsNull()) return; + + TopoDS_Shape aShape = aRefShape->GetValue(); + if (aShape.IsNull()) { + SetErrorCode("The Objects has NULL Shape"); + return; + } + + //Compute the parameters + Standard_Real T; + FaceMin = EdgeMin = VertMin = RealLast(); + FaceMax = EdgeMax = VertMax = -RealLast(); + + try { + for (TopExp_Explorer ExF (aShape, TopAbs_FACE); ExF.More(); ExF.Next()) { + TopoDS_Face Face = TopoDS::Face(ExF.Current()); + T = BRep_Tool::Tolerance(Face); + if (T > FaceMax) + FaceMax = T; + if (T < FaceMin) + FaceMin = T; + } + for (TopExp_Explorer ExE (aShape, TopAbs_EDGE); ExE.More(); ExE.Next()) { + TopoDS_Edge Edge = TopoDS::Edge(ExE.Current()); + T = BRep_Tool::Tolerance(Edge); + if (T > EdgeMax) + EdgeMax = T; + if (T < EdgeMin) + EdgeMin = T; + } + for (TopExp_Explorer ExV (aShape, TopAbs_VERTEX); ExV.More(); ExV.Next()) { + TopoDS_Vertex Vertex = TopoDS::Vertex(ExV.Current()); + T = BRep_Tool::Tolerance(Vertex); + if (T > VertMax) + VertMax = T; + if (T < VertMin) + VertMin = T; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return; + } + + SetErrorCode(OK); +} + +//============================================================================= +/*! + * CheckShape + */ +//============================================================================= +bool GEOMImpl_IMeasureOperations::CheckShape (Handle(GEOM_Object) theShape, + TCollection_AsciiString& theDump) +{ + SetErrorCode(KO); + + if (theShape.IsNull()) return false; + + Handle(GEOM_Function) aRefShape = theShape->GetLastFunction(); + if (aRefShape.IsNull()) return false; + + TopoDS_Shape aShape = aRefShape->GetValue(); + if (aShape.IsNull()) { + SetErrorCode("The Objects has NULL Shape"); + return false; + } + + //Compute the parameters + bool isValid = false; + try { + BRepCheck_Analyzer ana (aShape, false); + if (ana.IsValid()) { + theDump.Clear(); + isValid = true; + } else { + StructuralDump(ana, aShape, theDump); + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return false; + } + + SetErrorCode(OK); + return isValid; +} + +//============================================================================= +/*! + * WhatIs + */ +//============================================================================= +TCollection_AsciiString GEOMImpl_IMeasureOperations::WhatIs (Handle(GEOM_Object) theShape) +{ + SetErrorCode(KO); + + TCollection_AsciiString Astr; + + if (theShape.IsNull()) return Astr; + + Handle(GEOM_Function) aRefShape = theShape->GetLastFunction(); + if (aRefShape.IsNull()) return Astr; + + TopoDS_Shape aShape = aRefShape->GetValue(); + if (aShape.IsNull()) { + SetErrorCode("The Objects has NULL Shape"); + return Astr; + } + + //Compute the parameters + if (aShape.ShapeType() == TopAbs_EDGE) { + if (BRep_Tool::Degenerated(TopoDS::Edge(aShape))) { + Astr = Astr + " It is a degenerated edge \n"; + } + } + + Astr = Astr + " Number of sub-shapes : \n"; + + try { + int iType, nbTypes [TopAbs_SHAPE]; + for (iType = 0; iType < TopAbs_SHAPE; ++iType) + nbTypes[iType] = 0; + nbTypes[aShape.ShapeType()]++; + + TopTools_MapOfShape aMapOfShape; + aMapOfShape.Add(aShape); + TopTools_ListOfShape aListOfShape; + aListOfShape.Append(aShape); + + TopTools_ListIteratorOfListOfShape itL (aListOfShape); + for (; itL.More(); itL.Next()) { + TopoDS_Iterator it (itL.Value()); + for (; it.More(); it.Next()) { + TopoDS_Shape s = it.Value(); + if (aMapOfShape.Add(s)) { + aListOfShape.Append(s); + nbTypes[s.ShapeType()]++; + } + } + } + + Astr = Astr + " VERTEX : " + TCollection_AsciiString(nbTypes[TopAbs_VERTEX]) + "\n"; + Astr = Astr + " EDGE : " + TCollection_AsciiString(nbTypes[TopAbs_EDGE]) + "\n"; + Astr = Astr + " WIRE : " + TCollection_AsciiString(nbTypes[TopAbs_WIRE]) + "\n"; + Astr = Astr + " FACE : " + TCollection_AsciiString(nbTypes[TopAbs_FACE]) + "\n"; + Astr = Astr + " SHELL : " + TCollection_AsciiString(nbTypes[TopAbs_SHELL]) + "\n"; + Astr = Astr + " SOLID : " + TCollection_AsciiString(nbTypes[TopAbs_SOLID]) + "\n"; + Astr = Astr + " COMPSOLID : " + TCollection_AsciiString(nbTypes[TopAbs_COMPSOLID]) + "\n"; + Astr = Astr + " COMPOUND : " + TCollection_AsciiString(nbTypes[TopAbs_COMPOUND]) + "\n"; + Astr = Astr + " SHAPE : " + TCollection_AsciiString(aMapOfShape.Extent()); + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return Astr; + } + + SetErrorCode(OK); + return Astr; +} + +//============================================================================= +/*! + * GetMinDistance + */ +//============================================================================= +Standard_Real GEOMImpl_IMeasureOperations::GetMinDistance + (Handle(GEOM_Object) theShape1, Handle(GEOM_Object) theShape2, + Standard_Real& X1, Standard_Real& Y1, Standard_Real& Z1, + Standard_Real& X2, Standard_Real& Y2, Standard_Real& Z2) +{ + SetErrorCode(KO); + Standard_Real MinDist = 1.e9; + + if (theShape1.IsNull() || theShape2.IsNull()) return MinDist; + + Handle(GEOM_Function) aRefShape1 = theShape1->GetLastFunction(); + Handle(GEOM_Function) aRefShape2 = theShape2->GetLastFunction(); + if (aRefShape1.IsNull() || aRefShape2.IsNull()) return MinDist; + + TopoDS_Shape aShape1 = aRefShape1->GetValue(); + TopoDS_Shape aShape2 = aRefShape2->GetValue(); + if (aShape1.IsNull() || aShape2.IsNull()) { + SetErrorCode("One of Objects has NULL Shape"); + return MinDist; + } + + //Compute the parameters + try { + BRepExtrema_DistShapeShape dst (aShape1, aShape2); + if (dst.IsDone()) { + gp_Pnt PMin1, PMin2, P1, P2; + + for (int i = 1; i <= dst.NbSolution(); i++) { + P1 = dst.PointOnShape1(i); + P2 = dst.PointOnShape2(i); + + Standard_Real Dist = P1.Distance(P2); + if (MinDist > Dist) { + MinDist = Dist; + PMin1 = P1; + PMin2 = P2; + } + } + + PMin1.Coord(X1, Y1, Z1); + PMin2.Coord(X2, Y2, Z2); + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return MinDist; + } + + SetErrorCode(OK); + return MinDist; +} + +//======================================================================= +//function : PointCoordinates +//purpose : Get coordinates of point +//======================================================================= +void GEOMImpl_IMeasureOperations::PointCoordinates( Handle(GEOM_Object) theShape, + Standard_Real& theX, Standard_Real& theY, Standard_Real& theZ ) +{ + SetErrorCode( KO ); + + if ( theShape.IsNull() ) + return; + + Handle(GEOM_Function) aRefShape = theShape->GetLastFunction(); + if ( aRefShape.IsNull() ) + return; + + TopoDS_Shape aShape = aRefShape->GetValue(); + if ( aShape.IsNull() || aShape.ShapeType() != TopAbs_VERTEX ) + { + SetErrorCode( "Shape must be a vertex" ); + return; + } + + try + { + gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) ); + theX = aPnt.X(); + theY = aPnt.Y(); + theZ = aPnt.Z(); + SetErrorCode( OK ); + } + catch ( Standard_Failure ) + { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode( aFail->GetMessageString() ); + } +} + +//======================================================================= +//function : StructuralDump +//purpose : Structural (data exchange) style of output. +//======================================================================= +void GEOMImpl_IMeasureOperations::StructuralDump (const BRepCheck_Analyzer& theAna, + const TopoDS_Shape& theShape, + TCollection_AsciiString& theDump) +{ + Standard_Integer i; + theDump.Clear(); + theDump += " -- The Shape has problems :\n"; + theDump += " Check Count\n"; + theDump += " ------------------------------------------------\n"; + + Standard_Integer last_stat = (Standard_Integer)BRepCheck_CheckFail; + Handle(TColStd_HArray1OfInteger) NbProblems = + new TColStd_HArray1OfInteger(1, last_stat); + for (i = 1; i <= last_stat; i++) + NbProblems->SetValue(i,0); + + Handle(TopTools_HSequenceOfShape) sl; + sl = new TopTools_HSequenceOfShape(); + TopTools_DataMapOfShapeListOfShape theMap; + theMap.Clear(); + GetProblemShapes(theAna, theShape, sl, NbProblems, theMap); + theMap.Clear(); + + Standard_Integer count = 0; + count = NbProblems->Value((Standard_Integer)BRepCheck_InvalidPointOnCurve); + if (count > 0) { + theDump += " Invalid Point on Curve ................... "; + theDump += TCollection_AsciiString(count) + "\n"; + } + count = NbProblems->Value((Standard_Integer)BRepCheck_InvalidPointOnCurveOnSurface); + if (count > 0) { + theDump += " Invalid Point on CurveOnSurface .......... "; + theDump += TCollection_AsciiString(count) + "\n"; + } + count = NbProblems->Value((Standard_Integer)BRepCheck_InvalidPointOnSurface); + if (count > 0) { + theDump += " Invalid Point on Surface ................. "; + theDump += TCollection_AsciiString(count) + "\n"; + } + count = NbProblems->Value((Standard_Integer)BRepCheck_No3DCurve); + if (count > 0) { + theDump += " No 3D Curve .............................. "; + theDump += TCollection_AsciiString(count) + "\n"; + } + count = NbProblems->Value((Standard_Integer)BRepCheck_Multiple3DCurve); + if (count > 0) { + theDump += " Multiple 3D Curve ........................ "; + theDump += TCollection_AsciiString(count) + "\n"; + } + count = NbProblems->Value((Standard_Integer)BRepCheck_Invalid3DCurve); + if (count > 0) { + theDump += " Invalid 3D Curve ......................... "; + theDump += TCollection_AsciiString(count) + "\n"; + } + count = NbProblems->Value((Standard_Integer)BRepCheck_NoCurveOnSurface); + if (count > 0) { + theDump += " No Curve on Surface ...................... "; + theDump += TCollection_AsciiString(count) + "\n"; + } + count = NbProblems->Value((Standard_Integer)BRepCheck_InvalidCurveOnSurface); + if (count > 0) { + theDump += " Invalid Curve on Surface ................. "; + theDump += TCollection_AsciiString(count) + "\n"; + } + count = NbProblems->Value((Standard_Integer)BRepCheck_InvalidCurveOnClosedSurface); + if (count > 0) { + theDump += " Invalid Curve on closed Surface .......... "; + theDump += TCollection_AsciiString(count) + "\n"; + } + count = NbProblems->Value((Standard_Integer)BRepCheck_InvalidSameRangeFlag); + if (count > 0) { + theDump += " Invalid SameRange Flag ................... "; + theDump += TCollection_AsciiString(count) + "\n"; + } + count = NbProblems->Value((Standard_Integer)BRepCheck_InvalidSameParameterFlag); + if (count > 0) { + theDump += " Invalid SameParameter Flag ............... "; + theDump += TCollection_AsciiString(count) + "\n"; + } + count = NbProblems->Value((Standard_Integer)BRepCheck_InvalidDegeneratedFlag); + if (count > 0) { + theDump += " Invalid Degenerated Flag ................. "; + theDump += TCollection_AsciiString(count) + "\n"; + } + count = NbProblems->Value((Standard_Integer)BRepCheck_FreeEdge); + if (count > 0) { + theDump += " Free Edge ................................ "; + theDump += TCollection_AsciiString(count) + "\n"; + } + count = NbProblems->Value((Standard_Integer)BRepCheck_InvalidMultiConnexity); + if (count > 0) { + theDump += " Invalid MultiConnexity ................... "; + theDump += TCollection_AsciiString(count) + "\n"; + } + count = NbProblems->Value((Standard_Integer)BRepCheck_InvalidRange); + if (count > 0) { + theDump += " Invalid Range ............................ "; + theDump += TCollection_AsciiString(count) + "\n"; + } + count = NbProblems->Value((Standard_Integer)BRepCheck_EmptyWire); + if (count > 0) { + theDump += " Empty Wire ............................... "; + theDump += TCollection_AsciiString(count) + "\n"; + } + count = NbProblems->Value((Standard_Integer)BRepCheck_RedundantEdge); + if (count > 0) { + theDump += " Redundant Edge ........................... "; + theDump += TCollection_AsciiString(count) + "\n"; + } + count = NbProblems->Value((Standard_Integer)BRepCheck_SelfIntersectingWire); + if (count > 0) { + theDump += " Self Intersecting Wire ................... "; + theDump += TCollection_AsciiString(count) + "\n"; + } + count = NbProblems->Value((Standard_Integer)BRepCheck_NoSurface); + if (count > 0) { + theDump += " No Surface ............................... "; + theDump += TCollection_AsciiString(count) + "\n"; + } + count = NbProblems->Value((Standard_Integer)BRepCheck_InvalidWire); + if (count > 0) { + theDump += " Invalid Wire ............................. "; + theDump += TCollection_AsciiString(count) + "\n"; + } + count = NbProblems->Value((Standard_Integer)BRepCheck_RedundantWire); + if (count > 0) { + theDump += " Redundant Wire ........................... "; + theDump += TCollection_AsciiString(count) + "\n"; + } + count = NbProblems->Value((Standard_Integer)BRepCheck_IntersectingWires); + if (count > 0) { + theDump += " Intersecting Wires ....................... "; + theDump += TCollection_AsciiString(count) + "\n"; + } + count = NbProblems->Value((Standard_Integer)BRepCheck_InvalidImbricationOfWires); + if (count > 0) { + theDump += " Invalid Imbrication of Wires ............. "; + theDump += TCollection_AsciiString(count) + "\n"; + } + count = NbProblems->Value((Standard_Integer)BRepCheck_EmptyShell); + if (count > 0) { + theDump += " Empty Shell .............................. "; + theDump += TCollection_AsciiString(count) + "\n"; + } + count = NbProblems->Value((Standard_Integer)BRepCheck_RedundantFace); + if (count > 0) { + theDump += " Redundant Face ........................... "; + theDump += TCollection_AsciiString(count) + "\n"; + } + count = NbProblems->Value((Standard_Integer)BRepCheck_UnorientableShape); + if (count > 0) { + theDump += " Unorientable Shape ....................... "; + theDump += TCollection_AsciiString(count) + "\n"; + } + count = NbProblems->Value((Standard_Integer)BRepCheck_NotClosed); + if (count > 0) { + theDump += " Not Closed ............................... "; + theDump += TCollection_AsciiString(count) + "\n"; + } + count = NbProblems->Value((Standard_Integer)BRepCheck_NotConnected); + if (count > 0) { + theDump += " Not Connected ............................ "; + theDump += TCollection_AsciiString(count) + "\n"; + } + count = NbProblems->Value((Standard_Integer)BRepCheck_SubshapeNotInShape); + if (count > 0) { + theDump += " Subshape not in Shape .................... "; + theDump += TCollection_AsciiString(count) + "\n"; + } + count = NbProblems->Value((Standard_Integer)BRepCheck_BadOrientation); + if (count > 0) { + theDump += " Bad Orientation .......................... "; + theDump += TCollection_AsciiString(count) + "\n"; + } + count = NbProblems->Value((Standard_Integer)BRepCheck_BadOrientationOfSubshape); + if (count > 0) { + theDump += " Bad Orientation of Subshape .............. "; + theDump += TCollection_AsciiString(count) + "\n"; + } + count = NbProblems->Value((Standard_Integer)BRepCheck_CheckFail); + if (count > 0) { + theDump += " checkshape failure ....................... "; + theDump += TCollection_AsciiString(count) + "\n"; + } + + theDump += " ------------------------------------------------\n"; + theDump += "*** Shapes with problems : "; + theDump += TCollection_AsciiString(sl->Length()) + "\n"; + + Standard_Integer nbv, nbe, nbw, nbf, nbs, nbo; + nbv = nbe = nbw = nbf = nbs = nbo = 0; + + for (i = 1; i <= sl->Length(); i++) { + TopoDS_Shape shi = sl->Value(i); + TopAbs_ShapeEnum sti = shi.ShapeType(); + switch (sti) { + case TopAbs_VERTEX : nbv++; break; + case TopAbs_EDGE : nbe++; break; + case TopAbs_WIRE : nbw++; break; + case TopAbs_FACE : nbf++; break; + case TopAbs_SHELL : nbs++; break; + case TopAbs_SOLID : nbo++; break; + default : break; + } + } + + if (nbv > 0) { + theDump += "VERTEX : "; + if (nbv < 10) theDump += " "; + theDump += TCollection_AsciiString(nbv) + "\n"; + } + if (nbe > 0) { + theDump += "EDGE : "; + if (nbe < 10) theDump += " "; + theDump += TCollection_AsciiString(nbe) + "\n"; + } + if (nbw > 0) { + theDump += "WIRE : "; + if (nbw < 10) theDump += " "; + theDump += TCollection_AsciiString(nbw) + "\n"; + } + if (nbf > 0) { + theDump += "FACE : "; + if (nbf < 10) theDump += " "; + theDump += TCollection_AsciiString(nbf) + "\n"; + } + if (nbs > 0) { + theDump += "SHELL : "; + if (nbs < 10) theDump += " "; + theDump += TCollection_AsciiString(nbs) + "\n"; + } + if (nbo > 0) { + theDump += "SOLID : "; + if (nbo < 10) theDump += " "; + theDump += TCollection_AsciiString(nbo) + "\n"; + } +} + +//======================================================================= +//function : GetProblemShapes +// purpose : for StructuralDump +//======================================================================= +void GEOMImpl_IMeasureOperations::GetProblemShapes (const BRepCheck_Analyzer& theAna, + const TopoDS_Shape& theShape, + Handle(TopTools_HSequenceOfShape)& sl, + Handle(TColStd_HArray1OfInteger)& NbProblems, + TopTools_DataMapOfShapeListOfShape& theMap) +{ + for (TopoDS_Iterator iter(theShape); iter.More(); iter.Next()) { + GetProblemShapes(theAna, iter.Value(), sl, NbProblems, theMap); + } + TopAbs_ShapeEnum styp = theShape.ShapeType(); + BRepCheck_ListIteratorOfListOfStatus itl; + if (!theMap.IsBound(theShape)) { + theMap.Bind(theShape,TopTools_ListOfShape()); + + if (!theAna.Result(theShape).IsNull()) { + itl.Initialize(theAna.Result(theShape)->Status()); + // !!! May be, we have to print all the problems, not only the first one ? + if (itl.Value() != BRepCheck_NoError) { + sl->Append(theShape); + BRepCheck_Status stat = itl.Value(); + NbProblems->SetValue((Standard_Integer)stat, + NbProblems->Value((Standard_Integer)stat) + 1); + } + } + } + + switch (styp) { + case TopAbs_EDGE: + GetProblemSub(theAna, theShape, sl, NbProblems, TopAbs_VERTEX, theMap); + break; + case TopAbs_FACE: + GetProblemSub(theAna, theShape, sl, NbProblems, TopAbs_WIRE, theMap); + GetProblemSub(theAna, theShape, sl, NbProblems, TopAbs_EDGE, theMap); + GetProblemSub(theAna, theShape, sl, NbProblems, TopAbs_VERTEX, theMap); + break; + case TopAbs_SHELL: + break; + case TopAbs_SOLID: + GetProblemSub(theAna, theShape, sl, NbProblems, TopAbs_SHELL, theMap); + break; + default: + break; + } +} + +//======================================================================= +//function : Contains +//======================================================================= +static Standard_Boolean Contains (const TopTools_ListOfShape& L, + const TopoDS_Shape& S) +{ + TopTools_ListIteratorOfListOfShape it; + for (it.Initialize(L); it.More(); it.Next()) { + if (it.Value().IsSame(S)) { + return Standard_True; + } + } + return Standard_False; +} + +//======================================================================= +//function : GetProblemSub +// purpose : for StructuralDump +//======================================================================= +void GEOMImpl_IMeasureOperations::GetProblemSub (const BRepCheck_Analyzer& theAna, + const TopoDS_Shape& theShape, + Handle(TopTools_HSequenceOfShape)& sl, + Handle(TColStd_HArray1OfInteger)& NbProblems, + const TopAbs_ShapeEnum Subtype, + TopTools_DataMapOfShapeListOfShape& theMap) +{ + BRepCheck_ListIteratorOfListOfStatus itl; + TopExp_Explorer exp; + for (exp.Init(theShape, Subtype); exp.More(); exp.Next()) { + const TopoDS_Shape& sub = exp.Current(); + + const Handle(BRepCheck_Result)& res = theAna.Result(sub); + for (res->InitContextIterator(); + res->MoreShapeInContext(); + res->NextShapeInContext()) { + if (res->ContextualShape().IsSame(theShape) && !Contains(theMap(sub), theShape)) { + theMap(sub).Append(theShape); + itl.Initialize(res->StatusOnShape()); + + if (itl.Value() != BRepCheck_NoError) { + Standard_Integer ii = 0; + + for (ii = 1; ii <= sl->Length(); ii++) + if (sl->Value(ii).IsSame(sub)) break; + + if (ii > sl->Length()) { + sl->Append(sub); + BRepCheck_Status stat = itl.Value(); + NbProblems->SetValue((Standard_Integer)stat, + NbProblems->Value((Standard_Integer)stat) + 1); + } + for (ii = 1; ii <= sl->Length(); ii++) + if (sl->Value(ii).IsSame(theShape)) break; + if (ii > sl->Length()) { + sl->Append(theShape); + BRepCheck_Status stat = itl.Value(); + NbProblems->SetValue((Standard_Integer)stat, + NbProblems->Value((Standard_Integer)stat) + 1); + } + } + break; + } + } + } +} diff --git a/src/GEOMImpl/GEOMImpl_IMeasureOperations.hxx b/src/GEOMImpl/GEOMImpl_IMeasureOperations.hxx new file mode 100644 index 000000000..9193fb91b --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_IMeasureOperations.hxx @@ -0,0 +1,74 @@ + +#ifndef _GEOMImpl_IMeasureOperations_HXX_ +#define _GEOMImpl_IMeasureOperations_HXX_ + +#include "GEOM_IOperations.hxx" + +#include +#include +#include +#include + +class GEOM_Engine; +class Handle(GEOM_Object); + +class GEOMImpl_IMeasureOperations : public GEOM_IOperations { + public: + GEOMImpl_IMeasureOperations(GEOM_Engine* theEngine, int theDocID); + ~GEOMImpl_IMeasureOperations(); + + Handle(GEOM_Object) GetCentreOfMass (Handle(GEOM_Object) theShape); + + void GetBasicProperties (Handle(GEOM_Object) theShape, + Standard_Real& theLength, + Standard_Real& theSurfArea, + Standard_Real& theVolume); + + void GetInertia (Handle(GEOM_Object) theShape, + Standard_Real& I11, Standard_Real& I12, Standard_Real& I13, + Standard_Real& I21, Standard_Real& I22, Standard_Real& I23, + Standard_Real& I31, Standard_Real& I32, Standard_Real& I33, + Standard_Real& Ix , Standard_Real& Iy , Standard_Real& Iz); + + void GetBoundingBox (Handle(GEOM_Object) theShape, + Standard_Real& Xmin, Standard_Real& Xmax, + Standard_Real& Ymin, Standard_Real& Ymax, + Standard_Real& Zmin, Standard_Real& Zmax); + + void GetTolerance (Handle(GEOM_Object) theShape, + Standard_Real& FaceMin, Standard_Real& FaceMax, + Standard_Real& EdgeMin, Standard_Real& EdgeMax, + Standard_Real& VertMin, Standard_Real& VertMax); + + bool CheckShape (Handle(GEOM_Object) theShape, + TCollection_AsciiString& theDump); + + TCollection_AsciiString WhatIs (Handle(GEOM_Object) theShape); + + Standard_Real GetMinDistance (Handle(GEOM_Object) theShape1, Handle(GEOM_Object) theShape2, + Standard_Real& X1, Standard_Real& Y1, Standard_Real& Z1, + Standard_Real& X2, Standard_Real& Y2, Standard_Real& Z2); + + void PointCoordinates( Handle(GEOM_Object) theShape, + Standard_Real& theX, Standard_Real& theY, Standard_Real& theZ ); + + private: + void StructuralDump (const BRepCheck_Analyzer& theAna, + const TopoDS_Shape& theShape, + TCollection_AsciiString& theDump); + + void GetProblemShapes (const BRepCheck_Analyzer& theAna, + const TopoDS_Shape& theShape, + Handle(TopTools_HSequenceOfShape)& sl, + Handle(TColStd_HArray1OfInteger)& NbProblems, + TopTools_DataMapOfShapeListOfShape& theMap); + + void GetProblemSub (const BRepCheck_Analyzer& theAna, + const TopoDS_Shape& theShape, + Handle(TopTools_HSequenceOfShape)& sl, + Handle(TColStd_HArray1OfInteger)& NbProblems, + const TopAbs_ShapeEnum Subtype, + TopTools_DataMapOfShapeListOfShape& theMap); +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_IMirror.hxx b/src/GEOMImpl/GEOMImpl_IMirror.hxx new file mode 100644 index 000000000..dcaff0d19 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_IMirror.hxx @@ -0,0 +1,30 @@ +//NOTE: This is an intreface to a function for the Mirror creation. + + +#include "GEOM_Function.hxx" + +#define MIRROR_ARG_ORIGINAL 1 +#define MIRROR_ARG_PLANE 2 +#define MIRROR_ARG_AXIS 3 +#define MIRROR_ARG_POINT 4 + +class GEOMImpl_IMirror +{ + public: + + GEOMImpl_IMirror(Handle(GEOM_Function) theFunction): _func(theFunction) {} + + void SetOriginal(Handle(GEOM_Function) theShape) { _func->SetReference(MIRROR_ARG_ORIGINAL, theShape); } + void SetPlane (Handle(GEOM_Function) thePlane) { _func->SetReference(MIRROR_ARG_PLANE, thePlane); } + void SetAxis (Handle(GEOM_Function) theAxis ) { _func->SetReference(MIRROR_ARG_AXIS , theAxis ); } + void SetPoint (Handle(GEOM_Function) thePoint) { _func->SetReference(MIRROR_ARG_POINT, thePoint); } + + Handle(GEOM_Function) GetOriginal() { return _func->GetReference(MIRROR_ARG_ORIGINAL); } + Handle(GEOM_Function) GetPlane() { return _func->GetReference(MIRROR_ARG_PLANE); } + Handle(GEOM_Function) GetAxis () { return _func->GetReference(MIRROR_ARG_AXIS ); } + Handle(GEOM_Function) GetPoint() { return _func->GetReference(MIRROR_ARG_POINT); } + + private: + + Handle(GEOM_Function) _func; +}; diff --git a/src/GEOMImpl/GEOMImpl_IOffset.hxx b/src/GEOMImpl/GEOMImpl_IOffset.hxx new file mode 100644 index 000000000..91434247c --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_IOffset.hxx @@ -0,0 +1,26 @@ +//NOTE: This is an intreface to a function for the Offset creation. + + +#include "GEOM_Function.hxx" + +#define OFF_ARG_SHAPE 1 +#define OFF_ARG_VALUE 2 + +class GEOMImpl_IOffset +{ + public: + + GEOMImpl_IOffset(Handle(GEOM_Function) theFunction): _func(theFunction) {} + + void SetShape(Handle(GEOM_Function) theShape) { _func->SetReference(OFF_ARG_SHAPE, theShape); } + + Handle(GEOM_Function) GetShape() { return _func->GetReference(OFF_ARG_SHAPE); } + + void SetValue(double theValue) { _func->SetReal(OFF_ARG_VALUE, theValue); } + + double GetValue() { return _func->GetReal(OFF_ARG_VALUE); } + + private: + + Handle(GEOM_Function) _func; +}; diff --git a/src/GEOMImpl/GEOMImpl_IPartition.hxx b/src/GEOMImpl/GEOMImpl_IPartition.hxx new file mode 100644 index 000000000..d89e7796f --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_IPartition.hxx @@ -0,0 +1,63 @@ +//NOTE: This is an intreface to a function for the Partition creation. + + +#include "GEOM_Function.hxx" + +#include "TColStd_HSequenceOfTransient.hxx" +#include "TColStd_HArray1OfInteger.hxx" + +#define PART_ARG_LIMIT 1 +#define PART_ARG_SHAPES 2 +#define PART_ARG_TOOLS 3 +#define PART_ARG_KEEP_IN 4 +#define PART_ARG_REM_IN 5 + +#define PART_ARG_MATERIALS 6 + +#define PART_ARG_SHAPE 7 +#define PART_ARG_PLANE 8 + +class GEOMImpl_IPartition +{ + public: + + GEOMImpl_IPartition(Handle(GEOM_Function) theFunction): _func(theFunction) {} + + void SetLimit(int theLimit) { _func->SetInteger(PART_ARG_LIMIT, theLimit); } + + void SetShapes(const Handle(TColStd_HSequenceOfTransient)& theShapes) + { _func->SetReferenceList(PART_ARG_SHAPES, theShapes); } + + void SetTools(const Handle(TColStd_HSequenceOfTransient)& theShapes) + { _func->SetReferenceList(PART_ARG_TOOLS, theShapes); } + + void SetKeepIns(const Handle(TColStd_HSequenceOfTransient)& theShapes) + { _func->SetReferenceList(PART_ARG_KEEP_IN, theShapes); } + + void SetRemoveIns(const Handle(TColStd_HSequenceOfTransient)& theShapes) + { _func->SetReferenceList(PART_ARG_REM_IN, theShapes); } + + void SetMaterials(const Handle(TColStd_HArray1OfInteger)& theMaterials) + { _func->SetIntegerArray(PART_ARG_MATERIALS, theMaterials); } + + + int GetLimit() { return _func->GetInteger(PART_ARG_LIMIT); } + + Handle(TColStd_HSequenceOfTransient) GetShapes() { return _func->GetReferenceList(PART_ARG_SHAPES); } + Handle(TColStd_HSequenceOfTransient) GetTools() { return _func->GetReferenceList(PART_ARG_TOOLS); } + Handle(TColStd_HSequenceOfTransient) GetKeepIns() { return _func->GetReferenceList(PART_ARG_KEEP_IN); } + Handle(TColStd_HSequenceOfTransient) GetRemoveIns() { return _func->GetReferenceList(PART_ARG_REM_IN); } + + Handle(TColStd_HArray1OfInteger) GetMaterials() { return _func->GetIntegerArray(PART_ARG_MATERIALS); } + + + void SetShape(Handle(GEOM_Function) theShape) { _func->SetReference(PART_ARG_SHAPE, theShape); } + void SetPlane(Handle(GEOM_Function) thePlane) { _func->SetReference(PART_ARG_PLANE, thePlane); } + + Handle(GEOM_Function) GetShape() { return _func->GetReference(PART_ARG_SHAPE); } + Handle(GEOM_Function) GetPlane() { return _func->GetReference(PART_ARG_PLANE); } + + private: + + Handle(GEOM_Function) _func; +}; diff --git a/src/GEOMImpl/GEOMImpl_IPipe.hxx b/src/GEOMImpl/GEOMImpl_IPipe.hxx new file mode 100644 index 000000000..4c104c5d4 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_IPipe.hxx @@ -0,0 +1,24 @@ +//NOTE: This is an intreface to a function for the Pipe creation. + + +#include "GEOM_Function.hxx" + +#define PIPE_ARG_BASE 1 +#define PIPE_ARG_PATH 2 + +class GEOMImpl_IPipe +{ + public: + + GEOMImpl_IPipe(Handle(GEOM_Function) theFunction): _func(theFunction) {} + + void SetBase (Handle(GEOM_Function) theBase) { _func->SetReference(PIPE_ARG_BASE, theBase); } + void SetPath (Handle(GEOM_Function) thePath) { _func->SetReference(PIPE_ARG_PATH, thePath); } + + Handle(GEOM_Function) GetBase() { return _func->GetReference(PIPE_ARG_BASE); } + Handle(GEOM_Function) GetPath() { return _func->GetReference(PIPE_ARG_PATH); } + + private: + + Handle(GEOM_Function) _func; +}; diff --git a/src/GEOMImpl/GEOMImpl_IPlane.hxx b/src/GEOMImpl/GEOMImpl_IPlane.hxx new file mode 100644 index 000000000..2353decb1 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_IPlane.hxx @@ -0,0 +1,47 @@ +//NOTE: This is an intreface to a function for the vector creation. + + +#include "GEOM_Function.hxx" + +#define PLN_ARG_SIZE 1 + +#define PLN_ARG_PNT1 2 +#define PLN_ARG_PNT2 3 +#define PLN_ARG_PNT3 4 + +#define PLN_ARG_VEC 5 + +#define PLN_ARG_REF 6 + +class GEOMImpl_IPlane +{ + public: + + GEOMImpl_IPlane(Handle(GEOM_Function) theFunction): _func(theFunction) {} + + void SetSize(double theSize) { _func->SetReal(PLN_ARG_SIZE, theSize); } + + double GetSize() { return _func->GetReal(PLN_ARG_SIZE); } + + void SetPoint (Handle(GEOM_Function) theRef) { _func->SetReference(PLN_ARG_PNT1, theRef); } + void SetVector(Handle(GEOM_Function) theRef) { _func->SetReference(PLN_ARG_VEC , theRef); } + + void SetFace (Handle(GEOM_Function) theRef) { _func->SetReference(PLN_ARG_REF , theRef); } + + void SetPoint1(Handle(GEOM_Function) theRef) { _func->SetReference(PLN_ARG_PNT1, theRef); } + void SetPoint2(Handle(GEOM_Function) theRef) { _func->SetReference(PLN_ARG_PNT2, theRef); } + void SetPoint3(Handle(GEOM_Function) theRef) { _func->SetReference(PLN_ARG_PNT3, theRef); } + + Handle(GEOM_Function) GetPoint () { return _func->GetReference(PLN_ARG_PNT1); } + Handle(GEOM_Function) GetVector() { return _func->GetReference(PLN_ARG_VEC ); } + + Handle(GEOM_Function) GetFace () { return _func->GetReference(PLN_ARG_REF ); } + + Handle(GEOM_Function) GetPoint1() { return _func->GetReference(PLN_ARG_PNT1); } + Handle(GEOM_Function) GetPoint2() { return _func->GetReference(PLN_ARG_PNT2); } + Handle(GEOM_Function) GetPoint3() { return _func->GetReference(PLN_ARG_PNT3); } + + private: + + Handle(GEOM_Function) _func; +}; diff --git a/src/GEOMImpl/GEOMImpl_IPoint.hxx b/src/GEOMImpl/GEOMImpl_IPoint.hxx new file mode 100755 index 000000000..61c424e0e --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_IPoint.hxx @@ -0,0 +1,44 @@ +//NOTE: This is an intreface to a function for the point creation. + + +#include "GEOM_Function.hxx" + +#define ARG_X 1 +#define ARG_Y 2 +#define ARG_Z 3 + +#define ARG_REF 4 + +#define ARG_PARAM 5 +#define ARG_CURVE 6 + +class GEOMImpl_IPoint +{ + public: + + GEOMImpl_IPoint(Handle(GEOM_Function) theFunction): _func(theFunction) {} + + void SetX(double theX) { _func->SetReal(ARG_X, theX); } + void SetY(double theY) { _func->SetReal(ARG_Y, theY); } + void SetZ(double theZ) { _func->SetReal(ARG_Z, theZ); } + + double GetX() { return _func->GetReal(ARG_X); } + double GetY() { return _func->GetReal(ARG_Y); } + double GetZ() { return _func->GetReal(ARG_Z); } + + void SetRef(Handle(GEOM_Function) theRefPoint) { _func->SetReference(ARG_REF, theRefPoint); } + + Handle(GEOM_Function) GetRef() { return _func->GetReference(ARG_REF); } + + void SetCurve(Handle(GEOM_Function) theRef) { _func->SetReference(ARG_CURVE, theRef); } + + Handle(GEOM_Function) GetCurve() { return _func->GetReference(ARG_CURVE); } + + void SetParameter(double theParam) { _func->SetReal(ARG_PARAM, theParam); } + + double GetParameter() { return _func->GetReal(ARG_PARAM); } + + private: + + Handle(GEOM_Function) _func; +}; diff --git a/src/GEOMImpl/GEOMImpl_IPolyline.hxx b/src/GEOMImpl/GEOMImpl_IPolyline.hxx new file mode 100644 index 000000000..89f424823 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_IPolyline.hxx @@ -0,0 +1,26 @@ +//NOTE: This is an intreface to a function for the Polyline creation. + + +#include "GEOM_Function.hxx" + +#define POLY_ARG_LENG 1 +#define POLY_ARG_LAST 1 + +class GEOMImpl_IPolyline +{ + public: + + GEOMImpl_IPolyline(Handle(GEOM_Function) theFunction): _func(theFunction) {} + + void SetLength(int theLen) { _func->SetInteger(POLY_ARG_LENG, theLen); } + + void SetPoint(int theId, Handle(GEOM_Function) theP) { _func->SetReference(POLY_ARG_LAST + theId, theP); } + + int GetLength() { return _func->GetInteger(POLY_ARG_LENG); } + + Handle(GEOM_Function) GetPoint(int theId) { return _func->GetReference(POLY_ARG_LAST + theId); } + + private: + + Handle(GEOM_Function) _func; +}; diff --git a/src/GEOMImpl/GEOMImpl_IPosition.hxx b/src/GEOMImpl/GEOMImpl_IPosition.hxx new file mode 100644 index 000000000..1e745a7c2 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_IPosition.hxx @@ -0,0 +1,33 @@ +//NOTE: This is an intreface to a function for the Setting In Position. + + +#include "GEOM_Function.hxx" + +#define POSITION_ARG_SHAPE 1 +#define POSITION_ARG_START_LCS 2 +#define POSITION_ARG_END_LCS 3 + +class GEOMImpl_IPosition +{ + public: + + GEOMImpl_IPosition(Handle(GEOM_Function) theFunction): _func(theFunction) {} + + void SetShape(Handle(GEOM_Function) theShape) { _func->SetReference(POSITION_ARG_SHAPE, theShape); } + + Handle(GEOM_Function) GetShape() { return _func->GetReference(POSITION_ARG_SHAPE); } + + void SetStartLCS(Handle(GEOM_Function) theStartLCS) + { _func->SetReference(POSITION_ARG_START_LCS, theStartLCS); } + + Handle(GEOM_Function) GetStartLCS() { return _func->GetReference(POSITION_ARG_START_LCS); } + + void SetEndLCS(Handle(GEOM_Function) theEndLCS) + { _func->SetReference(POSITION_ARG_END_LCS, theEndLCS); } + + Handle(GEOM_Function) GetEndLCS() { return _func->GetReference(POSITION_ARG_END_LCS); } + + private: + + Handle(GEOM_Function) _func; +}; diff --git a/src/GEOMImpl/GEOMImpl_IPrism.hxx b/src/GEOMImpl/GEOMImpl_IPrism.hxx new file mode 100644 index 000000000..a3da6d399 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_IPrism.hxx @@ -0,0 +1,35 @@ +//NOTE: This is an intreface to a function for the Prism creation. + + +#include "GEOM_Function.hxx" + +#define PRISM_ARG_H 1 +#define PRISM_ARG_VEC 2 +#define PRISM_ARG_BASE 3 +#define PRISM_ARG_PNT_F 4 +#define PRISM_ARG_PNT_L 5 + +class GEOMImpl_IPrism +{ + public: + + GEOMImpl_IPrism(Handle(GEOM_Function) theFunction): _func(theFunction) {} + + void SetBase (Handle(GEOM_Function) theRefBase ) { _func->SetReference(PRISM_ARG_BASE, theRefBase); } + void SetVector(Handle(GEOM_Function) theRefVector) { _func->SetReference(PRISM_ARG_VEC , theRefVector); } + void SetFirstPoint(Handle(GEOM_Function) thePoint) { _func->SetReference(PRISM_ARG_PNT_F, thePoint); } + void SetLastPoint (Handle(GEOM_Function) thePoint) { _func->SetReference(PRISM_ARG_PNT_L, thePoint); } + + Handle(GEOM_Function) GetBase () { return _func->GetReference(PRISM_ARG_BASE); } + Handle(GEOM_Function) GetVector() { return _func->GetReference(PRISM_ARG_VEC ); } + Handle(GEOM_Function) GetFirstPoint() { return _func->GetReference(PRISM_ARG_PNT_F ); } + Handle(GEOM_Function) GetLastPoint () { return _func->GetReference(PRISM_ARG_PNT_L ); } + + void SetH(double theH) { _func->SetReal(PRISM_ARG_H, theH); } + + double GetH() { return _func->GetReal(PRISM_ARG_H); } + + private: + + Handle(GEOM_Function) _func; +}; diff --git a/src/GEOMImpl/GEOMImpl_IRevolution.hxx b/src/GEOMImpl/GEOMImpl_IRevolution.hxx new file mode 100644 index 000000000..e630a6282 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_IRevolution.hxx @@ -0,0 +1,31 @@ +//NOTE: This is an intreface to a function for the Revolution creation. + + +#include "GEOM_Function.hxx" + +#define REVOL_ARG_ANGLE 1 +#define REVOL_ARG_AXIS 2 +#define REVOL_ARG_BASE 3 + +class GEOMImpl_IRevolution +{ + public: + + GEOMImpl_IRevolution(Handle(GEOM_Function) theFunction): _func(theFunction) {} + + void SetAngle(double theAngle) { _func->SetReal(REVOL_ARG_ANGLE, theAngle); } + + double GetAngle() { return _func->GetReal(REVOL_ARG_ANGLE); } + + void SetAxis(Handle(GEOM_Function) theRefAxis) { _func->SetReference(REVOL_ARG_AXIS, theRefAxis); } + + Handle(GEOM_Function) GetAxis() { return _func->GetReference(REVOL_ARG_AXIS); } + + void SetBase(Handle(GEOM_Function) theRefBase) { _func->SetReference(REVOL_ARG_BASE, theRefBase); } + + Handle(GEOM_Function) GetBase() { return _func->GetReference(REVOL_ARG_BASE); } + + private: + + Handle(GEOM_Function) _func; +}; diff --git a/src/GEOMImpl/GEOMImpl_IRotate.hxx b/src/GEOMImpl/GEOMImpl_IRotate.hxx new file mode 100644 index 000000000..8b38e4dd8 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_IRotate.hxx @@ -0,0 +1,47 @@ +//NOTE: This is an intreface to a function for the Rotate operation. + + +#include "GEOM_Function.hxx" + +#define ROTATE_ANGLE 1 +#define ROTATE_AXIS 2 +#define ROTATE_ORGN 3 +#define ROTATE_STEP1 4 +#define ROTATE_NBITER1 5 +#define ROTATE_NBITER2 6 + +class GEOMImpl_IRotate +{ + public: + + GEOMImpl_IRotate(Handle(GEOM_Function) theFunction): _func(theFunction) {} + + void SetAngle(Standard_Real theAngle) { _func->SetReal(ROTATE_ANGLE, theAngle); } + + Standard_Real GetAngle() { return _func->GetReal(ROTATE_ANGLE); } + + void SetAxis(Handle(GEOM_Function) theVector) { _func->SetReference(ROTATE_AXIS, theVector); } + + Handle(GEOM_Function) GetAxis() { return _func->GetReference(ROTATE_AXIS); } + + void SetOriginal(Handle(GEOM_Function) theOriginal) { _func->SetReference(ROTATE_ORGN, theOriginal); } + + Handle(GEOM_Function) GetOriginal() { return _func->GetReference(ROTATE_ORGN); } + + void SetStep(double theStep) { return _func->SetReal(ROTATE_STEP1, theStep); } + + double GetStep() { return _func->GetReal(ROTATE_STEP1); } + + void SetNbIter1(int theNbIter) { _func->SetInteger(ROTATE_NBITER1, theNbIter); } + + int GetNbIter1() { return _func->GetInteger(ROTATE_NBITER1); } + + void SetNbIter2(int theNbIter) { _func->SetInteger(ROTATE_NBITER2, theNbIter); } + + int GetNbIter2() { return _func->GetInteger(ROTATE_NBITER2); } + + + private: + + Handle(GEOM_Function) _func; +}; diff --git a/src/GEOMImpl/GEOMImpl_IScale.hxx b/src/GEOMImpl/GEOMImpl_IScale.hxx new file mode 100644 index 000000000..15905e7d1 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_IScale.hxx @@ -0,0 +1,31 @@ +//NOTE: This is an intreface to a function for the Scale creation. + + +#include "GEOM_Function.hxx" + +#define SCALE_ARG_SHAPE 1 +#define SCALE_ARG_VALUE 2 +#define SCALE_ARG_POINT 3 + +class GEOMImpl_IScale +{ + public: + + GEOMImpl_IScale(Handle(GEOM_Function) theFunction): _func(theFunction) {} + + void SetShape(Handle(GEOM_Function) theShape) { _func->SetReference(SCALE_ARG_SHAPE, theShape); } + + Handle(GEOM_Function) GetShape() { return _func->GetReference(SCALE_ARG_SHAPE); } + + void SetFactor(double theValue) { _func->SetReal(SCALE_ARG_VALUE, theValue); } + + double GetFactor() { return _func->GetReal(SCALE_ARG_VALUE); } + + void SetPoint(Handle(GEOM_Function) thePoint) { _func->SetReference(SCALE_ARG_POINT, thePoint); } + + Handle(GEOM_Function) GetPoint() { return _func->GetReference(SCALE_ARG_POINT); } + + private: + + Handle(GEOM_Function) _func; +}; diff --git a/src/GEOMImpl/GEOMImpl_IShapes.hxx b/src/GEOMImpl/GEOMImpl_IShapes.hxx new file mode 100644 index 000000000..64845e7d8 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_IShapes.hxx @@ -0,0 +1,55 @@ +// NOTE: This is an intreface to a function for the Shapes +// (Wire, Face, Shell, Solid and Compound) creation. + + +#include "GEOM_Function.hxx" + +#include "TColStd_HSequenceOfTransient.hxx" +#include "TColStd_HArray1OfInteger.hxx" + +#define SHAPE_ARG_SHAPES 1 // for Wire, Shell, Solid and Compound + +#define SHAPE_ARG_BASE 2 // for Face, Solid and Sub-shape + +#define SHAPE_ARG_PLANAR 3 // for Face + +#define SHAPE_ARG_SUBTYPE 4 // for Sub-shape +#define SHAPE_ARG_INDICES 5 // for Sub-shape + +class GEOMImpl_IShapes +{ + public: + + GEOMImpl_IShapes(Handle(GEOM_Function) theFunction): _func(theFunction) {} + + void SetShapes(const Handle(TColStd_HSequenceOfTransient)& theShapes) + { _func->SetReferenceList(SHAPE_ARG_SHAPES, theShapes); } + + Handle(TColStd_HSequenceOfTransient) GetShapes() + { return _func->GetReferenceList(SHAPE_ARG_SHAPES); } + + void SetBase(Handle(GEOM_Function) theRefBase) + { _func->SetReference(SHAPE_ARG_BASE, theRefBase); } + + Handle(GEOM_Function) GetBase() { return _func->GetReference(SHAPE_ARG_BASE); } + + void SetIsPlanar(const Standard_Boolean isPlanarWanted) + { _func->SetInteger(SHAPE_ARG_PLANAR, isPlanarWanted ? 1 : 0); } + + Standard_Boolean GetIsPlanar() { return (_func->GetInteger(SHAPE_ARG_PLANAR) == 1); } + + void SetSubShapeType(const Standard_Integer theType) + { _func->SetInteger(SHAPE_ARG_SUBTYPE, theType); } + + Standard_Integer GetSubShapeType() { return _func->GetInteger(SHAPE_ARG_SUBTYPE); } + + void SetIndices(const Handle(TColStd_HArray1OfInteger)& theIndices) + { _func->SetIntegerArray(SHAPE_ARG_INDICES, theIndices); } + + Handle(TColStd_HArray1OfInteger) GetIndices() + { return _func->GetIntegerArray(SHAPE_ARG_INDICES); } + + private: + + Handle(GEOM_Function) _func; +}; diff --git a/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx b/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx new file mode 100644 index 000000000..ee637328b --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx @@ -0,0 +1,821 @@ +using namespace std; + +#include "GEOMImpl_IShapesOperations.hxx" + +#include "GEOMImpl_Types.hxx" + +#include "GEOMImpl_VectorDriver.hxx" +#include "GEOMImpl_ShapeDriver.hxx" +#include "GEOMImpl_CopyDriver.hxx" +#include "GEOMImpl_GlueDriver.hxx" + +#include "GEOMImpl_IVector.hxx" +#include "GEOMImpl_IShapes.hxx" +#include "GEOMImpl_IGlue.hxx" + +#include "GEOM_Function.hxx" + +#include "utilities.h" +#include "OpUtil.hxx" +#include "Utils_ExceptHandlers.hxx" + +#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 + +//============================================================================= +/*! + * constructor: + */ +//============================================================================= +GEOMImpl_IShapesOperations::GEOMImpl_IShapesOperations (GEOM_Engine* theEngine, int theDocID) +: GEOM_IOperations(theEngine, theDocID) +{ + MESSAGE("GEOMImpl_IShapesOperations::GEOMImpl_IShapesOperations"); +} + +//============================================================================= +/*! + * destructor + */ +//============================================================================= +GEOMImpl_IShapesOperations::~GEOMImpl_IShapesOperations() +{ + MESSAGE("GEOMImpl_IShapesOperations::~GEOMImpl_IShapesOperations"); +} + + +//============================================================================= +/*! + * MakeEdge + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeEdge + (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2) +{ + SetErrorCode(KO); + + if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL; + + //Add a new Edge object + Handle(GEOM_Object) anEdge = GetEngine()->AddObject(GetDocID(), GEOM_EDGE); + + //Add a new Vector function + Handle(GEOM_Function) aFunction = + anEdge->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_TWO_PNT); + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL; + + GEOMImpl_IVector aPI (aFunction); + + Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction(); + Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction(); + if (aRef1.IsNull() || aRef2.IsNull()) return NULL; + + aPI.SetPoint1(aRef1); + aPI.SetPoint2(aRef2); + + //Compute the Edge value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Vector driver failed"); + 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(anEdge->GetEntry(), anEntry); + aDescr += (anEntry+" = IShapesOperations.MakeEdge("); + TDF_Tool::Entry(thePnt1->GetEntry(), anEntry); + aDescr += (anEntry+", "); + TDF_Tool::Entry(thePnt2->GetEntry(), anEntry); + aDescr += (anEntry+")"); + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return anEdge; +} + +//============================================================================= +/*! + * MakeWire + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeWire + (list theShapes) +{ + return MakeShape(theShapes, GEOM_WIRE, WIRE_EDGES, "MakeWire"); +} + +//============================================================================= +/*! + * MakeFace + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeFace (Handle(GEOM_Object) theWire, + const bool isPlanarWanted) +{ + SetErrorCode(KO); + + if (theWire.IsNull()) return NULL; + + //Add a new Face object + Handle(GEOM_Object) aFace = GetEngine()->AddObject(GetDocID(), GEOM_FACE); + + //Add a new Shape function for creation of a face from a wire + Handle(GEOM_Function) aFunction = + aFace->AddFunction(GEOMImpl_ShapeDriver::GetID(), FACE_WIRE); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_ShapeDriver::GetID()) return NULL; + + GEOMImpl_IShapes aCI (aFunction); + + Handle(GEOM_Function) aRefWire = theWire->GetLastFunction(); + + if (aRefWire.IsNull()) return NULL; + + aCI.SetBase(aRefWire); + aCI.SetIsPlanar(isPlanarWanted); + + //Compute the Face value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Shape driver failed to compute a face"); + 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(aFace->GetEntry(), anEntry); + aDescr += anEntry; + aDescr += " = IShapesOperations.MakeFace("; + TDF_Tool::Entry(theWire->GetEntry(), anEntry); + aDescr += anEntry; + if (isPlanarWanted) + aDescr += ", 1)"; + + else + aDescr += ", 0)"; + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aFace; +} + +//============================================================================= +/*! + * MakeFaceWires + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeFaceWires + (list theShapes, bool isPlanarWanted) +{ + SetErrorCode(KO); + + //Add a new object + Handle(GEOM_Object) aShape = GetEngine()->AddObject(GetDocID(), GEOM_FACE); + + //Add a new function + Handle(GEOM_Function) aFunction = + aShape->AddFunction(GEOMImpl_ShapeDriver::GetID(), FACE_WIRES); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_ShapeDriver::GetID()) return NULL; + + GEOMImpl_IShapes aCI (aFunction); + + Handle(TColStd_HSequenceOfTransient) aShapesSeq = new TColStd_HSequenceOfTransient; + + // Shapes + list::iterator it = theShapes.begin(); + for (; it != theShapes.end(); it++) { + Handle(GEOM_Function) aRefSh = (*it)->GetLastFunction(); + if (aRefSh.IsNull()) { + SetErrorCode("NULL argument shape for the face construction"); + return NULL; + } + aShapesSeq->Append(aRefSh); + } + aCI.SetShapes(aShapesSeq); + + aCI.SetIsPlanar(isPlanarWanted); + + //Compute the shape + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Shape driver failed"); + 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(aShape->GetEntry(), anEntry); + aDescr += (anEntry + " = IShapesOperations.MakeFaceWires(["); + // Shapes + it = theShapes.begin(); + if (it != theShapes.end()) { + TDF_Tool::Entry((*it)->GetEntry(), anEntry); + it++; + aDescr += (anEntry+", "); + for (; it != theShapes.end(); it++) { + aDescr += ", "; + TDF_Tool::Entry((*it)->GetEntry(), anEntry); + aDescr += anEntry; + } + } + if (isPlanarWanted) + aDescr += "], 1)"; + + else + aDescr += "], 0)"; + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aShape; +} + +//============================================================================= +/*! + * MakeShell + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeShell + (list theShapes) +{ + return MakeShape(theShapes, GEOM_SHELL, SHELL_FACES, "MakeShell"); +} + +//============================================================================= +/*! + * MakeSolidShells + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeSolidShells + (list theShapes) +{ + return MakeShape(theShapes, GEOM_SOLID, SOLID_SHELLS, "MakeSolidShells"); +} + +//============================================================================= +/*! + * MakeSolidShell + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeSolidShell (Handle(GEOM_Object) theShell) +{ + SetErrorCode(KO); + + if (theShell.IsNull()) return NULL; + + //Add a new Solid object + Handle(GEOM_Object) aSolid = GetEngine()->AddObject(GetDocID(), GEOM_SOLID); + + //Add a new Solid function for creation of a solid from a shell + Handle(GEOM_Function) aFunction = + aSolid->AddFunction(GEOMImpl_ShapeDriver::GetID(), SOLID_SHELL); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_ShapeDriver::GetID()) return NULL; + + GEOMImpl_IShapes aCI (aFunction); + + Handle(GEOM_Function) aRefShell = theShell->GetLastFunction(); + + if (aRefShell.IsNull()) return NULL; + + aCI.SetBase(aRefShell); + + //Compute the Solid value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Solid driver failed"); + 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(aSolid->GetEntry(), anEntry); + aDescr += anEntry; + aDescr += " = IShapesOperations.MakeSolidShell("; + TDF_Tool::Entry(theShell->GetEntry(), anEntry); + aDescr += (anEntry+")"); + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aSolid; +} + +//============================================================================= +/*! + * MakeCompound + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeCompound + (list theShapes) +{ + return MakeShape(theShapes, GEOM_COMPOUND, COMPOUND_SHAPES, "MakeCompound"); +} + +//============================================================================= +/*! + * MakeShape + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeShape + (list theShapes, + const Standard_Integer theObjectType, + const Standard_Integer theFunctionType, + const TCollection_AsciiString theMethodName) +{ + SetErrorCode(KO); + + //Add a new object + Handle(GEOM_Object) aShape = GetEngine()->AddObject(GetDocID(), theObjectType); + + //Add a new function + Handle(GEOM_Function) aFunction = + aShape->AddFunction(GEOMImpl_ShapeDriver::GetID(), theFunctionType); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_ShapeDriver::GetID()) return NULL; + + GEOMImpl_IShapes aCI (aFunction); + + Handle(TColStd_HSequenceOfTransient) aShapesSeq = new TColStd_HSequenceOfTransient; + + // Shapes + list::iterator it = theShapes.begin(); + for (; it != theShapes.end(); it++) { + Handle(GEOM_Function) aRefSh = (*it)->GetLastFunction(); + if (aRefSh.IsNull()) { + SetErrorCode("NULL argument shape for the shape construction"); + return NULL; + } + aShapesSeq->Append(aRefSh); + } + aCI.SetShapes(aShapesSeq); + + //Compute the shape + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Shape driver failed"); + 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(aShape->GetEntry(), anEntry); + aDescr += (anEntry + " = IShapesOperations."); + aDescr += (theMethodName + "(["); + // Shapes + it = theShapes.begin(); + if (it != theShapes.end()) { + TDF_Tool::Entry((*it)->GetEntry(), anEntry); + it++; + aDescr += (anEntry+", "); + for (; it != theShapes.end(); it++) { + aDescr += ", "; + TDF_Tool::Entry((*it)->GetEntry(), anEntry); + aDescr += anEntry; + } + } + aDescr += "])"; + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aShape; +} + +//============================================================================= +/*! + * MakeGlueFaces + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeGlueFaces + (Handle(GEOM_Object) theShape, + const Standard_Real theTolerance) +{ + SetErrorCode(KO); + + if (theShape.IsNull()) return NULL; + + //Add a new Glued object + Handle(GEOM_Object) aGlued = GetEngine()->AddObject(GetDocID(), GEOM_GLUED); + + //Add a new Glue function + Handle(GEOM_Function) aFunction; + aFunction = aGlued->AddFunction(GEOMImpl_GlueDriver::GetID(), GLUE_FACES); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_GlueDriver::GetID()) return NULL; + + GEOMImpl_IGlue aCI (aFunction); + + Handle(GEOM_Function) aRefShape = theShape->GetLastFunction(); + if (aRefShape.IsNull()) return NULL; + + aCI.SetBase(aRefShape); + aCI.SetTolerance(theTolerance); + + //Compute the sub-shape value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Shape driver failed to glue faces"); + 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(aGlued->GetEntry(), anEntry); + aDescr += anEntry; + aDescr += " = IShapesOperations.MakeGlueFaces("; + TDF_Tool::Entry(theShape->GetEntry(), anEntry); + aDescr += anEntry + ", "; + aDescr += TCollection_AsciiString(theTolerance) + ")"; + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aGlued; +} + +//============================================================================= +/*! + * MakeExplode + */ +//============================================================================= +Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::MakeExplode + (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_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient; + Handle(GEOM_Object) anObj; + Handle(GEOM_Function) aFunction; + 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); + TCollection_AsciiString anAsciiList = "[", anEntry; + for (int index = 1; itSub.More(); itSub.Next(), ++index) { + TopoDS_Shape aValue = itSub.Value(); + anArray = new TColStd_HArray1OfInteger(1,1); + anArray->SetValue(1, anIndices.FindIndex(aValue)); + anObj = GetEngine()->AddSubShape(theShape, anArray); + aSeq->Append(anObj); + + TDF_Tool::Entry(anObj->GetEntry(), anEntry); + anAsciiList += anEntry; + anAsciiList += ","; + } + + anAsciiList.Trunc(anAsciiList.Length() - 1); + anAsciiList += "]"; + + anAsciiList = TCollection_AsciiString("\n") + anAsciiList; + + //The explode doesn't change object so no new function is requiered. + aFunction = theShape->GetLastFunction(); + + //Make a Python command + TCollection_AsciiString aDescr(anAsciiList); + TDF_Tool::Entry(theShape->GetEntry(), anEntry); + aDescr += " = IShapesOperations.MakeExplode("; + 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; +} + +//============================================================================= +/*! + * GetSubShape + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetSubShape + (Handle(GEOM_Object) theMainShape, + const Standard_Integer theID) +{ + SetErrorCode(KO); + + if (theMainShape.IsNull()) return NULL; + + Handle(TColStd_HArray1OfInteger) anArray = new TColStd_HArray1OfInteger(1,1); + anArray->SetValue(1, theID); + Handle(GEOM_Object) anObj = GetEngine()->AddSubShape(theMainShape, anArray); + if (anObj.IsNull()) { + SetErrorCode("Can not get a sub-shape with the given ID"); + return NULL; + } + + //The GetSubShape() doesn't change object so no new function is requiered. + Handle(GEOM_Function) aFunction = theMainShape->GetLastFunction(); + + //Make a Python command + TCollection_AsciiString aDescr ("\n"); + TCollection_AsciiString anEntry; + TDF_Tool::Entry(anObj->GetEntry(), anEntry); + aDescr += anEntry + " = IShapesOperations.GetSubShape("; + TDF_Tool::Entry(theMainShape->GetEntry(), anEntry); + aDescr += anEntry + ", "; + aDescr += TCollection_AsciiString(theID) + ")"; + + TCollection_AsciiString anOldDescr = aFunction->GetDescription(); + anOldDescr = anOldDescr + aDescr; + aFunction->SetDescription(anOldDescr); + + SetErrorCode(OK); + return anObj; +} + + +//============================================================================= +/*! + * NumberOfFaces + */ +//============================================================================= +Standard_Integer GEOMImpl_IShapesOperations::NumberOfFaces (Handle(GEOM_Object) theShape) +{ + SetErrorCode(KO); + + Standard_Integer nb = 0; + + if (theShape.IsNull()) return -1; + TopoDS_Shape aShape = theShape->GetValue(); + if (aShape.IsNull()) return -1; + + TopTools_MapOfShape mapShape; + + TopExp_Explorer exp (aShape, TopAbs_FACE); + for (; exp.More(); exp.Next()) + if (mapShape.Add(exp.Current())) + nb++; + + SetErrorCode(OK); + return nb; +} + +//============================================================================= +/*! + * NumberOfEdges + */ +//============================================================================= +Standard_Integer GEOMImpl_IShapesOperations::NumberOfEdges (Handle(GEOM_Object) theShape) +{ + SetErrorCode(KO); + + Standard_Integer nb = 0; + + if (theShape.IsNull()) return -1; + TopoDS_Shape aShape = theShape->GetValue(); + if (aShape.IsNull()) return -1; + + TopTools_MapOfShape mapShape; + + TopExp_Explorer exp (aShape, TopAbs_EDGE); + for (; exp.More(); exp.Next()) + if (mapShape.Add(exp.Current())) + nb++; + + SetErrorCode(OK); + return nb; +} + +//============================================================================= +/*! + * ReverseShape + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IShapesOperations::ReverseShape(Handle(GEOM_Object) theShape) +{ + SetErrorCode(KO); + + if (theShape.IsNull()) return NULL; + + //Add a new reversed object + Handle(GEOM_Object) aReversed = GetEngine()->AddObject(GetDocID(), theShape->GetType()); + + //Add a new Revese function + Handle(GEOM_Function) aFunction; + aFunction = aReversed->AddFunction(GEOMImpl_ShapeDriver::GetID(), REVERSE_ORIENTATION); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_ShapeDriver::GetID()) return NULL; + + GEOMImpl_IShapes aSI (aFunction); + + Handle(GEOM_Function) aRefShape = theShape->GetLastFunction(); + if (aRefShape.IsNull()) return NULL; + + aSI.SetBase(aRefShape); + + //Compute the sub-shape value + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Shape driver failed to reverse 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(aReversed->GetEntry(), anEntry); + aDescr += anEntry; + aDescr += " = IShapesOperations.ReverseShape("; + TDF_Tool::Entry(theShape->GetEntry(), anEntry); + aDescr += anEntry + ")"; + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aReversed; +} + + +//======================================================================= +//function : SortShapes +//purpose : +//======================================================================= +void GEOMImpl_IShapesOperations::SortShapes(TopTools_ListOfShape& SL) +{ + Standard_Integer MaxShapes = SL.Extent(); + TopTools_Array1OfShape aShapes (1,MaxShapes); + TColStd_Array1OfInteger OrderInd(1,MaxShapes); + TColStd_Array1OfReal MidXYZ (1,MaxShapes); //X,Y,Z; + TColStd_Array1OfReal Length (1,MaxShapes); //X,Y,Z; + + // Computing of CentreOfMass + Standard_Integer Index; + GProp_GProps GPr; + gp_Pnt GPoint; + TopTools_ListIteratorOfListOfShape it(SL); + for (Index=1; it.More(); Index++) + { + TopoDS_Shape S = it.Value(); + SL.Remove( it ); // == it.Next() + aShapes(Index) = S; + OrderInd.SetValue (Index, Index); + if (S.ShapeType() == TopAbs_VERTEX) + { + GPoint = BRep_Tool::Pnt( TopoDS::Vertex( S )); + Length.SetValue( Index, (Standard_Real) S.Orientation()); + } + else + { + BRepGProp::LinearProperties (S, GPr); + GPoint = GPr.CentreOfMass(); + Length.SetValue( Index, GPr.Mass() ); + } + MidXYZ.SetValue(Index, + GPoint.X()*999 + GPoint.Y()*99 + GPoint.Z()*0.9); + } + // Sorting + Standard_Integer aTemp; + Standard_Boolean exchange, Sort = Standard_True; + while (Sort) + { + Sort = Standard_False; + for (Index=1; Index < MaxShapes; Index++) + { + if (MidXYZ(OrderInd(Index)) > MidXYZ(OrderInd(Index+1))) + exchange = Standard_True; + else if (MidXYZ(OrderInd(Index)) == MidXYZ(OrderInd(Index+1)) && + Length(OrderInd(Index)) > Length(OrderInd(Index+1)) ) + exchange = Standard_True; + else + exchange = Standard_False; + if (exchange) + { + aTemp = OrderInd(Index); + OrderInd(Index) = OrderInd(Index+1); + OrderInd(Index+1) = aTemp; + Sort = Standard_True; + } + } + } + for (Index=1; Index <= MaxShapes; Index++) + SL.Append( aShapes( OrderInd(Index) )); +} diff --git a/src/GEOMImpl/GEOMImpl_IShapesOperations.hxx b/src/GEOMImpl/GEOMImpl_IShapesOperations.hxx new file mode 100644 index 000000000..9ae51717a --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_IShapesOperations.hxx @@ -0,0 +1,62 @@ + +#ifndef _GEOMImpl_IShapesOperations_HXX_ +#define _GEOMImpl_IShapesOperations_HXX_ + +#include "GEOM_IOperations.hxx" + +#include +#include + +#include + +class GEOM_Engine; +class Handle(GEOM_Object); +class Handle(TColStd_HArray1OfInteger); + +class GEOMImpl_IShapesOperations : public GEOM_IOperations { + public: + GEOMImpl_IShapesOperations(GEOM_Engine* theEngine, int theDocID); + ~GEOMImpl_IShapesOperations(); + + Handle(GEOM_Object) MakeEdge (Handle(GEOM_Object) thePoint1, + Handle(GEOM_Object) thePoint2); + + Handle(GEOM_Object) MakeWire (list theEdgesAndWires); + + Handle(GEOM_Object) MakeFace (Handle(GEOM_Object) theWire, bool isPlanarWanted); + + Handle(GEOM_Object) MakeFaceWires (list theWires, bool isPlanarWanted); + + Handle(GEOM_Object) MakeShell (list theShapes); + + Handle(GEOM_Object) MakeSolidShell (Handle(GEOM_Object) theShell); + + Handle(GEOM_Object) MakeSolidShells (list theShells); + + Handle(GEOM_Object) MakeCompound (list theShapes); + + Handle(GEOM_Object) MakeGlueFaces (Handle(GEOM_Object) theShape, + const Standard_Real theTolerance); + + Handle(TColStd_HSequenceOfTransient) MakeExplode (Handle(GEOM_Object) theShape, + const Standard_Integer theShapeType, + const Standard_Boolean isSorted); + + Handle(GEOM_Object) GetSubShape (Handle(GEOM_Object) theMainShape, + const Standard_Integer theID); + + Standard_Integer NumberOfFaces (Handle(GEOM_Object) theShape); + Standard_Integer NumberOfEdges (Handle(GEOM_Object) theShape); + + Handle(GEOM_Object) ReverseShape(Handle(GEOM_Object) theShapes); + + static void SortShapes (TopTools_ListOfShape& SL); + + private: + Handle(GEOM_Object) MakeShape (list theShapes, + const Standard_Integer theObjectType, + const Standard_Integer theFunctionType, + const TCollection_AsciiString theMethodName); +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_ISketcher.hxx b/src/GEOMImpl/GEOMImpl_ISketcher.hxx new file mode 100644 index 000000000..74912ff38 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_ISketcher.hxx @@ -0,0 +1,28 @@ +//NOTE: This is an interface to a function for the Sketcher creation. + + +#include "GEOM_Function.hxx" + +#define SKETCH_ARG_CMD 1 +#define SKETCH_ARG_WPLANE 2 + +class GEOMImpl_ISketcher +{ + public: + + GEOMImpl_ISketcher(Handle(GEOM_Function) theFunction): _func(theFunction) {} + + void SetCommand(const TCollection_AsciiString& theCommand) + { _func->SetString(SKETCH_ARG_CMD, theCommand); } + + TCollection_AsciiString GetCommand() { return _func->GetString(SKETCH_ARG_CMD); } + + void SetWorkingPlane(int theInd, double theValue) + { _func->SetReal(SKETCH_ARG_WPLANE + theInd, theValue); } + + double GetWorkingPlane(int theInd) { return _func->GetReal(SKETCH_ARG_WPLANE + theInd); } + + private: + + Handle(GEOM_Function) _func; +}; diff --git a/src/GEOMImpl/GEOMImpl_ISphere.hxx b/src/GEOMImpl/GEOMImpl_ISphere.hxx new file mode 100644 index 000000000..048e56cea --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_ISphere.hxx @@ -0,0 +1,26 @@ +//NOTE: This is an intreface to a function for the Sphere creation. + + +#include "GEOM_Function.hxx" + +#define SPH_ARG_R 1 +#define SPH_ARG_PNT 4 + +class GEOMImpl_ISphere +{ + public: + + GEOMImpl_ISphere(Handle(GEOM_Function) theFunction): _func(theFunction) {} + + void SetR(double theR) { _func->SetReal(SPH_ARG_R, theR); } + + double GetR() { return _func->GetReal(SPH_ARG_R); } + + void SetPoint(Handle(GEOM_Function) theRefPoint) { _func->SetReference(SPH_ARG_PNT, theRefPoint); } + + Handle(GEOM_Function) GetPoint() { return _func->GetReference(SPH_ARG_PNT); } + + private: + + Handle(GEOM_Function) _func; +}; diff --git a/src/GEOMImpl/GEOMImpl_ISpline.hxx b/src/GEOMImpl/GEOMImpl_ISpline.hxx new file mode 100644 index 000000000..19880be21 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_ISpline.hxx @@ -0,0 +1,26 @@ +//NOTE: This is an intreface to a function for the Spline creation. + + +#include "GEOM_Function.hxx" + +#define SPL_ARG_LENG 1 +#define SPL_ARG_LAST 1 + +class GEOMImpl_ISpline +{ + public: + + GEOMImpl_ISpline(Handle(GEOM_Function) theFunction): _func(theFunction) {} + + void SetLength(int theLen) { _func->SetInteger(SPL_ARG_LENG, theLen); } + + void SetPoint(int theId, Handle(GEOM_Function) theP) { _func->SetReference(SPL_ARG_LAST + theId, theP); } + + int GetLength() { return _func->GetInteger(SPL_ARG_LENG); } + + Handle(GEOM_Function) GetPoint(int theId) { return _func->GetReference(SPL_ARG_LAST + theId); } + + private: + + Handle(GEOM_Function) _func; +}; diff --git a/src/GEOMImpl/GEOMImpl_ITorus.hxx b/src/GEOMImpl/GEOMImpl_ITorus.hxx new file mode 100644 index 000000000..8bbca42d9 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_ITorus.hxx @@ -0,0 +1,32 @@ +//NOTE: This is an intreface to a function for the Torus creation. + + +#include "GEOM_Function.hxx" + +#define TORUS_ARG_CC 1 +#define TORUS_ARG_VV 2 +#define TORUS_ARG_RMAJ 3 +#define TORUS_ARG_RMIN 4 + +class GEOMImpl_ITorus +{ + public: + + GEOMImpl_ITorus(Handle(GEOM_Function) theFunction): _func(theFunction) {} + + void SetCenter(Handle(GEOM_Function) theP) { _func->SetReference(TORUS_ARG_CC, theP); } + void SetVector(Handle(GEOM_Function) theV) { _func->SetReference(TORUS_ARG_VV, theV); } + + void SetRMajor(double theR) { _func->SetReal(TORUS_ARG_RMAJ, theR); } + void SetRMinor(double theR) { _func->SetReal(TORUS_ARG_RMIN, theR); } + + Handle(GEOM_Function) GetCenter() { return _func->GetReference(TORUS_ARG_CC); } + Handle(GEOM_Function) GetVector() { return _func->GetReference(TORUS_ARG_VV); } + + double GetRMajor() { return _func->GetReal(TORUS_ARG_RMAJ); } + double GetRMinor() { return _func->GetReal(TORUS_ARG_RMIN); } + + private: + + Handle(GEOM_Function) _func; +}; diff --git a/src/GEOMImpl/GEOMImpl_ITransformOperations.cxx b/src/GEOMImpl/GEOMImpl_ITransformOperations.cxx new file mode 100644 index 000000000..d7e2397c0 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_ITransformOperations.cxx @@ -0,0 +1,1465 @@ +using namespace std; + +#include "GEOMImpl_ITransformOperations.hxx" + +#include "utilities.h" +#include "OpUtil.hxx" +#include "Utils_ExceptHandlers.hxx" + +#include +#include +#include +#include + +#include "GEOM_Function.hxx" + +#include "GEOMImpl_TranslateDriver.hxx" +#include "GEOMImpl_MirrorDriver.hxx" +#include "GEOMImpl_OffsetDriver.hxx" +#include "GEOMImpl_ScaleDriver.hxx" +#include "GEOMImpl_RotateDriver.hxx" +#include "GEOMImpl_PositionDriver.hxx" + +#include "GEOMImpl_ITranslate.hxx" +#include "GEOMImpl_IMirror.hxx" +#include "GEOMImpl_IOffset.hxx" +#include "GEOMImpl_IScale.hxx" +#include "GEOMImpl_IRotate.hxx" +#include "GEOMImpl_IPosition.hxx" + +#include "GEOMImpl_Types.hxx" + +#include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC + +//============================================================================= +/*! + * constructor: + */ +//============================================================================= + +GEOMImpl_ITransformOperations::GEOMImpl_ITransformOperations (GEOM_Engine* theEngine, int theDocID) +: GEOM_IOperations(theEngine, theDocID) +{ + MESSAGE("GEOMImpl_ITransformOperations::GEOMImpl_ITransformOperations"); +} + +//============================================================================= +/*! + * destructor + */ +//============================================================================= + +GEOMImpl_ITransformOperations::~GEOMImpl_ITransformOperations() +{ + MESSAGE("GEOMImpl_ITransformOperations::~GEOMImpl_ITransformOperations"); +} + + +//============================================================================= +/*! + * TranslateTwoPoints + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateTwoPoints + (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2) +{ + SetErrorCode(KO); + + if (theObject.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL; + + Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction(); + if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved + + // Get last functions of the arguments + Handle(GEOM_Function) aP1F = thePoint1->GetLastFunction(); + Handle(GEOM_Function) aP2F = thePoint2->GetLastFunction(); + + //Add a translate function + aFunction = theObject->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_TWO_POINTS); + + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL; + + GEOMImpl_ITranslate aTI (aFunction); + aTI.SetPoint1(aP1F); + aTI.SetPoint2(aP2F); + aTI.SetOriginal(aLastFunction); + + //Compute the translation + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Translation driver failed"); + 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(theObject->GetEntry(), anEntry); + aDescr += (anEntry+" = ITransformOperations.TranslateTwoPoints("); + aDescr += (anEntry+", "); + TDF_Tool::Entry(thePoint1->GetEntry(), anEntry); + aDescr += (anEntry+", "); + TDF_Tool::Entry(thePoint2->GetEntry(), anEntry); + aDescr += (anEntry+")"); + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return theObject; +} + +//============================================================================= +/*! + * TranslateDXDYDZ + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateDXDYDZ + (Handle(GEOM_Object) theObject, double theX, double theY, double theZ) +{ + SetErrorCode(KO); + + if (theObject.IsNull()) return NULL; + + Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction(); + if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved + + //Add a translate function + aFunction = theObject->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_XYZ); + + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL; + + GEOMImpl_ITranslate aTI(aFunction); + aTI.SetDX(theX); + aTI.SetDY(theY); + aTI.SetDZ(theZ); + aTI.SetOriginal(aLastFunction); + + //Compute the translation + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Translation driver failed"); + 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(theObject->GetEntry(), anEntry); + aDescr += (anEntry+" = ITransformOperations.TranslateDXDXYDZ("); + aDescr += (anEntry+", "); + aDescr += (TCollection_AsciiString(theX)+", "); + aDescr += (TCollection_AsciiString(theY)+", "); + aDescr += (TCollection_AsciiString(theZ)+")"); + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return theObject; +} + + +//============================================================================= +/*! + * TranslateTwoPointsCopy + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateTwoPointsCopy + (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2) +{ + SetErrorCode(KO); + + if (theObject.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL; + + Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction(); + if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved + + //Add a new Copy object + Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType()); + + //Add a translate function + Handle(GEOM_Function) aFunction = + aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_TWO_POINTS_COPY); + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL; + + GEOMImpl_ITranslate aTI(aFunction); + aTI.SetPoint1(thePoint1->GetLastFunction()); + aTI.SetPoint2(thePoint2->GetLastFunction()); + //aTI.SetShape(theObject->GetValue()); + aTI.SetOriginal(aLastFunction); + + //Compute the translation + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Translation driver failed"); + 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+" = ITransformOperations.TranslateTwoPointsCopy("); + TDF_Tool::Entry(theObject->GetEntry(), anEntry); + aDescr += (anEntry+", "); + TDF_Tool::Entry(thePoint1->GetEntry(), anEntry); + aDescr += (anEntry+", "); + TDF_Tool::Entry(thePoint2->GetEntry(), anEntry); + aDescr += (anEntry+")"); + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aCopy; +} + +//============================================================================= +/*! + * TranslateDXDYDZCopy + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateDXDYDZCopy + (Handle(GEOM_Object) theObject, double theX, double theY, double theZ) +{ + 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 moved + + //Add a new Copy object + Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType()); + + //Add a translate function + Handle(GEOM_Function) aFunction = + aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_XYZ_COPY); + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL; + + GEOMImpl_ITranslate aTI(aFunction); + aTI.SetDX(theX); + aTI.SetDY(theY); + aTI.SetDZ(theZ); + aTI.SetOriginal(aLastFunction); + + //Compute the translation + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Translation driver failed"); + 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+" = ITransformOperations.TranslateDXDXYDZCopy("); + TDF_Tool::Entry(theObject->GetEntry(), anEntry); + aDescr += (anEntry+", "); + aDescr += (TCollection_AsciiString(theX)+", "); + aDescr += (TCollection_AsciiString(theY)+", "); + aDescr += (TCollection_AsciiString(theZ)+")"); + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aCopy; +} + + +//============================================================================= +/*! + * TranslateVector + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateVector + (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector) +{ + SetErrorCode(KO); + + if (theObject.IsNull() || theVector.IsNull()) return NULL; + + Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction(); + if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved + + // Get last functions of the arguments + Handle(GEOM_Function) aVF = theVector->GetLastFunction(); + + //Add a translate function + aFunction = theObject->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_VECTOR); + + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL; + + GEOMImpl_ITranslate aTI (aFunction); + aTI.SetVector(aVF); + aTI.SetOriginal(aLastFunction); + + //Compute the translation + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Translation driver failed"); + 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(theObject->GetEntry(), anEntry); + aDescr += (anEntry+" = ITransformOperations.TranslateVector("); + aDescr += (anEntry+", "); + TDF_Tool::Entry(theVector->GetEntry(), anEntry); + aDescr += (anEntry+") "); + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return theObject; +} + +//============================================================================= +/*! + * TranslateVectorCopy + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateVectorCopy + (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector) +{ + SetErrorCode(KO); + + if (theObject.IsNull() || theVector.IsNull()) return NULL; + + Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction(); + if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved + + //Add a new Copy object + Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType()); + + //Add a translate function + Handle(GEOM_Function) aFunction = + aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_VECTOR_COPY); + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL; + + GEOMImpl_ITranslate aTI(aFunction); + aTI.SetVector(theVector->GetLastFunction()); +// aTI.SetShape(theObject->GetValue()); + aTI.SetOriginal(aLastFunction); + + //Compute the translation + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Translation driver failed"); + 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+" = ITransformOperations.TranslateVectorCopy("); + TDF_Tool::Entry(theObject->GetEntry(), anEntry); + aDescr += (anEntry+", "); + TDF_Tool::Entry(theVector->GetEntry(), anEntry); + aDescr += (anEntry+")"); + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aCopy; +} + +//============================================================================= +/*! + * Translate1D + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ITransformOperations::Translate1D + (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector, + double theStep, Standard_Integer theNbTimes) +{ + SetErrorCode(KO); + + if (theObject.IsNull() || theVector.IsNull()) return NULL; + + Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction(); + if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved + + //Add a new Copy object + Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType()); + + //Add a translate function + Handle(GEOM_Function) aFunction = + aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_1D); + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL; + + GEOMImpl_ITranslate aTI(aFunction); + aTI.SetVector(theVector->GetLastFunction()); + aTI.SetOriginal(aLastFunction); + aTI.SetStep1(theStep); + aTI.SetNbIter1(theNbTimes); + + //Compute the translation + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Translation driver failed"); + 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+" = ITransformOperations.Translate1D("); + TDF_Tool::Entry(theObject->GetEntry(), anEntry); + aDescr += (anEntry+", "); + TDF_Tool::Entry(theVector->GetEntry(), anEntry); + aDescr += (anEntry+", "); + aDescr += (TCollection_AsciiString(theStep)+", "); + aDescr += (TCollection_AsciiString(theNbTimes)+") "); + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aCopy; +} + +//============================================================================= +/*! + * Translate2D + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ITransformOperations::Translate2D (Handle(GEOM_Object) theObject, + Handle(GEOM_Object) theVector, + double theStep1, + Standard_Integer theNbTimes1, + Handle(GEOM_Object) theVector2, + double theStep2, + Standard_Integer theNbTimes2) +{ + SetErrorCode(KO); + + if (theObject.IsNull() || theVector.IsNull() || theVector2.IsNull()) return NULL; + + Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction(); + if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved + + //Add a new Copy object + Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType()); + + //Add a translate function + Handle(GEOM_Function) aFunction = + aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_2D); + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL; + + GEOMImpl_ITranslate aTI(aFunction); + aTI.SetVector(theVector->GetLastFunction()); + aTI.SetVector2(theVector2->GetLastFunction()); + aTI.SetOriginal(aLastFunction); + aTI.SetStep1(theStep1); + aTI.SetNbIter1(theNbTimes1); + aTI.SetStep2(theStep2); + aTI.SetNbIter2(theNbTimes2); + + //Compute the translation + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Translation driver failed"); + 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+" = ITransformOperations.Translate2D("); + TDF_Tool::Entry(theObject->GetEntry(), anEntry); + aDescr += (anEntry+", "); + TDF_Tool::Entry(theVector->GetEntry(), anEntry); + aDescr += (anEntry+", "); + aDescr += (TCollection_AsciiString(theStep1)+", "); + aDescr += (TCollection_AsciiString(theNbTimes2)+", "); + TDF_Tool::Entry(theVector2->GetEntry(), anEntry); + aDescr += (anEntry+", "); + aDescr += (TCollection_AsciiString(theStep2)+", "); + aDescr += (TCollection_AsciiString(theNbTimes2)+") "); + + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aCopy; +} + + +//============================================================================= +/*! + * MirrorPlane + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPlane + (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePlane) +{ + SetErrorCode(KO); + + if (theObject.IsNull() || thePlane.IsNull()) return NULL; + + Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction(); + if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored + + // Get last functions of the arguments + Handle(GEOM_Function) aPF = thePlane->GetLastFunction(); + + //Add a mirror function + Handle(GEOM_Function) aFunction = + theObject->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_PLANE); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL; + + GEOMImpl_IMirror aTI (aFunction); + aTI.SetPlane(aPF); + aTI.SetOriginal(aLastFunction); + + //Compute the mirror + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Mirror driver failed"); + 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(theObject->GetEntry(), anEntry); + aDescr += (anEntry + " = ITransformOperations.MirrorPlane("); + aDescr += (anEntry + ", "); + TDF_Tool::Entry(thePlane->GetEntry(), anEntry); + aDescr += (anEntry + ") "); + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return theObject; +} + +//============================================================================= +/*! + * MirrorPlaneCopy + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPlaneCopy + (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePlane) +{ + SetErrorCode(KO); + + if (theObject.IsNull() || thePlane.IsNull()) return NULL; + + Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction(); + if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored + + //Add a new Copy object + Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType()); + + //Add a mirror function + Handle(GEOM_Function) aFunction = + aCopy->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_PLANE_COPY); + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL; + + GEOMImpl_IMirror aTI (aFunction); + aTI.SetPlane(thePlane->GetLastFunction()); + aTI.SetOriginal(aLastFunction); + + //Compute the mirror + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Mirror driver failed"); + 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 + " = ITransformOperations.MirrorPlaneCopy("); + TDF_Tool::Entry(theObject->GetEntry(), anEntry); + aDescr += (anEntry + ", "); + TDF_Tool::Entry(thePlane->GetEntry(), anEntry); + aDescr += (anEntry + ")"); + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aCopy; +} + +//============================================================================= +/*! + * MirrorPoint + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPoint + (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint) +{ + SetErrorCode(KO); + + if (theObject.IsNull() || thePoint.IsNull()) return NULL; + + Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction(); + if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored + + // Get last functions of the arguments + Handle(GEOM_Function) aPF = thePoint->GetLastFunction(); + + //Add a mirror function + Handle(GEOM_Function) aFunction = + theObject->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_POINT); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL; + + GEOMImpl_IMirror aTI (aFunction); + aTI.SetPoint(aPF); + aTI.SetOriginal(aLastFunction); + + //Compute the mirror + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Mirror driver failed"); + 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(theObject->GetEntry(), anEntry); + aDescr += (anEntry + " = ITransformOperations.MirrorPoint("); + aDescr += (anEntry + ", "); + TDF_Tool::Entry(thePoint->GetEntry(), anEntry); + aDescr += (anEntry + ") "); + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return NULL; +} + +//============================================================================= +/*! + * MirrorPointCopy + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPointCopy + (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint) +{ + SetErrorCode(KO); + + if (theObject.IsNull() || thePoint.IsNull()) return NULL; + + Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction(); + if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored + + //Add a new Copy object + Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType()); + + //Add a mirror function + Handle(GEOM_Function) aFunction = + aCopy->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_POINT_COPY); + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL; + + GEOMImpl_IMirror aTI (aFunction); + aTI.SetPoint(thePoint->GetLastFunction()); + aTI.SetOriginal(aLastFunction); + + //Compute the mirror + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Mirror driver failed"); + 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 + " = ITransformOperations.MirrorPointCopy("); + TDF_Tool::Entry(theObject->GetEntry(), anEntry); + aDescr += (anEntry + ", "); + TDF_Tool::Entry(thePoint->GetEntry(), anEntry); + aDescr += (anEntry + ")"); + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aCopy; +} + +//============================================================================= +/*! + * MirrorAxis + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorAxis + (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theAxis) +{ + SetErrorCode(KO); + + if (theObject.IsNull() || theAxis.IsNull()) return NULL; + + Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction(); + if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored + + // Get last functions of the arguments + Handle(GEOM_Function) anAF = theAxis->GetLastFunction(); + + //Add a mirror function + Handle(GEOM_Function) aFunction = + theObject->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_AXIS); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL; + + GEOMImpl_IMirror aTI (aFunction); + aTI.SetAxis(anAF); + aTI.SetOriginal(aLastFunction); + + //Compute the mirror + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Mirror driver failed"); + 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(theObject->GetEntry(), anEntry); + aDescr += (anEntry + " = ITransformOperations.MirrorAxis("); + aDescr += (anEntry + ", "); + TDF_Tool::Entry(theAxis->GetEntry(), anEntry); + aDescr += (anEntry + ") "); + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return NULL; +} + +//============================================================================= +/*! + * MirrorAxisCopy + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorAxisCopy + (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theAxis) +{ + SetErrorCode(KO); + + if (theObject.IsNull() || theAxis.IsNull()) return NULL; + + Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction(); + if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored + + //Add a new Copy object + Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType()); + + //Add a mirror function + Handle(GEOM_Function) aFunction = + aCopy->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_AXIS_COPY); + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL; + + GEOMImpl_IMirror aTI (aFunction); + aTI.SetAxis(theAxis->GetLastFunction()); + aTI.SetOriginal(aLastFunction); + + //Compute the mirror + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Mirror driver failed"); + 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 + " = ITransformOperations.MirrorAxisCopy("); + TDF_Tool::Entry(theObject->GetEntry(), anEntry); + aDescr += (anEntry + ", "); + TDF_Tool::Entry(theAxis->GetEntry(), anEntry); + aDescr += (anEntry + ")"); + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aCopy; +} + + +//============================================================================= +/*! + * OffsetShape + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ITransformOperations::OffsetShape + (Handle(GEOM_Object) theObject, double theOffset) +{ + SetErrorCode(KO); + + if (theObject.IsNull()) return NULL; + + Handle(GEOM_Function) anOriginal = theObject->GetLastFunction(); + if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be offset + + //Add a new Offset function + Handle(GEOM_Function) aFunction = + theObject->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_SHAPE); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_OffsetDriver::GetID()) return NULL; + + GEOMImpl_IOffset aTI (aFunction); + aTI.SetShape(anOriginal); + aTI.SetValue(theOffset); + + //Compute the offset + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Offset driver failed"); + 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(theObject->GetEntry(), anEntry); + aDescr += (anEntry+" = ITransformOperations.OffsetShape("); + aDescr += (anEntry+", "); + aDescr += TCollection_AsciiString(theOffset)+")"; + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return theObject; +} + +//============================================================================= +/*! + * OffsetShapeCopy + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ITransformOperations::OffsetShapeCopy + (Handle(GEOM_Object) theObject, double theOffset) +{ + SetErrorCode(KO); + + if (theObject.IsNull()) return NULL; + + Handle(GEOM_Function) anOriginal = theObject->GetLastFunction(); + if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be offset + + //Add a new Copy object + Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType()); + + //Add a new Offset function + Handle(GEOM_Function) aFunction = + aCopy->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_SHAPE_COPY); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_OffsetDriver::GetID()) return NULL; + + GEOMImpl_IOffset aTI (aFunction); + aTI.SetShape(anOriginal); + aTI.SetValue(theOffset); + + //Compute the offset + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Offset driver failed"); + 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+" = ITransformOperations.OffsetShapeCopy("); + TDF_Tool::Entry(theObject->GetEntry(), anEntry); + aDescr += (anEntry+", "); + aDescr += TCollection_AsciiString(theOffset)+")"; + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aCopy; +} + + +//============================================================================= +/*! + * ScaleShape + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShape + (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint, double theFactor) +{ + SetErrorCode(KO); + + if (theObject.IsNull() || thePoint.IsNull()) return NULL; + + Handle(GEOM_Function) anOriginal = theObject->GetLastFunction(); + if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be scaled + + // Get last functions of the arguments + Handle(GEOM_Function) aPF = thePoint->GetLastFunction(); + + //Add a scale function + Handle(GEOM_Function) aFunction = + theObject->AddFunction(GEOMImpl_ScaleDriver::GetID(), SCALE_SHAPE); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_ScaleDriver::GetID()) return NULL; + + GEOMImpl_IScale aTI (aFunction); + aTI.SetShape(anOriginal); + aTI.SetPoint(aPF); + aTI.SetFactor(theFactor); + + //Compute the scale + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Scale driver failed"); + 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(theObject->GetEntry(), anEntry); + aDescr += (anEntry+" = ITransformOperations.ScaleShape("); + aDescr += (anEntry+", "); + TDF_Tool::Entry(thePoint->GetEntry(), anEntry); + aDescr += (anEntry+", "); + aDescr += TCollection_AsciiString(theFactor)+")"; + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return theObject; +} + +//============================================================================= +/*! + * ScaleShapeCopy + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShapeCopy + (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint, double theFactor) +{ + SetErrorCode(KO); + + if (theObject.IsNull() || thePoint.IsNull()) return NULL; + + Handle(GEOM_Function) anOriginal = theObject->GetLastFunction(); + if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be scaled + + //Add a new Copy object + Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType()); + + //Add a scale function + Handle(GEOM_Function) aFunction = + aCopy->AddFunction(GEOMImpl_ScaleDriver::GetID(), SCALE_SHAPE_COPY); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_ScaleDriver::GetID()) return NULL; + + GEOMImpl_IScale aTI (aFunction); + aTI.SetShape(anOriginal); + aTI.SetPoint(thePoint->GetLastFunction()); + aTI.SetFactor(theFactor); + + //Compute the scale + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Scale driver failed"); + 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+" = ITransformOperations.ScaleShapeCopy("); + TDF_Tool::Entry(theObject->GetEntry(), anEntry); + aDescr += (anEntry+", "); + TDF_Tool::Entry(thePoint->GetEntry(), anEntry); + aDescr += (anEntry+", "); + aDescr += TCollection_AsciiString(theFactor)+")"; + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aCopy; +} + +//============================================================================= +/*! + * PositionShape + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionShape + (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theStartLCS, Handle(GEOM_Object) theEndLCS) +{ + SetErrorCode(KO); + + if (theObject.IsNull() || theStartLCS.IsNull() || theEndLCS.IsNull()) return NULL; + + Handle(GEOM_Function) anOriginal = theObject->GetLastFunction(); + if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be set in position + + // Get last functions of the arguments + Handle(GEOM_Function) aStartLCS = theStartLCS->GetLastFunction(); + Handle(GEOM_Function) aEndLCS = theEndLCS->GetLastFunction(); + + //Add a Position function + Handle(GEOM_Function) aFunction = + theObject->AddFunction(GEOMImpl_PositionDriver::GetID(), POSITION_SHAPE); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_PositionDriver::GetID()) return NULL; + + GEOMImpl_IPosition aTI (aFunction); + aTI.SetShape(anOriginal); + aTI.SetStartLCS(aStartLCS); + aTI.SetEndLCS(aEndLCS); + + //Compute the Position + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Position driver failed"); + 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(theObject->GetEntry(), anEntry); + aDescr += (anEntry+" = ITransformOperations.PositionShape("); + aDescr += (anEntry+", "); + TDF_Tool::Entry(theStartLCS->GetEntry(), anEntry); + aDescr += (anEntry+", "); + TDF_Tool::Entry(theEndLCS->GetEntry(), anEntry); + aDescr += (anEntry+") "); + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return theObject; +} + +//============================================================================= +/*! + * PositionShapeCopy + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionShapeCopy + (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theStartLCS, Handle(GEOM_Object) theEndLCS) +{ + SetErrorCode(KO); + + if (theObject.IsNull() || theStartLCS.IsNull() || theEndLCS.IsNull()) return NULL; + + Handle(GEOM_Function) anOriginal = theObject->GetLastFunction(); + if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be set in position + + //Add a new Copy object + Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType()); + + //Add a position function + Handle(GEOM_Function) aFunction = + aCopy->AddFunction(GEOMImpl_PositionDriver::GetID(), POSITION_SHAPE_COPY); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_PositionDriver::GetID()) return NULL; + + GEOMImpl_IPosition aTI (aFunction); + aTI.SetShape(anOriginal); + aTI.SetStartLCS(theStartLCS->GetLastFunction()); + aTI.SetEndLCS(theEndLCS->GetLastFunction()); + + //Compute the position + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Position driver failed"); + 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+" = ITransformOperations.PositionShapeCopy("); + TDF_Tool::Entry(theObject->GetEntry(), anEntry); + aDescr += (anEntry+", "); + TDF_Tool::Entry(theStartLCS->GetEntry(), anEntry); + aDescr += (anEntry+", "); + TDF_Tool::Entry(theEndLCS->GetEntry(), anEntry); + aDescr += (anEntry+")"); + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aCopy; +} + +//============================================================================= +/*! + * Rotate + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate (Handle(GEOM_Object) theObject, + Handle(GEOM_Object) theAxis, + double theAngle) +{ + SetErrorCode(KO); + + if (theObject.IsNull() || theAxis.IsNull()) return NULL; + + Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction(); + if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated + + // Get last functions of the arguments + Handle(GEOM_Function) anAF = theAxis->GetLastFunction(); + + //Add a rotate function + aFunction = theObject->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE); + + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL; + + GEOMImpl_IRotate aRI(aFunction); + aRI.SetAxis(anAF); + aRI.SetOriginal(aLastFunction); + aRI.SetAngle(theAngle); + + //Compute the translation + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Rotate driver failed"); + 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(theObject->GetEntry(), anEntry); + aDescr += (anEntry+" = ITransformOperations.Rotate("); + aDescr += (anEntry+", "); + TDF_Tool::Entry(theAxis->GetEntry(), anEntry); + aDescr += (anEntry+", "); + aDescr += (TCollection_AsciiString(theAngle)+") "); + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return theObject; +} + +//============================================================================= +/*! + * Rotate + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateCopy (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theAxis, double theAngle) +{ + SetErrorCode(KO); + + if (theObject.IsNull() || theAxis.IsNull()) return NULL; + + Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction(); + if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated + + //Add a new Copy object + Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType()); + + //Add a rotate function + aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_COPY); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL; + + GEOMImpl_IRotate aRI(aFunction); + aRI.SetAxis(theAxis->GetLastFunction()); + aRI.SetOriginal(aLastFunction); + aRI.SetAngle(theAngle); + + //Compute the translation + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Rotate driver failed"); + 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(theObject->GetEntry(), anEntry); + aDescr += (anEntry+" = ITransformOperations.RotateCopy("); + aDescr += (anEntry+", "); + TDF_Tool::Entry(theAxis->GetEntry(), anEntry); + aDescr += (anEntry+", "); + aDescr += (TCollection_AsciiString(theAngle)+") "); + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aCopy; +} + +//============================================================================= +/*! + * Rotate1D + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate1D (Handle(GEOM_Object) theObject, + Handle(GEOM_Object) theAxis, + Standard_Integer theNbTimes) +{ + SetErrorCode(KO); + + if (theObject.IsNull() || theAxis.IsNull()) return NULL; + + Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction(); + if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated + + //Add a new Copy object + Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType()); + + //Add a rotate function + aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_1D); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL; + + GEOMImpl_IRotate aRI(aFunction); + aRI.SetOriginal(aLastFunction); + aRI.SetAxis(theAxis->GetLastFunction()); + aRI.SetNbIter1(theNbTimes); + + //Compute the translation + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Rotate driver failed"); + 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(theObject->GetEntry(), anEntry); + aDescr += (anEntry+" = ITransformOperations.Rotate1D("); + aDescr += (anEntry+", "); + TDF_Tool::Entry(theAxis->GetEntry(), anEntry); + aDescr += (anEntry+", "); + aDescr += (TCollection_AsciiString(theNbTimes)+") "); + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aCopy; +} + +//============================================================================= +/*! + * Rotate2D + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate2D (Handle(GEOM_Object) theObject, + Handle(GEOM_Object) theAxis, + double theAngle, + Standard_Integer theNbTimes1, + double theStep, + Standard_Integer theNbTimes2) +{ + SetErrorCode(KO); + + if (theObject.IsNull() || theAxis.IsNull()) return NULL; + + Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction(); + if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated + + //Add a new Copy object + Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType()); + + //Add a rotate function + aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_2D); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL; + + GEOMImpl_IRotate aRI(aFunction); + aRI.SetAxis(theAxis->GetLastFunction()); + aRI.SetOriginal(aLastFunction); + aRI.SetNbIter1(theNbTimes1); + aRI.SetNbIter2(theNbTimes2); + aRI.SetAngle(theAngle); + aRI.SetStep(theStep); + + //Compute the translation + try { + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Rotate driver failed"); + 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(theObject->GetEntry(), anEntry); + aDescr += (anEntry+" = ITransformOperations.Rotate2D("); + aDescr += (anEntry+", "); + TDF_Tool::Entry(theAxis->GetEntry(), anEntry); + aDescr += (anEntry+", "); + aDescr += (TCollection_AsciiString(theAngle)+", "); + aDescr += (TCollection_AsciiString(theNbTimes1)+", "); + aDescr += (TCollection_AsciiString(theStep)+", "); + aDescr += (TCollection_AsciiString(theNbTimes2)+") "); + aFunction->SetDescription(aDescr); + + SetErrorCode(OK); + return aCopy; +} diff --git a/src/GEOMImpl/GEOMImpl_ITransformOperations.hxx b/src/GEOMImpl/GEOMImpl_ITransformOperations.hxx new file mode 100644 index 000000000..5ac2879a3 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_ITransformOperations.hxx @@ -0,0 +1,93 @@ + +#ifndef _GEOMImpl_ITransformOperations_HXX_ +#define _GEOMImpl_ITransformOperations_HXX_ + +#include "Utils_SALOME_Exception.hxx" +#include "GEOM_IOperations.hxx" +#include "GEOM_Engine.hxx" +#include "GEOM_Object.hxx" +#include + +class GEOMImpl_ITransformOperations : public GEOM_IOperations { + public: + GEOMImpl_ITransformOperations(GEOM_Engine* theEngine, int theDocID); + ~GEOMImpl_ITransformOperations(); + + Handle(GEOM_Object) TranslateTwoPoints (Handle(GEOM_Object) theObject, + Handle(GEOM_Object) thePoint1, + Handle(GEOM_Object) thePoint2); + + Handle(GEOM_Object) TranslateTwoPointsCopy (Handle(GEOM_Object) theObject, + Handle(GEOM_Object) thePoint1, + Handle(GEOM_Object) thePoint2); + + Handle(GEOM_Object) TranslateDXDYDZ (Handle(GEOM_Object) theObject, double theX, double theY, double theZ); + + Handle(GEOM_Object) TranslateDXDYDZCopy (Handle(GEOM_Object) theObject, double theX, double theY, double theZ); + + Handle(GEOM_Object) TranslateVector (Handle(GEOM_Object) theObject, + Handle(GEOM_Object) theVector); + + Handle(GEOM_Object) TranslateVectorCopy (Handle(GEOM_Object) theObject, + Handle(GEOM_Object) theVector); + + Handle(GEOM_Object) Translate1D (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector, double theStep, Standard_Integer theNbTimes); + + Handle(GEOM_Object) Translate2D (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector, double theStep1, Standard_Integer theNbTimes1, + Handle(GEOM_Object) theVector2, double theStep2, Standard_Integer theNbTimes2); + + Handle(GEOM_Object) MirrorPlane (Handle(GEOM_Object) theObject, + Handle(GEOM_Object) thePlane); + + Handle(GEOM_Object) MirrorPlaneCopy (Handle(GEOM_Object) theObject, + Handle(GEOM_Object) thePlane); + + Handle(GEOM_Object) MirrorAxis (Handle(GEOM_Object) theObject, + Handle(GEOM_Object) theAxis); + + Handle(GEOM_Object) MirrorAxisCopy (Handle(GEOM_Object) theObject, + Handle(GEOM_Object) theAxis); + + Handle(GEOM_Object) MirrorPoint (Handle(GEOM_Object) theObject, + Handle(GEOM_Object) thePoint); + + Handle(GEOM_Object) MirrorPointCopy (Handle(GEOM_Object) theObject, + Handle(GEOM_Object) thePoint); + + Handle(GEOM_Object) OffsetShape (Handle(GEOM_Object) theObject, + double theOffset); + + Handle(GEOM_Object) OffsetShapeCopy (Handle(GEOM_Object) theObject, + double theOffset); + + Handle(GEOM_Object) ScaleShape (Handle(GEOM_Object) theObject, + Handle(GEOM_Object) thePoint, + double theFactor); + + Handle(GEOM_Object) ScaleShapeCopy (Handle(GEOM_Object) theObject, + Handle(GEOM_Object) thePoint, + double theFactor); + + Handle(GEOM_Object) PositionShape (Handle(GEOM_Object) theObject, + Handle(GEOM_Object) theStartLCS, + Handle(GEOM_Object) theEndLCS); + + Handle(GEOM_Object) PositionShapeCopy (Handle(GEOM_Object) theObject, + Handle(GEOM_Object) theStartLCS, + Handle(GEOM_Object) theEndLCS); + + Handle(GEOM_Object) Rotate (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theAxis, double theAngle); + + Handle(GEOM_Object) RotateCopy (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theAxis, double theAngle); + + Handle(GEOM_Object) Rotate1D (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theAxis, Standard_Integer theNbTimes); + + Handle(GEOM_Object) Rotate2D (Handle(GEOM_Object) theObject, + Handle(GEOM_Object) theAxis, + double theAngle, + Standard_Integer theNbTimes1, + double theStep, + Standard_Integer theNbTimes2); +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_ITranslate.hxx b/src/GEOMImpl/GEOMImpl_ITranslate.hxx new file mode 100755 index 000000000..886f7744f --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_ITranslate.hxx @@ -0,0 +1,82 @@ +//NOTE: This is an intreface to a function for the Translate creation. + + +#include "GEOM_Function.hxx" + +#define TRANSLATE_ARG_POINT1 1 +#define TRANSLATE_ARG_POINT2 2 +#define TRANSLATE_ARG_VECTOR 3 +#define TRANSLATE_ARG_REF 4 +#define TRANSLATE_ARG_SHAPE 5 +#define TRANSLATE_ARG_ORIGINAL 6 +#define TRANSLATE_ARG_STEP1 7 +#define TRANSLATE_ARG_NBITER1 8 +#define TRANSLATE_ARG_STEP2 9 +#define TRANSLATE_ARG_NBITER2 10 +#define TRANSLATE_ARG_VECTOR2 11 +#define TRANSLATE_ARG_DX 12 +#define TRANSLATE_ARG_DY 13 +#define TRANSLATE_ARG_DZ 14 + +class GEOMImpl_ITranslate +{ + public: + + GEOMImpl_ITranslate(Handle(GEOM_Function) theFunction): _func(theFunction) {} + + void SetPoint1(Handle(GEOM_Function) thePoint1) { _func->SetReference(TRANSLATE_ARG_POINT1, thePoint1); } + + Handle(GEOM_Function) GetPoint1() { return _func->GetReference(TRANSLATE_ARG_POINT1); } + + void SetPoint2(Handle(GEOM_Function) thePoint2) { _func->SetReference(TRANSLATE_ARG_POINT2, thePoint2); } + + Handle(GEOM_Function) GetPoint2() { return _func->GetReference(TRANSLATE_ARG_POINT2); } + + void SetVector(Handle(GEOM_Function) theVector) { _func->SetReference(TRANSLATE_ARG_VECTOR, theVector); } + + Handle(GEOM_Function) GetVector() { return _func->GetReference(TRANSLATE_ARG_VECTOR); } + + void SetShape(const TopoDS_Shape& theShape) { _func->SetShape(TRANSLATE_ARG_SHAPE, theShape); } + + TopoDS_Shape GetShape() { return _func->GetShape(TRANSLATE_ARG_SHAPE); } + + void SetOriginal(Handle(GEOM_Function) theOriginal) { _func->SetReference(TRANSLATE_ARG_ORIGINAL, theOriginal); } + + Handle(GEOM_Function) GetOriginal() { return _func->GetReference(TRANSLATE_ARG_ORIGINAL); } + + void SetStep1(double theStep) { return _func->SetReal(TRANSLATE_ARG_STEP1, theStep); } + + double GetStep1() { return _func->GetReal(TRANSLATE_ARG_STEP1); } + + void SetNbIter1(int theNbIter) { _func->SetInteger(TRANSLATE_ARG_NBITER1, theNbIter); } + + int GetNbIter1() { return _func->GetInteger(TRANSLATE_ARG_NBITER1); } + + void SetStep2(double theStep) { return _func->SetReal(TRANSLATE_ARG_STEP2, theStep); } + + double GetStep2() { return _func->GetReal(TRANSLATE_ARG_STEP2); } + + void SetNbIter2(int theNbIter) { _func->SetInteger(TRANSLATE_ARG_NBITER2, theNbIter); } + + int GetNbIter2() { return _func->GetInteger(TRANSLATE_ARG_NBITER2); } + + void SetVector2(Handle(GEOM_Function) theVector) { _func->SetReference(TRANSLATE_ARG_VECTOR2, theVector); } + + Handle(GEOM_Function) GetVector2() { return _func->GetReference(TRANSLATE_ARG_VECTOR2); } + + void SetDX(double theDX) { return _func->SetReal(TRANSLATE_ARG_DX, theDX); } + + double GetDX() { return _func->GetReal(TRANSLATE_ARG_DX); } + + void SetDY(double theDY) { return _func->SetReal(TRANSLATE_ARG_DY, theDY); } + + double GetDY() { return _func->GetReal(TRANSLATE_ARG_DY); } + + void SetDZ(double theDZ) { return _func->SetReal(TRANSLATE_ARG_DZ, theDZ); } + + double GetDZ() { return _func->GetReal(TRANSLATE_ARG_DZ); } + + private: + + Handle(GEOM_Function) _func; +}; diff --git a/src/GEOMImpl/GEOMImpl_IVector.hxx b/src/GEOMImpl/GEOMImpl_IVector.hxx new file mode 100644 index 000000000..e1a344b8d --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_IVector.hxx @@ -0,0 +1,36 @@ +//NOTE: This is an intreface to a function for the vector creation. + + +#include "GEOM_Function.hxx" + +#define VEC_ARG_DX 1 +#define VEC_ARG_DY 2 +#define VEC_ARG_DZ 3 + +#define VEC_ARG_PNT1 4 +#define VEC_ARG_PNT2 5 + +class GEOMImpl_IVector +{ + public: + + GEOMImpl_IVector(Handle(GEOM_Function) theFunction): _func(theFunction) {} + + void SetDX(double theDX) { _func->SetReal(VEC_ARG_DX, theDX); } + void SetDY(double theDY) { _func->SetReal(VEC_ARG_DY, theDY); } + void SetDZ(double theDZ) { _func->SetReal(VEC_ARG_DZ, theDZ); } + + double GetDX() { return _func->GetReal(VEC_ARG_DX); } + double GetDY() { return _func->GetReal(VEC_ARG_DY); } + double GetDZ() { return _func->GetReal(VEC_ARG_DZ); } + + void SetPoint1(Handle(GEOM_Function) theRef) { _func->SetReference(VEC_ARG_PNT1, theRef); } + void SetPoint2(Handle(GEOM_Function) theRef) { _func->SetReference(VEC_ARG_PNT2, theRef); } + + Handle(GEOM_Function) GetPoint1() { return _func->GetReference(VEC_ARG_PNT1); } + Handle(GEOM_Function) GetPoint2() { return _func->GetReference(VEC_ARG_PNT2); } + + private: + + Handle(GEOM_Function) _func; +}; diff --git a/src/GEOMImpl/GEOMImpl_ImportDriver.cxx b/src/GEOMImpl/GEOMImpl_ImportDriver.cxx new file mode 100644 index 000000000..5f3fef221 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_ImportDriver.cxx @@ -0,0 +1,142 @@ + +using namespace std; +#include "GEOMImpl_ImportDriver.hxx" +#include "GEOMImpl_IImportExport.hxx" +#include "GEOMImpl_Types.hxx" +#include "GEOM_Function.hxx" + +#include "utilities.h" + +#include + +#include +#include + +#ifdef WNT +#include +#else +#include +#endif + +#ifdef WNT +#define LibHandle HMODULE +#define LoadLib( name ) LoadLibrary( name ) +#define GetProc GetProcAddress +#define UnLoadLib( handle ) FreeLibrary( handle ); +#else +#define LibHandle void* +#define LoadLib( name ) dlopen( name, RTLD_LAZY ) +#define GetProc dlsym +#define UnLoadLib( handle ) dlclose( handle ); +#endif + +typedef TopoDS_Shape (*funcPoint)(const TCollection_AsciiString&, TCollection_AsciiString&); + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& GEOMImpl_ImportDriver::GetID() +{ + static Standard_GUID aImportDriver("FF1BBB60-5D14-4df2-980B-3A668264EA16"); + return aImportDriver; +} + + +//======================================================================= +//function : GEOMImpl_ImportDriver +//purpose : +//======================================================================= +GEOMImpl_ImportDriver::GEOMImpl_ImportDriver() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_ImportDriver::Execute(TFunction_Logbook& log) const +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); + + GEOMImpl_IImportExport aCI (aFunction); + //Standard_Integer aType = aFunction->GetType(); + + // retrieve the file and plugin library names + TCollection_AsciiString aFileName = aCI.GetFileName(); + TCollection_AsciiString aLibName = aCI.GetPluginName(); + if (aFileName.IsEmpty() || aLibName.IsEmpty()) + return 0; + + // load plugin library + LibHandle anImportLib = LoadLib( aLibName.ToCString() ); + funcPoint fp = 0; + if ( anImportLib ) + fp = (funcPoint)GetProc( anImportLib, "Import" ); + + if ( !fp ) + return 0; + + // perform the import + TCollection_AsciiString anError; + TopoDS_Shape aShape = fp( aFileName, anError ); + + // unload plugin library + UnLoadLib( anImportLib ); + + if ( aShape.IsNull() ) { + StdFail_NotDone::Raise(anError.ToCString()); + return 0; + } + + // set the function result + aFunction->SetValue(aShape); + + log.SetTouched(Label()); + + return 1; +} + + +//======================================================================= +//function : GEOMImpl_ImportDriver_Type_ +//purpose : +//======================================================================= +Standard_EXPORT Handle_Standard_Type& GEOMImpl_ImportDriver_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); + 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("GEOMImpl_ImportDriver", + sizeof(GEOMImpl_ImportDriver), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + +//======================================================================= +//function : DownCast +//purpose : +//======================================================================= +const Handle(GEOMImpl_ImportDriver) Handle(GEOMImpl_ImportDriver)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOMImpl_ImportDriver) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_ImportDriver))) { + _anOtherObject = Handle(GEOMImpl_ImportDriver)((Handle(GEOMImpl_ImportDriver)&)AnObject); + } + } + + return _anOtherObject ; +} diff --git a/src/GEOMImpl/GEOMImpl_ImportDriver.hxx b/src/GEOMImpl/GEOMImpl_ImportDriver.hxx new file mode 100644 index 000000000..8fcb48451 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_ImportDriver.hxx @@ -0,0 +1,139 @@ +// File : GEOMImpl_ImportDriver.ixx +// Module : GEOMImpl + +#ifndef _GEOMImpl_ImportDriver_HeaderFile +#define _GEOMImpl_ImportDriver_HeaderFile + +#ifndef _TColStd_SequenceOfExtendedString_HeaderFile +#include +#endif +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_GUID_HeaderFile +#include +#endif + +#ifndef _Handle_TFunction_Driver_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TFunction_Driver); +class GEOMImpl_ImportDriver; + +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMImpl_ImportDriver); + +class Handle(GEOMImpl_ImportDriver) : public Handle(TFunction_Driver) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + Handle(GEOMImpl_ImportDriver)():Handle(TFunction_Driver)() {} + Handle(GEOMImpl_ImportDriver)(const Handle(GEOMImpl_ImportDriver)& aHandle) : Handle(TFunction_Driver)(aHandle) + { + } + + Handle(GEOMImpl_ImportDriver)(const GEOMImpl_ImportDriver* anItem) : Handle(TFunction_Driver)((TFunction_Driver *)anItem) + { + } + + Handle(GEOMImpl_ImportDriver)& operator=(const Handle(GEOMImpl_ImportDriver)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOMImpl_ImportDriver)& operator=(const GEOMImpl_ImportDriver* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOMImpl_ImportDriver* operator->() + { + return (GEOMImpl_ImportDriver *)ControlAccess(); + } + + GEOMImpl_ImportDriver* operator->() const + { + return (GEOMImpl_ImportDriver *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOMImpl_ImportDriver)() {}; + + Standard_EXPORT static const Handle(GEOMImpl_ImportDriver) DownCast(const Handle(Standard_Transient)& AnObject); +}; + +#ifndef _TFunction_Driver_HeaderFile +#include +#endif +#ifndef _TFunction_Logbook_HeaderFile +#include +#endif +#ifndef _Standard_CString_HeaderFile +#include +#endif + +class TColStd_SequenceOfExtendedString; + + +class GEOMImpl_ImportDriver : public TFunction_Driver { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + // Methods PUBLIC + // +Standard_EXPORT GEOMImpl_ImportDriver(); +Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; +Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {} +Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const { return Standard_True; } +Standard_EXPORT static const Standard_GUID& GetID(); +Standard_EXPORT ~GEOMImpl_ImportDriver() {}; + + + // Type management + // +Standard_EXPORT friend Handle_Standard_Type& GEOMImpl_ImportDriver_Type_(); +Standard_EXPORT const Handle(Standard_Type)& DynamicType() const { return STANDARD_TYPE(GEOMImpl_ImportDriver) ; } +Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const { return (STANDARD_TYPE(GEOMImpl_ImportDriver) == AType || TFunction_Driver::IsKind(AType)); } + + +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_LineDriver.cxx b/src/GEOMImpl/GEOMImpl_LineDriver.cxx new file mode 100644 index 000000000..57903e3d2 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_LineDriver.cxx @@ -0,0 +1,154 @@ + +using namespace std; +#include "GEOMImpl_LineDriver.hxx" +#include "GEOMImpl_ILine.hxx" +#include "GEOMImpl_Types.hxx" +#include "GEOM_Function.hxx" + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& GEOMImpl_LineDriver::GetID() +{ + static Standard_GUID aLineDriver("FF1BBB06-5D14-4df2-980B-3A668264EA16"); + return aLineDriver; +} + + +//======================================================================= +//function : GEOMImpl_LineDriver +//purpose : +//======================================================================= +GEOMImpl_LineDriver::GEOMImpl_LineDriver() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_LineDriver::Execute(TFunction_Logbook& log) const +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); + + GEOMImpl_ILine aPI (aFunction); + Standard_Integer aType = aFunction->GetType(); + + TopoDS_Shape aShape; + + if (aType == LINE_TWO_PNT) { + Handle(GEOM_Function) aRefPnt1 = aPI.GetPoint1(); + Handle(GEOM_Function) aRefPnt2 = aPI.GetPoint2(); + TopoDS_Shape aShape1 = aRefPnt1->GetValue(); + TopoDS_Shape aShape2 = aRefPnt2->GetValue(); + if (aShape1.ShapeType() != TopAbs_VERTEX || + aShape2.ShapeType() != TopAbs_VERTEX) return 0; + if (aShape1.IsSame(aShape2)) { + Standard_ConstructionError::Raise("The end points must be different"); + } + gp_Pnt P1 = BRep_Tool::Pnt(TopoDS::Vertex(aShape1)); + gp_Pnt P2 = BRep_Tool::Pnt(TopoDS::Vertex(aShape2)); + if (P1.Distance(P2) < Precision::Confusion()) { + Standard_ConstructionError::Raise("The end points are too close"); + } + aShape = BRepBuilderAPI_MakeEdge(P1, P2).Shape(); + + } else if (aType == LINE_PNT_DIR) { + Handle(GEOM_Function) aRefPnt = aPI.GetPoint1(); + Handle(GEOM_Function) aRefDir = aPI.GetPoint2(); + TopoDS_Shape aShape1 = aRefPnt->GetValue(); + TopoDS_Shape aShape2 = aRefDir->GetValue(); + if (aShape1.ShapeType() != TopAbs_VERTEX || + aShape2.ShapeType() != TopAbs_EDGE) return 0; + if (aShape1.IsSame(aShape2)) { + Standard_ConstructionError::Raise("The end points must be different"); + } + gp_Pnt P1 = BRep_Tool::Pnt(TopoDS::Vertex(aShape1)); + + TopoDS_Edge anE = TopoDS::Edge(aShape2); + TopoDS_Vertex V1, V2; + TopExp::Vertices(anE, V1, V2, Standard_True); + if (V1.IsNull() || V2.IsNull()) { + Standard_NullObject::Raise("Line creation aborted: vector is not defined"); + } + gp_Pnt PV1 = BRep_Tool::Pnt(V1); + gp_Pnt PV2 = BRep_Tool::Pnt(V2); + if (PV1.Distance(PV2) < Precision::Confusion()) { + Standard_ConstructionError::Raise("Vector with null magnitude"); + } + + gp_Pnt P2 (P1.XYZ() + PV2.XYZ() - PV1.XYZ()); + aShape = BRepBuilderAPI_MakeEdge(P1, P2).Shape(); + } else { + } + + if (aShape.IsNull()) return 0; + aShape.Infinite(true); + + aFunction->SetValue(aShape); + + log.SetTouched(Label()); + + return 1; +} + + +//======================================================================= +//function : GEOMImpl_LineDriver_Type_ +//purpose : +//======================================================================= +Standard_EXPORT Handle_Standard_Type& GEOMImpl_LineDriver_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); + 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("GEOMImpl_LineDriver", + sizeof(GEOMImpl_LineDriver), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + +//======================================================================= +//function : DownCast +//purpose : +//======================================================================= +const Handle(GEOMImpl_LineDriver) Handle(GEOMImpl_LineDriver)::DownCast + (const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOMImpl_LineDriver) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_LineDriver))) { + _anOtherObject = Handle(GEOMImpl_LineDriver)((Handle(GEOMImpl_LineDriver)&)AnObject); + } + } + + return _anOtherObject ; +} diff --git a/src/GEOMImpl/GEOMImpl_LineDriver.hxx b/src/GEOMImpl/GEOMImpl_LineDriver.hxx new file mode 100644 index 000000000..d134835ef --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_LineDriver.hxx @@ -0,0 +1,138 @@ +// File : GEOMImpl_LineDriver.hxx +// Module : GEOMImpl + +#ifndef _GEOMImpl_LineDriver_HeaderFile +#define _GEOMImpl_LineDriver_HeaderFile + +#ifndef _TColStd_SequenceOfExtendedString_HeaderFile +#include +#endif +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_GUID_HeaderFile +#include +#endif + +#ifndef _Handle_TFunction_Driver_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TFunction_Driver); +class GEOMImpl_LineDriver; + +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMImpl_LineDriver); + +class Handle(GEOMImpl_LineDriver) : public Handle(TFunction_Driver) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + Handle(GEOMImpl_LineDriver)():Handle(TFunction_Driver)() {} + Handle(GEOMImpl_LineDriver)(const Handle(GEOMImpl_LineDriver)& aHandle) : Handle(TFunction_Driver)(aHandle) + { + } + + Handle(GEOMImpl_LineDriver)(const GEOMImpl_LineDriver* anItem) : Handle(TFunction_Driver)((TFunction_Driver *)anItem) + { + } + + Handle(GEOMImpl_LineDriver)& operator=(const Handle(GEOMImpl_LineDriver)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOMImpl_LineDriver)& operator=(const GEOMImpl_LineDriver* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOMImpl_LineDriver* operator->() + { + return (GEOMImpl_LineDriver *)ControlAccess(); + } + + GEOMImpl_LineDriver* operator->() const + { + return (GEOMImpl_LineDriver *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOMImpl_LineDriver)() {}; + + Standard_EXPORT static const Handle(GEOMImpl_LineDriver) DownCast(const Handle(Standard_Transient)& AnObject); +}; + +#ifndef _TFunction_Driver_HeaderFile +#include +#endif +#ifndef _TFunction_Logbook_HeaderFile +#include +#endif +#ifndef _Standard_CString_HeaderFile +#include +#endif + +class TColStd_SequenceOfExtendedString; + + +class GEOMImpl_LineDriver : public TFunction_Driver { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + // Methods PUBLIC + // +Standard_EXPORT GEOMImpl_LineDriver(); +Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; +Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {} +Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const { return Standard_True; } +Standard_EXPORT static const Standard_GUID& GetID(); +Standard_EXPORT ~GEOMImpl_LineDriver() {}; + + + // Type management + // +Standard_EXPORT friend Handle_Standard_Type& GEOMImpl_LineDriver_Type_(); +Standard_EXPORT const Handle(Standard_Type)& DynamicType() const { return STANDARD_TYPE(GEOMImpl_LineDriver) ; } +Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const { return (STANDARD_TYPE(GEOMImpl_LineDriver) == AType || TFunction_Driver::IsKind(AType)); } + +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_MarkerDriver.cxx b/src/GEOMImpl/GEOMImpl_MarkerDriver.cxx new file mode 100644 index 000000000..e5594d16e --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_MarkerDriver.cxx @@ -0,0 +1,140 @@ + +using namespace std; +#include "GEOMImpl_MarkerDriver.hxx" +#include "GEOMImpl_IMarker.hxx" +#include "GEOMImpl_Types.hxx" +#include "GEOM_Function.hxx" + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include + +#include + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& GEOMImpl_MarkerDriver::GetID() +{ + static Standard_GUID aMarkerDriver("FF1BBB07-5D14-4df2-980B-3A668264EA16"); + return aMarkerDriver; +} + + +//======================================================================= +//function : GEOMImpl_MarkerDriver +//purpose : +//======================================================================= +GEOMImpl_MarkerDriver::GEOMImpl_MarkerDriver() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_MarkerDriver::Execute(TFunction_Logbook& log) const +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); + + GEOMImpl_IMarker aPI (aFunction); + Standard_Integer aType = aFunction->GetType(); + + TopoDS_Shape aShape; + + if (aType == MARKER_CS) { + double OX, OY, OZ; + double XDX, XDY, XDZ; + double YDX, YDY, YDZ; + aPI.GetOrigin(OX, OY, OZ); + aPI.GetXDir(XDX, XDY, XDZ); + aPI.GetYDir(YDX, YDY, YDZ); + + gp_Pnt aPO (OX, OY, OZ); + gp_Vec aVX (XDX, XDY, XDZ); + gp_Vec aVY (YDX, YDY, YDZ); + Standard_Real aTol = Precision::Confusion(); + if (aVX.Magnitude() < aTol || + aVY.Magnitude() < aTol || + aVX.IsParallel(aVY, Precision::Angular())) { + Standard_ConstructionError::Raise("Degenerated or parallel directions given"); + } + + gp_Vec aN = aVX ^ aVY; + gp_Ax3 anA (aPO, aN, aVX); + gp_Pln aPln (anA); + + double aTrimSize = 100.0; + aShape = BRepBuilderAPI_MakeFace(aPln, -aTrimSize, +aTrimSize, -aTrimSize, +aTrimSize).Shape(); + } else { + } + + if (aShape.IsNull()) return 0; + + aFunction->SetValue(aShape); + + log.SetTouched(Label()); + + return 1; +} + + +//======================================================================= +//function : GEOMImpl_MarkerDriver_Type_ +//purpose : +//======================================================================= +Standard_EXPORT Handle_Standard_Type& GEOMImpl_MarkerDriver_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); + 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("GEOMImpl_MarkerDriver", + sizeof(GEOMImpl_MarkerDriver), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + +//======================================================================= +//function : DownCast +//purpose : +//======================================================================= +const Handle(GEOMImpl_MarkerDriver) Handle(GEOMImpl_MarkerDriver)::DownCast + (const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOMImpl_MarkerDriver) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_MarkerDriver))) { + _anOtherObject = Handle(GEOMImpl_MarkerDriver)((Handle(GEOMImpl_MarkerDriver)&)AnObject); + } + } + + return _anOtherObject ; +} diff --git a/src/GEOMImpl/GEOMImpl_MarkerDriver.hxx b/src/GEOMImpl/GEOMImpl_MarkerDriver.hxx new file mode 100644 index 000000000..cf1a069f4 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_MarkerDriver.hxx @@ -0,0 +1,138 @@ +// File : GEOMImpl_MarkerDriver.hxx +// Module : GEOMImpl + +#ifndef _GEOMImpl_MarkerDriver_HeaderFile +#define _GEOMImpl_MarkerDriver_HeaderFile + +#ifndef _TColStd_SequenceOfExtendedString_HeaderFile +#include +#endif +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_GUID_HeaderFile +#include +#endif + +#ifndef _Handle_TFunction_Driver_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TFunction_Driver); +class GEOMImpl_MarkerDriver; + +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMImpl_MarkerDriver); + +class Handle(GEOMImpl_MarkerDriver) : public Handle(TFunction_Driver) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + Handle(GEOMImpl_MarkerDriver)():Handle(TFunction_Driver)() {} + Handle(GEOMImpl_MarkerDriver)(const Handle(GEOMImpl_MarkerDriver)& aHandle) : Handle(TFunction_Driver)(aHandle) + { + } + + Handle(GEOMImpl_MarkerDriver)(const GEOMImpl_MarkerDriver* anItem) : Handle(TFunction_Driver)((TFunction_Driver *)anItem) + { + } + + Handle(GEOMImpl_MarkerDriver)& operator=(const Handle(GEOMImpl_MarkerDriver)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOMImpl_MarkerDriver)& operator=(const GEOMImpl_MarkerDriver* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOMImpl_MarkerDriver* operator->() + { + return (GEOMImpl_MarkerDriver *)ControlAccess(); + } + + GEOMImpl_MarkerDriver* operator->() const + { + return (GEOMImpl_MarkerDriver *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOMImpl_MarkerDriver)() {}; + + Standard_EXPORT static const Handle(GEOMImpl_MarkerDriver) DownCast(const Handle(Standard_Transient)& AnObject); +}; + +#ifndef _TFunction_Driver_HeaderFile +#include +#endif +#ifndef _TFunction_Logbook_HeaderFile +#include +#endif +#ifndef _Standard_CString_HeaderFile +#include +#endif + +class TColStd_SequenceOfExtendedString; + + +class GEOMImpl_MarkerDriver : public TFunction_Driver { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + // Methods PUBLIC + // +Standard_EXPORT GEOMImpl_MarkerDriver(); +Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; +Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {} +Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const { return Standard_True; } +Standard_EXPORT static const Standard_GUID& GetID(); +Standard_EXPORT ~GEOMImpl_MarkerDriver() {}; + + + // Type management + // +Standard_EXPORT friend Handle_Standard_Type& GEOMImpl_MarkerDriver_Type_(); +Standard_EXPORT const Handle(Standard_Type)& DynamicType() const { return STANDARD_TYPE(GEOMImpl_MarkerDriver) ; } +Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const { return (STANDARD_TYPE(GEOMImpl_MarkerDriver) == AType || TFunction_Driver::IsKind(AType)); } + +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_MeasureDriver.cxx b/src/GEOMImpl/GEOMImpl_MeasureDriver.cxx new file mode 100644 index 000000000..c2b5a15d3 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_MeasureDriver.cxx @@ -0,0 +1,134 @@ + +using namespace std; +#include "GEOMImpl_MeasureDriver.hxx" +#include "GEOMImpl_IMeasure.hxx" +#include "GEOMImpl_IMeasureOperations.hxx" +#include "GEOMImpl_Types.hxx" +#include "GEOM_Function.hxx" + +#include +#include +#include + +#include +#include +#include + +#include + +#include +#include +#include + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& GEOMImpl_MeasureDriver::GetID() +{ + static Standard_GUID aMeasureDriver("FF1BBB65-5D14-4df2-980B-3A668264EA16"); + return aMeasureDriver; +} + + +//======================================================================= +//function : GEOMImpl_MeasureDriver +//purpose : +//======================================================================= +GEOMImpl_MeasureDriver::GEOMImpl_MeasureDriver() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_MeasureDriver::Execute(TFunction_Logbook& log) const +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); + + GEOMImpl_IMeasure aCI (aFunction); + Standard_Integer aType = aFunction->GetType(); + + TopoDS_Shape aShape; + + if (aType == CDG_MEASURE) { + Handle(GEOM_Function) aRefBase = aCI.GetBase(); + TopoDS_Shape aShapeBase = aRefBase->GetValue(); + if (aShapeBase.IsNull()) { + Standard_NullObject::Raise("Shape for centre of mass calculation is null"); + } + + GProp_GProps aSystem; + gp_Pnt aCenterMass; + + if (aShapeBase.ShapeType() == TopAbs_VERTEX) { + aCenterMass = BRep_Tool::Pnt(TopoDS::Vertex(aShapeBase)); + } else if (aShapeBase.ShapeType() == TopAbs_EDGE || aShapeBase.ShapeType() == TopAbs_WIRE) { + BRepGProp::LinearProperties(aShapeBase, aSystem); + aCenterMass = aSystem.CentreOfMass(); + } else if (aShapeBase.ShapeType() == TopAbs_FACE || aShapeBase.ShapeType() == TopAbs_SHELL) { + BRepGProp::SurfaceProperties(aShapeBase, aSystem); + aCenterMass = aSystem.CentreOfMass(); + } else { + BRepGProp::VolumeProperties(aShapeBase, aSystem); + aCenterMass = aSystem.CentreOfMass(); + } + + aShape = BRepBuilderAPI_MakeVertex(aCenterMass).Shape(); + + } else { + } + + if (aShape.IsNull()) return 0; + + aFunction->SetValue(aShape); + + log.SetTouched(Label()); + + return 1; +} + + +//======================================================================= +//function : GEOMImpl_MeasureDriver_Type_ +//purpose : +//======================================================================= +Standard_EXPORT Handle_Standard_Type& GEOMImpl_MeasureDriver_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); + 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("GEOMImpl_MeasureDriver", + sizeof(GEOMImpl_MeasureDriver), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + +//======================================================================= +//function : DownCast +//purpose : +//======================================================================= +const Handle(GEOMImpl_MeasureDriver) Handle(GEOMImpl_MeasureDriver)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOMImpl_MeasureDriver) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_MeasureDriver))) { + _anOtherObject = Handle(GEOMImpl_MeasureDriver)((Handle(GEOMImpl_MeasureDriver)&)AnObject); + } + } + + return _anOtherObject ; +} diff --git a/src/GEOMImpl/GEOMImpl_MeasureDriver.hxx b/src/GEOMImpl/GEOMImpl_MeasureDriver.hxx new file mode 100644 index 000000000..3286f06c6 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_MeasureDriver.hxx @@ -0,0 +1,139 @@ +// File : GEOMImpl_MeasureDriver.ixx +// Module : GEOMImpl + +#ifndef _GEOMImpl_MeasureDriver_HeaderFile +#define _GEOMImpl_MeasureDriver_HeaderFile + +#ifndef _TColStd_SequenceOfExtendedString_HeaderFile +#include +#endif +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_GUID_HeaderFile +#include +#endif + +#ifndef _Handle_TFunction_Driver_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TFunction_Driver); +class GEOMImpl_MeasureDriver; + +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMImpl_MeasureDriver); + +class Handle(GEOMImpl_MeasureDriver) : public Handle(TFunction_Driver) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + Handle(GEOMImpl_MeasureDriver)():Handle(TFunction_Driver)() {} + Handle(GEOMImpl_MeasureDriver)(const Handle(GEOMImpl_MeasureDriver)& aHandle) : Handle(TFunction_Driver)(aHandle) + { + } + + Handle(GEOMImpl_MeasureDriver)(const GEOMImpl_MeasureDriver* anItem) : Handle(TFunction_Driver)((TFunction_Driver *)anItem) + { + } + + Handle(GEOMImpl_MeasureDriver)& operator=(const Handle(GEOMImpl_MeasureDriver)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOMImpl_MeasureDriver)& operator=(const GEOMImpl_MeasureDriver* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOMImpl_MeasureDriver* operator->() + { + return (GEOMImpl_MeasureDriver *)ControlAccess(); + } + + GEOMImpl_MeasureDriver* operator->() const + { + return (GEOMImpl_MeasureDriver *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOMImpl_MeasureDriver)() {}; + + Standard_EXPORT static const Handle(GEOMImpl_MeasureDriver) DownCast(const Handle(Standard_Transient)& AnObject); +}; + +#ifndef _TFunction_Driver_HeaderFile +#include +#endif +#ifndef _TFunction_Logbook_HeaderFile +#include +#endif +#ifndef _Standard_CString_HeaderFile +#include +#endif + +class TColStd_SequenceOfExtendedString; + + +class GEOMImpl_MeasureDriver : public TFunction_Driver { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + // Methods PUBLIC + // +Standard_EXPORT GEOMImpl_MeasureDriver(); +Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; +Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {} +Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const { return Standard_True; } +Standard_EXPORT static const Standard_GUID& GetID(); +Standard_EXPORT ~GEOMImpl_MeasureDriver() {}; + + + // Type management + // +Standard_EXPORT friend Handle_Standard_Type& GEOMImpl_MeasureDriver_Type_(); +Standard_EXPORT const Handle(Standard_Type)& DynamicType() const { return STANDARD_TYPE(GEOMImpl_MeasureDriver) ; } +Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const { return (STANDARD_TYPE(GEOMImpl_MeasureDriver) == AType || TFunction_Driver::IsKind(AType)); } + + +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_MirrorDriver.cxx b/src/GEOMImpl/GEOMImpl_MirrorDriver.cxx new file mode 100644 index 000000000..fefb1531d --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_MirrorDriver.cxx @@ -0,0 +1,166 @@ + +using namespace std; +#include "GEOMImpl_MirrorDriver.hxx" + +#include +#include +#include "GEOM_Function.hxx" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& GEOMImpl_MirrorDriver::GetID() +{ + static Standard_GUID aMirrorDriver("FF1BBB57-5D14-4df2-980B-3A668264EA16"); + return aMirrorDriver; +} + + +//======================================================================= +//function : GEOMImpl_MirrorDriver +//purpose : +//======================================================================= + +GEOMImpl_MirrorDriver::GEOMImpl_MirrorDriver() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_MirrorDriver::Execute(TFunction_Logbook& log) const +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); + + if (aFunction.IsNull()) return 0; + + TopoDS_Shape aShape; + gp_Trsf aTrsf; + + GEOMImpl_IMirror TI (aFunction); + Standard_Integer aType = aFunction->GetType(); + + Handle(GEOM_Function) anOriginalFunction = TI.GetOriginal(); + if (anOriginalFunction.IsNull()) return 0; + + TopoDS_Shape anOriginal = anOriginalFunction->GetValue(); + if (anOriginal.IsNull()) return 0; + + if (aType == MIRROR_PLANE || aType == MIRROR_PLANE_COPY) { + Handle(GEOM_Function) aPlane = TI.GetPlane(); + if (aPlane.IsNull()) return 0; + TopoDS_Shape aFaceShape = aPlane->GetValue(); + if (aFaceShape.IsNull() || aFaceShape.ShapeType() != TopAbs_FACE) return 0; + TopoDS_Face aFace = TopoDS::Face(aFaceShape); + + Handle(Geom_Surface) surf = BRep_Tool::Surface(aFace); + Handle(Geom_Plane) myPlane = Handle(Geom_Plane)::DownCast(surf); + const gp_Ax3 pos = myPlane->Position(); + const gp_Pnt loc = pos.Location(); /* location of the plane */ + const gp_Dir dir = pos.Direction(); /* Main direction of the plane (Z axis) */ + gp_Ax2 aPln (loc, dir); + aTrsf.SetMirror(aPln); + + } else if (aType == MIRROR_AXIS || aType == MIRROR_AXIS_COPY) { + Handle(GEOM_Function) anAxis = TI.GetAxis(); + if (anAxis.IsNull()) return 0; + TopoDS_Shape anAxisShape = anAxis->GetValue(); + if (anAxisShape.IsNull() || anAxisShape.ShapeType() != TopAbs_EDGE) return 0; + TopoDS_Edge anEdge = TopoDS::Edge(anAxisShape); + + gp_Pnt aP1 = BRep_Tool::Pnt(TopExp::FirstVertex(anEdge)); + gp_Pnt aP2 = BRep_Tool::Pnt(TopExp::LastVertex (anEdge)); + gp_Vec aV (aP1, aP2); + gp_Ax1 anAx1 (aP1, aV); + aTrsf.SetMirror(anAx1); + + } else if (aType == MIRROR_POINT || aType == MIRROR_POINT_COPY) { + Handle(GEOM_Function) aPoint = TI.GetPoint(); + if (aPoint.IsNull()) return 0; + TopoDS_Shape aVertexShape = aPoint->GetValue(); + if (aVertexShape.IsNull() || aVertexShape.ShapeType() != TopAbs_VERTEX) return 0; + TopoDS_Vertex aVertex = TopoDS::Vertex(aVertexShape); + + gp_Pnt aP = BRep_Tool::Pnt(aVertex); + aTrsf.SetMirror(aP); + } else { + return 0; + } + + BRepBuilderAPI_Transform aTransformation (anOriginal, aTrsf, Standard_False); + aShape = aTransformation.Shape(); + + if (aShape.IsNull()) return 0; + + aFunction->SetValue(aShape); + + log.SetTouched(Label()); + + return 1; +} + + +//======================================================================= +//function : GEOMImpl_MirrorDriver_Type_ +//purpose : +//======================================================================= +Standard_EXPORT Handle_Standard_Type& GEOMImpl_MirrorDriver_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); + 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("GEOMImpl_MirrorDriver", + sizeof(GEOMImpl_MirrorDriver), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + +//======================================================================= +//function : DownCast +//purpose : +//======================================================================= + +const Handle(GEOMImpl_MirrorDriver) Handle(GEOMImpl_MirrorDriver)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOMImpl_MirrorDriver) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_MirrorDriver))) { + _anOtherObject = Handle(GEOMImpl_MirrorDriver)((Handle(GEOMImpl_MirrorDriver)&)AnObject); + } + } + + return _anOtherObject ; +} + + diff --git a/src/GEOMImpl/GEOMImpl_MirrorDriver.hxx b/src/GEOMImpl/GEOMImpl_MirrorDriver.hxx new file mode 100644 index 000000000..b9ad4a31b --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_MirrorDriver.hxx @@ -0,0 +1,139 @@ +// File : GEOMImpl_MirrorDriver.hxx +// Module : GEOMImpl + +#ifndef _GEOMImpl_MirrorDriver_HeaderFile +#define _GEOMImpl_MirrorDriver_HeaderFile + +#ifndef _TColStd_SequenceOfExtendedString_HeaderFile +#include +#endif +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_GUID_HeaderFile +#include +#endif + +#ifndef _Handle_TFunction_Driver_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TFunction_Driver); +class GEOMImpl_MirrorDriver; + +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMImpl_MirrorDriver); + +class Handle(GEOMImpl_MirrorDriver) : public Handle(TFunction_Driver) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + Handle(GEOMImpl_MirrorDriver)():Handle(TFunction_Driver)() {} + Handle(GEOMImpl_MirrorDriver)(const Handle(GEOMImpl_MirrorDriver)& aHandle) : Handle(TFunction_Driver)(aHandle) + { + } + + Handle(GEOMImpl_MirrorDriver)(const GEOMImpl_MirrorDriver* anItem) : Handle(TFunction_Driver)((TFunction_Driver *)anItem) + { + } + + Handle(GEOMImpl_MirrorDriver)& operator=(const Handle(GEOMImpl_MirrorDriver)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOMImpl_MirrorDriver)& operator=(const GEOMImpl_MirrorDriver* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOMImpl_MirrorDriver* operator->() + { + return (GEOMImpl_MirrorDriver *)ControlAccess(); + } + + GEOMImpl_MirrorDriver* operator->() const + { + return (GEOMImpl_MirrorDriver *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOMImpl_MirrorDriver)() {}; + + Standard_EXPORT static const Handle(GEOMImpl_MirrorDriver) DownCast(const Handle(Standard_Transient)& AnObject); +}; + +#ifndef _TFunction_Driver_HeaderFile +#include +#endif +#ifndef _TFunction_Logbook_HeaderFile +#include +#endif +#ifndef _Standard_CString_HeaderFile +#include +#endif + +class TColStd_SequenceOfExtendedString; + + +class GEOMImpl_MirrorDriver : public TFunction_Driver { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + // Methods PUBLIC + // +Standard_EXPORT GEOMImpl_MirrorDriver(); +Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; +Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {} +Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const { return Standard_True; } +Standard_EXPORT static const Standard_GUID& GetID(); +Standard_EXPORT ~GEOMImpl_MirrorDriver() {}; + + + // Type management + // +Standard_EXPORT friend Handle_Standard_Type& GEOMImpl_MirrorDriver_Type_(); +Standard_EXPORT const Handle(Standard_Type)& DynamicType() const { return STANDARD_TYPE(GEOMImpl_MirrorDriver) ; } +Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const { return (STANDARD_TYPE(GEOMImpl_MirrorDriver) == AType || TFunction_Driver::IsKind(AType)); } + + +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_OffsetDriver.cxx b/src/GEOMImpl/GEOMImpl_OffsetDriver.cxx new file mode 100644 index 000000000..5d82b97b4 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_OffsetDriver.cxx @@ -0,0 +1,128 @@ + +using namespace std; +#include "GEOMImpl_OffsetDriver.hxx" +#include "GEOMImpl_IOffset.hxx" +#include "GEOMImpl_Types.hxx" +#include "GEOM_Function.hxx" + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& GEOMImpl_OffsetDriver::GetID() +{ + static Standard_GUID aOffsetDriver("FF1BBB51-5D14-4df2-980B-3A668264EA16"); + return aOffsetDriver; +} + + +//======================================================================= +//function : GEOMImpl_OffsetDriver +//purpose : +//======================================================================= +GEOMImpl_OffsetDriver::GEOMImpl_OffsetDriver() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_OffsetDriver::Execute(TFunction_Logbook& log) const +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); + + GEOMImpl_IOffset aCI (aFunction); + Standard_Integer aType = aFunction->GetType(); + + TopoDS_Shape aShape; + + if (aType == OFFSET_SHAPE || aType == OFFSET_SHAPE_COPY) { + Handle(GEOM_Function) aRefShape = aCI.GetShape(); + TopoDS_Shape aShapeBase = aRefShape->GetValue(); + Standard_Real anOffset = aCI.GetValue(); + Standard_Real aTol = Precision::Confusion(); + + if (Abs(anOffset) < aTol) { + TCollection_AsciiString aMsg ("Absolute value of offset can not be less than the tolerance value ("); + aMsg += TCollection_AsciiString(aTol); + aMsg += ")"; + StdFail_NotDone::Raise(aMsg.ToCString()); + } + + BRepOffsetAPI_MakeOffsetShape MO (aShapeBase, + aCI.GetValue(), + aTol); + if (MO.IsDone()) { + aShape = MO.Shape(); + } else { + StdFail_NotDone::Raise("Offset construction failed"); + } + } else { + } + + if (aShape.IsNull()) return 0; + + aFunction->SetValue(aShape); + + log.SetTouched(Label()); + + return 1; +} + + +//======================================================================= +//function : GEOMImpl_OffsetDriver_Type_ +//purpose : +//======================================================================= +Standard_EXPORT Handle_Standard_Type& GEOMImpl_OffsetDriver_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); + 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("GEOMImpl_OffsetDriver", + sizeof(GEOMImpl_OffsetDriver), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + +//======================================================================= +//function : DownCast +//purpose : +//======================================================================= +const Handle(GEOMImpl_OffsetDriver) Handle(GEOMImpl_OffsetDriver)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOMImpl_OffsetDriver) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_OffsetDriver))) { + _anOtherObject = Handle(GEOMImpl_OffsetDriver)((Handle(GEOMImpl_OffsetDriver)&)AnObject); + } + } + + return _anOtherObject ; +} diff --git a/src/GEOMImpl/GEOMImpl_OffsetDriver.hxx b/src/GEOMImpl/GEOMImpl_OffsetDriver.hxx new file mode 100644 index 000000000..a9d34d745 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_OffsetDriver.hxx @@ -0,0 +1,139 @@ +// File : GEOMImpl_OffsetDriver.ixx +// Module : GEOMImpl + +#ifndef _GEOMImpl_OffsetDriver_HeaderFile +#define _GEOMImpl_OffsetDriver_HeaderFile + +#ifndef _TColStd_SequenceOfExtendedString_HeaderFile +#include +#endif +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_GUID_HeaderFile +#include +#endif + +#ifndef _Handle_TFunction_Driver_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TFunction_Driver); +class GEOMImpl_OffsetDriver; + +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMImpl_OffsetDriver); + +class Handle(GEOMImpl_OffsetDriver) : public Handle(TFunction_Driver) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + Handle(GEOMImpl_OffsetDriver)():Handle(TFunction_Driver)() {} + Handle(GEOMImpl_OffsetDriver)(const Handle(GEOMImpl_OffsetDriver)& aHandle) : Handle(TFunction_Driver)(aHandle) + { + } + + Handle(GEOMImpl_OffsetDriver)(const GEOMImpl_OffsetDriver* anItem) : Handle(TFunction_Driver)((TFunction_Driver *)anItem) + { + } + + Handle(GEOMImpl_OffsetDriver)& operator=(const Handle(GEOMImpl_OffsetDriver)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOMImpl_OffsetDriver)& operator=(const GEOMImpl_OffsetDriver* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOMImpl_OffsetDriver* operator->() + { + return (GEOMImpl_OffsetDriver *)ControlAccess(); + } + + GEOMImpl_OffsetDriver* operator->() const + { + return (GEOMImpl_OffsetDriver *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOMImpl_OffsetDriver)() {}; + + Standard_EXPORT static const Handle(GEOMImpl_OffsetDriver) DownCast(const Handle(Standard_Transient)& AnObject); +}; + +#ifndef _TFunction_Driver_HeaderFile +#include +#endif +#ifndef _TFunction_Logbook_HeaderFile +#include +#endif +#ifndef _Standard_CString_HeaderFile +#include +#endif + +class TColStd_SequenceOfExtendedString; + + +class GEOMImpl_OffsetDriver : public TFunction_Driver { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + // Methods PUBLIC + // +Standard_EXPORT GEOMImpl_OffsetDriver(); +Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; +Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {} +Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const { return Standard_True; } +Standard_EXPORT static const Standard_GUID& GetID(); +Standard_EXPORT ~GEOMImpl_OffsetDriver() {}; + + + // Type management + // +Standard_EXPORT friend Handle_Standard_Type& GEOMImpl_OffsetDriver_Type_(); +Standard_EXPORT const Handle(Standard_Type)& DynamicType() const { return STANDARD_TYPE(GEOMImpl_OffsetDriver) ; } +Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const { return (STANDARD_TYPE(GEOMImpl_OffsetDriver) == AType || TFunction_Driver::IsKind(AType)); } + + +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_PartitionDriver.cxx b/src/GEOMImpl/GEOMImpl_PartitionDriver.cxx new file mode 100644 index 000000000..5f284c488 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_PartitionDriver.cxx @@ -0,0 +1,224 @@ + +using namespace std; +#include "GEOMImpl_PartitionDriver.hxx" +#include "GEOMImpl_IPartition.hxx" +#include "GEOMImpl_Types.hxx" +#include "GEOM_Function.hxx" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& GEOMImpl_PartitionDriver::GetID() +{ + static Standard_GUID aPartitionDriver("FF1BBB22-5D14-4df2-980B-3A668264EA16"); + return aPartitionDriver; +} + + +//======================================================================= +//function : GEOMImpl_PartitionDriver +//purpose : +//======================================================================= +GEOMImpl_PartitionDriver::GEOMImpl_PartitionDriver() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_PartitionDriver::Execute(TFunction_Logbook& log) const +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); + + GEOMImpl_IPartition aCI (aFunction); + Standard_Integer aType = aFunction->GetType(); + + TopoDS_Shape aShape; + + if (aType == PARTITION_PARTITION) { + Handle(TColStd_HSequenceOfTransient) aShapes = aCI.GetShapes(); + Handle(TColStd_HSequenceOfTransient) aTools = aCI.GetTools(); + Handle(TColStd_HSequenceOfTransient) aKeepIns = aCI.GetKeepIns(); + Handle(TColStd_HSequenceOfTransient) aRemIns = aCI.GetRemoveIns(); + Handle(TColStd_HArray1OfInteger) aMaterials = aCI.GetMaterials(); + Standard_Boolean DoRemoveWebs = !aMaterials.IsNull(); + + unsigned int ind, nbshapes = 0; + nbshapes += aShapes->Length() + aTools->Length(); + nbshapes += aKeepIns->Length() + aRemIns->Length(); + + NMTAlgo_Splitter1 PS; + TopTools_MapOfShape ShapesMap(nbshapes), ToolsMap(nbshapes); + + // add object shapes that are in ListShapes; + for (ind = 1; ind <= aShapes->Length(); ind++) { + Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(aShapes->Value(ind)); + TopoDS_Shape aShape_i = aRefShape->GetValue(); + if (aShape_i.IsNull()) { + Standard_NullObject::Raise("In Partition a shape is null"); + } + if (ShapesMap.Add(aShape_i)) { + PS.AddShape(aShape_i); + if (DoRemoveWebs) { + if (aMaterials->Length() >= ind) + PS.SetMaterial(aShape_i, aMaterials->Value(ind)); + } + } + } + + // add tool shapes that are in ListTools and not in ListShapes; + for (ind = 1; ind <= aTools->Length(); ind++) { + Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(aTools->Value(ind)); + TopoDS_Shape aShape_i = aRefShape->GetValue(); + if (aShape_i.IsNull()) { + Standard_NullObject::Raise("In Partition a tool shape is null"); + } + if (!ShapesMap.Contains(aShape_i) && ToolsMap.Add(aShape_i)) + PS.AddTool(aShape_i); + } + + // add shapes that are in ListKeepInside, as object shapes; + for (ind = 1; ind <= aKeepIns->Length(); ind++) { + Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(aKeepIns->Value(ind)); + TopoDS_Shape aShape_i = aRefShape->GetValue(); + if (aShape_i.IsNull()) { + Standard_NullObject::Raise("In Partition a Keep Inside shape is null"); + } + if (!ToolsMap.Contains(aShape_i) && ShapesMap.Add(aShape_i)) + PS.AddShape(aShape_i); + } + + // add shapes that are in ListRemoveInside, as object shapes; + for (ind = 1; ind <= aRemIns->Length(); ind++) { + Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(aRemIns->Value(ind)); + TopoDS_Shape aShape_i = aRefShape->GetValue(); + if (aShape_i.IsNull()) { + Standard_NullObject::Raise("In Partition a Remove Inside shape is null"); + } + if (!ToolsMap.Contains(aShape_i) && ShapesMap.Add(aShape_i)) + PS.AddShape(aShape_i); + } + + PS.Compute(); + PS.SetRemoveWebs(DoRemoveWebs); + PS.Build((TopAbs_ShapeEnum) aCI.GetLimit()); + + // suppress result outside of shapes in KInsideMap + for (ind = 1; ind <= aKeepIns->Length(); ind++) { + Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(aKeepIns->Value(ind)); + TopoDS_Shape aShape_i = aRefShape->GetValue(); + PS.KeepShapesInside(aShape_i); + } + + // suppress result inside of shapes in RInsideMap + for (ind = 1; ind <= aRemIns->Length(); ind++) { + Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(aRemIns->Value(ind)); + TopoDS_Shape aShape_i = aRefShape->GetValue(); + PS.RemoveShapesInside(aShape_i); + } + + aShape = PS.Shape(); + + if (!BRepAlgo::IsValid(aShape)) { + Standard_ConstructionError::Raise("Partition aborted : non valid shape result"); + } + } else if (aType == PARTITION_HALF) { + Handle(GEOM_Function) aRefShape = aCI.GetShape(); + Handle(GEOM_Function) aRefPlane = aCI.GetPlane(); + TopoDS_Shape aShapeArg = aRefShape->GetValue(); + TopoDS_Shape aPlaneArg = aRefPlane->GetValue(); + + if (aShapeArg.IsNull() || aPlaneArg.IsNull()) { + Standard_NullObject::Raise("In Half Partition a shape or a plane is null"); + } + + NMTAlgo_Splitter1 PS; + + // add object shapes that are in ListShapes; + PS.AddShape(aShapeArg); + + // add tool shapes that are in ListTools and not in ListShapes; + PS.AddTool(aPlaneArg); + + PS.Compute(); + PS.SetRemoveWebs(Standard_False); + PS.Build(aShapeArg.ShapeType()); + + aShape = PS.Shape(); + + if (!BRepAlgo::IsValid(aShape)) { + Standard_ConstructionError::Raise("Partition aborted : non valid shape result"); + } + } + else { + } + + if (aShape.IsNull()) return 0; + + aFunction->SetValue(aShape); + + log.SetTouched(Label()); + + return 1; +} + + +//======================================================================= +//function : GEOMImpl_PartitionDriver_Type_ +//purpose : +//======================================================================= +Standard_EXPORT Handle_Standard_Type& GEOMImpl_PartitionDriver_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); + 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("GEOMImpl_PartitionDriver", + sizeof(GEOMImpl_PartitionDriver), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + +//======================================================================= +//function : DownCast +//purpose : +//======================================================================= +const Handle(GEOMImpl_PartitionDriver) Handle(GEOMImpl_PartitionDriver)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOMImpl_PartitionDriver) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_PartitionDriver))) { + _anOtherObject = Handle(GEOMImpl_PartitionDriver)((Handle(GEOMImpl_PartitionDriver)&)AnObject); + } + } + + return _anOtherObject ; +} diff --git a/src/GEOMImpl/GEOMImpl_PartitionDriver.hxx b/src/GEOMImpl/GEOMImpl_PartitionDriver.hxx new file mode 100644 index 000000000..f71c6a2ec --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_PartitionDriver.hxx @@ -0,0 +1,139 @@ +// File : GEOMImpl_PartitionDriver.ixx +// Module : GEOMImpl + +#ifndef _GEOMImpl_PartitionDriver_HeaderFile +#define _GEOMImpl_PartitionDriver_HeaderFile + +#ifndef _TColStd_SequenceOfExtendedString_HeaderFile +#include +#endif +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_GUID_HeaderFile +#include +#endif + +#ifndef _Handle_TFunction_Driver_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TFunction_Driver); +class GEOMImpl_PartitionDriver; + +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMImpl_PartitionDriver); + +class Handle(GEOMImpl_PartitionDriver) : public Handle(TFunction_Driver) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + Handle(GEOMImpl_PartitionDriver)():Handle(TFunction_Driver)() {} + Handle(GEOMImpl_PartitionDriver)(const Handle(GEOMImpl_PartitionDriver)& aHandle) : Handle(TFunction_Driver)(aHandle) + { + } + + Handle(GEOMImpl_PartitionDriver)(const GEOMImpl_PartitionDriver* anItem) : Handle(TFunction_Driver)((TFunction_Driver *)anItem) + { + } + + Handle(GEOMImpl_PartitionDriver)& operator=(const Handle(GEOMImpl_PartitionDriver)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOMImpl_PartitionDriver)& operator=(const GEOMImpl_PartitionDriver* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOMImpl_PartitionDriver* operator->() + { + return (GEOMImpl_PartitionDriver *)ControlAccess(); + } + + GEOMImpl_PartitionDriver* operator->() const + { + return (GEOMImpl_PartitionDriver *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOMImpl_PartitionDriver)() {}; + + Standard_EXPORT static const Handle(GEOMImpl_PartitionDriver) DownCast(const Handle(Standard_Transient)& AnObject); +}; + +#ifndef _TFunction_Driver_HeaderFile +#include +#endif +#ifndef _TFunction_Logbook_HeaderFile +#include +#endif +#ifndef _Standard_CString_HeaderFile +#include +#endif + +class TColStd_SequenceOfExtendedString; + + +class GEOMImpl_PartitionDriver : public TFunction_Driver { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + // Methods PUBLIC + // +Standard_EXPORT GEOMImpl_PartitionDriver(); +Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; +Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {} +Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const { return Standard_True; } +Standard_EXPORT static const Standard_GUID& GetID(); +Standard_EXPORT ~GEOMImpl_PartitionDriver() {}; + + + // Type management + // +Standard_EXPORT friend Handle_Standard_Type& GEOMImpl_PartitionDriver_Type_(); +Standard_EXPORT const Handle(Standard_Type)& DynamicType() const { return STANDARD_TYPE(GEOMImpl_PartitionDriver) ; } +Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const { return (STANDARD_TYPE(GEOMImpl_PartitionDriver) == AType || TFunction_Driver::IsKind(AType)); } + + +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_PipeDriver.cxx b/src/GEOMImpl/GEOMImpl_PipeDriver.cxx new file mode 100644 index 000000000..54b81eddc --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_PipeDriver.cxx @@ -0,0 +1,139 @@ + +using namespace std; +#include "GEOMImpl_PipeDriver.hxx" +#include "GEOMImpl_IPipe.hxx" +#include "GEOMImpl_Types.hxx" +#include "GEOM_Function.hxx" + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& GEOMImpl_PipeDriver::GetID() +{ + static Standard_GUID aPipeDriver("FF1BBB19-5D14-4df2-980B-3A668264EA16"); + return aPipeDriver; +} + + +//======================================================================= +//function : GEOMImpl_PipeDriver +//purpose : +//======================================================================= +GEOMImpl_PipeDriver::GEOMImpl_PipeDriver() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_PipeDriver::Execute(TFunction_Logbook& log) const +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); + + GEOMImpl_IPipe aCI (aFunction); + Standard_Integer aType = aFunction->GetType(); + + TopoDS_Shape aShape; + + if (aType == PIPE_BASE_PATH) { + Handle(GEOM_Function) aRefBase = aCI.GetBase(); + Handle(GEOM_Function) aRefPath = aCI.GetPath(); + TopoDS_Shape aShapeBase = aRefBase->GetValue(); + TopoDS_Shape aShapePath = aRefPath->GetValue(); + if (aShapeBase.IsNull() || aShapePath.IsNull()) { + Standard_NullObject::Raise("MakePipe aborted : null shape argument"); + } + + // Get path contour + TopoDS_Wire aWire; + if (aShapePath.ShapeType() == TopAbs_WIRE) { + aWire = TopoDS::Wire(aShapePath); + } else { + if (aShapePath.ShapeType() == TopAbs_EDGE) { + TopoDS_Edge anEdge = TopoDS::Edge(aShapePath); + aWire = BRepBuilderAPI_MakeWire(anEdge); + } else { + Standard_TypeMismatch::Raise("MakePipe aborted : path shape is neither a wire nor an edge"); + } + } + + // Make pipe + aShape = BRepOffsetAPI_MakePipe(aWire, aShapeBase); + } + else { + } + + if (aShape.IsNull()) return 0; + + BRepCheck_Analyzer ana (aShape, Standard_False); + if (!ana.IsValid()) { + Standard_ConstructionError::Raise("Algorithm have produced an invalid shape result"); + } + + aFunction->SetValue(aShape); + + log.SetTouched(Label()); + + return 1; +} + + +//======================================================================= +//function : GEOMImpl_PipeDriver_Type_ +//purpose : +//======================================================================= +Standard_EXPORT Handle_Standard_Type& GEOMImpl_PipeDriver_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); + 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("GEOMImpl_PipeDriver", + sizeof(GEOMImpl_PipeDriver), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + +//======================================================================= +//function : DownCast +//purpose : +//======================================================================= +const Handle(GEOMImpl_PipeDriver) Handle(GEOMImpl_PipeDriver)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOMImpl_PipeDriver) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_PipeDriver))) { + _anOtherObject = Handle(GEOMImpl_PipeDriver)((Handle(GEOMImpl_PipeDriver)&)AnObject); + } + } + + return _anOtherObject ; +} diff --git a/src/GEOMImpl/GEOMImpl_PipeDriver.hxx b/src/GEOMImpl/GEOMImpl_PipeDriver.hxx new file mode 100644 index 000000000..819b5b143 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_PipeDriver.hxx @@ -0,0 +1,139 @@ +// File : GEOMImpl_PipeDriver.ixx +// Module : GEOMImpl + +#ifndef _GEOMImpl_PipeDriver_HeaderFile +#define _GEOMImpl_PipeDriver_HeaderFile + +#ifndef _TColStd_SequenceOfExtendedString_HeaderFile +#include +#endif +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_GUID_HeaderFile +#include +#endif + +#ifndef _Handle_TFunction_Driver_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TFunction_Driver); +class GEOMImpl_PipeDriver; + +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMImpl_PipeDriver); + +class Handle(GEOMImpl_PipeDriver) : public Handle(TFunction_Driver) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + Handle(GEOMImpl_PipeDriver)():Handle(TFunction_Driver)() {} + Handle(GEOMImpl_PipeDriver)(const Handle(GEOMImpl_PipeDriver)& aHandle) : Handle(TFunction_Driver)(aHandle) + { + } + + Handle(GEOMImpl_PipeDriver)(const GEOMImpl_PipeDriver* anItem) : Handle(TFunction_Driver)((TFunction_Driver *)anItem) + { + } + + Handle(GEOMImpl_PipeDriver)& operator=(const Handle(GEOMImpl_PipeDriver)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOMImpl_PipeDriver)& operator=(const GEOMImpl_PipeDriver* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOMImpl_PipeDriver* operator->() + { + return (GEOMImpl_PipeDriver *)ControlAccess(); + } + + GEOMImpl_PipeDriver* operator->() const + { + return (GEOMImpl_PipeDriver *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOMImpl_PipeDriver)() {}; + + Standard_EXPORT static const Handle(GEOMImpl_PipeDriver) DownCast(const Handle(Standard_Transient)& AnObject); +}; + +#ifndef _TFunction_Driver_HeaderFile +#include +#endif +#ifndef _TFunction_Logbook_HeaderFile +#include +#endif +#ifndef _Standard_CString_HeaderFile +#include +#endif + +class TColStd_SequenceOfExtendedString; + + +class GEOMImpl_PipeDriver : public TFunction_Driver { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + // Methods PUBLIC + // +Standard_EXPORT GEOMImpl_PipeDriver(); +Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; +Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {} +Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const { return Standard_True; } +Standard_EXPORT static const Standard_GUID& GetID(); +Standard_EXPORT ~GEOMImpl_PipeDriver() {}; + + + // Type management + // +Standard_EXPORT friend Handle_Standard_Type& GEOMImpl_PipeDriver_Type_(); +Standard_EXPORT const Handle(Standard_Type)& DynamicType() const { return STANDARD_TYPE(GEOMImpl_PipeDriver) ; } +Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const { return (STANDARD_TYPE(GEOMImpl_PipeDriver) == AType || TFunction_Driver::IsKind(AType)); } + + +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_PlaneDriver.cxx b/src/GEOMImpl/GEOMImpl_PlaneDriver.cxx new file mode 100644 index 000000000..510d7a291 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_PlaneDriver.cxx @@ -0,0 +1,163 @@ + +using namespace std; +#include "GEOMImpl_PlaneDriver.hxx" +#include "GEOMImpl_IPlane.hxx" +#include "GEOMImpl_Types.hxx" +#include "GEOM_Function.hxx" + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include + +#include +#include + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& GEOMImpl_PlaneDriver::GetID() +{ + static Standard_GUID aPlaneDriver("FF1BBB05-5D14-4df2-980B-3A668264EA16"); + return aPlaneDriver; +} + + +//======================================================================= +//function : GEOMImpl_PlaneDriver +//purpose : +//======================================================================= +GEOMImpl_PlaneDriver::GEOMImpl_PlaneDriver() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_PlaneDriver::Execute(TFunction_Logbook& log) const +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); + + GEOMImpl_IPlane aPI (aFunction); + Standard_Integer aType = aFunction->GetType(); + + TopoDS_Shape aShape; + + double aSize = aPI.GetSize() / 2.0; + if (aType == PLANE_PNT_VEC) { + Handle(GEOM_Function) aRefPnt = aPI.GetPoint(); + Handle(GEOM_Function) aRefVec = aPI.GetVector(); + TopoDS_Shape aShape1 = aRefPnt->GetValue(); + TopoDS_Shape aShape2 = aRefVec->GetValue(); + if (aShape1.ShapeType() != TopAbs_VERTEX || + aShape2.ShapeType() != TopAbs_EDGE) return 0; + gp_Pnt aP = BRep_Tool::Pnt(TopoDS::Vertex(aShape1)); + TopoDS_Edge anE = TopoDS::Edge(aShape2); + TopoDS_Vertex V1, V2; + TopExp::Vertices(anE, V1, V2, Standard_True); + if (!V1.IsNull() && !V2.IsNull()) { + gp_Vec aV (BRep_Tool::Pnt(V1), BRep_Tool::Pnt(V2)); + gp_Pln aPln (aP, aV); + aShape = BRepBuilderAPI_MakeFace(aPln, -aSize, +aSize, -aSize, +aSize).Shape(); + } + } else if (aType == PLANE_THREE_PNT) { + Handle(GEOM_Function) aRefPnt1 = aPI.GetPoint1(); + Handle(GEOM_Function) aRefPnt2 = aPI.GetPoint2(); + Handle(GEOM_Function) aRefPnt3 = aPI.GetPoint3(); + TopoDS_Shape aShape1 = aRefPnt1->GetValue(); + TopoDS_Shape aShape2 = aRefPnt2->GetValue(); + TopoDS_Shape aShape3 = aRefPnt3->GetValue(); + if (aShape1.ShapeType() != TopAbs_VERTEX || + aShape2.ShapeType() != TopAbs_VERTEX || + aShape3.ShapeType() != TopAbs_VERTEX) return 0; + gp_Pnt aP1 = BRep_Tool::Pnt(TopoDS::Vertex(aShape1)); + gp_Pnt aP2 = BRep_Tool::Pnt(TopoDS::Vertex(aShape2)); + gp_Pnt aP3 = BRep_Tool::Pnt(TopoDS::Vertex(aShape3)); + if (aP1.Distance(aP2) < gp::Resolution() || + aP1.Distance(aP3) < gp::Resolution() || + aP2.Distance(aP3) < gp::Resolution()) + Standard_ConstructionError::Raise("Plane creation aborted: coincident points given"); + if (gp_Vec(aP1, aP2).IsParallel(gp_Vec(aP1, aP3), Precision::Angular())) + Standard_ConstructionError::Raise("Plane creation aborted: points lay on one line"); + GC_MakePlane aMakePlane (aP1, aP2, aP3); + aShape = BRepBuilderAPI_MakeFace(aMakePlane, -aSize, +aSize, -aSize, +aSize).Shape(); + } else if (aType == PLANE_FACE) { + Handle(GEOM_Function) aRef = aPI.GetFace(); + TopoDS_Shape aRefShape = aRef->GetValue(); + if (aRefShape.ShapeType() != TopAbs_FACE) return 0; + Handle(Geom_Surface) aGS = BRep_Tool::Surface(TopoDS::Face(aRefShape)); + if (!aGS->IsKind(STANDARD_TYPE(Geom_Plane))) { + Standard_TypeMismatch::Raise("Plane creation aborted: non-planar face given as argument"); + } + aShape = BRepBuilderAPI_MakeFace(aGS, -aSize, +aSize, -aSize, +aSize).Shape(); + } else { + } + + if (aShape.IsNull()) return 0; + + aFunction->SetValue(aShape); + + log.SetTouched(Label()); + + return 1; +} + + +//======================================================================= +//function : GEOMImpl_PlaneDriver_Type_ +//purpose : +//======================================================================= +Standard_EXPORT Handle_Standard_Type& GEOMImpl_PlaneDriver_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); + 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("GEOMImpl_PlaneDriver", + sizeof(GEOMImpl_PlaneDriver), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + +//======================================================================= +//function : DownCast +//purpose : +//======================================================================= +const Handle(GEOMImpl_PlaneDriver) Handle(GEOMImpl_PlaneDriver)::DownCast + (const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOMImpl_PlaneDriver) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_PlaneDriver))) { + _anOtherObject = Handle(GEOMImpl_PlaneDriver)((Handle(GEOMImpl_PlaneDriver)&)AnObject); + } + } + + return _anOtherObject ; +} diff --git a/src/GEOMImpl/GEOMImpl_PlaneDriver.hxx b/src/GEOMImpl/GEOMImpl_PlaneDriver.hxx new file mode 100644 index 000000000..8245b280a --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_PlaneDriver.hxx @@ -0,0 +1,138 @@ +// File : GEOMImpl_PlaneDriver.hxx +// Module : GEOMImpl + +#ifndef _GEOMImpl_PlaneDriver_HeaderFile +#define _GEOMImpl_PlaneDriver_HeaderFile + +#ifndef _TColStd_SequenceOfExtendedString_HeaderFile +#include +#endif +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_GUID_HeaderFile +#include +#endif + +#ifndef _Handle_TFunction_Driver_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TFunction_Driver); +class GEOMImpl_PlaneDriver; + +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMImpl_PlaneDriver); + +class Handle(GEOMImpl_PlaneDriver) : public Handle(TFunction_Driver) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + Handle(GEOMImpl_PlaneDriver)():Handle(TFunction_Driver)() {} + Handle(GEOMImpl_PlaneDriver)(const Handle(GEOMImpl_PlaneDriver)& aHandle) : Handle(TFunction_Driver)(aHandle) + { + } + + Handle(GEOMImpl_PlaneDriver)(const GEOMImpl_PlaneDriver* anItem) : Handle(TFunction_Driver)((TFunction_Driver *)anItem) + { + } + + Handle(GEOMImpl_PlaneDriver)& operator=(const Handle(GEOMImpl_PlaneDriver)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOMImpl_PlaneDriver)& operator=(const GEOMImpl_PlaneDriver* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOMImpl_PlaneDriver* operator->() + { + return (GEOMImpl_PlaneDriver *)ControlAccess(); + } + + GEOMImpl_PlaneDriver* operator->() const + { + return (GEOMImpl_PlaneDriver *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOMImpl_PlaneDriver)() {}; + + Standard_EXPORT static const Handle(GEOMImpl_PlaneDriver) DownCast(const Handle(Standard_Transient)& AnObject); +}; + +#ifndef _TFunction_Driver_HeaderFile +#include +#endif +#ifndef _TFunction_Logbook_HeaderFile +#include +#endif +#ifndef _Standard_CString_HeaderFile +#include +#endif + +class TColStd_SequenceOfExtendedString; + + +class GEOMImpl_PlaneDriver : public TFunction_Driver { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + // Methods PUBLIC + // +Standard_EXPORT GEOMImpl_PlaneDriver(); +Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; +Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {} +Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const { return Standard_True; } +Standard_EXPORT static const Standard_GUID& GetID(); +Standard_EXPORT ~GEOMImpl_PlaneDriver() {}; + + + // Type management + // +Standard_EXPORT friend Handle_Standard_Type& GEOMImpl_PlaneDriver_Type_(); +Standard_EXPORT const Handle(Standard_Type)& DynamicType() const { return STANDARD_TYPE(GEOMImpl_PlaneDriver) ; } +Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const { return (STANDARD_TYPE(GEOMImpl_PlaneDriver) == AType || TFunction_Driver::IsKind(AType)); } + +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_PointDriver.cxx b/src/GEOMImpl/GEOMImpl_PointDriver.cxx new file mode 100644 index 000000000..98a839b58 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_PointDriver.cxx @@ -0,0 +1,138 @@ + +using namespace std; +#include "GEOMImpl_PointDriver.hxx" +#include "GEOMImpl_IPoint.hxx" +#include "GEOMImpl_Types.hxx" +#include "GEOM_Function.hxx" + +#include +#include + +#include +#include +#include +#include +#include + +#include +#include + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& GEOMImpl_PointDriver::GetID() +{ + static Standard_GUID aPointDriver("FF1BBB02-5D14-4df2-980B-3A668264EA16"); + return aPointDriver; +} + + +//======================================================================= +//function : GEOMImpl_PointDriver +//purpose : +//======================================================================= +GEOMImpl_PointDriver::GEOMImpl_PointDriver() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_PointDriver::Execute(TFunction_Logbook& log) const +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); + + GEOMImpl_IPoint aPI (aFunction); + Standard_Integer aType = aFunction->GetType(); + + gp_Pnt aPnt; + + if (aType == POINT_XYZ) { + aPnt = gp_Pnt(aPI.GetX(), aPI.GetY(), aPI.GetZ()); + + } else if (aType == POINT_XYZ_REF) { + + Handle(GEOM_Function) aRefPoint = aPI.GetRef(); + TopoDS_Shape aRefShape = aRefPoint->GetValue(); + if (aRefShape.ShapeType() != TopAbs_VERTEX) { + Standard_TypeMismatch::Raise + ("Point creation aborted : referenced shape is not a vertex"); + } + gp_Pnt P = BRep_Tool::Pnt(TopoDS::Vertex(aRefShape)); + aPnt = gp_Pnt(P.X() + aPI.GetX(), P.Y() + aPI.GetY(), P.Z() + aPI.GetZ()); + + } else if (aType == POINT_CURVE_PAR) { + + Handle(GEOM_Function) aRefCurve = aPI.GetCurve(); + TopoDS_Shape aRefShape = aRefCurve->GetValue(); + if (aRefShape.ShapeType() != TopAbs_EDGE) { + Standard_TypeMismatch::Raise + ("Point On Curve creation aborted : curve shape is not an edge"); + } + Standard_Real aFP, aLP, aP; + Handle(Geom_Curve) aCurve = BRep_Tool::Curve(TopoDS::Edge(aRefShape), aFP, aLP); + aP = aFP + (aLP - aFP) * aPI.GetParameter(); + aPnt = aCurve->Value(aP); + + } else { + return 0; + } + + BRepBuilderAPI_MakeVertex mkVertex (aPnt); + TopoDS_Shape aShape = mkVertex.Shape(); + aShape.Infinite(Standard_True); + aFunction->SetValue(aShape); + + log.SetTouched(Label()); + + return 1; +} + + +//======================================================================= +//function : GEOMImpl_PointDriver_Type_ +//purpose : +//======================================================================= +Standard_EXPORT Handle_Standard_Type& GEOMImpl_PointDriver_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); + 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("GEOMImpl_PointDriver", + sizeof(GEOMImpl_PointDriver), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + +//======================================================================= +//function : DownCast +//purpose : +//======================================================================= + +const Handle(GEOMImpl_PointDriver) Handle(GEOMImpl_PointDriver)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOMImpl_PointDriver) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_PointDriver))) { + _anOtherObject = Handle(GEOMImpl_PointDriver)((Handle(GEOMImpl_PointDriver)&)AnObject); + } + } + + return _anOtherObject ; +} + + diff --git a/src/GEOMImpl/GEOMImpl_PointDriver.hxx b/src/GEOMImpl/GEOMImpl_PointDriver.hxx new file mode 100644 index 000000000..13bcb999f --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_PointDriver.hxx @@ -0,0 +1,138 @@ +// File : GEOMImpl_PointDriver.hxx +// Module : GEOMImpl + +#ifndef _GEOMImpl_PointDriver_HeaderFile +#define _GEOMImpl_PointDriver_HeaderFile + +#ifndef _TColStd_SequenceOfExtendedString_HeaderFile +#include +#endif +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_GUID_HeaderFile +#include +#endif + +#ifndef _Handle_TFunction_Driver_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TFunction_Driver); +class GEOMImpl_PointDriver; + +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMImpl_PointDriver); + +class Handle(GEOMImpl_PointDriver) : public Handle(TFunction_Driver) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + Handle(GEOMImpl_PointDriver)():Handle(TFunction_Driver)() {} + Handle(GEOMImpl_PointDriver)(const Handle(GEOMImpl_PointDriver)& aHandle) : Handle(TFunction_Driver)(aHandle) + { + } + + Handle(GEOMImpl_PointDriver)(const GEOMImpl_PointDriver* anItem) : Handle(TFunction_Driver)((TFunction_Driver *)anItem) + { + } + + Handle(GEOMImpl_PointDriver)& operator=(const Handle(GEOMImpl_PointDriver)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOMImpl_PointDriver)& operator=(const GEOMImpl_PointDriver* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOMImpl_PointDriver* operator->() + { + return (GEOMImpl_PointDriver *)ControlAccess(); + } + + GEOMImpl_PointDriver* operator->() const + { + return (GEOMImpl_PointDriver *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOMImpl_PointDriver)() {}; + + Standard_EXPORT static const Handle(GEOMImpl_PointDriver) DownCast(const Handle(Standard_Transient)& AnObject); +}; + +#ifndef _TFunction_Driver_HeaderFile +#include +#endif +#ifndef _TFunction_Logbook_HeaderFile +#include +#endif +#ifndef _Standard_CString_HeaderFile +#include +#endif + +class TColStd_SequenceOfExtendedString; + + +class GEOMImpl_PointDriver : public TFunction_Driver { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + // Methods PUBLIC + // +Standard_EXPORT GEOMImpl_PointDriver(); +Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; +Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {} +Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const { return Standard_True; } +Standard_EXPORT static const Standard_GUID& GetID(); +Standard_EXPORT ~GEOMImpl_PointDriver() {}; + + + // Type management + // +Standard_EXPORT friend Handle_Standard_Type& GEOMImpl_PointDriver_Type_(); +Standard_EXPORT const Handle(Standard_Type)& DynamicType() const { return STANDARD_TYPE(GEOMImpl_PointDriver) ; } +Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const { return (STANDARD_TYPE(GEOMImpl_PointDriver) == AType || TFunction_Driver::IsKind(AType)); } + +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_PolylineDriver.cxx b/src/GEOMImpl/GEOMImpl_PolylineDriver.cxx new file mode 100644 index 000000000..83dde5be4 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_PolylineDriver.cxx @@ -0,0 +1,124 @@ + +using namespace std; +#include "GEOMImpl_PolylineDriver.hxx" +#include "GEOMImpl_IPolyline.hxx" +#include "GEOMImpl_Types.hxx" +#include "GEOM_Function.hxx" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& GEOMImpl_PolylineDriver::GetID() +{ + static Standard_GUID aPolylineDriver("FF1BBB31-5D14-4df2-980B-3A668264EA16"); + return aPolylineDriver; +} + + +//======================================================================= +//function : GEOMImpl_PolylineDriver +//purpose : +//======================================================================= +GEOMImpl_PolylineDriver::GEOMImpl_PolylineDriver() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_PolylineDriver::Execute(TFunction_Logbook& log) const +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); + + GEOMImpl_IPolyline aCI (aFunction); + Standard_Integer aType = aFunction->GetType(); + + TopoDS_Shape aShape; + + if (aType == POLYLINE_POINTS) { + int aLen = aCI.GetLength(); + int ind = 1; + BRepBuilderAPI_MakePolygon aMakePoly; + for (; ind <= aLen; ind++) + { + Handle(GEOM_Function) aRefPoint = aCI.GetPoint(ind); + TopoDS_Shape aShapePnt = aRefPoint->GetValue(); + if (aShapePnt.ShapeType() == TopAbs_VERTEX) { + aMakePoly.Add(TopoDS::Vertex(aShapePnt)); +// if (!aMakePoly.Added()) return 0; + } + } + if (false) aMakePoly.Close(); + if (aMakePoly.IsDone()) { + aShape = aMakePoly.Wire(); + } + } + else { + } + + if (aShape.IsNull()) return 0; + + aFunction->SetValue(aShape); + + log.SetTouched(Label()); + + return 1; +} + + +//======================================================================= +//function : GEOMImpl_PolylineDriver_Type_ +//purpose : +//======================================================================= +Standard_EXPORT Handle_Standard_Type& GEOMImpl_PolylineDriver_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); + 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("GEOMImpl_PolylineDriver", + sizeof(GEOMImpl_PolylineDriver), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + +//======================================================================= +//function : DownCast +//purpose : +//======================================================================= +const Handle(GEOMImpl_PolylineDriver) Handle(GEOMImpl_PolylineDriver)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOMImpl_PolylineDriver) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_PolylineDriver))) { + _anOtherObject = Handle(GEOMImpl_PolylineDriver)((Handle(GEOMImpl_PolylineDriver)&)AnObject); + } + } + + return _anOtherObject ; +} diff --git a/src/GEOMImpl/GEOMImpl_PolylineDriver.hxx b/src/GEOMImpl/GEOMImpl_PolylineDriver.hxx new file mode 100644 index 000000000..3a6a2bd77 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_PolylineDriver.hxx @@ -0,0 +1,139 @@ +// File : GEOMImpl_PolylineDriver.ixx +// Module : GEOMImpl + +#ifndef _GEOMImpl_PolylineDriver_HeaderFile +#define _GEOMImpl_PolylineDriver_HeaderFile + +#ifndef _TColStd_SequenceOfExtendedString_HeaderFile +#include +#endif +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_GUID_HeaderFile +#include +#endif + +#ifndef _Handle_TFunction_Driver_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TFunction_Driver); +class GEOMImpl_PolylineDriver; + +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMImpl_PolylineDriver); + +class Handle(GEOMImpl_PolylineDriver) : public Handle(TFunction_Driver) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + Handle(GEOMImpl_PolylineDriver)():Handle(TFunction_Driver)() {} + Handle(GEOMImpl_PolylineDriver)(const Handle(GEOMImpl_PolylineDriver)& aHandle) : Handle(TFunction_Driver)(aHandle) + { + } + + Handle(GEOMImpl_PolylineDriver)(const GEOMImpl_PolylineDriver* anItem) : Handle(TFunction_Driver)((TFunction_Driver *)anItem) + { + } + + Handle(GEOMImpl_PolylineDriver)& operator=(const Handle(GEOMImpl_PolylineDriver)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOMImpl_PolylineDriver)& operator=(const GEOMImpl_PolylineDriver* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOMImpl_PolylineDriver* operator->() + { + return (GEOMImpl_PolylineDriver *)ControlAccess(); + } + + GEOMImpl_PolylineDriver* operator->() const + { + return (GEOMImpl_PolylineDriver *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOMImpl_PolylineDriver)() {}; + + Standard_EXPORT static const Handle(GEOMImpl_PolylineDriver) DownCast(const Handle(Standard_Transient)& AnObject); +}; + +#ifndef _TFunction_Driver_HeaderFile +#include +#endif +#ifndef _TFunction_Logbook_HeaderFile +#include +#endif +#ifndef _Standard_CString_HeaderFile +#include +#endif + +class TColStd_SequenceOfExtendedString; + + +class GEOMImpl_PolylineDriver : public TFunction_Driver { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + // Methods PUBLIC + // +Standard_EXPORT GEOMImpl_PolylineDriver(); +Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; +Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {} +Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const { return Standard_True; } +Standard_EXPORT static const Standard_GUID& GetID(); +Standard_EXPORT ~GEOMImpl_PolylineDriver() {}; + + + // Type management + // +Standard_EXPORT friend Handle_Standard_Type& GEOMImpl_PolylineDriver_Type_(); +Standard_EXPORT const Handle(Standard_Type)& DynamicType() const { return STANDARD_TYPE(GEOMImpl_PolylineDriver) ; } +Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const { return (STANDARD_TYPE(GEOMImpl_PolylineDriver) == AType || TFunction_Driver::IsKind(AType)); } + + +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_PositionDriver.cxx b/src/GEOMImpl/GEOMImpl_PositionDriver.cxx new file mode 100644 index 000000000..8bbf2e3bd --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_PositionDriver.cxx @@ -0,0 +1,173 @@ + +using namespace std; +#include "GEOMImpl_PositionDriver.hxx" +#include "GEOMImpl_IPosition.hxx" +#include "GEOMImpl_Types.hxx" +#include "GEOM_Function.hxx" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& GEOMImpl_PositionDriver::GetID() +{ + static Standard_GUID aPositionDriver("FF1BBB69-5D14-4df2-980B-3A668264EA16"); + return aPositionDriver; +} + + +//======================================================================= +//function : GEOMImpl_PositionDriver +//purpose : +//======================================================================= +GEOMImpl_PositionDriver::GEOMImpl_PositionDriver() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_PositionDriver::Execute(TFunction_Logbook& log) const +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); + + GEOMImpl_IPosition aCI (aFunction); + Standard_Integer aType = aFunction->GetType(); + + TopoDS_Shape aShape; + + if (aType == POSITION_SHAPE || aType == POSITION_SHAPE_COPY) { + Handle(GEOM_Function) aRefShape = aCI.GetShape(); + Handle(GEOM_Function) aRefStartLCS = aCI.GetStartLCS(); + Handle(GEOM_Function) aRefEndLCS = aCI.GetEndLCS(); + + TopoDS_Shape aShapeBase = aRefShape->GetValue(); + TopoDS_Shape aShapeStartLCS = aRefStartLCS->GetValue(); + TopoDS_Shape aShapeEndLCS = aRefEndLCS->GetValue(); + + if (aShapeBase.IsNull() || aShapeStartLCS.IsNull() || + aShapeEndLCS.IsNull() || aShapeEndLCS.ShapeType() != TopAbs_FACE) + return 0; + + gp_Trsf aTrsf; + gp_Ax3 aStartAx3, aDestAx3; + aStartAx3.Transform(aShapeStartLCS.Location().Transformation()); + aDestAx3.Transform(aShapeEndLCS.Location().Transformation()); + + Handle(Geom_Surface) aGS2 = BRep_Tool::Surface( TopoDS::Face( aShapeEndLCS ) ); + if (!aGS2.IsNull() && aGS2->IsKind( STANDARD_TYPE( Geom_Plane ) ) ) { + Handle(Geom_Plane) aGPlane2 = Handle(Geom_Plane)::DownCast( aGS2 ); + gp_Pln aPln2 = aGPlane2->Pln(); + aDestAx3 = aPln2.Position(); + } + + if(aShapeStartLCS.ShapeType() == TopAbs_FACE) { + Handle(Geom_Surface) aGS = BRep_Tool::Surface( TopoDS::Face( aShapeStartLCS ) ); + if (!aGS.IsNull() && aGS->IsKind( STANDARD_TYPE( Geom_Plane ) ) ) { + Handle(Geom_Plane) aGPlane = Handle(Geom_Plane)::DownCast( aGS ); + gp_Pln aPln = aGPlane->Pln(); + aStartAx3 = aPln.Position(); + } + aTrsf.SetDisplacement(aStartAx3, aDestAx3); + } + else { + gp_Trsf aTrsf1, aTrsf2; + aTrsf1.SetDisplacement(aStartAx3, aDestAx3); + BRepBuilderAPI_Transform aBT (aShapeBase, aTrsf1, Standard_False); + TopoDS_Shape aNewShape = aBT.Shape(); + + gp_Pnt aPnt; + if (aNewShape.ShapeType() == TopAbs_VERTEX) { + aPnt = BRep_Tool::Pnt(TopoDS::Vertex(aNewShape)); + } + else { + GProp_GProps aSystem; + if (aNewShape.ShapeType() == TopAbs_EDGE || aNewShape.ShapeType() == TopAbs_WIRE) + BRepGProp::LinearProperties(aNewShape, aSystem); + else if (aNewShape.ShapeType() == TopAbs_FACE || aNewShape.ShapeType() == TopAbs_SHELL) + BRepGProp::SurfaceProperties(aNewShape, aSystem); + else + BRepGProp::VolumeProperties(aNewShape, aSystem); + + aPnt = aSystem.CentreOfMass(); + } + + gp_Vec aVec(aPnt, aDestAx3.Location()); + aTrsf2.SetTranslation(aVec); + aTrsf = aTrsf2 * aTrsf1; + } + + BRepBuilderAPI_Transform aBRepTrsf (aShapeBase, aTrsf, Standard_False); + aShape = aBRepTrsf.Shape(); + } + else + return 0; + + if (aShape.IsNull()) return 0; + + aFunction->SetValue(aShape); + + log.SetTouched(Label()); + + return 1; +} + + +//======================================================================= +//function : GEOMImpl_PositionDriver_Type_ +//purpose : +//======================================================================= +Standard_EXPORT Handle_Standard_Type& GEOMImpl_PositionDriver_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); + 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("GEOMImpl_PositionDriver", + sizeof(GEOMImpl_PositionDriver), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + +//======================================================================= +//function : DownCast +//purpose : +//======================================================================= +const Handle(GEOMImpl_PositionDriver) Handle(GEOMImpl_PositionDriver)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOMImpl_PositionDriver) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_PositionDriver))) { + _anOtherObject = Handle(GEOMImpl_PositionDriver)((Handle(GEOMImpl_PositionDriver)&)AnObject); + } + } + + return _anOtherObject ; +} diff --git a/src/GEOMImpl/GEOMImpl_PositionDriver.hxx b/src/GEOMImpl/GEOMImpl_PositionDriver.hxx new file mode 100644 index 000000000..785fed132 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_PositionDriver.hxx @@ -0,0 +1,139 @@ +// File : GEOMImpl_PositionDriver.ixx +// Module : GEOMImpl + +#ifndef _GEOMImpl_PositionDriver_HeaderFile +#define _GEOMImpl_PositionDriver_HeaderFile + +#ifndef _TColStd_SequenceOfExtendedString_HeaderFile +#include +#endif +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_GUID_HeaderFile +#include +#endif + +#ifndef _Handle_TFunction_Driver_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TFunction_Driver); +class GEOMImpl_PositionDriver; + +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMImpl_PositionDriver); + +class Handle(GEOMImpl_PositionDriver) : public Handle(TFunction_Driver) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + Handle(GEOMImpl_PositionDriver)():Handle(TFunction_Driver)() {} + Handle(GEOMImpl_PositionDriver)(const Handle(GEOMImpl_PositionDriver)& aHandle) : Handle(TFunction_Driver)(aHandle) + { + } + + Handle(GEOMImpl_PositionDriver)(const GEOMImpl_PositionDriver* anItem) : Handle(TFunction_Driver)((TFunction_Driver *)anItem) + { + } + + Handle(GEOMImpl_PositionDriver)& operator=(const Handle(GEOMImpl_PositionDriver)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOMImpl_PositionDriver)& operator=(const GEOMImpl_PositionDriver* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOMImpl_PositionDriver* operator->() + { + return (GEOMImpl_PositionDriver *)ControlAccess(); + } + + GEOMImpl_PositionDriver* operator->() const + { + return (GEOMImpl_PositionDriver *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOMImpl_PositionDriver)() {}; + + Standard_EXPORT static const Handle(GEOMImpl_PositionDriver) DownCast(const Handle(Standard_Transient)& AnObject); +}; + +#ifndef _TFunction_Driver_HeaderFile +#include +#endif +#ifndef _TFunction_Logbook_HeaderFile +#include +#endif +#ifndef _Standard_CString_HeaderFile +#include +#endif + +class TColStd_SequenceOfExtendedString; + + +class GEOMImpl_PositionDriver : public TFunction_Driver { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + // Methods PUBLIC + // +Standard_EXPORT GEOMImpl_PositionDriver(); +Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; +Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {} +Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const { return Standard_True; } +Standard_EXPORT static const Standard_GUID& GetID(); +Standard_EXPORT ~GEOMImpl_PositionDriver() {}; + + + // Type management + // +Standard_EXPORT friend Handle_Standard_Type& GEOMImpl_PositionDriver_Type_(); +Standard_EXPORT const Handle(Standard_Type)& DynamicType() const { return STANDARD_TYPE(GEOMImpl_PositionDriver) ; } +Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const { return (STANDARD_TYPE(GEOMImpl_PositionDriver) == AType || TFunction_Driver::IsKind(AType)); } + + +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_PrismDriver.cxx b/src/GEOMImpl/GEOMImpl_PrismDriver.cxx new file mode 100644 index 000000000..71b460c5a --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_PrismDriver.cxx @@ -0,0 +1,145 @@ + +using namespace std; +#include "GEOMImpl_PrismDriver.hxx" +#include "GEOMImpl_IPrism.hxx" +#include "GEOMImpl_Types.hxx" +#include "GEOM_Function.hxx" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& GEOMImpl_PrismDriver::GetID() +{ + static Standard_GUID aPrismDriver("FF1BBB17-5D14-4df2-980B-3A668264EA16"); + return aPrismDriver; +} + + +//======================================================================= +//function : GEOMImpl_PrismDriver +//purpose : +//======================================================================= +GEOMImpl_PrismDriver::GEOMImpl_PrismDriver() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_PrismDriver::Execute(TFunction_Logbook& log) const +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); + + GEOMImpl_IPrism aCI (aFunction); + Standard_Integer aType = aFunction->GetType(); + + TopoDS_Shape aShape; + + if (aType == PRISM_BASE_VEC_H) { + Handle(GEOM_Function) aRefBase = aCI.GetBase(); + Handle(GEOM_Function) aRefVector = aCI.GetVector(); + TopoDS_Shape aShapeBase = aRefBase->GetValue(); + TopoDS_Shape aShapeVec = aRefVector->GetValue(); + if (aShapeVec.ShapeType() == TopAbs_EDGE) { + TopoDS_Edge anE = TopoDS::Edge(aShapeVec); + TopoDS_Vertex V1, V2; + TopExp::Vertices(anE, V1, V2, Standard_True); + if (!V1.IsNull() && !V2.IsNull()) { + gp_Vec aV (BRep_Tool::Pnt(V1), BRep_Tool::Pnt(V2)); + if (Abs(aCI.GetH()) < Precision::Confusion()) { + Standard_ConstructionError::Raise("Absolute value of prism height is too small"); + } + if (aV.Magnitude() > Precision::Confusion()) { + aV.Normalize(); + aShape = BRepPrimAPI_MakePrism(aShapeBase, aV * aCI.GetH(), Standard_False).Shape(); + } + } + } + } else if (aType == PRISM_BASE_TWO_PNT) { + Handle(GEOM_Function) aRefBase = aCI.GetBase(); + Handle(GEOM_Function) aRefPnt1 = aCI.GetFirstPoint(); + Handle(GEOM_Function) aRefPnt2 = aCI.GetLastPoint(); + TopoDS_Shape aShapeBase = aRefBase->GetValue(); + TopoDS_Shape aShapePnt1 = aRefPnt1->GetValue(); + TopoDS_Shape aShapePnt2 = aRefPnt2->GetValue(); + if (aShapePnt1.ShapeType() == TopAbs_VERTEX && + aShapePnt2.ShapeType() == TopAbs_VERTEX) { + TopoDS_Vertex V1 = TopoDS::Vertex(aShapePnt1); + TopoDS_Vertex V2 = TopoDS::Vertex(aShapePnt2); + if (!V1.IsNull() && !V2.IsNull()) { + gp_Vec aV (BRep_Tool::Pnt(V1), BRep_Tool::Pnt(V2)); + if (aV.Magnitude() > gp::Resolution()) { + aShape = BRepPrimAPI_MakePrism(aShapeBase, aV, Standard_False).Shape(); + } + } + } + } else { + } + + if (aShape.IsNull()) return 0; + + aFunction->SetValue(aShape); + + log.SetTouched(Label()); + + return 1; +} + + +//======================================================================= +//function : GEOMImpl_PrismDriver_Type_ +//purpose : +//======================================================================= +Standard_EXPORT Handle_Standard_Type& GEOMImpl_PrismDriver_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); + 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("GEOMImpl_PrismDriver", + sizeof(GEOMImpl_PrismDriver), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + +//======================================================================= +//function : DownCast +//purpose : +//======================================================================= +const Handle(GEOMImpl_PrismDriver) Handle(GEOMImpl_PrismDriver)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOMImpl_PrismDriver) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_PrismDriver))) { + _anOtherObject = Handle(GEOMImpl_PrismDriver)((Handle(GEOMImpl_PrismDriver)&)AnObject); + } + } + + return _anOtherObject ; +} diff --git a/src/GEOMImpl/GEOMImpl_PrismDriver.hxx b/src/GEOMImpl/GEOMImpl_PrismDriver.hxx new file mode 100644 index 000000000..7dcb76403 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_PrismDriver.hxx @@ -0,0 +1,139 @@ +// File : GEOMImpl_PrismDriver.ixx +// Module : GEOMImpl + +#ifndef _GEOMImpl_PrismDriver_HeaderFile +#define _GEOMImpl_PrismDriver_HeaderFile + +#ifndef _TColStd_SequenceOfExtendedString_HeaderFile +#include +#endif +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_GUID_HeaderFile +#include +#endif + +#ifndef _Handle_TFunction_Driver_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TFunction_Driver); +class GEOMImpl_PrismDriver; + +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMImpl_PrismDriver); + +class Handle(GEOMImpl_PrismDriver) : public Handle(TFunction_Driver) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + Handle(GEOMImpl_PrismDriver)():Handle(TFunction_Driver)() {} + Handle(GEOMImpl_PrismDriver)(const Handle(GEOMImpl_PrismDriver)& aHandle) : Handle(TFunction_Driver)(aHandle) + { + } + + Handle(GEOMImpl_PrismDriver)(const GEOMImpl_PrismDriver* anItem) : Handle(TFunction_Driver)((TFunction_Driver *)anItem) + { + } + + Handle(GEOMImpl_PrismDriver)& operator=(const Handle(GEOMImpl_PrismDriver)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOMImpl_PrismDriver)& operator=(const GEOMImpl_PrismDriver* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOMImpl_PrismDriver* operator->() + { + return (GEOMImpl_PrismDriver *)ControlAccess(); + } + + GEOMImpl_PrismDriver* operator->() const + { + return (GEOMImpl_PrismDriver *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOMImpl_PrismDriver)() {}; + + Standard_EXPORT static const Handle(GEOMImpl_PrismDriver) DownCast(const Handle(Standard_Transient)& AnObject); +}; + +#ifndef _TFunction_Driver_HeaderFile +#include +#endif +#ifndef _TFunction_Logbook_HeaderFile +#include +#endif +#ifndef _Standard_CString_HeaderFile +#include +#endif + +class TColStd_SequenceOfExtendedString; + + +class GEOMImpl_PrismDriver : public TFunction_Driver { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + // Methods PUBLIC + // +Standard_EXPORT GEOMImpl_PrismDriver(); +Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; +Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {} +Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const { return Standard_True; } +Standard_EXPORT static const Standard_GUID& GetID(); +Standard_EXPORT ~GEOMImpl_PrismDriver() {}; + + + // Type management + // +Standard_EXPORT friend Handle_Standard_Type& GEOMImpl_PrismDriver_Type_(); +Standard_EXPORT const Handle(Standard_Type)& DynamicType() const { return STANDARD_TYPE(GEOMImpl_PrismDriver) ; } +Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const { return (STANDARD_TYPE(GEOMImpl_PrismDriver) == AType || TFunction_Driver::IsKind(AType)); } + + +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_RevolutionDriver.cxx b/src/GEOMImpl/GEOMImpl_RevolutionDriver.cxx new file mode 100644 index 000000000..60222bcdf --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_RevolutionDriver.cxx @@ -0,0 +1,135 @@ + +using namespace std; +#include "GEOMImpl_RevolutionDriver.hxx" +#include "GEOMImpl_IRevolution.hxx" +#include "GEOMImpl_Types.hxx" +#include "GEOM_Function.hxx" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& GEOMImpl_RevolutionDriver::GetID() +{ + static Standard_GUID aRevolutionDriver("FF1BBB18-5D14-4df2-980B-3A668264EA16"); + return aRevolutionDriver; +} + + +//======================================================================= +//function : GEOMImpl_RevolutionDriver +//purpose : +//======================================================================= +GEOMImpl_RevolutionDriver::GEOMImpl_RevolutionDriver() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_RevolutionDriver::Execute(TFunction_Logbook& log) const +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); + + GEOMImpl_IRevolution aCI (aFunction); + Standard_Integer aType = aFunction->GetType(); + + TopoDS_Shape aShape; + + if (aType == REVOLUTION_BASE_AXIS_ANGLE) { + Handle(GEOM_Function) aRefBase = aCI.GetBase(); + Handle(GEOM_Function) aRefAxis = aCI.GetAxis(); + TopoDS_Shape aShapeBase = aRefBase->GetValue(); + TopoDS_Shape aShapeAxis = aRefAxis->GetValue(); + if (aShapeAxis.ShapeType() != TopAbs_EDGE) { + Standard_TypeMismatch::Raise("Revolution Axis must be an edge"); + } + + TopoDS_Edge anE = TopoDS::Edge(aShapeAxis); + TopoDS_Vertex V1, V2; + TopExp::Vertices(anE, V1, V2, Standard_True); + if (V1.IsNull() || V2.IsNull()) { + Standard_ConstructionError::Raise("Bad edge for the Revolution Axis given"); + } + + gp_Vec aV (BRep_Tool::Pnt(V1), BRep_Tool::Pnt(V2)); + if (aV.Magnitude() < Precision::Confusion()) { + Standard_ConstructionError::Raise + ("End vertices of edge, defining the Revolution Axis, are too close"); + } + + gp_Ax1 anAxis (BRep_Tool::Pnt(V1), aV); + BRepPrimAPI_MakeRevol MR (aShapeBase, anAxis, aCI.GetAngle(), Standard_False); + if (!MR.IsDone()) MR.Build(); + if (!MR.IsDone()) StdFail_NotDone::Raise("Revolution algorithm has failed"); + aShape = MR.Shape(); + } else { + } + + if (aShape.IsNull()) return 0; + aFunction->SetValue(aShape); + + log.SetTouched(Label()); + + return 1; +} + + +//======================================================================= +//function : GEOMImpl_RevolutionDriver_Type_ +//purpose : +//======================================================================= +Standard_EXPORT Handle_Standard_Type& GEOMImpl_RevolutionDriver_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); + 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("GEOMImpl_RevolutionDriver", + sizeof(GEOMImpl_RevolutionDriver), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + +//======================================================================= +//function : DownCast +//purpose : +//======================================================================= +const Handle(GEOMImpl_RevolutionDriver) Handle(GEOMImpl_RevolutionDriver)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOMImpl_RevolutionDriver) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_RevolutionDriver))) { + _anOtherObject = Handle(GEOMImpl_RevolutionDriver)((Handle(GEOMImpl_RevolutionDriver)&)AnObject); + } + } + + return _anOtherObject ; +} diff --git a/src/GEOMImpl/GEOMImpl_RevolutionDriver.hxx b/src/GEOMImpl/GEOMImpl_RevolutionDriver.hxx new file mode 100644 index 000000000..e994b9381 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_RevolutionDriver.hxx @@ -0,0 +1,139 @@ +// File : GEOMImpl_RevolutionDriver.ixx +// Module : GEOMImpl + +#ifndef _GEOMImpl_RevolutionDriver_HeaderFile +#define _GEOMImpl_RevolutionDriver_HeaderFile + +#ifndef _TColStd_SequenceOfExtendedString_HeaderFile +#include +#endif +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_GUID_HeaderFile +#include +#endif + +#ifndef _Handle_TFunction_Driver_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TFunction_Driver); +class GEOMImpl_RevolutionDriver; + +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMImpl_RevolutionDriver); + +class Handle(GEOMImpl_RevolutionDriver) : public Handle(TFunction_Driver) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + Handle(GEOMImpl_RevolutionDriver)():Handle(TFunction_Driver)() {} + Handle(GEOMImpl_RevolutionDriver)(const Handle(GEOMImpl_RevolutionDriver)& aHandle) : Handle(TFunction_Driver)(aHandle) + { + } + + Handle(GEOMImpl_RevolutionDriver)(const GEOMImpl_RevolutionDriver* anItem) : Handle(TFunction_Driver)((TFunction_Driver *)anItem) + { + } + + Handle(GEOMImpl_RevolutionDriver)& operator=(const Handle(GEOMImpl_RevolutionDriver)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOMImpl_RevolutionDriver)& operator=(const GEOMImpl_RevolutionDriver* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOMImpl_RevolutionDriver* operator->() + { + return (GEOMImpl_RevolutionDriver *)ControlAccess(); + } + + GEOMImpl_RevolutionDriver* operator->() const + { + return (GEOMImpl_RevolutionDriver *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOMImpl_RevolutionDriver)() {}; + + Standard_EXPORT static const Handle(GEOMImpl_RevolutionDriver) DownCast(const Handle(Standard_Transient)& AnObject); +}; + +#ifndef _TFunction_Driver_HeaderFile +#include +#endif +#ifndef _TFunction_Logbook_HeaderFile +#include +#endif +#ifndef _Standard_CString_HeaderFile +#include +#endif + +class TColStd_SequenceOfExtendedString; + + +class GEOMImpl_RevolutionDriver : public TFunction_Driver { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + // Methods PUBLIC + // +Standard_EXPORT GEOMImpl_RevolutionDriver(); +Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; +Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {} +Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const { return Standard_True; } +Standard_EXPORT static const Standard_GUID& GetID(); +Standard_EXPORT ~GEOMImpl_RevolutionDriver() {}; + + + // Type management + // +Standard_EXPORT friend Handle_Standard_Type& GEOMImpl_RevolutionDriver_Type_(); +Standard_EXPORT const Handle(Standard_Type)& DynamicType() const { return STANDARD_TYPE(GEOMImpl_RevolutionDriver) ; } +Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const { return (STANDARD_TYPE(GEOMImpl_RevolutionDriver) == AType || TFunction_Driver::IsKind(AType)); } + + +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_RotateDriver.cxx b/src/GEOMImpl/GEOMImpl_RotateDriver.cxx new file mode 100644 index 000000000..4f656dd5e --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_RotateDriver.cxx @@ -0,0 +1,243 @@ + +using namespace std; +#include "GEOMImpl_RotateDriver.hxx" +#include +#include +#include "GEOM_Function.hxx" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& GEOMImpl_RotateDriver::GetID() +{ + static Standard_GUID aRotateDriver("FF1BBB56-5D14-4df2-980B-3A668264EA16"); + return aRotateDriver; +} + + +//======================================================================= +//function : GEOMImpl_RotateDriver +//purpose : +//======================================================================= + +GEOMImpl_RotateDriver::GEOMImpl_RotateDriver() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_RotateDriver::Execute(TFunction_Logbook& log) const +{ + if(Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); + + if(aFunction.IsNull()) return 0; + + GEOMImpl_IRotate RI(aFunction); + gp_Trsf aTrsf; + Standard_Integer aType = aFunction->GetType(); + Handle(GEOM_Function) anOriginalFunction = RI.GetOriginal(); + if(anOriginalFunction.IsNull()) return 0; + TopoDS_Shape aShape, anOriginal = anOriginalFunction->GetValue(); + if(anOriginal.IsNull()) return 0; + + if(aType == ROTATE || aType == ROTATE_COPY) { + Handle(GEOM_Function) anAxis = RI.GetAxis(); + if(anAxis.IsNull()) return 0; + TopoDS_Shape A = anAxis->GetValue(); + if(A.IsNull() || A.ShapeType() != TopAbs_EDGE) return 0; + TopoDS_Edge anEdge = TopoDS::Edge(A); + + gp_Pnt aP1 = BRep_Tool::Pnt(TopExp::FirstVertex(anEdge)); + gp_Pnt aP2 = BRep_Tool::Pnt(TopExp::LastVertex(anEdge)); + gp_Dir aDir(gp_Vec(aP1, aP2)); + gp_Ax1 anAx1(aP1, aDir); + Standard_Real anAngle = RI.GetAngle(); + aTrsf.SetRotation(anAx1, anAngle); + + BRepBuilderAPI_Transform aTransformation(anOriginal, aTrsf, Standard_False); + aShape = aTransformation.Shape(); + } + else if(aType == ROTATE_1D) { + //Get direction + Handle(GEOM_Function) anAxis = RI.GetAxis(); + if(anAxis.IsNull()) return 0; + TopoDS_Shape A = anAxis->GetValue(); + if(A.IsNull() || A.ShapeType() != TopAbs_EDGE) return 0; + TopoDS_Edge anEdge = TopoDS::Edge(A); + + gp_Pnt aP1 = BRep_Tool::Pnt(TopExp::FirstVertex(anEdge)); + gp_Pnt aP2 = BRep_Tool::Pnt(TopExp::LastVertex(anEdge)); + gp_Dir D(gp_Vec(aP1, aP2)) ; + + gp_Ax1 AX1(aP1, D) ; + + Standard_Integer nbtimes = RI.GetNbIter1(); + Standard_Real angle = 360.0/nbtimes ; + + TopoDS_Compound aCompound; + BRep_Builder B; + B.MakeCompound( aCompound ); + + for (int i = 0; i < nbtimes; i++ ) { + aTrsf.SetRotation(AX1, i*angle*PI180) ; + BRepBuilderAPI_Transform myBRepTransformation(anOriginal, aTrsf, Standard_False) ; + B.Add( aCompound, myBRepTransformation.Shape() ); + } + + aShape = aCompound ; + } + else if(aType == ROTATE_2D) { + Standard_Real DX, DY, DZ ; + + //Get direction + Handle(GEOM_Function) anAxis = RI.GetAxis(); + if(anAxis.IsNull()) return 0; + TopoDS_Shape A = anAxis->GetValue(); + if(A.IsNull() || A.ShapeType() != TopAbs_EDGE) return 0; + TopoDS_Edge anEdge = TopoDS::Edge(A); + gp_Pnt aP1 = BRep_Tool::Pnt(TopExp::FirstVertex(anEdge)); + gp_Pnt aP2 = BRep_Tool::Pnt(TopExp::LastVertex(anEdge)); + gp_Dir D(gp_Vec(aP1, aP2)) ; + + gp_Ax1 AX1(aP1, D) ; + + + gp_Trsf theTransformation1 ; + gp_Trsf theTransformation2 ; + gp_Pnt P1 ; + GProp_GProps System ; + + if ( anOriginal.ShapeType() == TopAbs_VERTEX) { + P1 = BRep_Tool::Pnt(TopoDS::Vertex( anOriginal )); + } + else if ( anOriginal.ShapeType() == TopAbs_EDGE || anOriginal.ShapeType() == TopAbs_WIRE ) { + BRepGProp::LinearProperties(anOriginal, System); + P1 = System.CentreOfMass() ; + } + else if ( anOriginal.ShapeType() == TopAbs_FACE || anOriginal.ShapeType() == TopAbs_SHELL ) { + BRepGProp::SurfaceProperties(anOriginal, System); + P1 = System.CentreOfMass() ; + } + else { + BRepGProp::VolumeProperties(anOriginal, System); + P1 = System.CentreOfMass() ; + } + + Handle(Geom_Line) Line = new Geom_Line(AX1); + gp_Pnt P2 = GeomAPI_ProjectPointOnCurve( P1, Line ) ; + + if ( P1.IsEqual(P2, Precision::Confusion() ) ) return 0; + + gp_Vec Vec(P1.X()-P2.X(), P1.Y()-P2.Y(), P1.Z()-P2.Z()) ; + Vec.Normalize(); + + Standard_Integer nbtimes2 = RI.GetNbIter2(); + Standard_Integer nbtimes1 = RI.GetNbIter1(); + Standard_Real step = RI.GetStep(); + Standard_Real ang = RI.GetAngle(); + + gp_Vec myVec ; + TopoDS_Compound aCompound; + BRep_Builder B; + B.MakeCompound( aCompound ); + for (int i = 0; i < nbtimes2; i++ ) { + for (int j = 0; j < nbtimes1; j++ ) { + DX = i * step * Vec.X() ; + DY = i * step * Vec.Y() ; + DZ = i * step * Vec.Z() ; + myVec.SetCoord( DX, DY, DZ ) ; + theTransformation1.SetTranslation(myVec) ; + theTransformation2.SetRotation(AX1, j*ang*PI180) ; + BRepBuilderAPI_Transform myBRepTransformation1(anOriginal, theTransformation1, Standard_False) ; + BRepBuilderAPI_Transform myBRepTransformation2(myBRepTransformation1.Shape(), theTransformation2, Standard_False) ; + B.Add( aCompound, myBRepTransformation2.Shape() ); + } + } + + aShape = aCompound; + + } + else return 0; + + + + + if (aShape.IsNull()) return 0; + + aFunction->SetValue(aShape); + + log.SetTouched(Label()); + + return 1; +} + + +//======================================================================= +//function : GEOMImpl_RotateDriver_Type_ +//purpose : +//======================================================================= +Standard_EXPORT Handle_Standard_Type& GEOMImpl_RotateDriver_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); + 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("GEOMImpl_RotateDriver", + sizeof(GEOMImpl_RotateDriver), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + +//======================================================================= +//function : DownCast +//purpose : +//======================================================================= + +const Handle(GEOMImpl_RotateDriver) Handle(GEOMImpl_RotateDriver)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOMImpl_RotateDriver) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_RotateDriver))) { + _anOtherObject = Handle(GEOMImpl_RotateDriver)((Handle(GEOMImpl_RotateDriver)&)AnObject); + } + } + + return _anOtherObject ; +} + + diff --git a/src/GEOMImpl/GEOMImpl_RotateDriver.hxx b/src/GEOMImpl/GEOMImpl_RotateDriver.hxx new file mode 100644 index 000000000..7db4c00dd --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_RotateDriver.hxx @@ -0,0 +1,139 @@ +// File : GEOMImpl_RotateDriver.hxx +// Module : GEOMImpl + +#ifndef _GEOMImpl_RotateDriver_HeaderFile +#define _GEOMImpl_RotateDriver_HeaderFile + +#ifndef _TColStd_SequenceOfExtendedString_HeaderFile +#include +#endif +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_GUID_HeaderFile +#include +#endif + +#ifndef _Handle_TFunction_Driver_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TFunction_Driver); +class GEOMImpl_RotateDriver; + +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMImpl_RotateDriver); + +class Handle(GEOMImpl_RotateDriver) : public Handle(TFunction_Driver) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + Handle(GEOMImpl_RotateDriver)():Handle(TFunction_Driver)() {} + Handle(GEOMImpl_RotateDriver)(const Handle(GEOMImpl_RotateDriver)& aHandle) : Handle(TFunction_Driver)(aHandle) + { + } + + Handle(GEOMImpl_RotateDriver)(const GEOMImpl_RotateDriver* anItem) : Handle(TFunction_Driver)((TFunction_Driver *)anItem) + { + } + + Handle(GEOMImpl_RotateDriver)& operator=(const Handle(GEOMImpl_RotateDriver)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOMImpl_RotateDriver)& operator=(const GEOMImpl_RotateDriver* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOMImpl_RotateDriver* operator->() + { + return (GEOMImpl_RotateDriver *)ControlAccess(); + } + + GEOMImpl_RotateDriver* operator->() const + { + return (GEOMImpl_RotateDriver *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOMImpl_RotateDriver)() {}; + + Standard_EXPORT static const Handle(GEOMImpl_RotateDriver) DownCast(const Handle(Standard_Transient)& AnObject); +}; + +#ifndef _TFunction_Driver_HeaderFile +#include +#endif +#ifndef _TFunction_Logbook_HeaderFile +#include +#endif +#ifndef _Standard_CString_HeaderFile +#include +#endif + +class TColStd_SequenceOfExtendedString; + + +class GEOMImpl_RotateDriver : public TFunction_Driver { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + // Methods PUBLIC + // +Standard_EXPORT GEOMImpl_RotateDriver(); +Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; +Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {} +Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const { return Standard_True; } +Standard_EXPORT static const Standard_GUID& GetID(); +Standard_EXPORT ~GEOMImpl_RotateDriver() {}; + + + // Type management + // +Standard_EXPORT friend Handle_Standard_Type& GEOMImpl_RotateDriver_Type_(); +Standard_EXPORT const Handle(Standard_Type)& DynamicType() const { return STANDARD_TYPE(GEOMImpl_RotateDriver) ; } +Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const { return (STANDARD_TYPE(GEOMImpl_RotateDriver) == AType || TFunction_Driver::IsKind(AType)); } + + +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_ScaleDriver.cxx b/src/GEOMImpl/GEOMImpl_ScaleDriver.cxx new file mode 100644 index 000000000..4e707cb72 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_ScaleDriver.cxx @@ -0,0 +1,118 @@ + +using namespace std; +#include "GEOMImpl_ScaleDriver.hxx" +#include "GEOMImpl_IScale.hxx" +#include "GEOMImpl_Types.hxx" +#include "GEOM_Function.hxx" + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& GEOMImpl_ScaleDriver::GetID() +{ + static Standard_GUID aScaleDriver("FF1BBB52-5D14-4df2-980B-3A668264EA16"); + return aScaleDriver; +} + + +//======================================================================= +//function : GEOMImpl_ScaleDriver +//purpose : +//======================================================================= +GEOMImpl_ScaleDriver::GEOMImpl_ScaleDriver() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_ScaleDriver::Execute(TFunction_Logbook& log) const +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); + + GEOMImpl_IScale aCI (aFunction); + Standard_Integer aType = aFunction->GetType(); + + TopoDS_Shape aShape; + + if (aType == SCALE_SHAPE || aType == SCALE_SHAPE_COPY) { + Handle(GEOM_Function) aRefShape = aCI.GetShape(); + Handle(GEOM_Function) aRefPoint = aCI.GetPoint(); + TopoDS_Shape aShapeBase = aRefShape->GetValue(); + TopoDS_Shape aShapePnt = aRefPoint->GetValue(); + if (aShapeBase.IsNull() || aShapePnt.IsNull()) return 0; + if (aShapePnt.ShapeType() != TopAbs_VERTEX) return 0; + + gp_Pnt aP = BRep_Tool::Pnt(TopoDS::Vertex(aShapePnt)); + gp_Trsf aTrsf; + aTrsf.SetScale(aP, aCI.GetFactor()); + BRepBuilderAPI_Transform aBRepTrsf (aShapeBase, aTrsf, Standard_False); + aShape = aBRepTrsf.Shape(); + } else { + } + + if (aShape.IsNull()) return 0; + + aFunction->SetValue(aShape); + + log.SetTouched(Label()); + + return 1; +} + + +//======================================================================= +//function : GEOMImpl_ScaleDriver_Type_ +//purpose : +//======================================================================= +Standard_EXPORT Handle_Standard_Type& GEOMImpl_ScaleDriver_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); + 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("GEOMImpl_ScaleDriver", + sizeof(GEOMImpl_ScaleDriver), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + +//======================================================================= +//function : DownCast +//purpose : +//======================================================================= +const Handle(GEOMImpl_ScaleDriver) Handle(GEOMImpl_ScaleDriver)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOMImpl_ScaleDriver) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_ScaleDriver))) { + _anOtherObject = Handle(GEOMImpl_ScaleDriver)((Handle(GEOMImpl_ScaleDriver)&)AnObject); + } + } + + return _anOtherObject ; +} diff --git a/src/GEOMImpl/GEOMImpl_ScaleDriver.hxx b/src/GEOMImpl/GEOMImpl_ScaleDriver.hxx new file mode 100644 index 000000000..a2fc5907b --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_ScaleDriver.hxx @@ -0,0 +1,139 @@ +// File : GEOMImpl_ScaleDriver.ixx +// Module : GEOMImpl + +#ifndef _GEOMImpl_ScaleDriver_HeaderFile +#define _GEOMImpl_ScaleDriver_HeaderFile + +#ifndef _TColStd_SequenceOfExtendedString_HeaderFile +#include +#endif +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_GUID_HeaderFile +#include +#endif + +#ifndef _Handle_TFunction_Driver_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TFunction_Driver); +class GEOMImpl_ScaleDriver; + +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMImpl_ScaleDriver); + +class Handle(GEOMImpl_ScaleDriver) : public Handle(TFunction_Driver) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + Handle(GEOMImpl_ScaleDriver)():Handle(TFunction_Driver)() {} + Handle(GEOMImpl_ScaleDriver)(const Handle(GEOMImpl_ScaleDriver)& aHandle) : Handle(TFunction_Driver)(aHandle) + { + } + + Handle(GEOMImpl_ScaleDriver)(const GEOMImpl_ScaleDriver* anItem) : Handle(TFunction_Driver)((TFunction_Driver *)anItem) + { + } + + Handle(GEOMImpl_ScaleDriver)& operator=(const Handle(GEOMImpl_ScaleDriver)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOMImpl_ScaleDriver)& operator=(const GEOMImpl_ScaleDriver* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOMImpl_ScaleDriver* operator->() + { + return (GEOMImpl_ScaleDriver *)ControlAccess(); + } + + GEOMImpl_ScaleDriver* operator->() const + { + return (GEOMImpl_ScaleDriver *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOMImpl_ScaleDriver)() {}; + + Standard_EXPORT static const Handle(GEOMImpl_ScaleDriver) DownCast(const Handle(Standard_Transient)& AnObject); +}; + +#ifndef _TFunction_Driver_HeaderFile +#include +#endif +#ifndef _TFunction_Logbook_HeaderFile +#include +#endif +#ifndef _Standard_CString_HeaderFile +#include +#endif + +class TColStd_SequenceOfExtendedString; + + +class GEOMImpl_ScaleDriver : public TFunction_Driver { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + // Methods PUBLIC + // +Standard_EXPORT GEOMImpl_ScaleDriver(); +Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; +Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {} +Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const { return Standard_True; } +Standard_EXPORT static const Standard_GUID& GetID(); +Standard_EXPORT ~GEOMImpl_ScaleDriver() {}; + + + // Type management + // +Standard_EXPORT friend Handle_Standard_Type& GEOMImpl_ScaleDriver_Type_(); +Standard_EXPORT const Handle(Standard_Type)& DynamicType() const { return STANDARD_TYPE(GEOMImpl_ScaleDriver) ; } +Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const { return (STANDARD_TYPE(GEOMImpl_ScaleDriver) == AType || TFunction_Driver::IsKind(AType)); } + + +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_ShapeDriver.cxx b/src/GEOMImpl/GEOMImpl_ShapeDriver.cxx new file mode 100644 index 000000000..09e2190a9 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_ShapeDriver.cxx @@ -0,0 +1,352 @@ + +using namespace std; +#include "GEOMImpl_ShapeDriver.hxx" +#include "GEOMImpl_IShapes.hxx" +#include "GEOMImpl_IShapesOperations.hxx" +#include "GEOMImpl_Types.hxx" +#include "GEOM_Function.hxx" + +#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 : GetID +//purpose : +//======================================================================= +const Standard_GUID& GEOMImpl_ShapeDriver::GetID() +{ + static Standard_GUID aShapeDriver("FF1BBB54-5D14-4df2-980B-3A668264EA16"); + return aShapeDriver; +} + + +//======================================================================= +//function : GEOMImpl_ShapeDriver +//purpose : +//======================================================================= +GEOMImpl_ShapeDriver::GEOMImpl_ShapeDriver() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); + + GEOMImpl_IShapes aCI (aFunction); + Standard_Integer aType = aFunction->GetType(); + + TopoDS_Shape aShape; + BRep_Builder B; + + if (aType == WIRE_EDGES) { + Handle(TColStd_HSequenceOfTransient) aShapes = aCI.GetShapes(); + unsigned int ind, nbshapes = aShapes->Length(); + + // add edges + BRepBuilderAPI_MakeWire MW; + for (ind = 1; ind <= nbshapes; ind++) { + Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(aShapes->Value(ind)); + TopoDS_Shape aShape_i = aRefShape->GetValue(); + if (aShape_i.IsNull()) { + Standard_NullObject::Raise("Shape for wire construction is null"); + } + if (aShape_i.ShapeType() == TopAbs_EDGE) + MW.Add(TopoDS::Edge(aShape_i)); + else if (aShape_i.ShapeType() == TopAbs_WIRE) + MW.Add(TopoDS::Wire(aShape_i)); + else + Standard_TypeMismatch::Raise + ("Shape for wire construction is neither an edge nor a wire"); + } + + if (!MW.IsDone()) { + Standard_ConstructionError::Raise("Wire construction failed"); + } + aShape = MW; + + } else if (aType == FACE_WIRE) { + Handle(GEOM_Function) aRefBase = aCI.GetBase(); + TopoDS_Shape aShapeBase = aRefBase->GetValue(); + if (aShapeBase.IsNull() || aShapeBase.ShapeType() != TopAbs_WIRE) { + Standard_NullObject::Raise + ("Shape for face construction is null or not a wire"); + } + TopoDS_Wire W = TopoDS::Wire(aShapeBase); + BRepBuilderAPI_MakeFace MF (W, aCI.GetIsPlanar()); + if (!MF.IsDone()) { + Standard_ConstructionError::Raise("Face construction failed"); + } + aShape = MF.Shape(); + + } else if (aType == FACE_WIRES) { + Handle(TColStd_HSequenceOfTransient) aShapes = aCI.GetShapes(); + + // first wire + Handle(GEOM_Function) aRefWire = Handle(GEOM_Function)::DownCast(aShapes->Value(1)); + TopoDS_Shape aWire = aRefWire->GetValue(); + if (aWire.IsNull() || aWire.ShapeType() != TopAbs_WIRE) { + Standard_NullObject::Raise("Shape for face construction is null or not a wire"); + } + TopoDS_Wire W = TopoDS::Wire(aWire); + + // basic face + BRepBuilderAPI_MakeFace MF (W, aCI.GetIsPlanar()); + if (!MF.IsDone()) { + Standard_ConstructionError::Raise("Face construction failed"); + } + TopoDS_Shape FFace = MF.Shape(); + if (!FFace.IsNull()) { + unsigned int ind, nbshapes = aShapes->Length(); + if (nbshapes == 1) { + aShape = FFace; + + } else if (nbshapes >= 2) { + TopoDS_Compound C; + BRep_Builder aBuilder; + aBuilder.MakeCompound(C); + BRepAlgo_FaceRestrictor FR; + + TopAbs_Orientation OriF = FFace.Orientation(); + TopoDS_Shape aLocalS = FFace.Oriented(TopAbs_FORWARD); + FR.Init(TopoDS::Face(aLocalS), Standard_False, Standard_True); + + for (ind = 1; ind <= nbshapes; ind++) { + Handle(GEOM_Function) aRefWire_i = + Handle(GEOM_Function)::DownCast(aShapes->Value(ind)); + TopoDS_Shape aWire_i = aRefWire_i->GetValue(); + if (aWire_i.IsNull() || aWire_i.ShapeType() != TopAbs_WIRE) { + Standard_NullObject::Raise("Shape for face construction is null or not a wire"); + } + + FR.Add(TopoDS::Wire(aWire_i)); + } + + FR.Perform(); + + if (FR.IsDone()) { + int k = 0; + TopoDS_Shape aFace; + for (; FR.More(); FR.Next()) { + aFace = FR.Current().Oriented(OriF); + aBuilder.Add(C, aFace); + k++; + } + if (k == 1) { + aShape = aFace; + } else { + aShape = C; + } + } + } + } + } else if (aType == SHELL_FACES) { + Handle(TColStd_HSequenceOfTransient) aShapes = aCI.GetShapes(); + unsigned int ind, nbshapes = aShapes->Length(); + + // add faces + BRepAlgo_Sewing aSewing(Precision::Confusion()*10.0); + for (ind = 1; ind <= nbshapes; ind++) { + Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(aShapes->Value(ind)); + TopoDS_Shape aShape_i = aRefShape->GetValue(); + if (aShape_i.IsNull()) { + Standard_NullObject::Raise("Face for shell construction is null"); + } + aSewing.Add(aShape_i); + } + + aSewing.Perform(); + + TopExp_Explorer exp (aSewing.SewedShape(), TopAbs_SHELL); + Standard_Integer ish = 0; + for (; exp.More(); exp.Next()) { + aShape = exp.Current(); + ish++; + } + + if (ish != 1) + aShape = aSewing.SewedShape(); + + } else if (aType == SOLID_SHELL) { + Handle(GEOM_Function) aRefShell = aCI.GetBase(); + TopoDS_Shape aShapeShell = aRefShell->GetValue(); + if (aShapeShell.IsNull() || aShapeShell.ShapeType() != TopAbs_SHELL) { + Standard_NullObject::Raise("Shape for solid construction is null or not a shell"); + } + + BRepCheck_Shell chkShell(TopoDS::Shell(aShapeShell)); + if(chkShell.Closed() == BRepCheck_NotClosed) return 0; + + TopoDS_Solid Sol; + B.MakeSolid(Sol); + B.Add(Sol, aShapeShell); + BRepClass3d_SolidClassifier SC (Sol); + SC.PerformInfinitePoint(Precision::Confusion()); + if (SC.State() == TopAbs_IN) { + B.MakeSolid(Sol); + B.Add(Sol, aShapeShell.Reversed()); + } + + aShape = Sol; + + } else if (aType == SOLID_SHELLS) { + Handle(TColStd_HSequenceOfTransient) aShapes = aCI.GetShapes(); + unsigned int ind, nbshapes = aShapes->Length(); + Standard_Integer ish = 0; + TopoDS_Solid Sol; + TopoDS_Compound Res; + B.MakeCompound(Res); + + // add shapes + for (ind = 1; ind <= nbshapes; ind++) { + Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(aShapes->Value(ind)); + TopoDS_Shape aShapeShell = aRefShape->GetValue(); + if (aShapeShell.IsNull()) { + Standard_NullObject::Raise("Shell for solid construction is null"); + } + if (aShapeShell.ShapeType() == TopAbs_SHELL) { + B.MakeSolid(Sol); + B.Add(Sol, aShapeShell); + BRepClass3d_SolidClassifier SC (Sol); + SC.PerformInfinitePoint(Precision::Confusion()); + if (SC.State() == TopAbs_IN) { + B.MakeSolid(Sol); + B.Add(Sol, aShapeShell.Reversed()); + } + B.Add(Res, Sol); + ish++; + } + } + if (ish == 1) aShape = Sol; + else aShape = Res; + + } else if (aType == COMPOUND_SHAPES) { + Handle(TColStd_HSequenceOfTransient) aShapes = aCI.GetShapes(); + unsigned int ind, nbshapes = aShapes->Length(); + + // add shapes + TopoDS_Compound C; + B.MakeCompound(C); + for (ind = 1; ind <= nbshapes; ind++) { + Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(aShapes->Value(ind)); + TopoDS_Shape aShape_i = aRefShape->GetValue(); + if (aShape_i.IsNull()) { + Standard_NullObject::Raise("Shape for compound construction is null"); + } + B.Add(C, aShape_i); + } + + aShape = C; + + } else if (aType == REVERSE_ORIENTATION) { + Handle(GEOM_Function) aRefShape = aCI.GetBase(); + TopoDS_Shape aShape_i = aRefShape->GetValue(); + if (aShape_i.IsNull()) { + Standard_NullObject::Raise("Shape for reverse is null"); + } + + BRepBuilderAPI_Copy Copy(aShape_i); + if( Copy.IsDone() ) { + TopoDS_Shape tds = Copy.Shape(); + if( tds.IsNull() ) { + Standard_ConstructionError::Raise("Orientation aborted : Can not reverse the shape"); + } + + if( tds.Orientation() == TopAbs_FORWARD) + tds.Orientation(TopAbs_REVERSED) ; + else + tds.Orientation(TopAbs_FORWARD) ; + + aShape = tds; + } + } + + if (aShape.IsNull()) return 0; + + // Check shape validity + BRepCheck_Analyzer ana (aShape, false); + if (!ana.IsValid()) { + Standard_ConstructionError::Raise("Algorithm have produced an invalid shape result"); + } + + aFunction->SetValue(aShape); + + log.SetTouched(Label()); + + return 1; +} + + +//======================================================================= +//function : GEOMImpl_ShapeDriver_Type_ +//purpose : +//======================================================================= +Standard_EXPORT Handle_Standard_Type& GEOMImpl_ShapeDriver_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); + 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("GEOMImpl_ShapeDriver", + sizeof(GEOMImpl_ShapeDriver), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + +//======================================================================= +//function : DownCast +//purpose : +//======================================================================= +const Handle(GEOMImpl_ShapeDriver) Handle(GEOMImpl_ShapeDriver)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOMImpl_ShapeDriver) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_ShapeDriver))) { + _anOtherObject = Handle(GEOMImpl_ShapeDriver)((Handle(GEOMImpl_ShapeDriver)&)AnObject); + } + } + + return _anOtherObject ; +} diff --git a/src/GEOMImpl/GEOMImpl_ShapeDriver.hxx b/src/GEOMImpl/GEOMImpl_ShapeDriver.hxx new file mode 100644 index 000000000..191a176bc --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_ShapeDriver.hxx @@ -0,0 +1,139 @@ +// File : GEOMImpl_ShapeDriver.ixx +// Module : GEOMImpl + +#ifndef _GEOMImpl_ShapeDriver_HeaderFile +#define _GEOMImpl_ShapeDriver_HeaderFile + +#ifndef _TColStd_SequenceOfExtendedString_HeaderFile +#include +#endif +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_GUID_HeaderFile +#include +#endif + +#ifndef _Handle_TFunction_Driver_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TFunction_Driver); +class GEOMImpl_ShapeDriver; + +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMImpl_ShapeDriver); + +class Handle(GEOMImpl_ShapeDriver) : public Handle(TFunction_Driver) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + Handle(GEOMImpl_ShapeDriver)():Handle(TFunction_Driver)() {} + Handle(GEOMImpl_ShapeDriver)(const Handle(GEOMImpl_ShapeDriver)& aHandle) : Handle(TFunction_Driver)(aHandle) + { + } + + Handle(GEOMImpl_ShapeDriver)(const GEOMImpl_ShapeDriver* anItem) : Handle(TFunction_Driver)((TFunction_Driver *)anItem) + { + } + + Handle(GEOMImpl_ShapeDriver)& operator=(const Handle(GEOMImpl_ShapeDriver)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOMImpl_ShapeDriver)& operator=(const GEOMImpl_ShapeDriver* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOMImpl_ShapeDriver* operator->() + { + return (GEOMImpl_ShapeDriver *)ControlAccess(); + } + + GEOMImpl_ShapeDriver* operator->() const + { + return (GEOMImpl_ShapeDriver *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOMImpl_ShapeDriver)() {}; + + Standard_EXPORT static const Handle(GEOMImpl_ShapeDriver) DownCast(const Handle(Standard_Transient)& AnObject); +}; + +#ifndef _TFunction_Driver_HeaderFile +#include +#endif +#ifndef _TFunction_Logbook_HeaderFile +#include +#endif +#ifndef _Standard_CString_HeaderFile +#include +#endif + +class TColStd_SequenceOfExtendedString; + + +class GEOMImpl_ShapeDriver : public TFunction_Driver { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + // Methods PUBLIC + // +Standard_EXPORT GEOMImpl_ShapeDriver(); +Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; +Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {} +Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const { return Standard_True; } +Standard_EXPORT static const Standard_GUID& GetID(); +Standard_EXPORT ~GEOMImpl_ShapeDriver() {}; + + + // Type management + // +Standard_EXPORT friend Handle_Standard_Type& GEOMImpl_ShapeDriver_Type_(); +Standard_EXPORT const Handle(Standard_Type)& DynamicType() const { return STANDARD_TYPE(GEOMImpl_ShapeDriver) ; } +Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const { return (STANDARD_TYPE(GEOMImpl_ShapeDriver) == AType || TFunction_Driver::IsKind(AType)); } + + +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_SketcherDriver.cxx b/src/GEOMImpl/GEOMImpl_SketcherDriver.cxx new file mode 100644 index 000000000..0b79130b2 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_SketcherDriver.cxx @@ -0,0 +1,129 @@ + +using namespace std; +#include "GEOMImpl_SketcherDriver.hxx" +#include "GEOMImpl_ISketcher.hxx" +#include "GEOMImpl_Types.hxx" +#include "GEOM_Function.hxx" + +#include +#include +#include +#include + +#include + +#include + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& GEOMImpl_SketcherDriver::GetID() +{ + static Standard_GUID aSketcherDriver("FF1BBB64-5D14-4df2-980B-3A668264EA16"); + return aSketcherDriver; +} + + +//======================================================================= +//function : GEOMImpl_SketcherDriver +//purpose : +//======================================================================= +GEOMImpl_SketcherDriver::GEOMImpl_SketcherDriver() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_SketcherDriver::Execute(TFunction_Logbook& log) const +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); + + GEOMImpl_ISketcher aCI (aFunction); + //Standard_Integer aType = aFunction->GetType(); + + // retrieve the command + TCollection_AsciiString aCommand = aCI.GetCommand(); + if (aCommand.IsEmpty()) + return 0; + + TopoDS_Shape aShape; + + // create sketcher + Sketcher_Profile aProfile (aCommand.ToCString()); + + if (!aProfile.IsDone()) { + Standard_ConstructionError::Raise("Sketcher creation failed"); + } + + aShape = aProfile.GetShape(); + if (aShape.IsNull()) + return 0; + + gp_Trsf aTrans; + gp_Pnt aOrigin = gp_Pnt(aCI.GetWorkingPlane(1), aCI.GetWorkingPlane(2), aCI.GetWorkingPlane(3)); + gp_Dir aDirZ = gp_Dir(aCI.GetWorkingPlane(4), aCI.GetWorkingPlane(5), aCI.GetWorkingPlane(6)); + gp_Dir aDirX = gp_Dir(aCI.GetWorkingPlane(7), aCI.GetWorkingPlane(8), aCI.GetWorkingPlane(9)); + gp_Ax3 aWPlane = gp_Ax3(aOrigin, aDirZ, aDirX); + + aTrans.SetTransformation(aWPlane); + aTrans.Invert(); + BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False); + aShape = aTransformation.Shape(); + + if (aShape.IsNull()) + return 0; + + // set the function result + aFunction->SetValue(aShape); + + log.SetTouched(Label()); + + return 1; +} + + +//======================================================================= +//function : GEOMImpl_SketcherDriver_Type_ +//purpose : +//======================================================================= +Standard_EXPORT Handle_Standard_Type& GEOMImpl_SketcherDriver_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); + 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("GEOMImpl_SketcherDriver", + sizeof(GEOMImpl_SketcherDriver), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + +//======================================================================= +//function : DownCast +//purpose : +//======================================================================= +const Handle(GEOMImpl_SketcherDriver) Handle(GEOMImpl_SketcherDriver)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOMImpl_SketcherDriver) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_SketcherDriver))) { + _anOtherObject = Handle(GEOMImpl_SketcherDriver)((Handle(GEOMImpl_SketcherDriver)&)AnObject); + } + } + + return _anOtherObject ; +} diff --git a/src/GEOMImpl/GEOMImpl_SketcherDriver.hxx b/src/GEOMImpl/GEOMImpl_SketcherDriver.hxx new file mode 100644 index 000000000..de9cfd9e9 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_SketcherDriver.hxx @@ -0,0 +1,139 @@ +// File : GEOMImpl_SketcherDriver.ixx +// Module : GEOMImpl + +#ifndef _GEOMImpl_SketcherDriver_HeaderFile +#define _GEOMImpl_SketcherDriver_HeaderFile + +#ifndef _TColStd_SequenceOfExtendedString_HeaderFile +#include +#endif +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_GUID_HeaderFile +#include +#endif + +#ifndef _Handle_TFunction_Driver_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TFunction_Driver); +class GEOMImpl_SketcherDriver; + +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMImpl_SketcherDriver); + +class Handle(GEOMImpl_SketcherDriver) : public Handle(TFunction_Driver) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + Handle(GEOMImpl_SketcherDriver)():Handle(TFunction_Driver)() {} + Handle(GEOMImpl_SketcherDriver)(const Handle(GEOMImpl_SketcherDriver)& aHandle) : Handle(TFunction_Driver)(aHandle) + { + } + + Handle(GEOMImpl_SketcherDriver)(const GEOMImpl_SketcherDriver* anItem) : Handle(TFunction_Driver)((TFunction_Driver *)anItem) + { + } + + Handle(GEOMImpl_SketcherDriver)& operator=(const Handle(GEOMImpl_SketcherDriver)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOMImpl_SketcherDriver)& operator=(const GEOMImpl_SketcherDriver* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOMImpl_SketcherDriver* operator->() + { + return (GEOMImpl_SketcherDriver *)ControlAccess(); + } + + GEOMImpl_SketcherDriver* operator->() const + { + return (GEOMImpl_SketcherDriver *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOMImpl_SketcherDriver)() {}; + + Standard_EXPORT static const Handle(GEOMImpl_SketcherDriver) DownCast(const Handle(Standard_Transient)& AnObject); +}; + +#ifndef _TFunction_Driver_HeaderFile +#include +#endif +#ifndef _TFunction_Logbook_HeaderFile +#include +#endif +#ifndef _Standard_CString_HeaderFile +#include +#endif + +class TColStd_SequenceOfExtendedString; + + +class GEOMImpl_SketcherDriver : public TFunction_Driver { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + // Methods PUBLIC + // +Standard_EXPORT GEOMImpl_SketcherDriver(); +Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; +Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {} +Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const { return Standard_True; } +Standard_EXPORT static const Standard_GUID& GetID(); +Standard_EXPORT ~GEOMImpl_SketcherDriver() {}; + + + // Type management + // +Standard_EXPORT friend Handle_Standard_Type& GEOMImpl_SketcherDriver_Type_(); +Standard_EXPORT const Handle(Standard_Type)& DynamicType() const { return STANDARD_TYPE(GEOMImpl_SketcherDriver) ; } +Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const { return (STANDARD_TYPE(GEOMImpl_SketcherDriver) == AType || TFunction_Driver::IsKind(AType)); } + + +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_SphereDriver.cxx b/src/GEOMImpl/GEOMImpl_SphereDriver.cxx new file mode 100644 index 000000000..af97bbc45 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_SphereDriver.cxx @@ -0,0 +1,113 @@ + +using namespace std; +#include "GEOMImpl_SphereDriver.hxx" +#include "GEOMImpl_ISphere.hxx" +#include "GEOMImpl_Types.hxx" +#include "GEOM_Function.hxx" + +#include +#include +#include +#include +#include +#include +#include + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& GEOMImpl_SphereDriver::GetID() +{ + static Standard_GUID aSphereDriver("FF1BBB16-5D14-4df2-980B-3A668264EA16"); + return aSphereDriver; +} + + +//======================================================================= +//function : GEOMImpl_SphereDriver +//purpose : +//======================================================================= +GEOMImpl_SphereDriver::GEOMImpl_SphereDriver() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_SphereDriver::Execute(TFunction_Logbook& log) const +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); + + GEOMImpl_ISphere aCI (aFunction); + Standard_Integer aType = aFunction->GetType(); + + TopoDS_Shape aShape; + + if (aType == SPHERE_R) { + aShape = BRepPrimAPI_MakeSphere(aCI.GetR()).Shape(); + } + else if (aType == SPHERE_PNT_R) { + Handle(GEOM_Function) aRefPoint = aCI.GetPoint(); + TopoDS_Shape aShapePnt = aRefPoint->GetValue(); + if (aShapePnt.ShapeType() == TopAbs_VERTEX) { + gp_Pnt aP = BRep_Tool::Pnt(TopoDS::Vertex(aShapePnt)); + aShape = BRepPrimAPI_MakeSphere(aP, aCI.GetR()).Shape(); + } + } + else { + } + + if (aShape.IsNull()) return 0; + + aFunction->SetValue(aShape); + + log.SetTouched(Label()); + + return 1; +} + + +//======================================================================= +//function : GEOMImpl_SphereDriver_Type_ +//purpose : +//======================================================================= +Standard_EXPORT Handle_Standard_Type& GEOMImpl_SphereDriver_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); + 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("GEOMImpl_SphereDriver", + sizeof(GEOMImpl_SphereDriver), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + +//======================================================================= +//function : DownCast +//purpose : +//======================================================================= +const Handle(GEOMImpl_SphereDriver) Handle(GEOMImpl_SphereDriver)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOMImpl_SphereDriver) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_SphereDriver))) { + _anOtherObject = Handle(GEOMImpl_SphereDriver)((Handle(GEOMImpl_SphereDriver)&)AnObject); + } + } + + return _anOtherObject ; +} diff --git a/src/GEOMImpl/GEOMImpl_SphereDriver.hxx b/src/GEOMImpl/GEOMImpl_SphereDriver.hxx new file mode 100644 index 000000000..ea5a4b09a --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_SphereDriver.hxx @@ -0,0 +1,139 @@ +// File : GEOMImpl_SphereDriver.ixx +// Module : GEOMImpl + +#ifndef _GEOMImpl_SphereDriver_HeaderFile +#define _GEOMImpl_SphereDriver_HeaderFile + +#ifndef _TColStd_SequenceOfExtendedString_HeaderFile +#include +#endif +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_GUID_HeaderFile +#include +#endif + +#ifndef _Handle_TFunction_Driver_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TFunction_Driver); +class GEOMImpl_SphereDriver; + +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMImpl_SphereDriver); + +class Handle(GEOMImpl_SphereDriver) : public Handle(TFunction_Driver) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + Handle(GEOMImpl_SphereDriver)():Handle(TFunction_Driver)() {} + Handle(GEOMImpl_SphereDriver)(const Handle(GEOMImpl_SphereDriver)& aHandle) : Handle(TFunction_Driver)(aHandle) + { + } + + Handle(GEOMImpl_SphereDriver)(const GEOMImpl_SphereDriver* anItem) : Handle(TFunction_Driver)((TFunction_Driver *)anItem) + { + } + + Handle(GEOMImpl_SphereDriver)& operator=(const Handle(GEOMImpl_SphereDriver)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOMImpl_SphereDriver)& operator=(const GEOMImpl_SphereDriver* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOMImpl_SphereDriver* operator->() + { + return (GEOMImpl_SphereDriver *)ControlAccess(); + } + + GEOMImpl_SphereDriver* operator->() const + { + return (GEOMImpl_SphereDriver *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOMImpl_SphereDriver)() {}; + + Standard_EXPORT static const Handle(GEOMImpl_SphereDriver) DownCast(const Handle(Standard_Transient)& AnObject); +}; + +#ifndef _TFunction_Driver_HeaderFile +#include +#endif +#ifndef _TFunction_Logbook_HeaderFile +#include +#endif +#ifndef _Standard_CString_HeaderFile +#include +#endif + +class TColStd_SequenceOfExtendedString; + + +class GEOMImpl_SphereDriver : public TFunction_Driver { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + // Methods PUBLIC + // +Standard_EXPORT GEOMImpl_SphereDriver(); +Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; +Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {} +Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const { return Standard_True; } +Standard_EXPORT static const Standard_GUID& GetID(); +Standard_EXPORT ~GEOMImpl_SphereDriver() {}; + + + // Type management + // +Standard_EXPORT friend Handle_Standard_Type& GEOMImpl_SphereDriver_Type_(); +Standard_EXPORT const Handle(Standard_Type)& DynamicType() const { return STANDARD_TYPE(GEOMImpl_SphereDriver) ; } +Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const { return (STANDARD_TYPE(GEOMImpl_SphereDriver) == AType || TFunction_Driver::IsKind(AType)); } + + +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_SplineDriver.cxx b/src/GEOMImpl/GEOMImpl_SplineDriver.cxx new file mode 100644 index 000000000..f63021373 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_SplineDriver.cxx @@ -0,0 +1,156 @@ + +using namespace std; +#include "GEOMImpl_SplineDriver.hxx" +#include "GEOMImpl_ISpline.hxx" +#include "GEOMImpl_Types.hxx" +#include "GEOM_Function.hxx" + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +//#include +#include + +#include +#include +#include +#include +#include +#include + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& GEOMImpl_SplineDriver::GetID() +{ + static Standard_GUID aSplineDriver("FF1BBB33-5D14-4df2-980B-3A668264EA16"); + return aSplineDriver; +} + + +//======================================================================= +//function : GEOMImpl_SplineDriver +//purpose : +//======================================================================= +GEOMImpl_SplineDriver::GEOMImpl_SplineDriver() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_SplineDriver::Execute(TFunction_Logbook& log) const +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); + + GEOMImpl_ISpline aCI (aFunction); + Standard_Integer aType = aFunction->GetType(); + + TopoDS_Shape aShape; + + if (aType == SPLINE_BEZIER || aType == SPLINE_INTERPOLATION) { + int ind, aLen = aCI.GetLength(); + if (aLen < 2) return 0; + Standard_Boolean isSeveral = Standard_False; + gp_Pnt aPrevP; + TColgp_Array1OfPnt CurvePoints (1, aLen); + for (ind = 1; ind <= aLen; ind++) { + Handle(GEOM_Function) aRefPoint = aCI.GetPoint(ind); + TopoDS_Shape aShapePnt = aRefPoint->GetValue(); + if (aShapePnt.ShapeType() == TopAbs_VERTEX) { + gp_Pnt aP = BRep_Tool::Pnt(TopoDS::Vertex(aShapePnt)); + if (!isSeveral && ind > 1) { + if (aP.Distance(aPrevP) > Precision::Confusion()) { + isSeveral = Standard_True; + } + } + CurvePoints.SetValue(ind, aP); + aPrevP = aP; + } + } + if (aType == SPLINE_BEZIER) { + if (!isSeveral) { + Standard_ConstructionError::Raise("Points for Bezier Curve are too close"); + } + Handle(Geom_BezierCurve) GBC = new Geom_BezierCurve(CurvePoints); + aShape = BRepBuilderAPI_MakeEdge(GBC).Edge(); + } else { +// GeomAPI_PointsToBSpline GBC (CurvePoints); +// aShape = BRepBuilderAPI_MakeEdge(GBC).Edge(); + Handle(TColgp_HArray1OfPnt) aHCurvePoints = new TColgp_HArray1OfPnt(1, aLen); + for (ind = 1; ind <= aLen; ind++) { + aHCurvePoints->SetValue(ind, CurvePoints.Value(ind)); + } + GeomAPI_Interpolate GBC (aHCurvePoints, Standard_False, gp::Resolution()); + GBC.Perform(); + if (GBC.IsDone()) + aShape = BRepBuilderAPI_MakeEdge(GBC).Edge(); + else + return 0; + } + } + else { + } + + if (aShape.IsNull()) return 0; + + aFunction->SetValue(aShape); + + log.SetTouched(Label()); + + return 1; +} + + +//======================================================================= +//function : GEOMImpl_SplineDriver_Type_ +//purpose : +//======================================================================= +Standard_EXPORT Handle_Standard_Type& GEOMImpl_SplineDriver_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); + 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("GEOMImpl_SplineDriver", + sizeof(GEOMImpl_SplineDriver), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + +//======================================================================= +//function : DownCast +//purpose : +//======================================================================= +const Handle(GEOMImpl_SplineDriver) Handle(GEOMImpl_SplineDriver)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOMImpl_SplineDriver) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_SplineDriver))) { + _anOtherObject = Handle(GEOMImpl_SplineDriver)((Handle(GEOMImpl_SplineDriver)&)AnObject); + } + } + + return _anOtherObject ; +} diff --git a/src/GEOMImpl/GEOMImpl_SplineDriver.hxx b/src/GEOMImpl/GEOMImpl_SplineDriver.hxx new file mode 100644 index 000000000..c3c7d2db6 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_SplineDriver.hxx @@ -0,0 +1,139 @@ +// File : GEOMImpl_SplineDriver.ixx +// Module : GEOMImpl + +#ifndef _GEOMImpl_SplineDriver_HeaderFile +#define _GEOMImpl_SplineDriver_HeaderFile + +#ifndef _TColStd_SequenceOfExtendedString_HeaderFile +#include +#endif +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_GUID_HeaderFile +#include +#endif + +#ifndef _Handle_TFunction_Driver_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TFunction_Driver); +class GEOMImpl_SplineDriver; + +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMImpl_SplineDriver); + +class Handle(GEOMImpl_SplineDriver) : public Handle(TFunction_Driver) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + Handle(GEOMImpl_SplineDriver)():Handle(TFunction_Driver)() {} + Handle(GEOMImpl_SplineDriver)(const Handle(GEOMImpl_SplineDriver)& aHandle) : Handle(TFunction_Driver)(aHandle) + { + } + + Handle(GEOMImpl_SplineDriver)(const GEOMImpl_SplineDriver* anItem) : Handle(TFunction_Driver)((TFunction_Driver *)anItem) + { + } + + Handle(GEOMImpl_SplineDriver)& operator=(const Handle(GEOMImpl_SplineDriver)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOMImpl_SplineDriver)& operator=(const GEOMImpl_SplineDriver* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOMImpl_SplineDriver* operator->() + { + return (GEOMImpl_SplineDriver *)ControlAccess(); + } + + GEOMImpl_SplineDriver* operator->() const + { + return (GEOMImpl_SplineDriver *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOMImpl_SplineDriver)() {}; + + Standard_EXPORT static const Handle(GEOMImpl_SplineDriver) DownCast(const Handle(Standard_Transient)& AnObject); +}; + +#ifndef _TFunction_Driver_HeaderFile +#include +#endif +#ifndef _TFunction_Logbook_HeaderFile +#include +#endif +#ifndef _Standard_CString_HeaderFile +#include +#endif + +class TColStd_SequenceOfExtendedString; + + +class GEOMImpl_SplineDriver : public TFunction_Driver { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + // Methods PUBLIC + // +Standard_EXPORT GEOMImpl_SplineDriver(); +Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; +Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {} +Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const { return Standard_True; } +Standard_EXPORT static const Standard_GUID& GetID(); +Standard_EXPORT ~GEOMImpl_SplineDriver() {}; + + + // Type management + // +Standard_EXPORT friend Handle_Standard_Type& GEOMImpl_SplineDriver_Type_(); +Standard_EXPORT const Handle(Standard_Type)& DynamicType() const { return STANDARD_TYPE(GEOMImpl_SplineDriver) ; } +Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const { return (STANDARD_TYPE(GEOMImpl_SplineDriver) == AType || TFunction_Driver::IsKind(AType)); } + + +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_Template.cxx b/src/GEOMImpl/GEOMImpl_Template.cxx new file mode 100644 index 000000000..1db7d00d3 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_Template.cxx @@ -0,0 +1,87 @@ + +using namespace std; +#include "GEOMImpl_Template.hxx" +#include "GEOM_Function.hxx" +#include + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& GEOMImpl_Template::GetID() +{ + static Standard_GUID aTemplate("Insert the correct GUID here"); + return aTemplate; +} + + +//======================================================================= +//function : GEOMImpl_Template +//purpose : +//======================================================================= + +GEOMImpl_Template::GEOMImpl_Template() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_Template::Execute(TFunction_Logbook& log) const +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); + if(aFunction.IsNull()) return 0; + + //Add implemetation here + + log.SetTouched(Label()); + return 1; +} + + +//======================================================================= +//function : GEOMImpl_Template_Type_ +//purpose : +//======================================================================= +Standard_EXPORT Handle_Standard_Type& GEOMImpl_Template_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); + 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("GEOMImpl_Template", + sizeof(GEOMImpl_Template), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + +//======================================================================= +//function : DownCast +//purpose : +//======================================================================= + +const Handle(GEOMImpl_Template) Handle(GEOMImpl_Template)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOMImpl_Template) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_Template))) { + _anOtherObject = Handle(GEOMImpl_Template)((Handle(GEOMImpl_Template)&)AnObject); + } + } + + return _anOtherObject ; +} + + diff --git a/src/GEOMImpl/GEOMImpl_Template.hxx b/src/GEOMImpl/GEOMImpl_Template.hxx new file mode 100644 index 000000000..d44f28c24 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_Template.hxx @@ -0,0 +1,139 @@ +// File : GEOMImpl_Template.hxx +// Module : GEOMImpl + +#ifndef _GEOMImpl_Template_HeaderFile +#define _GEOMImpl_Template_HeaderFile + +#ifndef _TColStd_SequenceOfExtendedString_HeaderFile +#include +#endif +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_GUID_HeaderFile +#include +#endif + +#ifndef _Handle_TFunction_Driver_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TFunction_Driver); +class GEOMImpl_Template; + +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMImpl_Template); + +class Handle(GEOMImpl_Template) : public Handle(TFunction_Driver) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + Handle(GEOMImpl_Template)():Handle(TFunction_Driver)() {} + Handle(GEOMImpl_Template)(const Handle(GEOMImpl_Template)& aHandle) : Handle(TFunction_Driver)(aHandle) + { + } + + Handle(GEOMImpl_Template)(const GEOMImpl_Template* anItem) : Handle(TFunction_Driver)((TFunction_Driver *)anItem) + { + } + + Handle(GEOMImpl_Template)& operator=(const Handle(GEOMImpl_Template)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOMImpl_Template)& operator=(const GEOMImpl_Template* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOMImpl_Template* operator->() + { + return (GEOMImpl_Template *)ControlAccess(); + } + + GEOMImpl_Template* operator->() const + { + return (GEOMImpl_Template *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOMImpl_Template)() {}; + + Standard_EXPORT static const Handle(GEOMImpl_Template) DownCast(const Handle(Standard_Transient)& AnObject); +}; + +#ifndef _TFunction_Driver_HeaderFile +#include +#endif +#ifndef _TFunction_Logbook_HeaderFile +#include +#endif +#ifndef _Standard_CString_HeaderFile +#include +#endif + +class TColStd_SequenceOfExtendedString; + + +class GEOMImpl_Template : public TFunction_Driver { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + // Methods PUBLIC + // +Standard_EXPORT GEOMImpl_Template(); +Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; +Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {} +Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const { return Standard_True; } +Standard_EXPORT static const Standard_GUID& GetID(); +Standard_EXPORT ~GEOMImpl_Template() {}; + + + // Type management + // +Standard_EXPORT friend Handle_Standard_Type& GEOMImpl_Template_Type_(); +Standard_EXPORT const Handle(Standard_Type)& DynamicType() const { return STANDARD_TYPE(GEOMImpl_Template) ; } +Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const { return (STANDARD_TYPE(GEOMImpl_Template) == AType || TFunction_Driver::IsKind(AType)); } + + +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_TorusDriver.cxx b/src/GEOMImpl/GEOMImpl_TorusDriver.cxx new file mode 100644 index 000000000..17b93936c --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_TorusDriver.cxx @@ -0,0 +1,142 @@ + +using namespace std; +#include "GEOMImpl_TorusDriver.hxx" +#include "GEOMImpl_ITorus.hxx" +#include "GEOMImpl_Types.hxx" +#include "GEOM_Function.hxx" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& GEOMImpl_TorusDriver::GetID() +{ + static Standard_GUID aTorusDriver("FF1BBB12-5D14-4df2-980B-3A668264EA16"); + return aTorusDriver; +} + + +//======================================================================= +//function : GEOMImpl_TorusDriver +//purpose : +//======================================================================= +GEOMImpl_TorusDriver::GEOMImpl_TorusDriver() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_TorusDriver::Execute(TFunction_Logbook& log) const +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); + + GEOMImpl_ITorus aCI (aFunction); + Standard_Integer aType = aFunction->GetType(); + + TopoDS_Shape aShape; + + if (aType == TORUS_RR) { + aShape = BRepPrimAPI_MakeTorus(aCI.GetRMajor(), aCI.GetRMinor()).Shape(); + + } else if (aType == TORUS_PNT_VEC_RR) { + Handle(GEOM_Function) aRefPoint = aCI.GetCenter(); + Handle(GEOM_Function) aRefVector = aCI.GetVector(); + TopoDS_Shape aShapePnt = aRefPoint->GetValue(); + TopoDS_Shape aShapeVec = aRefVector->GetValue(); + if (aShapePnt.ShapeType() != TopAbs_VERTEX) { + Standard_TypeMismatch::Raise("Torus Center must be a vertex"); + } + if (aShapeVec.ShapeType() != TopAbs_EDGE) { + Standard_TypeMismatch::Raise("Torus Axis must be an edge"); + } + + gp_Pnt aP = BRep_Tool::Pnt(TopoDS::Vertex(aShapePnt)); + TopoDS_Edge anE = TopoDS::Edge(aShapeVec); + TopoDS_Vertex V1, V2; + TopExp::Vertices(anE, V1, V2, Standard_True); + if (V1.IsNull() || V2.IsNull()) { + Standard_ConstructionError::Raise("Bad edge for the Torus Axis given"); + } + + gp_Vec aV (BRep_Tool::Pnt(V1), BRep_Tool::Pnt(V2)); + if (aV.Magnitude() < Precision::Confusion()) { + Standard_ConstructionError::Raise + ("End vertices of edge, defining the Torus Axis, are too close"); + } + + gp_Ax2 anAxes (aP, aV); + BRepPrimAPI_MakeTorus MT (anAxes, aCI.GetRMajor(), aCI.GetRMinor()); + if (!MT.IsDone()) MT.Build(); + if (!MT.IsDone()) StdFail_NotDone::Raise("Torus construction algorithm has failed"); + aShape = MT.Shape(); + } else { + } + + if (aShape.IsNull()) return 0; + aFunction->SetValue(aShape); + + log.SetTouched(Label()); + + return 1; +} + + +//======================================================================= +//function : GEOMImpl_TorusDriver_Type_ +//purpose : +//======================================================================= +Standard_EXPORT Handle_Standard_Type& GEOMImpl_TorusDriver_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); + 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("GEOMImpl_TorusDriver", + sizeof(GEOMImpl_TorusDriver), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + +//======================================================================= +//function : DownCast +//purpose : +//======================================================================= +const Handle(GEOMImpl_TorusDriver) Handle(GEOMImpl_TorusDriver)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOMImpl_TorusDriver) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_TorusDriver))) { + _anOtherObject = Handle(GEOMImpl_TorusDriver)((Handle(GEOMImpl_TorusDriver)&)AnObject); + } + } + + return _anOtherObject ; +} diff --git a/src/GEOMImpl/GEOMImpl_TorusDriver.hxx b/src/GEOMImpl/GEOMImpl_TorusDriver.hxx new file mode 100644 index 000000000..d31eadb40 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_TorusDriver.hxx @@ -0,0 +1,139 @@ +// File : GEOMImpl_TorusDriver.ixx +// Module : GEOMImpl + +#ifndef _GEOMImpl_TorusDriver_HeaderFile +#define _GEOMImpl_TorusDriver_HeaderFile + +#ifndef _TColStd_SequenceOfExtendedString_HeaderFile +#include +#endif +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_GUID_HeaderFile +#include +#endif + +#ifndef _Handle_TFunction_Driver_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TFunction_Driver); +class GEOMImpl_TorusDriver; + +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMImpl_TorusDriver); + +class Handle(GEOMImpl_TorusDriver) : public Handle(TFunction_Driver) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + Handle(GEOMImpl_TorusDriver)():Handle(TFunction_Driver)() {} + Handle(GEOMImpl_TorusDriver)(const Handle(GEOMImpl_TorusDriver)& aHandle) : Handle(TFunction_Driver)(aHandle) + { + } + + Handle(GEOMImpl_TorusDriver)(const GEOMImpl_TorusDriver* anItem) : Handle(TFunction_Driver)((TFunction_Driver *)anItem) + { + } + + Handle(GEOMImpl_TorusDriver)& operator=(const Handle(GEOMImpl_TorusDriver)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOMImpl_TorusDriver)& operator=(const GEOMImpl_TorusDriver* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOMImpl_TorusDriver* operator->() + { + return (GEOMImpl_TorusDriver *)ControlAccess(); + } + + GEOMImpl_TorusDriver* operator->() const + { + return (GEOMImpl_TorusDriver *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOMImpl_TorusDriver)() {}; + + Standard_EXPORT static const Handle(GEOMImpl_TorusDriver) DownCast(const Handle(Standard_Transient)& AnObject); +}; + +#ifndef _TFunction_Driver_HeaderFile +#include +#endif +#ifndef _TFunction_Logbook_HeaderFile +#include +#endif +#ifndef _Standard_CString_HeaderFile +#include +#endif + +class TColStd_SequenceOfExtendedString; + + +class GEOMImpl_TorusDriver : public TFunction_Driver { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + // Methods PUBLIC + // +Standard_EXPORT GEOMImpl_TorusDriver(); +Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; +Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {} +Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const { return Standard_True; } +Standard_EXPORT static const Standard_GUID& GetID(); +Standard_EXPORT ~GEOMImpl_TorusDriver() {}; + + + // Type management + // +Standard_EXPORT friend Handle_Standard_Type& GEOMImpl_TorusDriver_Type_(); +Standard_EXPORT const Handle(Standard_Type)& DynamicType() const { return STANDARD_TYPE(GEOMImpl_TorusDriver) ; } +Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const { return (STANDARD_TYPE(GEOMImpl_TorusDriver) == AType || TFunction_Driver::IsKind(AType)); } + + +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_TranslateDriver.cxx b/src/GEOMImpl/GEOMImpl_TranslateDriver.cxx new file mode 100644 index 000000000..699209886 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_TranslateDriver.cxx @@ -0,0 +1,223 @@ + +using namespace std; +#include "GEOMImpl_TranslateDriver.hxx" +#include +#include +#include "GEOM_Function.hxx" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& GEOMImpl_TranslateDriver::GetID() +{ + static Standard_GUID aTranslateDriver("FF1BBB03-5D14-4df2-980B-3A668264EA16"); + return aTranslateDriver; +} + + +//======================================================================= +//function : GEOMImpl_TranslateDriver +//purpose : +//======================================================================= + +GEOMImpl_TranslateDriver::GEOMImpl_TranslateDriver() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_TranslateDriver::Execute(TFunction_Logbook& log) const +{ + if(Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); + + if(aFunction.IsNull()) return 0; + + GEOMImpl_ITranslate TI(aFunction); + gp_Trsf aTrsf; + gp_Pnt aP1, aP2; + Standard_Integer aType = aFunction->GetType(); + + Handle(GEOM_Function) anOriginalFunction = TI.GetOriginal(); + if(anOriginalFunction.IsNull()) return 0; + TopoDS_Shape aShape, anOriginal = anOriginalFunction->GetValue(); + if(anOriginal.IsNull()) return 0; + + if(aType == TRANSLATE_TWO_POINTS || aType == TRANSLATE_TWO_POINTS_COPY) { + Handle(GEOM_Function) aPoint1 = TI.GetPoint1(); + Handle(GEOM_Function) aPoint2 = TI.GetPoint2(); + if(aPoint1.IsNull() || aPoint2.IsNull()) return 0; + TopoDS_Shape aV1 = aPoint1->GetValue(); + TopoDS_Shape aV2 = aPoint2->GetValue(); + if(aV1.IsNull() || aV1.ShapeType() != TopAbs_VERTEX) return 0; + if(aV2.IsNull() || aV2.ShapeType() != TopAbs_VERTEX) return 0; + + aP1 = BRep_Tool::Pnt(TopoDS::Vertex(aV1)); + aP2 = BRep_Tool::Pnt(TopoDS::Vertex(aV2)); + + aTrsf.SetTranslation(aP1, aP2); + BRepBuilderAPI_Transform aTransformation(anOriginal, aTrsf, Standard_False); + aShape = aTransformation.Shape(); + + } else if(aType == TRANSLATE_VECTOR || aType == TRANSLATE_VECTOR_COPY) { + Handle(GEOM_Function) aVector = TI.GetVector(); + if(aVector.IsNull()) return 0; + TopoDS_Shape aV = aVector->GetValue(); + if(aV.IsNull() || aV.ShapeType() != TopAbs_EDGE) return 0; + TopoDS_Edge anEdge = TopoDS::Edge(aV); + + aP1 = BRep_Tool::Pnt(TopExp::FirstVertex(anEdge)); + aP2 = BRep_Tool::Pnt(TopExp::LastVertex(anEdge)); + + aTrsf.SetTranslation(aP1, aP2); + BRepBuilderAPI_Transform aTransformation(anOriginal, aTrsf, Standard_False); + aShape = aTransformation.Shape(); + } + else if(aType == TRANSLATE_XYZ || aType == TRANSLATE_XYZ_COPY) { + gp_Vec aVec(TI.GetDX(), TI.GetDY(), TI.GetDZ()); + aTrsf.SetTranslation(aVec); + BRepBuilderAPI_Transform aTransformation(anOriginal, aTrsf, Standard_False); + aShape = aTransformation.Shape(); + } + else if(aType == TRANSLATE_1D) { + Standard_Real DX, DY, DZ, step = TI.GetStep1(); + Standard_Integer nbtimes = TI.GetNbIter1(); + gp_Vec myVec ; + TopoDS_Compound aCompound; + BRep_Builder B; + B.MakeCompound( aCompound ); + + Handle(GEOM_Function) aVector = TI.GetVector(); + if(aVector.IsNull()) return 0; + TopoDS_Shape aV = aVector->GetValue(); + if(aV.IsNull() || aV.ShapeType() != TopAbs_EDGE) return 0; + TopoDS_Edge anEdge = TopoDS::Edge(aV); + + gp_Vec Vec(BRep_Tool::Pnt(TopExp::FirstVertex(anEdge)), BRep_Tool::Pnt(TopExp::LastVertex(anEdge))); + Vec.Normalize(); + + for (int i = 0; i < nbtimes; i++ ) { + DX = i * step * Vec.X() ; + DY = i * step * Vec.Y() ; + DZ = i * step * Vec.Z() ; + myVec.SetCoord( DX, DY, DZ ) ; + aTrsf.SetTranslation(myVec) ; + BRepBuilderAPI_Transform aTransformation(anOriginal, aTrsf, Standard_False) ; + B.Add(aCompound , aTransformation.Shape() ); + } + aShape = aCompound; + } + else if(aType == TRANSLATE_2D) { + Standard_Integer nbtimes1 = TI.GetNbIter1(), nbtimes2 = TI.GetNbIter2(); + Standard_Real DX, DY, DZ, step1 = TI.GetStep1(), step2 = TI.GetStep2(); + gp_Vec myVec ; + Handle(GEOM_Function) aVector = TI.GetVector(); + if(aVector.IsNull()) return 0; + TopoDS_Shape aV = aVector->GetValue(); + if(aV.IsNull() || aV.ShapeType() != TopAbs_EDGE) return 0; + TopoDS_Edge anEdge = TopoDS::Edge(aV); + + gp_Vec Vec1(BRep_Tool::Pnt(TopExp::FirstVertex(anEdge)), BRep_Tool::Pnt(TopExp::LastVertex(anEdge))); + Vec1.Normalize(); + + Handle(GEOM_Function) aVector2 = TI.GetVector2(); + if(aVector2.IsNull()) return 0; + aV = aVector2->GetValue(); + if(aV.IsNull() || aV.ShapeType() != TopAbs_EDGE) return 0; + anEdge = TopoDS::Edge(aV); + + gp_Vec Vec2(BRep_Tool::Pnt(TopExp::FirstVertex(anEdge)), BRep_Tool::Pnt(TopExp::LastVertex(anEdge))); + Vec2.Normalize(); + + TopoDS_Compound aCompound; + BRep_Builder B; + B.MakeCompound( aCompound ); + + for (int i = 0; i < nbtimes1; i++ ) { + for (int j = 0; j < nbtimes2; j++ ) { + DX = i * step1 * Vec1.X() + j * step2 * Vec2.X() ; + DY = i * step1 * Vec1.Y() + j * step2 * Vec2.Y() ; + DZ = i * step1 * Vec1.Z() + j * step2 * Vec2.Z() ; + myVec.SetCoord( DX, DY, DZ ) ; + aTrsf.SetTranslation(myVec) ; + BRepBuilderAPI_Transform myBRepTransformation(anOriginal, aTrsf, Standard_False) ; + B.Add(aCompound , myBRepTransformation.Shape() ); + } + } + aShape = aCompound; + } + else return 0; + + + + if (aShape.IsNull()) return 0; + + aFunction->SetValue(aShape); + + log.SetTouched(Label()); + + return 1; +} + + +//======================================================================= +//function : GEOMImpl_TranslateDriver_Type_ +//purpose : +//======================================================================= +Standard_EXPORT Handle_Standard_Type& GEOMImpl_TranslateDriver_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); + 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("GEOMImpl_TranslateDriver", + sizeof(GEOMImpl_TranslateDriver), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + +//======================================================================= +//function : DownCast +//purpose : +//======================================================================= + +const Handle(GEOMImpl_TranslateDriver) Handle(GEOMImpl_TranslateDriver)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOMImpl_TranslateDriver) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_TranslateDriver))) { + _anOtherObject = Handle(GEOMImpl_TranslateDriver)((Handle(GEOMImpl_TranslateDriver)&)AnObject); + } + } + + return _anOtherObject ; +} + + diff --git a/src/GEOMImpl/GEOMImpl_TranslateDriver.hxx b/src/GEOMImpl/GEOMImpl_TranslateDriver.hxx new file mode 100644 index 000000000..baceff741 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_TranslateDriver.hxx @@ -0,0 +1,139 @@ +// File : GEOMImpl_TranslateDriver.hxx +// Module : GEOMImpl + +#ifndef _GEOMImpl_TranslateDriver_HeaderFile +#define _GEOMImpl_TranslateDriver_HeaderFile + +#ifndef _TColStd_SequenceOfExtendedString_HeaderFile +#include +#endif +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_GUID_HeaderFile +#include +#endif + +#ifndef _Handle_TFunction_Driver_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TFunction_Driver); +class GEOMImpl_TranslateDriver; + +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMImpl_TranslateDriver); + +class Handle(GEOMImpl_TranslateDriver) : public Handle(TFunction_Driver) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + Handle(GEOMImpl_TranslateDriver)():Handle(TFunction_Driver)() {} + Handle(GEOMImpl_TranslateDriver)(const Handle(GEOMImpl_TranslateDriver)& aHandle) : Handle(TFunction_Driver)(aHandle) + { + } + + Handle(GEOMImpl_TranslateDriver)(const GEOMImpl_TranslateDriver* anItem) : Handle(TFunction_Driver)((TFunction_Driver *)anItem) + { + } + + Handle(GEOMImpl_TranslateDriver)& operator=(const Handle(GEOMImpl_TranslateDriver)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOMImpl_TranslateDriver)& operator=(const GEOMImpl_TranslateDriver* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOMImpl_TranslateDriver* operator->() + { + return (GEOMImpl_TranslateDriver *)ControlAccess(); + } + + GEOMImpl_TranslateDriver* operator->() const + { + return (GEOMImpl_TranslateDriver *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOMImpl_TranslateDriver)() {}; + + Standard_EXPORT static const Handle(GEOMImpl_TranslateDriver) DownCast(const Handle(Standard_Transient)& AnObject); +}; + +#ifndef _TFunction_Driver_HeaderFile +#include +#endif +#ifndef _TFunction_Logbook_HeaderFile +#include +#endif +#ifndef _Standard_CString_HeaderFile +#include +#endif + +class TColStd_SequenceOfExtendedString; + + +class GEOMImpl_TranslateDriver : public TFunction_Driver { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + // Methods PUBLIC + // +Standard_EXPORT GEOMImpl_TranslateDriver(); +Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; +Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {} +Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const { return Standard_True; } +Standard_EXPORT static const Standard_GUID& GetID(); +Standard_EXPORT ~GEOMImpl_TranslateDriver() {}; + + + // Type management + // +Standard_EXPORT friend Handle_Standard_Type& GEOMImpl_TranslateDriver_Type_(); +Standard_EXPORT const Handle(Standard_Type)& DynamicType() const { return STANDARD_TYPE(GEOMImpl_TranslateDriver) ; } +Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const { return (STANDARD_TYPE(GEOMImpl_TranslateDriver) == AType || TFunction_Driver::IsKind(AType)); } + + +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_Types.hxx b/src/GEOMImpl/GEOMImpl_Types.hxx new file mode 100755 index 000000000..fa8aed6dc --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_Types.hxx @@ -0,0 +1,208 @@ +//GEOM_Object types + +#define GEOM_COPY 0 +#define GEOM_IMPORT 1 + +#define GEOM_POINT 2 +#define GEOM_VECTOR 3 +#define GEOM_PLANE 4 +#define GEOM_LINE 5 + +#define GEOM_TORUS 6 +#define GEOM_BOX 7 +#define GEOM_CYLINDER 8 +#define GEOM_CONE 9 +#define GEOM_SPHERE 10 + +#define GEOM_PRISM 11 +#define GEOM_REVOLUTION 12 + +#define GEOM_BOOLEAN 13 +#define GEOM_PARTITION 14 + +#define GEOM_POLYLINE 15 +#define GEOM_CIRCLE 16 +#define GEOM_SPLINE 17 +#define GEOM_ELLIPSE 18 +#define GEOM_CIRC_ARC 19 + +#define GEOM_FILLET 20 +#define GEOM_CHAMFER 21 + +#define GEOM_EDGE 22 +#define GEOM_WIRE 23 +#define GEOM_FACE 24 +#define GEOM_SHELL 25 +#define GEOM_SOLID 26 +#define GEOM_COMPOUND 27 + +#define GEOM_SUBSHAPE 28 + +#define GEOM_PIPE 29 + +#define GEOM_ARCHIMEDE 30 + +#define GEOM_FILLING 31 + +#define GEOM_EXPLODE 32 + +#define GEOM_GLUED 33 + +#define GEOM_SKETCHER 34 + +#define GEOM_CDG 35 + +#define GEOM_FREE_BOUNDS 36 + +#define GEOM_GROUP 37 + +#define GEOM_BLOCK 38 + +#define GEOM_MARKER 39 + +//GEOM_Function types + +#define COPY_WITH_REF 1 +#define COPY_WITHOUT_REF 2 + +#define EXPORT_SHAPE 1 +#define IMPORT_SHAPE 1 + +#define POINT_XYZ 1 +#define POINT_XYZ_REF 2 +#define POINT_CURVE_PAR 3 + +#define VECTOR_TWO_PNT 1 +#define VECTOR_DX_DY_DZ 2 + +#define PLANE_PNT_VEC 1 +#define PLANE_FACE 2 +#define PLANE_THREE_PNT 3 + +#define LINE_TWO_PNT 1 +#define LINE_PNT_DIR 2 + +#define TRANSLATE_TWO_POINTS 1 +#define TRANSLATE_VECTOR 2 +#define TRANSLATE_TWO_POINTS_COPY 3 +#define TRANSLATE_VECTOR_COPY 4 +#define TRANSLATE_1D 5 +#define TRANSLATE_2D 6 +#define TRANSLATE_XYZ 7 +#define TRANSLATE_XYZ_COPY 8 + +#define ROTATE 1 +#define ROTATE_COPY 2 +#define ROTATE_1D 3 +#define ROTATE_2D 4 + +#define MIRROR_PLANE 1 +#define MIRROR_PLANE_COPY 2 +#define MIRROR_AXIS 3 +#define MIRROR_AXIS_COPY 4 +#define MIRROR_POINT 5 +#define MIRROR_POINT_COPY 6 + +#define OFFSET_SHAPE 1 +#define OFFSET_SHAPE_COPY 2 + +#define SCALE_SHAPE 1 +#define SCALE_SHAPE_COPY 2 + +#define POSITION_SHAPE 1 +#define POSITION_SHAPE_COPY 2 + +#define TORUS_RR 1 +#define TORUS_PNT_VEC_RR 2 + +#define BOX_DX_DY_DZ 1 +#define BOX_TWO_PNT 2 + +#define CYLINDER_R_H 1 +#define CYLINDER_PNT_VEC_R_H 2 + +#define CONE_R1_R2_H 1 +#define CONE_PNT_VEC_R1_R2_H 2 + +#define SPHERE_R 1 +#define SPHERE_PNT_R 2 + +#define PRISM_BASE_VEC_H 1 +#define PRISM_BASE_TWO_PNT 2 + +#define REVOLUTION_BASE_AXIS_ANGLE 1 + +#define PIPE_BASE_PATH 1 + +#define BOOLEAN_COMMON 1 +#define BOOLEAN_CUT 2 +#define BOOLEAN_FUSE 3 +#define BOOLEAN_SECTION 4 + +#define PARTITION_PARTITION 1 +#define PARTITION_HALF 2 + +#define POLYLINE_POINTS 1 + +#define CIRCLE_THREE_PNT 1 +#define CIRCLE_PNT_VEC_R 2 + +#define SPLINE_BEZIER 1 +#define SPLINE_INTERPOLATION 2 + +#define ELLIPSE_PNT_VEC_RR 1 + +#define CIRC_ARC_THREE_PNT 1 + +#define FILLET_SHAPE_ALL 1 +#define FILLET_SHAPE_EDGES 2 +#define FILLET_SHAPE_FACES 3 + +#define CHAMFER_SHAPE_ALL 1 +#define CHAMFER_SHAPE_EDGE 2 +#define CHAMFER_SHAPE_FACES 3 + +#define WIRE_EDGES 1 +#define FACE_WIRE 2 +#define SHELL_FACES 3 +#define SOLID_SHELL 4 +#define SOLID_SHELLS 5 +#define COMPOUND_SHAPES 6 +#define SUBSHAPE_SORTED 7 +#define SUBSHAPE_NOT_SORTED 8 +#define FACE_WIRES 9 +#define REVERSE_ORIENTATION 10 + +#define ARCHIMEDE_TYPE 1 + +// Shape Healing operators +#define SHAPE_PROCESS 1 +#define SUPPRESS_FACES 2 +#define CLOSE_CONTOUR 3 +#define REMOVE_INT_WIRES 4 +#define FILL_HOLES 5 +#define SEWING 6 +#define DIVIDE_EDGE 7 + +#define BASIC_FILLING 1 + +#define GLUE_FACES 1 + +#define SKETCHER_COMMAND 1 + +#define CDG_MEASURE 1 + +#define GROUP_FUNCTION 1 + +// Blocks +#define BLOCK_FACE_FOUR_PNT 1 +#define BLOCK_FACE_FOUR_EDGES 2 +#define BLOCK_FACE_TWO_EDGES 3 +#define BLOCK_SIX_FACES 4 +#define BLOCK_TWO_FACES 5 +#define BLOCK_MULTI_TRANSFORM_1D 6 +#define BLOCK_MULTI_TRANSFORM_2D 7 +#define BLOCK_COMPOUND_GLUE 8 + +// Marker +#define MARKER_CS 1 diff --git a/src/GEOMImpl/GEOMImpl_VectorDriver.cxx b/src/GEOMImpl/GEOMImpl_VectorDriver.cxx new file mode 100644 index 000000000..312fe4b23 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_VectorDriver.cxx @@ -0,0 +1,134 @@ + +using namespace std; +#include "GEOMImpl_VectorDriver.hxx" +#include "GEOMImpl_IVector.hxx" +#include "GEOMImpl_Types.hxx" +#include "GEOM_Function.hxx" + +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& GEOMImpl_VectorDriver::GetID() +{ + static Standard_GUID aVectorDriver("FF1BBB04-5D14-4df2-980B-3A668264EA16"); + return aVectorDriver; +} + + +//======================================================================= +//function : GEOMImpl_VectorDriver +//purpose : +//======================================================================= +GEOMImpl_VectorDriver::GEOMImpl_VectorDriver() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_VectorDriver::Execute(TFunction_Logbook& log) const +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); + + GEOMImpl_IVector aPI (aFunction); + Standard_Integer aType = aFunction->GetType(); + if (aType != VECTOR_DX_DY_DZ && aType != VECTOR_TWO_PNT) return 0; + + TopoDS_Shape aShape; + + if (aType == VECTOR_DX_DY_DZ) { + gp_Pnt P1 = gp::Origin(); + gp_Pnt P2 (aPI.GetDX(), aPI.GetDY(), aPI.GetDZ()); + if (P1.Distance(P2) < Precision::Confusion()) { + TCollection_AsciiString aMsg ("Can not build vector with length, less than "); + aMsg += TCollection_AsciiString(Precision::Confusion()); + Standard_ConstructionError::Raise(aMsg.ToCString()); + } + aShape = BRepBuilderAPI_MakeEdge(P1, P2).Shape(); + } else if (aType == VECTOR_TWO_PNT) { + Handle(GEOM_Function) aRefPnt1 = aPI.GetPoint1(); + Handle(GEOM_Function) aRefPnt2 = aPI.GetPoint2(); + TopoDS_Shape aShape1 = aRefPnt1->GetValue(); + TopoDS_Shape aShape2 = aRefPnt2->GetValue(); + if (aShape1.ShapeType() != TopAbs_VERTEX || + aShape2.ShapeType() != TopAbs_VERTEX) return 0; + if (aShape1.IsSame(aShape2)) { + Standard_ConstructionError::Raise("The end points must be different"); + } + gp_Pnt P1 = BRep_Tool::Pnt(TopoDS::Vertex(aShape1)); + gp_Pnt P2 = BRep_Tool::Pnt(TopoDS::Vertex(aShape2)); + if (P1.Distance(P2) < Precision::Confusion()) { + Standard_ConstructionError::Raise("The end points are too close"); + } + aShape = BRepBuilderAPI_MakeEdge(P1, P2).Shape(); + } else { + } + + if (aShape.IsNull()) return 0; + + aFunction->SetValue(aShape); + + log.SetTouched(Label()); + + return 1; +} + + +//======================================================================= +//function : GEOMImpl_VectorDriver_Type_ +//purpose : +//======================================================================= +Standard_EXPORT Handle_Standard_Type& GEOMImpl_VectorDriver_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); + 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("GEOMImpl_VectorDriver", + sizeof(GEOMImpl_VectorDriver), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + +//======================================================================= +//function : DownCast +//purpose : +//======================================================================= +const Handle(GEOMImpl_VectorDriver) Handle(GEOMImpl_VectorDriver)::DownCast + (const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOMImpl_VectorDriver) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_VectorDriver))) { + _anOtherObject = Handle(GEOMImpl_VectorDriver)((Handle(GEOMImpl_VectorDriver)&)AnObject); + } + } + + return _anOtherObject ; +} diff --git a/src/GEOMImpl/GEOMImpl_VectorDriver.hxx b/src/GEOMImpl/GEOMImpl_VectorDriver.hxx new file mode 100644 index 000000000..7802c123c --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_VectorDriver.hxx @@ -0,0 +1,138 @@ +// File : GEOMImpl_VectorDriver.hxx +// Module : GEOMImpl + +#ifndef _GEOMImpl_VectorDriver_HeaderFile +#define _GEOMImpl_VectorDriver_HeaderFile + +#ifndef _TColStd_SequenceOfExtendedString_HeaderFile +#include +#endif +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_GUID_HeaderFile +#include +#endif + +#ifndef _Handle_TFunction_Driver_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TFunction_Driver); +class GEOMImpl_VectorDriver; + +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMImpl_VectorDriver); + +class Handle(GEOMImpl_VectorDriver) : public Handle(TFunction_Driver) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + Handle(GEOMImpl_VectorDriver)():Handle(TFunction_Driver)() {} + Handle(GEOMImpl_VectorDriver)(const Handle(GEOMImpl_VectorDriver)& aHandle) : Handle(TFunction_Driver)(aHandle) + { + } + + Handle(GEOMImpl_VectorDriver)(const GEOMImpl_VectorDriver* anItem) : Handle(TFunction_Driver)((TFunction_Driver *)anItem) + { + } + + Handle(GEOMImpl_VectorDriver)& operator=(const Handle(GEOMImpl_VectorDriver)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOMImpl_VectorDriver)& operator=(const GEOMImpl_VectorDriver* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOMImpl_VectorDriver* operator->() + { + return (GEOMImpl_VectorDriver *)ControlAccess(); + } + + GEOMImpl_VectorDriver* operator->() const + { + return (GEOMImpl_VectorDriver *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOMImpl_VectorDriver)() {}; + + Standard_EXPORT static const Handle(GEOMImpl_VectorDriver) DownCast(const Handle(Standard_Transient)& AnObject); +}; + +#ifndef _TFunction_Driver_HeaderFile +#include +#endif +#ifndef _TFunction_Logbook_HeaderFile +#include +#endif +#ifndef _Standard_CString_HeaderFile +#include +#endif + +class TColStd_SequenceOfExtendedString; + + +class GEOMImpl_VectorDriver : public TFunction_Driver { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + // Methods PUBLIC + // +Standard_EXPORT GEOMImpl_VectorDriver(); +Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; +Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {} +Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const { return Standard_True; } +Standard_EXPORT static const Standard_GUID& GetID(); +Standard_EXPORT ~GEOMImpl_VectorDriver() {}; + + + // Type management + // +Standard_EXPORT friend Handle_Standard_Type& GEOMImpl_VectorDriver_Type_(); +Standard_EXPORT const Handle(Standard_Type)& DynamicType() const { return STANDARD_TYPE(GEOMImpl_VectorDriver) ; } +Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const { return (STANDARD_TYPE(GEOMImpl_VectorDriver) == AType || TFunction_Driver::IsKind(AType)); } + +}; + +#endif diff --git a/src/GEOMImpl/GUID.txt b/src/GEOMImpl/GUID.txt new file mode 100755 index 000000000..285d047d6 --- /dev/null +++ b/src/GEOMImpl/GUID.txt @@ -0,0 +1,69 @@ +FF1BBB02-5D14-4df2-980B-3A668264EA16 // Point + +FF1BBB03-5D14-4df2-980B-3A668264EA16 // Translation + +FF1BBB04-5D14-4df2-980B-3A668264EA16 // Vector +FF1BBB05-5D14-4df2-980B-3A668264EA16 // Plane +FF1BBB06-5D14-4df2-980B-3A668264EA16 // Line +FF1BBB07-5D14-4df2-980B-3A668264EA16 // Marker + +FF1BBB00-5D14-4df2-980B-3A668264EA16 // GUID for Functions tree +FF1BBB10-5D14-4df2-980B-3A668264EA16 // GUID for References tree + +FF1BBB12-5D14-4df2-980B-3A668264EA16 // Torus +FF1BBB13-5D14-4df2-980B-3A668264EA16 // Box +FF1BBB14-5D14-4df2-980B-3A668264EA16 // Cylinder +FF1BBB15-5D14-4df2-980B-3A668264EA16 // Cone +FF1BBB16-5D14-4df2-980B-3A668264EA16 // Sphere +FF1BBB17-5D14-4df2-980B-3A668264EA16 // Prism (Extrusion) +FF1BBB18-5D14-4df2-980B-3A668264EA16 // Revolution +FF1BBB19-5D14-4df2-980B-3A668264EA16 // Pipe + +FF1BBB21-5D14-4df2-980B-3A668264EA16 // Boolean +FF1BBB22-5D14-4df2-980B-3A668264EA16 // Partition + +FF1BBB31-5D14-4df2-980B-3A668264EA16 // Polyline +FF1BBB32-5D14-4df2-980B-3A668264EA16 // Circle +FF1BBB33-5D14-4df2-980B-3A668264EA16 // Spline +FF1BBB34-5D14-4df2-980B-3A668264EA16 // Ellipse +FF1BBB35-5D14-4df2-980B-3A668264EA16 // Arc of circle + +FF1BBB41-5D14-4df2-980B-3A668264EA16 // Fillet +FF1BBB42-5D14-4df2-980B-3A668264EA16 // Chamfer + +FF1BBB51-5D14-4df2-980B-3A668264EA16 // Offset +FF1BBB52-5D14-4df2-980B-3A668264EA16 // Scale + +FF1BBB53-5D14-4df2-980B-3A668264EA16 // Copy + +FF1BBB54-5D14-4df2-980B-3A668264EA16 // Shape (Wire, Face, Shell, Solid, Compound) + +FF1BBB55-5D14-4df2-980B-3A668264EA16 // Subshape + +FF1BBB56-5D14-4df2-980B-3A668264EA16 // Rotate + +FF1BBB57-5D14-4df2-980B-3A668264EA16 // Mirror + +FF1BBB58-5D14-4df2-980B-3A668264EA16 // Export + +FF1BBB59-5D14-4df2-980B-3A668264EA16 // Archimede + +FF1BBB60-5D14-4df2-980B-3A668264EA16 // Import + +FF1BBB61-5D14-4df2-980B-3A668264EA16 // Shape Healing + +FF1BBB62-5D14-4df2-980B-3A668264EA16 // Filling + +FF1BBB63-5D14-4df2-980B-3A668264EA16 // Glue Faces + +FF1BBB64-5D14-4df2-980B-3A668264EA16 // Sketcher + +FF1BBB65-5D14-4df2-980B-3A668264EA16 // Measurements + +FF1BBB66-5D14-4df2-980B-3A668264EA16 // Group + +FF1BBB67-5D14-4df2-980B-3A668264EA16 // Blocks + +FF1BBB68-5D14-4df2-980B-3A668264EA16 // Sub shape GUID + +FF1BBB69-5D14-4df2-980B-3A668264EA16 // Modify the Location diff --git a/src/GEOMImpl/Makefile.in b/src/GEOMImpl/Makefile.in new file mode 100644 index 000000000..05cbe7e7a --- /dev/null +++ b/src/GEOMImpl/Makefile.in @@ -0,0 +1,182 @@ + +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + + +@COMMENCE@ + +# Libraries targets + +LIB = libGEOMimpl.la +LIB_SRC = GEOMImpl_IBasicOperations.cxx \ + GEOMImpl_ITransformOperations.cxx \ + GEOMImpl_IHealingOperations.cxx \ + GEOMImpl_I3DPrimOperations.cxx \ + GEOMImpl_IShapesOperations.cxx \ + GEOMImpl_IBlocksOperations.cxx \ + GEOMImpl_IBooleanOperations.cxx \ + GEOMImpl_ICurvesOperations.cxx \ + GEOMImpl_ILocalOperations.cxx \ + GEOMImpl_IInsertOperations.cxx \ + GEOMImpl_IMeasureOperations.cxx \ + GEOMImpl_IGroupOperations.cxx \ + GEOMImpl_Gen.cxx \ + GEOMImpl_PointDriver.cxx \ + GEOMImpl_VectorDriver.cxx \ + GEOMImpl_LineDriver.cxx \ + GEOMImpl_PlaneDriver.cxx \ + GEOMImpl_MarkerDriver.cxx \ + GEOMImpl_TranslateDriver.cxx \ + GEOMImpl_MirrorDriver.cxx \ + GEOMImpl_OffsetDriver.cxx \ + GEOMImpl_ScaleDriver.cxx \ + GEOMImpl_PositionDriver.cxx \ + GEOMImpl_BoxDriver.cxx \ + GEOMImpl_ConeDriver.cxx \ + GEOMImpl_CylinderDriver.cxx \ + GEOMImpl_SphereDriver.cxx \ + GEOMImpl_TorusDriver.cxx \ + GEOMImpl_PrismDriver.cxx \ + GEOMImpl_PipeDriver.cxx \ + GEOMImpl_RevolutionDriver.cxx \ + GEOMImpl_ShapeDriver.cxx \ + GEOMImpl_BlockDriver.cxx \ + GEOMImpl_Block6Explorer.cxx \ + GEOMImpl_MeasureDriver.cxx \ + GEOMImpl_PolylineDriver.cxx \ + GEOMImpl_CircleDriver.cxx \ + GEOMImpl_EllipseDriver.cxx \ + GEOMImpl_ArcDriver.cxx \ + GEOMImpl_SplineDriver.cxx \ + GEOMImpl_SketcherDriver.cxx \ + GEOMImpl_FilletDriver.cxx \ + GEOMImpl_ChamferDriver.cxx \ + GEOMImpl_BooleanDriver.cxx \ + GEOMImpl_PartitionDriver.cxx \ + GEOMImpl_CopyDriver.cxx \ + GEOMImpl_ExportDriver.cxx \ + GEOMImpl_ImportDriver.cxx \ + GEOMImpl_RotateDriver.cxx \ + GEOMImpl_ArchimedeDriver.cxx \ + GEOMImpl_HealingDriver.cxx \ + GEOMImpl_FillingDriver.cxx \ + GEOMImpl_GlueDriver.cxx + +LIB_CLIENT_IDL = +LIB_SERVER_IDL = + +# Executables targets +BIN = +BIN_SRC = +BIN_CLIENT_IDL = +BIN_SERVER_IDL = + +# header files +EXPORT_HEADERS= GEOMImpl_Gen.hxx \ + GEOMImpl_IBasicOperations.hxx \ + GEOMImpl_ITransformOperations.hxx \ + GEOMImpl_IHealingOperations.hxx \ + GEOMImpl_I3DPrimOperations.hxx \ + GEOMImpl_IShapesOperations.hxx \ + GEOMImpl_IBlocksOperations.hxx \ + GEOMImpl_IBooleanOperations.hxx \ + GEOMImpl_ICurvesOperations.hxx \ + GEOMImpl_ILocalOperations.hxx \ + GEOMImpl_IInsertOperations.hxx \ + GEOMImpl_IMeasureOperations.hxx \ + GEOMImpl_IGroupOperations.hxx \ + GEOMImpl_PointDriver.hxx \ + GEOMImpl_VectorDriver.hxx \ + GEOMImpl_LineDriver.hxx \ + GEOMImpl_PlaneDriver.hxx \ + GEOMImpl_MarkerDriver.hxx \ + GEOMImpl_TranslateDriver.hxx \ + GEOMImpl_MirrorDriver.hxx \ + GEOMImpl_PositionDriver.hxx \ + GEOMImpl_OffsetDriver.hxx \ + GEOMImpl_ScaleDriver.hxx \ + GEOMImpl_BoxDriver.hxx \ + GEOMImpl_ConeDriver.hxx \ + GEOMImpl_CylinderDriver.hxx \ + GEOMImpl_SphereDriver.hxx \ + GEOMImpl_TorusDriver.hxx \ + GEOMImpl_PrismDriver.hxx \ + GEOMImpl_PipeDriver.hxx \ + GEOMImpl_RevolutionDriver.hxx \ + GEOMImpl_ShapeDriver.hxx \ + GEOMImpl_BlockDriver.hxx \ + GEOMImpl_MeasureDriver.hxx \ + GEOMImpl_PolylineDriver.hxx \ + GEOMImpl_CircleDriver.hxx \ + GEOMImpl_EllipseDriver.hxx \ + GEOMImpl_ArcDriver.hxx \ + GEOMImpl_SplineDriver.hxx \ + GEOMImpl_SketcherDriver.hxx \ + GEOMImpl_FilletDriver.hxx \ + GEOMImpl_ChamferDriver.hxx \ + GEOMImpl_BooleanDriver.hxx \ + GEOMImpl_PartitionDriver.hxx \ + GEOMImpl_CopyDriver.hxx \ + GEOMImpl_ExportDriver.hxx \ + GEOMImpl_ImportDriver.hxx \ + GEOMImpl_RotateDriver.hxx \ + GEOMImpl_ArchimedeDriver.hxx \ + GEOMImpl_FillingDriver.hxx \ + GEOMImpl_GlueDriver.hxx \ + GEOMImpl_IArchimede.hxx \ + GEOMImpl_IPoint.hxx \ + GEOMImpl_IVector.hxx \ + GEOMImpl_ILine.hxx \ + GEOMImpl_IPlane.hxx \ + GEOMImpl_IMarker.hxx \ + GEOMImpl_IMirror.hxx \ + GEOMImpl_IOffset.hxx \ + GEOMImpl_IScale.hxx \ + GEOMImpl_IPosition.hxx \ + GEOMImpl_IBox.hxx \ + GEOMImpl_ICone.hxx \ + GEOMImpl_ICylinder.hxx \ + GEOMImpl_ISphere.hxx \ + GEOMImpl_ITorus.hxx \ + GEOMImpl_IPrism.hxx \ + GEOMImpl_IPipe.hxx \ + GEOMImpl_IRevolution.hxx \ + GEOMImpl_IShapes.hxx \ + GEOMImpl_IBlocks.hxx \ + GEOMImpl_IMeasure.hxx \ + GEOMImpl_IPolyline.hxx \ + GEOMImpl_ICircle.hxx \ + GEOMImpl_IEllipse.hxx \ + GEOMImpl_IArc.hxx \ + GEOMImpl_ISpline.hxx \ + GEOMImpl_ISketcher.hxx \ + GEOMImpl_IFillet.hxx \ + GEOMImpl_IChamfer.hxx \ + GEOMImpl_IBoolean.hxx \ + GEOMImpl_IPartition.hxx \ + GEOMImpl_ICopy.hxx \ + GEOMImpl_IImportExport.hxx \ + GEOMImpl_ITranslate.hxx \ + GEOMImpl_IRotate.hxx \ + GEOMImpl_IBlockTrsf.hxx \ + GEOMImpl_Types.hxx \ + GEOMImpl_IHealing.hxx \ + GEOMImpl_IFilling.hxx \ + GEOMImpl_IGlue.hxx \ + GEOMImpl_HealingDriver.hxx + +# additionnal information to compil and link file +CPPFLAGS += $(OCC_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome $(BOOST_CPPFLAGS) +CXXFLAGS += $(OCC_CXXFLAGS) -I${KERNEL_ROOT_DIR}/include/salome +LDFLAGS += -L${KERNEL_ROOT_DIR}/lib/salome $(CAS_LDPATH) -lTKCAF -lCASCatch -lGEOMbasic -lNMTAlgo -lShHealOper + + +# additional file to be cleaned +MOSTLYCLEAN = +CLEAN = +DISTCLEAN = + +@CONCLUDE@ + diff --git a/src/GEOMToolsGUI/GEOMToolsGUI.cxx b/src/GEOMToolsGUI/GEOMToolsGUI.cxx index e4aab6706..9be35edb9 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI.cxx +++ b/src/GEOMToolsGUI/GEOMToolsGUI.cxx @@ -21,59 +21,101 @@ // // // -// File : GEOMToolsGUI.cxx +// File : GEOMBase_Tools.cxx // Author : Damien COQUERET // Module : GEOM -// $Header: +// $Header$ #include "GEOMToolsGUI.h" +#include "GeometryGUI.h" +#include "GEOM_Actor.h" +#include "GEOMBase.h" +#include "GEOM_Operation.h" +#include "GEOM_Displayer.h" -#include "QAD_Config.h" +#include "QAD_Desktop.h" #include "QAD_FileDlg.h" #include "QAD_Tools.h" #include "QAD_MessageBox.h" #include "QAD_RightFrame.h" -#include "QAD_PyEditor.h" +#include "QAD_WaitCursor.h" #include "OCCViewer_Viewer3d.h" #include "VTKViewer_ViewFrame.h" +#include "VTKViewer_RenderWindowInteractor.h" #include "SALOME_ListIteratorOfListIO.hxx" -#include "SALOMEGUI_NameDlg.h" #include "SALOMEGUI_ImportOperation.h" #include "SALOMEGUI_QtCatchCorbaException.hxx" -#include -#include -#include +#include +#include -#include -#include -#include -#include -#include +#include "utilities.h" -#include -#include -#include +using namespace std; -#include "GEOMToolsGUI_NbIsosDlg.h" // Method ISOS adjustement -#include "GEOMToolsGUI_TransparencyDlg.h" // Method TRANSPARENCY adjustement +GEOMToolsGUI* GEOMToolsGUI::myGUIObject = 0; -#include "utilities.h" +typedef QMap FilterMap; -using namespace std; +//======================================================================= +// function : getFileName +// purpose : Selection of a file name for Import/Export. Returns also +// the selected file type code through argument. +//======================================================================= +static QString getFileName( QWidget* parent, + const QString& initial, + const FilterMap& filterMap, + const QString& caption, + bool open, + QString& format ) +{ + static QString lastUsedFilter; + QStringList filters; + for ( FilterMap::const_iterator it = filterMap.begin(); it != filterMap.end(); ++it ) + filters.push_back( it.key() ); + + QAD_FileDlg* fd = new QAD_FileDlg( parent, open, true, true ); + if ( !caption.isEmpty() ) + fd->setCaption( caption ); + + if ( !initial.isEmpty() ) + fd->setSelection( initial ); + + if ( !lastUsedFilter.isEmpty() && filterMap.contains( lastUsedFilter ) ) + fd->setSelectedFilter( lastUsedFilter ); + + fd->setFilters( filters ); + + fd->exec(); + QString filename = fd->selectedFile(); + format = filterMap[fd->selectedFilter()]; + lastUsedFilter = fd->selectedFilter(); + delete fd; + qApp->processEvents(); + return filename; +} + +//======================================================================= +// function : GetGEOMToolsGUI() +// purpose : Get the only GEOMToolsGUI object [ static ] +//======================================================================= +GEOMToolsGUI* GEOMToolsGUI::GetGEOMToolsGUI() +{ + if ( myGUIObject == 0 ) { + // init GEOMToolsGUI only once + myGUIObject = new GEOMToolsGUI(); + } + return myGUIObject; +} //======================================================================= // function : GEOMToolsGUI() // purpose : Constructor //======================================================================= -GEOMToolsGUI::GEOMToolsGUI() : - QObject() +GEOMToolsGUI::GEOMToolsGUI() : GEOMGUI() { - myGeomBase = new GEOMBase(); - myGeomGUI = GEOMContext::GetGeomGUI(); - myGeom = myGeomGUI->myComponentGeom; } @@ -92,8 +134,7 @@ GEOMToolsGUI::~GEOMToolsGUI() //======================================================================= bool GEOMToolsGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) { - GEOMToolsGUI* myGEOMToolsGUI = new GEOMToolsGUI(); - myGEOMToolsGUI->myGeomGUI->EmitSignalDeactivateDialog(); + GeometryGUI::GetGeomGUI()->EmitSignalDeactivateDialog(); SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection()); SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument(); @@ -101,444 +142,86 @@ bool GEOMToolsGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) { case 31: // COPY { - myGEOMToolsGUI->OnEditCopy(); + OnEditCopy(); break; } case 33: // DELETE { - myGEOMToolsGUI->OnEditDelete(); + OnEditDelete(); break; } case 111: // IMPORT BREP - { - myGEOMToolsGUI->Import(theCommandID); - break; - } case 112: // IMPORT IGES - { - myGEOMToolsGUI->Import(theCommandID); - break; - } case 113: // IMPORT STEP { - myGEOMToolsGUI->Import(theCommandID); + Import(); break; } case 121: // EXPORT BREP - { - myGEOMToolsGUI->Export(theCommandID); - break; - } case 122: // EXPORT IGES - { - myGEOMToolsGUI->Export(theCommandID); - break; - } case 123: // EXPORT STEP { - myGEOMToolsGUI->Export(theCommandID); + Export(); break; } case 411: // SETTINGS - ADD IN STUDY { - QMenuBar* Mb = QAD_Application::getDesktop()->getMainMenuBar(); - QMenuData* pp; - QMenuItem* item = parent->menuBar()->findItem(411, &pp); - bool check = !pp->isItemChecked(411); - pp->setItemChecked(411,check); - //myGEOMToolsGUI->myGeomGUI->GetSettings_AddInStudy() = check; - QAD_CONFIG->addSetting("Geometry:SettingsAddInStudy", check); + // SAN -- TO BE REMOVED !!! break; } case 412: // SETTINGS - SHADING COLOR { - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC) - break; - - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); - - QString SCr = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorRed"); - QString SCg = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorGreen"); - QString SCb = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorBlue"); - QColor color; - if(!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty()) { - color = QColor (SCr.toInt(), SCg.toInt(), SCb.toInt()); - } - else { - Quantity_Color Default = Quantity_Color(); - color = QColor ((int)( Default.Red() * 255.0 ), (int)( Default.Green() * 255.0 ), (int)( Default.Blue() * 255.0 ) ); - } - - QColor c = QColorDialog::getColor(color, QAD_Application::getDesktop()); - if(c.isValid()) { - //myGEOMToolsGUI->myGeomGUI->GetShadingColor() = Quantity_Color(c.red() / 255.0, c.green() / 255.0, c.blue() / 255.0, Quantity_TOC_RGB); - - AIS_ListOfInteractive List; - ic->DisplayedObjects(List); - AIS_ListOfInteractive List1; - ic->ObjectsInCollector(List1); - List.Append(List1); - - AIS_ListIteratorOfListOfInteractive ite(List); - while(ite.More()) { - if(ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) { - Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value()); - aSh->SetShadingColor(Quantity_Color(c.red() / 255.0, c.green() / 255.0, c.blue() / 255.0, Quantity_TOC_RGB)); - ic->Redisplay(aSh, Standard_True, Standard_True); - } - ite.Next(); - } - - ic->UpdateCurrentViewer(); - - QAD_CONFIG->addSetting("Geometry:SettingsShadingColorRed", c.red()); - QAD_CONFIG->addSetting("Geometry:SettingsShadingColorGreen", c.green()); - QAD_CONFIG->addSetting("Geometry:SettingsShadingColorBlue", c.blue()); - } + OnSettingsColor(); break; } case 413: // SETTINGS - ISOS { - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC) - break; - - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); - - QString IsoU = QAD_CONFIG->getSetting("Geometry:SettingsIsoU"); - QString IsoV = QAD_CONFIG->getSetting("Geometry:SettingsIsoV"); - if(!IsoU.isEmpty()) - ic->DefaultDrawer()->UIsoAspect()->SetNumber(IsoU.toInt()); - else - IsoU = "1"; - if (!IsoV.isEmpty()) - ic->DefaultDrawer()->VIsoAspect()->SetNumber(IsoV.toInt()); - else - IsoV = "1"; - - GEOMToolsGUI_NbIsosDlg* NbIsosDlg = new GEOMToolsGUI_NbIsosDlg(QAD_Application::getDesktop(), tr("GEOM_MEN_ISOS"), TRUE); - int UIso = IsoU.toInt(); - int VIso = IsoV.toInt(); - - NbIsosDlg->SpinBoxU->setValue(UIso); - NbIsosDlg->SpinBoxV->setValue(VIso); - - if(NbIsosDlg->exec()) { - UIso = NbIsosDlg->SpinBoxU->text().toInt(); - VIso = NbIsosDlg->SpinBoxV->text().toInt(); - - ic->DefaultDrawer()->UIsoAspect()->SetNumber(UIso); - ic->DefaultDrawer()->VIsoAspect()->SetNumber(VIso); - QAD_CONFIG->addSetting("Geometry:SettingsIsoU", NbIsosDlg->SpinBoxU->text()); /* text format */ - QAD_CONFIG->addSetting("Geometry:SettingsIsoV", NbIsosDlg->SpinBoxV->text()); /* text format */ - } - - AIS_ListOfInteractive List; - ic->DisplayedObjects(List); - AIS_ListOfInteractive List1; - ic->ObjectsInCollector(List1); - List.Append(List1); - - AIS_ListIteratorOfListOfInteractive ite(List); - ic->InitCurrent(); - if(ic->NbCurrents()) - while(ite.More()) { - if(ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) { - Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value()); - Handle (AIS_Drawer) CurDrawer; - CurDrawer = aSh->Attributes(); - CurDrawer->UIsoAspect()->SetNumber(UIso); - CurDrawer->VIsoAspect()->SetNumber(VIso); - ic->SetLocalAttributes(aSh, CurDrawer); - ic->Redisplay(aSh); - } - ite.Next(); - } - ic->UpdateCurrentViewer(); + OnSettingsIsos(); break; } case 414: // SETTINGS : STEP VALUE FOR SPIN BOXES { - QString step = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep"); - if(step.isEmpty()) - step = "100.0"; - - Standard_Boolean res = false; - double dd = myGEOMToolsGUI->myGeomBase->Parameter(res, QString("%1").arg(step), tr("GEOM_MEN_STEP_LABEL"), tr("GEOM_STEP_TITLE"), 0.001, 10000.0, 3); - if(res) { - QAD_CONFIG->addSetting("Geometry:SettingsGeomStep", QString("%1").arg(dd)); - - /* Emit signal to GeometryGUI_SpinBoxes */ - myGEOMToolsGUI->myGeomGUI->EmitSignalDefaultStepValueChanged(dd); - } - else - parent->putInfo(tr("GEOM_PRP_ABORT")); + OnSettingsStep(); break; } case 804: // ADD IN STUDY - POPUP VIEWER { - const SALOME_ListIO& ListSelected = Sel->StoredIObjects(); - SALOME_ListIteratorOfListIO It(ListSelected); - for(; It.More(); It.Next()) { - Handle(SALOME_InteractiveObject) IObject = It.Value(); - myGEOMToolsGUI->myGeomBase->AddInStudy(true, IObject); - } - /* Is set on the dialog box */ - QApplication::restoreOverrideCursor(); + // SAN -- TO BE REMOVED !!!! break; } case 901: // RENAME { - SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); - for(; It.More(); It.Next()) { - Handle(SALOME_InteractiveObject) IObject = It.Value(); - - SALOMEDS::SObject_var obj = aStudy->FindObjectID(IObject->getEntry()); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeName_var aName; - if(!obj->_is_nil()) { - if(obj->FindAttribute(anAttr, "AttributeName")) { - aName = SALOMEDS::AttributeName::_narrow(anAttr); - - QString nm = QString(aName->Value()); - nm = SALOMEGUI_NameDlg::getName(QAD_Application::getDesktop(), nm); - if(!nm.isEmpty()) { - QApplication::setOverrideCursor(Qt::waitCursor); - QAD_Application::getDesktop()->getActiveStudy()->renameIObject(IObject, nm); - QApplication::restoreOverrideCursor(); - } - } - } - } + OnRename(); break; } case 5103: // CHECK GEOMETRY { - QAD_PyEditor* PyEditor = QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getPyEditor(); - PyEditor->setText("from GEOM_usinggeom import *\n"); - //PyEditor->setText(">>> "); - PyEditor->handleReturn(); + OnCheckGeometry(); break; } case 5104: // LOAD SCRIPT { - QStringList filtersList; - filtersList.append(tr("GEOM_MEN_LOAD_SCRIPT")); - filtersList.append(tr("GEOM_MEN_ALL_FILES")); - - QString aFile = QAD_FileDlg::getFileName(QAD_Application::getDesktop(), "", filtersList, tr("GEOM_MEN_IMPORT"), true); - if(!aFile.isEmpty()) { - QFileInfo file = aFile; - QApplication::setOverrideCursor(Qt::waitCursor); - QAD_PyEditor* PyEditor = QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getPyEditor(); - - PyEditor->setText("import geompy\n"); - PyEditor->handleReturn(); - - QStringList aTextList = QStringList::split(".", file.fileName()); - PyEditor->setText("geompy.Path('" + file.dirPath() + "')\n"); - PyEditor->handleReturn(); - - PyEditor->setText("from " + aTextList.first() + " import *\n"); - PyEditor->handleReturn(); - } - QApplication::restoreOverrideCursor(); + OnLoadScript(); break; } case 8032: // COLOR - POPUP VIEWER { - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { - // VTK - VTKViewer_RenderWindowInteractor* myRenderInter = ((VTKViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); - - SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); - Handle(SALOME_InteractiveObject) FirstIOS = Sel->firstIObject(); - if(!FirstIOS.IsNull()) { - QColor initcolor = myRenderInter->GetColor(FirstIOS); - QColor c = QColorDialog::getColor( initcolor, QAD_Application::getDesktop()); - - if(c.isValid()) { - QApplication::setOverrideCursor(Qt::waitCursor); - for(;It.More();It.Next()) { - Handle(SALOME_InteractiveObject) IOS = It.Value(); - myRenderInter->SetColor(IOS,c); - } - } - QApplication::restoreOverrideCursor(); - } - } - else if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { - Handle(SALOME_InteractiveObject) IO = Sel->firstIObject(); - Standard_Boolean found; - Handle(GEOM_AISShape) Shape = myGEOMToolsGUI->myGeomBase->ConvertIOinGEOMAISShape(IO, found, true); - if(found) { - Quantity_Color CSFColor; - Shape->Color(CSFColor); - - QColor c = QColorDialog::getColor(QColor((int)(CSFColor.Red() * 255.0), (int)(CSFColor.Green() * 255.0), (int)(CSFColor.Blue() * 255.0)), QAD_Application::getDesktop()); - - if(c.isValid()) { - CSFColor = Quantity_Color (c.red()/255., c.green()/255., c.blue()/255., Quantity_TOC_RGB); - QApplication::setOverrideCursor( Qt::waitCursor ); - - SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); - for(;It.More();It.Next()) { - Handle(SALOME_InteractiveObject) IObject = It.Value(); - Standard_Boolean found; - Handle(GEOM_AISShape) Shape = myGEOMToolsGUI->myGeomBase->ConvertIOinGEOMAISShape(IObject, found, true); - if(found) { - Shape->SetColor(CSFColor); - Shape->SetShadingColor(CSFColor); - } - } - } - } - } - QApplication::restoreOverrideCursor(); + OnColor(); break; } case 8033: // TRANSPARENCY - POPUP VIEWER { - Handle(AIS_InteractiveContext) ic; - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - ic = v3d->getAISContext(); - } - GEOMToolsGUI_TransparencyDlg *aDlg = new GEOMToolsGUI_TransparencyDlg(parent, "", Sel, ic); + OnTransparency(); break; } case 8034: // ISOS - POPUP VIEWER { - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC) - break; - - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); - - ic->InitCurrent(); - if(ic->MoreCurrent()) { - Handle(GEOM_AISShape) CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current()); - QString IsoU = QAD_CONFIG->getSetting("Geometry:SettingsIsoU"); - QString IsoV = QAD_CONFIG->getSetting("Geometry:SettingsIsoV"); - - if(!IsoU.isEmpty()) - ic->DefaultDrawer()->UIsoAspect()->SetNumber(IsoU.toInt()); - else - IsoU = "1"; - if (!IsoV.isEmpty()) - ic->DefaultDrawer()->VIsoAspect()->SetNumber(IsoV.toInt()); - else - IsoV = "1"; - - GEOMToolsGUI_NbIsosDlg * NbIsosDlg = - new GEOMToolsGUI_NbIsosDlg(QAD_Application::getDesktop(), tr("GEOM_MEN_ISOS"), TRUE); - - NbIsosDlg->SpinBoxU->setValue(IsoU.toInt()); - NbIsosDlg->SpinBoxV->setValue(IsoV.toInt()); - - if(NbIsosDlg->exec()) { - QApplication::setOverrideCursor(Qt::waitCursor); - for(; ic->MoreCurrent(); ic->NextCurrent()) { - Handle(AIS_Drawer) CurDrawer; - - CurDrawer = ic->Current()->Attributes(); - CurDrawer->UIsoAspect()->SetNumber(NbIsosDlg->SpinBoxU->text().toInt()); - CurDrawer->VIsoAspect()->SetNumber(NbIsosDlg->SpinBoxV->text().toInt()); - - ic->SetLocalAttributes(CurObject, CurDrawer); - ic->Redisplay(CurObject); - } - } - } - QApplication::restoreOverrideCursor(); + OnNbIsos(); break; } case 9024 : // OPEN - OBJBROSER POPUP { - SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); - Handle(SALOME_InteractiveObject) anIObject; - for(;It.More();It.Next()) { - anIObject = It.Value(); - SALOMEDS::SObject_var obj = aStudy->FindObjectID(anIObject->getEntry()); - SALOMEDS::AttributePersistentRef_var aPersist; - SALOMEDS::AttributeIOR_var anIOR; - if(!obj->_is_nil()) { - // this SObject may be GEOM module root SObject - SALOMEDS::ChildIterator_var anIter = aStudy->NewChildIterator(obj); - SALOMEDS::GenericAttribute_var anAttr; - bool useSubItems = false; - while (anIter->More() && !useSubItems) { - SALOMEDS::SObject_var subobj = anIter->Value(); - if (subobj->FindAttribute(anAttr, "AttributePersistentRef")) { - useSubItems = true; - obj = subobj; - } - else - anIter->Next(); - } - obj->FindAttribute(anAttr, "AttributePersistentRef"); - - while(useSubItems?anIter->More():!anAttr->_is_nil()) { - if(!obj->FindAttribute(anAttr, "AttributeIOR") && - obj->FindAttribute(anAttr, "AttributePersistentRef")) { - - SALOMEDS::SComponent_var FComp = obj->GetFatherComponent(); - if (!CORBA::is_nil(FComp)) { - if (FComp->FindAttribute(anAttr, "AttributeName")) { - SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr); - QString compName = parent->getComponentName(aName->Value()); - // parent->loadComponentData(parent->getComponentName(aName->Value())); - Engines::Component_var comp ; - if ( compName.compare("SUPERV") == 0 ) { - comp = parent->getEngine( "SuperVisionContainer", compName) ; - } - else { - comp = parent->getEngine( "FactoryServer", compName); - if ( comp->_is_nil() ) - comp = parent->getEngine( "FactoryServerPy", compName); - } - - if (!CORBA::is_nil(comp)) { - SALOMEDS::Driver_var driver = SALOMEDS::Driver::_narrow(comp); - if (!CORBA::is_nil(driver)) { - SALOMEDS::StudyBuilder_var B = aStudy->NewBuilder(); - if (!CORBA::is_nil(B)) { - B->LoadWith(FComp,driver); - } else { - return false; - } - } else { - MESSAGE("loadComponentData(): Driver is null"); - return false; - } - } else { - MESSAGE("loadComponentData(): Engine is null"); - return false; - } - // // load - // Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer","GEOM"); - // if (!CORBA::is_nil(comp)) { - // SALOMEDS::Driver_var driver = SALOMEDS::Driver::_narrow(comp); - // SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); - // SALOMEDS::SComponent_var SC = aStudy->FindComponent("GEOM"); - // if (!CORBA::is_nil(SC)) - // aStudyBuilder->LoadWith(SC,driver); - } - } - else { - MESSAGE("Component is null"); - } - } - if(useSubItems) { - anIter->Next(); - obj = anIter->Value(); - } - else - anAttr = SALOMEDS::GenericAttribute::_nil(); - } - } - } + OnOpen(); break; } default: @@ -557,102 +240,118 @@ bool GEOMToolsGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) //=============================================================================== void GEOMToolsGUI::OnEditDelete() { - SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection()); - if(Sel->IObjectCount() == 0) + SALOME_Selection* Sel = SALOME_Selection::Selection( + QAD_Application::getDesktop()->getActiveStudy()->getSelection() ); + + if ( Sel->IObjectCount() == 0 ) return; - - if(QAD_MessageBox::warn2(QAD_Application::getDesktop(), tr("GEOM_WRN_WARNING"), tr("GEOM_REALLY_DELETE"), tr("GEOM_BUT_YES"), tr("GEOM_BUT_NO"), 1, 0, 0) != 1) + + SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument(); + + bool aLocked = aStudy->GetProperties()->IsLocked(); + if ( aLocked ) { + QAD_MessageBox::warn1 ( (QWidget*)QAD_Application::getDesktop(), + QObject::tr("WRN_WARNING"), + QObject::tr("WRN_STUDY_LOCKED"), + QObject::tr("BUT_OK") ); + return; + } + + if ( QAD_MessageBox::warn2( QAD_Application::getDesktop(), + tr( "GEOM_WRN_WARNING" ), + tr( "GEOM_REALLY_DELETE" ), + tr( "GEOM_BUT_YES" ), + tr( "GEOM_BUT_NO" ), 1, 0, 0 ) != 1 ) return; - + int nbSf = QAD_Application::getDesktop()->getActiveStudy()->getStudyFramesCount(); - + Standard_Boolean found; - SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument(); - SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeIOR_var anIOR; + SALOMEDS::AttributeIOR_var anIOR; + + SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); - SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); QAD_Operation* op = new SALOMEGUI_ImportOperation( QAD_Application::getDesktop()->getActiveStudy() ); + op->start(); - Standard_Boolean deleted = false; - for(;It.More();It.Next()) { - Handle(SALOME_InteractiveObject) IObject = It.Value(); - if(IObject->hasEntry()) { - SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument(); - SALOMEDS::SObject_var SO = aStudy->FindObjectID(IObject->getEntry()); - - /* Erase child graphical objects */ - SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator(SO); - for(; it->More();it->Next()) { - SALOMEDS::SObject_var CSO= it->Value(); - if(CSO->FindAttribute(anAttr, "AttributeIOR") ) { - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - /* Delete child(s) shape in Client : */ - const TCollection_AsciiString ASCior(anIOR->Value()) ; - myGeomGUI->GetShapeReader().RemoveShapeFromBuffer(ASCior); - - for(int i = 0; i < nbSf; i++) { - QAD_StudyFrame* sf = QAD_Application::getDesktop()->getActiveStudy()->getStudyFrame(i); - if(sf->getTypeView() == VIEW_OCC) { - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getViewer(); - Handle (AIS_InteractiveContext) myContext = v3d->getAISContext(); - Handle(GEOM_AISShape) Result = myGeomBase->ConvertIORinGEOMAISShape(anIOR->Value(), found); - if(found) - myContext->Erase(Result, true, false); - } - else if(sf->getTypeView() == VIEW_VTK) { - //vtkRenderer* Renderer = ((VTKViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getRenderer(); - VTKViewer_RenderWindowInteractor* myRenderInter = ((VTKViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getRWInteractor(); - GEOM_Actor* ac = myGeomBase->ConvertIORinGEOMActor(anIOR->Value(), found); - if(found) { - //Renderer->RemoveActor(ac); - if(ac->hasIO()) - myRenderInter->Remove(ac->getIO()); - } - } - } - } - } - - /* Erase main graphical object */ - for(int i = 0; i < nbSf; i++) { - QAD_StudyFrame* sf = QAD_Application::getDesktop()->getActiveStudy()->getStudyFrame(i); - if(sf->getTypeView() == VIEW_OCC) { - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getViewer(); - Handle(AIS_InteractiveContext) myContext = v3d->getAISContext(); - Handle(GEOM_AISShape) Result = myGeomBase->ConvertIOinGEOMAISShape(IObject, found ); - if(found) - myContext->Erase(Result, true, false); - } - else if(sf->getTypeView() == VIEW_VTK) { - VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getRWInteractor(); - myRenderInter->Remove( IObject ); - } - } - - /* Delete main shape in Client : */ - if(SO->FindAttribute(anAttr, "AttributeIOR")) { - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - const TCollection_AsciiString ASCIor(anIOR->Value()) ; - myGeomGUI->GetShapeReader().RemoveShapeFromBuffer(ASCIor); - } + + Standard_Boolean deleted = false; + + for ( ;It.More();It.Next() ) + { + Handle( SALOME_InteractiveObject ) IObject = It.Value(); + + if ( !IObject->hasEntry() ) + continue; + + SALOMEDS::SObject_var SO = aStudy->FindObjectID( IObject->getEntry() ); + + /* Erase child graphical objects */ - /* Erase objects in Study */ - SALOMEDS::SObject_var obj = aStudy->FindObjectID(IObject->getEntry()); - if(!obj->_is_nil()) { - aStudyBuilder->RemoveObject(obj); - deleted = true; + SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator( SO ); + for ( ; it->More();it->Next() ) + { + SALOMEDS::SObject_var CSO = it->Value(); + + if ( CSO->FindAttribute( anAttr, "AttributeIOR" ) ) + { + anIOR = SALOMEDS::AttributeIOR::_narrow( anAttr ); + + // Delete child( s ) shape in Client : + + const TCollection_AsciiString ASCior( anIOR->Value() ) ; + GeometryGUI::GetGeomGUI()->GetShapeReader().RemoveShapeFromBuffer( ASCior ); + + for ( int i = 0; i < nbSf; i++ ) + { + GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow( CSO->GetObject() ); + if ( !aGeomObj->_is_nil() ) + GEOM_Displayer().Erase( aGeomObj, true ); + } } + } - } /* IObject->hasEntry() */ - } /* more/next */ + /* Erase main graphical object */ - if (deleted) op->finish(); - else op->abort(); + for ( int i = 0; i < nbSf; i++ ) + { + QAD_StudyFrame* sf = QAD_Application::getDesktop()->getActiveStudy()->getStudyFrame( i ); + GEOM_Displayer().Erase( IObject, true ); + } + + /* Delete main shape in Client : */ + + if ( SO->FindAttribute( anAttr, "AttributeIOR" ) ) + { + anIOR = SALOMEDS::AttributeIOR::_narrow( anAttr ); + const TCollection_AsciiString ASCIor( anIOR->Value() ) ; + GeometryGUI::GetGeomGUI()->GetShapeReader().RemoveShapeFromBuffer( ASCIor ); + } + + /* Erase objects in Study */ + + SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() ); + if ( !obj->_is_nil() ) + { + SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); + aStudyBuilder->RemoveObject( obj ); + + GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow( obj->GetObject() ); + if ( !aGeomObj->_is_nil() ) + GeometryGUI::GetGeomGUI()->GetGeomGen()->RemoveObject( aGeomObj ); + + deleted = true; + } + } + + if ( deleted ) + op->finish(); + else + op->abort(); /* Clear any previous selection */ - Sel->ClearIObjects(); + Sel->ClearIObjects(); QAD_Application::getDesktop()->getActiveStudy()->updateObjBrowser(); } @@ -662,9 +361,10 @@ void GEOMToolsGUI::OnEditDelete() // purpose : //============================================================================== void GEOMToolsGUI::OnEditCopy() -{ - SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection() ); - GEOM::GEOM_Gen::ListOfIOR_var listIOR = new GEOM::GEOM_Gen::ListOfIOR; +{ +/* + SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection() ); + GEOM::string_array_var listIOR = new GEOM::string_array; const SALOME_ListIO& List = Sel->StoredIObjects(); @@ -672,11 +372,14 @@ void GEOMToolsGUI::OnEditCopy() Sel->ClearIObjects(); + SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument(); + int aStudyID = aStudy->StudyId(); + for (unsigned int ind = 0; ind < listIOR->length();ind++) { - GEOM::GEOM_Shape_var aShapeInit = myGeom->GetIORFromString(listIOR[ind]); + GEOM::GEOM_Object_var aShapeInit = myGeom->GetIORFromString(listIOR[ind]); try { - GEOM::GEOM_Shape_var result = myGeom->MakeCopy(aShapeInit) ; - result->NameType( aShapeInit->NameType() ); + GEOM::GEOM_IInsertOperations_var IOp = myGeom->GetIInsertOperations(aStudyID); + GEOM::GEOM_Object_var result = IOp->MakeCopy(aShapeInit) ; myGeomBase->Display(result); } catch (const SALOME::SALOME_Exception& S_ex) { @@ -685,6 +388,7 @@ void GEOMToolsGUI::OnEditCopy() } QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_READY")); +*/ } @@ -692,115 +396,73 @@ void GEOMToolsGUI::OnEditCopy() // function : Import // purpose : BRep, Iges, Step //===================================================================================== -bool GEOMToolsGUI::Import(int aState) +bool GEOMToolsGUI::Import() { - SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument(); - SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); - - GEOM::GEOM_Shape_var aShape; - QString file; - QStringList filtersList; + QAD_Study* aDoc = QAD_Application::getDesktop()->getActiveStudy(); + SALOMEDS::Study_var aStudy = aDoc->getStudyDocument(); + + bool aLocked = aStudy->GetProperties()->IsLocked(); + if ( aLocked ) { + QAD_MessageBox::warn1 ( (QWidget*)QAD_Application::getDesktop(), + QObject::tr("WRN_WARNING"), + QObject::tr("WRN_STUDY_LOCKED"), + QObject::tr("BUT_OK") ); + return false; + } + + GEOM::GEOM_IInsertOperations_var aInsOp = GeometryGUI::GetGeomGUI()->GetGeomGen()->GetIInsertOperations( aStudy->StudyId() ); + if ( aInsOp->_is_nil() ) + return false; - switch(aState) - { - case 111 : // Import BREP - { - filtersList.append(tr("GEOM_MEN_IMPORT_BREP")); - filtersList.append(tr("GEOM_MEN_ALL_FILES")); - - file = QAD_FileDlg::getFileName(QAD_Application::getDesktop(), "", filtersList, tr("GEOM_MEN_IMPORT"), true); - if(!file.isEmpty()) { - QApplication::setOverrideCursor(Qt::waitCursor); - try { - aShape = myGeom->ImportBREP(file.latin1()); - } - catch(const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - } - break; - } - case 112 : // Import IGES - { - filtersList.append( tr("GEOM_MEN_IMPORT_IGES") ) ; - filtersList.append( tr("GEOM_MEN_ALL_FILES") ) ; - - file = QAD_FileDlg::getFileName(QAD_Application::getDesktop(), - "", - filtersList, - tr("GEOM_MEN_IMPORT"), - true); - if ( !file.isEmpty() ) { - QApplication::setOverrideCursor( Qt::waitCursor ); - try { - aShape = myGeom->ImportIGES( file.latin1() ); - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - } - break; - } - case 113 : // Import STEP - { - filtersList.append( tr("GEOM_MEN_IMPORT_STEP") ) ; - filtersList.append( tr("GEOM_MEN_ALL_FILES") ) ; - - file = QAD_FileDlg::getFileName(QAD_Application::getDesktop(), - "", - filtersList, - tr("GEOM_MEN_IMPORT"), - true); - if ( !file.isEmpty() ) { - QApplication::setOverrideCursor( Qt::waitCursor ); - try { - aShape = myGeom->ImportSTEP( file.latin1() ); - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - } - break; - } - } + GEOM::GEOM_Object_var anObj; + + // Obtain a list of available import formats + FilterMap aMap; + GEOM::string_array_var aFormats, aPatterns; + aInsOp->ImportTranslators( aFormats, aPatterns ); + for ( int i = 0, n = aFormats->length(); i < n; i++ ) + aMap.insert( (char*)aPatterns[i], (char*)aFormats[i] ); + + QString fileType; + + QString file = getFileName(QAD_Application::getDesktop(), "", aMap, tr("GEOM_MEN_IMPORT"), true, fileType ); + if( file.isEmpty() || fileType.isEmpty() ) + return false; - if ( !file.isEmpty() ) { + GEOM_Operation* anOp = new GEOM_Operation( aDoc, aInsOp.in() ); + try { + QAD_WaitCursor wc; QAD_Application::getDesktop()->putInfo( tr("GEOM_PRP_LOADING").arg(QAD_Tools::getFileNameFromPath( file )) ); - SALOMEDS::SComponent_var father = aStudy->FindComponent("GEOM"); - SALOMEDS::SObject_var fatherSF = aStudy->FindObjectID(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->entry()); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeName_var aName; - SALOMEDS::AttributePixMap_var aPixmap; - int aLocked = false; - if (father->_is_nil()) { - QAD_Operation* op = new SALOMEGUI_ImportOperation(QAD_Application::getDesktop()->getActiveStudy() ); - op->start(); - aLocked = aStudy->GetProperties()->IsLocked(); - if (aLocked) aStudy->GetProperties()->SetLocked(false); - father = aStudyBuilder->NewComponent("GEOM"); - anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributeName"); - aName = SALOMEDS::AttributeName::_narrow(anAttr); - // aName->SetValue( tr("GEOM_MEN_COMPONENT") ); - aName->SetValue(QAD_Application::getDesktop()->getComponentUserName( "GEOM" ) ); - anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributePixMap"); - aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); - aPixmap->SetPixMap( "ICON_OBJBROWSER_Geometry" ); - aStudyBuilder->DefineComponentInstance( father, myGeom ); - if (aLocked) aStudy->GetProperties()->SetLocked(true); - op->finish(); - } -// if (aLocked) return false; - father->ComponentIOR(myGeomGUI->GetFatherior()); + anOp->start(); - QString nameShape = QAD_Tools::getFileNameFromPath(file,false) + QString("_%1").arg(myGeomGUI->myNbGeom++); + anObj = aInsOp->Import( file.latin1(), fileType.latin1() ); - if(myGeomBase->Display(aShape, (char*)nameShape.latin1())) { - QAD_Application::getDesktop()->getActiveStudy()->setMessage( tr("GEOM_INF_LOADED").arg(QAD_Tools::getFileNameFromPath( file )) ); - QAD_Application::getDesktop()->putInfo( tr("GEOM_PRP_READY")); + if ( !anObj->_is_nil() && aInsOp->IsDone() ) { + anObj->SetName( GEOMBase::GetDefaultName( QObject::tr( "GEOM_IMPORT" ) ).latin1() ); + QString aPublishObjName = GEOMBase::GetDefaultName( QAD_Tools::getFileNameFromPath( file )); + GeometryGUI::GetGeomGUI()->GetGeomGen()->PublishInStudy( + aStudy, SALOMEDS::SObject::_nil(), anObj, aPublishObjName ); + + GEOM_Displayer().Display( anObj.in() ); + + anOp->finish(); } + else { + anOp->abort(); + wc.stop(); + QAD_MessageBox::error1( QAD_Application::getDesktop(), + QObject::tr( "GEOM_ERROR" ), + QObject::tr("GEOM_PRP_ABORT") + "\n" + QString( aInsOp->GetErrorCode() ), + QObject::tr("BUT_OK") ); + } + } + catch(const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + anOp->abort(); + return false; } - QApplication::restoreOverrideCursor(); + return true; } @@ -809,140 +471,62 @@ bool GEOMToolsGUI::Import(int aState) // function : Export // purpose : BRep, Iges, Step //===================================================================================== -bool GEOMToolsGUI::Export(int aState) +bool GEOMToolsGUI::Export() { SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument(); - SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); - - GEOM::GEOM_Shape_var aShape; - - static QString filters[] = { tr("GEOM_MEN_IMPORT_BREP"), - tr("GEOM_MEN_IMPORT_IGES"), - tr("GEOM_MEN_IMPORT_STEP") }; + GEOM::GEOM_IInsertOperations_var aInsOp = GeometryGUI::GetGeomGUI()->GetGeomGen()->GetIInsertOperations( aStudy->StudyId() ); + if ( aInsOp->_is_nil() ) + return false; + + // Obtain a list of available export formats + FilterMap aMap; + GEOM::string_array_var aFormats, aPatterns; + aInsOp->ExportTranslators( aFormats, aPatterns ); + for ( int i = 0, n = aFormats->length(); i < n; i++ ) + aMap.insert( (char*)aPatterns[i], (char*)aFormats[i] ); SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection()); SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); - switch (aState) - { - case 121 : - { - for(;It.More();It.Next()) { - QApplication::restoreOverrideCursor(); - Handle(SALOME_InteractiveObject) IObject = It.Value(); - Standard_Boolean found; - GEOM::GEOM_Shape_var aShape = myGeomBase->ConvertIOinGEOMShape(IObject, found); - // Handle(GEOM_AISShape) Shape = myGeomGUI->ConvertIOinGEOMAISShape(IObject, found, true); - if ( found ) { - QString file = QAD_FileDlg::getFileName(QAD_Application::getDesktop(), - QString( IObject->getName() ) + ".brep", - tr("GEOM_MEN_IMPORT_BREP"), - tr("GEOM_MEN_EXPORT"), - false); - if ( !file.isEmpty() && !aShape->_is_nil() ) { - QApplication::setOverrideCursor( Qt::waitCursor ); - // Standard_Boolean result = BRepTools::Write(Shape->Shape(), strdup(file.latin1()) ); - try { - myGeom->ExportBREP((char*)file.latin1(), aShape); - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - } - } - } - break; - } - case 122 : - { - for(;It.More();It.Next()) { - QApplication::restoreOverrideCursor(); - Handle(SALOME_InteractiveObject) IObject = It.Value(); - Standard_Boolean found; - GEOM::GEOM_Shape_var aShape = myGeomBase->ConvertIOinGEOMShape(IObject, found); - // Handle(GEOM_AISShape) Shape = myGeomGUI->ConvertIOinGEOMAISShape(IObject, found, true); - if ( found ) { - QString file = QAD_FileDlg::getFileName(QAD_Application::getDesktop(), - QString( IObject->getName() ) + ".igs", - tr("GEOM_MEN_IMPORT_IGES"), - tr("GEOM_MEN_EXPORT"), - false); - if ( !file.isEmpty() && !aShape->_is_nil() ) { - QApplication::setOverrideCursor( Qt::waitCursor ); - try { - myGeom->ExportIGES((char*)file.latin1(), aShape); - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } -// //VRV: OCC 4.0 migration -// IGESControl_Controller::Init(); -// IGESControl_Writer ICW (Interface_Static::CVal("XSTEP.iges.unit"), -// Interface_Static::IVal("XSTEP.iges.writebrep.mode")); -// //VRV: OCC 4.0 migration - -// ICW.AddShape (Shape->Shape()); -// ICW.ComputeModel(); -// Standard_Boolean result = ICW.Write( strdup(file.latin1()) ); - } - } - } - break; - } + for(;It.More();It.Next()) { + Handle(SALOME_InteractiveObject) IObject = It.Value(); + Standard_Boolean found; + GEOM::GEOM_Object_var anObj = GEOMBase::ConvertIOinGEOMObject(IObject, found); - case 123 : - { -// bool test = false ; -// IFSelect_ReturnStatus status ; -// //VRV: OCC 4.0 migration -// STEPControl_Writer aWriter; -// //VRV: OCC 4.0 migration - QString file; - - for( ; It.More(); It.Next() ) { -// GEOM::GEOM_Shape_var aShape = myGeomBase->ConvertIOinGEOMShape(IObject, found); - QApplication::restoreOverrideCursor(); - Handle(SALOME_InteractiveObject) IObject = It.Value(); - Standard_Boolean found; - GEOM::GEOM_Shape_var aShape = myGeomBase->ConvertIOinGEOMShape(IObject, found); - // Handle(GEOM_AISShape) Shape = myGeomBase->ConvertIOinGEOMAISShape(IObject, found, true); - if ( found ) { - file = QAD_FileDlg::getFileName(QAD_Application::getDesktop(), - QString( IObject->getName() ) + ".stp", - tr("GEOM_MEN_IMPORT_STEP"), - tr("GEOM_MEN_EXPORT"), - false); - if ( !file.isEmpty() && !aShape->_is_nil() ) { - - QApplication::setOverrideCursor( Qt::waitCursor ) ; - try { - myGeom->ExportSTEP((char*)file.latin1(), aShape); - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } -// //VRV: OCC 4.0 migration -// status = aWriter.Transfer( Shape->Shape(), STEPControl_ManifoldSolidBrep ) ; -// //VRV: OCC 4.0 migration -// test = true ; -// if ( status != IFSelect_RetDone ) { -// QApplication::restoreOverrideCursor() ; -// return false ; -// } - } - } - } -// if(test) { -// status = aWriter.Write( strdup(file.latin1()) ) ; -// QApplication::restoreOverrideCursor() ; -// return status ; -// } - break; - } + if ( !found || anObj->_is_nil() ) + continue; + + QString fileType; + QString file = getFileName(QAD_Application::getDesktop(), + QString( IObject->getName() ), + aMap, + tr("GEOM_MEN_EXPORT"), + false, + fileType); + + // User has pressed "Cancel" --> stop the operation + if ( file.isEmpty() || fileType.isEmpty() ) + return false; + // Standard_Boolean result = BRepTools::Write(Shape->Shape(), strdup(file.latin1()) ); + try { + QAD_WaitCursor wc; + aInsOp->Export( anObj, file, fileType.latin1() ); + if ( !aInsOp->IsDone() ) { + wc.stop(); + QAD_MessageBox::error1( QAD_Application::getDesktop(), + QObject::tr( "GEOM_ERROR" ), + QObject::tr("GEOM_PRP_ABORT") + "\n" + QString( aInsOp->GetErrorCode() ), + QObject::tr("BUT_OK") ); + return false; + } + } + catch (const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); } - QApplication::restoreOverrideCursor() ; - return true; + } + + return true; } @@ -951,6 +535,8 @@ bool GEOMToolsGUI::Export(int aState) //===================================================================================== extern "C" { - bool OnGUIEvent(int theCommandID, QAD_Desktop* parent) - {return GEOMToolsGUI::OnGUIEvent(theCommandID, parent);} + GEOMGUI* GetLibGUI() + { + return GEOMToolsGUI::GetGEOMToolsGUI(); + } } diff --git a/src/GEOMToolsGUI/GEOMToolsGUI.h b/src/GEOMToolsGUI/GEOMToolsGUI.h index 8296fdb69..4927db5d5 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI.h +++ b/src/GEOMToolsGUI/GEOMToolsGUI.h @@ -21,41 +21,56 @@ // // // -// File : GEOMBase_Tools.h +// File : GEOMToolsGUI.h // Author : Damien COQUERET // Module : GEOM -// $Header: +// $Header$ #ifndef GEOMTOOLSGUI_H #define GEOMTOOLSGUI_H -#include "GEOMBase.h" +#include "GEOMGUI.h" //================================================================================= -// class : GEOMBase_Tools +// class : GEOMToolsGUI // purpose : //================================================================================= -class GEOMToolsGUI : public QObject +class GEOMToolsGUI : public GEOMGUI { - Q_OBJECT /* for QT compatibility */ +protected: + GEOMToolsGUI(); // hide constructor to avoid direct creation public : - GEOMToolsGUI(); ~GEOMToolsGUI(); - static bool OnGUIEvent(int theCommandID, QAD_Desktop* parent); + // Get the only GEOMToolsGUI object + static GEOMToolsGUI* GetGEOMToolsGUI(); + bool OnGUIEvent(int theCommandID, QAD_Desktop* parent); + +private: /* Import and export topology methods */ - bool Import(int aState); - bool Export(int aState); + bool Import(); + bool Export(); void OnEditCopy(); void OnEditDelete(); - GEOMBase* myGeomBase; - GEOMContext* myGeomGUI; - GEOM::GEOM_Gen_var myGeom; /* Current Geom Component */ + void OnSettingsColor(); + void OnSettingsIsos(); + void OnSettingsStep(); + void OnRename(); + void OnCheckGeometry(); + void OnLoadScript(); + + // Popup commands + void OnColor(); + void OnTransparency(); + void OnNbIsos(); + void OnOpen(); +private: + static GEOMToolsGUI* myGUIObject; // the only GEOMToolsGUI object }; #endif diff --git a/src/GEOMToolsGUI/GEOMToolsGUI_1.cxx b/src/GEOMToolsGUI/GEOMToolsGUI_1.cxx new file mode 100644 index 000000000..499106347 --- /dev/null +++ b/src/GEOMToolsGUI/GEOMToolsGUI_1.cxx @@ -0,0 +1,451 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2004 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org or email : webmaster.salome@opencascade.org +// +// +// +// File : GEOMToolsGUI_1.cxx +// Author : Sergey ANIKIN +// Module : GEOM +// $Header$ + +#include "GEOMToolsGUI.h" +#include "GeometryGUI.h" +#include "GEOM_Actor.h" +#include "GEOMBase.h" + +#include "QAD_Desktop.h" +#include "QAD_Config.h" +#include "QAD_FileDlg.h" +#include "QAD_PyEditor.h" +#include "QAD_RightFrame.h" +#include "QAD_MessageBox.h" +#include "SALOMEGUI_NameDlg.h" + +#include "OCCViewer_Viewer3d.h" +#include "OCCViewer_ViewFrame.h" +#include "VTKViewer_ViewFrame.h" +#include "VTKViewer_RenderWindowInteractor.h" + +#include "SALOME_ListIO.hxx" +#include "SALOME_ListIteratorOfListIO.hxx" + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "GEOMToolsGUI_NbIsosDlg.h" // Method ISOS adjustement +#include "GEOMToolsGUI_TransparencyDlg.h" // Method TRANSPARENCY adjustement + +#include "utilities.h" + +using namespace std; + +void GEOMToolsGUI::OnSettingsColor() +{ + + QString aSCr = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorRed"); + QString aSCg = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorGreen"); + QString aSCb = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorBlue"); + QColor anInitColor; + if(!aSCr.isEmpty() && !aSCg.isEmpty() && !aSCb.isEmpty()) { + anInitColor = QColor (aSCr.toInt(), aSCg.toInt(), aSCb.toInt()); + } + else { + Quantity_Color aDefColor = Quantity_Color(); + anInitColor = + QColor ((int)( aDefColor.Red() * 255.0 ), (int)( aDefColor.Green() * 255.0 ), (int)( aDefColor.Blue() * 255.0 ) ); + } + + QColor aDialogColor = QColorDialog::getColor(anInitColor, QAD_Application::getDesktop()); + if(aDialogColor.isValid()) { + QApplication::setOverrideCursor(Qt::waitCursor); + + if( QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_OCC && + QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK ) + MESSAGE("Settings Color is not supported for current Viewer"); + + QAD_CONFIG->addSetting("Geometry:SettingsShadingColorRed", aDialogColor.red()); + QAD_CONFIG->addSetting("Geometry:SettingsShadingColorGreen", aDialogColor.green()); + QAD_CONFIG->addSetting("Geometry:SettingsShadingColorBlue", aDialogColor.blue()); + QApplication::restoreOverrideCursor(); + } +} + +void GEOMToolsGUI::OnSettingsIsos() +{ + if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC) + return; + + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); + + QString IsoU = QAD_CONFIG->getSetting("Geometry:SettingsIsoU"); + QString IsoV = QAD_CONFIG->getSetting("Geometry:SettingsIsoV"); + + if(!IsoU.isEmpty()) + ic->DefaultDrawer()->UIsoAspect()->SetNumber(IsoU.toInt()); + else + IsoU = "1"; + if (!IsoV.isEmpty()) + ic->DefaultDrawer()->VIsoAspect()->SetNumber(IsoV.toInt()); + else + IsoV = "1"; + + GEOMBase_NbIsosDlg* NbIsosDlg = new GEOMBase_NbIsosDlg(QAD_Application::getDesktop(), tr("GEOM_MEN_ISOS"), TRUE); + int UIso = IsoU.toInt(); + int VIso = IsoV.toInt(); + + NbIsosDlg->SpinBoxU->setValue(UIso); + NbIsosDlg->SpinBoxV->setValue(VIso); + + if(NbIsosDlg->exec()) { + UIso = NbIsosDlg->SpinBoxU->text().toInt(); + VIso = NbIsosDlg->SpinBoxV->text().toInt(); + + ic->DefaultDrawer()->UIsoAspect()->SetNumber(UIso); + ic->DefaultDrawer()->VIsoAspect()->SetNumber(VIso); + QAD_CONFIG->addSetting("Geometry:SettingsIsoU", NbIsosDlg->SpinBoxU->text()); /* text format */ + QAD_CONFIG->addSetting("Geometry:SettingsIsoV", NbIsosDlg->SpinBoxV->text()); /* text format */ + } +} + +void GEOMToolsGUI::OnSettingsStep() +{ + QString step = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep"); + if(step.isEmpty()) + step = "100.0"; + + Standard_Boolean res = false; + double dd = GEOMBase::Parameter(res, QString("%1").arg(step), tr("GEOM_MEN_STEP_LABEL"), tr("GEOM_STEP_TITLE"), 0.001, 10000.0, 3); + if(res) { + QAD_CONFIG->addSetting("Geometry:SettingsGeomStep", QString("%1").arg(dd)); + + /* Emit signal to GeometryGUI_SpinBoxes */ + GeometryGUI::GetGeomGUI()->EmitSignalDefaultStepValueChanged(dd); + } + else + QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_ABORT")); +} + +void GEOMToolsGUI::OnRename() +{ + SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection()); + SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument(); + + bool aLocked = aStudy->GetProperties()->IsLocked(); + if ( aLocked ) { + QAD_MessageBox::warn1 ( (QWidget*)QAD_Application::getDesktop(), + QObject::tr("WRN_WARNING"), + QObject::tr("WRN_STUDY_LOCKED"), + QObject::tr("BUT_OK") ); + return; + } + + SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); + for(; It.More(); It.Next()) { + Handle(SALOME_InteractiveObject) IObject = It.Value(); + + SALOMEDS::SObject_var obj = aStudy->FindObjectID(IObject->getEntry()); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + if(!obj->_is_nil()) { + if(obj->FindAttribute(anAttr, "AttributeName")) { + aName = SALOMEDS::AttributeName::_narrow(anAttr); + + QString nm = QString(aName->Value()); + nm = SALOMEGUI_NameDlg::getName(QAD_Application::getDesktop(), nm); + if(!nm.isEmpty()) { + QApplication::setOverrideCursor(Qt::waitCursor); + QAD_Application::getDesktop()->getActiveStudy()->renameIObject(IObject, nm); + QApplication::restoreOverrideCursor(); + } + } + } + } +} + +void GEOMToolsGUI::OnCheckGeometry() +{ + QAD_PyEditor* PyEditor = QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getPyEditor(); + PyEditor->setText("from GEOM_usinggeom import *\n"); + PyEditor->handleReturn(); +} + +void GEOMToolsGUI::OnLoadScript() +{ + SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument(); + bool aLocked = aStudy->GetProperties()->IsLocked(); + if ( aLocked ) { + QAD_MessageBox::warn1 ( (QWidget*)QAD_Application::getDesktop(), + QObject::tr("WRN_WARNING"), + QObject::tr("WRN_STUDY_LOCKED"), + QObject::tr("BUT_OK") ); + return; + } + + QStringList filtersList; + filtersList.append(tr("GEOM_MEN_LOAD_SCRIPT")); + filtersList.append(tr("GEOM_MEN_ALL_FILES")); + + QString aFile = QAD_FileDlg::getFileName(QAD_Application::getDesktop(), "", filtersList, tr("GEOM_MEN_IMPORT"), true); + if(!aFile.isEmpty()) { + QFileInfo file = aFile; + QApplication::setOverrideCursor(Qt::waitCursor); + QAD_PyEditor* PyEditor = QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getPyEditor(); + + QStringList aTextList = QStringList::split(".", file.fileName()); + + PyEditor->setText("import geompy; geompy.addPath('" + file.dirPath() + "'); from " + aTextList.first() + " import *\n" ); + PyEditor->handleReturn(); + } + QApplication::restoreOverrideCursor(); +} + +void GEOMToolsGUI::OnColor() +{ + SALOME_Selection* Sel = SALOME_Selection::Selection( + QAD_Application::getDesktop()->getActiveStudy()->getSelection() ); + + if ( QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) + { + VTKViewer_RenderWindowInteractor* myRenderInter = + ( (VTKViewer_ViewFrame*)QAD_Application::getDesktop()-> + getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); + + SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); + Handle(SALOME_InteractiveObject) FirstIOS = Sel->firstIObject(); + if ( !FirstIOS.IsNull() ) + { + QColor initcolor = myRenderInter->GetColor(FirstIOS); + QColor c = QColorDialog::getColor( initcolor, QAD_Application::getDesktop() ); + + if ( c.isValid() ) + { + QApplication::setOverrideCursor( Qt::waitCursor ); + for ( ;It.More();It.Next() ) + { + Handle(SALOME_InteractiveObject) IOS = It.Value(); + myRenderInter->SetColor(IOS,c); + } + } + QApplication::restoreOverrideCursor(); + } + } + else if( QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) + { + Handle(AIS_InteractiveObject) anIO = GEOMBase::GetAIS( Sel->firstIObject() ); + if ( !anIO.IsNull() ) + { + Quantity_Color aColor; + anIO->Color( aColor ); + + QColor qColor = QColorDialog::getColor( QColor( (int)( aColor.Red() * 255.0 ), + (int)( aColor.Green() * 255.0 ), + (int)( aColor.Blue() * 255.0 ) ), + QAD_Application::getDesktop()); + + if ( qColor.isValid() ) + { + aColor = Quantity_Color( qColor.red() / 255., + qColor.green() / 255., + qColor.blue() / 255., + Quantity_TOC_RGB ); + + QApplication::setOverrideCursor( Qt::waitCursor ); + + SALOME_ListIteratorOfListIO anIter ( Sel->StoredIObjects() ); + for( ;anIter.More();anIter.Next() ) + { + Handle(SALOME_InteractiveObject) IObject = anIter.Value(); + Handle(AIS_InteractiveObject) anIO = GEOMBase::GetAIS( IObject, true ); + if ( !anIO.IsNull() ) + { + anIO->SetColor( aColor ); + + if ( anIO->IsKind( STANDARD_TYPE(GEOM_AISShape) ) ) + Handle(GEOM_AISShape)::DownCast( anIO )->SetShadingColor( aColor ); + + anIO->Redisplay( Standard_True ); + } + } + } + } + } + + QApplication::restoreOverrideCursor(); +} + +void GEOMToolsGUI::OnTransparency() +{ + Handle(AIS_InteractiveContext) ic; + SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection()); + if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + ic = v3d->getAISContext(); + } + new GEOMBase_TransparencyDlg(QAD_Application::getDesktop(), "", Sel, ic); +} + +void GEOMToolsGUI::OnNbIsos() +{ + if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC) + return; + + OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); + + ic->InitCurrent(); + if(ic->MoreCurrent()) { + Handle(GEOM_AISShape) CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current()); + Handle(AIS_Drawer) CurDrawer = CurObject->Attributes(); + + int UIso = CurDrawer->UIsoAspect()->Number(); + int VIso = CurDrawer->VIsoAspect()->Number(); + + GEOMBase_NbIsosDlg * NbIsosDlg = + new GEOMBase_NbIsosDlg(QAD_Application::getDesktop(), tr("GEOM_MEN_ISOS"), TRUE); + + NbIsosDlg->SpinBoxU->setValue( UIso ); + NbIsosDlg->SpinBoxV->setValue( VIso ); + + if(NbIsosDlg->exec()) { + QApplication::setOverrideCursor(Qt::waitCursor); + for(; ic->MoreCurrent(); ic->NextCurrent()) { + CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current()); + Handle(AIS_Drawer) CurDrawer = CurObject->Attributes(); + + int nbUIso = NbIsosDlg->SpinBoxU->text().toInt(); + int nbVIso = NbIsosDlg->SpinBoxV->text().toInt(); + + CurDrawer->SetUIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 0.5 , nbUIso) ); + CurDrawer->SetVIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 0.5 , nbVIso) ); + + ic->SetLocalAttributes(CurObject, CurDrawer); + ic->Redisplay(CurObject); + } + } + } + QApplication::restoreOverrideCursor(); +} + +void GEOMToolsGUI::OnOpen() +{ + SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection()); + SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument(); + + SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); + Handle(SALOME_InteractiveObject) anIObject; + for(;It.More();It.Next()) { + anIObject = It.Value(); + SALOMEDS::SObject_var obj = aStudy->FindObjectID(anIObject->getEntry()); + SALOMEDS::AttributePersistentRef_var aPersist; + SALOMEDS::AttributeIOR_var anIOR; + if(!obj->_is_nil()) { + // this SObject may be GEOM module root SObject + SALOMEDS::ChildIterator_var anIter = aStudy->NewChildIterator(obj); + SALOMEDS::GenericAttribute_var anAttr; + bool useSubItems = false; + while (anIter->More() && !useSubItems) { + SALOMEDS::SObject_var subobj = anIter->Value(); + if (subobj->FindAttribute(anAttr, "AttributePersistentRef")) { + useSubItems = true; + obj = subobj; + } + else + anIter->Next(); + } + obj->FindAttribute(anAttr, "AttributePersistentRef"); + + while(useSubItems?anIter->More():!anAttr->_is_nil()) { + if(!obj->FindAttribute(anAttr, "AttributeIOR") && + obj->FindAttribute(anAttr, "AttributePersistentRef")) { + SALOMEDS::SComponent_var FComp = obj->GetFatherComponent(); + if (!CORBA::is_nil(FComp)) { + if (FComp->FindAttribute(anAttr, "AttributeName")) { + SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr); + QString compName = QAD_Application::getDesktop()->getComponentName(aName->Value()); + // parent->loadComponentData(parent->getComponentName(aName->Value())); + Engines::Component_var comp ; + if ( compName.compare("SUPERV") == 0 ) { + comp = QAD_Application::getDesktop()->getEngine( "SuperVisionContainer", compName) ; + } + else { + comp = QAD_Application::getDesktop()->getEngine( "FactoryServer", compName); + if ( comp->_is_nil() ) + comp = QAD_Application::getDesktop()->getEngine( "FactoryServerPy", compName); + } + + if (!CORBA::is_nil(comp)) { + SALOMEDS::Driver_var driver = SALOMEDS::Driver::_narrow(comp); + if (!CORBA::is_nil(driver)) { + SALOMEDS::StudyBuilder_var B = aStudy->NewBuilder(); + if (!CORBA::is_nil(B)) { + B->LoadWith(FComp,driver); + } else { + return; + } + } + else { + MESSAGE("loadComponentData(): Driver is null"); + return; + } + } + else { + MESSAGE("loadComponentData(): Engine is null"); + return; + } + // // load + // Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer","GEOM"); + // if (!CORBA::is_nil(comp)) { + // SALOMEDS::Driver_var driver = SALOMEDS::Driver::_narrow(comp); + // SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); + // SALOMEDS::SComponent_var SC = aStudy->FindComponent("GEOM"); + // if (!CORBA::is_nil(SC)) + // aStudyBuilder->LoadWith(SC,driver); + } + } + else { + MESSAGE("Component is null"); + } + } + if(useSubItems) { + anIter->Next(); + obj = anIter->Value(); + } + else + anAttr = SALOMEDS::GenericAttribute::_nil(); + } + } + } +} diff --git a/src/GEOMToolsGUI/GEOMToolsGUI_NbIsosDlg.cxx b/src/GEOMToolsGUI/GEOMToolsGUI_NbIsosDlg.cxx index 842332015..5ef80f650 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI_NbIsosDlg.cxx +++ b/src/GEOMToolsGUI/GEOMToolsGUI_NbIsosDlg.cxx @@ -21,7 +21,7 @@ // // // -// File : GEOMToolsGUI_NbIsosDlg.cxx +// File : GEOMBase_NbIsosDlg.cxx // Author : // Module : GEOM // $Header: @@ -37,17 +37,17 @@ using namespace std; #include //================================================================================= -// class : GEOMToolsGUI_NbIsosDlg() -// purpose : Constructs a GEOMToolsGUI_NbIsosDlg which is a child of 'parent', with the +// class : GEOMBase_NbIsosDlg() +// purpose : Constructs a GEOMBase_NbIsosDlg 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. //================================================================================= -GEOMToolsGUI_NbIsosDlg::GEOMToolsGUI_NbIsosDlg(QWidget* parent, const char* name, bool modal, WFlags fl) +GEOMBase_NbIsosDlg::GEOMBase_NbIsosDlg(QWidget* parent, const char* name, bool modal, WFlags fl) :QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) { if( !name ) - setName("GEOMToolsGUI_NbIsosDlg"); + setName("GEOMBase_NbIsosDlg"); setCaption(name); setSizeGripEnabled(TRUE); QGridLayout* MyDialogLayout = new QGridLayout(this); @@ -122,10 +122,10 @@ GEOMToolsGUI_NbIsosDlg::GEOMToolsGUI_NbIsosDlg(QWidget* parent, const char* name //================================================================================= -// function : ~GEOMToolsGUI_NbIsosDlg() +// function : ~GEOMBase_NbIsosDlg() // purpose : Destroys the object and frees any allocated resources //================================================================================= -GEOMToolsGUI_NbIsosDlg::~GEOMToolsGUI_NbIsosDlg() +GEOMBase_NbIsosDlg::~GEOMBase_NbIsosDlg() { // no need to delete child widgets, Qt does it all for us } diff --git a/src/GEOMToolsGUI/GEOMToolsGUI_NbIsosDlg.h b/src/GEOMToolsGUI/GEOMToolsGUI_NbIsosDlg.h index 07e471200..48c70c563 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI_NbIsosDlg.h +++ b/src/GEOMToolsGUI/GEOMToolsGUI_NbIsosDlg.h @@ -21,13 +21,13 @@ // // // -// File : GEOMToolsGUI_NbIsosDlg.h +// File : GEOMBase_NbIsosDlg.h // Author : // Module : GEOM // $Header: -#ifndef GEOMTOOLSGUI_NBISOSDLG_H -#define GEOMTOOLSGUI_NBISOSDLG_H +#ifndef GEOMBASE_NBISOSDLG_H +#define GEOMBASE_NBISOSDLG_H #include @@ -36,16 +36,16 @@ class QSpinBox; class QPushButton; //================================================================================= -// class : GEOMToolsGUI_NbIsosDlg +// class : GEOMBase_NbIsosDlg // purpose : //================================================================================= -class GEOMToolsGUI_NbIsosDlg : public QDialog +class GEOMBase_NbIsosDlg : public QDialog { Q_OBJECT public: - GEOMToolsGUI_NbIsosDlg(QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0); - ~GEOMToolsGUI_NbIsosDlg(); + GEOMBase_NbIsosDlg(QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0); + ~GEOMBase_NbIsosDlg(); QPushButton* buttonOk; QPushButton* buttonCancel; @@ -56,4 +56,4 @@ public: }; -#endif // GEOMTOOLSGUI_NBISOSDLG_H +#endif // GEOMETRYGUI_NBISOSDLG_H diff --git a/src/GEOMToolsGUI/GEOMToolsGUI_TransparencyDlg.cxx b/src/GEOMToolsGUI/GEOMToolsGUI_TransparencyDlg.cxx index 12beaaaa5..f681d13c7 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI_TransparencyDlg.cxx +++ b/src/GEOMToolsGUI/GEOMToolsGUI_TransparencyDlg.cxx @@ -21,16 +21,18 @@ // // // -// File : GEOMToolsGUI_TransparencyDlg.cxx +// File : GEOMBase_TransparencyDlg.cxx // Author : Lucien PIGNOLONI // Module : GEOM using namespace std; #include "GEOMToolsGUI_TransparencyDlg.h" +#include "QAD_Desktop.h" #include "QAD_RightFrame.h" #include "SALOME_ListIteratorOfListIO.hxx" #include "OCCViewer_Viewer3d.h" +#include "OCCViewer_ViewFrame.h" #include #include @@ -48,24 +50,24 @@ using namespace std; #include "VTKViewer_RenderWindowInteractor.h" //================================================================================= -// class : GEOMToolsGUI_TransparencyDlg() +// class : GEOMBase_TransparencyDlg() // purpose : Constructs a GEOMBase_SUBSHAPE which is a child of 'parent', with the // name 'name' and widget flags set to 'f'. // // : WARNING : this dialog is modal ! // //================================================================================= -GEOMToolsGUI_TransparencyDlg::GEOMToolsGUI_TransparencyDlg(QWidget* parent, const char* name, SALOME_Selection* Sel, const Handle(AIS_InteractiveContext)& ic, bool modal, WFlags fl) +GEOMBase_TransparencyDlg::GEOMBase_TransparencyDlg(QWidget* parent, const char* name, SALOME_Selection* Sel, const Handle(AIS_InteractiveContext)& ic, bool modal, WFlags fl) :QDialog(parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) { if(!name) - setName("GEOMToolsGUI_TransparencyDlg"); + setName("GEOMBase_TransparencyDlg"); resize(152, 107); setCaption(tr("GEOM_TRANSPARENCY_TITLE")); setSizeGripEnabled(TRUE); - GEOMToolsGUI_TransparencyDlgLayout = new QGridLayout(this); - GEOMToolsGUI_TransparencyDlgLayout->setSpacing(6); - GEOMToolsGUI_TransparencyDlgLayout->setMargin(11); + GEOMBase_TransparencyDlgLayout = new QGridLayout(this); + GEOMBase_TransparencyDlgLayout->setSpacing(6); + GEOMBase_TransparencyDlgLayout->setMargin(11); /*************************************************************************/ QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" ); @@ -112,11 +114,10 @@ GEOMToolsGUI_TransparencyDlg::GEOMToolsGUI_TransparencyDlg(QWidget* parent, cons GroupC1Layout->addMultiCellWidget( Slider1, 1, 1, 0, 2 ); /*************************************************************************/ - GEOMToolsGUI_TransparencyDlgLayout->addWidget(GroupC1, 0, 0); - GEOMToolsGUI_TransparencyDlgLayout->addWidget(GroupButtons, 1, 0); + GEOMBase_TransparencyDlgLayout->addWidget(GroupC1, 0, 0); + GEOMBase_TransparencyDlgLayout->addWidget(GroupButtons, 1, 0); /* Initialisations */ - this->myGeomGUI = GEOMContext::GetGeomGUI(); this->myGeomBase = new GEOMBase(); this->myIc = ic; this->mySel = Sel; @@ -133,18 +134,18 @@ GEOMToolsGUI_TransparencyDlg::GEOMToolsGUI_TransparencyDlg(QWidget* parent, cons connect(Slider1, SIGNAL(valueChanged(int)), this, SLOT(ValueHasChanged(int))); /* Move widget on the botton right corner of main widget */ -// int x, y ; -// myGeomBase->DefineDlgPosition(this, x, y); -// this->move(x, y) ; + int x, y ; + myGeomBase->DefineDlgPosition(this, x, y); + this->move(x, y) ; this->show() ; /* Displays this Dialog */ } //================================================================================= -// function : ~GEOMToolsGUI_TransparencyDlg() +// function : ~GEOMBase_TransparencyDlg() // purpose : //================================================================================= -GEOMToolsGUI_TransparencyDlg::~GEOMToolsGUI_TransparencyDlg() +GEOMBase_TransparencyDlg::~GEOMBase_TransparencyDlg() { // no need to delete child widgets, Qt does it all for us } @@ -154,7 +155,7 @@ GEOMToolsGUI_TransparencyDlg::~GEOMToolsGUI_TransparencyDlg() // function : ClickOnOk() // purpose : //======================================================================= -void GEOMToolsGUI_TransparencyDlg::ClickOnOk() +void GEOMBase_TransparencyDlg::ClickOnOk() { accept(); return; @@ -165,7 +166,7 @@ void GEOMToolsGUI_TransparencyDlg::ClickOnOk() // function : ClickOnClose() // purpose : //======================================================================= -void GEOMToolsGUI_TransparencyDlg::ClickOnClose() +void GEOMBase_TransparencyDlg::ClickOnClose() { accept(); return; @@ -177,7 +178,7 @@ void GEOMToolsGUI_TransparencyDlg::ClickOnClose() // purpose : Called when value of slider change // : or the first time as initilisation //================================================================================= -void GEOMToolsGUI_TransparencyDlg::ValueHasChanged(int newValue) +void GEOMBase_TransparencyDlg::ValueHasChanged(int newValue) { if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { // VTK @@ -191,6 +192,7 @@ void GEOMToolsGUI_TransparencyDlg::ValueHasChanged(int newValue) this->myFirstInit = false; float transp = (myRenderInter->GetTransparency(FirstIOS))*10.0; this->Slider1->setValue(int(transp)); + return; } } @@ -199,6 +201,7 @@ void GEOMToolsGUI_TransparencyDlg::ValueHasChanged(int newValue) Handle(SALOME_InteractiveObject) IOS = It.Value(); myRenderInter->SetTransparency(IOS, newValue/10.0); } + myRenderInter->Render(); QApplication::restoreOverrideCursor(); } diff --git a/src/GEOMToolsGUI/GEOMToolsGUI_TransparencyDlg.h b/src/GEOMToolsGUI/GEOMToolsGUI_TransparencyDlg.h index 8ae122d1b..94889f6ef 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI_TransparencyDlg.h +++ b/src/GEOMToolsGUI/GEOMToolsGUI_TransparencyDlg.h @@ -21,7 +21,7 @@ // // // -// File : GEOMToolsGUI_TransparencyDlg.h +// File : GEOMBase_TransparencyDlg.h // Author : Lucien PIGNOLONI // Module : GEOM // $Header$ @@ -51,28 +51,27 @@ class QSlider; //================================================================================= -// class : GEOMToolsGUI_TransparencyDlg +// class : GEOMBase_TransparencyDlg // purpose : // : WARNING : that is a MODAL dialog. //================================================================================= -class GEOMToolsGUI_TransparencyDlg : public QDialog +class GEOMBase_TransparencyDlg : public QDialog { Q_OBJECT public: - GEOMToolsGUI_TransparencyDlg( QWidget* parent = 0, + GEOMBase_TransparencyDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, const Handle(AIS_InteractiveContext)& ic = 0, bool modal = TRUE, WFlags fl = 0 ); - ~GEOMToolsGUI_TransparencyDlg(); + ~GEOMBase_TransparencyDlg(); private : - GEOMContext* myGeomGUI ; /* Current GeomGUI object */ - GEOMBase* myGeomBase ; /* Current GeomGUI object */ + GEOMBase* myGeomBase ; /* Current GeomGUI object */ bool myFirstInit ; /* Inform for the first init */ SALOME_Selection* mySel; /* User selection */ Handle(AIS_InteractiveContext) myIc ; /* Interactive context */ @@ -89,7 +88,7 @@ public slots: void ValueHasChanged( int newValue ) ; protected: - QGridLayout* GEOMToolsGUI_TransparencyDlgLayout; + QGridLayout* GEOMBase_TransparencyDlgLayout; QHBoxLayout* Layout1; QHBoxLayout* Layout2; }; diff --git a/src/GEOMToolsGUI/Makefile.in b/src/GEOMToolsGUI/Makefile.in index 95cc8b8f8..0614a6d83 100644 --- a/src/GEOMToolsGUI/Makefile.in +++ b/src/GEOMToolsGUI/Makefile.in @@ -41,6 +41,7 @@ LIB = libGEOMToolsGUI.la EXPORT_HEADERS= LIB_SRC = GEOMToolsGUI.cxx \ + GEOMToolsGUI_1.cxx \ GEOMToolsGUI_NbIsosDlg.cxx \ GEOMToolsGUI_TransparencyDlg.cxx @@ -49,7 +50,7 @@ LIB_MOC = \ GEOMToolsGUI_NbIsosDlg.h \ GEOMToolsGUI_TransparencyDlg.h -LIB_CLIENT_IDL = SALOMEDS_Attributes.idl +LIB_CLIENT_IDL = SALOMEDS_Attributes.idl SALOME_GenericObj.idl LIB_SERVER_IDL = diff --git a/src/GEOM_I/GEOM_Gen_i.cc b/src/GEOM_I/GEOM_Gen_i.cc new file mode 100644 index 000000000..f87278d4a --- /dev/null +++ b/src/GEOM_I/GEOM_Gen_i.cc @@ -0,0 +1,839 @@ +using namespace std; + +#include "GEOM_Gen_i.hh" +#include "GEOM_Object_i.hh" +#include "SALOMEDS_Tool.hxx" + +#include "Utils_CorbaException.hxx" +#include "OpUtil.hxx" +#include "Utils_ExceptHandlers.hxx" +#include "utilities.h" + +#include "GEOM_Object_i.hh" +#include "GEOM_Object.hxx" +#include "GEOM_Function.hxx" +#include "GEOMImpl_Types.hxx" +#include "GEOMImpl_CopyDriver.hxx" + +// Cascade headers +#include +#include +#include +#include +#include +#include +#include + +//============================================================================ +// function : GEOM_Gen_i() +// purpose : constructor to be called for servant creation. +//============================================================================ +GEOM_Gen_i::GEOM_Gen_i(CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + PortableServer::ObjectId * contId, + const char *instanceName, + const char *interfaceName) : + Engines_Component_i(orb, poa, contId, instanceName, interfaceName) +{ + _thisObj = this ; + _id = _poa->activate_object(_thisObj); + name_service = new SALOME_NamingService(_orb); + + _impl = new ::GEOMImpl_Gen; + +} + + + +//============================================================================ +// function : ~GEOM_Gen_i() +// purpose : destructor +//============================================================================ +GEOM_Gen_i::~GEOM_Gen_i() { + delete name_service; + delete _impl; +} + + +//============================================================================ +// function : IORToLocalPersistentID() +// purpose : +//============================================================================ +char* GEOM_Gen_i::IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject, + const char* IORString, + CORBA::Boolean isMultiFile, + CORBA::Boolean isASCII) +{ + GEOM::GEOM_Object_var anObject = GEOM::GEOM_Object::_narrow(_orb->string_to_object(IORString)); + if (!CORBA::is_nil(anObject)) { + return strdup(anObject->GetEntry()); + } + return 0; +} + + +//============================================================================ +// function : LocalPersistentIDToIOR() +// purpose : Create/Load CORBA object from a persistent ref (an entry) +// : Used when a study is loaded +// : The IOR (IORName) of object created is returned +//============================================================================ +char* GEOM_Gen_i::LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject, + const char* aLocalPersistentID, + CORBA::Boolean isMultiFile, + CORBA::Boolean isASCII) +{ + SALOMEDS::Study_var aStudy = theSObject->GetStudy(); + + Handle(GEOM_Object) anObject = _impl->GetObject(aStudy->StudyId(), const_cast(aLocalPersistentID)); + TCollection_AsciiString anEntry; + TDF_Tool::Entry(anObject->GetEntry(), anEntry); + GEOM::GEOM_Object_var obj = GetObject(anObject->GetDocID(), anEntry.ToCString()); + + CORBA::String_var aPersRefString = _orb->object_to_string(obj); + return strdup(aPersRefString); +} + +//============================================================================ +// function : CanPublishInStudy +// purpose : +//============================================================================ +bool GEOM_Gen_i::CanPublishInStudy(CORBA::Object_ptr theIOR) +{ + GEOM::GEOM_Object_var anObject = GEOM::GEOM_Object::_narrow(theIOR); + return !(anObject->_is_nil()); +} + + +//============================================================================ +// function : PublishInStudy +// purpose : +//============================================================================ +SALOMEDS::SObject_ptr GEOM_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy, + SALOMEDS::SObject_ptr theSObject, + CORBA::Object_ptr theObject, + const char* theName) throw (SALOME::SALOME_Exception) +{ + Unexpect aCatch(SALOME_SalomeException); + SALOMEDS::SObject_var aResultSO; + if(CORBA::is_nil(theObject) || theStudy->_is_nil()) return aResultSO; + + GEOM::GEOM_Object_var aShape = GEOM::GEOM_Object::_narrow(theObject); + if(aShape->_is_nil()) return aResultSO; + + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder(); + + SALOMEDS::SComponent_var aFather = theStudy->FindComponent("GEOM"); + if (aFather->_is_nil()) { + aFather = aStudyBuilder->NewComponent("GEOM"); + anAttr = aStudyBuilder->FindOrCreateAttribute(aFather, "AttributeName"); + SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr); + aName->SetValue("Geometry"); + anAttr = aStudyBuilder->FindOrCreateAttribute(aFather, "AttributePixMap"); + SALOMEDS::AttributePixMap::_narrow(anAttr)->SetPixMap("ICON_OBJBROWSER_Geometry"); + aStudyBuilder->DefineComponentInstance(aFather, GEOM_Gen::_this()); + } + if (aFather->_is_nil()) return aResultSO; + + if (CORBA::is_nil(theSObject)) { + aResultSO = aStudyBuilder->NewObject(aFather); + } else { + if (!theSObject->ReferencedObject(aResultSO)) + aResultSO = SALOMEDS::SObject::_duplicate(theSObject); //SRN: Added Aug 24,2004 : for the method AddInStudy with theFather argumenet != NULL + //THROW_SALOME_CORBA_EXCEPTION("Publish in study supervision graph error",SALOME::BAD_PARAM); + } + anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeIOR"); + SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + char *aGeomObjIOR = _orb->object_to_string(theObject); + anIOR->SetValue(strdup(aGeomObjIOR)); + + anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributePixMap"); + SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); + TCollection_AsciiString aShapeName("Shape_"); + + if ( aShape->GetType() == GEOM_GROUP ) { + GEOM::GEOM_IGroupOperations_var anOp = GetIGroupOperations( theStudy->StudyId() ); + switch ( (TopAbs_ShapeEnum)anOp->GetType( aShape ) ) { + case TopAbs_VERTEX: + aPixmap->SetPixMap( "ICON_OBJBROWSER_GROUP_PNT" ); + aShapeName = "Group_Of_Vertices_"; + break; + case TopAbs_EDGE: + aPixmap->SetPixMap( "ICON_OBJBROWSER_GROUP_EDGE" ); + aShapeName = "Group_Of_Edges_"; + break; + case TopAbs_FACE: + aPixmap->SetPixMap( "ICON_OBJBROWSER_GROUP_FACE" ); + aShapeName = "Group_Of_Faces_"; + break; + case TopAbs_SOLID: + aPixmap->SetPixMap( "ICON_OBJBROWSER_GROUP_SOLID" ); + aShapeName = "Group_Of_Solids_"; + break; + } + } else if ( aShape->GetType() == GEOM_MARKER ) { + aPixmap->SetPixMap( "ICON_OBJBROWSER_LCS" ); + aShapeName = "LocalCS_"; + } else if ( aShape->GetShapeType() == GEOM::COMPOUND ) { + aPixmap->SetPixMap( "ICON_OBJBROWSER_COMPOUND" ); + aShapeName = "Compound_"; + } else if ( aShape->GetShapeType() == GEOM::COMPSOLID ) { + aPixmap->SetPixMap( "ICON_OBJBROWSER_COMPSOLID" ); + aShapeName = "Compsolid_"; + } else if ( aShape->GetShapeType() == GEOM::SOLID ) { + aPixmap->SetPixMap( "ICON_OBJBROWSER_SOLID" ); + aShapeName = "Solid_"; + } else if ( aShape->GetShapeType() == GEOM::SHELL ) { + aPixmap->SetPixMap( "ICON_OBJBROWSER_SHELL" ); + aShapeName = "Shell_"; + } else if ( aShape->GetShapeType() == GEOM::FACE ) { + aPixmap->SetPixMap( "ICON_OBJBROWSER_FACE" ); + aShapeName = "Face_"; + } else if ( aShape->GetShapeType() == GEOM::WIRE ) { + aPixmap->SetPixMap( "ICON_OBJBROWSER_WIRE" ); + aShapeName = "Wire_"; + } else if ( aShape->GetShapeType() == GEOM::EDGE ) { + aPixmap->SetPixMap( "ICON_OBJBROWSER_EDGE" ); + aShapeName = "Edge_"; + } else if ( aShape->GetShapeType() == GEOM::VERTEX ) { + aPixmap->SetPixMap( "ICON_OBJBROWSER_VERTEX" ); + aShapeName = "Vertex_"; + } + if (strlen(theName) == 0) aShapeName += TCollection_AsciiString(aResultSO->Tag()); + else aShapeName = TCollection_AsciiString(strdup(theName)); + + //Set the study entry as a name of the published GEOM_Object + aShape->SetStudyEntry(aResultSO->GetID()); + + //Set a name of the added shape + anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeName"); + SALOMEDS::AttributeName_var aNameAttrib = SALOMEDS::AttributeName::_narrow(anAttr); + aNameAttrib->SetValue(aShapeName.ToCString()); + + return aResultSO._retn(); +} + + +//============================================================================ +// function : Save() +// purpose : save OCAF/Geom document +//============================================================================ +SALOMEDS::TMPFile* GEOM_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent, + const char* theURL, + bool isMultiFile) { + SALOMEDS::TMPFile_var aStreamFile; + // Get a temporary directory to store a file + std::string aTmpDir = (isMultiFile)?theURL:SALOMEDS_Tool::GetTmpDir(); + // Create a list to store names of created files + SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames; + aSeq->length(1); + // Prepare a file name to open + TCollection_AsciiString aNameWithExt(""); + if (isMultiFile) + aNameWithExt = TCollection_AsciiString((char*)(SALOMEDS_Tool::GetNameFromPath(theComponent->GetStudy()->URL())).c_str()); + aNameWithExt += TCollection_AsciiString("_GEOM.sgd"); + aSeq[0] = CORBA::string_dup(aNameWithExt.ToCString()); + // Build a full file name of temporary file + TCollection_AsciiString aFullName = TCollection_AsciiString((char*)aTmpDir.c_str()) + aNameWithExt; + // Save GEOM component in this file + _impl->Save(theComponent->GetStudy()->StudyId(), aFullName.ToCString()); + // Conver a file to the byte stream + aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir.c_str(), aSeq.in(), isMultiFile); + // Remove the created file and tmp directory + if (!isMultiFile) SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.c_str(), aSeq.in(), true); + + // Return the created byte stream + return aStreamFile._retn(); +} + + +//============================================================================ +// function : SaveASCII() +// purpose : +//============================================================================ +SALOMEDS::TMPFile* GEOM_Gen_i::SaveASCII(SALOMEDS::SComponent_ptr theComponent, + const char* theURL, + bool isMultiFile) { + SALOMEDS::TMPFile_var aStreamFile = Save(theComponent, theURL, isMultiFile); + return aStreamFile._retn(); +} + + +//============================================================================ +// function : Load() +// purpose : +//============================================================================ +CORBA::Boolean GEOM_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent, + const SALOMEDS::TMPFile& theStream, + const char* theURL, + bool isMultiFile) { + + if (theStream.length() <= 9) { + MESSAGE("The TMPFile is too short : " << theStream.length() << " bytes "); + return false; + } + + // Get a temporary directory for a file + std::string aTmpDir = isMultiFile?theURL:SALOMEDS_Tool::GetTmpDir(); + // Conver the byte stream theStream to a file and place it in tmp directory + SALOMEDS::ListOfFileNames_var aSeq = SALOMEDS_Tool::PutStreamToFiles(theStream, aTmpDir.c_str(), isMultiFile); + + // Prepare a file name to open + TCollection_AsciiString aNameWithExt(""); + if (isMultiFile) + aNameWithExt = TCollection_AsciiString((char*)(SALOMEDS_Tool::GetNameFromPath(theComponent->GetStudy()->URL())).c_str()); + aNameWithExt += TCollection_AsciiString("_GEOM.sgd"); + TCollection_AsciiString aFullName = (TCollection_AsciiString((char*)aTmpDir.c_str()) + aNameWithExt); + + // Open document + if (!_impl->Load(theComponent->GetStudy()->StudyId(), aFullName.ToCString())) return false; + + // Remove the created file and tmp directory + if (!isMultiFile) SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.c_str(), aSeq.in(), true); + + SALOMEDS::Study_var Study = theComponent->GetStudy(); + TCollection_AsciiString name( strdup(Study->Name()) ); + + return true; +} + + +//============================================================================ +// function : LoadASCII() +// purpose : +//============================================================================ +CORBA::Boolean GEOM_Gen_i::LoadASCII(SALOMEDS::SComponent_ptr theComponent, + const SALOMEDS::TMPFile& theStream, + const char* theURL, + bool isMultiFile) { + return Load(theComponent, theStream, theURL, isMultiFile); +} + + +//============================================================================ +// function : Close() +// purpose : +//============================================================================ +void GEOM_Gen_i::Close(SALOMEDS::SComponent_ptr theComponent) +{ + _impl->Close(theComponent->GetStudy()->StudyId()); +} + +//============================================================================ +// function : CanCopy() +// purpose : +//============================================================================ +CORBA::Boolean GEOM_Gen_i::CanCopy(SALOMEDS::SObject_ptr theObject) { + // Try to retrieve known by Geometry component GEOM_Object by given IOR + SALOMEDS::GenericAttribute_var anAttr; + if (!theObject->FindAttribute(anAttr, "AttributeIOR")) return false; + + SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + + GEOM::GEOM_Object_var anObject = GEOM::GEOM_Object::_narrow(_orb->string_to_object(anIOR->Value())); + // If the object is null one it can't be copied: return false + if (anObject->_is_nil()) return false; + return true; +} + +//============================================================================ +// function : CopyFrom() +// purpose : +//============================================================================ +SALOMEDS::TMPFile* GEOM_Gen_i::CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID) { + // Declare a sequence of the byte to store the copied object + SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile; + + // Try to get GEOM_Object object by given SObject + SALOMEDS::GenericAttribute_var anAttr; + if (!theObject->FindAttribute(anAttr, "AttributeIOR")) return aStreamFile._retn(); + GEOM::GEOM_Object_var anObject = GEOM::GEOM_Object::_narrow(_orb->string_to_object(SALOMEDS::AttributeIOR::_narrow(anAttr)->Value())); + if (anObject->_is_nil()) return aStreamFile._retn(); + + aStreamFile = anObject->GetShapeStream(); + + // Assign an ID the type of GEOM_Object + theObjectID = anObject->GetType(); + + // Return created TMPFile + return aStreamFile._retn(); +} + +//============================================================================ +// function : CanPaste() +// purpose : +//============================================================================ +CORBA::Boolean GEOM_Gen_i::CanPaste(const char* theComponentName, CORBA::Long theObjectID) { + // The Geometry component can paste only objects copied by Geometry component + // and with the object type = 1 + if (strcmp(theComponentName, ComponentDataType()) != 0) return false; + return true; +} + +//============================================================================ +// function : PasteInto() +// purpose : +//============================================================================ +SALOMEDS::SObject_ptr GEOM_Gen_i::PasteInto(const SALOMEDS::TMPFile& theStream, + CORBA::Long theObjectID, + SALOMEDS::SObject_ptr theObject) { + // Find the current Study and StudyBuilder + SALOMEDS::Study_var aStudy = theObject->GetStudy(); + SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); + + // Retrieve a TopoDS_Shape from byte stream + TopoDS_Shape aTopology; + istrstream aStreamedBrep((char*) &theStream[0], theStream.length()); + BRep_Builder aBuilder; + try { + BRepTools::Read(aTopology, aStreamedBrep, aBuilder); + } catch (Standard_Failure) { + return false; + } + + // SObject of the created shape is theObject or new Child of Component if theObject == geom component + SALOMEDS::SObject_var aNewSO; + if (strcmp(theObject->GetFatherComponent()->GetID(),theObject->GetID()) == 0) { + aNewSO = aStudyBuilder->NewObject(theObject); + } else aNewSO = SALOMEDS::SObject::_duplicate(theObject); + + + //Create a new GEOM_Object + Handle(GEOM_Object) anObj = _impl->AddObject(aNewSO->GetStudy()->StudyId(), theObjectID); + Handle(GEOM_Function) aFunction = anObj->AddFunction(GEOMImpl_CopyDriver::GetID(), COPY_WITHOUT_REF); + aFunction->SetValue(aTopology); + + TCollection_AsciiString anEntry; + TDF_Tool::Entry(anObj->GetEntry(), anEntry); + GEOM::GEOM_Object_var obj = GetObject(anObj->GetDocID(), anEntry.ToCString()); + + // Add IORAttribute to the Study and set IOR of the created GEOM_Object to it + SALOMEDS::GenericAttribute_var anAttr = aStudyBuilder->FindOrCreateAttribute(aNewSO, "AttributeIOR"); + SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + anIOR->SetValue(_orb->object_to_string(obj)); + + // Return the created in the Study SObject + return aNewSO._retn(); +} + +//============================================================================ +// function : ComponentDataType() +// purpose : +//============================================================================ +char* GEOM_Gen_i::ComponentDataType() +{ + return strdup("GEOM"); +} + +//============================================================================ +// function : AddInStudy +// purpose : +//============================================================================ +SALOMEDS::SObject_ptr GEOM_Gen_i::AddInStudy(SALOMEDS::Study_ptr theStudy, GEOM::GEOM_Object_ptr theObject, const char* theName, GEOM::GEOM_Object_ptr theFather) +{ + SALOMEDS::SObject_var aResultSO; + if(theObject->_is_nil() || theStudy->_is_nil()) return aResultSO; + + SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder(); + char* IOR; + + if(!theFather->_is_nil()) { + IOR = _orb->object_to_string(theFather); + SALOMEDS::SObject_var aFatherSO = theStudy->FindObjectIOR(IOR); + if(aFatherSO->_is_nil()) return aResultSO._retn(); + aResultSO = aStudyBuilder->NewObject(aFatherSO); + //aStudyBuilder->Addreference(aResultSO, aResultSO); + } + + aResultSO = PublishInStudy(theStudy, aResultSO, theObject, theName); + if(aResultSO->_is_nil()) return aResultSO._retn(); + + GEOM::ListOfGO_var aList = theObject->GetDependency(); + Standard_Integer aLength = aList->length(); + if(aLength < 1) return aResultSO._retn(); + + //Publish the arguments + for(Standard_Integer i = 0; i< aLength; i++) { + GEOM::GEOM_Object_var anObject = aList[i]; + if(anObject->_is_nil()) continue; + IOR = _orb->object_to_string(anObject); + SALOMEDS::SObject_var aSO = theStudy->FindObjectIOR(IOR); + if(aSO->_is_nil()) continue; + SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aResultSO); + aStudyBuilder->Addreference(aSubSO, aSO); + } + + return aResultSO._retn(); +} + +//============================================================================ +// function : register() +// purpose : register 'name' in 'name_service' +//============================================================================ +void GEOM_Gen_i::register_name(char * name) +{ + GEOM::GEOM_Gen_ptr g = GEOM::GEOM_Gen::_narrow(POA_GEOM::GEOM_Gen::_this()); + name_service->Register(g, strdup(name)); +} + +//============================================================================ +// function : Undo +// purpose : +//============================================================================ +void GEOM_Gen_i::Undo(CORBA::Long theStudyID) +{ + _impl->Undo(theStudyID); +} + +//============================================================================ +// function : Redo +// purpose : +//============================================================================ +void GEOM_Gen_i::Redo(CORBA::Long theStudyID) +{ + _impl->Redo(theStudyID); +} + +//============================================================================ +// function : GetIBasicOperations +// purpose : +//============================================================================ +GEOM::GEOM_IBasicOperations_ptr GEOM_Gen_i::GetIBasicOperations(CORBA::Long theStudyID) + throw ( SALOME::SALOME_Exception ) +{ + Unexpect aCatch(SALOME_SalomeException); + MESSAGE( "GEOM_Gen_i::GetIBasicOperations" ); + + GEOM::GEOM_Gen_ptr engine = POA_GEOM::GEOM_Gen::_this(); + + GEOM_IBasicOperations_i* aServant = + new GEOM_IBasicOperations_i(_poa, engine, _impl->GetIBasicOperations(theStudyID)); + + // activate the CORBA servant + GEOM::GEOM_IBasicOperations_var operations = aServant->_this(); + return operations._retn(); +} + +//============================================================================ +// function : GetITransformOperations +// purpose : +//============================================================================ +GEOM::GEOM_ITransformOperations_ptr GEOM_Gen_i::GetITransformOperations(CORBA::Long theStudyID) + throw ( SALOME::SALOME_Exception ) +{ + Unexpect aCatch(SALOME_SalomeException); + MESSAGE( "GEOM_Gen_i::GetITransformOperations" ); + + GEOM::GEOM_Gen_ptr engine = POA_GEOM::GEOM_Gen::_this(); + + GEOM_ITransformOperations_i* aServant = + new GEOM_ITransformOperations_i(_poa, engine, _impl->GetITransformOperations(theStudyID)); + + // activate the CORBA servant + GEOM::GEOM_ITransformOperations_var operations = aServant->_this(); + return operations._retn(); +} + +//============================================================================ +// function : GetI3DPrimOperations +// purpose : +//============================================================================ +GEOM::GEOM_I3DPrimOperations_ptr GEOM_Gen_i::GetI3DPrimOperations(CORBA::Long theStudyID) + throw ( SALOME::SALOME_Exception ) +{ + Unexpect aCatch(SALOME_SalomeException); + MESSAGE( "GEOM_Gen_i::GetI3DPrimOperations" ); + + GEOM::GEOM_Gen_ptr engine = POA_GEOM::GEOM_Gen::_this(); + + GEOM_I3DPrimOperations_i* aServant = + new GEOM_I3DPrimOperations_i(_poa, engine, _impl->GetI3DPrimOperations(theStudyID)); + + // activate the CORBA servant + GEOM::GEOM_I3DPrimOperations_var operations = aServant->_this(); + return operations._retn(); +} + +//============================================================================ +// function : GetIShapesOperations +// purpose : +//============================================================================ +GEOM::GEOM_IShapesOperations_ptr GEOM_Gen_i::GetIShapesOperations(CORBA::Long theStudyID) + throw ( SALOME::SALOME_Exception ) +{ + Unexpect aCatch(SALOME_SalomeException); + MESSAGE( "GEOM_Gen_i::GetIShapesOperations" ); + + GEOM::GEOM_Gen_ptr engine = POA_GEOM::GEOM_Gen::_this(); + + GEOM_IShapesOperations_i* aServant = + new GEOM_IShapesOperations_i(_poa, engine, _impl->GetIShapesOperations(theStudyID)); + + // activate the CORBA servant + GEOM::GEOM_IShapesOperations_var operations = aServant->_this(); + return operations._retn(); +} + +//============================================================================ +// function : GetIBlocksOperations +// purpose : +//============================================================================ +GEOM::GEOM_IBlocksOperations_ptr GEOM_Gen_i::GetIBlocksOperations(CORBA::Long theStudyID) + throw ( SALOME::SALOME_Exception ) +{ + Unexpect aCatch(SALOME_SalomeException); + MESSAGE( "GEOM_Gen_i::GetIBlocksOperations" ); + + GEOM::GEOM_Gen_ptr engine = POA_GEOM::GEOM_Gen::_this(); + + GEOM_IBlocksOperations_i* aServant = + new GEOM_IBlocksOperations_i(_poa, engine, _impl->GetIBlocksOperations(theStudyID)); + + // activate the CORBA servant + GEOM::GEOM_IBlocksOperations_var operations = aServant->_this(); + return operations._retn(); +} + +//============================================================================ +// function : GetIBooleanOperations +// purpose : +//============================================================================ +GEOM::GEOM_IBooleanOperations_ptr GEOM_Gen_i::GetIBooleanOperations(CORBA::Long theStudyID) + throw ( SALOME::SALOME_Exception ) +{ + Unexpect aCatch(SALOME_SalomeException); + MESSAGE( "GEOM_Gen_i::GetIBooleanOperations" ); + + GEOM::GEOM_Gen_ptr engine = POA_GEOM::GEOM_Gen::_this(); + + GEOM_IBooleanOperations_i* aServant = + new GEOM_IBooleanOperations_i(_poa, engine, _impl->GetIBooleanOperations(theStudyID)); + + // activate the CORBA servant + GEOM::GEOM_IBooleanOperations_var operations = aServant->_this(); + return operations._retn(); +} + +//============================================================================ +// function : GetICurvesOperations +// purpose : +//============================================================================ +GEOM::GEOM_ICurvesOperations_ptr GEOM_Gen_i::GetICurvesOperations(CORBA::Long theStudyID) + throw ( SALOME::SALOME_Exception ) +{ + Unexpect aCatch(SALOME_SalomeException); + MESSAGE( "GEOM_Gen_i::GetICurvesOperations" ); + + GEOM::GEOM_Gen_ptr engine = POA_GEOM::GEOM_Gen::_this(); + + GEOM_ICurvesOperations_i* aServant = + new GEOM_ICurvesOperations_i(_poa, engine, _impl->GetICurvesOperations(theStudyID)); + + // activate the CORBA servant + GEOM::GEOM_ICurvesOperations_var operations = aServant->_this(); + return operations._retn(); +} + +//============================================================================ +// function : GetILocalOperations +// purpose : +//============================================================================ +GEOM::GEOM_ILocalOperations_ptr GEOM_Gen_i::GetILocalOperations(CORBA::Long theStudyID) + throw ( SALOME::SALOME_Exception ) +{ + Unexpect aCatch(SALOME_SalomeException); + MESSAGE( "GEOM_Gen_i::GetILocalOperations" ); + + GEOM::GEOM_Gen_ptr engine = POA_GEOM::GEOM_Gen::_this(); + + GEOM_ILocalOperations_i* aServant = + new GEOM_ILocalOperations_i(_poa, engine, _impl->GetILocalOperations(theStudyID)); + + // activate the CORBA servant + GEOM::GEOM_ILocalOperations_var operations = aServant->_this(); + return operations._retn(); +} + +//============================================================================ +// function : GetIHealingOperations +// purpose : +//============================================================================ +GEOM::GEOM_IHealingOperations_ptr GEOM_Gen_i::GetIHealingOperations(CORBA::Long theStudyID) + throw ( SALOME::SALOME_Exception ) +{ + Unexpect aCatch(SALOME_SalomeException); + MESSAGE( "GEOM_Gen_i::IHealingOperations" ); + + GEOM::GEOM_Gen_ptr engine = POA_GEOM::GEOM_Gen::_this(); + + GEOM_IHealingOperations_i* aServant = + new GEOM_IHealingOperations_i(_poa, engine, _impl->GetIHealingOperations(theStudyID)); + + // activate the CORBA servant + GEOM::GEOM_IHealingOperations_var operations = aServant->_this(); + return operations._retn(); +} + +//============================================================================ +// function : GetIInsertOperations +// purpose : +//============================================================================ +GEOM::GEOM_IInsertOperations_ptr GEOM_Gen_i::GetIInsertOperations(CORBA::Long theStudyID) + throw ( SALOME::SALOME_Exception ) +{ + Unexpect aCatch(SALOME_SalomeException); + MESSAGE( "GEOM_Gen_i::GetIInsertOperations" ); + + GEOM::GEOM_Gen_ptr engine = POA_GEOM::GEOM_Gen::_this(); + + GEOM_IInsertOperations_i* aServant = + new GEOM_IInsertOperations_i(_poa, engine, _impl->GetIInsertOperations(theStudyID)); + + // activate the CORBA servant + GEOM::GEOM_IInsertOperations_var operations = aServant->_this(); + return operations._retn(); +} + +//============================================================================ +// function : GetIMeasureOperations +// purpose : +//============================================================================ +GEOM::GEOM_IMeasureOperations_ptr GEOM_Gen_i::GetIMeasureOperations(CORBA::Long theStudyID) + throw ( SALOME::SALOME_Exception ) +{ + Unexpect aCatch(SALOME_SalomeException); + MESSAGE( "GEOM_Gen_i::GetIMeasureOperations" ); + + GEOM::GEOM_Gen_ptr engine = POA_GEOM::GEOM_Gen::_this(); + + GEOM_IMeasureOperations_i* aServant = + new GEOM_IMeasureOperations_i(_poa, engine, _impl->GetIMeasureOperations(theStudyID)); + + // activate the CORBA servant + GEOM::GEOM_IMeasureOperations_var operations = aServant->_this(); + return operations._retn(); +} + +//============================================================================ +// function : GetIGroupOperations +// purpose : +//============================================================================ +GEOM::GEOM_IGroupOperations_ptr GEOM_Gen_i::GetIGroupOperations(CORBA::Long theStudyID) + throw ( SALOME::SALOME_Exception ) +{ + Unexpect aCatch(SALOME_SalomeException); + MESSAGE( "GEOM_Gen_i::GetIGroupOperations" ); + + GEOM::GEOM_Gen_ptr engine = POA_GEOM::GEOM_Gen::_this(); + + GEOM_IGroupOperations_i* aServant = + new GEOM_IGroupOperations_i(_poa, engine, _impl->GetIGroupOperations(theStudyID)); + + // activate the CORBA servant + GEOM::GEOM_IGroupOperations_var operations = aServant->_this(); + return operations._retn(); +} + +//============================================================================= +/*! + * AddSubShape + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Gen_i::AddSubShape(GEOM::GEOM_Object_ptr theMainShape, const GEOM::ListOfLong& theIndices) +{ + if(theMainShape == NULL || theIndices.length() < 1) return GEOM::GEOM_Object::_nil(); + Handle(GEOM_Object) aMainsShape = _impl->GetObject(theMainShape->GetStudyID(), theMainShape->GetEntry()); + if (aMainsShape.IsNull()) return GEOM::GEOM_Object::_nil(); + + Handle(TColStd_HArray1OfInteger) anArray = new TColStd_HArray1OfInteger(1, theIndices.length()); + for(Standard_Integer i = 0; iSetValue(i+1, theIndices[i]); + + Handle(GEOM_Object) anObject = _impl->AddSubShape(aMainsShape, anArray); + if(anObject.IsNull()) return GEOM::GEOM_Object::_nil(); + + TCollection_AsciiString anEntry; + TDF_Tool::Entry(anObject->GetEntry(), anEntry); + return GetObject(anObject->GetDocID(), anEntry.ToCString()); +} + +//============================================================================= +/*! + * RemoveObject + */ +//============================================================================= +void GEOM_Gen_i::RemoveObject(GEOM::GEOM_Object_ptr theObject) +{ + Handle(GEOM_Object) anObject = _impl->GetObject(theObject->GetStudyID(), theObject->GetEntry()); + if (anObject.IsNull()) return; + _impl->RemoveObject(anObject); + return; +} + + +//================================================================================= +// function : GetStringFromIOR() +// purpose : returns a string that represents a 'GEOM::GEOM_Object_var' +//================================================================================= +char* GEOM_Gen_i::GetStringFromIOR(GEOM::GEOM_Object_ptr theObject) { + return _orb->object_to_string(theObject); +} + + +//================================================================================= +// function : GetIORFromString() +// purpose : returns a 'GEOM::GEOM_Object_var' from a string representing it +//================================================================================= +GEOM::GEOM_Object_ptr GEOM_Gen_i::GetIORFromString(const char* stringIOR) { + GEOM::GEOM_Object_var aGeomObject; + if(strcmp(stringIOR,"") != 0){ + CORBA::Object_var anObject = _orb->string_to_object(stringIOR); + if(!CORBA::is_nil(anObject)) + aGeomObject = GEOM::GEOM_Object::_narrow(anObject.in()) ; + } + return aGeomObject._retn() ; +} + +//================================================================================= +// function : GetObject() +// purpose : +//================================================================================= +GEOM::GEOM_Object_ptr GEOM_Gen_i::GetObject(CORBA::Long theStudyID, const char* theEntry) +{ + GEOM::GEOM_Object_var obj; + Handle(GEOM_Object) handle_object = _impl->GetObject(theStudyID, (char*)theEntry); + if(handle_object.IsNull()) return NULL; + TCollection_AsciiString stringIOR = handle_object->GetIOR(); + if(stringIOR.Length() > 1) { + CORBA::Object_var corba_object = _orb->string_to_object(stringIOR.ToCString()); + if(!CORBA::is_nil(corba_object)) obj = GEOM::GEOM_Object::_narrow(corba_object); + return obj._retn(); + } + + GEOM::GEOM_Gen_ptr engine = POA_GEOM::GEOM_Gen::_this(); + GEOM_Object_i* servant = new GEOM_Object_i(_poa, engine, handle_object); + + obj = servant->_this(); + stringIOR = _orb->object_to_string(obj); + handle_object->SetIOR(stringIOR); + return obj._retn(); +} + + +//===================================================================================== +// EXPORTED METHODS +//===================================================================================== +extern "C" +{ + PortableServer::ObjectId * GEOMEngine_factory(CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + PortableServer::ObjectId * contId, + const char *instanceName, + const char * interfaceName) + { + GEOM_Gen_i * myGEOM_Gen_i = new GEOM_Gen_i(orb, poa, contId, instanceName, interfaceName); + myGEOM_Gen_i->register_name("/myGEOM_Gen"); // NRI : 11/07/2002 : Add for Supervision example + return myGEOM_Gen_i->getId() ; + } +} + diff --git a/src/GEOM_I/GEOM_Gen_i.hh b/src/GEOM_I/GEOM_Gen_i.hh new file mode 100644 index 000000000..f8537d7d3 --- /dev/null +++ b/src/GEOM_I/GEOM_Gen_i.hh @@ -0,0 +1,191 @@ +#ifndef __GEOM_GEN_I_H__ +#define __GEOM_GEN_I_H__ + +#include "GEOMImpl_Gen.hxx" + +// IDL headers +#include +#include CORBA_SERVER_HEADER(GEOM_Gen) +#include CORBA_SERVER_HEADER(SALOMEDS) +#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) + +#include "SALOME_Component_i.hxx" + +#include "SALOME_NamingService.hxx" + +#include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC + +#include "GEOM_IBasicOperations_i.hh" +#include "GEOM_ITransformOperations_i.hh" +#include "GEOM_I3DPrimOperations_i.hh" +#include "GEOM_IShapesOperations_i.hh" +#include "GEOM_IBlocksOperations_i.hh" +#include "GEOM_IBooleanOperations_i.hh" +#include "GEOM_ICurvesOperations_i.hh" +#include "GEOM_ILocalOperations_i.hh" +#include "GEOM_IHealingOperations_i.hh" +#include "GEOM_IInsertOperations_i.hh" +#include "GEOM_IMeasureOperations_i.hh" +#include "GEOM_IGroupOperations_i.hh" + +//===================================================================== +// GEOM_Gen_i : class definition +//===================================================================== +class GEOM_Gen_i: public POA_GEOM::GEOM_Gen, public Engines_Component_i +{ + public: + + //-----------------------------------------------------------------------// + // Constructor / Destructor // + //-----------------------------------------------------------------------// + // constructor to be called for servant creation. + GEOM_Gen_i(); + GEOM_Gen_i(CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + PortableServer::ObjectId * contId, + const char *instanceName, + const char *interfaceName); + + // destructor, doing nothing (for now) + virtual ~GEOM_Gen_i(); + + // generic method to be put in a super class + void register_name(char * name); + + + //-----------------------------------------------------------------------// + // Inherited methods from SALOMEDS::Driver // + //-----------------------------------------------------------------------// + + SALOMEDS::TMPFile* Save(SALOMEDS::SComponent_ptr theComponent, + const char* theURL, + bool isMultiFile); + + SALOMEDS::TMPFile* SaveASCII(SALOMEDS::SComponent_ptr theComponent, + const char* theURL, + bool isMultiFile); + + CORBA::Boolean Load(SALOMEDS::SComponent_ptr theComponent, + const SALOMEDS::TMPFile& theStream, + const char* theURL, + bool isMultiFile); + + CORBA::Boolean LoadASCII(SALOMEDS::SComponent_ptr theComponent, + const SALOMEDS::TMPFile& theStream, + const char* theURL, + bool isMultiFile); + + void Close(SALOMEDS::SComponent_ptr theComponent); + char* ComponentDataType(); + + + char* IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject, + const char* IORString, + CORBA::Boolean isMultiFile, + CORBA::Boolean isASCII); + char* LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject, + const char* aLocalPersistentID, + CORBA::Boolean isMultiFile, + CORBA::Boolean isASCII); + + bool CanPublishInStudy(CORBA::Object_ptr theIOR); + SALOMEDS::SObject_ptr PublishInStudy(SALOMEDS::Study_ptr theStudy, + SALOMEDS::SObject_ptr theSObject, + CORBA::Object_ptr theObject, + const char* theName) throw (SALOME::SALOME_Exception) ; + + CORBA::Boolean CanCopy(SALOMEDS::SObject_ptr theObject); + SALOMEDS::TMPFile* CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID); + CORBA::Boolean CanPaste(const char* theComponentName, CORBA::Long theObjectID); + SALOMEDS::SObject_ptr PasteInto(const SALOMEDS::TMPFile& theStream, + CORBA::Long theObjectID, + SALOMEDS::SObject_ptr theObject); + + //Adds theObject in the study with a name = theName, if theFather is not null the object is placed under theFather + SALOMEDS::SObject_ptr AddInStudy(SALOMEDS::Study_ptr theStudy, GEOM::GEOM_Object_ptr theObject, const char* theName, GEOM::GEOM_Object_ptr theFather); + + //-----------------------------------------------------------------------// + // Transaction methods // + //-----------------------------------------------------------------------// + + //Undos one transaction in the document associated with theStudyID + virtual void Undo(CORBA::Long theStudyID); + + //Redos one transaction in the document associated with theStudyID + virtual void Redo(CORBA::Long theStudyID); + + //-----------------------------------------------------------------------// + // Operations methods // + //-----------------------------------------------------------------------// + + //Returns a pointer to BasicOperations interface + virtual GEOM::GEOM_IBasicOperations_ptr GetIBasicOperations (CORBA::Long theStudyID) + throw (SALOME::SALOME_Exception); + + //Returns a pointer to TransformOperations interface + virtual GEOM::GEOM_ITransformOperations_ptr GetITransformOperations (CORBA::Long theStudyID) + throw (SALOME::SALOME_Exception); + + //Returns a pointer to 3DPrimOperations interface + virtual GEOM::GEOM_I3DPrimOperations_ptr GetI3DPrimOperations (CORBA::Long theStudyID) + throw (SALOME::SALOME_Exception); + + //Returns a pointer to ShapesOperations interface + virtual GEOM::GEOM_IShapesOperations_ptr GetIShapesOperations (CORBA::Long theStudyID) + throw (SALOME::SALOME_Exception); + + //Returns a pointer to BlocksOperations interface + virtual GEOM::GEOM_IBlocksOperations_ptr GetIBlocksOperations (CORBA::Long theStudyID) + throw (SALOME::SALOME_Exception); + + //Returns a pointer to BooleanOperations interface + virtual GEOM::GEOM_IBooleanOperations_ptr GetIBooleanOperations (CORBA::Long theStudyID) + throw (SALOME::SALOME_Exception); + + //Returns a pointer to CurvesOperations interface + virtual GEOM::GEOM_ICurvesOperations_ptr GetICurvesOperations (CORBA::Long theStudyID) + throw (SALOME::SALOME_Exception); + + //Returns a pointer to LocalOperations interface + virtual GEOM::GEOM_ILocalOperations_ptr GetILocalOperations (CORBA::Long theStudyID) + throw (SALOME::SALOME_Exception); + + //Returns a pointer to HealingOperations interface + virtual GEOM::GEOM_IHealingOperations_ptr GetIHealingOperations (CORBA::Long theStudyID) + throw (SALOME::SALOME_Exception); + + //Returns a pointer to InsertOperations interface + virtual GEOM::GEOM_IInsertOperations_ptr GetIInsertOperations (CORBA::Long theStudyID) + throw (SALOME::SALOME_Exception); + + //Returns a pointer to MeasureOperations interface + virtual GEOM::GEOM_IMeasureOperations_ptr GetIMeasureOperations (CORBA::Long theStudyID) + throw (SALOME::SALOME_Exception); + + //Returns a pointer to GroupOperations interface + virtual GEOM::GEOM_IGroupOperations_ptr GetIGroupOperations (CORBA::Long theStudyID) + throw (SALOME::SALOME_Exception); + + //Adds a new sub shape + virtual GEOM::GEOM_Object_ptr AddSubShape(GEOM::GEOM_Object_ptr theMainShape, const GEOM::ListOfLong& theIndices); + + virtual void RemoveObject(GEOM::GEOM_Object_ptr theObject); + + virtual char* GetStringFromIOR(GEOM::GEOM_Object_ptr theObject); + + virtual GEOM::GEOM_Object_ptr GetIORFromString(const char* stringIOR); + + //********************************************************************************************************// + // Internal methods + //********************************************************************************************************// + virtual GEOM::GEOM_Object_ptr GetObject(CORBA::Long theStudyID, const char* theEntry); + + private: + + ::GEOMImpl_Gen* _impl; + SALOME_NamingService * name_service; + char * _name; + +}; + +#endif diff --git a/src/GEOM_I/GEOM_I3DPrimOperations_i.cc b/src/GEOM_I/GEOM_I3DPrimOperations_i.cc new file mode 100644 index 000000000..e6f153bce --- /dev/null +++ b/src/GEOM_I/GEOM_I3DPrimOperations_i.cc @@ -0,0 +1,467 @@ +using namespace std; + +#include "GEOM_I3DPrimOperations_i.hh" + +#include "utilities.h" +#include "OpUtil.hxx" +#include "Utils_ExceptHandlers.hxx" + +#include "GEOM_Engine.hxx" +#include "GEOM_Object.hxx" + +//============================================================================= +/*! + * constructor: + */ +//============================================================================= +GEOM_I3DPrimOperations_i::GEOM_I3DPrimOperations_i(PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr theEngine, ::GEOMImpl_I3DPrimOperations* theImpl) +:GEOM_IOperations_i(thePOA, theEngine, theImpl) +{ + MESSAGE("GEOM_I3DPrimOperations_i::GEOM_I3DPrimOperations_i"); +} + +//============================================================================= +/*! + * destructor + */ +//============================================================================= +GEOM_I3DPrimOperations_i::~GEOM_I3DPrimOperations_i() +{ + MESSAGE("GEOM_I3DPrimOperations_i::~GEOM_I3DPrimOperations_i"); +} + + +//============================================================================= +/*! + * MakeBoxDXDYDZ + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeBoxDXDYDZ (CORBA::Double theDX, + CORBA::Double theDY, + CORBA::Double theDZ) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Create the Box + Handle(GEOM_Object) anObject = GetOperations()->MakeBoxDXDYDZ(theDX, theDY, theDZ); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakeBoxTwoPnt + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeBoxTwoPnt + (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (thePnt1 == NULL || thePnt2 == NULL) return aGEOMObject._retn(); + + //Get the reference points + Handle(GEOM_Object) aPnt1 = GetOperations()->GetEngine()->GetObject + (thePnt1->GetStudyID(), thePnt1->GetEntry()); + Handle(GEOM_Object) aPnt2 = GetOperations()->GetEngine()->GetObject + (thePnt2->GetStudyID(), thePnt2->GetEntry()); + + if (aPnt1.IsNull() || aPnt2.IsNull()) return aGEOMObject._retn(); + + //Create the Box + Handle(GEOM_Object) anObject = GetOperations()->MakeBoxTwoPnt(aPnt1, aPnt2); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakeCylinderRH + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeCylinderRH (CORBA::Double theR, + CORBA::Double theH) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Create the Cylinder + Handle(GEOM_Object) anObject = GetOperations()->MakeCylinderRH(theR, theH); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakeCylinderPntVecRH + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeCylinderPntVecRH + (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec, + CORBA::Double theR, CORBA::Double theH) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (thePnt == NULL || theVec == NULL) return aGEOMObject._retn(); + + //Get the reference points + Handle(GEOM_Object) aPnt = GetOperations()->GetEngine()->GetObject + (thePnt->GetStudyID(), thePnt->GetEntry()); + Handle(GEOM_Object) aVec = GetOperations()->GetEngine()->GetObject + (theVec->GetStudyID(), theVec->GetEntry()); + + if (aPnt.IsNull() || aVec.IsNull()) return aGEOMObject._retn(); + + //Create the Cylinder + Handle(GEOM_Object) anObject = GetOperations()->MakeCylinderPntVecRH(aPnt, aVec, theR, theH); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakeConeR1R2H + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeConeR1R2H (CORBA::Double theR1, + CORBA::Double theR2, + CORBA::Double theH) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Create the Cone + Handle(GEOM_Object) anObject = GetOperations()->MakeConeR1R2H(theR1, theR2, theH); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakeConePntVecR1R2H + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeConePntVecR1R2H + (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec, + CORBA::Double theR1, CORBA::Double theR2, CORBA::Double theH) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (thePnt == NULL || theVec == NULL) return aGEOMObject._retn(); + + //Get the reference points + Handle(GEOM_Object) aPnt = GetOperations()->GetEngine()->GetObject + (thePnt->GetStudyID(), thePnt->GetEntry()); + Handle(GEOM_Object) aVec = GetOperations()->GetEngine()->GetObject + (theVec->GetStudyID(), theVec->GetEntry()); + + if (aPnt.IsNull() || aVec.IsNull()) return aGEOMObject._retn(); + + //Create the Cone + Handle(GEOM_Object) anObject = + GetOperations()->MakeConePntVecR1R2H(aPnt, aVec, theR1, theR2, theH); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakeSphereR + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeSphereR (CORBA::Double theR) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Create the Cone + Handle(GEOM_Object) anObject = GetOperations()->MakeSphereR(theR); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakeSpherePntR + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeSpherePntR + (GEOM::GEOM_Object_ptr thePnt, CORBA::Double theR) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (thePnt == NULL) return aGEOMObject._retn(); + + //Get the reference point + Handle(GEOM_Object) aPnt = GetOperations()->GetEngine()->GetObject + (thePnt->GetStudyID(), thePnt->GetEntry()); + + if (aPnt.IsNull()) return aGEOMObject._retn(); + + //Create the Sphere + Handle(GEOM_Object) anObject = + GetOperations()->MakeSpherePntR(aPnt, theR); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakeTorusRR + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeTorusRR + (CORBA::Double theRMajor, CORBA::Double theRMinor) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + // Make Torus + Handle(GEOM_Object) anObject = + GetOperations()->MakeTorusRR(theRMajor, theRMinor); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakeTorusPntVecRR + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeTorusPntVecRR + (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec, + CORBA::Double theRMajor, CORBA::Double theRMinor) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (thePnt == NULL || theVec == NULL) return aGEOMObject._retn(); + + //Get the reference points + Handle(GEOM_Object) aPnt = GetOperations()->GetEngine()->GetObject + (thePnt->GetStudyID(), thePnt->GetEntry()); + Handle(GEOM_Object) aVec = GetOperations()->GetEngine()->GetObject + (theVec->GetStudyID(), theVec->GetEntry()); + + if (aPnt.IsNull() || aVec.IsNull()) return aGEOMObject._retn(); + + // Make Torus + Handle(GEOM_Object) anObject = + GetOperations()->MakeTorusPntVecRR(aPnt, aVec, theRMajor, theRMinor); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakePrismVecH + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakePrismVecH + (GEOM::GEOM_Object_ptr theBase, GEOM::GEOM_Object_ptr theVec, + CORBA::Double theH) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theBase == NULL || theVec == NULL) return aGEOMObject._retn(); + + //Get the reference objects + Handle(GEOM_Object) aBase = GetOperations()->GetEngine()->GetObject + (theBase->GetStudyID(), theBase->GetEntry()); + Handle(GEOM_Object) aVec = GetOperations()->GetEngine()->GetObject + (theVec->GetStudyID(), theVec->GetEntry()); + + if (aBase.IsNull() || aVec.IsNull()) return aGEOMObject._retn(); + + //Create the Prism + Handle(GEOM_Object) anObject = + GetOperations()->MakePrismVecH(aBase, aVec, theH); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakePrismTwoPnt + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakePrismTwoPnt + (GEOM::GEOM_Object_ptr theBase, + GEOM::GEOM_Object_ptr thePoint1, + GEOM::GEOM_Object_ptr thePoint2) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theBase == NULL || thePoint1 == NULL || thePoint2 == NULL) + return aGEOMObject._retn(); + + //Get the reference objects + Handle(GEOM_Object) aBase = GetOperations()->GetEngine()->GetObject + (theBase->GetStudyID(), theBase->GetEntry()); + Handle(GEOM_Object) aPoint1 = GetOperations()->GetEngine()->GetObject + (thePoint1->GetStudyID(), thePoint1->GetEntry()); + Handle(GEOM_Object) aPoint2 = GetOperations()->GetEngine()->GetObject + (thePoint2->GetStudyID(), thePoint2->GetEntry()); + + if (aBase.IsNull() || aPoint1.IsNull() || aPoint2.IsNull()) + return aGEOMObject._retn(); + + //Create the Prism + Handle(GEOM_Object) anObject = + GetOperations()->MakePrismTwoPnt(aBase, aPoint1, aPoint2); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakePipe + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakePipe + (GEOM::GEOM_Object_ptr theBase, GEOM::GEOM_Object_ptr thePath) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theBase == NULL || thePath == NULL) return aGEOMObject._retn(); + + //Get the reference objects + Handle(GEOM_Object) aBase = GetOperations()->GetEngine()->GetObject + (theBase->GetStudyID(), theBase->GetEntry()); + Handle(GEOM_Object) aPath = GetOperations()->GetEngine()->GetObject + (thePath->GetStudyID(), thePath->GetEntry()); + + if (aBase.IsNull() || aPath.IsNull()) return aGEOMObject._retn(); + + //Create the Pipe + Handle(GEOM_Object) anObject = + GetOperations()->MakePipe(aBase, aPath); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakeRevolutionAxisAngle + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeRevolutionAxisAngle + (GEOM::GEOM_Object_ptr theBase, GEOM::GEOM_Object_ptr theAxis, + CORBA::Double theAngle) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theBase == NULL || theAxis == NULL) return aGEOMObject._retn(); + + //Get the reference objects + Handle(GEOM_Object) aBase = GetOperations()->GetEngine()->GetObject + (theBase->GetStudyID(), theBase->GetEntry()); + Handle(GEOM_Object) anAxis = GetOperations()->GetEngine()->GetObject + (theAxis->GetStudyID(), theAxis->GetEntry()); + + if (aBase.IsNull() || anAxis.IsNull()) return aGEOMObject._retn(); + + //Create the Revolution + Handle(GEOM_Object) anObject = + GetOperations()->MakeRevolutionAxisAngle(aBase, anAxis, theAngle); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakeFilling + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeFilling(GEOM::GEOM_Object_ptr theShape, + CORBA::Long theMinDeg, + CORBA::Long theMaxDeg, + CORBA::Double theTol2D, + CORBA::Double theTol3D, + CORBA::Long theNbIter) +{ + 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(); + + //Create the Solid + Handle(GEOM_Object) anObject = GetOperations()->MakeFilling(aShape, theMinDeg, theMaxDeg, theTol2D, theTol3D, theNbIter); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} diff --git a/src/GEOM_I/GEOM_I3DPrimOperations_i.hh b/src/GEOM_I/GEOM_I3DPrimOperations_i.hh new file mode 100644 index 000000000..bcd42446a --- /dev/null +++ b/src/GEOM_I/GEOM_I3DPrimOperations_i.hh @@ -0,0 +1,82 @@ + +#ifndef _GEOM_I3DPrimOperations_i_HeaderFile +#define _GEOM_I3DPrimOperations_i_HeaderFile + + +#include + +#include CORBA_SERVER_HEADER(GEOM_Gen) +#include "GEOM_IOperations_i.hh" +#include "GEOM_Object_i.hh" + +#include "GEOMImpl_I3DPrimOperations.hxx" + +class GEOM_I3DPrimOperations_i : + public virtual POA_GEOM::GEOM_I3DPrimOperations, + public virtual GEOM_IOperations_i +{ + public: + GEOM_I3DPrimOperations_i (PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr theEngine, + ::GEOMImpl_I3DPrimOperations* theImpl); + ~GEOM_I3DPrimOperations_i(); + + GEOM::GEOM_Object_ptr MakeBoxDXDYDZ (CORBA::Double theDX, + CORBA::Double theDY, + CORBA::Double theDZ); + + GEOM::GEOM_Object_ptr MakeBoxTwoPnt (GEOM::GEOM_Object_ptr thePnt1, + GEOM::GEOM_Object_ptr thePnt2); + + GEOM::GEOM_Object_ptr MakeCylinderRH (CORBA::Double theR, + CORBA::Double theH); + + GEOM::GEOM_Object_ptr MakeCylinderPntVecRH (GEOM::GEOM_Object_ptr thePnt, + GEOM::GEOM_Object_ptr theVec, + CORBA::Double theR, + CORBA::Double theH); + + GEOM::GEOM_Object_ptr MakeConeR1R2H (CORBA::Double theR1, + CORBA::Double theR2, + CORBA::Double theH); + + GEOM::GEOM_Object_ptr MakeConePntVecR1R2H (GEOM::GEOM_Object_ptr thePnt, + GEOM::GEOM_Object_ptr theVec, + CORBA::Double theR1, + CORBA::Double theR2, + CORBA::Double theH); + + GEOM::GEOM_Object_ptr MakeSphereR (CORBA::Double theR); + + GEOM::GEOM_Object_ptr MakeSpherePntR (GEOM::GEOM_Object_ptr thePnt, + CORBA::Double theR); + + GEOM::GEOM_Object_ptr MakeTorusRR (CORBA::Double theRMajor, + CORBA::Double theRMinor); + + GEOM::GEOM_Object_ptr MakeTorusPntVecRR (GEOM::GEOM_Object_ptr theCenter, + GEOM::GEOM_Object_ptr theVector, + CORBA::Double theRMajor, + CORBA::Double theRMinor); + + GEOM::GEOM_Object_ptr MakePrismVecH (GEOM::GEOM_Object_ptr theBase, + GEOM::GEOM_Object_ptr theVec, + CORBA::Double theH); + + GEOM::GEOM_Object_ptr MakePrismTwoPnt (GEOM::GEOM_Object_ptr theBase, + GEOM::GEOM_Object_ptr thePoint1, + GEOM::GEOM_Object_ptr thePoint2); + + GEOM::GEOM_Object_ptr MakePipe (GEOM::GEOM_Object_ptr theBase, + GEOM::GEOM_Object_ptr thePath); + + GEOM::GEOM_Object_ptr MakeRevolutionAxisAngle (GEOM::GEOM_Object_ptr theBase, + GEOM::GEOM_Object_ptr theAxis, + CORBA::Double theAngle); + + GEOM::GEOM_Object_ptr MakeFilling(GEOM::GEOM_Object_ptr theShape, CORBA::Long theMinDeg, CORBA::Long theMaxDeg, CORBA::Double theTol2D, CORBA::Double theTol3D, CORBA::Long theNbIter); + + ::GEOMImpl_I3DPrimOperations* GetOperations() + { return (::GEOMImpl_I3DPrimOperations*)GetImpl(); } +}; + +#endif diff --git a/src/GEOM_I/GEOM_IBasicOperations_i.cc b/src/GEOM_I/GEOM_IBasicOperations_i.cc new file mode 100644 index 000000000..0cf0e8366 --- /dev/null +++ b/src/GEOM_I/GEOM_IBasicOperations_i.cc @@ -0,0 +1,371 @@ +using namespace std; + +#include "GEOM_IBasicOperations_i.hh" + +#include "utilities.h" +#include "OpUtil.hxx" +#include "Utils_ExceptHandlers.hxx" + +#include "GEOM_Engine.hxx" +#include "GEOM_Object.hxx" + +//============================================================================= +/*! + * constructor: + */ +//============================================================================= +GEOM_IBasicOperations_i::GEOM_IBasicOperations_i (PortableServer::POA_ptr thePOA, + GEOM::GEOM_Gen_ptr theEngine, + ::GEOMImpl_IBasicOperations* theImpl) + :GEOM_IOperations_i(thePOA, theEngine, theImpl) +{ + MESSAGE("GEOM_IBasicOperations_i::GEOM_IBasicOperations_i"); +} + +//============================================================================= +/*! + * destructor + */ +//============================================================================= +GEOM_IBasicOperations_i::~GEOM_IBasicOperations_i() +{ + MESSAGE("GEOM_IBasicOperations_i::~GEOM_IBasicOperations_i"); +} + + +//============================================================================= +/*! + * MakePointXYZ + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointXYZ + (CORBA::Double theX, CORBA::Double theY, CORBA::Double theZ) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Create the point + + Handle(GEOM_Object) anObject = GetOperations()->MakePointXYZ(theX, theY, theZ); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakePointWithReference + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointWithReference + (GEOM::GEOM_Object_ptr theReference, CORBA::Double theX, CORBA::Double theY, CORBA::Double theZ) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if(theReference == NULL) return aGEOMObject._retn(); + + //Get the reference point + + Handle(GEOM_Object) aRefernce = GetOperations()->GetEngine()->GetObject + (theReference->GetStudyID(), theReference->GetEntry()); + if (aRefernce.IsNull()) return aGEOMObject._retn(); + + //Create the point + + Handle(GEOM_Object) anObject = + GetOperations()->MakePointWithReference(aRefernce, theX, theY, theZ); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakePointOnCurve + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnCurve + (GEOM::GEOM_Object_ptr theCurve, CORBA::Double theParameter) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theCurve == NULL) return aGEOMObject._retn(); + + //Get the reference curve + + Handle(GEOM_Object) aRefernce = GetOperations()->GetEngine()->GetObject + (theCurve->GetStudyID(), theCurve->GetEntry()); + if (aRefernce.IsNull()) return aGEOMObject._retn(); + + //Create the point + + Handle(GEOM_Object) anObject = + GetOperations()->MakePointOnCurve(aRefernce, theParameter); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + + +//============================================================================= +/*! + * MakeVectorDXDYDZ + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeVectorDXDYDZ + (CORBA::Double theDX, CORBA::Double theDY, CORBA::Double theDZ) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Create the Vector + + Handle(GEOM_Object) anObject = GetOperations()->MakeVectorDXDYDZ(theDX, theDY, theDZ); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakeVectorTwoPnt + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeVectorTwoPnt + (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (thePnt1 == NULL || thePnt2 == NULL) return aGEOMObject._retn(); + + //Get the reference points + + Handle(GEOM_Object) aRef1 = GetOperations()->GetEngine()->GetObject + (thePnt1->GetStudyID(), thePnt1->GetEntry()); + Handle(GEOM_Object) aRef2 = GetOperations()->GetEngine()->GetObject + (thePnt2->GetStudyID(), thePnt2->GetEntry()); + if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn(); + + //Create the vector + + Handle(GEOM_Object) anObject = + GetOperations()->MakeVectorTwoPnt(aRef1, aRef2); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + + +//============================================================================= +/*! + * MakeLine + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeLine + (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theDir) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (thePnt == NULL || theDir == NULL) return aGEOMObject._retn(); + + //Get the reference objects + + Handle(GEOM_Object) aRef1 = GetOperations()->GetEngine()->GetObject + (thePnt->GetStudyID(), thePnt->GetEntry()); + Handle(GEOM_Object) aRef2 = GetOperations()->GetEngine()->GetObject + (theDir->GetStudyID(), theDir->GetEntry()); + if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn(); + + //Create the Line + + Handle(GEOM_Object) anObject = + GetOperations()->MakeLine(aRef1, aRef2); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakeLineTwoPnt + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeLineTwoPnt + (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (thePnt1 == NULL || thePnt2 == NULL) return aGEOMObject._retn(); + + //Get the reference points + + Handle(GEOM_Object) aRef1 = GetOperations()->GetEngine()->GetObject + (thePnt1->GetStudyID(), thePnt1->GetEntry()); + Handle(GEOM_Object) aRef2 = GetOperations()->GetEngine()->GetObject + (thePnt2->GetStudyID(), thePnt2->GetEntry()); + if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn(); + + //Create the Line + + Handle(GEOM_Object) anObject = + GetOperations()->MakeLineTwoPnt(aRef1, aRef2); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + + +//============================================================================= +/*! + * MakePlanePntVec + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlanePntVec + (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec, + CORBA::Double theTrimSize) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (thePnt == NULL || theVec == NULL) return aGEOMObject._retn(); + + //Get the references + + Handle(GEOM_Object) aRef1 = GetOperations()->GetEngine()->GetObject + (thePnt->GetStudyID(), thePnt->GetEntry()); + Handle(GEOM_Object) aRef2 = GetOperations()->GetEngine()->GetObject + (theVec->GetStudyID(), theVec->GetEntry()); + if (aRef1.IsNull() || aRef2.IsNull()) return aGEOMObject._retn(); + + //Create the plane + + Handle(GEOM_Object) anObject = + GetOperations()->MakePlanePntVec(aRef1, aRef2, theTrimSize); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakePlaneThreePnt + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlaneThreePnt + (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2, + GEOM::GEOM_Object_ptr thePnt3, CORBA::Double theTrimSize) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (thePnt1 == NULL || thePnt2 == NULL || thePnt3 == NULL) + return aGEOMObject._retn(); + + //Get the reference points + + Handle(GEOM_Object) aRef1 = GetOperations()->GetEngine()->GetObject + (thePnt1->GetStudyID(), thePnt1->GetEntry()); + Handle(GEOM_Object) aRef2 = GetOperations()->GetEngine()->GetObject + (thePnt2->GetStudyID(), thePnt2->GetEntry()); + Handle(GEOM_Object) aRef3 = GetOperations()->GetEngine()->GetObject + (thePnt3->GetStudyID(), thePnt3->GetEntry()); + if (aRef1.IsNull() || aRef2.IsNull() || aRef3.IsNull()) + return aGEOMObject._retn(); + + //Create the plane + + Handle(GEOM_Object) anObject = + GetOperations()->MakePlaneThreePnt(aRef1, aRef2, aRef3, theTrimSize); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakePlaneFace + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePlaneFace + (GEOM::GEOM_Object_ptr theFace, CORBA::Double theTrimSize) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theFace == NULL) return aGEOMObject._retn(); + + //Get the reference face + + Handle(GEOM_Object) aRef = GetOperations()->GetEngine()->GetObject + (theFace->GetStudyID(), theFace->GetEntry()); + if (aRef.IsNull()) return aGEOMObject._retn(); + + //Create the plane + + Handle(GEOM_Object) anObject = + GetOperations()->MakePlaneFace(aRef, theTrimSize); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + + +//============================================================================= +/*! + * MakeMarker + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeMarker + (CORBA::Double theOX , CORBA::Double theOY , CORBA::Double theOZ, + CORBA::Double theXDX, CORBA::Double theXDY, CORBA::Double theXDZ, + CORBA::Double theYDX, CORBA::Double theYDY, CORBA::Double theYDZ) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Create the point + Handle(GEOM_Object) anObject = GetOperations()->MakeMarker(theOX , theOY , theOZ, + theXDX, theXDY, theXDZ, + theYDX, theYDY, theYDZ); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} diff --git a/src/GEOM_I/GEOM_IBasicOperations_i.hh b/src/GEOM_I/GEOM_IBasicOperations_i.hh new file mode 100644 index 000000000..5bedb15a9 --- /dev/null +++ b/src/GEOM_I/GEOM_IBasicOperations_i.hh @@ -0,0 +1,68 @@ + +#ifndef _GEOM_IBasicOperations_i_HeaderFile +#define _GEOM_IBasicOperations_i_HeaderFile + + +#include + +#include CORBA_SERVER_HEADER(GEOM_Gen) +#include "GEOM_IOperations_i.hh" +#include "GEOM_Object_i.hh" + +#include "GEOMImpl_IBasicOperations.hxx" + +class GEOM_IBasicOperations_i : + public virtual POA_GEOM::GEOM_IBasicOperations, + public virtual GEOM_IOperations_i +{ + public: + GEOM_IBasicOperations_i (PortableServer::POA_ptr thePOA, + GEOM::GEOM_Gen_ptr theEngine, + ::GEOMImpl_IBasicOperations* theImpl); + ~GEOM_IBasicOperations_i(); + + GEOM::GEOM_Object_ptr MakePointXYZ (CORBA::Double theX, + CORBA::Double theY, + CORBA::Double theZ); + + GEOM::GEOM_Object_ptr MakePointWithReference (GEOM::GEOM_Object_ptr theReference, + CORBA::Double theX, + CORBA::Double theY, + CORBA::Double theZ); + + GEOM::GEOM_Object_ptr MakePointOnCurve (GEOM::GEOM_Object_ptr theCurve, + CORBA::Double theParameter); + + GEOM::GEOM_Object_ptr MakeVectorDXDYDZ (CORBA::Double theDX, + CORBA::Double theDY, + CORBA::Double theDZ); + + GEOM::GEOM_Object_ptr MakeVectorTwoPnt (GEOM::GEOM_Object_ptr thePnt1, + GEOM::GEOM_Object_ptr thePnt2); + + GEOM::GEOM_Object_ptr MakeLine (GEOM::GEOM_Object_ptr thePnt, + GEOM::GEOM_Object_ptr theDir); + + GEOM::GEOM_Object_ptr MakeLineTwoPnt (GEOM::GEOM_Object_ptr thePnt1, + GEOM::GEOM_Object_ptr thePnt2); + + GEOM::GEOM_Object_ptr MakePlaneThreePnt (GEOM::GEOM_Object_ptr thePnt1, + GEOM::GEOM_Object_ptr thePnt2, + GEOM::GEOM_Object_ptr thePnt3, + CORBA::Double theTrimSize); + + GEOM::GEOM_Object_ptr MakePlanePntVec (GEOM::GEOM_Object_ptr thePnt, + GEOM::GEOM_Object_ptr theVec, + CORBA::Double theTrimSize); + + GEOM::GEOM_Object_ptr MakePlaneFace (GEOM::GEOM_Object_ptr theFace, + CORBA::Double theTrimSize); + + GEOM::GEOM_Object_ptr MakeMarker (CORBA::Double theOX , CORBA::Double theOY , CORBA::Double theOZ, + CORBA::Double theXDX, CORBA::Double theXDY, CORBA::Double theXDZ, + CORBA::Double theYDX, CORBA::Double theYDY, CORBA::Double theYDZ); + + ::GEOMImpl_IBasicOperations* GetOperations() { return (::GEOMImpl_IBasicOperations*)GetImpl(); } +}; + +#endif diff --git a/src/GEOM_I/GEOM_IBlocksOperations_i.cc b/src/GEOM_I/GEOM_IBlocksOperations_i.cc new file mode 100644 index 000000000..a5aeb7ee8 --- /dev/null +++ b/src/GEOM_I/GEOM_IBlocksOperations_i.cc @@ -0,0 +1,939 @@ +using namespace std; + +#include "GEOM_IBlocksOperations_i.hh" + +#include "utilities.h" +#include "OpUtil.hxx" +#include "Utils_ExceptHandlers.hxx" + +#include "GEOM_Engine.hxx" +#include "GEOM_Object.hxx" + +#include +#include + +//============================================================================= +/*! + * constructor: + */ +//============================================================================= +GEOM_IBlocksOperations_i::GEOM_IBlocksOperations_i (PortableServer::POA_ptr thePOA, + GEOM::GEOM_Gen_ptr theEngine, + ::GEOMImpl_IBlocksOperations* theImpl) +:GEOM_IOperations_i(thePOA, theEngine, theImpl) +{ + MESSAGE("GEOM_IBlocksOperations_i::GEOM_IBlocksOperations_i"); +} + +//============================================================================= +/*! + * destructor + */ +//============================================================================= +GEOM_IBlocksOperations_i::~GEOM_IBlocksOperations_i() +{ + MESSAGE("GEOM_IBlocksOperations_i::~GEOM_IBlocksOperations_i"); +} + + +//============================================================================= +/*! + * MakeQuad + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeQuad + (GEOM::GEOM_Object_ptr theEdge1, GEOM::GEOM_Object_ptr theEdge2, + GEOM::GEOM_Object_ptr theEdge3, GEOM::GEOM_Object_ptr theEdge4) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theEdge1 == NULL || theEdge2 == NULL || + theEdge3 == NULL || theEdge4 == NULL) return aGEOMObject._retn(); + + //Get the reference edges + Handle(GEOM_Object) anEdge1 = GetOperations()->GetEngine()->GetObject + (theEdge1->GetStudyID(), theEdge1->GetEntry()); + Handle(GEOM_Object) anEdge2 = GetOperations()->GetEngine()->GetObject + (theEdge2->GetStudyID(), theEdge2->GetEntry()); + Handle(GEOM_Object) anEdge3 = GetOperations()->GetEngine()->GetObject + (theEdge3->GetStudyID(), theEdge3->GetEntry()); + Handle(GEOM_Object) anEdge4 = GetOperations()->GetEngine()->GetObject + (theEdge4->GetStudyID(), theEdge4->GetEntry()); + + if (anEdge1.IsNull() || anEdge2.IsNull() || + anEdge3.IsNull() || anEdge4.IsNull()) return aGEOMObject._retn(); + + //Create the Face + Handle(GEOM_Object) anObject = + GetOperations()->MakeQuad(anEdge1, anEdge2, anEdge3, anEdge4); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakeQuad2Edges + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeQuad2Edges + (GEOM::GEOM_Object_ptr theEdge1, GEOM::GEOM_Object_ptr theEdge2) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theEdge1 == NULL || theEdge2 == NULL) return aGEOMObject._retn(); + + //Get the reference edges + Handle(GEOM_Object) anEdge1 = GetOperations()->GetEngine()->GetObject + (theEdge1->GetStudyID(), theEdge1->GetEntry()); + Handle(GEOM_Object) anEdge2 = GetOperations()->GetEngine()->GetObject + (theEdge2->GetStudyID(), theEdge2->GetEntry()); + + if (anEdge1.IsNull() || anEdge2.IsNull()) return aGEOMObject._retn(); + + //Create the Face + Handle(GEOM_Object) anObject = + GetOperations()->MakeQuad2Edges(anEdge1, anEdge2); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakeQuad4Vertices + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeQuad4Vertices + (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2, + GEOM::GEOM_Object_ptr thePnt3, GEOM::GEOM_Object_ptr thePnt4) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (thePnt1 == NULL || thePnt2 == NULL || + thePnt3 == NULL || thePnt4 == NULL) return aGEOMObject._retn(); + + //Get the reference points + Handle(GEOM_Object) aPnt1 = GetOperations()->GetEngine()->GetObject + (thePnt1->GetStudyID(), thePnt1->GetEntry()); + Handle(GEOM_Object) aPnt2 = GetOperations()->GetEngine()->GetObject + (thePnt2->GetStudyID(), thePnt2->GetEntry()); + Handle(GEOM_Object) aPnt3 = GetOperations()->GetEngine()->GetObject + (thePnt3->GetStudyID(), thePnt3->GetEntry()); + Handle(GEOM_Object) aPnt4 = GetOperations()->GetEngine()->GetObject + (thePnt4->GetStudyID(), thePnt4->GetEntry()); + + if (aPnt1.IsNull() || aPnt2.IsNull() || + aPnt3.IsNull() || aPnt4.IsNull()) return aGEOMObject._retn(); + + //Create the Face + Handle(GEOM_Object) anObject = + GetOperations()->MakeQuad4Vertices(aPnt1, aPnt2, aPnt3, aPnt4); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakeHexa + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeHexa + (GEOM::GEOM_Object_ptr theFace1, GEOM::GEOM_Object_ptr theFace2, + GEOM::GEOM_Object_ptr theFace3, GEOM::GEOM_Object_ptr theFace4, + GEOM::GEOM_Object_ptr theFace5, GEOM::GEOM_Object_ptr theFace6) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theFace1 == NULL || theFace2 == NULL || + theFace3 == NULL || theFace4 == NULL || + theFace5 == NULL || theFace6 == NULL) return aGEOMObject._retn(); + + //Get the reference Faces + Handle(GEOM_Object) anFace1 = GetOperations()->GetEngine()->GetObject + (theFace1->GetStudyID(), theFace1->GetEntry()); + Handle(GEOM_Object) anFace2 = GetOperations()->GetEngine()->GetObject + (theFace2->GetStudyID(), theFace2->GetEntry()); + Handle(GEOM_Object) anFace3 = GetOperations()->GetEngine()->GetObject + (theFace3->GetStudyID(), theFace3->GetEntry()); + Handle(GEOM_Object) anFace4 = GetOperations()->GetEngine()->GetObject + (theFace4->GetStudyID(), theFace4->GetEntry()); + Handle(GEOM_Object) anFace5 = GetOperations()->GetEngine()->GetObject + (theFace5->GetStudyID(), theFace5->GetEntry()); + Handle(GEOM_Object) anFace6 = GetOperations()->GetEngine()->GetObject + (theFace6->GetStudyID(), theFace6->GetEntry()); + + if (anFace1.IsNull() || anFace2.IsNull() || + anFace3.IsNull() || anFace4.IsNull() || + anFace5.IsNull() || anFace6.IsNull()) return aGEOMObject._retn(); + + //Create the Face + Handle(GEOM_Object) anObject = GetOperations()->MakeHexa + (anFace1, anFace2, anFace3, anFace4, anFace5, anFace6); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakeHexa2Faces + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeHexa2Faces + (GEOM::GEOM_Object_ptr theFace1, GEOM::GEOM_Object_ptr theFace2) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theFace1 == NULL || theFace2 == NULL) return aGEOMObject._retn(); + + //Get the reference Faces + Handle(GEOM_Object) anFace1 = GetOperations()->GetEngine()->GetObject + (theFace1->GetStudyID(), theFace1->GetEntry()); + Handle(GEOM_Object) anFace2 = GetOperations()->GetEngine()->GetObject + (theFace2->GetStudyID(), theFace2->GetEntry()); + + if (anFace1.IsNull() || anFace2.IsNull()) return aGEOMObject._retn(); + + //Create the Face + Handle(GEOM_Object) anObject = + GetOperations()->MakeHexa2Faces(anFace1, anFace2); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakeBlockCompound + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeBlockCompound + (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 Compound + Handle(GEOM_Object) aCompound = GetOperations()->GetEngine()->GetObject + (theCompound->GetStudyID(), theCompound->GetEntry()); + + if (aCompound.IsNull()) return aGEOMObject._retn(); + + //Create the Blocks Compound + Handle(GEOM_Object) anObject = + GetOperations()->MakeBlockCompound(aCompound); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * GetPoint + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetPoint (GEOM::GEOM_Object_ptr theShape, + const CORBA::Double theX, + const CORBA::Double theY, + const CORBA::Double theZ, + const CORBA::Double theEpsilon) +{ + 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(); + + //Create the Point + Handle(GEOM_Object) anObject = + GetOperations()->GetPoint(aShape, theX, theY, theZ, theEpsilon); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * GetEdge + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetEdge (GEOM::GEOM_Object_ptr theShape, + GEOM::GEOM_Object_ptr thePoint1, + GEOM::GEOM_Object_ptr thePoint2) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theShape == NULL || + thePoint1 == NULL || thePoint2 == NULL) return aGEOMObject._retn(); + + //Get the reference Objects + Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject + (theShape->GetStudyID(), theShape->GetEntry()); + Handle(GEOM_Object) aPoint1 = GetOperations()->GetEngine()->GetObject + (thePoint1->GetStudyID(), thePoint1->GetEntry()); + Handle(GEOM_Object) aPoint2 = GetOperations()->GetEngine()->GetObject + (thePoint2->GetStudyID(), thePoint2->GetEntry()); + + if (aShape.IsNull() || + aPoint1.IsNull() || aPoint2.IsNull()) return aGEOMObject._retn(); + + //Create the Point + Handle(GEOM_Object) anObject = + GetOperations()->GetEdge(aShape, aPoint1, aPoint2); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * GetEdgeNearPoint + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetEdgeNearPoint (GEOM::GEOM_Object_ptr theShape, + GEOM::GEOM_Object_ptr thePoint) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theShape == NULL || thePoint == NULL) return aGEOMObject._retn(); + + //Get the reference Objects + Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject + (theShape->GetStudyID(), theShape->GetEntry()); + Handle(GEOM_Object) aPoint = GetOperations()->GetEngine()->GetObject + (thePoint->GetStudyID(), thePoint->GetEntry()); + + if (aShape.IsNull() || aPoint.IsNull()) return aGEOMObject._retn(); + + //Create the Edge + Handle(GEOM_Object) anObject = + GetOperations()->GetEdgeNearPoint(aShape, aPoint); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * GetFaceByPoints + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetFaceByPoints + (GEOM::GEOM_Object_ptr theShape, + GEOM::GEOM_Object_ptr thePoint1, + GEOM::GEOM_Object_ptr thePoint2, + GEOM::GEOM_Object_ptr thePoint3, + GEOM::GEOM_Object_ptr thePoint4) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theShape == NULL || + thePoint1 == NULL || thePoint2 == NULL || + thePoint3 == NULL || thePoint4 == NULL) return aGEOMObject._retn(); + + //Get the reference Objects + Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject + (theShape->GetStudyID(), theShape->GetEntry()); + Handle(GEOM_Object) aPoint1 = GetOperations()->GetEngine()->GetObject + (thePoint1->GetStudyID(), thePoint1->GetEntry()); + Handle(GEOM_Object) aPoint2 = GetOperations()->GetEngine()->GetObject + (thePoint2->GetStudyID(), thePoint2->GetEntry()); + Handle(GEOM_Object) aPoint3 = GetOperations()->GetEngine()->GetObject + (thePoint3->GetStudyID(), thePoint3->GetEntry()); + Handle(GEOM_Object) aPoint4 = GetOperations()->GetEngine()->GetObject + (thePoint4->GetStudyID(), thePoint4->GetEntry()); + + if (aShape.IsNull() || + aPoint1.IsNull() || aPoint2.IsNull() || + aPoint3.IsNull() || aPoint4.IsNull()) return aGEOMObject._retn(); + + //Create the Face + Handle(GEOM_Object) anObject = + GetOperations()->GetFaceByPoints(aShape, aPoint1, aPoint2, aPoint3, aPoint4); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * GetFaceByEdges + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetFaceByEdges + (GEOM::GEOM_Object_ptr theShape, + GEOM::GEOM_Object_ptr theEdge1, + GEOM::GEOM_Object_ptr theEdge2) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theShape == NULL || + theEdge1 == NULL || theEdge2 == NULL) return aGEOMObject._retn(); + + //Get the reference Objects + Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject + (theShape->GetStudyID(), theShape->GetEntry()); + Handle(GEOM_Object) anEdge1 = GetOperations()->GetEngine()->GetObject + (theEdge1->GetStudyID(), theEdge1->GetEntry()); + Handle(GEOM_Object) anEdge2 = GetOperations()->GetEngine()->GetObject + (theEdge2->GetStudyID(), theEdge2->GetEntry()); + + if (aShape.IsNull() || + anEdge1.IsNull() || anEdge2.IsNull()) return aGEOMObject._retn(); + + //Create the Face + Handle(GEOM_Object) anObject = + GetOperations()->GetFaceByEdges(aShape, anEdge1, anEdge2); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * GetOppositeFace + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetOppositeFace (GEOM::GEOM_Object_ptr theShape, + GEOM::GEOM_Object_ptr theFace) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theShape == NULL || theFace == NULL) return aGEOMObject._retn(); + + //Get the reference Objects + Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject + (theShape->GetStudyID(), theShape->GetEntry()); + Handle(GEOM_Object) aFace = GetOperations()->GetEngine()->GetObject + (theFace->GetStudyID(), theFace->GetEntry()); + + if (aShape.IsNull() || aFace.IsNull()) return aGEOMObject._retn(); + + //Create the Face + Handle(GEOM_Object) anObject = + GetOperations()->GetOppositeFace(aShape, aFace); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * GetFaceNearPoint + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetFaceNearPoint (GEOM::GEOM_Object_ptr theShape, + GEOM::GEOM_Object_ptr thePoint) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theShape == NULL || thePoint == NULL) return aGEOMObject._retn(); + + //Get the reference Objects + Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject + (theShape->GetStudyID(), theShape->GetEntry()); + Handle(GEOM_Object) aPoint = GetOperations()->GetEngine()->GetObject + (thePoint->GetStudyID(), thePoint->GetEntry()); + + if (aShape.IsNull() || aPoint.IsNull()) return aGEOMObject._retn(); + + //Create the Face + Handle(GEOM_Object) anObject = + GetOperations()->GetFaceNearPoint(aShape, aPoint); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * GetFaceByNormale + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetFaceByNormale (GEOM::GEOM_Object_ptr theShape, + GEOM::GEOM_Object_ptr theVector) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theShape == NULL || theVector == NULL) return aGEOMObject._retn(); + + //Get the reference Objects + Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject + (theShape->GetStudyID(), theShape->GetEntry()); + Handle(GEOM_Object) aVector = GetOperations()->GetEngine()->GetObject + (theVector->GetStudyID(), theVector->GetEntry()); + + if (aShape.IsNull() || aVector.IsNull()) return aGEOMObject._retn(); + + //Create the Face + Handle(GEOM_Object) anObject = + GetOperations()->GetFaceByNormale(aShape, aVector); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * ExplodeCompoundOfBlocks + */ +//============================================================================= +GEOM::ListOfGO* GEOM_IBlocksOperations_i::ExplodeCompoundOfBlocks + (GEOM::GEOM_Object_ptr theCompound, + const CORBA::Long theMinNbFaces, + const CORBA::Long theMaxNbFaces) +{ + GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theCompound == NULL) return aSeq._retn(); + + //Get the reference Compound + Handle(GEOM_Object) aCompound = GetOperations()->GetEngine()->GetObject + (theCompound->GetStudyID(), theCompound->GetEntry()); + + if (aCompound.IsNull()) return aSeq._retn(); + + //Explode + Handle(TColStd_HSequenceOfTransient) aHSeq = + GetOperations()->ExplodeCompoundOfBlocks(aCompound, theMinNbFaces, theMaxNbFaces); + 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(); +} + +//============================================================================= +/*! + * IsCompoundOfBlocks + */ +//============================================================================= +CORBA::Boolean GEOM_IBlocksOperations_i::IsCompoundOfBlocks + (GEOM::GEOM_Object_ptr theCompound, + const CORBA::Long theMinNbFaces, + const CORBA::Long theMaxNbFaces, + CORBA::Long& theNbBlocks) +{ + theNbBlocks = 0; + CORBA::Boolean isComp = false; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theCompound == NULL) return isComp; + + //Get the reference Compound + Handle(GEOM_Object) aCompound = GetOperations()->GetEngine()->GetObject + (theCompound->GetStudyID(), theCompound->GetEntry()); + + if (aCompound.IsNull()) return isComp; + + //Check + Standard_Integer nbBlocks = 0; + isComp = GetOperations()->IsCompoundOfBlocks(aCompound, + theMinNbFaces, + theMaxNbFaces, + nbBlocks); + if (!GetOperations()->IsDone()) + return isComp; + + theNbBlocks = nbBlocks; + return isComp; +} + +//============================================================================= +/*! + * CheckCompoundOfBlocks + */ +//============================================================================= +CORBA::Boolean GEOM_IBlocksOperations_i::CheckCompoundOfBlocks + (GEOM::GEOM_Object_ptr theCompound, + GEOM::GEOM_IBlocksOperations::BCErrors_out theErrors) +{ + CORBA::Boolean isComp = false; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theCompound == NULL) return isComp; + + //Get the reference Compound + Handle(GEOM_Object) aCompound = GetOperations()->GetEngine()->GetObject + (theCompound->GetStudyID(), theCompound->GetEntry()); + + if (aCompound.IsNull()) return isComp; + + //Check + list errList; + isComp = GetOperations()->CheckCompoundOfBlocks(aCompound, errList); + if (!GetOperations()->IsDone()) + return isComp; + + const int nbErr = errList.size(); + GEOM::GEOM_IBlocksOperations::BCErrors_var anErrArray = + new GEOM::GEOM_IBlocksOperations::BCErrors(); + anErrArray->length(nbErr); + + // fill the local CORBA array with values from lists + list::iterator errIt = errList.begin(); + int i = 0; + for (; errIt != errList.end(); i++, errIt++) { + GEOM::GEOM_IBlocksOperations::BCError_var anError = + new GEOM::GEOM_IBlocksOperations::BCError(); + + GEOMImpl_IBlocksOperations::BCError errStruct = *errIt; + + switch (errStruct.error) { + case GEOMImpl_IBlocksOperations::NOT_BLOCK: + anError->error = GEOM::GEOM_IBlocksOperations::NOT_BLOCK; + break; + case GEOMImpl_IBlocksOperations::INVALID_CONNECTION: + anError->error = GEOM::GEOM_IBlocksOperations::INVALID_CONNECTION; + break; + case GEOMImpl_IBlocksOperations::NOT_CONNECTED: + anError->error = GEOM::GEOM_IBlocksOperations::NOT_CONNECTED; + break; + case GEOMImpl_IBlocksOperations::NOT_GLUED: + anError->error = GEOM::GEOM_IBlocksOperations::NOT_GLUED; + break; + default: + break; + } + + list sshList = errStruct.incriminated; + GEOM::ListOfLong_var anIncrims = new GEOM::ListOfLong(); + anIncrims->length(sshList.size()); + + list::iterator sshIt = sshList.begin(); + int jj = 0; + for (; sshIt != sshList.end(); jj++, sshIt++) { + anIncrims[jj] = *sshIt; + } + + anError->incriminated = anIncrims; + + anErrArray[i] = anError; + } + + // initialize out-parameter with local array + theErrors = anErrArray._retn(); + + return isComp; +} + +//============================================================================= +/*! + * PrintBCErrors + */ +//============================================================================= +char* GEOM_IBlocksOperations_i::PrintBCErrors + (GEOM::GEOM_Object_ptr theCompound, + const GEOM::GEOM_IBlocksOperations::BCErrors& theErrors) +{ + //Get the reference Compound + if (theCompound == NULL) return NULL; + Handle(GEOM_Object) aCompound = GetOperations()->GetEngine()->GetObject + (theCompound->GetStudyID(), theCompound->GetEntry()); + if (aCompound.IsNull()) return NULL; + + // Convert the errors sequence + list anErrors; + int nbErr = theErrors.length(); + int ie = 0; + for (; ie < nbErr; ie++) { + const GEOM::GEOM_IBlocksOperations::BCError err = theErrors[ie]; + const GEOM::GEOM_IBlocksOperations::BCErrorType typ = err.error; + const GEOM::ListOfLong incrims = err.incriminated; + + GEOMImpl_IBlocksOperations::BCError errStruct; + switch (typ) { + case GEOM::GEOM_IBlocksOperations::NOT_BLOCK: + errStruct.error = GEOMImpl_IBlocksOperations::NOT_BLOCK; + break; + case GEOM::GEOM_IBlocksOperations::INVALID_CONNECTION: + errStruct.error = GEOMImpl_IBlocksOperations::INVALID_CONNECTION; + break; + case GEOM::GEOM_IBlocksOperations::NOT_CONNECTED: + errStruct.error = GEOMImpl_IBlocksOperations::NOT_CONNECTED; + break; + case GEOM::GEOM_IBlocksOperations::NOT_GLUED: + errStruct.error = GEOMImpl_IBlocksOperations::NOT_GLUED; + break; + default: + break; + } + + int ii = 0; + int aLen = incrims.length(); + for (; ii < aLen; ii++) { + errStruct.incriminated.push_back(incrims[ii]); + } + + anErrors.push_back(errStruct); + } + + TCollection_AsciiString aDescr = GetOperations()->PrintBCErrors(aCompound, anErrors); + return CORBA::string_dup(aDescr.ToCString()); +} + +//============================================================================= +/*! + * GetBlockNearPoint + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetBlockNearPoint (GEOM::GEOM_Object_ptr theCompound, + GEOM::GEOM_Object_ptr thePoint) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theCompound == NULL || thePoint == NULL) return aGEOMObject._retn(); + + //Get the reference Objects + Handle(GEOM_Object) aCompound = GetOperations()->GetEngine()->GetObject + (theCompound->GetStudyID(), theCompound->GetEntry()); + Handle(GEOM_Object) aPoint = GetOperations()->GetEngine()->GetObject + (thePoint->GetStudyID(), thePoint->GetEntry()); + + if (aCompound.IsNull() || aPoint.IsNull()) return aGEOMObject._retn(); + + //Get the block + Handle(GEOM_Object) anObject = + GetOperations()->GetBlockNearPoint(aCompound, aPoint); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * GetBlockByParts + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetBlockByParts (GEOM::GEOM_Object_ptr theCompound, + const GEOM::ListOfGO& theParts) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theCompound == NULL) return aGEOMObject._retn(); + + //Get the reference Compound + Handle(GEOM_Object) aCompound = GetOperations()->GetEngine()->GetObject + (theCompound->GetStudyID(), theCompound->GetEntry()); + + if (aCompound.IsNull()) return aGEOMObject._retn(); + + //Get the parts + int ind, aLen; + Handle(TColStd_HSequenceOfTransient) aParts = new TColStd_HSequenceOfTransient; + + aLen = theParts.length(); + for (ind = 0; ind < aLen; ind++) { + if (theParts[ind] == NULL) return aGEOMObject._retn(); + Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject + (theParts[ind]->GetStudyID(), theParts[ind]->GetEntry()); + if (aSh.IsNull()) return aGEOMObject._retn(); + aParts->Append(aSh); + } + + //Get the Block + Handle(GEOM_Object) anObject = + GetOperations()->GetBlockByParts(aCompound, aParts); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * GetBlocksByParts + */ +//============================================================================= +GEOM::ListOfGO* GEOM_IBlocksOperations_i::GetBlocksByParts (GEOM::GEOM_Object_ptr theCompound, + const GEOM::ListOfGO& theParts) +{ + GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theCompound == NULL) return aSeq._retn(); + + //Get the reference Compound + Handle(GEOM_Object) aCompound = GetOperations()->GetEngine()->GetObject + (theCompound->GetStudyID(), theCompound->GetEntry()); + + if (aCompound.IsNull()) return aSeq._retn(); + + //Get the parts + int ind, aLen; + Handle(TColStd_HSequenceOfTransient) aParts = new TColStd_HSequenceOfTransient; + + aLen = theParts.length(); + for (ind = 0; ind < aLen; ind++) { + if (theParts[ind] == NULL) return aSeq._retn(); + Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject + (theParts[ind]->GetStudyID(), theParts[ind]->GetEntry()); + if (aSh.IsNull()) return aSeq._retn(); + aParts->Append(aSh); + } + + //Get the Block + Handle(TColStd_HSequenceOfTransient) aHSeq = + GetOperations()->GetBlocksByParts(aCompound, aParts); + 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(); +} + +//============================================================================= +/*! + * MakeMultiTransformation1D + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeMultiTransformation1D + (GEOM::GEOM_Object_ptr theBlock, + const CORBA::Long theDirFace1, + const CORBA::Long theDirFace2, + const CORBA::Long theNbTimes) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theBlock == NULL) return aGEOMObject._retn(); + + //Get the object itself and the vector of translation + Handle(GEOM_Object) aBasicObject = GetOperations()->GetEngine()->GetObject + (theBlock->GetStudyID(), theBlock->GetEntry()); + + if (aBasicObject.IsNull()) return aGEOMObject._retn(); + + //Perform the transformation + Handle(GEOM_Object) anObject = GetOperations()->MakeMultiTransformation1D + (aBasicObject, theDirFace1, theDirFace2, theNbTimes); + if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakeMultiTransformation2D + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeMultiTransformation2D + (GEOM::GEOM_Object_ptr theBlock, + const CORBA::Long theDirFace1U, + const CORBA::Long theDirFace2U, + const CORBA::Long theNbTimesU, + const CORBA::Long theDirFace1V, + const CORBA::Long theDirFace2V, + const CORBA::Long theNbTimesV) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theBlock == NULL) return aGEOMObject._retn(); + + //Get the object itself + Handle(GEOM_Object) aBasicObject = GetOperations()->GetEngine()->GetObject + (theBlock->GetStudyID(), theBlock->GetEntry()); + + if (aBasicObject.IsNull()) return aGEOMObject._retn(); + + //Perform the transformation + Handle(GEOM_Object) anObject = GetOperations()->MakeMultiTransformation2D + (aBasicObject, + theDirFace1U, theDirFace2U, theNbTimesU, + theDirFace1V, theDirFace2V, theNbTimesV); + if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn(); + + return GetObject(anObject); +} diff --git a/src/GEOM_I/GEOM_IBlocksOperations_i.hh b/src/GEOM_I/GEOM_IBlocksOperations_i.hh new file mode 100644 index 000000000..32c5085da --- /dev/null +++ b/src/GEOM_I/GEOM_IBlocksOperations_i.hh @@ -0,0 +1,126 @@ + +#ifndef _GEOM_IBlocksOperations_i_HeaderFile +#define _GEOM_IBlocksOperations_i_HeaderFile + + +#include + +#include CORBA_SERVER_HEADER(GEOM_Gen) +#include "GEOM_IOperations_i.hh" +#include "GEOM_Object_i.hh" + +#include "GEOMImpl_IBlocksOperations.hxx" + +class GEOM_IBlocksOperations_i : + public virtual POA_GEOM::GEOM_IBlocksOperations, + public virtual GEOM_IOperations_i +{ + public: + GEOM_IBlocksOperations_i (PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr theEngine, + ::GEOMImpl_IBlocksOperations* theImpl); + ~GEOM_IBlocksOperations_i(); + + // Creation of blocks and block faces + GEOM::GEOM_Object_ptr MakeQuad (GEOM::GEOM_Object_ptr theEdge1, + GEOM::GEOM_Object_ptr theEdge2, + GEOM::GEOM_Object_ptr theEdge3, + GEOM::GEOM_Object_ptr theEdge4); + + GEOM::GEOM_Object_ptr MakeQuad2Edges (GEOM::GEOM_Object_ptr theEdge1, + GEOM::GEOM_Object_ptr theEdge2); + + GEOM::GEOM_Object_ptr MakeQuad4Vertices (GEOM::GEOM_Object_ptr thePnt1, + GEOM::GEOM_Object_ptr thePnt2, + GEOM::GEOM_Object_ptr thePnt3, + GEOM::GEOM_Object_ptr thePnt4); + + GEOM::GEOM_Object_ptr MakeHexa (GEOM::GEOM_Object_ptr theFace1, + GEOM::GEOM_Object_ptr theFace2, + GEOM::GEOM_Object_ptr theFace3, + GEOM::GEOM_Object_ptr theFace4, + GEOM::GEOM_Object_ptr theFace5, + GEOM::GEOM_Object_ptr theFace6); + + GEOM::GEOM_Object_ptr MakeHexa2Faces (GEOM::GEOM_Object_ptr theFace1, + GEOM::GEOM_Object_ptr theFace2); + + GEOM::GEOM_Object_ptr MakeBlockCompound (GEOM::GEOM_Object_ptr theCompound); + + // Extract elements of blocks and blocks compounds + GEOM::GEOM_Object_ptr GetPoint (GEOM::GEOM_Object_ptr theShape, + const CORBA::Double theX, + const CORBA::Double theY, + const CORBA::Double theZ, + const CORBA::Double theEpsilon); + + GEOM::GEOM_Object_ptr GetEdge (GEOM::GEOM_Object_ptr theShape, + GEOM::GEOM_Object_ptr thePoint1, + GEOM::GEOM_Object_ptr thePoint2); + + GEOM::GEOM_Object_ptr GetEdgeNearPoint (GEOM::GEOM_Object_ptr theShape, + GEOM::GEOM_Object_ptr thePoint); + + GEOM::GEOM_Object_ptr GetFaceByPoints (GEOM::GEOM_Object_ptr theShape, + GEOM::GEOM_Object_ptr thePoint1, + GEOM::GEOM_Object_ptr thePoint2, + GEOM::GEOM_Object_ptr thePoint3, + GEOM::GEOM_Object_ptr thePoint4); + + GEOM::GEOM_Object_ptr GetFaceByEdges (GEOM::GEOM_Object_ptr theShape, + GEOM::GEOM_Object_ptr theEdge1, + GEOM::GEOM_Object_ptr theEdge2); + + GEOM::GEOM_Object_ptr GetOppositeFace (GEOM::GEOM_Object_ptr theBlock, + GEOM::GEOM_Object_ptr theFace); + + GEOM::GEOM_Object_ptr GetFaceNearPoint (GEOM::GEOM_Object_ptr theShape, + GEOM::GEOM_Object_ptr thePoint); + + GEOM::GEOM_Object_ptr GetFaceByNormale (GEOM::GEOM_Object_ptr theBlock, + GEOM::GEOM_Object_ptr theVector); + + // Check blocks compound + CORBA::Boolean IsCompoundOfBlocks (GEOM::GEOM_Object_ptr theCompound, + const CORBA::Long theMinNbFaces, + const CORBA::Long theMaxNbFaces, + CORBA::Long& theNbBlocks); + + CORBA::Boolean CheckCompoundOfBlocks (GEOM::GEOM_Object_ptr theCompound, + GEOM::GEOM_IBlocksOperations::BCErrors_out theErrors); + + char* PrintBCErrors (GEOM::GEOM_Object_ptr theCompound, + const GEOM::GEOM_IBlocksOperations::BCErrors& theErrors); + + // Extract blocks from blocks compounds + GEOM::ListOfGO* ExplodeCompoundOfBlocks (GEOM::GEOM_Object_ptr theCompound, + const CORBA::Long theMinNbFaces, + const CORBA::Long theMaxNbFaces); + + GEOM::GEOM_Object_ptr GetBlockNearPoint (GEOM::GEOM_Object_ptr theCompound, + GEOM::GEOM_Object_ptr thePoint); + + GEOM::GEOM_Object_ptr GetBlockByParts (GEOM::GEOM_Object_ptr theCompound, + const GEOM::ListOfGO& theParts); + + GEOM::ListOfGO* GetBlocksByParts (GEOM::GEOM_Object_ptr theCompound, + const GEOM::ListOfGO& theParts); + + // Operations on blocks with gluing of result + GEOM::GEOM_Object_ptr MakeMultiTransformation1D (GEOM::GEOM_Object_ptr theBlock, + const CORBA::Long theDirFace1, + const CORBA::Long theDirFace2, + const CORBA::Long theNbTimes); + + GEOM::GEOM_Object_ptr MakeMultiTransformation2D (GEOM::GEOM_Object_ptr theBlock, + const CORBA::Long theDirFace1U, + const CORBA::Long theDirFace2U, + const CORBA::Long theNbTimesU, + const CORBA::Long theDirFace1V, + const CORBA::Long theDirFace2V, + const CORBA::Long theNbTimesV); + + ::GEOMImpl_IBlocksOperations* GetOperations() + { return (::GEOMImpl_IBlocksOperations*)GetImpl(); } +}; + +#endif diff --git a/src/GEOM_I/GEOM_IBooleanOperations_i.cc b/src/GEOM_I/GEOM_IBooleanOperations_i.cc new file mode 100644 index 000000000..4bfaba4af --- /dev/null +++ b/src/GEOM_I/GEOM_IBooleanOperations_i.cc @@ -0,0 +1,183 @@ +using namespace std; + +#include "GEOM_IBooleanOperations_i.hh" + +#include "utilities.h" +#include "OpUtil.hxx" + +#include "GEOM_Engine.hxx" +#include "GEOM_Object.hxx" + +#include + +//============================================================================= +/*! + * constructor: + */ +//============================================================================= +GEOM_IBooleanOperations_i::GEOM_IBooleanOperations_i (PortableServer::POA_ptr thePOA, + GEOM::GEOM_Gen_ptr theEngine, + ::GEOMImpl_IBooleanOperations* theImpl) +:GEOM_IOperations_i(thePOA, theEngine, theImpl) +{ + MESSAGE("GEOM_IBooleanOperations_i::GEOM_IBooleanOperations_i"); +} + +//============================================================================= +/*! + * destructor + */ +//============================================================================= +GEOM_IBooleanOperations_i::~GEOM_IBooleanOperations_i() +{ + MESSAGE("GEOM_IBooleanOperations_i::~GEOM_IBooleanOperations_i"); +} + + +//============================================================================= +/*! + * MakeBoolean + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeBoolean + (GEOM::GEOM_Object_ptr theShape1, + GEOM::GEOM_Object_ptr theShape2, + CORBA::Long theOp) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theShape1 == NULL || theShape2 == NULL) return aGEOMObject._retn(); + + //Get the reference shapes + Handle(GEOM_Object) aSh1 = GetOperations()->GetEngine()->GetObject + (theShape1->GetStudyID(), theShape1->GetEntry()); + Handle(GEOM_Object) aSh2 = GetOperations()->GetEngine()->GetObject + (theShape2->GetStudyID(), theShape2->GetEntry()); + + if (aSh1.IsNull() || aSh2.IsNull()) return aGEOMObject._retn(); + + // Make Boolean + Handle(GEOM_Object) anObject = GetOperations()->MakeBoolean(aSh1, aSh2, theOp); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakePartition + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakePartition + (const GEOM::ListOfGO& theShapes, + const GEOM::ListOfGO& theTools, + const GEOM::ListOfGO& theKeepIns, + const GEOM::ListOfGO& theRemoveIns, + const CORBA::Short theLimit, + const CORBA::Boolean theRemoveWebs, + const GEOM::ListOfLong& theMaterials) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + int ind, aLen; + Handle(TColStd_HSequenceOfTransient) aShapes = new TColStd_HSequenceOfTransient; + Handle(TColStd_HSequenceOfTransient) aTools = new TColStd_HSequenceOfTransient; + Handle(TColStd_HSequenceOfTransient) aKeepIns = new TColStd_HSequenceOfTransient; + Handle(TColStd_HSequenceOfTransient) aRemIns = new TColStd_HSequenceOfTransient; + Handle(TColStd_HArray1OfInteger) aMaterials; + + //Get the shapes + aLen = theShapes.length(); + for (ind = 0; ind < aLen; ind++) { + if (theShapes[ind] == NULL) return aGEOMObject._retn(); + Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject + (theShapes[ind]->GetStudyID(), theShapes[ind]->GetEntry()); + if (aSh.IsNull()) return aGEOMObject._retn(); + aShapes->Append(aSh); + } + + //Get the tools + aLen = theTools.length(); + for (ind = 0; ind < aLen; ind++) { + if (theTools[ind] == NULL) return aGEOMObject._retn(); + Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject + (theTools[ind]->GetStudyID(), theTools[ind]->GetEntry()); + if (aSh.IsNull()) return aGEOMObject._retn(); + aTools->Append(aSh); + } + + //Get the keep inside shapes + aLen = theKeepIns.length(); + for (ind = 0; ind < aLen; ind++) { + if (theKeepIns[ind] == NULL) return aGEOMObject._retn(); + Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject + (theKeepIns[ind]->GetStudyID(), theKeepIns[ind]->GetEntry()); + if (aSh.IsNull()) return aGEOMObject._retn(); + aKeepIns->Append(aSh); + } + + //Get the remove inside shapes + aLen = theRemoveIns.length(); + for (ind = 0; ind < aLen; ind++) { + if (theRemoveIns[ind] == NULL) return aGEOMObject._retn(); + Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject + (theRemoveIns[ind]->GetStudyID(), theRemoveIns[ind]->GetEntry()); + if (aSh.IsNull()) return aGEOMObject._retn(); + aRemIns->Append(aSh); + } + + //Get the materials + aLen = theMaterials.length(); + aMaterials = new TColStd_HArray1OfInteger (1, aLen); + for (ind = 0; ind < aLen; ind++) { + aMaterials->SetValue(ind+1, theMaterials[ind]); + } + + // Make Partition + Handle(GEOM_Object) anObject = + GetOperations()->MakePartition(aShapes, aTools, aKeepIns, aRemIns, + theLimit, theRemoveWebs, aMaterials); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakeHalfPartition + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeHalfPartition + (GEOM::GEOM_Object_ptr theShape, + 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 shapes + Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject + (theShape->GetStudyID(), theShape->GetEntry()); + Handle(GEOM_Object) aPl = GetOperations()->GetEngine()->GetObject + (thePlane->GetStudyID(), thePlane->GetEntry()); + + if (aSh.IsNull() || aPl.IsNull()) return aGEOMObject._retn(); + + // Make Half Partition + Handle(GEOM_Object) anObject = GetOperations()->MakeHalfPartition(aSh, aPl); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} diff --git a/src/GEOM_I/GEOM_IBooleanOperations_i.hh b/src/GEOM_I/GEOM_IBooleanOperations_i.hh new file mode 100644 index 000000000..48db54c99 --- /dev/null +++ b/src/GEOM_I/GEOM_IBooleanOperations_i.hh @@ -0,0 +1,43 @@ + +#ifndef _GEOM_IBooleanOperations_i_HeaderFile +#define _GEOM_IBooleanOperations_i_HeaderFile + + +#include + +#include CORBA_SERVER_HEADER(GEOM_Gen) +#include "GEOM_IOperations_i.hh" +#include "GEOM_Object_i.hh" + +#include "GEOMImpl_IBooleanOperations.hxx" + +class GEOM_IBooleanOperations_i : + public virtual POA_GEOM::GEOM_IBooleanOperations, + public virtual GEOM_IOperations_i +{ + public: + GEOM_IBooleanOperations_i (PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr theEngine, + ::GEOMImpl_IBooleanOperations* theImpl); + ~GEOM_IBooleanOperations_i(); + + GEOM::GEOM_Object_ptr MakeBoolean (GEOM::GEOM_Object_ptr theShape1, + GEOM::GEOM_Object_ptr theShape2, + CORBA::Long theOp); + + GEOM::GEOM_Object_ptr MakePartition (const GEOM::ListOfGO& theShapes, + const GEOM::ListOfGO& theTools, + const GEOM::ListOfGO& theKeepInside, + const GEOM::ListOfGO& theRemoveInside, + const CORBA::Short theLimit, + const CORBA::Boolean theRemoveWebs, + const GEOM::ListOfLong& theMaterials); + + + GEOM::GEOM_Object_ptr MakeHalfPartition (GEOM::GEOM_Object_ptr theShape, + GEOM::GEOM_Object_ptr thePlane); + + ::GEOMImpl_IBooleanOperations* GetOperations() + { return (::GEOMImpl_IBooleanOperations*)GetImpl(); } +}; + +#endif diff --git a/src/GEOM_I/GEOM_ICurvesOperations_i.cc b/src/GEOM_I/GEOM_ICurvesOperations_i.cc new file mode 100644 index 000000000..ba436bb03 --- /dev/null +++ b/src/GEOM_I/GEOM_ICurvesOperations_i.cc @@ -0,0 +1,305 @@ +using namespace std; + +#include "GEOM_ICurvesOperations_i.hh" + +#include "utilities.h" +#include "OpUtil.hxx" + +#include "GEOM_Engine.hxx" +#include "GEOM_Object.hxx" + +//============================================================================= +/*! + * constructor: + */ +//============================================================================= +GEOM_ICurvesOperations_i::GEOM_ICurvesOperations_i (PortableServer::POA_ptr thePOA, + GEOM::GEOM_Gen_ptr theEngine, + ::GEOMImpl_ICurvesOperations* theImpl) +:GEOM_IOperations_i(thePOA, theEngine, theImpl) +{ + MESSAGE("GEOM_ICurvesOperations_i::GEOM_ICurvesOperations_i"); +} + +//============================================================================= +/*! + * destructor + */ +//============================================================================= +GEOM_ICurvesOperations_i::~GEOM_ICurvesOperations_i() +{ + MESSAGE("GEOM_ICurvesOperations_i::~GEOM_ICurvesOperations_i"); +} + + +//============================================================================= +/*! + * MakeCirclePntVecR + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCirclePntVecR + (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec, + CORBA::Double theR) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (thePnt == NULL || theVec == NULL) return aGEOMObject._retn(); + + //Get the reference points + Handle(GEOM_Object) aPnt = GetOperations()->GetEngine()->GetObject + (thePnt->GetStudyID(), thePnt->GetEntry()); + Handle(GEOM_Object) aVec = GetOperations()->GetEngine()->GetObject + (theVec->GetStudyID(), theVec->GetEntry()); + + if (aPnt.IsNull() || aVec.IsNull()) return aGEOMObject._retn(); + + // Make Circle + Handle(GEOM_Object) anObject = + GetOperations()->MakeCirclePntVecR(aPnt, aVec, theR); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakeCircleThreePnt + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCircleThreePnt + (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2, + GEOM::GEOM_Object_ptr thePnt3) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (thePnt1 == NULL || thePnt2 == NULL || thePnt3 == NULL) return aGEOMObject._retn(); + + //Get the reference points + Handle(GEOM_Object) aPnt1 = GetOperations()->GetEngine()->GetObject + (thePnt1->GetStudyID(), thePnt1->GetEntry()); + Handle(GEOM_Object) aPnt2 = GetOperations()->GetEngine()->GetObject + (thePnt2->GetStudyID(), thePnt2->GetEntry()); + Handle(GEOM_Object) aPnt3 = GetOperations()->GetEngine()->GetObject + (thePnt3->GetStudyID(), thePnt3->GetEntry()); + + if (aPnt1.IsNull() || aPnt2.IsNull() || aPnt3.IsNull()) return aGEOMObject._retn(); + + // Make Circle + Handle(GEOM_Object) anObject = + GetOperations()->MakeCircleThreePnt(aPnt1, aPnt2, aPnt3); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakeEllipse + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeEllipse + (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec, + CORBA::Double theRMajor, double theRMinor) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (thePnt == NULL || theVec == NULL) return aGEOMObject._retn(); + + //Get the reference points + Handle(GEOM_Object) aPnt = GetOperations()->GetEngine()->GetObject + (thePnt->GetStudyID(), thePnt->GetEntry()); + Handle(GEOM_Object) aVec = GetOperations()->GetEngine()->GetObject + (theVec->GetStudyID(), theVec->GetEntry()); + + if (aPnt.IsNull() || aVec.IsNull()) return aGEOMObject._retn(); + + // Make Ellipse + Handle(GEOM_Object) anObject = + GetOperations()->MakeEllipse(aPnt, aVec, theRMajor, theRMinor); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakeArc + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeArc + (GEOM::GEOM_Object_ptr thePnt1, + GEOM::GEOM_Object_ptr thePnt2, + GEOM::GEOM_Object_ptr thePnt3) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (thePnt1 == NULL || thePnt2 == NULL || thePnt3 == NULL) return aGEOMObject._retn(); + + //Get the reference points + Handle(GEOM_Object) aPnt1 = GetOperations()->GetEngine()->GetObject + (thePnt1->GetStudyID(), thePnt1->GetEntry()); + Handle(GEOM_Object) aPnt2 = GetOperations()->GetEngine()->GetObject + (thePnt2->GetStudyID(), thePnt2->GetEntry()); + Handle(GEOM_Object) aPnt3 = GetOperations()->GetEngine()->GetObject + (thePnt3->GetStudyID(), thePnt3->GetEntry()); + + if (aPnt1.IsNull() || aPnt2.IsNull() || aPnt3.IsNull()) return aGEOMObject._retn(); + + // Make Arc + Handle(GEOM_Object) anObject = + GetOperations()->MakeArc(aPnt1, aPnt2, aPnt3); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakePolyline + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakePolyline + (const GEOM::ListOfGO& thePoints) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Get the reference point + int ind = 0; + int aLen = thePoints.length(); + list aPoints; + for (; ind < aLen; ind++) { + if (thePoints[ind] == NULL) return aGEOMObject._retn(); + + Handle(GEOM_Object) aPnt = GetOperations()->GetEngine()->GetObject + (thePoints[ind]->GetStudyID(), thePoints[ind]->GetEntry()); + + if (aPnt.IsNull()) return aGEOMObject._retn(); + aPoints.push_back(aPnt); + } + + // Make Polyline + Handle(GEOM_Object) anObject = + GetOperations()->MakePolyline(aPoints); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakeSplineBezier + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSplineBezier + (const GEOM::ListOfGO& thePoints) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Get the reference point + int ind = 0; + int aLen = thePoints.length(); + list aPoints; + for (; ind < aLen; ind++) { + if (thePoints[ind] == NULL) return aGEOMObject._retn(); + + Handle(GEOM_Object) aPnt = GetOperations()->GetEngine()->GetObject + (thePoints[ind]->GetStudyID(), thePoints[ind]->GetEntry()); + + if (aPnt.IsNull()) return aGEOMObject._retn(); + aPoints.push_back(aPnt); + } + + // Make Bezier curve + Handle(GEOM_Object) anObject = + GetOperations()->MakeSplineBezier(aPoints); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakeSplineInterpolation + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSplineInterpolation + (const GEOM::ListOfGO& thePoints) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Get the reference point + int ind = 0; + int aLen = thePoints.length(); + list aPoints; + for (; ind < aLen; ind++) { + if (thePoints[ind] == NULL) return aGEOMObject._retn(); + + Handle(GEOM_Object) aPnt = GetOperations()->GetEngine()->GetObject + (thePoints[ind]->GetStudyID(), thePoints[ind]->GetEntry()); + + if (aPnt.IsNull()) return aGEOMObject._retn(); + aPoints.push_back(aPnt); + } + + // Make Polyline + Handle(GEOM_Object) anObject = + GetOperations()->MakeSplineInterpolation(aPoints); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakeSketcher + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSketcher (const char* theCommand, const GEOM::ListOfDouble& theWorkingPlane) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + int ind = 0; + int aLen = theWorkingPlane.length(); + list aWorkingPlane; + for (; ind < aLen; ind++) + aWorkingPlane.push_back(theWorkingPlane[ind]); + + // Make Sketcher + Handle(GEOM_Object) anObject = + GetOperations()->MakeSketcher(theCommand, aWorkingPlane); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} diff --git a/src/GEOM_I/GEOM_ICurvesOperations_i.hh b/src/GEOM_I/GEOM_ICurvesOperations_i.hh new file mode 100644 index 000000000..6308621f8 --- /dev/null +++ b/src/GEOM_I/GEOM_ICurvesOperations_i.hh @@ -0,0 +1,51 @@ + +#ifndef _GEOM_ICurvesOperations_i_HeaderFile +#define _GEOM_ICurvesOperations_i_HeaderFile + + +#include + +#include CORBA_SERVER_HEADER(GEOM_Gen) +#include "GEOM_IOperations_i.hh" +#include "GEOM_Object_i.hh" + +#include "GEOMImpl_ICurvesOperations.hxx" + +class GEOM_ICurvesOperations_i : + public virtual POA_GEOM::GEOM_ICurvesOperations, + public virtual GEOM_IOperations_i +{ + public: + GEOM_ICurvesOperations_i (PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr theEngine, + ::GEOMImpl_ICurvesOperations* theImpl); + ~GEOM_ICurvesOperations_i(); + + GEOM::GEOM_Object_ptr MakeCirclePntVecR (GEOM::GEOM_Object_ptr theCenter, + GEOM::GEOM_Object_ptr theVector, + double theR); + + GEOM::GEOM_Object_ptr MakeCircleThreePnt (GEOM::GEOM_Object_ptr thePnt1, + GEOM::GEOM_Object_ptr thePnt2, + GEOM::GEOM_Object_ptr thePnt3); + + GEOM::GEOM_Object_ptr MakeEllipse (GEOM::GEOM_Object_ptr theCenter, + GEOM::GEOM_Object_ptr theVector, + double theRMajor, double theRMinor); + + GEOM::GEOM_Object_ptr MakeArc (GEOM::GEOM_Object_ptr thePnt1, + GEOM::GEOM_Object_ptr thePnt2, + GEOM::GEOM_Object_ptr thePnt3); + + GEOM::GEOM_Object_ptr MakePolyline (const GEOM::ListOfGO& thePoints); + + GEOM::GEOM_Object_ptr MakeSplineBezier (const GEOM::ListOfGO& thePoints); + + GEOM::GEOM_Object_ptr MakeSplineInterpolation (const GEOM::ListOfGO& thePoints); + + GEOM::GEOM_Object_ptr MakeSketcher (const char* theCommand, const GEOM::ListOfDouble& theWorkingPlane); + + ::GEOMImpl_ICurvesOperations* GetOperations() + { return (::GEOMImpl_ICurvesOperations*)GetImpl(); } +}; + +#endif diff --git a/src/GEOM_I/GEOM_IGroupOperations_i.cc b/src/GEOM_I/GEOM_IGroupOperations_i.cc new file mode 100644 index 000000000..3ff5c9bb6 --- /dev/null +++ b/src/GEOM_I/GEOM_IGroupOperations_i.cc @@ -0,0 +1,179 @@ +using namespace std; + +#include "GEOM_IGroupOperations_i.hh" + +#include "utilities.h" +#include "OpUtil.hxx" +#include "Utils_ExceptHandlers.hxx" + +#include "GEOM_Engine.hxx" +#include "GEOM_Object.hxx" + +#include +#include + +//============================================================================= +/*! + * constructor: + */ +//============================================================================= +GEOM_IGroupOperations_i::GEOM_IGroupOperations_i (PortableServer::POA_ptr thePOA, + GEOM::GEOM_Gen_ptr theEngine, + ::GEOMImpl_IGroupOperations* theImpl) + :GEOM_IOperations_i(thePOA, theEngine, theImpl) +{ + MESSAGE("GEOM_IGroupOperations_i::GEOM_IGroupOperations_i"); +} + +//============================================================================= +/*! + * destructor + */ +//============================================================================= +GEOM_IGroupOperations_i::~GEOM_IGroupOperations_i() +{ + MESSAGE("GEOM_IGroupOperations_i::~GEOM_IGroupOperations_i"); +} + + +//============================================================================= +/*! + * CreateGroup + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IGroupOperations_i::CreateGroup(GEOM::GEOM_Object_ptr theMainShape, CORBA::Long theShapeType) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theMainShape == NULL || theShapeType < 0) return aGEOMObject._retn(); + + //Get the reference shape + Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject(theMainShape->GetStudyID(), theMainShape->GetEntry()); + + if (aShapeRef.IsNull()) return aGEOMObject._retn(); + + //Create the Fillet + Handle(GEOM_Object) anObject = GetOperations()->CreateGroup(aShapeRef, (TopAbs_ShapeEnum)theShapeType); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * AddObject + */ +//============================================================================= +void GEOM_IGroupOperations_i::AddObject(GEOM::GEOM_Object_ptr theGroup, CORBA::Long theSubShapeId) +{ + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theGroup == NULL) return; + + //Get the reference group + Handle(GEOM_Object) aGroupRef = GetOperations()->GetEngine()->GetObject(theGroup->GetStudyID(), theGroup->GetEntry()); + if (aGroupRef.IsNull()) return; + + GetOperations()->AddObject(aGroupRef, theSubShapeId); + return; +} + +//============================================================================= +/*! + * RemoveObject + */ +//============================================================================= +void GEOM_IGroupOperations_i::RemoveObject(GEOM::GEOM_Object_ptr theGroup, CORBA::Long theSubShapeId) +{ + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theGroup == NULL) return; + + //Get the reference group + Handle(GEOM_Object) aGroupRef = GetOperations()->GetEngine()->GetObject(theGroup->GetStudyID(), theGroup->GetEntry()); + if (aGroupRef.IsNull()) return; + + GetOperations()->RemoveObject(aGroupRef, theSubShapeId); + + return; +} + +//============================================================================= +/*! + * GetType + */ +//============================================================================= +CORBA::Long GEOM_IGroupOperations_i::GetType(GEOM::GEOM_Object_ptr theGroup) +{ + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theGroup == NULL) return -1; + + //Get the reference group + Handle(GEOM_Object) aGroupRef = GetOperations()->GetEngine()->GetObject(theGroup->GetStudyID(), theGroup->GetEntry()); + + if (aGroupRef.IsNull()) return -1; + + return GetOperations()->GetType(aGroupRef); +} + +//============================================================================= +/*! + * GetMainShape + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IGroupOperations_i::GetMainShape(GEOM::GEOM_Object_ptr theGroup) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theGroup == NULL) return aGEOMObject._retn(); + + //Get the reference group + Handle(GEOM_Object) aGroupRef = GetOperations()->GetEngine()->GetObject(theGroup->GetStudyID(), theGroup->GetEntry()); + if (aGroupRef.IsNull()) return aGEOMObject._retn(); + + Handle(GEOM_Object) anObject = GetOperations()->GetMainShape(aGroupRef); + if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * GetObjects + */ +//============================================================================= +GEOM::ListOfLong* GEOM_IGroupOperations_i::GetObjects(GEOM::GEOM_Object_ptr theGroup) +{ + GEOM::ListOfLong_var aList; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theGroup == NULL) return aList._retn(); + + //Get the reference group + Handle(GEOM_Object) aGroupRef = GetOperations()->GetEngine()->GetObject(theGroup->GetStudyID(), theGroup->GetEntry()); + if (aGroupRef.IsNull()) return aList._retn(); + + aList = new GEOM::ListOfLong; + + Handle(TColStd_HArray1OfInteger) aSeq = GetOperations()->GetObjects(aGroupRef); + if (!GetOperations()->IsDone() || aSeq.IsNull()) return aList._retn(); + + aList->length(aSeq->Length()); + for(int i = 1; i<=aSeq->Length(); i++) aList[i-1] = aSeq->Value(i); + + return aList._retn(); +} + diff --git a/src/GEOM_I/GEOM_IGroupOperations_i.hh b/src/GEOM_I/GEOM_IGroupOperations_i.hh new file mode 100644 index 000000000..14ccec8aa --- /dev/null +++ b/src/GEOM_I/GEOM_IGroupOperations_i.hh @@ -0,0 +1,39 @@ + +#ifndef _GEOM_IGroupOperations_i_HeaderFile +#define _GEOM_IGroupOperations_i_HeaderFile + + +#include + +#include CORBA_SERVER_HEADER(GEOM_Gen) +#include "GEOM_IOperations_i.hh" +#include "GEOM_Object_i.hh" + +#include "GEOMImpl_IGroupOperations.hxx" + +class GEOM_IGroupOperations_i : + public virtual POA_GEOM::GEOM_IGroupOperations, + public virtual GEOM_IOperations_i +{ + public: + GEOM_IGroupOperations_i (PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr theEngine, + ::GEOMImpl_IGroupOperations* theImpl); + ~GEOM_IGroupOperations_i(); + + GEOM::GEOM_Object_ptr CreateGroup (GEOM::GEOM_Object_ptr theMainShape, CORBA::Long theShapeType); + + void AddObject (GEOM::GEOM_Object_ptr theGroup, CORBA::Long theSubShapeId); + + void RemoveObject (GEOM::GEOM_Object_ptr theGroup, CORBA::Long theSubShapeId); + + CORBA::Long GetType (GEOM::GEOM_Object_ptr theGroup); + + GEOM::GEOM_Object_ptr GetMainShape (GEOM::GEOM_Object_ptr theGroup); + + GEOM::ListOfLong* GetObjects (GEOM::GEOM_Object_ptr theGroup); + + ::GEOMImpl_IGroupOperations* GetOperations() + { return (::GEOMImpl_IGroupOperations*)GetImpl(); } +}; + +#endif diff --git a/src/GEOM_I/GEOM_IHealingOperations_i.cc b/src/GEOM_I/GEOM_IHealingOperations_i.cc new file mode 100644 index 000000000..ea8fe487f --- /dev/null +++ b/src/GEOM_I/GEOM_IHealingOperations_i.cc @@ -0,0 +1,401 @@ +#include +using namespace std; + +#include "GEOM_IHealingOperations_i.hh" +#include "GEOM_Engine.hxx" +#include "GEOM_Object.hxx" + +#include "utilities.h" +#include "OpUtil.hxx" +#include "Utils_ExceptHandlers.hxx" + +#include + +//============================================================================= +/*! + * constructor: + */ +//============================================================================= + +GEOM_IHealingOperations_i::GEOM_IHealingOperations_i (PortableServer::POA_ptr thePOA, + GEOM::GEOM_Gen_ptr theEngine, + ::GEOMImpl_IHealingOperations* theImpl) +:GEOM_IOperations_i(thePOA, theEngine, theImpl) +{ + MESSAGE("GEOM_IHealingOperations_i::GEOM_IHealingOperations_i"); +} + +//============================================================================= +/*! + * destructor + */ +//============================================================================= + +GEOM_IHealingOperations_i::~GEOM_IHealingOperations_i() +{ + MESSAGE("GEOM_IHealingOperations_i::~GEOM_IHealingOperations_i"); +} + +//============================================================================= +/*! + * Convert + */ +//============================================================================= +Handle(TColStd_HArray1OfInteger) GEOM_IHealingOperations_i::Convert + (const GEOM::short_array& theInArray) +{ + Handle(TColStd_HArray1OfInteger) anOutArray; + int n = theInArray.length(); + if ( n <= 0 ) + return anOutArray; + anOutArray = new TColStd_HArray1OfInteger( 1, n ); + for (int i = 0; i < n; i++) + anOutArray->SetValue( i+1, theInArray[i] ); + return anOutArray; +} + +//============================================================================= +/*! + * Convert + */ +//============================================================================= +Handle(TColStd_HArray1OfExtendedString) GEOM_IHealingOperations_i::Convert + (const GEOM::string_array& theInArray) +{ + Handle(TColStd_HArray1OfExtendedString) anOutArray; + int n = theInArray.length(); + if ( n <= 0 ) + return anOutArray; + anOutArray = new TColStd_HArray1OfExtendedString( 1, n ); + char* str; + for ( int i = 0; i < n; i++ ) + { + str = CORBA::string_dup( theInArray[i] ); + anOutArray->SetValue( i+1, TCollection_ExtendedString( str ) ); + } + return anOutArray; +} + +//============================================================================= +/*! + * ProcessShape + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IHealingOperations_i::ProcessShape (GEOM::GEOM_Object_ptr theObject, + const GEOM::string_array& theOperations, + const GEOM::string_array& theParams, + const GEOM::string_array& theValues) +{ + GEOM::GEOM_Object_var aGEOMObject; + + // Set a not done flag + GetOperations()->SetNotDone(); + + // Check parameters + if ( CORBA::is_nil(theObject) ) + return aGEOMObject._retn(); + + // Check if theOperations has more than 0 elements and theParams and theValues have the same length +// if ( theOperations.length() <= 0 || theParams.length() != theValues.length() ) +// return aGEOMObject._retn(); + + // Get the object itself + Handle(GEOM_Object) anObject = + GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry()); + if ( anObject.IsNull() ) + return aGEOMObject._retn(); + + // Perform + Handle(GEOM_Object) aNewObject = GetOperations()->ShapeProcess( anObject, + Convert( theOperations ), Convert( theParams ), Convert( theValues ) ); + if ( !GetOperations()->IsDone() || aNewObject.IsNull() ) + return aGEOMObject._retn(); + + return GetObject( aNewObject ); +} + +//============================================================================= +/*! + * GetShapeProcessParameters + */ +//============================================================================= +void GEOM_IHealingOperations_i::GetShapeProcessParameters(GEOM::string_array_out theOperations, + GEOM::string_array_out theParams, + GEOM::string_array_out theValues) +{ + // retrieve the values as stl-lists + list operationsList, paramsList, valuesList; + GetOperations()->GetShapeProcessParameters( operationsList, paramsList, valuesList ); + const int opSize = operationsList.size(), + parSize = paramsList.size(), + valSize = valuesList.size(); + + // returns in case of an error + if ( opSize < 0 || parSize < 0 || parSize != valSize ) + return; + + // allocate the CORBA arrays, sizes == returned lists' sizes + GEOM::string_array_var anOpArray = new GEOM::string_array(); + GEOM::string_array_var aParArray = new GEOM::string_array(); + GEOM::string_array_var aValArray = new GEOM::string_array(); + anOpArray->length(opSize); + aParArray->length(parSize); + aValArray->length(valSize); + + // fill the local CORBA arrays with values from lists + list::iterator opIt, parIt, valIt; + int i = 0; + for ( opIt = operationsList.begin(); opIt != operationsList.end(); i++,++opIt ) + anOpArray[i] = CORBA::string_dup( (*opIt).c_str() ); + + for ( i = 0, parIt = paramsList.begin(), valIt = valuesList.begin(); + parIt != paramsList.end(); i++, ++parIt,++valIt ) + { + aParArray[i] = CORBA::string_dup( (*parIt).c_str() ); + aValArray[i] = CORBA::string_dup( (*valIt).c_str() ); + } + + // initialize out-parameters with local arrays + theOperations = anOpArray._retn(); + theParams = aParArray._retn(); + theValues = aValArray._retn(); +} + +//============================================================================= +/*! + * SuppressFaces + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IHealingOperations_i::SuppressFaces (GEOM::GEOM_Object_ptr theObject, + const GEOM::short_array& theFaces) +{ + GEOM::GEOM_Object_var aGEOMObject; + + // Set a not done flag + GetOperations()->SetNotDone(); + + // Check parameters + if ( CORBA::is_nil(theObject) ) // if theFaces is empty - it's OK, it means that ALL faces must be removed + return aGEOMObject._retn(); + + // Get the object itself + Handle(GEOM_Object) anObject = + GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry()); + if (anObject.IsNull()) + return aGEOMObject._retn(); + + // Perform + Handle(GEOM_Object) aNewObject = + GetOperations()->SuppressFaces( anObject, Convert( theFaces ) ); + if (!GetOperations()->IsDone() || aNewObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject( aNewObject ); +} + +//============================================================================= +/*! + * CloseContour + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IHealingOperations_i::CloseContour (GEOM::GEOM_Object_ptr theObject, + const GEOM::short_array& theWires, + CORBA::Boolean isCommonVertex) +{ + GEOM::GEOM_Object_var aGEOMObject; + + // Set a not done flag + GetOperations()->SetNotDone(); + + // Check parameters + if ( CORBA::is_nil(theObject) ) + return aGEOMObject._retn(); + + // Get the object itself + Handle(GEOM_Object) anObject = + GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry()); + if (anObject.IsNull()) + return aGEOMObject._retn(); + + // Perform + Handle(GEOM_Object) aNewObject = + GetOperations()->CloseContour( anObject, Convert( theWires ), isCommonVertex ); + if (!GetOperations()->IsDone() || aNewObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(aNewObject); +} + +//============================================================================= +/*! + * RemoveIntWires + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IHealingOperations_i::RemoveIntWires (GEOM::GEOM_Object_ptr theObject, + const GEOM::short_array& theWires) +{ + GEOM::GEOM_Object_var aGEOMObject; + + // Set a not done flag + GetOperations()->SetNotDone(); + + // Check parameters + if ( CORBA::is_nil(theObject) ) // if theWires is empty - it's OK, it means that ALL wires should be removed + return aGEOMObject._retn(); + + // Get the object itself + Handle(GEOM_Object) anObject = + GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry()); + if (anObject.IsNull()) + return aGEOMObject._retn(); + + // Perform + Handle(GEOM_Object) aNewObject = + GetOperations()->RemoveIntWires( anObject, Convert( theWires ) ); + if (!GetOperations()->IsDone() || aNewObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(aNewObject); +} + +//============================================================================= +/*! + * FillHoles + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IHealingOperations_i::FillHoles (GEOM::GEOM_Object_ptr theObject, + const GEOM::short_array& theWires) +{ + GEOM::GEOM_Object_var aGEOMObject; + + // Set a not done flag + GetOperations()->SetNotDone(); + + // Check parameters + if ( CORBA::is_nil(theObject) ) // if theWires is empty - it's OK, it means that ALL wires should be removed + return aGEOMObject._retn(); + + // Get the object itself + Handle(GEOM_Object) anObject = + GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry()); + if (anObject.IsNull()) + return aGEOMObject._retn(); + + // Perform + Handle(GEOM_Object) aNewObject = + GetOperations()->FillHoles( anObject, Convert( theWires ) ); + if (!GetOperations()->IsDone() || aNewObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(aNewObject); +} + +//============================================================================= +/*! + * Sew + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IHealingOperations_i::Sew (GEOM::GEOM_Object_ptr theObject, + CORBA::Double theTolerance) +{ + GEOM::GEOM_Object_var aGEOMObject; + + // Set a not done flag + GetOperations()->SetNotDone(); + + // Check parameters + if ( CORBA::is_nil(theObject) || theTolerance < 0 ) + return aGEOMObject._retn(); + + // Get the object itself + Handle(GEOM_Object) anObject = + GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry()); + if (anObject.IsNull()) + return aGEOMObject._retn(); + + // Perform + Handle(GEOM_Object) aNewObject = + GetOperations()->Sew( anObject, theTolerance ); + if (!GetOperations()->IsDone() || aNewObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(aNewObject); +} + +//============================================================================= +/*! + * DivideEdge + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IHealingOperations_i::DivideEdge (GEOM::GEOM_Object_ptr theObject, + CORBA::Short theIndex, + CORBA::Double theValue, + CORBA::Boolean isByParameter) +{ + GEOM::GEOM_Object_var aGEOMObject; + + // Set a not done flag + GetOperations()->SetNotDone(); + + // Check parameters + if ( CORBA::is_nil(theObject) || theValue < 0 || theValue > 1 ) + return aGEOMObject._retn(); + + // Get the object itself + Handle(GEOM_Object) anObject = + GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry()); + if (anObject.IsNull()) + return aGEOMObject._retn(); + + // Perform + Handle(GEOM_Object) aNewObject = + GetOperations()->DivideEdge( anObject, theIndex, theValue, isByParameter ); + if (!GetOperations()->IsDone() || aNewObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(aNewObject); +} + +//============================================================================= +/*! + * GetFreeBoundary + */ +//============================================================================= +CORBA::Boolean GEOM_IHealingOperations_i::GetFreeBoundary ( GEOM::GEOM_Object_ptr theObject, + GEOM::ListOfGO_out theClosedWires, + GEOM::ListOfGO_out theOpenWires ) +{ + theClosedWires = new GEOM::ListOfGO; + theOpenWires = new GEOM::ListOfGO; + + // Set a not done flag + GetOperations()->SetNotDone(); + + if ( CORBA::is_nil(theObject) ) + return false; + + // Get the object itself + Handle(GEOM_Object) anObject = + GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry()); + if (anObject.IsNull()) + return false; + + Handle(TColStd_HSequenceOfTransient) aClosed = new TColStd_HSequenceOfTransient(); + Handle(TColStd_HSequenceOfTransient) anOpen = new TColStd_HSequenceOfTransient(); + bool res = GetOperations()->GetFreeBoundary( anObject, aClosed, anOpen ); + + if ( !GetOperations()->IsDone() || !res ) + return false; + + int i, n = aClosed->Length(); + theClosedWires->length( n ); + for ( i = 1; i <= n; i++ ) + (*theClosedWires)[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aClosed->Value(i))); + + n = anOpen->Length(); + theOpenWires->length( n ); + for ( i = 1, n = anOpen->Length(); i <= n; i++ ) + (*theOpenWires)[i-1] = GetObject(Handle(GEOM_Object)::DownCast(anOpen->Value(i))); + + return true; +} diff --git a/src/GEOM_I/GEOM_IHealingOperations_i.hh b/src/GEOM_I/GEOM_IHealingOperations_i.hh new file mode 100644 index 000000000..f26f5dc99 --- /dev/null +++ b/src/GEOM_I/GEOM_IHealingOperations_i.hh @@ -0,0 +1,51 @@ + +#ifndef _GEOM_IHealingOperations_i_HeaderFile +#define _GEOM_IHealingOperations_i_HeaderFile + + +#include + +#include CORBA_SERVER_HEADER(GEOM_Gen) +#include "GEOM_IOperations_i.hh" +#include "GEOM_Object_i.hh" + +#include "GEOMImpl_IHealingOperations.hxx" + +#include +#include + +class GEOM_IHealingOperations_i : + public virtual POA_GEOM::GEOM_IHealingOperations, + public virtual GEOM_IOperations_i +{ + public: + GEOM_IHealingOperations_i(PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr theEngine, ::GEOMImpl_IHealingOperations* theImpl); + ~GEOM_IHealingOperations_i(); + + GEOM::GEOM_Object_ptr ProcessShape(GEOM::GEOM_Object_ptr theObject, const GEOM::string_array& theOperations, const GEOM::string_array& theParams, const GEOM::string_array& theValues); + + void GetShapeProcessParameters(GEOM::string_array_out theOperations, GEOM::string_array_out theParams, GEOM::string_array_out theValues); + + GEOM::GEOM_Object_ptr SuppressFaces(GEOM::GEOM_Object_ptr theObject, const GEOM::short_array& theFaces); + + GEOM::GEOM_Object_ptr CloseContour (GEOM::GEOM_Object_ptr theObject, const GEOM::short_array& theWires, CORBA::Boolean isCommonVertex); + + GEOM::GEOM_Object_ptr RemoveIntWires (GEOM::GEOM_Object_ptr theObject, const GEOM::short_array& theWires); + + GEOM::GEOM_Object_ptr FillHoles (GEOM::GEOM_Object_ptr theObject, const GEOM::short_array& theWires); + + GEOM::GEOM_Object_ptr Sew (GEOM::GEOM_Object_ptr theObject, CORBA::Double theTolerance); + + GEOM::GEOM_Object_ptr DivideEdge (GEOM::GEOM_Object_ptr theObject, CORBA::Short theIndex, CORBA::Double theValue, CORBA::Boolean isByParameter); + + CORBA::Boolean GetFreeBoundary(GEOM::GEOM_Object_ptr theObject, GEOM::ListOfGO_out theClosedWires, GEOM::ListOfGO_out theOpenWires ); + + ::GEOMImpl_IHealingOperations* GetOperations() { return (::GEOMImpl_IHealingOperations*)GetImpl(); } + +private: + Handle(TColStd_HArray1OfExtendedString) Convert( const GEOM::string_array& ); + Handle(TColStd_HArray1OfInteger) Convert( const GEOM::short_array& ); + +}; + +#endif diff --git a/src/GEOM_I/GEOM_IInsertOperations_i.cc b/src/GEOM_I/GEOM_IInsertOperations_i.cc new file mode 100644 index 000000000..8585c7049 --- /dev/null +++ b/src/GEOM_I/GEOM_IInsertOperations_i.cc @@ -0,0 +1,194 @@ +using namespace std; + +#include "GEOM_IInsertOperations_i.hh" + +#include "utilities.h" +#include "OpUtil.hxx" +#include "Utils_ExceptHandlers.hxx" + +#include "GEOM_Engine.hxx" +#include "GEOM_Object.hxx" + +#include + +//============================================================================= +/*! + * constructor: + */ +//============================================================================= +GEOM_IInsertOperations_i::GEOM_IInsertOperations_i (PortableServer::POA_ptr thePOA, + GEOM::GEOM_Gen_ptr theEngine, + ::GEOMImpl_IInsertOperations* theImpl) + :GEOM_IOperations_i(thePOA, theEngine, theImpl) +{ + MESSAGE("GEOM_IInsertOperations_i::GEOM_IInsertOperations_i"); +} + +//============================================================================= +/*! + * destructor + */ +//============================================================================= +GEOM_IInsertOperations_i::~GEOM_IInsertOperations_i() +{ + MESSAGE("GEOM_IInsertOperations_i::~GEOM_IInsertOperations_i"); +} + + +//============================================================================= +/*! + * MakeCopy + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IInsertOperations_i::MakeCopy(GEOM::GEOM_Object_ptr theOriginal) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theOriginal == NULL) return aGEOMObject._retn(); + + //Get the reference shape + Handle(GEOM_Object) anOriginal = + GetOperations()->GetEngine()->GetObject(theOriginal->GetStudyID(), + theOriginal->GetEntry()); + + if (anOriginal.IsNull()) return aGEOMObject._retn(); + + //Create the copy + Handle(GEOM_Object) anObject = GetOperations()->MakeCopy(anOriginal); + + if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * Export + */ +//============================================================================= +void GEOM_IInsertOperations_i::Export + (GEOM::GEOM_Object_ptr theOriginal, + const char* theFileName, + const char* theFormatName) +{ + GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theOriginal); + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theOriginal == NULL) return; + + //Get the reference shape + Handle(GEOM_Object) anOriginal = + GetOperations()->GetEngine()->GetObject(theOriginal->GetStudyID(), + theOriginal->GetEntry()); + + if (anOriginal.IsNull()) return; + + //Export the shape to the file + char* aFileName = strdup(theFileName); + char* aFormatName = strdup(theFormatName); + GetOperations()->Export(anOriginal, aFileName, aFormatName); + free(aFileName); + free(aFormatName); + + return; +} + +//============================================================================= +/*! + * Import + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IInsertOperations_i::Import + (const char* theFileName, + const char* theFormatName) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Import the shape from the file + char* aFileName = strdup(theFileName); + char* aFormatName = strdup(theFormatName); + Handle(GEOM_Object) anObject = GetOperations()->Import(aFileName, aFormatName); + free(aFileName); + free(aFormatName); + + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * ImportTranslators + */ +//============================================================================= +void GEOM_IInsertOperations_i::ImportTranslators + (GEOM::string_array_out theFormats, GEOM::string_array_out thePatterns) +{ + // Get sequences of available formats + Handle(TColStd_HSequenceOfAsciiString) aFormats = new TColStd_HSequenceOfAsciiString; + Handle(TColStd_HSequenceOfAsciiString) aPatterns = new TColStd_HSequenceOfAsciiString; + if (!GetOperations()->ImportTranslators(aFormats, aPatterns)) return; + + const int formSize = aFormats->Length(), pattSize = aPatterns->Length(); + if (formSize != pattSize) return; + + // allocate the CORBA arrays + GEOM::string_array_var aFormatsArray = new GEOM::string_array(); + GEOM::string_array_var aPatternsArray = new GEOM::string_array(); + aFormatsArray->length(formSize); + aPatternsArray->length(formSize); + + // fill the local CORBA arrays with values from sequences + CORBA::Long i = 1; + for (; i <= formSize; i++) { + aFormatsArray[i-1] = CORBA::string_dup(aFormats->Value(i).ToCString()); + aPatternsArray[i-1] = CORBA::string_dup(aPatterns->Value(i).ToCString()); + } + + // initialize out-parameters with local arrays + theFormats = aFormatsArray._retn(); + thePatterns = aPatternsArray._retn(); +} + +//============================================================================= +/*! + * ExportTranslators + */ +//============================================================================= +void GEOM_IInsertOperations_i::ExportTranslators + (GEOM::string_array_out theFormats, GEOM::string_array_out thePatterns) +{ + // Get sequences of available formats + Handle(TColStd_HSequenceOfAsciiString) aFormats = new TColStd_HSequenceOfAsciiString; + Handle(TColStd_HSequenceOfAsciiString) aPatterns = new TColStd_HSequenceOfAsciiString; + if (!GetOperations()->ExportTranslators(aFormats, aPatterns)) return; + + const int formSize = aFormats->Length(), pattSize = aPatterns->Length(); + if (formSize != pattSize) return; + + // allocate the CORBA arrays + GEOM::string_array_var aFormatsArray = new GEOM::string_array(); + GEOM::string_array_var aPatternsArray = new GEOM::string_array(); + aFormatsArray->length(formSize); + aPatternsArray->length(formSize); + + // fill the local CORBA arrays with values from sequences + CORBA::Long i = 1; + for (; i <= formSize; i++) { + aFormatsArray[i-1] = CORBA::string_dup(aFormats->Value(i).ToCString()); + aPatternsArray[i-1] = CORBA::string_dup(aPatterns->Value(i).ToCString()); + } + + // initialize out-parameters with local arrays + theFormats = aFormatsArray._retn(); + thePatterns = aPatternsArray._retn(); +} diff --git a/src/GEOM_I/GEOM_IInsertOperations_i.hh b/src/GEOM_I/GEOM_IInsertOperations_i.hh new file mode 100644 index 000000000..d4822ce98 --- /dev/null +++ b/src/GEOM_I/GEOM_IInsertOperations_i.hh @@ -0,0 +1,42 @@ + +#ifndef _GEOM_IInsertOperations_i_HeaderFile +#define _GEOM_IInsertOperations_i_HeaderFile + + +#include + +#include CORBA_SERVER_HEADER(GEOM_Gen) +#include "GEOM_IOperations_i.hh" +#include "GEOM_Object_i.hh" + +#include "GEOMImpl_IInsertOperations.hxx" + +class GEOM_IInsertOperations_i : + public virtual POA_GEOM::GEOM_IInsertOperations, + public virtual GEOM_IOperations_i +{ + public: + GEOM_IInsertOperations_i (PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr theEngine, + ::GEOMImpl_IInsertOperations* theImpl); + ~GEOM_IInsertOperations_i(); + + GEOM::GEOM_Object_ptr MakeCopy (GEOM::GEOM_Object_ptr theOriginal); + + void Export (GEOM::GEOM_Object_ptr theOriginal, + const char* theFileName, + const char* theFormatName); + + GEOM::GEOM_Object_ptr Import (const char* theFileName, + const char* theFormatName); + + void ImportTranslators (GEOM::string_array_out theFormats, + GEOM::string_array_out thePatterns); + + void ExportTranslators (GEOM::string_array_out theFormats, + GEOM::string_array_out thePatterns); + + ::GEOMImpl_IInsertOperations* GetOperations() + { return (::GEOMImpl_IInsertOperations*)GetImpl(); } +}; + +#endif diff --git a/src/GEOM_I/GEOM_ILocalOperations_i.cc b/src/GEOM_I/GEOM_ILocalOperations_i.cc new file mode 100644 index 000000000..cfd948da1 --- /dev/null +++ b/src/GEOM_I/GEOM_ILocalOperations_i.cc @@ -0,0 +1,275 @@ +using namespace std; + +#include "GEOM_ILocalOperations_i.hh" + +#include "utilities.h" +#include "OpUtil.hxx" +#include "Utils_ExceptHandlers.hxx" + +#include "GEOM_Engine.hxx" +#include "GEOM_Object.hxx" + +//============================================================================= +/*! + * constructor: + */ +//============================================================================= +GEOM_ILocalOperations_i::GEOM_ILocalOperations_i (PortableServer::POA_ptr thePOA, + GEOM::GEOM_Gen_ptr theEngine, + ::GEOMImpl_ILocalOperations* theImpl) + :GEOM_IOperations_i(thePOA, theEngine, theImpl) +{ + MESSAGE("GEOM_ILocalOperations_i::GEOM_ILocalOperations_i"); +} + +//============================================================================= +/*! + * destructor + */ +//============================================================================= +GEOM_ILocalOperations_i::~GEOM_ILocalOperations_i() +{ + MESSAGE("GEOM_ILocalOperations_i::~GEOM_ILocalOperations_i"); +} + + +//============================================================================= +/*! + * MakeFilletAll + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFilletAll + (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR) +{ + GEOM::GEOM_Object_var aGEOMObject; + + if (theShape == NULL) return aGEOMObject._retn(); + + //Get the reference shape + Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject + (theShape->GetStudyID(), theShape->GetEntry()); + + if (aShapeRef.IsNull()) return aGEOMObject._retn(); + + //Create the Fillet + Handle(GEOM_Object) anObject = + GetOperations()->MakeFilletAll(aShapeRef, theR); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakeFilletEdges + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFilletEdges + (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR, + const GEOM::ListOfLong& theEdges) +{ + GEOM::GEOM_Object_var aGEOMObject; + + if (theShape == NULL) return aGEOMObject._retn(); + + //Get the reference shape + Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject + (theShape->GetStudyID(), theShape->GetEntry()); + if (aShapeRef.IsNull()) return aGEOMObject._retn(); + + //Get the reference edges + int ind = 0; + int aLen = theEdges.length(); + list anEdges; + for (; ind < aLen; ind++) { + anEdges.push_back(theEdges[ind]); + } + + //Create the Fillet + Handle(GEOM_Object) anObject = + GetOperations()->MakeFilletEdges(aShapeRef, theR, anEdges); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakeFilletFaces + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFilletFaces + (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR, + const GEOM::ListOfLong& theFaces) +{ + GEOM::GEOM_Object_var aGEOMObject; + + if (theShape == NULL) return aGEOMObject._retn(); + + //Get the reference shape + Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject + (theShape->GetStudyID(), theShape->GetEntry()); + if (aShapeRef.IsNull()) return aGEOMObject._retn(); + + //Get the reference faces + int ind = 0; + int aLen = theFaces.length(); + list aFaces; + for (; ind < aLen; ind++) { + aFaces.push_back(theFaces[ind]); + } + + //Create the Fillet + Handle(GEOM_Object) anObject = + GetOperations()->MakeFilletFaces(aShapeRef, theR, aFaces); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakeChamferAll + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferAll + (GEOM::GEOM_Object_ptr theShape, CORBA::Double theD) +{ + GEOM::GEOM_Object_var aGEOMObject; + + if (theShape == NULL) return aGEOMObject._retn(); + + //Get the reference shape + Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject + (theShape->GetStudyID(), theShape->GetEntry()); + + if (aShapeRef.IsNull()) return aGEOMObject._retn(); + + //Create the Chamfer + Handle(GEOM_Object) anObject = + GetOperations()->MakeChamferAll(aShapeRef, theD); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakeChamferEdge + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferEdge + (GEOM::GEOM_Object_ptr theShape, + CORBA::Double theD1, CORBA::Double theD2, + CORBA::Long theFace1, CORBA::Long theFace2) +{ + GEOM::GEOM_Object_var aGEOMObject; + + if (theShape == NULL) return aGEOMObject._retn(); + + //Get the reference shape + Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject + (theShape->GetStudyID(), theShape->GetEntry()); + if (aShapeRef.IsNull()) return aGEOMObject._retn(); + + //Create the Chamfer + Handle(GEOM_Object) anObject = + GetOperations()->MakeChamferEdge(aShapeRef, theD1, theD2, theFace1, theFace2); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakeChamferFaces + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeChamferFaces + (GEOM::GEOM_Object_ptr theShape, + CORBA::Double theD1, CORBA::Double theD2, + const GEOM::ListOfLong& theFaces) +{ + GEOM::GEOM_Object_var aGEOMObject; + + if (theShape == NULL) return aGEOMObject._retn(); + + //Get the reference shape + Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject + (theShape->GetStudyID(), theShape->GetEntry()); + if (aShapeRef.IsNull()) return aGEOMObject._retn(); + + //Get the reference faces + int ind = 0; + int aLen = theFaces.length(); + list aFaces; + for (; ind < aLen; ind++) { + aFaces.push_back(theFaces[ind]); + } + + //Create the Chamfer + Handle(GEOM_Object) anObject = + GetOperations()->MakeChamferFaces(aShapeRef, theD1, theD2, aFaces); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakeArchimede + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeArchimede (GEOM::GEOM_Object_ptr theShape, + CORBA::Double theWeight, + CORBA::Double theWaterDensity, + CORBA::Double theMeshingDeflection) +{ + GEOM::GEOM_Object_var aGEOMObject; + + if (theShape == NULL) return aGEOMObject._retn(); + + //Get the reference shape + Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject + (theShape->GetStudyID(), theShape->GetEntry()); + if (aShapeRef.IsNull()) return aGEOMObject._retn(); + + //Create the Archimede + Handle(GEOM_Object) anObject = GetOperations()->MakeArchimede + (aShapeRef, theWeight, theWaterDensity, theMeshingDeflection); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * GetSubShapeIndex + */ +//============================================================================= +CORBA::Long GEOM_ILocalOperations_i::GetSubShapeIndex + (GEOM::GEOM_Object_ptr theShape, GEOM::GEOM_Object_ptr theSubShape) +{ + if (theShape == NULL || theSubShape == NULL) return -1; + + //Get the reference shapes + Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject + (theShape->GetStudyID(), theShape->GetEntry()); + Handle(GEOM_Object) aSubShapeRef = GetOperations()->GetEngine()->GetObject + (theSubShape->GetStudyID(), theSubShape->GetEntry()); + if (aShapeRef.IsNull() || aSubShapeRef.IsNull()) return -1; + + //Get the unique ID of inside + CORBA::Long anID = GetOperations()->GetSubShapeIndex(aShapeRef, aSubShapeRef); + if (!GetOperations()->IsDone()) + return -1; + + return anID; +} diff --git a/src/GEOM_I/GEOM_ILocalOperations_i.hh b/src/GEOM_I/GEOM_ILocalOperations_i.hh new file mode 100644 index 000000000..50e37fde8 --- /dev/null +++ b/src/GEOM_I/GEOM_ILocalOperations_i.hh @@ -0,0 +1,50 @@ + +#ifndef _GEOM_ILocalOperations_i_HeaderFile +#define _GEOM_ILocalOperations_i_HeaderFile + + +#include + +#include CORBA_SERVER_HEADER(GEOM_Gen) +#include "GEOM_IOperations_i.hh" +#include "GEOM_Object_i.hh" + +#include "GEOMImpl_ILocalOperations.hxx" + +class GEOM_ILocalOperations_i : + public virtual POA_GEOM::GEOM_ILocalOperations, + public virtual GEOM_IOperations_i +{ + public: + GEOM_ILocalOperations_i (PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr theEngine, + ::GEOMImpl_ILocalOperations* theImpl); + ~GEOM_ILocalOperations_i(); + + GEOM::GEOM_Object_ptr MakeFilletAll (GEOM::GEOM_Object_ptr theShape, + CORBA::Double theR); + GEOM::GEOM_Object_ptr MakeFilletEdges (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR, + const GEOM::ListOfLong& theEdges); + GEOM::GEOM_Object_ptr MakeFilletFaces (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR, + const GEOM::ListOfLong& theFaces); + + GEOM::GEOM_Object_ptr MakeChamferAll (GEOM::GEOM_Object_ptr theShape, CORBA::Double theD); + GEOM::GEOM_Object_ptr MakeChamferEdge (GEOM::GEOM_Object_ptr theShape, + CORBA::Double theD1, CORBA::Double theD2, + CORBA::Long theFace1, CORBA::Long theFace2); + GEOM::GEOM_Object_ptr MakeChamferFaces (GEOM::GEOM_Object_ptr theShape, + CORBA::Double theD1, CORBA::Double theD2, + const GEOM::ListOfLong& theFaces); + + GEOM::GEOM_Object_ptr MakeArchimede (GEOM::GEOM_Object_ptr theShape, + CORBA::Double theWeight, + CORBA::Double theWaterDensity, + CORBA::Double theMeshingDeflection); + + CORBA::Long GetSubShapeIndex (GEOM::GEOM_Object_ptr theShape, + GEOM::GEOM_Object_ptr theSubShape); + + ::GEOMImpl_ILocalOperations* GetOperations() + { return (::GEOMImpl_ILocalOperations*)GetImpl(); } +}; + +#endif diff --git a/src/GEOM_I/GEOM_IMeasureOperations_i.cc b/src/GEOM_I/GEOM_IMeasureOperations_i.cc new file mode 100644 index 000000000..6ff28f176 --- /dev/null +++ b/src/GEOM_I/GEOM_IMeasureOperations_i.cc @@ -0,0 +1,275 @@ +using namespace std; + +#include "GEOM_IMeasureOperations_i.hh" + +#include "utilities.h" +#include "OpUtil.hxx" + +#include "GEOM_Engine.hxx" +#include "GEOM_Object.hxx" + +//============================================================================= +/*! + * constructor: + */ +//============================================================================= +GEOM_IMeasureOperations_i::GEOM_IMeasureOperations_i (PortableServer::POA_ptr thePOA, + GEOM::GEOM_Gen_ptr theEngine, + ::GEOMImpl_IMeasureOperations* theImpl) +:GEOM_IOperations_i(thePOA, theEngine, theImpl) +{ + MESSAGE("GEOM_IMeasureOperations_i::GEOM_IMeasureOperations_i"); +} + +//============================================================================= +/*! + * destructor + */ +//============================================================================= +GEOM_IMeasureOperations_i::~GEOM_IMeasureOperations_i() +{ + MESSAGE("GEOM_IMeasureOperations_i::~GEOM_IMeasureOperations_i"); +} + + +//============================================================================= +/*! + * GetCentreOfMass + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IMeasureOperations_i::GetCentreOfMass + (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 shape + Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject + (theShape->GetStudyID(), theShape->GetEntry()); + + if (aShape.IsNull()) return aGEOMObject._retn(); + + // Make Point - centre of mass of theShape + Handle(GEOM_Object) anObject = GetOperations()->GetCentreOfMass(aShape); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * GetBasicProperties + */ +//============================================================================= +void GEOM_IMeasureOperations_i::GetBasicProperties (GEOM::GEOM_Object_ptr theShape, + CORBA::Double& theLength, + CORBA::Double& theSurfArea, + CORBA::Double& theVolume) +{ + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theShape == NULL) return; + + //Get the reference shape + Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject + (theShape->GetStudyID(), theShape->GetEntry()); + + if (aShape.IsNull()) return; + + // Get shape parameters + GetOperations()->GetBasicProperties(aShape, theLength, theSurfArea, theVolume); +} + +//============================================================================= +/*! + * GetInertia + */ +//============================================================================= +void GEOM_IMeasureOperations_i::GetInertia + (GEOM::GEOM_Object_ptr theShape, + CORBA::Double& I11, CORBA::Double& I12, CORBA::Double& I13, + CORBA::Double& I21, CORBA::Double& I22, CORBA::Double& I23, + CORBA::Double& I31, CORBA::Double& I32, CORBA::Double& I33, + CORBA::Double& Ix , CORBA::Double& Iy , CORBA::Double& Iz) +{ + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theShape == NULL) return; + + //Get the reference shape + Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject + (theShape->GetStudyID(), theShape->GetEntry()); + + if (aShape.IsNull()) return; + + // Get shape parameters + GetOperations()->GetInertia(aShape, + I11, I12, I13, + I21, I22, I23, + I31, I32, I33, + Ix , Iy , Iz); +} + +//============================================================================= +/*! + * GetBoundingBox + */ +//============================================================================= +void GEOM_IMeasureOperations_i::GetBoundingBox (GEOM::GEOM_Object_ptr theShape, + CORBA::Double& Xmin, CORBA::Double& Xmax, + CORBA::Double& Ymin, CORBA::Double& Ymax, + CORBA::Double& Zmin, CORBA::Double& Zmax) +{ + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theShape == NULL) return; + + //Get the reference shape + Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject + (theShape->GetStudyID(), theShape->GetEntry()); + + if (aShape.IsNull()) return; + + // Get shape parameters + GetOperations()->GetBoundingBox(aShape, Xmin, Xmax, Ymin, Ymax, Zmin, Zmax); +} + +//============================================================================= +/*! + * GetTolerance + */ +//============================================================================= +void GEOM_IMeasureOperations_i::GetTolerance + (GEOM::GEOM_Object_ptr theShape, + CORBA::Double& FaceMin, CORBA::Double& FaceMax, + CORBA::Double& EdgeMin, CORBA::Double& EdgeMax, + CORBA::Double& VertMin, CORBA::Double& VertMax) +{ + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theShape == NULL) return; + + //Get the reference shape + Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject + (theShape->GetStudyID(), theShape->GetEntry()); + + if (aShape.IsNull()) return; + + // Get shape parameters + GetOperations()->GetTolerance(aShape, + FaceMin, FaceMax, + EdgeMin, EdgeMax, + VertMin, VertMax); +} + +//============================================================================= +/*! + * CheckShape + */ +//============================================================================= +CORBA::Boolean GEOM_IMeasureOperations_i::CheckShape (GEOM::GEOM_Object_ptr theShape, + CORBA::String_out theDescription) +{ + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theShape == NULL) return 0; + + //Get the reference shape + Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject + (theShape->GetStudyID(), theShape->GetEntry()); + + if (aShape.IsNull()) return 0; + + // Get shape parameters + TCollection_AsciiString aDump; + if (GetOperations()->CheckShape(aShape, aDump)) return 1; + + theDescription = CORBA::string_dup(aDump.ToCString()); + return 0; +} + +//============================================================================= +/*! + * WhatIs + */ +//============================================================================= +char* GEOM_IMeasureOperations_i::WhatIs (GEOM::GEOM_Object_ptr theShape) +{ + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theShape == NULL) return NULL; + + //Get the reference shape + Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject + (theShape->GetStudyID(), theShape->GetEntry()); + + if (aShape.IsNull()) return NULL; + + // Get shape parameters + TCollection_AsciiString aDescription = GetOperations()->WhatIs(aShape); + return strdup(aDescription.ToCString()); +} + +//============================================================================= +/*! + * GetMinDistance + */ +//============================================================================= +CORBA::Double GEOM_IMeasureOperations_i::GetMinDistance + (GEOM::GEOM_Object_ptr theShape1, GEOM::GEOM_Object_ptr theShape2, + CORBA::Double& X1, CORBA::Double& Y1, CORBA::Double& Z1, + CORBA::Double& X2, CORBA::Double& Y2, CORBA::Double& Z2) +{ + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theShape1 == NULL || theShape2 == NULL) return -1.0; + + //Get the reference shape + 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 -1.0; + + // Get shape parameters + return GetOperations()->GetMinDistance(aShape1, aShape2, X1, Y1, Z1, X2, Y2, Z2); +} + +//============================================================================= +/*! + * PointCoordinates + */ +//============================================================================= +void GEOM_IMeasureOperations_i::PointCoordinates( + GEOM::GEOM_Object_ptr theShape, CORBA::Double& X, CORBA::Double& Y, CORBA::Double& Z ) + +{ + //Set a not done flag + GetOperations()->SetNotDone(); + + if ( theShape->_is_nil() ) + return; + + //Get the reference shape + Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject( + theShape->GetStudyID(), theShape->GetEntry() ); + + if ( aShape.IsNull() ) + return; + + // Get shape parameters + GetOperations()->PointCoordinates( aShape, X, Y, Z ); +} diff --git a/src/GEOM_I/GEOM_IMeasureOperations_i.hh b/src/GEOM_I/GEOM_IMeasureOperations_i.hh new file mode 100644 index 000000000..6e26f873e --- /dev/null +++ b/src/GEOM_I/GEOM_IMeasureOperations_i.hh @@ -0,0 +1,64 @@ + +#ifndef _GEOM_IMeasureOperations_i_HeaderFile +#define _GEOM_IMeasureOperations_i_HeaderFile + + +#include + +#include CORBA_SERVER_HEADER(GEOM_Gen) +#include "GEOM_IOperations_i.hh" +#include "GEOM_Object_i.hh" + +#include "GEOMImpl_IMeasureOperations.hxx" + +class GEOM_IMeasureOperations_i : + public virtual POA_GEOM::GEOM_IMeasureOperations, + public virtual GEOM_IOperations_i +{ + public: + GEOM_IMeasureOperations_i (PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr theEngine, + ::GEOMImpl_IMeasureOperations* theImpl); + ~GEOM_IMeasureOperations_i(); + + void GetBasicProperties (GEOM::GEOM_Object_ptr theShape, + CORBA::Double& theLength, + CORBA::Double& theSurfArea, + CORBA::Double& theVolume); + + GEOM::GEOM_Object_ptr GetCentreOfMass (GEOM::GEOM_Object_ptr theShape); + + void GetInertia (GEOM::GEOM_Object_ptr theShape, + CORBA::Double& I11, CORBA::Double& I12, CORBA::Double& I13, + CORBA::Double& I21, CORBA::Double& I22, CORBA::Double& I23, + CORBA::Double& I31, CORBA::Double& I32, CORBA::Double& I33, + CORBA::Double& Ix , CORBA::Double& Iy , CORBA::Double& Iz); + + void GetBoundingBox (GEOM::GEOM_Object_ptr theShape, + CORBA::Double& Xmin, CORBA::Double& Xmax, + CORBA::Double& Ymin, CORBA::Double& Ymax, + CORBA::Double& Zmin, CORBA::Double& Zmax); + + void GetTolerance (GEOM::GEOM_Object_ptr theShape, + CORBA::Double& FaceMin, CORBA::Double& FaceMax, + CORBA::Double& EdgeMin, CORBA::Double& EdgeMax, + CORBA::Double& VertMin, CORBA::Double& VertMax); + + CORBA::Boolean CheckShape (GEOM::GEOM_Object_ptr theShape, + CORBA::String_out theDescription); + + char* WhatIs (GEOM::GEOM_Object_ptr theShape); + + CORBA::Double GetMinDistance (GEOM::GEOM_Object_ptr theShape1, + GEOM::GEOM_Object_ptr theShape2, + CORBA::Double& X1, CORBA::Double& Y1, CORBA::Double& Z1, + CORBA::Double& X2, CORBA::Double& Y2, CORBA::Double& Z2); + + + void PointCoordinates( GEOM::GEOM_Object_ptr theShape, + CORBA::Double& X, CORBA::Double& Y, CORBA::Double& Z ); + + ::GEOMImpl_IMeasureOperations* GetOperations() + { return (::GEOMImpl_IMeasureOperations*)GetImpl(); } +}; + +#endif diff --git a/src/GEOM_I/GEOM_IOperations_i.cc b/src/GEOM_I/GEOM_IOperations_i.cc new file mode 100644 index 000000000..d570efe16 --- /dev/null +++ b/src/GEOM_I/GEOM_IOperations_i.cc @@ -0,0 +1,123 @@ +using namespace std; + +#include "GEOM_IOperations_i.hh" + +#include "utilities.h" +#include "OpUtil.hxx" +#include "Utils_ExceptHandlers.hxx" + +#include "GEOM_Engine.hxx" + +#include "GEOM_Gen_i.hh" + +#include +#include + +//============================================================================= +/*! + * default constructor: + */ +//============================================================================= + +GEOM_IOperations_i::GEOM_IOperations_i(PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr theEngine, ::GEOM_IOperations* theImpl) +:SALOME::GenericObj_i( thePOA ), _impl(theImpl), _engine(theEngine) +{ + thePOA->activate_object(this); +} + +//============================================================================= +/*! + * destructor + */ +//============================================================================= + +GEOM_IOperations_i::~GEOM_IOperations_i() +{} + + +//============================================================================= +/*! + * IsDone + */ +//============================================================================= +CORBA::Boolean GEOM_IOperations_i::IsDone() +{ + return _impl->IsDone(); +} + + +//============================================================================= +/*! + * SetErrorCode + */ +//============================================================================= +void GEOM_IOperations_i::SetErrorCode(const char* theErrorCode) +{ + _impl->SetErrorCode((char*)theErrorCode); +} + +//============================================================================= +/*! + * GetErrorCode + */ +//============================================================================= +char* GEOM_IOperations_i::GetErrorCode() +{ + return _impl->GetErrorCode(); +} + +//============================================================================= +/*! + * GetStudyID + */ +//============================================================================= +CORBA::Long GEOM_IOperations_i::GetStudyID() +{ + return _impl->GetDocID(); +} + +//============================================================================= +/*! + * StartOperation + */ +//============================================================================= +void GEOM_IOperations_i::StartOperation() +{ + _impl->StartOperation(); +} + +//============================================================================= +/*! + * FinishOperation + */ +//============================================================================= +void GEOM_IOperations_i::FinishOperation() +{ + _impl->FinishOperation(); +} + + +//============================================================================= +/*! + * AboutOperation + */ +//============================================================================= +void GEOM_IOperations_i::AbortOperation() +{ + _impl->AbortOperation(); +} + +//============================================================================= +/*! + * GetObject + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IOperations_i::GetObject(Handle(GEOM_Object) theObject) +{ + if(theObject.IsNull()) return NULL; + TCollection_AsciiString anEntry; + TDF_Tool::Entry(theObject->GetEntry(), anEntry); + GEOM::GEOM_Object_var GO = GEOM::GEOM_Object::_duplicate(_engine->GetObject(theObject->GetDocID(), anEntry.ToCString())); + return GO._retn(); +} + diff --git a/src/GEOM_I/GEOM_IOperations_i.hh b/src/GEOM_I/GEOM_IOperations_i.hh new file mode 100644 index 000000000..b881fcbe4 --- /dev/null +++ b/src/GEOM_I/GEOM_IOperations_i.hh @@ -0,0 +1,45 @@ + +#ifndef _GEOM_IOperations_i_HeaderFile +#define _GEOM_IOperations_i_HeaderFile + + +#include + +#include CORBA_SERVER_HEADER(GEOM_Gen) +#include "SALOME_GenericObj_i.hh" +#include "GEOM_IOperations.hxx" +#include "GEOM_Object_i.hh" +#include "GEOM_Object.hxx" + +class GEOM_IOperations_i : public virtual POA_GEOM::GEOM_IOperations, public virtual SALOME::GenericObj_i +{ + public: + GEOM_IOperations_i(PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr theEngine, ::GEOM_IOperations* theImpl); + ~GEOM_IOperations_i(); + + virtual CORBA::Boolean IsDone(); + + virtual void SetErrorCode(const char* theErrorCode); + + virtual char* GetErrorCode(); + + virtual CORBA::Long GetStudyID(); + + virtual GEOM::GEOM_Object_ptr GetObject(Handle(GEOM_Object) theObject); + + virtual void StartOperation(); + + virtual void FinishOperation(); + + virtual void AbortOperation(); + + + ::GEOM_IOperations* GetImpl() { return _impl; } + + private: + + ::GEOM_IOperations* _impl; + GEOM::GEOM_Gen_ptr _engine; +}; + +#endif diff --git a/src/GEOM_I/GEOM_IShapesOperations_i.cc b/src/GEOM_I/GEOM_IShapesOperations_i.cc new file mode 100644 index 000000000..4f8236d4a --- /dev/null +++ b/src/GEOM_I/GEOM_IShapesOperations_i.cc @@ -0,0 +1,451 @@ +using namespace std; + +#include "GEOM_IShapesOperations_i.hh" + +#include "utilities.h" +#include "OpUtil.hxx" +#include "Utils_ExceptHandlers.hxx" + +#include "GEOM_Engine.hxx" +#include "GEOM_Object.hxx" + +#include +#include + +//============================================================================= +/*! + * constructor: + */ +//============================================================================= +GEOM_IShapesOperations_i::GEOM_IShapesOperations_i (PortableServer::POA_ptr thePOA, + GEOM::GEOM_Gen_ptr theEngine, + ::GEOMImpl_IShapesOperations* theImpl) +:GEOM_IOperations_i(thePOA, theEngine, theImpl) +{ + MESSAGE("GEOM_IShapesOperations_i::GEOM_IShapesOperations_i"); +} + +//============================================================================= +/*! + * destructor + */ +//============================================================================= +GEOM_IShapesOperations_i::~GEOM_IShapesOperations_i() +{ + MESSAGE("GEOM_IShapesOperations_i::~GEOM_IShapesOperations_i"); +} + + +//============================================================================= +/*! + * MakeEdge + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeEdge + (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (thePnt1 == NULL || thePnt2 == NULL) return aGEOMObject._retn(); + + //Get the reference points + Handle(GEOM_Object) aPnt1 = GetOperations()->GetEngine()->GetObject + (thePnt1->GetStudyID(), thePnt1->GetEntry()); + Handle(GEOM_Object) aPnt2 = GetOperations()->GetEngine()->GetObject + (thePnt2->GetStudyID(), thePnt2->GetEntry()); + + if (aPnt1.IsNull() || aPnt2.IsNull()) return aGEOMObject._retn(); + + //Create the Edge + Handle(GEOM_Object) anObject = GetOperations()->MakeEdge(aPnt1, aPnt2); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakeWire + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeWire + (const GEOM::ListOfGO& theEdgesAndWires) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + int ind, aLen; + list aShapes; + + //Get the shapes + aLen = theEdgesAndWires.length(); + for (ind = 0; ind < aLen; ind++) { + if (theEdgesAndWires[ind] == NULL) return aGEOMObject._retn(); + Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject + (theEdgesAndWires[ind]->GetStudyID(), theEdgesAndWires[ind]->GetEntry()); + if (aSh.IsNull()) return aGEOMObject._retn(); + aShapes.push_back(aSh); + } + + // Make Solid + Handle(GEOM_Object) anObject = + GetOperations()->MakeWire(aShapes); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakeFace + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeFace + (GEOM::GEOM_Object_ptr theWire, CORBA::Boolean isPlanarWanted) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theWire == NULL) return aGEOMObject._retn(); + + //Get the reference wire + Handle(GEOM_Object) aWire = GetOperations()->GetEngine()->GetObject + (theWire->GetStudyID(), theWire->GetEntry()); + + if (aWire.IsNull()) return aGEOMObject._retn(); + + //Create the Face + Handle(GEOM_Object) anObject = GetOperations()->MakeFace(aWire, isPlanarWanted); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakeFaceWires + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeFaceWires + (const GEOM::ListOfGO& theWires, + CORBA::Boolean isPlanarWanted) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + int ind, aLen; + list aShapes; + + //Get the shapes + aLen = theWires.length(); + for (ind = 0; ind < aLen; ind++) { + if (theWires[ind] == NULL) return aGEOMObject._retn(); + Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject + (theWires[ind]->GetStudyID(), theWires[ind]->GetEntry()); + if (aSh.IsNull()) return aGEOMObject._retn(); + aShapes.push_back(aSh); + } + + // Make Face + Handle(GEOM_Object) anObject = + GetOperations()->MakeFaceWires(aShapes, isPlanarWanted); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakeShell + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeShell + (const GEOM::ListOfGO& theFacesAndShells) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + int ind, aLen; + list aShapes; + + //Get the shapes + aLen = theFacesAndShells.length(); + for (ind = 0; ind < aLen; ind++) { + if (theFacesAndShells[ind] == NULL) return aGEOMObject._retn(); + Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject + (theFacesAndShells[ind]->GetStudyID(), theFacesAndShells[ind]->GetEntry()); + if (aSh.IsNull()) return aGEOMObject._retn(); + aShapes.push_back(aSh); + } + + // Make Solid + Handle(GEOM_Object) anObject = + GetOperations()->MakeShell(aShapes); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakeSolidShell + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeSolidShell + (GEOM::GEOM_Object_ptr theShell) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theShell == NULL) return aGEOMObject._retn(); + + //Get the reference objects + Handle(GEOM_Object) aShell = GetOperations()->GetEngine()->GetObject + (theShell->GetStudyID(), theShell->GetEntry()); + + if (aShell.IsNull()) return aGEOMObject._retn(); + + //Create the Solid + Handle(GEOM_Object) anObject = GetOperations()->MakeSolidShell(aShell); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakeSolidShells + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeSolidShells + (const GEOM::ListOfGO& theShells) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + int ind, aLen; + list aShapes; + + //Get the shapes + aLen = theShells.length(); + for (ind = 0; ind < aLen; ind++) { + if (theShells[ind] == NULL) return aGEOMObject._retn(); + Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject + (theShells[ind]->GetStudyID(), theShells[ind]->GetEntry()); + if (aSh.IsNull()) return aGEOMObject._retn(); + aShapes.push_back(aSh); + } + + // Make Solid + Handle(GEOM_Object) anObject = + GetOperations()->MakeSolidShells(aShapes); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakeCompound + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeCompound + (const GEOM::ListOfGO& theShapes) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + int ind, aLen; + list aShapes; + + //Get the shapes + aLen = theShapes.length(); + for (ind = 0; ind < aLen; ind++) { + if (theShapes[ind] == NULL) return aGEOMObject._retn(); + Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject + (theShapes[ind]->GetStudyID(), theShapes[ind]->GetEntry()); + if (aSh.IsNull()) return aGEOMObject._retn(); + aShapes.push_back(aSh); + } + + // Make Solid + Handle(GEOM_Object) anObject = + GetOperations()->MakeCompound(aShapes); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakeGlueFaces + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeGlueFaces + (GEOM::GEOM_Object_ptr theShape, + const CORBA::Double theTolerance) +{ + 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(); + + //Perform the glueing + Handle(GEOM_Object) anObject = + GetOperations()->MakeGlueFaces(aShape, theTolerance); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakeExplode + */ +//============================================================================= +GEOM::ListOfGO* GEOM_IShapesOperations_i::MakeExplode (GEOM::GEOM_Object_ptr theShape, + const CORBA::Long theShapeType, + 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(); + + 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(); +} + +//============================================================================= +/*! + * GetSubShape + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetSubShape + (GEOM::GEOM_Object_ptr theMainShape, + const CORBA::Long theID) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theMainShape == NULL) return aGEOMObject._retn(); + + //Get the reference objects + Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject + (theMainShape->GetStudyID(), theMainShape->GetEntry()); + + if (aShape.IsNull()) return aGEOMObject._retn(); + + Handle(GEOM_Object) anObject = GetOperations()->GetSubShape(aShape, theID); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * NumberOfFaces + */ +//============================================================================= +CORBA::Long GEOM_IShapesOperations_i::NumberOfFaces (GEOM::GEOM_Object_ptr theShape) +{ + if (theShape == NULL) return -1; + + Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject + (theShape->GetStudyID(), theShape->GetEntry()); + + CORBA::Long aNb = GetOperations()->NumberOfFaces(aShape); + if (!GetOperations()->IsDone()) return -1; + + return aNb; +} + +//============================================================================= +/*! + * NumberOfEdges + */ +//============================================================================= +CORBA::Long GEOM_IShapesOperations_i::NumberOfEdges (GEOM::GEOM_Object_ptr theShape) +{ + if (theShape == NULL) return -1; + + Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject + (theShape->GetStudyID(), theShape->GetEntry()); + + CORBA::Long aNb = GetOperations()->NumberOfEdges(aShape); + if (!GetOperations()->IsDone()) return -1; + + return aNb; +} + +//============================================================================= +/*! + * ReverseOrientation + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::ChangeOrientation + (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(); + + //Create the Solid + Handle(GEOM_Object) anObject = GetOperations()->ReverseShape(aShape); + 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 new file mode 100644 index 000000000..4a63bb1f5 --- /dev/null +++ b/src/GEOM_I/GEOM_IShapesOperations_i.hh @@ -0,0 +1,61 @@ + +#ifndef _GEOM_IShapesOperations_i_HeaderFile +#define _GEOM_IShapesOperations_i_HeaderFile + + +#include + +#include CORBA_SERVER_HEADER(GEOM_Gen) +#include "GEOM_IOperations_i.hh" +#include "GEOM_Object_i.hh" + +#include "GEOMImpl_IShapesOperations.hxx" + +class GEOM_IShapesOperations_i : + public virtual POA_GEOM::GEOM_IShapesOperations, + public virtual GEOM_IOperations_i +{ + public: + GEOM_IShapesOperations_i (PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr theEngine, + ::GEOMImpl_IShapesOperations* theImpl); + ~GEOM_IShapesOperations_i(); + + GEOM::GEOM_Object_ptr MakeEdge (GEOM::GEOM_Object_ptr thePnt1, + GEOM::GEOM_Object_ptr thePnt2); + + GEOM::GEOM_Object_ptr MakeWire (const GEOM::ListOfGO& theEdgesAndWires); + + GEOM::GEOM_Object_ptr MakeFace (GEOM::GEOM_Object_ptr theWire, + CORBA::Boolean isPlanarWanted); + + GEOM::GEOM_Object_ptr MakeFaceWires (const GEOM::ListOfGO& theWires, + CORBA::Boolean isPlanarWanted); + + GEOM::GEOM_Object_ptr MakeShell (const GEOM::ListOfGO& theFacesAndShells); + + GEOM::GEOM_Object_ptr MakeSolidShell (GEOM::GEOM_Object_ptr theShell); + + GEOM::GEOM_Object_ptr MakeSolidShells (const GEOM::ListOfGO& theShells); + + GEOM::GEOM_Object_ptr MakeCompound (const GEOM::ListOfGO& theShapes); + + GEOM::GEOM_Object_ptr MakeGlueFaces (GEOM::GEOM_Object_ptr theShape, + const CORBA::Double theTolerance); + + GEOM::ListOfGO* MakeExplode (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); + + CORBA::Long NumberOfFaces (GEOM::GEOM_Object_ptr theShape); + CORBA::Long NumberOfEdges (GEOM::GEOM_Object_ptr theShape); + + GEOM::GEOM_Object_ptr ChangeOrientation (GEOM::GEOM_Object_ptr theShape); + + ::GEOMImpl_IShapesOperations* GetOperations() + { return (::GEOMImpl_IShapesOperations*)GetImpl(); } +}; + +#endif diff --git a/src/GEOM_I/GEOM_ITransformOperations_i.cc b/src/GEOM_I/GEOM_ITransformOperations_i.cc new file mode 100644 index 000000000..07f027b5e --- /dev/null +++ b/src/GEOM_I/GEOM_ITransformOperations_i.cc @@ -0,0 +1,944 @@ +using namespace std; + +#include "GEOM_ITransformOperations_i.hh" + +#include "utilities.h" +#include "OpUtil.hxx" +#include "Utils_ExceptHandlers.hxx" + +#include +#include +#include +#include "GEOM_Engine.hxx" +#include "GEOM_Object.hxx" + +#define SUBSHAPE_ERROR "Sub shape cannot be transformed" + +//============================================================================= +/*! + * constructor: + */ +//============================================================================= + +GEOM_ITransformOperations_i::GEOM_ITransformOperations_i (PortableServer::POA_ptr thePOA, + GEOM::GEOM_Gen_ptr theEngine, + ::GEOMImpl_ITransformOperations* theImpl) + :GEOM_IOperations_i(thePOA, theEngine, theImpl) +{ + MESSAGE("GEOM_ITransformOperations_i::GEOM_ITransformOperations_i"); +} + +//============================================================================= +/*! + * destructor + */ +//============================================================================= + +GEOM_ITransformOperations_i::~GEOM_ITransformOperations_i() +{ + MESSAGE("GEOM_ITransformOperations_i::~GEOM_ITransformOperations_i"); +} + + +//============================================================================= +/*! + * TranslateTwoPoints + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateTwoPoints + (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr thePoint1, + GEOM::GEOM_Object_ptr thePoint2) +{ + //Set a not done flag + GetOperations()->SetNotDone(); + GEOM::GEOM_Object_var aGEOMObject; + + if (thePoint1 == NULL || thePoint2 == NULL || theObject == NULL) return aGEOMObject._retn(); + + //check if the object is a subshape + if(!theObject->IsMainShape()) { + GetOperations()->SetErrorCode(SUBSHAPE_ERROR); + return aGEOMObject._retn(); + } + + aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject); + + //Get the object itself + Handle(GEOM_Object) anObject = + GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry()); + if (anObject.IsNull()) return aGEOMObject._retn(); + + //Get the first point of translation + Handle(GEOM_Object) aPoint1 = + GetOperations()->GetEngine()->GetObject(thePoint1->GetStudyID(), thePoint1->GetEntry()); + if (aPoint1.IsNull()) return aGEOMObject._retn(); + + //Get the second point of translation + Handle(GEOM_Object) aPoint2 = + GetOperations()->GetEngine()->GetObject(thePoint2->GetStudyID(), thePoint2->GetEntry()); + if (aPoint2.IsNull()) return aGEOMObject._retn(); + + //Perform the translation + GetOperations()->TranslateTwoPoints(anObject, aPoint1, aPoint2); + + return aGEOMObject._retn(); +} + +//============================================================================= +/*! + * TranslateTwoPointsCopy + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateTwoPointsCopy + (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr thePoint1, + GEOM::GEOM_Object_ptr thePoint2) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (thePoint1 == NULL || thePoint2 == NULL || theObject == NULL) return aGEOMObject._retn(); + + //Get the object itself + Handle(GEOM_Object) aBasicObject = + GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry()); + if (aBasicObject.IsNull()) return aGEOMObject._retn(); + + //Get the first point of translation + Handle(GEOM_Object) aPoint1 = + GetOperations()->GetEngine()->GetObject(thePoint1->GetStudyID(), thePoint1->GetEntry()); + if (aPoint1.IsNull()) return aGEOMObject._retn(); + + //Get the second point of translation + Handle(GEOM_Object) aPoint2 = + GetOperations()->GetEngine()->GetObject(thePoint2->GetStudyID(), thePoint2->GetEntry()); + if (aPoint2.IsNull()) return aGEOMObject._retn(); + + //Create the translated shape + Handle(GEOM_Object) anObject = + GetOperations()->TranslateTwoPointsCopy(aBasicObject, aPoint1, aPoint2); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * TranslateDXDYDZ + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateDXDYDZ (GEOM::GEOM_Object_ptr theObject, + CORBA::Double theDX, CORBA::Double theDY, CORBA::Double theDZ) +{ + //Set a not done flag + GetOperations()->SetNotDone(); + GEOM::GEOM_Object_var aGEOMObject ; + + if (theObject == NULL) return aGEOMObject._retn(); + + //check if the object is a subshape + if(!theObject->IsMainShape()) { + GetOperations()->SetErrorCode(SUBSHAPE_ERROR); + return aGEOMObject._retn(); + } + + aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject); + + //Get the object itself + Handle(GEOM_Object) anObject = + GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry()); + if (anObject.IsNull()) return aGEOMObject._retn(); + + //Perform the translation + GetOperations()->TranslateDXDYDZ(anObject, theDX, theDY, theDZ); + + return aGEOMObject._retn(); +} + + +//============================================================================= +/*! + * TranslateDXDYDZCopy + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateDXDYDZCopy + (GEOM::GEOM_Object_ptr theObject, CORBA::Double theDX, CORBA::Double theDY, CORBA::Double theDZ) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theObject == NULL) return aGEOMObject._retn(); + + //Get the object itself + Handle(GEOM_Object) aBasicObject = + GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry()); + if (aBasicObject.IsNull()) return aGEOMObject._retn(); + + + + //Create the translated shape + Handle(GEOM_Object) anObject = + GetOperations()->TranslateDXDYDZCopy(aBasicObject, theDX, theDY, theDZ); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + + +//============================================================================= +/*! + * TranslateVector + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateVector + (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr theVector) +{ + //Set a not done flag + GetOperations()->SetNotDone(); + GEOM::GEOM_Object_var aGEOMObject; + + if (theObject == NULL || theVector == NULL) return aGEOMObject._retn(); + + //check if the object is a subshape + if(!theObject->IsMainShape()) { + GetOperations()->SetErrorCode(SUBSHAPE_ERROR); + return aGEOMObject._retn(); + } + + aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject); + + //Get the object itself + Handle(GEOM_Object) anObject = + GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry()); + if (anObject.IsNull()) return aGEOMObject._retn(); + + //Get the vector of translation + Handle(GEOM_Object) aVector = + GetOperations()->GetEngine()->GetObject(theVector->GetStudyID(), theVector->GetEntry()); + if (aVector.IsNull()) return aGEOMObject._retn(); + + //Perform the translation + GetOperations()->TranslateVector(anObject, aVector); + + return aGEOMObject._retn(); +} + +//============================================================================= +/*! + * TranslateVectorCopy + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateVectorCopy + (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr theVector) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theObject == NULL || theVector == NULL) return aGEOMObject._retn(); + + //Get the object itself + Handle(GEOM_Object) aBasicObject = + GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry()); + if (aBasicObject.IsNull()) return aGEOMObject._retn(); + + //Get the vector of translation + Handle(GEOM_Object) aVector = + GetOperations()->GetEngine()->GetObject(theVector->GetStudyID(), theVector->GetEntry()); + if (aVector.IsNull()) return aGEOMObject._retn(); + + //Perform the translation + Handle(GEOM_Object) anObject = GetOperations()->TranslateVectorCopy(aBasicObject, aVector); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + + +//============================================================================= +/*! + * Rotate + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::Rotate (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr theAxis, + CORBA::Double theAngle) +{ + //Set a not done flag + GetOperations()->SetNotDone(); + GEOM::GEOM_Object_var aGEOMObject; + + if (theObject == NULL || theAxis == NULL) return aGEOMObject._retn(); + + //check if the object is a subshape + if(!theObject->IsMainShape()) { + GetOperations()->SetErrorCode(SUBSHAPE_ERROR); + return aGEOMObject._retn(); + } + + aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject); + + //Get the object itself + Handle(GEOM_Object) anObject = GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry()); + if (anObject.IsNull()) return aGEOMObject._retn(); + + //Get the axis of revolution + Handle(GEOM_Object) anAxis = + GetOperations()->GetEngine()->GetObject(theAxis->GetStudyID(), theAxis->GetEntry()); + if (anAxis.IsNull()) return aGEOMObject._retn(); + + //Perform the rotation + GetOperations()->Rotate(anObject, anAxis, theAngle); + + return aGEOMObject._retn(); +} + +//============================================================================= +/*! + * RotateCopy + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::RotateCopy (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr theAxis, + CORBA::Double theAngle) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theObject == NULL || theAxis == NULL) return aGEOMObject._retn(); + + //Get the object itself + Handle(GEOM_Object) aBasicObject = + GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry()); + if (aBasicObject.IsNull()) return aGEOMObject._retn(); + + //Get the axis of rotation + Handle(GEOM_Object) anAxis = + GetOperations()->GetEngine()->GetObject(theAxis->GetStudyID(), theAxis->GetEntry()); + if (anAxis.IsNull()) return aGEOMObject._retn(); + + //Perform the rotation + Handle(GEOM_Object) anObject = GetOperations()->RotateCopy(aBasicObject, anAxis, theAngle); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + + +//============================================================================= +/*! + * MirrorPlane + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPlane + (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr thePlane) +{ + GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject); + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theObject == NULL || thePlane == NULL) return aGEOMObject._retn(); + + //check if the object is a subshape + if(!theObject->IsMainShape()) { + GetOperations()->SetErrorCode(SUBSHAPE_ERROR); + return aGEOMObject._retn(); + } + + //Get the object itself + Handle(GEOM_Object) anObject = + GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry()); + if (anObject.IsNull()) return aGEOMObject._retn(); + + //Get the plane + Handle(GEOM_Object) aPlane = + GetOperations()->GetEngine()->GetObject(thePlane->GetStudyID(), thePlane->GetEntry()); + if (aPlane.IsNull()) return aGEOMObject._retn(); + + //Perform the mirror + GetOperations()->MirrorPlane(anObject, aPlane); + + return aGEOMObject._retn(); +} + +//============================================================================= +/*! + * MirrorPlaneCopy + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPlaneCopy + (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr thePlane) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theObject == NULL || thePlane == NULL) return aGEOMObject._retn(); + + //Get the object itself + Handle(GEOM_Object) aBasicObject = + GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry()); + if (aBasicObject.IsNull()) return aGEOMObject._retn(); + + //Get the vector of translation + Handle(GEOM_Object) aPlane = + GetOperations()->GetEngine()->GetObject(thePlane->GetStudyID(), thePlane->GetEntry()); + if (aPlane.IsNull()) return aGEOMObject._retn(); + + //Perform the mirror + Handle(GEOM_Object) anObject = GetOperations()->MirrorPlaneCopy(aBasicObject, aPlane); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MirrorAxis + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorAxis + (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr theAxis) +{ + GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject); + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theObject == NULL || theAxis == NULL) return aGEOMObject._retn(); + + //check if the object is a subshape + if(!theObject->IsMainShape()) { + GetOperations()->SetErrorCode(SUBSHAPE_ERROR); + return aGEOMObject._retn(); + } + + //Get the object itself + Handle(GEOM_Object) anObject = + GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry()); + if (anObject.IsNull()) return aGEOMObject._retn(); + + //Get the axis + Handle(GEOM_Object) aAxis = + GetOperations()->GetEngine()->GetObject(theAxis->GetStudyID(), theAxis->GetEntry()); + if (aAxis.IsNull()) return aGEOMObject._retn(); + + //Perform the mirror + GetOperations()->MirrorAxis(anObject, aAxis); + + return aGEOMObject._retn(); +} + +//============================================================================= +/*! + * MirrorAxisCopy + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorAxisCopy + (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr theAxis) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theObject == NULL || theAxis == NULL) return aGEOMObject._retn(); + + //Get the object itself + Handle(GEOM_Object) aBasicObject = + GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry()); + if (aBasicObject.IsNull()) return aGEOMObject._retn(); + + //Get the vector of translation + Handle(GEOM_Object) aAxis = + GetOperations()->GetEngine()->GetObject(theAxis->GetStudyID(), theAxis->GetEntry()); + if (aAxis.IsNull()) return aGEOMObject._retn(); + + //Perform the mirror + Handle(GEOM_Object) anObject = GetOperations()->MirrorAxisCopy(aBasicObject, aAxis); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MirrorPoint + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPoint + (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr thePoint) +{ + GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject); + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theObject == NULL || thePoint == NULL) return aGEOMObject._retn(); + + //check if the object is a subshape + if(!theObject->IsMainShape()) { + GetOperations()->SetErrorCode(SUBSHAPE_ERROR); + return aGEOMObject._retn(); + } + + //Get the object itself + Handle(GEOM_Object) anObject = + GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry()); + if (anObject.IsNull()) return aGEOMObject._retn(); + + //Get the point + Handle(GEOM_Object) aPoint = + GetOperations()->GetEngine()->GetObject(thePoint->GetStudyID(), thePoint->GetEntry()); + if (aPoint.IsNull()) return aGEOMObject._retn(); + + //Perform the mirror + GetOperations()->MirrorPoint(anObject, aPoint); + + return aGEOMObject._retn(); +} + +//============================================================================= +/*! + * MirrorPointCopy + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPointCopy + (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr thePoint) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theObject == NULL || thePoint == NULL) return aGEOMObject._retn(); + + //Get the object itself + Handle(GEOM_Object) aBasicObject = + GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry()); + if (aBasicObject.IsNull()) return aGEOMObject._retn(); + + //Get the vector of translation + Handle(GEOM_Object) aPoint = + GetOperations()->GetEngine()->GetObject(thePoint->GetStudyID(), thePoint->GetEntry()); + if (aPoint.IsNull()) return aGEOMObject._retn(); + + //Perform the mirror + Handle(GEOM_Object) anObject = GetOperations()->MirrorPointCopy(aBasicObject, aPoint); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + + +//============================================================================= +/*! + * OffsetShape + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::OffsetShape + (GEOM::GEOM_Object_ptr theObject, + CORBA::Double theOffset) +{ + GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject); + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theObject == NULL) return aGEOMObject._retn(); + + //check if the object is a subshape + if(!theObject->IsMainShape()) { + GetOperations()->SetErrorCode(SUBSHAPE_ERROR); + return aGEOMObject._retn(); + } + + + //Get the basic object + Handle(GEOM_Object) aBasicObject = + GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry()); + if (aBasicObject.IsNull()) return aGEOMObject._retn(); + + //Create the offset shape + GetOperations()->OffsetShape(aBasicObject, theOffset); + + return aGEOMObject._retn(); +} + +//============================================================================= +/*! + * OffsetShapeCopy + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::OffsetShapeCopy + (GEOM::GEOM_Object_ptr theObject, + CORBA::Double theOffset) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theObject == NULL) return aGEOMObject._retn(); + + //Get the basic object + Handle(GEOM_Object) aBasicObject = + GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry()); + if (aBasicObject.IsNull()) return aGEOMObject._retn(); + + //Create the offset shape + Handle(GEOM_Object) anObject = GetOperations()->OffsetShapeCopy(aBasicObject, theOffset); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + + +//============================================================================= +/*! + * ScaleShape + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ScaleShape + (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr thePoint, + CORBA::Double theFactor) +{ + GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject); + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (thePoint == NULL || theObject == NULL) return aGEOMObject._retn(); + + //check if the object is a subshape + if(!theObject->IsMainShape()) { + GetOperations()->SetErrorCode(SUBSHAPE_ERROR); + return aGEOMObject._retn(); + } + + //Get the object itself + Handle(GEOM_Object) anObject = + GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry()); + if (anObject.IsNull()) return aGEOMObject._retn(); + + //Get the point + Handle(GEOM_Object) aPoint = + GetOperations()->GetEngine()->GetObject(thePoint->GetStudyID(), thePoint->GetEntry()); + if (aPoint.IsNull()) return aGEOMObject._retn(); + + //Perform the scale + GetOperations()->ScaleShape(anObject, aPoint, theFactor); + + return aGEOMObject._retn(); +} + +//============================================================================= +/*! + * ScaleShapeCopy + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ScaleShapeCopy + (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr thePoint, + CORBA::Double theFactor) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (thePoint == NULL || theObject == NULL) return aGEOMObject._retn(); + + //Get the basic object + Handle(GEOM_Object) aBasicObject = + GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry()); + if (aBasicObject.IsNull()) return aGEOMObject._retn(); + + //Get the point + Handle(GEOM_Object) aPoint = + GetOperations()->GetEngine()->GetObject(thePoint->GetStudyID(), thePoint->GetEntry()); + if (aPoint.IsNull()) return aGEOMObject._retn(); + + //Perform the scale + Handle(GEOM_Object) anObject = + GetOperations()->ScaleShapeCopy(aBasicObject, aPoint, theFactor); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * PositionShape + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::PositionShape + (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr theStartLCS, + GEOM::GEOM_Object_ptr theEndLCS) +{ + GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject); + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theObject == NULL || theStartLCS == NULL || theEndLCS == NULL) + return aGEOMObject._retn(); + + //check if the object is a subshape + if(!theObject->IsMainShape()) { + GetOperations()->SetErrorCode(SUBSHAPE_ERROR); + return aGEOMObject._retn(); + } + + //Get the basic object + Handle(GEOM_Object) anObject = + GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry()); + if (anObject.IsNull()) return aGEOMObject._retn(); + + //Get the Start LCS + Handle(GEOM_Object) aStartLCS = + GetOperations()->GetEngine()->GetObject(theStartLCS->GetStudyID(), theStartLCS->GetEntry()); + if (aStartLCS.IsNull()) return aGEOMObject._retn(); + + //Get the End LCS + Handle(GEOM_Object) aEndLCS = + GetOperations()->GetEngine()->GetObject(theEndLCS->GetStudyID(), theEndLCS->GetEntry()); + if (aEndLCS.IsNull()) return aGEOMObject._retn(); + + //Perform the Position + GetOperations()->PositionShape(anObject, aStartLCS, aEndLCS); + + return aGEOMObject._retn(); +} + +//============================================================================= +/*! + * PositionShapeCopy + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::PositionShapeCopy + (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr theStartLCS, + GEOM::GEOM_Object_ptr theEndLCS) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theObject == NULL || theStartLCS == NULL || theEndLCS == NULL) + return aGEOMObject._retn(); + + //Get the basic object + Handle(GEOM_Object) aBasicObject = + GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry()); + if (aBasicObject.IsNull()) return aGEOMObject._retn(); + + //Get the Start LCS + Handle(GEOM_Object) aStartLCS = + GetOperations()->GetEngine()->GetObject(theStartLCS->GetStudyID(), theStartLCS->GetEntry()); + if (aStartLCS.IsNull()) return aGEOMObject._retn(); + + //Get the End LCS + Handle(GEOM_Object) aEndLCS = + GetOperations()->GetEngine()->GetObject(theEndLCS->GetStudyID(), theEndLCS->GetEntry()); + if (aEndLCS.IsNull()) return aGEOMObject._retn(); + + //Perform the position + Handle(GEOM_Object) anObject = + GetOperations()->PositionShapeCopy(aBasicObject, aStartLCS, aEndLCS); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MultiTranslate1D + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiTranslate1D (GEOM::GEOM_Object_ptr theObject, GEOM::GEOM_Object_ptr theVector, CORBA::Double theStep, CORBA::Long theNbTimes) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theObject == NULL || theVector == NULL) return aGEOMObject._retn(); + + //check if the object is a subshape + if(!theObject->IsMainShape()) { + GetOperations()->SetErrorCode(SUBSHAPE_ERROR); + return aGEOMObject._retn(); + } + + //Get the object itself + Handle(GEOM_Object) aBasicObject = GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry()); + if (aBasicObject.IsNull()) return aGEOMObject._retn(); + + //Get the vector of translation + Handle(GEOM_Object) aVector = GetOperations()->GetEngine()->GetObject(theVector->GetStudyID(), theVector->GetEntry()); + if (aVector.IsNull()) return aGEOMObject._retn(); + + //Perform the translation + Handle(GEOM_Object) anObject = GetOperations()->Translate1D(aBasicObject, aVector, theStep, theNbTimes); + if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MultiTranslate2D + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiTranslate2D (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr theVector1, + CORBA::Double theStep1, + CORBA::Long theNbTimes1, + GEOM::GEOM_Object_ptr theVector2, + CORBA::Double theStep2, + CORBA::Long theNbTimes2) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theObject == NULL || theVector1 == NULL || theVector2 == NULL) return aGEOMObject._retn(); + + //check if the object is a subshape + if(!theObject->IsMainShape()) { + GetOperations()->SetErrorCode(SUBSHAPE_ERROR); + return aGEOMObject._retn(); + } + + //Get the object itself + Handle(GEOM_Object) aBasicObject = GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry()); + if (aBasicObject.IsNull()) return aGEOMObject._retn(); + + //Get the vector1 of translation + Handle(GEOM_Object) aVector1 = GetOperations()->GetEngine()->GetObject(theVector1->GetStudyID(), theVector1->GetEntry()); + if (aVector1.IsNull()) return aGEOMObject._retn(); + + //Get the vector2 of translation + Handle(GEOM_Object) aVector2 = GetOperations()->GetEngine()->GetObject(theVector2->GetStudyID(), theVector2->GetEntry()); + if (aVector2.IsNull()) return aGEOMObject._retn(); + + //Perform the translation + Handle(GEOM_Object) anObject = GetOperations()->Translate2D(aBasicObject, aVector1, theStep1, theNbTimes1, aVector2, theStep2, theNbTimes2); + if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MultiRotate1D + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiRotate1D (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr theVector, + CORBA::Long theNbTimes) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theObject == NULL || theVector == NULL) return aGEOMObject._retn(); + + //check if the object is a subshape + if(!theObject->IsMainShape()) { + GetOperations()->SetErrorCode(SUBSHAPE_ERROR); + return aGEOMObject._retn(); + } + + //Get the object itself + Handle(GEOM_Object) aBasicObject = + GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry()); + if (aBasicObject.IsNull()) return aGEOMObject._retn(); + + //Get the a directon of rotation + Handle(GEOM_Object) aVector = GetOperations()->GetEngine()->GetObject(theVector->GetStudyID(), theVector->GetEntry()); + if (aVector.IsNull()) return aGEOMObject._retn(); + + + //Perform the rotation + Handle(GEOM_Object) anObject = GetOperations()->Rotate1D(aBasicObject, aVector, theNbTimes); + if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MultiRotate2D + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiRotate2D (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr theVector, + CORBA::Double theAngle, + CORBA::Long theNbTimes1, + CORBA::Double theStep, + CORBA::Long theNbTimes2) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theObject == NULL || theVector == NULL) return aGEOMObject._retn(); + + //check if the object is a subshape + if(!theObject->IsMainShape()) { + GetOperations()->SetErrorCode(SUBSHAPE_ERROR); + return aGEOMObject._retn(); + } + + //Get the object itself + Handle(GEOM_Object) aBasicObject = GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry()); + if (aBasicObject.IsNull()) return aGEOMObject._retn(); + + + //Get the a directon of rotation + Handle(GEOM_Object) aVector = GetOperations()->GetEngine()->GetObject(theVector->GetStudyID(), theVector->GetEntry()); + if (aVector.IsNull()) return aGEOMObject._retn(); + + + //Perform the rotation + Handle(GEOM_Object) anObject = GetOperations()->Rotate2D(aBasicObject, aVector, theAngle, theNbTimes1, theStep, theNbTimes2); + if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn(); + + return GetObject(anObject); +} diff --git a/src/GEOM_I/GEOM_ITransformOperations_i.hh b/src/GEOM_I/GEOM_ITransformOperations_i.hh new file mode 100644 index 000000000..4b721ef5f --- /dev/null +++ b/src/GEOM_I/GEOM_ITransformOperations_i.hh @@ -0,0 +1,111 @@ + +#ifndef _GEOM_ITransformOperations_i_HeaderFile +#define _GEOM_ITransformOperations_i_HeaderFile + + +#include + +#include CORBA_SERVER_HEADER(GEOM_Gen) +#include "GEOM_IOperations_i.hh" +#include "GEOM_Object_i.hh" + +#include "GEOMImpl_ITransformOperations.hxx" + +class GEOM_ITransformOperations_i : + public virtual POA_GEOM::GEOM_ITransformOperations, + public virtual GEOM_IOperations_i +{ + public: + GEOM_ITransformOperations_i (PortableServer::POA_ptr thePOA, + GEOM::GEOM_Gen_ptr theEngine, + ::GEOMImpl_ITransformOperations* theImpl); + ~GEOM_ITransformOperations_i(); + + GEOM::GEOM_Object_ptr TranslateTwoPoints (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr thePoint1, + GEOM::GEOM_Object_ptr thePoint2); + + GEOM::GEOM_Object_ptr TranslateTwoPointsCopy (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr thePoint1, + GEOM::GEOM_Object_ptr thePoint2); + + GEOM::GEOM_Object_ptr TranslateDXDYDZ (GEOM::GEOM_Object_ptr theObject, CORBA::Double theDX, CORBA::Double theDY, CORBA::Double theDZ); + + + GEOM::GEOM_Object_ptr TranslateDXDYDZCopy (GEOM::GEOM_Object_ptr theObject, CORBA::Double theDX, CORBA::Double theDY, CORBA::Double theDZ); + + GEOM::GEOM_Object_ptr TranslateVector (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr theVector); + + GEOM::GEOM_Object_ptr TranslateVectorCopy (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr theVector); + + GEOM::GEOM_Object_ptr MultiTranslate1D (GEOM::GEOM_Object_ptr theObject, GEOM::GEOM_Object_ptr theVector, CORBA::Double theStep, CORBA::Long theNbTimes); + + GEOM::GEOM_Object_ptr MultiTranslate2D (GEOM::GEOM_Object_ptr theObject, GEOM::GEOM_Object_ptr theVector1, CORBA::Double theStep1, CORBA::Long theNbTimes1, + GEOM::GEOM_Object_ptr theVector2, CORBA::Double theStep2, CORBA::Long theNbTimes2); + + GEOM::GEOM_Object_ptr Rotate (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr theAxis, + CORBA::Double theAngle); + + GEOM::GEOM_Object_ptr MultiRotate1D (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr theVector, + CORBA::Long theNbTimes); + + + GEOM::GEOM_Object_ptr MultiRotate2D (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr theVector, + CORBA::Double theAngle, + CORBA::Long theNbTimes1, + CORBA::Double theStep, + CORBA::Long theNbTimes2); + + GEOM::GEOM_Object_ptr RotateCopy (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr theAxis, + CORBA::Double theAngle); + + GEOM::GEOM_Object_ptr MirrorPlane (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr thePlane); + + GEOM::GEOM_Object_ptr MirrorPlaneCopy (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr thePlane); + + GEOM::GEOM_Object_ptr MirrorAxis (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr theAxis); + + GEOM::GEOM_Object_ptr MirrorAxisCopy (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr theAxis); + + GEOM::GEOM_Object_ptr MirrorPoint (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr thePoint); + + GEOM::GEOM_Object_ptr MirrorPointCopy (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr thePoint); + + GEOM::GEOM_Object_ptr OffsetShape (GEOM::GEOM_Object_ptr theObject, + CORBA::Double theOffset); + + GEOM::GEOM_Object_ptr OffsetShapeCopy (GEOM::GEOM_Object_ptr theObject, + CORBA::Double theOffset); + + GEOM::GEOM_Object_ptr ScaleShape (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr thePoint, + CORBA::Double theFactor); + + GEOM::GEOM_Object_ptr ScaleShapeCopy (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr thePoint, + CORBA::Double theFactor); + + GEOM::GEOM_Object_ptr PositionShape (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr theStartLCS, + GEOM::GEOM_Object_ptr theEndLCS); + + GEOM::GEOM_Object_ptr PositionShapeCopy (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr theStartLCS, + GEOM::GEOM_Object_ptr theEndLCS); + + ::GEOMImpl_ITransformOperations* GetOperations() { return (::GEOMImpl_ITransformOperations*)GetImpl(); } +}; + +#endif diff --git a/src/GEOM_I/GEOM_Object_i.cc b/src/GEOM_I/GEOM_Object_i.cc new file mode 100644 index 000000000..2af09b209 --- /dev/null +++ b/src/GEOM_I/GEOM_Object_i.cc @@ -0,0 +1,292 @@ +using namespace std; + +#include "GEOM_Object_i.hh" +#include "GEOM_Gen_i.hh" +#include "GEOM_ISubShape.hxx" +#include "GEOMImpl_Types.hxx" + +#include "utilities.h" +#include "OpUtil.hxx" +#include "Utils_ExceptHandlers.hxx" +#include +#include +#include + +#include +#include + +#include +#include +#include + +//============================================================================= +/*! + * constructor: + */ +//============================================================================= + +GEOM_Object_i::GEOM_Object_i (PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr theEngine, + Handle(GEOM_Object) theImpl) +:SALOME::GenericObj_i( thePOA ), _engine(theEngine), _impl(theImpl) +{ + thePOA->activate_object(this); +} + +//============================================================================= +/*! + * destructor + */ +//============================================================================= + +GEOM_Object_i::~GEOM_Object_i() +{} + + +//============================================================================= +/*! + * GetEntry + */ +//============================================================================= +char* GEOM_Object_i::GetEntry() +{ + const TDF_Label& aLabel = _impl->GetEntry(); + TCollection_AsciiString anEntry; + TDF_Tool::Entry(aLabel, anEntry); + return CORBA::string_dup(anEntry.ToCString()); +} + +//============================================================================= +/*! + * GetStudyID + */ +//============================================================================= +CORBA::Long GEOM_Object_i::GetStudyID() +{ + return _impl->GetDocID(); +} + + +//============================================================================= +/*! + * GetType + */ +//============================================================================= +CORBA::Long GEOM_Object_i::GetType() +{ + return _impl->GetType(); +} + +//============================================================================= +/*! + * GetShapeType + */ +//============================================================================= +GEOM::shape_type GEOM_Object_i::GetShapeType() +{ + TopoDS_Shape _geom = _impl->GetValue(); + if(_geom.IsNull()) return GEOM::SHAPE; + return (GEOM::shape_type)_geom.ShapeType(); +} + +//============================================================================= +/*! + * SetName + */ +//============================================================================= +void GEOM_Object_i::SetName(const char* theName) +{ + _impl->SetName(theName); +} + + +//============================================================================= +/*! + * GetName + */ +//============================================================================= +char* GEOM_Object_i::GetName() +{ + char* aName = _impl->GetName(); + if(aName) return strdup(aName); + return strdup(""); +} + +//============================================================================= +/*! + * SetStudyEntry + */ +//============================================================================= +void GEOM_Object_i::SetStudyEntry(const char* theEntry) +{ + _impl->SetAuxData(theEntry); +} + + +//============================================================================= +/*! + * GetStudyEntry + */ +//============================================================================= +char* GEOM_Object_i::GetStudyEntry() +{ + char* anEntry = _impl->GetAuxData(); + if(anEntry) return strdup(anEntry); + return strdup(""); +} + + +//============================================================================= +/*! + * GetDependency + */ +//============================================================================= +GEOM::ListOfGO* GEOM_Object_i::GetDependency() +{ + GEOM::ListOfGO_var aList = new GEOM::ListOfGO(); + aList->length(0); + + Handle(TColStd_HSequenceOfTransient) aSeq = _impl->GetAllDependency(); + if (aSeq.IsNull()) return aList._retn(); + int aLength = aSeq->Length(); + if (aLength == 0) return aList._retn(); + + aList->length(aLength); + + TCollection_AsciiString anEntry; + + for (int i = 1; i<=aLength; i++) { + Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(aSeq->Value(i)); + if (anObj.IsNull()) continue; + TDF_Tool::Entry(anObj->GetEntry(), anEntry); + GEOM::GEOM_Object_var obj = GEOM::GEOM_Object::_duplicate(_engine->GetObject(anObj->GetDocID(), anEntry.ToCString())); + aList[i-1] = obj; + } + + return aList._retn(); +} + +//============================================================================= +/*! + * GetLastDependency + */ +//============================================================================= +GEOM::ListOfGO* GEOM_Object_i::GetLastDependency() +{ + GEOM::ListOfGO_var aList = new GEOM::ListOfGO(); + aList->length(0); + + Handle(TColStd_HSequenceOfTransient) aSeq = _impl->GetLastDependency(); + if (aSeq.IsNull()) return aList._retn(); + int aLength = aSeq->Length(); + if (aLength == 0) return aList._retn(); + + aList->length(aLength); + + TCollection_AsciiString anEntry; + + for (int i = 1; i<=aLength; i++) { + Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(aSeq->Value(i)); + if (anObj.IsNull()) continue; + TDF_Tool::Entry(anObj->GetEntry(), anEntry); + GEOM::GEOM_Object_var obj = GEOM::GEOM_Object::_duplicate(_engine->GetObject(anObj->GetDocID(), anEntry.ToCString())); + aList[i-1] = obj; + } + + return aList._retn(); +} + +//================================================================================= +// function : GetShapeStream +// Transfer resulting shape to client as sequence of bytes +//client can extract shape from stream using BrepTools::Read function +//================================================================================= +SALOMEDS::TMPFile* GEOM_Object_i::GetShapeStream() +{ + TopoDS_Shape aShape = _impl->GetValue(); + + if(aShape.IsNull()) return NULL; + + ostrstream streamShape; + //Write TopoDS_Shape in ASCII format to the stream + BRepTools::Write(aShape, streamShape); + //Returns the number of bytes that have been stored in the stream's buffer. + int size = streamShape.pcount(); + char* buf = new char [size]; + //Get pointer on internal character array in ostrstream + char* valueOfStream = streamShape.str(); + //Create copy of ostrstream content + memcpy(buf, valueOfStream, size); + //Allow automatic deletion of ostrstream content + streamShape.rdbuf()->freeze(0); + + CORBA::Octet* OctetBuf = (CORBA::Octet*)buf; + SALOMEDS::TMPFile_var SeqFile = new SALOMEDS::TMPFile(size,size,OctetBuf,1); + return SeqFile._retn(); + +} + + +//======================================================================= +//function : getShape +//purpose : return the TopoDS_Shape when client and servant are colocated, be careful +//======================================================================= +long GEOM_Object_i::getShape() { + _geom = _impl->GetValue(); + return((long)(&_geom)); +} + +//============================================================================= +/*! + * GetSubShapeIndices + */ +//============================================================================= +GEOM::ListOfLong* GEOM_Object_i::GetSubShapeIndices() +{ + GEOM::ListOfLong_var anIndices = new GEOM::ListOfLong; + + if(!_impl->IsMainShape()) { + Handle(GEOM_Function) aFunction = _impl->GetFunction(1); //Get SubShape function (always the first (and last) one) + if(aFunction.IsNull()) return anIndices._retn(); + GEOM_ISubShape ISS(aFunction); + Handle(TColStd_HArray1OfInteger) anArray = ISS.GetIndices(); + if(anArray.IsNull() || anArray->Length() < 1) return anIndices._retn(); + anIndices->length(anArray->Length()); + for(int i=1; i<=anArray->Length(); i++) anIndices[i-1] = anArray->Value(i); + } + else { + anIndices->length(0); + } + + return anIndices._retn(); +} + + +//============================================================================= +/*! + * GetMainShape + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Object_i::GetMainShape() +{ + GEOM::GEOM_Object_var obj; + if(!_impl->IsMainShape()) { + Handle(GEOM_Function) aFunction = _impl->GetFunction(1); //Get SubShape function (always the first (and last) one) + if(aFunction.IsNull()) return obj._retn(); + GEOM_ISubShape ISS(aFunction); + + aFunction = ISS.GetMainShape(); + if(aFunction.IsNull()) return obj._retn(); + TDF_Label aLabel = aFunction->GetOwnerEntry(); + if(aLabel.IsNull()) return obj._retn(); + TCollection_AsciiString anEntry; + TDF_Tool::Entry(aLabel, anEntry); + return GEOM::GEOM_Object::_duplicate(_engine->GetObject(_impl->GetDocID(), anEntry.ToCString())); + } + + return obj._retn(); +} + +bool GEOM_Object_i::IsShape() +{ + return !_impl->GetValue().IsNull() && _impl->GetType() != GEOM_MARKER; +} diff --git a/src/GEOM_I/GEOM_Object_i.hh b/src/GEOM_I/GEOM_Object_i.hh new file mode 100644 index 000000000..06bea0b09 --- /dev/null +++ b/src/GEOM_I/GEOM_Object_i.hh @@ -0,0 +1,62 @@ + +#ifndef _GEOM_Object_i_HeaderFile +#define _GEOM_Object_i_HeaderFile + + +#include + +#include CORBA_SERVER_HEADER(SALOMEDS) +#include CORBA_SERVER_HEADER(GEOM_Gen) + +#include "SALOME_GenericObj_i.hh" +#include "GEOM_Object.hxx" +#include + +class GEOM_Object_i : public virtual POA_GEOM::GEOM_Object, public virtual SALOME::GenericObj_i +{ + public: + GEOM_Object_i(PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr theEngine, Handle(GEOM_Object) theImpl); + ~GEOM_Object_i(); + + virtual char* GetEntry(); + + virtual CORBA::Long GetStudyID(); + + virtual CORBA::Long GetType(); + + virtual GEOM::shape_type GetShapeType(); + + virtual void SetName(const char* theName); + + virtual char* GetName(); + + virtual void SetStudyEntry(const char* theEntry); + + virtual char* GetStudyEntry(); + + virtual GEOM::ListOfGO* GetDependency(); + + virtual GEOM::ListOfGO* GetLastDependency(); + + virtual SALOMEDS::TMPFile* GetShapeStream(); + + long getShape(); + + virtual bool IsMainShape() { return _impl->IsMainShape(); } + + virtual GEOM::ListOfLong* GetSubShapeIndices(); + + virtual GEOM::GEOM_Object_ptr GetMainShape(); + + virtual bool IsShape(); + + Handle(GEOM_Object) GetImpl() { return _impl; } + + private: + + GEOM::GEOM_Gen_ptr _engine; + Handle(GEOM_Object) _impl; + TopoDS_Shape _geom; +}; + +#endif diff --git a/src/GEOM_I/Makefile.in b/src/GEOM_I/Makefile.in new file mode 100644 index 000000000..ce1b86325 --- /dev/null +++ b/src/GEOM_I/Makefile.in @@ -0,0 +1,93 @@ +# GEOM GEOM : implementaion of GEOM_Gen.idl +# +# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +# +# +# +# File : Makefile.in +# Author : Patrick GOLDBRONN (CEA) +# Module : GEOM +# $Header$ + +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + +@COMMENCE@ + +# Libraries targets + +LIB = libGEOMEngine.la +LIB_SRC = \ + GEOM_Object_i.cc \ + GEOM_IOperations_i.cc \ + GEOM_IBasicOperations_i.cc \ + GEOM_IHealingOperations_i.cc \ + GEOM_I3DPrimOperations_i.cc \ + GEOM_IShapesOperations_i.cc \ + GEOM_IBlocksOperations_i.cc \ + GEOM_IBooleanOperations_i.cc \ + GEOM_ICurvesOperations_i.cc \ + GEOM_ILocalOperations_i.cc \ + GEOM_IInsertOperations_i.cc \ + GEOM_ITransformOperations_i.cc \ + GEOM_IMeasureOperations_i.cc \ + GEOM_IGroupOperations_i.cc \ + GEOM_Gen_i.cc + +LIB_SERVER_IDL = SALOME_Component.idl SALOMEDS.idl SALOME_Exception.idl \ + GEOM_Gen.idl SALOME_GenericObj.idl + +# Executables targets +BIN = +BIN_SRC = +BIN_CLIENT_IDL = +BIN_SERVER_IDL = + +#This export required to compile GEOM_Superv_i.lo library +EXPORT_HEADERS = GEOM_Object_i.hh \ + GEOM_IOperations_i.hh \ + GEOM_IBasicOperations_i.hh \ + GEOM_IHealingOperations_i.hh \ + GEOM_I3DPrimOperations_i.hh \ + GEOM_IShapesOperations_i.hh \ + GEOM_IBlocksOperations_i.hh \ + GEOM_IBooleanOperations_i.hh \ + GEOM_ICurvesOperations_i.hh \ + GEOM_ILocalOperations_i.hh \ + GEOM_IInsertOperations_i.hh \ + GEOM_ITransformOperations_i.hh \ + GEOM_IMeasureOperations_i.hh \ + GEOM_IGroupOperations_i.hh \ + GEOM_Gen_i.hh + +# additionnal information to compil and link file +CPPFLAGS += $(OCC_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome $(BOOST_CPPFLAGS) +CXXFLAGS += $(OCC_CXXFLAGS) -I${KERNEL_ROOT_DIR}/include/salome +LDFLAGS += -lTOOLSDS -lSalomeNS -lSalomeContainer -lGEOMPartition -lGEOMArchimede -lGEOMbasic -lGEOMimpl $(CAS_LDPATH) -lTKIGES -lTKSTEP -lTKFillet -lTKOffset -lGEOMSketcher -L${KERNEL_ROOT_DIR}/lib/salome -lSalomeGenericObj + +# additional file to be cleaned +MOSTLYCLEAN = +CLEAN = +DISTCLEAN = + +@CONCLUDE@ + diff --git a/src/GEOM_I_Superv/GEOM_Superv_i.cc b/src/GEOM_I_Superv/GEOM_Superv_i.cc new file mode 100644 index 000000000..360ad2686 --- /dev/null +++ b/src/GEOM_I_Superv/GEOM_Superv_i.cc @@ -0,0 +1,1747 @@ +using namespace std; + +#include "GEOM_Superv_i.hh" + +//============================================================================= +// constructor: +//============================================================================= +GEOM_Superv_i::GEOM_Superv_i(CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + PortableServer::ObjectId * contId, + const char *instanceName, + const char *interfaceName) : + Engines_Component_i(orb, poa, contId, instanceName, interfaceName) +{ + MESSAGE("GEOM_Superv_i::GEOM_Superv_i"); + + _thisObj = this ; + _id = _poa->activate_object(_thisObj); + name_service = new SALOME_NamingService(_orb); + + myGeomEngine = GEOM::GEOM_Gen::_nil(); + myStudyID = -1; + + myBasicOp = GEOM::GEOM_IBasicOperations::_nil(); + my3DPrimOp = GEOM::GEOM_I3DPrimOperations::_nil(); + myBoolOp = GEOM::GEOM_IBooleanOperations::_nil(); + myInsOp = GEOM::GEOM_IInsertOperations::_nil(); + myTransfOp = GEOM::GEOM_ITransformOperations::_nil(); + myShapesOp = GEOM::GEOM_IShapesOperations::_nil(); + myBlocksOp = GEOM::GEOM_IBlocksOperations::_nil(); + myCurvesOp = GEOM::GEOM_ICurvesOperations::_nil(); + myLocalOp = GEOM::GEOM_ILocalOperations::_nil(); + myGroupOp = GEOM::GEOM_IGroupOperations::_nil(); +} + +//============================================================================= +// destructor +//============================================================================= +GEOM_Superv_i::~GEOM_Superv_i() +{ + MESSAGE("GEOM_Superv_i::~GEOM_Superv_i"); + delete name_service; +} + +//============================================================================ +// function : register() +// purpose : register 'name' in 'name_service' +//============================================================================ +void GEOM_Superv_i::register_name(char * name) +{ + GEOM::GEOM_Superv_ptr g = GEOM::GEOM_Superv::_narrow(POA_GEOM::GEOM_Superv::_this()); + name_service->Register(g, strdup(name)); +} + +//============================================================================= +// setGEOMEngine: +//============================================================================= +void GEOM_Superv_i::setGeomEngine() +{ + // get GEOM_Gen engine + SALOME_LifeCycleCORBA* lcc = new SALOME_LifeCycleCORBA( name_service ); + Engines::Component_var comp = lcc->FindOrLoad_Component( "FactoryServer", "GEOM" ); + + myGeomEngine = GEOM::GEOM_Gen::_narrow(comp); +} + +//============================================================================= +// SetStudyID: +//============================================================================= +void GEOM_Superv_i::SetStudyID( CORBA::Long theId ) +{ + myStudyID = theId; +} + +//============================================================================= +// getBasicOp: +//============================================================================= +void GEOM_Superv_i::getBasicOp() +{ + if (CORBA::is_nil(myGeomEngine)) + setGeomEngine(); + // get GEOM_IBasicOperations interface + myBasicOp = myGeomEngine->GetIBasicOperations(myStudyID); +} + +//============================================================================= +// get3DPrimOp: +//============================================================================= +void GEOM_Superv_i::get3DPrimOp() +{ + if (CORBA::is_nil(myGeomEngine)) + setGeomEngine(); + // get GEOM_I3DPrimOperations interface + my3DPrimOp = myGeomEngine->GetI3DPrimOperations(myStudyID); +} + +//============================================================================= +// getBoolOp: +//============================================================================= +void GEOM_Superv_i::getBoolOp() +{ + if (CORBA::is_nil(myGeomEngine)) + setGeomEngine(); + // get GEOM_IBooleanOperations interface + myBoolOp = myGeomEngine->GetIBooleanOperations(myStudyID); +} + +//============================================================================= +// getInsOp: +//============================================================================= +void GEOM_Superv_i::getInsOp() +{ + if (CORBA::is_nil(myGeomEngine)) + setGeomEngine(); + // get GEOM_IInsertOperations interface + myInsOp = myGeomEngine->GetIInsertOperations(myStudyID); +} + +//============================================================================= +// getTransfOp: +//============================================================================= +void GEOM_Superv_i::getTransfOp() +{ + if (CORBA::is_nil(myGeomEngine)) + setGeomEngine(); + // get GEOM_ITransformOperations interface + myTransfOp = myGeomEngine->GetITransformOperations(myStudyID); +} + +//============================================================================= +// getShapesOp: +//============================================================================= +void GEOM_Superv_i::getShapesOp() +{ + if (CORBA::is_nil(myGeomEngine)) + setGeomEngine(); + // get GEOM_IShapesOperations interface + myShapesOp = myGeomEngine->GetIShapesOperations(myStudyID); +} + +//============================================================================= +// getBlocksOp: +//============================================================================= +void GEOM_Superv_i::getBlocksOp() +{ + if (CORBA::is_nil(myGeomEngine)) + setGeomEngine(); + // get GEOM_IBlocksOperations interface + myBlocksOp = myGeomEngine->GetIBlocksOperations(myStudyID); +} + +//============================================================================= +// getCurvesOp: +//============================================================================= +void GEOM_Superv_i::getCurvesOp() +{ + if (CORBA::is_nil(myGeomEngine)) + setGeomEngine(); + // get GEOM_ICurvesOperations interface + myCurvesOp = myGeomEngine->GetICurvesOperations(myStudyID); +} + +//============================================================================= +// getLocalOp: +//============================================================================= +void GEOM_Superv_i::getLocalOp() +{ + if (CORBA::is_nil(myGeomEngine)) + setGeomEngine(); + // get GEOM_ILocalOperations interface + myLocalOp = myGeomEngine->GetILocalOperations(myStudyID); +} + +//============================================================================= +// getGroupOp: +//============================================================================= +void GEOM_Superv_i::getGroupOp() +{ + if (CORBA::is_nil(myGeomEngine)) + setGeomEngine(); + // get GEOM_IGroupOperations interface + myGroupOp = myGeomEngine->GetIGroupOperations(myStudyID); +} + +//============================================================================ +// function : Save() +// purpose : save OCAF/Geom document +//============================================================================ +SALOMEDS::TMPFile* GEOM_Superv_i::Save(SALOMEDS::SComponent_ptr theComponent, + const char* theURL, + bool isMultiFile) +{ + SALOMEDS::TMPFile_var aStreamFile; + return aStreamFile._retn(); +} + +//============================================================================ +// function : SaveASCII() +// purpose : +//============================================================================ +SALOMEDS::TMPFile* GEOM_Superv_i::SaveASCII(SALOMEDS::SComponent_ptr theComponent, + const char* theURL, + bool isMultiFile) +{ + SALOMEDS::TMPFile_var aStreamFile; + return aStreamFile._retn(); +} + +//============================================================================ +// function : Load() +// purpose : +//============================================================================ +CORBA::Boolean GEOM_Superv_i::Load(SALOMEDS::SComponent_ptr theComponent, + const SALOMEDS::TMPFile& theStream, + const char* theURL, + bool isMultiFile) +{ + return false; +} + +//============================================================================ +// function : LoadASCII() +// purpose : +//============================================================================ +CORBA::Boolean GEOM_Superv_i::LoadASCII(SALOMEDS::SComponent_ptr theComponent, + const SALOMEDS::TMPFile& theStream, + const char* theURL, + bool isMultiFile) +{ + return false; +} + +//============================================================================ +// function : Close() +// purpose : +//============================================================================ +void GEOM_Superv_i::Close(SALOMEDS::SComponent_ptr theComponent) +{} + +//============================================================================ +// function : ComponentDataType() +// purpose : +//============================================================================ +char* GEOM_Superv_i::ComponentDataType() +{ + return 0; +} + +//============================================================================ +// function : IORToLocalPersistentID() +// purpose : +//============================================================================ +char* GEOM_Superv_i::IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject, + const char* IORString, + CORBA::Boolean isMultiFile, + CORBA::Boolean isASCII) +{ + return 0; +} + +//============================================================================ +// function : LocalPersistentIDToIOR() +// purpose : Create/Load CORBA object from a persistent ref (an entry) +// : Used when a study is loaded +// : The IOR (IORName) of object created is returned +//============================================================================ +char* GEOM_Superv_i::LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject, + const char* aLocalPersistentID, + CORBA::Boolean isMultiFile, + CORBA::Boolean isASCII) +{ + return 0; +} + +//============================================================================ +// function : CanPublishInStudy +// purpose : +//============================================================================ +bool GEOM_Superv_i::CanPublishInStudy(CORBA::Object_ptr theIOR) +{ + if (CORBA::is_nil(myGeomEngine)) + setGeomEngine(); + return myGeomEngine->CanPublishInStudy(theIOR); +} + +//============================================================================ +// function : PublishInStudy +// purpose : +//============================================================================ +SALOMEDS::SObject_ptr GEOM_Superv_i::PublishInStudy(SALOMEDS::Study_ptr theStudy, + SALOMEDS::SObject_ptr theSObject, + CORBA::Object_ptr theObject, + const char* theName) throw (SALOME::SALOME_Exception) +{ + if (CORBA::is_nil(myGeomEngine)) + setGeomEngine(); + return myGeomEngine->PublishInStudy(theStudy, theSObject, theObject, theName); +} + +//============================================================================ +// function : CanCopy() +// purpose : +//============================================================================ +CORBA::Boolean GEOM_Superv_i::CanCopy(SALOMEDS::SObject_ptr theObject) +{ + return false; +} + +//============================================================================ +// function : CopyFrom() +// purpose : +//============================================================================ +SALOMEDS::TMPFile* GEOM_Superv_i::CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID) +{ + SALOMEDS::TMPFile_var aStreamFile; + return aStreamFile._retn(); +} + +//============================================================================ +// function : CanPaste() +// purpose : +//============================================================================ +CORBA::Boolean GEOM_Superv_i::CanPaste(const char* theComponentName, CORBA::Long theObjectID) +{ + return false; +} + +//============================================================================ +// function : PasteInto() +// purpose : +//============================================================================ +SALOMEDS::SObject_ptr GEOM_Superv_i::PasteInto(const SALOMEDS::TMPFile& theStream, + CORBA::Long theObjectID, + SALOMEDS::SObject_ptr theObject) +{ + SALOMEDS::SObject_var aNewSO; + return aNewSO._retn(); +} + +//================= Primitives Construction : BasicOperations ================= +//============================================================================= +// MakePointXYZ: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakePointXYZ(CORBA::Double theX, + CORBA::Double theY, + CORBA::Double theZ) +{ + MESSAGE("GEOM_Superv_i::MakePointXYZ"); + if (CORBA::is_nil(myBasicOp)) getBasicOp(); + // make vertex and return + return myBasicOp->MakePointXYZ(theX, theY, theZ); +} + +//============================================================================= +// MakePointWithReference: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakePointWithReference (GEOM::GEOM_Object_ptr theReference, + CORBA::Double theX, + CORBA::Double theY, + CORBA::Double theZ) +{ + MESSAGE("GEOM_Superv_i::MakePointWithReference"); + if (CORBA::is_nil(myBasicOp)) getBasicOp(); + return myBasicOp->MakePointWithReference(theReference, theX, theY, theZ); +} + +//============================================================================= +// MakePointOnCurve: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakePointOnCurve (GEOM::GEOM_Object_ptr theRefCurve, + CORBA::Double theParameter) +{ + MESSAGE("GEOM_Superv_i::MakePointOnCurve"); + if (CORBA::is_nil(myBasicOp)) getBasicOp(); + return myBasicOp->MakePointOnCurve(theRefCurve, theParameter); +} + +//============================================================================= +// MakeVectorDXDYDZ: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeVectorDXDYDZ (CORBA::Double theDX, + CORBA::Double theDY, + CORBA::Double theDZ) +{ + MESSAGE("GEOM_Superv_i::MakeVectorDXDYDZ"); + if (CORBA::is_nil(myBasicOp)) getBasicOp(); + return myBasicOp->MakeVectorDXDYDZ(theDX, theDY, theDZ); +} + +//============================================================================= +// MakeVectorTwoPnt: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeVectorTwoPnt (GEOM::GEOM_Object_ptr thePnt1, + GEOM::GEOM_Object_ptr thePnt2) +{ + MESSAGE("GEOM_Superv_i::MakeVector"); + if (CORBA::is_nil(myBasicOp)) getBasicOp(); + return myBasicOp->MakeVectorTwoPnt(thePnt1, thePnt2); +} + +//============================================================================= +// MakeLineTwoPnt: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeLineTwoPnt (GEOM::GEOM_Object_ptr thePnt1, + GEOM::GEOM_Object_ptr thePnt2) +{ + MESSAGE("GEOM_Superv_i::MakeLineTwoPnt"); + if (CORBA::is_nil(myBasicOp)) getBasicOp(); + return myBasicOp->MakeLineTwoPnt(thePnt1, thePnt2); +} + +//============================================================================= +// MakePlaneThreePnt: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakePlaneThreePnt (GEOM::GEOM_Object_ptr thePnt1, + GEOM::GEOM_Object_ptr thePnt2, + GEOM::GEOM_Object_ptr thePnt3, + CORBA::Double theTrimSize) +{ + MESSAGE("GEOM_Superv_i::MakePlaneThreePnt"); + if (CORBA::is_nil(myBasicOp)) getBasicOp(); + return myBasicOp->MakePlaneThreePnt(thePnt1, thePnt2, thePnt3, theTrimSize); +} + +//============================================================================= +// MakePlanePntVec: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakePlanePntVec (GEOM::GEOM_Object_ptr thePnt, + GEOM::GEOM_Object_ptr theVec, + CORBA::Double theTrimSize) +{ + MESSAGE("GEOM_Superv_i::MakePlanePntVec"); + if (CORBA::is_nil(myBasicOp)) getBasicOp(); + return myBasicOp->MakePlanePntVec(thePnt, theVec, theTrimSize); +} + +//============================================================================= +// MakePlaneFace: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakePlaneFace (GEOM::GEOM_Object_ptr theFace, + CORBA::Double theTrimSize) +{ + MESSAGE("GEOM_Superv_i::MakePlaneFace"); + if (CORBA::is_nil(myBasicOp)) getBasicOp(); + return myBasicOp->MakePlaneFace(theFace, theTrimSize); +} + +//============================================================================= +// MakeMarker: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeMarker +(CORBA::Double theOX , CORBA::Double theOY , CORBA::Double theOZ, + CORBA::Double theXDX, CORBA::Double theXDY, CORBA::Double theXDZ, + CORBA::Double theYDX, CORBA::Double theYDY, CORBA::Double theYDZ) +{ + MESSAGE("GEOM_Superv_i::MakeMarker"); + if (CORBA::is_nil(myBasicOp)) getBasicOp(); + return myBasicOp->MakeMarker(theOX, theOY, theOZ, theXDX, theXDY, theXDZ, theYDX, theYDY, theYDZ); +} + +//================= Primitives Construction : 3DPrimOperations ================ +//============================================================================= +// MakeBox: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeBox (CORBA::Double theX1, + CORBA::Double theY1, + CORBA::Double theZ1, + CORBA::Double theX2, + CORBA::Double theY2, + CORBA::Double theZ2) +{ + MESSAGE("GEOM_Superv_i::MakeBox"); + if (CORBA::is_nil(myBasicOp)) getBasicOp(); + if (CORBA::is_nil(my3DPrimOp)) get3DPrimOp(); + return my3DPrimOp->MakeBoxTwoPnt(myBasicOp->MakePointXYZ(theX1, theY1, theZ1), + myBasicOp->MakePointXYZ(theX2, theY2, theZ2)); +} + +//============================================================================= +// MakeBoxDXDYDZ: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeBoxDXDYDZ (CORBA::Double theDX, + CORBA::Double theDY, + CORBA::Double theDZ) +{ + MESSAGE("GEOM_Superv_i::MakeBoxDXDYDZ"); + if (CORBA::is_nil(my3DPrimOp)) get3DPrimOp(); + return my3DPrimOp->MakeBoxDXDYDZ(theDX, theDY, theDZ); +} + +//============================================================================= +// MakeBoxTwoPnt: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeBoxTwoPnt (GEOM::GEOM_Object_ptr thePnt1, + GEOM::GEOM_Object_ptr thePnt2) +{ + MESSAGE("GEOM_Superv_i::MakeBoxTwoPnt"); + if (CORBA::is_nil(my3DPrimOp)) get3DPrimOp(); + return my3DPrimOp->MakeBoxTwoPnt(thePnt1, thePnt2); +} + +//============================================================================= +// MakeCylinderPntVecRH: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeCylinderPntVecRH (GEOM::GEOM_Object_ptr thePnt, + GEOM::GEOM_Object_ptr theAxis, + CORBA::Double theRadius, + CORBA::Double theHeight) +{ + MESSAGE("GEOM_Superv_i::MakeCylinderPntVecRH"); + if (CORBA::is_nil(my3DPrimOp)) get3DPrimOp(); + return my3DPrimOp->MakeCylinderPntVecRH(thePnt, theAxis, theRadius, theHeight); +} + +//============================================================================= +// MakeCylinderRH: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeCylinderRH (CORBA::Double theR, + CORBA::Double theH) +{ + MESSAGE("GEOM_Superv_i::MakeCylinderRH"); + if (CORBA::is_nil(my3DPrimOp)) get3DPrimOp(); + return my3DPrimOp->MakeCylinderRH(theR, theH); +} + +//============================================================================= +// MakeSphere: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeSphere (CORBA::Double theX, + CORBA::Double theY, + CORBA::Double theZ, + CORBA::Double theRadius) +{ + MESSAGE("GEOM_Superv_i::MakeSphepe"); + if (CORBA::is_nil(myBasicOp)) getBasicOp(); + if (CORBA::is_nil(my3DPrimOp)) get3DPrimOp(); + return my3DPrimOp->MakeSpherePntR(myBasicOp->MakePointXYZ(theX, theY, theZ), theRadius); +} + +//============================================================================= +// MakeSphereR: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeSphereR (CORBA::Double theR) +{ + MESSAGE("GEOM_Superv_i::MakeSphereR"); + if (CORBA::is_nil(my3DPrimOp)) get3DPrimOp(); + return my3DPrimOp->MakeSphereR(theR); +} + +//============================================================================= +// MakeSpherePntR: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeSpherePntR (GEOM::GEOM_Object_ptr thePnt, + CORBA::Double theR) +{ + MESSAGE("GEOM_Superv_i::MakeSpherePntR"); + if (CORBA::is_nil(my3DPrimOp)) get3DPrimOp(); + return my3DPrimOp->MakeSpherePntR(thePnt, theR); +} + +//============================================================================= +// MakeTorusPntVecRR: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeTorusPntVecRR (GEOM::GEOM_Object_ptr thePnt, + GEOM::GEOM_Object_ptr theVec, + CORBA::Double theRMajor, + CORBA::Double theRMinor) +{ + MESSAGE("GEOM_Superv_i::MakeTorusPntVecRR"); + if (CORBA::is_nil(my3DPrimOp)) get3DPrimOp(); + return my3DPrimOp->MakeTorusPntVecRR(thePnt, theVec, theRMajor, theRMinor); +} + +//============================================================================= +// MakeTorusRR: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeTorusRR (CORBA::Double theRMajor, + CORBA::Double theRMinor) +{ + MESSAGE("GEOM_Superv_i::MakeTorusRR"); + if (CORBA::is_nil(my3DPrimOp)) get3DPrimOp(); + return my3DPrimOp->MakeTorusRR(theRMajor, theRMinor); +} + +//============================================================================= +// MakeConePntVecR1R2H: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeConePntVecR1R2H (GEOM::GEOM_Object_ptr thePnt, + GEOM::GEOM_Object_ptr theAxis, + CORBA::Double theR1, + CORBA::Double theR2, + CORBA::Double theHeight) +{ + MESSAGE("GEOM_Superv_i::MakeConePntVecR1R2H"); + if (CORBA::is_nil(my3DPrimOp)) get3DPrimOp(); + return my3DPrimOp->MakeConePntVecR1R2H(thePnt, theAxis, theR1, theR2, theHeight); +} + +//============================================================================= +// MakeConeR1R2H: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeConeR1R2H (CORBA::Double theR1, + CORBA::Double theR2, + CORBA::Double theHeight) +{ + MESSAGE("GEOM_Superv_i::MakeConeR1R2H"); + if (CORBA::is_nil(my3DPrimOp)) get3DPrimOp(); + return my3DPrimOp->MakeConeR1R2H(theR1, theR2, theHeight); +} + +//============================================================================= +// MakePrismVecH: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakePrismVecH (GEOM::GEOM_Object_ptr theBase, + GEOM::GEOM_Object_ptr theVec, + CORBA::Double theH) +{ + MESSAGE("GEOM_Superv_i::MakePrismVecH"); + if (CORBA::is_nil(my3DPrimOp)) get3DPrimOp(); + return my3DPrimOp->MakePrismVecH(theBase, theVec, theH); +} + + +//============================================================================= +// MakePrismTwoPnt: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakePrismTwoPnt (GEOM::GEOM_Object_ptr theBase, + GEOM::GEOM_Object_ptr thePoint1, + GEOM::GEOM_Object_ptr thePoint2) +{ + MESSAGE("GEOM_Superv_i::MakePrismTwoPnt"); + if (CORBA::is_nil(my3DPrimOp)) get3DPrimOp(); + return my3DPrimOp->MakePrismTwoPnt(theBase, thePoint1, thePoint2); +} + +//============================================================================= +// MakePipe: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakePipe (GEOM::GEOM_Object_ptr theBase, + GEOM::GEOM_Object_ptr thePath) +{ + MESSAGE("GEOM_Superv_i::MakePipe"); + if (CORBA::is_nil(my3DPrimOp)) get3DPrimOp(); + return my3DPrimOp->MakePipe(theBase, thePath); +} + +//============================================================================= +// MakeRevolutionAxisAngle: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeRevolutionAxisAngle (GEOM::GEOM_Object_ptr theBase, + GEOM::GEOM_Object_ptr theAxis, + CORBA::Double theAngle) +{ + MESSAGE("GEOM_Superv_i::MakeRevolutionAxisAngle"); + if (CORBA::is_nil(my3DPrimOp)) get3DPrimOp(); + return my3DPrimOp->MakeRevolutionAxisAngle(theBase, theAxis, theAngle); +} + +//============================================================================= +// MakeFilling: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeFilling (GEOM::GEOM_Object_ptr theShape, + CORBA::Long theMinDeg, CORBA::Long theMaxDeg, + CORBA::Double theTol2D, CORBA::Double theTol3D, + CORBA::Long theNbIter) +{ + MESSAGE("GEOM_Superv_i::MakeFilling"); + if (CORBA::is_nil(my3DPrimOp)) get3DPrimOp(); + return my3DPrimOp->MakeFilling(theShape, theMinDeg, theMaxDeg, theTol2D, theTol3D, theNbIter); +} + +//============================= BooleanOperations ============================= +//============================================================================= +// MakeBoolean: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeBoolean (GEOM::GEOM_Object_ptr theShape1, + GEOM::GEOM_Object_ptr theShape2, + CORBA::Long theOperation) +{ + // theOperation indicates the operation to be done: + // 1 - Common, 2 - Cut, 3 - Fuse, 4 - Section + MESSAGE("GEOM_Superv_i::MakeBoolean"); + if (CORBA::is_nil(myBoolOp)) getBoolOp(); + return myBoolOp->MakeBoolean(theShape1, theShape2, theOperation); +} + +//============================================================================= +// MakeFuse: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeFuse (GEOM::GEOM_Object_ptr theShape1, + GEOM::GEOM_Object_ptr theShape2) +{ + MESSAGE("GEOM_Superv_i::MakeFuse"); + if (CORBA::is_nil(myBoolOp)) getBoolOp(); + return myBoolOp->MakeBoolean(theShape1, theShape2, 3); +} + +//============================================================================= +// MakePartition: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakePartition (const GEOM::ListOfGO& theShapes, + const GEOM::ListOfGO& theTools, + const GEOM::ListOfGO& theKeepInside, + const GEOM::ListOfGO& theRemoveInside, + const CORBA::Short theLimit, + const CORBA::Boolean theRemoveWebs, + const GEOM::ListOfLong& theMaterials) +{ + MESSAGE("GEOM_Superv_i::MakePartition"); + if (CORBA::is_nil(myBoolOp)) getBoolOp(); + return myBoolOp->MakePartition(theShapes, theTools, theKeepInside, theRemoveInside, + theLimit, theRemoveWebs, theMaterials); +} + +//============================================================================= +// MakeHalfPartition: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeHalfPartition (GEOM::GEOM_Object_ptr theShape, + GEOM::GEOM_Object_ptr thePlane) +{ + MESSAGE("GEOM_Superv_i::MakeHalfPartition"); + if (CORBA::is_nil(myBoolOp)) getBoolOp(); + return myBoolOp->MakeHalfPartition(theShape, thePlane); +} + +//============================== InsertOperations ============================= +//============================================================================= +// MakeCopy: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeCopy (GEOM::GEOM_Object_ptr theOriginal) +{ + MESSAGE("GEOM_Superv_i::MakeCopy"); + if (CORBA::is_nil(myInsOp)) getInsOp(); + return myInsOp->MakeCopy(theOriginal); +} + +//============================================================================= +// Export: +//============================================================================= +void GEOM_Superv_i::Export (GEOM::GEOM_Object_ptr theObject, + const char* theFileName, + const char* theFormatName) +{ + MESSAGE("GEOM_Superv_i::Export"); + if (CORBA::is_nil(myInsOp)) getInsOp(); + myInsOp->Export(theObject, theFileName, theFormatName); +} + +//============================================================================= +// Import: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::Import (const char* theFileName, + const char* theFormatName) +{ + MESSAGE("GEOM_Superv_i::Import"); + if (CORBA::is_nil(myInsOp)) getInsOp(); + return myInsOp->Import(theFileName, theFormatName); +} + +//============================================================================= +// ImportTranslators: +//============================================================================= +void GEOM_Superv_i::ImportTranslators (GEOM::string_array_out theFormats, + GEOM::string_array_out thePatterns) +{ + MESSAGE("GEOM_Superv_i::ImportTranslators"); + if (CORBA::is_nil(myInsOp)) getInsOp(); + myInsOp->ImportTranslators(theFormats, thePatterns); +} + +//============================================================================= +// ExportTranslators: +//============================================================================= +void GEOM_Superv_i::ExportTranslators (GEOM::string_array_out theFormats, + GEOM::string_array_out thePatterns) +{ + MESSAGE("GEOM_Superv_i::ExportTranslators"); + if (CORBA::is_nil(myInsOp)) getInsOp(); + myInsOp->ExportTranslators(theFormats, thePatterns); +} + +//============================= TransformOperations =========================== +//============================================================================= +// TranslateTwoPoints: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::TranslateTwoPoints (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr thePoint1, + GEOM::GEOM_Object_ptr thePoint2) +{ + MESSAGE("GEOM_Superv_i::TranslateTwoPoints"); + if (CORBA::is_nil(myTransfOp)) getTransfOp(); + return myTransfOp->TranslateTwoPoints(theObject, thePoint1, thePoint2); +} + +//============================================================================= +// TranslateTwoPointsCopy: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::TranslateTwoPointsCopy (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr thePoint1, + GEOM::GEOM_Object_ptr thePoint2) +{ + MESSAGE("GEOM_Superv_i::TranslateTwoPointsCopy"); + if (CORBA::is_nil(myTransfOp)) getTransfOp(); + return myTransfOp->TranslateTwoPointsCopy(theObject, thePoint1, thePoint2); +} + +//============================================================================= +// TranslateDXDYDZ: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::TranslateDXDYDZ (GEOM::GEOM_Object_ptr theObject, + CORBA::Double theDX, + CORBA::Double theDY, + CORBA::Double theDZ) +{ + MESSAGE("GEOM_Superv_i::TranslateDXDYDZ"); + if (CORBA::is_nil(myTransfOp)) getTransfOp(); + return myTransfOp->TranslateDXDYDZ(theObject, theDX, theDY, theDZ); +} + +//============================================================================= +// TranslateDXDYDZCopy: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::TranslateDXDYDZCopy (GEOM::GEOM_Object_ptr theObject, + CORBA::Double theDX, + CORBA::Double theDY, + CORBA::Double theDZ) +{ + MESSAGE("GEOM_Superv_i::TranslateDXDYDZCopy"); + if (CORBA::is_nil(myTransfOp)) getTransfOp(); + return myTransfOp->TranslateDXDYDZCopy(theObject, theDX, theDY, theDZ); +} + +//============================================================================= +// TranslateVector: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::TranslateVector (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr theVector) +{ + MESSAGE("GEOM_Superv_i::TranslateVector"); + if (CORBA::is_nil(myTransfOp)) getTransfOp(); + return myTransfOp->TranslateVector(theObject, theVector); +} + +//============================================================================= +// TranslateVectorCopy: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::TranslateVectorCopy (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr theVector) +{ + MESSAGE("GEOM_Superv_i::TranslateVectorCopy"); + if (CORBA::is_nil(myTransfOp)) getTransfOp(); + return myTransfOp->TranslateVectorCopy(theObject, theVector); +} + +//============================================================================= +// MultiTranslate1D: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MultiTranslate1D (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr theVector, + CORBA::Double theStep, + CORBA::Long theNbTimes) +{ + MESSAGE("GEOM_Superv_i::MultiTranslate1D"); + if (CORBA::is_nil(myTransfOp)) getTransfOp(); + return myTransfOp->MultiTranslate1D(theObject, theVector, theStep, theNbTimes); +} + +//============================================================================= +// MultiTranslate2D: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MultiTranslate2D (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr theVector1, + CORBA::Double theStep1, + CORBA::Long theNbTimes1, + GEOM::GEOM_Object_ptr theVector2, + CORBA::Double theStep2, + CORBA::Long theNbTimes2) +{ + MESSAGE("GEOM_Superv_i::MultiTranslate2D"); + if (CORBA::is_nil(myTransfOp)) getTransfOp(); + return myTransfOp->MultiTranslate2D(theObject, theVector1, theStep1, theNbTimes1, + theVector2, theStep2, theNbTimes2); +} + +//============================================================================= +// Rotate: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::Rotate (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr theAxis, + CORBA::Double theAngle) +{ + MESSAGE("GEOM_Superv_i::Rotate"); + if (CORBA::is_nil(myTransfOp)) getTransfOp(); + return myTransfOp->Rotate(theObject, theAxis, theAngle); +} + +//============================================================================= +// RotateCopy: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::RotateCopy (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr theAxis, + CORBA::Double theAngle) +{ + MESSAGE("GEOM_Superv_i::RotateCopy"); + if (CORBA::is_nil(myTransfOp)) getTransfOp(); + return myTransfOp->RotateCopy(theObject, theAxis, theAngle); +} + +//============================================================================= +// MultiRotate1D: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MultiRotate1D (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr theAxis, + CORBA::Long theNbTimes) +{ + MESSAGE("GEOM_Superv_i::MultiRotate1D"); + if (CORBA::is_nil(myTransfOp)) getTransfOp(); + return myTransfOp->MultiRotate1D(theObject, theAxis, theNbTimes); +} + +//============================================================================= +// MultiRotate2D: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MultiRotate2D (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr theAxis, + CORBA::Double theAngle, + CORBA::Long theNbTimes1, + CORBA::Double theStep, + CORBA::Long theNbTimes2) +{ + MESSAGE("GEOM_Superv_i::MultiRotate2D"); + if (CORBA::is_nil(myTransfOp)) getTransfOp(); + return myTransfOp->MultiRotate2D(theObject, theAxis, theAngle, theNbTimes1, theStep, theNbTimes2); +} + +//============================================================================= +// MirrorPlane: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MirrorPlane (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr thePlane) +{ + MESSAGE("GEOM_Superv_i::MirrorPlane"); + if (CORBA::is_nil(myTransfOp)) getTransfOp(); + return myTransfOp->MirrorPlane(theObject, thePlane); +} + +//============================================================================= +// MirrorPlaneCopy: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MirrorPlaneCopy (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr thePlane) +{ + MESSAGE("GEOM_Superv_i::MirrorPlaneCopy"); + if (CORBA::is_nil(myTransfOp)) getTransfOp(); + return myTransfOp->MirrorPlaneCopy(theObject, thePlane); +} + +//============================================================================= +// MirrorAxis: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MirrorAxis (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr theAxis) +{ + MESSAGE("GEOM_Superv_i::MirrorAxis"); + if (CORBA::is_nil(myTransfOp)) getTransfOp(); + return myTransfOp->MirrorAxis(theObject, theAxis); +} + +//============================================================================= +// MirrorAxisCopy: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MirrorAxisCopy (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr theAxis) +{ + MESSAGE("GEOM_Superv_i::MirrorAxisCopy"); + if (CORBA::is_nil(myTransfOp)) getTransfOp(); + return myTransfOp->MirrorAxisCopy(theObject, theAxis); +} + +//============================================================================= +// MirrorPoint: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MirrorPoint (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr thePoint) +{ + MESSAGE("GEOM_Superv_i::MirrorPoint"); + if (CORBA::is_nil(myTransfOp)) getTransfOp(); + return myTransfOp->MirrorPoint(theObject, thePoint); +} + +//============================================================================= +// MirrorPointCopy: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MirrorPointCopy (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr thePoint) +{ + MESSAGE("GEOM_Superv_i::MirrorPointCopy"); + if (CORBA::is_nil(myTransfOp)) getTransfOp(); + return myTransfOp->MirrorPointCopy(theObject, thePoint); +} + +//============================================================================= +// OffsetShape: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::OffsetShape (GEOM::GEOM_Object_ptr theObject, + CORBA::Double theOffset) +{ + MESSAGE("GEOM_Superv_i::OffsetShape"); + if (CORBA::is_nil(myTransfOp)) getTransfOp(); + return myTransfOp->OffsetShape(theObject, theOffset); +} + +//============================================================================= +// OffsetShapeCopy: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::OffsetShapeCopy (GEOM::GEOM_Object_ptr theObject, + CORBA::Double theOffset) +{ + MESSAGE("GEOM_Superv_i::OffsetShapeCopy"); + if (CORBA::is_nil(myTransfOp)) getTransfOp(); + return myTransfOp->OffsetShapeCopy(theObject, theOffset); +} + +//============================================================================= +// ScaleShape: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::ScaleShape (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr thePoint, + CORBA::Double theFactor) +{ + MESSAGE("GEOM_Superv_i::ScaleShape"); + if (CORBA::is_nil(myTransfOp)) getTransfOp(); + return myTransfOp->ScaleShape(theObject, thePoint, theFactor); +} + +//============================================================================= +// ScaleShapeCopy: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::ScaleShapeCopy (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr thePoint, + CORBA::Double theFactor) +{ + MESSAGE("GEOM_Superv_i::ScaleShapeCopy"); + if (CORBA::is_nil(myTransfOp)) getTransfOp(); + return myTransfOp->ScaleShapeCopy(theObject, thePoint, theFactor); +} + +//============================================================================= +// PositionShape: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::PositionShape (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr theStartLCS, + GEOM::GEOM_Object_ptr theEndLCS) +{ + MESSAGE("GEOM_Superv_i::PositionShape"); + if (CORBA::is_nil(myTransfOp)) getTransfOp(); + return myTransfOp->PositionShape(theObject, theStartLCS, theEndLCS); +} + +//============================================================================= +// PositionShapeCopy: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::PositionShapeCopy (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr theStartLCS, + GEOM::GEOM_Object_ptr theEndLCS) +{ + MESSAGE("GEOM_Superv_i::PositionShapeCopy"); + if (CORBA::is_nil(myTransfOp)) getTransfOp(); + return myTransfOp->PositionShapeCopy(theObject, theStartLCS, theEndLCS); +} + +//=============================== ShapesOperations ============================ +//============================================================================= +// Make: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeEdge (GEOM::GEOM_Object_ptr thePnt1, + GEOM::GEOM_Object_ptr thePnt2) +{ + MESSAGE("GEOM_Superv_i::MakeEdge"); + if (CORBA::is_nil(myShapesOp)) getShapesOp(); + return myShapesOp->MakeEdge(thePnt1, thePnt2); +} + +//============================================================================= +// MakeWire: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeWire (const GEOM::ListOfGO& theEdgesAndWires) +{ + MESSAGE("GEOM_Superv_i::MakeWire"); + if (CORBA::is_nil(myShapesOp)) getShapesOp(); + return myShapesOp->MakeWire(theEdgesAndWires); +} + +//============================================================================= +// MakeFace: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeFace (GEOM::GEOM_Object_ptr theWire, + CORBA::Boolean isPlanarWanted) +{ + MESSAGE("GEOM_Superv_i::MakeFace"); + if (CORBA::is_nil(myShapesOp)) getShapesOp(); + return myShapesOp->MakeFace(theWire, isPlanarWanted); +} + +//============================================================================= +// MakeFaceWires: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeFaceWires (const GEOM::ListOfGO& theWires, + CORBA::Boolean isPlanarWanted) +{ + MESSAGE("GEOM_Superv_i::MakeFaceWires"); + if (CORBA::is_nil(myShapesOp)) getShapesOp(); + return myShapesOp->MakeFaceWires(theWires, isPlanarWanted); +} + +//============================================================================= +// MakeShell: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeShell (const GEOM::ListOfGO& theFacesAndShells) +{ + MESSAGE("GEOM_Superv_i::MakeShell"); + if (CORBA::is_nil(myShapesOp)) getShapesOp(); + return myShapesOp->MakeShell(theFacesAndShells); +} + +//============================================================================= +// MakeSolidShell: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeSolidShell (GEOM::GEOM_Object_ptr theShell) +{ + MESSAGE("GEOM_Superv_i::MakeSolidShell"); + if (CORBA::is_nil(myShapesOp)) getShapesOp(); + return myShapesOp->MakeSolidShell(theShell); +} + +//============================================================================= +// MakeSolidShells: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeSolidShells (const GEOM::ListOfGO& theShells) +{ + MESSAGE("GEOM_Superv_i::MakeSolidShells"); + if (CORBA::is_nil(myShapesOp)) getShapesOp(); + return myShapesOp->MakeSolidShells(theShells); +} + +//============================================================================= +// MakeCompound: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeCompound (const GEOM::ListOfGO& theShapes) +{ + MESSAGE("GEOM_Superv_i::MakeCompound"); + if (CORBA::is_nil(myShapesOp)) getShapesOp(); + return myShapesOp->MakeCompound(theShapes); +} + +//============================================================================= +// MakeGlueFaces: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeGlueFaces (GEOM::GEOM_Object_ptr theShape, + const CORBA::Double theTolerance) +{ + MESSAGE("GEOM_Superv_i::MakeGlueFaces"); + if (CORBA::is_nil(myShapesOp)) getShapesOp(); + return myShapesOp->MakeGlueFaces(theShape, theTolerance); +} + +//============================================================================= +// MakeExplode: +//============================================================================= +GEOM::ListOfGO* GEOM_Superv_i::MakeExplode (GEOM::GEOM_Object_ptr theShape, + const CORBA::Long theShapeType, + const CORBA::Boolean isSorted) +{ + MESSAGE("GEOM_Superv_i::MakeExplode"); + if (CORBA::is_nil(myShapesOp)) getShapesOp(); + return myShapesOp->MakeExplode(theShape, theShapeType, isSorted); +} + +//============================================================================= +// NumberOfFaces: +//============================================================================= +CORBA::Long GEOM_Superv_i::NumberOfFaces (GEOM::GEOM_Object_ptr theShape) +{ + MESSAGE("GEOM_Superv_i::NumberOfFaces"); + if (CORBA::is_nil(myShapesOp)) getShapesOp(); + return myShapesOp->NumberOfFaces(theShape); +} + +//============================================================================= +// NumberOfEdges: +//============================================================================= +CORBA::Long GEOM_Superv_i::NumberOfEdges (GEOM::GEOM_Object_ptr theShape) +{ + MESSAGE("GEOM_Superv_i::NumberOfEdges"); + if (CORBA::is_nil(myShapesOp)) getShapesOp(); + return myShapesOp->NumberOfEdges(theShape); +} + +//============================================================================= +// ChangeOrientation: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::ChangeOrientation (GEOM::GEOM_Object_ptr theShape) +{ + MESSAGE("GEOM_Superv_i::ChangeOrientation"); + if (CORBA::is_nil(myShapesOp)) getShapesOp(); + return myShapesOp->ChangeOrientation(theShape); +} + + +//=============================== BlocksOperations ============================ +//============================================================================= +// MakeQuad4Vertices: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeQuad4Vertices (GEOM::GEOM_Object_ptr thePnt1, + GEOM::GEOM_Object_ptr thePnt2, + GEOM::GEOM_Object_ptr thePnt3, + GEOM::GEOM_Object_ptr thePnt4) +{ + MESSAGE("GEOM_Superv_i::MakeQuad4Vertices"); + if (CORBA::is_nil(myBlocksOp)) getBlocksOp(); + return myBlocksOp->MakeQuad4Vertices(thePnt1, thePnt2, thePnt3, thePnt4); +} + +//============================================================================= +// MakeQuad: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeQuad (GEOM::GEOM_Object_ptr theEdge1, + GEOM::GEOM_Object_ptr theEdge2, + GEOM::GEOM_Object_ptr theEdge3, + GEOM::GEOM_Object_ptr theEdge4) +{ + MESSAGE("GEOM_Superv_i::MakeQuad"); + if (CORBA::is_nil(myBlocksOp)) getBlocksOp(); + return myBlocksOp->MakeQuad(theEdge1, theEdge2, theEdge3, theEdge4); +} + +//============================================================================= +// MakeQuad2Edges: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeQuad2Edges (GEOM::GEOM_Object_ptr theEdge1, + GEOM::GEOM_Object_ptr theEdge2) +{ + MESSAGE("GEOM_Superv_i::MakeQuad2Edges"); + if (CORBA::is_nil(myBlocksOp)) getBlocksOp(); + return myBlocksOp->MakeQuad2Edges(theEdge1, theEdge2); +} + +//============================================================================= +// MakeHexa: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeHexa (GEOM::GEOM_Object_ptr theFace1, + GEOM::GEOM_Object_ptr theFace2, + GEOM::GEOM_Object_ptr theFace3, + GEOM::GEOM_Object_ptr theFace4, + GEOM::GEOM_Object_ptr theFace5, + GEOM::GEOM_Object_ptr theFace6) +{ + MESSAGE("GEOM_Superv_i::MakeHexa"); + if (CORBA::is_nil(myBlocksOp)) getBlocksOp(); + return myBlocksOp->MakeHexa(theFace1, theFace2, theFace3, theFace4, theFace5, theFace6); +} + +//============================================================================= +// MakeHexa2Faces: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeHexa2Faces (GEOM::GEOM_Object_ptr theFace1, + GEOM::GEOM_Object_ptr theFace2) +{ + MESSAGE("GEOM_Superv_i::MakeHexa2Faces"); + if (CORBA::is_nil(myBlocksOp)) getBlocksOp(); + return myBlocksOp->MakeHexa2Faces(theFace1, theFace2); +} + +//============================================================================= +// GetPoint: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::GetPoint (GEOM::GEOM_Object_ptr theShape, + const CORBA::Double theX, + const CORBA::Double theY, + const CORBA::Double theZ, + const CORBA::Double theEpsilon) +{ + MESSAGE("GEOM_Superv_i::GetPoint"); + if (CORBA::is_nil(myBlocksOp)) getBlocksOp(); + return myBlocksOp->GetPoint(theShape, theX, theY, theZ, theEpsilon); +} + +//============================================================================= +// GetEdge: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::GetEdge (GEOM::GEOM_Object_ptr theShape, + GEOM::GEOM_Object_ptr thePoint1, + GEOM::GEOM_Object_ptr thePoint2) +{ + MESSAGE("GEOM_Superv_i::GetEdge"); + if (CORBA::is_nil(myBlocksOp)) getBlocksOp(); + return myBlocksOp->GetEdge(theShape, thePoint1, thePoint2); +} + +//============================================================================= +// GetEdgeNearPoint: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::GetEdgeNearPoint (GEOM::GEOM_Object_ptr theShape, + GEOM::GEOM_Object_ptr thePoint) +{ + MESSAGE("GEOM_Superv_i::GetEdgeNearPoint"); + if (CORBA::is_nil(myBlocksOp)) getBlocksOp(); + return myBlocksOp->GetEdgeNearPoint(theShape, thePoint); +} + +//============================================================================= +// GetFaceByPoints: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::GetFaceByPoints (GEOM::GEOM_Object_ptr theShape, + GEOM::GEOM_Object_ptr thePoint1, + GEOM::GEOM_Object_ptr thePoint2, + GEOM::GEOM_Object_ptr thePoint3, + GEOM::GEOM_Object_ptr thePoint4) +{ + MESSAGE("GEOM_Superv_i::GetFaceByPoints"); + if (CORBA::is_nil(myBlocksOp)) getBlocksOp(); + return myBlocksOp->GetFaceByPoints(theShape, thePoint1, thePoint2, thePoint3, thePoint4); +} + +//============================================================================= +// GetFaceByEdges: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::GetFaceByEdges (GEOM::GEOM_Object_ptr theShape, + GEOM::GEOM_Object_ptr theEdge1, + GEOM::GEOM_Object_ptr theEdge2) +{ + MESSAGE("GEOM_Superv_i::GetFaceByEdges"); + if (CORBA::is_nil(myBlocksOp)) getBlocksOp(); + return myBlocksOp->GetFaceByEdges(theShape, theEdge1, theEdge2); +} + +//============================================================================= +// GetOppositeFace: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::GetOppositeFace (GEOM::GEOM_Object_ptr theBlock, + GEOM::GEOM_Object_ptr theFace) +{ + MESSAGE("GEOM_Superv_i::GetOppositeFace"); + if (CORBA::is_nil(myBlocksOp)) getBlocksOp(); + return myBlocksOp->GetOppositeFace(theBlock, theFace); +} + +//============================================================================= +// GetFaceNearPoint: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::GetFaceNearPoint (GEOM::GEOM_Object_ptr theShape, + GEOM::GEOM_Object_ptr thePoint) +{ + MESSAGE("GEOM_Superv_i::GetFaceNearPoint"); + if (CORBA::is_nil(myBlocksOp)) getBlocksOp(); + return myBlocksOp->GetFaceNearPoint(theShape, thePoint); +} + +//============================================================================= +// GetFaceByNormale: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::GetFaceByNormale (GEOM::GEOM_Object_ptr theBlock, + GEOM::GEOM_Object_ptr theVector) +{ + MESSAGE("GEOM_Superv_i::GetFaceByNormale"); + if (CORBA::is_nil(myBlocksOp)) getBlocksOp(); + return myBlocksOp->GetFaceByNormale(theBlock, theVector); +} + +//============================================================================= +// IsCompoundOfBlocks: +//============================================================================= +CORBA::Boolean GEOM_Superv_i::IsCompoundOfBlocks (GEOM::GEOM_Object_ptr theCompound, + const CORBA::Long theMinNbFaces, + const CORBA::Long theMaxNbFaces, + CORBA::Long& theNbBlocks) +{ + MESSAGE("GEOM_Superv_i::IsCompoundOfBlocks"); + if (CORBA::is_nil(myBlocksOp)) getBlocksOp(); + return myBlocksOp->IsCompoundOfBlocks(theCompound, theMinNbFaces, theMaxNbFaces, theNbBlocks); +} + +//============================================================================= +// CheckCompoundOfBlocks: +//============================================================================= +CORBA::Boolean GEOM_Superv_i::CheckCompoundOfBlocks +(GEOM::GEOM_Object_ptr theCompound, + GEOM::GEOM_IBlocksOperations::BCErrors_out theErrors) +{ + MESSAGE("GEOM_Superv_i::CheckCompoundOfBlocks"); + if (CORBA::is_nil(myBlocksOp)) getBlocksOp(); + return myBlocksOp->CheckCompoundOfBlocks(theCompound, theErrors); +} + +//============================================================================= +// PrintBCErrors: +//============================================================================= +char* GEOM_Superv_i::PrintBCErrors (GEOM::GEOM_Object_ptr theCompound, + const GEOM::GEOM_IBlocksOperations::BCErrors& theErrors) +{ + MESSAGE("GEOM_Superv_i::PrintBCErrors"); + if (CORBA::is_nil(myBlocksOp)) getBlocksOp(); + return myBlocksOp->PrintBCErrors(theCompound, theErrors); +} + +//============================================================================= +// ExplodeCompoundOfBlocks: +//============================================================================= +GEOM::ListOfGO* GEOM_Superv_i::ExplodeCompoundOfBlocks (GEOM::GEOM_Object_ptr theCompound, + const CORBA::Long theMinNbFaces, + const CORBA::Long theMaxNbFaces) +{ + MESSAGE("GEOM_Superv_i::ExplodeCompoundOfBlocks"); + if (CORBA::is_nil(myBlocksOp)) getBlocksOp(); + return myBlocksOp->ExplodeCompoundOfBlocks(theCompound, theMinNbFaces, theMaxNbFaces); +} + +//============================================================================= +// GetBlockNearPoint: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::GetBlockNearPoint (GEOM::GEOM_Object_ptr theCompound, + GEOM::GEOM_Object_ptr thePoint) +{ + MESSAGE("GEOM_Superv_i::GetBlockNearPoint"); + if (CORBA::is_nil(myBlocksOp)) getBlocksOp(); + return myBlocksOp->GetBlockNearPoint(theCompound, thePoint); +} + +//============================================================================= +// GetBlockByParts: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::GetBlockByParts (GEOM::GEOM_Object_ptr theCompound, + const GEOM::ListOfGO& theParts) +{ + MESSAGE("GEOM_Superv_i::GetBlockByParts"); + if (CORBA::is_nil(myBlocksOp)) getBlocksOp(); + return myBlocksOp->GetBlockByParts(theCompound, theParts); +} + +//============================================================================= +// GetBlocksByParts: +//============================================================================= +GEOM::ListOfGO* GEOM_Superv_i::GetBlocksByParts (GEOM::GEOM_Object_ptr theCompound, + const GEOM::ListOfGO& theParts) +{ + MESSAGE("GEOM_Superv_i::GetBlocksByParts"); + if (CORBA::is_nil(myBlocksOp)) getBlocksOp(); + return myBlocksOp->GetBlocksByParts(theCompound, theParts); +} + +//============================================================================= +// MakeMultiTransformation1D: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeMultiTransformation1D (GEOM::GEOM_Object_ptr theBlock, + const CORBA::Long theDirFace1, + const CORBA::Long theDirFace2, + const CORBA::Long theNbTimes) +{ + MESSAGE("GEOM_Superv_i::MakeMultiTransformation1D"); + if (CORBA::is_nil(myBlocksOp)) getBlocksOp(); + return myBlocksOp->MakeMultiTransformation1D(theBlock, theDirFace1, theDirFace2, theNbTimes); +} + +//============================================================================= +// MakeMultiTransformation2D: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeMultiTransformation2D +(GEOM::GEOM_Object_ptr theBlock, + const CORBA::Long theDirFace1U, + const CORBA::Long theDirFace2U, + const CORBA::Long theNbTimesU, + const CORBA::Long theDirFace1V, + const CORBA::Long theDirFace2V, + const CORBA::Long theNbTimesV) +{ + MESSAGE("GEOM_Superv_i::MakeMultiTransformation2D"); + if (CORBA::is_nil(myBlocksOp)) getBlocksOp(); + return myBlocksOp->MakeMultiTransformation2D(theBlock, + theDirFace1U, theDirFace2U, theNbTimesU, + theDirFace1V, theDirFace2V, theNbTimesV); +} + +//=============================== CurvesOperations ============================ +//============================================================================= +// MakeCirclePntVecR: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeCirclePntVecR (GEOM::GEOM_Object_ptr theCenter, + GEOM::GEOM_Object_ptr theVector, + CORBA::Double theR) +{ + MESSAGE("GEOM_Superv_i::MakeCirclePntVecR"); + if (CORBA::is_nil(myCurvesOp)) getCurvesOp(); + return myCurvesOp->MakeCirclePntVecR(theCenter, theVector, theR); +} + +//============================================================================= +// MakeCircleThreePnt: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeCircleThreePnt (GEOM::GEOM_Object_ptr thePnt1, + GEOM::GEOM_Object_ptr thePnt2, + GEOM::GEOM_Object_ptr thePnt3) +{ + MESSAGE("GEOM_Superv_i::MakeCircleThreePnt"); + if (CORBA::is_nil(myCurvesOp)) getCurvesOp(); + return myCurvesOp->MakeCircleThreePnt(thePnt1, thePnt2, thePnt3); +} + +//============================================================================= +// MakeEllipse: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeEllipse (GEOM::GEOM_Object_ptr theCenter, + GEOM::GEOM_Object_ptr theVector, + CORBA::Double theRMajor, + CORBA::Double theRMinor) +{ + MESSAGE("GEOM_Superv_i::MakeEllipse"); + if (CORBA::is_nil(myCurvesOp)) getCurvesOp(); + return myCurvesOp->MakeEllipse(theCenter, theVector, theRMajor, theRMinor); +} + +//============================================================================= +// MakeArc: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeArc (GEOM::GEOM_Object_ptr thePnt1, + GEOM::GEOM_Object_ptr thePnt2, + GEOM::GEOM_Object_ptr thePnt3) +{ + MESSAGE("GEOM_Superv_i::MakeArc"); + if (CORBA::is_nil(myCurvesOp)) getCurvesOp(); + return myCurvesOp->MakeArc(thePnt1, thePnt2, thePnt3); +} + +//============================================================================= +// MakePolyline: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakePolyline (const GEOM::ListOfGO& thePoints) +{ + MESSAGE("GEOM_Superv_i::MakePolyline"); + if (CORBA::is_nil(myCurvesOp)) getCurvesOp(); + return myCurvesOp->MakePolyline(thePoints); +} + +//============================================================================= +// MakeSplineBezier: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeSplineBezier (const GEOM::ListOfGO& thePoints) +{ + MESSAGE("GEOM_Superv_i::MakeSplineBezier"); + if (CORBA::is_nil(myCurvesOp)) getCurvesOp(); + return myCurvesOp->MakeSplineBezier(thePoints); +} + +//============================================================================= +// MakeSplineInterpolation: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeSplineInterpolation (const GEOM::ListOfGO& thePoints) +{ + MESSAGE("GEOM_Superv_i::MakeSplineInterpolation"); + if (CORBA::is_nil(myCurvesOp)) getCurvesOp(); + return myCurvesOp->MakeSplineInterpolation(thePoints); +} + +//============================================================================= +// MakeSketcher: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeSketcher (const char* theCommand, + const GEOM::ListOfDouble& theWorkingPlane) +{ + MESSAGE("GEOM_Superv_i::MakeSketcher"); + if (CORBA::is_nil(myCurvesOp)) getCurvesOp(); + return myCurvesOp->MakeSketcher(theCommand, theWorkingPlane); +} + +//=============================== LocalOperations ============================= +//============================================================================= +// MakeFilletAll: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeFilletAll (GEOM::GEOM_Object_ptr theShape, + CORBA::Double theR) +{ + MESSAGE("GEOM_Superv_i::MakeFilletAllMakeSketcher"); + if (CORBA::is_nil(myLocalOp)) getLocalOp(); + return myLocalOp->MakeFilletAll(theShape, theR); +} + +//============================================================================= +// MakeFilletEdges: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeFilletEdges (GEOM::GEOM_Object_ptr theShape, + CORBA::Double theR, + const GEOM::ListOfLong& theEdges) +{ + MESSAGE("GEOM_Superv_i::MakeFilletEdges"); + if (CORBA::is_nil(myLocalOp)) getLocalOp(); + return myLocalOp->MakeFilletEdges(theShape, theR, theEdges); +} + +//============================================================================= +// MakeFilletFaces: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeFilletFaces (GEOM::GEOM_Object_ptr theShape, + CORBA::Double theR, + const GEOM::ListOfLong& theFaces) +{ + MESSAGE("GEOM_Superv_i::MakeFilletFaces"); + if (CORBA::is_nil(myLocalOp)) getLocalOp(); + return myLocalOp->MakeFilletFaces(theShape, theR, theFaces); +} + +//============================================================================= +// MakeChamferAll: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeChamferAll (GEOM::GEOM_Object_ptr theShape, CORBA::Double theD) +{ + MESSAGE("GEOM_Superv_i::MakeChamferAll"); + if (CORBA::is_nil(myLocalOp)) getLocalOp(); + return myLocalOp->MakeChamferAll(theShape, theD); +} + +//============================================================================= +// MakeChamferEdge: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeChamferEdge (GEOM::GEOM_Object_ptr theShape, + CORBA::Double theD1, CORBA::Double theD2, + CORBA::Long theFace1, CORBA::Long theFace2) +{ + MESSAGE("GEOM_Superv_i::MakeChamferEdge"); + if (CORBA::is_nil(myLocalOp)) getLocalOp(); + return myLocalOp->MakeChamferEdge(theShape, theD1, theD2, theFace1, theFace2); +} + +//============================================================================= +// MakeChamferFaces: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeChamferFaces (GEOM::GEOM_Object_ptr theShape, + CORBA::Double theD1, CORBA::Double theD2, + const GEOM::ListOfLong& theFaces) +{ + MESSAGE("GEOM_Superv_i::MakeChamferFaces"); + if (CORBA::is_nil(myLocalOp)) getLocalOp(); + return myLocalOp->MakeChamferFaces(theShape, theD1, theD2, theFaces); +} + +//============================================================================= +// MakeArchimede: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeArchimede (GEOM::GEOM_Object_ptr theShape, + CORBA::Double theWeight, + CORBA::Double theWaterDensity, + CORBA::Double theMeshingDeflection) +{ + MESSAGE("GEOM_Superv_i::MakeArchimede"); + if (CORBA::is_nil(myLocalOp)) getLocalOp(); + return myLocalOp->MakeArchimede(theShape, theWeight, theWaterDensity, theMeshingDeflection); +} + +//============================================================================= +// GetSubShapeIndexMakeFilletAll: +//============================================================================= +CORBA::Long GEOM_Superv_i::GetSubShapeIndex (GEOM::GEOM_Object_ptr theShape, + GEOM::GEOM_Object_ptr theSubShape) +{ + MESSAGE("GEOM_Superv_i::GetSubShapeIndexMakeArchimede"); + if (CORBA::is_nil(myLocalOp)) getLocalOp(); + return myLocalOp->GetSubShapeIndex(theShape, theSubShape); +} + +//=============================== GroupOperations ============================= +//============================================================================= +// CreateGroup: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::CreateGroup (GEOM::GEOM_Object_ptr theMainShape, + CORBA::Long theShapeType) +{ + MESSAGE("GEOM_Superv_i::CreateGroup"); + if (CORBA::is_nil(myGroupOp)) getGroupOp(); + return myGroupOp->CreateGroup(theMainShape, theShapeType); +} + +//============================================================================= +// AddObject: +//============================================================================= +void GEOM_Superv_i::AddObject (GEOM::GEOM_Object_ptr theGroup, + CORBA::Long theSubShapeId) +{ + MESSAGE("GEOM_Superv_i::AddObject"); + if (CORBA::is_nil(myGroupOp)) getGroupOp(); + myGroupOp->AddObject(theGroup, theSubShapeId); +} + +//============================================================================= +// RemoveObject: +//============================================================================= +void GEOM_Superv_i::RemoveObject (GEOM::GEOM_Object_ptr theGroup, + CORBA::Long theSubShapeId) +{ + MESSAGE("GEOM_Superv_i::RemoveObject"); + if (CORBA::is_nil(myGroupOp)) getGroupOp(); + myGroupOp->RemoveObject(theGroup, theSubShapeId); +} + +//============================================================================= +// GetType: +//============================================================================= +CORBA::Long GEOM_Superv_i::GetType (GEOM::GEOM_Object_ptr theGroup) +{ + MESSAGE("GEOM_Superv_i::GetType"); + if (CORBA::is_nil(myGroupOp)) getGroupOp(); + return myGroupOp->GetType(theGroup); +} + +//============================================================================= +// GetMainShape: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::GetMainShape (GEOM::GEOM_Object_ptr theGroup) +{ + MESSAGE("GEOM_Superv_i::GetMainShape"); + if (CORBA::is_nil(myGroupOp)) getGroupOp(); + return myGroupOp->GetMainShape(theGroup); +} + +//============================================================================= +// GetObjects: +//============================================================================= +GEOM::ListOfLong* GEOM_Superv_i::GetObjects (GEOM::GEOM_Object_ptr theGroup) +{ + MESSAGE("GEOM_Superv_i::GetObjects"); + if (CORBA::is_nil(myGroupOp)) getGroupOp(); + return myGroupOp->GetObjects(theGroup); +} + +//===================================================================================== +// EXPORTED METHODS +//===================================================================================== +extern "C" +{ + PortableServer::ObjectId * GEOM_SupervEngine_factory(CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + PortableServer::ObjectId * contId, + const char *instanceName, + const char * interfaceName) + { + GEOM_Superv_i * myGEOM_Superv_i = new GEOM_Superv_i(orb, poa, contId, instanceName, interfaceName); + myGEOM_Superv_i->register_name("/myGEOM_Superv"); + return myGEOM_Superv_i->getId() ; + } +} diff --git a/src/GEOM_I_Superv/GEOM_Superv_i.hh b/src/GEOM_I_Superv/GEOM_Superv_i.hh new file mode 100644 index 000000000..67f780c10 --- /dev/null +++ b/src/GEOM_I_Superv/GEOM_Superv_i.hh @@ -0,0 +1,462 @@ +#ifndef __GEOM_SUPERV_I_H__ +#define __GEOM_SUPERV_I_H__ + +// IDL headers +#include +#include CORBA_SERVER_HEADER(GEOM_Superv) + +#include "GEOM_Gen_i.hh" + +#include "QAD_Study.h" +#include "QAD_Application.h" +#include "QAD_Desktop.h" + +class GEOM_Superv_i : public virtual POA_GEOM::GEOM_Superv, + public Engines_Component_i +{ +public: + GEOM_Superv_i(CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + PortableServer::ObjectId * contId, + const char *instanceName, + const char *interfaceName); + ~GEOM_Superv_i(); + + // generic method to be put in a super class + void register_name(char * name); + void setGeomEngine(); + + void getBasicOp(); + void get3DPrimOp(); + void getBoolOp(); + void getInsOp(); + void getTransfOp(); + void getShapesOp(); + void getBlocksOp(); + void getCurvesOp(); + void getLocalOp(); + void getGroupOp(); + + //-----------------------------------------------------------------------// + // Set current stydy ID // + //-----------------------------------------------------------------------// + void SetStudyID( CORBA::Long theId ); + + //-----------------------------------------------------------------------// + // Inherited methods from SALOMEDS::Driver // + //-----------------------------------------------------------------------// + + SALOMEDS::TMPFile* Save(SALOMEDS::SComponent_ptr theComponent, + const char* theURL, + bool isMultiFile); + + SALOMEDS::TMPFile* SaveASCII(SALOMEDS::SComponent_ptr theComponent, + const char* theURL, + bool isMultiFile); + + CORBA::Boolean Load(SALOMEDS::SComponent_ptr theComponent, + const SALOMEDS::TMPFile& theStream, + const char* theURL, + bool isMultiFile); + + CORBA::Boolean LoadASCII(SALOMEDS::SComponent_ptr theComponent, + const SALOMEDS::TMPFile& theStream, + const char* theURL, + bool isMultiFile); + + void Close(SALOMEDS::SComponent_ptr theComponent); + char* ComponentDataType(); + + + char* IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject, + const char* IORString, + CORBA::Boolean isMultiFile, + CORBA::Boolean isASCII); + char* LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject, + const char* aLocalPersistentID, + CORBA::Boolean isMultiFile, + CORBA::Boolean isASCII); + + bool CanPublishInStudy(CORBA::Object_ptr theIOR); + SALOMEDS::SObject_ptr PublishInStudy(SALOMEDS::Study_ptr theStudy, + SALOMEDS::SObject_ptr theSObject, + CORBA::Object_ptr theObject, + const char* theName) throw (SALOME::SALOME_Exception) ; + + CORBA::Boolean CanCopy(SALOMEDS::SObject_ptr theObject); + SALOMEDS::TMPFile* CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID); + CORBA::Boolean CanPaste(const char* theComponentName, CORBA::Long theObjectID); + SALOMEDS::SObject_ptr PasteInto(const SALOMEDS::TMPFile& theStream, + CORBA::Long theObjectID, + SALOMEDS::SObject_ptr theObject); + + //-----------------------------------------------------------// + // Primitives Construction : BasicOperations // + //-----------------------------------------------------------// + GEOM::GEOM_Object_ptr MakePointXYZ (CORBA::Double theX, + CORBA::Double theY, + CORBA::Double theZ); + GEOM::GEOM_Object_ptr MakePointWithReference (GEOM::GEOM_Object_ptr theReference, + CORBA::Double theX, + CORBA::Double theY, + CORBA::Double theZ); + GEOM::GEOM_Object_ptr MakePointOnCurve (GEOM::GEOM_Object_ptr theRefCurve, + CORBA::Double theParameter); + GEOM::GEOM_Object_ptr MakeVectorDXDYDZ (CORBA::Double theDX, + CORBA::Double theDY, + CORBA::Double theDZ); + GEOM::GEOM_Object_ptr MakeVectorTwoPnt (GEOM::GEOM_Object_ptr thePnt1, + GEOM::GEOM_Object_ptr thePnt2); + GEOM::GEOM_Object_ptr MakeLineTwoPnt (GEOM::GEOM_Object_ptr thePnt1, + GEOM::GEOM_Object_ptr thePnt2); + GEOM::GEOM_Object_ptr MakePlaneThreePnt (GEOM::GEOM_Object_ptr thePnt1, + GEOM::GEOM_Object_ptr thePnt2, + GEOM::GEOM_Object_ptr thePnt3, + CORBA::Double theTrimSize); + GEOM::GEOM_Object_ptr MakePlanePntVec (GEOM::GEOM_Object_ptr thePnt, + GEOM::GEOM_Object_ptr theVec, + CORBA::Double theTrimSize); + GEOM::GEOM_Object_ptr MakePlaneFace (GEOM::GEOM_Object_ptr theFace, + CORBA::Double theTrimSize); + GEOM::GEOM_Object_ptr MakeMarker (CORBA::Double theOX , CORBA::Double theOY , CORBA::Double theOZ, + CORBA::Double theXDX, CORBA::Double theXDY, CORBA::Double theXDZ, + CORBA::Double theYDX, CORBA::Double theYDY, CORBA::Double theYDZ); + + //-----------------------------------------------------------// + // Primitives Construction : 3DPrimOperations // + //-----------------------------------------------------------// + GEOM::GEOM_Object_ptr MakeBox (CORBA::Double theX1, + CORBA::Double theY1, + CORBA::Double theZ1, + CORBA::Double theX2, + CORBA::Double theY2, + CORBA::Double theZ2); + GEOM::GEOM_Object_ptr MakeBoxDXDYDZ (CORBA::Double theDX, + CORBA::Double theDY, + CORBA::Double theDZ); + GEOM::GEOM_Object_ptr MakeBoxTwoPnt (GEOM::GEOM_Object_ptr thePnt1, + GEOM::GEOM_Object_ptr thePnt2); + GEOM::GEOM_Object_ptr MakeCylinderPntVecRH (GEOM::GEOM_Object_ptr thePnt, + GEOM::GEOM_Object_ptr theAxis, + CORBA::Double theRadius, + CORBA::Double theHeight); + GEOM::GEOM_Object_ptr MakeCylinderRH (CORBA::Double theR, + CORBA::Double theH); + GEOM::GEOM_Object_ptr MakeSphere (CORBA::Double theX, + CORBA::Double theY, + CORBA::Double theZ, + CORBA::Double theRadius); + GEOM::GEOM_Object_ptr MakeSphereR (CORBA::Double theR); + GEOM::GEOM_Object_ptr MakeSpherePntR (GEOM::GEOM_Object_ptr thePnt, + CORBA::Double theR); + GEOM::GEOM_Object_ptr MakeTorusPntVecRR (GEOM::GEOM_Object_ptr thePnt, + GEOM::GEOM_Object_ptr theVec, + CORBA::Double theRMajor, + CORBA::Double theRMinor); + GEOM::GEOM_Object_ptr MakeTorusRR (CORBA::Double theRMajor, + CORBA::Double theRMinor); + GEOM::GEOM_Object_ptr MakeConePntVecR1R2H (GEOM::GEOM_Object_ptr thePnt, + GEOM::GEOM_Object_ptr theAxis, + CORBA::Double theR1, + CORBA::Double theR2, + CORBA::Double theHeight); + GEOM::GEOM_Object_ptr MakeConeR1R2H (CORBA::Double theR1, + CORBA::Double theR2, + CORBA::Double theHeight); + GEOM::GEOM_Object_ptr MakePrismVecH (GEOM::GEOM_Object_ptr theBase, + GEOM::GEOM_Object_ptr theVec, + CORBA::Double theH); + GEOM::GEOM_Object_ptr MakePrismTwoPnt (GEOM::GEOM_Object_ptr theBase, + GEOM::GEOM_Object_ptr thePoint1, + GEOM::GEOM_Object_ptr thePoint2); + GEOM::GEOM_Object_ptr MakePipe (GEOM::GEOM_Object_ptr theBase, + GEOM::GEOM_Object_ptr thePath); + GEOM::GEOM_Object_ptr MakeRevolutionAxisAngle (GEOM::GEOM_Object_ptr theBase, + GEOM::GEOM_Object_ptr theAxis, + CORBA::Double theAngle); + GEOM::GEOM_Object_ptr MakeFilling (GEOM::GEOM_Object_ptr theShape, + CORBA::Long theMinDeg, CORBA::Long theMaxDeg, + CORBA::Double theTol2D, CORBA::Double theTol3D, + CORBA::Long theNbIter); + + //-----------------------------------------------------------// + // BooleanOperations // + //-----------------------------------------------------------// + GEOM::GEOM_Object_ptr MakeBoolean (GEOM::GEOM_Object_ptr theShape1, + GEOM::GEOM_Object_ptr theShape2, + CORBA::Long theOperation); + GEOM::GEOM_Object_ptr MakeFuse (GEOM::GEOM_Object_ptr theShape1, + GEOM::GEOM_Object_ptr theShape2); + GEOM::GEOM_Object_ptr MakePartition (const GEOM::ListOfGO& theShapes, + const GEOM::ListOfGO& theTools, + const GEOM::ListOfGO& theKeepInside, + const GEOM::ListOfGO& theRemoveInside, + const CORBA::Short theLimit, + const CORBA::Boolean theRemoveWebs, + const GEOM::ListOfLong& theMaterials); + GEOM::GEOM_Object_ptr MakeHalfPartition (GEOM::GEOM_Object_ptr theShape, + GEOM::GEOM_Object_ptr thePlane); + + //-----------------------------------------------------------// + // InsertOperations // + //-----------------------------------------------------------// + GEOM::GEOM_Object_ptr MakeCopy (GEOM::GEOM_Object_ptr theOriginal); + void Export (GEOM::GEOM_Object_ptr theObject, + const char* theFileName, + const char* theFormatName); + GEOM::GEOM_Object_ptr Import (const char* theFileName, + const char* theFormatName); + void ImportTranslators (GEOM::string_array_out theFormats, + GEOM::string_array_out thePatterns); + void ExportTranslators (GEOM::string_array_out theFormats, + GEOM::string_array_out thePatterns); + + //-----------------------------------------------------------// + // TransformOperations // + //-----------------------------------------------------------// + GEOM::GEOM_Object_ptr TranslateTwoPoints (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr thePoint1, + GEOM::GEOM_Object_ptr thePoint2); + GEOM::GEOM_Object_ptr TranslateTwoPointsCopy (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr thePoint1, + GEOM::GEOM_Object_ptr thePoint2); + GEOM::GEOM_Object_ptr TranslateDXDYDZ (GEOM::GEOM_Object_ptr theObject, + CORBA::Double theDX, + CORBA::Double theDY, + CORBA::Double theDZ); + GEOM::GEOM_Object_ptr TranslateDXDYDZCopy (GEOM::GEOM_Object_ptr theObject, + CORBA::Double theDX, + CORBA::Double theDY, + CORBA::Double theDZ); + GEOM::GEOM_Object_ptr TranslateVector (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr theVector); + GEOM::GEOM_Object_ptr TranslateVectorCopy (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr theVector); + GEOM::GEOM_Object_ptr MultiTranslate1D (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr theVector, + CORBA::Double theStep, + CORBA::Long theNbTimes); + GEOM::GEOM_Object_ptr MultiTranslate2D (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr theVector1, + CORBA::Double theStep1, + CORBA::Long theNbTimes1, + GEOM::GEOM_Object_ptr theVector2, + CORBA::Double theStep2, + CORBA::Long theNbTimes2); + GEOM::GEOM_Object_ptr Rotate (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr theAxis, + CORBA::Double theAngle); + GEOM::GEOM_Object_ptr RotateCopy (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr theAxis, + CORBA::Double theAngle); + GEOM::GEOM_Object_ptr MultiRotate1D (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr theAxis, + CORBA::Long theNbTimes); + GEOM::GEOM_Object_ptr MultiRotate2D (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr theAxis, + CORBA::Double theAngle, + CORBA::Long theNbTimes1, + CORBA::Double theStep, + CORBA::Long theNbTimes2); + GEOM::GEOM_Object_ptr MirrorPlane (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr thePlane); + GEOM::GEOM_Object_ptr MirrorPlaneCopy (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr thePlane); + GEOM::GEOM_Object_ptr MirrorAxis (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr theAxis); + GEOM::GEOM_Object_ptr MirrorAxisCopy (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr theAxis); + GEOM::GEOM_Object_ptr MirrorPoint (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr thePoint); + GEOM::GEOM_Object_ptr MirrorPointCopy (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr thePoint); + GEOM::GEOM_Object_ptr OffsetShape (GEOM::GEOM_Object_ptr theObject, + CORBA::Double theOffset); + GEOM::GEOM_Object_ptr OffsetShapeCopy (GEOM::GEOM_Object_ptr theObject, + CORBA::Double theOffset); + GEOM::GEOM_Object_ptr ScaleShape (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr thePoint, + CORBA::Double theFactor); + GEOM::GEOM_Object_ptr ScaleShapeCopy (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr thePoint, + CORBA::Double theFactor); + GEOM::GEOM_Object_ptr PositionShape (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr theStartLCS, + GEOM::GEOM_Object_ptr theEndLCS); + GEOM::GEOM_Object_ptr PositionShapeCopy (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr theStartLCS, + GEOM::GEOM_Object_ptr theEndLCS); + + //-----------------------------------------------------------// + // ShapesOperations // + //-----------------------------------------------------------// + GEOM::GEOM_Object_ptr MakeEdge (GEOM::GEOM_Object_ptr thePnt1, + GEOM::GEOM_Object_ptr thePnt2); + GEOM::GEOM_Object_ptr MakeWire (const GEOM::ListOfGO& theEdgesAndWires); + GEOM::GEOM_Object_ptr MakeFace (GEOM::GEOM_Object_ptr theWire, + CORBA::Boolean isPlanarWanted); + GEOM::GEOM_Object_ptr MakeFaceWires (const GEOM::ListOfGO& theWires, + CORBA::Boolean isPlanarWanted); + GEOM::GEOM_Object_ptr MakeShell (const GEOM::ListOfGO& theFacesAndShells); + GEOM::GEOM_Object_ptr MakeSolidShell (GEOM::GEOM_Object_ptr theShell); + GEOM::GEOM_Object_ptr MakeSolidShells (const GEOM::ListOfGO& theShells); + GEOM::GEOM_Object_ptr MakeCompound (const GEOM::ListOfGO& theShapes); + GEOM::GEOM_Object_ptr MakeGlueFaces (GEOM::GEOM_Object_ptr theShape, + const CORBA::Double theTolerance); + GEOM::ListOfGO* MakeExplode (GEOM::GEOM_Object_ptr theShape, + const CORBA::Long theShapeType, + const CORBA::Boolean isSorted); + CORBA::Long NumberOfFaces (GEOM::GEOM_Object_ptr theShape); + CORBA::Long NumberOfEdges (GEOM::GEOM_Object_ptr theShape); + GEOM::GEOM_Object_ptr ChangeOrientation (GEOM::GEOM_Object_ptr theShape); + + //-----------------------------------------------------------// + // BlocksOperations // + //-----------------------------------------------------------// + GEOM::GEOM_Object_ptr MakeQuad4Vertices (GEOM::GEOM_Object_ptr thePnt1, + GEOM::GEOM_Object_ptr thePnt2, + GEOM::GEOM_Object_ptr thePnt3, + GEOM::GEOM_Object_ptr thePnt4); + GEOM::GEOM_Object_ptr MakeQuad (GEOM::GEOM_Object_ptr theEdge1, + GEOM::GEOM_Object_ptr theEdge2, + GEOM::GEOM_Object_ptr theEdge3, + GEOM::GEOM_Object_ptr theEdge4); + GEOM::GEOM_Object_ptr MakeQuad2Edges (GEOM::GEOM_Object_ptr theEdge1, + GEOM::GEOM_Object_ptr theEdge2); + GEOM::GEOM_Object_ptr MakeHexa (GEOM::GEOM_Object_ptr theFace1, + GEOM::GEOM_Object_ptr theFace2, + GEOM::GEOM_Object_ptr theFace3, + GEOM::GEOM_Object_ptr theFace4, + GEOM::GEOM_Object_ptr theFace5, + GEOM::GEOM_Object_ptr theFace6); + GEOM::GEOM_Object_ptr MakeHexa2Faces (GEOM::GEOM_Object_ptr theFace1, + GEOM::GEOM_Object_ptr theFace2); + GEOM::GEOM_Object_ptr GetPoint (GEOM::GEOM_Object_ptr theShape, + const CORBA::Double theX, + const CORBA::Double theY, + const CORBA::Double theZ, + const CORBA::Double theEpsilon); + GEOM::GEOM_Object_ptr GetEdge (GEOM::GEOM_Object_ptr theShape, + GEOM::GEOM_Object_ptr thePoint1, + GEOM::GEOM_Object_ptr thePoint2); + GEOM::GEOM_Object_ptr GetEdgeNearPoint (GEOM::GEOM_Object_ptr theShape, + GEOM::GEOM_Object_ptr thePoint); + GEOM::GEOM_Object_ptr GetFaceByPoints (GEOM::GEOM_Object_ptr theShape, + GEOM::GEOM_Object_ptr thePoint1, + GEOM::GEOM_Object_ptr thePoint2, + GEOM::GEOM_Object_ptr thePoint3, + GEOM::GEOM_Object_ptr thePoint4); + GEOM::GEOM_Object_ptr GetFaceByEdges (GEOM::GEOM_Object_ptr theShape, + GEOM::GEOM_Object_ptr theEdge1, + GEOM::GEOM_Object_ptr theEdge2); + GEOM::GEOM_Object_ptr GetOppositeFace (GEOM::GEOM_Object_ptr theBlock, + GEOM::GEOM_Object_ptr theFace); + GEOM::GEOM_Object_ptr GetFaceNearPoint (GEOM::GEOM_Object_ptr theShape, + GEOM::GEOM_Object_ptr thePoint); + GEOM::GEOM_Object_ptr GetFaceByNormale (GEOM::GEOM_Object_ptr theBlock, + GEOM::GEOM_Object_ptr theVector); + CORBA::Boolean IsCompoundOfBlocks (GEOM::GEOM_Object_ptr theCompound, + const CORBA::Long theMinNbFaces, + const CORBA::Long theMaxNbFaces, + CORBA::Long& theNbBlocks); + CORBA::Boolean CheckCompoundOfBlocks (GEOM::GEOM_Object_ptr theCompound, + GEOM::GEOM_IBlocksOperations::BCErrors_out theErrors); + char* PrintBCErrors (GEOM::GEOM_Object_ptr theCompound, + const GEOM::GEOM_IBlocksOperations::BCErrors& theErrors); + GEOM::ListOfGO* ExplodeCompoundOfBlocks (GEOM::GEOM_Object_ptr theCompound, + const CORBA::Long theMinNbFaces, + const CORBA::Long theMaxNbFaces); + GEOM::GEOM_Object_ptr GetBlockNearPoint (GEOM::GEOM_Object_ptr theCompound, + GEOM::GEOM_Object_ptr thePoint); + GEOM::GEOM_Object_ptr GetBlockByParts (GEOM::GEOM_Object_ptr theCompound, + const GEOM::ListOfGO& theParts); + GEOM::ListOfGO* GetBlocksByParts (GEOM::GEOM_Object_ptr theCompound, + const GEOM::ListOfGO& theParts); + GEOM::GEOM_Object_ptr MakeMultiTransformation1D (GEOM::GEOM_Object_ptr theBlock, + const CORBA::Long theDirFace1, + const CORBA::Long theDirFace2, + const CORBA::Long theNbTimes); + GEOM::GEOM_Object_ptr MakeMultiTransformation2D (GEOM::GEOM_Object_ptr theBlock, + const CORBA::Long theDirFace1U, + const CORBA::Long theDirFace2U, + const CORBA::Long theNbTimesU, + const CORBA::Long theDirFace1V, + const CORBA::Long theDirFace2V, + const CORBA::Long theNbTimesV); + + //-----------------------------------------------------------// + // CurvesOperations // + //-----------------------------------------------------------// + GEOM::GEOM_Object_ptr MakeCirclePntVecR (GEOM::GEOM_Object_ptr theCenter, + GEOM::GEOM_Object_ptr theVector, + CORBA::Double theR); + GEOM::GEOM_Object_ptr MakeCircleThreePnt (GEOM::GEOM_Object_ptr thePnt1, + GEOM::GEOM_Object_ptr thePnt2, + GEOM::GEOM_Object_ptr thePnt3); + GEOM::GEOM_Object_ptr MakeEllipse (GEOM::GEOM_Object_ptr theCenter, + GEOM::GEOM_Object_ptr theVector, + CORBA::Double theRMajor, CORBA::Double theRMinor); + GEOM::GEOM_Object_ptr MakeArc (GEOM::GEOM_Object_ptr thePnt1, + GEOM::GEOM_Object_ptr thePnt2, + GEOM::GEOM_Object_ptr thePnt3); + GEOM::GEOM_Object_ptr MakePolyline (const GEOM::ListOfGO& thePoints); + GEOM::GEOM_Object_ptr MakeSplineBezier (const GEOM::ListOfGO& thePoints); + GEOM::GEOM_Object_ptr MakeSplineInterpolation (const GEOM::ListOfGO& thePoints); + GEOM::GEOM_Object_ptr MakeSketcher (const char* theCommand, + const GEOM::ListOfDouble& theWorkingPlane); + + //-----------------------------------------------------------// + // LocalOperations // + //-----------------------------------------------------------// + GEOM::GEOM_Object_ptr MakeFilletAll (GEOM::GEOM_Object_ptr theShape, + CORBA::Double theR); + GEOM::GEOM_Object_ptr MakeFilletEdges (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR, + const GEOM::ListOfLong& theEdges); + GEOM::GEOM_Object_ptr MakeFilletFaces (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR, + const GEOM::ListOfLong& theFaces); + GEOM::GEOM_Object_ptr MakeChamferAll (GEOM::GEOM_Object_ptr theShape, CORBA::Double theD); + GEOM::GEOM_Object_ptr MakeChamferEdge (GEOM::GEOM_Object_ptr theShape, + CORBA::Double theD1, CORBA::Double theD2, + CORBA::Long theFace1, CORBA::Long theFace2); + GEOM::GEOM_Object_ptr MakeChamferFaces (GEOM::GEOM_Object_ptr theShape, + CORBA::Double theD1, CORBA::Double theD2, + const GEOM::ListOfLong& theFaces); + GEOM::GEOM_Object_ptr MakeArchimede (GEOM::GEOM_Object_ptr theShape, + CORBA::Double theWeight, + CORBA::Double theWaterDensity, + CORBA::Double theMeshingDeflection); + CORBA::Long GetSubShapeIndex (GEOM::GEOM_Object_ptr theShape, + GEOM::GEOM_Object_ptr theSubShape); + + //-----------------------------------------------------------// + // GroupOperations // + //-----------------------------------------------------------// + GEOM::GEOM_Object_ptr CreateGroup (GEOM::GEOM_Object_ptr theMainShape, + CORBA::Long theShapeType); + void AddObject (GEOM::GEOM_Object_ptr theGroup, + CORBA::Long theSubShapeId); + void RemoveObject (GEOM::GEOM_Object_ptr theGroup, + CORBA::Long theSubShapeId); + CORBA::Long GetType (GEOM::GEOM_Object_ptr theGroup); + GEOM::GEOM_Object_ptr GetMainShape (GEOM::GEOM_Object_ptr theGroup); + GEOM::ListOfLong* GetObjects (GEOM::GEOM_Object_ptr theGroup); + +private: + SALOME_NamingService * name_service; + GEOM::GEOM_Gen_ptr myGeomEngine; + CORBA::Long myStudyID; + + GEOM::GEOM_IBasicOperations_ptr myBasicOp; + GEOM::GEOM_I3DPrimOperations_ptr my3DPrimOp; + GEOM::GEOM_IBooleanOperations_ptr myBoolOp; + GEOM::GEOM_IInsertOperations_ptr myInsOp; + GEOM::GEOM_ITransformOperations_ptr myTransfOp; + GEOM::GEOM_IShapesOperations_ptr myShapesOp; + GEOM::GEOM_IBlocksOperations_ptr myBlocksOp; + GEOM::GEOM_ICurvesOperations_ptr myCurvesOp; + GEOM::GEOM_ILocalOperations_ptr myLocalOp; + GEOM::GEOM_IGroupOperations_ptr myGroupOp; + +}; + +#endif diff --git a/src/GEOM_I_Superv/Makefile.in b/src/GEOM_I_Superv/Makefile.in new file mode 100644 index 000000000..14c03b7bf --- /dev/null +++ b/src/GEOM_I_Superv/Makefile.in @@ -0,0 +1,64 @@ +# GEOM GEOM : implementaion of GEOM_Superv.idl +# +# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +# +# +# +# File : Makefile.in +# Author : Patrick GOLDBRONN (CEA) +# Module : GEOM +# $Header$ + +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + +@COMMENCE@ + +# Libraries targets + +LIB = libGEOM_SupervEngine.la +LIB_SRC = \ + GEOM_Superv_i.cc + +LIB_SERVER_IDL = SALOMEDS.idl SALOMEDS_Attributes.idl SALOME_Component.idl SALOME_Exception.idl \ + SALOME_GenericObj.idl SALOME_ModuleCatalog.idl GEOM_Gen.idl GEOM_Superv.idl \ + +# Executables targets +BIN = +BIN_SRC = +BIN_CLIENT_IDL = +BIN_SERVER_IDL = + +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 + +# additional file to be cleaned +MOSTLYCLEAN = +CLEAN = +DISTCLEAN = + +@CONCLUDE@ + diff --git a/src/GEOM_SWIG/GEOM_Partition1.py b/src/GEOM_SWIG/GEOM_Partition1.py index 4eea3ff99..3a6118833 100755 --- a/src/GEOM_SWIG/GEOM_Partition1.py +++ b/src/GEOM_SWIG/GEOM_Partition1.py @@ -8,7 +8,7 @@ # Module : GEOM #%Make geometry (like CEA script (A1)) using Partition algorithm% -# appel: +# appel: # import alveole_3D_01_GEOM # reload(alveole_3D_01_GEOM) @@ -38,61 +38,49 @@ boolean_section = 4 # -- +pnt0 = geompy.MakeVertex(0.,0.,0.) +vecz = geompy.MakeVectorDXDYDZ(0.,0.,1.) + barier = geompy.MakeCylinder( - geom.MakePointStruct(0.,0.,0.), - geom.MakeDirection(geom.MakePointStruct(0.,0.,1.)), + pnt0, + vecz, barier_radius, barier_height) # -- -colis = geompy.MakeCylinder( - geom.MakePointStruct(0.,0.,0.), - geom.MakeDirection(geom.MakePointStruct(0.,0.,1.)), - colis_radius, - barier_height) +colis = geompy.MakeCylinder(pnt0, vecz, colis_radius, barier_height) -cc = geompy.MakeCylinder( - geom.MakePointStruct(0.,0.,0.), - geom.MakeDirection(geom.MakePointStruct(0.,0.,1.)), - cc_radius, - barier_height) +cc = geompy.MakeCylinder(pnt0, vecz, cc_radius, barier_height) -colis_cc = geompy.MakeCompound( - [colis._get_Name(), cc._get_Name()]) +colis_cc = geompy.MakeCompound([colis, cc]) -colis_cc = geompy.MakeTranslation( - colis_cc, colis_center, 0.0, 0.0) +colis_cc = geompy.MakeTranslation(colis_cc, colis_center, 0.0, 0.0) -colis_cc_multi = geompy.MakeMultiRotation1D( - colis_cc, - geom.MakeDirection(geom.MakePointStruct(0.,0.,1.)), - geom.MakePointStruct(0.,0.,0.), - 4) +colis_cc_multi = geompy.MultiRotate1D(colis_cc, vecz, 4) # -- -alveole = geompy.Partition( - [colis_cc_multi._get_Name(), barier._get_Name()]) +alveole = geompy.MakePartition([colis_cc_multi, barier]) -subshapes = geompy.SubShapeAll( alveole, geompy.ShapeType["SHAPE"] ) +geompy.addToStudy(alveole, "alveole before explode") -## there are 9 subshapes +subshapes = geompy.SubShapeAll(alveole, geompy.ShapeType["SHAPE"]) -comp1 = geompy.MakeCompound( [ subshapes[0]._get_Name(), subshapes[1]._get_Name() ] ); -comp2 = geompy.MakeCompound( [ subshapes[2]._get_Name(), subshapes[3]._get_Name() ] ); -comp3 = geompy.MakeCompound( [ subshapes[4]._get_Name(), subshapes[5]._get_Name() ] ); -comp4 = geompy.MakeCompound( [ subshapes[6]._get_Name(), subshapes[7]._get_Name() ] ); +## there are 9 subshapes -compIORs = [] -compIORs.append( comp1._get_Name() ); -compIORs.append( comp2._get_Name() ); -compIORs.append( comp3._get_Name() ); -compIORs.append( comp4._get_Name() ); -comp = geompy.MakeCompound( compIORs ); +comp1 = geompy.MakeCompound([subshapes[0], subshapes[1]]); +comp2 = geompy.MakeCompound([subshapes[2], subshapes[3]]); +comp3 = geompy.MakeCompound([subshapes[4], subshapes[5]]); +comp4 = geompy.MakeCompound([subshapes[6], subshapes[7]]); -alveole = geompy.MakeCompound( [ comp._get_Name(), subshapes[8]._get_Name() ]); - -geompy.addToStudy(alveole, "alveole") +compGOs = [] +compGOs.append(comp1); +compGOs.append(comp2); +compGOs.append(comp3); +compGOs.append(comp4); +comp = geompy.MakeCompound(compGOs); +alveole = geompy.MakeCompound([comp, subshapes[8]]); +geompy.addToStudy(alveole, "alveole") diff --git a/src/GEOM_SWIG/GEOM_Partition2.py b/src/GEOM_SWIG/GEOM_Partition2.py index db8ce8ec6..2a4ca4e73 100755 --- a/src/GEOM_SWIG/GEOM_Partition2.py +++ b/src/GEOM_SWIG/GEOM_Partition2.py @@ -19,6 +19,9 @@ import geompy geom = geompy.geom +vecx = geompy.MakeVectorDXDYDZ(1.,0.,0.) +vecy = geompy.MakeVectorDXDYDZ(0.,1.,0.) + # -- colis colis_xmin = 05.76 @@ -26,8 +29,8 @@ colis_xmax = 19.83 colis_radius = 0.3 colis = geompy.MakeCylinder( - geom.MakePointStruct(colis_xmin,0.,0.), - geom.MakeDirection(geom.MakePointStruct(1.,0.,0.)), + geompy.MakeVertex(colis_xmin,0.,0.), + vecx, colis_radius, colis_xmax-colis_xmin) @@ -38,8 +41,8 @@ bo_xmax = colis_xmax bo_radius = 1.23 bo = geompy.MakeCylinder( - geom.MakePointStruct(bo_xmin,0.,0.), - geom.MakeDirection(geom.MakePointStruct(1.,0.,0.)), + geompy.MakeVertex(bo_xmin,0.,0.), + vecx, bo_radius, bo_xmax-bo_xmin) @@ -51,8 +54,8 @@ alvRup_xmax = colis_xmax alvRup_radius = 1.6 alvRup = geompy.MakeCylinder( - geom.MakePointStruct(alvRup_xmin,0.,0.), - geom.MakeDirection(geom.MakePointStruct(1.,0.,0.)), + geompy.MakeVertex(alvRup_xmin,0.,0.), + vecx, alvRup_radius, alvRup_xmax-alvRup_xmin) @@ -64,8 +67,8 @@ bouchon_xmax = 22.83 bouchon_radius = alvRup_radius bouchon = geompy.MakeCylinder( - geom.MakePointStruct(bouchon_xmin,0.,0.), - geom.MakeDirection(geom.MakePointStruct(1.,0.,0.)), + geompy.MakeVertex(bouchon_xmin,0.,0.), + vecx, bouchon_radius, bouchon_xmax-bouchon_xmin) @@ -75,9 +78,11 @@ galerie_xmax = 25.0 galerie_radius = 3.0 box_y = 30.0 +pnt_galerie_xmax = geompy.MakeVertex(galerie_xmax,0.,0.) + galerie = geompy.MakeCylinder( - geom.MakePointStruct(galerie_xmax,0.,0.), - geom.MakeDirection(geom.MakePointStruct(0.,1.,0.)), + pnt_galerie_xmax, + vecy, galerie_radius, box_y) galerie = geompy.MakeTranslation(galerie, 0, -box_y/2, 0) @@ -94,8 +99,8 @@ galRup_xmax = galerie_xmax galRup_radius = 3.9 galRup = geompy.MakeCylinder( - geom.MakePointStruct(galerie_xmax,0.,0.), - geom.MakeDirection(geom.MakePointStruct(0.,1.,0.)), + pnt_galerie_xmax, + vecy, galRup_radius, box_y) galRup = geompy.MakeTranslation(galRup, 0, -box_y/2, 0) @@ -105,11 +110,7 @@ galRup = geompy.MakeTranslation(galRup, 0, -box_y/2, 0) galEnd_xmax = galerie_xmax galEnd_radius = 4.6 -galEnd = geompy.MakeCylinder( - geom.MakePointStruct(galerie_xmax,0.,0.), - geom.MakeDirection(geom.MakePointStruct(0.,1.,0.)), - galEnd_radius, - box_y) +galEnd = geompy.MakeCylinder(pnt_galerie_xmax, vecy, galEnd_radius, box_y) galEnd = geompy.MakeTranslation(galEnd, 0, -box_y/2, 0) # -- endommagement alveole @@ -119,30 +120,26 @@ alvEnd_xmax = galerie_xmax alvEnd_radius = 2.46 alvEnd = geompy.MakeCylinder( - geom.MakePointStruct(alvEnd_xmin,0.,0.), - geom.MakeDirection(geom.MakePointStruct(1.,0.,0.)), + geompy.MakeVertex(alvEnd_xmin,0.,0.), + vecx, alvEnd_radius, alvEnd_xmax-alvEnd_xmin) # remove internal parts of galEnd intersecting alvEnd -galEnd_alvEnd = geompy.Partition( - [ alvEnd._get_Name() ] , [], [], [ galEnd._get_Name() ] ) +galEnd_alvEnd = geompy.MakePartition([alvEnd], [], [], [galEnd]) -iorL = [ colis._get_Name() ] -iorL += [ bo._get_Name() ] -iorL += [ alvRup._get_Name() ] -#iorL += [ galerie._get_Name() ] -iorL += [ galRup._get_Name() ] -iorL += [ galEnd_alvEnd._get_Name() ] +GOList = [colis] +GOList += [bo] +GOList += [alvRup] +#GOList += [galerie ] +GOList += [galRup] +GOList += [galEnd_alvEnd] # -- # remove section parts outside bo and inside bouchon -callovo = geompy.Partition( - iorL, [], [ box._get_Name() ], [galerie._get_Name(), bouchon._get_Name()] ) - - +callovo = geompy.MakePartition(GOList, [], [box], [galerie, bouchon]) geompy.addToStudy(callovo, "callovo perp. 2") diff --git a/src/GEOM_SWIG/GEOM_Partition3.py b/src/GEOM_SWIG/GEOM_Partition3.py index d325f848e..9f35f08b8 100755 --- a/src/GEOM_SWIG/GEOM_Partition3.py +++ b/src/GEOM_SWIG/GEOM_Partition3.py @@ -15,6 +15,8 @@ import geompy geom = geompy.geom +vecx = geompy.MakeVectorDXDYDZ(1.,0.,0.) + # -- colis colis_xmin = 05.76 @@ -22,12 +24,12 @@ colis_xmax = 19.83 colis_radius = 0.3 colis = geompy.MakeCylinder( - geom.MakePointStruct(colis_xmin,0.,0.), - geom.MakeDirection(geom.MakePointStruct(1.,0.,0.)), + geompy.MakeVertex(colis_xmin,0.,0.), + vecx, colis_radius, colis_xmax-colis_xmin) -iorL = [colis._get_Name()] +GOList = [colis] # -- bo @@ -36,12 +38,12 @@ bo_xmax = colis_xmax bo_radius = 1.23 bo = geompy.MakeCylinder( - geom.MakePointStruct(bo_xmin,0.,0.), - geom.MakeDirection(geom.MakePointStruct(1.,0.,0.)), + geompy.MakeVertex(bo_xmin,0.,0.), + vecx, bo_radius, bo_xmax-bo_xmin) -iorL.append(bo._get_Name()) +GOList.append(bo) # -- rupture alveole @@ -50,12 +52,12 @@ alvRup_xmax = colis_xmax alvRup_radius = 1.6 alvRup = geompy.MakeCylinder( - geom.MakePointStruct(alvRup_xmin,0.,0.), - geom.MakeDirection(geom.MakePointStruct(1.,0.,0.)), + geompy.MakeVertex(alvRup_xmin,0.,0.), + vecx, alvRup_radius, alvRup_xmax-alvRup_xmin) -iorL.append(alvRup._get_Name()) +GOList.append(alvRup) # bouchon @@ -64,12 +66,12 @@ bouchon_xmax = 22.83 bouchon_radius = alvRup_radius bouchon = geompy.MakeCylinder( - geom.MakePointStruct(bouchon_xmin,0.,0.), - geom.MakeDirection(geom.MakePointStruct(1.,0.,0.)), + geompy.MakeVertex(bouchon_xmin,0.,0.), + vecx, bouchon_radius, bouchon_xmax-bouchon_xmin) -#iorL.append(bouchon._get_Name()) +#GOList.append(bouchon) # -- endommagement alveole @@ -78,12 +80,12 @@ alvEnd_xmax = 20.66 alvEnd_radius = 2.46 alvEnd = geompy.MakeCylinder( - geom.MakePointStruct(alvEnd_xmin,0.,0.), - geom.MakeDirection(geom.MakePointStruct(1.,0.,0.)), + geompy.MakeVertex(alvEnd_xmin,0.,0.), + vecx, alvEnd_radius, alvEnd_xmax-alvEnd_xmin) -iorL.append(alvEnd._get_Name()) +GOList.append(alvEnd) # galerie @@ -92,12 +94,12 @@ galerie_xmax = 25.0 galerie_radius = 2.17 galerie = geompy.MakeCylinder( - geom.MakePointStruct(galerie_xmin,0.,0.), - geom.MakeDirection(geom.MakePointStruct(1.,0.,0.)), + geompy.MakeVertex(galerie_xmin,0.,0.), + vecx, galerie_radius, galerie_xmax-galerie_xmin) -iorL.append(galerie._get_Name()) +GOList.append(galerie) # -- rupture galerie @@ -106,12 +108,12 @@ galRup_xmax = galerie_xmax galRup_radius = 2.82 galRup = geompy.MakeCylinder( - geom.MakePointStruct(galRup_xmin,0.,0.), - geom.MakeDirection(geom.MakePointStruct(1.,0.,0.)), + geompy.MakeVertex(galRup_xmin,0.,0.), + vecx, galRup_radius, galRup_xmax-galRup_xmin) -iorL.append(galRup._get_Name()) +GOList.append(galRup) # -- endom. galerie @@ -120,12 +122,12 @@ galEnd_xmax = galerie_xmax galEnd_radius = 4.34 galEnd = geompy.MakeCylinder( - geom.MakePointStruct(galEnd_xmin,0.,0.), - geom.MakeDirection(geom.MakePointStruct(1.,0.,0.)), + geompy.MakeVertex(galEnd_xmin,0.,0.), + vecx, galEnd_radius, galEnd_xmax-galEnd_xmin) -iorL.append(galEnd._get_Name()) +GOList.append(galEnd) # -- @@ -133,9 +135,9 @@ box_y = 30.0 box = geompy.MakeBox(0., 0., 0., galerie_xmax, box_y, box_y) box = geompy.MakeTranslation(box, 0.0, -box_y/2, -box_y/2) -iorL.append(box._get_Name()) +GOList.append(box) # -- -callovo = geompy.Partition(iorL,[],[], [bouchon._get_Name()]) +callovo = geompy.MakePartition(GOList, [], [], [bouchon]) geompy.addToStudy(callovo, "callovo 2") diff --git a/src/GEOM_SWIG/GEOM_Partition4.py b/src/GEOM_SWIG/GEOM_Partition4.py index 17c7632c9..96dd0d4f8 100755 --- a/src/GEOM_SWIG/GEOM_Partition4.py +++ b/src/GEOM_SWIG/GEOM_Partition4.py @@ -39,49 +39,45 @@ geom = geompy.geom # -- Construction de backfill -backA = geompy.MakeBox(0.0,0.0,0.0,baDx,baDy,baDz) -back = geompy.MakeTranslation(backA,-baDx/2,-baDy/2,-baDz/2) +backA = geompy.MakeBox(0.0, 0.0, 0.0, baDx, baDy, baDz) +back = geompy.MakeTranslation(backA, -baDx/2, -baDy/2, -baDz/2) # -- Construction de alveolus import math -alveA = geompy.MakeBox(0.0,0.0,0.0,alDx,alDy,alDz) -alveB = geompy.MakeTranslation(alveA,-alDx/2,baDy/2,-alDz/2) -axis = geompy.geom.MakeAxisStruct(0.0,0.0,0.0,1.0,0.0,0.0) -alve1 = geompy.MakeRotation(alveB,axis,math.pi) -alve2 = geompy.MakeTranslation(alveB,+alSepx/2,0.0,0.0) -alve3 = geompy.MakeTranslation(alveB,-alSepx/2,0.0,0.0) -IORlist = [] -IORlist.append(alve1._get_Name()) -IORlist.append(alve2._get_Name()) -IORlist.append(alve3._get_Name()) -alve = geompy.MakeCompound(IORlist) +alveA = geompy.MakeBox(0.0, 0.0, 0.0, alDx, alDy, alDz) +alveB = geompy.MakeTranslation(alveA, -alDx/2, baDy/2, -alDz/2) +axis = geompy.MakeVectorDXDYDZ(1.0, 0.0, 0.0) +alve1 = geompy.MakeRotation(alveB, axis, math.pi) +alve2 = geompy.MakeTranslation(alveB, +alSepx/2, 0.0, 0.0) +alve3 = geompy.MakeTranslation(alveB, -alSepx/2, 0.0, 0.0) +GOlist = [] +GOlist.append(alve1) +GOlist.append(alve2) +GOlist.append(alve3) +alve = geompy.MakeCompound(GOlist) # -- Construction de geological medium -geolA = geompy.MakeBox(0.0,0.0,0.0,gmDx,gmDy,gmDz) -geol = geompy.MakeTranslation(geolA,-gmDx/2,-gmDy/2,-gmDz/2) +geolA = geompy.MakeBox(0.0, 0.0, 0.0, gmDx, gmDy, gmDz) +geol = geompy.MakeTranslation(geolA, -gmDx/2, -gmDy/2, -gmDz/2) -geol = geompy.Partition( - [alve._get_Name(), geol._get_Name(), back._get_Name()]) +geol = geompy.MakePartition([alve, geol, back]) -subshapes = geompy.SubShapeAll( geol, geompy.ShapeType["SHAPE"] ) +subshapes = geompy.SubShapeAll(geol, geompy.ShapeType["SHAPE"]) -IORlist = [] -IORlist.append(subshapes[0]._get_Name()) -IORlist.append(subshapes[1]._get_Name()) -IORlist.append(subshapes[2]._get_Name()) -alve = geompy.MakeCompound(IORlist) +GOlist = [] +GOlist.append(subshapes[0]) +GOlist.append(subshapes[1]) +GOlist.append(subshapes[2]) +alve = geompy.MakeCompound(GOlist) geol = subshapes[3] back = subshapes[4] # -- -geol = geompy.MakeCompound( - [geol._get_Name(), back._get_Name(), alve._get_Name()]) - -geompy.addToStudy(geol,"couplex2 2") - +geol = geompy.MakeCompound([geol, back, alve]) +geompy.addToStudy(geol, "couplex2 2") diff --git a/src/GEOM_SWIG/GEOM_Partition5.py b/src/GEOM_SWIG/GEOM_Partition5.py index cbc1c5c5f..ca6d5de81 100755 --- a/src/GEOM_SWIG/GEOM_Partition5.py +++ b/src/GEOM_SWIG/GEOM_Partition5.py @@ -19,29 +19,26 @@ geom = geompy.geom # -- Dimensions de la boite entiˆre LX, LY, LZ = 300.0, 150.0, 150.0 +p0 = geompy.MakeVertex(0.,0.,0.) +vy = geompy.MakeVectorDXDYDZ(0.,1.,0.) # -- D‰finition du plan de sym‰trie (O,Ox,Oz) -symPlane = geompy.MakePlane ( - geom.MakePointStruct(0.,0.,0.), - geom.MakeDirection(geom.MakePointStruct(0.,1.,0.)), - 10.0 ) +symPlane = geompy.MakePlane(p0, vy, 10.0) # -- bo -bo = geompy.MakeBox(0.0,0.0,0.0,LX,LY,LZ) -bo = geompy.MakeTranslation(bo,0.0,-LY/2,-LZ/2) +bo = geompy.MakeBoxDXDYDZ(LX, LY, LZ) +bo = geompy.MakeTranslation(bo, 0.0, -LY/2, -LZ/2) # -- Galerie principale gal_diam = 80.0 gal_lony = LY gal_x = LX-20.0-gal_diam/2 -gal = geompy.MakeCylinder( - geom.MakePointStruct(0.,0.,0.), - geom.MakeDirection(geom.MakePointStruct(0.,1.,0.)), - gal_diam/2,gal_lony) -gal = geompy.MakeTranslation(gal,gal_x,-gal_lony/2,0.0) + +gal = geompy.MakeCylinder(p0, vy, gal_diam/2, gal_lony) +gal = geompy.MakeTranslation(gal, gal_x, -gal_lony/2, 0.0) # -- Galerie perpendiculaire # -- Dimensions de la galerie perpendiculaire @@ -51,53 +48,46 @@ gal = geompy.MakeTranslation(gal,gal_x,-gal_lony/2,0.0) gpe_long, gpe_diam = 200.0, 60.0 gpe_x = gal_x gpe = geompy.MakeCylinder( - geom.MakePointStruct(0.,0.,0.), - geom.MakeDirection(geom.MakePointStruct(-1.,0.,0.)), + p0, + geompy.MakeVectorDXDYDZ(-1.,0.,0.), gpe_diam/2,gpe_long) -gpe = geompy.MakeTranslation(gpe,gpe_x,0,0) +gpe = geompy.MakeTranslation(gpe, gpe_x, 0, 0) # -- Dimensions d'une alveole # -- Construction d'une alv‰ole alv_long, alv_diam = 60.0, 18.0 -alv01 = geompy.MakeCylinder( - geom.MakePointStruct(0.,0.,0.), - geom.MakeDirection(geom.MakePointStruct(0.,1.,0.)), - alv_diam/2,alv_long) -alv02 = geompy.MakeMirrorByPlane(alv01,symPlane) -alv0 = geompy.MakeCompound( [ alv01._get_Name(), alv02._get_Name() ] ) +alv01 = geompy.MakeCylinder(p0, vy, alv_diam/2, alv_long) +alv02 = geompy.MakeMirrorByPlane(alv01, symPlane) +alv0 = geompy.MakeCompound([alv01, alv02]) # -- Construction des alv‰oles alv_del, alv_sep = 40.0, 35.0 -alv1 = geompy.MakeTranslation ( - alv0,gal_x-gal_diam/2-alv_sep,0.0,0.0 ) -alv2 = geompy.MakeTranslation ( - alv1,-alv_del,0.0,0.0 ) -alv3 = geompy.MakeTranslation ( - alv2,-alv_del,0.0,0.0 ) -alv = geompy.MakeCompound( [ alv1._get_Name(), alv2._get_Name(), alv3._get_Name() ] ) +alv1 = geompy.MakeTranslation(alv0, gal_x-gal_diam/2-alv_sep, 0.0, 0.0) +alv2 = geompy.MakeTranslation(alv1, -alv_del, 0.0, 0.0 ) +alv3 = geompy.MakeTranslation(alv2, -alv_del, 0.0, 0.0 ) +alv = geompy.MakeCompound([alv1, alv2, alv3]) # -- Remplissage de la BO -gallery = geompy.Partition( - [ alv._get_Name(), bo._get_Name() ], [], [], [ gal._get_Name(), gpe._get_Name() ]) +gallery = geompy.MakePartition([alv, bo], [], [], [gal, gpe]) -subshapes = geompy.SubShapeAll( gallery, geompy.ShapeType["SHAPE"] ) +subshapes = geompy.SubShapeAll(gallery, geompy.ShapeType["SHAPE"]) -alvIORs = [] -alvIORs.append( subshapes[0]._get_Name() ) -alvIORs.append( subshapes[1]._get_Name() ) -alvIORs.append( subshapes[2]._get_Name() ) -alvIORs.append( subshapes[3]._get_Name() ) -alvIORs.append( subshapes[4]._get_Name() ) -alvIORs.append( subshapes[5]._get_Name() ) -alvcomp = geompy.MakeCompound( alvIORs ) +alvGOs = [] +alvGOs.append(subshapes[0]) +alvGOs.append(subshapes[1]) +alvGOs.append(subshapes[2]) +alvGOs.append(subshapes[3]) +alvGOs.append(subshapes[4]) +alvGOs.append(subshapes[5]) +alvcomp = geompy.MakeCompound(alvGOs) -boIOR = subshapes[6]._get_Name() -galIOR = subshapes[7]._get_Name() -gpeIOR = subshapes[8]._get_Name() +boGO = subshapes[6] +galGO = subshapes[7] +gpeGO = subshapes[8] -gallery = geompy.MakeCompound( [ boIOR, alvcomp._get_Name(), gpeIOR, galIOR ] ) +gallery = geompy.MakeCompound([boGO, alvcomp, gpeGO, galGO]) geompy.addToStudy(gallery,"Gallery 2") diff --git a/src/GEOM_SWIG/GEOM_Spanner.py b/src/GEOM_SWIG/GEOM_Spanner.py new file mode 100644 index 000000000..fd08520ac --- /dev/null +++ b/src/GEOM_SWIG/GEOM_Spanner.py @@ -0,0 +1,533 @@ +# GEOM GEOM_SWIG : binding of C++ implementaion with Python +# +# Copyright (C) 2003 CEA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org or email : webmaster.salome@opencascade.org +# +# +# +# File : GEOM_Spanner.py +# Author : Julia DOROVSKIKH +# 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): + + ### Variables ### + + th = 4.0 + + ### BlocksOp ### + + BlocksOp = geompy.BlocksOp + + ### Basic points and directions ### + + p0 = geompy.MakeVertex(0., 0., 0.) + pth = geompy.MakeVertex(0., 0., th) + + vx = geompy.MakeVectorDXDYDZ(1., 0., 0.) + vy = geompy.MakeVectorDXDYDZ(0., 1., 0.) + vz = geompy.MakeVectorDXDYDZ(0., 0., 1.) + + vxy = geompy.MakeVectorDXDYDZ(1., 1., 0.) + + ### Block 1 ### + + p_10_0 = geompy.MakeVertex(10., 0., 0.) + p_10_25 = geompy.MakeVertex(10., 25., 0.) + p_0_35 = geompy.MakeVertex( 0., 35., 0.) + p_0_10 = geompy.MakeVertex( 0., 10., 0.) + + Face11 = geompy.MakeQuad4Vertices(p_10_0, p_10_25, p_0_10, p_0_35); + id_face11 = geompy.addToStudy(Face11, "1 Face for Block 1") + + Face12 = geompy.MakeTranslationTwoPoints(Face11, p0, pth) + id_face12 = geompy.addToStudy(Face12, "2 Face for Block 1") + + Block1 = geompy.MakeHexa2Faces(Face11, Face12) + id_block1 = geompy.addToStudy(Block1, "Block 1") + + ### Block 2 ### + + p_15_0 = geompy.MakeVertex(15., 0., 0.) + p_15_20 = geompy.MakeVertex(15., 20., 0.) + + 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() + id_edge22 = geompy.addToStudy(Edge22, "2 Edge for Block 2") + + Face21 = geompy.MakeQuad2Edges(Edge21, Edge22); + id_face21 = geompy.addToStudy(Face21, "1 Face for Block 2") + + Face22 = geompy.MakeTranslationTwoPoints(Face21, p0, pth) + id_face22 = geompy.addToStudy(Face22, "2 Face for Block 2") + + Block2 = geompy.MakeHexa2Faces(Face21, Face22) + id_block2 = geompy.addToStudy(Block2, "Block 2") + + ### Block 3 ### + + p_15_10_1 = geompy.MakeVertex(15., 10., 1.) + + Face31 = GetFaceNearPoint(geompy, Block2, p_15_10_1) + id_face31 = geompy.addToStudy(Face31, "1 Face for Block 3") + + Prism1 = geompy.MakePrismVecH(Face31, vx, 5); + id_prism1 = geompy.addToStudy(Prism1, "Prism to be Block 3") + + nbFaces = geompy.ShapesOp.NumberOfFaces(Prism1) + if nbFaces == 6: + print "Prism 1 is a hexahedral solid" + else: + print "Prism 1 is not a hexahedral solid" + + Prism1_faces = geompy.SubShapeAllSorted(Prism1, geompy.ShapeType["FACE"]) + ii = 1 + for aFace in Prism1_faces: + name = geompy.SubShapeName(aFace, Prism1) + Id_Face = geompy.addToStudyInFather(Prism1, aFace, name) + ii = ii + 1 + + Block3 = geompy.MakeHexa(Prism1_faces[0], Prism1_faces[1], + Prism1_faces[2], Prism1_faces[3], + Prism1_faces[4], Prism1_faces[5]); + id_block3 = geompy.addToStudy(Block3, "Block 3") + + ### Block 4 ### + + Face41 = GetOppositeFace(geompy, Block3, Face31) + id_face41 = geompy.addToStudy(Face41, "1 Face for Block 4") + + p_25_5 = geompy.MakeVertex(25., 5., 0.) + p_25_20 = geompy.MakeVertex(25., 20., 0.) + + Edge41 = geompy.MakeEdge(p_25_5, p_25_20) + id_edge41 = geompy.addToStudy(Edge41, "1 Edge for Block 4") + + p_25_5_2 = geompy.MakeVertex(25., 5., th) + p_25_20_2 = geompy.MakeVertex(25., 20., th) + + Edge42 = geompy.MakeEdge(p_25_5_2, p_25_20_2) + id_edge42 = geompy.addToStudy(Edge42, "2 Edge for Block 4") + + Edge43 = geompy.MakeEdge(p_25_5, p_25_5_2) + id_edge43 = geompy.addToStudy(Edge43, "3 Edge for Block 4") + + Edge44 = geompy.MakeEdge(p_25_20, p_25_20_2) + id_edge44 = geompy.addToStudy(Edge44, "4 Edge for Block 4") + + Face42 = geompy.MakeQuad(Edge41, Edge42, Edge43, Edge44) + id_face42 = geompy.addToStudy(Face42, "2 Face for Block 4") + + Block4 = geompy.MakeHexa2Faces(Face41, Face42) + id_block4 = geompy.addToStudy(Block4, "Block 4") + + ### Block 5 ### + + p_25_30 = geompy.MakeVertex(25., 30., 0.) + p_25_30_1 = geompy.MakeVertex(25., 30., 1) + axis_rot = geompy.MakeVector(p_25_30, p_25_30_1) + + Face51 = Face42 + Face52 = geompy.MakeRotation(Face51, axis_rot, math.pi/2.) + id_face52 = geompy.addToStudy(Face52, "2 Face for Block 5") + + Block5 = geompy.MakeHexa2Faces(Face51, Face52) + id_block5 = geompy.addToStudy(Block5, "Block 5") + + ### Compound of blocks 1 - 4 ### + + Comp1234 = geompy.MakeCompound([Block1, Block2, Block3, Block4]) + Glue1234 = geompy.MakeGlueFaces(Comp1234, 1e-5) + id_glue1234 = geompy.addToStudy(Glue1234, "Glue 1234") + + plane_mirror = geompy.MakePlane(p_25_30, vxy, 100.) + #id_plane_mirror = geompy.addToStudy(plane_mirror, "Plane for mirror") + + Mirror1 = geompy.MakeMirrorByPlane(Glue1234, plane_mirror) + id_mirror1 = geompy.addToStudy(Mirror1, "Mirror 1") + + ### The second end ### + + p_18_0 = geompy.MakeVertex(18., 0., 0.) + p_20_0 = geompy.MakeVertex(20., 0., 0.) + p_40_0 = geompy.MakeVertex(40., 0., 0.) + + Edge1s = geompy.MakeEdge(p_20_0, p_40_0) + id_edge1s = geompy.addToStudy(Edge1s, "1 Edge for Block 1s") + + Edge2s = geompy.MakeRotation(Edge1s, vz, math.pi/12.) + id_edge2s = geompy.addToStudy(Edge2s, "2 Edge for Block 1s") + + p_18_0_r = geompy.MakeRotation(p_18_0, vz, math.pi/24.) + p_20_0_r = geompy.MakeRotation(p_20_0, vz, math.pi/12.) + p_40_0_r = geompy.MakeRotation(p_40_0, vz, math.pi/12.) + + Edge3s = geompy.MakeEdge(p_40_0, p_40_0_r) + id_edge3s = geompy.addToStudy(Edge3s, "3 Edge for Block 1s") + + Edge4s = geompy.MakeArc(p_20_0, p_18_0_r, p_20_0_r) + id_edge4s = geompy.addToStudy(Edge4s, "4 Edge for Block 1s") + + Face1s = geompy.MakeQuad(Edge1s, Edge2s, Edge3s, Edge4s) + id_face1s = geompy.addToStudy(Face1s, "1 Face for Block 1s") + + Block1s = geompy.MakePrismVecH(Face1s, vz, th); + id_block1s = geompy.addToStudy(Block1s, "Block 1s") + + p_30_0_1 = geompy.MakeVertex(30., 0., 1.) + + Face2s = GetFaceNearPoint(geompy, Block1s, p_30_0_1) + id_face2s = geompy.addToStudy(Face2s, "2 Face of Block 1s") + + f2s_ind = geompy.LocalOp.GetSubShapeIndex(Block1s, Face2s) + + Block1s_tr1 = geompy.MakeMultiTransformation1D(Block1s, f2s_ind, 0, 24) + id_block1s_tr1 = geompy.addToStudy(Block1s_tr1, "Multi-transformed Block 1s") + + p_60_150_0 = geompy.MakeVertex(60., -150., 0.) + Gear = geompy.MakeTranslationTwoPoints(Block1s_tr1, p0, p_60_150_0) + id_gear = geompy.addToStudy(Gear, "Gear") + + ### Link two parts ### + + ### Linking Block 1 ### + + 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) + id_face11l = geompy.addToStudy(Face11l, "1 Face for Linking Block 1") + + Face12l = GetFaceNearPoint(geompy, Gear, p_55_110_1) + id_face12l = geompy.addToStudy(Face12l, "2 Face for Linking Block 1") + + Block1l = geompy.MakeHexa2Faces(Face11l, Face12l) + id_block1l = geompy.addToStudy(Block1l, "Linking Block 1") + + ### Linking Block 2 ### + + 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) + id_face21l = geompy.addToStudy(Face21l, "1 Face for Linking Block 2") + + Face22l = GetFaceNearPoint(geompy, Gear, p_45_110_1) + id_face22l = geompy.addToStudy(Face22l, "2 Face for Linking Block 2") + + Block2l = geompy.MakeHexa2Faces(Face21l, Face22l) + id_block2l = geompy.addToStudy(Block2l, "Linking Block 2") + + ### Linking Block 3 ### + + 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) + id_face31l = geompy.addToStudy(Face31l, "1 Face for Linking Block 3") + + Face32l = GetFaceNearPoint(geompy, Gear, p_65_110_1) + id_face32l = geompy.addToStudy(Face32l, "2 Face for Linking Block 3") + + Block3l = geompy.MakeHexa2Faces(Face31l, Face32l) + id_block3l = geompy.addToStudy(Block3l, "Linking Block 3") + + ### Handle ### + + CompLB = geompy.MakeCompound([Block1l, Block2l, Block3l]) + Handle = geompy.MakeGlueFaces(CompLB, 1e-5) + id_handle = geompy.addToStudy(Handle, "Handle") + + Block1h = GetBlockNearPoint(geompy, Handle, p_45_110_1) + id_block1h = geompy.addToStudyInFather(Handle, Block1h, "Block 1 of Handle") + + Block2h = GetBlockNearPoint(geompy, Handle, p_65_110_1) + id_block2h = geompy.addToStudyInFather(Handle, Block2h, "Block 2 of Handle") + + Face11h = GetFaceByNormale(geompy, Block1h, vx) + id_face11h = geompy.addToStudyInFather(Block1h, Face11h, "Face 1") + + Face12h = GetOppositeFace(geompy, Block1h, Face11h) + id_face12h = geompy.addToStudyInFather(Block1h, Face12h, "Face 2") + + Face21h = GetFaceByNormale(geompy, Block2h, vx) + id_face21h = geompy.addToStudyInFather(Block2h, Face21h, "Face 1") + + Face22h = GetOppositeFace(geompy, Block2h, Face21h) + id_face22h = geompy.addToStudyInFather(Block2h, Face22h, "Face 2") + + Block3h = BlocksOp.GetBlockByParts(Handle, [Face11h, Face21h]) + if BlocksOp.IsDone() == 0: + Block3h = BlocksOp.GetBlockByParts(Handle, [Face11h, Face22h]) + if BlocksOp.IsDone() == 0: + Block3h = BlocksOp.GetBlockByParts(Handle, [Face12h, Face21h]) + if BlocksOp.IsDone() == 0: + Block3h = BlocksOp.GetBlockByParts(Handle, [Face12h, Face22h]) + if BlocksOp.IsDone() == 0: + print "ERROR: BlocksOp.GetBlockByParts() failed : ", BlocksOp.GetErrorCode() + else: + id_block3h = geompy.addToStudyInFather(Handle, Block3h, "Block 3 of Handle") + + ### The whole shape ### + + CompALL = geompy.MakeCompound([Glue1234, Block5, Mirror1, Handle, Gear]) + Spanner = geompy.MakeGlueFaces(CompALL, 1e-5) + id_glueALL = geompy.addToStudy(Spanner, "The Spanner") + + ### Check the Spanner ### + + isCompOfBlocks6 = BlocksOp.IsCompoundOfBlocks(Spanner, 6, 6) + if isCompOfBlocks6 == 0: + print "Spanner is not a compound of hexahedral solids" + else: + print "Spanner is a compound of hexahedral solids" + + if isBlocksTest == 1: + + print "##################### Test More #####################" + + ### 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() + 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() + + for aBlock in Blocks_f4_sp: + name = geompy.SubShapeName(aBlock, Spanner) + Id_block = geompy.addToStudyInFather(Spanner, aBlock, name) + + f42_sp_ind = geompy.LocalOp.GetSubShapeIndex(aBlock, Face42_sp) + + Face_5_horiz = GetFaceByNormale(geompy, 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: + 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" + + ### Get one face of the Gear ### + + p_20_0_tr = geompy.MakeTranslationTwoPoints(p_20_0 , p0, p_60_150_0) + p_20_0_r_tr = geompy.MakeTranslationTwoPoints(p_20_0_r, p0, p_60_150_0) + 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() + id_face_g_1 = geompy.addToStudyInFather(Gear, Face_g_1, "Face of Gear by four points") + + edgesNb = geompy.ShapesOp.NumberOfEdges(Face_g_1) + print "Face of Gear has ", edgesNb, " edges" + + Face_g_1_tr = geompy.MakeTranslationTwoPoints(Face_g_1, p0, pth) + id_face_g_1_tr = geompy.addToStudyInFather(Gear, Face_g_1_tr, "Face of Gear by four points, translated") + + ### equivalent of Block1s, but made as block + + Block_new = geompy.MakeHexa2Faces(Face_g_1, Face_g_1_tr) + id_block_new = geompy.addToStudy(Block_new, "Block New") + + if isMeshTest == 1: + + print "##################### Build Mesh #####################" + + import StdMeshers + + # ---- 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) + 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) + id_facetop = geompy.addToStudyInFather(BlockMh, FaceTop, "Top Face") + + # ---- add long edges of the top face in study + + FaceTop_edges = geompy.SubShapeAllSorted(FaceTop, geompy.ShapeType["EDGE"]) + Edge1 = FaceTop_edges[0] + Edge2 = FaceTop_edges[3] + Id_Edge1 = geompy.addToStudyInFather(FaceTop, Edge1, "Edge 1") + Id_Edge2 = geompy.addToStudyInFather(FaceTop, Edge2, "Edge 2") + + # ---- launch SMESH + + smeshgui = None + if hasGUI == 1: + smeshgui = salome.ImportComponentGUI("SMESH") + smeshgui.Init(salome.myStudyId) + + print "-------------------------- create Hypothesis" + + print "-------------------------- NumberOfSegments" + + hypNbSeg3 = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so") + hypNbSeg3.SetNumberOfSegments(3) + print hypNbSeg3.GetName() + print hypNbSeg3.GetId() + print hypNbSeg3.GetNumberOfSegments() + + if hasGUI == 1: + idseg = salome.ObjectToID(hypNbSeg3) + smeshgui.SetName(idseg, "NumberOfSegments_3"); + + print "-------------------------- LocalLength" + + hypLen1 = smesh.CreateHypothesis("LocalLength", "libStdMeshersEngine.so") + hypLen1.SetLength(10) + print hypLen1.GetName() + print hypLen1.GetId() + print hypLen1.GetLength() + + if hasGUI == 1: + idlength = salome.ObjectToID(hypLen1) + smeshgui.SetName(idlength, "Local_Length_10"); + + print "-------------------------- Propagation" + + hypProp = smesh.CreateHypothesis("Propagation", "libStdMeshersEngine.so") + print hypProp.GetName() + print hypProp.GetId() + + if hasGUI == 1: + idprop = salome.ObjectToID(hypProp) + smeshgui.SetName(idprop, "Propagation hypothesis"); + + #print "-------------------------- NumberOfSegments" + # + #hypNbSeg15 = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so") + #hypNbSeg15.SetNumberOfSegments(15) + #print hypNbSeg15.GetName() + #print hypNbSeg15.GetId() + #print hypNbSeg15.GetNumberOfSegments() + # + #if hasGUI == 1: + # idseg15 = salome.ObjectToID(hypNbSeg15) + # smeshgui.SetName(idseg15, "NumberOfSegments_15"); + + print "-------------------------- Regular_1D" + + algoReg = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so") + listHyp = algoReg.GetCompatibleHypothesis() + for hyp in listHyp: + print hyp + print algoReg.GetName() + print algoReg.GetId() + + if hasGUI == 1: + idreg = salome.ObjectToID(algoReg) + smeshgui.SetName(idreg, "Regular_1D"); + + print "-------------------------- Quadrangle_2D" + + algoQuad = smesh.CreateHypothesis("Quadrangle_2D", "libStdMeshersEngine.so") + listHyp = algoQuad.GetCompatibleHypothesis() + for hyp in listHyp: + print hyp + print algoQuad.GetName() + print algoQuad.GetId() + + if hasGUI == 1: + idquad = salome.ObjectToID(algoQuad) + smeshgui.SetName(idquad, "Quadrangle_2D"); + + print "---- Init a Mesh with the Spanner" + + mesh = smesh.CreateMesh(Spanner) + if hasGUI == 1: + idmesh = salome.ObjectToID(mesh) + smeshgui.SetName(idmesh, "Meshed Spanner"); + + print "-------------------------- add hypothesis to Spanner" + + mesh.AddHypothesis(Spanner, algoReg) + mesh.AddHypothesis(Spanner, hypNbSeg3) + mesh.AddHypothesis(Spanner, algoQuad) + + print "-------------------------- add hypothesis to the Middle Block" + + submesh_bl = mesh.GetSubMesh(BlockMh, "SubMesh Middle Block") + mesh.AddHypothesis(BlockMh, hypLen1) + + print "-------------------------- add hypothesis to the long edges of the Top Face of the Middle Block" + + submesh_e1 = mesh.GetSubMesh(Edge1, "SubMesh Edge 1 of Top Face") + mesh.AddHypothesis(Edge1, hypProp) + #mesh.AddHypothesis(Edge1, hypNbSeg15) + + submesh_e2 = mesh.GetSubMesh(Edge2, "SubMesh Edge 2 of Top Face") + mesh.AddHypothesis(Edge2, hypProp) + #mesh.AddHypothesis(Edge2, hypNbSeg15) + + print "-------------------------- compute the mesh" + smesh.Compute(mesh, Spanner) + + print "Information about the Mesh:" + print "Number of nodes : ", mesh.NbNodes() + print "Number of edges : ", mesh.NbEdges() + print "Number of faces : ", mesh.NbFaces() + print "Number of triangles : ", mesh.NbTriangles() + print "Number of quadrangles : ", mesh.NbQuadrangles() + print "Number of volumes : ", mesh.NbVolumes() + print "Number of tetrahedrons: ", mesh.NbTetras() + + return Spanner diff --git a/src/GEOM_SWIG/GEOM_TestAll.py b/src/GEOM_SWIG/GEOM_TestAll.py new file mode 100644 index 000000000..4d24d8009 --- /dev/null +++ b/src/GEOM_SWIG/GEOM_TestAll.py @@ -0,0 +1,327 @@ +# GEOM GEOM_SWIG : binding of C++ omplementaion with Python +# +# Copyright (C) 2003 CEA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org or email : webmaster.salome@opencascade.org +# +# +# File : GEOM_usinggeom.py +# Author : Damien COQUERET, Open CASCADE +# Module : GEOM +# $Header$ + +def TestAll (geompy, math): + + #Create base Variables + nbtimes1 = 5 #Short + nbtimes2 = 5 + mindeg = 2 + maxdeg = 5 + nbiter = 5 + ShapeTypeFace = geompy.ShapeType["FACE"] + ShapeTypeEdge = geompy.ShapeType["EDGE"] + WantPlanarFace = 1 #True + + radius = 10. #Double + radius1 = 100. + radius2 = 200. + height = 200. + d1 = 10. + d2 = 10. + step1 = 250. + step2 = 250. + angle = 45. + angle1 = angle * math.pi / 180 + angle2 = 2 * angle1 + factor = 2. + tol3d = 0.0001 + tol2d = 0.0001 + weight = 1000000. + waterdensity = 1. + meshingdeflection = 0.01 + trimsize = 1000. + precision = 0.00001 + + #Create base points + p0 = geompy.MakeVertex(0. , 0. , 0. ) #(3 Doubles)->GEOM_Object_ptr + px = geompy.MakeVertex(100., 0. , 0. ) + py = geompy.MakeVertex(0. , 100., 0. ) + pz = geompy.MakeVertex(0. , 0. , 100.) + pxyz = geompy.MakeVertex(100., 100., 100.) + + p200 = geompy.MakeVertexWithRef(pxyz, 100., 100., 100.) #(GEOM_Object_ptr, 3 Doubles)->GEOM_Object_ptr + + #Create base directions + vx = geompy.MakeVector(p0, px) #(GEOM_Object_ptr, GEOM_Object_ptr)->GEOM_Object_ptr + vy = geompy.MakeVector(p0, py) + vz = geompy.MakeVector(p0, pz) + vxy = geompy.MakeVector(px, py) + + vxyz = geompy.MakeVectorDXDYDZ(100., 100., 100.) #(3 Doubles)->GEOM_Object_ptr + + #Create local coordinate systems + cs1 = geompy.MakeMarker(50,50,50, 1,0,0, 0,1,0) + cs2 = geompy.MakeMarker(70,80,10, 1,0,1, 1,1,0) + + #Create base geometry 2D + Line = geompy.MakeLineTwoPnt(p0, pxyz) #(2 GEOM_Object_ptr)->GEOM_Object_ptr + Line1 = geompy.MakeLine(pz, vxy) #(2 GEOM_Object_ptr)->GEOM_Object_ptr + Plane = geompy.MakePlane(pz, vxyz, trimsize) #(2 GEOM_Object_ptr, Double)->GEOM_Object_ptr + Plane1 = geompy.MakePlaneThreePnt(px, pz, p200, trimsize) #(4 Doubles)->GEOM_Object_ptr + + Arc = geompy.MakeArc(py, pz, px) #(3 GEOM_Object_ptr)->GEOM_Object_ptr + Circle = geompy.MakeCircle(p0, vz, radius1) #(2 GEOM_Object_ptr, Double)->GEOM_Object_ptr + Circle1 = geompy.MakeCircleThreePnt(p0, pxyz, px) #(3 GEOM_Object_ptr)->GEOM_Object_ptr + Ellipse = geompy.MakeEllipse(p0, vy, radius2, radius1) #(2 GEOM_Object_ptr, 2 Doubles)->GEOM_Object_ptr + Polyline = geompy.MakePolyline([p0, pz, py, p200]) #(List of GEOM_Object_ptr)->GEOM_Object_ptr + Bezier = geompy.MakeBezier([p0, pz, p200, px]) #(List of GEOM_Object_ptr)->GEOM_Object_ptr + Interpol = geompy.MakeInterpol([px, py, p200, pxyz]) #(List of GEOM_Object_ptr)->GEOM_Object_ptr + Sketcher = geompy.MakeSketcher("Sketcher:F -100 -100:TT 250 -100:R 0:C 100 150:R 0:L 300:WW", + [100,0,0, 1,1,1, -1,1,0]) #(String, List of Doubles)->GEOM_Object_ptr + + #Test point on curve creation + p_on_arc = geompy.MakeVertexOnCurve(Arc, 0.25) #(GEOM_Object_ptr, Double)->GEOM_Object_ptr + + #Create base geometry 3D + Box = geompy.MakeBoxTwoPnt(p0, p200) #(2 GEOM_Object_ptr)->GEOM_Object_ptr + Box1 = geompy.MakeBoxDXDYDZ(10, 20, 30) #(3 Doubles)->GEOM_Object_ptr + Box2 = geompy.MakeBox(10,20,30, 15,25,35) #(6 Doubles)->GEOM_Object_ptr + Cylinder = geompy.MakeCylinder(p0, vz, radius1, height) #(2 GEOM_Object_ptr, 2 Doubles)->GEOM_Object_ptr + Cyl1 = geompy.MakeCylinderRH(radius2, height) #(2 Doubles)->GEOM_Object_ptr + Sphere = geompy.MakeSpherePntR(p0, radius1) #(GEOM_Object_ptr, Double)->GEOM_Object_ptr + Sphere1 = geompy.MakeSphereR(radius) #(Double)->GEOM_Object_ptr + Sphere2 = geompy.MakeSphere(50, 70, 30, radius) #(4 Doubles)->GEOM_Object_ptr + Cone = geompy.MakeCone(p0, vz, radius2, radius, height) #(2 GEOM_Object_ptr, 3 Doubles)->GEOM_Object_ptr + Cone1 = geompy.MakeConeR1R2H(radius1, radius, height) #(3 Doubles)->GEOM_Object_ptr + Torus = geompy.MakeTorus(p0, vz, radius2, radius) #(2 GEOM_Object_ptr, 2 Doubles)->GEOM_Object_ptr + Torus1 = geompy.MakeTorusRR(radius2, radius1) #(2 Doubles)->GEOM_Object_ptr + + #Boolean (Common, Cut, Fuse, Section) + Common = geompy.MakeBoolean(Box, Sphere, 1) #(2 GEOM_Object_ptr, Short)->GEOM_Object_ptr + Cut = geompy.MakeBoolean(Box, Sphere, 2) + Fuse = geompy.MakeBoolean(Box, Sphere, 3) + Section = geompy.MakeBoolean(Box, Sphere, 4) + + #Create base objects + Edge = geompy.MakeEdge(p0, pxyz) #(2 GEOM_Object_ptr)->GEOM_Object_ptr + Wire = geompy.MakeWire([vxy, Arc]) #(List Of GEOM_Object_ptr)->GEOM_Object_ptr + Face = geompy.MakeFace(Wire, WantPlanarFace) #(GEOM_Object_ptr, Boolean)->GEOM_Object_ptr + Face1 = geompy.MakeFaceWires([Wire, Sketcher], + WantPlanarFace) #(List of GEOM_Object_ptr, Boolean)->GEOM_Object_ptr + Face2 = geompy.MakeFace(Sketcher, WantPlanarFace) + Shell = geompy.MakeShell([Face, Face1]) #(List of GEOM_Object_ptr)->GEOM_Object_ptr + + Prism1 = geompy.MakePrism(Face2, p0, pxyz) #(3 GEOM_Object_ptr)->GEOM_Object_ptr + prism1_faces = geompy.SubShapeAllSorted(Prism1, ShapeTypeFace) + Shell1 = geompy.MakeShell([prism1_faces[0], prism1_faces[1], + prism1_faces[3], prism1_faces[4], + prism1_faces[5], prism1_faces[2]]) + Solid = geompy.MakeSolid([Shell1]) #(List of GEOM_Object_ptr)->GEOM_Object_ptr + + ShapeListCompound = [] + i = 0 + while i <= 3 : + S = geompy.MakeTranslation(Arc, i * 100., i * 100., i * 100.) + ShapeListCompound.append(S) + i = i + 1 + Compound = geompy.MakeCompound(ShapeListCompound) #(List of GEOM_Object_ptr)->GEOM_Object_ptr + + # Test plane from existing face creation + Plane2 = geompy.MakePlaneFace(Face, trimsize) #(GEOM_Object_ptr, Double)->GEOM_Object_ptr + + #ShapeList for Sewing + S = geompy.MakeRotation(Face, vxy, angle1) + + #Create advanced objects + Copy = geompy.MakeCopy(Box) #(GEOM_Object_ptr)->GEOM_Object_ptr + Prism = geompy.MakePrismVecH(Face, vz, 100.0) #(2 GEOM_Object_ptr, Double)->GEOM_Object_ptr + Revolution = geompy.MakeRevolution(Face, vz, angle2) # + Filling = geompy.MakeFilling(Compound, mindeg, maxdeg, + tol2d, tol3d, nbiter) #(GEOM_Object_ptr, 4 Doubles, Short)->GEOM_Object_ptr + Pipe = geompy.MakePipe(Wire, Edge) #(2 GEOM_Object_ptr)->GEOM_Object_ptr + Sewing = geompy.MakeSewing([Face, S], precision) #(List Of GEOM_Object_ptr, Double)->GEOM_Object_ptr + + #Transform objects + Translation = geompy.MakeTranslationTwoPoints(Box, px, pz) #(3 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 + 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) + + #IDList for Fillet/Chamfer + prism_edges = geompy.SubShapeAllSorted(Prism, ShapeTypeEdge) + + for anEdge in prism_edges: + eid = geompy.GetSubShapeID(Prism, anEdge) + sse = geompy.GetSubShape(Prism, [eid]) + + sse_id = geompy.GetSubShapeID(Prism, sse) + if sse_id != eid: + print "Error: GetSubShape() or GetSubShapeID() has failed!" + + IDlist_e = [] + IDlist_e.append(geompy.GetSubShapeID(Prism, prism_edges[0])) + IDlist_e.append(geompy.GetSubShapeID(Prism, prism_edges[1])) + IDlist_e.append(geompy.GetSubShapeID(Prism, prism_edges[2])) + + prism_faces = geompy.SubShapeAllSorted(Prism, ShapeTypeFace) + + f_ind_1 = geompy.GetSubShapeID(Prism, prism_faces[0]) + f_ind_2 = geompy.GetSubShapeID(Prism, prism_faces[1]) + + IDlist_f = [f_ind_1, f_ind_2] + + #Local operations + Fillet = geompy.MakeFillet (Prism, radius, ShapeTypeEdge, + IDlist_e) #(GEOM_Object_ptr, Double, Short, ListOfLong)->GEOM_Object_ptr + Chamfer = geompy.MakeChamferEdge(Prism, d1, d2, + f_ind_1, f_ind_2) #(GEOM_Object_ptr, 2 Doubles, 2 Long)->GEOM_Object_ptr + Chamfer2 = geompy.MakeChamferFaces(Prism, d1, d2, + IDlist_f) #(GEOM_Object_ptr, 2 Doubles, ListOfLong)->GEOM_Object_ptr + + #Create Patterns + MultiTrans1D = geompy.MakeMultiTranslation1D(Fillet, vz, step1, nbtimes1) + MultiTrans2D = geompy.MakeMultiTranslation2D(Fillet, vz, step1, nbtimes1, vy, step2, nbtimes2) + #!!!!Angle In Degree!!!! + MultiRot1D = geompy.MultiRotate1D(Chamfer, vx, nbtimes1) + MultiRot2D = geompy.MultiRotate2D(Chamfer, vx, angle, nbtimes1, step1, nbtimes2) + + #Create Informations objects + CDG = geompy.MakeCDG(Prism) #(GEOM_Object_ptr)->GEOM_Object_ptr + Archimede = geompy.Archimede(Box, weight, waterdensity, + meshingdeflection) #(GEOM_Object_ptr, 3 Doubles)->GEOM_Object_ptr + CheckShape = geompy.CheckShape(Prism) #(GEOM_Object_ptr)->Boolean + print "CheckShape(Prism) = ", CheckShape + + #Partition objects + Partition = geompy.MakePartition([Box], [Plane]) #(2 Lists Of GEOM_Object_ptr)->GEOM_Object_ptr + + #Add In Study + + id_p0 = geompy.addToStudy(p0, "Vertex 0") + id_px = geompy.addToStudy(px, "Vertex X") + id_py = geompy.addToStudy(py, "Vertex Y") + id_pz = geompy.addToStudy(pz, "Vertex Z") + id_pxyz = geompy.addToStudy(pxyz, "Vertex XYZ") + id_p200 = geompy.addToStudy(p200, "Vertex 200") + + id_vx = geompy.addToStudy(vx, "Vector X") + id_vy = geompy.addToStudy(vy, "Vector Y") + id_vz = geompy.addToStudy(vz, "Vector Z") + id_vxy = geompy.addToStudy(vxy, "Vector XY") + id_vxyz = geompy.addToStudy(vxyz, "Vector XYZ") + + id_cs1 = geompy.addToStudy(cs1, "CS 50,50,50, 1,0,0, 0,1,0") + id_cs2 = geompy.addToStudy(cs2, "CS 70,80,10, 1,0,1, 1,1,0") + + id_Line = geompy.addToStudy(Line, "Line") + id_Line1 = geompy.addToStudy(Line1, "Line by point and vector") + id_Plane = geompy.addToStudy(Plane, "Plane") + id_Plane1 = geompy.addToStudy(Plane1, "Plane by 3 points") + + id_Arc = geompy.addToStudy(Arc, "Arc") + id_Circle = geompy.addToStudy(Circle, "Circle") + id_Circle1 = geompy.addToStudy(Circle1, "Circle by 3 points") + id_Ellipse = geompy.addToStudy(Ellipse, "Ellipse") + id_Polyline = geompy.addToStudy(Polyline, "Polyline") + id_Bezier = geompy.addToStudy(Bezier, "Bezier") + id_Interpol = geompy.addToStudy(Interpol, "Interpol") + id_Sketcher = geompy.addToStudy(Sketcher, "Sketcher") + + id_p_on_arc = geompy.addToStudy(p_on_arc, "Vertex on Arc") + + id_Box = geompy.addToStudy(Box, "Box") + id_Box1 = geompy.addToStudy(Box1, "Box 10x20x30") + id_Box2 = geompy.addToStudy(Box2, "Box (10,20,30)-(15,25,35)") + id_Cylinder = geompy.addToStudy(Cylinder, "Cylinder") + id_Cyl1 = geompy.addToStudy(Cyl1, "Cylinder RH") + id_Sphere = geompy.addToStudy(Sphere, "Sphere Pnt R") + id_Sphere1 = geompy.addToStudy(Sphere1, "Sphere R") + id_Sphere2 = geompy.addToStudy(Sphere2, "Sphere") + id_Cone = geompy.addToStudy(Cone, "Cone") + id_Cone1 = geompy.addToStudy(Cone1, "Cone R1R2H") + id_Torus = geompy.addToStudy(Torus, "Torus") + id_Torus1 = geompy.addToStudy(Torus1, "Torus RR") + + id_Common = geompy.addToStudy(Common, "Common") + id_Cut = geompy.addToStudy(Cut, "Cut") + id_Fuse = geompy.addToStudy(Fuse, "Fuse") + id_Section = geompy.addToStudy(Section, "Section") + + id_Edge = geompy.addToStudy(Edge, "Edge") + id_Wire = geompy.addToStudy(Wire, "Wire") + id_Face = geompy.addToStudy(Face, "Face") + id_Face1 = geompy.addToStudy(Face1, "Face from two wires") + id_Face2 = geompy.addToStudy(Face2, "Face from Sketcher") + id_Shell = geompy.addToStudy(Shell, "Shell") + + id_Prism1 = geompy.addToStudy(Prism1, "Prism by Two Pnt") + id_Shell1 = geompy.addToStudy(Shell1, "Shell from Prism1 faces") + id_Solid = geompy.addToStudy(Solid, "Solid") + id_Compound = geompy.addToStudy(Compound, "Compound") + + id_Plane2 = geompy.addToStudy(Plane2, "Plane on Face") + + id_Copy = geompy.addToStudy(Copy, "Copy") + id_Prism = geompy.addToStudy(Prism, "Prism") + id_Revolution = geompy.addToStudy(Revolution, "Revolution") + id_Filling = geompy.addToStudy(Filling, "Filling") + id_Pipe = geompy.addToStudy(Pipe, "Pipe") + id_Sewing = geompy.addToStudy(Sewing, "Sewing") + + id_Translation = geompy.addToStudy(Translation, "Translation") + id_Rotation = geompy.addToStudy(Rotation, "Rotation") + id_Scale = geompy.addToStudy(Scale, "Scale") + id_Mirror = geompy.addToStudy(Mirror, "Mirror") + id_Position = geompy.addToStudy(Position, "Positioned box") + id_Offset = geompy.addToStudy(Offset, "Offset") + id_Orientation = geompy.addToStudy(Orientation, "Orientation") + + id_Fillet = geompy.addToStudy(Fillet, "Fillet") + id_Chamfer = geompy.addToStudy(Chamfer, "Chamfer on Edge") + id_Chamfer2 = geompy.addToStudy(Chamfer2, "Chamfer on Faces") + + id_MultiTrans1D = geompy.addToStudy(MultiTrans1D, "MultiTrans1D") + id_MultiTrans2D = geompy.addToStudy(MultiTrans2D, "MultiTrans2D") + id_MultiRot1D = geompy.addToStudy(MultiRot1D, "MultiRot1D") + id_MultiRot2D = geompy.addToStudy(MultiRot2D, "MultiRot2D") + + id_CDG = geompy.addToStudy(CDG, "CDG") + id_Archimede = geompy.addToStudy(Archimede, "Archimede") + + id_Partition = geompy.addToStudy(Partition, "Partition") + + #Decompose objects + SubFace = geompy.SubShape(Box, geompy.ShapeType["FACE"], [2]) + name = geompy.SubShapeName(SubFace, Box) + id_SubFace = geompy.addToStudyInFather(Box, SubFace, name) + + SubFaceS = geompy.SubShapeSorted(Box, geompy.ShapeType["FACE"], [5]) + nameS = geompy.SubShapeName(SubFaceS, Box) + id_SubFace = geompy.addToStudyInFather(Box, SubFaceS, nameS) + + SubEdgeList = geompy.SubShapeAll(SubFace, geompy.ShapeType["EDGE"]) + i=0 + for SubEdge in SubEdgeList : + name = geompy.SubShapeName(SubEdge, SubFace) + id_SubEdge = geompy.addToStudyInFather(SubFace, SubEdge, name) + + #------------------- + + print "DONE" diff --git a/src/GEOM_SWIG/GEOM_TestHealing.py b/src/GEOM_SWIG/GEOM_TestHealing.py new file mode 100644 index 000000000..4ad4a1ca3 --- /dev/null +++ b/src/GEOM_SWIG/GEOM_TestHealing.py @@ -0,0 +1,331 @@ +# GEOM GEOM_SWIG : binding of C++ implementaion with Python +# +# Copyright (C) 2003 CEA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org or email : webmaster.salome@opencascade.org +# +# +# File : GEOM_TestHealing.py +# Author : Julia DOROVSKIKH +# Module : GEOM +# $Header$ + +def TestProcessShape (geompy): + + ##Load shape from BREP file + #import os + #datadir = os.getenv("GEOM_TEST") + #if datadir != 0: + # datadir = datadir + "/Resources/" + #else: + # "Please, define GEOM_TEST variable !" + # + #print "Import ", datadir + "aze2.brep" + #Shape = batchmode_geompy.Import(datadir + "aze2.brep", "BREP") + + p1 = geompy.MakeVertex(0,0,0) + p2 = geompy.MakeVertex(200,0,0) + p3 = geompy.MakeVertex(100,150,0) + + edge = geompy.MakeEdge(p1,p2) + arc = geompy.MakeArc(p1,p3,p2) + wire = geompy.MakeWire([edge,arc]) + face = geompy.MakeFace(wire, 1) + + theShape = geompy.MakePrismVecH(face, edge, 130) + + #Check shape + print "Before ProcessShape:" + isValid = geompy.CheckShape(theShape) + if isValid == 0: + print "The shape is not valid" + else: + print "The shape seems to be valid" + + #Process Shape + Operators = ["FixShape"] + Parameters = ["FixShape.Tolerance3d"] + Values = ["1e-7"] + + PS = geompy.ProcessShape(theShape, Operators, Parameters, Values) + + #Check shape + print "After ProcessShape:" + isValid = geompy.CheckShape(PS) + if isValid == 0: + print "The shape is not valid" + raise RuntimeError, "It seems, that the ProcessShape() has failed" + else: + print "The shape seems to be valid" + + #Add In Study + Id_Shape = geompy.addToStudy(theShape, "Invalid Shape") + Id_PS = geompy.addToStudy(PS, "Processed Shape") + +def TestSuppressFaces (geompy): + + #Create base geometry 3D + Box = geompy.MakeBoxDXDYDZ(200., 200., 200.) + + #IDList for SuppHole + faces = [] + faces = geompy.SubShapeAllSorted(Box, geompy.ShapeType["FACE"]) + + f_glob_id = geompy.GetSubShapeID(Box, faces[5]) + + #Transform objects + SuppFace = geompy.SuppressFaces(Box, [f_glob_id]) + + #Add In Study + Id_SuppFace = geompy.addToStudy(SuppFace, "SuppFace") + +def TestSuppressInternalWires (geompy): + + #Create Face with hole + p11 = geompy.MakeVertex( 0, 0, 0) + p12 = geompy.MakeVertex(30, 0, 0) + p13 = geompy.MakeVertex(30, 30, 0) + p14 = geompy.MakeVertex( 0, 30, 0) + + p21 = geompy.MakeVertex(10, 10, 0) + p22 = geompy.MakeVertex(20, 10, 0) + p23 = geompy.MakeVertex(20, 20, 0) + p24 = geompy.MakeVertex(10, 20, 0) + + e11 = geompy.MakeEdge(p11, p12) + e12 = geompy.MakeEdge(p12, p13) + e13 = geompy.MakeEdge(p13, p14) + e14 = geompy.MakeEdge(p14, p11) + + e21 = geompy.MakeEdge(p21, p22) + e22 = geompy.MakeEdge(p22, p23) + e23 = geompy.MakeEdge(p23, p24) + e24 = geompy.MakeEdge(p24, p21) + + w1 = geompy.MakeWire([e11, e12, e13, e14]) + w2 = geompy.MakeWire([e21, e22, e23, e24]) + + id_w1 = geompy.addToStudy(w1, "Outside Wire") + id_w2 = geompy.addToStudy(w2, "Inside Wire") + + f12 = geompy.MakeFaceWires([w1, w2], 0) + id_f12 = geompy.addToStudy(f12, "Face WO + WI") + + #Get Free Boundary + Res1 = geompy.GetFreeBoundary(f12) + isSuccess1 = Res1[0] + ClosedWires1 = Res1[1] + OpenWires1 = Res1[2] + nbw1 = 0 + + for wire in ClosedWires1: + nbw1 = nbw1 + 1 + + if nbw1 != 2: + raise RuntimeError, "GetFreeBoundary(f12) must return 2 closed wires, but returned ", nbw1 + + #SuppressInternalWires + face = geompy.SuppressInternalWires(f12, []) + + #Get Free Boundary + Res2 = geompy.GetFreeBoundary(face) + isSuccess2 = Res2[0] + ClosedWires2 = Res2[1] + OpenWires2 = Res2[2] + nbw2 = 0 + + for wire in ClosedWires2: + nbw2 = nbw2 + 1 + + if nbw2 != 1: + print "GetFreeBoundary(face) must return 1 closed wires, but returned ", nbw2 + raise RuntimeError, "SuppressInternalWires() works not correctly" + + #Add In Study + Id_face = geompy.addToStudy(face, "Face without internal wires") + +def TestCloseContour (geompy): + + ##Load shape from BREP file + #import os + #datadir = os.getenv("GEOM_TEST") + #if datadir != 0: + # datadir = datadir + "/Resources/" + #else: + # "Please, define GEOM_TEST variable !" + # + #print "Import ", datadir + "open_cont.brep" + #Shape = geompy.Import(datadir + "open_cont.brep", "BREP") + + p0 = geompy.MakeVertex(0. , 0. , 0. ) + py = geompy.MakeVertex(0. , 100., 0. ) + pz = geompy.MakeVertex(0. , 0. , 100.) + p200 = geompy.MakeVertex(200., 200., 200.) + + Shape = geompy.MakePolyline([p0, pz, py, p200]) + + #Check shape + print "Before closing contour:" + isValid = geompy.CheckShape(Shape) + if isValid == 0: + print "The shape is not valid" + else: + print "The shape seems to be valid" + + #Close Contour + IsCommonVertex = 0 # false + + shape_wires = geompy.SubShapeAll(Shape, geompy.ShapeType["WIRE"]) + Wires = [] + wi = 0 + + for wire in shape_wires: + Wires.append(geompy.GetSubShapeID(Shape, shape_wires[wi])) + wi = wi + 1 + + CC = geompy.CloseContour(Shape, Wires, IsCommonVertex) + + #Check shape + print "After closing contour:" + isValid = geompy.CheckShape(CC) + if isValid == 0: + print "The shape is not valid" + raise RuntimeError, "It seems, that the contour was not closed" + else: + print "The shape seems to be valid" + + #Add In Study + Id_Shape = geompy.addToStudy(Shape, "Shape with open wire") + Id_CC = geompy.addToStudy(CC, "Shape with closed wire") + +def TestSuppressHoles (geompy): + + #Create base Variables + radius = 50. + height = 300. + + #Create base points + p1 = geompy.MakeVertex(100., 100., 50.) + + #Create base directions + vz = geompy.MakeVectorDXDYDZ(0., 0., 100.) + + #Create base geometry 3D + Box = geompy.MakeBoxDXDYDZ(200., 200., 200.) + Cylinder = geompy.MakeCylinder(p1, vz, radius, height) + + #Boolean (Cut) + Cut = geompy.MakeBoolean(Box, Cylinder, 2) + idCut = geompy.addToStudy(Cut, "CUT") + + #IDList for SuppressFaces + faces = [] + faces = geompy.SubShapeAllSorted(Cut, geompy.ShapeType["FACE"]) + ind = 0 + for face in faces: + f_name = "FACE %d"%(ind) + f_id = geompy.addToStudyInFather(Cut, face, f_name) + + f_glob_id = geompy.GetSubShapeID(Cut, face) + print "face ", ind, " global index = ", f_glob_id + ind = ind + 1 + + f_glob_id_0 = geompy.GetSubShapeID(Cut, faces[0]) + cut_without_f_0 = geompy.SuppressFaces(Cut, [f_glob_id_0]) + + faces1 = [] + faces1 = geompy.SubShapeAllSorted(cut_without_f_0, geompy.ShapeType["FACE"]) + ind = 0 + for face in faces1: + f_name = "FACE %d"%(ind) + f_id = geompy.addToStudyInFather(cut_without_f_0, face, f_name) + + f_glob_id = geompy.GetSubShapeID(cut_without_f_0, face) + print "face ", ind, " global index = ", f_glob_id + ind = ind + 1 + + f_glob_id_5 = geompy.GetSubShapeID(cut_without_f_0, faces1[5]) + cut_without_f_0_5 = geompy.SuppressFaces(cut_without_f_0, [f_glob_id_5]) + cut_without_f_0_5_id = geompy.addToStudy(cut_without_f_0_5, "Cut without faces 0 and 5") + + #IDList for SuppHole + wires = [] + wires = geompy.SubShapeAllSorted(cut_without_f_0_5, geompy.ShapeType["WIRE"]) + ind = 0 + for wire in wires: + w_name = "WIRE %d"%(ind) + w_id = geompy.addToStudyInFather(cut_without_f_0_5, wire, w_name) + + w_glob_id = geompy.GetSubShapeID(cut_without_f_0_5, wire) + print "wire ", ind, " global index = ", w_glob_id + ind = ind + 1 + + w_3 = geompy.GetSubShapeID(cut_without_f_0_5, wires[3]) + + SuppHole3 = geompy.SuppressHoles(cut_without_f_0_5, [w_3]) + SuppHole3_id = geompy.addToStudy(SuppHole3, "Supp Hole 3") + +def TestMakeSewing (geompy, math): + + #Create base points + px = geompy.MakeVertex(100., 0., 0.) + py = geompy.MakeVertex(0., 100., 0.) + pz = geompy.MakeVertex(0., 0., 100.) + + #Create base geometry 2D & 3D + Vector = geompy.MakeVector(px, py) + Arc = geompy.MakeArc(py, pz, px) + + #Create base objects + angle = 45. * math.pi / 180 + WantPlanarFace = 1 #True + + Wire = geompy.MakeWire([Vector, Arc]) + Face = geompy.MakeFace(Wire, WantPlanarFace) + S = geompy.MakeRotation(Face, Vector, angle) + + #Make Sewing + precision = 0.00001 + Sewing = geompy.MakeSewing([Face, S], precision) + + #Add In Study + id_Sewing = geompy.addToStudy(Sewing, "Sewing") + +def TestDivideEdge (geompy): + + #Create Box + Box = geompy.MakeBoxDXDYDZ(200., 200., 200.) + + #Divide Edge + box_edges = geompy.SubShapeAllSorted(Box, geompy.ShapeType["EDGE"]) + edge_ind = geompy.GetSubShapeID(Box, box_edges[1]) + + Divide = geompy.DivideEdge(Box, edge_ind, 0.5, 1) # Obj, ind, param, is_curve_param + + #Add In Study + Id_Box = geompy.addToStudy(Box, "Box") + Id_Divide = geompy.addToStudy(Divide, "Box with Divided Edge") + +def TestHealingOperations (geompy, math): + + TestMakeSewing(geompy, math) + TestDivideEdge(geompy) + TestSuppressHoles(geompy) + TestSuppressInternalWires(geompy) + TestCloseContour(geompy) + TestSuppressFaces(geompy) + TestProcessShape(geompy) diff --git a/src/GEOM_SWIG/GEOM_TestMeasures.py b/src/GEOM_SWIG/GEOM_TestMeasures.py new file mode 100644 index 000000000..53604ea18 --- /dev/null +++ b/src/GEOM_SWIG/GEOM_TestMeasures.py @@ -0,0 +1,102 @@ +def TestMeasureOperations (geompy, math): + + p0 = geompy.MakeVertex(0 , 0, 0) + p137 = geompy.MakeVertex(10, 30, 70) + + box = geompy.MakeBoxTwoPnt(p0, p137) + + p678 = geompy.MakeVertex(60, 70, 80) + p789 = geompy.MakeVertex(70, 80, 90) + + cube = geompy.MakeBoxTwoPnt(p678, p789) + + ####### PointCoordinates ####### + + Coords = geompy.PointCoordinates(p137) + if Coords[0] != 10 or Coords[1] != 30 or Coords[2] != 70: + print "Coordinates of p137 must be (10, 30, 70), but returned (", Coords[0], ", ", Coords[1], ", ", Coords[2], ")" + + ####### CheckShape ####### + + IsValid = geompy.CheckShape(box) + if IsValid == 0: + raise RuntimeError, "Invalid box created" + else: + print "\nBox is valid" + + ####### WhatIs ####### + + Descr = geompy.WhatIs(box) + print "\nBox 10x30x70 description:" + print Descr + + ####### BasicProperties ####### + + Props = geompy.BasicProperties(box) + print "\nBox 10x30x70 Basic Properties:" + print " Wires length: ", Props[0] + print " Surface area: ", Props[1] + print " Volume : ", Props[2] + + dl = math.sqrt((Props[0] - 880)*(Props[0] - 880)) + da = math.sqrt((Props[1] - 6200)*(Props[1] - 6200)) + dv = math.sqrt((Props[2] - 21000)*(Props[2] - 21000)) + #print "|Props[0] - 880| = ", dl + + if dl > 1e-7 or da > 1e-7 or dv > 1e-7: + print "While must be:" + print " Wires length: ", 880 + print " Surface area: ", 6200 + print " Volume : ", 21000 + + ####### BoundingBox ####### + + BB = geompy.BoundingBox(box) + print "\nBounding Box of box 10x30x70:" + print " Xmin = ", BB[0], ", Xmax = ", BB[1] + print " Ymin = ", BB[2], ", Ymax = ", BB[3] + print " Zmin = ", BB[4], ", Zmax = ", BB[5] + + ####### Inertia ####### + + In = geompy.Inertia(box) + print "\nInertia matrix of box 10x30x70:" + print " (", In[0], ", ", In[1], ", ", In[2], ")" + print " (", In[3], ", ", In[4], ", ", In[5], ")" + print " (", In[6], ", ", In[7], ", ", In[8], ")" + print "Main moments of inertia of box 10x30x70:" + print " Ix = ", In[9], ", Iy = ", In[10], ", Iz = ", In[11] + + ####### Tolerance ####### + + Toler = geompy.Tolerance(box) + print "\nBox 10x30x70 tolerance:" + print " Face min. tolerance: ", Toler[0] + print " Face max. tolerance: ", Toler[1] + print " Edge min. tolerance: ", Toler[2] + print " Edge max. tolerance: ", Toler[3] + print " Vertex min. tolerance: ", Toler[4] + print " Vertex max. tolerance: ", Toler[5] + + ####### MakeCDG ####### + + pcdg = geompy.MakeCDG(box) + if pcdg is None: + raise RuntimeError, "MakeCDG(box) failed" + else: + print "\nCentre of gravity of box has been successfully obtained:" + Coords = geompy.PointCoordinates(pcdg) + print "(", Coords[0], ", ", Coords[1], ", ", Coords[2], ")" + if Coords[0] != 5 or Coords[1] != 15 or Coords[2] != 35: + print "But must be (5, 15, 35)" + + ####### MinDistance ####### + + MinDist = geompy.MinDistance(box, cube) + + #print "\nMinimal distance between Box and Cube = ", MinDist[0] + #print "It is reached at points:" + #print " On Box (", MinDist[1], ", ", MinDist[2], ", ", MinDist[3], ")" + #print " On Cube (", MinDist[4], ", ", MinDist[5], ", ", MinDist[6], ")" + + print "\nMinimal distance between Box and Cube = ", MinDist diff --git a/src/GEOM_SWIG/GEOM_TestOthers.py b/src/GEOM_SWIG/GEOM_TestOthers.py new file mode 100644 index 000000000..9ef7d1e5e --- /dev/null +++ b/src/GEOM_SWIG/GEOM_TestOthers.py @@ -0,0 +1,209 @@ +# GEOM GEOM_SWIG : binding of C++ implementaion with Python +# +# Copyright (C) 2003 CEA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org or email : webmaster.salome@opencascade.org +# +# +# File : GEOM_TestOthers.py +# Author : Julia DOROVSKIKH +# Module : GEOM +# $Header$ + +def TestOtherOperations (geompy, math, BATCHMODE = None): + + # MakeFaces + p11 = geompy.MakeVertex( 0, 0, 0) + p12 = geompy.MakeVertex(30, 0, 0) + p13 = geompy.MakeVertex(30, 30, 0) + p14 = geompy.MakeVertex( 0, 30, 0) + + p21 = geompy.MakeVertex(10, 10, 0) + p22 = geompy.MakeVertex(20, 10, 0) + p23 = geompy.MakeVertex(20, 20, 0) + p24 = geompy.MakeVertex(10, 20, 0) + + e11 = geompy.MakeEdge(p11, p12) + e12 = geompy.MakeEdge(p12, p13) + e13 = geompy.MakeEdge(p13, p14) + e14 = geompy.MakeEdge(p14, p11) + + e21 = geompy.MakeEdge(p21, p22) + e22 = geompy.MakeEdge(p22, p23) + e23 = geompy.MakeEdge(p23, p24) + e24 = geompy.MakeEdge(p24, p21) + + w1 = geompy.MakeWire([e11, e12, e13, e14]) + w2 = geompy.MakeWire([e21, e22, e23, e24]) + w3 = geompy.MakeTranslation(w2, 0, 0, 10) + + id_w1 = geompy.addToStudy(w1, "Outside Wire") + id_w2 = geompy.addToStudy(w2, "Inside Wire") + id_w3 = geompy.addToStudy(w3, "Inside Wire, translated along OZ") + + f12 = geompy.MakeFaces([w1, w2], 0) + id_f12 = geompy.addToStudy(f12, "MakeFaces WO + WI") + + # OrientationChange + Box = geompy.MakeBoxDXDYDZ(200, 200, 200) + Orientation = geompy.OrientationChange(Box) + id_Orientation = geompy.addToStudy(Orientation, "OrientationChange") + + # MakeCommon, MakeCut, MakeFuse, MakeSection + Sphere = geompy.MakeSphereR(100) + + Common = geompy.MakeCommon (Box, Sphere) + Cut = geompy.MakeCut (Box, Sphere) + Fuse = geompy.MakeFuse (Box, Sphere) + Section = geompy.MakeSection(Box, Sphere) + + id_Common = geompy.addToStudy(Common, "Common") + id_Cut = geompy.addToStudy(Cut, "Cut") + id_Fuse = geompy.addToStudy(Fuse, "Fuse") + id_Section = geompy.addToStudy(Section, "Section") + + # Partition + p100 = geompy.MakeVertex(100, 100, 100) + p300 = geompy.MakeVertex(300, 300, 300) + Box1 = geompy.MakeBoxTwoPnt(p100, p300) + Partition = geompy.Partition([Box], [Box1], [], [Box]) + id_Partition = geompy.addToStudy(Partition, "Partition of Box by Box1") + + # MakeMultiRotation1D, MakeMultiRotation2D + pz = geompy.MakeVertex(0, 0, 100) + vy = geompy.MakeVectorDXDYDZ(0, 100, 0) + + MultiRot1D = geompy.MakeMultiRotation1D(f12, vy, pz, 6) + MultiRot2D = geompy.MakeMultiRotation2D(f12, vy, pz, 45, 6, 30, 3) + + id_MultiRot1D = geompy.addToStudy(MultiRot1D, "MakeMultiRotation1D") + id_MultiRot2D = geompy.addToStudy(MultiRot2D, "MakeMultiRotation2D") + + # MakeFilletAll + radius_fillet = 10. + face5 = geompy.SubShapeSorted(Box, geompy.ShapeType["FACE"], [5]) + f_glob_id = geompy.GetSubShapeID(Box, face5) + SuppFace = geompy.SuppressFaces(Box, [f_glob_id]) + + MakeFilletAll = geompy.MakeFilletAll(SuppFace, radius_fillet) + id_MakeFilletAll = geompy.addToStudy(MakeFilletAll, "MakeFilletAll") + + # MakeChamferAll + dimension_chamfer = 10. + MakeChamferAll = geompy.MakeChamferAll(SuppFace, dimension_chamfer) + id_MakeChamferAll = geompy.addToStudy(MakeChamferAll, "MakeChamferAll") + + # MakeChamfer + d1 = 13. + d2 = 7. + box_faces = geompy.SubShapeAllSorted(Box, geompy.ShapeType["FACE"]) + f_ind_1 = geompy.GetSubShapeID(Box, box_faces[0]) + f_ind_2 = geompy.GetSubShapeID(Box, box_faces[1]) + f_ind_3 = geompy.GetSubShapeID(Box, box_faces[2]) + + MakeChamfer = geompy.MakeChamfer(Box, d1, d2, geompy.ShapeType["FACE"], + [f_ind_1, f_ind_2, f_ind_3]) + id_MakeChamfer = geompy.addToStudy(MakeChamfer, "MakeChamfer") + + # Export + geompy.Export(f12, "/tmp/testExportImport.brep", "BREP") + + # ExportBREP, ExportIGES, ExportSTEP + if BATCHMODE is not None: + geompy.Export(f12, "/tmp/testExportImportBREP.brep","BREP") + geompy.Export(f12, "/tmp/testExportImportIGES.iges","IGES") + geompy.Export(f12, "/tmp/testExportImportSTEP.step","STEP") + else: + geompy.ExportBREP(f12, "/tmp/testExportImportBREP.brep") + geompy.ExportIGES(f12, "/tmp/testExportImportIGES.iges") + geompy.ExportSTEP(f12, "/tmp/testExportImportSTEP.step") + + # Import + Import = geompy.Import("/tmp/testExportImport.brep", "BREP") + + id_Import = geompy.addToStudy(Import, "Import") + + # ImportBREP, ImportIGES, ImportSTEP + if BATCHMODE is not None: + ImportBREP = geompy.Import("/tmp/testExportImportBREP.brep","BREP") + ImportIGES = geompy.Import("/tmp/testExportImportIGES.iges","IGES") + ImportSTEP = geompy.Import("/tmp/testExportImportSTEP.step","STEP") + else: + ImportBREP = geompy.ImportBREP("/tmp/testExportImportBREP.brep") + ImportIGES = geompy.ImportIGES("/tmp/testExportImportIGES.iges") + ImportSTEP = geompy.ImportSTEP("/tmp/testExportImportSTEP.step") + + id_ImportBREP = geompy.addToStudy(ImportBREP, "ImportBREP") + id_ImportIGES = geompy.addToStudy(ImportIGES, "ImportIGES") + id_ImportSTEP = geompy.addToStudy(ImportSTEP, "ImportSTEP") + + # MakeBlockExplode + Compound = geompy.MakeCompound([Box, Sphere]) + MakeBlockExplode = geompy.MakeBlockExplode(Compound, 6, 6) + + id_MakeBlockExplode = geompy.addToStudy(MakeBlockExplode[0], "MakeBlockExplode") + + # CheckCompoundOfBlocks + p1 = geompy.MakeVertex(200, 0, 0) + p2 = geompy.MakeVertex(400, 200, 200) + p3 = geompy.MakeVertex(400, 50, 50) + p4 = geompy.MakeVertex(600, 250, 250) + + Box2 = geompy.MakeBoxTwoPnt(p1, p2) + Box3 = geompy.MakeBoxTwoPnt(p3, p4) + Cyl = geompy.MakeCylinderRH(50, 300) + Cone = geompy.MakeConeR1R2H(150, 10, 400) + + Compound1 = geompy.MakeCompound([Box, Cyl, Cone, Box3, Box2]) + + IsValid = geompy.CheckCompoundOfBlocks(Compound1) + if IsValid == 0: + print "The Blocks Compound is NOT VALID" + else: + print "The Blocks Compound is VALID" + + IsValid = geompy.CheckCompoundOfBlocks(Box) + if IsValid == 0: + print "The Box is NOT VALID" + else: + print "The Box is VALID" + + # test geometrical groups + + # CreateGroup + CreateGroup = geompy.CreateGroup(Box, geompy.ShapeType["FACE"]) + + id_CreateGroup = geompy.addToStudy(CreateGroup, "CreateGroup") + + # AddObject + f_ind_4 = geompy.GetSubShapeID(Box, box_faces[3]) + f_ind_5 = geompy.GetSubShapeID(Box, box_faces[4]) + f_ind_6 = geompy.GetSubShapeID(Box, box_faces[5]) + + geompy.AddObject(CreateGroup, f_ind_6) + geompy.AddObject(CreateGroup, f_ind_1) + geompy.AddObject(CreateGroup, f_ind_4) + + # RemoveObject(theGroup, theSubShapeID) + geompy.RemoveObject(CreateGroup, f_ind_1) + + # GetObjectIDs + GetObjectIDs = geompy.GetObjectIDs(CreateGroup) + + print "Group of Box's faces includes the following IDs:" + for ObjectID in GetObjectIDs: + print " ", ObjectID diff --git a/src/GEOM_SWIG/GEOM_blocks.py b/src/GEOM_SWIG/GEOM_blocks.py new file mode 100644 index 000000000..fca4d3fb6 --- /dev/null +++ b/src/GEOM_SWIG/GEOM_blocks.py @@ -0,0 +1,41 @@ +# GEOM GEOM_SWIG : binding of C++ implementaion with Python +# +# Copyright (C) 2003 CEA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org or email : webmaster.salome@opencascade.org +# +# +# +# File : GEOM_blocks.py +# Author : Julia DOROVSKIKH +# Module : GEOM +# $Header$ + +import salome +import geompy +import math + +import GEOM_Spanner + +isBlocksTest = 0 # False +isMeshTest = 0 # False + +smesh = None + +GEOM_Spanner.MakeSpanner(salome, geompy, math, isBlocksTest, isMeshTest, smesh) + +salome.sg.updateObjBrowser(1); diff --git a/src/GEOM_SWIG/GEOM_example.py b/src/GEOM_SWIG/GEOM_example.py index e293a3e57..6feb7b453 100644 --- a/src/GEOM_SWIG/GEOM_example.py +++ b/src/GEOM_SWIG/GEOM_example.py @@ -39,9 +39,16 @@ while ind < 5: y2 = 20. * (ind+1) z2 = 30. * (ind+1) print x1, y1, z1, x2, y2, z2 + + point1 = geompy.MakeVertex(x1, y1, z1) + name1 = "point1_%d"%(ind) + id_pt1 = geompy.addToStudy(point1, name1) + point2 = geompy.MakeVertex(x2, y2, z2) + name2 = "point2_%d"%(ind) + id_pt2 = geompy.addToStudy(point2, name2) + name = "box%d"%(ind) - box = geompy.MakeBox(x1, y1, z1, x2, y2, z2) + box = geompy.MakeBoxTwoPnt(point1, point2) id_box = geompy.addToStudy(box, name) boxlist.append(box) - ind = ind +1 - + ind = ind + 1 diff --git a/src/GEOM_SWIG/GEOM_example2.py b/src/GEOM_SWIG/GEOM_example2.py index 147e6a4c7..87ae39ddc 100644 --- a/src/GEOM_SWIG/GEOM_example2.py +++ b/src/GEOM_SWIG/GEOM_example2.py @@ -33,32 +33,36 @@ import math geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM") myBuilder = salome.myStudy.NewBuilder() -point0 = geom.MakePointStruct(0.,0.,0.) -pointz1 = geom.MakePointStruct(0.,0.,1.) -dirz = geom.MakeDirection(pointz1) +BasicOp = geom.GetIBasicOperations(salome.myStudyId) +PrimOp = geom.GetI3DPrimOperations(salome.myStudyId) +InsertOp = geom.GetIInsertOperations(salome.myStudyId) +TrsfOp = geom.GetITransformOperations(salome.myStudyId) -torus1 = geompy.MakeTorus(point0,dirz,150.,25.) +point0 = BasicOp.MakePointXYZ(0.,0.,0.) +pointz1 = BasicOp.MakePointXYZ(0.,0.,1.) +dirz = BasicOp.MakeVectorTwoPnt(point0,pointz1) + +torus1 = PrimOp.MakeTorusPntVecRR(point0,dirz,150.,25.) id_torus1 = geompy.addToStudy(torus1,"torus1") -torus2 = geom.MakeCopy(torus1) -torus2 = geom.MakeTranslation(torus2,0.,0.,100.) +torus2 = InsertOp.MakeCopy(torus1) + +vec1 = BasicOp.MakeVectorDXDYDZ(0.,0.,100.) +torus2 = TrsfOp.TranslateVectorCopy(torus2,vec1) id_torus2 = geompy.addToStudy(torus2,"torus2") -cylz1 = geompy.MakeCylinder(point0,dirz,25.,100.) +cylz1 = PrimOp.MakeCylinderPntVecRH(point0,dirz,25.,100.) ind = 0 cyllist = [] while ind < 6: - acyl = geom.MakeCopy(cylz1) + acyl = InsertOp.MakeCopy(cylz1) x = 150. * math.cos(ind * math.pi/3.) y = 150. * math.sin(ind * math.pi/3.) z = 0. + vec_i = BasicOp.MakeVectorDXDYDZ(x,y,z) name = "cyl%d"%(ind) - acyl = geompy.MakeTranslation(acyl,x,y,z) + acyl = TrsfOp.TranslateVectorCopy(acyl,vec_i) id_acyl = geompy.addToStudy(acyl,name) cyllist.append(acyl) - ind = ind +1 - - - - + ind = ind + 1 diff --git a/src/GEOM_SWIG/GEOM_example3.py b/src/GEOM_SWIG/GEOM_example3.py index e98ecd11d..1287f6853 100644 --- a/src/GEOM_SWIG/GEOM_example3.py +++ b/src/GEOM_SWIG/GEOM_example3.py @@ -36,31 +36,39 @@ myBuilder = salome.myStudy.NewBuilder() gg = salome.ImportComponentGUI("GEOM") -point0 = geom.MakePointStruct(0.,0.,0.) -pointz1 = geom.MakePointStruct(0.,0.,1.) -dirz = geom.MakeDirection(pointz1) +BasicOp = geom.GetIBasicOperations(salome.myStudyId) +PrimOp = geom.GetI3DPrimOperations(salome.myStudyId) +InsertOp = geom.GetIInsertOperations(salome.myStudyId) +TrsfOp = geom.GetITransformOperations(salome.myStudyId) -torus1 = geompy.MakeTorus(point0,dirz,150.,25.) +point0 = BasicOp.MakePointXYZ(0.,0.,0.) +pointz1 = BasicOp.MakePointXYZ(0.,0.,1.) +dirz = BasicOp.MakeVectorTwoPnt(point0,pointz1) + +torus1 = PrimOp.MakeTorusPntVecRR(point0,dirz,150.,25.) id_torus1 = geompy.addToStudy(torus1,"torus1") gg.createAndDisplayGO(id_torus1) -torus2 = geom.MakeCopy(torus1) -torus2 = geom.MakeTranslation(torus2,0.,0.,100.) +torus2 = InsertOp.MakeCopy(torus1) + +vec1 = BasicOp.MakeVectorDXDYDZ(0.,0.,100.) +torus2 = TrsfOp.TranslateVectorCopy(torus2,vec1) id_torus2 = geompy.addToStudy(torus2,"torus2") gg.createAndDisplayGO(id_torus2) -cylz1 = geompy.MakeCylinder(point0,dirz,25.,100.) +cylz1 = PrimOp.MakeCylinderPntVecRH(point0,dirz,25.,100.) ind = 0 shapeList = [] idList = [] while ind < 6: - acyl = geom.MakeCopy(cylz1) + acyl = InsertOp.MakeCopy(cylz1) x = 150. * math.cos(ind * math.pi/3.) y = 150. * math.sin(ind * math.pi/3.) z = 0. + vec_i = BasicOp.MakeVectorDXDYDZ(x,y,z) name = "cyl%d"%(ind) - acyl = geompy.MakeTranslation(acyl,x,y,z) + acyl = TrsfOp.TranslateVectorCopy(acyl,vec_i) id_acyl = geompy.addToStudy(acyl,name) gg.createAndDisplayGO(id_acyl) shapeList.append(acyl) @@ -72,11 +80,7 @@ shapeList.append(torus2) idList.append(id_torus1) idList.append(id_torus2) -iorStringList = [] -for shape in shapeList: - iorStringList.append(shape._get_Name()) - -cage = geompy.MakeCompound(iorStringList) +cage = geompy.MakeCompound(shapeList) id_cage = geompy.addToStudy(cage,"cage") gg.createAndDisplayGO(id_cage) diff --git a/src/GEOM_SWIG/GEOM_example4.py b/src/GEOM_SWIG/GEOM_example4.py index 7d50005a5..631ef13ca 100755 --- a/src/GEOM_SWIG/GEOM_example4.py +++ b/src/GEOM_SWIG/GEOM_example4.py @@ -24,12 +24,11 @@ # File : GEOM_example4.py # Module : GEOM -import SMESH -import smeshpy +#import SMESH +#import smeshpy import salome from salome import sg import math -#import SMESH_BasicHypothesis_idl import geompy @@ -37,8 +36,8 @@ geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM") myBuilder = salome.myStudy.NewBuilder() from geompy import gg -smeshgui = salome.ImportComponentGUI("SMESH") -smeshgui.Init(salome.myStudyId); +#smeshgui = salome.ImportComponentGUI("SMESH") +#smeshgui.Init(salome.myStudyId); ShapeTypeCompSolid = 1 ShapeTypeSolid = 2 @@ -69,24 +68,17 @@ rc2=150 rc3=150 rc4=300 # --------------------------------------------- -point_0 = geom.MakePointStruct(0, 0, 0) -point_z = geom.MakePointStruct(0, 0, 1) +point_0 = geompy.MakeVertex(0, 0, 0) +point_z = geompy.MakeVertex(0, 0, 1) -point_a = geom.MakePointStruct(xa, ya, za) -point_b = geom.MakePointStruct(xb, yb, zb) -point_c = geom.MakePointStruct(xc, yc, zc) +point_a = geompy.MakeVertex(xa, ya, za) +point_b = geompy.MakeVertex(xb, yb, zb) +point_c = geompy.MakeVertex(xc, yc, zc) -dir_z = geom.MakeDirection(point_z) -axe_z = geom.MakeAxisStruct(0, 0, 0, 0, 0, 1) - -dir_a = geom.MakeDirection(point_a) -axe_a = geom.MakeAxisStruct(0, 0, 0, xa, ya, za) - -dir_b = geom.MakeDirection(point_b) -axe_b = geom.MakeAxisStruct(0, 0, 0, xb, yb, zb) - -dir_c = geom.MakeDirection(point_c) -axe_c = geom.MakeAxisStruct(0, 0, 0, xc, yc, zc) +dir_z = geompy.MakeVector(point_0,point_z) +dir_a = geompy.MakeVector(point_0,point_a) +dir_b = geompy.MakeVector(point_0,point_b) +dir_c = geompy.MakeVector(point_0,point_c) cyl_1 = geompy.MakeCylinder(point_0, dir_z, rc1, hc1) @@ -100,7 +92,7 @@ cyl_b = geompy.MakeTranslation(cyl_t, -1.2*rc1, -0.1*rc1, -0.5*hc1) hc4=2*hc1 cyl_t = geompy.MakeCylinder(point_0, dir_c, rc4, hc4) -cyl_t = geompy.MakeRotation(cyl_t, axe_c, pi/2) +cyl_t = geompy.MakeRotation(cyl_t, dir_c, pi/2) cyl_c = geompy.MakeTranslation(cyl_t, -hc1, 0, 0) cyl_d = geompy.MakeTranslation(cyl_t, -hc1, 0, 1.3*rc4) diff --git a/src/GEOM_SWIG/GEOM_example5.py b/src/GEOM_SWIG/GEOM_example5.py new file mode 100644 index 000000000..c26239ba4 --- /dev/null +++ b/src/GEOM_SWIG/GEOM_example5.py @@ -0,0 +1,54 @@ +# GEOM GEOM_SWIG : binding of C++ omplementaion with Python +# +# 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 : GEOM_example5.py +# Author : Damien COQUERET, Open CASCADE +# Module : GEOM +# $Header$ + +import salome +import geompy + +geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM") + +#Create Points +BasicOp = geom.GetIBasicOperations(salome.myStudyId) +Vertex1 = BasicOp.MakePointXYZ(0., 0., 0.) +Vertex2 = BasicOp.MakePointXYZ(100., 20., 30.) +Vertex3 = BasicOp.MakePointXYZ(150., 100., -25.) +Vertex4 = BasicOp.MakePointXYZ(40., -80., 79.) + +#GEOM_Objects List for Splines +GOList = [] +GOList.append(Vertex1) +GOList.append(Vertex2) +GOList.append(Vertex3) +GOList.append(Vertex4) + +#Create Splines +Bezier = geompy.MakeBezier(GOList) +Interpol = geompy.MakeInterpol(GOList) + +#Add In Study +id_Bezier = geompy.addToStudy(Bezier, "Bezier") +id_Interpol = geompy.addToStudy(Interpol, "Interpol") diff --git a/src/GEOM_SWIG/GEOM_moteur.py b/src/GEOM_SWIG/GEOM_moteur.py index 2e8e30ed4..dfe87ae27 100644 --- a/src/GEOM_SWIG/GEOM_moteur.py +++ b/src/GEOM_SWIG/GEOM_moteur.py @@ -1,23 +1,23 @@ # GEOM GEOM_SWIG : binding of C++ omplementaion with Python # # 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 +# 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 # # # @@ -40,7 +40,7 @@ PosZ = 0 NbBranches = 7 #>2 HauteurT = 70 #Hauteur total du stator -#Varaibles +#Variables Angle1 = 2 * math.pi / NbBranches Angle2 = Angle1 / 2 HauteurR = HauteurT / 3 @@ -56,30 +56,32 @@ PosCour = PosZ + HauteurT * 4 / 7 PosRot = PosZ + 0.9 * HauteurT #Points -P0 = geom.MakePointStruct(0, 0, 1) -P1 = geom.MakePointStruct(PosX, PosY, PosZ) -P2 = geom.MakePointStruct(PosX, PosY, PosZ + Ep) -P3 = geom.MakePointStruct(PosX, PosY, PosCour) -P4 = geom.MakePointStruct(PosX, PosY, PosCour + Ep) -P5 = geom.MakePointStruct(PosX, PosY, PosRot) -P6 = geom.MakePointStruct(Pos1C, Pos1S, PosZ) -P7 = geom.MakePointStruct(PosX + DExtExt, Pos1S, PosZ) -P8 = geom.MakePointStruct(Pos1C, Pos1S, PosZ + HauteurT) +BasicOp = geom.GetIBasicOperations(salome.myStudyId) +OO = BasicOp.MakePointXYZ(0, 0, 0) +P0 = BasicOp.MakePointXYZ(0, 0, 1) +P1 = BasicOp.MakePointXYZ(PosX, PosY, PosZ) +P2 = BasicOp.MakePointXYZ(PosX, PosY, PosZ + Ep) +P3 = BasicOp.MakePointXYZ(PosX, PosY, PosCour) +P4 = BasicOp.MakePointXYZ(PosX, PosY, PosCour + Ep) +P5 = BasicOp.MakePointXYZ(PosX, PosY, PosRot) +P6 = BasicOp.MakePointXYZ(Pos1C, Pos1S, PosZ) +P7 = BasicOp.MakePointXYZ(PosX + DExtExt, Pos1S, PosZ) +P8 = BasicOp.MakePointXYZ(Pos1C, Pos1S, PosZ + HauteurT) #Vecteurs -V1 = geom.MakeDirection(P0) -V2 = geom.MakeAxisStruct(PosX, PosY, PosZ, 0, 0, 1) -V3 = geom.MakeAxisStruct(Pos1C, Pos1S, PosZ, 0, 0, 1) +V1 = BasicOp.MakeVectorTwoPnt(OO,P0) +V2 = BasicOp.MakeVectorTwoPnt(P1,P2) +V3 = BasicOp.MakeVectorTwoPnt(P6,P8) #Cylindre central -C0 = geompy.MakeCylinder(P1, V1, DIntInt, PosCour + Ep - PosZ) +C0 = geompy.MakeCylinder(P1, V1, DIntInt, PosCour + Ep - PosZ) C01 = geompy.MakeCylinder(P1, V1, DIntExt, PosCour + Ep - PosZ) Cylindre = geompy.MakeBoolean(C01, C0, 2) #Id_Cyl = geompy.addToStudy(Cylindre, "Cylindre") #Camemberts de coupe -B1 = geompy.MakeVector(P6, P7) -B2 = geompy.MakePrism(B1, P6, P8) +B1 = BasicOp.MakeVectorTwoPnt(P6, P7) +B2 = geompy.MakePrismVecH(B1, V1, HauteurT) S0 = geompy.MakeRevolution(B2, V3, Angle1) CoupeList = [] CoupeList.append(S0) @@ -88,10 +90,7 @@ while Ind < NbBranches : S = geompy.MakeRotation(S0, V2, Ind * Angle1) CoupeList.append(S) Ind = Ind + 1 -IorCoupeList = [] -for CoupeShape in CoupeList : - IorCoupeList.append(CoupeShape._get_Name()) -Coupe1 = geompy.MakeCompound(IorCoupeList) +Coupe1 = geompy.MakeCompound(CoupeList) #Id_Coupe1 = geompy.addToStudy(Coupe1, "Coupe1") #Couronne1 @@ -117,10 +116,7 @@ C10 = geompy.MakeCylinder(P5, V1, DIntExt / 4, 2 * HauteurR) Rotor1List = [] Rotor1List.append(C9) Rotor1List.append(C10) -IorRotor1List = [] -for Rotor1Shape in Rotor1List : - IorRotor1List.append(Rotor1Shape._get_Name()) -Rotor1 = geompy.MakeCompound(IorRotor1List) +Rotor1 = geompy.MakeCompound(Rotor1List) Id_Rotor1 = geompy.addToStudy(Rotor1, "Rotor1") #Rotor2 @@ -132,10 +128,7 @@ while Ind < NbBranches : R = geompy.MakeRotation(D0, V2, Ind * Angle1) Rotor2List.append(R) Ind = Ind + 1 -IorRotor2List = [] -for Rotor2Shape in Rotor2List : - IorRotor2List.append(Rotor2Shape._get_Name()) -Rotor2 = geompy.MakeCompound(IorRotor2List) +Rotor2 = geompy.MakeCompound(Rotor2List) Id_Rotor2 = geompy.addToStudy(Rotor2, "Rotor2") #Rotor3 @@ -147,8 +140,5 @@ StatorList = [] StatorList.append(Cylindre) StatorList.append(Couronne1) StatorList.append(Couronne2) -IorStatorList = [] -for StatorShape in StatorList : - IorStatorList.append(StatorShape._get_Name()) -Stator = geompy.MakeCompound(IorStatorList) +Stator = geompy.MakeCompound(StatorList) Id_Stator = geompy.addToStudy(Stator, "Stator") diff --git a/src/GEOM_SWIG/GEOM_usinggeom.py b/src/GEOM_SWIG/GEOM_usinggeom.py index 976526928..08fdc0864 100644 --- a/src/GEOM_SWIG/GEOM_usinggeom.py +++ b/src/GEOM_SWIG/GEOM_usinggeom.py @@ -1,23 +1,23 @@ # GEOM GEOM_SWIG : binding of C++ omplementaion with Python # # 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 +# 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 # # # @@ -26,227 +26,15 @@ # Module : GEOM # $Header$ -import salome import geompy import math -geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM") -myBuilder = salome.myStudy.NewBuilder() - -from geompy import gg - -#Create base Variables -nbtimes1 = 5 #Short -nbtimes2 = 5 -mindeg = 2 -maxdeg = 5 -nbiter = 5 -ShapeTypeFace = 4 -ShapeTypeEdge = 6 -WantPlanarFace = 1 #True - -radius = 10. #Double -radius1 = 100. -radius2 = 200. -height = 200. -d1 = 10. -d2 = 10. -step1 = 250. -step2 = 250. -angle = 45. -angle1 = angle * math.pi / 180 -angle2 = 2 * angle1 -factor = 2. -tol3d = 0.0001 -tol2d = 0.0001 -weight = 1000000. -waterdensity = 1. -meshingdeflection = 0.01 -trimsize = 1000. -precision = 0.00001 - -#Create base points -p0 = geom.MakePointStruct(0., 0., 0.) #(Double, Double, Double)->PointStruct -px = geom.MakePointStruct(100., 0., 0.) -py = geom.MakePointStruct(0., 100., 0.) -pz = geom.MakePointStruct(0., 0., 100.) -pxyz = geom.MakePointStruct(100., 100., 100.) - -#Create base directions -vx = geom.MakeDirection(px) #(PointStruct)->DirStruct -vy = geom.MakeDirection(py) -vz = geom.MakeDirection(pz) -vxyz = geom.MakeDirection(pxyz) -ax = geom.MakeAxisStruct(0., 0., 0., 100., 0., 0.) #(Double, Double, Double, Double, Double, Double)->AxisStruct -axy = geom.MakeAxisStruct(100., 0., 0., -100., 100., 0.) -ay = geom.MakeAxisStruct(0., 0., 0., 0., 100., 0.) -az = geom.MakeAxisStruct(0., 0., 0., 0., 0., 100.) - -#Create base geometry 2D -Vertex = geom.MakeVertex(100., 50., 200.) #(Double, Double, Double)->GEOM_Shape_ptr -Vector = geom.MakeVector(px, py) #(PointStruct, PointStruct)->GEOM_Shape_ptr -Line = geom.MakeLine(p0, vxyz) #(PointStruct, DirStruct)->GEOM_Shape_ptr -Arc = geom.MakeArc(py, pz, px) #(PointStruct, PointStruct, PointStruct)->GEOM_Shape_ptr -Circle = geom.MakeCircle(p0, vz, radius1) #(PointStruct, DirStruct, Double)->GEOM_Shape_ptr -Plane = geom.MakePlane(pz, vxyz, trimsize) #(PointStruct, DirStruct, Double)->GEOM_Shape_ptr - -#Create base geometry 3D -Box = geompy.MakeBox(0., 0., 0., 200., 200., 200.) #(Double, Double, Double)->GEOM_Shape_ptr -Cylinder = geompy.MakeCylinder(p0, vz, radius1, height) #(Double, Double, Double)->GEOM_Shape_ptr -Sphere = geompy.MakeSphere(0., 0., 0., radius1) #(Double, Double, Double)->GEOM_Shape_ptr -Cone = geompy.MakeCone(p0, vz, radius2, radius, height) #(PointStruct)->DirStruct -Torus = geompy.MakeTorus(p0, vz, radius2, radius) #(Double, Double, Double)->GEOM_Shape_ptr - -#Boolean (Common, Cut, Fuse, Section) -Common = geompy.MakeBoolean(Box, Sphere, 1) #(GEOM_Shape_ptr, GEOM_Shape_ptr, Short)->GEOM_Shape_ptr -Cut = geompy.MakeBoolean(Box, Sphere, 2) -Fuse = geompy.MakeBoolean(Box, Sphere, 3) -Section = geompy.MakeBoolean(Box, Sphere, 4) - -#IORList for Wire -ShapeListWire = [] -IORListWire = [] -ShapeListWire.append(Vector) -ShapeListWire.append(Arc) -for Shape in ShapeListWire : - IORListWire.append(Shape._get_Name()) - -#IORList for Compound -ShapeListCompound = [] -IORListCompound = [] -i = 0 -while i <= 3 : - S = geompy.MakeTranslation(Arc, i * 100., i * 100., i * 100.) - ShapeListCompound.append(S) - i = i + 1 -for Shape in ShapeListCompound : - IORListCompound.append(Shape._get_Name()) - -#Create base objects -Edge = geompy.MakeEdge(p0, pxyz) #(PointStruct, PointStruct)->GEOM_Shape_ptr -Wire = geompy.MakeWire(IORListWire) #(ListOfIOR)->GEOM_Shape_ptr -Face = geompy.MakeFace(Wire, WantPlanarFace) #(GEOM_Shape_ptr, Boolean)->GEOM_Shape_ptr -Compound = geompy.MakeCompound(IORListCompound) #(ListOfIOR)->GEOM_Shape_ptr - -#IORList for Sewing -ShapeListSewing = [] -IORListSewing = [] -ShapeListSewing.append(Face) -S = geompy.MakeRotation(Face, axy, angle1) -ShapeListSewing.append(S) -for Shape in ShapeListSewing : - IORListSewing.append(Shape._get_Name()) - -#Create advanced objects -Copy = geompy.MakeCopy(Box) #(GEOM_Shape_ptr)->GEOM_Shape_ptr -Prism = geompy.MakePrism(Face, p0, pz) #(GEOM_Shape_ptr, PointStruct, PointStruct)->GEOM_Shape_ptr -#Revolution = geompy.MakeRevolution(Face, az, angle2) #(GEOM_Shape_ptr, AxisStruct, Double)->GEOM_Shape_ptr -Filling = geompy.MakeFilling(Compound, mindeg, maxdeg, tol3d, tol2d, nbiter) #(GEOM_Shape_ptr, Short, Short, Double, Double, Short)->GEOM_Shape_ptr -Pipe = geompy.MakePipe(Edge, Wire) #(GEOM_Shape_ptr, GEOM_Shape_ptr)->GEOM_Shape_ptr -Sewing = geompy.MakeSewing(IORListSewing, precision) #(ListOfIOR, Double)->GEOM_Shape_ptr - -#IDList for Fillet/Chamfer -IDlist = [] -i = 1 -while i <= 3 : - IDlist.append(i) - i = i + 1 - -#Transform objects -Translation = geompy.MakeTranslation(Box, 300., 300., 300.) #(GEOM_Shape_ptr, Double, Double, Double)->GEOM_Shape_ptr -Rotation = geompy.MakeRotation(Box, az, angle1) #(GEOM_Shape_ptr, AxisStruct, Double)->GEOM_Shape_ptr -Scale = geompy.MakeScaleTransform(Box, p0, factor) #(GEOM_Shape_ptr, PointStruct, Double)->GEOM_Shape_ptr -Mirror = geompy.MakeMirrorByPlane(Box, Plane) #(GEOM_Shape_ptr, GEOM_Shape_ptr)->GEOM_Shape_ptr -Orientation = geompy.OrientationChange(Box) #(GEOM_Shape_ptr)->GEOM_Shape_ptr -Fillet = geompy.MakeFillet (Prism, radius, ShapeTypeEdge, IDlist) #(GEOM_Shape_ptr, Double, Short, ListOfSubShapeID)->GEOM_Shape_ptr -Chamfer = geompy.MakeChamfer(Prism, d1, d2, ShapeTypeEdge, IDlist) #(GEOM_Shape_ptr, Double, Double, Short, ListOfSubShapeID)->GEOM_Shape_ptr - -#Create Patterns -MultiTrans1D = geompy.MakeMultiTranslation1D(Fillet, vz, step1, nbtimes1) #(GEOM_Shape_ptr, DirStruct, Double, Short)->GEOM_Shape_ptr -MultiTrans2D = geompy.MakeMultiTranslation2D(Fillet, vz, step1, nbtimes1, vy, step2, nbtimes2) #(GEOM_Shape_ptr, DirStruct, Double, Short, DirStruct, Double, Short)->GEOM_Shape_ptr -#!!!!Angle In Degree!!!! -MultiRot1D = geompy.MakeMultiRotation1D(Chamfer, vx, px, nbtimes1) #(GEOM_Shape_ptr, DirStruct, PointStruct, Short)->GEOM_Shape_ptr -MultiRot2D = geompy.MakeMultiRotation2D(Chamfer, vx, px, angle, nbtimes1, step1, nbtimes2) #(GEOM_Shape_ptr, DirStruct, PointStruct, Double, Short, Double, Short)->GEOM_Shape_ptr - -#IDList for Partition -ShapeListPartition1 = [] -ShapeListPartition1.append(Box) -IORListPartition1 = [] -for Shape in ShapeListPartition1 : - IORListPartition1.append(Shape._get_Name()) -ShapeListPartition2 = [] -ShapeListPartition2.append(Plane) -IORListPartition2 = [] -for Shape in ShapeListPartition2 : - IORListPartition2.append(Shape._get_Name()) - -#IDList for SubShape -IDlistSubShape = [] -IDlistSubShape.append(3) - -#Create Informations objects -CDG = geompy.MakeCDG(Prism) #(GEOM_Shape_ptr)->GEOM_Shape_ptr -Archimede = geompy.Archimede(Box, weight, waterdensity, meshingdeflection) #(GEOM_Shape_ptr, Double, Double, Double)->GEOM_Shape_ptr -CheckShape = geompy.CheckShape(Prism) #(GEOM_Shape_ptr)->Boolean - -#Partition objects -Partition = geompy.Partition(IORListPartition1, IORListPartition2) #(ListOfIOR, ListOfIOR)->GEOM_Shape_ptr - -#Add In Study -id_Vertex = geompy.addToStudy(Vertex, "Vertex") -id_Vector = geompy.addToStudy(Vector, "Vector") -id_Line = geompy.addToStudy(Line, "Line") -id_Arc = geompy.addToStudy(Arc, "Arc") -id_Circle = geompy.addToStudy(Circle, "Circle") -id_Plane = geompy.addToStudy(Plane, "Plane") - -id_Box = geompy.addToStudy(Box, "Box") -id_Cylinder = geompy.addToStudy(Cylinder, "Cylinder") -id_Sphere = geompy.addToStudy(Sphere, "Sphere") -id_Cone = geompy.addToStudy(Cone, "Cone") -id_Torus = geompy.addToStudy(Torus, "Torus") - -id_Edge = geompy.addToStudy(Edge, "Edge") -id_Wire = geompy.addToStudy(Wire, "Wire") -id_Face = geompy.addToStudy(Face, "Face") -id_Compound = geompy.addToStudy(Compound, "Compound") - -id_Common = geompy.addToStudy(Common, "Common") -id_Cut = geompy.addToStudy(Cut, "Cut") -id_Fuse = geompy.addToStudy(Fuse, "Fuse") -id_Section = geompy.addToStudy(Section, "Section") - -id_Copy = geompy.addToStudy(Copy, "Copy") -id_Prism = geompy.addToStudy(Prism, "Prism") -#id_Revolution = geompy.addToStudy(Revolution, "Revolution") -id_Filling = geompy.addToStudy(Filling, "Filling") -id_Pipe = geompy.addToStudy(Pipe, "Pipe") -id_Sewing = geompy.addToStudy(Sewing, "Sewing") - -Id_Translation = geompy.addToStudy(Translation, "Translation") -Id_Rotation = geompy.addToStudy(Rotation, "Rotation") -Id_Scale = geompy.addToStudy(Scale, "Scale") -Id_Mirror = geompy.addToStudy(Mirror, "Mirror") -Id_Orientation = geompy.addToStudy(Orientation, "Orientation") -Id_Fillet = geompy.addToStudy(Fillet, "Fillet") -Id_Chamfer = geompy.addToStudy(Chamfer, "Chamfer") - -Id_MultiTrans1D = geompy.addToStudy(MultiTrans1D, "MultiTrans1D") -Id_MultiTrans2D = geompy.addToStudy(MultiTrans2D, "MultiTrans2D") -Id_MultiRot1D = geompy.addToStudy(MultiRot1D, "MultiRot1D") -Id_MultiRot2D = geompy.addToStudy(MultiRot2D, "MultiRot2D") - -Id_Partition = geompy.addToStudy(Partition, "Partition") -Id_CDG = geompy.addToStudy(CDG, "CDG") -Id_Archimede = geompy.addToStudy(Archimede, "Archimede") - -#Decompose objects -SubShape = geompy.SubShape(Box, ShapeTypeFace, IDlistSubShape) #(GEOM_Shape_ptr, Short, ListOfSubShapeID)->GEOM_Shape_ptr -name = geompy.SubShapeName( SubShape._get_Name(), Box._get_Name() ) -Id_SubShape = geompy.addToStudyInFather(Box, SubShape, name) +import GEOM_TestAll +import GEOM_TestOthers +import GEOM_TestHealing +import GEOM_TestMeasures -SubShapeAllList = [] -SubShapeAllList = geompy.SubShapeAll(SubShape, ShapeTypeEdge) #(GEOM_Shape_ptr, Short)->ListOfGeomShapes -for Shape in SubShapeAllList : - name = geompy.SubShapeName( Shape._get_Name(), Box._get_Name() ) - Id_SubShapeAll = geompy.addToStudyInFather(SubShape, Shape, name) +GEOM_TestMeasures.TestMeasureOperations(geompy, math) +GEOM_TestHealing.TestHealingOperations(geompy, math) +GEOM_TestOthers.TestOtherOperations(geompy, math) +GEOM_TestAll.TestAll(geompy, math) diff --git a/src/GEOM_SWIG/Makefile.in b/src/GEOM_SWIG/Makefile.in index a053a12a1..51fb02ed1 100644 --- a/src/GEOM_SWIG/Makefile.in +++ b/src/GEOM_SWIG/Makefile.in @@ -1,23 +1,23 @@ # GEOM GEOM_SWIG : binding of C++ omplementaion with Python # # 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 +# 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 # # # @@ -37,29 +37,39 @@ VPATH=.:@srcdir@:@top_srcdir@/idl # Libraries targets LIB = libGEOM_Swigcmodule.la -LIB_SRC = +LIB_SRC = SWIG_DEF = libGEOM_Swig.i -EXPORT_PYSCRIPTS = libGEOM_Swig.py geompy.py batchmode_geompy.py \ - GEOM_example.py \ - GEOM_example2.py \ - GEOM_example3.py \ - GEOM_example4.py \ - GEOM_moteur.py \ - GEOM_usinggeom.py \ - GEOM_Partition1.py \ - GEOM_Partition2.py \ - GEOM_Partition3.py \ - GEOM_Partition4.py \ - GEOM_Partition5.py \ - GEOM_Sketcher.py +EXPORT_PYSCRIPTS = \ + libGEOM_Swig.py \ + geompy.py \ + batchmode_geompy.py \ + GEOM_Spanner.py \ + GEOM_blocks.py \ + GEOM_example.py \ + GEOM_example2.py \ + GEOM_example3.py \ + GEOM_example4.py \ + GEOM_example5.py \ + GEOM_moteur.py \ + GEOM_TestAll.py \ + GEOM_TestOthers.py \ + GEOM_TestHealing.py \ + GEOM_TestMeasures.py \ + GEOM_usinggeom.py \ + GEOM_Partition1.py \ + GEOM_Partition2.py \ + GEOM_Partition3.py \ + GEOM_Partition4.py \ + GEOM_Partition5.py \ + GEOM_Sketcher.py LIB_CLIENT_IDL = SALOMEDS.idl \ SALOMEDS_Attributes.idl \ SALOME_Exception.idl \ GEOM_Gen.idl \ - GEOM_Shape.idl \ - SALOME_Component.idl + SALOME_Component.idl \ + SALOME_GenericObj.idl EXPORT_SHAREDPYSCRIPTS=\ GEOM_shared_modules.py diff --git a/src/GEOM_SWIG/batchmode_geompy.py b/src/GEOM_SWIG/batchmode_geompy.py index 041330f6a..93e695b96 100644 --- a/src/GEOM_SWIG/batchmode_geompy.py +++ b/src/GEOM_SWIG/batchmode_geompy.py @@ -1,6 +1,23 @@ # GEOM GEOM_SWIG : binding of C++ omplementaion with Python # -# Copyright (C) 2003 CEA/DEN, EDF R&D +# 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 # # # @@ -12,378 +29,576 @@ from batchmode_salome import * import GEOM -#-------------------------------------------------------------------------- -modulecatalog = naming_service.Resolve("/Kernel/ModulCatalog") - -geom = lcc.FindOrLoadComponent("FactoryServer", "GEOM") -geom.GetCurrentStudy(myStudyId) +g=None +step = 0 +while step < 50 and g == None: + g = lcc.FindOrLoadComponent("FactoryServer", "GEOM") + step = step + 1 + time.sleep(4) +geom = g._narrow( GEOM.GEOM_Gen ) myBuilder = myStudy.NewBuilder() father = myStudy.FindComponent("GEOM") if father is None: father = myBuilder.NewComponent("GEOM") - A1 = myBuilder.FindOrCreateAttribute(father, "AttributeName"); + A1 = myBuilder.FindOrCreateAttribute(father, "AttributeName") FName = A1._narrow(SALOMEDS.AttributeName) -# FName.SetValue("Geometry") - - Comp = modulecatalog.GetComponent( "GEOM" ) - FName.SetValue( Comp._get_componentusername() ) - - A2 = myBuilder.FindOrCreateAttribute(father, "AttributePixMap"); - aPixmap = A2._narrow(SALOMEDS.AttributePixMap); - aPixmap.SetPixMap( "ICON_OBJBROWSER_Geometry" ); + FName.SetValue("Geometry") + A2 = myBuilder.FindOrCreateAttribute(father, "AttributePixMap") + aPixmap = A2._narrow(SALOMEDS.AttributePixMap) + aPixmap.SetPixMap("ICON_OBJBROWSER_Geometry") myBuilder.DefineComponentInstance(father,geom) - # ----------------------------------------------------------------------------- -# add To Study +# add To Study # ----------------------------------------------------------------------------- -def SubShapeName(aSubId, aMainId): -# index = gg.getIndexTopology(aSubId, aMainId) -# print index -# name = gg.getShapeTypeString(aSubId) + "_%d"%(index) - name = "Shape" +def SubShapeName(aSubObj, aMainObj): + name = "SubShape" print name return name -def addArguments(aShape): - ListIOR = [] - ListIOR = geom.GetReferencedObjects(aShape) - - if aShape._get_StudyShapeId()!="": - father = IDToSObject(aShape._get_StudyShapeId()) - - myBuilder.NewCommand() - if len(ListIOR) > 0: - Arg = myBuilder.NewObject(father) - A1 = myBuilder.FindOrCreateAttribute(Arg, "AttributeName"); - ArgName = A1._narrow(SALOMEDS.AttributeName) - ArgName.SetValue("Arguments") - A2 = myBuilder.FindOrCreateAttribute(Arg, "AttributeSelectable"); - SelAttr = A2._narrow(SALOMEDS.AttributeSelectable); - SelAttr.SetSelectable(0); - - OneObject = 0 - for anIOR in ListIOR: - Shape = orb.string_to_object(anIOR) - if Shape is not None: - if Shape._get_StudyShapeId()!="": - Obj = IDToSObject(Shape._get_StudyShapeId()) - if Obj is not None: - Obj1 = myBuilder.NewObject(Arg) - myBuilder.Addreference(Obj1,Obj) - OneObject = 1 - - if OneObject == 0: - myBuilder.RemoveObject(Arg) - - myBuilder.CommitCommand() - return 1 +# ----------------------------------------------------------------------------- +# Operations +# ----------------------------------------------------------------------------- def addToStudy(aShape, aName): - try: - myBuilder.NewCommand() - newObj = myBuilder.NewObject(father) - ior = orb.object_to_string(aShape) - A1 = myBuilder.FindOrCreateAttribute(newObj, "AttributeIOR"); - ObjIOR = A1._narrow(SALOMEDS.AttributeIOR) - ObjIOR.SetValue(ior) - A2 = myBuilder.FindOrCreateAttribute(newObj, "AttributeName"); - ObjName = A2._narrow(SALOMEDS.AttributeName) - ObjName.SetValue(aName) - id = newObj.GetID() - aShape._set_StudyShapeId(id) - myBuilder.CommitCommand() - - addArguments( aShape ) - + try: + aSObject = geom.AddInStudy(myStudy, aShape, aName, None) except: - return None - return id + print "addToStudy() failed" + return "" + return aShape.GetStudyEntry() def addToStudyInFather(aFather, aShape, aName): - myBuilder.NewCommand() - newObj = myBuilder.NewObject( IDToSObject(aFather._get_StudyShapeId()) ) - ior = orb.object_to_string(aShape) - A1 = myBuilder.FindOrCreateAttribute(newObj, "AttributeIOR"); - ObjIOR = A1._narrow(SALOMEDS.AttributeIOR) - ObjIOR.SetValue(ior) - A2 = myBuilder.FindOrCreateAttribute(newObj, "AttributeName"); - ObjName = A2._narrow(SALOMEDS.AttributeName) - ObjName.SetValue(aName) - id = newObj.GetID() - aShape._set_StudyShapeId(id) - myBuilder.CommitCommand() - addArguments( aShape ) - return id + try: +# myBuilder.NewCommand() + aSObject = geom.AddInStudy(myStudy, aShape, aName, aFather) +# myBuilder.CommitCommand() + except: + print "addToStudyInFather() failed" + return "" + return aShape.GetStudyEntry() + +# ----------------------------------------------------------------------------- +# enumeration ShapeType as a dictionary +# ----------------------------------------------------------------------------- + +ShapeType = {"COMPOUND":0, "COMPSOLID":1, "SOLID":2, "SHELL":3, "FACE":4, "WIRE":5, "EDGE":6, "VERTEX":7, "SHAPE":8} # ----------------------------------------------------------------------------- -# Create Geometry 2D +# Get Operations Interfaces +# ----------------------------------------------------------------------------- + +BasicOp = geom.GetIBasicOperations (myStudyId) +CurvesOp = geom.GetICurvesOperations (myStudyId) +PrimOp = geom.GetI3DPrimOperations (myStudyId) +ShapesOp = geom.GetIShapesOperations (myStudyId) +HealOp = geom.GetIHealingOperations (myStudyId) +InsertOp = geom.GetIInsertOperations (myStudyId) +BoolOp = geom.GetIBooleanOperations (myStudyId) +TrsfOp = geom.GetITransformOperations(myStudyId) +LocalOp = geom.GetILocalOperations (myStudyId) +MeasuOp = geom.GetIMeasureOperations (myStudyId) +BlocksOp = geom.GetIBlocksOperations (myStudyId) +GroupOp = geom.GetIGroupOperations (myStudyId) + +# ----------------------------------------------------------------------------- +# Basic primitives # ----------------------------------------------------------------------------- def MakeVertex(x,y,z): - anObj = geom.MakeVertex(x,y,z) - ior = orb.object_to_string(anObj) - anObj._set_Name(ior) + anObj = BasicOp.MakePointXYZ(x,y,z) + if BasicOp.IsDone() == 0: + print "MakePointXYZ : ", BasicOp.GetErrorCode() + return anObj + +def MakeVertexWithRef(vertex,x,y,z): + anObj = BasicOp.MakePointWithReference(vertex,x,y,z) + if BasicOp.IsDone() == 0: + print "MakePointWithReference : ", BasicOp.GetErrorCode() + return anObj + +def MakeVertexOnCurve(curve,par): + anObj = BasicOp.MakePointOnCurve(curve,par) + if BasicOp.IsDone() == 0: + print "MakePointOnCurve : ", BasicOp.GetErrorCode() + return anObj + +def MakeVectorDXDYDZ(dx,dy,dz): + anObj = BasicOp.MakeVectorDXDYDZ(dx,dy,dz) + if BasicOp.IsDone() == 0: + print "MakeVectorDXDYDZ : ", BasicOp.GetErrorCode() return anObj def MakeVector(p1,p2): - anObj = geom.MakeVector(p1,p2) - ior = orb.object_to_string(anObj) - anObj._set_Name(ior) + anObj = BasicOp.MakeVectorTwoPnt(p1, p2) + if BasicOp.IsDone() == 0: + print "MakeVectorTwoPnt : ", BasicOp.GetErrorCode() + return anObj + +def MakeLine(p1, d1): + anObj = BasicOp.MakeLine(p1,d1) + if BasicOp.IsDone() == 0: + print "MakeLine : ", BasicOp.GetErrorCode() + return anObj + +def MakeLineTwoPnt(p1, p2): + anObj = BasicOp.MakeLineTwoPnt(p1,p2) + if BasicOp.IsDone() == 0: + print "MakeLineTwoPnt : ", BasicOp.GetErrorCode() + return anObj + +def MakePlane(p1,v1,trimsize): + anObj = BasicOp.MakePlanePntVec(p1,v1,trimsize) + if BasicOp.IsDone() == 0: + print "MakePlanePntVec : ", BasicOp.GetErrorCode() return anObj -def MakeLine(p1,d1): - anObj = geom.MakeLine(p1,d1) - ior = orb.object_to_string(anObj) - anObj._set_Name(ior) +def MakePlaneThreePnt(p1,p2,p3,trimsize): + anObj = BasicOp.MakePlaneThreePnt(p1,p2,p3,trimsize) + if BasicOp.IsDone() == 0: + print "MakePlaneThreePnt : ", BasicOp.GetErrorCode() return anObj +def MakePlaneFace(face,trimsize): + anObj = BasicOp.MakePlaneFace(face,trimsize) + if BasicOp.IsDone() == 0: + print "MakePlaneFace : ", BasicOp.GetErrorCode() + return anObj + +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: + print "MakeMarker : ", BasicOp.GetErrorCode() + return anObj + +# ----------------------------------------------------------------------------- +# Curves +# ----------------------------------------------------------------------------- + def MakeArc(p1,p2,p3): - anObj = geom.MakeArc(p1,p2,p3) - ior = orb.object_to_string(anObj) - anObj._set_Name(ior) + anObj = CurvesOp.MakeArc(p1,p2,p3) + if CurvesOp.IsDone() == 0: + print "MakeArc : ", CurvesOp.GetErrorCode() + return anObj + +def MakeCircle(p1,v1,radius): + anObj = CurvesOp.MakeCirclePntVecR(p1,v1,radius) + if CurvesOp.IsDone() == 0: + print "MakeCirclePntVecR : ", CurvesOp.GetErrorCode() + return anObj + +def MakeCircleThreePnt(p1,p2,p3): + anObj = CurvesOp.MakeCircleThreePnt(p1,p2,p3) + if CurvesOp.IsDone() == 0: + print "MakeCircleThreePnt : ", CurvesOp.GetErrorCode() + return anObj + +def MakeEllipse(p1,v1,radiusMaj,radiusMin): + anObj = CurvesOp.MakeEllipse(p1,v1,radiusMaj, radiusMin) + if CurvesOp.IsDone() == 0: + print "MakeEllipse : ", CurvesOp.GetErrorCode() return anObj -def MakeCircle(p1,d1,radius): - anObj = geom.MakeCircle(p1,d1,radius) - ior = orb.object_to_string(anObj) - anObj._set_Name(ior) +def MakePolyline(ListShape): + anObj = CurvesOp.MakePolyline(ListShape) + if CurvesOp.IsDone() == 0: + print "MakePolyline : ", CurvesOp.GetErrorCode() return anObj -def MakeEllipse(p1,d1,radiusMaj,radiusMin): - anObj = geom.MakeEllipse(p1,d1,radiusMaj, radiusMin) - ior = orb.object_to_string(anObj) - anObj._set_Name(ior) +def MakeBezier(ListShape): + anObj = CurvesOp.MakeSplineBezier(ListShape) + if CurvesOp.IsDone() == 0: + print "MakeSplineBezier : ", CurvesOp.GetErrorCode() return anObj -def MakePlane(p1,d1,trimsize): - anObj = geom.MakePlane(p1,d1,trimsize) - ior = orb.object_to_string(anObj) - anObj._set_Name(ior) +def MakeInterpol(ListShape): + anObj = CurvesOp.MakeSplineInterpolation(ListShape) + if CurvesOp.IsDone() == 0: + print "MakeSplineInterpolation : ", CurvesOp.GetErrorCode() return anObj -def MakeSketcher(Cmd): - anObj = geom.MakeSketcher(Cmd) - ior = orb.object_to_string(anObj) - anObj._set_Name(ior) +# : Nine double values, defining origin, +# OZ and OX directions of the working plane. +def MakeSketcher(Cmd, WPL = [0,0,0, 0,0,1, 1,0,0]): + anObj = CurvesOp.MakeSketcher(Cmd, WPL) + if CurvesOp.IsDone() == 0: + print "MakeSketcher : ", CurvesOp.GetErrorCode() return anObj # ----------------------------------------------------------------------------- -# Create Geometry 3D +# Create 3D Primitives # ----------------------------------------------------------------------------- def MakeBox(x1,y1,z1,x2,y2,z2): - anObj = geom.MakeBox(x1,y1,z1,x2,y2,z2) - ior = orb.object_to_string(anObj) - anObj._set_Name(ior) + pnt1 = MakeVertex(x1,y1,z1) + pnt2 = MakeVertex(x2,y2,z2) + return MakeBoxTwoPnt(pnt1,pnt2) + +def MakeBoxDXDYDZ(dx,dy,dz): + anObj = PrimOp.MakeBoxDXDYDZ(dx,dy,dz) + if PrimOp.IsDone() == 0: + print "MakeBoxDXDYDZ : ", PrimOp.GetErrorCode() + return anObj + +def MakeBoxTwoPnt(point1, point2): + anObj = PrimOp.MakeBoxTwoPnt(point1, point2) + if PrimOp.IsDone() == 0: + print "MakeBoxTwoPnt : ", PrimOp.GetErrorCode() return anObj -def MakeCylinder(p1,d1,radius,height): - anObj = geom.MakeCylinder(p1,d1,radius,height) - ior = orb.object_to_string(anObj) - anObj._set_Name(ior) +def MakeCylinder(p1,v1,radius,height): + anObj = PrimOp.MakeCylinderPntVecRH(p1,v1,radius,height) + if PrimOp.IsDone() == 0: + print "MakeCylinderPntVecRH : ", PrimOp.GetErrorCode() + return anObj + +def MakeCylinderRH(radius,height): + anObj = PrimOp.MakeCylinderRH(radius,height) + if PrimOp.IsDone() == 0: + print "MakeCylinderRH : ", PrimOp.GetErrorCode() + return anObj + +def MakeSpherePntR(point,radius): + anObj = PrimOp.MakeSpherePntR(point,radius) + if PrimOp.IsDone() == 0: + print "MakeSpherePntR : ", PrimOp.GetErrorCode() return anObj def MakeSphere(x,y,z,radius): - anObj = geom.MakeSphere(x,y,z,radius) - ior = orb.object_to_string(anObj) - anObj._set_Name(ior) + point = MakeVertex(x,y,z) + anObj = MakeSpherePntR(point,radius) + return anObj + +def MakeSphereR(radius): + anObj = PrimOp.MakeSphereR(radius) + if PrimOp.IsDone() == 0: + print "MakeSphereR : ", PrimOp.GetErrorCode() + return anObj + +def MakeCone(p1,v1,radius1,radius2,height): + anObj = PrimOp.MakeConePntVecR1R2H(p1,v1,radius1,radius2,height) + if PrimOp.IsDone() == 0: + print "MakeConePntVecR1R2H : ", PrimOp.GetErrorCode() + return anObj + +def MakeConeR1R2H(radius1,radius2,height): + anObj = PrimOp.MakeConeR1R2H(radius1,radius2,height) + if PrimOp.IsDone() == 0: + print "MakeConeR1R2H : ", PrimOp.GetErrorCode() + return anObj + +def MakeTorus(p1,v1,major_radius,minor_radius): + anObj = PrimOp.MakeTorusPntVecRR(p1,v1,major_radius,minor_radius) + if PrimOp.IsDone() == 0: + print "MakeTorusPntVecRR : ", PrimOp.GetErrorCode() + return anObj + +def MakeTorusRR(major_radius,minor_radius): + anObj = PrimOp.MakeTorusRR(major_radius,minor_radius) + if PrimOp.IsDone() == 0: + print "MakeTorusRR : ", PrimOp.GetErrorCode() + return anObj + +def MakePrism(baseShape,point1,point2): + anObj = PrimOp.MakePrismTwoPnt(baseShape,point1,point2) + if PrimOp.IsDone() == 0: + print "MakePrismTwoPnt : ", PrimOp.GetErrorCode() return anObj -def MakeCone(p1,d1,radius1,radius2,height): - anObj = geom.MakeCone(p1,d1,radius1,radius2,height) - ior = orb.object_to_string(anObj) - anObj._set_Name(ior) +def MakePrismVecH(baseShape,vector,height): + anObj = PrimOp.MakePrismVecH(baseShape,vector,height) + if PrimOp.IsDone() == 0: + print "MakePrismVecH : ", PrimOp.GetErrorCode() return anObj -def MakeTorus(p1,d1,major_radius,minor_radius): - anObj = geom.MakeTorus(p1,d1,major_radius,minor_radius) - ior = orb.object_to_string(anObj) - anObj._set_Name(ior) +def MakePipe(baseShape,pathShape): + anObj = PrimOp.MakePipe(baseShape,pathShape) + if PrimOp.IsDone() == 0: + print "MakePipe : ", PrimOp.GetErrorCode() + return anObj + +def MakeRevolution(aShape,axis,angle): + anObj = PrimOp.MakeRevolutionAxisAngle(aShape,axis,angle) + if PrimOp.IsDone() == 0: + print "MakeRevolutionAxisAngle : ", PrimOp.GetErrorCode() return anObj # ----------------------------------------------------------------------------- -# Create base objects +# Create base shapes # ----------------------------------------------------------------------------- def MakeEdge(p1,p2): - anObj = geom.MakeEdge(p1,p2) - ior = orb.object_to_string(anObj) - anObj._set_Name(ior) + anObj = ShapesOp.MakeEdge(p1,p2) + if ShapesOp.IsDone() == 0: + print "MakeEdge : ", ShapesOp.GetErrorCode() return anObj def MakeWire(ListShape): - anObj = geom.MakeWire(ListShape) - ior = orb.object_to_string(anObj) - anObj._set_Name(ior) + anObj = ShapesOp.MakeWire(ListShape) + if ShapesOp.IsDone() == 0: + print "MakeWire : ", ShapesOp.GetErrorCode() return anObj def MakeFace(aShapeWire,WantPlanarFace): - anObj = geom.MakeFace(aShapeWire,WantPlanarFace) - ior = orb.object_to_string(anObj) - anObj._set_Name(ior) + anObj = ShapesOp.MakeFace(aShapeWire,WantPlanarFace) + if ShapesOp.IsDone() == 0: + print "MakeFace : ", ShapesOp.GetErrorCode() + return anObj + +def MakeFaceWires(ListWires,WantPlanarFace): + anObj = ShapesOp.MakeFaceWires(ListWires,WantPlanarFace) + if ShapesOp.IsDone() == 0: + print "MakeFaceWires : ", ShapesOp.GetErrorCode() + return anObj + +def MakeFaces(ListWires,WantPlanarFace): + anObj = MakeFaceWires(ListWires,WantPlanarFace) return anObj -def MakeFaces(ListShape,WantPlanarFace): - anObj = geom.MakeFaces(ListShape,WantPlanarFace) - ior = orb.object_to_string(anObj) - anObj._set_Name(ior) +def MakeShell(ListOfShapes): + anObj = ShapesOp.MakeShell(ListOfShapes) + if ShapesOp.IsDone() == 0: + print "MakeShell : ", ShapesOp.GetErrorCode() + return anObj + +def MakeSolid(ListOfShells): + anObj = ShapesOp.MakeSolidShells(ListOfShells) + if ShapesOp.IsDone() == 0: + print "MakeSolid : ", ShapesOp.GetErrorCode() return anObj def MakeCompound(ListShape): - anObj = geom.MakeCompound(ListShape) - ior = orb.object_to_string(anObj) - anObj._set_Name(ior) + anObj = ShapesOp.MakeCompound(ListShape) + if ShapesOp.IsDone() == 0: + print "MakeCompound : ", ShapesOp.GetErrorCode() + return anObj + +def ChangeOrientation(Shape): + anObj = ShapesOp.ChangeOrientation(Shape) + if ShapesOp.IsDone() == 0: + print "ChangeOrientation : ", ShapesOp.GetErrorCode() + return anObj + +def OrientationChange(Shape): + anObj = ChangeOrientation(Shape) return anObj # ----------------------------------------------------------------------------- -# Create advanced objects +# Access to sub-shapes by their unique IDs inside the main shape. # ----------------------------------------------------------------------------- -def MakeCopy(aShape): - anObj = geom.MakeCopy(aShape) - ior = orb.object_to_string(anObj) - anObj._set_Name(ior) +# Obtain a composite sub-shape of , composed from sub-shapes +# of , selected by their unique IDs inside +def GetSubShape(aShape, ListOfID): + anObj = geom.AddSubShape(aShape,ListOfID) return anObj -def MakePrism(baseShape,p1,p2): - anObj = geom.MakePrism(baseShape,p1,p2) - ior = orb.object_to_string(anObj) - anObj._set_Name(ior) +# Obtain unique ID of sub-shape inside +def GetSubShapeID(aShape, aSubShape): + anID = LocalOp.GetSubShapeIndex(aShape, aSubShape) + if LocalOp.IsDone() == 0: + print "GetSubShapeIndex : ", LocalOp.GetErrorCode() + return anID + +# ----------------------------------------------------------------------------- +# Decompose objects +# ----------------------------------------------------------------------------- + +def SubShapeAll(aShape, aType): + ListObj = ShapesOp.MakeExplode(aShape,aType,0) + if ShapesOp.IsDone() == 0: + print "MakeExplode : ", ShapesOp.GetErrorCode() + return ListObj + +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 +def SubShape(aShape, aType, ListOfInd): + ListOfIDs = [] + AllShapeList = SubShapeAll(aShape, aType) + for ind in ListOfInd: + ListOfIDs.append(GetSubShapeID(aShape, AllShapeList[ind - 1])) + anObj = GetSubShape(aShape, ListOfIDs) return anObj -def MakeRevolution(aShape,axis,angle): - anObj = geom.MakeRevolution(aShape,axis,angle) - ior = orb.object_to_string(anObj) - anObj._set_Name(ior) +# Obtain a compound of sub-shapes of , +# selected by they indices in sorted list of all sub-shapes of type +def SubShapeSorted(aShape, aType, ListOfInd): + ListOfIDs = [] + AllShapeList = SubShapeAllSorted(aShape, aType) + for ind in ListOfInd: + ListOfIDs.append(GetSubShapeID(aShape, AllShapeList[ind - 1])) + anObj = GetSubShape(aShape, ListOfIDs) return anObj -def MakeFilling(aShape,mindeg,maxdeg,tol3d,tol2d,nbiter): - anObj = geom.MakeFilling(aShape,mindeg,maxdeg,tol3d,tol2d,nbiter) - ior = orb.object_to_string(anObj) - anObj._set_Name(ior) +# ----------------------------------------------------------------------------- +# Healing operations +# ----------------------------------------------------------------------------- + +def ProcessShape(Shape, Operators, Parameters, Values): + anObj = HealOp.ProcessShape(Shape, Operators, Parameters, Values) + if HealOp.IsDone() == 0: + print "ProcessShape : ", HealOp.GetErrorCode() return anObj -def MakePipe(pathShape,baseShape): - anObj = geom.MakePipe(pathShape,baseShape) - ior = orb.object_to_string(anObj) - anObj._set_Name(ior) +def SuppressFaces(aShape,ListOfId): + anObj = HealOp.SuppressFaces(aShape,ListOfId) + if HealOp.IsDone() == 0: + print "SuppressFaces : ", HealOp.GetErrorCode() return anObj def MakeSewing(ListShape,precision): - anObj = geom.MakeSewing(ListShape,precision) - ior = orb.object_to_string(anObj) - anObj._set_Name(ior) + comp = MakeCompound(ListShape) + anObj = Sew(comp,precision) return anObj -# ----------------------------------------------------------------------------- -# Boolean (Common, Cut, Fuse, Section) -# ----------------------------------------------------------------------------- +def Sew(aShape,precision): + anObj = HealOp.Sew(aShape,precision) + if HealOp.IsDone() == 0: + print "Sew : ", HealOp.GetErrorCode() + return anObj -def MakeBoolean(shape1,shape2,operation): - anObj = geom.MakeBoolean(shape1,shape2,operation) - ior = orb.object_to_string(anObj) - anObj._set_Name(ior) +def SuppressInternalWires(aShape, Wires): + anObj = HealOp.RemoveIntWires(aShape, Wires) + if HealOp.IsDone() == 0: + print "SuppressInternalWires : ", HealOp.GetErrorCode() + return anObj + +def SuppressHoles(aShape, ListOfId): + anObj = HealOp.FillHoles(aShape,ListOfId) + if HealOp.IsDone() == 0: + print "SuppressHoles : ", HealOp.GetErrorCode() + return anObj + +def CloseContour(aShape, Wires, IsCommonVertex): + anObj = HealOp.CloseContour(aShape, Wires, IsCommonVertex) + if HealOp.IsDone() == 0: + print "CloseContour : ", HealOp.GetErrorCode() + return anObj + +def DivideEdge(aShape, EdgeID, Value, IsByParameter): + anObj = HealOp.DivideEdge(aShape, EdgeID, Value, IsByParameter) + if HealOp.IsDone() == 0: + print "DivideEdge : ", HealOp.GetErrorCode() + return anObj + +def GetFreeBoundary(Shape): + anObj = HealOp.GetFreeBoundary(Shape) + if HealOp.IsDone() == 0: + print "GetFreeBoundaries : ", HealOp.GetErrorCode() return anObj # ----------------------------------------------------------------------------- -# Transform objects +# Create advanced objects # ----------------------------------------------------------------------------- -def MakeTranslation(aShape,x,y,z): - anObj = geom.MakeTranslation(aShape,x,y,z) - ior = orb.object_to_string(anObj) - anObj._set_Name(ior) +def MakeCopy(aShape): + anObj = InsertOp.MakeCopy(aShape) + if InsertOp.IsDone() == 0: + print "MakeCopy : ", InsertOp.GetErrorCode() return anObj -def MakeRotation(aShape,axis,angle): - anObj = geom.MakeRotation(aShape,axis,angle) - ior = orb.object_to_string(anObj) - anObj._set_Name(ior) +def MakeFilling(aShape,mindeg,maxdeg,tol2d,tol3d,nbiter): + anObj = PrimOp.MakeFilling(aShape,mindeg,maxdeg,tol2d,tol3d,nbiter) + if PrimOp.IsDone() == 0: + print "MakeFilling : ", PrimOp.GetErrorCode() return anObj -def MakeScaleTransform(aShape,theCenterofScale,factor): - anObj = geom.MakeScaleTransform(aShape,theCenterofScale,factor) - ior = orb.object_to_string(anObj) - anObj._set_Name(ior) +def MakeGlueFaces(aShape,aTolerance): + anObj = ShapesOp.MakeGlueFaces(aShape,aTolerance) + if ShapesOp.IsDone() == 0: + print "MakeGlueFaces : ", ShapesOp.GetErrorCode() return anObj -def MakeMirrorByPlane(aShape,aPlane): - anObj = geom.MakeMirrorByPlane(aShape,aPlane) - ior = orb.object_to_string(anObj) - anObj._set_Name(ior) - return anObj +# ----------------------------------------------------------------------------- +# Boolean (Common, Cut, Fuse, Section) +# ----------------------------------------------------------------------------- -def OrientationChange(aShape): - anObj = geom.OrientationChange(aShape) - ior = orb.object_to_string(anObj) - anObj._set_Name(ior) +def MakeBoolean(shape1,shape2,operation): + anObj = BoolOp.MakeBoolean(shape1,shape2,operation) + if BoolOp.IsDone() == 0: + print "MakeBoolean : ", BoolOp.GetErrorCode() return anObj -def MakeFillet(aShape,radius,ShapeType,ListShape): - anObj = geom.MakeFillet(aShape,radius,ShapeType,ListShape) - ior = orb.object_to_string(anObj) - anObj._set_Name(ior) +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) + +def MakePartition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[], + Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[]): + anObj = BoolOp.MakePartition(ListShapes, ListTools, + ListKeepInside, ListRemoveInside, + Limit, RemoveWebs, ListMaterials); + if BoolOp.IsDone() == 0: + print "MakePartition : ", BoolOp.GetErrorCode() return anObj -def MakeChamfer(aShape,d1,d2,ShapeType,ListShape): - anObj = geom.MakeChamfer(aShape,d1,d2,ShapeType,ListShape) - ior = orb.object_to_string(anObj) - anObj._set_Name(ior) +def Partition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[], + Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[]): + anObj = MakePartition(ListShapes, ListTools, + ListKeepInside, ListRemoveInside, + Limit, RemoveWebs, ListMaterials); return anObj # ----------------------------------------------------------------------------- -# Decompose objects +# Transform objects # ----------------------------------------------------------------------------- -def SubShape(aShape,type,ListOfId): - anObj = geom.SubShape(aShape,type, ListOfId) - ior = orb.object_to_string(anObj) - anObj._set_Name(ior) +def MakeTranslationTwoPoints(aShape,point1,point2): + anObj = TrsfOp.TranslateTwoPointsCopy(aShape,point1,point2) + if TrsfOp.IsDone() == 0: + print "TranslateTwoPointsCopy : ", TrsfOp.GetErrorCode() return anObj -def SubShapeAll(aShape,type): - ListObj = geom.SubShapeAll(aShape,type) - for anObj in ListObj : - ior = orb.object_to_string(anObj) - anObj._set_Name(ior) - return ListObj - -def SubShapeSorted(aShape,type,ListOfId): - anObj = geom.SubShapeSorted(aShape,type, ListOfId) - ior = orb.object_to_string(anObj) - anObj._set_Name(ior) +def MakeTranslation(aShape,dx,dy,dz): + anObj = TrsfOp.TranslateDXDYDZCopy(aShape,dx,dy,dz) + if TrsfOp.IsDone() == 0: + print "TranslateDXDYDZCopy : ", TrsfOp.GetErrorCode() return anObj -def SubShapeAllSorted(aShape,type): - ListObj = geom.SubShapeAllSorted(aShape,type) - for anObj in ListObj : - ior = orb.object_to_string(anObj) - anObj._set_Name(ior) - return ListObj +def MakeRotation(aShape,axis,angle): + anObj = TrsfOp.RotateCopy(aShape,axis,angle) + if TrsfOp.IsDone() == 0: + print "RotateCopy : ", TrsfOp.GetErrorCode() + return anObj -# -- enumeration ShapeType as a dictionary -- -ShapeType = {"COMPOUND":0, "COMPSOLID":1, "SOLID":2, "SHELL":3, "FACE":4, "WIRE":5, "EDGE":6, "VERTEX":7, "SHAPE":8} +def MakeScaleTransform(aShape,theCenterofScale,factor): + anObj = TrsfOp.ScaleShapeCopy(aShape,theCenterofScale,factor) + if TrsfOp.IsDone() == 0: + print "ScaleShapeCopy : ", TrsfOp.GetErrorCode() + return anObj -def Partition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[], Limit=ShapeType["SHAPE"]): - anObj = geom.Partition(ListShapes, ListTools, ListKeepInside, ListRemoveInside, Limit); - ior = orb.object_to_string(anObj) - anObj._set_Name(ior) +def MakeMirrorByPlane(aShape,aPlane): + anObj = TrsfOp.MirrorPlaneCopy(aShape,aPlane) + if TrsfOp.IsDone() == 0: + print "MirrorPlaneCopy : ", TrsfOp.GetErrorCode() return anObj -def SuppressFaces(aShape,ListOfId): - ListObj = geom.SuppressFaces(aShape,ListOfId) - for anObj in ListObj : - ior = orb.object_to_string(anObj) - anObj._set_Name(ior) - return ListObj +def MakePosition(aShape,theStartLCS,theEndLCS): + anObj = TrsfOp.PositionShapeCopy(aShape,theStartLCS,theEndLCS) + if TrsfOp.IsDone() == 0: + print "PositionShapeCopy : ", TrsfOp.GetErrorCode() + return anObj -def SuppressHole(aShape,ListOfFace,ListOfWire,ListOfEndFace): - anObj = geom.SuppressHole(aShape,ListOfFace,ListOfWire,ListOfEndFace) - ior = orb.object_to_string(anObj) - anObj._set_Name(ior) +def MakeOffset(aShape, anOffset): + anObj = TrsfOp.OffsetShapeCopy(aShape, anOffset) + if TrsfOp.IsDone() == 0: + print "OffsetShapeCopy : ", TrsfOp.GetErrorCode() return anObj # ----------------------------------------------------------------------------- @@ -391,79 +606,257 @@ def SuppressHole(aShape,ListOfFace,ListOfWire,ListOfEndFace): # ----------------------------------------------------------------------------- def MakeMultiTranslation1D(aShape,aDir,aStep,aNbTimes): - anObj = geom.MakeMultiTranslation1D(aShape,aDir,aStep,aNbTimes) - ior = orb.object_to_string(anObj) - anObj._set_Name(ior) + anObj = TrsfOp.MultiTranslate1D(aShape,aDir,aStep,aNbTimes) + if TrsfOp.IsDone() == 0: + print "MultiTranslate1D : ", TrsfOp.GetErrorCode() return anObj def MakeMultiTranslation2D(aShape,d1,step1,nbtimes1,d2,step2,nbtimes2): - anObj = geom.MakeMultiTranslation2D(aShape,d1,step1,nbtimes1,d2,step2,nbtimes2) - ior = orb.object_to_string(anObj) - anObj._set_Name(ior) + anObj = TrsfOp.MultiTranslate2D(aShape,d1,step1,nbtimes1,d2,step2,nbtimes2) + if TrsfOp.IsDone() == 0: + print "MultiTranslate2D : ", TrsfOp.GetErrorCode() + return anObj + +def MultiRotate1D(aShape,aVec,aNbTimes): + anObj = TrsfOp.MultiRotate1D(aShape,aVec,aNbTimes) + if TrsfOp.IsDone() == 0: + print "MultiRotate1D : ", TrsfOp.GetErrorCode() + return anObj + +def MultiRotate2D(aShape,aVec,anAngle,nbtimes1,aStep,nbtimes2): + anObj = TrsfOp.MultiRotate2D(aShape,aVec,anAngle,nbtimes1,aStep,nbtimes2) + if TrsfOp.IsDone() == 0: + print "MultiRotate2D : ", TrsfOp.GetErrorCode() return anObj def MakeMultiRotation1D(aShape,aDir,aPoint,aNbTimes): - anObj = geom.MakeMultiRotation1D(aShape,aDir,aPoint,aNbTimes) - ior = orb.object_to_string(anObj) - anObj._set_Name(ior) + aVec = MakeLine(aPoint,aDir) + anObj = MultiRotate1D(aShape,aVec,aNbTimes) return anObj def MakeMultiRotation2D(aShape,aDir,aPoint,anAngle,nbtimes1,aStep,nbtimes2): - anObj = geom.MakeMultiRotation2D(aShape,aDir,aPoint,anAngle,nbtimes1,aStep,nbtimes2) - ior = orb.object_to_string(anObj) - anObj._set_Name(ior) + aVec = MakeLine(aPoint,aDir) + anObj = MultiRotate2D(aShape,aVec,anAngle,nbtimes1,aStep,nbtimes2) return anObj # ----------------------------------------------------------------------------- -# Import objects +# Local operations # ----------------------------------------------------------------------------- -def ImportBREP(filename): - anObj = geom.ImportBREP(filename) - ior = orb.object_to_string(anObj) - anObj._set_Name(ior) +def MakeFilletAll(aShape,radius): + anObj = LocalOp.MakeFilletAll(aShape,radius) + if LocalOp.IsDone() == 0: + print "MakeFilletAll : ", LocalOp.GetErrorCode() + return anObj + +def MakeFillet(aShape,radius,aShapeType,ListShape): + anObj = None + if aShapeType == ShapeType["EDGE"]: + anObj = LocalOp.MakeFilletEdges(aShape,radius,ListShape) + else: + anObj = LocalOp.MakeFilletFaces(aShape,radius,ListShape) + if LocalOp.IsDone() == 0: + print "MakeFillet : ", LocalOp.GetErrorCode() + return anObj + +def MakeChamferAll(aShape,d): + anObj = LocalOp.MakeChamferAll(aShape,d) + if LocalOp.IsDone() == 0: + print "MakeChamferAll : ", LocalOp.GetErrorCode() return anObj -def ImportIGES(filename): - anObj = geom.ImportIGES(filename) - ior = orb.object_to_string(anObj) - anObj._set_Name(ior) +def MakeChamferEdge(aShape,d1,d2,face1,face2): + anObj = LocalOp.MakeChamferEdge(aShape,d1,d2,face1,face2) + if LocalOp.IsDone() == 0: + print "MakeChamferEdge : ", LocalOp.GetErrorCode() return anObj -def ImportSTEP(filename): - anObj = geom.ImportSTEP(filename) - ior = orb.object_to_string(anObj) - anObj._set_Name(ior) +def MakeChamferFaces(aShape,d1,d2,ListShape): + anObj = LocalOp.MakeChamferFaces(aShape,d1,d2,ListShape) + if LocalOp.IsDone() == 0: + print "MakeChamferFaces : ", LocalOp.GetErrorCode() return anObj +def MakeChamfer(aShape,d1,d2,aShapeType,ListShape): + anObj = None + if aShapeType == ShapeType["EDGE"]: + anObj = MakeChamferEdge(aShape,d1,d2,ListShape[0],ListShape[1]) + else: + anObj = MakeChamferFaces(aShape,d1,d2,ListShape) + return anObj + +def Archimede(aShape,weight,WaterDensity,MeshingDeflection): + anObj = LocalOp.MakeArchimede(aShape,weight,WaterDensity,MeshingDeflection) + if LocalOp.IsDone() == 0: + print "MakeArchimede : ", LocalOp.GetErrorCode() + return anObj + +# ----------------------------------------------------------------------------- +# Information objects # ----------------------------------------------------------------------------- -# Export objects + +def PointCoordinates(Point): + aTuple = MeasuOp.PointCoordinates(Point) + if MeasuOp.IsDone() == 0: + print "PointCoordinates : ", MeasuOp.GetErrorCode() + return aTuple + +def BasicProperties(Shape): + aTuple = MeasuOp.GetBasicProperties(Shape) + if MeasuOp.IsDone() == 0: + print "BasicProperties : ", MeasuOp.GetErrorCode() + return aTuple + +def BoundingBox(Shape): + aTuple = MeasuOp.GetBoundingBox(Shape) + if MeasuOp.IsDone() == 0: + print "BoundingBox : ", MeasuOp.GetErrorCode() + return aTuple + +def Inertia(Shape): + aTuple = MeasuOp.GetInertia(Shape) + if MeasuOp.IsDone() == 0: + print "Inertia : ", MeasuOp.GetErrorCode() + return aTuple + +def MinDistance(Shape1, Shape2): + aTuple = MeasuOp.GetMinDistance(Shape1, Shape2) + if MeasuOp.IsDone() == 0: + print "MinDistance : ", MeasuOp.GetErrorCode() + return aTuple[0] + +def Tolerance(Shape): + aTuple = MeasuOp.GetTolerance(Shape) + if MeasuOp.IsDone() == 0: + print "Tolerance : ", MeasuOp.GetErrorCode() + return aTuple + +def WhatIs(Shape): + aDescr = MeasuOp.WhatIs(Shape) + if MeasuOp.IsDone() == 0: + print "WhatIs : ", MeasuOp.GetErrorCode() + return aDescr + +def MakeCDG(aShape): + anObj = MeasuOp.GetCentreOfMass(aShape) + if MeasuOp.IsDone() == 0: + print "GetCentreOfMass : ", MeasuOp.GetErrorCode() + return anObj + +def CheckShape(aShape): + (IsValid, Status) = MeasuOp.CheckShape(aShape) + if MeasuOp.IsDone() == 0: + print "CheckShape : ", MeasuOp.GetErrorCode() + else: + if IsValid == 0: + print Status + return IsValid + +# ----------------------------------------------------------------------------- +# Import/Export objects # ----------------------------------------------------------------------------- -def ExportBREP(filename,aShape): - geom.ExportBREP(filename,aShape) -def ExportIGES(filename,aShape): - geom.ExportIGES(filename,aShape) +def Import(filename, formatname): + anObj = InsertOp.Import(filename, formatname) + if InsertOp.IsDone() == 0: + print "Import : ", InsertOp.GetErrorCode() + return anObj -def ExportSTEP(filename,aShape): - geom.ExportSTEP(filename,aShape) +def Export(aShape, filename, formatname): + InsertOp.Export(aShape, filename, formatname) + if InsertOp.IsDone() == 0: + print "Export : ", InsertOp.GetErrorCode() # ----------------------------------------------------------------------------- -# Information objects +# Block operations # ----------------------------------------------------------------------------- -def MakeCDG(aShape): - anObj = geom.MakeCDG(aShape) - ior = orb.object_to_string(anObj) - anObj._set_Name(ior) +def MakeQuad(E1, E2, E3, E4): + anObj = BlocksOp.MakeQuad(E1, E2, E3, E4) + if BlocksOp.IsDone() == 0: + print "MakeQuad : ", BlocksOp.GetErrorCode() + return anObj + +def MakeQuad2Edges(E1, E2): + anObj = BlocksOp.MakeQuad2Edges(E1, E2) + if BlocksOp.IsDone() == 0: + print "MakeQuad2Edges : ", BlocksOp.GetErrorCode() + return anObj + +def MakeQuad4Vertices(V1, V2, V3, V4): + anObj = BlocksOp.MakeQuad4Vertices(V1, V2, V3, V4) + if BlocksOp.IsDone() == 0: + print "MakeQuad4Vertices : ", BlocksOp.GetErrorCode() + return anObj + +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 + +def MakeHexa2Faces(F1, F2): + anObj = BlocksOp.MakeHexa2Faces(F1, F2) + if BlocksOp.IsDone() == 0: + print "MakeHexa2Faces : ", BlocksOp.GetErrorCode() + return anObj + +def MakeMultiTransformation1D(Block, DirFaceID1, DirFaceID2, NbTimes): + anObj = BlocksOp.MakeMultiTransformation1D(Block, DirFaceID1, DirFaceID2, NbTimes) + if BlocksOp.IsDone() == 0: + print "MakeMultiTransformation1D : ", BlocksOp.GetErrorCode() return anObj -def Archimede(aShape,weight,WaterDensity,MeshingDeflection): - anObj = geom.Archimede(aShape,weight,WaterDensity,MeshingDeflection) - ior = orb.object_to_string(anObj) - anObj._set_Name(ior) +def MakeMultiTransformation2D(Block, DirFaceID1U, DirFaceID2U, NbTimesU, + DirFaceID1V, DirFaceID2V, NbTimesV): + anObj = BlocksOp.MakeMultiTransformation2D(Block, DirFaceID1U, DirFaceID2U, NbTimesU, + DirFaceID1V, DirFaceID2V, NbTimesV) + if BlocksOp.IsDone() == 0: + print "MakeMultiTransformation2D : ", BlocksOp.GetErrorCode() return anObj -def CheckShape(aShape): - Status = geom.CheckShape(aShape) - return Status +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) + if BlocksOp.IsDone() == 0: + print "CheckCompoundOfBlocks : ", BlocksOp.GetErrorCode() + else: + if IsValid == 0: + Descr = BlocksOp.PrintBCErrors(Compound, BCErrors) + print Descr + return IsValid + +# ----------------------------------------------------------------------------- +# Group operations +# ----------------------------------------------------------------------------- + +def CreateGroup(MainShape, ShapeType): + anObj = GroupOp.CreateGroup(MainShape, ShapeType) + if GroupOp.IsDone() == 0: + print "CreateGroup : ", GroupOp.GetErrorCode() + return anObj + +def AddObject(Group, SubShapeID): + GroupOp.AddObject(Group, SubShapeID) + if GroupOp.IsDone() == 0: + print "AddObject : ", GroupOp.GetErrorCode() + +def RemoveObject(Group, SubShapeID): + GroupOp.RemoveObject(Group, SubShapeID) + if GroupOp.IsDone() == 0: + print "RemoveObject : ", GroupOp.GetErrorCode() + +def GetObjectIDs(Group): + ListIDs = GroupOp.GetObjects(Group) + if GroupOp.IsDone() == 0: + print "GetObjectIDs : ", GroupOp.GetErrorCode() + return ListIDs + +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 6d0fca32a..b2bc785ac 100644 --- a/src/GEOM_SWIG/geompy.py +++ b/src/GEOM_SWIG/geompy.py @@ -1,23 +1,23 @@ # GEOM GEOM_SWIG : binding of C++ omplementaion with Python # # 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 +# 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 # # # @@ -26,470 +26,1755 @@ # Module : GEOM # $Header$ -import salome -import SALOMEDS -#import SALOMEDS_Attributes_idl +from salome import * +import GEOM -#NRI : BugID 1682 : from libSALOME_Swig import * +g = lcc.FindOrLoadComponent("FactoryServer", "GEOM") +geom = g._narrow( GEOM.GEOM_Gen ) +myBuilder = myStudy.NewBuilder() -geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM") -geom.GetCurrentStudy(salome.myStudyId) -myBuilder = salome.myStudy.NewBuilder() - -gg = salome.ImportComponentGUI("GEOM") - -father = salome.myStudy.FindComponent("GEOM") +father = myStudy.FindComponent("GEOM") if father is None: father = myBuilder.NewComponent("GEOM") - A1 = myBuilder.FindOrCreateAttribute(father, "AttributeName"); + A1 = myBuilder.FindOrCreateAttribute(father, "AttributeName") FName = A1._narrow(SALOMEDS.AttributeName) - FName.SetValue( salome.sg.getComponentUserName("GEOM") ) - A2 = myBuilder.FindOrCreateAttribute(father, "AttributePixMap"); - aPixmap = A2._narrow(SALOMEDS.AttributePixMap); - aPixmap.SetPixMap( "ICON_OBJBROWSER_Geometry" ); + FName.SetValue("Geometry") + A2 = myBuilder.FindOrCreateAttribute(father, "AttributePixMap") + aPixmap = A2._narrow(SALOMEDS.AttributePixMap) + aPixmap.SetPixMap("ICON_OBJBROWSER_Geometry") myBuilder.DefineComponentInstance(father,geom) +gg = ImportComponentGUI("GEOM") -# ----------------------------------------------------------------------------- -# add To Study -# ----------------------------------------------------------------------------- - -def SubShapeName(aSubId, aMainId): +# * 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) index = gg.getIndexTopology(aSubId, aMainId) name = gg.getShapeTypeString(aSubId) + "_%d"%(index) return name -def addArguments(aShape): - ListIOR = [] - ListIOR = geom.GetReferencedObjects(aShape) - - if aShape._get_StudyShapeId()!="": - father = salome.IDToSObject(aShape._get_StudyShapeId()) - - myBuilder.NewCommand() - if len(ListIOR) > 0: - Arg = myBuilder.NewObject(father) - A1 = myBuilder.FindOrCreateAttribute(Arg, "AttributeName"); - ArgName = A1._narrow(SALOMEDS.AttributeName) - ArgName.SetValue("Arguments") - A2 = myBuilder.FindOrCreateAttribute(Arg, "AttributeSelectable"); - SelAttr = A2._narrow(SALOMEDS.AttributeSelectable); - SelAttr.SetSelectable(0); - - OneObject = 0 - for anIOR in ListIOR: - Shape = salome.orb.string_to_object(anIOR) - if Shape is not None: - if Shape._get_StudyShapeId()!="": - Obj = salome.IDToSObject(Shape._get_StudyShapeId()) - if Obj is not None: - Obj1 = myBuilder.NewObject(Arg) - myBuilder.Addreference(Obj1,Obj) - OneObject = 1 - - if OneObject == 0: - myBuilder.RemoveObject(Arg) - - myBuilder.CommitCommand() - return 1 - +# * Publish in study aShape with name aName +# +# * Example: see GEOM_TestAll.py +# def addToStudy(aShape, aName): - myBuilder.NewCommand() - newObj = myBuilder.NewObject(father) - ior = salome.orb.object_to_string(aShape) - A1 = myBuilder.FindOrCreateAttribute(newObj, "AttributeIOR"); - ObjIOR = A1._narrow(SALOMEDS.AttributeIOR) - ObjIOR.SetValue(ior) - A2 = myBuilder.FindOrCreateAttribute(newObj, "AttributeName"); - ObjName = A2._narrow(SALOMEDS.AttributeName) - ObjName.SetValue(aName) - A3 = myBuilder.FindOrCreateAttribute(newObj, "AttributePixMap"); - ObjPixmap = A3._narrow(SALOMEDS.AttributePixMap) - anIcon = gg.getShapeTypeIcon(ior); - ObjPixmap.SetPixMap(anIcon) - id = newObj.GetID() - aShape._set_StudyShapeId(id) - myBuilder.CommitCommand() - - addArguments( aShape ) - -#NRI : BugID 1682 : sg = SALOMEGUI_Swig() -#NRI : BugID 1682 : sg.updateObjBrowser(0) -# salome.sg.updateObjBrowser(0) - return id - + try: + aSObject = geom.AddInStudy(myStudy, aShape, aName, None) + except: + print "addToStudy() failed" + return "" + return aShape.GetStudyEntry() + +# * 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) + except: + print "addToStudyInFather() failed" + return "" + return aShape.GetStudyEntry() + +# ----------------------------------------------------------------------------- +# enumeration ShapeType as a dictionary +# ----------------------------------------------------------------------------- -#NRI : BugID 1682 : sg = SALOMEGUI_Swig() - myBuilder.NewCommand() - newObj = myBuilder.NewObject( salome.IDToSObject(aFather._get_StudyShapeId()) ) - ior = salome.orb.object_to_string(aShape) - A1 = myBuilder.FindOrCreateAttribute(newObj, "AttributeIOR"); - ObjIOR = A1._narrow(SALOMEDS.AttributeIOR) - ObjIOR.SetValue(ior) - A2 = myBuilder.FindOrCreateAttribute(newObj, "AttributeName"); - ObjName = A2._narrow(SALOMEDS.AttributeName) - ObjName.SetValue(aName) - A3 = myBuilder.FindOrCreateAttribute(newObj, "AttributePixMap"); - ObjPixmap = A3._narrow(SALOMEDS.AttributePixMap) - anIcon = gg.getShapeTypeIcon(ior); - ObjPixmap.SetPixMap(anIcon) - id = newObj.GetID() - aShape._set_StudyShapeId(id) - myBuilder.CommitCommand() +ShapeType = {"COMPOUND":0, "COMPSOLID":1, "SOLID":2, "SHELL":3, "FACE":4, "WIRE":5, "EDGE":6, "VERTEX":7, "SHAPE":8} - addArguments( aShape ) +# ----------------------------------------------------------------------------- +# Get Operations Interfaces +# ----------------------------------------------------------------------------- -#NRI : BugID 1682 : sg.updateObjBrowser(0) -# salome.sg.updateObjBrowser(0) - return id +BasicOp = geom.GetIBasicOperations (myStudyId) +CurvesOp = geom.GetICurvesOperations (myStudyId) +PrimOp = geom.GetI3DPrimOperations (myStudyId) +ShapesOp = geom.GetIShapesOperations (myStudyId) +HealOp = geom.GetIHealingOperations (myStudyId) +InsertOp = geom.GetIInsertOperations (myStudyId) +BoolOp = geom.GetIBooleanOperations (myStudyId) +TrsfOp = geom.GetITransformOperations(myStudyId) +LocalOp = geom.GetILocalOperations (myStudyId) +MeasuOp = geom.GetIMeasureOperations (myStudyId) +BlocksOp = geom.GetIBlocksOperations (myStudyId) +GroupOp = geom.GetIGroupOperations (myStudyId) # ----------------------------------------------------------------------------- -# Create Geometry 2D +# Basic primitives # ----------------------------------------------------------------------------- -def MakeVertex(x,y,z): - anObj = geom.MakeVertex(x,y,z) - ior = salome.orb.object_to_string(anObj) - anObj._set_Name(ior) +# * 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 -def MakeVector(p1,p2): - anObj = geom.MakeVector(p1,p2) - ior = salome.orb.object_to_string(anObj) - anObj._set_Name(ior) +# * 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 +# +def MakeVertexOnCurve(theRefCurve, theParameter): + anObj = BasicOp.MakePointOnCurve(theRefCurve, theParameter) + if BasicOp.IsDone() == 0: + print "MakePointOnCurve : ", BasicOp.GetErrorCode() return anObj -def MakeLine(p1,d1): - anObj = geom.MakeLine(p1,d1) - ior = salome.orb.object_to_string(anObj) - anObj._set_Name(ior) +# * 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 +# +def MakeVector(thePnt1, thePnt2): + anObj = BasicOp.MakeVectorTwoPnt(thePnt1, thePnt2) + if BasicOp.IsDone() == 0: + print "MakeVectorTwoPnt : ", BasicOp.GetErrorCode() return anObj -def MakeArc(p1,p2,p3): - anObj = geom.MakeArc(p1,p2,p3) - ior = salome.orb.object_to_string(anObj) - anObj._set_Name(ior) +# * 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 -def MakeCircle(p1,d1,radius): - anObj = geom.MakeCircle(p1,d1,radius) - ior = salome.orb.object_to_string(anObj) - anObj._set_Name(ior) +# * 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 -def MakeEllipse(p1,d1,radiusMaj,radiusMin): - anObj = geom.MakeEllipse(p1,d1,radiusMaj, radiusMin) - ior = salome.orb.object_to_string(anObj) - anObj._set_Name(ior) +# * 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 -def MakePlane(p1,d1,trimsize): - anObj = geom.MakePlane(p1,d1,trimsize) - ior = salome.orb.object_to_string(anObj) - anObj._set_Name(ior) +# * 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 -def MakeSketcher(Cmd): - anObj = geom.MakeSketcher(Cmd) - ior = salome.orb.object_to_string(anObj) - anObj._set_Name(ior) +# * 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 +# +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: + print "MakeMarker : ", BasicOp.GetErrorCode() return anObj # ----------------------------------------------------------------------------- -# Create Geometry 3D +# Curves # ----------------------------------------------------------------------------- -def MakeBox(x1,y1,z1,x2,y2,z2): - anObj = geom.MakeBox(x1,y1,z1,x2,y2,z2) - ior = salome.orb.object_to_string(anObj) - anObj._set_Name(ior) +# * 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 +# +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 +# +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 +# +def MakeEllipse(thePnt, theVec, theRMajor, theRMinor): + anObj = CurvesOp.MakeEllipse(thePnt, theVec, theRMajor, theRMinor) + if CurvesOp.IsDone() == 0: + print "MakeEllipse : ", CurvesOp.GetErrorCode() return anObj -def MakeCylinder(p1,d1,radius,height): - anObj = geom.MakeCylinder(p1,d1,radius,height) - ior = salome.orb.object_to_string(anObj) - anObj._set_Name(ior) +# * 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 -def MakeSphere(x,y,z,radius): - anObj = geom.MakeSphere(x,y,z,radius) - ior = salome.orb.object_to_string(anObj) - anObj._set_Name(ior) +# * 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 -def MakeCone(p1,d1,radius1,radius2,height): - anObj = geom.MakeCone(p1,d1,radius1,radius2,height) - ior = salome.orb.object_to_string(anObj) - anObj._set_Name(ior) +# * 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 -def MakeTorus(p1,d1,major_radius,minor_radius): - anObj = geom.MakeTorus(p1,d1,major_radius,minor_radius) - ior = salome.orb.object_to_string(anObj) - anObj._set_Name(ior) +# * 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: + print "MakeSketcher : ", CurvesOp.GetErrorCode() return anObj # ----------------------------------------------------------------------------- -# Create base objects +# Create 3D Primitives # ----------------------------------------------------------------------------- -def MakeEdge(p1,p2): - anObj = geom.MakeEdge(p1,p2) - ior = salome.orb.object_to_string(anObj) - anObj._set_Name(ior) +# * 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 +# +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 +# +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 +# +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 +# +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 +# +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 +# +def MakeSphere(x, y, z, theR): + point = MakeVertex(x, y, z) + anObj = MakeSpherePntR(point, theR) return anObj -def MakeWire(ListShape): - anObj = geom.MakeWire(ListShape) - ior = salome.orb.object_to_string(anObj) - anObj._set_Name(ior) +# * 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 -def MakeFace(aShapeWire,WantPlanarFace): - anObj = geom.MakeFace(aShapeWire,WantPlanarFace) - ior = salome.orb.object_to_string(anObj) - anObj._set_Name(ior) +# * 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 -def MakeFaces(ListShape,WantPlanarFace): - anObj = geom.MakeFaces(ListShape,WantPlanarFace) - ior = salome.orb.object_to_string(anObj) - anObj._set_Name(ior) +# * 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 -def MakeCompound(ListShape): - anObj = geom.MakeCompound(ListShape) - ior = salome.orb.object_to_string(anObj) - anObj._set_Name(ior) +# * 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 +# +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 +# +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 +# +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 +# +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 +# +def MakeRevolution(theBase, theAxis, theAngle): + anObj = PrimOp.MakeRevolutionAxisAngle(theBase, theAxis, theAngle) + if PrimOp.IsDone() == 0: + print "MakeRevolutionAxisAngle : ", PrimOp.GetErrorCode() return anObj # ----------------------------------------------------------------------------- -# Create advanced objects +# Create base shapes # ----------------------------------------------------------------------------- -def MakeCopy(aShape): - anObj = geom.MakeCopy(aShape) - ior = salome.orb.object_to_string(anObj) - anObj._set_Name(ior) +# * 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 +# +def MakeWire(theEdgesAndWires): + anObj = ShapesOp.MakeWire(theEdgesAndWires) + if ShapesOp.IsDone() == 0: + print "MakeWire : ", ShapesOp.GetErrorCode() return anObj -def MakePrism(baseShape,p1,p2): - anObj = geom.MakePrism(baseShape,p1,p2) - ior = salome.orb.object_to_string(anObj) - anObj._set_Name(ior) +# * 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 -def MakeRevolution(aShape,axis,angle): - anObj = geom.MakeRevolution(aShape,axis,angle) - ior = salome.orb.object_to_string(anObj) - anObj._set_Name(ior) +# * 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 -def MakeFilling(aShape,mindeg,maxdeg,tol3d,tol2d,nbiter): - anObj = geom.MakeFilling(aShape,mindeg,maxdeg,tol3d,tol2d,nbiter) - ior = salome.orb.object_to_string(anObj) - anObj._set_Name(ior) +# * Shortcut to MakeFaceWires() +# +# * Example: see GEOM_TestOthers.py +# +def MakeFaces(theWires, isPlanarWanted): + anObj = MakeFaceWires(theWires, isPlanarWanted) return anObj -def MakePipe(pathShape,baseShape): - anObj = geom.MakePipe(pathShape,baseShape) - ior = salome.orb.object_to_string(anObj) - anObj._set_Name(ior) +# * 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 -def MakeSewing(ListShape,precision): - anObj = geom.MakeSewing(ListShape,precision) - ior = salome.orb.object_to_string(anObj) - anObj._set_Name(ior) +# * 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 +# +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 +# +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 +# +def OrientationChange(theShape): + anObj = ChangeOrientation(theShape) return anObj # ----------------------------------------------------------------------------- -# Boolean (Common, Cut, Fuse, Section) +# Access to sub-shapes by their unique IDs inside the main shape. # ----------------------------------------------------------------------------- -def MakeBoolean(shape1,shape2,operation): - anObj = geom.MakeBoolean(shape1,shape2,operation) - ior = salome.orb.object_to_string(anObj) - anObj._set_Name(ior) +# * 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 +# +def GetSubShapeID(aShape, aSubShape): + anID = LocalOp.GetSubShapeIndex(aShape, aSubShape) + if LocalOp.IsDone() == 0: + print "GetSubShapeIndex : ", LocalOp.GetErrorCode() + return anID + # ----------------------------------------------------------------------------- -# Transform objects +# Decompose objects # ----------------------------------------------------------------------------- -def MakeTranslation(aShape,x,y,z): - anObj = geom.MakeTranslation(aShape,x,y,z) - ior = salome.orb.object_to_string(anObj) - anObj._set_Name(ior) +# * 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 +# +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 +# +def SubShape(aShape, aType, ListOfInd): + ListOfIDs = [] + AllShapeList = SubShapeAll(aShape, aType) + for ind in ListOfInd: + ListOfIDs.append(GetSubShapeID(aShape, AllShapeList[ind - 1])) + 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 +# +def SubShapeSorted(aShape, aType, ListOfInd): + ListOfIDs = [] + AllShapeList = SubShapeAllSorted(aShape, aType) + for ind in ListOfInd: + ListOfIDs.append(GetSubShapeID(aShape, AllShapeList[ind - 1])) + anObj = GetSubShape(aShape, ListOfIDs) return anObj -def MakeRotation(aShape,axis,angle): - anObj = geom.MakeRotation(aShape,axis,angle) - ior = salome.orb.object_to_string(anObj) - anObj._set_Name(ior) +# ----------------------------------------------------------------------------- +# 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 +# +def ProcessShape(theShape, theOperators, theParameters, theValues): + anObj = HealOp.ProcessShape(theShape, theOperators, theParameters, theValues) + if HealOp.IsDone() == 0: + print "ProcessShape : ", HealOp.GetErrorCode() return anObj -def MakeScaleTransform(aShape,theCenterofScale,factor): - anObj = geom.MakeScaleTransform(aShape,theCenterofScale,factor) - ior = salome.orb.object_to_string(anObj) - anObj._set_Name(ior) +# * 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 -def MakeMirrorByPlane(aShape,aPlane): - anObj = geom.MakeMirrorByPlane(aShape,aPlane) - ior = salome.orb.object_to_string(anObj) - anObj._set_Name(ior) +# * 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 -def OrientationChange(aShape): - anObj = geom.OrientationChange(aShape) - ior = salome.orb.object_to_string(anObj) - anObj._set_Name(ior) +# * 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 -def MakeFillet(aShape,radius,ShapeType,ListShape): - anObj = geom.MakeFillet(aShape,radius,ShapeType,ListShape) - ior = salome.orb.object_to_string(anObj) - anObj._set_Name(ior) +# * 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 -def MakeChamfer(aShape,d1,d2,ShapeType,ListShape): - anObj = geom.MakeChamfer(aShape,d1,d2,ShapeType,ListShape) - ior = salome.orb.object_to_string(anObj) - anObj._set_Name(ior) +# * 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 +# +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 +# +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 +# +def GetFreeBoundary(theObject): + anObj = HealOp.GetFreeBoundary(theObject) + if HealOp.IsDone() == 0: + print "GetFreeBoundaries : ", HealOp.GetErrorCode() return anObj # ----------------------------------------------------------------------------- -# Decompose objects +# Create advanced objects # ----------------------------------------------------------------------------- -def SubShape(aShape,type,ListOfId): - anObj = geom.SubShape(aShape,type, ListOfId) - ior = salome.orb.object_to_string(anObj) - anObj._set_Name(ior) +# * 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 -def SubShapeAll(aShape,type): - ListObj = geom.SubShapeAll(aShape,type) - for anObj in ListObj : - ior = salome.orb.object_to_string(anObj) - anObj._set_Name(ior) - return ListObj +# * 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 -def SubShapeSorted(aShape,type,ListOfId): - anObj = geom.SubShapeSorted(aShape,type, ListOfId) - ior = salome.orb.object_to_string(anObj) - anObj._set_Name(ior) +# * 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: + print "MakeGlueFaces : ", ShapesOp.GetErrorCode() return anObj -def SubShapeAllSorted(aShape,type): - ListObj = geom.SubShapeAllSorted(aShape,type) - for anObj in ListObj : - ior = salome.orb.object_to_string(anObj) - anObj._set_Name(ior) - return ListObj +# ----------------------------------------------------------------------------- +# Boolean (Common, Cut, Fuse, Section) +# ----------------------------------------------------------------------------- -# -- enumeration ShapeType as a dictionary -- -ShapeType = {"COMPOUND":0, "COMPSOLID":1, "SOLID":2, "SHELL":3, "FACE":4, "WIRE":5, "EDGE":6, "VERTEX":7, "SHAPE":8} +# * 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 -def Partition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[], Limit=ShapeType["SHAPE"]): - anObj = geom.Partition(ListShapes, ListTools, ListKeepInside, ListRemoveInside, Limit); - ior = salome.orb.object_to_string(anObj) - anObj._set_Name(ior) +# * 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 +# +def MakePartition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[], + Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[]): + anObj = BoolOp.MakePartition(ListShapes, ListTools, + ListKeepInside, ListRemoveInside, + Limit, RemoveWebs, ListMaterials); + if BoolOp.IsDone() == 0: + print "MakePartition : ", BoolOp.GetErrorCode() return anObj -def SuppressFaces(aShape,ListOfId): - ListObj = geom.SuppressFaces(aShape,ListOfId) - for anObj in ListObj : - ior = salome.orb.object_to_string(anObj) - anObj._set_Name(ior) - return ListObj +# * Shortcut to MakePartition() +# +# * Example: see GEOM_TestOthers.py +# +def Partition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[], + Limit=ShapeType["SHAPE"], RemoveWebs=0, ListMaterials=[]): + anObj = MakePartition(ListShapes, ListTools, + ListKeepInside, ListRemoveInside, + Limit, RemoveWebs, ListMaterials); + return anObj + +# ----------------------------------------------------------------------------- +# Transform objects +# ----------------------------------------------------------------------------- -def SuppressHole(aShape,ListOfFace,ListOfWire,ListOfEndFace): - anObj = geom.SuppressHole(aShape,ListOfFace,ListOfWire,ListOfEndFace) - ior = salome.orb.object_to_string(anObj) - anObj._set_Name(ior) +# * 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 +# +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 +# +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 +# +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 +# +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 +# +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 +# +def MakeOffset(theObject, theOffset): + anObj = TrsfOp.OffsetShapeCopy(theObject, theOffset) + if TrsfOp.IsDone() == 0: + print "OffsetShapeCopy : ", TrsfOp.GetErrorCode() return anObj # ----------------------------------------------------------------------------- # Patterns # ----------------------------------------------------------------------------- -def MakeMultiTranslation1D(aShape,aDir,aStep,aNbTimes): - anObj = geom.MakeMultiTranslation1D(aShape,aDir,aStep,aNbTimes) - ior = salome.orb.object_to_string(anObj) - anObj._set_Name(ior) +# * 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 +# +def MakeMultiTranslation2D(theObject, theVector1, theStep1, theNbTimes1, + theVector2, theStep2, theNbTimes2): + anObj = TrsfOp.MultiTranslate2D(theObject, theVector1, theStep1, theNbTimes1, + theVector2, theStep2, theNbTimes2) + if TrsfOp.IsDone() == 0: + 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 +# +def MultiRotate1D(theObject, theAxis, theNbTimes): + anObj = TrsfOp.MultiRotate1D(theObject, theAxis, theNbTimes) + if TrsfOp.IsDone() == 0: + print "MultiRotate1D : ", TrsfOp.GetErrorCode() return anObj -def MakeMultiTranslation2D(aShape,d1,step1,nbtimes1,d2,step2,nbtimes2): - anObj = geom.MakeMultiTranslation2D(aShape,d1,step1,nbtimes1,d2,step2,nbtimes2) - ior = salome.orb.object_to_string(anObj) - anObj._set_Name(ior) +# * 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 +# def MakeMultiRotation1D(aShape,aDir,aPoint,aNbTimes): - anObj = geom.MakeMultiRotation1D(aShape,aDir,aPoint,aNbTimes) - ior = salome.orb.object_to_string(anObj) - anObj._set_Name(ior) + 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 +# def MakeMultiRotation2D(aShape,aDir,aPoint,anAngle,nbtimes1,aStep,nbtimes2): - anObj = geom.MakeMultiRotation2D(aShape,aDir,aPoint,anAngle,nbtimes1,aStep,nbtimes2) - ior = salome.orb.object_to_string(anObj) - anObj._set_Name(ior) + aVec = MakeLine(aPoint,aDir) + anObj = MultiRotate2D(aShape,aVec,anAngle,nbtimes1,aStep,nbtimes2) return anObj # ----------------------------------------------------------------------------- -# Import objects +# Local operations # ----------------------------------------------------------------------------- -def ImportBREP(filename): - anObj = geom.ImportBREP(filename) - ior = salome.orb.object_to_string(anObj) - anObj._set_Name(ior) +# * 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 +# +def MakeFillet(theShape, theR, theShapeType, theListShapes): + anObj = None + if theShapeType == ShapeType["EDGE"]: + anObj = LocalOp.MakeFilletEdges(theShape, theR, theListShapes) + else: + anObj = LocalOp.MakeFilletFaces(theShape, theR, theListShapes) + if LocalOp.IsDone() == 0: + print "MakeFillet : ", LocalOp.GetErrorCode() return anObj -def ImportIGES(filename): - anObj = geom.ImportIGES(filename) - ior = salome.orb.object_to_string(anObj) - anObj._set_Name(ior) +# * 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 -def ImportSTEP(filename): - anObj = geom.ImportSTEP(filename) - ior = salome.orb.object_to_string(anObj) - anObj._set_Name(ior) +# * 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 +# +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 +# +def MakeChamfer(aShape,d1,d2,aShapeType,ListShape): + anObj = None + if aShapeType == ShapeType["EDGE"]: + anObj = MakeChamferEdge(aShape,d1,d2,ListShape[0],ListShape[1]) + else: + 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 +# +def Archimede(theShape, theWeight, theWaterDensity, theMeshDeflection): + anObj = LocalOp.MakeArchimede(theShape, theWeight, theWaterDensity, theMeshDeflection) + if LocalOp.IsDone() == 0: + print "MakeArchimede : ", LocalOp.GetErrorCode() return anObj # ----------------------------------------------------------------------------- -# Export objects +# Information objects # ----------------------------------------------------------------------------- -def ExportBREP(filename,aShape): - geom.ExportBREP(filename,aShape) -def ExportIGES(filename,aShape): - geom.ExportIGES(filename,aShape) +# * 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 +# +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 +# +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 +# +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 +# +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 +# +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 +# +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 +# +def MakeCDG(theShape): + anObj = MeasuOp.GetCentreOfMass(theShape) + if MeasuOp.IsDone() == 0: + print "GetCentreOfMass : ", MeasuOp.GetErrorCode() + return anObj -def ExportSTEP(filename,aShape): - geom.ExportSTEP(filename,aShape) +# * 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: + print "CheckShape : ", MeasuOp.GetErrorCode() + else: + if IsValid == 0: + print Status + return IsValid # ----------------------------------------------------------------------------- -# Information objects +# 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 +# +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 +# +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 +# +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 +# +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") + +# ----------------------------------------------------------------------------- +# Block operations # ----------------------------------------------------------------------------- -def MakeCDG(aShape): - anObj = geom.MakeCDG(aShape) - ior = salome.orb.object_to_string(anObj) - anObj._set_Name(ior) +# * 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 +# +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 +# +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 +# +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 +# +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) + 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 -def Archimede(aShape,weight,WaterDensity,MeshingDeflection): - anObj = geom.Archimede(aShape,weight,WaterDensity,MeshingDeflection) - ior = salome.orb.object_to_string(anObj) - anObj._set_Name(ior) +# * 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 + +# * 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 +# +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 + +# ----------------------------------------------------------------------------- +# 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 +# +def CreateGroup(theMainShape, theShapeType): + anObj = GroupOp.CreateGroup(theMainShape, theShapeType) + if GroupOp.IsDone() == 0: + print "CreateGroup : ", GroupOp.GetErrorCode() return anObj -def CheckShape(aShape): - Status = geom.CheckShape(aShape) - return Status +# * 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 +# +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 +# +def GetObjectIDs(theGroup): + ListIDs = GroupOp.GetObjects(theGroup) + if GroupOp.IsDone() == 0: + print "GetObjectIDs : ", GroupOp.GetErrorCode() + return ListIDs + +# Add Path to the system path +# +def addPath(Path): + if (sys.path.count(Path) < 1): + sys.path.append(Path) diff --git a/src/GenerationGUI/GenerationGUI.cxx b/src/GenerationGUI/GenerationGUI.cxx index 78bc4fdeb..b6ba761b3 100644 --- a/src/GenerationGUI/GenerationGUI.cxx +++ b/src/GenerationGUI/GenerationGUI.cxx @@ -24,28 +24,39 @@ // File : GenerationGUI.cxx // Author : Damien COQUERET // Module : GEOM -// $Header: +// $Header$ using namespace std; #include "GenerationGUI.h" #include "SALOMEGUI_QtCatchCorbaException.hxx" +#include "QAD_Desktop.h" #include "GenerationGUI_PrismDlg.h" // Method PRISM #include "GenerationGUI_RevolDlg.h" // Method REVOL #include "GenerationGUI_FillingDlg.h" // Method FILLING #include "GenerationGUI_PipeDlg.h" // Method PIPE +GenerationGUI* GenerationGUI::myGUIObject = 0; + +//======================================================================= +// function : GetGenerationGUI() +// purpose : Get the only GenerationGUI object [ static ] +//======================================================================= +GenerationGUI* GenerationGUI::GetGenerationGUI() +{ + if ( myGUIObject == 0 ) + myGUIObject = new GenerationGUI(); + + return myGUIObject; +} + //======================================================================= // function : GenerationGUI() // purpose : Constructor //======================================================================= -GenerationGUI::GenerationGUI() : - QObject() +GenerationGUI::GenerationGUI() : GEOMGUI() { - myGeomBase = new GEOMBase(); - myGeomGUI = GEOMContext::GetGeomGUI(); - myGeom = myGeomGUI->myComponentGeom; } @@ -62,164 +73,29 @@ GenerationGUI::~GenerationGUI() // function : OnGUIEvent() // purpose : //======================================================================= -bool GenerationGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) +bool GenerationGUI::OnGUIEvent( int theCommandID, QAD_Desktop* parent ) { - GenerationGUI* myGenerationGUI = new GenerationGUI(); - myGenerationGUI->myGeomGUI->EmitSignalDeactivateDialog(); - SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection()); - - switch (theCommandID) - { - case 4031: // PRISM - { - GenerationGUI_PrismDlg *aDlg = new GenerationGUI_PrismDlg(parent, "", myGenerationGUI, Sel); - break; - } - case 4032: // REVOL - { - GenerationGUI_RevolDlg *aDlg = new GenerationGUI_RevolDlg(parent, "", myGenerationGUI, Sel); - break; - } - case 4033: // FILLING - { - GenerationGUI_FillingDlg *aDlg = new GenerationGUI_FillingDlg(parent, "", myGenerationGUI, Sel); - break; - } - case 4034: // PIPE - { - GenerationGUI_PipeDlg *aDlg = new GenerationGUI_PipeDlg(parent, "", myGenerationGUI, Sel); - break; - } - default: - { - parent->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); - break; - } - } - return true; -} - - -//======================================================================= -// function : MakePrismAndDisplay() -// purpose : P1 and P2 is to define a vector for prism -//======================================================================= -void GenerationGUI::MakePrismAndDisplay(GEOM::GEOM_Shape_ptr BaseShape, const gp_Pnt P1, const gp_Pnt P2) -{ - try { - if(BaseShape->_is_nil()) { - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_NULLSHAPE")); - return; - } - - GEOM::PointStruct PS1 = myGeom->MakePointStruct(P1.X(), P1.Y(), P1.Z()); - GEOM::PointStruct PS2 = myGeom->MakePointStruct(P2.X(), P2.Y(), P2.Z()); - GEOM::GEOM_Shape_ptr result = myGeom->MakePrism(BaseShape, PS1, PS2); - if(result->_is_nil()) { - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_NULLSHAPE")); - return; - } - - TopoDS_Shape S = myGeomGUI->GetShapeReader().GetShape(myGeom, result); - Standard_CString type; - myGeomBase->GetShapeTypeString(S,type); - result->NameType(type); - - if(myGeomBase->Display(result)) - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); + GeometryGUI::GetGeomGUI()->EmitSignalDeactivateDialog(); + + SALOME_Selection* Sel = SALOME_Selection::Selection( + QAD_Application::getDesktop()->getActiveStudy()->getSelection() ); + + QDialog* aDlg = NULL; + + switch ( theCommandID ) + { + case 4031: aDlg = new GenerationGUI_PrismDlg ( parent, "", Sel ); break; + case 4032: aDlg = new GenerationGUI_RevolDlg ( parent, "", Sel ); break; + case 4033: aDlg = new GenerationGUI_FillingDlg ( parent, "", Sel ); break; + case 4034: aDlg = new GenerationGUI_PipeDlg ( parent, "", Sel ); break; + + default: parent->putInfo( tr( "GEOM_PRP_COMMAND" ).arg( theCommandID ) ); break; } - catch(const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return; -} - - -//======================================================================================= -// function : MakeRevolutionAndDisplay() -// purpose : -//======================================================================================= -void GenerationGUI::MakeRevolutionAndDisplay(GEOM::GEOM_Shape_ptr Shape, const gp_Pnt loc, const gp_Dir dir, const Standard_Real revolAngle) -{ - try { - GEOM::AxisStruct axis = myGeom->MakeAxisStruct(loc.X(), loc.Y(), loc.Z(), dir.X(), dir.Y(), dir.Z()); - GEOM::GEOM_Shape_ptr result = myGeom->MakeRevolution(Shape, axis, revolAngle) ; - if(result->_is_nil()) { - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_ABORT")); - return; - } - TopoDS_Shape S = myGeomGUI->GetShapeReader().GetShape(myGeom, result); - Standard_CString type; - myGeomBase->GetShapeTypeString(S,type); - result->NameType(type); - - if(myGeomBase->Display(result)) - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); - } - catch(const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return; -} - - -//===================================================================================== -// function : MakeFillingAndDisplay() -// purpose : -//===================================================================================== -void GenerationGUI::MakeFillingAndDisplay(GEOM::GEOM_Shape_ptr SectionShape, const short mindeg, - const short maxdeg, const double tol3d, - const double tol2d, const short nbiter) -{ - try { - GEOM::GEOM_Shape_ptr result = myGeom->MakeFilling(SectionShape, mindeg, maxdeg, - tol3d, tol2d, nbiter); - if(result->_is_nil()) { - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_NULLSHAPE")); - return; - } - - TopoDS_Shape S = myGeomGUI->GetShapeReader().GetShape(myGeom, result); - Standard_CString type; - myGeomBase->GetShapeTypeString(S,type); - result->NameType(type); - - if(myGeomBase->Display(result)) - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); - return; - } - catch(const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return; -} - - -//===================================================================================== -// function : MakePipeAndDisplay() -// purpose : -//===================================================================================== -void GenerationGUI::MakePipeAndDisplay(GEOM::GEOM_Shape_ptr aPath, GEOM::GEOM_Shape_ptr aBase) -{ - try { - GEOM::GEOM_Shape_ptr result = myGeom->MakePipe(aPath, aBase); - if (!result->_is_nil() && myGeomBase->Display(result)) { - TopoDS_Shape S = myGeomGUI->GetShapeReader().GetShape(myGeom, result); - Standard_CString type; - myGeomBase->GetShapeTypeString(S,type); - result->NameType(type); - - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); - } - else { - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_ABORT")); - } - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return; + if ( aDlg != NULL ) + aDlg->show(); + + return true; } @@ -228,6 +104,8 @@ void GenerationGUI::MakePipeAndDisplay(GEOM::GEOM_Shape_ptr aPath, GEOM::GEOM_Sh //===================================================================================== extern "C" { - bool OnGUIEvent(int theCommandID, QAD_Desktop* parent) - {return GenerationGUI::OnGUIEvent(theCommandID, parent);} + GEOMGUI* GetLibGUI() + { + return GenerationGUI::GetGenerationGUI(); + } } diff --git a/src/GenerationGUI/GenerationGUI.h b/src/GenerationGUI/GenerationGUI.h index c565bda16..cde32bc34 100644 --- a/src/GenerationGUI/GenerationGUI.h +++ b/src/GenerationGUI/GenerationGUI.h @@ -21,41 +21,35 @@ // // // -// File : BooleanGUI.h +// File : GenerationGUI.h // Author : Damien COQUERET // Module : GEOM -// $Header: +// $Header$ #ifndef GENERATIONGUI_H #define GENERATIONGUI_H -#include "GEOMBase.h" +#include "GEOMGUI.h" //================================================================================= // class : GenerationGUI // purpose : //================================================================================= -class GenerationGUI : public QObject +class GenerationGUI : public GEOMGUI { - Q_OBJECT /* for QT compatibility */ +protected: + GenerationGUI(); // hide constructor to avoid direct creation public : - GenerationGUI(); ~GenerationGUI(); - static bool OnGUIEvent(int theCommandID, QAD_Desktop* parent); + // Get the only GenerationGUI object + static GenerationGUI* GetGenerationGUI(); - void MakePrismAndDisplay(GEOM::GEOM_Shape_ptr BaseShape, const gp_Pnt P1, const gp_Pnt P2); - void MakeRevolutionAndDisplay(GEOM::GEOM_Shape_ptr Shape, const gp_Pnt loc, - const gp_Dir dir, Standard_Real revolAngle); - void MakeFillingAndDisplay(GEOM::GEOM_Shape_ptr SectionShape, const short mindeg, const short maxdeg, - const double tol3d, const double tol2d, const short nbiter); - void MakePipeAndDisplay(GEOM::GEOM_Shape_ptr aPath, GEOM::GEOM_Shape_ptr aBase); - - GEOMBase* myGeomBase; - GEOMContext* myGeomGUI; - GEOM::GEOM_Gen_var myGeom; /* Current Geom Component */ + bool OnGUIEvent( int theCommandID, QAD_Desktop* parent ); +private: + static GenerationGUI* myGUIObject; // the only GenerationGUI object }; #endif diff --git a/src/GenerationGUI/GenerationGUI_FillingDlg.cxx b/src/GenerationGUI/GenerationGUI_FillingDlg.cxx index 85d0203b8..2a5478e77 100644 --- a/src/GenerationGUI/GenerationGUI_FillingDlg.cxx +++ b/src/GenerationGUI/GenerationGUI_FillingDlg.cxx @@ -30,6 +30,7 @@ #include "QAD_WaitCursor.h" #include "QAD_Config.h" +#include "QAD_Desktop.h" #include #include @@ -42,11 +43,10 @@ #include #include #include +#include "GEOMImpl_Types.hxx" #include "utilities.h" -using namespace std; - //================================================================================= // class : GenerationGUI_FillingDlg() // purpose : Constructs a GenerationGUI_FillingDlg which is a child of 'parent', with the @@ -54,7 +54,7 @@ using namespace std; // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -GenerationGUI_FillingDlg::GenerationGUI_FillingDlg(QWidget* parent, const char* name, GenerationGUI* theGenerationGUI, SALOME_Selection* Sel, bool modal, WFlags fl) +GenerationGUI_FillingDlg::GenerationGUI_FillingDlg(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_FILLING"))); @@ -77,12 +77,12 @@ GenerationGUI_FillingDlg::GenerationGUI_FillingDlg(QWidget* parent, const char* GroupPoints->TextLabel5->setText(tr("GEOM_FILLING_MAX_DEG")); GroupPoints->TextLabel6->setText(tr("GEOM_FILLING_TOL_3D")); GroupPoints->PushButton1->setPixmap(image1); + GroupPoints->LineEdit1->setReadOnly( true ); - Layout1->addWidget(GroupPoints, 1, 0); + Layout1->addWidget(GroupPoints, 2, 0); /***************************************************************/ /* Initialisations */ - myGenerationGUI = theGenerationGUI; Init(); } @@ -105,16 +105,16 @@ void GenerationGUI_FillingDlg::Init() { /* init variables */ myEditCurrentArgument = GroupPoints->LineEdit1; + GroupPoints->LineEdit1->setReadOnly( true ); myMinDeg = 2; myMaxDeg = 5; myTol3D = 0.0001; myTol2D = 0.0001; myNbIter = 5; - myOkSectionShape = false; + myOkCompound = false; - myCompoundFilter = new GEOM_ShapeTypeFilter(TopAbs_COMPOUND, myGeom); - mySelection->AddFilter(myCompoundFilter); + globalSelection( GEOM_COMPOUND ); double SpecificStep1 = 1; double SpecificStep2 = 0.0001; @@ -152,11 +152,7 @@ void GenerationGUI_FillingDlg::Init() connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ; - /* displays Dialog */ - GroupPoints->show(); - this->show(); - - return; + initName(tr("GEOM_FILLING")); } @@ -166,9 +162,8 @@ void GenerationGUI_FillingDlg::Init() //================================================================================= void GenerationGUI_FillingDlg::ClickOnOk() { - this->ClickOnApply(); - ClickOnCancel(); - return; + if ( ClickOnApply() ) + ClickOnCancel(); } @@ -176,18 +171,13 @@ void GenerationGUI_FillingDlg::ClickOnOk() // function : ClickOnApply() // purpose : //================================================================================= -void GenerationGUI_FillingDlg::ClickOnApply() +bool GenerationGUI_FillingDlg::ClickOnApply() { - buttonApply->setFocus(); - QAD_Application::getDesktop()->putInfo(tr("")); - if (mySimulationTopoDs.IsNull()) - return; - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); + if ( !onAccept() ) + return false; - if(myOkSectionShape) - myGenerationGUI->MakeFillingAndDisplay(myGeomShape, myMinDeg, myMaxDeg, myTol3D, myTol2D, myNbIter); - return; + initName(); + return true; } @@ -197,39 +187,40 @@ void GenerationGUI_FillingDlg::ClickOnApply() //================================================================================= void GenerationGUI_FillingDlg::SelectionIntoArgument() { - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); + erasePreview(); myEditCurrentArgument->setText(""); - QString aString = ""; /* name of selection */ - - int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString); - if(nbSel != 1) { + + if(mySelection->IObjectCount() != 1) { if(myEditCurrentArgument == GroupPoints->LineEdit1) - myOkSectionShape = false; + myOkCompound = false; return; } // nbSel == 1 - Standard_Boolean testResult; - Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); - if(!myGeomBase->GetTopoFromSelection(mySelection, mySectionShape)) + Standard_Boolean testResult = Standard_False; + GEOM::GEOM_Object_ptr aSelectedObject = GEOMBase::ConvertIOinGEOMObject( mySelection->firstIObject(), testResult ); + + if (!testResult) return; - if(myEditCurrentArgument == GroupPoints->LineEdit1 && mySectionShape.ShapeType() == TopAbs_COMPOUND) { - myGeomShape = myGeomBase->ConvertIOinGEOMShape(IO, testResult); - if(!testResult) - return; - // mySectionShape should be a compound of edges - for ( TopoDS_Iterator it( mySectionShape ); it.More(); it.Next() ) - if ( it.Value().ShapeType() != TopAbs_EDGE ) - return; - myEditCurrentArgument->setText(aString); - myOkSectionShape = true; + if(myEditCurrentArgument == GroupPoints->LineEdit1) { + TopoDS_Shape S; + myOkCompound = false; + + if ( GEOMBase::GetShape(aSelectedObject, S) && + S.ShapeType() == TopAbs_COMPOUND) + { + // myCompound should be a compound of edges + for ( TopoDS_Iterator it( S ); it.More(); it.Next() ) + if ( it.Value().ShapeType() != TopAbs_EDGE ) + return; + myCompound = aSelectedObject; + myOkCompound = true; + } } - - if(myOkSectionShape) - this->MakeFillingSimulationAndDisplay(); - return; + + myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) ); + displayPreview(); } @@ -240,16 +231,14 @@ void GenerationGUI_FillingDlg::SelectionIntoArgument() void GenerationGUI_FillingDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); - mySelection->ClearFilters(); + globalSelection( GEOM_ALLSHAPES ); if(send == GroupPoints->PushButton1) { GroupPoints->LineEdit1->setFocus(); myEditCurrentArgument = GroupPoints->LineEdit1; - mySelection->AddFilter(myCompoundFilter); + globalSelection( GEOM_COMPOUND ); this->SelectionIntoArgument(); } - - return; } @@ -261,12 +250,10 @@ void GenerationGUI_FillingDlg::LineEditReturnPressed() { QLineEdit* send = (QLineEdit*)sender(); if(send == GroupPoints->LineEdit1) - myEditCurrentArgument = GroupPoints->LineEdit1; - else - return; - - GEOMBase_Skeleton::LineEditReturnPressed(); - return; + { + myEditCurrentArgument = send; + GEOMBase_Skeleton::LineEditReturnPressed(); + } } @@ -278,10 +265,8 @@ void GenerationGUI_FillingDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - mySelection->AddFilter(myCompoundFilter); - if(!mySimulationTopoDs.IsNull()) - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - return; + globalSelection( GEOM_COMPOUND ); + displayPreview(); } @@ -291,10 +276,8 @@ void GenerationGUI_FillingDlg::ActivateThisDialog() //================================================================================= void GenerationGUI_FillingDlg::enterEvent(QEvent* e) { - if (GroupConstructors->isEnabled()) - return; - this->ActivateThisDialog(); - return; + if ( !GroupConstructors->isEnabled() ) + ActivateThisDialog(); } @@ -317,70 +300,41 @@ void GenerationGUI_FillingDlg::ValueChangedInSpinBox(double newValue) else if(send == GroupPoints->SpinBox_5) myTol3D = newValue; - if(myOkSectionShape) - this->MakeFillingSimulationAndDisplay(); - return; + displayPreview(); +} + +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr GenerationGUI_FillingDlg::createOperation() +{ + return getGeomEngine()->GetI3DPrimOperations( getStudyId() ); } +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool GenerationGUI_FillingDlg::isValid( QString& ) +{ + return myOkCompound > 0; +} //================================================================================= -// function : MakeFillingSimulationAndDisplay() +// function : execute // purpose : //================================================================================= -void GenerationGUI_FillingDlg::MakeFillingSimulationAndDisplay() +bool GenerationGUI_FillingDlg::execute( ObjectList& objects ) { - QAD_WaitCursor wc; - - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); - - try { - /* we verify the contents of the shape */ - TopExp_Explorer Ex; - TopoDS_Shape Scurrent; - Standard_Real First, Last; - Handle(Geom_Curve) C; - GeomFill_SectionGenerator Section; - - Standard_Integer i = 0; - for(Ex.Init(mySectionShape, TopAbs_EDGE); Ex.More(); Ex.Next()) { - Scurrent = Ex.Current(); - if( Scurrent.IsNull() || Scurrent.ShapeType() != TopAbs_EDGE) - return; - C = BRep_Tool::Curve(TopoDS::Edge(Scurrent), First, Last); - if (C.IsNull()) continue; - C = new Geom_TrimmedCurve(C, First, Last); - Section.AddCurve(C) ; - i++ ; - } - - /* a 'tolerance' is used to compare 2 knots : see GeomFill_Generator.cdl */ - /* We set 'tolerance' = tol3d */ - // Section.Perform( tol3d ) ; NRI */ - Section.Perform(Precision::Confusion()); - Handle(GeomFill_Line) Line = new GeomFill_Line(i); - - GeomFill_AppSurf App(myMinDeg, myMaxDeg, myTol3D, myTol2D, myNbIter) ; /* user parameters */ - App.Perform(Line, Section); - - if(!App.IsDone()) - return; + GEOM::GEOM_Object_var anObj; - Standard_Integer UDegree, VDegree, NbUPoles, NbVPoles, NbUKnots, NbVKnots; - App.SurfShape(UDegree, VDegree, NbUPoles, NbVPoles, NbUKnots, NbVKnots); - Handle(Geom_BSplineSurface) GBS = new Geom_BSplineSurface(App.SurfPoles(), App.SurfWeights(), App.SurfUKnots(), App.SurfVKnots(), App.SurfUMults(), App.SurfVMults(), App.UDegree(), App.VDegree()); - - if(GBS.IsNull()) - return; - mySimulationTopoDs = BRepBuilderAPI_MakeFace(GBS); - if(mySimulationTopoDs.IsNull()) - return; - else - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - } - catch(Standard_Failure) { - MESSAGE("Exception catched in MakePrismSimulationAndDisplay" << endl); - return; - } - return; + anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation() )->MakeFilling( + myCompound, myMinDeg, myMaxDeg, myTol2D, myTol3D, myNbIter ); + + if ( !anObj->_is_nil() ) + objects.push_back( anObj._retn() ); + + return true; } + diff --git a/src/GenerationGUI/GenerationGUI_FillingDlg.h b/src/GenerationGUI/GenerationGUI_FillingDlg.h index 967c9d78c..885630cc2 100644 --- a/src/GenerationGUI/GenerationGUI_FillingDlg.h +++ b/src/GenerationGUI/GenerationGUI_FillingDlg.h @@ -32,10 +32,6 @@ #include "GEOMBase_Skeleton.h" #include "DlgRef_1Sel5Spin.h" -#include "GenerationGUI.h" - -#include "GEOM_ShapeTypeFilter.hxx" - //================================================================================= // class : GenerationGUI_FillingDlg // purpose : @@ -45,32 +41,32 @@ class GenerationGUI_FillingDlg : public GEOMBase_Skeleton Q_OBJECT public: - GenerationGUI_FillingDlg(QWidget* parent = 0, const char* name = 0, GenerationGUI* theGenerationGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + GenerationGUI_FillingDlg(QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); ~GenerationGUI_FillingDlg(); +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& msg ); + virtual bool execute( ObjectList& objects ); + private: void Init(); void enterEvent(QEvent* e); - void MakeFillingSimulationAndDisplay(); - - GenerationGUI* myGenerationGUI; - - Handle(GEOM_ShapeTypeFilter) myCompoundFilter; /* Filter selection */ - GEOM::GEOM_Shape_var myGeomShape; /* is mySectionShape */ - TopoDS_Shape mySectionShape; + GEOM::GEOM_Object_var myCompound; /* compound of curves */ Standard_Integer myMinDeg; Standard_Integer myMaxDeg; Standard_Real myTol3D; Standard_Real myTol2D; Standard_Integer myNbIter; - bool myOkSectionShape; /* to check when arguments is defined */ + bool myOkCompound; /* to check when curv. compound is defined */ DlgRef_1Sel5Spin* GroupPoints; private slots: void ClickOnOk(); - void ClickOnApply(); + bool ClickOnApply(); void ActivateThisDialog(); void LineEditReturnPressed(); void SelectionIntoArgument(); diff --git a/src/GenerationGUI/GenerationGUI_PipeDlg.cxx b/src/GenerationGUI/GenerationGUI_PipeDlg.cxx index adb21593b..51674226a 100644 --- a/src/GenerationGUI/GenerationGUI_PipeDlg.cxx +++ b/src/GenerationGUI/GenerationGUI_PipeDlg.cxx @@ -37,9 +37,10 @@ #include #endif -#include "utilities.h" +#include "GEOMImpl_Types.hxx" -using namespace std; +#include "QAD_Desktop.h" +#include "utilities.h" //================================================================================= // class : GenerationGUI_PipeDlg() @@ -48,7 +49,7 @@ using namespace std; // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -GenerationGUI_PipeDlg::GenerationGUI_PipeDlg(QWidget* parent, const char* name, GenerationGUI* theGenerationGUI, SALOME_Selection* Sel, bool modal, WFlags fl) +GenerationGUI_PipeDlg::GenerationGUI_PipeDlg(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_PIPE"))); @@ -68,12 +69,13 @@ GenerationGUI_PipeDlg::GenerationGUI_PipeDlg(QWidget* parent, const char* name, GroupPoints->TextLabel2->setText(tr("GEOM_PATH_OBJECT")); GroupPoints->PushButton1->setPixmap(image1); GroupPoints->PushButton2->setPixmap(image1); + GroupPoints->LineEdit1->setReadOnly( true ); + GroupPoints->LineEdit2->setReadOnly( true ); - Layout1->addWidget(GroupPoints, 1, 0); + Layout1->addWidget(GroupPoints, 2, 0); /***************************************************************/ /* Initialisations */ - myGenerationGUI = theGenerationGUI; Init(); } @@ -96,8 +98,10 @@ void GenerationGUI_PipeDlg::Init() { /* init variables */ myEditCurrentArgument = GroupPoints->LineEdit1; + GroupPoints->LineEdit1->setReadOnly( true ); + GroupPoints->LineEdit2->setReadOnly( true ); - myOkShape1 = myOkShape2 = false; + myOkBase = myOkPath = false; /* signals and slots connections */ connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); @@ -111,11 +115,9 @@ void GenerationGUI_PipeDlg::Init() connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - /* displays Dialog */ - GroupPoints->show(); - this->show(); + initName(tr("GEOM_PIPE")); - return; + globalSelection( GEOM_ALLSHAPES ); } @@ -125,9 +127,8 @@ void GenerationGUI_PipeDlg::Init() //================================================================================= void GenerationGUI_PipeDlg::ClickOnOk() { - this->ClickOnApply(); - ClickOnCancel(); - return; + if ( ClickOnApply() ) + ClickOnCancel(); } @@ -135,18 +136,13 @@ void GenerationGUI_PipeDlg::ClickOnOk() // function : ClickOnAply() // purpose : //================================================================================= -void GenerationGUI_PipeDlg::ClickOnApply() +bool GenerationGUI_PipeDlg::ClickOnApply() { - QAD_Application::getDesktop()->putInfo(tr("")); - if (mySimulationTopoDs.IsNull()) - return; - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); + if ( !onAccept() ) + return false; - if(myOkShape1 && myOkShape2) - myGenerationGUI->MakePipeAndDisplay(myGeomShape2 ,myGeomShape1); - - return; + initName(); + return true; } @@ -156,53 +152,52 @@ void GenerationGUI_PipeDlg::ClickOnApply() //================================================================================= void GenerationGUI_PipeDlg::SelectionIntoArgument() { - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); + erasePreview(); myEditCurrentArgument->setText(""); - QString aString = ""; /* name of selection */ - int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString); - if(nbSel != 1) { + if(mySelection->IObjectCount() != 1) { if(myEditCurrentArgument == GroupPoints->LineEdit1) - myOkShape1 = false; + myOkBase = false; else if(myEditCurrentArgument == GroupPoints->LineEdit2) - myOkShape2 = false; + myOkPath = false; return; } // nbSel == 1 - TopoDS_Shape S; - Standard_Boolean testResult; - Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); - if(!myGeomBase->GetTopoFromSelection(mySelection, S)) + Standard_Boolean testResult = Standard_False; + GEOM::GEOM_Object_ptr aSelectedObject = GEOMBase::ConvertIOinGEOMObject( mySelection->firstIObject(), testResult ); + + if (!testResult) return; + TopoDS_Shape S; + if(myEditCurrentArgument == GroupPoints->LineEdit1) { - myOkShape1 = false; - if(S.ShapeType() != TopAbs_COMPSOLID && S.ShapeType() != TopAbs_COMPOUND && S.ShapeType() != TopAbs_SOLID && S.ShapeType() != TopAbs_SHAPE) { - myGeomShape1 = myGeomBase->ConvertIOinGEOMShape(IO, testResult); - if(!testResult) - return; - myEditCurrentArgument->setText(aString); - myOkShape1 = true; - myShape1 = S; - } + myOkBase = false; + + if(!GEOMBase::GetShape(aSelectedObject, S) || + S.ShapeType() == TopAbs_COMPSOLID || + S.ShapeType() == TopAbs_COMPOUND || + S.ShapeType() == TopAbs_SOLID || + S.ShapeType() == TopAbs_SHAPE) + return; + + myBase = aSelectedObject; + myOkBase = true; } else if(myEditCurrentArgument == GroupPoints->LineEdit2) { - myOkShape2 = false; - if(S.ShapeType() == TopAbs_WIRE || S.ShapeType() == TopAbs_EDGE ) { - myGeomShape2 = myGeomBase->ConvertIOinGEOMShape(IO, testResult); - if(!testResult) - return; - myEditCurrentArgument->setText(aString); - myOkShape2 = true; - myShape2 = S; - } + myOkPath = false; + + if(!GEOMBase::GetShape(aSelectedObject, S) || + !(S.ShapeType() == TopAbs_WIRE || S.ShapeType() == TopAbs_EDGE) ) + return; + + myPath = aSelectedObject; + myOkPath = true; } - - if(myOkShape1 && myOkShape2) - this->MakePipeSimulationAndDisplay(); - return; + myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) ); + + displayPreview(); } @@ -222,9 +217,7 @@ void GenerationGUI_PipeDlg::SetEditCurrentArgument() GroupPoints->LineEdit2->setFocus(); myEditCurrentArgument = GroupPoints->LineEdit2; } - this->SelectionIntoArgument(); - - return; + SelectionIntoArgument(); } @@ -235,15 +228,12 @@ void GenerationGUI_PipeDlg::SetEditCurrentArgument() void GenerationGUI_PipeDlg::LineEditReturnPressed() { QLineEdit* send = (QLineEdit*)sender(); - if(send == GroupPoints->LineEdit1) - myEditCurrentArgument = GroupPoints->LineEdit1; - else if (send == GroupPoints->LineEdit2) - myEditCurrentArgument = GroupPoints->LineEdit2; - else - return; - - GEOMBase_Skeleton::LineEditReturnPressed(); - return; + if(send == GroupPoints->LineEdit1 || + send == GroupPoints->LineEdit2) + { + myEditCurrentArgument = send; + GEOMBase_Skeleton::LineEditReturnPressed(); + } } @@ -253,10 +243,8 @@ void GenerationGUI_PipeDlg::LineEditReturnPressed() //================================================================================= void GenerationGUI_PipeDlg::enterEvent(QEvent* e) { - if (GroupConstructors->isEnabled()) - return; - this->ActivateThisDialog(); - return; + if ( !GroupConstructors->isEnabled() ) + ActivateThisDialog(); } @@ -267,47 +255,46 @@ void GenerationGUI_PipeDlg::enterEvent(QEvent* e) void GenerationGUI_PipeDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); + globalSelection( GEOM_ALLSHAPES ); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - if(!mySimulationTopoDs.IsNull()) - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - return; + displayPreview(); } //================================================================================= -// function : MakeMirrorSimulationAndDisplay() -// purpose : S1 is a shape and S2 a mirror. +// function : createOperation +// purpose : //================================================================================= -void GenerationGUI_PipeDlg::MakePipeSimulationAndDisplay() +GEOM::GEOM_IOperations_ptr GenerationGUI_PipeDlg::createOperation() { - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); - - try { - TopoDS_Wire aWire; - - if(myShape2.ShapeType() == TopAbs_WIRE) - aWire = TopoDS::Wire(myShape2); - else if(myShape2.ShapeType() == TopAbs_EDGE) { - TopoDS_Edge aEdge = TopoDS::Edge(myShape2); - aWire = BRepBuilderAPI_MakeWire(aEdge); - } + return getGeomEngine()->GetI3DPrimOperations( getStudyId() ); +} - TopoDS_Shape tds = BRepOffsetAPI_MakePipe(aWire,myShape1); -#if OCC_VERSION_MAJOR >= 5 - if(BRepAlgo::IsValid(tds)) -#else - if(BRepAlgoAPI::IsValid(tds)) -#endif - { - //Draw Pipe - mySimulationTopoDs = tds; - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - } - } - catch(Standard_Failure) { - MESSAGE("Exception catched in MakePipeSimulationAndDisplay"); - return; - } - return; +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool GenerationGUI_PipeDlg::isValid( QString& ) +{ + return myOkBase && myOkPath; +} + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool GenerationGUI_PipeDlg::execute( ObjectList& objects ) +{ + GEOM::GEOM_Object_var anObj; + + anObj = GEOM::GEOM_I3DPrimOperations::_narrow( + getOperation() )->MakePipe( myBase, myPath ); + + if ( !anObj->_is_nil() ) + objects.push_back( anObj._retn() ); + + return true; } + + + diff --git a/src/GenerationGUI/GenerationGUI_PipeDlg.h b/src/GenerationGUI/GenerationGUI_PipeDlg.h index 795c36ed4..6df389000 100644 --- a/src/GenerationGUI/GenerationGUI_PipeDlg.h +++ b/src/GenerationGUI/GenerationGUI_PipeDlg.h @@ -32,8 +32,6 @@ #include "GEOMBase_Skeleton.h" #include "DlgRef_2Sel_QTD.h" -#include "GenerationGUI.h" - //================================================================================= // class : GenerationGUI_PipeDlg // purpose : @@ -43,28 +41,29 @@ class GenerationGUI_PipeDlg : public GEOMBase_Skeleton Q_OBJECT public: - GenerationGUI_PipeDlg(QWidget* parent = 0, const char* name = 0, GenerationGUI* theGenerationGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + GenerationGUI_PipeDlg(QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); ~GenerationGUI_PipeDlg(); +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& msg ); + virtual bool execute( ObjectList& objects ); + private: void Init(); void enterEvent(QEvent* e); - void MakePipeSimulationAndDisplay(); - - GenerationGUI* myGenerationGUI; - TopoDS_Shape myShape1; /* topology used */ - TopoDS_Shape myShape2; /* topology used */ - GEOM::GEOM_Shape_var myGeomShape1; /* is myShape1 */ - GEOM::GEOM_Shape_var myGeomShape2; /* is myShape2 */ - bool myOkShape1; - bool myOkShape2; /* to check when arguments are defined */ + GEOM::GEOM_Object_var myBase; /* Base shape */ + GEOM::GEOM_Object_var myPath; /* Shape, defining the path */ + bool myOkBase; + bool myOkPath ; /* to check when arguments are defined */ DlgRef_2Sel_QTD* GroupPoints; private slots: void ClickOnOk(); - void ClickOnApply(); + bool ClickOnApply(); void ActivateThisDialog(); void LineEditReturnPressed(); void SelectionIntoArgument(); diff --git a/src/GenerationGUI/GenerationGUI_PrismDlg.cxx b/src/GenerationGUI/GenerationGUI_PrismDlg.cxx index 90fc67b70..bd18da9b4 100644 --- a/src/GenerationGUI/GenerationGUI_PrismDlg.cxx +++ b/src/GenerationGUI/GenerationGUI_PrismDlg.cxx @@ -29,11 +29,15 @@ #include "GenerationGUI_PrismDlg.h" #include +#include +#include #include "QAD_Config.h" +#include "QAD_Desktop.h" +#include "GEOMImpl_Types.hxx" -#include "utilities.h" +#include -using namespace std; +#include "utilities.h" //================================================================================= // class : GenerationGUI_PrismDlg() @@ -42,7 +46,7 @@ using namespace std; // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -GenerationGUI_PrismDlg::GenerationGUI_PrismDlg(QWidget* parent, const char* name, GenerationGUI* theGenerationGUI, SALOME_Selection* Sel, bool modal, WFlags fl) +GenerationGUI_PrismDlg::GenerationGUI_PrismDlg(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_PRISM"))); @@ -56,20 +60,22 @@ GenerationGUI_PrismDlg::GenerationGUI_PrismDlg(QWidget* parent, const char* name RadioButton2->close(TRUE); RadioButton3->close(TRUE); - GroupPoints = new DlgRef_2Sel1Spin1Check(this, "GroupPoints"); + GroupPoints = new DlgRef_2Sel1Spin2Check(this, "GroupPoints"); + GroupPoints->CheckButton1->hide(); GroupPoints->GroupBox1->setTitle(tr("GEOM_PRISM_BSV")); GroupPoints->TextLabel1->setText(tr("GEOM_BASE")); GroupPoints->TextLabel2->setText(tr("GEOM_VECTOR")); GroupPoints->TextLabel3->setText(tr("GEOM_HEIGHT")); - GroupPoints->CheckButton1->setText(tr("GEOM_REVERSE")); GroupPoints->PushButton1->setPixmap(image1); GroupPoints->PushButton2->setPixmap(image1); + GroupPoints->LineEdit1->setReadOnly( true ); + GroupPoints->LineEdit2->setReadOnly( true ); + GroupPoints->CheckButton2->setText(tr("GEOM_REVERSE")); - Layout1->addWidget(GroupPoints, 1, 0); + Layout1->addWidget(GroupPoints, 2, 0); /***************************************************************/ /* Initialisations */ - myGenerationGUI = theGenerationGUI; Init(); } @@ -92,20 +98,18 @@ void GenerationGUI_PrismDlg::Init() { /* init variables */ myEditCurrentArgument = GroupPoints->LineEdit1; + GroupPoints->LineEdit1->setReadOnly( true ); + GroupPoints->LineEdit2->setReadOnly( true ); - myHeight = 100.000; - myDx = myDy = myDz = 0.0; - myOkBase = myOkLine = false; - - myEdgeFilter = new GEOM_ShapeTypeFilter(TopAbs_EDGE, myGeom); - + myOkBase = myOkVec = false; + /* Get setting of step value from file configuration */ QString St = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep"); - step = St.toDouble(); + double step = St.toDouble(); /* min, max, step and decimals for spin boxes & initial values */ - GroupPoints->SpinBox_DX->RangeStepAndValidator(0.001, 999.999, step, 3); - GroupPoints->SpinBox_DX->SetValue(myHeight); + GroupPoints->SpinBox_DX->RangeStepAndValidator(-999.999, +999.999, step, 3); + GroupPoints->SpinBox_DX->SetValue(100.0); /* signals and slots connections */ connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); @@ -117,17 +121,16 @@ void GenerationGUI_PrismDlg::Init() connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox_DX, SLOT(SetStep(double))); - connect(GroupPoints->CheckButton1, SIGNAL(stateChanged(int)), this, SLOT(ReverseVector(int))); - + + connect(GroupPoints->CheckButton2, SIGNAL(toggled(bool)), this, SLOT(onReverse())); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ; - /* displays Dialog */ - GroupPoints->show(); - this->show(); + initName(tr("GEOM_PRISM")); - return; + globalSelection( GEOM_ALLSHAPES ); } @@ -137,9 +140,8 @@ void GenerationGUI_PrismDlg::Init() //================================================================================= void GenerationGUI_PrismDlg::ClickOnOk() { - this->ClickOnApply(); - ClickOnCancel(); - return; + if ( ClickOnApply() ) + ClickOnCancel(); } @@ -147,33 +149,13 @@ void GenerationGUI_PrismDlg::ClickOnOk() // function : ClickOnApply() // purpose : //================================================================================= -void GenerationGUI_PrismDlg::ClickOnApply() +bool GenerationGUI_PrismDlg::ClickOnApply() { - buttonApply->setFocus(); - QAD_Application::getDesktop()->putInfo(tr("")); - if (mySimulationTopoDs.IsNull()) - return; - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); + if ( !onAccept() ) + return false; - gp_Pnt P1, P2; - - try { - gp_Vec Vec(myDx, myDy, myDz); - Vec.Normalize(); - Vec *= myHeight; - P1.SetCoord(0.0, 0.0, 0.0); - P2.SetCoord(Vec.X(), Vec.Y(), Vec.Z()); - - if(myOkBase && myOkLine) - myGenerationGUI->MakePrismAndDisplay(myGeomShape, P1, P2); - } - catch(Standard_Failure) { - MESSAGE("Exception intercepted in GenerationGUI_PrismDlg" << endl); - return; - } - - return; + initName(); + return true; } @@ -183,48 +165,43 @@ void GenerationGUI_PrismDlg::ClickOnApply() //================================================================================= void GenerationGUI_PrismDlg::SelectionIntoArgument() { - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); + erasePreview(); myEditCurrentArgument->setText(""); - QString aString = ""; /* name of selection */ - int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString); - if(nbSel != 1) { - if(myEditCurrentArgument == GroupPoints->LineEdit1) - myOkBase = false; - else if(myEditCurrentArgument == GroupPoints->LineEdit2) - myOkLine = false; - return; - } + if(mySelection->IObjectCount() != 1) + { + if(myEditCurrentArgument == GroupPoints->LineEdit1) + myOkBase = false; + else if(myEditCurrentArgument == GroupPoints->LineEdit2) + myOkVec = false; + return; + } // nbSel == 1 - TopoDS_Shape S; - Standard_Boolean testResult; - Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); - if(!myGeomBase->GetTopoFromSelection(mySelection, S)) - return; - - gp_Pnt aPoint1, aPoint2; + Standard_Boolean testResult = Standard_False; + GEOM::GEOM_Object_ptr aSelectedObject = GEOMBase::ConvertIOinGEOMObject( mySelection->firstIObject(), testResult ); + if (!testResult) + return; + if(myEditCurrentArgument == GroupPoints->LineEdit1) { - myGeomShape = myGeomBase->ConvertIOinGEOMShape(IO, testResult); - if(!testResult) - return; - if(S.ShapeType() <= 2) + myOkBase = false; + TopoDS_Shape S; + + if ( !GEOMBase::GetShape(aSelectedObject, S) || + S.ShapeType() <= 2) return; - myEditCurrentArgument->setText(aString); + + myBase = aSelectedObject; myOkBase = true; - myBaseTopo = S; } - else if(myEditCurrentArgument == GroupPoints->LineEdit2 && myGeomBase->LinearEdgeExtremities(S, aPoint1, aPoint2)) { - myGeomBase->GetBipointDxDyDz(aPoint1, aPoint2, myDx, myDy, myDz); - myEditCurrentArgument->setText(aString); - myOkLine = true; + else if(myEditCurrentArgument == GroupPoints->LineEdit2) { + myVec = aSelectedObject; + myOkVec = true; } - - if(myOkBase && myOkLine) - this->MakePrismSimulationAndDisplay(); - return; + myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) ); + + displayPreview(); } @@ -235,7 +212,7 @@ void GenerationGUI_PrismDlg::SelectionIntoArgument() void GenerationGUI_PrismDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); - mySelection->ClearFilters(); + globalSelection( GEOM_ALLSHAPES ); if(send == GroupPoints->PushButton1) { GroupPoints->LineEdit1->setFocus(); @@ -244,11 +221,9 @@ void GenerationGUI_PrismDlg::SetEditCurrentArgument() else if(send == GroupPoints->PushButton2) { GroupPoints->LineEdit2->setFocus(); myEditCurrentArgument = GroupPoints->LineEdit2; - mySelection->AddFilter(myEdgeFilter); + globalSelection( GEOM_LINE ); } - this->SelectionIntoArgument(); - - return; + SelectionIntoArgument(); } @@ -259,28 +234,22 @@ void GenerationGUI_PrismDlg::SetEditCurrentArgument() void GenerationGUI_PrismDlg::LineEditReturnPressed() { QLineEdit* send = (QLineEdit*)sender(); - if(send == GroupPoints->LineEdit1) - myEditCurrentArgument = GroupPoints->LineEdit1; - else if (send == GroupPoints->LineEdit2) - myEditCurrentArgument = GroupPoints->LineEdit2; - else - return; - - GEOMBase_Skeleton::LineEditReturnPressed(); - return; + if(send == GroupPoints->LineEdit1 || + send == GroupPoints->LineEdit2) + { + myEditCurrentArgument = send; + GEOMBase_Skeleton::LineEditReturnPressed(); + } } - //================================================================================= // function : enterEvent() // purpose : when mouse enter onto the QWidget //================================================================================= void GenerationGUI_PrismDlg::enterEvent(QEvent * e) { - if (GroupConstructors->isEnabled()) - return; - this->ActivateThisDialog(); - return; + if ( !GroupConstructors->isEnabled() ) + ActivateThisDialog(); } @@ -291,12 +260,11 @@ void GenerationGUI_PrismDlg::enterEvent(QEvent * e) void GenerationGUI_PrismDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); + globalSelection( GEOM_ALLSHAPES ); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); GroupPoints->LineEdit1->setFocus(); myEditCurrentArgument = GroupPoints->LineEdit1; - if(!mySimulationTopoDs.IsNull()) - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - return; + displayPreview(); } @@ -304,52 +272,66 @@ void GenerationGUI_PrismDlg::ActivateThisDialog() // function : ValueChangedInSpinBox() // purpose : //================================================================================= -void GenerationGUI_PrismDlg::ValueChangedInSpinBox(double newValue) +void GenerationGUI_PrismDlg::ValueChangedInSpinBox() { - myHeight = newValue; - if(myOkBase && myOkLine) - this->MakePrismSimulationAndDisplay(); - return; + displayPreview(); } + //================================================================================= -// function : ReverseVector() -// purpose : 'state' not used here +// function : getHeight() +// purpose : //================================================================================= -void GenerationGUI_PrismDlg::ReverseVector(int state) +double GenerationGUI_PrismDlg::getHeight() const { - myDx = -myDx; - myDy = -myDy; - myDz = -myDz; - if(myOkBase && myOkLine) - this->MakePrismSimulationAndDisplay(); - return; -} + return GroupPoints->SpinBox_DX->GetValue(); +} +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr GenerationGUI_PrismDlg::createOperation() +{ + return getGeomEngine()->GetI3DPrimOperations( getStudyId() ); +} //================================================================================= -// function : MakePrismSimulationAndDisplay() +// function : isValid // purpose : //================================================================================= -void GenerationGUI_PrismDlg::MakePrismSimulationAndDisplay() +bool GenerationGUI_PrismDlg::isValid( QString& ) { - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); - - try { - gp_Vec Vec(myDx, myDy, myDz); - Vec.Normalize(); - Vec *= myHeight; - mySimulationTopoDs = BRepPrimAPI_MakePrism(myBaseTopo, Vec, Standard_False).Shape(); - if(mySimulationTopoDs.IsNull()) - return; - else - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - } - catch(Standard_Failure) { - MESSAGE("Exception catched in MakePrismSimulationAndDisplay" << endl); - return; - } - return; + return myOkBase && myOkVec; } + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool GenerationGUI_PrismDlg::execute( ObjectList& objects ) +{ + GEOM::GEOM_Object_var anObj; + + anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation() )->MakePrismVecH ( myBase, myVec, getHeight() ); + + if ( !anObj->_is_nil() ) + objects.push_back( anObj._retn() ); + + return true; +} + + +//================================================================================= +// function : onReverse() +// purpose : +//================================================================================= +void GenerationGUI_PrismDlg::onReverse() +{ + double anOldValue = GroupPoints->SpinBox_DX->GetValue(); + GroupPoints->SpinBox_DX->SetValue( -anOldValue ); +} + + + diff --git a/src/GenerationGUI/GenerationGUI_PrismDlg.h b/src/GenerationGUI/GenerationGUI_PrismDlg.h index 77b47a410..3b90b2ecb 100644 --- a/src/GenerationGUI/GenerationGUI_PrismDlg.h +++ b/src/GenerationGUI/GenerationGUI_PrismDlg.h @@ -30,11 +30,7 @@ #define DIALOGBOX_PRISM_H #include "GEOMBase_Skeleton.h" -#include "DlgRef_2Sel1Spin1Check.h" - -#include "GenerationGUI.h" - -#include "GEOM_ShapeTypeFilter.hxx" +#include "DlgRef_2Sel1Spin2Check.h" //================================================================================= // class : GenerationGUI_PrismDlg @@ -45,40 +41,37 @@ class GenerationGUI_PrismDlg : public GEOMBase_Skeleton Q_OBJECT public: - GenerationGUI_PrismDlg(QWidget* parent = 0, const char* name = 0, GenerationGUI* theGenerationGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + GenerationGUI_PrismDlg(QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); ~GenerationGUI_PrismDlg(); +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& msg ); + virtual bool execute( ObjectList& objects ); + private : void Init(); void enterEvent(QEvent* e); - void MakePrismSimulationAndDisplay(); + double getHeight() const; - GenerationGUI* myGenerationGUI; + GEOM::GEOM_Object_var myBase; /* Base shape */ + GEOM::GEOM_Object_var myVec; /* Vector, defining the direction */ - double step; - Handle(GEOM_ShapeTypeFilter) myEdgeFilter; /* Filters selection */ - - Standard_Real myDx; - Standard_Real myDy; - Standard_Real myDz; - Standard_Real myHeight; /* Height used for prism (extrusion) */ - TopoDS_Shape myBaseTopo; /* topology used as base of prism */ - GEOM::GEOM_Shape_var myGeomShape; /* that is myBaseTopo */ bool myOkBase; - bool myOkLine; /* to check when arguments myDx, myDy, myDz are defined */ + bool myOkVec; - DlgRef_2Sel1Spin1Check* GroupPoints; + DlgRef_2Sel1Spin2Check* GroupPoints; private slots: void ClickOnOk(); - void ClickOnApply(); + bool ClickOnApply(); void ActivateThisDialog(); void LineEditReturnPressed(); void SelectionIntoArgument(); void SetEditCurrentArgument(); - void ReverseVector(int state); - void ValueChangedInSpinBox(double newValue); - + void ValueChangedInSpinBox(); + void onReverse(); }; #endif // DIALOGBOX_PRISM_H diff --git a/src/GenerationGUI/GenerationGUI_RevolDlg.cxx b/src/GenerationGUI/GenerationGUI_RevolDlg.cxx index 0aa52712c..f811dba46 100644 --- a/src/GenerationGUI/GenerationGUI_RevolDlg.cxx +++ b/src/GenerationGUI/GenerationGUI_RevolDlg.cxx @@ -32,12 +32,14 @@ #include #include #include "QAD_Config.h" +#include "QAD_Desktop.h" #include #include +#include "GEOMImpl_Types.hxx" -#include "utilities.h" +#include -using namespace std; +#include "utilities.h" //================================================================================= // class : GenerationGUI_RevolDlg() @@ -46,7 +48,7 @@ using namespace std; // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -GenerationGUI_RevolDlg::GenerationGUI_RevolDlg(QWidget* parent, const char* name, GenerationGUI* theGenerationGUI, SALOME_Selection* Sel, bool modal, WFlags fl) +GenerationGUI_RevolDlg::GenerationGUI_RevolDlg(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_REVOL"))); @@ -60,20 +62,22 @@ GenerationGUI_RevolDlg::GenerationGUI_RevolDlg(QWidget* parent, const char* name RadioButton2->close(TRUE); RadioButton3->close(TRUE); - GroupPoints = new DlgRef_2Sel1Spin1Check(this, "GroupPoints"); + GroupPoints = new DlgRef_2Sel1Spin2Check(this, "GroupPoints"); + GroupPoints->CheckButton1->hide(); GroupPoints->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); GroupPoints->TextLabel1->setText(tr("GEOM_OBJECT")); GroupPoints->TextLabel2->setText(tr("GEOM_AXIS")); GroupPoints->TextLabel3->setText(tr("GEOM_ANGLE")); - GroupPoints->CheckButton1->setText(tr("GEOM_REVERSE")); GroupPoints->PushButton1->setPixmap(image1); GroupPoints->PushButton2->setPixmap(image1); + GroupPoints->LineEdit1->setReadOnly( true ); + GroupPoints->LineEdit2->setReadOnly( true ); + GroupPoints->CheckButton2->setText(tr("GEOM_REVERSE")); - Layout1->addWidget(GroupPoints, 1, 0); + Layout1->addWidget(GroupPoints, 2, 0); /***************************************************************/ /* Initialisations */ - myGenerationGUI = theGenerationGUI; Init(); } @@ -96,16 +100,15 @@ void GenerationGUI_RevolDlg::Init() { /* init variables */ myEditCurrentArgument = GroupPoints->LineEdit1; + GroupPoints->LineEdit1->setReadOnly( true ); + GroupPoints->LineEdit2->setReadOnly( true ); - myAngle = 45.0; myOkBase = myOkAxis = false; - myEdgeFilter = new GEOM_ShapeTypeFilter(TopAbs_EDGE, myGeom); - double SpecificStep = 5; /* min, max, step and decimals for spin boxes & initial values */ GroupPoints->SpinBox_DX->RangeStepAndValidator(-999.999, 999.999, SpecificStep, 3); - GroupPoints->SpinBox_DX->SetValue(myAngle); + GroupPoints->SpinBox_DX->SetValue(45.0); /* signals and slots connections */ connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); @@ -117,18 +120,16 @@ void GenerationGUI_RevolDlg::Init() connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox_DX, SLOT(SetStep(double))); + connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); + connect(GroupPoints->CheckButton2, SIGNAL(toggled(bool)), this, SLOT(onReverse())); - connect(GroupPoints->CheckButton1, SIGNAL(stateChanged(int)), this, SLOT(ReverseAngle(int))); - + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox_DX, SLOT(SetStep(double))); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ; - /* displays Dialog */ - GroupPoints->show(); - this->show(); + initName(tr("GEOM_REVOLUTION")); - return; + globalSelection( GEOM_ALLSHAPES ); } @@ -138,9 +139,8 @@ void GenerationGUI_RevolDlg::Init() //================================================================================= void GenerationGUI_RevolDlg::ClickOnOk() { - this->ClickOnApply(); - ClickOnCancel(); - return; + if ( ClickOnApply() ) + ClickOnCancel(); } @@ -148,18 +148,13 @@ void GenerationGUI_RevolDlg::ClickOnOk() // function : ClickOnApply() // purpose : //================================================================================= -void GenerationGUI_RevolDlg::ClickOnApply() +bool GenerationGUI_RevolDlg::ClickOnApply() { - buttonApply->setFocus(); - QAD_Application::getDesktop()->putInfo(tr("")); - if (mySimulationTopoDs.IsNull()) - return; - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); + if ( !onAccept() ) + return false; - if(myOkBase && myOkAxis) - myGenerationGUI->MakeRevolutionAndDisplay(myGeomShape, myLoc, myDir, myAngle*PI180); - return; + initName(); + return true; } //======================================================================= @@ -195,48 +190,41 @@ static bool isAcceptableBase(const TopoDS_Shape& theBase) //================================================================================= void GenerationGUI_RevolDlg::SelectionIntoArgument() { - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); + erasePreview(); myEditCurrentArgument->setText(""); - QString aString = ""; /* name of selection */ - int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString); - if(nbSel != 1) { + if(mySelection->IObjectCount() != 1) { if(myEditCurrentArgument == GroupPoints->LineEdit1) - myOkBase = false; + myOkBase = false; else if(myEditCurrentArgument == GroupPoints->LineEdit2) myOkAxis = false; return; } // nbSel == 1 - TopoDS_Shape S; - Standard_Boolean testResult; - Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); - if(!myGeomBase->GetTopoFromSelection(mySelection, S)) + Standard_Boolean testResult = Standard_False; + GEOM::GEOM_Object_ptr aSelectedObject = GEOMBase::ConvertIOinGEOMObject( mySelection->firstIObject(), testResult ); + + if (!testResult) return; - + if(myEditCurrentArgument == GroupPoints->LineEdit1) { - myGeomShape = myGeomBase->ConvertIOinGEOMShape(IO, testResult); - if(!testResult) - return; - if( !isAcceptableBase( S )) + TopoDS_Shape S; + myOkBase = false; + + if ( !GEOMBase::GetShape(aSelectedObject, S) || !isAcceptableBase( S ) ) return; - myEditCurrentArgument->setText(aString); + + myBase = aSelectedObject; myOkBase = true; - myBase = S; } else if(myEditCurrentArgument == GroupPoints->LineEdit2) { - BRepAdaptor_Curve curv(TopoDS::Edge(S)); - myDir = curv.Line().Direction(); - myLoc = curv.Line().Location(); - myEditCurrentArgument->setText(aString); + myAxis = aSelectedObject; myOkAxis = true; } + myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) ); - if(myOkBase && myOkAxis) - this->MakeRevolutionSimulationAndDisplay(); - return; + displayPreview(); } @@ -247,7 +235,7 @@ void GenerationGUI_RevolDlg::SelectionIntoArgument() void GenerationGUI_RevolDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); - mySelection->ClearFilters(); + globalSelection( GEOM_ALLSHAPES ); if(send == GroupPoints->PushButton1) { GroupPoints->LineEdit1->setFocus(); @@ -256,11 +244,9 @@ void GenerationGUI_RevolDlg::SetEditCurrentArgument() else if(send == GroupPoints->PushButton2) { GroupPoints->LineEdit2->setFocus(); myEditCurrentArgument = GroupPoints->LineEdit2; - mySelection->AddFilter(myEdgeFilter); + globalSelection( GEOM_LINE ); } - this->SelectionIntoArgument(); - - return; + SelectionIntoArgument(); } @@ -271,15 +257,12 @@ void GenerationGUI_RevolDlg::SetEditCurrentArgument() void GenerationGUI_RevolDlg::LineEditReturnPressed() { QLineEdit* send = (QLineEdit*)sender(); - if(send == GroupPoints->LineEdit1) - myEditCurrentArgument = GroupPoints->LineEdit1; - else if (send == GroupPoints->LineEdit2) - myEditCurrentArgument = GroupPoints->LineEdit2; - else - return; - - GEOMBase_Skeleton::LineEditReturnPressed(); - return; + if(send == GroupPoints->LineEdit1 || + send == GroupPoints->LineEdit2) + { + myEditCurrentArgument = send; + GEOMBase_Skeleton::LineEditReturnPressed(); + } } @@ -290,12 +273,11 @@ void GenerationGUI_RevolDlg::LineEditReturnPressed() void GenerationGUI_RevolDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); + globalSelection( GEOM_ALLSHAPES ); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); GroupPoints->LineEdit1->setFocus(); myEditCurrentArgument = GroupPoints->LineEdit1; - if(!mySimulationTopoDs.IsNull()) - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - return; + displayPreview(); } @@ -305,10 +287,8 @@ void GenerationGUI_RevolDlg::ActivateThisDialog() //================================================================================= void GenerationGUI_RevolDlg::enterEvent(QEvent* e) { - if (GroupConstructors->isEnabled()) - return; - this->ActivateThisDialog(); - return; + if ( !GroupConstructors->isEnabled() ) + ActivateThisDialog(); } @@ -316,49 +296,63 @@ void GenerationGUI_RevolDlg::enterEvent(QEvent* e) // function : ValueChangedInSpinBox() // purpose : //================================================================================= -void GenerationGUI_RevolDlg::ValueChangedInSpinBox(double newValue) -{ - myAngle = newValue; - if(myOkBase && myOkAxis) - this->MakeRevolutionSimulationAndDisplay(); - return; +void GenerationGUI_RevolDlg::ValueChangedInSpinBox() +{ + displayPreview(); } //================================================================================= -// function : ReverseAngle() -// purpose : 'state' not used here +// function : getAngle() +// purpose : +//================================================================================= +double GenerationGUI_RevolDlg::getAngle() const +{ + return GroupPoints->SpinBox_DX->GetValue(); +} + +//================================================================================= +// function : createOperation +// purpose : //================================================================================= -void GenerationGUI_RevolDlg::ReverseAngle(int state) +GEOM::GEOM_IOperations_ptr GenerationGUI_RevolDlg::createOperation() { - myAngle = -myAngle; - GroupPoints->SpinBox_DX->SetValue(myAngle); - if(myOkBase && myOkAxis) - this->MakeRevolutionSimulationAndDisplay(); - return; + return getGeomEngine()->GetI3DPrimOperations( getStudyId() ); } +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool GenerationGUI_RevolDlg::isValid( QString& ) +{ + return myOkBase && myOkAxis; +} //================================================================================= -// function : MakeRevolutionSimulationAndDisplay() +// function : execute // purpose : //================================================================================= -void GenerationGUI_RevolDlg::MakeRevolutionSimulationAndDisplay() +bool GenerationGUI_RevolDlg::execute( ObjectList& objects ) { - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); + GEOM::GEOM_Object_var anObj; - if (!isAcceptableBase( myBase )) - return; + anObj = GEOM::GEOM_I3DPrimOperations::_narrow( + getOperation() )->MakeRevolutionAxisAngle( myBase, myAxis, getAngle() * PI180 ); - try { - gp_Ax1 AX(myLoc, myDir); - mySimulationTopoDs = BRepPrimAPI_MakeRevol(myBase, AX, myAngle*PI180); - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - } - catch(Standard_Failure) { - MESSAGE("Exception catched in MakeRevolutionSimulationAndDisplay"); - return; - } - return; + if ( !anObj->_is_nil() ) + objects.push_back( anObj._retn() ); + + return true; +} + + +//================================================================================= +// function : onReverse() +// purpose : +//================================================================================= +void GenerationGUI_RevolDlg::onReverse() +{ + double anOldValue = GroupPoints->SpinBox_DX->GetValue(); + GroupPoints->SpinBox_DX->SetValue( -anOldValue ); } diff --git a/src/GenerationGUI/GenerationGUI_RevolDlg.h b/src/GenerationGUI/GenerationGUI_RevolDlg.h index eddc3c30f..acc71d3d0 100644 --- a/src/GenerationGUI/GenerationGUI_RevolDlg.h +++ b/src/GenerationGUI/GenerationGUI_RevolDlg.h @@ -30,11 +30,8 @@ #define DIALOGBOX_REVOLUTION_H #include "GEOMBase_Skeleton.h" -#include "DlgRef_2Sel1Spin1Check.h" +#include "DlgRef_2Sel1Spin2Check.h" -#include "GenerationGUI.h" - -#include "GEOM_ShapeTypeFilter.hxx" #include //================================================================================= @@ -46,37 +43,36 @@ class GenerationGUI_RevolDlg : public GEOMBase_Skeleton Q_OBJECT public: - GenerationGUI_RevolDlg(QWidget* parent = 0, const char* name = 0, GenerationGUI* theGenerationGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + GenerationGUI_RevolDlg(QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); ~GenerationGUI_RevolDlg(); +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& msg ); + virtual bool execute( ObjectList& objects ); + private : void Init(); void enterEvent(QEvent* e); - void MakeRevolutionSimulationAndDisplay(); - - GenerationGUI* myGenerationGUI; - - Handle(GEOM_ShapeTypeFilter) myEdgeFilter; /* Filters selection */ + double getAngle() const; - TopoDS_Shape myBase; - GEOM::GEOM_Shape_var myGeomShape; /* is myBase */ - gp_Pnt myLoc; - gp_Dir myDir; - Standard_Real myAngle; + GEOM::GEOM_Object_var myBase; /* Base shape */ + GEOM::GEOM_Object_var myAxis; /* Axis of the revolution */ bool myOkBase; bool myOkAxis; - DlgRef_2Sel1Spin1Check* GroupPoints; + DlgRef_2Sel1Spin2Check* GroupPoints; private slots: void ClickOnOk(); - void ClickOnApply(); + bool ClickOnApply(); void ActivateThisDialog(); void LineEditReturnPressed(); void SelectionIntoArgument(); void SetEditCurrentArgument(); - void ReverseAngle(int state); - void ValueChangedInSpinBox(double newValue); + void ValueChangedInSpinBox(); + void onReverse(); }; diff --git a/src/GenerationGUI/Makefile.in b/src/GenerationGUI/Makefile.in index 06eb796c0..66f3f7df3 100644 --- a/src/GenerationGUI/Makefile.in +++ b/src/GenerationGUI/Makefile.in @@ -47,15 +47,14 @@ LIB_SRC = GenerationGUI.cxx \ GenerationGUI_PipeDlg.cxx LIB_MOC = \ - GenerationGUI.h \ GenerationGUI_PrismDlg.h \ GenerationGUI_RevolDlg.h \ GenerationGUI_FillingDlg.h \ GenerationGUI_PipeDlg.h -LIB_CLIENT_IDL = +LIB_CLIENT_IDL = SALOME_GenericObj.idl SALOME_Component.idl -LIB_SERVER_IDL = +LIB_SERVER_IDL = # additionnal information to compil and link file diff --git a/src/GroupGUI/GroupGUI.cxx b/src/GroupGUI/GroupGUI.cxx new file mode 100644 index 000000000..6252e88bd --- /dev/null +++ b/src/GroupGUI/GroupGUI.cxx @@ -0,0 +1,134 @@ +// 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.salome-platform.org or email : webmaster.salome@opencascade.org +// +// +// +// File : GroupGUI.cxx +// Author : Sergey ANIKIN +// Module : GEOM +// $Header$ + +#include "GroupGUI.h" +#include "GroupGUI_GroupDlg.h" + +#include "GEOMImpl_Types.hxx" + +#include "SALOMEGUI_QtCatchCorbaException.hxx" +#include "QAD_Desktop.h" +#include "QAD_MessageBox.h" + +GroupGUI* GroupGUI::myGUIObject = 0; + +//======================================================================= +// function : GetGroupGUI() +// purpose : Get the only GroupGUI object [ static ] +//======================================================================= +GroupGUI* GroupGUI::GetGroupGUI() +{ + if ( myGUIObject == 0 ) + myGUIObject = new GroupGUI(); + + return myGUIObject; +} + +//======================================================================= +// function : GroupGUI() +// purpose : Constructor +//======================================================================= +GroupGUI::GroupGUI() +: GEOMGUI() +{ +} + + +//======================================================================= +// function : ~GroupGUI() +// purpose : Destructor +//======================================================================= +GroupGUI::~GroupGUI() +{ +} + + +//======================================================================= +// function : OnGUIEvent() +// purpose : +//======================================================================= +bool GroupGUI::OnGUIEvent( int theCommandID, QAD_Desktop* parent ) +{ + GeometryGUI::GetGeomGUI()->EmitSignalDeactivateDialog(); + + SALOME_Selection* Sel = SALOME_Selection::Selection( + QAD_Application::getDesktop()->getActiveStudy()->getSelection() ); + + QDialog* aDlg = NULL; + + if ( QAD_Application::getDesktop()->getActiveStudy()->isLocked() ) { + QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), + QObject::tr("WRN_WARNING"), + QObject::tr("WRN_STUDY_LOCKED"), + QObject::tr("BUT_OK") ); + return false; + } + + switch ( theCommandID ) { + case 800: + aDlg = new GroupGUI_GroupDlg( GroupGUI_GroupDlg::CreateGroup, parent, "", Sel ); + break; + case 801: + { + if ( Sel->IObjectCount() == 1 ) { + Standard_Boolean aResult = Standard_False; + GEOM::GEOM_Object_var anObj = + GEOMBase::ConvertIOinGEOMObject( Sel->firstIObject(), aResult ); + + if ( aResult && !CORBA::is_nil( anObj ) && anObj->GetType() == GEOM_GROUP ) { + aDlg = new GroupGUI_GroupDlg( GroupGUI_GroupDlg::EditGroup, parent, "", Sel ); + break; + } + } + QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), + tr("WRN_WARNING"), + tr("NO_GROUP"), + tr("BUT_OK") ); + break; + } + default: + parent->putInfo( tr( "GEOM_PRP_COMMAND" ).arg( theCommandID ) ); + break; + } + + if ( aDlg != NULL ) + aDlg->show(); + + return true; +} + +//===================================================================================== +// EXPORTED METHODS +//===================================================================================== +extern "C" +{ + GEOMGUI* GetLibGUI() + { + return GroupGUI::GetGroupGUI(); + } +} diff --git a/src/GroupGUI/GroupGUI.h b/src/GroupGUI/GroupGUI.h new file mode 100644 index 000000000..dd3fd8de9 --- /dev/null +++ b/src/GroupGUI/GroupGUI.h @@ -0,0 +1,57 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2004 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org or email : webmaster.salome@opencascade.org +// +// +// +// File : GroupGUI.h +// Author : Sergey ANIKIN +// Module : GEOM +// $Header$ + +#ifndef GROUPGUI_H +#define GROUPGUI_H + +#include "GEOMGUI.h" + +//================================================================================= +// class : GroupGUI +// purpose : +//================================================================================= +class GroupGUI : public GEOMGUI +{ + Q_OBJECT + +protected: + GroupGUI(); // hide constructor to avoid direct creation + +public : + ~GroupGUI(); + + // Get the only GroupGUI object + static GroupGUI* GetGroupGUI(); + + bool OnGUIEvent( int theCommandID, QAD_Desktop* parent ); + +private: + static GroupGUI* myGUIObject; // the only GroupGUI object +}; + +#endif diff --git a/src/GroupGUI/GroupGUI_GroupDlg.cxx b/src/GroupGUI/GroupGUI_GroupDlg.cxx new file mode 100644 index 000000000..0559aaff7 --- /dev/null +++ b/src/GroupGUI/GroupGUI_GroupDlg.cxx @@ -0,0 +1,648 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2004 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org or email : webmaster.salome@opencascade.org +// +// +// +// File : GroupGUI_GroupDlg.cxx +// Author : Sergey ANIKIN +// Module : GEOM +// $Header$ + +#include "GroupGUI_GroupDlg.h" + +#include "GEOMBase.h" + +#include "GEOMImpl_Types.hxx" + +#include "QAD_Desktop.h" + +#include +#include +#include +#include + +#include +#include + +GroupGUI_GroupDlg::GroupGUI_GroupDlg(Mode mode, + QWidget* parent, + const char* name, + SALOME_Selection* Sel, + bool modal, + WFlags fl) + :GEOMBase_Skeleton( parent, "GroupGUI_GroupDlg", Sel, false, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu), + myMode( mode ), + myBusy( false ) +{ + QPixmap image0( QAD_Desktop::getResourceManager()->loadPixmap( "GEOM", tr( "ICON_OBJBROWSER_VERTEX" ) ) ); + QPixmap image1( QAD_Desktop::getResourceManager()->loadPixmap( "GEOM", tr( "ICON_OBJBROWSER_EDGE" ) ) ); + QPixmap image2( QAD_Desktop::getResourceManager()->loadPixmap( "GEOM", tr( "ICON_OBJBROWSER_FACE" ) ) ); + QPixmap image3( QAD_Desktop::getResourceManager()->loadPixmap( "GEOM", tr( "ICON_OBJBROWSER_SOLID" ) ) ); + + QPixmap iconSelect( QAD_Desktop::getResourceManager()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) ); + + setCaption( myMode == CreateGroup ? tr( "CREATE_GROUP_TITLE" ) : tr( "EDIT_GROUP_TITLE" ) ); + + // Shape type button group + GroupConstructors->setEnabled( myMode == CreateGroup ); + GroupConstructors->setTitle( tr( "SHAPE_TYPE" ) ); + RadioButton1->setPixmap( image0 ); + RadioButton2->setPixmap( image1 ); + RadioButton3->setPixmap( image2 ); + RadioButton4->setPixmap( image3 ); + RadioButton4->show(); + + // Group name + GroupBoxName->setTitle( tr( "GROUP_NAME" ) ); + + // Main shape and sub-shapes + GroupMedium = new QGroupBox( 1, Qt::Vertical, tr( "MAIN_SUB_SHAPES" ), this ); + GroupMedium->setInsideMargin( 10 ); + Layout1->addWidget( GroupMedium, 2, 0 ); + + QWidget* aFrame = new QWidget( GroupMedium ); + QGridLayout* aMedLayout = new QGridLayout( aFrame, 4, 4, 0, 6 ); + + QLabel* aMainLabel = new QLabel( tr( "MAIN_SHAPE" ), aFrame ); + + mySelBtn = new QPushButton( aFrame ); + mySelBtn->setPixmap( iconSelect ); + mySelBtn->setEnabled( myMode == CreateGroup ); + + myMainName = new QLineEdit( aFrame ); + myMainName->setReadOnly( true ); + myMainName->setEnabled( myMode == CreateGroup ); + + mySelSubBtn = new QPushButton( tr( "SELECT_SUB_SHAPES" ), aFrame ); + mySelAllBtn = new QPushButton( tr( "SELECT_ALL" ), aFrame ); + myAddBtn = new QPushButton( tr( "ADD" ), aFrame ); + myRemBtn = new QPushButton( tr( "REMOVE" ), aFrame ); + myIdList = new QListBox( aFrame ); + + myIdList->setSelectionMode( QListBox::Extended ); + myIdList->setRowMode( QListBox::FitToWidth ); + + aMedLayout->addWidget( aMainLabel, 0, 0 ); + aMedLayout->addWidget( mySelBtn, 0, 1 ); + aMedLayout->addMultiCellWidget( myMainName, 0, 0, 2, 3 ); + aMedLayout->addMultiCellWidget( mySelSubBtn, 1, 1, 0, 2 ); + aMedLayout->addWidget( mySelAllBtn, 1, 3 ); + aMedLayout->addMultiCellWidget( myIdList, 2, 3, 0, 2 ); + aMedLayout->addWidget( myAddBtn, 2, 3 ); + aMedLayout->addWidget( myRemBtn, 3, 3 ); + + Init( Sel ); +} + +GroupGUI_GroupDlg::~GroupGUI_GroupDlg() +{ +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void GroupGUI_GroupDlg::Init( SALOME_Selection* Sel ) +{ + mySelection = Sel; + + // san -- TODO: clear selected sub-shapes... + + if ( myMode == CreateGroup ) { + initName( tr( "GROUP_PREFIX" ) ); + + // Get ready for main shape selection + myEditCurrentArgument = myMainName; + + connect( GroupConstructors, SIGNAL( clicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) ); + connect( mySelBtn, SIGNAL( clicked() ), this, SLOT(SetEditCurrentArgument())); + } + else if ( myMode == EditGroup && Sel->IObjectCount() ) { + Standard_Boolean aResult = Standard_False; + GEOM::GEOM_Object_var anObj = + GEOMBase::ConvertIOinGEOMObject( Sel->firstIObject(), aResult ); + + if ( aResult && !CORBA::is_nil( anObj ) && anObj->GetType() == GEOM_GROUP ) { + myGroup = anObj; + + ResultName->setText( GEOMBase::GetName( myGroup ) ); + + GEOM::GEOM_IGroupOperations_var anOp = GEOM::GEOM_IGroupOperations::_narrow( getOperation() ); + myMainObj = anOp->GetMainShape( myGroup ); + if ( !CORBA::is_nil( myMainObj ) ) + myMainName->setText( GEOMBase::GetName( myMainObj ) ); + + setShapeType( (TopAbs_ShapeEnum)anOp->GetType( myGroup ) ); + + GEOM::ListOfLong_var aCurrList = anOp->GetObjects( myGroup ); + QListBoxItem* anItem; + for ( int i = 0, n = aCurrList->length(); i < n; i++ ) { + anItem = new QListBoxText( QString( "%1" ).arg(aCurrList[i] ) ); + myIdList->insertItem( anItem ); + } + + myEditCurrentArgument = 0; + } + } + + connect( buttonOk , SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); + connect( buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) ); + + connect( mySelSubBtn, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); + connect( mySelAllBtn, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); + connect( mySelection,SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + connect( mySelAllBtn, SIGNAL( clicked() ), this, SLOT( selectAllSubShapes() ) ); + connect( myAddBtn, SIGNAL( clicked() ), this, SLOT( add() ) ); + connect( myRemBtn, SIGNAL( clicked() ), this, SLOT( remove() ) ); + connect( myIdList, SIGNAL( selectionChanged() ), this, SLOT( selectionChanged() ) ); + + activateSelection(); +} + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void GroupGUI_GroupDlg::enterEvent( QEvent* e ) +{ + if ( !buttonCancel->isEnabled() ) + this->ActivateThisDialog(); +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void GroupGUI_GroupDlg::ClickOnOk() +{ + if ( ClickOnApply() ) + ClickOnCancel(); +} + + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +bool GroupGUI_GroupDlg::ClickOnApply() +{ + if ( !onAccept( myMode == CreateGroup, true ) ) + return false; + + if ( myMode == CreateGroup ) + initName(); + return true; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void GroupGUI_GroupDlg::ActivateThisDialog() +{ + GEOMBase_Skeleton::ActivateThisDialog(); + + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + + activateSelection(); +} + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void GroupGUI_GroupDlg::LineEditReturnPressed() +{ + QLineEdit* send = ( QLineEdit* )sender(); + + if ( send == myMainName && !myEditCurrentArgument ) { + myEditCurrentArgument = myMainName; + activateSelection(); + } + else + GEOMBase_Skeleton::LineEditReturnPressed(); + + updateState(); +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void GroupGUI_GroupDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + + if ( send == mySelBtn ) + myEditCurrentArgument = myMainName; + else if ( send == mySelSubBtn || send == mySelAllBtn ) + myEditCurrentArgument = 0; + + activateSelection(); + updateState(); +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection has changed +//================================================================================= +void GroupGUI_GroupDlg::SelectionIntoArgument() +{ + if ( myEditCurrentArgument ) { // Selection of a main shape is active + myEditCurrentArgument->setText( "" ); + + if ( mySelection->IObjectCount() == 1 ) { + Standard_Boolean aResult = Standard_False; + GEOM::GEOM_Object_var anObj = + GEOMBase::ConvertIOinGEOMObject( mySelection->firstIObject(), aResult ); + + if ( aResult && !anObj->_is_nil() && GEOMBase::IsShape( anObj ) ) { + myMainObj = anObj; + myEditCurrentArgument->setText( GEOMBase::GetName( anObj ) ); + updateState(); + return; + } + } + + myMainObj = GEOM::GEOM_Object::_nil(); + } + else { // an attempt to synchronize list box selection with 3d viewer + if ( myBusy ) + return; + + bool isBlocked = myIdList->signalsBlocked(); + myIdList->blockSignals( true ); + myIdList->clearSelection(); + + if ( mySelection->IObjectCount() == 1 ) { + Standard_Boolean aResult = Standard_False; + GEOM::GEOM_Object_var anObj = + GEOMBase::ConvertIOinGEOMObject( mySelection->firstIObject(), aResult ); + + if ( aResult && !anObj->_is_nil() ) { + QMap aMap; + for ( int i = 0, n = myIdList->count(); i < n; i++ ) + aMap.insert( myIdList->item( i )->text().toInt(), i ); + + TColStd_IndexedMapOfInteger aMapIndex; + mySelection->GetIndex( mySelection->firstIObject(), aMapIndex ); + for ( int ii = 1, nn = aMapIndex.Extent(); ii <= nn; ii++ ) { + if ( aMap.contains( aMapIndex( ii ) ) ) + myIdList->setSelected( aMap[aMapIndex( ii )], true ); + } + } + } + + myIdList->blockSignals( isBlocked ); + } + + updateState(); +} + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void GroupGUI_GroupDlg::ConstructorsClicked( int constructorId ) +{ + myIdList->clear(); + activateSelection(); + updateState(); +} + +//================================================================================= +// function : selectAllSubShapes +// purpose : +//================================================================================= +void GroupGUI_GroupDlg::selectAllSubShapes() +{ + if ( CORBA::is_nil( myMainObj ) ) + return; + + GEOM::GEOM_IShapesOperations_var aShOp = getGeomEngine()->GetIShapesOperations( getStudyId() ); + GEOM::GEOM_ILocalOperations_var aLocOp = getGeomEngine()->GetILocalOperations( getStudyId() ); + + GEOM::ListOfGO_var aSubShapes = aShOp->MakeExplode( myMainObj, getShapeType(), false ); + if ( !aShOp->IsDone() ) + return; + + bool isBlocked = myIdList->signalsBlocked(); + myIdList->blockSignals( true ); + myIdList->clear(); + + QListBoxItem* anItem; + for ( int i = 0, n = aSubShapes->length(); i < n; i++ ) { + CORBA::Long anIndex = aLocOp->GetSubShapeIndex( myMainObj, aSubShapes[i] ); + if ( anIndex < 0 ) + continue; + + anItem = new QListBoxText( QString( "%1" ).arg( anIndex ) ); + myIdList->insertItem( anItem ); + myIdList->setSelected( anItem, true ); + } + + myIdList->blockSignals( isBlocked ); + highlightSubShapes(); + updateState(); +} + +//================================================================================= +// function : add +// purpose : +//================================================================================= +void GroupGUI_GroupDlg::add() +{ + TColStd_MapOfInteger aMap; + for ( int i = 0, n = myIdList->count(); i < n; i++ ) + aMap.Add( myIdList->item( i )->text().toInt() ); + + if ( mySelection->IObjectCount() == 1 ) { + Standard_Boolean aResult = Standard_False; + GEOM::GEOM_Object_var anObj = + GEOMBase::ConvertIOinGEOMObject( mySelection->firstIObject(), aResult ); + + if ( aResult && !anObj->_is_nil() ) { + TColStd_IndexedMapOfInteger aMapIndex; + mySelection->GetIndex( mySelection->firstIObject(), aMapIndex ); + QListBoxItem* anItem; + bool isBlocked = myIdList->signalsBlocked(); + myIdList->blockSignals( true ); + + for ( int i = 1, n = aMapIndex.Extent(); i <= n; i++ ) { + if ( aMap.Contains( aMapIndex( i ) ) ) + continue; + + anItem = new QListBoxText( QString( "%1" ).arg( aMapIndex( i ) ) ); + myIdList->insertItem( anItem ); + myIdList->setSelected( anItem, true ); + } + + myIdList->blockSignals( isBlocked ); + } + } + updateState(); +} + +//================================================================================= +// function : remove +// purpose : +//================================================================================= +void GroupGUI_GroupDlg::remove() +{ + for ( int i = myIdList->count() - 1; i >= 0; i-- ) { + if ( myIdList->isSelected( i ) ) + myIdList->removeItem( i ); + } + updateState(); +} + + +//================================================================================= +// function : getConstructorId() +// purpose : +//================================================================================= +int GroupGUI_GroupDlg::getConstructorId() const +{ + return GroupConstructors->id( GroupConstructors->selected() ); +} + +//================================================================================= +// function : getShapeType() +// purpose : +//================================================================================= +TopAbs_ShapeEnum GroupGUI_GroupDlg::getShapeType() const +{ + switch ( getConstructorId() ) { + case 0: return TopAbs_VERTEX; + case 1: return TopAbs_EDGE; + case 2: return TopAbs_FACE; + case 3: return TopAbs_SOLID; + default: return TopAbs_SHAPE; + } +} + +//================================================================================= +// function : setShapeType() +// purpose : +//================================================================================= +void GroupGUI_GroupDlg::setShapeType( const TopAbs_ShapeEnum theType ) +{ + int anId = 0; + switch ( theType ) { + case TopAbs_VERTEX: anId = 0; break; + case TopAbs_EDGE: anId = 1; break; + case TopAbs_FACE: anId = 2; break; + case TopAbs_SOLID: anId = 3; break; + } + GroupConstructors->setButton( anId ); +} + + +//================================================================================= +// function : activateSelection +// purpose : Activate selection in accordance with myEditCurrentArgument +//================================================================================= +void GroupGUI_GroupDlg::activateSelection() +{ + globalSelection( GEOM_ALLSHAPES ); + + if ( !myMainObj->_is_nil() && !myEditCurrentArgument ) { + localSelection( myMainObj, getShapeType() ); + } + + SelectionIntoArgument(); +} + +//================================================================================= +// function : updateState +// purpose : +//================================================================================= +void GroupGUI_GroupDlg::updateState() +{ + bool isAdd = false; + if ( mySelection->IObjectCount() == 1 ) { + Standard_Boolean aResult = Standard_False; + GEOM::GEOM_Object_var anObj = + GEOMBase::ConvertIOinGEOMObject( mySelection->firstIObject(), aResult ); + + if ( aResult && !anObj->_is_nil() ) { + TColStd_IndexedMapOfInteger aMapIndex; + mySelection->GetIndex( mySelection->firstIObject(), aMapIndex ); + isAdd = aMapIndex.Extent() > 0; + } + } + myAddBtn->setEnabled( !myEditCurrentArgument && !CORBA::is_nil( myMainObj ) && isAdd ); + bool hasSel = false; + for ( int ii = 0, nn = myIdList->count(); !hasSel && ii < nn; ii++ ) + hasSel = myIdList->isSelected( ii ); + myRemBtn->setEnabled( hasSel ); + mySelSubBtn->setEnabled( !CORBA::is_nil( myMainObj ) ); + mySelAllBtn->setEnabled( !CORBA::is_nil( myMainObj ) ); +} + +//================================================================================= +// function : selectionChanged +// purpose : +//================================================================================= +void GroupGUI_GroupDlg::selectionChanged() +{ + highlightSubShapes(); +} + +//================================================================================= +// function : highlightSubShapes +// purpose : +//================================================================================= +void GroupGUI_GroupDlg::highlightSubShapes() +{ + if ( CORBA::is_nil( myMainObj ) ) + return; + + Standard_Boolean isOk; + Handle(GEOM_AISShape) aSh = + GEOMBase::ConvertIORinGEOMAISShape( GEOMBase::GetIORFromObject( myMainObj ), isOk, true ); + if ( !isOk || aSh.IsNull() ) + return; + + TColStd_MapOfInteger anIds; + + myBusy = true; + + for ( int ii = 0, nn = myIdList->count(); ii < nn; ii++ ) + if ( myIdList->isSelected( ii ) ) + anIds.Add( myIdList->item( ii )->text().toInt() ); + + mySelection->ClearIObjects(); + mySelection->AddOrRemoveIndex( aSh->getIO(), anIds, false, true ); + + myBusy = false; + + updateState(); +} + +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr GroupGUI_GroupDlg::createOperation() +{ + return getGeomEngine()->GetIGroupOperations( getStudyId() ); +} + +#define RETURN_WITH_MSG(a, b) \ + if ( !(a) ) { \ + theMessage += (b); \ + return false; \ + } + +//================================================================================= +// function : isValid() +// purpose : Verify validity of input data +//================================================================================= +bool GroupGUI_GroupDlg::isValid( QString& theMessage ) +{ + QAD_Study* study = getStudy(); + ASSERT(study); + RETURN_WITH_MSG ( !study->getStudyDocument()->GetProperties()->IsLocked(), tr( "GEOM_STUDY_LOCKED" ) ) + + if ( myMode == CreateGroup ) { + RETURN_WITH_MSG( !CORBA::is_nil( myMainObj ), tr( "NO_MAIN_OBJ" ) ) + } + else { + RETURN_WITH_MSG( !CORBA::is_nil( myMainObj ), tr( "NO_GROUP" ) ) + } + + const char* aName = getNewObjectName(); + RETURN_WITH_MSG ( aName && strlen( aName ), tr( "EMPTY_NAME" ) ) + + RETURN_WITH_MSG ( myIdList->count(), tr( "EMPTY_LIST" ) ) + return true; +} + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool GroupGUI_GroupDlg::execute( ObjectList& objects ) +{ + GEOM::GEOM_IGroupOperations_var anOp = GEOM::GEOM_IGroupOperations::_narrow( getOperation() ); + + GEOM::GEOM_Object_var aGroup; + if ( myMode == CreateGroup ) + aGroup = anOp->CreateGroup( myMainObj, getShapeType() ); + else if ( myMode == EditGroup ) + aGroup = myGroup; + + if ( CORBA::is_nil( aGroup ) || ( myMode == CreateGroup && !anOp->IsDone() ) ) + return false; + + GEOM::ListOfLong_var aCurrList = anOp->GetObjects( aGroup ); + if ( !anOp->IsDone() ) + return false; + + for ( int i = 0, n = aCurrList->length(); i < n; i++ ) { + anOp->RemoveObject( aGroup, aCurrList[i] ); + if ( !anOp->IsDone() ) + return false; + } + + for ( int ii = 0, nn = myIdList->count(); ii < nn; ii++ ) { + anOp->AddObject( aGroup, myIdList->item( ii )->text().toInt() ); + if ( !anOp->IsDone() ) + return false; + } + + QAD_Study* study = getStudy(); + if ( study ) { + string IOR = GEOMBase::GetIORFromObject( aGroup ); + if ( IOR != "" ) { + SALOMEDS::SObject_var SO = study->getStudyDocument()->FindObjectIOR( IOR.c_str() ); + if ( !SO->_is_nil() ) { + SALOMEDS::StudyBuilder_var aBuilder = study->getStudyDocument()->NewBuilder(); + aBuilder->SetName( SO, getNewObjectName() ); + } + } + } + + objects.push_back( aGroup._retn() ); + + return true; +} + +//================================================================ +// Function : getFather +// Purpose : Get father object for object to be added in study +// ( called with addInStudy method ) +//================================================================ +GEOM::GEOM_Object_ptr GroupGUI_GroupDlg::getFather( GEOM::GEOM_Object_ptr theObj ) +{ + GEOM::GEOM_Object_var aFatherObj; + if ( theObj->GetType() == GEOM_GROUP ) { + GEOM::GEOM_IGroupOperations_var anOp = GEOM::GEOM_IGroupOperations::_narrow( getOperation() ); + aFatherObj = anOp->GetMainShape( theObj ); + } + return aFatherObj._retn(); +} diff --git a/src/GroupGUI/GroupGUI_GroupDlg.h b/src/GroupGUI/GroupGUI_GroupDlg.h new file mode 100644 index 000000000..d2da0e231 --- /dev/null +++ b/src/GroupGUI/GroupGUI_GroupDlg.h @@ -0,0 +1,103 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2004 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org or email : webmaster.salome@opencascade.org +// +// +// +// File : GroupGUI_GroupDlg.h +// Author : Sergey ANIKIN +// Module : GEOM +// $Header$ + +#ifndef GROUPGUI_GROUPDLG_H +#define GROUPGUI_GROUPDLG_H + +#include "GEOMBase_Skeleton.h" + +#include + +class QLineEdit; +class QListBox; + +//================================================================================= +// class : GroupGUI_GroupDlg +// purpose : +//================================================================================= +class GroupGUI_GroupDlg : public GEOMBase_Skeleton +{ + Q_OBJECT + +public: + typedef enum { + CreateGroup, + EditGroup + } Mode; + + GroupGUI_GroupDlg(Mode mode, QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + ~GroupGUI_GroupDlg(); + +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& msg ); + virtual bool execute( ObjectList& objects ); + virtual GEOM::GEOM_Object_ptr getFather( GEOM::GEOM_Object_ptr theObj ); + + +private slots: + void ClickOnOk(); + bool ClickOnApply(); + void ActivateThisDialog(); + void LineEditReturnPressed(); + void SelectionIntoArgument(); + void SetEditCurrentArgument(); + void ConstructorsClicked( int constructorId ); + + void selectAllSubShapes(); + void add(); + void remove(); + void selectionChanged(); + +private: + void Init( SALOME_Selection* ); + void enterEvent( QEvent* e ); + int getConstructorId() const; + TopAbs_ShapeEnum getShapeType() const; + void setShapeType( const TopAbs_ShapeEnum ); + void activateSelection(); + void updateState(); + void highlightSubShapes(); + +private: + Mode myMode; + bool myBusy; + GEOM::GEOM_Object_var myMainObj; + GEOM::GEOM_Object_var myGroup; + + QPushButton* mySelBtn; + QLineEdit* myMainName; + QPushButton* mySelSubBtn; + QPushButton* mySelAllBtn; + QPushButton* myAddBtn; + QPushButton* myRemBtn; + QListBox* myIdList; +}; + +#endif diff --git a/src/GroupGUI/Makefile.in b/src/GroupGUI/Makefile.in new file mode 100755 index 000000000..c615b7d85 --- /dev/null +++ b/src/GroupGUI/Makefile.in @@ -0,0 +1,60 @@ +# GEOM BUILDGUI : +# +# 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.salome-platform.org or email : webmaster.salome@opencascade.org +# +# +# +# File : Makefile.in +# Author : Sergey ANIKIN (OCC) +# Module : GEOM +# $Header: + +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + + +@COMMENCE@ + +# header files +EXPORT_HEADERS= + +# Libraries targets +LIB = libGroupGUI.la + +LIB_SRC = GroupGUI.cxx \ + GroupGUI_GroupDlg.cxx + +LIB_MOC = GroupGUI.h \ + GroupGUI_GroupDlg.h + +LIB_CLIENT_IDL = SALOME_GenericObj.idl SALOME_Component.idl + +LIB_SERVER_IDL = + +# additionnal information to compil and link file + +CPPFLAGS += $(QT_INCLUDES) $(VTK_INCLUDES) $(OCC_INCLUDES) $(PYTHON_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome +CXXFLAGS += -I${KERNEL_ROOT_DIR}/include/salome + +LDFLAGS += -lGEOMFiltersSelection -lGEOMBase + +@CONCLUDE@ diff --git a/src/IGESExport/IGESExport.cxx b/src/IGESExport/IGESExport.cxx new file mode 100644 index 000000000..8ce7f9933 --- /dev/null +++ b/src/IGESExport/IGESExport.cxx @@ -0,0 +1,48 @@ +// File: IGESExport.cxx +// Created: Wed May 19 14:49:45 2004 +// Author: Pavel TELKOV +// + +#include "utilities.h" + +#include +#include +#include + +#include +#include + +//============================================================================= +/*! + * + */ +//============================================================================= + +extern "C" +{ +#ifdef WNT + __declspec(__dllexport) +#endif + int Export(const TopoDS_Shape& theShape, const TCollection_AsciiString& theFileName) + { + MESSAGE("Export IGES into file " << theFileName.ToCString()); + try + { + //VRV: OCC 4.0 migration + IGESControl_Controller::Init(); + IGESControl_Writer ICW (Interface_Static::CVal("XSTEP.iges.unit"), + Interface_Static::IVal("XSTEP.iges.writebrep.mode")); + //VRV: OCC 4.0 migration + + ICW.AddShape( theShape ); + ICW.ComputeModel(); + if ( ICW.Write( theFileName.ToCString() ) ) + return 1; + } + catch(Standard_Failure) + { + //THROW_SALOME_CORBA_EXCEPTION("Exception catched in IGESExport", SALOME::BAD_PARAM); + } + return 0; + } +} diff --git a/src/IGESExport/Makefile.in b/src/IGESExport/Makefile.in new file mode 100644 index 000000000..d9abe4c34 --- /dev/null +++ b/src/IGESExport/Makefile.in @@ -0,0 +1,45 @@ +# Copyright (C) 2003 CEA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org or email : webmaster.salome@opencascade.org +# +# +# +# File : Makefile.in +# Author : Pavel TELKOV +# Module : GEOM +# $Header$ + +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + +@COMMENCE@ + +# Libraries targets + +LIB= libIGESExport.la + +LIB_SRC = IGESExport.cxx + +# additionnal information to compil and link file +CPPFLAGS+= $(OCC_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome +CXXFLAGS+= $(OCC_CXXFLAGS) -I${KERNEL_ROOT_DIR}/include/salome + +LDFLAGS+= $(CAS_LDPATH) -lTKIGES -L${KERNEL_ROOT_DIR}/lib/salome + +@CONCLUDE@ diff --git a/src/IGESImport/IGESImport.cxx b/src/IGESImport/IGESImport.cxx new file mode 100644 index 000000000..f0cb68c8b --- /dev/null +++ b/src/IGESImport/IGESImport.cxx @@ -0,0 +1,72 @@ +// File: IGESImport.cxx +// Created: Wed May 19 14:36:35 2004 +// Author: Pavel TELKOV +// + +#include "utilities.h" + +#include +#include + +#include +#include + +//============================================================================= +/*! + * + */ +//============================================================================= + +extern "C" +{ +#ifdef WNT + __declspec(__dllexport) +#endif + TopoDS_Shape Import (const TCollection_AsciiString& theFileName, + TCollection_AsciiString& theError) + { + IGESControl_Reader aReader; + TopoDS_Shape aResShape; + try { + IFSelect_ReturnStatus status = aReader.ReadFile(theFileName.ToCString()); + + if (status == IFSelect_RetDone) { + MESSAGE("ImportIGES : all Geometry Transfer"); + //OCC 5.1.2 porting + // aReader.Clear(); + // aReader.TransferRoots(false); + aReader.ClearShapes(); + aReader.TransferRoots(); + + MESSAGE("ImportIGES : count of shapes produced = " << aReader.NbShapes()); + aResShape = aReader.OneShape(); + + } else { +// switch (status) { +// case IFSelect_RetVoid: +// theError = "Nothing created or No data to process"; +// break; +// case IFSelect_RetError: +// theError = "Error in command or input data"; +// break; +// case IFSelect_RetFail: +// theError = "Execution was run, but has failed"; +// break; +// case IFSelect_RetStop: +// theError = "Execution has been stopped. Quite possible, an exception was raised"; +// break; +// default: +// break; +// } + theError = "Wrong format of the imported file. Can't import file."; + aResShape.Nullify(); + } + } + catch(Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + theError = aFail->GetMessageString(); + aResShape.Nullify(); + } + return aResShape; + } +} diff --git a/src/IGESImport/Makefile.in b/src/IGESImport/Makefile.in new file mode 100644 index 000000000..e9aaaa840 --- /dev/null +++ b/src/IGESImport/Makefile.in @@ -0,0 +1,45 @@ +# Copyright (C) 2003 CEA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org or email : webmaster.salome@opencascade.org +# +# +# +# File : Makefile.in +# Author : Pavel TELKOV +# Module : GEOM +# $Header$ + +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + +@COMMENCE@ + +# Libraries targets + +LIB= libIGESImport.la + +LIB_SRC = IGESImport.cxx + +# additionnal information to compil and link file +CPPFLAGS+= $(OCC_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome +CXXFLAGS+= $(OCC_CXXFLAGS) -I${KERNEL_ROOT_DIR}/include/salome + +LDFLAGS+= $(CAS_LDPATH) -lTKIGES -L${KERNEL_ROOT_DIR}/lib/salome + +@CONCLUDE@ diff --git a/src/Makefile.in b/src/Makefile.in index 766733aad..7fed1dceb 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -32,6 +32,6 @@ VPATH=.:@srcdir@ @COMMENCE@ -SUBDIRS = OBJECT ARCHIMEDE PARTITION SKETCHER GEOMDS GEOM GEOMClient GEOMFiltersSelection DlgRef GEOMContext GEOMBase DisplayGUI GEOMToolsGUI BasicGUI PrimitiveGUI GenerationGUI EntityGUI BuildGUI BooleanGUI TransformationGUI OperationGUI RepairGUI MeasureGUI GEOMGUI GEOM_SWIG +SUBDIRS = OBJECT ARCHIMEDE NMTDS NMTTools NMTAlgo SKETCHER PARTITION GEOM BREPExport BREPImport IGESExport IGESImport STEPExport STEPImport ShHealOper GEOMImpl GEOM_I GEOMClient DlgRef GEOMFiltersSelection GEOMGUI GEOMBase DisplayGUI GEOMToolsGUI BasicGUI PrimitiveGUI GenerationGUI EntityGUI BuildGUI BooleanGUI TransformationGUI OperationGUI RepairGUI MeasureGUI GroupGUI BlocksGUI GEOM_SWIG GEOM_I_Superv @MODULE@ diff --git a/src/MeasureGUI/Makefile.in b/src/MeasureGUI/Makefile.in index 2b983be0d..dd2706fd9 100644 --- a/src/MeasureGUI/Makefile.in +++ b/src/MeasureGUI/Makefile.in @@ -55,10 +55,10 @@ LIB_SRC = MeasureGUI.cxx \ MeasureGUI_DistanceDlg.cxx \ MeasureGUI_MaxToleranceDlg.cxx \ MeasureGUI_WhatisDlg.cxx \ - MeasureGUI_CheckShapeDlg.cxx + MeasureGUI_CheckShapeDlg.cxx \ + MeasureGUI_PointDlg.cxx LIB_MOC = \ - MeasureGUI.h \ MeasureGUI_Skeleton_QTD.h \ MeasureGUI_1Sel3LineEdit_QTD.h \ MeasureGUI_1Sel6LineEdit_QTD.h \ @@ -73,11 +73,12 @@ LIB_MOC = \ MeasureGUI_DistanceDlg.h \ MeasureGUI_MaxToleranceDlg.h \ MeasureGUI_WhatisDlg.h \ - MeasureGUI_CheckShapeDlg.h + MeasureGUI_CheckShapeDlg.h \ + MeasureGUI_PointDlg.h -LIB_CLIENT_IDL = +LIB_CLIENT_IDL = SALOME_GenericObj.idl SALOME_Component.idl -LIB_SERVER_IDL = +LIB_SERVER_IDL = # additionnal information to compil and link file diff --git a/src/MeasureGUI/MeasureGUI.cxx b/src/MeasureGUI/MeasureGUI.cxx index d2a67dac4..2eb28d73e 100644 --- a/src/MeasureGUI/MeasureGUI.cxx +++ b/src/MeasureGUI/MeasureGUI.cxx @@ -24,10 +24,10 @@ // File : MeasureGUI.cxx // Author : Damien COQUERET // Module : GEOM -// $Header: +// $Header$ -using namespace std; #include "MeasureGUI.h" +#include "QAD_Desktop.h" #include "SALOMEGUI_QtCatchCorbaException.hxx" @@ -39,17 +39,29 @@ using namespace std; #include "MeasureGUI_MaxToleranceDlg.h" // Method MAXTOLERANCE #include "MeasureGUI_WhatisDlg.h" // Method WHATIS #include "MeasureGUI_CheckShapeDlg.h" // Method CHECKSHAPE +#include "MeasureGUI_PointDlg.h" // Method POINTCOORDINATES + +MeasureGUI* MeasureGUI::myGUIObject = 0; + +//======================================================================= +// function : GetMeasureGUI() +// purpose : Get the only MeasureGUI object [ static ] +//======================================================================= +MeasureGUI* MeasureGUI::GetMeasureGUI() +{ + if ( myGUIObject == 0 ) { + // init MeasureGUI only once + myGUIObject = new MeasureGUI(); + } + return myGUIObject; +} //======================================================================= // function : MeasureGUI() // purpose : Constructor //======================================================================= -MeasureGUI::MeasureGUI() : - QObject() +MeasureGUI::MeasureGUI() : GEOMGUI() { - myGeomBase = new GEOMBase(); - myGeomGUI = GEOMContext::GetGeomGUI(); - myGeom = myGeomGUI->myComponentGeom; } @@ -66,60 +78,27 @@ MeasureGUI::~MeasureGUI() // function : OnGUIEvent() // purpose : //======================================================================= -bool MeasureGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) +bool MeasureGUI::OnGUIEvent( int theCommandID, QAD_Desktop* parent ) { - MeasureGUI* myMeasureGUI = new MeasureGUI(); - myMeasureGUI->myGeomGUI->EmitSignalDeactivateDialog(); - SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection()); + MeasureGUI* myMeasureGUI = GetMeasureGUI(); + GeometryGUI::GetGeomGUI()->EmitSignalDeactivateDialog(); + SALOME_Selection* Sel = SALOME_Selection::Selection( + QAD_Application::getDesktop()->getActiveStudy()->getSelection() ); - switch (theCommandID) - { - case 701: // PROPERTIES (Length, surface, volume) - { - MeasureGUI_PropertiesDlg *aDlg = new MeasureGUI_PropertiesDlg(parent, "", Sel); - break; - } - case 702: // CDG : Center of mass - { - MeasureGUI_CenterMassDlg *aDlg = new MeasureGUI_CenterMassDlg(parent, "", myMeasureGUI, Sel); - break; - } - case 703: // INERTIA - { - MeasureGUI_InertiaDlg *aDlg = new MeasureGUI_InertiaDlg(parent, "", Sel); - break; - } - case 7041: // BOUNDING BOX - { - MeasureGUI_BndBoxDlg *aDlg = new MeasureGUI_BndBoxDlg(parent, "", Sel); - break; - } - case 7042: // MIN DISTANCE - { - MeasureGUI_DistanceDlg *aDlg = new MeasureGUI_DistanceDlg(parent, "", Sel); - break; - } - case 705: // MAXTOLERANCE - { - MeasureGUI_MaxToleranceDlg *aDlg = new MeasureGUI_MaxToleranceDlg(parent, "", Sel); - break; - } - case 706: // WHATIS - { - MeasureGUI_WhatisDlg *aDlg = new MeasureGUI_WhatisDlg(parent, "", Sel); - break; - } - case 707: // CHECKSHAPE - { - MeasureGUI_CheckShapeDlg *aDlg = new MeasureGUI_CheckShapeDlg(parent, "", Sel); - break; - } - default: - { - parent->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); - break; - } - } + 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 + + default: parent->putInfo( tr( "GEOM_PRP_COMMAND" ).arg( theCommandID ) ); break; + } return true; } @@ -128,8 +107,10 @@ bool MeasureGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) // function : MakeCDGAndDisplay() // purpose : //===================================================================================== -void MeasureGUI::MakeCDGAndDisplay(GEOM::GEOM_Shape_ptr Shape) +/*void MeasureGUI::MakeCDGAndDisplay(GEOM::GEOM_Shape_ptr Shape) { + QAD_Application::getDesktop()->putInfo("MakeCDGAndDisplay method from MeasureGUI should be reimplemented ..."); + try { GEOM::GEOM_Shape_var result = myGeom->MakeCDG(Shape); if(result->_is_nil()) { @@ -142,9 +123,11 @@ void MeasureGUI::MakeCDGAndDisplay(GEOM::GEOM_Shape_ptr Shape) } catch(const SALOME::SALOME_Exception& S_ex) { QtCatchCorbaException(S_ex); - } + } + return; } +*/ //===================================================================================== @@ -152,6 +135,8 @@ void MeasureGUI::MakeCDGAndDisplay(GEOM::GEOM_Shape_ptr Shape) //===================================================================================== extern "C" { - bool OnGUIEvent(int theCommandID, QAD_Desktop* parent) - {return MeasureGUI::OnGUIEvent(theCommandID, parent);} + GEOMGUI* GetLibGUI() + { + return MeasureGUI::GetMeasureGUI(); + } } diff --git a/src/MeasureGUI/MeasureGUI.h b/src/MeasureGUI/MeasureGUI.h index 751574e47..b3eaadea7 100644 --- a/src/MeasureGUI/MeasureGUI.h +++ b/src/MeasureGUI/MeasureGUI.h @@ -24,33 +24,29 @@ // File : MeasureGUI.h // Author : Damien COQUERET // Module : GEOM -// $Header: +// $Header$ #ifndef MEASUREGUI_H #define MEASUREGUI_H -#include "GEOMBase.h" +#include "GEOMGUI.h" //================================================================================= // class : MeasureGUI // purpose : //================================================================================= -class MeasureGUI : public QObject +class MeasureGUI : public GEOMGUI { - Q_OBJECT /* for QT compatibility */ +protected: + MeasureGUI(); public : - MeasureGUI(); - ~MeasureGUI(); - - static bool OnGUIEvent(int theCommandID, QAD_Desktop* parent); - - void MakeCDGAndDisplay(GEOM::GEOM_Shape_ptr Shape); - - GEOMBase* myGeomBase; - GEOMContext* myGeomGUI; - GEOM::GEOM_Gen_var myGeom; /* Current Geom Component */ + ~MeasureGUI(); + static MeasureGUI* GetMeasureGUI(); + bool OnGUIEvent( int , QAD_Desktop* ); +private: + static MeasureGUI* myGUIObject; }; #endif diff --git a/src/MeasureGUI/MeasureGUI_BndBoxDlg.cxx b/src/MeasureGUI/MeasureGUI_BndBoxDlg.cxx index 838f140e7..cc7349832 100644 --- a/src/MeasureGUI/MeasureGUI_BndBoxDlg.cxx +++ b/src/MeasureGUI/MeasureGUI_BndBoxDlg.cxx @@ -27,13 +27,22 @@ // $Header$ #include "MeasureGUI_BndBoxDlg.h" +#include "MeasureGUI_1Sel6LineEdit_QTD.h" +#include "SALOMEGUI_QtCatchCorbaException.hxx" + +#include "GEOMBase.h" +#include "GEOM_Displayer.h" #include -#include #include "utilities.h" +#include "QAD_Desktop.h" -using namespace std; +#include +#include +#include +#include +#include //================================================================================= // class : MeasureGUI_BndBoxDlg() @@ -42,39 +51,44 @@ using namespace std; // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -MeasureGUI_BndBoxDlg::MeasureGUI_BndBoxDlg(QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl) - :MeasureGUI_Skeleton(parent, name, Sel, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) +MeasureGUI_BndBoxDlg::MeasureGUI_BndBoxDlg( QWidget* parent, SALOME_Selection* Sel ) +: MeasureGUI_Skeleton( parent, "MeasureGUI_PropertiesDlg", Sel ) { - QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_BOUNDING_BOX"))); - QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); + QPixmap image0( QAD_Desktop::getResourceManager()->loadPixmap( + "GEOM",tr( "ICON_DLG_BOUNDING_BOX" ) ) ); + QPixmap image1( QAD_Desktop::getResourceManager()->loadPixmap( + "GEOM",tr( "ICON_SELECT" ) ) ); - setCaption(tr("GEOM_BNDBOX_TITLE")); + setCaption( tr( "GEOM_BNDBOX_TITLE" ) ); /***************************************************************/ - GroupConstructors->setTitle(tr("GEOM_BNDBOX")); - RadioButton1->setPixmap(image0); - - GroupC1 = new MeasureGUI_1Sel6LineEdit_QTD(this, "GroupC1"); - GroupC1->GroupBox1->setTitle(tr("GEOM_BNDBOX_OBJDIM")); - GroupC1->TextLabel1->setText(tr("GEOM_OBJECT")); - GroupC1->TextLabel2->setText(tr("GEOM_MIN")); - GroupC1->TextLabel3->setText(tr("GEOM_MAX")); - GroupC1->TextLabel4->setText(tr("GEOM_X")); - GroupC1->TextLabel5->setText(tr("GEOM_Y")); - GroupC1->TextLabel6->setText(tr("GEOM_Z")); - GroupC1->LineEdit11->setReadOnly(TRUE); - GroupC1->LineEdit12->setReadOnly(TRUE); - GroupC1->LineEdit21->setReadOnly(TRUE); - GroupC1->LineEdit22->setReadOnly(TRUE); - GroupC1->LineEdit31->setReadOnly(TRUE); - GroupC1->LineEdit32->setReadOnly(TRUE); - GroupC1->PushButton1->setPixmap(image1); - - Layout1->addWidget(GroupC1, 1, 0); + + GroupConstructors->setTitle( tr( "GEOM_BNDBOX" ) ); + RadioButton1->setPixmap( image0 ); + + myGrp = new MeasureGUI_1Sel6LineEdit_QTD( this, "myGrp" ); + myGrp->GroupBox1->setTitle( tr( "GEOM_BNDBOX_OBJDIM" ) ); + myGrp->TextLabel1->setText( tr( "GEOM_OBJECT" ) ); + myGrp->TextLabel2->setText( tr( "GEOM_MIN" ) ); + myGrp->TextLabel3->setText( tr( "GEOM_MAX" ) ); + myGrp->TextLabel4->setText( tr( "GEOM_X" ) ); + myGrp->TextLabel5->setText( tr( "GEOM_Y" ) ); + myGrp->TextLabel6->setText( tr( "GEOM_Z" ) ); + myGrp->LineEdit11->setReadOnly( TRUE ); + myGrp->LineEdit12->setReadOnly( TRUE ); + myGrp->LineEdit21->setReadOnly( TRUE ); + myGrp->LineEdit22->setReadOnly( TRUE ); + myGrp->LineEdit31->setReadOnly( TRUE ); + myGrp->LineEdit32->setReadOnly( TRUE ); + myGrp->PushButton1->setPixmap( image1 ); + myGrp->LineEdit1->setReadOnly( true ); + + Layout1->addWidget( myGrp, 1, 0 ); + /***************************************************************/ /* Initialisation */ - Init(); + Init( Sel ); } @@ -84,7 +98,6 @@ MeasureGUI_BndBoxDlg::MeasureGUI_BndBoxDlg(QWidget* parent, const char* name, SA //================================================================================= MeasureGUI_BndBoxDlg::~MeasureGUI_BndBoxDlg() { - // no need to delete child widgets, Qt does it all for us } @@ -92,155 +105,105 @@ MeasureGUI_BndBoxDlg::~MeasureGUI_BndBoxDlg() // function : Init() // purpose : //================================================================================= -void MeasureGUI_BndBoxDlg::Init() +void MeasureGUI_BndBoxDlg::Init( SALOME_Selection* Sel ) { - /* init variables */ - myEditCurrentArgument = GroupC1->LineEdit1; - - /* signals and slots connections */ - connect(GroupC1->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupC1->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - - /* displays Dialog */ - GroupC1->show(); - this->show(); - - return; + mySelBtn = myGrp->PushButton1; + mySelEdit = myGrp->LineEdit1; + MeasureGUI_Skeleton::Init( Sel ); } - -//================================================================================= -// function : SelectionIntoArgument() -// purpose : Called when selection as changed or other case //================================================================================= -void MeasureGUI_BndBoxDlg::SelectionIntoArgument() -{ - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); - myEditCurrentArgument->setText(""); - QString aString = ""; - - GroupC1->LineEdit11->setText(""); - GroupC1->LineEdit12->setText(""); - GroupC1->LineEdit21->setText(""); - GroupC1->LineEdit22->setText(""); - GroupC1->LineEdit31->setText(""); - GroupC1->LineEdit32->setText(""); - - int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString); - if(nbSel != 1) - return; - - /* nbSel == 1 */ - TopoDS_Shape S; - if(!myGeomBase->GetTopoFromSelection(mySelection, S) || S.IsNull()) - return; - - GroupC1->LineEdit1->setText(aString); - - this->CalculateAndDisplayBndBox(S); - return; -} - - -//================================================================================= -// function : SetEditCurrentArgument() +// function : processObject // purpose : //================================================================================= -void MeasureGUI_BndBoxDlg::SetEditCurrentArgument() +void MeasureGUI_BndBoxDlg::processObject() { - QPushButton* send = (QPushButton*)sender(); - - if(send == GroupC1->PushButton1) { - GroupC1->LineEdit1->setFocus(); - myEditCurrentArgument = GroupC1->LineEdit1; + double aXMin, aXMax, aYMin, aYMax, aZMin, aZMax; + + if ( !getParameters( aXMin, aXMax, aYMin, aYMax, aZMin, aZMax ) ) + { + mySelEdit->setText( "" ); + myGrp->LineEdit11->setText( "" ); + myGrp->LineEdit12->setText( "" ); + myGrp->LineEdit21->setText( "" ); + myGrp->LineEdit22->setText( "" ); + myGrp->LineEdit31->setText( "" ); + myGrp->LineEdit32->setText( "" ); } + else + { + + myGrp->LineEdit11->setText( tr( "%1" ).arg( aXMin, 12, 'f', 6 ) ); + myGrp->LineEdit12->setText( tr( "%1" ).arg( aXMax, 12, 'f', 6 ) ); - this->SelectionIntoArgument(); - return; -} + myGrp->LineEdit21->setText( tr( "%1" ).arg( aYMin, 12, 'f', 6 ) ); + myGrp->LineEdit22->setText( tr( "%1" ).arg( aYMax, 12, 'f', 6 ) ); + myGrp->LineEdit31->setText( tr( "%1" ).arg( aZMin, 12, 'f', 6 ) ); + myGrp->LineEdit32->setText( tr( "%1" ).arg( aZMax, 12, 'f', 6 ) ); + } +} //================================================================================= -// function : LineEditReturnPressed() +// function : getParameters // purpose : //================================================================================= -void MeasureGUI_BndBoxDlg::LineEditReturnPressed() +bool MeasureGUI_BndBoxDlg::getParameters( double& theXmin, double& theXmax, + double& theYmin, double& theYmax, + double& theZmin, double& theZmax ) { - QLineEdit* send = (QLineEdit*)sender(); - if(send == GroupC1->LineEdit1) - myEditCurrentArgument = GroupC1->LineEdit1; + if ( myObj->_is_nil() ) + return false; else - return; - - MeasureGUI_Skeleton::LineEditReturnPressed(); - return; + { + try + { + GEOM::GEOM_IMeasureOperations::_narrow( getOperation() )->GetBoundingBox( + myObj, theXmin, theXmax, theYmin, theYmax, theZmin, theZmax ); + } + catch( const SALOME::SALOME_Exception& e ) + { + QtCatchCorbaException( e ); + return false; + } + + return getOperation()->IsDone(); + } } - //================================================================================= -// function : ActivateThisDialog() +// function : buildPrs // purpose : //================================================================================= -void MeasureGUI_BndBoxDlg::ActivateThisDialog() +SALOME_Prs* MeasureGUI_BndBoxDlg::buildPrs() { - MeasureGUI_Skeleton::ActivateThisDialog(); - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - if(!mySimulationTopoDs.IsNull()) - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - return; -} + double aXMin, aYMin, aZMin, aXMax, aYMax, aZMax; + if ( myObj->_is_nil() || !getParameters( aXMin, aXMax, aYMin, aYMax, aZMin, aZMax ) ) + return 0; + + TopoDS_Shape aShape = BRepPrimAPI_MakeBox( gp_Pnt( aXMin, aYMin, aZMin ), + gp_Pnt( aXMax, aYMax, aZMax ) ).Shape(); + + return !aShape.IsNull() ? getDisplayer()->BuildPrs( aShape ) : 0; -//================================================================================= -// function : enterEvent() -// purpose : -//================================================================================= -void MeasureGUI_BndBoxDlg::enterEvent(QEvent* e) -{ - if(GroupConstructors->isEnabled()) - return; - this->ActivateThisDialog(); - return; } -//================================================================================= -// function : CalculateAndDisplayBndBox() -// purpose : -//================================================================================= -void MeasureGUI_BndBoxDlg::CalculateAndDisplayBndBox(const TopoDS_Shape& S) -{ - GroupC1->LineEdit11->setText(""); - GroupC1->LineEdit12->setText(""); - GroupC1->LineEdit21->setText(""); - GroupC1->LineEdit22->setText(""); - GroupC1->LineEdit31->setText(""); - GroupC1->LineEdit32->setText(""); - - if(S.IsNull()) - return; - - Standard_Real axmin, aymin, azmin, axmax, aymax, azmax; - Bnd_Box B; - - try { - BRepBndLib::Add(S,B); - B.Get(axmin, aymin, azmin, axmax, aymax, azmax); - GroupC1->LineEdit11->setText(tr("%1").arg(axmin, 12, 'f', 6)); - GroupC1->LineEdit12->setText(tr("%1").arg(axmax, 12, 'f', 6)); - GroupC1->LineEdit21->setText(tr("%1").arg(aymin, 12, 'f', 6)); - GroupC1->LineEdit22->setText(tr("%1").arg(aymax, 12, 'f', 6)); - GroupC1->LineEdit31->setText(tr("%1").arg(azmin, 12, 'f', 6)); - GroupC1->LineEdit32->setText(tr("%1").arg(azmax, 12, 'f', 6)); - - mySimulationTopoDs = BRepPrimAPI_MakeBox(gp_Pnt(axmin, aymin, azmin), gp_Pnt(axmax, aymax, azmax)).Shape(); - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - } - catch(Standard_Failure) { - MESSAGE("Catch intercepted in CalculateAndDisplayBndBox()"); - } - return; -} + + + + + + + + + + + + + + + + + diff --git a/src/MeasureGUI/MeasureGUI_BndBoxDlg.h b/src/MeasureGUI/MeasureGUI_BndBoxDlg.h index ee17c7008..50e24820b 100644 --- a/src/MeasureGUI/MeasureGUI_BndBoxDlg.h +++ b/src/MeasureGUI/MeasureGUI_BndBoxDlg.h @@ -30,9 +30,8 @@ #define DIALOGBOX_BNDBOX_H #include "MeasureGUI_Skeleton.h" -#include "MeasureGUI_1Sel6LineEdit_QTD.h" -#include "MeasureGUI.h" +class MeasureGUI_1Sel6LineEdit_QTD; //================================================================================= // class : DialogBox_PROPERTIES @@ -43,22 +42,39 @@ class MeasureGUI_BndBoxDlg : public MeasureGUI_Skeleton Q_OBJECT public: - MeasureGUI_BndBoxDlg(QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); - ~MeasureGUI_BndBoxDlg(); + MeasureGUI_BndBoxDlg( QWidget* parent, + SALOME_Selection* Sel ); + ~MeasureGUI_BndBoxDlg(); +protected: + + // redefined from GEOMBase_Helper and MeasureGUI_Skeleton + virtual void processObject(); + virtual SALOME_Prs* buildPrs(); private: - void Init(); - void enterEvent(QEvent* e); - void CalculateAndDisplayBndBox(const TopoDS_Shape& S); - MeasureGUI_1Sel6LineEdit_QTD* GroupC1; + void Init( SALOME_Selection* Sel ); + bool getParameters( double& Xmin, double& Xmax, + double& Ymin, double& Ymax, + double& Zmin, double& Zmax ); -private slots: - void SetEditCurrentArgument(); - void SelectionIntoArgument(); - void LineEditReturnPressed(); - void ActivateThisDialog(); +private: + MeasureGUI_1Sel6LineEdit_QTD* myGrp; }; #endif // DIALOGBOX_BNDBOX_H + + + + + + + + + + + + + + diff --git a/src/MeasureGUI/MeasureGUI_CenterMassDlg.cxx b/src/MeasureGUI/MeasureGUI_CenterMassDlg.cxx index 2ddbc82f0..ed0a1087e 100644 --- a/src/MeasureGUI/MeasureGUI_CenterMassDlg.cxx +++ b/src/MeasureGUI/MeasureGUI_CenterMassDlg.cxx @@ -1,23 +1,23 @@ // 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 +// 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 // // // @@ -27,54 +27,56 @@ // $Header$ #include "MeasureGUI_CenterMassDlg.h" - -#include -#include -#include -#include - +#include "MeasureGUI_1Sel3LineEdit_QTD.h" +#include "SALOMEGUI_QtCatchCorbaException.hxx" #include "utilities.h" +#include "QAD_Desktop.h" -using namespace std; +#include +#include +#include +#include //================================================================================= // class : MeasureGUI_CenterMassDlg() -// purpose : Constructs a MeasureGUI_CenterMassDlg which is a child of 'parent', with the +// purpose : Constructs a MeasureGUI_CenterMassDlg 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_CenterMassDlg::MeasureGUI_CenterMassDlg(QWidget* parent, const char* name, MeasureGUI* theMeasureGUI, SALOME_Selection* Sel, bool modal, WFlags fl) - :GEOMBase_Skeleton(parent, name, Sel, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) +MeasureGUI_CenterMassDlg::MeasureGUI_CenterMassDlg( QWidget* parent, SALOME_Selection* Sel ) +: GEOMBase_Skeleton( parent, "MeasureGUI_CenterMassDlg", Sel, false, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) { - QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_CENTERMASS"))); - QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); + QPixmap image0( QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr( "ICON_DLG_CENTERMASS" ) ) ); + QPixmap image1( QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr( "ICON_SELECT" ) ) ); - setCaption(tr("GEOM_CMASS_TITLE")); + setCaption( tr( "GEOM_CMASS_TITLE" ) ); /***************************************************************/ - GroupConstructors->setTitle(tr("GEOM_CMASS")); - RadioButton1->setPixmap(image0); - RadioButton2->close(TRUE); - RadioButton3->close(TRUE); - - GroupC1 = new MeasureGUI_1Sel3LineEdit_QTD(this, "GroupC1"); - GroupC1->GroupBox1->setTitle(tr("GEOM_CENTER")); - GroupC1->TextLabel1->setText(tr("GEOM_OBJECT")); - GroupC1->TextLabel2->setText(tr("GEOM_X")); - GroupC1->TextLabel3->setText(tr("GEOM_Y")); - GroupC1->TextLabel4->setText(tr("GEOM_Z")); - GroupC1->LineEdit2->setReadOnly(TRUE); - GroupC1->LineEdit3->setReadOnly(TRUE); - GroupC1->LineEdit4->setReadOnly(TRUE); - GroupC1->PushButton1->setPixmap(image1); - - Layout1->addWidget(GroupC1, 1, 0); + + GroupConstructors->setTitle( tr( "GEOM_CMASS" ) ); + RadioButton1->setPixmap( image0 ); + RadioButton2->close( TRUE ); + RadioButton3->close( TRUE ); + + myGrp = new MeasureGUI_1Sel3LineEdit_QTD( this, "myGrp" ); + myGrp->GroupBox1->setTitle( tr( "GEOM_CENTER" ) ); + myGrp->TextLabel1->setText( tr( "GEOM_OBJECT" ) ); + myGrp->TextLabel2->setText( tr( "GEOM_X" ) ); + myGrp->TextLabel3->setText( tr( "GEOM_Y" ) ); + myGrp->TextLabel4->setText( tr( "GEOM_Z" ) ); + myGrp->LineEdit2->setReadOnly( TRUE ); + myGrp->LineEdit3->setReadOnly( TRUE ); + myGrp->LineEdit4->setReadOnly( TRUE ); + myGrp->PushButton1->setPixmap( image1 ); + myGrp->LineEdit1->setReadOnly( true ); + + Layout1->addWidget( myGrp, 2, 0 ); /***************************************************************/ /* Initialisation */ - myMeasureGUI = theMeasureGUI; - Init(); + Init( Sel ); } @@ -84,7 +86,6 @@ MeasureGUI_CenterMassDlg::MeasureGUI_CenterMassDlg(QWidget* parent, const char* //================================================================================= MeasureGUI_CenterMassDlg::~MeasureGUI_CenterMassDlg() { - // no need to delete child widgets, Qt does it all for us } @@ -92,27 +93,28 @@ MeasureGUI_CenterMassDlg::~MeasureGUI_CenterMassDlg() // function : Init() // purpose : //================================================================================= -void MeasureGUI_CenterMassDlg::Init() +void MeasureGUI_CenterMassDlg::Init( SALOME_Selection* Sel ) { /* init variables */ - myEditCurrentArgument = GroupC1->LineEdit1; - - myOkCenterMass = false; + mySelection = Sel; + myEditCurrentArgument = myGrp->LineEdit1; /* signals and slots connections */ - connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); - connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); + connect( buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) ); + + connect( myGrp->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); + connect( myGrp->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); - connect(GroupC1->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupC1->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + initName( tr( "GEOM_POINT") ); + globalSelection(); + SelectionIntoArgument(); /* displays Dialog */ - GroupC1->show(); + myGrp->show(); this->show(); - - return; } @@ -122,9 +124,8 @@ void MeasureGUI_CenterMassDlg::Init() //================================================================================= void MeasureGUI_CenterMassDlg::ClickOnOk() { - this->ClickOnApply(); - ClickOnCancel(); - return; + if ( ClickOnApply() ) + ClickOnCancel(); } @@ -132,17 +133,15 @@ void MeasureGUI_CenterMassDlg::ClickOnOk() // function : ClickOnApply() // purpose : //================================================================================= -void MeasureGUI_CenterMassDlg::ClickOnApply() +bool MeasureGUI_CenterMassDlg::ClickOnApply() { - QAD_Application::getDesktop()->putInfo(tr("")); - if (mySimulationTopoDs.IsNull()) - return; - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); + if ( !onAccept() ) + return false; - if(myOkCenterMass) - myMeasureGUI->MakeCDGAndDisplay(myGeomShape); - return; + initName(); + return true; + +// myMeasureGUI->MakeCDGAndDisplay( myGeomShape ); } @@ -152,34 +151,28 @@ void MeasureGUI_CenterMassDlg::ClickOnApply() //================================================================================= void MeasureGUI_CenterMassDlg::SelectionIntoArgument() { - myGeomBase->EraseSimulationShape(); - myEditCurrentArgument->setText(""); - QString aString = ""; - - myOkCenterMass = false; - GroupC1->LineEdit2->setText(""); - GroupC1->LineEdit3->setText(""); - GroupC1->LineEdit4->setText(""); + erasePreview(); + myObj = GEOM::GEOM_Object::_nil(); - int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString); - if(nbSel != 1) + if ( mySelection->IObjectCount() != 1 ) + { + processObject(); return; + } - /* nbSel == 1 */ - Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); - if(!myGeomBase->GetTopoFromSelection(mySelection, this->myShape)) - return; + Standard_Boolean testResult = Standard_False; + GEOM::GEOM_Object_var aSelectedObject = + GEOMBase::ConvertIOinGEOMObject( mySelection->firstIObject(), testResult ); - Standard_Boolean testResult; - myGeomShape = myGeomBase->ConvertIOinGEOMShape(IO, testResult); - if(!testResult) + if ( !testResult || aSelectedObject->_is_nil() ) + { + processObject(); return; + } - myEditCurrentArgument->setText(aString); - - if(this->CalculateAndDisplayCenterMass()) - myOkCenterMass = true; - return; + myObj = aSelectedObject; + processObject(); + displayPreview(); } @@ -189,15 +182,9 @@ void MeasureGUI_CenterMassDlg::SelectionIntoArgument() //================================================================================= void MeasureGUI_CenterMassDlg::SetEditCurrentArgument() { - QPushButton* send = (QPushButton*)sender(); - - if(send == GroupC1->PushButton1) { - GroupC1->LineEdit1->setFocus(); - myEditCurrentArgument = GroupC1->LineEdit1; - } - - this->SelectionIntoArgument(); - return; + myGrp->LineEdit1->setFocus(); + myEditCurrentArgument = myGrp->LineEdit1; + SelectionIntoArgument(); } @@ -207,14 +194,12 @@ void MeasureGUI_CenterMassDlg::SetEditCurrentArgument() //================================================================================= void MeasureGUI_CenterMassDlg::LineEditReturnPressed() { - QLineEdit* send = (QLineEdit*)sender(); - if(send == GroupC1->LineEdit1) - myEditCurrentArgument = GroupC1->LineEdit1; - else - return; - - GEOMBase_Skeleton::LineEditReturnPressed(); - return; + QLineEdit* send = ( QLineEdit* )sender(); + if ( send == myGrp->LineEdit1 ) + { + myEditCurrentArgument = myGrp->LineEdit1; + GEOMBase_Skeleton::LineEditReturnPressed(); + } } @@ -225,10 +210,41 @@ void MeasureGUI_CenterMassDlg::LineEditReturnPressed() void MeasureGUI_CenterMassDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - if(!mySimulationTopoDs.IsNull()) - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - return; + + connect( mySelection, SIGNAL( currentSelectionChanged() ), + this, SLOT ( SelectionIntoArgument() ) ); + + globalSelection(); + displayPreview(); +} + +//================================================================================= +// function : processObject() +// purpose : Fill dialog fields in accordance with myObj +//================================================================================= +void MeasureGUI_CenterMassDlg::processObject() +{ + if ( myObj->_is_nil() ) + { + myGrp->LineEdit1->setText( "" ); + myGrp->LineEdit2->setText( "" ); + myGrp->LineEdit3->setText( "" ); + myGrp->LineEdit4->setText( "" ); + erasePreview(); + } + else + { + double x = 0, y = 0, z = 0; + + getParameters( x, y, z ); + + myGrp->LineEdit1->setText( GEOMBase::GetName( myObj ) ); + myGrp->LineEdit2->setText( QString( "%1" ).arg( x ) ); + myGrp->LineEdit3->setText( QString( "%1" ).arg( y ) ); + myGrp->LineEdit4->setText( QString( "%1" ).arg( z ) ); + + displayPreview(); + } } @@ -236,65 +252,85 @@ void MeasureGUI_CenterMassDlg::ActivateThisDialog() // function : enterEvent() // purpose : //================================================================================= -void MeasureGUI_CenterMassDlg::enterEvent(QEvent* e) +void MeasureGUI_CenterMassDlg::enterEvent( QEvent* e ) { - if(GroupConstructors->isEnabled()) - return; - this->ActivateThisDialog(); - return; + if ( !GroupConstructors->isEnabled() ) + ActivateThisDialog(); } +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr MeasureGUI_CenterMassDlg::createOperation() +{ + return getGeomEngine()->GetIMeasureOperations( getStudyId() ); +} //================================================================================= -// function : CalculateAndDisplayCenterMass() +// function : isValid // purpose : //================================================================================= -bool MeasureGUI_CenterMassDlg::CalculateAndDisplayCenterMass() +bool MeasureGUI_CenterMassDlg::isValid( QString& ) { - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); - - try { - QString resString; - GProp_GProps System; - - if(myShape.ShapeType() == TopAbs_VERTEX) - myGeomBase->VertexToPoint(myShape, myCenterMass); - else if(myShape.ShapeType() == TopAbs_EDGE || myShape.ShapeType() == TopAbs_WIRE) { - BRepGProp::LinearProperties(myShape, System); - myCenterMass = System.CentreOfMass(); - } - else if(myShape.ShapeType() == TopAbs_FACE || myShape.ShapeType() == TopAbs_SHELL) { - BRepGProp::SurfaceProperties(myShape, System); - myCenterMass = System.CentreOfMass(); - } - else { - BRepGProp::VolumeProperties(myShape, System); - myCenterMass = System.CentreOfMass(); - } - - BRepBuilderAPI_MakeVertex V(myCenterMass); - mySimulationTopoDs = V.Shape(); - - resString = tr("%1").arg(myCenterMass.X(), 12, 'f', 6); - GroupC1->LineEdit2->setText(resString); - - resString = tr("%1").arg(myCenterMass.Y(), 12, 'f', 6); - GroupC1->LineEdit3->setText(resString); - - resString = tr("%1").arg(myCenterMass.Z(), 12, 'f', 6); - GroupC1->LineEdit4->setText(resString); - - - if(!mySimulationTopoDs.IsNull()) { - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); + return !myObj->_is_nil(); +} + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool MeasureGUI_CenterMassDlg::getParameters( double& theX, double& theY, double& theZ ) +{ + if ( myObj->_is_nil() ) + return false; + else + { + try + { + GEOM::GEOM_Object_var anObj; + anObj = GEOM::GEOM_IMeasureOperations::_narrow( getOperation() )->GetCentreOfMass( myObj ); + if ( !getOperation()->IsDone() ) + return false; + + TopoDS_Shape aShape; + if ( !GEOMBase::GetShape( anObj, aShape ) || + aShape.IsNull() || + aShape.ShapeType() != TopAbs_VERTEX ) + return false; + + TopoDS_Vertex aVertex = TopoDS::Vertex( aShape ); + + gp_Pnt aPnt = BRep_Tool::Pnt( aVertex ); + + theX = aPnt.X(); + theY = aPnt.Y(); + theZ = aPnt.Z(); + return true; } + catch( const SALOME::SALOME_Exception& e ) + { + QtCatchCorbaException( e ); + return false; + } } - catch(Standard_Failure) { - MESSAGE("Catch intercepted in CalculateAndDisplayCenterMass()"); - } - return false; +} + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool MeasureGUI_CenterMassDlg::execute( ObjectList& objects ) +{ + GEOM::GEOM_Object_var anObj; + + anObj = GEOM::GEOM_IMeasureOperations::_narrow( getOperation() )->GetCentreOfMass( myObj ); + + if ( !anObj->_is_nil() ) + objects.push_back( anObj._retn() ); + + return true; } diff --git a/src/MeasureGUI/MeasureGUI_CenterMassDlg.h b/src/MeasureGUI/MeasureGUI_CenterMassDlg.h index e67a67ccf..74703bce9 100644 --- a/src/MeasureGUI/MeasureGUI_CenterMassDlg.h +++ b/src/MeasureGUI/MeasureGUI_CenterMassDlg.h @@ -1,23 +1,23 @@ // 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 +// 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 // // // @@ -29,46 +29,48 @@ #define DIALOGBOX_CMASS_H #include "GEOMBase_Skeleton.h" -#include "MeasureGUI_1Sel3LineEdit_QTD.h" - -#include "MeasureGUI.h" -#include +class MeasureGUI_1Sel3LineEdit_QTD; //================================================================================= // class : MeasureGUI_CenterMassDlg // purpose : //================================================================================= class MeasureGUI_CenterMassDlg : public GEOMBase_Skeleton -{ +{ Q_OBJECT public: - MeasureGUI_CenterMassDlg(QWidget* parent = 0, const char* name = 0, MeasureGUI* theMeasureGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); - ~MeasureGUI_CenterMassDlg(); + MeasureGUI_CenterMassDlg( QWidget* parent, + SALOME_Selection* Sel ); + ~MeasureGUI_CenterMassDlg(); -private: - void Init(); - void enterEvent(QEvent* e); - bool CalculateAndDisplayCenterMass(); +protected: + + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& msg ); + virtual bool execute( ObjectList& objects ); - MeasureGUI* myMeasureGUI; +private slots: + void ClickOnOk(); + bool ClickOnApply(); + void ActivateThisDialog(); + void LineEditReturnPressed(); + void SelectionIntoArgument(); + void SetEditCurrentArgument(); - GEOM::GEOM_Shape_var myGeomShape; /* is myBase */ - TopoDS_Shape myShape; /* Shape argument */ - gp_Pnt myCenterMass; - bool myOkCenterMass; /* true after center of mass simulation calculation */ +private: - MeasureGUI_1Sel3LineEdit_QTD* GroupC1; - -private slots: - void ClickOnOk(); - void ClickOnApply(); - void SetEditCurrentArgument(); - void SelectionIntoArgument(); - void LineEditReturnPressed(); - void ActivateThisDialog(); + void Init( SALOME_Selection* ); + void enterEvent( QEvent* e ); + void processObject(); + bool getParameters( double&, double&, double& ); +private: + + GEOM::GEOM_Object_var myObj; + MeasureGUI_1Sel3LineEdit_QTD* myGrp; }; #endif // DIALOGBOX_CMASS_H diff --git a/src/MeasureGUI/MeasureGUI_CheckShapeDlg.cxx b/src/MeasureGUI/MeasureGUI_CheckShapeDlg.cxx index 407824be7..3ed0566df 100644 --- a/src/MeasureGUI/MeasureGUI_CheckShapeDlg.cxx +++ b/src/MeasureGUI/MeasureGUI_CheckShapeDlg.cxx @@ -1,23 +1,23 @@ // 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 +// 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 // // // @@ -27,45 +27,61 @@ // $Header$ #include "MeasureGUI_CheckShapeDlg.h" +#include "MeasureGUI_1Sel1TextView_QTD.h" +#include "SALOMEGUI_QtCatchCorbaException.hxx" -#include +#include "utilities.h" +#include "QAD_Desktop.h" #include +#include +#include +#include +#include +#include -#include "utilities.h" - -using namespace std; +#define TEXTEDIT_FONT_FAMILY "Courier" +#define TEXTEDIT_FONT_SIZE 11 //================================================================================= // class : MeasureGUI_CheckShapeDlg() -// purpose : Constructs a MeasureGUI_CheckShapeDlg which is a child of 'parent', with the +// purpose : Constructs a MeasureGUI_CheckShapeDlg 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_CheckShapeDlg::MeasureGUI_CheckShapeDlg(QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl) - :MeasureGUI_Skeleton(parent, name, Sel, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) +MeasureGUI_CheckShapeDlg::MeasureGUI_CheckShapeDlg( QWidget* parent, SALOME_Selection* Sel ) +: MeasureGUI_Skeleton( parent, "MeasureGUI_CheckShapeDlg", Sel ) { - QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_CHECKSHAPE"))); - QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); + QPixmap image0( QAD_Desktop::getResourceManager()->loadPixmap( + "GEOM",tr( "ICON_DLG_CHECKSHAPE" ) ) ); + QPixmap image1( QAD_Desktop::getResourceManager()->loadPixmap( + "GEOM",tr( "ICON_SELECT" ) ) ); - setCaption(tr("GEOM_CHECK_TITLE")); + setCaption( tr( "GEOM_CHECK_TITLE" ) ); /***************************************************************/ - GroupConstructors->setTitle(tr("GEOM_CHECK_SHAPE")); - RadioButton1->setPixmap(image0); - GroupC1 = new MeasureGUI_1Sel1TextView_QTD(this, "GroupC1"); - GroupC1->GroupBox1->setTitle(tr("GEOM_CHECK_INFOS")); - GroupC1->TextLabel1->setText(tr("GEOM_OBJECT")); - GroupC1->TextEdit1->setReadOnly(TRUE); - GroupC1->PushButton1->setPixmap(image1); + GroupConstructors->setTitle( tr( "GEOM_CHECK_SHAPE" ) ); + 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 ); + + Layout1->addWidget( myGrp, 1, 0 ); - Layout1->addWidget(GroupC1, 1, 0); /***************************************************************/ /* Initialisation */ - Init(); + Init( Sel ); } @@ -75,7 +91,6 @@ MeasureGUI_CheckShapeDlg::MeasureGUI_CheckShapeDlg(QWidget* parent, const char* //================================================================================= MeasureGUI_CheckShapeDlg::~MeasureGUI_CheckShapeDlg() { - // no need to delete child widgets, Qt does it all for us } @@ -83,132 +98,60 @@ MeasureGUI_CheckShapeDlg::~MeasureGUI_CheckShapeDlg() // function : Init() // purpose : //================================================================================= -void MeasureGUI_CheckShapeDlg::Init() -{ - /* init variables */ - myEditCurrentArgument = GroupC1->LineEdit1; - - /* signals and slots connections */ - connect(GroupC1->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupC1->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - - /* displays Dialog */ - GroupC1->show(); - this->show(); - - return; -} - - -//================================================================================= -// function : SelectionIntoArgument() -// purpose : Called when selection as changed or other case -//================================================================================= -void MeasureGUI_CheckShapeDlg::SelectionIntoArgument() -{ - myEditCurrentArgument->setText(""); - SelectedName = ""; /* future the name of selection */ - GroupC1->TextEdit1->setText(""); - - int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, SelectedName); - if(nbSel != 1) - return; - - /* nbSel == 1 */ - TopoDS_Shape S; - if(!myGeomBase->GetTopoFromSelection(mySelection, S)) - return; - - if(S.IsNull()) - return; - - myEditCurrentArgument->setText(SelectedName); - this->Check(S); - - return; -} - - -//================================================================================= -// function : SetEditCurrentArgument() -// purpose : -//================================================================================= -void MeasureGUI_CheckShapeDlg::SetEditCurrentArgument() +void MeasureGUI_CheckShapeDlg::Init( SALOME_Selection* Sel ) { - QPushButton* send = (QPushButton*)sender(); - - if(send == GroupC1->PushButton1) { - GroupC1->LineEdit1->setFocus(); - myEditCurrentArgument = GroupC1->LineEdit1; - } - - this->SelectionIntoArgument(); - return; + mySelBtn = myGrp->PushButton1; + mySelEdit = myGrp->LineEdit1; + MeasureGUI_Skeleton::Init( Sel ); } - //================================================================================= -// function : LineEditReturnPressed() +// function : getParameters // purpose : //================================================================================= -void MeasureGUI_CheckShapeDlg::LineEditReturnPressed() +bool MeasureGUI_CheckShapeDlg::getParameters ( bool& theIsValid, QString& theMsg ) { - QLineEdit* send = (QLineEdit*)sender(); - if(send == GroupC1->LineEdit1) - myEditCurrentArgument = GroupC1->LineEdit1; + if ( myObj->_is_nil() ) + return false; else - return; - - MeasureGUI_Skeleton::LineEditReturnPressed(); - return; -} - - -//================================================================================= -// function : ActivateThisDialog() -// purpose : -//================================================================================= -void MeasureGUI_CheckShapeDlg::ActivateThisDialog() -{ - MeasureGUI_Skeleton::ActivateThisDialog(); - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - return; -} - - -//================================================================================= -// function : enterEvent() -// purpose : -//================================================================================= -void MeasureGUI_CheckShapeDlg::enterEvent(QEvent* e) -{ - if(GroupConstructors->isEnabled()) - return; - this->ActivateThisDialog(); - return; + { + try + { + char* aMsg; + theIsValid = GEOM::GEOM_IMeasureOperations::_narrow( getOperation() )->CheckShape( myObj, aMsg ); + theMsg = aMsg; + } + catch( const SALOME::SALOME_Exception& e ) + { + QtCatchCorbaException( e ); + return false; + } + + return getOperation()->IsDone(); + } } //================================================================================= -// function : Check() +// function : processObject // purpose : //================================================================================= -void MeasureGUI_CheckShapeDlg::Check(const TopoDS_Shape S) +void MeasureGUI_CheckShapeDlg::processObject() { - if(S.IsNull()) + bool isShapeValid; + QString aMsg; + if ( !getParameters( isShapeValid, aMsg ) ) + { + myGrp->TextEdit1->setText( "" ); return; - - try { - BRepCheck_Analyzer ana(S,false); - if(ana.IsValid()) - GroupC1->TextEdit1->setText("This Shape seems to be valid."); - else - GroupC1->TextEdit1->setText("This Shape is not valid."); } - catch(Standard_Failure) { - MESSAGE("Catch intercepted in Check()"); + + if (isShapeValid) { + myGrp->TextEdit1->setText("This Shape seems to be valid."); + } else { + QString aDescr ("This Shape is not valid.\n"); + aDescr += aMsg; + myGrp->TextEdit1->setText(aDescr); +// myGrp->TextEdit1->setText("This Shape is not valid."); } - return; } diff --git a/src/MeasureGUI/MeasureGUI_CheckShapeDlg.h b/src/MeasureGUI/MeasureGUI_CheckShapeDlg.h index 1c80efd27..514d06065 100644 --- a/src/MeasureGUI/MeasureGUI_CheckShapeDlg.h +++ b/src/MeasureGUI/MeasureGUI_CheckShapeDlg.h @@ -1,23 +1,23 @@ // 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 +// 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 // // // @@ -30,35 +30,35 @@ #define DIALOGBOX_CHECKSHAPEDLG_H #include "MeasureGUI_Skeleton.h" -#include "MeasureGUI_1Sel1TextView_QTD.h" -#include "MeasureGUI.h" +class MeasureGUI_1Sel1TextView_QTD; //================================================================================= // class : MeasureGUI_CheckShapeDlg // purpose : //================================================================================= class MeasureGUI_CheckShapeDlg : public MeasureGUI_Skeleton -{ +{ Q_OBJECT public: - MeasureGUI_CheckShapeDlg(QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); - ~MeasureGUI_CheckShapeDlg(); + MeasureGUI_CheckShapeDlg( QWidget* parent, + SALOME_Selection* Sel ); + ~MeasureGUI_CheckShapeDlg(); +protected: + + // redefined from GEOMBase_Helper and MeasureGUI_Skeleton + virtual void processObject(); private: - void Init(); - void enterEvent(QEvent* e); - void Check(const TopoDS_Shape S); - QString SelectedName; - MeasureGUI_1Sel1TextView_QTD* GroupC1; + void Init( SALOME_Selection* Sel ); + bool getParameters( bool& theIsValid, + QString& theMsg); + +private: -private slots: - void SetEditCurrentArgument(); - void SelectionIntoArgument(); - void LineEditReturnPressed(); - void ActivateThisDialog(); + MeasureGUI_1Sel1TextView_QTD* myGrp; }; diff --git a/src/MeasureGUI/MeasureGUI_DistanceDlg.cxx b/src/MeasureGUI/MeasureGUI_DistanceDlg.cxx index f33a3415b..2e9a3934a 100644 --- a/src/MeasureGUI/MeasureGUI_DistanceDlg.cxx +++ b/src/MeasureGUI/MeasureGUI_DistanceDlg.cxx @@ -1,23 +1,23 @@ // 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 +// 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 // // // @@ -27,13 +27,17 @@ // $Header$ #include "MeasureGUI_DistanceDlg.h" - +#include "MeasureGUI_2Sel1LineEdit_QTD.h" +#include "GEOMBase.h" +#include "GEOM_Displayer.h" #include "QAD_RightFrame.h" +#include "QAD_Desktop.h" #include "OCCViewer_Viewer3d.h" +#include "OCCViewer_Prs.h" +#include "SALOMEGUI_QtCatchCorbaException.hxx" #include #include -#include #include #include #include @@ -43,41 +47,51 @@ #include "utilities.h" -using namespace std; +#include +#include +#include +#include +#include //================================================================================= // class : MeasureGUI_DistanceDlg() -// purpose : Constructs a MeasureGUI_DistanceDlg which is a child of 'parent', with the +// purpose : Constructs a MeasureGUI_DistanceDlg 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_DistanceDlg::MeasureGUI_DistanceDlg(QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl) - :MeasureGUI_Skeleton(parent, name, Sel, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) +MeasureGUI_DistanceDlg::MeasureGUI_DistanceDlg( QWidget* parent, SALOME_Selection* Sel ) +: MeasureGUI_Skeleton( parent, "MeasureGUI_DistanceDlg", Sel ) { - QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_MINDIST"))); - QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); + QPixmap image0( QAD_Desktop::getResourceManager()->loadPixmap( + "GEOM",tr( "ICON_DLG_MINDIST" ) ) ); + QPixmap image1( QAD_Desktop::getResourceManager()->loadPixmap( + "GEOM",tr( "ICON_SELECT" ) ) ); - setCaption(tr("GEOM_MINDIST_TITLE")); + setCaption( tr( "GEOM_MINDIST_TITLE" ) ); /***************************************************************/ - GroupConstructors->setTitle(tr("GEOM_DISTANCE")); - RadioButton1->setPixmap(image0); - - GroupC1 = new MeasureGUI_2Sel1LineEdit_QTD(this, "GroupC1"); - GroupC1->GroupBox1->setTitle(tr("GEOM_MINDIST_OBJ")); - GroupC1->TextLabel1->setText(tr("GEOM_OBJECT_I").arg("1")); - GroupC1->TextLabel2->setText(tr("GEOM_OBJECT_I").arg("2")); - GroupC1->TextLabel3->setText(tr("GEOM_LENGTH")); - GroupC1->LineEdit3->setReadOnly(TRUE); - GroupC1->PushButton1->setPixmap(image1); - GroupC1->PushButton2->setPixmap(image1); - - Layout1->addWidget(GroupC1, 1, 0); + + GroupConstructors->setTitle( tr( "GEOM_DISTANCE" ) ); + RadioButton1->setPixmap( image0 ); + + myGrp = new MeasureGUI_2Sel1LineEdit_QTD( this, "myGrp" ); + myGrp->GroupBox1->setTitle( tr( "GEOM_MINDIST_OBJ" ) ); + myGrp->TextLabel1->setText( tr( "GEOM_OBJECT_I" ).arg( "1" ) ); + myGrp->TextLabel2->setText( tr( "GEOM_OBJECT_I" ).arg( "2" ) ); + myGrp->TextLabel3->setText( tr( "GEOM_LENGTH" ) ); + myGrp->LineEdit3->setReadOnly( TRUE ); + myGrp->PushButton1->setPixmap( image1 ); + myGrp->PushButton2->setPixmap( image1 ); + myGrp->LineEdit1->setReadOnly( true ); + myGrp->LineEdit2->setReadOnly( true ); + + Layout1->addWidget( myGrp, 1, 0 ); + /***************************************************************/ /* Initialisation */ - Init(); + Init( Sel ); } @@ -86,8 +100,7 @@ MeasureGUI_DistanceDlg::MeasureGUI_DistanceDlg(QWidget* parent, const char* name // purpose : Destroys the object and frees any allocated resources //================================================================================= MeasureGUI_DistanceDlg::~MeasureGUI_DistanceDlg() -{ - /* no need to delete child widgets, Qt does it all for us */ +{ } @@ -95,97 +108,98 @@ MeasureGUI_DistanceDlg::~MeasureGUI_DistanceDlg() // function : Init() // purpose : //================================================================================= -void MeasureGUI_DistanceDlg::Init() +void MeasureGUI_DistanceDlg::Init( SALOME_Selection* Sel ) { - /* init variables */ - myEditCurrentArgument = GroupC1->LineEdit1; + mySelBtn = myGrp->PushButton1; + mySelEdit = myGrp->LineEdit1; + mySelBtn2 = myGrp->PushButton2; + mySelEdit2 = myGrp->LineEdit2; + + myEditCurrentArgument = mySelEdit; - myOkShape1 = myOkShape2 = false; + connect( mySelEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); + connect( mySelBtn2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); - /* signals and slots connections */ - connect(buttonClose, SIGNAL(clicked()), this, SLOT(ClickOnCancel())); - connect(myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog())); - connect(myGeomGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel())); + MeasureGUI_Skeleton::Init( Sel ); - connect(GroupC1->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupC1->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); +} - connect(GroupC1->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect(GroupC1->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection has changed +//================================================================================= +void MeasureGUI_DistanceDlg::SelectionIntoArgument() +{ + Standard_Boolean testResult = Standard_False; + GEOM::GEOM_Object_var aSelectedObject = + GEOMBase::ConvertIOinGEOMObject( mySelection->firstIObject(), testResult ); - /* displays Dialog */ - GroupC1->show(); - this->show(); + if ( !testResult ) + aSelectedObject = GEOM::GEOM_Object::_nil(); - return; -} + if ( myEditCurrentArgument == mySelEdit ) + myObj = aSelectedObject; + else + myObj2 = aSelectedObject; + processObject(); +} //================================================================================= -// function : ClickOnCancel() -// purpose : +// function : processObject() +// purpose : Fill dialogs fileds in accordance with myObj and myObj2 //================================================================================= -void MeasureGUI_DistanceDlg::ClickOnCancel() +void MeasureGUI_DistanceDlg::processObject() { - this->EraseDistance(); - MeasureGUI_Skeleton::ClickOnCancel(); - return; + myGrp->LineEdit1->setText( !myObj->_is_nil() ? GEOMBase::GetName( myObj ) : "" ); + myGrp->LineEdit2->setText( !myObj2->_is_nil() ? GEOMBase::GetName( myObj2 ) : "" ); + + gp_Pnt aPnt1, aPnt2; + double aDist = 0.; + if ( getParameters( aDist, aPnt1, aPnt2 ) ) + { + myGrp->LineEdit3->setText( QString( "%1" ).arg( aDist ) ); + redisplayPreview(); + } + else + { + myGrp->LineEdit3->setText( "" ); + erasePreview(); + } + } - //================================================================================= -// function : SelectionIntoArgument() -// purpose : Called when selection has changed +// function : getParameters() +// purpose : Get distance between objects //================================================================================= -void MeasureGUI_DistanceDlg::SelectionIntoArgument() +bool MeasureGUI_DistanceDlg::getParameters( double& theDistance, + gp_Pnt& thePnt1, + gp_Pnt& thePnt2 ) { - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); - this->EraseDistance(); - myEditCurrentArgument->setText(""); - QString aString = ""; - - GroupC1->LineEdit3->setText(""); - - int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString); - if(nbSel != 1) { - if(myEditCurrentArgument == GroupC1->LineEdit1) - myOkShape1 = false; - else if(myEditCurrentArgument == GroupC1->LineEdit2) - myOkShape2 = false; - return; - } - - /* nbSel == 1 */ - TopoDS_Shape S; - if(!myGeomBase->GetTopoFromSelection(mySelection, S)) - return; + QString msg; + if ( !isValid( msg ) ) + return false; + else + { + try + { + double x1, y1, z1, x2, y2, z2; + theDistance = GEOM::GEOM_IMeasureOperations::_narrow( getOperation() )->GetMinDistance( + myObj, myObj2, x1, y1, z1, x2, y2, z2 ); + + thePnt1.SetCoord( x1, y1, z1 ); + thePnt2.SetCoord( x2, y2, z2 ); + } + catch( const SALOME::SALOME_Exception& e ) + { + QtCatchCorbaException( e ); + return false; + } - Standard_Boolean testResult; - Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); - - if(myEditCurrentArgument == GroupC1->LineEdit1) { - myGeomShape1 = myGeomBase->ConvertIOinGEOMShape(IO, testResult); - if(!testResult) - return; - myShape1 = S; - myEditCurrentArgument->setText(aString); - myOkShape1 = true; - } - else if(myEditCurrentArgument == GroupC1->LineEdit2) { - myGeomShape2 = myGeomBase->ConvertIOinGEOMShape(IO, testResult); - if(!testResult) - return; - myShape2 = S; - myEditCurrentArgument->setText(aString); - myOkShape2 = true; + return getOperation()->IsDone(); } - - if(myOkShape1 && myOkShape2) - this->MakeDistanceSimulationAndDisplay(myShape1 ,myShape2); - return; } @@ -195,19 +209,20 @@ void MeasureGUI_DistanceDlg::SelectionIntoArgument() //================================================================================= void MeasureGUI_DistanceDlg::SetEditCurrentArgument() { - QPushButton* send = (QPushButton*)sender(); + QPushButton* send = ( QPushButton* )sender(); - if(send == GroupC1->PushButton1) { - GroupC1->LineEdit1->setFocus(); - myEditCurrentArgument = GroupC1->LineEdit1; + if( send == mySelBtn ) + { + mySelEdit->setFocus(); + myEditCurrentArgument = mySelEdit; } - else if(send == GroupC1->PushButton2) { - GroupC1->LineEdit2->setFocus(); - myEditCurrentArgument = GroupC1->LineEdit2; + else + { + mySelEdit2->setFocus(); + myEditCurrentArgument = mySelEdit2; } - this->SelectionIntoArgument(); - return; + SelectionIntoArgument(); } @@ -217,157 +232,101 @@ void MeasureGUI_DistanceDlg::SetEditCurrentArgument() //================================================================================= void MeasureGUI_DistanceDlg::LineEditReturnPressed() { - QLineEdit* send = (QLineEdit*)sender(); - if(send == GroupC1->LineEdit1) - myEditCurrentArgument = GroupC1->LineEdit1; - else if(send == GroupC1->LineEdit2) - myEditCurrentArgument = GroupC1->LineEdit2; + QLineEdit* send = ( QLineEdit* )sender(); + + if( send == mySelEdit ) + myEditCurrentArgument = mySelEdit; else - return; + myEditCurrentArgument = mySelEdit2; - MeasureGUI_Skeleton::LineEditReturnPressed(); - return; + if ( GEOMBase::SelectionByNameInDialogs( this, mySelEdit->text(), mySelection ) ) + mySelEdit->setText( mySelEdit->text() ); } //================================================================================= -// function : ActivateThisDialog() +// function : buildPrs() // purpose : //================================================================================= -void MeasureGUI_DistanceDlg::ActivateThisDialog() +SALOME_Prs* MeasureGUI_DistanceDlg::buildPrs() { - MeasureGUI_Skeleton::ActivateThisDialog(); - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - if(!mySimulationTopoDs.IsNull()) - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - return; -} - + double aDist = 0.; + gp_Pnt aPnt1( 0, 0, 0 ), aPnt2( 0, 0, 0 ); + + if ( myObj->_is_nil() || myObj2->_is_nil() || !getParameters( aDist, aPnt1, aPnt2 ) || + QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_OCC ) + return 0; + + try + { + if( aDist <= 1.e-9 ) + { + BRepBuilderAPI_MakeVertex aMaker( aPnt1 ); + return getDisplayer()->BuildPrs( aMaker.Vertex() ); + } + else + { + BRepBuilderAPI_MakeEdge MakeEdge( aPnt1, aPnt2 ); + TopoDS_Vertex aVert1 = BRepBuilderAPI_MakeVertex( aPnt1 ); + TopoDS_Vertex aVert2 = BRepBuilderAPI_MakeVertex( aPnt2 ); -//================================================================================= -// function : enterEvent() -// purpose : when mouse enter onto the QWidget -//================================================================================= -void MeasureGUI_DistanceDlg::enterEvent(QEvent* e) -{ - if(GroupConstructors->isEnabled()) - return; - this->ActivateThisDialog(); - return; -} + QString aLabel; + aLabel.sprintf( "%.1f", aDist ); + gp_Pnt aPnt3( ( aPnt1.X() + aPnt2.X() ) / 2, + ( aPnt1.Y() + aPnt2.Y() ) / 2, + ( aPnt1.Z() + aPnt2.Z() ) / 2 + 100 ); -//================================================================================= -// function : closeEvent() -// purpose : -//================================================================================= -void MeasureGUI_DistanceDlg::closeEvent(QCloseEvent* e) -{ - /* same than click on cancel button */ - this->ClickOnCancel(); - return; -} + gp_Vec va( aPnt3, aPnt1 ); + gp_Vec vb( aPnt3, aPnt2 ); -//================================================================================= -// function : MakeDistanceSimulationAndDisplay() -// purpose : -//================================================================================= -void MeasureGUI_DistanceDlg::MakeDistanceSimulationAndDisplay(const TopoDS_Shape& S1, const TopoDS_Shape& S2) -{ - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); - GroupC1->LineEdit3->setText(""); - - BRepExtrema_DistShapeShape dst(S1, S2); - - try { - if(dst.IsDone()) { - gp_Pnt P1, P2; - Standard_Real Dist = 1.e9; - for(int i = 1; i <= dst.NbSolution(); i++) { - P1 = (dst.PointOnShape1(i)); - P2 = (dst.PointOnShape2(i)); - - Standard_Real MinDist = P1.Distance(P2); - if(Dist > MinDist) - Dist = MinDist; + if ( va.IsParallel( vb, Precision::Angular() ) ) + { + aPnt3.SetY( ( aPnt1.Y() + aPnt2.Y() ) / 2 + 100 ); + aPnt3.SetZ( ( aPnt1.Z() + aPnt2.Z() ) / 2 ); } + + gce_MakePln gce_MP( aPnt1, aPnt2, aPnt3 ); + Handle( Geom_Plane ) P = new Geom_Plane( gce_MP.Value() ); - if(Dist <= 1.e-9) { - BRepBuilderAPI_MakeVertex MakeVertex(P1); - mySimulationTopoDs = MakeVertex.Vertex(); - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - - GroupC1->LineEdit3->setText("0.0"); - } - else { - BRepBuilderAPI_MakeEdge MakeEdge(P1, P2); - mySimulationTopoDs = MakeEdge.Edge(); - - TopoDS_Vertex V1 = BRepBuilderAPI_MakeVertex(P1); - TopoDS_Vertex V2 = BRepBuilderAPI_MakeVertex(P2); - - QString S; - S.sprintf("%.1f", Dist); - - gp_Pnt P3; - P3.SetX((P1.X() + P2.X()) / 2); - P3.SetY((P1.Y() + P2.Y()) / 2); - P3.SetZ(((P1.Z() + P2.Z()) / 2) + 100); - gp_Vec va(P3, P1); - gp_Vec vb(P3, P2); - if(va.IsParallel(vb, Precision::Angular())) { - P3.SetY(((P1.Y() + P2.Y()) / 2) + 100); - P3.SetZ(((P1.Z() + P2.Z()) / 2)); - } - gce_MakePln gce_MP(P1, P2, P3); - gp_Pln gp_P = gce_MP.Value(); - Handle(Geom_Plane) P = new Geom_Plane(gp_P); - - char* aCopyS = CORBA::string_dup(S); - Handle(AIS_LengthDimension) Distance = new AIS_LengthDimension(V1, V2, P, Dist, TCollection_ExtendedString(aCopyS)); - delete(aCopyS); - - GroupC1->LineEdit3->setText(S); - - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); - ic->Display(Distance); - ic->UpdateCurrentViewer(); - } - } + Handle( AIS_LengthDimension ) anIO = new AIS_LengthDimension( + aVert1, aVert2, P, aDist, TCollection_ExtendedString( (Standard_CString)aLabel.latin1() ) ); + + QAD_ViewFrame* vf = GEOM_Displayer::GetActiveView(); + OCCViewer_Prs* aPrs = dynamic_cast( vf->CreatePrs( 0 ) ); + + if ( aPrs ) + aPrs->AddObject( anIO ); + + return aPrs; } } - catch(Standard_Failure) { - MESSAGE("Catch intercepted in MakeDistanceSimulationAndDisplay()"); + catch( Standard_Failure ) + { + return 0; } - return; } - //================================================================================= -// function : EraseDistance() +// function : isValid() // purpose : //================================================================================= -void MeasureGUI_DistanceDlg::EraseDistance() +bool MeasureGUI_DistanceDlg::isValid( QString& msg ) { - int count = QAD_Application::getDesktop()->getActiveStudy()->getStudyFramesCount(); - for(int i = 0; i < count; i++) { - if (QAD_Application::getDesktop()->getActiveStudy()->getStudyFrame(i)->getTypeView() == VIEW_OCC ) { - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getStudyFrame(i)->getRightFrame()->getViewFrame())->getViewer(); - Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); - - AIS_ListOfInteractive L; - ic->DisplayedObjects(AIS_KOI_Relation, -1, L); - AIS_ListIteratorOfListOfInteractive ite(L); - while (ite.More()) { - ic->Remove(ite.Value()); - ic->UpdateCurrentViewer(); - ite.Next(); - } - } - } - return; + return MeasureGUI_Skeleton::isValid( msg ) && !myObj2->_is_nil(); } + + + + + + + + + + + + + + diff --git a/src/MeasureGUI/MeasureGUI_DistanceDlg.h b/src/MeasureGUI/MeasureGUI_DistanceDlg.h index 50718dd40..25c60f9d5 100644 --- a/src/MeasureGUI/MeasureGUI_DistanceDlg.h +++ b/src/MeasureGUI/MeasureGUI_DistanceDlg.h @@ -30,9 +30,10 @@ #define DIALOGBOX_DISTANCE_H #include "MeasureGUI_Skeleton.h" -#include "MeasureGUI_2Sel1LineEdit_QTD.h" -#include "MeasureGUI.h" +class MeasureGUI_2Sel1LineEdit_QTD; +class gp_Pnt; + //================================================================================= // class : MeasureGUI_DistanceDlg @@ -43,31 +44,33 @@ class MeasureGUI_DistanceDlg : public MeasureGUI_Skeleton Q_OBJECT public: - MeasureGUI_DistanceDlg(QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); - ~MeasureGUI_DistanceDlg(); + MeasureGUI_DistanceDlg( QWidget* parent, + SALOME_Selection* Sel ); + ~MeasureGUI_DistanceDlg(); +protected: + + // redefined from GEOMBase_Helper and MeasureGUI_Skeleton + virtual void processObject(); + virtual SALOME_Prs* buildPrs(); + virtual void SelectionIntoArgument(); + virtual void LineEditReturnPressed(); + virtual void SetEditCurrentArgument(); + virtual bool isValid( QString& msg ); private: - void Init(); - void enterEvent(QEvent* e); - void closeEvent(QCloseEvent* e); - void MakeDistanceSimulationAndDisplay(const TopoDS_Shape& S1, const TopoDS_Shape& S2); - void EraseDistance(); - TopoDS_Shape myShape1; - TopoDS_Shape myShape2; - GEOM::GEOM_Shape_var myGeomShape1; - GEOM::GEOM_Shape_var myGeomShape2; - bool myOkShape1; - bool myOkShape2; /* to check when arguments are defined */ + void Init( SALOME_Selection* Sel ); + bool getParameters( double& theDistance, + gp_Pnt& thePnt1, + gp_Pnt& thePnt2 ); +private: - MeasureGUI_2Sel1LineEdit_QTD* GroupC1; + QLineEdit* myEditCurrentArgument; + QLineEdit* mySelEdit2; + QPushButton* mySelBtn2; -private slots: - void ClickOnCancel(); - void SetEditCurrentArgument(); - void SelectionIntoArgument(); - void LineEditReturnPressed(); - void ActivateThisDialog(); + MeasureGUI_2Sel1LineEdit_QTD* myGrp; + GEOM::GEOM_Object_var myObj2; }; diff --git a/src/MeasureGUI/MeasureGUI_InertiaDlg.cxx b/src/MeasureGUI/MeasureGUI_InertiaDlg.cxx index 8ceaea053..96c38a341 100644 --- a/src/MeasureGUI/MeasureGUI_InertiaDlg.cxx +++ b/src/MeasureGUI/MeasureGUI_InertiaDlg.cxx @@ -26,60 +26,77 @@ // Module : GEOM #include "MeasureGUI_InertiaDlg.h" +#include "MeasureGUI_1Sel12LineEdit_QTD.h" +#include "SALOMEGUI_QtCatchCorbaException.hxx" + +#include "GEOMBase.h" #include #include #include +#include +#include #include "utilities.h" +#include "QAD_Desktop.h" -using namespace std; +#include +#include +#include +#include +#include //================================================================================= // class : MeasureGUI_InertiaDlg() -// purpose : Constructs a MeasureGUI_InertiaDlg which is a child of 'parent', with the +// purpose : Constructs a MeasureGUI_InertiaDlg 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_InertiaDlg::MeasureGUI_InertiaDlg(QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl) - :MeasureGUI_Skeleton(parent, name, Sel, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) -{ - QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_INERTIA"))); - QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); - - setCaption(tr("GEOM_INERTIA_TITLE")); - /***************************************************************/ - GroupConstructors->setTitle(tr("GEOM_INERTIA_CONSTR")); - RadioButton1->setPixmap(image0); +MeasureGUI_InertiaDlg::MeasureGUI_InertiaDlg( QWidget* parent, SALOME_Selection* Sel ) +: MeasureGUI_Skeleton( parent, "MeasureGUI_InertiaDlg", Sel ) +{ + QPixmap image0( QAD_Desktop::getResourceManager()->loadPixmap( + "GEOM",tr( "ICON_DLG_INERTIA" ) ) ); + QPixmap image1( QAD_Desktop::getResourceManager()->loadPixmap( + "GEOM",tr( "ICON_SELECT" ) ) ); - GroupC1 = new MeasureGUI_1Sel12LineEdit_QTD(this, "GroupC1"); - GroupC1->GroupBox1->setTitle(tr("GEOM_MATRIX")); - GroupC1->TextLabel1->setText(tr("GEOM_OBJECT")); - GroupC1->TextLabel2->setText(tr("GEOM_INERTIA_I").arg("1")); - GroupC1->TextLabel3->setText(tr("GEOM_INERTIA_I").arg("2")); - GroupC1->TextLabel4->setText(tr("GEOM_INERTIA_I").arg("3")); - GroupC1->TextLabel5->setText(tr("GEOM_INERTIA_IXYZ")); - GroupC1->LineEdit11->setReadOnly(TRUE); - GroupC1->LineEdit12->setReadOnly(TRUE); - GroupC1->LineEdit13->setReadOnly(TRUE); - GroupC1->LineEdit21->setReadOnly(TRUE); - GroupC1->LineEdit22->setReadOnly(TRUE); - GroupC1->LineEdit23->setReadOnly(TRUE); - GroupC1->LineEdit31->setReadOnly(TRUE); - GroupC1->LineEdit32->setReadOnly(TRUE); - GroupC1->LineEdit33->setReadOnly(TRUE); - GroupC1->LineEdit41->setReadOnly(TRUE); - GroupC1->LineEdit42->setReadOnly(TRUE); - GroupC1->LineEdit43->setReadOnly(TRUE); - GroupC1->PushButton1->setPixmap(image1); + setCaption( tr( "GEOM_INERTIA_TITLE" ) ); - Layout1->addWidget(GroupC1, 1, 0); + /***************************************************************/ + + GroupConstructors->setTitle( tr( "GEOM_INERTIA_CONSTR" ) ); + RadioButton1->setPixmap( image0 ); + + myGrp = new MeasureGUI_1Sel12LineEdit_QTD( this, "myGrp" ); + myGrp->GroupBox1->setTitle( tr( "GEOM_MATRIX" ) ); + myGrp->TextLabel1->setText( tr( "GEOM_OBJECT" ) ); + myGrp->TextLabel2->setText( tr( "GEOM_INERTIA_I" ).arg( "1" ) ); + myGrp->TextLabel3->setText( tr( "GEOM_INERTIA_I" ).arg( "2" ) ); + myGrp->TextLabel4->setText( tr( "GEOM_INERTIA_I" ).arg( "3" ) ); + myGrp->TextLabel5->setText( tr( "GEOM_INERTIA_IXYZ" ) ); + myGrp->LineEdit11->setReadOnly( TRUE ); + myGrp->LineEdit12->setReadOnly( TRUE ); + myGrp->LineEdit13->setReadOnly( TRUE ); + myGrp->LineEdit21->setReadOnly( TRUE ); + myGrp->LineEdit22->setReadOnly( TRUE ); + myGrp->LineEdit23->setReadOnly( TRUE ); + myGrp->LineEdit31->setReadOnly( TRUE ); + myGrp->LineEdit32->setReadOnly( TRUE ); + myGrp->LineEdit33->setReadOnly( TRUE ); + myGrp->LineEdit41->setReadOnly( TRUE ); + myGrp->LineEdit42->setReadOnly( TRUE ); + myGrp->LineEdit43->setReadOnly( TRUE ); + myGrp->PushButton1->setPixmap( image1 ); + myGrp->LineEdit1->setReadOnly( true ); + + Layout1->addWidget( myGrp, 1, 0 ); + /***************************************************************/ /* Initialisation */ - Init(); + Init( Sel ); } @@ -89,7 +106,6 @@ MeasureGUI_InertiaDlg::MeasureGUI_InertiaDlg(QWidget* parent, const char* name, //================================================================================= MeasureGUI_InertiaDlg::~MeasureGUI_InertiaDlg() { - // no need to delete child widgets, Qt does it all for us } @@ -97,193 +113,91 @@ MeasureGUI_InertiaDlg::~MeasureGUI_InertiaDlg() // function : Init() // purpose : //================================================================================= -void MeasureGUI_InertiaDlg::Init() +void MeasureGUI_InertiaDlg::Init( SALOME_Selection* Sel ) { - /* init variables */ - myEditCurrentArgument = GroupC1->LineEdit1; - - /* signals and slots connections */ - connect(GroupC1->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupC1->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - - /* displays Dialog */ - GroupC1->show(); - this->show(); - - return; + mySelBtn = myGrp->PushButton1; + mySelEdit = myGrp->LineEdit1; + MeasureGUI_Skeleton::Init( Sel ); } - //================================================================================= -// function : SelectionIntoArgument() -// purpose : Called when selection as changed or other case -//================================================================================= -void MeasureGUI_InertiaDlg::SelectionIntoArgument() -{ - myEditCurrentArgument->setText(""); - QString aString = ""; - - GroupC1->LineEdit11->setText(""); - GroupC1->LineEdit12->setText(""); - GroupC1->LineEdit13->setText(""); - GroupC1->LineEdit21->setText(""); - GroupC1->LineEdit22->setText(""); - GroupC1->LineEdit23->setText(""); - GroupC1->LineEdit31->setText(""); - GroupC1->LineEdit32->setText(""); - GroupC1->LineEdit33->setText(""); - GroupC1->LineEdit41->setText(""); - GroupC1->LineEdit42->setText(""); - GroupC1->LineEdit43->setText(""); - - int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString); - if(nbSel != 1) - return; - - /* nbSel == 1 */ - TopoDS_Shape S; - if(!myGeomBase->GetTopoFromSelection(mySelection, S) || S.IsNull()) - return; - - GroupC1->LineEdit1->setText(aString); - - this->CalculateAndDisplayInertia(S); - return; -} - - -//================================================================================= -// function : SetEditCurrentArgument() +// function : processObject // purpose : //================================================================================= -void MeasureGUI_InertiaDlg::SetEditCurrentArgument() +void MeasureGUI_InertiaDlg::processObject() { - QPushButton* send = (QPushButton*)sender(); - - if(send == GroupC1->PushButton1) { - GroupC1->LineEdit1->setFocus(); - myEditCurrentArgument = GroupC1->LineEdit1; - } - - this->SelectionIntoArgument(); - return; -} + gp_XYZ anIXYZ; + gp_Mat aMat; + if ( !getParameters( aMat, anIXYZ ) ) + { + mySelEdit->setText( "" ); + + myGrp->LineEdit11->setText( "" ); + myGrp->LineEdit12->setText( "" ); + myGrp->LineEdit13->setText( "" ); + + myGrp->LineEdit21->setText( "" ); + myGrp->LineEdit22->setText( "" ); + myGrp->LineEdit23->setText( "" ); + + myGrp->LineEdit31->setText( "" ); + myGrp->LineEdit32->setText( "" ); + myGrp->LineEdit33->setText( "" ); -//================================================================================= -// function : LineEditReturnPressed() -// purpose : -//================================================================================= -void MeasureGUI_InertiaDlg::LineEditReturnPressed() -{ - QLineEdit* send = (QLineEdit*)sender(); - if(send == GroupC1->LineEdit1) - myEditCurrentArgument = GroupC1->LineEdit1; + myGrp->LineEdit41->setText( "" ); + myGrp->LineEdit42->setText( "" ); + myGrp->LineEdit43->setText( "" ); + } else - return; - - MeasureGUI_Skeleton::LineEditReturnPressed(); - return; -} - - -//================================================================================= -// function : ActivateThisDialog() -// purpose : -//================================================================================= -void MeasureGUI_InertiaDlg::ActivateThisDialog() -{ - MeasureGUI_Skeleton::ActivateThisDialog(); - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - return; -} - - -//================================================================================= -// function : enterEvent() -// purpose : -//================================================================================= -void MeasureGUI_InertiaDlg::enterEvent(QEvent* e) -{ - if(GroupConstructors->isEnabled()) - return; - this->ActivateThisDialog(); - return; + { + myGrp->LineEdit11->setText( QString( "%1" ).arg( aMat( 1, 1 ), 12, 'e', 4 ) ); + myGrp->LineEdit12->setText( QString( "%1" ).arg( aMat( 1, 2 ), 12, 'e', 4 ) ); + myGrp->LineEdit13->setText( QString( "%1" ).arg( aMat( 1, 3 ), 12, 'e', 4 ) ); + + myGrp->LineEdit21->setText( QString( "%1" ).arg( aMat( 2, 1 ), 12, 'e', 4 ) ); + myGrp->LineEdit22->setText( QString( "%1" ).arg( aMat( 2, 2 ), 12, 'e', 4 ) ); + myGrp->LineEdit23->setText( QString( "%1" ).arg( aMat( 2, 3 ), 12, 'e', 4 ) ); + + myGrp->LineEdit31->setText( QString( "%1" ).arg( aMat( 3, 1 ), 12, 'e', 4 ) ); + myGrp->LineEdit32->setText( QString( "%1" ).arg( aMat( 3, 2 ), 12, 'e', 4 ) ); + myGrp->LineEdit33->setText( QString( "%1" ).arg( aMat( 3, 3 ), 12, 'e', 4 ) ); + + myGrp->LineEdit41->setText( QString( "%1" ).arg( anIXYZ.X(), 12, 'e', 4 ) ); + myGrp->LineEdit42->setText( QString( "%1" ).arg( anIXYZ.Y(), 12, 'e', 4 ) ); + myGrp->LineEdit43->setText( QString( "%1" ).arg( anIXYZ.Z(), 12, 'e', 4 ) ); + } } - //================================================================================= -// function : CalculateAndDisplayInertia() +// function : getParameters // purpose : //================================================================================= -void MeasureGUI_InertiaDlg::CalculateAndDisplayInertia(const TopoDS_Shape& S) +bool MeasureGUI_InertiaDlg::getParameters( gp_Mat& I, + gp_XYZ& theIXYZ ) { - GroupC1->LineEdit11->setText(""); - GroupC1->LineEdit12->setText(""); - GroupC1->LineEdit13->setText(""); - GroupC1->LineEdit21->setText(""); - GroupC1->LineEdit22->setText(""); - GroupC1->LineEdit23->setText(""); - GroupC1->LineEdit31->setText(""); - GroupC1->LineEdit32->setText(""); - GroupC1->LineEdit33->setText(""); - GroupC1->LineEdit41->setText(""); - GroupC1->LineEdit42->setText(""); - GroupC1->LineEdit43->setText(""); - - if(S.IsNull()) - return; - - QString resString; - GProp_GProps System; - - try { - if(S.ShapeType() == TopAbs_VERTEX || S.ShapeType() == TopAbs_EDGE || S.ShapeType() == TopAbs_WIRE) - BRepGProp::LinearProperties(S, System); - else if(S.ShapeType() == TopAbs_FACE || S.ShapeType() == TopAbs_SHELL) - BRepGProp::SurfaceProperties(S, System); - else - BRepGProp::VolumeProperties(S, System); - - gp_Mat I = System.MatrixOfInertia() ; - GProp_PrincipalProps Pr = System.PrincipalProperties(); - Standard_Real Ix,Iy,Iz; - Pr.Moments(Ix,Iy,Iz); - - /* matrix 3x3 */ - resString = tr("%1").arg(I(1,1), 12, 'f', 6); - GroupC1->LineEdit11->setText(resString); - resString = tr("%1").arg(I(1,2), 12, 'f', 6); - GroupC1->LineEdit12->setText(resString); - resString = tr("%1").arg(I(1,3), 12, 'f', 6); - GroupC1->LineEdit13->setText(resString); - - resString = tr("%1").arg(I(2,1), 12, 'f', 6); - GroupC1->LineEdit21->setText(resString); - resString = tr("%1").arg(I(2,2), 12, 'f', 6); - GroupC1->LineEdit22->setText(resString); - resString = tr("%1").arg(I(2,3), 12, 'f', 6); - GroupC1->LineEdit23->setText(resString); - - resString = tr("%1").arg(I(3,1), 12, 'f', 6); - GroupC1->LineEdit31->setText(resString); - resString = tr("%1").arg(I(3,2), 12, 'f', 6); - GroupC1->LineEdit32->setText(resString); - resString = tr("%1").arg(I(3,3), 12, 'f', 6); - GroupC1->LineEdit33->setText(resString); - - /* moments */ - resString = tr("%1").arg(Ix, 12, 'f', 6); - GroupC1->LineEdit41->setText(resString); - resString = tr("%1").arg(Ix, 12, 'f', 6); - GroupC1->LineEdit42->setText(resString); - resString = tr("%1").arg(Iz, 12, 'f', 6); - GroupC1->LineEdit43->setText(resString); - } - catch(Standard_Failure) { - MESSAGE("Catch intercepted in CalculateAndDisplayInertia()"); + if ( myObj->_is_nil() ) + return false; + else + { + try + { + double x, y, z; + GEOM::GEOM_IMeasureOperations::_narrow( getOperation() )->GetInertia( myObj, + I( 1, 1 ), I( 1, 2 ), I( 1, 3 ), + I( 2, 1 ), I( 2, 2 ), I( 2, 3 ), + I( 3, 1 ), I( 3, 2 ), I( 3, 3 ), + x, y, z ); + + theIXYZ.SetCoord( x, y, z ); + } + catch( const SALOME::SALOME_Exception& e ) + { + QtCatchCorbaException( e ); + return false; + } + + return getOperation()->IsDone(); } - return; } + diff --git a/src/MeasureGUI/MeasureGUI_InertiaDlg.h b/src/MeasureGUI/MeasureGUI_InertiaDlg.h index 4e6bc2f02..0a45b87d2 100644 --- a/src/MeasureGUI/MeasureGUI_InertiaDlg.h +++ b/src/MeasureGUI/MeasureGUI_InertiaDlg.h @@ -30,35 +30,38 @@ #define DIALOGBOX_INERTIA_H #include "MeasureGUI_Skeleton.h" -#include "MeasureGUI_1Sel12LineEdit_QTD.h" -#include "MeasureGUI.h" +class MeasureGUI_1Sel12LineEdit_QTD; +class gp_XYZ; +class gp_Mat; //================================================================================= // class : MeasureGUI_InertiaDlg -// purpose : +// purpose : Dialog for displaying moment of inertia //================================================================================= + class MeasureGUI_InertiaDlg : public MeasureGUI_Skeleton { Q_OBJECT public: - MeasureGUI_InertiaDlg(QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); - ~MeasureGUI_InertiaDlg(); + MeasureGUI_InertiaDlg( QWidget* parent, + SALOME_Selection* Sel ); + ~MeasureGUI_InertiaDlg(); +protected: -private: - void Init(); - void enterEvent(QEvent* e); - void CalculateAndDisplayInertia(const TopoDS_Shape& S); + // redefined from GEOMBase_Helper and MeasureGUI_Skeleton + virtual void processObject(); - MeasureGUI_1Sel12LineEdit_QTD* GroupC1; +private: -private slots: - void SetEditCurrentArgument(); - void SelectionIntoArgument(); - void LineEditReturnPressed(); - void ActivateThisDialog(); + void Init( SALOME_Selection* Sel ); + bool getParameters( gp_Mat& theMatrix, + gp_XYZ& theMoment ); +private: + + MeasureGUI_1Sel12LineEdit_QTD* myGrp; }; #endif // DIALOGBOX_INERTIA_H diff --git a/src/MeasureGUI/MeasureGUI_MaxToleranceDlg.cxx b/src/MeasureGUI/MeasureGUI_MaxToleranceDlg.cxx index 04b810b89..7fb4de9f6 100644 --- a/src/MeasureGUI/MeasureGUI_MaxToleranceDlg.cxx +++ b/src/MeasureGUI/MeasureGUI_MaxToleranceDlg.cxx @@ -27,57 +27,63 @@ // $Header$ #include "MeasureGUI_MaxToleranceDlg.h" - -#include -#include -#include -#include -#include +#include "MeasureGUI_1Sel6LineEdit_QTD.h" +#include "SALOMEGUI_QtCatchCorbaException.hxx" #include "utilities.h" +#include "QAD_Desktop.h" -using namespace std; +#include +#include +#include +#include +#include //================================================================================= // class : MeasureGUI_MaxToleranceDlg() -// purpose : Constructs a MeasureGUI_MaxToleranceDlg which is a child of 'parent', with the +// purpose : Constructs a MeasureGUI_MaxToleranceDlg 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_MaxToleranceDlg::MeasureGUI_MaxToleranceDlg(QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl) - :MeasureGUI_Skeleton(parent, name, Sel, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) +MeasureGUI_MaxToleranceDlg::MeasureGUI_MaxToleranceDlg( QWidget* parent, SALOME_Selection* Sel ) +: MeasureGUI_Skeleton( parent, "MeasureGUI_MaxToleranceDlg", Sel ) { - QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_TOLERANCE"))); - QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); + QPixmap image0( QAD_Desktop::getResourceManager()->loadPixmap( + "GEOM",tr( "ICON_DLG_TOLERANCE" ) ) ); + QPixmap image1( QAD_Desktop::getResourceManager()->loadPixmap( + "GEOM",tr( "ICON_SELECT" ) ) ); - setCaption(tr("GEOM_TOLERANCE_TITLE")); + setCaption( tr( "GEOM_TOLERANCE_TITLE" ) ); /***************************************************************/ - GroupConstructors->setTitle(tr("GEOM_TOLERANCE")); - RadioButton1->setPixmap(image0); - - GroupC1 = new MeasureGUI_1Sel6LineEdit_QTD(this, "GroupC1"); - GroupC1->GroupBox1->setTitle(tr("GEOM_TOLERANCE_CONSTR")); - GroupC1->TextLabel1->setText(tr("GEOM_OBJECT")); - GroupC1->TextLabel2->setText(tr("GEOM_MIN")); - GroupC1->TextLabel3->setText(tr("GEOM_MAX")); - GroupC1->TextLabel4->setText(tr("GEOM_TOLERANCE_FACE")); - GroupC1->TextLabel5->setText(tr("GEOM_TOLERANCE_EDGE")); - GroupC1->TextLabel6->setText(tr("GEOM_TOLERANCE_VERTEX")); - GroupC1->LineEdit11->setReadOnly(TRUE); - GroupC1->LineEdit12->setReadOnly(TRUE); - GroupC1->LineEdit21->setReadOnly(TRUE); - GroupC1->LineEdit22->setReadOnly(TRUE); - GroupC1->LineEdit31->setReadOnly(TRUE); - GroupC1->LineEdit32->setReadOnly(TRUE); - GroupC1->PushButton1->setPixmap(image1); - - Layout1->addWidget(GroupC1, 1, 0); + + GroupConstructors->setTitle( tr( "GEOM_TOLERANCE" ) ); + RadioButton1->setPixmap( image0 ); + + myGrp = new MeasureGUI_1Sel6LineEdit_QTD( this, "myGrp" ); + myGrp->GroupBox1->setTitle( tr( "GEOM_TOLERANCE_CONSTR" ) ); + myGrp->TextLabel1->setText( tr( "GEOM_OBJECT" ) ); + myGrp->TextLabel2->setText( tr( "GEOM_MIN" ) ); + myGrp->TextLabel3->setText( tr( "GEOM_MAX" ) ); + myGrp->TextLabel4->setText( tr( "GEOM_TOLERANCE_FACE" ) ); + myGrp->TextLabel5->setText( tr( "GEOM_TOLERANCE_EDGE" ) ); + myGrp->TextLabel6->setText( tr( "GEOM_TOLERANCE_VERTEX" ) ); + myGrp->LineEdit11->setReadOnly( TRUE ); + myGrp->LineEdit12->setReadOnly( TRUE ); + myGrp->LineEdit21->setReadOnly( TRUE ); + myGrp->LineEdit22->setReadOnly( TRUE ); + myGrp->LineEdit31->setReadOnly( TRUE ); + myGrp->LineEdit32->setReadOnly( TRUE ); + myGrp->PushButton1->setPixmap( image1 ); + myGrp->LineEdit1->setReadOnly( true ); + + Layout1->addWidget( myGrp, 1, 0 ); + /***************************************************************/ /* Initialisation */ - Init(); + Init( Sel ); } @@ -87,7 +93,6 @@ MeasureGUI_MaxToleranceDlg::MeasureGUI_MaxToleranceDlg(QWidget* parent, const ch //================================================================================= MeasureGUI_MaxToleranceDlg::~MeasureGUI_MaxToleranceDlg() { - // no need to delete child widgets, Qt does it all for us } @@ -95,193 +100,102 @@ MeasureGUI_MaxToleranceDlg::~MeasureGUI_MaxToleranceDlg() // function : Init() // purpose : //================================================================================= -void MeasureGUI_MaxToleranceDlg::Init() +void MeasureGUI_MaxToleranceDlg::Init( SALOME_Selection* Sel ) { - /* init variables */ - myEditCurrentArgument = GroupC1->LineEdit1; - - /* signals and slots connections */ - connect(GroupC1->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupC1->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - - /* displays Dialog */ - GroupC1->show(); - this->show(); - - return; + mySelBtn = myGrp->PushButton1; + mySelEdit = myGrp->LineEdit1; + MeasureGUI_Skeleton::Init( Sel ); } - //================================================================================= -// function : SelectionIntoArgument() -// purpose : Called when selection as changed or other case +// function : processObject +// purpose : //================================================================================= -void MeasureGUI_MaxToleranceDlg::SelectionIntoArgument() +void MeasureGUI_MaxToleranceDlg::processObject() { - myEditCurrentArgument->setText(""); - QString aString = ""; - - GroupC1->LineEdit11->setText(""); - GroupC1->LineEdit12->setText(""); - GroupC1->LineEdit21->setText(""); - GroupC1->LineEdit22->setText(""); - GroupC1->LineEdit31->setText(""); - GroupC1->LineEdit32->setText(""); - - int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString); - if(nbSel != 1) - return; + double aMinFaceToler, aMaxFaceToler; + double aMinEdgeToler, aMaxEdgeToler; + double aMinVertexToler, aMaxVertexToler; + + if ( !getParameters( aMinFaceToler, aMaxFaceToler, + aMinEdgeToler, aMaxEdgeToler, + aMinVertexToler, aMaxVertexToler ) ) + { + myGrp->LineEdit11->setText( "" ); + myGrp->LineEdit12->setText( "" ); + + myGrp->LineEdit21->setText( "" ); + myGrp->LineEdit22->setText( "" ); + + myGrp->LineEdit31->setText( "" ); + myGrp->LineEdit32->setText( "" ); - /* nbSel == 1 */ - TopoDS_Shape S; - if(!myGeomBase->GetTopoFromSelection(mySelection, S) || S.IsNull()) return; + } - if(S.IsNull()) - return; + double invalidMin = RealLast(); + double invalidMax = -RealLast(); - GroupC1->LineEdit1->setText(aString); + myGrp->LineEdit11->setText( aMinFaceToler != invalidMin ? QString( "%1" ).arg( aMinFaceToler, 5, 'e', 8 ) : QString("") ); + myGrp->LineEdit12->setText( aMaxFaceToler != invalidMax ? QString( "%1" ).arg( aMaxFaceToler, 5, 'e', 8 ) : QString("") ); - this->CalculateMaxTolerance(S); - return; -} + myGrp->LineEdit21->setText( aMinEdgeToler != invalidMin ? QString( "%1" ).arg( aMinEdgeToler, 5, 'e', 8 ) : QString("") ); + myGrp->LineEdit22->setText( aMaxEdgeToler != invalidMax ? QString( "%1" ).arg( aMaxEdgeToler, 5, 'e', 8 ) : QString("") ); + myGrp->LineEdit31->setText( aMinVertexToler != invalidMin ? QString( "%1" ).arg( aMinVertexToler, 5, 'e', 8 ) : QString("") ); + myGrp->LineEdit32->setText( aMaxVertexToler != invalidMax ? QString( "%1" ).arg( aMaxVertexToler, 5, 'e', 8 ) : QString("") ); +} //================================================================================= -// function : SetEditCurrentArgument() -// purpose : +// function : getParameters +// purpose : Get tolerances. Returns false is myObj is nill. If there is no a +// type of entity ( face, edge or vertex ) in selected object then corresponding +// tolerances is less than 0 //================================================================================= -void MeasureGUI_MaxToleranceDlg::SetEditCurrentArgument() +bool MeasureGUI_MaxToleranceDlg::getParameters( double& theMinFaceToler, + double& theMaxFaceToler, + double& theMinEdgeToler, + double& theMaxEdgeToler, + double& theMinVertexToler, + double& theMaxVertexToler ) { - QPushButton* send = (QPushButton*)sender(); + if ( myObj->_is_nil() ) + return false; + else + { + try + { + GEOM::GEOM_IMeasureOperations::_narrow( getOperation() )->GetTolerance( myObj, + theMinFaceToler, theMaxFaceToler, theMinEdgeToler, + theMaxEdgeToler, theMinVertexToler, theMaxVertexToler ); + } + catch( const SALOME::SALOME_Exception& e ) + { + QtCatchCorbaException( e ); + return false; + } - if(send == GroupC1->PushButton1) { - GroupC1->LineEdit1->setFocus(); - myEditCurrentArgument = GroupC1->LineEdit1; + return getOperation()->IsDone(); } - - this->SelectionIntoArgument(); - return; } -//================================================================================= -// function : LineEditReturnPressed() -// purpose : -//================================================================================= -void MeasureGUI_MaxToleranceDlg::LineEditReturnPressed() -{ - QLineEdit* send = (QLineEdit*)sender(); - if(send == GroupC1->LineEdit1) - myEditCurrentArgument = GroupC1->LineEdit1; - else - return; - MeasureGUI_Skeleton::LineEditReturnPressed(); - return; -} -//================================================================================= -// function : ActivateThisDialog() -// purpose : -//================================================================================= -void MeasureGUI_MaxToleranceDlg::ActivateThisDialog() -{ - MeasureGUI_Skeleton::ActivateThisDialog(); - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - return; -} -//================================================================================= -// function : enterEvent() -// purpose : -//================================================================================= -void MeasureGUI_MaxToleranceDlg::enterEvent(QEvent* e) -{ - if(GroupConstructors->isEnabled()) - return; - this->ActivateThisDialog(); - return; -} -//================================================================================= -// function : CalculateMaxTolerance() -// purpose : -//================================================================================= -void MeasureGUI_MaxToleranceDlg::CalculateMaxTolerance(const TopoDS_Shape& S) -{ - GroupC1->LineEdit11->setText(""); - GroupC1->LineEdit12->setText(""); - GroupC1->LineEdit21->setText(""); - GroupC1->LineEdit22->setText(""); - GroupC1->LineEdit31->setText(""); - GroupC1->LineEdit32->setText(""); - - if(S.IsNull()) - return; - Standard_Real T, TMF, TME, TMV, TmF, TmE, TmV; - Standard_Integer nbF, nbE, nbV; - bool m_isFace, m_isEdge, m_isVertex; - - TMF = TME = TMV = -RealLast(); - TmF = TmE = TmV = RealLast(); - nbF = nbE = nbV = 0; - m_isFace = m_isEdge = m_isVertex = false; - - try { - for(TopExp_Explorer ExF(S,TopAbs_FACE); ExF.More(); ExF.Next()) { - m_isFace = true; - TopoDS_Face Face=TopoDS::Face(ExF.Current()); - T=BRep_Tool::Tolerance(Face); - if(T>TMF) - TMF=T; - if(TTME) - TME=T; - if(TTMV) - TMV=T; - if(TLineEdit11->setText(tr("%1").arg(TmF, 5, 'e', 8)); - GroupC1->LineEdit12->setText(tr("%1").arg(TMF, 5, 'e', 8)); - } - if(m_isEdge) { - GroupC1->LineEdit21->setText(tr("%1").arg(TmE, 5, 'e', 8)); - GroupC1->LineEdit22->setText(tr("%1").arg(TME, 5, 'e', 8)); - } - if(m_isVertex) { - GroupC1->LineEdit31->setText(tr("%1").arg(TmV, 5, 'e', 8)); - GroupC1->LineEdit32->setText(tr("%1").arg(TMV, 5, 'e', 8)); - } - } - catch(Standard_Failure) - { - MESSAGE("Catch intercepted in CalculateMaxTolerance()"); - } - return; -} + + + + + + + + + + diff --git a/src/MeasureGUI/MeasureGUI_MaxToleranceDlg.h b/src/MeasureGUI/MeasureGUI_MaxToleranceDlg.h index 5513582b7..e580873db 100644 --- a/src/MeasureGUI/MeasureGUI_MaxToleranceDlg.h +++ b/src/MeasureGUI/MeasureGUI_MaxToleranceDlg.h @@ -30,9 +30,8 @@ #define DIALOGBOX_MAXTOLERANCE_H #include "MeasureGUI_Skeleton.h" -#include "MeasureGUI_1Sel6LineEdit_QTD.h" -#include "MeasureGUI.h" +class MeasureGUI_1Sel6LineEdit_QTD; //================================================================================= // class : DialogBox_PROPERTIES @@ -43,22 +42,40 @@ class MeasureGUI_MaxToleranceDlg : public MeasureGUI_Skeleton Q_OBJECT public: - MeasureGUI_MaxToleranceDlg(QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); - ~MeasureGUI_MaxToleranceDlg(); + MeasureGUI_MaxToleranceDlg( QWidget* parent, + SALOME_Selection* ); + ~MeasureGUI_MaxToleranceDlg(); + +protected: + + // redefined from GEOMBase_Helper and MeasureGUI_Skeleton + virtual void processObject(); private: - void Init(); - void enterEvent(QEvent* e); - void CalculateMaxTolerance(const TopoDS_Shape& S); - MeasureGUI_1Sel6LineEdit_QTD* GroupC1; + void Init( SALOME_Selection* Sel ); + bool getParameters( double& theMinFaceToler, + double& theMaxFaceToler, + double& theMinEdgeToler, + double& theMaxEdgeToler, + double& theMinVertexToler, + double& theMaxVertexToler ); + -private slots: - void SetEditCurrentArgument(); - void SelectionIntoArgument(); - void LineEditReturnPressed(); - void ActivateThisDialog(); +private: + + MeasureGUI_1Sel6LineEdit_QTD* myGrp; }; #endif // DIALOGBOX_MAXTOLERANCE_H + + + + + + + + + + diff --git a/src/MeasureGUI/MeasureGUI_PointDlg.cxx b/src/MeasureGUI/MeasureGUI_PointDlg.cxx new file mode 100644 index 000000000..5747f70b9 --- /dev/null +++ b/src/MeasureGUI/MeasureGUI_PointDlg.cxx @@ -0,0 +1,219 @@ +// 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_PointDlg.cxx +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +#include "MeasureGUI_PointDlg.h" +#include "utilities.h" +#include "QAD_Desktop.h" +#include "GEOMBase.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +//================================================================================= +// class : MeasureGUI_PointDlg() +// purpose : Constructs a MeasureGUI_PointDlg which is a child of 'parent' +// +//================================================================================= +MeasureGUI_PointDlg::MeasureGUI_PointDlg( QWidget* parent, SALOME_Selection* Sel ) +: MeasureGUI_Skeleton( parent, "MeasureGUI_PointDlg", Sel ) +{ + QPixmap iconPnt( QAD_Desktop::getResourceManager()->loadPixmap( + "GEOM",tr( "ICON_DLG_POINT" ) ) ); + + QPixmap iconSelect( QAD_Desktop::getResourceManager()->loadPixmap( + "GEOM",tr( "ICON_SELECT" ) ) ); + + setCaption( tr( "CAPTION" ) ); + + GroupConstructors->setTitle( tr( "CAPTION" ) ); + RadioButton1->setPixmap( iconPnt ); + + QGroupBox* aGrp = new QGroupBox( 2, Qt::Horizontal, tr( "COORDINATES" ), this ); + + new QLabel( tr( "POINT" ), aGrp ); + QFrame* aFrame = new QFrame( aGrp ); + mySelBtn = new QPushButton( aFrame ); + mySelBtn->setPixmap( iconSelect ); + mySelEdit = new QLineEdit( aFrame ); + QHBoxLayout* aLay = new QHBoxLayout( aFrame, 0, 10 ); + aLay->addWidget( mySelBtn ); + aLay->addWidget( mySelEdit ); + + new QLabel( tr( "X" ), aGrp ); + myX = new QLineEdit( aGrp ); + new QLabel( tr( "Y" ), aGrp ); + myY = new QLineEdit( aGrp ); + new QLabel( tr( "Z" ), aGrp ); + myZ = new QLineEdit( aGrp ); + + mySelEdit->setReadOnly( true ); + myX->setReadOnly( true ); + myY->setReadOnly( true ); + myZ->setReadOnly( true ); + + Layout1->addWidget( aGrp, 1, 0 ); + + Init( Sel ); +} + + +//================================================================================= +// function : ~MeasureGUI_PointDlg() +// purpose : Destroys the object and frees any allocated resources +//======================myX->setReadOnly( true );=========================================================== +MeasureGUI_PointDlg::~MeasureGUI_PointDlg() +{ +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void MeasureGUI_PointDlg::Init( SALOME_Selection* Sel ) +{ + QSize aSize( size() ); + resize( (int)(aSize.width() *0.75 ), aSize.height() ); + MeasureGUI_Skeleton::Init( Sel ); +} + +//================================================================================= +// function : activateSelection +// purpose : +//================================================================================= +void MeasureGUI_PointDlg::activateSelection() +{ + localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); +} + +//================================================================================= +// function : SelectionIntoArgument +// purpose : +//================================================================================= +void MeasureGUI_PointDlg::SelectionIntoArgument() +{ + try + { + myObj = GEOM::GEOM_Object::_nil(); + mySelEdit->setText( "" ); + myX->setText( "" ); + myY->setText( "" ); + myZ->setText( "" ); + + Standard_Boolean testResult = Standard_False; + GEOM::GEOM_Object_var aSelectedObject = + GEOMBase::ConvertIOinGEOMObject( mySelection->firstIObject(), testResult ); + + if( !testResult || aSelectedObject->_is_nil() ) + return; + + myObj = aSelectedObject; + + TColStd_IndexedMapOfInteger anIndexes; + mySelection->GetIndex( mySelection->firstIObject(), anIndexes ); + + TopoDS_Shape aShape; + if ( anIndexes.Extent() > 1 || !GEOMBase::GetShape( myObj, aShape ) || aShape.IsNull() ) + return; + + TopoDS_Vertex aPoint; + QString aName = GEOMBase::GetName( myObj ); + if ( anIndexes.Extent() == 0 ) + { + if ( aShape.ShapeType() == TopAbs_VERTEX ) + aPoint = TopoDS::Vertex( aShape ); + } + else + { + int i = anIndexes( 1 ); + + TopTools_IndexedMapOfShape aShapes; + TopExp::MapShapes( aShape, aShapes ); + + if ( aShape != aShapes( i ) ) + aName += QString( ":%1" ).arg( i ); + + aPoint = TopoDS::Vertex( aShapes( i ) ); + } + + if ( !aPoint.IsNull() ) + { + gp_Pnt aPnt = BRep_Tool::Pnt( aPoint ); + mySelEdit->setText( aName ); + myX->setText( QString( "%1" ).arg( aPnt.X() ) ); + myY->setText( QString( "%1" ).arg( aPnt.Y() ) ); + myZ->setText( QString( "%1" ).arg( aPnt.Z() ) ); + } + } + catch( ... ) + { + myObj = GEOM::GEOM_Object::_nil(); + mySelEdit->setText( "" ); + myX->setText( "" ); + myY->setText( "" ); + myZ->setText( "" ); + } +} + + + + + + + + + + + + + + + + + + + + diff --git a/src/MeasureGUI/MeasureGUI_PointDlg.h b/src/MeasureGUI/MeasureGUI_PointDlg.h new file mode 100644 index 000000000..a79072547 --- /dev/null +++ b/src/MeasureGUI/MeasureGUI_PointDlg.h @@ -0,0 +1,79 @@ +// 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_PointDlg.h +// Author : Sergey LITONIN +// Module : GEOM + +#ifndef MEASUREGUI_POINTDLG_H +#define MEASUREGUI_POINTDLG_H + +#include "MeasureGUI_Skeleton.h" + +class QLineEdit; + +//================================================================================= +// class : MeasureGUI_PointDlg +// purpose : Dialog for displaying point coordinates +//================================================================================= + +class MeasureGUI_PointDlg : public MeasureGUI_Skeleton +{ + Q_OBJECT + +public: + MeasureGUI_PointDlg( QWidget* parent, + SALOME_Selection* Sel ); + ~MeasureGUI_PointDlg(); + +protected: + + // redefined from GEOMBase_Helper and MeasureGUI_Skeleton + virtual void activateSelection(); + virtual void SelectionIntoArgument(); + +private: + + void Init( SALOME_Selection* Sel ); +private: + QLineEdit* myX; + QLineEdit* myY; + QLineEdit* myZ; + +}; + +#endif // DIALOGBOX_PROPERTIES_H + + + + + + + + + + + + + + diff --git a/src/MeasureGUI/MeasureGUI_PropertiesDlg.cxx b/src/MeasureGUI/MeasureGUI_PropertiesDlg.cxx index ede6403fa..b26488704 100644 --- a/src/MeasureGUI/MeasureGUI_PropertiesDlg.cxx +++ b/src/MeasureGUI/MeasureGUI_PropertiesDlg.cxx @@ -27,15 +27,21 @@ // $Header$ #include "MeasureGUI_PropertiesDlg.h" - -#include -#include -#include -#include - +#include "MeasureGUI_1Sel3LineEdit_QTD.h" +#include "SALOMEGUI_QtCatchCorbaException.hxx" +#include "GEOM_Displayer.h" #include "utilities.h" +#include "QAD_Desktop.h" +#include "GEOMImpl_Types.hxx" +#include "GEOMBase.h" -using namespace std; +#include + +#include +#include +#include +#include +#include //================================================================================= // class : MeasureGUI_PropertiesDlg() @@ -44,34 +50,39 @@ using namespace std; // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -MeasureGUI_PropertiesDlg::MeasureGUI_PropertiesDlg(QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl) - :MeasureGUI_Skeleton(parent, name, Sel, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) +MeasureGUI_PropertiesDlg::MeasureGUI_PropertiesDlg( QWidget* parent, SALOME_Selection* Sel ) +: MeasureGUI_Skeleton( parent, "MeasureGUI_PropertiesDlg", Sel ) { - QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_BASICPROPERTIES"))); - QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); + QPixmap image0( QAD_Desktop::getResourceManager()->loadPixmap( + "GEOM",tr( "ICON_DLG_BASICPROPERTIES" ) ) ); + QPixmap image1( QAD_Desktop::getResourceManager()->loadPixmap( + "GEOM",tr( "ICON_SELECT" ) ) ); - setCaption(tr("GEOM_PROPERTIES_TITLE")); + setCaption( tr( "GEOM_PROPERTIES_TITLE" ) ); /***************************************************************/ - GroupConstructors->setTitle(tr("GEOM_PROPERTIES")); - RadioButton1->setPixmap(image0); - - GroupC1 = new MeasureGUI_1Sel3LineEdit_QTD(this, "GroupC1"); - GroupC1->GroupBox1->setTitle(tr("GEOM_PROPERTIES_CONSTR")); - GroupC1->TextLabel1->setText(tr("GEOM_OBJECT")); - GroupC1->TextLabel2->setText(tr("GEOM_LENGTH")); - GroupC1->TextLabel3->setText(tr("GEOM_PROPERTIES_SURFACE")); - GroupC1->TextLabel4->setText(tr("GEOM_PROPERTIES_VOLUME")); - GroupC1->LineEdit2->setReadOnly(TRUE); - GroupC1->LineEdit3->setReadOnly(TRUE); - GroupC1->LineEdit4->setReadOnly(TRUE); - GroupC1->PushButton1->setPixmap(image1); - - Layout1->addWidget(GroupC1, 1, 0); + + GroupConstructors->setTitle( tr( "GEOM_PROPERTIES" ) ); + RadioButton1->setPixmap( image0 ); + + myGrp = new MeasureGUI_1Sel3LineEdit_QTD( this, "myGrp" ); + myGrp->GroupBox1->setTitle( tr( "GEOM_PROPERTIES_CONSTR" ) ); + myGrp->TextLabel1->setText( tr( "GEOM_OBJECT" ) ); + myGrp->TextLabel2->setText( tr( "GEOM_LENGTH" ) ); + myGrp->TextLabel3->setText( tr( "GEOM_PROPERTIES_SURFACE" ) ); + myGrp->TextLabel4->setText( tr( "GEOM_PROPERTIES_VOLUME" ) ); + myGrp->LineEdit2->setReadOnly( TRUE ); + myGrp->LineEdit3->setReadOnly( TRUE ); + myGrp->LineEdit4->setReadOnly( TRUE ); + myGrp->PushButton1->setPixmap( image1 ); + myGrp->LineEdit1->setReadOnly( true ); + + Layout1->addWidget( myGrp, 1, 0 ); + /***************************************************************/ /* Initialisation */ - Init(); + Init( Sel ); } @@ -81,7 +92,6 @@ MeasureGUI_PropertiesDlg::MeasureGUI_PropertiesDlg(QWidget* parent, const char* //================================================================================= MeasureGUI_PropertiesDlg::~MeasureGUI_PropertiesDlg() { - // no need to delete child widgets, Qt does it all for us } @@ -89,173 +99,121 @@ MeasureGUI_PropertiesDlg::~MeasureGUI_PropertiesDlg() // function : Init() // purpose : //================================================================================= -void MeasureGUI_PropertiesDlg::Init() +void MeasureGUI_PropertiesDlg::Init( SALOME_Selection* Sel ) { - /* init variables */ - myEditCurrentArgument = GroupC1->LineEdit1; - - /* signals and slots connections */ - connect(GroupC1->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupC1->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - - /* displays Dialog */ - GroupC1->show(); - this->show(); - - return; + mySelBtn = myGrp->PushButton1; + mySelEdit = myGrp->LineEdit1; + MeasureGUI_Skeleton::Init( Sel ); } - //================================================================================= -// function : SelectionIntoArgument() -// purpose : Called when selection as changed or other case +// function : activateSelection +// purpose : //================================================================================= -void MeasureGUI_PropertiesDlg::SelectionIntoArgument() +void MeasureGUI_PropertiesDlg::activateSelection() { - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); - myEditCurrentArgument->setText(""); - QString aString = ""; - - GroupC1->LineEdit2->setText(""); - GroupC1->LineEdit3->setText(""); - GroupC1->LineEdit4->setText(""); - - int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString); - if(nbSel != 1) - return; - - /* nbSel == 1 */ - TopoDS_Shape S; - if(!myGeomBase->GetTopoFromSelection(mySelection, S)) - return; - - - if(S.IsNull() || S.ShapeType() == TopAbs_VERTEX) - return; - - GroupC1->LineEdit1->setText(aString); - - /* Try to display of a cone simulation shape to show direction of a linear edge only in OCC viewer */ - if(myGeomBase->CreateArrowForLinearEdge(S, mySimulationTopoDs)) - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); + static TColStd_MapOfInteger aTypes; + if ( aTypes.IsEmpty() ) + { + aTypes.Add( GEOM_COMPOUND ); +// aTypes.Add( TopAbs_COMPSOLID ); + aTypes.Add( GEOM_SOLID ); + aTypes.Add( GEOM_SHELL ); + aTypes.Add( GEOM_FACE ); + aTypes.Add( GEOM_WIRE ); + aTypes.Add( GEOM_EDGE ); + } - this->CalculateAndDisplayProperties(S); - return; + globalSelection( aTypes ); } - //================================================================================= -// function : SetEditCurrentArgument() +// function : processObject // purpose : //================================================================================= -void MeasureGUI_PropertiesDlg::SetEditCurrentArgument() +void MeasureGUI_PropertiesDlg::processObject() { - QPushButton* send = (QPushButton*)sender(); - - if(send == GroupC1->PushButton1) { - GroupC1->LineEdit1->setFocus(); - myEditCurrentArgument = GroupC1->LineEdit1; + double aLength, anArea, aVolume; + + if ( !getParameters( aLength, anArea, aVolume ) ) + { + mySelEdit->setText( "" ); + myGrp->LineEdit2->setText( "" ); + myGrp->LineEdit3->setText( "" ); + myGrp->LineEdit4->setText( "" ); + } + else + { + myGrp->LineEdit2->setText( QString( "%1" ).arg( aLength ) ); + myGrp->LineEdit3->setText( QString( "%1" ).arg( anArea ) ); + myGrp->LineEdit4->setText( QString( "%1" ).arg( aVolume ) ); } - - this->SelectionIntoArgument(); - return; } - //================================================================================= -// function : LineEditReturnPressed() +// function : getParameters // purpose : //================================================================================= -void MeasureGUI_PropertiesDlg::LineEditReturnPressed() +bool MeasureGUI_PropertiesDlg::getParameters( double& theLength, + double& theArea, + double& theVolume ) { - QLineEdit* send = (QLineEdit*)sender(); - if(send == GroupC1->LineEdit1) - myEditCurrentArgument = GroupC1->LineEdit1; + if ( myObj->_is_nil() ) + return false; else - return; + { + try + { + GEOM::GEOM_IMeasureOperations::_narrow( getOperation() )->GetBasicProperties( + myObj, theLength, theArea, theVolume ); + } + catch( const SALOME::SALOME_Exception& e ) + { + QtCatchCorbaException( e ); + return false; + } - MeasureGUI_Skeleton::LineEditReturnPressed(); - return; + return getOperation()->IsDone(); + } } - //================================================================================= -// function : ActivateThisDialog() +// function : createOperation // purpose : //================================================================================= -void MeasureGUI_PropertiesDlg::ActivateThisDialog() +SALOME_Prs* MeasureGUI_PropertiesDlg::buildPrs() { - MeasureGUI_Skeleton::ActivateThisDialog(); - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - if(!mySimulationTopoDs.IsNull()) - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - return; + TopoDS_Shape aShape, aResult; + + if ( myObj->_is_nil() || + !GEOMBase::GetShape( myObj, aShape )|| + aShape.IsNull() || + aShape.ShapeType() != TopAbs_EDGE || + !GEOMBase::CreateArrowForLinearEdge( aShape, aResult ) || + aResult.IsNull() ) + return 0; + + return getDisplayer()->BuildPrs( aResult ); + } -//================================================================================= -// function : enterEvent() -// purpose : -//================================================================================= -void MeasureGUI_PropertiesDlg::enterEvent(QEvent* e) -{ - if(GroupConstructors->isEnabled()) - return; - this->ActivateThisDialog(); - return; -} -//================================================================================= -// function : CalculateAndDisplayProperties() -// purpose : -//================================================================================= -void MeasureGUI_PropertiesDlg::CalculateAndDisplayProperties(const TopoDS_Shape& S) -{ - GroupC1->LineEdit2->setText(""); - GroupC1->LineEdit3->setText(""); - GroupC1->LineEdit4->setText(""); - - if(S.IsNull()) - return; - - Standard_Real result; - GProp_GProps LProps, SProps; - QString resString; - - try { - BRepGProp::LinearProperties(S,LProps); - result = LProps.Mass(); - if(!IsEqual(result, 0.0)) { - resString = tr("%1").arg(result, 12, 'f', 6); - GroupC1->LineEdit2->setText(resString); - } - BRepGProp::SurfaceProperties(S, SProps); - result = SProps.Mass(); - if(!IsEqual(result, 0.0)) { - resString = tr("%1").arg(result, 12, 'f', 6); - GroupC1->LineEdit3->setText(resString); - } - - result = 0.0; - if(S.ShapeType() < TopAbs_SHELL) { - for(TopExp_Explorer Exp(S,TopAbs_SOLID); Exp.More(); Exp.Next()) { - GProp_GProps VProps; - BRepGProp::VolumeProperties(Exp.Current(), VProps); - result += VProps.Mass(); - } - } - if (!IsEqual(result, 0.0)) { - resString = tr("%1").arg(result, 12, 'f', 6); - GroupC1->LineEdit4->setText(resString); - } - } - catch(Standard_Failure) { - MESSAGE("Catch intercepted in CalculateAndDisplayProperties()"); - } - return; -} + + + + + + + + + + + + + + + + diff --git a/src/MeasureGUI/MeasureGUI_PropertiesDlg.h b/src/MeasureGUI/MeasureGUI_PropertiesDlg.h index d2402393d..d52ea9d8a 100644 --- a/src/MeasureGUI/MeasureGUI_PropertiesDlg.h +++ b/src/MeasureGUI/MeasureGUI_PropertiesDlg.h @@ -29,35 +29,53 @@ #define DIALOGBOX_PROPERTIES_H #include "MeasureGUI_Skeleton.h" -#include "MeasureGUI_1Sel3LineEdit_QTD.h" - -#include "MeasureGUI.h" +class MeasureGUI_1Sel3LineEdit_QTD; //================================================================================= // class : MeasureGUI_PropertiesDlg -// purpose : +// purpose : Dialog for displaying length, area and volume //================================================================================= + class MeasureGUI_PropertiesDlg : public MeasureGUI_Skeleton { Q_OBJECT public: - MeasureGUI_PropertiesDlg(QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); - ~MeasureGUI_PropertiesDlg(); + MeasureGUI_PropertiesDlg( QWidget* parent, + SALOME_Selection* Sel ); + ~MeasureGUI_PropertiesDlg(); + +protected: + + // redefined from GEOMBase_Helper and MeasureGUI_Skeleton + virtual void processObject(); + virtual void activateSelection(); + virtual SALOME_Prs* buildPrs(); private: - void Init(); - void enterEvent(QEvent* e); - void CalculateAndDisplayProperties(const TopoDS_Shape& S); - MeasureGUI_1Sel3LineEdit_QTD* GroupC1; + void Init( SALOME_Selection* Sel ); + bool getParameters( double& theLength, + double& theArea, + double& theVolume ); -private slots: - void SetEditCurrentArgument(); - void SelectionIntoArgument(); - void LineEditReturnPressed(); - void ActivateThisDialog(); +private: + MeasureGUI_1Sel3LineEdit_QTD* myGrp; }; #endif // DIALOGBOX_PROPERTIES_H + + + + + + + + + + + + + + diff --git a/src/MeasureGUI/MeasureGUI_Skeleton.cxx b/src/MeasureGUI/MeasureGUI_Skeleton.cxx index 39498d509..39bcaf04f 100644 --- a/src/MeasureGUI/MeasureGUI_Skeleton.cxx +++ b/src/MeasureGUI/MeasureGUI_Skeleton.cxx @@ -24,10 +24,21 @@ // File : MeasureGUI_Skeleton.cxx // Author : Damien COQUERET // Module : GEOM -// $Header: +// $Header$ -using namespace std; #include "MeasureGUI_Skeleton.h" +#include "QAD_Desktop.h" +#include "QAD_WaitCursor.h" +#include "GEOMBase.h" +#include "GEOM_Displayer.h" +#include "GeometryGUI.h" +#include "SALOMEGUI_QtCatchCorbaException.hxx" + +#include +#include +#include +#include +#include //================================================================================= // class : MeasureGUI_Skeleton() @@ -36,18 +47,26 @@ using namespace std; // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -MeasureGUI_Skeleton::MeasureGUI_Skeleton(QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl) - :MeasureGUI_Skeleton_QTD(parent, name, modal, fl) +MeasureGUI_Skeleton::MeasureGUI_Skeleton( QWidget* parent, + const char* name, + SALOME_Selection* Sel ) +: MeasureGUI_Skeleton_QTD( parent, name, false, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ) { - if (!name) - setName("MeasureGUI_Skeleton"); - buttonClose->setText(tr("GEOM_BUT_CLOSE")); + mySelBtn = 0; + mySelEdit = 0; + myDisplayer = 0; + + if ( !name ) + setName( "MeasureGUI_Skeleton" ); + + buttonClose->setText( tr( "GEOM_BUT_CLOSE" ) ); - GroupMedium->close(TRUE); - resize(350, 0); + buttonClose->setAutoDefault( false ); - Init(Sel); + GroupMedium->close( TRUE ); + resize( 350, 0 ); } @@ -57,8 +76,8 @@ MeasureGUI_Skeleton::MeasureGUI_Skeleton(QWidget* parent, const char* name, SALO //================================================================================= MeasureGUI_Skeleton::~MeasureGUI_Skeleton() { - // no need to delete child widgets, Qt does it all for us - this->destroy(TRUE, TRUE); + myGeomGUI->SetActiveDialogBox( 0 ); + delete myDisplayer; } @@ -66,30 +85,42 @@ MeasureGUI_Skeleton::~MeasureGUI_Skeleton() // function : Init() // purpose : //================================================================================= -void MeasureGUI_Skeleton::Init(SALOME_Selection* Sel) +void MeasureGUI_Skeleton::Init( SALOME_Selection* Sel ) { + myGeomGUI = GeometryGUI::GetGeomGUI(); + /* init variables */ mySelection = Sel; - mySimulationTopoDs.Nullify(); - myGeomBase = new GEOMBase(); - myGeomGUI = GEOMContext::GetGeomGUI(); myGeomGUI->SetActiveDialogBox((QDialog*)this); - myGeom = myGeomGUI->myComponentGeom; /* signals and slots connections */ - connect(buttonClose, SIGNAL(clicked()), this, SLOT(ClickOnCancel())); - connect(myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog())); - connect(myGeomGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel())); + + connect( buttonClose, SIGNAL( clicked() ), + this, SLOT( ClickOnCancel() ) ); + + connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), + this, SLOT ( DeactivateActiveDialog() ) ); + + connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ), + this, SLOT ( ClickOnCancel() ) ); - /* Move widget on the botton right corner of main widget */ -// int x, y; -// myGeomBase->DefineDlgPosition( this, x, y ); + connect( mySelEdit, SIGNAL( returnPressed() ), + this, SLOT( LineEditReturnPressed() ) ); + + connect( mySelBtn, SIGNAL( clicked() ), + this, SLOT ( SetEditCurrentArgument() ) ); + + if ( mySelection ) + connect( mySelection, SIGNAL( currentSelectionChanged() ), + this, SLOT ( SelectionIntoArgument() ) ); /* displays Dialog */ - RadioButton1->setChecked(TRUE); + RadioButton1->setChecked( TRUE ); - return; + activateSelection(); + SelectionIntoArgument(); + show(); } @@ -99,14 +130,7 @@ void MeasureGUI_Skeleton::Init(SALOME_Selection* Sel) //================================================================================= void MeasureGUI_Skeleton::ClickOnCancel() { - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); - - disconnect(mySelection, 0, this, 0); - //myGeomGUI->ResetState(); - reject(); - - return; + close(); } @@ -119,12 +143,12 @@ void MeasureGUI_Skeleton::LineEditReturnPressed() /* User name of object input management */ /* If successfull the selection is changed and signal emitted... */ /* so SelectionIntoArgument() is automatically called. */ - const QString objectUserName = myEditCurrentArgument->text(); - QWidget* thisWidget = (QWidget*)this; - if(myGeomBase->SelectionByNameInDialogs(thisWidget, objectUserName, mySelection)) - myEditCurrentArgument->setText(objectUserName); - - return; + + const QString objectUserName = mySelEdit->text(); + QWidget* thisWidget = ( QWidget* )this; + + if ( GEOMBase::SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) + mySelEdit->setText( objectUserName ); } @@ -134,12 +158,14 @@ void MeasureGUI_Skeleton::LineEditReturnPressed() //================================================================================= void MeasureGUI_Skeleton::DeactivateActiveDialog() { - this->setEnabled(false); - //myGeomGUI->ResetState(); - disconnect(mySelection, 0, this, 0); - myGeomBase->EraseSimulationShape(); - myGeomGUI->SetActiveDialogBox(0); - return; + setEnabled( false ); + + if ( mySelection ) + disconnect( mySelection, 0, this, 0 ); + + myGeomGUI->SetActiveDialogBox( 0 ); + + globalSelection(); } @@ -149,21 +175,186 @@ void MeasureGUI_Skeleton::DeactivateActiveDialog() //================================================================================= void MeasureGUI_Skeleton::ActivateThisDialog() { - /* Emit a signal to deactivate the active dialog */ myGeomGUI->EmitSignalDeactivateDialog(); - this->setEnabled(true); - myGeomGUI->SetActiveDialogBox((QDialog*)this); - return; + + setEnabled( true ); + + myGeomGUI->SetActiveDialogBox( ( QDialog* )this ); + + if ( mySelection ) + connect( mySelection, SIGNAL( currentSelectionChanged() ), + this, SLOT ( SelectionIntoArgument() ) ); + + redisplayPreview(); + activateSelection(); +} + +//================================================================================= +// function : SetEditCurrentArgument +// purpose : +//================================================================================= +void MeasureGUI_Skeleton::SetEditCurrentArgument() +{ + mySelEdit->setFocus(); + SelectionIntoArgument(); +} + +//================================================================================= +// function : SelectionIntoArgument +// purpose : +//================================================================================= +void MeasureGUI_Skeleton::SelectionIntoArgument() +{ + myObj = GEOM::GEOM_Object::_nil(); + + Standard_Boolean testResult = Standard_False; + GEOM::GEOM_Object_var aSelectedObject = + GEOMBase::ConvertIOinGEOMObject( mySelection->firstIObject(), testResult ); + + if( !testResult || aSelectedObject->_is_nil() ) + { + mySelEdit->setText( "" ); + processObject(); + erasePreview(); + return; + } + + myObj = aSelectedObject; + mySelEdit->setText( GEOMBase::GetName( myObj ) ); + processObject(); + redisplayPreview(); } +//================================================================================= +// function : processObject +// purpose : +//================================================================================= +void MeasureGUI_Skeleton::processObject() +{ +} + + +//================================================================================= +// function : closeEvent +// purpose : +//================================================================================= +void MeasureGUI_Skeleton::closeEvent( QCloseEvent* e ) +{ + disconnect( mySelection, 0, this, 0 ); + QDialog::closeEvent( e ); +} + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void MeasureGUI_Skeleton::enterEvent(QEvent* e) +{ + if ( GroupConstructors->isEnabled() ) + return; + + ActivateThisDialog(); +} + +//================================================================================= +// function : buildPrs +// purpose : Build presentation for "preview" +//================================================================================= +SALOME_Prs* MeasureGUI_Skeleton::buildPrs() +{ + return 0; +} //================================================================================= // function : closeEvent() +// purpose : Build presentation for "preview" +//================================================================================= +void MeasureGUI_Skeleton::redisplayPreview() +{ + QString aMess; + if ( !isValid( aMess ) ) + { + erasePreview( true ); + return; + } + + erasePreview( false ); + + try + { + QAD_WaitCursor wc; + + getDisplayer()->SetColor( Quantity_NOC_VIOLET ); + getDisplayer()->SetToActivate( false ); + + if ( SALOME_Prs* aPrs = buildPrs() ) + displayPreview( aPrs ); + } + catch( const SALOME::SALOME_Exception& e ) + { + QtCatchCorbaException( e ); + } + +} + +//================================================================================= +// function : activateSelection +// purpose : +//================================================================================= +void MeasureGUI_Skeleton::activateSelection() +{ + globalSelection( GEOM_ALLSHAPES ); +} + +//================================================================================= +// function : isValid // purpose : //================================================================================= -void MeasureGUI_Skeleton::closeEvent(QCloseEvent* e) +bool MeasureGUI_Skeleton::isValid( QString& ) { - /* same than click on cancel button */ - this->ClickOnCancel(); - return; + return !myObj->_is_nil(); } + +//================================================================ +// Function : getDisplayer +// Purpose : +//================================================================ +GEOM_Displayer* MeasureGUI_Skeleton::getDisplayer() +{ + if ( !myDisplayer ) + myDisplayer = new GEOM_Displayer(); + return myDisplayer; +} + +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr MeasureGUI_Skeleton::createOperation() +{ + return getGeomEngine()->GetIMeasureOperations( getStudyId() ); +} + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/MeasureGUI/MeasureGUI_Skeleton.h b/src/MeasureGUI/MeasureGUI_Skeleton.h index 299c51a85..664ee5a33 100644 --- a/src/MeasureGUI/MeasureGUI_Skeleton.h +++ b/src/MeasureGUI/MeasureGUI_Skeleton.h @@ -30,44 +30,71 @@ #define MEASUREGUI_SKELETON_H #include "MeasureGUI_Skeleton_QTD.h" +#include "GEOMBase_Helper.h" -#include "GEOMBase.h" +class GeometryGUI; +class QWidget; +class QLineEdit; +class QPushButton; +class SALOME_Selection; +class GEOM_Displayer; -#include -#include -#include -#include -#include -#include -#include - -class MeasureGUI_Skeleton : public MeasureGUI_Skeleton_QTD +class MeasureGUI_Skeleton : public MeasureGUI_Skeleton_QTD, + public GEOMBase_Helper { Q_OBJECT public: - MeasureGUI_Skeleton(QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); - ~MeasureGUI_Skeleton(); + MeasureGUI_Skeleton( QWidget* parent, + const char* name, + SALOME_Selection* Sel = 0 ); + ~MeasureGUI_Skeleton(); + +protected slots: -private : - void Init(SALOME_Selection* Sel); + virtual void ClickOnCancel(); + virtual void DeactivateActiveDialog(); + virtual void ActivateThisDialog(); + virtual void SelectionIntoArgument(); + virtual void LineEditReturnPressed(); + virtual void SetEditCurrentArgument(); protected: - void closeEvent(QCloseEvent* e); - TopoDS_Shape mySimulationTopoDs; /* Shape used for simulation display */ - QLineEdit* myEditCurrentArgument; /* Current LineEdit */ - SALOME_Selection* mySelection; /* User shape selection */ - GEOM::GEOM_Gen_var myGeom; /* Current GeomI object */ - GEOMBase* myGeomBase; - GEOMContext* myGeomGUI; /* Current GeomGUI object */ + void Init( SALOME_Selection* Sel ); -protected slots: - void ClickOnCancel(); - void LineEditReturnPressed(); - void DeactivateActiveDialog(); - void ActivateThisDialog(); + void enterEvent( QEvent* e ); + void closeEvent( QCloseEvent* e ); + void redisplayPreview(); + GEOM_Displayer* getDisplayer(); + + virtual bool isValid( QString& msg ); + virtual SALOME_Prs* buildPrs(); + virtual void processObject(); + virtual void activateSelection(); + virtual GEOM::GEOM_IOperations_ptr createOperation(); + +protected: + + QPushButton* mySelBtn; + QLineEdit* mySelEdit; + GEOM::GEOM_Object_var myObj; + + SALOME_Selection* mySelection; + GeometryGUI* myGeomGUI; + GEOM_Displayer* myDisplayer; }; #endif // MEASUREGUI_SKELETON_H + + + + + + + + + + + diff --git a/src/MeasureGUI/MeasureGUI_WhatisDlg.cxx b/src/MeasureGUI/MeasureGUI_WhatisDlg.cxx index 3fddd8492..0f30aaed2 100644 --- a/src/MeasureGUI/MeasureGUI_WhatisDlg.cxx +++ b/src/MeasureGUI/MeasureGUI_WhatisDlg.cxx @@ -27,51 +27,64 @@ // $Header$ #include "MeasureGUI_WhatisDlg.h" +#include "MeasureGUI_1Sel1TextView_QTD.h" +#include "SALOMEGUI_QtCatchCorbaException.hxx" +#include "GEOMBase.h" #include #include #include #include +#include #include -#include - #include #include "utilities.h" +#include "QAD_Desktop.h" -using namespace std; +#include +#include +#include +#include +#include +#include //================================================================================= -// class : MeasureGUI_WhatisDlg() -// purpose : Constructs a MeasureGUI_WhatisDlg which is a child of 'parent', with the +// class : MeasureGUI_WhatisDlg( ) +// purpose : Constructs a MeasureGUI_WhatisDlg 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_WhatisDlg::MeasureGUI_WhatisDlg(QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl) - :MeasureGUI_Skeleton(parent, name, Sel, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) +MeasureGUI_WhatisDlg::MeasureGUI_WhatisDlg( QWidget* parent, SALOME_Selection* Sel ) +: MeasureGUI_Skeleton( parent, "MeasureGUI_WhatisDlg", Sel ) { - QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_WHATIS"))); - QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); + QPixmap image0( QAD_Desktop::getResourceManager()->loadPixmap( + "GEOM",tr( "ICON_DLG_WHATIS" ) ) ); + QPixmap image1( QAD_Desktop::getResourceManager()->loadPixmap( + "GEOM",tr( "ICON_SELECT" ) ) ); - setCaption(tr("GEOM_WHATIS_TITLE")); + setCaption( tr( "GEOM_WHATIS_TITLE" ) ); /***************************************************************/ - GroupConstructors->setTitle(tr("GEOM_WHATIS")); - RadioButton1->setPixmap(image0); + + GroupConstructors->setTitle( tr( "GEOM_WHATIS" ) ); + RadioButton1->setPixmap( image0 ); - GroupC1 = new MeasureGUI_1Sel1TextView_QTD(this, "GroupC1"); - GroupC1->GroupBox1->setTitle(tr("GEOM_WHATIS_OBJECT")); - GroupC1->TextLabel1->setText(tr("GEOM_OBJECT")); - GroupC1->TextEdit1->setReadOnly(TRUE); - GroupC1->PushButton1->setPixmap(image1); + myGrp = new MeasureGUI_1Sel1TextView_QTD( this, "myGrp" ); + myGrp->GroupBox1->setTitle( tr( "GEOM_WHATIS_OBJECT" ) ); + myGrp->TextLabel1->setText( tr( "GEOM_OBJECT" ) ); + myGrp->TextEdit1->setReadOnly( TRUE ); + myGrp->PushButton1->setPixmap( image1 ); + myGrp->LineEdit1->setReadOnly( true ); + + Layout1->addWidget( myGrp, 1, 0 ); - Layout1->addWidget(GroupC1, 1, 0); /***************************************************************/ /* Initialisation */ - Init(); + Init( Sel ); } @@ -81,7 +94,6 @@ MeasureGUI_WhatisDlg::MeasureGUI_WhatisDlg(QWidget* parent, const char* name, SA //================================================================================= MeasureGUI_WhatisDlg::~MeasureGUI_WhatisDlg() { - // no need to delete child widgets, Qt does it all for us } @@ -89,179 +101,47 @@ MeasureGUI_WhatisDlg::~MeasureGUI_WhatisDlg() // function : Init() // purpose : //================================================================================= -void MeasureGUI_WhatisDlg::Init() -{ - /* init variables */ - myEditCurrentArgument = GroupC1->LineEdit1; - - /* signals and slots connections */ - connect(GroupC1->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupC1->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - - /* displays Dialog */ - GroupC1->show(); - this->show(); - - return; -} - - -//================================================================================= -// function : SelectionIntoArgument() -// purpose : Called when selection as changed or other case -//================================================================================= -void MeasureGUI_WhatisDlg::SelectionIntoArgument() +void MeasureGUI_WhatisDlg::Init( SALOME_Selection* Sel ) { - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); - - myEditCurrentArgument->setText(""); - SelectedName = ""; /* future the name of selection */ - GroupC1->TextEdit1->setText(""); - - int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, SelectedName); - if(nbSel != 1) - return; - - /* nbSel == 1 */ - TopoDS_Shape S; - if(!myGeomBase->GetTopoFromSelection(mySelection, S)) - return; - - if(S.IsNull()) - return; - - /* Try to display of a cone simulation shape to show direction of a linear edge only in OCC viewer */ - if(myGeomBase->CreateArrowForLinearEdge(S, mySimulationTopoDs)) - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - - GroupC1->LineEdit1->setText(SelectedName); - this->CalculateWhatis(S); - - return; + mySelBtn = myGrp->PushButton1; + mySelEdit = myGrp->LineEdit1; + MeasureGUI_Skeleton::Init( Sel ); } - //================================================================================= -// function : SetEditCurrentArgument() +// function : processObject // purpose : //================================================================================= -void MeasureGUI_WhatisDlg::SetEditCurrentArgument() +void MeasureGUI_WhatisDlg::processObject() { - QPushButton* send = (QPushButton*)sender(); - - if(send == GroupC1->PushButton1) { - GroupC1->LineEdit1->setFocus(); - myEditCurrentArgument = GroupC1->LineEdit1; - } - - this->SelectionIntoArgument(); - return; + QString aText; + myGrp->TextEdit1->setText( getParameters( aText ) ? aText : QString("") ); } //================================================================================= -// function : LineEditReturnPressed() +// function : getParameters // purpose : //================================================================================= -void MeasureGUI_WhatisDlg::LineEditReturnPressed() +bool MeasureGUI_WhatisDlg::getParameters( QString& theText ) { - QLineEdit* send = (QLineEdit*)sender(); - if(send == GroupC1->LineEdit1) - myEditCurrentArgument = GroupC1->LineEdit1; + if ( myObj->_is_nil() ) + return false; else - return; - - MeasureGUI_Skeleton::LineEditReturnPressed(); - return; -} - - -//================================================================================= -// function : ActivateThisDialog() -// purpose : -//================================================================================= -void MeasureGUI_WhatisDlg::ActivateThisDialog() -{ - MeasureGUI_Skeleton::ActivateThisDialog(); - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - if(!mySimulationTopoDs.IsNull()) - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - return; -} - - -//================================================================================= -// function : enterEvent() -// purpose : -//================================================================================= -void MeasureGUI_WhatisDlg::enterEvent(QEvent* e) -{ - if(GroupConstructors->isEnabled()) - return; - this->ActivateThisDialog(); - return; -} - - -//================================================================================= -// function : CalculateWhatis() -// purpose : -//================================================================================= -void MeasureGUI_WhatisDlg::CalculateWhatis(const TopoDS_Shape& S) -{ - if(S.IsNull()) - return; - - TCollection_AsciiString Astr; - - if ( S.ShapeType() == TopAbs_EDGE ) { - if( BRep_Tool::Degenerated(TopoDS::Edge(S)) ) { - Astr = Astr + " " + CORBA::string_dup(SelectedName.latin1()) + " is a degenerated edge \n"; + { + try + { + theText = GEOM::GEOM_IMeasureOperations::_narrow( getOperation() )->WhatIs( myObj ); } - } - - Astr = Astr + " Number of shapes in " + CORBA::string_dup(SelectedName.latin1()) + " : \n"; - - try { - int iType, nbTypes [TopAbs_SHAPE]; - for(iType = 0; iType < TopAbs_SHAPE; ++iType) - nbTypes[iType] = 0; - nbTypes[S.ShapeType()]++; - - TopTools_MapOfShape aMapOfShape; - aMapOfShape.Add(S); - TopTools_ListOfShape aListOfShape; - aListOfShape.Append(S); - - TopTools_ListIteratorOfListOfShape itL(aListOfShape); - for(; itL.More(); itL.Next()) { - TopoDS_Iterator it(itL.Value()); - for(; it.More(); it.Next()) { - TopoDS_Shape s = it.Value(); - if(aMapOfShape.Add(s)) { - aListOfShape.Append(s); - nbTypes[s.ShapeType()]++; - } - } + catch( const SALOME::SALOME_Exception& e ) + { + QtCatchCorbaException( e ); + return false; } - Astr = Astr + " VERTEX : " + TCollection_AsciiString(nbTypes[TopAbs_VERTEX]) + "\n"; - Astr = Astr + " EDGE : " + TCollection_AsciiString(nbTypes[TopAbs_EDGE]) + "\n"; - Astr = Astr + " WIRE : " + TCollection_AsciiString(nbTypes[TopAbs_WIRE]) + "\n"; - Astr = Astr + " FACE : " + TCollection_AsciiString(nbTypes[TopAbs_FACE]) + "\n"; - Astr = Astr + " SHELL : " + TCollection_AsciiString(nbTypes[TopAbs_SHELL]) + "\n"; - Astr = Astr + " SOLID : " + TCollection_AsciiString(nbTypes[TopAbs_SOLID]) + "\n"; - Astr = Astr + " COMPSOLID : " + TCollection_AsciiString(nbTypes[TopAbs_COMPSOLID]) + "\n"; - Astr = Astr + " COMPOUND : " + TCollection_AsciiString(nbTypes[TopAbs_COMPOUND]) + "\n"; - Astr = Astr + " SHAPE : " + TCollection_AsciiString(aMapOfShape.Extent()); - - GroupC1->TextEdit1->setText(Astr.ToCString()); - } - catch(Standard_Failure) { - MESSAGE("Catch intercepted in CalculateWhatis()"); + return getOperation()->IsDone(); } - return; } + + + diff --git a/src/MeasureGUI/MeasureGUI_WhatisDlg.h b/src/MeasureGUI/MeasureGUI_WhatisDlg.h index 2714f0b26..e94d8dd0a 100644 --- a/src/MeasureGUI/MeasureGUI_WhatisDlg.h +++ b/src/MeasureGUI/MeasureGUI_WhatisDlg.h @@ -30,9 +30,8 @@ #define DIALOGBOX_WHATIS_H #include "MeasureGUI_Skeleton.h" -#include "MeasureGUI_1Sel1TextView_QTD.h" -#include "MeasureGUI.h" +class MeasureGUI_1Sel1TextView_QTD; //================================================================================= // class : DialogBox_PROPERTIES @@ -43,22 +42,23 @@ class MeasureGUI_WhatisDlg : public MeasureGUI_Skeleton Q_OBJECT public: - MeasureGUI_WhatisDlg(QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); - ~MeasureGUI_WhatisDlg(); + MeasureGUI_WhatisDlg( QWidget* parent, + SALOME_Selection* Sel ); + ~MeasureGUI_WhatisDlg(); + +protected: + + // redefined from GEOMBase_Helper and MeasureGUI_Skeleton + virtual void processObject(); private: - void Init(); - void enterEvent(QEvent* e); - void CalculateWhatis(const TopoDS_Shape& S); - QString SelectedName; - MeasureGUI_1Sel1TextView_QTD* GroupC1; + void Init( SALOME_Selection* Sel ); + bool getParameters( QString& ); + +private: -private slots: - void SetEditCurrentArgument(); - void SelectionIntoArgument(); - void LineEditReturnPressed(); - void ActivateThisDialog(); + MeasureGUI_1Sel1TextView_QTD* myGrp; }; diff --git a/src/NMTAlgo/Makefile.in b/src/NMTAlgo/Makefile.in new file mode 100644 index 000000000..1dac5fc5f --- /dev/null +++ b/src/NMTAlgo/Makefile.in @@ -0,0 +1,70 @@ +# GEOM NMTAlgo : partition algorithm +# +# 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.salome-platform.org or email : webmaster.salome@opencascade.org +# +# +# +# File : Makefile.in +# Author : Julia DOROVSKIKH +# Module : GEOM +# $Header$ + +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@ + + +@COMMENCE@ + +# Libraries targets +LIB = libNMTAlgo.la +LIB_SRC = \ + NMTAlgo_Algo.cxx \ + NMTAlgo_Builder.cxx \ + NMTAlgo_Loop3d.cxx \ + NMTAlgo_Splitter.cxx \ + NMTAlgo_Splitter1.cxx \ + NMTAlgo_Splitter_1.cxx \ + NMTAlgo_Splitter_2.cxx \ + NMTAlgo_Tools.cxx + +LIB_CLIENT_IDL = +LIB_SERVER_IDL = + +# header files +EXPORT_HEADERS = \ + NMTAlgo_Splitter1.hxx \ + NMTAlgo_Splitter.hxx \ + NMTAlgo_Builder.hxx \ + NMTAlgo_Algo.hxx + +# idl files +EXPORT_IDLS= + + +CPPFLAGS += $(OCC_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome +CXXFLAGS += $(OCC_CXXFLAGS) -I${KERNEL_ROOT_DIR}/include/salome +LDFLAGS += $(CAS_LDPATH) -lNMTTools -lTKBool -lTKBO -L${KERNEL_ROOT_DIR}/lib/salome + +%_moc.cxx: %.h + $(MOC) $< -o $@ + +@CONCLUDE@ diff --git a/src/NMTAlgo/NMTAlgo.cdl b/src/NMTAlgo/NMTAlgo.cdl new file mode 100644 index 000000000..19f52dad4 --- /dev/null +++ b/src/NMTAlgo/NMTAlgo.cdl @@ -0,0 +1,40 @@ +-- File: NMTAlgo.cdl +-- Created: Tue Jan 27 14:39:05 2004 +-- Author: Peter KURNEV +-- +---Copyright: Matra Datavision 2004 + + +package NMTAlgo + + ---Purpose: + +uses + TCollection, + TColStd, + gp, + TopAbs, + TopoDS, + TopTools, + + BooleanOperations, + BOPTColStd, + IntTools, + BOPTools, + BOP, + + NMTDS, + NMTTools, + + BRep, + BRepAlgo + +is + deferred class Algo; + class Splitter; + class Splitter1; --modified by NIZNHY-PKV Wed Feb 11 14:28:50 2004 + class Builder; + class Tools; + class Loop3d; + +end NMTAlgo; diff --git a/src/NMTAlgo/NMTAlgo_Algo.cdl b/src/NMTAlgo/NMTAlgo_Algo.cdl new file mode 100644 index 000000000..cad765560 --- /dev/null +++ b/src/NMTAlgo/NMTAlgo_Algo.cdl @@ -0,0 +1,59 @@ +-- File: NMTAlgo_Algo.cdl +-- Created: Tue Jan 27 14:41:04 2004 +-- Author: Peter KURNEV +-- +---Copyright: Matra Datavision 2004 + + +deferred class Algo from NMTAlgo + + ---Purpose: + +uses + Shape from TopoDS, + + DSFiller from NMTTools, + PDSFiller from NMTTools + +--raises + +is + Initialize + returns Algo from NMTAlgo; + ---C++: alias "Standard_EXPORT virtual ~NMTAlgo_Algo();" + + + SetFiller(me:out; + aDSF: DSFiller from NMTTools); + + Filler(me) + returns DSFiller from NMTTools; + ---C++: return const & + + ComputeWithFiller(me:out; + aDSF: DSFiller from NMTTools) + is virtual; + + Clear (me:out) + is virtual; + + Shape (me) + returns Shape from TopoDS; + ---C++: return const & + + IsDone(me) + returns Boolean from Standard; + + ErrorStatus (me) + returns Integer from Standard; + +fields + myDSFiller : PDSFiller from NMTTools is protected; + myShape : Shape from TopoDS is protected; + -- + myIsDone : Boolean from Standard is protected; + myIsComputed : Boolean from Standard is protected; + myErrorStatus : Integer from Standard is protected; + myDraw : Integer from Standard is protected; + +end Algo; diff --git a/src/NMTAlgo/NMTAlgo_Algo.cxx b/src/NMTAlgo/NMTAlgo_Algo.cxx new file mode 100644 index 000000000..1b77cbceb --- /dev/null +++ b/src/NMTAlgo/NMTAlgo_Algo.cxx @@ -0,0 +1,119 @@ +// File: NMTAlgo_Algo.cxx +// Created: Tue Jan 27 14:58:21 2004 +// Author: Peter KURNEV +// + + +#include +#include +//======================================================================= +// function: NMTAlgo_Algo::NMTAlgo_Algo +// purpose: +//======================================================================= + NMTAlgo_Algo::NMTAlgo_Algo() +: + myDSFiller(NULL), + myIsDone(Standard_False), + myIsComputed(Standard_False), + myErrorStatus(1) +{ + myDraw=0; + // + char* xr=getenv("MDISP"); + if (xr!=NULL) { + if (!strcmp (xr, "yes")) { + myDraw=1; + } + } +} +//======================================================================= +// function: NMTAlgo_Algo +// purpose: +//======================================================================= + NMTAlgo_Algo::~NMTAlgo_Algo() +{ + Clear(); +} +//======================================================================= +// function: Clear +// purpose: +//======================================================================= + void NMTAlgo_Algo::Clear() +{ + myIsDone=Standard_False; + myIsComputed=Standard_False; + myErrorStatus=1; +} +//======================================================================= +// function: SetFiller +// purpose: +//======================================================================= + void NMTAlgo_Algo::SetFiller(const NMTTools_DSFiller& aDSF) +{ + myDSFiller=(NMTTools_DSFiller *)&aDSF; +} +//======================================================================= +// function: Filler +// purpose: +//======================================================================= + const NMTTools_DSFiller& NMTAlgo_Algo::Filler()const +{ + return *myDSFiller; +} +//======================================================================= +// function: ComputeWithFiller +// purpose: +//======================================================================= + void NMTAlgo_Algo::ComputeWithFiller(const NMTTools_DSFiller& aDSF) +{ + SetFiller(aDSF); +} +//======================================================================= +// function: Shape +// purpose: +//======================================================================= + const TopoDS_Shape& NMTAlgo_Algo::Shape()const +{ + return myShape; +} +//======================================================================= +// function: IsDone +// purpose: +//======================================================================= + Standard_Boolean NMTAlgo_Algo::IsDone()const +{ + return myIsDone; +} +//======================================================================= +// function: ErrorStatus +// purpose: +//======================================================================= + Standard_Integer NMTAlgo_Algo::ErrorStatus()const +{ + return myErrorStatus; +} +/* +//======================================================================= +// function: Compute +// purpose: +//======================================================================= + void NMTAlgo_Algo::Compute() +{ +} +//======================================================================= +// function: SetCompositeShape +// purpose: +//======================================================================= + void NMTAlgo_Algo::SetCompositeShape(const TopoDS_Shape& aS) +{ + myCompositeShape=aS; +} +//======================================================================= +// function: CompositeShape +// purpose: +//======================================================================= + const TopoDS_Shape& NMTAlgo_Algo::CompositeShape()const +{ + return myCompositeShape; +} +*/ diff --git a/src/NMTAlgo/NMTAlgo_Algo.hxx b/src/NMTAlgo/NMTAlgo_Algo.hxx new file mode 100644 index 000000000..afa9726cd --- /dev/null +++ b/src/NMTAlgo/NMTAlgo_Algo.hxx @@ -0,0 +1,109 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _NMTAlgo_Algo_HeaderFile +#define _NMTAlgo_Algo_HeaderFile + +#ifndef _NMTTools_PDSFiller_HeaderFile +#include +#endif +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +#ifndef _Standard_Integer_HeaderFile +#include +#endif +class NMTTools_DSFiller; +class TopoDS_Shape; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class NMTAlgo_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 NMTTools_DSFiller& aDSF) ; +Standard_EXPORT const NMTTools_DSFiller& Filler() const; +Standard_EXPORT virtual void ComputeWithFiller(const NMTTools_DSFiller& aDSF) ; +Standard_EXPORT virtual void Clear() ; +Standard_EXPORT const TopoDS_Shape& Shape() const; +Standard_EXPORT Standard_Boolean IsDone() const; +Standard_EXPORT Standard_Integer ErrorStatus() const; + + + + + +protected: + + // Methods PROTECTED + // +Standard_EXPORT NMTAlgo_Algo(); +Standard_EXPORT virtual ~NMTAlgo_Algo(); + + + // Fields PROTECTED + // +NMTTools_PDSFiller myDSFiller; +TopoDS_Shape myShape; +Standard_Boolean myIsDone; +Standard_Boolean myIsComputed; +Standard_Integer myErrorStatus; +Standard_Integer myDraw; + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // + + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/NMTAlgo/NMTAlgo_Algo.ixx b/src/NMTAlgo/NMTAlgo_Algo.ixx new file mode 100644 index 000000000..0d5a23360 --- /dev/null +++ b/src/NMTAlgo/NMTAlgo_Algo.ixx @@ -0,0 +1,19 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include + + + + diff --git a/src/NMTAlgo/NMTAlgo_Algo.jxx b/src/NMTAlgo/NMTAlgo_Algo.jxx new file mode 100644 index 000000000..a31f1b55c --- /dev/null +++ b/src/NMTAlgo/NMTAlgo_Algo.jxx @@ -0,0 +1,9 @@ +#ifndef _NMTTools_DSFiller_HeaderFile +#include +#endif +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif +#ifndef _NMTAlgo_Algo_HeaderFile +#include +#endif diff --git a/src/NMTAlgo/NMTAlgo_Builder.cdl b/src/NMTAlgo/NMTAlgo_Builder.cdl new file mode 100644 index 000000000..8587477fe --- /dev/null +++ b/src/NMTAlgo/NMTAlgo_Builder.cdl @@ -0,0 +1,79 @@ +-- File: NMTAlgo_Builder.cdl +-- Created: Tue Jan 27 15:09:45 2004 +-- Author: Peter KURNEV +-- +---Copyright: Matra Datavision 2004 + + +class Builder from NMTAlgo + inherits Algo from NMTAlgo + + ---Purpose: + +uses + Shape from TopoDS, + Face from TopoDS, + Edge from TopoDS, + IndexedMapOfShape from TopTools, + IndexedDataMapOfShapeListOfShape from TopTools, + IndexedDataMapOfShapeShape from TopTools, + Image from BRepAlgo, + DSFiller from NMTTools +--raises + +is + Create + returns Builder from NMTAlgo; + ---C++: alias "Standard_EXPORT virtual ~NMTAlgo_Builder();" + + Clear (me:out) + is redefined; + + ComputeWithFiller(me:out; + aDSF: DSFiller from NMTTools) + is redefined; + + FillImagesEdges (me:out) + is protected; + + FillIn2DParts (me:out) + is protected; + + FillImagesFaces (me:out) + is protected; + + FillSDFaces (me:out) + is protected; + + --- Queries + SplitVertices (me:out) + is protected; + + IsSectionEdge (me; + E : Edge from TopoDS) + returns Boolean from Standard + is protected; + + HasSameDomainF(me; + F : Face from TopoDS) + returns Boolean from Standard + is protected; + + IsSameDomainF(me; + F1 : Face from TopoDS; + F2 : Face from TopoDS) + returns Boolean from Standard + is protected; + +fields + + myImagesEdges : Image from BRepAlgo is protected; + myImagesFaces : Image from BRepAlgo is protected; + + myQueryShapes : IndexedMapOfShape from TopTools is protected; + -- + myIn2DParts : IndexedDataMapOfShapeListOfShape from TopTools is protected; + mySectionParts : IndexedDataMapOfShapeListOfShape from TopTools is protected; + mySDFaces : IndexedDataMapOfShapeShape from TopTools is protected; + -- +end Builder; diff --git a/src/NMTAlgo/NMTAlgo_Builder.cxx b/src/NMTAlgo/NMTAlgo_Builder.cxx new file mode 100644 index 000000000..c7a902f06 --- /dev/null +++ b/src/NMTAlgo/NMTAlgo_Builder.cxx @@ -0,0 +1,637 @@ +// File: NMTAlgo_Inter3d.cxx +// Created: Tue Jan 27 15:14:13 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 + +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +//======================================================================= +// function: NMTAlgo_Inter3d::NMTAlgo_Inter3d() +// purpose: +//======================================================================= + NMTAlgo_Builder::NMTAlgo_Builder() +: + NMTAlgo_Algo() +{ +} +//======================================================================= +// function: ~NMTAlgo_Builder +// purpose: +//======================================================================= + NMTAlgo_Builder::~NMTAlgo_Builder() +{ + Clear(); +} +//======================================================================= +// function: Clear +// purpose: +//======================================================================= + void NMTAlgo_Builder::Clear() +{ + NMTAlgo_Algo::Clear(); + // + myImagesEdges.Clear(); + myImagesFaces.Clear(); + myIn2DParts.Clear(); + mySectionParts.Clear(); + mySDFaces.Clear(); +} +//======================================================================= +// function: ComputeWithFiller +// purpose: +//======================================================================= + void NMTAlgo_Builder::ComputeWithFiller(const NMTTools_DSFiller& aDSF) +{ + myErrorStatus=0; + myIsDone=Standard_False; + // + SetFiller(aDSF); + // edges + FillImagesEdges(); + // faces + FillIn2DParts(); + FillImagesFaces(); + FillSDFaces(); +} + +//======================================================================= +// function: FillSDFaces +// purpose: +//======================================================================= + void NMTAlgo_Builder::FillSDFaces() +{ + const NMTDS_ShapesDataStructure& aDS=myDSFiller->DS(); + NMTTools_PaveFiller* pPF=(NMTTools_PaveFiller*)&(myDSFiller->PaveFiller()); + BOPTools_InterferencePool* pIP=(BOPTools_InterferencePool*)&myDSFiller->InterfPool(); + BOPTools_CArray1OfSSInterference& aFFs=pIP->SSInterferences(); + IntTools_Context& aCtx= pPF->ChangeContext(); + // + Standard_Boolean bIsSDF; + Standard_Integer i, j, aNbFF, nF1, nF2, aNbPBInOn, aNbC; + TopTools_ListIteratorOfListOfShape aItF1, aItF2; + NMTTools_ListOfCoupleOfShape aLCS; + // + mySDFaces.Clear(); + // + // 1. For each FF find among images of faces + // all pairs of same domain faces (SDF) [=> aLCS] + aNbFF=aFFs.Extent(); + for (i=1; i<=aNbFF; ++i) { + BOPTools_SSInterference& aFF=aFFs(i); + aFF.Indices(nF1, nF2); + // + const TopoDS_Face& aF1=TopoDS::Face(aDS.Shape(nF1)); + const TopoDS_Face& aF2=TopoDS::Face(aDS.Shape(nF2)); + // + // if there are no in/on 2D split parts the faces nF1, nF2 + // can not be SDF + const BOPTools_ListOfPaveBlock& aLPBInOn=aFF.PaveBlocks(); + aNbPBInOn=aLPBInOn.Extent(); + if (!aNbPBInOn) { + continue; + } + // + // if there is at least one section edge between faces nF1, nF2 + // they can not be SDF + BOPTools_SequenceOfCurves& aSC=aFF.Curves(); + aNbC=aSC.Length(); + if (aNbC) { + continue; + } + // + // the faces are suspected to be SDF. + // Try to find SDF among images of nF1, nF2 + const TopTools_ListOfShape& aLF1=myImagesFaces.Image(aF1); + const TopTools_ListOfShape& aLF2=myImagesFaces.Image(aF2); + // + aItF1.Initialize(aLF1); + for (; aItF1.More(); aItF1.Next()) { + const TopoDS_Face& aF1x=TopoDS::Face(aItF1.Value()); + // + aItF2.Initialize(aLF2); + for (; aItF2.More(); aItF2.Next()) { + const TopoDS_Face& aF2y=TopoDS::Face(aItF2.Value()); + bIsSDF=NMTTools_Tools::AreFacesSameDomain(aF1x, aF2y, aCtx); + if (bIsSDF) { + NMTTools_CoupleOfShape aCS; + // + aCS.SetShape1(aF1x); + aCS.SetShape2(aF2y); + aLCS.Append(aCS); + } + } + } + }//for (i=1; i<=aNbFF; ++i) + // + aNbC=aLCS.Extent(); + if (!aNbC) { + return; + } + // + // 2. Find Chains + NMTTools_IndexedDataMapOfShapeIndexedMapOfShape aMC; + // + NMTTools_Tools::FindChains(aLCS, aMC); + // + // 3. Fill the map of SDF mySDFaces + aNbC=aMC.Extent(); + for (i=1; i<=aNbC; ++i) { + const TopoDS_Shape& aF=aMC.FindKey(i); + const TopTools_IndexedMapOfShape& aMSDF=aMC(i); + // + aNbFF=aMSDF.Extent(); + for (j=1; j<=aNbFF; ++j) { + const TopoDS_Shape& aFSD=aMSDF(j); + mySDFaces.Add(aFSD, aF); + } + } + // +} +//======================================================================= +// function: FillImagesFaces +// purpose: +//======================================================================= + void NMTAlgo_Builder::FillImagesFaces() +{ + const NMTDS_ShapesDataStructure& aDS=myDSFiller->DS(); + NMTTools_PaveFiller* pPF=(NMTTools_PaveFiller*)&(myDSFiller->PaveFiller()); + IntTools_Context& aCtx= pPF->ChangeContext(); + // + Standard_Integer i, j, aNb, aNbE; + TopTools_IndexedMapOfShape aMFence, aME; + TColStd_IndexedMapOfInteger aMFP; + // + // 1. Select Faces to process (MFP) + aNb=aDS.NumberOfShapesOfTheObject(); + for (i=1; i<=aNb; ++i) { + const TopoDS_Shape& aF=aDS.Shape(i); + if (aF.ShapeType()!=TopAbs_FACE) { + continue; + } + if (aMFence.Contains(aF)) { + continue; + } + aMFence.Add(aF); + // + if (myIn2DParts.Contains(aF)) { + aMFP.Add(i); + continue; + } + // + if (mySectionParts.Contains(aF)) { + aMFP.Add(i); + continue; + } + // + aME.Clear(); + TopExp::MapShapes(aF, TopAbs_EDGE, aME); + // + aNbE=aME.Extent(); + for(j=1; j<=aNbE; ++j) { + const TopoDS_Shape& aE=aME(j); + // + if (myImagesEdges.HasImage(aE)) { + aMFP.Add(i); + break; + } + } + }// for (i=1; i<=aNb; ++i) + // + // 2. ProcessFaces + Standard_Boolean bToReverse, bIsClosed, bIsDegenerated; + Standard_Integer aNbF, nF; + TopoDS_Face aFF; + TopoDS_Edge aSp; + TopExp_Explorer anExp; + TopTools_ListIteratorOfListOfShape aIt; + BRepAlgo_Image aImagesFaces; + TopAbs_Orientation anOriF; + // + aNbF=aMFP.Extent(); + for (i=1; i<=aNbF; ++i) { + nF=aMFP(i); + const TopoDS_Face& aF=TopoDS::Face(aDS.Shape(nF)); + anOriF=aF.Orientation(); + aFF=aF; + aFF.Orientation(TopAbs_FORWARD); + // + aMFence.Clear(); + // + // 2.1. Fill WES + BOP_WireEdgeSet aWES; + aWES.Initialize(aFF); + // + // 2.1.1. Add Split parts + anExp.Init(aFF, TopAbs_EDGE); + for (; anExp.More(); anExp.Next()) { + const TopoDS_Edge& aE=TopoDS::Edge(anExp.Current()); + // + if (!myImagesEdges.HasImage(aE)) { + aWES.AddStartElement(aE); + continue; + } + // + bIsDegenerated=BRep_Tool::Degenerated(aE); + bIsClosed=BRep_Tool::IsClosed(aE, aF); + // + const TopTools_ListOfShape& aLIE=myImagesEdges.Image(aE); + aIt.Initialize(aLIE); + for (; aIt.More(); aIt.Next()) { + aSp=TopoDS::Edge(aIt.Value()); + // + if (bIsDegenerated) { + aSp.Orientation(aE.Orientation()); + aWES.AddStartElement(aSp); + continue; + } + // + if (bIsClosed){ + if (!aMFence.Contains(aSp)){ + aMFence.Add(aSp); + // + if (!BRep_Tool::IsClosed(aSp, aF)){ + BOPTools_Tools3D::DoSplitSEAMOnFace(aSp, aF); + } + // + aSp.Orientation(TopAbs_FORWARD); + aWES.AddStartElement(aSp); + // + aSp.Orientation(TopAbs_REVERSED); + aWES.AddStartElement(aSp); + continue; + } + } + // + bToReverse=BOPTools_Tools3D::IsSplitToReverse1(aSp, aE, aCtx); + if (bToReverse) { + aSp.Reverse(); + } + aWES.AddStartElement(aSp); + } + } + // + // 2.1.2. Add In2D Parts + if (myIn2DParts.Contains(aF)) { + const TopTools_ListOfShape& aLE=myIn2DParts.FindFromKey(aF); + aIt.Initialize(aLE); + for (; aIt.More(); aIt.Next()) { + aSp=TopoDS::Edge(aIt.Value()); + // + aSp.Orientation(TopAbs_FORWARD); + aWES.AddStartElement(aSp); + // + aSp.Orientation(TopAbs_REVERSED); + aWES.AddStartElement(aSp); + } + } + // + // 2.1.3. Add Section Parts + if (mySectionParts.Contains(aF)) { + const TopTools_ListOfShape& aLE=mySectionParts.FindFromKey(aF); + aIt.Initialize(aLE); + for (; aIt.More(); aIt.Next()) { + aSp=TopoDS::Edge(aIt.Value()); + // + aSp.Orientation(TopAbs_FORWARD); + aWES.AddStartElement(aSp); + // + aSp.Orientation(TopAbs_REVERSED); + aWES.AddStartElement(aSp); + } + } + // + // 2.2. Build images Faces + BOP_FaceBuilder aFB; + // + aFB.SetTreatment(0); // 0-Do Internal Edges + aFB.SetTreatSDScales(0); // what is 0 ?? + // + aFB.Do(aWES); + // + TopTools_ListOfShape aLFR; + // + const TopTools_ListOfShape& aLF=aFB.NewFaces(); + + aIt.Initialize(aLF); + for (; aIt.More(); aIt.Next()) { + TopoDS_Shape& aFR=aIt.Value(); + if (anOriF==TopAbs_REVERSED) { + aFR.Orientation(TopAbs_REVERSED); + } + aLFR.Append(aFR); + } + + // + // 2.3. Collect images Faces + myImagesFaces.Bind(aF, aLFR); + }//for (i=1; i<=aNbF; ++i) +} +//======================================================================= +// function: FillIn2DParts +// purpose: +//======================================================================= + void NMTAlgo_Builder::FillIn2DParts() +{ + const NMTDS_ShapesDataStructure& aDS=myDSFiller->DS(); + NMTTools_PaveFiller* pPF=(NMTTools_PaveFiller*)&(myDSFiller->PaveFiller()); + BOPTools_InterferencePool* pIP=(BOPTools_InterferencePool*)&myDSFiller->InterfPool(); + BOPTools_CArray1OfSSInterference& aFFs=pIP->SSInterferences(); + // + Standard_Integer i, j, aNb, nF1, nF2, aNbFF, iFF, nSpIn, nSpSc, aNbCurves; + BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger aFFMap; + BOPTools_ListOfPaveBlock aLPBIn, aLPBSc; + BOPTools_ListIteratorOfListOfPaveBlock aItPBIn, aItPBSc; + TopTools_IndexedMapOfShape aMF, aMFence; + TopTools_ListOfShape aLSpIn, aLSpSc; + // + BOP_BuilderTools::DoMap(aFFs, aFFMap); + // + // 1. Collect Splits In 2D (myIn2DParts) and + // Section Edges (mySectionParts) + // for each source face that involved in FF + aNb=aFFMap.Extent(); + for (i=1; i<=aNb; ++i) { + nF1=aFFMap.FindKey(i); + const TopoDS_Shape& aF=aDS.Shape(nF1); + // + if (aMF.Contains(aF)) { + continue; + } + aMF.Add(aF); + // + aLPBIn.Clear(); + aLPBSc.Clear(); + // + const TColStd_IndexedMapOfInteger& aFFIndicesMap=aFFMap.FindFromIndex(i); + // + aNbFF=aFFIndicesMap.Extent(); + for (j=1; j<=aNbFF; ++j) { + iFF=aFFIndicesMap(j); + BOPTools_SSInterference& aFF=aFFs(iFF); + nF2=aFF.OppositeIndex(nF1); + // + // In 2D + pPF->RealSplitsInFace(0, nF2, nF1, aLPBIn); + // + // Sections + BOPTools_SequenceOfCurves& aSC=aFF.Curves(); + aNbCurves=aSC.Length(); + if (!aNbCurves) { + continue; + } + // + const BOPTools_Curve& aBC=aSC(1); + const BOPTools_ListOfPaveBlock& aLPB=aBC.NewPaveBlocks(); + // + aItPBSc.Initialize(aLPB); + for (; aItPBSc.More(); aItPBSc.Next()) { + const BOPTools_PaveBlock& aPBSc=aItPBSc.Value(); + aLPBSc.Append(aPBSc); + } + }// for (j=1; j<=aNbFF; ++j) + // + // In 2D Parts + aMFence.Clear(); + // + aLSpIn.Clear(); + aItPBIn.Initialize(aLPBIn); + for (; aItPBIn.More(); aItPBIn.Next()) { + const BOPTools_PaveBlock& aPBR=aItPBIn.Value(); + nSpIn=aPBR.Edge(); + const TopoDS_Shape& aSpIn=aDS.Shape(nSpIn); + if (!aMFence.Contains(aSpIn)){ + aMFence.Add(aSpIn); + aLSpIn.Append(aSpIn); + } + } + myIn2DParts.Add(aF, aLSpIn); + // + // Section Parts + aLSpSc.Clear(); + aItPBSc.Initialize(aLPBSc); + for (; aItPBSc.More(); aItPBSc.Next()) { + const BOPTools_PaveBlock& aPBSc=aItPBSc.Value(); + nSpSc=aPBSc.Edge(); + const TopoDS_Shape& aSpSc=aDS.Shape(nSpSc); + if (!aMFence.Contains(aSpSc)){ + aMFence.Add(aSpSc); + aLSpSc.Append(aSpSc); + } + } + mySectionParts.Add(aF, aLSpSc); + } //for (i=1; i<=aNb; ++i) +} + +//======================================================================= +// function: FillImagesEdges +// purpose: +//======================================================================= + void NMTAlgo_Builder::FillImagesEdges() +{ + const NMTDS_ShapesDataStructure& aDS=myDSFiller->DS(); + NMTTools_PaveFiller* pPF=(NMTTools_PaveFiller*)&(myDSFiller->PaveFiller()); + const BOPTools_SplitShapesPool& aSSP=pPF->SplitShapesPool(); + // + Standard_Integer nE, aNb, aNbSp, nSp; + BOPTools_ListIteratorOfListOfPaveBlock aIt; + TopTools_IndexedMapOfShape aMFence; + TopTools_ListOfShape aLSp; + // + aNb=aDS.NumberOfShapesOfTheObject(); + for (nE=1; nE<=aNb; ++nE) { + const TopoDS_Shape& aE=aDS.Shape(nE); + if (aE.ShapeType()!=TopAbs_EDGE) { + continue; + } + if (aMFence.Contains(aE)) { + continue; + } + aMFence.Add(aE); + // + const BOPTools_ListOfPaveBlock& aLPB=aSSP(aDS.RefEdge(nE)); + aNbSp=aLPB.Extent(); + // + if (!aNbSp) {// no splits + //myImagesEdges.Bind(aE, aE); + continue; + } + // + aLSp.Clear(); + aIt.Initialize(aLPB); + for (; aIt.More(); aIt.Next()) { + const BOPTools_PaveBlock& aPB=aIt.Value(); + const BOPTools_PaveBlock& aPBR=pPF->RealPaveBlock(aPB); + nSp=aPBR.Edge(); + const TopoDS_Shape& aSp=aDS.Shape(nSp); + aLSp.Append(aSp); + } + myImagesEdges.Bind(aE, aLSp); + } +} +//======================================================================= +// function: SplitVertices +// purpose: +//======================================================================= + void NMTAlgo_Builder::SplitVertices() +{ + const NMTDS_ShapesDataStructure& aDS=myDSFiller->DS(); + NMTTools_PaveFiller* pPF=(NMTTools_PaveFiller*)&(myDSFiller->PaveFiller()); + const BOPTools_SplitShapesPool& aSSP=pPF->SplitShapesPool(); + // + Standard_Integer nE, aNb, aNbSp, nV1, nV2; + BOPTools_ListIteratorOfListOfPaveBlock aIt; + // + myQueryShapes.Clear(); + // + aNb=aDS.NumberOfShapesOfTheObject(); + for (nE=1; nE<=aNb; ++nE) { + const TopoDS_Shape& aE=aDS.Shape(nE); + if (aE.ShapeType()!=TopAbs_EDGE) { + continue; + } + // + const BOPTools_ListOfPaveBlock& aLPB=aSSP(aDS.RefEdge(nE)); + aNbSp=aLPB.Extent(); + // + if (!aNbSp) {// no splits + continue; + } + // + aIt.Initialize(aLPB); + for (; aIt.More(); aIt.Next()) { + const BOPTools_PaveBlock& aPB=aIt.Value(); + const BOPTools_PaveBlock& aPBR=pPF->RealPaveBlock(aPB); + // + nV1=aPBR.Pave1().Index(); + if (aDS.IsNewShape(nV1)) { + const TopoDS_Shape& aV1=aDS.Shape(nV1); + myQueryShapes.Add(aV1); + } + // + nV2=aPBR.Pave2().Index(); + if (aDS.IsNewShape(nV2)) { + const TopoDS_Shape& aV2=aDS.Shape(nV2); + myQueryShapes.Add(aV2); + } + } + } +} +//======================================================================= +// function: IsSectionEdge +// purpose: +//======================================================================= + Standard_Boolean NMTAlgo_Builder::IsSectionEdge(const TopoDS_Edge& aE)const +{ + return myImagesEdges.HasImage(aE); +} +//======================================================================= +// function: IsSameDomainF +// purpose: +//======================================================================= + Standard_Boolean NMTAlgo_Builder::HasSameDomainF(const TopoDS_Face& aF1)const +{ + Standard_Boolean bFlag=Standard_False; + TopTools_ListIteratorOfListOfShape aItF1; + // + const TopTools_ListOfShape& aLF1=myImagesFaces.Image(aF1); + aItF1.Initialize(aLF1); + for (; aItF1.More(); aItF1.Next()) { + const TopoDS_Shape& aF1x=aItF1.Value(); + // + if (mySDFaces.Contains(aF1x)){ + return !bFlag; + } + } + return bFlag; +} +//======================================================================= +// function: IsSameDomainF +// purpose: +//======================================================================= + Standard_Boolean NMTAlgo_Builder::IsSameDomainF(const TopoDS_Face& aF1, + const TopoDS_Face& aF2)const +{ + Standard_Boolean bFlag=Standard_False; + TopTools_ListIteratorOfListOfShape aItF1, aItF2; + // + const TopTools_ListOfShape& aLF1=myImagesFaces.Image(aF1); + const TopTools_ListOfShape& aLF2=myImagesFaces.Image(aF2); + // + aItF1.Initialize(aLF1); + for (; aItF1.More(); aItF1.Next()) { + const TopoDS_Shape& aF1x=aItF1.Value(); + // + if (!mySDFaces.Contains(aF1x)){ + continue; + } + const TopoDS_Shape& aFSD1x=mySDFaces.FindFromKey(aF1x); + // + aItF2.Initialize(aLF2); + for (; aItF2.More(); aItF2.Next()) { + const TopoDS_Shape& aF2y=aItF2.Value(); + if (!mySDFaces.Contains(aF2y)){ + continue; + } + const TopoDS_Shape& aFSD2y=mySDFaces.FindFromKey(aF2y); + if (aFSD1x.IsSame(aFSD2y)) { + return !bFlag; + } + } + } + return bFlag; +} diff --git a/src/NMTAlgo/NMTAlgo_Builder.hxx b/src/NMTAlgo/NMTAlgo_Builder.hxx new file mode 100644 index 000000000..a39a1c505 --- /dev/null +++ b/src/NMTAlgo/NMTAlgo_Builder.hxx @@ -0,0 +1,119 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _NMTAlgo_Builder_HeaderFile +#define _NMTAlgo_Builder_HeaderFile + +#ifndef _BRepAlgo_Image_HeaderFile +#include +#endif +#ifndef _TopTools_IndexedMapOfShape_HeaderFile +#include +#endif +#ifndef _TopTools_IndexedDataMapOfShapeListOfShape_HeaderFile +#include +#endif +#ifndef _TopTools_IndexedDataMapOfShapeShape_HeaderFile +#include +#endif +#ifndef _NMTAlgo_Algo_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +class NMTTools_DSFiller; +class TopoDS_Edge; +class TopoDS_Face; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class NMTAlgo_Builder : public NMTAlgo_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 NMTAlgo_Builder(); +Standard_EXPORT virtual ~NMTAlgo_Builder(); +Standard_EXPORT virtual void Clear() ; +Standard_EXPORT virtual void ComputeWithFiller(const NMTTools_DSFiller& aDSF) ; + + + + + +protected: + + // Methods PROTECTED + // +Standard_EXPORT void FillImagesEdges() ; +Standard_EXPORT void FillIn2DParts() ; +Standard_EXPORT void FillImagesFaces() ; +Standard_EXPORT void FillSDFaces() ; +Standard_EXPORT void SplitVertices() ; +Standard_EXPORT Standard_Boolean IsSectionEdge(const TopoDS_Edge& E) const; +Standard_EXPORT Standard_Boolean HasSameDomainF(const TopoDS_Face& F) const; +Standard_EXPORT Standard_Boolean IsSameDomainF(const TopoDS_Face& F1,const TopoDS_Face& F2) const; + + + // Fields PROTECTED + // +BRepAlgo_Image myImagesEdges; +BRepAlgo_Image myImagesFaces; +TopTools_IndexedMapOfShape myQueryShapes; +TopTools_IndexedDataMapOfShapeListOfShape myIn2DParts; +TopTools_IndexedDataMapOfShapeListOfShape mySectionParts; +TopTools_IndexedDataMapOfShapeShape mySDFaces; + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // + + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/NMTAlgo/NMTAlgo_Builder.ixx b/src/NMTAlgo/NMTAlgo_Builder.ixx new file mode 100644 index 000000000..09480b40e --- /dev/null +++ b/src/NMTAlgo/NMTAlgo_Builder.ixx @@ -0,0 +1,19 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include + + + + diff --git a/src/NMTAlgo/NMTAlgo_Builder.jxx b/src/NMTAlgo/NMTAlgo_Builder.jxx new file mode 100644 index 000000000..00dfa436e --- /dev/null +++ b/src/NMTAlgo/NMTAlgo_Builder.jxx @@ -0,0 +1,12 @@ +#ifndef _NMTTools_DSFiller_HeaderFile +#include +#endif +#ifndef _TopoDS_Edge_HeaderFile +#include +#endif +#ifndef _TopoDS_Face_HeaderFile +#include +#endif +#ifndef _NMTAlgo_Builder_HeaderFile +#include +#endif diff --git a/src/NMTAlgo/NMTAlgo_Loop3d.cdl b/src/NMTAlgo/NMTAlgo_Loop3d.cdl new file mode 100644 index 000000000..f029d889b --- /dev/null +++ b/src/NMTAlgo/NMTAlgo_Loop3d.cdl @@ -0,0 +1,66 @@ + +class Loop3d from NMTAlgo + + ---Purpose: Builds the shells from a set of faces. + -- Provides methods for comparing faces mutual + -- location. + +uses + Vec from gp, + MapOfOrientedShape from TopTools, + IndexedDataMapOfShapeListOfShape from TopTools, + Face from TopoDS, + Edge from TopoDS, + ListOfShape from TopTools, + Shape from TopoDS + +is + + Create + returns Loop3d from NMTAlgo ; + + AddConstFaces (me:out; + S : Shape from TopoDS) + ---Purpose: Add faces of as unique faces in the result. + is static; + + AddSectionFaces (me:out; + S : Shape from TopoDS) + ---Purpose: Add faces of as double faces in the result. + is static; + + MakeShells (me:out; + AvoidFacesMap : MapOfOrientedShape from TopTools) + returns ListOfShape from TopTools is static; + ---Purpose: Make and return shells. + -- can contain faces that must not be + -- added to result shells. + ---C++: return const & + + + ---Category: class methods + + IsInside (myclass; E : Edge from TopoDS; + F1, F2 : Face from TopoDS; + CountDot : Boolean from Standard; + Dot : in out Real from Standard; + GoodOri : in out Boolean from Standard) + returns Boolean from Standard; + ---Purpose: check if is inside by edge . + -- if , compute : scalar production of + -- normalized vectors pointing inside faces, and + -- check if faces are oriented well for sewing + + Normal (myclass; E : Edge from TopoDS; + F : Face from TopoDS) + returns Vec from gp; + + +fields + + myNewShells : ListOfShape from TopTools; -- result + + myFaces : ListOfShape from TopTools; + myEFMap : IndexedDataMapOfShapeListOfShape from TopTools; + +end Loop3d; diff --git a/src/NMTAlgo/NMTAlgo_Loop3d.cxx b/src/NMTAlgo/NMTAlgo_Loop3d.cxx new file mode 100644 index 000000000..9aceec61d --- /dev/null +++ b/src/NMTAlgo/NMTAlgo_Loop3d.cxx @@ -0,0 +1,330 @@ + +//using namespace std; + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static + TopoDS_Edge FindEinF(const TopoDS_Edge&, const TopoDS_Face&); +static + gp_Vec NextNormal(const TopoDS_Edge&, const TopoDS_Face&); + +//======================================================================= +//function : +//purpose : +//======================================================================= + NMTAlgo_Loop3d::NMTAlgo_Loop3d() +{ +} + +//======================================================================= +//function : AddConstFaces +//purpose : Add faces of as unique faces in the result. +//======================================================================= + void NMTAlgo_Loop3d::AddConstFaces(const TopoDS_Shape& S) +{ + TopExp_Explorer FaceExp(S, TopAbs_FACE); + for (; FaceExp.More(); FaceExp.Next()){ + myFaces.Append( FaceExp.Current() ); + } + TopExp::MapShapesAndAncestors(S, TopAbs_EDGE, TopAbs_FACE, myEFMap); +} + +//======================================================================= +//function : AddSectionFaces +//purpose : Add faces of as double faces in the result. +//======================================================================= + void NMTAlgo_Loop3d::AddSectionFaces(const TopoDS_Shape& S) +{ + AddConstFaces( S ); + AddConstFaces( S.Reversed() ); +} + +//======================================================================= +//function : MakeShells +//purpose : Make and return shells. +// can contain faces that must not be +// added to result shells. +//======================================================================= + const TopTools_ListOfShape& NMTAlgo_Loop3d::MakeShells + (const TopTools_MapOfOrientedShape& AvoidFacesMap) +{ + myNewShells.Clear(); + + BRep_Builder Builder; + TopTools_MapOfShape CheckedEdgesMap; + TopTools_MapOfOrientedShape AddedFacesMap; + + TopTools_ListIteratorOfListOfShape itF (myFaces); + for (; itF.More(); itF.Next()) { + const TopoDS_Shape& FF = itF.Value(); + if (AvoidFacesMap.Contains( FF ) || + ! AddedFacesMap.Add( FF ) ) + continue; + + // make a new shell + TopoDS_Shell Shell; + Builder.MakeShell(Shell); + Builder.Add(Shell,FF); + + // clear the maps from shapes added to previous Shell + TopTools_MapIteratorOfMapOfShape itEM (CheckedEdgesMap); + for (; itEM.More(); itEM.Next()) { + TopTools_ListOfShape& FL = myEFMap.ChangeFromKey( itEM.Key()); + TopTools_ListIteratorOfListOfShape it (FL); + while ( it.More()) { + if (AddedFacesMap.Contains( it.Value())) + FL.Remove( it ); + else + it.Next(); + } + } + CheckedEdgesMap.Clear(); + + + // loop on faces added to Shell; add their neighbor faces to Shell and so on + TopoDS_Iterator itAddedF (Shell); + for (; itAddedF.More(); itAddedF.Next()){ + const TopoDS_Face& F = TopoDS::Face (itAddedF.Value()); + + // loop on edges of F; find a good neighbor face of F by E + TopExp_Explorer EdgeExp(F, TopAbs_EDGE); + for (; EdgeExp.More(); EdgeExp.Next()){ + const TopoDS_Edge& E = TopoDS::Edge( EdgeExp.Current()); + if (! CheckedEdgesMap.Add( E )) + continue; + + // candidate faces list + const TopTools_ListOfShape& FL = myEFMap.ChangeFromKey(E); + if (FL.IsEmpty()) + continue; + // select one of neighbors + TopoDS_Face SelF; + if (FL.Extent() == 2) { + if (! F.IsSame( FL.First() )) + SelF = TopoDS::Face( FL.First() ); + else if (!F.IsSame( FL.Last() )) + SelF = TopoDS::Face( FL.Last() ); + } + else { + // check if a face already added to Shell shares E + TopTools_ListIteratorOfListOfShape it (FL); + Standard_Boolean found = Standard_False; + for (; !found && it.More(); it.Next()) + if (F != it.Value()) + found = AddedFacesMap.Contains( it.Value() ); + if (found) + continue; + // select basing on geometrical check + Standard_Boolean GoodOri, inside; + Standard_Real dot, MaxDot = -100; + TopTools_ListOfShape TangFL; // tangent faces + for ( it.Initialize( FL ) ; it.More(); it.Next()) { + const TopoDS_Face& NeighborF = TopoDS::Face( it.Value()); + if (NeighborF.IsSame( F )) + continue; + inside = NMTAlgo_Loop3d::IsInside( E, F, NeighborF, 1, dot, GoodOri); + if (!GoodOri) + continue; + if (!inside) + dot = -dot - 3; + if (dot < MaxDot) + continue; + if ( IsEqual( dot, MaxDot)) + TangFL.Append(SelF); + else + TangFL.Clear(); + MaxDot = dot; + SelF = NeighborF; + } + if (!TangFL.IsEmpty()) { + for (it.Initialize( TangFL ); it.More(); it.Next()) { + const TopoDS_Face& NeighborF = TopoDS::Face( it.Value()); + if (NMTAlgo_Loop3d:: IsInside( E, SelF , NeighborF, 0, dot, GoodOri)) + SelF = NeighborF; + } + } + } + if (!SelF.IsNull() && + AddedFacesMap.Add( SelF ) && + !AvoidFacesMap.Contains( SelF )) + Builder.Add( Shell, SelF); + + } // loop on edges of F + + } // loop on the faces added to Shell + + // Shell is complete + myNewShells.Append( Shell ); + + } // loop on myFaces + + + // prepare to the next call + myFaces.Clear(); + myEFMap.Clear(); + + return myNewShells; +} +//======================================================================= +//function : Normal +//purpose : +//======================================================================= + gp_Vec NMTAlgo_Loop3d::Normal(const TopoDS_Edge& E, + const TopoDS_Face& F) +{ + gp_Vec Norm, V1, V2; + Standard_Real First, Last; + gp_Pnt Ps; + + Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface (E, F, First, Last); + Handle(Geom_Surface) Sf = BRep_Tool::Surface(F); + + gp_Pnt2d p = C2d->Value( 0.5*(First+Last) ); + Sf->D1(p.X(), p.Y(), Ps, V1, V2); + Norm = V1.Crossed(V2); + + if (F.Orientation() == TopAbs_REVERSED ) + Norm.Reverse(); + + return Norm; +} +//======================================================================= +//function : IsInside +//purpose : check if is inside by edge . +// if , compute : scalar production of +// normalized vectors pointing inside faces, and +// check if faces are oriented well for sewing +//======================================================================= + Standard_Boolean NMTAlgo_Loop3d::IsInside(const TopoDS_Edge& E, + const TopoDS_Face& F1, + const TopoDS_Face& F2, + const Standard_Boolean CountDot, + Standard_Real& Dot, + Standard_Boolean& GoodOri) +{ + Standard_Real f, l; + gp_Pnt P; + gp_Vec Vc1, Vc2, Vin1, Vin2, Nf1, Nf2; + Handle(Geom_Curve) Curve = BRep_Tool::Curve(E,f,l); + Curve->D1( 0.5*(f + l), P, Vc2); + TopoDS_Edge E1, E2 = FindEinF (E, F2); + if (E2.Orientation() == TopAbs_REVERSED ) Vc2.Reverse(); + + Nf1 = Normal(E,F1); + Nf2 = Normal(E,F2); + + Standard_Real sin = + Nf1.CrossSquareMagnitude(Nf2) / Nf1.SquareMagnitude() / Nf2.SquareMagnitude(); + Standard_Boolean tangent = sin < 0.001; + + Standard_Boolean inside = 0; + if (tangent) { + E1 = FindEinF (E, F1); + gp_Vec NNf1 = NextNormal(E1,F1); + gp_Vec NNf2 = NextNormal(E2,F2); + Vin2 = NNf2.Crossed(Vc2); + inside = Vin2 * NNf1 < 0; + } + else { + Vin2 = Nf2.Crossed(Vc2); + inside = Vin2 * Nf1 < 0; + } + + if (!CountDot) return inside; + + if (tangent) + Vin2 = Nf2.Crossed(Vc2); + else + E1 = FindEinF (E, F1); + + Vc1 = Vc2; + if (E1.Orientation() != E2.Orientation()) + Vc1.Reverse(); + Vin1 = Nf1.Crossed(Vc1); + + if (tangent) { + Standard_Real N1N2 = Nf1 * Nf2; + GoodOri = (Vin2 * Vin1 < 0) ? N1N2 > 0 : N1N2 < 0; + } + else { + Standard_Real V1N2 = Vin1 * Nf2; + GoodOri = ( inside ? V1N2 <= 0 : V1N2 >= 0); + } + + Vin1.Normalize(); + Vin2.Normalize(); + + Dot = Vin2 * Vin1; + + return inside; +} +//======================================================================= +//function : NextNormal +//purpose : find normal to F at point a little inside F near the middle of E +//warning : E must be properly oriented in F. +//======================================================================= +gp_Vec NextNormal(const TopoDS_Edge& E, + const TopoDS_Face& F) +{ + Standard_Real First, Last; + + Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface (E, F, First, Last); + Handle(Geom_Surface) Sf = BRep_Tool::Surface(F); + + gp_Pnt2d p; + gp_Vec2d v; + C2d->D1( 0.5*(First+Last), p, v); + if (E.Orientation() != F.Orientation()) + v.Reverse(); + gp_Dir2d dir( -v.Y(), v.X() ); // dir inside F + + Standard_Real duv = 1e-6; // this is not Ok and may give incorrect result if + // resolutionUV of compared faces is very different. To have a good result, + //it is necessary to get normal to faces at points equidistant from E in 3D + + p.SetX( p.X() + dir.X()*duv ); + p.SetY( p.Y() + dir.Y()*duv ); + + gp_Pnt Ps; + gp_Vec Norm, V1, V2, VV1, VV2; + Sf->D1( p.X(), p.Y(), Ps, V1, V2); + Norm = V1.Crossed(V2); + + if (F.Orientation() == TopAbs_REVERSED ) + Norm.Reverse(); + + return Norm; +} +//======================================================================= +//function : FindEinF +//purpose : find E in F +//======================================================================= +TopoDS_Edge FindEinF(const TopoDS_Edge& E, + const TopoDS_Face& F) +{ + TopExp_Explorer expl (F, TopAbs_EDGE); + for (; expl.More(); expl.Next()) + if( E.IsSame( expl.Current() )) + return TopoDS::Edge(expl.Current()); + TopoDS_Edge nullE; + return nullE; +} diff --git a/src/NMTAlgo/NMTAlgo_Loop3d.hxx b/src/NMTAlgo/NMTAlgo_Loop3d.hxx new file mode 100644 index 000000000..707b3aec4 --- /dev/null +++ b/src/NMTAlgo/NMTAlgo_Loop3d.hxx @@ -0,0 +1,107 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _NMTAlgo_Loop3d_HeaderFile +#define _NMTAlgo_Loop3d_HeaderFile + +#ifndef _TopTools_ListOfShape_HeaderFile +#include +#endif +#ifndef _TopTools_IndexedDataMapOfShapeListOfShape_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +#ifndef _Standard_Real_HeaderFile +#include +#endif +class TopoDS_Shape; +class TopTools_ListOfShape; +class TopTools_MapOfOrientedShape; +class TopoDS_Edge; +class TopoDS_Face; +class gp_Vec; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class NMTAlgo_Loop3d { + +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 NMTAlgo_Loop3d(); +Standard_EXPORT void AddConstFaces(const TopoDS_Shape& S) ; +Standard_EXPORT void AddSectionFaces(const TopoDS_Shape& S) ; +Standard_EXPORT const TopTools_ListOfShape& MakeShells(const TopTools_MapOfOrientedShape& AvoidFacesMap) ; +Standard_EXPORT static Standard_Boolean IsInside(const TopoDS_Edge& E,const TopoDS_Face& F1,const TopoDS_Face& F2,const Standard_Boolean CountDot,Standard_Real& Dot,Standard_Boolean& GoodOri) ; +Standard_EXPORT static gp_Vec Normal(const TopoDS_Edge& E,const TopoDS_Face& F) ; + + + + + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // +TopTools_ListOfShape myNewShells; +TopTools_ListOfShape myFaces; +TopTools_IndexedDataMapOfShapeListOfShape myEFMap; + + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/NMTAlgo/NMTAlgo_Loop3d.ixx b/src/NMTAlgo/NMTAlgo_Loop3d.ixx new file mode 100644 index 000000000..e546fd196 --- /dev/null +++ b/src/NMTAlgo/NMTAlgo_Loop3d.ixx @@ -0,0 +1,19 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include + + + + diff --git a/src/NMTAlgo/NMTAlgo_Loop3d.jxx b/src/NMTAlgo/NMTAlgo_Loop3d.jxx new file mode 100644 index 000000000..f63b0450a --- /dev/null +++ b/src/NMTAlgo/NMTAlgo_Loop3d.jxx @@ -0,0 +1,21 @@ +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif +#ifndef _TopTools_ListOfShape_HeaderFile +#include +#endif +#ifndef _TopTools_MapOfOrientedShape_HeaderFile +#include +#endif +#ifndef _TopoDS_Edge_HeaderFile +#include +#endif +#ifndef _TopoDS_Face_HeaderFile +#include +#endif +#ifndef _gp_Vec_HeaderFile +#include +#endif +#ifndef _NMTAlgo_Loop3d_HeaderFile +#include +#endif diff --git a/src/NMTAlgo/NMTAlgo_Splitter.cdl b/src/NMTAlgo/NMTAlgo_Splitter.cdl new file mode 100644 index 000000000..761c051f3 --- /dev/null +++ b/src/NMTAlgo/NMTAlgo_Splitter.cdl @@ -0,0 +1,170 @@ +-- File: NMTAlgo_Splitter.cdl +-- Created: Tue Jan 27 15:09:45 2004 +-- Author: Peter KURNEV +-- +---Copyright: Matra Datavision 2004 + + +class Splitter from NMTAlgo + inherits Builder from NMTAlgo + + ---Purpose: + +uses + Builder from BRep, + ShapeEnum from TopAbs, + Compound from TopoDS, + Face from TopoDS, + Edge from TopoDS, + Shape from TopoDS, + MapOfOrientedShape from TopTools, + IndexedMapOfShape from TopTools, + DataMapOfShapeShape from TopTools, + ListOfShape from TopTools, + MapOfShape from TopTools, + AsDes from BRepAlgo, + Image from BRepAlgo, + + DSFiller from NMTTools + +--raises + +is + Create + returns Splitter from NMTAlgo; + ---C++: alias "Standard_EXPORT virtual ~NMTAlgo_Splitter();" + + AddShape (me:out; + S : Shape from TopoDS) + is virtual; + + AddTool (me:out; + S : Shape from TopoDS) + is virtual; + + Compute(me:out) + is virtual; + + Build (me:out; + aLimit:ShapeEnum from TopAbs=TopAbs_SHAPE) + is virtual; + + ComputeWithFiller(me:out; + aDSF: DSFiller from NMTTools) + is redefined; + +----vv + KeepShapesInside (me:out; + S : Shape from TopoDS); + ---Purpose: remove shapes that are outside of S from result. + -- S should be an object shape. + ---Warning: call it after Build() + + RemoveShapesInside (me:out; + S : Shape from TopoDS); + ---Purpose: remove shapes that are inside S from result. + -- S should be an object shape. + ---Warning: call it after Build() + + Modified(me:out; + S : Shape from TopoDS) + returns ListOfShape from TopTools; + ---Purpose: Returns the list of shapes modified from the shape . + ---C++: return const & + ---Level: Public + + Generated(me:out; + S : Shape from TopoDS) + returns ListOfShape from TopTools; + ---Purpose: Returns the list of shapes generated from the shape . + ---C++: return const & + ---Level: Public + + IsDeleted (me:out; + S : Shape from TopoDS) + returns Boolean from Standard; +----^^ + + Clear (me:out) + is redefined; + + SourceShapes(me) + returns ListOfShape from TopTools; + ---C++: return const & + + FillResult(me:out) + is protected; + + FillImageShape(me:out) + is protected; + + SplittedFaces (me:out) + is protected; + + SplittedWires (me:out) + is protected; + + SplitsAndSections (me:out) + is protected; + + ShellsAndSolids(me:out) + is protected; + + MakeShells(me:out; + aS :Shape from TopoDS; + aLNS:out ListOfShape from TopTools) + is protected; + + MakeSolids (me:out; + Solid : Shape from TopoDS; + Shells: out ListOfShape from TopTools) + is protected; + + FindFacesInside (me:out; + S : Shape from TopoDS; + CheckClosed : Boolean from Standard= Standard_False; + All : Boolean from Standard= Standard_False) + returns Shape from TopoDS + is protected; + + IsInside (myclass; + S1,S2 : Shape from TopoDS) + returns Boolean from Standard is protected; + ---Purpose: Return True if the first vertex of S1 inside S2. + -- If S1.IsNull(), check infinite point against S2. + + GetOriginalShape(me; + aShape : Shape from TopoDS) + returns Shape from TopoDS + is protected; + +fields + myDoneStep : ShapeEnum from TopAbs is protected; -- rebuilt level + myBuilder : Builder from BRep is protected; + + myListShapes : ListOfShape from TopTools is protected; -- object shapes + myMapFaces : MapOfShape from TopTools is protected; -- object faces + myMapTools : MapOfShape from TopTools is protected; -- tool faces + myEqualEdges : MapOfShape from TopTools is protected; -- equal splits + myNewSection : MapOfShape from TopTools is protected; -- new secton edges + myClosedShapes : MapOfShape from TopTools is protected; + myWrappingSolid: MapOfShape from TopTools is protected; -- solids having other shapes inside + myFaceShapeMap : DataMapOfShapeShape from TopTools is protected; -- to find a shape by face + + myInternalFaces: DataMapOfShapeShape from TopTools is protected; -- shape and its internal faces + myIntNotClFaces: DataMapOfShapeShape from TopTools is protected; -- internal but not closed + + myImageShape : Image from BRepAlgo is protected; + + -- avoid rebuilding twice commont part of solids + myAddedFacesMap: MapOfOrientedShape from TopTools is protected; + --***-- + mySourceShapes : ListOfShape from TopTools is protected; + myLimit : ShapeEnum from TopAbs is protected; + myToolShapes : MapOfShape from TopTools is protected; + myObjShapes : MapOfShape from TopTools is protected; + myMapSIFC : DataMapOfShapeShape from TopTools is protected; +----vv + myGenerated : ListOfShape from TopTools is protected; +----^^ +end Splitter; diff --git a/src/NMTAlgo/NMTAlgo_Splitter.cxx b/src/NMTAlgo/NMTAlgo_Splitter.cxx new file mode 100644 index 000000000..83b82b84d --- /dev/null +++ b/src/NMTAlgo/NMTAlgo_Splitter.cxx @@ -0,0 +1,573 @@ +// File: NMTAlgo_Splitter.cxx +// Created: Thu Jan 29 17:13:03 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 +#include + +#include +#include +#include +#include + +#include +#include +#include +// +#include +#include +#include +#include + + +static + Standard_Boolean isClosed(const TopoDS_Shape& theShape); + +//======================================================================= +//function : NMTAlgo_Spliter::NMTAlgo_Splitter +//purpose : +//======================================================================= + NMTAlgo_Splitter::NMTAlgo_Splitter() +: + NMTAlgo_Builder() +{ + myErrorStatus=0; +} +//======================================================================= +// function: ~NMTAlgo_Splitter +// purpose: +//======================================================================= + NMTAlgo_Splitter::~NMTAlgo_Splitter() +{ + Clear(); + + if (myDSFiller){ + delete myDSFiller; + } +} +//======================================================================= +// function: SourceShapes +// purpose: +//======================================================================= + const TopTools_ListOfShape& NMTAlgo_Splitter::SourceShapes()const +{ + return mySourceShapes; +} +//======================================================================= +//function : Clear +//purpose : +//======================================================================= + void NMTAlgo_Splitter::Clear() +{ + NMTAlgo_Builder::Clear(); + // + myListShapes.Clear(); + myMapFaces.Clear(); + myMapTools.Clear(); + myClosedShapes.Clear(); + myEqualEdges.Clear(); + myNewSection.Clear(); + myWrappingSolid.Clear(); + myFaceShapeMap.Clear(); + myInternalFaces.Clear(); + myIntNotClFaces.Clear(); + // + myImageShape.Clear(); + myAddedFacesMap.Clear(); + // + myDoneStep = TopAbs_SHAPE; + myIsComputed=Standard_False; + mySourceShapes.Clear(); + myObjShapes.Clear(); + myToolShapes.Clear(); + myMapSIFC.Clear(); + myErrorStatus=0; +} +//======================================================================= +//function : AddShape +//purpose : add object Shape to be splited +//======================================================================= + void NMTAlgo_Splitter::AddShape(const TopoDS_Shape& aS) +{ + myErrorStatus=0; + if (myIsComputed) { + // DS is already computed + myErrorStatus=100; + return; + } + // + if (aS.IsNull()){ + // Null shape is not allowed here + myErrorStatus=101; + return; + } + // + TopAbs_ShapeEnum aType=aS.ShapeType(); + // + if (aType < TopAbs_SOLID) { + // compound or compsolid + TopoDS_Iterator it (aS); + for (; it.More(); it.Next()) { + const TopoDS_Shape& aSS=it.Value(); + AddShape(aSS); + // to know compound by shape + myFaceShapeMap.Bind(aSS, aS); + } + return; + } + //--- + myObjShapes.Add(aS); + mySourceShapes.Append(aS); + //--- + // + TopExp_Explorer exp(aS, TopAbs_FACE); + if (!exp.More()) { + // do not split edges and vertices + return; + } + // not to add twice the same S + Standard_Integer nbFacesBefore = myMapFaces.Extent(); + // + for (; exp.More(); exp.Next()) { + const TopoDS_Shape& aFace = exp.Current(); + if (!myFaceShapeMap.IsBound(aFace)) { + // keep shape of tool face added as object + myFaceShapeMap.Bind(aFace, aS); + } + if (myMapFaces.Add(aFace)){ + myImagesFaces.SetRoot(aFace); + } + } + // + if (nbFacesBefore == myMapFaces.Extent()){ + return; + } + // solids must be processed before all + if (aType==TopAbs_SOLID){ + myListShapes.Prepend(aS); + } + else{ + myListShapes.Append(aS); + } + if (isClosed(aS)){ + myClosedShapes.Add(aS); + } +} +//======================================================================= +//function : AddTool +//purpose : add cutting tool that will _NOT_ be in result +//======================================================================= + void NMTAlgo_Splitter::AddTool(const TopoDS_Shape& aS) +{ + myErrorStatus=0; + if (myIsComputed) { + // DS is already computed + myErrorStatus=100; + return; + } + // + if (aS.IsNull()){ + // Null shape is not allowed here + myErrorStatus=101; + return; + } + // + TopAbs_ShapeEnum aType=aS.ShapeType(); + + if (aType < TopAbs_SOLID) { // compound or compsolid + TopoDS_Iterator it (aS); + for (; it.More(); it.Next()) { + const TopoDS_Shape& aSS=it.Value(); + AddTool(aSS); + myFaceShapeMap.Bind(aSS, aS); // to know compound by shape + } + return; + } + //--- + myToolShapes.Add(aS); + mySourceShapes.Append(aS); + //--- + // + TopExp_Explorer exp(aS, TopAbs_FACE); + for (; exp.More(); exp.Next()) { + const TopoDS_Shape& aFace = exp.Current(); + myMapTools.Add(aFace); + myFaceShapeMap.Bind(aFace, aS); + } + // + // solids must be processed before all + if (aType==TopAbs_SOLID){ + myListShapes.Prepend(aS); + } + else{ + myListShapes.Append(aS); + } + // + if (isClosed(aS)) { + myClosedShapes.Add(aS); + } +} +//======================================================================= +// function: Compute +// purpose: +//======================================================================= + void NMTAlgo_Splitter::Compute() +{ + if (!mySourceShapes.Extent()){ + // No source shapes to treat + myErrorStatus=103; + return; + } + // + BRep_Builder aBB; + TopoDS_Compound aCS; + TopTools_ListIteratorOfListOfShape aIt; + // + aBB.MakeCompound(aCS); + // + aIt.Initialize(mySourceShapes); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aS=aIt.Value(); + aBB.Add(aCS, aS); + } + // + NMTTools_DSFiller* pDSF=new NMTTools_DSFiller; + // + pDSF->SetCompositeShape(aCS); + pDSF->Perform(); + // + myIsComputed=Standard_False; + // + NMTAlgo_Splitter::ComputeWithFiller(*pDSF); +} +//======================================================================= +// function: ComputeWithFiller +// purpose: +//======================================================================= + void NMTAlgo_Splitter::ComputeWithFiller(const NMTTools_DSFiller& aDSF) +{ + myErrorStatus=0; + // + if (myIsComputed) { + // DS is already computed + myErrorStatus=100; + return; + } + // + if (!mySourceShapes.Extent()){ + // No source shapes to treat + myErrorStatus=103; + return; + } + // + NMTAlgo_Builder::ComputeWithFiller(aDSF); + // + myIsComputed=Standard_True; +} +//======================================================================= +//function : Build +//purpose : +//======================================================================= + void NMTAlgo_Splitter::Build(const TopAbs_ShapeEnum aLimit) +{ + myErrorStatus=0; + myLimit=aLimit; + // + if (!myIsComputed){ + myErrorStatus=102;// DS is not computed + return; + } + // + TopoDS_Compound aCShape; + // + myBuilder.MakeCompound(aCShape); + myShape=aCShape; + // + // 1. VERTEX + // + if (myLimit==TopAbs_VERTEX) { + SplitVertices(); + FillResult(); + return; + } + // + // 2. EDGE + if (myLimit==TopAbs_EDGE) { + SplitsAndSections(); + FillResult(); + return; + } + // + // 3. WIRE + FillImageShape(); + // + if (myLimit==TopAbs_WIRE) { + SplittedWires(); + FillResult(); + return; + } + // + // 4. FACE + // + if (myLimit==TopAbs_FACE) { + SplittedFaces(); + FillResult(); + return; + } + // + // 5.6. SHELL / SOLID + ShellsAndSolids(); + BOP_CorrectTolerances::CorrectTolerances(myShape, 0.01); +} +//======================================================================= +// function: SplitsAndSections +// purpose: +//======================================================================= + void NMTAlgo_Splitter::SplitsAndSections() +{ + Standard_Integer i, aNbE, aNbF; + TopTools_ListIteratorOfListOfShape aItLS, aIt; + TopTools_IndexedMapOfShape aME, aMF; + // + myQueryShapes.Clear(); + // + // 1. Splits / no splits + aItLS.Initialize(myListShapes); + for ( ;aItLS.More(); aItLS.Next()) { + const TopoDS_Shape& aS=aItLS.Value(); + // + if (myToolShapes.Contains(aS)) { + continue; // skip tool Shapes + } + // + TopExp::MapShapes(aS, TopAbs_EDGE, aME); + TopExp::MapShapes(aS, TopAbs_FACE, aMF); + } + // + // 1. Splits / no splits + aNbE=aME.Extent(); + for (i=1; i<=aNbE; ++i) { + const TopoDS_Shape& aE=aME(i); + // + if (!myImagesEdges.HasImage(aE)) { + myQueryShapes.Add(aE); + } + else { + const TopTools_ListOfShape& aLSp=myImagesEdges.Image(aE); + // + aIt.Initialize(aLSp); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aSp=aIt.Value(); + myQueryShapes.Add(aSp); + } + } + } + // + // 2. Sections + aNbF=aMF.Extent(); + for (i=1; i<=aNbF; ++i) { + const TopoDS_Shape& aF=aMF(i); + if (mySectionParts.Contains(aF)) { + const TopTools_ListOfShape& aLSc=mySectionParts.FindFromKey(aF); + aIt.Initialize(aLSc); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aSc=aIt.Value(); + myQueryShapes.Add(aSc); + } + } + } +} +//======================================================================= +// function: SplittedWires +// purpose: +//======================================================================= + void NMTAlgo_Splitter::SplittedWires() +{ + Standard_Integer i, aNbF; + TopoDS_Iterator aIt; + TopTools_IndexedMapOfShape aMF; + // + SplittedFaces(); + // + aMF=myQueryShapes; + myQueryShapes.Clear(); + // + aNbF=aMF.Extent(); + for (i=1; i<=aNbF; ++i) { + const TopoDS_Shape& aF=aMF(i); + aIt.Initialize(aF); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aW=aIt.Value(); + myQueryShapes.Add(aW); + } + } +} +//======================================================================= +// function: SplittedFaces +// purpose: +//======================================================================= + void NMTAlgo_Splitter::SplittedFaces() +{ + TopTools_ListIteratorOfListOfShape aIt; + TopoDS_Iterator aItF; + // + myQueryShapes.Clear(); + // + aIt.Initialize(myListShapes); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aS=aIt.Value(); + // + if (myToolShapes.Contains(aS)) { + continue; + } + // + const TopoDS_Shape& aFC = myImageShape.Image(aS).First(); + aItF.Initialize(aFC); + for (; aItF.More(); aItF.Next()) { + const TopoDS_Shape& aF=aItF.Value(); + myQueryShapes.Add(aF); + } + } +} +//======================================================================= +//function : FillImageShape +//purpose : +//======================================================================= + void NMTAlgo_Splitter::FillImageShape() +{ + Standard_Integer i, aNbF, iSense; + TopTools_ListIteratorOfListOfShape aItS, aItFI; + TopExp_Explorer aExp; + TopAbs_Orientation aOriFS; + TopoDS_Face aFIx; + BRep_Builder aBB; + // + myImageShape.Clear(); + // + aItS.Initialize(myListShapes); + for ( ;aItS.More(); aItS.Next()) { + const TopoDS_Shape& aS=aItS.Value(); + // + myQueryShapes.Clear(); + // + aExp.Init(aS, TopAbs_FACE); + for (; aExp.More(); aExp.Next()) { + const TopoDS_Face& aFS=TopoDS::Face(aExp.Current()); + aOriFS= aFS.Orientation(); + // + if (!myImagesFaces.HasImage(aFS)) { + myQueryShapes.Add(aFS); + continue; + } + // + const TopTools_ListOfShape& aLFI=myImagesFaces.Image(aFS); + aItFI.Initialize(aLFI); + for (; aItFI.More(); aItFI.Next()) { + const TopoDS_Face& aFI=TopoDS::Face(aItFI.Value()); + aFIx=aFI; + aFIx.Orientation(aOriFS); + // + if (mySDFaces.Contains(aFIx)) { + const TopoDS_Face& aFSDI=TopoDS::Face(mySDFaces.FindFromKey(aFIx)); + TopoDS_Face aFSDIx=aFSDI; + // + iSense=NMTAlgo_Tools::Sense(aFIx, aFSDIx); + // + if (iSense < 0) { + aFSDIx.Reverse(); + } + myQueryShapes.Add(aFSDIx); + } + else { + myQueryShapes.Add(aFIx); + } + } + }//for (; aExp.More(); aExp.Next()) { + // + TopoDS_Compound aCompound; + // + aBB.MakeCompound(aCompound); + // + aNbF=myQueryShapes.Extent(); + for (i=1; i<=aNbF; ++i) { + const TopoDS_Shape& aF=myQueryShapes(i); + aBB.Add(aCompound, aF); + } + // + myImageShape.Bind(aS, aCompound); + }// for ( ;aItS.More(); aItS.Next()) + // + myQueryShapes.Clear(); +} +//======================================================================= +//function : FillResult +//purpose : +//======================================================================= + void NMTAlgo_Splitter::FillResult() +{ + Standard_Integer i, aNb; + // + aNb=myQueryShapes.Extent(); + for (i=1; i<=aNb; ++i) { + const TopoDS_Shape& aS=myQueryShapes(i); + myBuilder.Add (myShape, aS); + } + BOP_CorrectTolerances::CorrectTolerances(myShape, 0.01); +} +//======================================================================= +//function : isClosed +//purpose : check id a shape is closed, ie is a solid or a closed shell +//======================================================================= + Standard_Boolean isClosed(const TopoDS_Shape& theShape) +{ + Standard_Boolean isClosed = (theShape.ShapeType() == TopAbs_SOLID); + // + if (!isClosed && theShape.ShapeType() == TopAbs_SHELL) { + TopTools_IndexedDataMapOfShapeListOfShape MEF; + TopExp::MapShapesAndAncestors(theShape, TopAbs_EDGE, TopAbs_FACE, MEF); + for (Standard_Integer i=1; isClosed && i<=MEF.Extent(); ++i) + isClosed = ( MEF(i).Extent() != 1 ); + } + // + return isClosed; +} +// +// myErrorStatus +// +// 100 - DS is already computed +// 101 - Null shape is not allowed here +// 102 - DS is not computed +// 103 - No source shapes to treat diff --git a/src/NMTAlgo/NMTAlgo_Splitter.hxx b/src/NMTAlgo/NMTAlgo_Splitter.hxx new file mode 100644 index 000000000..0609ad516 --- /dev/null +++ b/src/NMTAlgo/NMTAlgo_Splitter.hxx @@ -0,0 +1,155 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _NMTAlgo_Splitter_HeaderFile +#define _NMTAlgo_Splitter_HeaderFile + +#ifndef _TopAbs_ShapeEnum_HeaderFile +#include +#endif +#ifndef _BRep_Builder_HeaderFile +#include +#endif +#ifndef _TopTools_ListOfShape_HeaderFile +#include +#endif +#ifndef _TopTools_MapOfShape_HeaderFile +#include +#endif +#ifndef _TopTools_DataMapOfShapeShape_HeaderFile +#include +#endif +#ifndef _BRepAlgo_Image_HeaderFile +#include +#endif +#ifndef _TopTools_MapOfOrientedShape_HeaderFile +#include +#endif +#ifndef _NMTAlgo_Builder_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +class TopoDS_Shape; +class NMTTools_DSFiller; +class TopTools_ListOfShape; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class NMTAlgo_Splitter : public NMTAlgo_Builder { + +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 NMTAlgo_Splitter(); +Standard_EXPORT virtual ~NMTAlgo_Splitter(); +Standard_EXPORT virtual void AddShape(const TopoDS_Shape& S) ; +Standard_EXPORT virtual void AddTool(const TopoDS_Shape& S) ; +Standard_EXPORT virtual void Compute() ; +Standard_EXPORT virtual void Build(const TopAbs_ShapeEnum aLimit = TopAbs_SHAPE) ; +Standard_EXPORT virtual void ComputeWithFiller(const NMTTools_DSFiller& aDSF) ; +Standard_EXPORT void KeepShapesInside(const TopoDS_Shape& S) ; +Standard_EXPORT void RemoveShapesInside(const TopoDS_Shape& S) ; +Standard_EXPORT const TopTools_ListOfShape& Modified(const TopoDS_Shape& S) ; +Standard_EXPORT const TopTools_ListOfShape& Generated(const TopoDS_Shape& S) ; +Standard_EXPORT Standard_Boolean IsDeleted(const TopoDS_Shape& S) ; +Standard_EXPORT virtual void Clear() ; +Standard_EXPORT const TopTools_ListOfShape& SourceShapes() const; + + + + + +protected: + + // Methods PROTECTED + // +Standard_EXPORT void FillResult() ; +Standard_EXPORT void FillImageShape() ; +Standard_EXPORT void SplittedFaces() ; +Standard_EXPORT void SplittedWires() ; +Standard_EXPORT void SplitsAndSections() ; +Standard_EXPORT void ShellsAndSolids() ; +Standard_EXPORT void MakeShells(const TopoDS_Shape& aS,TopTools_ListOfShape& aLNS) ; +Standard_EXPORT void MakeSolids(const TopoDS_Shape& Solid,TopTools_ListOfShape& Shells) ; +Standard_EXPORT TopoDS_Shape FindFacesInside(const TopoDS_Shape& S,const Standard_Boolean CheckClosed = Standard_False,const Standard_Boolean All = Standard_False) ; +Standard_EXPORT static Standard_Boolean IsInside(const TopoDS_Shape& S1,const TopoDS_Shape& S2) ; +Standard_EXPORT TopoDS_Shape GetOriginalShape(const TopoDS_Shape& aShape) const; + + + // Fields PROTECTED + // +TopAbs_ShapeEnum myDoneStep; +BRep_Builder myBuilder; +TopTools_ListOfShape myListShapes; +TopTools_MapOfShape myMapFaces; +TopTools_MapOfShape myMapTools; +TopTools_MapOfShape myEqualEdges; +TopTools_MapOfShape myNewSection; +TopTools_MapOfShape myClosedShapes; +TopTools_MapOfShape myWrappingSolid; +TopTools_DataMapOfShapeShape myFaceShapeMap; +TopTools_DataMapOfShapeShape myInternalFaces; +TopTools_DataMapOfShapeShape myIntNotClFaces; +BRepAlgo_Image myImageShape; +TopTools_MapOfOrientedShape myAddedFacesMap; +TopTools_ListOfShape mySourceShapes; +TopAbs_ShapeEnum myLimit; +TopTools_MapOfShape myToolShapes; +TopTools_MapOfShape myObjShapes; +TopTools_DataMapOfShapeShape myMapSIFC; +TopTools_ListOfShape myGenerated; + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // + + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/NMTAlgo/NMTAlgo_Splitter.ixx b/src/NMTAlgo/NMTAlgo_Splitter.ixx new file mode 100644 index 000000000..fdec89e46 --- /dev/null +++ b/src/NMTAlgo/NMTAlgo_Splitter.ixx @@ -0,0 +1,19 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include + + + + diff --git a/src/NMTAlgo/NMTAlgo_Splitter.jxx b/src/NMTAlgo/NMTAlgo_Splitter.jxx new file mode 100644 index 000000000..e27984c18 --- /dev/null +++ b/src/NMTAlgo/NMTAlgo_Splitter.jxx @@ -0,0 +1,12 @@ +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif +#ifndef _NMTTools_DSFiller_HeaderFile +#include +#endif +#ifndef _TopTools_ListOfShape_HeaderFile +#include +#endif +#ifndef _NMTAlgo_Splitter_HeaderFile +#include +#endif diff --git a/src/NMTAlgo/NMTAlgo_Splitter1.cdl b/src/NMTAlgo/NMTAlgo_Splitter1.cdl new file mode 100644 index 000000000..eafb3127c --- /dev/null +++ b/src/NMTAlgo/NMTAlgo_Splitter1.cdl @@ -0,0 +1,73 @@ +-- File: NMTAlgo_Splitter1.cdl +-- Created: Wed Feb 11 14:23:25 2004 +-- Author: Peter KURNEV +-- +---Copyright: Matra Datavision 2004 + + +class Splitter1 from NMTAlgo + inherits Splitter from NMTAlgo + + ---Purpose: + +uses + ShapeEnum from TopAbs, + Shape from TopoDS, + DataMapOfShapeInteger from TopTools + +--raises + +is + Create + returns Splitter1 from NMTAlgo; + ---C++: alias "Standard_EXPORT virtual ~NMTAlgo_Splitter1();" + + Clear (me:out) + is redefined; + + AddShape (me:out; + aS : Shape from TopoDS) + is redefined; + + + AddTool(me:out; + aS : Shape from TopoDS) + is redefined; + + + SetMaterial (me:out; + aS : Shape from TopoDS; + aM : Integer from Standard=0); + + SetRemoveWebs(me:out; + bFlag:Boolean from Standard); + + RemoveWebs(me) + returns Boolean from Standard; + + GetMaterialTable(me) + returns DataMapOfShapeInteger from TopTools; + ---C++: return const & + + Build (me:out; + Limit:ShapeEnum from TopAbs=TopAbs_SHAPE) + is redefined; + + -- protected block + TreatSolids (me:out) + is protected; + + TreatWebs (me:out) + is protected; + + RestParts (me:out) + is protected; + + +fields + myRemoveWebs : Boolean from Standard is protected; + myMapSWM : DataMapOfShapeInteger from TopTools is protected; + myMapSWMOut : DataMapOfShapeInteger from TopTools is protected; + myRestParts : Shape from TopoDS is protected; + +end Splitter1; diff --git a/src/NMTAlgo/NMTAlgo_Splitter1.cxx b/src/NMTAlgo/NMTAlgo_Splitter1.cxx new file mode 100644 index 000000000..260ac90ec --- /dev/null +++ b/src/NMTAlgo/NMTAlgo_Splitter1.cxx @@ -0,0 +1,348 @@ +// File: NMTAlgo_Splitter1.cxx +// Created: Wed Feb 11 14:26:27 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 + +//======================================================================= +//function : NMTAlgo_Spliter1::NMTAlgo_Splitter1 +//purpose : +//======================================================================= + NMTAlgo_Splitter1::NMTAlgo_Splitter1() +: + NMTAlgo_Splitter() +{ + myRemoveWebs=Standard_False; +} +//======================================================================= +// function: ~NMTAlgo_Splitter1 +// purpose: +//======================================================================= + NMTAlgo_Splitter1::~NMTAlgo_Splitter1() +{ + Clear(); +} +//======================================================================= +//function : Clear +//purpose : +//======================================================================= + void NMTAlgo_Splitter1::Clear() +{ + NMTAlgo_Splitter::Clear(); + // + myRemoveWebs=Standard_False; + myMapSWM.Clear(); + myMapSWMOut.Clear(); +} +//======================================================================= +//function : SetRemoveWebs +//purpose : +//======================================================================= + void NMTAlgo_Splitter1::SetRemoveWebs(const Standard_Boolean bFlag) +{ + myRemoveWebs=bFlag; +} +//======================================================================= +//function : RemoveWebs +//purpose : +//======================================================================= + Standard_Boolean NMTAlgo_Splitter1::RemoveWebs()const +{ + return myRemoveWebs; +} +//======================================================================= +//function : GetMaterialTable +//purpose : +//======================================================================= + const TopTools_DataMapOfShapeInteger& NMTAlgo_Splitter1::GetMaterialTable()const +{ + return myMapSWMOut; +} +//======================================================================= +//function : SetMaterial +//purpose : +//======================================================================= + void NMTAlgo_Splitter1::SetMaterial(const TopoDS_Shape& aS, + const Standard_Integer iMt) +{ + TopExp_Explorer aExp; + // + aExp.Init(aS, TopAbs_SOLID); + for(; aExp.More(); aExp.Next()) { + const TopoDS_Shape& aSd=aExp.Current(); + myMapSWM.Bind(aSd, iMt); + } +} +//======================================================================= +//function : AddShape +//purpose : +//======================================================================= + void NMTAlgo_Splitter1::AddShape(const TopoDS_Shape& aS) +{ + SetMaterial(aS, 0); + NMTAlgo_Splitter::AddShape(aS); +} +//======================================================================= +//function : AddToolWithMaterial +//purpose : +//======================================================================= + void NMTAlgo_Splitter1::AddTool(const TopoDS_Shape& aS) + +{ + SetMaterial(aS, 0); + NMTAlgo_Splitter::AddTool(aS); +} +//======================================================================= +//function : Build +//purpose : +//======================================================================= + void NMTAlgo_Splitter1::Build(const TopAbs_ShapeEnum aLimit) +{ + NMTAlgo_Splitter::Build(aLimit); + // + myMapSWMOut.Clear(); + // + TreatSolids(); + // + if (myRemoveWebs && myMapSWMOut.Extent()) { + RestParts(); + TreatWebs(); + } +} +//======================================================================= +//function : TreatWebs +//purpose : +//======================================================================= + void NMTAlgo_Splitter1::TreatWebs() +{ + Standard_Integer nMt; + TopTools_DataMapOfIntegerListOfShape aMMLS; + TopoDS_Iterator aIt; + TopTools_DataMapIteratorOfDataMapOfShapeInteger aIt2; + TopTools_DataMapIteratorOfDataMapOfIntegerListOfShape aIt1; + TopTools_ListIteratorOfListOfShape aItS; + TopoDS_Compound aCx; + TopoDS_Shape aCSR; + // + aIt2.Initialize(myMapSWMOut); + for (; aIt2.More(); aIt2.Next()) { + const TopoDS_Shape& aS=aIt2.Key(); + nMt=aIt2.Value(); + // + if (aMMLS.IsBound(nMt)){ + TopTools_ListOfShape& aLS=aMMLS.ChangeFind(nMt); + aLS.Append(aS); + } + else { + TopTools_ListOfShape aLS; + aLS.Append(aS); + aMMLS.Bind(nMt, aLS); + } + } + // + myMapSWMOut.Clear(); + myBuilder.MakeCompound(aCx); + // + aIt1.Initialize(aMMLS); + for (; aIt1.More(); aIt1.Next()) { + nMt=aIt1.Key(); + // + TopoDS_Compound aCS; + myBuilder.MakeCompound(aCS); + const TopTools_ListOfShape& aLS=aIt1.Value(); + aItS.Initialize(aLS); + for (; aItS.More(); aItS.Next()) { + const TopoDS_Shape& aS=aItS.Value(); + myBuilder.Add(aCS, aS); + } + // + NMTAlgo_Tools::BreakWebs(aCS, aCSR); + // + aIt.Initialize(aCSR); + for(; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aS=aIt.Value(); + myBuilder.Add(aCx, aS); + // + myMapSWMOut.Bind(aS, nMt); + } + } + // + aIt.Initialize(myRestParts); + for(; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aS=aIt.Value(); + myBuilder.Add(aCx, aS); + } + // + myShape=aCx; +} + +//======================================================================= +//function : RestParts +//purpose : +//======================================================================= + void NMTAlgo_Splitter1::RestParts() +{ + TopoDS_Iterator aIt; + TopoDS_Compound aR; + // + myBuilder.MakeCompound(aR); + // + aIt.Initialize(myShape); + for(; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aS=aIt.Value(); + if (aS.ShapeType()==TopAbs_SOLID){ + if (myMapSWMOut.IsBound(aS)) { + continue; + } + } + myBuilder.Add(aR, aS); + } + myRestParts=aR; +} +//======================================================================= +//function : TreatSolids +//purpose : +//======================================================================= + void NMTAlgo_Splitter1::TreatSolids() +{ + Standard_Integer i, j, aNbSd, aNbSdx, nMtMax, nMt; + TopAbs_ShapeEnum aType; + TopoDS_Iterator aIt; + TopTools_IndexedMapOfShape aMSo, aMSd; + TopTools_IndexedDataMapOfShapeListOfShape aMFS; + TopTools_ListIteratorOfListOfShape aItS, aItLS; + NMTTools_IndexedDataMapOfShapeIndexedMapOfShape aMCS; + // + TopExp::MapShapesAndAncestors(myShape, TopAbs_FACE, TopAbs_SOLID, aMFS); + TopExp::MapShapes(myShape, TopAbs_SOLID, aMSo); + // + aNbSd=aMSo.Extent(); + if (!aNbSd) { + return; + } + // + aItS.Initialize(myListShapes); + for ( ;aItS.More(); aItS.Next()) { + const TopoDS_Shape& aS=aItS.Value(); + // + aType=aS.ShapeType(); + if (aType != TopAbs_SOLID) { + continue; + } + // + if (myToolShapes.Contains(aS)) { + continue; + } + // + if (!myMapSIFC.IsBound(aS)){ + continue; + } + // + aMSd.Clear(); + // + const TopoDS_Shape& aIFC=myMapSIFC.Find(aS); + // + aIt.Initialize(aIFC); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aIF=aIt.Value(); + if (aMFS.Contains(aIF)) { + const TopTools_ListOfShape& aLS=aMFS.FindFromKey(aIF); + aItLS.Initialize(aLS); + for ( ;aItLS.More(); aItLS.Next()) { + const TopoDS_Shape& aSd=aItLS.Value(); + if (!aMSd.Contains(aSd)) { + aMSd.Add(aSd); + } + } + } + } + // + aNbSd=aMSd.Extent(); + if (!aNbSd) { + TopoDS_Shape aSd; + // + const TopoDS_Shape& aFC=myImageShape.Image(aS).First(); + NMTAlgo_Tools::FindImageSolid(aFC, aMSo, aSd); + // + aMSd.Add(aSd); + } + aMCS.Add(aS, aMSd); + } //for ( ;aItS.More(); aItS.Next()) + // + aMFS.Clear(); + // + aNbSd=aMCS.Extent(); + for (i=1; i<=aNbSd; ++i) { + const TopoDS_Shape& aSd=aMCS.FindKey(i); + const TopTools_IndexedMapOfShape& aMSdx=aMCS(i); + aNbSdx=aMSdx.Extent(); + for (j=1; j<=aNbSdx; ++j) { + const TopoDS_Shape& aSdx=aMSdx(j); + // + if (aMFS.Contains(aSdx)) { + TopTools_ListOfShape& aLS=aMFS.ChangeFromKey(aSdx); + aLS.Append(aSd); + } + else { + TopTools_ListOfShape aLS; + aLS.Append(aSd); + aMFS.Add(aSdx, aLS); + } + } + } + // + // Assign materials values to subsolids + // + myMapSWMOut.Clear(); + // + aNbSdx=aMFS.Extent(); + for (i=1; i<=aNbSdx; ++i) { + const TopoDS_Shape& aSdx=aMFS.FindKey(i); + const TopTools_ListOfShape& aLS=aMFS(i); + aItLS.Initialize(aLS); + for (j=0; aItLS.More(); aItLS.Next(), ++j) { + const TopoDS_Shape& aSd=aItLS.Value(); + // + if (!myMapSWM.IsBound(aSd)){ + continue; + } + // + nMt=myMapSWM.Find(aSd); + if (!j) { + nMtMax=nMt; + continue; + } + if (nMt>nMtMax) { + nMtMax=nMt; + } + } + myMapSWMOut.Bind(aSdx, nMtMax); + } + // +} diff --git a/src/NMTAlgo/NMTAlgo_Splitter1.hxx b/src/NMTAlgo/NMTAlgo_Splitter1.hxx new file mode 100644 index 000000000..1948d3508 --- /dev/null +++ b/src/NMTAlgo/NMTAlgo_Splitter1.hxx @@ -0,0 +1,117 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _NMTAlgo_Splitter1_HeaderFile +#define _NMTAlgo_Splitter1_HeaderFile + +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +#ifndef _TopTools_DataMapOfShapeInteger_HeaderFile +#include +#endif +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif +#ifndef _NMTAlgo_Splitter_HeaderFile +#include +#endif +#ifndef _Standard_Integer_HeaderFile +#include +#endif +#ifndef _TopAbs_ShapeEnum_HeaderFile +#include +#endif +class TopoDS_Shape; +class TopTools_DataMapOfShapeInteger; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class NMTAlgo_Splitter1 : public NMTAlgo_Splitter { + +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 NMTAlgo_Splitter1(); +Standard_EXPORT virtual ~NMTAlgo_Splitter1(); +Standard_EXPORT virtual void Clear() ; +Standard_EXPORT virtual void AddShape(const TopoDS_Shape& aS) ; +Standard_EXPORT virtual void AddTool(const TopoDS_Shape& aS) ; +Standard_EXPORT void SetMaterial(const TopoDS_Shape& aS,const Standard_Integer aM = 0) ; +Standard_EXPORT void SetRemoveWebs(const Standard_Boolean bFlag) ; +Standard_EXPORT Standard_Boolean RemoveWebs() const; +Standard_EXPORT const TopTools_DataMapOfShapeInteger& GetMaterialTable() const; +Standard_EXPORT virtual void Build(const TopAbs_ShapeEnum Limit = TopAbs_SHAPE) ; + + + + + +protected: + + // Methods PROTECTED + // +Standard_EXPORT void TreatSolids() ; +Standard_EXPORT void TreatWebs() ; +Standard_EXPORT void RestParts() ; + + + // Fields PROTECTED + // +Standard_Boolean myRemoveWebs; +TopTools_DataMapOfShapeInteger myMapSWM; +TopTools_DataMapOfShapeInteger myMapSWMOut; +TopoDS_Shape myRestParts; + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // + + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/NMTAlgo/NMTAlgo_Splitter1.ixx b/src/NMTAlgo/NMTAlgo_Splitter1.ixx new file mode 100644 index 000000000..c036c0734 --- /dev/null +++ b/src/NMTAlgo/NMTAlgo_Splitter1.ixx @@ -0,0 +1,19 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include + + + + diff --git a/src/NMTAlgo/NMTAlgo_Splitter1.jxx b/src/NMTAlgo/NMTAlgo_Splitter1.jxx new file mode 100644 index 000000000..b589b4d38 --- /dev/null +++ b/src/NMTAlgo/NMTAlgo_Splitter1.jxx @@ -0,0 +1,9 @@ +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif +#ifndef _TopTools_DataMapOfShapeInteger_HeaderFile +#include +#endif +#ifndef _NMTAlgo_Splitter1_HeaderFile +#include +#endif diff --git a/src/NMTAlgo/NMTAlgo_Splitter_1.cxx b/src/NMTAlgo/NMTAlgo_Splitter_1.cxx new file mode 100644 index 000000000..2c057d7f0 --- /dev/null +++ b/src/NMTAlgo/NMTAlgo_Splitter_1.cxx @@ -0,0 +1,689 @@ +// File: NMTAlgo_Splitter_1.cxx +// Created: Mon Feb 2 14:58:54 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 + +//======================================================================= +//function : ShellsAndSolids +//purpose : +//======================================================================= + void NMTAlgo_Splitter::ShellsAndSolids() +{ + Standard_Boolean bMakeSolids; + TopAbs_ShapeEnum aType; + TopTools_ListIteratorOfListOfShape aItS; + TopTools_ListOfShape aLNS; + // + myAddedFacesMap.Clear(); + bMakeSolids=(myLimit==TopAbs_SHAPE || myLimit TopAbs_SHELL) { + continue;//face,wire,... + } + // + aLNS.Clear(); + // + MakeShells (aS, aLNS); + // + if (bMakeSolids && aType==TopAbs_SOLID) { + MakeSolids(aS, aLNS); + } + // + TopTools_ListIteratorOfListOfShape it (aLNS); + for (; it.More(); it.Next()) { + myBuilder.Add (myShape, it.Value()); + } + } + // + // add split faces + aItS.Initialize(myListShapes); + for ( ;aItS.More(); aItS.Next()) { + const TopoDS_Shape& aS=aItS.Value(); + // + aType=aS.ShapeType(); + if (aType!=TopAbs_FACE || myMapTools.Contains(aS)) { + continue; + } + // + const TopoDS_Shape& aCSF=myImageShape.Image(aS).First(); + TopoDS_Iterator itS(aCSF); + for (; itS.More(); itS.Next()){ + const TopoDS_Shape& aF=itS.Value(); + if (!myAddedFacesMap.Contains(aF)){ + myBuilder.Add (myShape, aF); + } + } + } +} +//======================================================================= +//function : MakeShells +//purpose : split S into compound of shells +//======================================================================= + void NMTAlgo_Splitter::MakeShells(const TopoDS_Shape& aS, + TopTools_ListOfShape& aLNS) +{ + NMTAlgo_Loop3d aShellMaker; + // + // get compound of split faces of aS + const TopoDS_Shape& aFC=myImageShape.Image(aS).First(); + aShellMaker.AddConstFaces(aFC); + // + // add split faces inside aS + if (myClosedShapes.Contains(aS)) { + // + // internal faces compound + TopoDS_Shape aIFC=FindFacesInside(aS, Standard_True); + aShellMaker.AddSectionFaces(aIFC); + } + // + aLNS=aShellMaker.MakeShells(myAddedFacesMap); + // + // Add faces added to new shell to myAddedFacesMap: + // avoid rebuilding twice common part of 2 solids. + + TopTools_ListIteratorOfListOfShape itS(aLNS); + TopExp_Explorer expF; + for (; itS.More(); itS.Next()) { + const TopoDS_Shape& aSh=itS.Value(); + expF.Init (aSh, TopAbs_FACE); + for (; expF.More(); expF.Next()){ + myAddedFacesMap.Add (expF.Current()); + } + } + +} +//======================================================================= +//function : MakeSolids +//purpose : make solids out of Shells +//======================================================================= + void NMTAlgo_Splitter::MakeSolids(const TopoDS_Shape& theSolid, + TopTools_ListOfShape& theShellList) +{ + // for a solid wrapping other shells or solids without intersection, + // it is necessary to find shells making holes in it + Standard_Boolean isWrapping; + TopTools_ListOfShape aNewSolids; // result + TopTools_ListOfShape aHoleShells; + TopoDS_Shape anInfinitePointShape; + TopTools_DataMapOfShapeShape aInOutMap; + TopTools_ListIteratorOfListOfShape aShellIt, aSolisIt; + // + isWrapping = myWrappingSolid.Contains(theSolid); + if (!isWrapping && !theShellList.IsEmpty()) { + // check if theSolid initially has internal shells + TopoDS_Iterator aShellExp (theSolid); + aShellExp.Next(); + isWrapping = aShellExp.More(); + } + // + aShellIt.Initialize(theShellList); + for ( ; aShellIt.More(); aShellIt.Next()) { + const TopoDS_Shape & aShell = aShellIt.Value(); + // check if a shell is a hole of theSolid + if (isWrapping && IsInside(anInfinitePointShape, aShell)){ + aHoleShells.Append(aShell); + } + else { + // make a solid from a shell + TopoDS_Solid Solid; + myBuilder.MakeSolid( Solid ); + myBuilder.Add (Solid, aShell); + + aNewSolids.Append (Solid); + } + } + // + // find outer a shell most close to each hole shell + aShellIt.Initialize(aHoleShells); + for (; aShellIt.More(); aShellIt.Next()){ + const TopoDS_Shape & aHole = aShellIt.Value(); + // + aSolisIt.Initialize(aNewSolids); + for ( ; aSolisIt.More(); aSolisIt.Next()) { + const TopoDS_Shape & aSolid = aSolisIt.Value(); + // + if (! IsInside(aHole, aSolid)){ + continue; + } + // + if ( aInOutMap.IsBound (aHole)){ + const TopoDS_Shape & aSolid2 = aInOutMap( aHole ); + if ( IsInside( aSolid, aSolid2 )) { + aInOutMap.UnBind( aHole ); + aInOutMap.Bind ( aHole, aSolid ); + } + } + else{ + aInOutMap.Bind (aHole, aSolid); + } + } + // + // add aHole to a solid + if (aInOutMap.IsBound( aHole )){ + TopoDS_Shape & aSolid=aInOutMap(aHole); + myBuilder.Add (aSolid, aHole); + } + } + theShellList.Clear(); + theShellList.Append( aNewSolids ); +} + +//======================================================================= +//function : FindFacesInside +//purpose : return compound of faces of other shapes that are +// inside . +// is an object shape. +// makes avoid faces that do not form a +// closed shell +// makes return already added faces +//======================================================================= + TopoDS_Shape NMTAlgo_Splitter::FindFacesInside(const TopoDS_Shape& theShape, + const Standard_Boolean CheckClosed, + const Standard_Boolean All) +{ + TopExp_Explorer expl; + // + // ================================================ + // check if internal faces have been already found + // ================================================ + if (myInternalFaces.IsBound(theShape)) { + TopoDS_Shape aIntFComp = myInternalFaces.Find (theShape); + TopoDS_Shape aIntRemFComp = myIntNotClFaces.Find (theShape); + + expl.Init( aIntRemFComp, TopAbs_FACE); + if (CheckClosed || !expl.More()){ + return aIntFComp; + } + // + TopoDS_Compound C; + myBuilder.MakeCompound( C ); + // add removed faces + for (; expl.More(); expl.Next()){ + myBuilder.Add( C, expl.Current() ); + } + // add good internal faces + expl.Init( aIntFComp, TopAbs_FACE); + for (; expl.More(); expl.Next()) { + myBuilder.Add( C, expl.Current() ); + } + // + return C; + } + + // =================================== + // 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_MapIteratorOfMapOfShape itm; + TopTools_ListOfShape EmptyL; + TopTools_ListIteratorOfListOfShape itl; + + // MSE filling: map of new section edges of CSF + expl.Init(CSF, TopAbs_EDGE); + for (; expl.More(); expl.Next()) { + const TopoDS_Shape& aE = expl.Current() ; + MSE.Add(aE); + } + // + // DMEF: map edge of CSF - faces of CSF + TopTools_IndexedDataMapOfShapeListOfShape DMEF; + TopExp::MapShapesAndAncestors(CSF, TopAbs_EDGE, TopAbs_FACE, DMEF); + // + // Fill + // 1. MFP - a map of faces to process: map of resulting faces except + // those of theShape; we`ll add to C those of them which are inside CSF + // 2. DMSEFP - edge of MSE => faces of MFP + // + itl.Initialize(myListShapes); + for (;itl.More(); itl.Next()) { + const TopoDS_Shape& aShape = itl.Value(); + // + if ( theShape.IsSame(aShape)) { + continue; + } + // fill maps + // iterate on split faces of aShape + const TopoDS_Shape& CSF1 = myImageShape.Image(aShape).First(); + TopoDS_Iterator itF (CSF1); + for ( ; itF.More(); itF.Next()) { + const TopoDS_Shape& aF1 = itF.Value(); + MFP.Add(aF1); + // iterate on edges of split faces of aShape, + // add to DMSEFP edges that are new + expl.Init(aF1, TopAbs_EDGE); + for (; expl.More(); expl.Next()) { + TopoDS_Shape aE1 = expl.Current(); + if ( MSE.Contains(aE1)) {// section edge + if (!DMSEFP.IsBound(aE1)) { + DMSEFP.Bind(aE1, EmptyL); + } + DMSEFP(aE1).Append(aF1); + } + } + } + }//for (;itl.More(); itl.Next()) + // + // add tool faces... (is absent) + // + // =========================== + // find faces inside theShape + // =========================== + Standard_Boolean skipAlreadyAdded = Standard_False; + Standard_Boolean GoodOri, inside; + Standard_Real dot; + 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); + + // 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()); + // 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; + if (myImagesFaces.IsImage(aFace1)){ + anOrigFace = myImagesFaces.Root(aFace1); + } + // + TopoDS_Shape aFace2; + if ( !isSectionE ) { + while (itl.More()) { + aFace2 = itl.Value(); + // + TopoDS_Shape anOrigFace2 = aFace2; + if (myImagesFaces.IsImage(aFace2)) { + anOrigFace2 = myImagesFaces.Root(aFace2); + } + // + if (!MFP.Contains( aFace2 )) { + LSF.Remove( itl ); + continue; + } + //if (anOrigFace.IsSame( myImagesFaces.Root( aFace2 ))) + if (anOrigFace.IsSame(anOrigFace2)) { + break; + } + itl.Next(); + } + if (itl.More()) { // aFace2 found, remove it from maps + LSF.Remove( itl ); + MFP.Remove(aFace2); + } + else{ + aFace2.Nullify(); + } + itl.Initialize( LSF ); + } + + // 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)); + 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)) + continue; // E is convex between origF1 and origF2 or they are tangent + } + // + // keep one of found faces + + //face of CSF sharing E + const TopoDS_Shape& aShapeFace = sameDom1 ? FL.Last() : FL.First(); + // analyse aFace1 state + inside = NMTAlgo_Loop3d::IsInside (E, TopoDS::Face(aShapeFace), aFace1, + 1, dot, GoodOri); +// if (inside && isSectionE) { + 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(); + if (aShapeFace2 != aShapeFace){ + inside = NMTAlgo_Loop3d::IsInside (E, TopoDS::Face(aShapeFace2), aFace1, + 1, dot, GoodOri); + } + } + // + // store internal face + if (inside) + KeepFaces.Append(aFace1); + + 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 ); + } + else + KeepFaces.Append(aFace2); + } + } + } + + // =================================================== + // 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); + // + while (!KeepFaces.IsEmpty()) { + // KeepEdges : map of edges of faces kept last time + TopTools_IndexedMapOfShape KeepEdges; + for ( itl.Initialize(KeepFaces); itl.More(); itl.Next() ) { + TopExp::MapShapes( itl.Value(), TopAbs_EDGE, KeepEdges); + KeptFaces.Append( itl.Value() ); + } + // + KeepFaces.Clear(); + // + // keep faces connected with already kept faces by KeepEdges + for ( itm.Initialize(MFP); itm.More(); itm.Next() ) { + const TopoDS_Shape& FP = itm.Key(); + for (expl.Init(FP,TopAbs_EDGE); expl.More(); expl.Next()) { + const TopoDS_Shape& se = expl.Current(); + if (!MSE.Contains(se) && KeepEdges.Contains(se) ) { + KeepFaces.Append(FP); + MFP.Remove(FP); + break; + } + } + } + } + + // =============================================================== + // here MFP contains faces outer of theShape and those of shapes + // which do not interfere with theShape at all and between which + // there may be those wrapped by theShape and whose faces may be + // needed to be returned as well + // =============================================================== + + Standard_Boolean isSolid = (theShape.ShapeType() == TopAbs_SOLID); + if (All || isSolid) // All is for sub-result removal + { + for ( itm.Initialize( MFP ); itm.More(); itm.Next() ) { + TopoDS_Shape aFace = itm.Key(); + + // find a shape aFace originates from + TopoDS_Shape anOrigShape = GetOriginalShape( aFace ); + + // find out if all faces of anOrigShape are not in MFP + // and by the way remove them from MFP + Standard_Boolean isAllOut = Standard_True; + TopoDS_Shape aSplitFaces = anOrigShape; + if (myImageShape.HasImage(anOrigShape)) + aSplitFaces = myImageShape.Image(anOrigShape).First(); + + TopTools_ListOfShape aSplitFaceL; + for (expl.Init( aSplitFaces, TopAbs_FACE ); expl.More(); expl.Next()) + { + const TopoDS_Shape & aSpFace = expl.Current(); + // a tool face which become object has image but the whole tool shape has not + if (myImageShape.HasImage( aSpFace )) + { + TopExp_Explorer exF (myImageShape.Image( aSpFace ).First(), TopAbs_FACE ); + for ( ; exF.More(); exF.Next() ) + { + aSplitFaceL.Append( exF.Current() ); + if ( ! MFP.Remove( exF.Current() )) + isAllOut = Standard_False; + } + } + else + { + aSplitFaceL.Append( aSpFace ); + if ( ! MFP.Remove( aSpFace )) + isAllOut = Standard_False; + } + } + itm.Initialize( MFP ); + if ( !isAllOut ) + continue; + + // classify anOrigShape against theShape + if (IsInside (anOrigShape, theShape)) { + if (isSolid && myClosedShapes.Contains(anOrigShape)) { + // to make a special care at solid reconstruction + myWrappingSolid.Add ( theShape ); + } + // keep faces of an internal shape anOrigShape + KeptFaces.Append( aSplitFaceL ); + } + } + } + + // ==================================================== + // check if kept faces form a shell without free edges + // ==================================================== + + DMEF.Clear(); // edge - kept faces + MFP.Clear(); // reuse it for wrong faces + if (CheckClosed) { + for (itl.Initialize(KeptFaces); itl.More(); itl.Next() ) + TopExp::MapShapesAndAncestors(itl.Value(), TopAbs_EDGE, TopAbs_FACE, DMEF); + + Standard_Integer i, nb = DMEF.Extent(); + Standard_Boolean isClosed = Standard_False; + while (!isClosed) { + isClosed = Standard_True; + for (i=1; isClosed && i<=nb; ++i) { + const TopoDS_Shape& E = DMEF.FindKey( i ); + if (! BRep_Tool::Degenerated( TopoDS::Edge( E )) && + ! MSE.Contains( E )) + isClosed = ( DMEF(i).Extent() != 1 ); + } + if (!isClosed) { + const TopoDS_Shape& F = DMEF.FindFromIndex( i-1 ).First(); // bad face + MFP.Add( F ); + // remove bad face from DMEF + for (expl.Init( F, TopAbs_EDGE); expl.More(); expl.Next()) { + const TopoDS_Shape& E = expl.Current(); + TopTools_ListOfShape& FL = DMEF.ChangeFromKey( E ); + for (itl.Initialize( FL ); itl.More(); itl.Next() ) { + if ( F.IsSame( itl.Value() )) { + FL.Remove( itl ); + break; + } + } + } + } + } + } + + // ============== + // make a result + // ============== + + TopoDS_Compound C; + // compound of removed internal faces + TopoDS_Compound CNotCl; + + myBuilder.MakeCompound(C); + myBuilder.MakeCompound(CNotCl); + + // add to compounds + itl.Initialize(KeptFaces); + for (; itl.More(); itl.Next() ) { + TopoDS_Shape & aIntFace = itl.Value(); + // + if (!All && + myAddedFacesMap.Contains(aIntFace) && + myAddedFacesMap.Contains(aIntFace.Reversed())) { + continue; + } + // + if (! MFP.Contains( aIntFace )){ + myBuilder.Add(C, aIntFace); + } + else{ + myBuilder.Add(CNotCl, aIntFace); + } + } + // + if (!skipAlreadyAdded && CheckClosed) { + myInternalFaces.Bind(theShape, C); + myIntNotClFaces.Bind(theShape, CNotCl); + } + // + // + if (!myMapSIFC.IsBound(theShape)) { + TopoDS_Compound aCIF; + myBuilder.MakeCompound(aCIF); + // + itl.Initialize(KeptFaces); + for (; itl.More(); itl.Next() ) { + TopoDS_Shape & aIntFace = itl.Value(); + if (! MFP.Contains(aIntFace )){ + myBuilder.Add(aCIF, aIntFace); + } + } + myMapSIFC.Bind(theShape, aCIF); + } + // + return C; +} +//======================================================================= +//function : IsInside +//purpose : Return True if the first vertex of S1 inside S2. +// If S1.IsNull(), check infinite point against S2. +//======================================================================= + Standard_Boolean NMTAlgo_Splitter::IsInside (const TopoDS_Shape& theS1, + const TopoDS_Shape& theS2) +{ + BRepClass3d_SolidClassifier aClassifier( theS2 ); + // + TopExp_Explorer expl(theS1, TopAbs_VERTEX); + // + if (!expl.More()){ + aClassifier.PerformInfinitePoint( ::RealSmall()); + } + else { + const TopoDS_Vertex & aVertex = TopoDS::Vertex( expl.Current() ); + aClassifier.Perform (BRep_Tool::Pnt( aVertex ), + BRep_Tool::Tolerance( aVertex )); + } + // + return ( aClassifier.State() == TopAbs_IN ); +} + +//======================================================================= +//function : GetOriginalShape +//purpose : Return the shape aShape originates from. aShape +// should be a face or more complex result shape +//======================================================================= + TopoDS_Shape NMTAlgo_Splitter::GetOriginalShape(const TopoDS_Shape& theShape) const +{ + TopoDS_Shape anOrigShape; + + TopExp_Explorer expl( theShape, TopAbs_FACE); + if (expl.More()) { + TopoDS_Shape aFace = expl.Current(); + if (myImagesFaces.IsImage( aFace )) + aFace = myImagesFaces.Root( aFace ); + anOrigShape = myFaceShapeMap.Find( aFace ); + } + return anOrigShape; +} diff --git a/src/NMTAlgo/NMTAlgo_Splitter_2.cxx b/src/NMTAlgo/NMTAlgo_Splitter_2.cxx new file mode 100644 index 000000000..0c1dc8f04 --- /dev/null +++ b/src/NMTAlgo/NMTAlgo_Splitter_2.cxx @@ -0,0 +1,515 @@ +// File: NMTAlgo_Splitter_2.cxx +// Created: Mon Feb 9 15:07:51 2004 +// Author: Igor FEOKTISTOV +// + + +#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 : KeepShapesInside +//purpose : remove shapes that are outside of S from resul +//======================================================================= + void NMTAlgo_Splitter::KeepShapesInside (const TopoDS_Shape& S) +{ + TopoDS_Iterator it; + if (S.ShapeType() < TopAbs_SOLID) { // compound or compsolid + for (it.Initialize( S ); it.More(); it.Next()) + KeepShapesInside( it.Value()); + return; + } + + Standard_Boolean isTool = Standard_False; + if (!myImageShape.HasImage( S )) { + //isTool = CheckTool( S ); + //if (!isTool) return; + return; + } + + // build map of internal faces + TopTools_IndexedMapOfShape MIF; + TopoDS_Shape IntFacesComp = FindFacesInside( S, Standard_False, Standard_True); + TopExp::MapShapes( IntFacesComp, TopAbs_FACE, MIF ); + + TopoDS_Compound C; + myBuilder.MakeCompound(C); + + TopAbs_ShapeEnum anInternalShapeType = TopAbs_SHAPE; + if (!MIF.IsEmpty()) + { + // leave in the result only those shapes having a face in MIF + for (it.Initialize( myShape ); it.More(); it.Next()) { + const TopoDS_Shape & aResShape = it.Value(); + TopExp_Explorer expResF( aResShape, TopAbs_FACE ); + for (; expResF.More(); expResF.Next()) { + if ( MIF.Contains( expResF.Current())) { + myBuilder.Add( C, aResShape ); + if (aResShape.ShapeType() < anInternalShapeType) + anInternalShapeType = aResShape.ShapeType(); + break; + } + } + } + } + + // may be S was not split by internal faces then it is missing + // in myShape, add it + if (!isTool && + (anInternalShapeType > TopAbs_SOLID || S.ShapeType() > TopAbs_SOLID)) + { + TopTools_IndexedMapOfShape MSF; // map of split faces of S + TopExp::MapShapes( myImageShape.Image(S).First(), TopAbs_FACE, MSF); + + // find a shape having all faces in MSF + for (it.Initialize( myShape ); it.More(); it.Next()) { + TopExp_Explorer expResF( it.Value(), TopAbs_FACE ); + for (; expResF.More(); expResF.Next()) { + if (! MSF.Contains( expResF.Current())) + break; + } + if (! expResF.More()) { + myBuilder.Add( C, it.Value() ); + break; + } + } + } + + myShape = C; +} + +//======================================================================= +//function : RemoveShapesInside +//purpose : remove shapes that are inside S from resul +//======================================================================= + void NMTAlgo_Splitter::RemoveShapesInside (const TopoDS_Shape& S) +{ + TopoDS_Iterator it; + if (S.ShapeType() < TopAbs_SOLID) { // compound or compsolid + for (it.Initialize( S ); it.More(); it.Next()) + RemoveShapesInside( it.Value()); + return; + } + Standard_Boolean isTool = Standard_False; + if (!myImageShape.HasImage( S )) { + //isTool = CheckTool( S ); + //if (!isTool) return; + 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); + + // 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())) + break; + + if (expResF.More()) + // add shape to result + myBuilder.Add( C, it.Value() ); + 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 (!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; + } + default: + isClosed = Standard_False; + } + 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()); + } + + if (S.ShapeType() == TopAbs_SOLID) { + TopoDS_Solid Solid; + myBuilder.MakeSolid( Solid ); + myBuilder.Add (Solid, Shell); + myBuilder.Add (C, Solid); + } + else + myBuilder.Add (C, Shell); + } + else { + if (myImageShape.HasImage( S )) { + for (it.Initialize( myImageShape.Image(S).First()); it.More(); it.Next()) + myBuilder.Add (C, it.Value()); + } + } + } + + myShape = C; +} + +//======================================================================= +//function : Modified +//purpose : +//======================================================================= + const TopTools_ListOfShape& NMTAlgo_Splitter::Modified (const TopoDS_Shape& S) + +{ + myGenerated.Clear(); + TopTools_ListIteratorOfListOfShape it; + TopTools_MapOfShape aMap; + TopExp_Explorer anExp; + + if(S.ShapeType() == TopAbs_FACE || S.ShapeType() == TopAbs_EDGE) { + + if(S.ShapeType() == TopAbs_FACE) { + if (myImagesFaces.HasImage( S )) { + it.Initialize(myImagesFaces.Image(S)); + anExp.Init(myShape, TopAbs_FACE); + } + } + else { + if (myImagesEdges.HasImage( S )) { + it.Initialize(myImagesEdges.Image(S)); + anExp.Init(myShape, TopAbs_EDGE); + } + } + + for(; anExp.More(); anExp.Next()) { + aMap.Add(anExp.Current()); + } + + for (; it.More(); it.Next()) { + if(aMap.Contains(it.Value())) { + myGenerated.Append(it.Value()); + } + } + + return myGenerated; + + } + + if(S.ShapeType() == TopAbs_VERTEX) { + + const NMTTools_DSFiller& aDSF = Filler(); + const NMTTools_PaveFiller& aPF = aDSF.PaveFiller(); + const NMTDS_ShapesDataStructure& aDS = aDSF.DS(); + + Standard_Integer aNbS = aDS.NumberOfSourceShapes(); + Standard_Integer anIndex = 0, i; + + for(i = 1; i <= aNbS; ++i) { + + const TopoDS_Shape& aS = aDS.Shape(i); + if(S.IsSame(aS)) { + anIndex = i; + break; + } + + } + + if(anIndex == 0) return myGenerated; + + Standard_Integer aSDVInd = aPF.FindSDVertex(anIndex); + + if(aSDVInd == 0) return myGenerated; + + const TopoDS_Shape aSDV = aDS.Shape(aSDVInd); + + anExp.Init(myShape, TopAbs_VERTEX); + for(; anExp.More(); anExp.Next()) { + + if(aSDV.IsSame(anExp.Current())) { + myGenerated.Append(aSDV); + break; + } + + } + + } + + return myGenerated; +} +//======================================================================= +//function : Generated +//purpose : +//======================================================================= + const TopTools_ListOfShape& NMTAlgo_Splitter::Generated(const TopoDS_Shape& S) +{ + myGenerated.Clear(); + TopTools_ListIteratorOfListOfShape it; + TopTools_MapOfShape aMap; + TopExp_Explorer anExp; + Standard_Boolean bCheckVert = Standard_False; + + if(S.ShapeType() == TopAbs_FACE) { + if (mySectionParts.Contains(S)) { + it.Initialize(mySectionParts.FindFromKey(S)); + anExp.Init(myShape, TopAbs_EDGE); + + for(; anExp.More(); anExp.Next()) { + aMap.Add(anExp.Current()); + } + + for (; it.More(); it.Next()) { + if(aMap.Contains(it.Value())) { + myGenerated.Append(it.Value()); + } + } + } + + NMTTools_PaveFiller& aPF = myDSFiller->ChangePaveFiller(); + const NMTDS_ShapesDataStructure& aDS = myDSFiller->DS(); + const BOPTools_PInterferencePool& anIP = aPF.InterfPool(); + + Standard_Integer aNbS = aDS.NumberOfSourceShapes(); + Standard_Integer anIndex = 0, i; + + for(i = 1; i <= aNbS; ++i) { + + const TopoDS_Shape& aS = aDS.Shape(i); + if(S.IsSame(aS)) { + anIndex = i; + break; + } + + } + + if(anIndex == 0) return myGenerated; + if(!anIP->HasInterference(anIndex)) return myGenerated; + + const BOPTools_CArray1OfESInterference& aESs = anIP->ESInterferences(); + Standard_Integer aNbI = aESs.Extent(); + + if(aNbI == 0) return myGenerated; + + for(i = 1; i <= aNbI; ++i) { + + const BOPTools_ESInterference& aES = aESs(i); + Standard_Integer ind1, ind2; + aES.Indices(ind1, ind2); + + if(ind1 == anIndex || ind2 == anIndex) { + + Standard_Integer aNSI = aES.NewShape(); + if(aDS.GetShapeType(aNSI) == TopAbs_VERTEX) { + myGenerated.Append(aDS.Shape(aNSI)); + bCheckVert = Standard_True; + } + + } + + } + + if(bCheckVert) { + aMap.Clear(); + anExp.Init(myShape, TopAbs_VERTEX); + + for(; anExp.More(); anExp.Next()) { + aMap.Add(anExp.Current()); + } + + it.Initialize(myGenerated); + for (; it.More(); it.Next()) { + + if(it.Value().ShapeType() != TopAbs_VERTEX) continue; + + if(!aMap.Contains(it.Value())) { + myGenerated.Remove(it); + } + + } + } + + return myGenerated; + } + + if(S.ShapeType() == TopAbs_EDGE) { + + NMTTools_PaveFiller& aPF = myDSFiller->ChangePaveFiller(); + const NMTDS_ShapesDataStructure& aDS = myDSFiller->DS(); + const BOPTools_PInterferencePool& anIP = aPF.InterfPool(); + + Standard_Integer aNbS = aDS.NumberOfSourceShapes(); + Standard_Integer anIndex = 0, i; + + for(i = 1; i <= aNbS; ++i) { + + const TopoDS_Shape& aS = aDS.Shape(i); + if(S.IsSame(aS)) { + anIndex = i; + break; + } + + } + + if(anIndex == 0) return myGenerated; + if(!anIP->HasInterference(anIndex)) return myGenerated; + + const BOPTools_CArray1OfEEInterference& aEEs = anIP->EEInterferences(); + Standard_Integer aNbI = aEEs.Extent(); + + for(i = 1; i <= aNbI; ++i) { + + const BOPTools_EEInterference& aEE = aEEs(i); + Standard_Integer ind1, ind2; + aEE.Indices(ind1, ind2); + + if(ind1 == anIndex || ind2 == anIndex) { + + Standard_Integer aNSI = aEE.NewShape(); + if(aDS.GetShapeType(aNSI) == TopAbs_VERTEX) { + myGenerated.Append(aDS.Shape(aNSI)); + bCheckVert = Standard_True; + } + + } + + } + + const BOPTools_CArray1OfESInterference& aESs = anIP->ESInterferences(); + aNbI = aESs.Extent(); + + for(i = 1; i <= aNbI; ++i) { + + const BOPTools_ESInterference& aES = aESs(i); + Standard_Integer ind1, ind2; + aES.Indices(ind1, ind2); + + if(ind1 == anIndex || ind2 == anIndex) { + + Standard_Integer aNSI = aES.NewShape(); + if(aDS.GetShapeType(aNSI) == TopAbs_VERTEX) { + myGenerated.Append(aDS.Shape(aNSI)); + bCheckVert = Standard_True; + } + + } + + } + + if(bCheckVert) { + aMap.Clear(); + anExp.Init(myShape, TopAbs_VERTEX); + + for(; anExp.More(); anExp.Next()) { + aMap.Add(anExp.Current()); + } + + it.Initialize(myGenerated); + for (; it.More(); it.Next()) { + + if(!aMap.Contains(it.Value())) { + myGenerated.Remove(it); + } + + } + } + + return myGenerated; + + } + + return myGenerated; +} + +//======================================================================= +//function : IsDeleted +//purpose : +//======================================================================= + Standard_Boolean NMTAlgo_Splitter::IsDeleted (const TopoDS_Shape& S) + +{ + const TopTools_ListOfShape& aL = Modified(S); + if(aL.Extent() != 0) return Standard_False; + + TopTools_MapOfShape aMap; + TopExp_Explorer anExp; + + TopAbs_ShapeEnum aType = S.ShapeType(); + + if(aType == TopAbs_VERTEX || + aType == TopAbs_EDGE || + aType == TopAbs_FACE ) { + + anExp.Init(myShape, aType); + for(; anExp.More(); anExp.Next()) { + if(S.IsSame(anExp.Current())) return Standard_False; + } + + } + + return Standard_True; +} + diff --git a/src/NMTAlgo/NMTAlgo_Tools.cdl b/src/NMTAlgo/NMTAlgo_Tools.cdl new file mode 100644 index 000000000..9b067fdad --- /dev/null +++ b/src/NMTAlgo/NMTAlgo_Tools.cdl @@ -0,0 +1,71 @@ +-- File: NMTAlgo_Tools.cdl +-- Created: Fri Jan 30 16:29:14 2004 +-- Author: Peter KURNEV +-- +---Copyright: Matra Datavision 2004 + + +class Tools from NMTAlgo + + ---Purpose: + +uses + Orientation from TopAbs, + + Shape from TopoDS, + Edge from TopoDS, + Face from TopoDS, + Shell from TopoDS, + + ListOfShape from TopTools, + IndexedMapOfShape from TopTools +--raises + +is + OrientFacesOnShell (myclass; + aShell: Shell from TopoDS; + aShellNew: out Shell from TopoDS); + + OrientFacesOnShell (myclass; + aF : Face from TopoDS; + aSh : out Shell from TopoDS); + + Orientation(myclass; + aE: Edge from TopoDS; + aF: Face from TopoDS) + returns Orientation from TopAbs; + + Sense (myclass; + aF1: Face from TopoDS; + aF2: Face from TopoDS) + returns Integer from Standard; + + IsInside (myclass; + aS1: Shape from TopoDS; + aS2: Shape from TopoDS) + returns Boolean from Standard; + + MakeShells(myclass; + aFC:Shape from TopoDS; + aLS:out ListOfShape from TopTools); + + MakeSolids(myclass; + aLS:out ListOfShape from TopTools); + + MakeSolids(myclass; + aFC:Shape from TopoDS; + aLS:out ListOfShape from TopTools); + + BreakWebs (myclass; + aS1: Shape from TopoDS; + aS2:out Shape from TopoDS); + + FindImageSolid (myclass; + aFC : Shape from TopoDS; + aMSo : IndexedMapOfShape from TopTools; + aSo : out Shape from TopoDS) + returns Boolean from Standard; + +--fields + +end Tools; diff --git a/src/NMTAlgo/NMTAlgo_Tools.cxx b/src/NMTAlgo/NMTAlgo_Tools.cxx new file mode 100644 index 000000000..2e95ca512 --- /dev/null +++ b/src/NMTAlgo/NMTAlgo_Tools.cxx @@ -0,0 +1,498 @@ +// File: NMTAlgo_Tools.cxx +// Created: Fri Jan 30 16:30:45 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 + + +//======================================================================= +// function: Sense +// purpose: +//======================================================================= + Standard_Integer NMTAlgo_Tools::Sense (const TopoDS_Face& aF1, + const TopoDS_Face& aF2) +{ + Standard_Integer iSense=0; + gp_Dir aDNF1, aDNF2; + TopoDS_Edge aE1, aE2; + TopExp_Explorer anExp; + // + anExp.Init(aF1, TopAbs_EDGE); + for (; anExp.More(); anExp.Next()) { + aE1=TopoDS::Edge(anExp.Current()); + if (!BRep_Tool::Degenerated(aE1)) { + if (!BRep_Tool::IsClosed(aE1, aF1)) { + break; + } + } + } + // + anExp.Init(aF2, TopAbs_EDGE); + for (; anExp.More(); anExp.Next()) { + aE2=TopoDS::Edge(anExp.Current()); + if (!BRep_Tool::Degenerated(aE2)) { + if (!BRep_Tool::IsClosed(aE2, aF2)) { + if (aE2.IsSame(aE1)) { + iSense=1; + break; + } + } + } + } + // + if (!iSense) { + return iSense; + } + // + BOPTools_Tools3D::GetNormalToFaceOnEdge(aE1, aF1, aDNF1); + BOPTools_Tools3D::GetNormalToFaceOnEdge(aE2, aF2, aDNF2); + // + iSense=BOPTools_Tools3D::SenseFlag(aDNF1, aDNF2); + // + return iSense; +} + +//======================================================================= +// function: OrientFacesOnShell +// purpose: +//======================================================================= + void NMTAlgo_Tools::OrientFacesOnShell (const TopoDS_Face& aF1, + TopoDS_Shell& aSh) +{ + Standard_Integer aNbFSh, iSenseFlag; + gp_Dir aDNF1, aDNF2; + TopExp_Explorer anExp; + TopoDS_Edge aE1, aESh; + TopTools_IndexedDataMapOfShapeListOfShape aMEFSh; + // + anExp.Init(aF1, TopAbs_EDGE); + for (; anExp.More(); anExp.Next()) { + aE1=TopoDS::Edge(anExp.Current()); + if (!BRep_Tool::Degenerated(aE1)) { + break; + } + } + // + BOPTools_Tools3D::GetNormalToFaceOnEdge(aE1, aF1, aDNF1); + // + TopExp::MapShapesAndAncestors(aSh, TopAbs_EDGE, TopAbs_FACE, aMEFSh); + if (aMEFSh.Contains(aE1)) { + const TopTools_ListOfShape& aLFSh=aMEFSh.FindFromKey(aE1); + aNbFSh=aLFSh.Extent(); + if (aNbFSh==1) { + const TopoDS_Face& aFSh=TopoDS::Face(aLFSh.First()); + // + BOPTools_Tools3D::OrientEdgeOnFace(aE1, aFSh, aESh); + BOPTools_Tools3D::GetNormalToFaceOnEdge(aESh, aFSh, aDNF2); + // + iSenseFlag=BOPTools_Tools3D::SenseFlag(aDNF1, aDNF2); + if (iSenseFlag==1) { + return; + } + // + anExp.Init(aSh, TopAbs_FACE); + for (; anExp.More(); anExp.Next()) { + const TopoDS_Shape& aFx=anExp.Current(); + TopoDS_Shape *pFx=(TopoDS_Shape *)&aFx; + pFx->Reverse(); + } + } + } +} +//======================================================================= +// function: OrientFacesOnShell +// purpose: +//======================================================================= + void NMTAlgo_Tools::OrientFacesOnShell (const TopoDS_Shell& aShell, + TopoDS_Shell& aShellNew) +{ + Standard_Boolean bIsProcessed1, bIsProcessed2; + Standard_Integer i, aNbE, aNbF, j; + TopAbs_Orientation anOrE1, anOrE2; + + TopTools_IndexedDataMapOfShapeListOfShape aEFMap; + TopTools_IndexedMapOfShape aProcessedFaces; + BRep_Builder aBB; + + aBB.MakeShell(aShellNew); + + TopExp::MapShapesAndAncestors(aShell, TopAbs_EDGE, TopAbs_FACE, aEFMap); + + aNbE=aEFMap.Extent(); + // + // One seam edge in aEFMap contains 2 equivalent faces. + for (i=1; i<=aNbE; i++) { + TopTools_ListOfShape& aLF=aEFMap.ChangeFromIndex(i); + + if (aLF.Extent()>1) { + TopTools_ListOfShape aLFTmp; + TopTools_IndexedMapOfShape aFM; + + TopTools_ListIteratorOfListOfShape anIt(aLF); + for (; anIt.More(); anIt.Next()) { + const TopoDS_Shape& aF=anIt.Value(); + if (!aFM.Contains(aF)) { + aFM.Add(aF); + aLFTmp.Append(aF); + } + } + aLF.Clear(); + aLF=aLFTmp; + } + } + // + // Do + for (i=1; i<=aNbE; i++) { + const TopoDS_Edge& aE=TopoDS::Edge(aEFMap.FindKey(i)); + + if (BRep_Tool::Degenerated(aE)) { + continue; + } + + const TopTools_ListOfShape& aLF=aEFMap.FindFromIndex(i); + aNbF=aLF.Extent(); + + if (aNbF==2) { + TopoDS_Face& aF1=TopoDS::Face(aLF.First()); + TopoDS_Face& aF2=TopoDS::Face(aLF.Last() ); + + + bIsProcessed1=aProcessedFaces.Contains(aF1); + bIsProcessed2=aProcessedFaces.Contains(aF2); + + if (bIsProcessed1 && bIsProcessed2) { + continue; + } + + if (!bIsProcessed1 && !bIsProcessed2) { + aProcessedFaces.Add(aF1); + aBB.Add(aShellNew, aF1); + + bIsProcessed1=!bIsProcessed1; + } + + // + TopoDS_Face aF1x, aF2x; + + aF1x=aF1; + if (bIsProcessed1) { + j=aProcessedFaces.FindIndex(aF1); + aF1x=TopoDS::Face(aProcessedFaces.FindKey(j)); + } + + aF2x=aF2; + if (bIsProcessed2) { + j=aProcessedFaces.FindIndex(aF2); + aF2x=TopoDS::Face(aProcessedFaces.FindKey(j)); + } + // + + anOrE1=NMTAlgo_Tools::Orientation(aE, aF1x); + anOrE2=NMTAlgo_Tools::Orientation(aE, aF2x); + + if (bIsProcessed1 && !bIsProcessed2) { + + if (anOrE1==anOrE2) { + if (!BRep_Tool::IsClosed(aE, aF1) && + !BRep_Tool::IsClosed(aE, aF2)) { + aF2.Reverse(); + } + } + aProcessedFaces.Add(aF2); + aBB.Add(aShellNew, aF2); + } + + else if (!bIsProcessed1 && bIsProcessed2) { + if (anOrE1==anOrE2) { + if (!BRep_Tool::IsClosed(aE, aF1) && + !BRep_Tool::IsClosed(aE, aF2)) { + aF1.Reverse(); + } + } + aProcessedFaces.Add(aF1); + aBB.Add(aShellNew, aF1); + } + } + } + // + // + for (i=1; i<=aNbE; i++) { + const TopoDS_Edge& aE=TopoDS::Edge(aEFMap.FindKey(i)); + + if (BRep_Tool::Degenerated(aE)) { + continue; + } + + const TopTools_ListOfShape& aLF=aEFMap.FindFromIndex(i); + aNbF=aLF.Extent(); + if (aNbF!=2) { + TopTools_ListIteratorOfListOfShape anIt(aLF); + for(; anIt.More(); anIt.Next()) { + const TopoDS_Face& aF=TopoDS::Face(anIt.Value()); + if (!aProcessedFaces.Contains(aF)) { + aProcessedFaces.Add(aF); + aBB.Add(aShellNew, aF); + } + } + } + } +} +//======================================================================= +//function : Orientation +//purpose : +//======================================================================= + TopAbs_Orientation NMTAlgo_Tools::Orientation(const TopoDS_Edge& anE, + const TopoDS_Face& aF) +{ + TopAbs_Orientation anOr=TopAbs_INTERNAL; + + TopExp_Explorer anExp; + anExp.Init(aF, TopAbs_EDGE); + for (; anExp.More(); anExp.Next()) { + const TopoDS_Edge& anEF1=TopoDS::Edge(anExp.Current()); + if (anEF1.IsSame(anE)) { + anOr=anEF1.Orientation(); + break; + } + } + return anOr; +} +//======================================================================= +//function : IsInside +//purpose : Return True if the first vertex of S1 inside S2. +// If S1.IsNull(), check infinite point against S2. +//======================================================================= + Standard_Boolean NMTAlgo_Tools::IsInside (const TopoDS_Shape& theS1, + const TopoDS_Shape& theS2) +{ + BRepClass3d_SolidClassifier aClassifier( theS2 ); + // + TopExp_Explorer expl(theS1, TopAbs_VERTEX); + // + if (!expl.More()){ + aClassifier.PerformInfinitePoint( ::RealSmall()); + } + else { + const TopoDS_Vertex & aVertex = TopoDS::Vertex( expl.Current() ); + aClassifier.Perform (BRep_Tool::Pnt( aVertex ), + BRep_Tool::Tolerance( aVertex )); + } + // + return ( aClassifier.State() == TopAbs_IN ); +} +//======================================================================= +//function : MakeShells +//purpose : +//======================================================================= + void NMTAlgo_Tools::MakeShells (const TopoDS_Shape& aFC, + TopTools_ListOfShape& aLNS) +{ + NMTAlgo_Loop3d aShellMaker; + TopTools_MapOfOrientedShape aMTmp; + // + aShellMaker.AddConstFaces(aFC); + aLNS=aShellMaker.MakeShells(aMTmp); +} +//======================================================================= +//function : MakeSolids +//purpose : +//======================================================================= + void NMTAlgo_Tools::MakeSolids(const TopoDS_Shape& aFC, + TopTools_ListOfShape& theShellList) +{ + NMTAlgo_Tools::MakeShells(aFC, theShellList); + NMTAlgo_Tools::MakeSolids(theShellList); +} +//======================================================================= +//function : MakeSolids +//purpose : +//======================================================================= + void NMTAlgo_Tools::MakeSolids(TopTools_ListOfShape& theShellList) +{ + TopTools_ListOfShape aHoleShells, aNewSolids; + TopoDS_Shape anInfinitePointShape; + TopTools_DataMapOfShapeShape aInOutMap; + TopTools_ListIteratorOfListOfShape aShellIt, aSolisIt; + BRep_Builder aBB; + // + aShellIt.Initialize(theShellList); + for ( ; aShellIt.More(); aShellIt.Next()) { + const TopoDS_Shape & aShell = aShellIt.Value(); + // check if a shell is a hole of theSolid + if (NMTAlgo_Tools::IsInside(anInfinitePointShape, aShell)){ + aHoleShells.Append(aShell); + } + else { + // make a solid from a shell + TopoDS_Solid Solid; + aBB.MakeSolid( Solid ); + aBB.Add (Solid, aShell); + aNewSolids.Append (Solid); + } + } + // + // find outer a shell most close to each hole shell + aShellIt.Initialize(aHoleShells); + for (; aShellIt.More(); aShellIt.Next()){ + const TopoDS_Shape & aHole = aShellIt.Value(); + // + aSolisIt.Initialize(aNewSolids); + for ( ; aSolisIt.More(); aSolisIt.Next()) { + const TopoDS_Shape & aSolid = aSolisIt.Value(); + // + if (! NMTAlgo_Tools::IsInside(aHole, aSolid)){ + continue; + } + // + if ( aInOutMap.IsBound (aHole)){ + const TopoDS_Shape & aSolid2 = aInOutMap( aHole ); + if ( IsInside( aSolid, aSolid2 )) { + aInOutMap.UnBind( aHole ); + aInOutMap.Bind ( aHole, aSolid ); + } + } + else{ + aInOutMap.Bind (aHole, aSolid); + } + } + // + // add aHole to a solid + if (aInOutMap.IsBound( aHole )){ + TopoDS_Shape & aSolid=aInOutMap(aHole); + aBB.Add (aSolid, aHole); + } + } + theShellList.Clear(); + theShellList.Append( aNewSolids ); +} +//======================================================================= +//function : BreakWebs +//purpose : +//======================================================================= + void NMTAlgo_Tools::BreakWebs(const TopoDS_Shape& aCS, + TopoDS_Shape& aCSR) +{ + Standard_Integer i, aNbF, aNbS; + TopTools_IndexedDataMapOfShapeListOfShape aMFS; + TopTools_MapOfShape aMF; + + TopoDS_Compound aFC, aCR; + BRep_Builder aBB; + // + aBB.MakeCompound(aFC); + TopExp::MapShapesAndAncestors(aCS, TopAbs_FACE, TopAbs_SOLID, aMFS); + // + aNbF=aMFS.Extent(); + for (i=1; i<=aNbF; ++i) { + const TopoDS_Shape& aF=aMFS.FindKey(i); + const TopTools_ListOfShape& aLS=aMFS(i); + aNbS=aLS.Extent(); + if (aNbS==2) { + aMF.Add(aF); + } + else { + aBB.Add(aFC, aF); + } + } + // + if (!aMF.Extent()) { + aCSR=aCS; + return; + } + // + TopTools_ListOfShape aLNS; + TopTools_ListIteratorOfListOfShape aItS; + // + NMTAlgo_Tools::MakeShells(aFC, aLNS); + NMTAlgo_Tools::MakeSolids(aLNS); + // + aBB.MakeCompound(aCR); + aItS.Initialize(aLNS); + for ( ;aItS.More(); aItS.Next()) { + const TopoDS_Shape& aS=aItS.Value(); + aBB.Add(aCR, aS); + } + aCSR=aCR; +} +//======================================================================= +//function : FindImageSolid +//purpose : +//======================================================================= + Standard_Boolean NMTAlgo_Tools::FindImageSolid(const TopoDS_Shape& aFC, + const TopTools_IndexedMapOfShape& aMSo, + TopoDS_Shape& aSox) +{ + Standard_Boolean bFound=Standard_False; + Standard_Integer i, j, aNbSo, aNbF, aNbFSo; + TopoDS_Iterator aIt; + TopTools_IndexedMapOfShape aMFC, aMFSo; + // + aIt.Initialize(aFC); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aF=aIt.Value(); + aMFC.Add(aF); + } + // + aNbF=aMFC.Extent(); + aNbSo=aMSo.Extent(); + for (i=1; i<=aNbSo; ++i) { + const TopoDS_Shape& aSo=aMSo(i); + // + bFound=Standard_True; + aMFSo.Clear(); + TopExp::MapShapes(aSo, TopAbs_FACE, aMFSo); + // + aNbFSo=aMFSo.Extent(); + if (aNbFSo!=aNbF) { + continue; + } + // + for (j=1; j<=aNbFSo; ++j) { + const TopoDS_Shape& aFSo=aMFSo(j); + if (!aMFC.Contains(aFSo)) { + bFound=Standard_False; + break; + } + } + if (bFound) { + aSox=aSo; + return bFound; + } + } + return bFound; +} diff --git a/src/NMTAlgo/NMTAlgo_Tools.hxx b/src/NMTAlgo/NMTAlgo_Tools.hxx new file mode 100644 index 000000000..78e211eb0 --- /dev/null +++ b/src/NMTAlgo/NMTAlgo_Tools.hxx @@ -0,0 +1,105 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _NMTAlgo_Tools_HeaderFile +#define _NMTAlgo_Tools_HeaderFile + +#ifndef _TopAbs_Orientation_HeaderFile +#include +#endif +#ifndef _Standard_Integer_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +class TopoDS_Shell; +class TopoDS_Face; +class TopoDS_Edge; +class TopoDS_Shape; +class TopTools_ListOfShape; +class TopTools_IndexedMapOfShape; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class NMTAlgo_Tools { + +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 void OrientFacesOnShell(const TopoDS_Shell& aShell,TopoDS_Shell& aShellNew) ; +Standard_EXPORT static void OrientFacesOnShell(const TopoDS_Face& aF,TopoDS_Shell& aSh) ; +Standard_EXPORT static TopAbs_Orientation Orientation(const TopoDS_Edge& aE,const TopoDS_Face& aF) ; +Standard_EXPORT static Standard_Integer Sense(const TopoDS_Face& aF1,const TopoDS_Face& aF2) ; +Standard_EXPORT static Standard_Boolean IsInside(const TopoDS_Shape& aS1,const TopoDS_Shape& aS2) ; +Standard_EXPORT static void MakeShells(const TopoDS_Shape& aFC,TopTools_ListOfShape& aLS) ; +Standard_EXPORT static void MakeSolids(TopTools_ListOfShape& aLS) ; +Standard_EXPORT static void MakeSolids(const TopoDS_Shape& aFC,TopTools_ListOfShape& aLS) ; +Standard_EXPORT static void BreakWebs(const TopoDS_Shape& aS1,TopoDS_Shape& aS2) ; +Standard_EXPORT static Standard_Boolean FindImageSolid(const TopoDS_Shape& aFC,const TopTools_IndexedMapOfShape& aMSo,TopoDS_Shape& aSo) ; + + + + + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // + + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/NMTAlgo/NMTAlgo_Tools.ixx b/src/NMTAlgo/NMTAlgo_Tools.ixx new file mode 100644 index 000000000..63e0dbaca --- /dev/null +++ b/src/NMTAlgo/NMTAlgo_Tools.ixx @@ -0,0 +1,19 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include + + + + diff --git a/src/NMTAlgo/NMTAlgo_Tools.jxx b/src/NMTAlgo/NMTAlgo_Tools.jxx new file mode 100644 index 000000000..ce06e1a68 --- /dev/null +++ b/src/NMTAlgo/NMTAlgo_Tools.jxx @@ -0,0 +1,21 @@ +#ifndef _TopoDS_Shell_HeaderFile +#include +#endif +#ifndef _TopoDS_Face_HeaderFile +#include +#endif +#ifndef _TopoDS_Edge_HeaderFile +#include +#endif +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif +#ifndef _TopTools_ListOfShape_HeaderFile +#include +#endif +#ifndef _TopTools_IndexedMapOfShape_HeaderFile +#include +#endif +#ifndef _NMTAlgo_Tools_HeaderFile +#include +#endif diff --git a/src/NMTDS/Handle_NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger.hxx b/src/NMTDS/Handle_NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger.hxx new file mode 100644 index 000000000..b97122941 --- /dev/null +++ b/src/NMTDS/Handle_NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger.hxx @@ -0,0 +1,85 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _Handle_NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger_HeaderFile +#define _Handle_NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger_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 NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger); + +class Handle(NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger) : 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(NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger)():Handle(TCollection_MapNode)() {} + Handle(NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger)(const Handle(NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger)& aHandle) : Handle(TCollection_MapNode)(aHandle) + { + } + + Handle(NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger)(const NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger* anItem) : Handle(TCollection_MapNode)((TCollection_MapNode *)anItem) + { + } + + Handle(NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger)& operator=(const Handle(NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger)& operator=(const NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger* operator->() + { + return (NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger *)ControlAccess(); + } + + NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger* operator->() const + { + return (NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger *)ControlAccess(); + } + + Standard_EXPORT ~Handle(NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger)(); + + Standard_EXPORT static const Handle(NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/NMTDS/Handle_NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors.hxx b/src/NMTDS/Handle_NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors.hxx new file mode 100644 index 000000000..7ea8762ea --- /dev/null +++ b/src/NMTDS/Handle_NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors.hxx @@ -0,0 +1,85 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _Handle_NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors_HeaderFile +#define _Handle_NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors_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 NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors); + +class Handle(NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors) : 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(NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors)():Handle(TCollection_MapNode)() {} + Handle(NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors)(const Handle(NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors)& aHandle) : Handle(TCollection_MapNode)(aHandle) + { + } + + Handle(NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors)(const NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors* anItem) : Handle(TCollection_MapNode)((TCollection_MapNode *)anItem) + { + } + + Handle(NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors)& operator=(const Handle(NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors)& operator=(const NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors* operator->() + { + return (NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors *)ControlAccess(); + } + + NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors* operator->() const + { + return (NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors *)ControlAccess(); + } + + Standard_EXPORT ~Handle(NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors)(); + + Standard_EXPORT static const Handle(NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/NMTDS/Makefile.in b/src/NMTDS/Makefile.in new file mode 100644 index 000000000..7bba78233 --- /dev/null +++ b/src/NMTDS/Makefile.in @@ -0,0 +1,72 @@ +# GEOM NMTAlgo : partition algorithm +# +# 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.salome-platform.org or email : webmaster.salome@opencascade.org +# +# +# +# File : Makefile.in +# Author : Julia DOROVSKIKH +# Module : GEOM +# $Header$ + +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@ + + +@COMMENCE@ + +# Libraries targets +LIB = libNMTDS.la + +LIB_SRC = \ + NMTDS_CArray1OfIndexRange_0.cxx \ + NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger_0.cxx \ + NMTDS_IndexedDataMapOfIntegerIndexedDataMapOfShapeInteger_0.cxx \ + NMTDS_IndexRange.cxx \ + NMTDS_ListIteratorOfListOfIndexedDataMapOfShapeAncestorsSuccessors_0.cxx \ + NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors_0.cxx \ + NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors_0.cxx \ + NMTDS_ShapesDataStructure.cxx + +LIB_CLIENT_IDL = +LIB_SERVER_IDL = + +# header files +EXPORT_HEADERS = \ + NMTDS_ShapesDataStructure.hxx \ + NMTDS_PShapesDataStructure.hxx \ + NMTDS_CArray1OfIndexRange.hxx \ + NMTDS_IndexedDataMapOfIntegerIndexedDataMapOfShapeInteger.hxx \ + Handle_NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger.hxx + +# idl files +EXPORT_IDLS= + + +CPPFLAGS += $(OCC_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome +CXXFLAGS += $(OCC_CXXFLAGS) -I${KERNEL_ROOT_DIR}/include/salome +LDFLAGS += $(CAS_LDPATH) -lTKBool -lTKBO -L${KERNEL_ROOT_DIR}/lib/salome + +%_moc.cxx: %.h + $(MOC) $< -o $@ + +@CONCLUDE@ diff --git a/src/NMTDS/NMTDS.cdl b/src/NMTDS/NMTDS.cdl new file mode 100644 index 000000000..19f4c097f --- /dev/null +++ b/src/NMTDS/NMTDS.cdl @@ -0,0 +1,39 @@ +-- File: NMTDS.cdl +-- Created: Fri Nov 28 10:13:19 2003 +-- Author: Peter KURNEV +-- +---Copyright: Matra Datavision 2003 + + +package NMTDS + + ---Purpose: + +uses + + TCollection, + TColStd, + Bnd, + TopoDS, + TopAbs, + TopTools, + BooleanOperations, + BOPTColStd +is + class ShapesDataStructure; + class IndexRange; + + pointer PShapesDataStructure to ShapesDataStructure from NMTDS; + + class CArray1OfIndexRange instantiates + CArray1 from BOPTColStd(IndexRange from NMTDS); + + class ListOfIndexedDataMapOfShapeAncestorsSuccessors instantiates + List from TCollection(IndexedDataMapOfShapeAncestorsSuccessors from BooleanOperations); + + class IndexedDataMapOfIntegerIndexedDataMapOfShapeInteger instantiates + IndexedDataMap from TCollection(Integer from Standard, + IndexedDataMapOfShapeInteger from BooleanOperations, + MapIntegerHasher from TColStd); + +end NMTDS; diff --git a/src/NMTDS/NMTDS_CArray1OfIndexRange.hxx b/src/NMTDS/NMTDS_CArray1OfIndexRange.hxx new file mode 100644 index 000000000..ad5d74299 --- /dev/null +++ b/src/NMTDS/NMTDS_CArray1OfIndexRange.hxx @@ -0,0 +1,132 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _NMTDS_CArray1OfIndexRange_HeaderFile +#define _NMTDS_CArray1OfIndexRange_HeaderFile + +#ifndef _Standard_Address_HeaderFile +#include +#endif +#ifndef _Standard_Integer_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +class Standard_OutOfRange; +class Standard_OutOfMemory; +class NMTDS_IndexRange; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class NMTDS_CArray1OfIndexRange { + +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 NMTDS_CArray1OfIndexRange(const Standard_Integer Length = 0,const Standard_Integer BlockLength = 5); +Standard_EXPORT void Resize(const Standard_Integer theNewLength) ; +Standard_EXPORT void Destroy() ; +~NMTDS_CArray1OfIndexRange() +{ + Destroy(); +} + +Standard_EXPORT Standard_Integer Length() const; +Standard_EXPORT Standard_Integer Extent() const; +Standard_EXPORT Standard_Integer FactLength() const; +Standard_EXPORT Standard_Integer Append(const NMTDS_IndexRange& Value) ; +Standard_EXPORT void Remove(const Standard_Integer Index) ; +Standard_EXPORT const NMTDS_IndexRange& Value(const Standard_Integer Index) const; + const NMTDS_IndexRange& operator ()(const Standard_Integer Index) const +{ + return Value(Index); +} + +Standard_EXPORT NMTDS_IndexRange& ChangeValue(const Standard_Integer Index) ; + NMTDS_IndexRange& operator ()(const Standard_Integer Index) +{ + return ChangeValue(Index); +} + +Standard_EXPORT void SetBlockLength(const Standard_Integer aBL) ; +Standard_EXPORT Standard_Integer BlockLength() const; + + + + + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // +Standard_EXPORT NMTDS_CArray1OfIndexRange(const NMTDS_CArray1OfIndexRange& AnArray); +Standard_EXPORT NMTDS_CArray1OfIndexRange& Assign(const NMTDS_CArray1OfIndexRange& Other) ; + NMTDS_CArray1OfIndexRange& operator =(const NMTDS_CArray1OfIndexRange& Other) +{ + return Assign(Other); +} + +Standard_EXPORT Standard_Boolean IsInvalidIndex(const Standard_Integer Index) const; + + + // Fields PRIVATE + // +Standard_Address myStart; +Standard_Integer myLength; +Standard_Integer myFactLength; +Standard_Integer myBlockLength; +Standard_Boolean myIsAllocated; + + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/NMTDS/NMTDS_CArray1OfIndexRange_0.cxx b/src/NMTDS/NMTDS_CArray1OfIndexRange_0.cxx new file mode 100644 index 000000000..c6bf6ef6e --- /dev/null +++ b/src/NMTDS/NMTDS_CArray1OfIndexRange_0.cxx @@ -0,0 +1,33 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include + +#ifndef _Standard_OutOfRange_HeaderFile +#include +#endif +#ifndef _Standard_OutOfMemory_HeaderFile +#include +#endif +#ifndef _NMTDS_IndexRange_HeaderFile +#include +#endif + + +#define Array1Item NMTDS_IndexRange +#define Array1Item_hxx +#define BOPTColStd_CArray1 NMTDS_CArray1OfIndexRange +#define BOPTColStd_CArray1_hxx +#include + diff --git a/src/NMTDS/NMTDS_IndexRange.cdl b/src/NMTDS/NMTDS_IndexRange.cdl new file mode 100644 index 000000000..6ffa3b86b --- /dev/null +++ b/src/NMTDS/NMTDS_IndexRange.cdl @@ -0,0 +1,39 @@ +-- File: NMTDS_IndexRange.cdl +-- Created: Fri Nov 28 10:31:05 2003 +-- Author: Peter KURNEV +-- +---Copyright: Matra Datavision 2003 + + +class IndexRange from NMTDS + + ---Purpose: + +--uses +--raises + +is + Create + returns IndexRange from NMTDS; + + SetFirst(me:out; + aFirst:Integer from Standard); + + SetLast(me:out; + aLast:Integer from Standard); + + First(me) + returns Integer from Standard; + + Last(me) + returns Integer from Standard; + + IsInRange(me; + aIndex:Integer from Standard) + returns Boolean from Standard; + +fields + myFirst : Integer from Standard is protected; + myLast : Integer from Standard is protected; + +end IndexRange; diff --git a/src/NMTDS/NMTDS_IndexRange.cxx b/src/NMTDS/NMTDS_IndexRange.cxx new file mode 100644 index 000000000..fc406ac30 --- /dev/null +++ b/src/NMTDS/NMTDS_IndexRange.cxx @@ -0,0 +1,57 @@ +// File: NMTDS_IndexRange.cxx +// Created: Fri Nov 28 10:34:59 2003 +// Author: Peter KURNEV +// + + +#include +//======================================================================= +//function :NMTDS_IndexRange::NMTDS_IndexRange +//purpose : +//======================================================================= + NMTDS_IndexRange::NMTDS_IndexRange() +: + myFirst(0), + myLast(0) +{ +} +//======================================================================= +//function :SetFirst +//purpose : +//======================================================================= + void NMTDS_IndexRange::SetFirst(const Standard_Integer aFirst) +{ + myFirst=aFirst; +} +//======================================================================= +//function :First +//purpose : +//======================================================================= + Standard_Integer NMTDS_IndexRange::First()const +{ + return myFirst; +} +//======================================================================= +//function :SetLast +//purpose : +//======================================================================= + void NMTDS_IndexRange::SetLast(const Standard_Integer aLast) +{ + myLast=aLast; +} +//======================================================================= +//function :Last +//purpose : +//======================================================================= + Standard_Integer NMTDS_IndexRange::Last()const +{ + return myLast; +} +//======================================================================= +//function :IsInRange +//purpose : +//======================================================================= + Standard_Boolean NMTDS_IndexRange::IsInRange(const Standard_Integer aIndex)const +{ + return (Standard_Boolean)(aIndex>=myFirst && aIndex<=myLast); +} diff --git a/src/NMTDS/NMTDS_IndexRange.hxx b/src/NMTDS/NMTDS_IndexRange.hxx new file mode 100644 index 000000000..76984233d --- /dev/null +++ b/src/NMTDS/NMTDS_IndexRange.hxx @@ -0,0 +1,94 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _NMTDS_IndexRange_HeaderFile +#define _NMTDS_IndexRange_HeaderFile + +#ifndef _Standard_Integer_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class NMTDS_IndexRange { + +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 NMTDS_IndexRange(); +Standard_EXPORT void SetFirst(const Standard_Integer aFirst) ; +Standard_EXPORT void SetLast(const Standard_Integer aLast) ; +Standard_EXPORT Standard_Integer First() const; +Standard_EXPORT Standard_Integer Last() const; +Standard_EXPORT Standard_Boolean IsInRange(const Standard_Integer aIndex) const; + + + + + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // +Standard_Integer myFirst; +Standard_Integer myLast; + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // + + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/NMTDS/NMTDS_IndexRange.ixx b/src/NMTDS/NMTDS_IndexRange.ixx new file mode 100644 index 000000000..0f8218223 --- /dev/null +++ b/src/NMTDS/NMTDS_IndexRange.ixx @@ -0,0 +1,19 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include + + + + diff --git a/src/NMTDS/NMTDS_IndexRange.jxx b/src/NMTDS/NMTDS_IndexRange.jxx new file mode 100644 index 000000000..6c8407321 --- /dev/null +++ b/src/NMTDS/NMTDS_IndexRange.jxx @@ -0,0 +1,3 @@ +#ifndef _NMTDS_IndexRange_HeaderFile +#include +#endif diff --git a/src/NMTDS/NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger.hxx b/src/NMTDS/NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger.hxx new file mode 100644 index 000000000..18d90fc36 --- /dev/null +++ b/src/NMTDS/NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger.hxx @@ -0,0 +1,136 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#ifndef _NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger_HeaderFile +#define _NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Handle_NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger_HeaderFile +#include +#endif + +#ifndef _Standard_Integer_HeaderFile +#include +#endif +#ifndef _BooleanOperations_IndexedDataMapOfShapeInteger_HeaderFile +#include +#endif +#ifndef _TCollection_MapNodePtr_HeaderFile +#include +#endif +#ifndef _TCollection_MapNode_HeaderFile +#include +#endif +class BooleanOperations_IndexedDataMapOfShapeInteger; +class TColStd_MapIntegerHasher; +class NMTDS_IndexedDataMapOfIntegerIndexedDataMapOfShapeInteger; + + +class NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger : 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 + // +NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger(const Standard_Integer& K1,const Standard_Integer K2,const BooleanOperations_IndexedDataMapOfShapeInteger& I,const TCollection_MapNodePtr& n1,const TCollection_MapNodePtr& n2); + Standard_Integer& Key1() const; + Standard_Integer& Key2() const; + TCollection_MapNodePtr& Next2() const; + BooleanOperations_IndexedDataMapOfShapeInteger& Value() const; +Standard_EXPORT ~NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger(); + + + + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger_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_Integer myKey1; +Standard_Integer myKey2; +BooleanOperations_IndexedDataMapOfShapeInteger myValue; +TCollection_MapNodePtr myNext2; + + +}; + +#define TheKey Standard_Integer +#define TheKey_hxx +#define TheItem BooleanOperations_IndexedDataMapOfShapeInteger +#define TheItem_hxx +#define Hasher TColStd_MapIntegerHasher +#define Hasher_hxx +#define TCollection_IndexedDataMapNode NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger +#define TCollection_IndexedDataMapNode_hxx +#define Handle_TCollection_IndexedDataMapNode Handle_NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger +#define TCollection_IndexedDataMapNode_Type_() NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger_Type_() +#define TCollection_IndexedDataMap NMTDS_IndexedDataMapOfIntegerIndexedDataMapOfShapeInteger +#define TCollection_IndexedDataMap_hxx + +#include + +#undef TheKey +#undef TheKey_hxx +#undef TheItem +#undef TheItem_hxx +#undef Hasher +#undef Hasher_hxx +#undef TCollection_IndexedDataMapNode +#undef TCollection_IndexedDataMapNode_hxx +#undef Handle_TCollection_IndexedDataMapNode +#undef TCollection_IndexedDataMapNode_Type_ +#undef TCollection_IndexedDataMap +#undef TCollection_IndexedDataMap_hxx + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/NMTDS/NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger_0.cxx b/src/NMTDS/NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger_0.cxx new file mode 100644 index 000000000..a69179f00 --- /dev/null +++ b/src/NMTDS/NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger_0.cxx @@ -0,0 +1,93 @@ +// File generated by CPPExt (Transient) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _BooleanOperations_IndexedDataMapOfShapeInteger_HeaderFile +#include +#endif +#ifndef _TColStd_MapIntegerHasher_HeaderFile +#include +#endif +#ifndef _NMTDS_IndexedDataMapOfIntegerIndexedDataMapOfShapeInteger_HeaderFile +#include +#endif +NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger::~NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger() {} + + + +Standard_EXPORT Handle_Standard_Type& NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger_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("NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger", + sizeof(NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + + +// DownCast method +// allow safe downcasting +// +const Handle(NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger) Handle(NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger))) { + _anOtherObject = Handle(NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger)((Handle(NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger)&)AnObject); + } + } + + return _anOtherObject ; +} +const Handle(Standard_Type)& NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger::DynamicType() const +{ + return STANDARD_TYPE(NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger) ; +} +Standard_Boolean NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger::IsKind(const Handle(Standard_Type)& AType) const +{ + return (STANDARD_TYPE(NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger) == AType || TCollection_MapNode::IsKind(AType)); +} +Handle_NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger::~Handle_NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger() {} +#define TheKey Standard_Integer +#define TheKey_hxx +#define TheItem BooleanOperations_IndexedDataMapOfShapeInteger +#define TheItem_hxx +#define Hasher TColStd_MapIntegerHasher +#define Hasher_hxx +#define TCollection_IndexedDataMapNode NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger +#define TCollection_IndexedDataMapNode_hxx +#define Handle_TCollection_IndexedDataMapNode Handle_NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger +#define TCollection_IndexedDataMapNode_Type_() NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger_Type_() +#define TCollection_IndexedDataMap NMTDS_IndexedDataMapOfIntegerIndexedDataMapOfShapeInteger +#define TCollection_IndexedDataMap_hxx +#include + diff --git a/src/NMTDS/NMTDS_IndexedDataMapOfIntegerIndexedDataMapOfShapeInteger.hxx b/src/NMTDS/NMTDS_IndexedDataMapOfIntegerIndexedDataMapOfShapeInteger.hxx new file mode 100644 index 000000000..94e036470 --- /dev/null +++ b/src/NMTDS/NMTDS_IndexedDataMapOfIntegerIndexedDataMapOfShapeInteger.hxx @@ -0,0 +1,133 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _NMTDS_IndexedDataMapOfIntegerIndexedDataMapOfShapeInteger_HeaderFile +#define _NMTDS_IndexedDataMapOfIntegerIndexedDataMapOfShapeInteger_HeaderFile + +#ifndef _TCollection_BasicMap_HeaderFile +#include +#endif +#ifndef _Standard_Integer_HeaderFile +#include +#endif +#ifndef _Handle_NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +class Standard_DomainError; +class Standard_OutOfRange; +class Standard_NoSuchObject; +class BooleanOperations_IndexedDataMapOfShapeInteger; +class TColStd_MapIntegerHasher; +class NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class NMTDS_IndexedDataMapOfIntegerIndexedDataMapOfShapeInteger : public TCollection_BasicMap { + +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 NMTDS_IndexedDataMapOfIntegerIndexedDataMapOfShapeInteger(const Standard_Integer NbBuckets = 1); +Standard_EXPORT NMTDS_IndexedDataMapOfIntegerIndexedDataMapOfShapeInteger& Assign(const NMTDS_IndexedDataMapOfIntegerIndexedDataMapOfShapeInteger& Other) ; + NMTDS_IndexedDataMapOfIntegerIndexedDataMapOfShapeInteger& operator =(const NMTDS_IndexedDataMapOfIntegerIndexedDataMapOfShapeInteger& Other) +{ + return Assign(Other); +} + +Standard_EXPORT void ReSize(const Standard_Integer NbBuckets) ; +Standard_EXPORT void Clear() ; +~NMTDS_IndexedDataMapOfIntegerIndexedDataMapOfShapeInteger() +{ + Clear(); +} + +Standard_EXPORT Standard_Integer Add(const Standard_Integer& K,const BooleanOperations_IndexedDataMapOfShapeInteger& I) ; +Standard_EXPORT void Substitute(const Standard_Integer I,const Standard_Integer& K,const BooleanOperations_IndexedDataMapOfShapeInteger& T) ; +Standard_EXPORT void RemoveLast() ; +Standard_EXPORT Standard_Boolean Contains(const Standard_Integer& K) const; +Standard_EXPORT const Standard_Integer& FindKey(const Standard_Integer I) const; +Standard_EXPORT const BooleanOperations_IndexedDataMapOfShapeInteger& FindFromIndex(const Standard_Integer I) const; + const BooleanOperations_IndexedDataMapOfShapeInteger& operator ()(const Standard_Integer I) const +{ + return FindFromIndex(I); +} + +Standard_EXPORT BooleanOperations_IndexedDataMapOfShapeInteger& ChangeFromIndex(const Standard_Integer I) ; + BooleanOperations_IndexedDataMapOfShapeInteger& operator ()(const Standard_Integer I) +{ + return ChangeFromIndex(I); +} + +Standard_EXPORT Standard_Integer FindIndex(const Standard_Integer& K) const; +Standard_EXPORT const BooleanOperations_IndexedDataMapOfShapeInteger& FindFromKey(const Standard_Integer& K) const; +Standard_EXPORT BooleanOperations_IndexedDataMapOfShapeInteger& ChangeFromKey(const Standard_Integer& K) ; + + + + + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // +Standard_EXPORT NMTDS_IndexedDataMapOfIntegerIndexedDataMapOfShapeInteger(const NMTDS_IndexedDataMapOfIntegerIndexedDataMapOfShapeInteger& Other); + + + // Fields PRIVATE + // + + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/NMTDS/NMTDS_IndexedDataMapOfIntegerIndexedDataMapOfShapeInteger_0.cxx b/src/NMTDS/NMTDS_IndexedDataMapOfIntegerIndexedDataMapOfShapeInteger_0.cxx new file mode 100644 index 000000000..f3a1280e0 --- /dev/null +++ b/src/NMTDS/NMTDS_IndexedDataMapOfIntegerIndexedDataMapOfShapeInteger_0.cxx @@ -0,0 +1,50 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include + +#ifndef _Standard_DomainError_HeaderFile +#include +#endif +#ifndef _Standard_OutOfRange_HeaderFile +#include +#endif +#ifndef _Standard_NoSuchObject_HeaderFile +#include +#endif +#ifndef _BooleanOperations_IndexedDataMapOfShapeInteger_HeaderFile +#include +#endif +#ifndef _TColStd_MapIntegerHasher_HeaderFile +#include +#endif +#ifndef _NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger_HeaderFile +#include +#endif + + +#define TheKey Standard_Integer +#define TheKey_hxx +#define TheItem BooleanOperations_IndexedDataMapOfShapeInteger +#define TheItem_hxx +#define Hasher TColStd_MapIntegerHasher +#define Hasher_hxx +#define TCollection_IndexedDataMapNode NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger +#define TCollection_IndexedDataMapNode_hxx +#define Handle_TCollection_IndexedDataMapNode Handle_NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger +#define TCollection_IndexedDataMapNode_Type_() NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger_Type_() +#define TCollection_IndexedDataMap NMTDS_IndexedDataMapOfIntegerIndexedDataMapOfShapeInteger +#define TCollection_IndexedDataMap_hxx +#include + diff --git a/src/NMTDS/NMTDS_ListIteratorOfListOfIndexedDataMapOfShapeAncestorsSuccessors.hxx b/src/NMTDS/NMTDS_ListIteratorOfListOfIndexedDataMapOfShapeAncestorsSuccessors.hxx new file mode 100644 index 000000000..9994af005 --- /dev/null +++ b/src/NMTDS/NMTDS_ListIteratorOfListOfIndexedDataMapOfShapeAncestorsSuccessors.hxx @@ -0,0 +1,124 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _NMTDS_ListIteratorOfListOfIndexedDataMapOfShapeAncestorsSuccessors_HeaderFile +#define _NMTDS_ListIteratorOfListOfIndexedDataMapOfShapeAncestorsSuccessors_HeaderFile + +#ifndef _Standard_Address_HeaderFile +#include +#endif +#ifndef _Handle_NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +class Standard_NoMoreObject; +class Standard_NoSuchObject; +class NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors; +class BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors; +class NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class NMTDS_ListIteratorOfListOfIndexedDataMapOfShapeAncestorsSuccessors { + +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 NMTDS_ListIteratorOfListOfIndexedDataMapOfShapeAncestorsSuccessors(); +Standard_EXPORT NMTDS_ListIteratorOfListOfIndexedDataMapOfShapeAncestorsSuccessors(const NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors& L); +Standard_EXPORT void Initialize(const NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors& L) ; + Standard_Boolean More() const; +Standard_EXPORT void Next() ; +Standard_EXPORT BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors& Value() const; + + +friend class NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors; + + + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // +Standard_Address current; +Standard_Address previous; + + +}; + +#define Item BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors +#define Item_hxx +#define TCollection_ListNode NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors +#define TCollection_ListNode_hxx +#define TCollection_ListIterator NMTDS_ListIteratorOfListOfIndexedDataMapOfShapeAncestorsSuccessors +#define TCollection_ListIterator_hxx +#define Handle_TCollection_ListNode Handle_NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors +#define TCollection_ListNode_Type_() NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors_Type_() +#define TCollection_List NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors +#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/NMTDS/NMTDS_ListIteratorOfListOfIndexedDataMapOfShapeAncestorsSuccessors_0.cxx b/src/NMTDS/NMTDS_ListIteratorOfListOfIndexedDataMapOfShapeAncestorsSuccessors_0.cxx new file mode 100644 index 000000000..bca4ea7df --- /dev/null +++ b/src/NMTDS/NMTDS_ListIteratorOfListOfIndexedDataMapOfShapeAncestorsSuccessors_0.cxx @@ -0,0 +1,45 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include + +#ifndef _Standard_NoMoreObject_HeaderFile +#include +#endif +#ifndef _Standard_NoSuchObject_HeaderFile +#include +#endif +#ifndef _NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors_HeaderFile +#include +#endif +#ifndef _BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors_HeaderFile +#include +#endif +#ifndef _NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors_HeaderFile +#include +#endif + + +#define Item BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors +#define Item_hxx +#define TCollection_ListNode NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors +#define TCollection_ListNode_hxx +#define TCollection_ListIterator NMTDS_ListIteratorOfListOfIndexedDataMapOfShapeAncestorsSuccessors +#define TCollection_ListIterator_hxx +#define Handle_TCollection_ListNode Handle_NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors +#define TCollection_ListNode_Type_() NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors_Type_() +#define TCollection_List NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors +#define TCollection_List_hxx +#include + diff --git a/src/NMTDS/NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors.hxx b/src/NMTDS/NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors.hxx new file mode 100644 index 000000000..5de01f304 --- /dev/null +++ b/src/NMTDS/NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors.hxx @@ -0,0 +1,123 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#ifndef _NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors_HeaderFile +#define _NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Handle_NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors_HeaderFile +#include +#endif + +#ifndef _BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors_HeaderFile +#include +#endif +#ifndef _TCollection_MapNode_HeaderFile +#include +#endif +#ifndef _TCollection_MapNodePtr_HeaderFile +#include +#endif +class BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors; +class NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors; +class NMTDS_ListIteratorOfListOfIndexedDataMapOfShapeAncestorsSuccessors; + + +class NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors : 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 + // +NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors(const BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors& I,const TCollection_MapNodePtr& n); + BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors& Value() const; +Standard_EXPORT ~NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors(); + + + + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors_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 + // +BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors myValue; + + +}; + +#define Item BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors +#define Item_hxx +#define TCollection_ListNode NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors +#define TCollection_ListNode_hxx +#define TCollection_ListIterator NMTDS_ListIteratorOfListOfIndexedDataMapOfShapeAncestorsSuccessors +#define TCollection_ListIterator_hxx +#define Handle_TCollection_ListNode Handle_NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors +#define TCollection_ListNode_Type_() NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors_Type_() +#define TCollection_List NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors +#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/NMTDS/NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors_0.cxx b/src/NMTDS/NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors_0.cxx new file mode 100644 index 000000000..f7566ef5f --- /dev/null +++ b/src/NMTDS/NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors_0.cxx @@ -0,0 +1,91 @@ +// File generated by CPPExt (Transient) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors_HeaderFile +#include +#endif +#ifndef _NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors_HeaderFile +#include +#endif +#ifndef _NMTDS_ListIteratorOfListOfIndexedDataMapOfShapeAncestorsSuccessors_HeaderFile +#include +#endif +NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors::~NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors() {} + + + +Standard_EXPORT Handle_Standard_Type& NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors_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("NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors", + sizeof(NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + + +// DownCast method +// allow safe downcasting +// +const Handle(NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors) Handle(NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors))) { + _anOtherObject = Handle(NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors)((Handle(NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors)&)AnObject); + } + } + + return _anOtherObject ; +} +const Handle(Standard_Type)& NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors::DynamicType() const +{ + return STANDARD_TYPE(NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors) ; +} +Standard_Boolean NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors::IsKind(const Handle(Standard_Type)& AType) const +{ + return (STANDARD_TYPE(NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors) == AType || TCollection_MapNode::IsKind(AType)); +} +Handle_NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors::~Handle_NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors() {} +#define Item BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors +#define Item_hxx +#define TCollection_ListNode NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors +#define TCollection_ListNode_hxx +#define TCollection_ListIterator NMTDS_ListIteratorOfListOfIndexedDataMapOfShapeAncestorsSuccessors +#define TCollection_ListIterator_hxx +#define Handle_TCollection_ListNode Handle_NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors +#define TCollection_ListNode_Type_() NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors_Type_() +#define TCollection_List NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors +#define TCollection_List_hxx +#include + diff --git a/src/NMTDS/NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors.hxx b/src/NMTDS/NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors.hxx new file mode 100644 index 000000000..600531c53 --- /dev/null +++ b/src/NMTDS/NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors.hxx @@ -0,0 +1,150 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors_HeaderFile +#define _NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors_HeaderFile + +#ifndef _Standard_Address_HeaderFile +#include +#endif +#ifndef _Handle_NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors_HeaderFile +#include +#endif +#ifndef _Standard_Integer_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +class Standard_NoSuchObject; +class NMTDS_ListIteratorOfListOfIndexedDataMapOfShapeAncestorsSuccessors; +class BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors; +class NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors { + +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 NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors(); +Standard_EXPORT void Assign(const NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors& Other) ; + void operator=(const NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors& Other) +{ + Assign(Other); +} + +Standard_EXPORT Standard_Integer Extent() const; +Standard_EXPORT void Clear() ; +~NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors() +{ + Clear(); +} + + Standard_Boolean IsEmpty() const; +Standard_EXPORT void Prepend(const BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors& I) ; +Standard_EXPORT void Prepend(const BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors& I,NMTDS_ListIteratorOfListOfIndexedDataMapOfShapeAncestorsSuccessors& theIt) ; +Standard_EXPORT void Prepend(NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors& Other) ; +Standard_EXPORT void Append(const BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors& I) ; +Standard_EXPORT void Append(const BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors& I,NMTDS_ListIteratorOfListOfIndexedDataMapOfShapeAncestorsSuccessors& theIt) ; +Standard_EXPORT void Append(NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors& Other) ; +Standard_EXPORT BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors& First() const; +Standard_EXPORT BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors& Last() const; +Standard_EXPORT void RemoveFirst() ; +Standard_EXPORT void Remove(NMTDS_ListIteratorOfListOfIndexedDataMapOfShapeAncestorsSuccessors& It) ; +Standard_EXPORT void InsertBefore(const BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors& I,NMTDS_ListIteratorOfListOfIndexedDataMapOfShapeAncestorsSuccessors& It) ; +Standard_EXPORT void InsertBefore(NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors& Other,NMTDS_ListIteratorOfListOfIndexedDataMapOfShapeAncestorsSuccessors& It) ; +Standard_EXPORT void InsertAfter(const BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors& I,NMTDS_ListIteratorOfListOfIndexedDataMapOfShapeAncestorsSuccessors& It) ; +Standard_EXPORT void InsertAfter(NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors& Other,NMTDS_ListIteratorOfListOfIndexedDataMapOfShapeAncestorsSuccessors& It) ; + + +friend class NMTDS_ListIteratorOfListOfIndexedDataMapOfShapeAncestorsSuccessors; + + + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // +Standard_EXPORT NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors(const NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors& Other); + + + // Fields PRIVATE + // +Standard_Address myFirst; +Standard_Address myLast; + + +}; + +#define Item BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors +#define Item_hxx +#define TCollection_ListNode NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors +#define TCollection_ListNode_hxx +#define TCollection_ListIterator NMTDS_ListIteratorOfListOfIndexedDataMapOfShapeAncestorsSuccessors +#define TCollection_ListIterator_hxx +#define Handle_TCollection_ListNode Handle_NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors +#define TCollection_ListNode_Type_() NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors_Type_() +#define TCollection_List NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors +#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/NMTDS/NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors_0.cxx b/src/NMTDS/NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors_0.cxx new file mode 100644 index 000000000..f4bdab6ef --- /dev/null +++ b/src/NMTDS/NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors_0.cxx @@ -0,0 +1,42 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include + +#ifndef _Standard_NoSuchObject_HeaderFile +#include +#endif +#ifndef _NMTDS_ListIteratorOfListOfIndexedDataMapOfShapeAncestorsSuccessors_HeaderFile +#include +#endif +#ifndef _BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors_HeaderFile +#include +#endif +#ifndef _NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors_HeaderFile +#include +#endif + + +#define Item BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors +#define Item_hxx +#define TCollection_ListNode NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors +#define TCollection_ListNode_hxx +#define TCollection_ListIterator NMTDS_ListIteratorOfListOfIndexedDataMapOfShapeAncestorsSuccessors +#define TCollection_ListIterator_hxx +#define Handle_TCollection_ListNode Handle_NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors +#define TCollection_ListNode_Type_() NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors_Type_() +#define TCollection_List NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors +#define TCollection_List_hxx +#include + diff --git a/src/NMTDS/NMTDS_PShapesDataStructure.hxx b/src/NMTDS/NMTDS_PShapesDataStructure.hxx new file mode 100644 index 000000000..11b37cb09 --- /dev/null +++ b/src/NMTDS/NMTDS_PShapesDataStructure.hxx @@ -0,0 +1,22 @@ +// File generated by CPPExt (Pointer) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#ifndef _NMTDS_PShapesDataStructure_HeaderFile +#define _NMTDS_PShapesDataStructure_HeaderFile + +class NMTDS_ShapesDataStructure; + +typedef NMTDS_ShapesDataStructure* NMTDS_PShapesDataStructure; + +#endif diff --git a/src/NMTDS/NMTDS_ShapesDataStructure.cdl b/src/NMTDS/NMTDS_ShapesDataStructure.cdl new file mode 100644 index 000000000..23391971c --- /dev/null +++ b/src/NMTDS/NMTDS_ShapesDataStructure.cdl @@ -0,0 +1,56 @@ +-- File: NMTDS_ShapesDataStructure.cdl +-- Created: Mon Dec 1 10:17:05 2003 +-- Author: Peter KURNEV +-- +---Copyright: Matra Datavision 2003 + + +class ShapesDataStructure from NMTDS + inherits ShapesDataStructure from BooleanOperations + + ---Purpose: + +uses + Shape from TopoDS, + CArray1OfIndexRange from NMTDS, + IndexedDataMapOfIntegerIndexedDataMapOfShapeInteger from NMTDS +--raises + +is + Create + returns ShapesDataStructure from NMTDS; + + SetCompositeShape(me:out; + aS:Shape from TopoDS); + + Init(me:out); + + Ranges(me) + returns CArray1OfIndexRange from NMTDS; + ---C++: return const & + + CompositeShape(me) + returns Shape from TopoDS; + ---C++: return const & + + ShapeRangeIndex(me; + aId:Integer from Standard) + returns Integer from Standard; + + Rank (me; + anIndex:Integer from Standard) + returns Integer from Standard + is redefined; + + ShapeIndex (me; + aS:Shape from TopoDS; + iRank:Integer from Standard) + returns Integer from Standard + is redefined; +fields + myCompositeShape: Shape from TopoDS is protected; + myRanges : CArray1OfIndexRange from NMTDS is protected; + myShapeIndexMap : IndexedDataMapOfIntegerIndexedDataMapOfShapeInteger from NMTDS is protected; + +end ShapesDataStructure; + diff --git a/src/NMTDS/NMTDS_ShapesDataStructure.cxx b/src/NMTDS/NMTDS_ShapesDataStructure.cxx new file mode 100644 index 000000000..6388a1655 --- /dev/null +++ b/src/NMTDS/NMTDS_ShapesDataStructure.cxx @@ -0,0 +1,226 @@ +// File: NMTDS_ShapesDataStructure.cxx +// Created: Mon Dec 1 10:21:04 2003 +// Author: Peter KURNEV +// + + +#include +#include +#include +#include +#include +#include +#include +#include + +//=========================================================================== +//function : NMTDS_ShapesDataStructure::NMTDS_ShapesDataStructure +//purpose : +//=========================================================================== + NMTDS_ShapesDataStructure::NMTDS_ShapesDataStructure() +: + BooleanOperations_ShapesDataStructure() +{} +//=========================================================================== +//function : SetCompositeShape +//purpose : +//=========================================================================== + void NMTDS_ShapesDataStructure::SetCompositeShape(const TopoDS_Shape& aS) +{ + myCompositeShape=aS; +} +//=========================================================================== +//function : CompositeShape +//purpose : +//=========================================================================== + const TopoDS_Shape& NMTDS_ShapesDataStructure::CompositeShape()const +{ + return myCompositeShape; +} +//=========================================================================== +//function : Ranges +//purpose : +//=========================================================================== + const NMTDS_CArray1OfIndexRange& NMTDS_ShapesDataStructure::Ranges()const +{ + return myRanges; +} +//=========================================================================== +//function : Init +//purpose : +//=========================================================================== + void NMTDS_ShapesDataStructure::Init() +{ + Standard_Integer i, j, aNbSx, aNbS, aShift, aNbRanges; + Standard_Integer iFirst, iLast; + NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors aLx; + NMTDS_ListIteratorOfListOfIndexedDataMapOfShapeAncestorsSuccessors aLit; + TopoDS_Iterator anIt; + // + aNbS=0; + anIt.Initialize(myCompositeShape); + for (i=0; anIt.More(); anIt.Next(), ++i) { + const TopoDS_Shape& aSx=anIt.Value(); + BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors aIndDatMapShape; + FillIndexedMapOfShapesAncestorsAndSuccessors(aSx, aIndDatMapShape); + aNbSx=aIndDatMapShape.Extent(); + aNbS+=aNbSx; + aLx.Append(aIndDatMapShape); + } + // + // Fill myRanges + myRanges.Resize(i); + aLit.Initialize(aLx); + for (i=1; aLit.More(); aLit.Next(), ++i) { + const BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors& aM=aLit.Value(); + aNbSx=aM.Extent(); + if (i==1) { + iFirst=1; + iLast=aNbSx; + myRanges(i).SetFirst(iFirst); + myRanges(i).SetLast(iLast); + continue; + } + iFirst=myRanges(i-1).Last()+1; + iLast=iFirst+aNbSx-1; + myRanges(i).SetFirst(iFirst); + myRanges(i).SetLast(iLast); + } + // + myNumberOfShapesOfTheObject=aNbS; + myNumberOfShapesOfTheTool=aNbS; + myLength=3*aNbS; + // + // Allocate the whole Table + myListOfShapeAndInterferences = (BooleanOperations_PShapeAndInterferences) + Standard::Allocate(myLength*sizeof(BooleanOperations_ShapeAndInterferences)); + // + // Fill the table + for (i=0; i<2; ++i) { + aShift=0; + if (i) { + aShift=myNumberOfShapesOfTheObject; + } + aLit.Initialize(aLx); + for (; aLit.More(); aLit.Next()) { + const BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors& aM=aLit.Value(); + aNbSx=aM.Extent(); + for (j=1; j<=aNbSx; ++j) { + const TopoDS_Shape& aSx=aM.FindKey(j); + const BooleanOperations_AncestorsSeqAndSuccessorsSeq& aASx=aM.FindFromIndex(j); + InsertShapeAndAncestorsSuccessors(aSx, aASx, aShift); + } + aShift+=aNbSx; + } + } + // + // myShapeIndexMap + myShapeIndexMap.Clear(); + // + aNbRanges=myRanges.Extent(); + for (i=1; i<=aNbRanges; ++i){ + BooleanOperations_IndexedDataMapOfShapeInteger aSIM; + // + const NMTDS_IndexRange& aR=myRanges(i); + iFirst=aR.First(); + iLast =aR.Last(); + for (j=iFirst; j<=iLast; ++j) { + const TopoDS_Shape& aS=GetShape(j); + aSIM.Add(aS, j); + } + myShapeIndexMap.Add(i, aSIM); + } + // + // myRefEdges + iLast=myNumberOfShapesOfTheObject+myNumberOfShapesOfTheTool; + myRefEdges.Resize(iLast); + + for (i=1; i<=iLast; ++i) { + const TopoDS_Shape& aS=Shape(i); + myRefEdges(i)=0; + if (aS.ShapeType()==TopAbs_EDGE) { + myNbEdges++; + myRefEdges(i)=myNbEdges; + } + } +} +//=========================================================================== +//function : ShapeRangeIndex +//purpose : +//=========================================================================== + Standard_Integer NMTDS_ShapesDataStructure::ShapeRangeIndex(const Standard_Integer aId)const +{ + Standard_Boolean bFound; + Standard_Integer i, aNbR, aIdx, aNbS, aZero=0; + // + aNbS=myNumberOfShapesOfTheObject+myNumberOfShapesOfTheTool; + + aIdx=aId; + if (aIdx > aNbS || aIdx < 1){ + return aZero; + } + // + if (aIdx > myNumberOfShapesOfTheObject) { + aIdx-=myNumberOfShapesOfTheObject; + } + // + aNbR=myRanges.Extent(); + for (i=1; i<=aNbR; ++i) { + const NMTDS_IndexRange& aRange=myRanges(i); + bFound=aRange.IsInRange(aIdx); + if (bFound) { + return i; + } + } + return aZero; +} +//=========================================================================== +//function : Rank +//purpose : +//=========================================================================== + Standard_Integer NMTDS_ShapesDataStructure::Rank(const Standard_Integer aId)const +{ + Standard_Boolean bFound; + Standard_Integer i, aNbR, aNbS, aZero=0; + // + aNbS=myNumberOfShapesOfTheObject; + + if (aId > aNbS || aId < 1){ + return aZero; + } + // + aNbR=myRanges.Extent(); + for (i=1; i<=aNbR; ++i) { + const NMTDS_IndexRange& aRange=myRanges(i); + bFound=aRange.IsInRange(aId); + if (bFound) { + return i; + } + } + return aZero; +} +//=========================================================================== +//function : ShapeIndex +//purpose : +//=========================================================================== + Standard_Integer NMTDS_ShapesDataStructure::ShapeIndex(const TopoDS_Shape& aS, + const Standard_Integer aRank)const +{ + Standard_Boolean bFound; + Standard_Integer aIndex=0; + // + bFound=myShapeIndexMap.Contains(aRank); + if (!bFound) { + return aIndex; + } + // + const BooleanOperations_IndexedDataMapOfShapeInteger& aSIM=myShapeIndexMap.FindFromKey(aRank); + // + bFound=aSIM.Contains(aS); + if (!bFound) { + return aIndex; + } + // + aIndex=aSIM.FindFromKey(aS); + return aIndex; +} diff --git a/src/NMTDS/NMTDS_ShapesDataStructure.hxx b/src/NMTDS/NMTDS_ShapesDataStructure.hxx new file mode 100644 index 000000000..167ccc337 --- /dev/null +++ b/src/NMTDS/NMTDS_ShapesDataStructure.hxx @@ -0,0 +1,108 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _NMTDS_ShapesDataStructure_HeaderFile +#define _NMTDS_ShapesDataStructure_HeaderFile + +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif +#ifndef _NMTDS_CArray1OfIndexRange_HeaderFile +#include +#endif +#ifndef _NMTDS_IndexedDataMapOfIntegerIndexedDataMapOfShapeInteger_HeaderFile +#include +#endif +#ifndef _BooleanOperations_ShapesDataStructure_HeaderFile +#include +#endif +#ifndef _Standard_Integer_HeaderFile +#include +#endif +class TopoDS_Shape; +class NMTDS_CArray1OfIndexRange; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class NMTDS_ShapesDataStructure : public BooleanOperations_ShapesDataStructure { + +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 NMTDS_ShapesDataStructure(); +Standard_EXPORT void SetCompositeShape(const TopoDS_Shape& aS) ; +Standard_EXPORT void Init() ; +Standard_EXPORT const NMTDS_CArray1OfIndexRange& Ranges() const; +Standard_EXPORT const TopoDS_Shape& CompositeShape() const; +Standard_EXPORT Standard_Integer ShapeRangeIndex(const Standard_Integer aId) const; +Standard_EXPORT virtual Standard_Integer Rank(const Standard_Integer anIndex) const; +Standard_EXPORT virtual Standard_Integer ShapeIndex(const TopoDS_Shape& aS,const Standard_Integer iRank) const; + + + + + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // +TopoDS_Shape myCompositeShape; +NMTDS_CArray1OfIndexRange myRanges; +NMTDS_IndexedDataMapOfIntegerIndexedDataMapOfShapeInteger myShapeIndexMap; + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // + + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/NMTDS/NMTDS_ShapesDataStructure.ixx b/src/NMTDS/NMTDS_ShapesDataStructure.ixx new file mode 100644 index 000000000..755a41624 --- /dev/null +++ b/src/NMTDS/NMTDS_ShapesDataStructure.ixx @@ -0,0 +1,19 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include + + + + diff --git a/src/NMTDS/NMTDS_ShapesDataStructure.jxx b/src/NMTDS/NMTDS_ShapesDataStructure.jxx new file mode 100644 index 000000000..fc29ab68f --- /dev/null +++ b/src/NMTDS/NMTDS_ShapesDataStructure.jxx @@ -0,0 +1,9 @@ +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif +#ifndef _NMTDS_CArray1OfIndexRange_HeaderFile +#include +#endif +#ifndef _NMTDS_ShapesDataStructure_HeaderFile +#include +#endif diff --git a/src/NMTTools/Handle_NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger.hxx b/src/NMTTools/Handle_NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger.hxx new file mode 100644 index 000000000..b97122941 --- /dev/null +++ b/src/NMTTools/Handle_NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger.hxx @@ -0,0 +1,85 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _Handle_NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger_HeaderFile +#define _Handle_NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger_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 NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger); + +class Handle(NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger) : 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(NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger)():Handle(TCollection_MapNode)() {} + Handle(NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger)(const Handle(NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger)& aHandle) : Handle(TCollection_MapNode)(aHandle) + { + } + + Handle(NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger)(const NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger* anItem) : Handle(TCollection_MapNode)((TCollection_MapNode *)anItem) + { + } + + Handle(NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger)& operator=(const Handle(NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger)& operator=(const NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger* operator->() + { + return (NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger *)ControlAccess(); + } + + NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger* operator->() const + { + return (NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger *)ControlAccess(); + } + + Standard_EXPORT ~Handle(NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger)(); + + Standard_EXPORT static const Handle(NMTDS_IndexedDataMapNodeOfIndexedDataMapOfIntegerIndexedDataMapOfShapeInteger) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/NMTTools/Handle_NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors.hxx b/src/NMTTools/Handle_NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors.hxx new file mode 100644 index 000000000..7ea8762ea --- /dev/null +++ b/src/NMTTools/Handle_NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors.hxx @@ -0,0 +1,85 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _Handle_NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors_HeaderFile +#define _Handle_NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors_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 NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors); + +class Handle(NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors) : 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(NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors)():Handle(TCollection_MapNode)() {} + Handle(NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors)(const Handle(NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors)& aHandle) : Handle(TCollection_MapNode)(aHandle) + { + } + + Handle(NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors)(const NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors* anItem) : Handle(TCollection_MapNode)((TCollection_MapNode *)anItem) + { + } + + Handle(NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors)& operator=(const Handle(NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors)& operator=(const NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors* operator->() + { + return (NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors *)ControlAccess(); + } + + NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors* operator->() const + { + return (NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors *)ControlAccess(); + } + + Standard_EXPORT ~Handle(NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors)(); + + Standard_EXPORT static const Handle(NMTDS_ListNodeOfListOfIndexedDataMapOfShapeAncestorsSuccessors) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/NMTTools/Handle_NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger.hxx b/src/NMTTools/Handle_NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger.hxx new file mode 100644 index 000000000..17949ac4a --- /dev/null +++ b/src/NMTTools/Handle_NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger.hxx @@ -0,0 +1,85 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _Handle_NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger_HeaderFile +#define _Handle_NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger_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 NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger); + +class Handle(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger) : 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(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger)():Handle(TCollection_MapNode)() {} + Handle(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger)(const Handle(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger)& aHandle) : Handle(TCollection_MapNode)(aHandle) + { + } + + Handle(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger)(const NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger* anItem) : Handle(TCollection_MapNode)((TCollection_MapNode *)anItem) + { + } + + Handle(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger)& operator=(const Handle(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger)& operator=(const NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger* operator->() + { + return (NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger *)ControlAccess(); + } + + NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger* operator->() const + { + return (NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger *)ControlAccess(); + } + + Standard_EXPORT ~Handle(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger)(); + + Standard_EXPORT static const Handle(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/NMTTools/Handle_NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape.hxx b/src/NMTTools/Handle_NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape.hxx new file mode 100644 index 000000000..cbcf4a002 --- /dev/null +++ b/src/NMTTools/Handle_NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape.hxx @@ -0,0 +1,85 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _Handle_NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape_HeaderFile +#define _Handle_NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape_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 NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape); + +class Handle(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape) : 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(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape)():Handle(TCollection_MapNode)() {} + Handle(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape)(const Handle(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape)& aHandle) : Handle(TCollection_MapNode)(aHandle) + { + } + + Handle(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape)(const NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape* anItem) : Handle(TCollection_MapNode)((TCollection_MapNode *)anItem) + { + } + + Handle(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape)& operator=(const Handle(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape)& operator=(const NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape* operator->() + { + return (NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape *)ControlAccess(); + } + + NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape* operator->() const + { + return (NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape *)ControlAccess(); + } + + Standard_EXPORT ~Handle(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape)(); + + Standard_EXPORT static const Handle(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/NMTTools/Handle_NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock.hxx b/src/NMTTools/Handle_NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock.hxx new file mode 100644 index 000000000..8dfb499b2 --- /dev/null +++ b/src/NMTTools/Handle_NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock.hxx @@ -0,0 +1,85 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _Handle_NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock_HeaderFile +#define _Handle_NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock_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 NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock); + +class Handle(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock) : 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(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock)():Handle(TCollection_MapNode)() {} + Handle(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock)(const Handle(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock)& aHandle) : Handle(TCollection_MapNode)(aHandle) + { + } + + Handle(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock)(const NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock* anItem) : Handle(TCollection_MapNode)((TCollection_MapNode *)anItem) + { + } + + Handle(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock)& operator=(const Handle(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock)& operator=(const NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock* operator->() + { + return (NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock *)ControlAccess(); + } + + NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock* operator->() const + { + return (NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock *)ControlAccess(); + } + + Standard_EXPORT ~Handle(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock)(); + + Standard_EXPORT static const Handle(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/NMTTools/Handle_NMTTools_ListNodeOfListOfCommonBlock.hxx b/src/NMTTools/Handle_NMTTools_ListNodeOfListOfCommonBlock.hxx new file mode 100644 index 000000000..a77311063 --- /dev/null +++ b/src/NMTTools/Handle_NMTTools_ListNodeOfListOfCommonBlock.hxx @@ -0,0 +1,85 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _Handle_NMTTools_ListNodeOfListOfCommonBlock_HeaderFile +#define _Handle_NMTTools_ListNodeOfListOfCommonBlock_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 NMTTools_ListNodeOfListOfCommonBlock; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(NMTTools_ListNodeOfListOfCommonBlock); + +class Handle(NMTTools_ListNodeOfListOfCommonBlock) : 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(NMTTools_ListNodeOfListOfCommonBlock)():Handle(TCollection_MapNode)() {} + Handle(NMTTools_ListNodeOfListOfCommonBlock)(const Handle(NMTTools_ListNodeOfListOfCommonBlock)& aHandle) : Handle(TCollection_MapNode)(aHandle) + { + } + + Handle(NMTTools_ListNodeOfListOfCommonBlock)(const NMTTools_ListNodeOfListOfCommonBlock* anItem) : Handle(TCollection_MapNode)((TCollection_MapNode *)anItem) + { + } + + Handle(NMTTools_ListNodeOfListOfCommonBlock)& operator=(const Handle(NMTTools_ListNodeOfListOfCommonBlock)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(NMTTools_ListNodeOfListOfCommonBlock)& operator=(const NMTTools_ListNodeOfListOfCommonBlock* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + NMTTools_ListNodeOfListOfCommonBlock* operator->() + { + return (NMTTools_ListNodeOfListOfCommonBlock *)ControlAccess(); + } + + NMTTools_ListNodeOfListOfCommonBlock* operator->() const + { + return (NMTTools_ListNodeOfListOfCommonBlock *)ControlAccess(); + } + + Standard_EXPORT ~Handle(NMTTools_ListNodeOfListOfCommonBlock)(); + + Standard_EXPORT static const Handle(NMTTools_ListNodeOfListOfCommonBlock) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/NMTTools/Handle_NMTTools_ListNodeOfListOfCoupleOfShape.hxx b/src/NMTTools/Handle_NMTTools_ListNodeOfListOfCoupleOfShape.hxx new file mode 100644 index 000000000..66f885016 --- /dev/null +++ b/src/NMTTools/Handle_NMTTools_ListNodeOfListOfCoupleOfShape.hxx @@ -0,0 +1,85 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _Handle_NMTTools_ListNodeOfListOfCoupleOfShape_HeaderFile +#define _Handle_NMTTools_ListNodeOfListOfCoupleOfShape_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 NMTTools_ListNodeOfListOfCoupleOfShape; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(NMTTools_ListNodeOfListOfCoupleOfShape); + +class Handle(NMTTools_ListNodeOfListOfCoupleOfShape) : 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(NMTTools_ListNodeOfListOfCoupleOfShape)():Handle(TCollection_MapNode)() {} + Handle(NMTTools_ListNodeOfListOfCoupleOfShape)(const Handle(NMTTools_ListNodeOfListOfCoupleOfShape)& aHandle) : Handle(TCollection_MapNode)(aHandle) + { + } + + Handle(NMTTools_ListNodeOfListOfCoupleOfShape)(const NMTTools_ListNodeOfListOfCoupleOfShape* anItem) : Handle(TCollection_MapNode)((TCollection_MapNode *)anItem) + { + } + + Handle(NMTTools_ListNodeOfListOfCoupleOfShape)& operator=(const Handle(NMTTools_ListNodeOfListOfCoupleOfShape)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(NMTTools_ListNodeOfListOfCoupleOfShape)& operator=(const NMTTools_ListNodeOfListOfCoupleOfShape* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + NMTTools_ListNodeOfListOfCoupleOfShape* operator->() + { + return (NMTTools_ListNodeOfListOfCoupleOfShape *)ControlAccess(); + } + + NMTTools_ListNodeOfListOfCoupleOfShape* operator->() const + { + return (NMTTools_ListNodeOfListOfCoupleOfShape *)ControlAccess(); + } + + Standard_EXPORT ~Handle(NMTTools_ListNodeOfListOfCoupleOfShape)(); + + Standard_EXPORT static const Handle(NMTTools_ListNodeOfListOfCoupleOfShape) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/NMTTools/Makefile.in b/src/NMTTools/Makefile.in new file mode 100644 index 000000000..9d5cbe8c2 --- /dev/null +++ b/src/NMTTools/Makefile.in @@ -0,0 +1,103 @@ +# GEOM NMTTools : partition algorithm +# +# 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.salome-platform.org or email : webmaster.salome@opencascade.org +# +# +# +# File : Makefile.in +# Author : Julia DOROVSKIKH +# Module : GEOM +# $Header$ + +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@ + + +@COMMENCE@ + +# Libraries targets +LIB = libNMTTools.la +LIB_SRC = \ + NMTTools_CommonBlock.cxx \ + NMTTools_CommonBlockAPI.cxx \ + NMTTools_CommonBlockPool_0.cxx \ + NMTTools_CoupleOfShape.cxx \ + NMTTools_DEProcessor.cxx \ + NMTTools_DSFiller.cxx \ + NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger_0.cxx \ + NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape_0.cxx \ + NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock_0.cxx \ + NMTTools_IndexedDataMapOfIndexedMapOfInteger_0.cxx \ + NMTTools_IndexedDataMapOfShapeIndexedMapOfShape_0.cxx \ + NMTTools_IndexedDataMapOfShapePaveBlock_0.cxx \ + NMTTools_IteratorOfCoupleOfShape.cxx \ + NMTTools_ListIteratorOfListOfCommonBlock_0.cxx \ + NMTTools_ListIteratorOfListOfCoupleOfShape_0.cxx \ + NMTTools_ListNodeOfListOfCommonBlock_0.cxx \ + NMTTools_ListNodeOfListOfCoupleOfShape_0.cxx \ + NMTTools_ListOfCommonBlock_0.cxx \ + NMTTools_ListOfCoupleOfShape_0.cxx \ + NMTTools_PaveFiller.cxx \ + NMTTools_PaveFiller_0.cxx \ + NMTTools_PaveFiller_1.cxx \ + NMTTools_PaveFiller_2.cxx \ + NMTTools_PaveFiller_3.cxx \ + NMTTools_PaveFiller_4.cxx \ + NMTTools_PaveFiller_5.cxx \ + NMTTools_PaveFiller_6.cxx \ + NMTTools_PaveFiller_7.cxx \ + NMTTools_PaveFiller_8.cxx \ + NMTTools_PaveFiller_9.cxx \ + NMTTools_PCurveMaker.cxx \ + NMTTools_Tools.cxx + +LIB_CLIENT_IDL = +LIB_SERVER_IDL = + +# header files +EXPORT_HEADERS = \ + NMTTools_PDSFiller.hxx \ + NMTTools_DSFiller.hxx \ + NMTTools_PPaveFiller.hxx \ + NMTTools_PaveFiller.hxx \ + NMTTools_ListOfCoupleOfShape.hxx \ + NMTTools_Tools.hxx \ + NMTTools_CoupleOfShape.hxx \ + NMTTools_ListIteratorOfListOfCoupleOfShape.hxx \ + NMTTools_IndexedDataMapOfShapeIndexedMapOfShape.hxx \ + NMTTools_IteratorOfCoupleOfShape.hxx \ + NMTTools_CommonBlockPool.hxx \ + Handle_NMTTools_ListNodeOfListOfCoupleOfShape.hxx \ + Handle_NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape.hxx + +# idl files +EXPORT_IDLS= + + +CPPFLAGS += $(OCC_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome +CXXFLAGS += $(OCC_CXXFLAGS) -I${KERNEL_ROOT_DIR}/include/salome +LDFLAGS += $(CAS_LDPATH) -lNMTDS -lTKBool -lTKBO -L${KERNEL_ROOT_DIR}/lib/salome + +%_moc.cxx: %.h + $(MOC) $< -o $@ + +@CONCLUDE@ diff --git a/src/NMTTools/NMTTools.cdl b/src/NMTTools/NMTTools.cdl new file mode 100644 index 000000000..78ba75d76 --- /dev/null +++ b/src/NMTTools/NMTTools.cdl @@ -0,0 +1,66 @@ +-- File: NMTTools.cdl +-- Created: Thu Dec 4 16:55:49 2003 +-- Author: Peter KURNEV +-- +---Copyright: Matra Datavision 2003 + + +package NMTTools + + ---Purpose: + +uses + + TCollection, + TColStd, + gp, + TopAbs, + TopoDS, + TopTools, + Geom2d, + BooleanOperations, + BOPTColStd, + IntTools, + BOPTools, + + NMTDS + +is + class IteratorOfCoupleOfShape; + class DSFiller; + class PaveFiller; + class Tools; + class CommonBlock; + class CommonBlockAPI; + class PCurveMaker; + class DEProcessor; + class CoupleOfShape; + + pointer PPaveFiller to PaveFiller from NMTTools; + pointer PDSFiller to DSFiller from NMTTools; + + class ListOfCommonBlock instantiates + List from TCollection(CommonBlock from NMTTools); + + class CommonBlockPool instantiates + CArray1 from BOPTColStd (ListOfCommonBlock from NMTTools); + + class IndexedDataMapOfIndexedMapOfInteger instantiates + IndexedDataMap from TCollection (Integer from Standard, + IndexedMapOfInteger from TColStd, + MapIntegerHasher from TColStd); + + class IndexedDataMapOfShapePaveBlock instantiates + IndexedDataMap from TCollection (Shape from TopoDS, + PaveBlock from BOPTools, + ShapeMapHasher from TopTools); + + class IndexedDataMapOfShapeIndexedMapOfShape instantiates + IndexedDataMap from TCollection (Shape from TopoDS, + IndexedMapOfShape from TopTools, + ShapeMapHasher from TopTools); + + class ListOfCoupleOfShape instantiates + List from TCollection(CoupleOfShape from NMTTools); + +end NMTTools; diff --git a/src/NMTTools/NMTTools_CommonBlock.cdl b/src/NMTTools/NMTTools_CommonBlock.cdl new file mode 100644 index 000000000..5971991f6 --- /dev/null +++ b/src/NMTTools/NMTTools_CommonBlock.cdl @@ -0,0 +1,88 @@ +-- File: NMTTools_CommonBlock.cdl +-- Created: Tue Dec 9 12:11:48 2003 +-- Author: Peter KURNEV +-- +---Copyright: Matra Datavision 2003 + + +class CommonBlock from NMTTools + + ---Purpose: + +uses + ListOfInteger from TColStd, + PaveBlock from BOPTools, + ListOfPaveBlock from BOPTools + +--raises + +is + Create + returns CommonBlock from NMTTools; + + AddPaveBlock(me:out; + aPB : PaveBlock from BOPTools); + + AddFace(me:out; + aF : Integer from Standard); + + AddFaces(me:out; + aLF: ListOfInteger from TColStd); + + PaveBlocks(me) + returns ListOfPaveBlock from BOPTools; + ---C++: return const & + + Faces (me) + returns ListOfInteger from TColStd; + ---C++: return const & + + PaveBlock1 (me) + returns PaveBlock from BOPTools; + ---C++: return const & + + PaveBlock1 (me:out; + anIx: Integer from Standard) + returns PaveBlock from BOPTools; + ---C++: return & + + PaveBlockOnEdge (me:out; + anIndex: Integer from Standard) + returns PaveBlock from BOPTools; + ---C++: return & + + IsPaveBlockOnFace (me; + anIndex: Integer from Standard) + returns Boolean from Standard; + + IsPaveBlockOnEdge (me; + anIndex: Integer from Standard) + returns Boolean from Standard; + + IsEqual (me; + aCB:CommonBlock from NMTTools) + returns Boolean from Standard; + + Contains(me; + aPB:PaveBlock from BOPTools) + returns Boolean from Standard; + +-- SetEdge (me:out; +-- anEdge:Integer from Standard); + +-- Edge (me) +-- returns Integer from Standard; + +fields + myPaveBlocks: ListOfPaveBlock from BOPTools is protected; + myFaces : ListOfInteger from TColStd is protected; + +end CommonBlock; + + + + + + + + diff --git a/src/NMTTools/NMTTools_CommonBlock.cxx b/src/NMTTools/NMTTools_CommonBlock.cxx new file mode 100644 index 000000000..80ab56142 --- /dev/null +++ b/src/NMTTools/NMTTools_CommonBlock.cxx @@ -0,0 +1,227 @@ +// File: NMTTools_CommonBlock.cxx +// Created: Tue Dec 9 12:23:29 2003 +// Author: Peter KURNEV +// + + +#include + +#include +#include + +//======================================================================= +// function: NMTTools_CommonBlock::NMTTools_CommonBlock() +// purpose: +//======================================================================= + NMTTools_CommonBlock::NMTTools_CommonBlock() +{ +} +//======================================================================= +// function: AddPaveBlock +// purpose: +//======================================================================= + void NMTTools_CommonBlock::AddPaveBlock(const BOPTools_PaveBlock& aPB) +{ + myPaveBlocks.Append(aPB); +} +//======================================================================= +// function: AddFace +// purpose: +//======================================================================= + void NMTTools_CommonBlock::AddFace(const Standard_Integer aF) +{ + myFaces.Append(aF); +} +//======================================================================= +// function: AddFaces +// purpose: +//======================================================================= + void NMTTools_CommonBlock::AddFaces(const TColStd_ListOfInteger& aLF) +{ + TColStd_ListIteratorOfListOfInteger aIt(aLF); + // + for (; aIt.More(); aIt.Next()) { + myFaces.Append(aIt.Value()); + } +} +//======================================================================= +// function: PaveBlocks +// purpose: +//======================================================================= + const BOPTools_ListOfPaveBlock& NMTTools_CommonBlock::PaveBlocks()const +{ + return myPaveBlocks; +} +//======================================================================= +// function: Faces +// purpose: +//======================================================================= + const TColStd_ListOfInteger& NMTTools_CommonBlock::Faces()const +{ + return myFaces; +} +//======================================================================= +// function: PaveBlock1 +// purpose: +//======================================================================= + const BOPTools_PaveBlock& NMTTools_CommonBlock::PaveBlock1()const +{ + return myPaveBlocks.First(); +} +//======================================================================= +// function: PaveBlock1 +// purpose: +//======================================================================= + BOPTools_PaveBlock& NMTTools_CommonBlock::PaveBlock1(const Standard_Integer aIx) +{ + return PaveBlockOnEdge(aIx); +} +//======================================================================= +// function: PaveBlockOnEdge +// purpose: +//======================================================================= + BOPTools_PaveBlock& NMTTools_CommonBlock::PaveBlockOnEdge(const Standard_Integer aIx) +{ + static BOPTools_PaveBlock aPBs; + Standard_Integer aIOr; + BOPTools_ListIteratorOfListOfPaveBlock anIt(myPaveBlocks); + // + for (; anIt.More(); anIt.Next()) { + BOPTools_PaveBlock& aPB=anIt.Value(); + aIOr=aPB.OriginalEdge(); + if (aIOr==aIx){ + return aPB; + } + } + return aPBs; +} +//======================================================================= +// function: IsPaveBlockOnFace +// purpose: +//======================================================================= + Standard_Boolean NMTTools_CommonBlock::IsPaveBlockOnFace(const Standard_Integer aIx)const +{ + Standard_Boolean bFound=Standard_False; + Standard_Integer nF; + TColStd_ListIteratorOfListOfInteger anIt(myFaces); + // + for (; anIt.More(); anIt.Next()) { + nF=anIt.Value(); + if (nF==aIx){ + return !bFound; + } + } + return bFound; +} +//======================================================================= +// function: IsPaveBlockOnEdge +// purpose: +//======================================================================= + Standard_Boolean NMTTools_CommonBlock::IsPaveBlockOnEdge(const Standard_Integer aIx)const +{ + Standard_Boolean bFound=Standard_False; + Standard_Integer aIOr; + BOPTools_ListIteratorOfListOfPaveBlock anIt(myPaveBlocks); + // + for (; anIt.More(); anIt.Next()) { + const BOPTools_PaveBlock& aPB=anIt.Value(); + aIOr=aPB.OriginalEdge(); + if (aIOr==aIx){ + return !bFound; + } + } + return bFound; +} +//======================================================================= +// function: IsEqual +// purpose: +//======================================================================= + Standard_Boolean NMTTools_CommonBlock::IsEqual(const NMTTools_CommonBlock& aOther)const +{ + Standard_Boolean bFound=Standard_True; + Standard_Integer aNb1, aNb2; + BOPTools_ListIteratorOfListOfPaveBlock anIt; + // + aNb1=myPaveBlocks.Extent(); + aNb2=aOther.myPaveBlocks.Extent(); + // + if (!aNb1 && !aNb2) { + return bFound; + } + if (!aNb1) { + return !bFound; + } + if (!aNb2) { + return !bFound; + } + // + const BOPTools_PaveBlock& aPB=PaveBlock1(); + // + anIt.Initialize(aOther.myPaveBlocks); + for (; anIt.More(); anIt.Next()) { + const BOPTools_PaveBlock& aPBOther=anIt.Value(); + if (aPB.IsEqual(aPBOther)){ + return bFound; + } + } + return !bFound; +} +//======================================================================= +// function: Contains +// purpose: +//======================================================================= + Standard_Boolean NMTTools_CommonBlock::Contains(const BOPTools_PaveBlock& aPBx)const +{ + Standard_Boolean bFound=Standard_False; + Standard_Integer aNb1; + BOPTools_ListIteratorOfListOfPaveBlock anIt; + // + aNb1=myPaveBlocks.Extent(); + // + if (!aNb1) { + return bFound; + } + // + anIt.Initialize(myPaveBlocks); + for (; anIt.More(); anIt.Next()) { + const BOPTools_PaveBlock& aPB=anIt.Value(); + if (aPB.IsEqual(aPBx)) { + return !bFound; + } + } + return bFound; +} +/* +//======================================================================= +// function: SetEdge +// purpose: +//======================================================================= + void NMTTools_CommonBlock::SetEdge(const Standard_Integer anEdge) +{ + BOPTools_ListIteratorOfListOfPaveBlock anIt; + // + anIt.Initialize(myPaveBlocks); + for (; anIt.More(); anIt.Next()) { + BOPTools_PaveBlock& aPB=anIt.Value(); + aPB.SetEdge(anEdge); + } +} +//======================================================================= +// function: Edge +// purpose: +//======================================================================= + Standard_Integer NMTTools_CommonBlock::Edge()const +{ + Standard_Integer aNb; + // + aNb=myPaveBlocks.Extent(); + // + if (!aNb) { + return aNb; + } + // + const BOPTools_PaveBlock& aPB=PaveBlock1(); + aNb=aPB.Edge(); + return aNb; +} +*/ diff --git a/src/NMTTools/NMTTools_CommonBlock.hxx b/src/NMTTools/NMTTools_CommonBlock.hxx new file mode 100644 index 000000000..4964ae8ea --- /dev/null +++ b/src/NMTTools/NMTTools_CommonBlock.hxx @@ -0,0 +1,110 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _NMTTools_CommonBlock_HeaderFile +#define _NMTTools_CommonBlock_HeaderFile + +#ifndef _BOPTools_ListOfPaveBlock_HeaderFile +#include +#endif +#ifndef _TColStd_ListOfInteger_HeaderFile +#include +#endif +#ifndef _Standard_Integer_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +class BOPTools_PaveBlock; +class TColStd_ListOfInteger; +class BOPTools_ListOfPaveBlock; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class NMTTools_CommonBlock { + +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 NMTTools_CommonBlock(); +Standard_EXPORT void AddPaveBlock(const BOPTools_PaveBlock& aPB) ; +Standard_EXPORT void AddFace(const Standard_Integer aF) ; +Standard_EXPORT void AddFaces(const TColStd_ListOfInteger& aLF) ; +Standard_EXPORT const BOPTools_ListOfPaveBlock& PaveBlocks() const; +Standard_EXPORT const TColStd_ListOfInteger& Faces() const; +Standard_EXPORT const BOPTools_PaveBlock& PaveBlock1() const; +Standard_EXPORT BOPTools_PaveBlock& PaveBlock1(const Standard_Integer anIx) ; +Standard_EXPORT BOPTools_PaveBlock& PaveBlockOnEdge(const Standard_Integer anIndex) ; +Standard_EXPORT Standard_Boolean IsPaveBlockOnFace(const Standard_Integer anIndex) const; +Standard_EXPORT Standard_Boolean IsPaveBlockOnEdge(const Standard_Integer anIndex) const; +Standard_EXPORT Standard_Boolean IsEqual(const NMTTools_CommonBlock& aCB) const; +Standard_EXPORT Standard_Boolean Contains(const BOPTools_PaveBlock& aPB) const; + + + + + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // +BOPTools_ListOfPaveBlock myPaveBlocks; +TColStd_ListOfInteger myFaces; + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // + + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/NMTTools/NMTTools_CommonBlock.ixx b/src/NMTTools/NMTTools_CommonBlock.ixx new file mode 100644 index 000000000..334b58a7d --- /dev/null +++ b/src/NMTTools/NMTTools_CommonBlock.ixx @@ -0,0 +1,19 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include + + + + diff --git a/src/NMTTools/NMTTools_CommonBlock.jxx b/src/NMTTools/NMTTools_CommonBlock.jxx new file mode 100644 index 000000000..dc32fca23 --- /dev/null +++ b/src/NMTTools/NMTTools_CommonBlock.jxx @@ -0,0 +1,12 @@ +#ifndef _BOPTools_PaveBlock_HeaderFile +#include +#endif +#ifndef _TColStd_ListOfInteger_HeaderFile +#include +#endif +#ifndef _BOPTools_ListOfPaveBlock_HeaderFile +#include +#endif +#ifndef _NMTTools_CommonBlock_HeaderFile +#include +#endif diff --git a/src/NMTTools/NMTTools_CommonBlockAPI.cdl b/src/NMTTools/NMTTools_CommonBlockAPI.cdl new file mode 100644 index 000000000..63d08dc71 --- /dev/null +++ b/src/NMTTools/NMTTools_CommonBlockAPI.cdl @@ -0,0 +1,54 @@ +-- File: NMTTools_CommonBlockAPI.cdl +-- Created: Mon Dec 15 11:35:46 2003 +-- Author: Peter KURNEV +-- +---Copyright: Matra Datavision 2003 + + +class CommonBlockAPI from NMTTools + + ---Purpose: + +uses + ListOfCommonBlock from NMTTools, + ListOfPaveBlock from BOPTools, + PaveBlock from BOPTools, + CommonBlock from NMTTools + +--raises + +is + Create (aList:ListOfCommonBlock from NMTTools) + returns CommonBlockAPI from NMTTools; + + List(me) + returns ListOfCommonBlock from NMTTools; + ---C++: return const & + ---Purpose: + --- Selector + --- + CommonPaveBlocks(me; + anE:Integer from Standard) + returns ListOfPaveBlock from BOPTools; + ---C++: return const & + ---Purpose: + --- Returns all PaveBlock-s (from the list) that are + --- common for the given edge with DS-index + --- + IsCommonBlock (me; + aPB: PaveBlock from BOPTools) + returns Boolean from Standard; + ---Purpose: + --- Returns TRUE if given PaveBlock is + --- common for the Blocks from the list + + CommonBlock(me; + aPB: PaveBlock from BOPTools) + returns CommonBlock from NMTTools; + ---C++: return & + +fields + myListOfCommonBlock :Address from Standard; + myListOfPaveBlock :ListOfPaveBlock from BOPTools; + +end CommonBlockAPI; diff --git a/src/NMTTools/NMTTools_CommonBlockAPI.cxx b/src/NMTTools/NMTTools_CommonBlockAPI.cxx new file mode 100644 index 000000000..ceb097361 --- /dev/null +++ b/src/NMTTools/NMTTools_CommonBlockAPI.cxx @@ -0,0 +1,114 @@ +// File: NMTTools_CommonBlockAPI.cxx +// Created: Mon Dec 15 11:38:04 2003 +// Author: Peter KURNEV +// + + +#include + +#include +#include +#include + +#include +#include +#include + +//======================================================================= +// function: NMTTools_CommonBlockAPI::NMTTools_CommonBlockAPI +// purpose: +//======================================================================= + NMTTools_CommonBlockAPI::NMTTools_CommonBlockAPI (const NMTTools_ListOfCommonBlock& aLCB) +{ + myListOfCommonBlock=(void *)&aLCB; +} +//======================================================================= +// function: List +// purpose: +//======================================================================= + const NMTTools_ListOfCommonBlock& NMTTools_CommonBlockAPI::List () const +{ + NMTTools_ListOfCommonBlock* pListOfCommonBlock=(NMTTools_ListOfCommonBlock*)myListOfCommonBlock; + return *pListOfCommonBlock; +} +//======================================================================= +// function: CommonPaveBlocks +// purpose: get all CommonPaveBlocks +//======================================================================= + const BOPTools_ListOfPaveBlock& NMTTools_CommonBlockAPI::CommonPaveBlocks(const Standard_Integer anE) const +{ + Standard_Integer anECurrent; + BOPTools_ListIteratorOfListOfPaveBlock anItPB; + // + BOPTools_ListOfPaveBlock* pmyListOfPaveBlock=(BOPTools_ListOfPaveBlock*) &myListOfPaveBlock; + pmyListOfPaveBlock->Clear(); + + NMTTools_ListOfCommonBlock* pListOfCommonBlock=(NMTTools_ListOfCommonBlock*)myListOfCommonBlock; + + NMTTools_ListIteratorOfListOfCommonBlock anIt(*pListOfCommonBlock); + for (; anIt.More(); anIt.Next()) { + const NMTTools_CommonBlock& aCB=anIt.Value(); + // + const BOPTools_ListOfPaveBlock& aLPB=aCB.PaveBlocks(); + anItPB.Initialize(aLPB); + for (; anItPB.More(); anItPB.Next()) { + const BOPTools_PaveBlock& aPB=anItPB.Value(); + anECurrent=aPB.OriginalEdge(); + if (anECurrent==anE) { + pmyListOfPaveBlock->Append(aPB); + break; + } + } + } + return myListOfPaveBlock; +} +//======================================================================= +// function: IsCommonBlock +// purpose: +//======================================================================= + Standard_Boolean NMTTools_CommonBlockAPI::IsCommonBlock(const BOPTools_PaveBlock& aPB) const +{ + Standard_Integer anE; + // + anE=aPB.OriginalEdge(); + // + CommonPaveBlocks(anE); + // + BOPTools_ListIteratorOfListOfPaveBlock anIt(myListOfPaveBlock); + for (; anIt.More(); anIt.Next()) { + const BOPTools_PaveBlock& aPB1=anIt.Value(); + if (aPB1.IsEqual(aPB)) { + return Standard_True; + } + } + return Standard_False; +} + +//======================================================================= +// function: CommonBlock +// purpose: +//======================================================================= + NMTTools_CommonBlock& NMTTools_CommonBlockAPI::CommonBlock(const BOPTools_PaveBlock& aPB)const +{ + static NMTTools_CommonBlock aCBTMP; + // + NMTTools_ListIteratorOfListOfCommonBlock anItCB; + BOPTools_ListIteratorOfListOfPaveBlock anItPB; + // + NMTTools_ListOfCommonBlock* pLCB=(NMTTools_ListOfCommonBlock*)myListOfCommonBlock; + // + anItCB.Initialize(*pLCB); + for (; anItCB.More(); anItCB.Next()) { + NMTTools_CommonBlock& aCB=anItCB.Value(); + // + const BOPTools_ListOfPaveBlock& aLPB=aCB.PaveBlocks(); + anItPB.Initialize(aLPB); + for (; anItPB.More(); anItPB.Next()) { + const BOPTools_PaveBlock& aPBx=anItPB.Value(); + if (aPBx.IsEqual(aPB)) { + return aCB; + } + } + } + return aCBTMP; +} diff --git a/src/NMTTools/NMTTools_CommonBlockAPI.hxx b/src/NMTTools/NMTTools_CommonBlockAPI.hxx new file mode 100644 index 000000000..37e84f4b7 --- /dev/null +++ b/src/NMTTools/NMTTools_CommonBlockAPI.hxx @@ -0,0 +1,103 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _NMTTools_CommonBlockAPI_HeaderFile +#define _NMTTools_CommonBlockAPI_HeaderFile + +#ifndef _Standard_Address_HeaderFile +#include +#endif +#ifndef _BOPTools_ListOfPaveBlock_HeaderFile +#include +#endif +#ifndef _Standard_Integer_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +class NMTTools_ListOfCommonBlock; +class BOPTools_ListOfPaveBlock; +class BOPTools_PaveBlock; +class NMTTools_CommonBlock; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class NMTTools_CommonBlockAPI { + +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 NMTTools_CommonBlockAPI(const NMTTools_ListOfCommonBlock& aList); +Standard_EXPORT const NMTTools_ListOfCommonBlock& List() const; +Standard_EXPORT const BOPTools_ListOfPaveBlock& CommonPaveBlocks(const Standard_Integer anE) const; +Standard_EXPORT Standard_Boolean IsCommonBlock(const BOPTools_PaveBlock& aPB) const; +Standard_EXPORT NMTTools_CommonBlock& CommonBlock(const BOPTools_PaveBlock& aPB) const; + + + + + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // +Standard_Address myListOfCommonBlock; +BOPTools_ListOfPaveBlock myListOfPaveBlock; + + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/NMTTools/NMTTools_CommonBlockAPI.ixx b/src/NMTTools/NMTTools_CommonBlockAPI.ixx new file mode 100644 index 000000000..983092a69 --- /dev/null +++ b/src/NMTTools/NMTTools_CommonBlockAPI.ixx @@ -0,0 +1,19 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include + + + + diff --git a/src/NMTTools/NMTTools_CommonBlockAPI.jxx b/src/NMTTools/NMTTools_CommonBlockAPI.jxx new file mode 100644 index 000000000..49570db30 --- /dev/null +++ b/src/NMTTools/NMTTools_CommonBlockAPI.jxx @@ -0,0 +1,15 @@ +#ifndef _NMTTools_ListOfCommonBlock_HeaderFile +#include +#endif +#ifndef _BOPTools_ListOfPaveBlock_HeaderFile +#include +#endif +#ifndef _BOPTools_PaveBlock_HeaderFile +#include +#endif +#ifndef _NMTTools_CommonBlock_HeaderFile +#include +#endif +#ifndef _NMTTools_CommonBlockAPI_HeaderFile +#include +#endif diff --git a/src/NMTTools/NMTTools_CommonBlockPool.hxx b/src/NMTTools/NMTTools_CommonBlockPool.hxx new file mode 100644 index 000000000..01e53c6dd --- /dev/null +++ b/src/NMTTools/NMTTools_CommonBlockPool.hxx @@ -0,0 +1,132 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _NMTTools_CommonBlockPool_HeaderFile +#define _NMTTools_CommonBlockPool_HeaderFile + +#ifndef _Standard_Address_HeaderFile +#include +#endif +#ifndef _Standard_Integer_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +class Standard_OutOfRange; +class Standard_OutOfMemory; +class NMTTools_ListOfCommonBlock; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class NMTTools_CommonBlockPool { + +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 NMTTools_CommonBlockPool(const Standard_Integer Length = 0,const Standard_Integer BlockLength = 5); +Standard_EXPORT void Resize(const Standard_Integer theNewLength) ; +Standard_EXPORT void Destroy() ; +~NMTTools_CommonBlockPool() +{ + Destroy(); +} + +Standard_EXPORT Standard_Integer Length() const; +Standard_EXPORT Standard_Integer Extent() const; +Standard_EXPORT Standard_Integer FactLength() const; +Standard_EXPORT Standard_Integer Append(const NMTTools_ListOfCommonBlock& Value) ; +Standard_EXPORT void Remove(const Standard_Integer Index) ; +Standard_EXPORT const NMTTools_ListOfCommonBlock& Value(const Standard_Integer Index) const; + const NMTTools_ListOfCommonBlock& operator ()(const Standard_Integer Index) const +{ + return Value(Index); +} + +Standard_EXPORT NMTTools_ListOfCommonBlock& ChangeValue(const Standard_Integer Index) ; + NMTTools_ListOfCommonBlock& operator ()(const Standard_Integer Index) +{ + return ChangeValue(Index); +} + +Standard_EXPORT void SetBlockLength(const Standard_Integer aBL) ; +Standard_EXPORT Standard_Integer BlockLength() const; + + + + + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // +Standard_EXPORT NMTTools_CommonBlockPool(const NMTTools_CommonBlockPool& AnArray); +Standard_EXPORT NMTTools_CommonBlockPool& Assign(const NMTTools_CommonBlockPool& Other) ; + NMTTools_CommonBlockPool& operator =(const NMTTools_CommonBlockPool& Other) +{ + return Assign(Other); +} + +Standard_EXPORT Standard_Boolean IsInvalidIndex(const Standard_Integer Index) const; + + + // Fields PRIVATE + // +Standard_Address myStart; +Standard_Integer myLength; +Standard_Integer myFactLength; +Standard_Integer myBlockLength; +Standard_Boolean myIsAllocated; + + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/NMTTools/NMTTools_CommonBlockPool_0.cxx b/src/NMTTools/NMTTools_CommonBlockPool_0.cxx new file mode 100644 index 000000000..33f0f2541 --- /dev/null +++ b/src/NMTTools/NMTTools_CommonBlockPool_0.cxx @@ -0,0 +1,33 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include + +#ifndef _Standard_OutOfRange_HeaderFile +#include +#endif +#ifndef _Standard_OutOfMemory_HeaderFile +#include +#endif +#ifndef _NMTTools_ListOfCommonBlock_HeaderFile +#include +#endif + + +#define Array1Item NMTTools_ListOfCommonBlock +#define Array1Item_hxx +#define BOPTColStd_CArray1 NMTTools_CommonBlockPool +#define BOPTColStd_CArray1_hxx +#include + diff --git a/src/NMTTools/NMTTools_CoupleOfShape.cdl b/src/NMTTools/NMTTools_CoupleOfShape.cdl new file mode 100644 index 000000000..cf3e0839b --- /dev/null +++ b/src/NMTTools/NMTTools_CoupleOfShape.cdl @@ -0,0 +1,39 @@ +-- File: NMTTools_CoupleOfShape.cdl +-- Created: Wed Jan 28 15:03:39 2004 +-- Author: Peter KURNEV +-- +---Copyright: Matra Datavision 2004 + + +class CoupleOfShape from NMTTools + + ---Purpose: + +uses + Shape from TopoDS + +--raises + +is + Create + returns CoupleOfShape from NMTTools; + + SetShape1(me:out; + aS: Shape from TopoDS); + + SetShape2(me:out; + aS: 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 CoupleOfShape; diff --git a/src/NMTTools/NMTTools_CoupleOfShape.cxx b/src/NMTTools/NMTTools_CoupleOfShape.cxx new file mode 100644 index 000000000..91847f60c --- /dev/null +++ b/src/NMTTools/NMTTools_CoupleOfShape.cxx @@ -0,0 +1,45 @@ +// File: NMTTools_CoupleOfShape.cxx +// Created: Wed Jan 28 15:06:11 2004 +// Author: Peter KURNEV +// + +#include + +//======================================================================= +// function: NMTTools_CoupleOfShape::NMTTools_CoupleOfShape +// purpose: +//======================================================================= + NMTTools_CoupleOfShape::NMTTools_CoupleOfShape() +{} +//======================================================================= +// function: SetShape1 +// purpose: +//======================================================================= + void NMTTools_CoupleOfShape::SetShape1(const TopoDS_Shape& aS) +{ + myShape1=aS; +} +//======================================================================= +// function: SetShape2 +// purpose: +//======================================================================= + void NMTTools_CoupleOfShape::SetShape2(const TopoDS_Shape& aS) +{ + myShape2=aS; +} +//======================================================================= +// function: Shape1 +// purpose: +//======================================================================= + const TopoDS_Shape& NMTTools_CoupleOfShape::Shape1()const +{ + return myShape1; +} +//======================================================================= +// function: Shape2 +// purpose: +//======================================================================= + const TopoDS_Shape& NMTTools_CoupleOfShape::Shape2()const +{ + return myShape2; +} diff --git a/src/NMTTools/NMTTools_CoupleOfShape.hxx b/src/NMTTools/NMTTools_CoupleOfShape.hxx new file mode 100644 index 000000000..9a140f7b5 --- /dev/null +++ b/src/NMTTools/NMTTools_CoupleOfShape.hxx @@ -0,0 +1,91 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _NMTTools_CoupleOfShape_HeaderFile +#define _NMTTools_CoupleOfShape_HeaderFile + +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif +class TopoDS_Shape; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class NMTTools_CoupleOfShape { + +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 NMTTools_CoupleOfShape(); +Standard_EXPORT void SetShape1(const TopoDS_Shape& aS) ; +Standard_EXPORT void SetShape2(const TopoDS_Shape& aS) ; +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/NMTTools/NMTTools_CoupleOfShape.ixx b/src/NMTTools/NMTTools_CoupleOfShape.ixx new file mode 100644 index 000000000..1895c6b5a --- /dev/null +++ b/src/NMTTools/NMTTools_CoupleOfShape.ixx @@ -0,0 +1,19 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include + + + + diff --git a/src/NMTTools/NMTTools_CoupleOfShape.jxx b/src/NMTTools/NMTTools_CoupleOfShape.jxx new file mode 100644 index 000000000..9acf2b8d7 --- /dev/null +++ b/src/NMTTools/NMTTools_CoupleOfShape.jxx @@ -0,0 +1,6 @@ +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif +#ifndef _NMTTools_CoupleOfShape_HeaderFile +#include +#endif diff --git a/src/NMTTools/NMTTools_DEProcessor.cdl b/src/NMTTools/NMTTools_DEProcessor.cdl new file mode 100644 index 000000000..8d286d50f --- /dev/null +++ b/src/NMTTools/NMTTools_DEProcessor.cdl @@ -0,0 +1,105 @@ +-- File: NMTTools_DEProcessor.cdl +-- Created: Wed Sep 12 12:08:37 2001 +-- Author: Peter KURNEV +-- +---Copyright: Matra Datavision 2001 + + +class DEProcessor from NMTTools + + ---Purpose: + -- + -- The Algorithm to compute and store in interferences' pool + --- and in the Data Structure the following values + --- for degenerated edges + --- 1. Paves/Pave set(s) + --- 2. Split parts + --- 3. States (3D) for split parts + --- + +uses + + Vertex from TopoDS, + Edge from TopoDS, + Face from TopoDS, + + PPaveFiller from NMTTools, + PaveFiller from NMTTools, + --PDSFiller from NMTTools, + ListOfPaveBlock from BOPTools, + PShapesDataStructure from NMTDS, + IndexedDataMapOfIntegerDEInfo from BOPTools + + +is + --Create (aFiller:out PDSFiller from NMTTools) + -- returns DEProcessor from NMTTools; + ---Purpose: + --- Constructor + --- + Create (aFiller:out PaveFiller from NMTTools) + returns DEProcessor from NMTTools; + ---Purpose: + --- Constructor + --- + Do(me:out); + ---Purpose: + --- Launches the processor + --- + IsDone(me) + returns Boolean from Standard; + ---Purpose: + --- Returns TRUE if it is Ok + --- + --- + --- Private block + --- + --- + FindDegeneratedEdges (me:out) + is protected; + + DoPaves (me:out) + is protected; + + FindPaveBlocks (me:out; + nED:Integer from Standard; + nVD:Integer from Standard; + nFD:Integer from Standard; + aLPB:out ListOfPaveBlock from BOPTools) + is protected; + + FillPaveSet (me:out; + nED:Integer from Standard; + nVD:Integer from Standard; + nFD:Integer from Standard; + aLPB: ListOfPaveBlock from BOPTools) + is protected; + + FillSplitEdgesPool(me:out; + nED:Integer from Standard) + is protected; + + MakeSplitEdges(me:out; + nED:Integer from Standard; + nFD:Integer from Standard) + is protected; + + MakeSplitEdge (me:out; + aS1: Edge from TopoDS; + aF : Face from TopoDS; + aV1: Vertex from TopoDS; + aP1: Real from Standard; + aV2: Vertex from TopoDS; + aP2: Real from Standard; + aNewEdge:out Edge from TopoDS) + is protected; + +fields + + --myDSFiller: PDSFiller from NMTTools is protected; + myFiller : PPaveFiller from NMTTools is protected; + myDS : PShapesDataStructure from NMTDS is protected; + myIsDone : Boolean from Standard is protected; + myDEMap : IndexedDataMapOfIntegerDEInfo from BOPTools is protected; + +end DEProcessor; diff --git a/src/NMTTools/NMTTools_DEProcessor.cxx b/src/NMTTools/NMTTools_DEProcessor.cxx new file mode 100644 index 000000000..1c6ea3068 --- /dev/null +++ b/src/NMTTools/NMTTools_DEProcessor.cxx @@ -0,0 +1,492 @@ +// File: BOPTools_DEProcessor.cxx +// Created: Wed Sep 12 12:10:52 2001 +// 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 + + + +//======================================================================= +// function: NMTTools_DEProcessor::NMTTools_DEProcessor +// purpose: +//======================================================================= + NMTTools_DEProcessor::NMTTools_DEProcessor(NMTTools_PaveFiller& aPaveFiller) +: + myIsDone(Standard_False) +{ + myFiller=(NMTTools_PaveFiller*) &aPaveFiller; + myDS=myFiller->DS(); +} +//======================================================================= +// function: IsDone +// purpose: +//======================================================================= + Standard_Boolean NMTTools_DEProcessor::IsDone() const +{ + return myIsDone; +} +//======================================================================= +// function: Do +// purpose: +//======================================================================= + void NMTTools_DEProcessor::Do() +{ + Standard_Integer aNbE; + myIsDone=Standard_False; + + FindDegeneratedEdges(); + aNbE=myDEMap.Extent(); + + if (!aNbE) { + myIsDone=Standard_True; + return; + } + DoPaves(); +} +//======================================================================= +// function: FindDegeneratedEdges +// purpose: +//======================================================================= + void NMTTools_DEProcessor::FindDegeneratedEdges() +{ + Standard_Integer i, aNb, nV, nF, nVx, ip, iRankE; + TopTools_IndexedDataMapOfShapeListOfShape aMEF; + // + aNb=myDS->NumberOfShapesOfTheObject(); + // + for (i=1; i<=aNb; i++) { + const TopoDS_Shape& aF=myDS->Shape(i); + if (aF.ShapeType()==TopAbs_FACE) { + TopExp::MapShapesAndAncestors (aF, TopAbs_EDGE, TopAbs_FACE, aMEF); + } + } + // + for (i=1; i<=aNb; i++) { + const TopoDS_Shape& aS=myDS->Shape(i); + if (aS.ShapeType()==TopAbs_EDGE) { + const TopoDS_Edge& aE=TopoDS::Edge(aS); + + if (BRep_Tool::Degenerated(aE)) { + iRankE=myDS->Rank(i); + + TopoDS_Vertex aV=TopExp::FirstVertex(aE); + + nVx=myDS->ShapeIndex(aV, iRankE); + // + nV=nVx; + ip=myFiller->FindSDVertex(nV); + if (ip) { + nV=ip; + } + // + TColStd_ListOfInteger aLFn; + const TopTools_ListOfShape& aLF=aMEF.FindFromKey(aE); + TopTools_ListIteratorOfListOfShape anIt(aLF); + for (; anIt.More(); anIt.Next()) { + const TopoDS_Shape& aF=anIt.Value(); + nF=myDS->ShapeIndex(aF, iRankE); + aLFn.Append(nF); + } + BOPTools_DEInfo aDEInfo; + aDEInfo.SetVertex(nV); + aDEInfo.SetFaces(aLFn); + + myDEMap.Add (i, aDEInfo); + } + } + } +} +//======================================================================= +// function: DoPaves +// purpose: +//======================================================================= + void NMTTools_DEProcessor::DoPaves() +{ + + Standard_Integer i, aNbE, nED, nVD, nFD=0; + // + aNbE=myDEMap.Extent(); + for (i=1; i<=aNbE; i++) { + nED=myDEMap.FindKey(i); + + const BOPTools_DEInfo& aDEInfo=myDEMap(i); + nVD=aDEInfo.Vertex(); + // Fill PaveSet for the edge nED + const TColStd_ListOfInteger& nLF=aDEInfo.Faces(); + TColStd_ListIteratorOfListOfInteger anIt(nLF); + for (; anIt.More(); anIt.Next()) { + nFD=anIt.Value(); + + BOPTools_ListOfPaveBlock aLPB; + FindPaveBlocks(nED, nVD, nFD, aLPB); + FillPaveSet (nED, nVD, nFD, aLPB); + } + // + // Fill aSplitEdges for the edge nED + FillSplitEdgesPool(nED); + // + // MakeSplitEdges + MakeSplitEdges(nED, nFD); + // + }// next nED +} +//======================================================================= +// function: FindPaveBlocks +// purpose: +//======================================================================= + void NMTTools_DEProcessor::FindPaveBlocks(const Standard_Integer , + const Standard_Integer nVD, + const Standard_Integer nFD, + BOPTools_ListOfPaveBlock& aLPBOut) +{ + BOPTools_ListIteratorOfListOfPaveBlock anIt; + Standard_Integer i, aNb, nF2, nV; + // + BOPTools_CArray1OfSSInterference& aFFs=(myFiller->InterfPool())->SSInterferences(); + // + aNb=aFFs.Extent(); + for (i=1; i<=aNb; ++i) { + BOPTools_SSInterference& aFF=aFFs(i); + // + nF2=aFF.OppositeIndex(nFD); + if (!nF2) { + continue; + } + // + // Split Parts + const BOPTools_ListOfPaveBlock& aLPBSplits=aFF.PaveBlocks(); + anIt.Initialize(aLPBSplits); + for (; anIt.More(); anIt.Next()) { + const BOPTools_PaveBlock& aPBSp=anIt.Value(); + // + const BOPTools_Pave& aPave1=aPBSp.Pave1(); + nV=aPave1.Index(); + if (nV==nVD) { + aLPBOut.Append(aPBSp); + continue; + } + // + const BOPTools_Pave& aPave2=aPBSp.Pave2(); + nV=aPave2.Index(); + if (nV==nVD) { + aLPBOut.Append(aPBSp); + continue; + } + } + // + // Section Parts + Standard_Integer j, aNbCurves; + BOPTools_SequenceOfCurves& aSC=aFF.Curves(); + aNbCurves=aSC.Length(); + + for (j=1; j<=aNbCurves; j++) { + const BOPTools_Curve& aBC=aSC(j); + const BOPTools_ListOfPaveBlock& aLPBSe=aBC.NewPaveBlocks(); + + anIt.Initialize(aLPBSe); + for (; anIt.More(); anIt.Next()) { + const BOPTools_PaveBlock& aPBSe=anIt.Value(); + + const BOPTools_Pave& aPv1=aPBSe.Pave1(); + nV=aPv1.Index(); + if (nV==nVD) { + aLPBOut.Append(aPBSe); + continue; + } + + const BOPTools_Pave& aPv2=aPBSe.Pave2(); + nV=aPv2.Index(); + if (nV==nVD) { + aLPBOut.Append(aPBSe); + continue; + } + } + } + } +} +//======================================================================= +// function: FillPaveSet +// purpose: +//======================================================================= + void NMTTools_DEProcessor::FillPaveSet (const Standard_Integer nED, + const Standard_Integer nVD, + const Standard_Integer nFD, + const BOPTools_ListOfPaveBlock& aLPB) +{ + Standard_Boolean bIsDone, bXDir, bRejectFlag; + Standard_Integer nE, aNbPoints, j; + Standard_Real aTD1, aTD2, aT1, aT2, aTolInter, aX, aDT; + // + aDT=Precision::PConfusion(); + // + BOPTools_PaveSet& aPaveSet= (myFiller->ChangePavePool()).ChangeValue(myDS->RefEdge(nED)); + // + // Clear aPaveSet, aSplitEdges + aPaveSet.ChangeSet().Clear(); + // + const TopoDS_Edge& aDE=TopoDS::Edge(myDS->Shape(nED)); + const TopoDS_Face& aDF=TopoDS::Face(myDS->Shape(nFD)); + // + // 2D Curve of degenerated edge on the face aDF + Handle(Geom2d_Curve) aC2DDE=BRep_Tool::CurveOnSurface(aDE, aDF, aTD1, aTD2); + // + // Choose direction for Degenerated Edge + gp_Pnt2d aP2d1, aP2d2; + aC2DDE->D0(aTD1, aP2d1); + aC2DDE->D0(aTD2, aP2d2); + + bXDir=Standard_False; + if (fabs(aP2d1.Y()-aP2d2.Y()) < aDT){ + bXDir=!bXDir; + } + // + // Prepare bounding Paves + BOPTools_Pave aPave1 (nVD, aTD1, BooleanOperations_UnknownInterference); + aPaveSet.Append(aPave1); + BOPTools_Pave aPave2 (nVD, aTD2, BooleanOperations_UnknownInterference); + aPaveSet.Append(aPave2); + // + // Fill other paves + BOPTools_ListIteratorOfListOfPaveBlock anIt(aLPB); + for (; anIt.More(); anIt.Next()) { + const BOPTools_PaveBlock& aPB=anIt.Value(); + nE=aPB.Edge(); + const TopoDS_Edge& aE=TopoDS::Edge(myDS->Shape(nE)); + + Handle(Geom2d_Curve) aC2D=BRep_Tool::CurveOnSurface(aE, aDF, aT1, aT2); + // + // Intersection + aTolInter=0.001; + + Geom2dAdaptor_Curve aGAC1, aGAC2; + + aGAC1.Load(aC2DDE, aTD1, aTD2); + Handle(Geom2d_Line) aL2D= Handle(Geom2d_Line)::DownCast(aC2D); + if (!aL2D.IsNull()) { + aGAC2.Load(aC2D); + } + else { + aGAC2.Load(aC2D, aT1, aT2); + } + + Geom2dInt_GInter aGInter(aGAC1, aGAC2, aTolInter, aTolInter); + + bIsDone=aGInter.IsDone(); + if(bIsDone) { + aNbPoints=aGInter.NbPoints(); + if (aNbPoints) { + for (j=1; j<=aNbPoints; ++j) { + gp_Pnt2d aP2D=aGInter.Point(j).Value(); + // + aX=(bXDir) ? aP2D.X(): aP2D.Y(); + // + if (fabs (aX-aTD1) < aDT || fabs (aX-aTD2) < aDT) { + continue; + } + if (aX < aTD1 || aX > aTD2) { + continue; + } + // + bRejectFlag=Standard_False; + const BOPTools_ListOfPave& aListOfPave=aPaveSet.Set(); + BOPTools_ListIteratorOfListOfPave aPaveIt(aListOfPave); + for (; aPaveIt.More(); aPaveIt.Next()) { + const BOPTools_Pave& aPavex=aPaveIt.Value(); + Standard_Real aXx=aPavex.Param(); + if (fabs (aX-aXx) < aDT) { + bRejectFlag=Standard_True; + break; + } + } + if (bRejectFlag) { + continue; + } + // + BOPTools_Pave aPave(nVD, aX, BooleanOperations_UnknownInterference); + aPaveSet.Append(aPave); + } + } + } + } +} +//======================================================================= +// function: FillSplitEdgesPool +// purpose: +//======================================================================= + void NMTTools_DEProcessor::FillSplitEdgesPool (const Standard_Integer nED) +{ + BOPTools_SplitShapesPool& aSplitShapesPool=myFiller->ChangeSplitShapesPool(); + BOPTools_ListOfPaveBlock& aSplitEdges=aSplitShapesPool.ChangeValue(myDS->RefEdge(nED)); + // + aSplitEdges.Clear(); + // + const BOPTools_PavePool& aPavePool=myFiller->PavePool(); + BOPTools_PavePool* pPavePool=(BOPTools_PavePool*) &aPavePool; + BOPTools_PaveSet& aPaveSet= pPavePool->ChangeValue(myDS->RefEdge(nED)); + + BOPTools_PaveBlockIterator aPBIt(nED, aPaveSet); + for (; aPBIt.More(); aPBIt.Next()) { + BOPTools_PaveBlock& aPB=aPBIt.Value(); + aSplitEdges.Append(aPB); + } +} +//======================================================================= +// function: MakeSplitEdges +// purpose: +//======================================================================= + void NMTTools_DEProcessor::MakeSplitEdges (const Standard_Integer nED, + const Standard_Integer nFD) +{ + const BOPTools_SplitShapesPool& aSplitShapesPool=myFiller->SplitShapesPool(); + const BOPTools_ListOfPaveBlock& aSplitEdges=aSplitShapesPool(myDS->RefEdge(nED)); + + Standard_Integer nV1, nV2, aNewShapeIndex; + Standard_Real t1, t2; + TopoDS_Edge aE, aESplit; + TopoDS_Vertex aV1, aV2; + + const TopoDS_Edge& aDE=TopoDS::Edge(myDS->Shape(nED)); + const TopoDS_Face& aDF=TopoDS::Face(myDS->Shape(nFD)); + + BOPTools_ListIteratorOfListOfPaveBlock aPBIt(aSplitEdges); + + for (; aPBIt.More(); aPBIt.Next()) { + BOPTools_PaveBlock& aPB=aPBIt.Value(); + + const BOPTools_Pave& aPave1=aPB.Pave1(); + nV1=aPave1.Index(); + t1=aPave1.Param(); + aV1=TopoDS::Vertex(myDS->GetShape(nV1)); + aV1.Orientation(TopAbs_FORWARD); + + const BOPTools_Pave& aPave2=aPB.Pave2(); + nV2=aPave2.Index(); + t2=aPave2.Param(); + aV2=TopoDS::Vertex(myDS->GetShape(nV2)); + aV2.Orientation(TopAbs_REVERSED); + + MakeSplitEdge(aDE, aDF, aV1, t1, aV2, t2, aESplit); + // + // Add Split Part of the Original Edge to the DS + BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq; + + anASSeq.SetNewSuccessor(nV1); + anASSeq.SetNewOrientation(aV1.Orientation()); + + anASSeq.SetNewSuccessor(nV2); + anASSeq.SetNewOrientation(aV2.Orientation()); + + myDS->InsertShapeAndAncestorsSuccessors(aESplit, anASSeq); + aNewShapeIndex=myDS->NumberOfInsertedShapes(); + myDS->SetState(aNewShapeIndex, BooleanOperations_UNKNOWN); + // + // Fill Split Set for the Original Edge + aPB.SetEdge(aNewShapeIndex); + // + } +} +//======================================================================= +// function: MakeSplitEdge +// purpose: +//======================================================================= + void NMTTools_DEProcessor::MakeSplitEdge (const TopoDS_Edge& aE, + const TopoDS_Face& aF, + const TopoDS_Vertex& aV1, + const Standard_Real aP1, + const TopoDS_Vertex& aV2, + const Standard_Real aP2, + TopoDS_Edge& aNewEdge) +{ + Standard_Real aTol=1.e-7; + + TopoDS_Edge E=aE; + + E.EmptyCopy(); + BRep_Builder BB; + BB.Add (E, aV1); + BB.Add (E, aV2); + + BB.Range(E, aF, aP1, aP2); + + BB.Degenerated(E, Standard_True); + + BB.UpdateEdge(E, aTol); + aNewEdge=E; +} +/* +//======================================================================= +// function: NMTTools_DEProcessor::NMTTools_DEProcessor +// purpose: +//======================================================================= + NMTTools_DEProcessor::NMTTools_DEProcessor(NMTTools_PDSFiller& pDSFiller) +: + myIsDone(Standard_False) +{ + myDSFiller=pDSFiller; + myFiller=(NMTTools_PaveFiller*) &(myDSFiller->PaveFiller()); + myDS=myFiller->DS(); +} +*/ diff --git a/src/NMTTools/NMTTools_DEProcessor.hxx b/src/NMTTools/NMTTools_DEProcessor.hxx new file mode 100644 index 000000000..fb3ccbb37 --- /dev/null +++ b/src/NMTTools/NMTTools_DEProcessor.hxx @@ -0,0 +1,117 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _NMTTools_DEProcessor_HeaderFile +#define _NMTTools_DEProcessor_HeaderFile + +#ifndef _NMTTools_PPaveFiller_HeaderFile +#include +#endif +#ifndef _NMTDS_PShapesDataStructure_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +#ifndef _BOPTools_IndexedDataMapOfIntegerDEInfo_HeaderFile +#include +#endif +#ifndef _Standard_Integer_HeaderFile +#include +#endif +#ifndef _Standard_Real_HeaderFile +#include +#endif +class NMTTools_PaveFiller; +class BOPTools_ListOfPaveBlock; +class TopoDS_Edge; +class TopoDS_Face; +class TopoDS_Vertex; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class NMTTools_DEProcessor { + +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 NMTTools_DEProcessor(NMTTools_PaveFiller& aFiller); +Standard_EXPORT void Do() ; +Standard_EXPORT Standard_Boolean IsDone() const; + + + + + +protected: + + // Methods PROTECTED + // +Standard_EXPORT void FindDegeneratedEdges() ; +Standard_EXPORT void DoPaves() ; +Standard_EXPORT void FindPaveBlocks(const Standard_Integer nED,const Standard_Integer nVD,const Standard_Integer nFD,BOPTools_ListOfPaveBlock& aLPB) ; +Standard_EXPORT void FillPaveSet(const Standard_Integer nED,const Standard_Integer nVD,const Standard_Integer nFD,const BOPTools_ListOfPaveBlock& aLPB) ; +Standard_EXPORT void FillSplitEdgesPool(const Standard_Integer nED) ; +Standard_EXPORT void MakeSplitEdges(const Standard_Integer nED,const Standard_Integer nFD) ; +Standard_EXPORT void MakeSplitEdge(const TopoDS_Edge& aS1,const TopoDS_Face& aF,const TopoDS_Vertex& aV1,const Standard_Real aP1,const TopoDS_Vertex& aV2,const Standard_Real aP2,TopoDS_Edge& aNewEdge) ; + + + // Fields PROTECTED + // +NMTTools_PPaveFiller myFiller; +NMTDS_PShapesDataStructure myDS; +Standard_Boolean myIsDone; +BOPTools_IndexedDataMapOfIntegerDEInfo myDEMap; + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // + + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/NMTTools/NMTTools_DEProcessor.ixx b/src/NMTTools/NMTTools_DEProcessor.ixx new file mode 100644 index 000000000..68448380c --- /dev/null +++ b/src/NMTTools/NMTTools_DEProcessor.ixx @@ -0,0 +1,19 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include + + + + diff --git a/src/NMTTools/NMTTools_DEProcessor.jxx b/src/NMTTools/NMTTools_DEProcessor.jxx new file mode 100644 index 000000000..a8c418d4e --- /dev/null +++ b/src/NMTTools/NMTTools_DEProcessor.jxx @@ -0,0 +1,18 @@ +#ifndef _NMTTools_PaveFiller_HeaderFile +#include +#endif +#ifndef _BOPTools_ListOfPaveBlock_HeaderFile +#include +#endif +#ifndef _TopoDS_Edge_HeaderFile +#include +#endif +#ifndef _TopoDS_Face_HeaderFile +#include +#endif +#ifndef _TopoDS_Vertex_HeaderFile +#include +#endif +#ifndef _NMTTools_DEProcessor_HeaderFile +#include +#endif diff --git a/src/NMTTools/NMTTools_DSFiller.cdl b/src/NMTTools/NMTTools_DSFiller.cdl new file mode 100644 index 000000000..069e82c7c --- /dev/null +++ b/src/NMTTools/NMTTools_DSFiller.cdl @@ -0,0 +1,80 @@ +-- File: NMTTools_DSFiller.cdl +-- Created: Fri Dec 5 13:57:03 2003 +-- Author: Peter KURNEV +-- +---Copyright: Matra Datavision 2003 + + +class DSFiller from NMTTools + + ---Purpose: + +uses + Shape from TopoDS, + InterferencePool from BOPTools, + PInterferencePool from BOPTools, + ShapesDataStructure from NMTDS, + PShapesDataStructure from NMTDS, + PPaveFiller from NMTTools, + PaveFiller from NMTTools +--raises + +is + Create + returns DSFiller from NMTTools; + + Destroy (me:out); + ---C++: alias ~ + ---Purpose: Destructor + -- + -- Selectors/Modifiers + SetCompositeShape (me:out; + aS: Shape from TopoDS); + + CompositeShape(me) + returns Shape from TopoDS; + ---C++: return const& + + SetNewFiller(me; + aFlag:Boolean from Standard); + + IsNewFiller(me) + returns Boolean from Standard; + -- + -- Perform the algo + Perform (me:out); + -- + -- Protected section + Clear (me:out) + is protected; + -- + -- Query section + DS (me) + returns ShapesDataStructure from NMTDS; + ---C++: return const & + + InterfPool (me) + returns InterferencePool from BOPTools; + ---C++: return const & + + IsDone(me) + returns Boolean from Standard; + + PaveFiller(me) + returns PaveFiller from NMTTools; + ---C++: return const & + + ChangePaveFiller (me:out) + returns PaveFiller from NMTTools; + ---C++: return & + +fields + myCompositeShape : Shape from TopoDS is protected; + myDS : PShapesDataStructure from NMTDS is protected; + myInterfPool : PInterferencePool from BOPTools is protected; + myPaveFiller : PPaveFiller from NMTTools is protected; + + myIsDone : Boolean from Standard is protected; + myIsNewFiller : Boolean from Standard is protected; + +end DSFiller; diff --git a/src/NMTTools/NMTTools_DSFiller.cxx b/src/NMTTools/NMTTools_DSFiller.cxx new file mode 100644 index 000000000..d0e53b50c --- /dev/null +++ b/src/NMTTools/NMTTools_DSFiller.cxx @@ -0,0 +1,149 @@ +// File: NMTTools_DSFiller.cxx +// Created: Fri Dec 5 14:06:34 2003 +// Author: Peter KURNEV +// + + +#include +#include + +//======================================================================= +// function: NMTTools_DSFiller::NMTTools_DSFiller +// purpose: +//======================================================================= + NMTTools_DSFiller::NMTTools_DSFiller() +{ + myPaveFiller=NULL; + myInterfPool=NULL; + myDS=NULL; + myIsNewFiller=Standard_True; + myIsDone=Standard_False; +} +//======================================================================= +// function:Destroy +// purpose: +//======================================================================= + void NMTTools_DSFiller::Destroy() +{ + Clear(); +} +//======================================================================= +// function: Clear +// purpose: +//======================================================================= + void NMTTools_DSFiller::Clear() +{ + if (myPaveFiller!=NULL) { + delete myPaveFiller; + } + if (myInterfPool!=NULL) { + delete myInterfPool; + } + if (myDS!=NULL) { + delete myDS; + } + myPaveFiller=NULL; + myInterfPool=NULL; + myDS=NULL; +} +//======================================================================= +// function: SetCompositeShape +// purpose: +//======================================================================= + void NMTTools_DSFiller::SetCompositeShape(const TopoDS_Shape& aS) +{ + myCompositeShape=aS; +} +//======================================================================= +// function: CompositeShape +// purpose: +//======================================================================= + const TopoDS_Shape& NMTTools_DSFiller::CompositeShape()const +{ + return myCompositeShape; +} +//======================================================================= +// function: SetNewFiller +// purpose: +//======================================================================= + void NMTTools_DSFiller::SetNewFiller(const Standard_Boolean aFlag) const +{ + NMTTools_DSFiller* pDSFiller=(NMTTools_DSFiller*)this; + pDSFiller->myIsNewFiller=aFlag; +} +//======================================================================= +// function: IsNewFiller +// purpose: +//======================================================================= + Standard_Boolean NMTTools_DSFiller::IsNewFiller() const +{ + return myIsNewFiller; +} +//======================================================================= +// function: DS +// purpose: +//======================================================================= + const NMTDS_ShapesDataStructure& NMTTools_DSFiller::DS () const +{ + return *myDS; +} +//======================================================================= +// function: InterfPool +// purpose: +//======================================================================= + const BOPTools_InterferencePool& NMTTools_DSFiller::InterfPool () const +{ + return *myInterfPool; +} +//======================================================================= +// function: IsDone +// purpose: +//======================================================================= + Standard_Boolean NMTTools_DSFiller::IsDone()const +{ + return myIsDone; +} +//======================================================================= +// function: PaveFiller +// purpose: +//======================================================================= + const NMTTools_PaveFiller& NMTTools_DSFiller::PaveFiller()const +{ + return *myPaveFiller; +} +//======================================================================= +// function: ChangePaveFiller +// purpose: +//======================================================================= + NMTTools_PaveFiller& NMTTools_DSFiller::ChangePaveFiller() +{ + return *myPaveFiller; +} +//======================================================================= +// function: Perform +// purpose: +//======================================================================= + void NMTTools_DSFiller::Perform() +{ + myIsDone=Standard_False; + // + if (myCompositeShape.IsNull()) { + return; + } + // + // + // Clear contents of the DS if it was before + Clear(); + // + myIsNewFiller=Standard_True; + // + myDS = new NMTDS_ShapesDataStructure; + myDS->SetCompositeShape(myCompositeShape); + myDS->Init(); + // + myInterfPool= new BOPTools_InterferencePool (*myDS); + // + myPaveFiller = new NMTTools_PaveFiller(*myInterfPool); + myPaveFiller->Perform(); + myIsDone=myPaveFiller->IsDone(); +} diff --git a/src/NMTTools/NMTTools_DSFiller.hxx b/src/NMTTools/NMTTools_DSFiller.hxx new file mode 100644 index 000000000..09c398e8e --- /dev/null +++ b/src/NMTTools/NMTTools_DSFiller.hxx @@ -0,0 +1,123 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _NMTTools_DSFiller_HeaderFile +#define _NMTTools_DSFiller_HeaderFile + +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif +#ifndef _NMTDS_PShapesDataStructure_HeaderFile +#include +#endif +#ifndef _BOPTools_PInterferencePool_HeaderFile +#include +#endif +#ifndef _NMTTools_PPaveFiller_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +class TopoDS_Shape; +class NMTDS_ShapesDataStructure; +class BOPTools_InterferencePool; +class NMTTools_PaveFiller; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class NMTTools_DSFiller { + +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 NMTTools_DSFiller(); +Standard_EXPORT void Destroy() ; +~NMTTools_DSFiller() +{ + Destroy(); +} + +Standard_EXPORT void SetCompositeShape(const TopoDS_Shape& aS) ; +Standard_EXPORT const TopoDS_Shape& CompositeShape() const; +Standard_EXPORT void SetNewFiller(const Standard_Boolean aFlag) const; +Standard_EXPORT Standard_Boolean IsNewFiller() const; +Standard_EXPORT void Perform() ; +Standard_EXPORT const NMTDS_ShapesDataStructure& DS() const; +Standard_EXPORT const BOPTools_InterferencePool& InterfPool() const; +Standard_EXPORT Standard_Boolean IsDone() const; +Standard_EXPORT const NMTTools_PaveFiller& PaveFiller() const; +Standard_EXPORT NMTTools_PaveFiller& ChangePaveFiller() ; + + + + + +protected: + + // Methods PROTECTED + // +Standard_EXPORT void Clear() ; + + + // Fields PROTECTED + // +TopoDS_Shape myCompositeShape; +NMTDS_PShapesDataStructure myDS; +BOPTools_PInterferencePool myInterfPool; +NMTTools_PPaveFiller myPaveFiller; +Standard_Boolean myIsDone; +Standard_Boolean myIsNewFiller; + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // + + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/NMTTools/NMTTools_DSFiller.ixx b/src/NMTTools/NMTTools_DSFiller.ixx new file mode 100644 index 000000000..e55cf6738 --- /dev/null +++ b/src/NMTTools/NMTTools_DSFiller.ixx @@ -0,0 +1,19 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include + + + + diff --git a/src/NMTTools/NMTTools_DSFiller.jxx b/src/NMTTools/NMTTools_DSFiller.jxx new file mode 100644 index 000000000..078fd15ab --- /dev/null +++ b/src/NMTTools/NMTTools_DSFiller.jxx @@ -0,0 +1,15 @@ +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif +#ifndef _NMTDS_ShapesDataStructure_HeaderFile +#include +#endif +#ifndef _BOPTools_InterferencePool_HeaderFile +#include +#endif +#ifndef _NMTTools_PaveFiller_HeaderFile +#include +#endif +#ifndef _NMTTools_DSFiller_HeaderFile +#include +#endif diff --git a/src/NMTTools/NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger.hxx b/src/NMTTools/NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger.hxx new file mode 100644 index 000000000..cf09e4f59 --- /dev/null +++ b/src/NMTTools/NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger.hxx @@ -0,0 +1,136 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#ifndef _NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger_HeaderFile +#define _NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Handle_NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger_HeaderFile +#include +#endif + +#ifndef _Standard_Integer_HeaderFile +#include +#endif +#ifndef _TColStd_IndexedMapOfInteger_HeaderFile +#include +#endif +#ifndef _TCollection_MapNodePtr_HeaderFile +#include +#endif +#ifndef _TCollection_MapNode_HeaderFile +#include +#endif +class TColStd_IndexedMapOfInteger; +class TColStd_MapIntegerHasher; +class NMTTools_IndexedDataMapOfIndexedMapOfInteger; + + +class NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger : 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 + // +NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger(const Standard_Integer& K1,const Standard_Integer K2,const TColStd_IndexedMapOfInteger& I,const TCollection_MapNodePtr& n1,const TCollection_MapNodePtr& n2); + Standard_Integer& Key1() const; + Standard_Integer& Key2() const; + TCollection_MapNodePtr& Next2() const; + TColStd_IndexedMapOfInteger& Value() const; +Standard_EXPORT ~NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger(); + + + + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger_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_Integer myKey1; +Standard_Integer myKey2; +TColStd_IndexedMapOfInteger myValue; +TCollection_MapNodePtr myNext2; + + +}; + +#define TheKey Standard_Integer +#define TheKey_hxx +#define TheItem TColStd_IndexedMapOfInteger +#define TheItem_hxx +#define Hasher TColStd_MapIntegerHasher +#define Hasher_hxx +#define TCollection_IndexedDataMapNode NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger +#define TCollection_IndexedDataMapNode_hxx +#define Handle_TCollection_IndexedDataMapNode Handle_NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger +#define TCollection_IndexedDataMapNode_Type_() NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger_Type_() +#define TCollection_IndexedDataMap NMTTools_IndexedDataMapOfIndexedMapOfInteger +#define TCollection_IndexedDataMap_hxx + +#include + +#undef TheKey +#undef TheKey_hxx +#undef TheItem +#undef TheItem_hxx +#undef Hasher +#undef Hasher_hxx +#undef TCollection_IndexedDataMapNode +#undef TCollection_IndexedDataMapNode_hxx +#undef Handle_TCollection_IndexedDataMapNode +#undef TCollection_IndexedDataMapNode_Type_ +#undef TCollection_IndexedDataMap +#undef TCollection_IndexedDataMap_hxx + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/NMTTools/NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger_0.cxx b/src/NMTTools/NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger_0.cxx new file mode 100644 index 000000000..1d989956b --- /dev/null +++ b/src/NMTTools/NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger_0.cxx @@ -0,0 +1,93 @@ +// File generated by CPPExt (Transient) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _TColStd_IndexedMapOfInteger_HeaderFile +#include +#endif +#ifndef _TColStd_MapIntegerHasher_HeaderFile +#include +#endif +#ifndef _NMTTools_IndexedDataMapOfIndexedMapOfInteger_HeaderFile +#include +#endif +NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger::~NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger() {} + + + +Standard_EXPORT Handle_Standard_Type& NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger_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("NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger", + sizeof(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + + +// DownCast method +// allow safe downcasting +// +const Handle(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger) Handle(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger))) { + _anOtherObject = Handle(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger)((Handle(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger)&)AnObject); + } + } + + return _anOtherObject ; +} +const Handle(Standard_Type)& NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger::DynamicType() const +{ + return STANDARD_TYPE(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger) ; +} +Standard_Boolean NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger::IsKind(const Handle(Standard_Type)& AType) const +{ + return (STANDARD_TYPE(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger) == AType || TCollection_MapNode::IsKind(AType)); +} +Handle_NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger::~Handle_NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger() {} +#define TheKey Standard_Integer +#define TheKey_hxx +#define TheItem TColStd_IndexedMapOfInteger +#define TheItem_hxx +#define Hasher TColStd_MapIntegerHasher +#define Hasher_hxx +#define TCollection_IndexedDataMapNode NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger +#define TCollection_IndexedDataMapNode_hxx +#define Handle_TCollection_IndexedDataMapNode Handle_NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger +#define TCollection_IndexedDataMapNode_Type_() NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger_Type_() +#define TCollection_IndexedDataMap NMTTools_IndexedDataMapOfIndexedMapOfInteger +#define TCollection_IndexedDataMap_hxx +#include + diff --git a/src/NMTTools/NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape.hxx b/src/NMTTools/NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape.hxx new file mode 100644 index 000000000..7721dd936 --- /dev/null +++ b/src/NMTTools/NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape.hxx @@ -0,0 +1,140 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#ifndef _NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape_HeaderFile +#define _NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Handle_NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape_HeaderFile +#include +#endif + +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif +#ifndef _Standard_Integer_HeaderFile +#include +#endif +#ifndef _TopTools_IndexedMapOfShape_HeaderFile +#include +#endif +#ifndef _TCollection_MapNodePtr_HeaderFile +#include +#endif +#ifndef _TCollection_MapNode_HeaderFile +#include +#endif +class TopoDS_Shape; +class TopTools_IndexedMapOfShape; +class TopTools_ShapeMapHasher; +class NMTTools_IndexedDataMapOfShapeIndexedMapOfShape; + + +class NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape : 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 + // +NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape(const TopoDS_Shape& K1,const Standard_Integer K2,const TopTools_IndexedMapOfShape& I,const TCollection_MapNodePtr& n1,const TCollection_MapNodePtr& n2); + TopoDS_Shape& Key1() const; + Standard_Integer& Key2() const; + TCollection_MapNodePtr& Next2() const; + TopTools_IndexedMapOfShape& Value() const; +Standard_EXPORT ~NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape(); + + + + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape_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 + // +TopoDS_Shape myKey1; +Standard_Integer myKey2; +TopTools_IndexedMapOfShape myValue; +TCollection_MapNodePtr myNext2; + + +}; + +#define TheKey TopoDS_Shape +#define TheKey_hxx +#define TheItem TopTools_IndexedMapOfShape +#define TheItem_hxx +#define Hasher TopTools_ShapeMapHasher +#define Hasher_hxx +#define TCollection_IndexedDataMapNode NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape +#define TCollection_IndexedDataMapNode_hxx +#define Handle_TCollection_IndexedDataMapNode Handle_NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape +#define TCollection_IndexedDataMapNode_Type_() NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape_Type_() +#define TCollection_IndexedDataMap NMTTools_IndexedDataMapOfShapeIndexedMapOfShape +#define TCollection_IndexedDataMap_hxx + +#include + +#undef TheKey +#undef TheKey_hxx +#undef TheItem +#undef TheItem_hxx +#undef Hasher +#undef Hasher_hxx +#undef TCollection_IndexedDataMapNode +#undef TCollection_IndexedDataMapNode_hxx +#undef Handle_TCollection_IndexedDataMapNode +#undef TCollection_IndexedDataMapNode_Type_ +#undef TCollection_IndexedDataMap +#undef TCollection_IndexedDataMap_hxx + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/NMTTools/NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape_0.cxx b/src/NMTTools/NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape_0.cxx new file mode 100644 index 000000000..beaae44e7 --- /dev/null +++ b/src/NMTTools/NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape_0.cxx @@ -0,0 +1,96 @@ +// File generated by CPPExt (Transient) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif +#ifndef _TopTools_IndexedMapOfShape_HeaderFile +#include +#endif +#ifndef _TopTools_ShapeMapHasher_HeaderFile +#include +#endif +#ifndef _NMTTools_IndexedDataMapOfShapeIndexedMapOfShape_HeaderFile +#include +#endif +NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape::~NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape() {} + + + +Standard_EXPORT Handle_Standard_Type& NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape_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("NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape", + sizeof(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + + +// DownCast method +// allow safe downcasting +// +const Handle(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape) Handle(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape))) { + _anOtherObject = Handle(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape)((Handle(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape)&)AnObject); + } + } + + return _anOtherObject ; +} +const Handle(Standard_Type)& NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape::DynamicType() const +{ + return STANDARD_TYPE(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape) ; +} +Standard_Boolean NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape::IsKind(const Handle(Standard_Type)& AType) const +{ + return (STANDARD_TYPE(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape) == AType || TCollection_MapNode::IsKind(AType)); +} +Handle_NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape::~Handle_NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape() {} +#define TheKey TopoDS_Shape +#define TheKey_hxx +#define TheItem TopTools_IndexedMapOfShape +#define TheItem_hxx +#define Hasher TopTools_ShapeMapHasher +#define Hasher_hxx +#define TCollection_IndexedDataMapNode NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape +#define TCollection_IndexedDataMapNode_hxx +#define Handle_TCollection_IndexedDataMapNode Handle_NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape +#define TCollection_IndexedDataMapNode_Type_() NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape_Type_() +#define TCollection_IndexedDataMap NMTTools_IndexedDataMapOfShapeIndexedMapOfShape +#define TCollection_IndexedDataMap_hxx +#include + diff --git a/src/NMTTools/NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock.hxx b/src/NMTTools/NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock.hxx new file mode 100644 index 000000000..453715207 --- /dev/null +++ b/src/NMTTools/NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock.hxx @@ -0,0 +1,140 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#ifndef _NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock_HeaderFile +#define _NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Handle_NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock_HeaderFile +#include +#endif + +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif +#ifndef _Standard_Integer_HeaderFile +#include +#endif +#ifndef _BOPTools_PaveBlock_HeaderFile +#include +#endif +#ifndef _TCollection_MapNodePtr_HeaderFile +#include +#endif +#ifndef _TCollection_MapNode_HeaderFile +#include +#endif +class TopoDS_Shape; +class BOPTools_PaveBlock; +class TopTools_ShapeMapHasher; +class NMTTools_IndexedDataMapOfShapePaveBlock; + + +class NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock : 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 + // +NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock(const TopoDS_Shape& K1,const Standard_Integer K2,const BOPTools_PaveBlock& I,const TCollection_MapNodePtr& n1,const TCollection_MapNodePtr& n2); + TopoDS_Shape& Key1() const; + Standard_Integer& Key2() const; + TCollection_MapNodePtr& Next2() const; + BOPTools_PaveBlock& Value() const; +Standard_EXPORT ~NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock(); + + + + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock_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 + // +TopoDS_Shape myKey1; +Standard_Integer myKey2; +BOPTools_PaveBlock myValue; +TCollection_MapNodePtr myNext2; + + +}; + +#define TheKey TopoDS_Shape +#define TheKey_hxx +#define TheItem BOPTools_PaveBlock +#define TheItem_hxx +#define Hasher TopTools_ShapeMapHasher +#define Hasher_hxx +#define TCollection_IndexedDataMapNode NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock +#define TCollection_IndexedDataMapNode_hxx +#define Handle_TCollection_IndexedDataMapNode Handle_NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock +#define TCollection_IndexedDataMapNode_Type_() NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock_Type_() +#define TCollection_IndexedDataMap NMTTools_IndexedDataMapOfShapePaveBlock +#define TCollection_IndexedDataMap_hxx + +#include + +#undef TheKey +#undef TheKey_hxx +#undef TheItem +#undef TheItem_hxx +#undef Hasher +#undef Hasher_hxx +#undef TCollection_IndexedDataMapNode +#undef TCollection_IndexedDataMapNode_hxx +#undef Handle_TCollection_IndexedDataMapNode +#undef TCollection_IndexedDataMapNode_Type_ +#undef TCollection_IndexedDataMap +#undef TCollection_IndexedDataMap_hxx + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/NMTTools/NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock_0.cxx b/src/NMTTools/NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock_0.cxx new file mode 100644 index 000000000..fe39f5347 --- /dev/null +++ b/src/NMTTools/NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock_0.cxx @@ -0,0 +1,96 @@ +// File generated by CPPExt (Transient) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif +#ifndef _BOPTools_PaveBlock_HeaderFile +#include +#endif +#ifndef _TopTools_ShapeMapHasher_HeaderFile +#include +#endif +#ifndef _NMTTools_IndexedDataMapOfShapePaveBlock_HeaderFile +#include +#endif +NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock::~NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock() {} + + + +Standard_EXPORT Handle_Standard_Type& NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock_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("NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock", + sizeof(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + + +// DownCast method +// allow safe downcasting +// +const Handle(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock) Handle(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock))) { + _anOtherObject = Handle(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock)((Handle(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock)&)AnObject); + } + } + + return _anOtherObject ; +} +const Handle(Standard_Type)& NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock::DynamicType() const +{ + return STANDARD_TYPE(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock) ; +} +Standard_Boolean NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock::IsKind(const Handle(Standard_Type)& AType) const +{ + return (STANDARD_TYPE(NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock) == AType || TCollection_MapNode::IsKind(AType)); +} +Handle_NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock::~Handle_NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock() {} +#define TheKey TopoDS_Shape +#define TheKey_hxx +#define TheItem BOPTools_PaveBlock +#define TheItem_hxx +#define Hasher TopTools_ShapeMapHasher +#define Hasher_hxx +#define TCollection_IndexedDataMapNode NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock +#define TCollection_IndexedDataMapNode_hxx +#define Handle_TCollection_IndexedDataMapNode Handle_NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock +#define TCollection_IndexedDataMapNode_Type_() NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock_Type_() +#define TCollection_IndexedDataMap NMTTools_IndexedDataMapOfShapePaveBlock +#define TCollection_IndexedDataMap_hxx +#include + diff --git a/src/NMTTools/NMTTools_IndexedDataMapOfIndexedMapOfInteger.hxx b/src/NMTTools/NMTTools_IndexedDataMapOfIndexedMapOfInteger.hxx new file mode 100644 index 000000000..f7e220d8e --- /dev/null +++ b/src/NMTTools/NMTTools_IndexedDataMapOfIndexedMapOfInteger.hxx @@ -0,0 +1,133 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _NMTTools_IndexedDataMapOfIndexedMapOfInteger_HeaderFile +#define _NMTTools_IndexedDataMapOfIndexedMapOfInteger_HeaderFile + +#ifndef _TCollection_BasicMap_HeaderFile +#include +#endif +#ifndef _Standard_Integer_HeaderFile +#include +#endif +#ifndef _Handle_NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +class Standard_DomainError; +class Standard_OutOfRange; +class Standard_NoSuchObject; +class TColStd_IndexedMapOfInteger; +class TColStd_MapIntegerHasher; +class NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class NMTTools_IndexedDataMapOfIndexedMapOfInteger : public TCollection_BasicMap { + +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 NMTTools_IndexedDataMapOfIndexedMapOfInteger(const Standard_Integer NbBuckets = 1); +Standard_EXPORT NMTTools_IndexedDataMapOfIndexedMapOfInteger& Assign(const NMTTools_IndexedDataMapOfIndexedMapOfInteger& Other) ; + NMTTools_IndexedDataMapOfIndexedMapOfInteger& operator =(const NMTTools_IndexedDataMapOfIndexedMapOfInteger& Other) +{ + return Assign(Other); +} + +Standard_EXPORT void ReSize(const Standard_Integer NbBuckets) ; +Standard_EXPORT void Clear() ; +~NMTTools_IndexedDataMapOfIndexedMapOfInteger() +{ + Clear(); +} + +Standard_EXPORT Standard_Integer Add(const Standard_Integer& K,const TColStd_IndexedMapOfInteger& I) ; +Standard_EXPORT void Substitute(const Standard_Integer I,const Standard_Integer& K,const TColStd_IndexedMapOfInteger& T) ; +Standard_EXPORT void RemoveLast() ; +Standard_EXPORT Standard_Boolean Contains(const Standard_Integer& K) const; +Standard_EXPORT const Standard_Integer& FindKey(const Standard_Integer I) const; +Standard_EXPORT const TColStd_IndexedMapOfInteger& FindFromIndex(const Standard_Integer I) const; + const TColStd_IndexedMapOfInteger& operator ()(const Standard_Integer I) const +{ + return FindFromIndex(I); +} + +Standard_EXPORT TColStd_IndexedMapOfInteger& ChangeFromIndex(const Standard_Integer I) ; + TColStd_IndexedMapOfInteger& operator ()(const Standard_Integer I) +{ + return ChangeFromIndex(I); +} + +Standard_EXPORT Standard_Integer FindIndex(const Standard_Integer& K) const; +Standard_EXPORT const TColStd_IndexedMapOfInteger& FindFromKey(const Standard_Integer& K) const; +Standard_EXPORT TColStd_IndexedMapOfInteger& ChangeFromKey(const Standard_Integer& K) ; + + + + + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // +Standard_EXPORT NMTTools_IndexedDataMapOfIndexedMapOfInteger(const NMTTools_IndexedDataMapOfIndexedMapOfInteger& Other); + + + // Fields PRIVATE + // + + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/NMTTools/NMTTools_IndexedDataMapOfIndexedMapOfInteger_0.cxx b/src/NMTTools/NMTTools_IndexedDataMapOfIndexedMapOfInteger_0.cxx new file mode 100644 index 000000000..0c4124fbc --- /dev/null +++ b/src/NMTTools/NMTTools_IndexedDataMapOfIndexedMapOfInteger_0.cxx @@ -0,0 +1,50 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include + +#ifndef _Standard_DomainError_HeaderFile +#include +#endif +#ifndef _Standard_OutOfRange_HeaderFile +#include +#endif +#ifndef _Standard_NoSuchObject_HeaderFile +#include +#endif +#ifndef _TColStd_IndexedMapOfInteger_HeaderFile +#include +#endif +#ifndef _TColStd_MapIntegerHasher_HeaderFile +#include +#endif +#ifndef _NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger_HeaderFile +#include +#endif + + +#define TheKey Standard_Integer +#define TheKey_hxx +#define TheItem TColStd_IndexedMapOfInteger +#define TheItem_hxx +#define Hasher TColStd_MapIntegerHasher +#define Hasher_hxx +#define TCollection_IndexedDataMapNode NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger +#define TCollection_IndexedDataMapNode_hxx +#define Handle_TCollection_IndexedDataMapNode Handle_NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger +#define TCollection_IndexedDataMapNode_Type_() NMTTools_IndexedDataMapNodeOfIndexedDataMapOfIndexedMapOfInteger_Type_() +#define TCollection_IndexedDataMap NMTTools_IndexedDataMapOfIndexedMapOfInteger +#define TCollection_IndexedDataMap_hxx +#include + diff --git a/src/NMTTools/NMTTools_IndexedDataMapOfShapeIndexedMapOfShape.hxx b/src/NMTTools/NMTTools_IndexedDataMapOfShapeIndexedMapOfShape.hxx new file mode 100644 index 000000000..9a7265cde --- /dev/null +++ b/src/NMTTools/NMTTools_IndexedDataMapOfShapeIndexedMapOfShape.hxx @@ -0,0 +1,134 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _NMTTools_IndexedDataMapOfShapeIndexedMapOfShape_HeaderFile +#define _NMTTools_IndexedDataMapOfShapeIndexedMapOfShape_HeaderFile + +#ifndef _TCollection_BasicMap_HeaderFile +#include +#endif +#ifndef _Handle_NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape_HeaderFile +#include +#endif +#ifndef _Standard_Integer_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +class Standard_DomainError; +class Standard_OutOfRange; +class Standard_NoSuchObject; +class TopoDS_Shape; +class TopTools_IndexedMapOfShape; +class TopTools_ShapeMapHasher; +class NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class NMTTools_IndexedDataMapOfShapeIndexedMapOfShape : public TCollection_BasicMap { + +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 NMTTools_IndexedDataMapOfShapeIndexedMapOfShape(const Standard_Integer NbBuckets = 1); +Standard_EXPORT NMTTools_IndexedDataMapOfShapeIndexedMapOfShape& Assign(const NMTTools_IndexedDataMapOfShapeIndexedMapOfShape& Other) ; + NMTTools_IndexedDataMapOfShapeIndexedMapOfShape& operator =(const NMTTools_IndexedDataMapOfShapeIndexedMapOfShape& Other) +{ + return Assign(Other); +} + +Standard_EXPORT void ReSize(const Standard_Integer NbBuckets) ; +Standard_EXPORT void Clear() ; +~NMTTools_IndexedDataMapOfShapeIndexedMapOfShape() +{ + Clear(); +} + +Standard_EXPORT Standard_Integer Add(const TopoDS_Shape& K,const TopTools_IndexedMapOfShape& I) ; +Standard_EXPORT void Substitute(const Standard_Integer I,const TopoDS_Shape& K,const TopTools_IndexedMapOfShape& T) ; +Standard_EXPORT void RemoveLast() ; +Standard_EXPORT Standard_Boolean Contains(const TopoDS_Shape& K) const; +Standard_EXPORT const TopoDS_Shape& FindKey(const Standard_Integer I) const; +Standard_EXPORT const TopTools_IndexedMapOfShape& FindFromIndex(const Standard_Integer I) const; + const TopTools_IndexedMapOfShape& operator ()(const Standard_Integer I) const +{ + return FindFromIndex(I); +} + +Standard_EXPORT TopTools_IndexedMapOfShape& ChangeFromIndex(const Standard_Integer I) ; + TopTools_IndexedMapOfShape& operator ()(const Standard_Integer I) +{ + return ChangeFromIndex(I); +} + +Standard_EXPORT Standard_Integer FindIndex(const TopoDS_Shape& K) const; +Standard_EXPORT const TopTools_IndexedMapOfShape& FindFromKey(const TopoDS_Shape& K) const; +Standard_EXPORT TopTools_IndexedMapOfShape& ChangeFromKey(const TopoDS_Shape& K) ; + + + + + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // +Standard_EXPORT NMTTools_IndexedDataMapOfShapeIndexedMapOfShape(const NMTTools_IndexedDataMapOfShapeIndexedMapOfShape& Other); + + + // Fields PRIVATE + // + + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/NMTTools/NMTTools_IndexedDataMapOfShapeIndexedMapOfShape_0.cxx b/src/NMTTools/NMTTools_IndexedDataMapOfShapeIndexedMapOfShape_0.cxx new file mode 100644 index 000000000..44fb79552 --- /dev/null +++ b/src/NMTTools/NMTTools_IndexedDataMapOfShapeIndexedMapOfShape_0.cxx @@ -0,0 +1,53 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include + +#ifndef _Standard_DomainError_HeaderFile +#include +#endif +#ifndef _Standard_OutOfRange_HeaderFile +#include +#endif +#ifndef _Standard_NoSuchObject_HeaderFile +#include +#endif +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif +#ifndef _TopTools_IndexedMapOfShape_HeaderFile +#include +#endif +#ifndef _TopTools_ShapeMapHasher_HeaderFile +#include +#endif +#ifndef _NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape_HeaderFile +#include +#endif + + +#define TheKey TopoDS_Shape +#define TheKey_hxx +#define TheItem TopTools_IndexedMapOfShape +#define TheItem_hxx +#define Hasher TopTools_ShapeMapHasher +#define Hasher_hxx +#define TCollection_IndexedDataMapNode NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape +#define TCollection_IndexedDataMapNode_hxx +#define Handle_TCollection_IndexedDataMapNode Handle_NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape +#define TCollection_IndexedDataMapNode_Type_() NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapeIndexedMapOfShape_Type_() +#define TCollection_IndexedDataMap NMTTools_IndexedDataMapOfShapeIndexedMapOfShape +#define TCollection_IndexedDataMap_hxx +#include + diff --git a/src/NMTTools/NMTTools_IndexedDataMapOfShapePaveBlock.hxx b/src/NMTTools/NMTTools_IndexedDataMapOfShapePaveBlock.hxx new file mode 100644 index 000000000..7880c6c78 --- /dev/null +++ b/src/NMTTools/NMTTools_IndexedDataMapOfShapePaveBlock.hxx @@ -0,0 +1,134 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _NMTTools_IndexedDataMapOfShapePaveBlock_HeaderFile +#define _NMTTools_IndexedDataMapOfShapePaveBlock_HeaderFile + +#ifndef _TCollection_BasicMap_HeaderFile +#include +#endif +#ifndef _Handle_NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock_HeaderFile +#include +#endif +#ifndef _Standard_Integer_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +class Standard_DomainError; +class Standard_OutOfRange; +class Standard_NoSuchObject; +class TopoDS_Shape; +class BOPTools_PaveBlock; +class TopTools_ShapeMapHasher; +class NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class NMTTools_IndexedDataMapOfShapePaveBlock : public TCollection_BasicMap { + +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 NMTTools_IndexedDataMapOfShapePaveBlock(const Standard_Integer NbBuckets = 1); +Standard_EXPORT NMTTools_IndexedDataMapOfShapePaveBlock& Assign(const NMTTools_IndexedDataMapOfShapePaveBlock& Other) ; + NMTTools_IndexedDataMapOfShapePaveBlock& operator =(const NMTTools_IndexedDataMapOfShapePaveBlock& Other) +{ + return Assign(Other); +} + +Standard_EXPORT void ReSize(const Standard_Integer NbBuckets) ; +Standard_EXPORT void Clear() ; +~NMTTools_IndexedDataMapOfShapePaveBlock() +{ + Clear(); +} + +Standard_EXPORT Standard_Integer Add(const TopoDS_Shape& K,const BOPTools_PaveBlock& I) ; +Standard_EXPORT void Substitute(const Standard_Integer I,const TopoDS_Shape& K,const BOPTools_PaveBlock& T) ; +Standard_EXPORT void RemoveLast() ; +Standard_EXPORT Standard_Boolean Contains(const TopoDS_Shape& K) const; +Standard_EXPORT const TopoDS_Shape& FindKey(const Standard_Integer I) const; +Standard_EXPORT const BOPTools_PaveBlock& FindFromIndex(const Standard_Integer I) const; + const BOPTools_PaveBlock& operator ()(const Standard_Integer I) const +{ + return FindFromIndex(I); +} + +Standard_EXPORT BOPTools_PaveBlock& ChangeFromIndex(const Standard_Integer I) ; + BOPTools_PaveBlock& operator ()(const Standard_Integer I) +{ + return ChangeFromIndex(I); +} + +Standard_EXPORT Standard_Integer FindIndex(const TopoDS_Shape& K) const; +Standard_EXPORT const BOPTools_PaveBlock& FindFromKey(const TopoDS_Shape& K) const; +Standard_EXPORT BOPTools_PaveBlock& ChangeFromKey(const TopoDS_Shape& K) ; + + + + + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // +Standard_EXPORT NMTTools_IndexedDataMapOfShapePaveBlock(const NMTTools_IndexedDataMapOfShapePaveBlock& Other); + + + // Fields PRIVATE + // + + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/NMTTools/NMTTools_IndexedDataMapOfShapePaveBlock_0.cxx b/src/NMTTools/NMTTools_IndexedDataMapOfShapePaveBlock_0.cxx new file mode 100644 index 000000000..4f55cebf3 --- /dev/null +++ b/src/NMTTools/NMTTools_IndexedDataMapOfShapePaveBlock_0.cxx @@ -0,0 +1,53 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include + +#ifndef _Standard_DomainError_HeaderFile +#include +#endif +#ifndef _Standard_OutOfRange_HeaderFile +#include +#endif +#ifndef _Standard_NoSuchObject_HeaderFile +#include +#endif +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif +#ifndef _BOPTools_PaveBlock_HeaderFile +#include +#endif +#ifndef _TopTools_ShapeMapHasher_HeaderFile +#include +#endif +#ifndef _NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock_HeaderFile +#include +#endif + + +#define TheKey TopoDS_Shape +#define TheKey_hxx +#define TheItem BOPTools_PaveBlock +#define TheItem_hxx +#define Hasher TopTools_ShapeMapHasher +#define Hasher_hxx +#define TCollection_IndexedDataMapNode NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock +#define TCollection_IndexedDataMapNode_hxx +#define Handle_TCollection_IndexedDataMapNode Handle_NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock +#define TCollection_IndexedDataMapNode_Type_() NMTTools_IndexedDataMapNodeOfIndexedDataMapOfShapePaveBlock_Type_() +#define TCollection_IndexedDataMap NMTTools_IndexedDataMapOfShapePaveBlock +#define TCollection_IndexedDataMap_hxx +#include + diff --git a/src/NMTTools/NMTTools_IteratorOfCoupleOfShape.cdl b/src/NMTTools/NMTTools_IteratorOfCoupleOfShape.cdl new file mode 100644 index 000000000..1d59d74b8 --- /dev/null +++ b/src/NMTTools/NMTTools_IteratorOfCoupleOfShape.cdl @@ -0,0 +1,55 @@ +-- File: NMTTools_IteratorOfCoupleOfShape.cdl +-- Created: Thu Dec 4 16:57:48 2003 +-- Author: Peter KURNEV +-- +---Copyright: Matra Datavision 2003 + + +class IteratorOfCoupleOfShape from NMTTools + inherits IteratorOfCoupleOfShape from BOPTools + + ---Purpose: + +uses + ShapeEnum from TopAbs, + IndexedMapOfCoupleOfInteger from BOPTools, + PShapesDataStructure from NMTDS, + ShapesDataStructure from NMTDS + +raises + NoSuchObject from Standard + +is + Create + returns IteratorOfCoupleOfShape from NMTTools; + + SetDS(me:out; + pDS:PShapesDataStructure from NMTDS); + + Initialize(me: in out; + Type1: ShapeEnum from TopAbs; + Type2: ShapeEnum from TopAbs) + raises NoSuchObject from Standard + is redefined; + + Current(me; Index1: in out Integer from Standard; + Index2: in out Integer from Standard; + WithSubShape: out Boolean from Standard) + is redefined; + + More(me) + returns Boolean from Standard + is redefined; + + DS(me) + returns ShapesDataStructure from NMTDS; + ---C++:return const & + +fields + myPNMTPS : PShapesDataStructure from NMTDS is protected; + myMap : IndexedMapOfCoupleOfInteger from BOPTools is protected; + myIndex1 : Integer from Standard is protected; + myIndex2 : Integer from Standard is protected; + myWithSubShapeFlag: Boolean from Standard is protected; + +end IteratorOfCoupleOfShape; diff --git a/src/NMTTools/NMTTools_IteratorOfCoupleOfShape.cxx b/src/NMTTools/NMTTools_IteratorOfCoupleOfShape.cxx new file mode 100644 index 000000000..155b9b843 --- /dev/null +++ b/src/NMTTools/NMTTools_IteratorOfCoupleOfShape.cxx @@ -0,0 +1,140 @@ +// File: NMTTools_IteratorOfCoupleOfShape.cxx +// Created: Thu Dec 4 17:00:03 2003 +// Author: Peter KURNEV +// + + +#include +#include +#include +#include +#include +#include + +//======================================================================= +// function: +// purpose: +//======================================================================= + NMTTools_IteratorOfCoupleOfShape::NMTTools_IteratorOfCoupleOfShape() +: + BOPTools_IteratorOfCoupleOfShape() +{ + myIndex1=0; + myIndex2=0; + myWithSubShapeFlag=Standard_False; +} +//======================================================================= +// function: SetDS +// purpose: +//======================================================================= + void NMTTools_IteratorOfCoupleOfShape::SetDS(const NMTDS_PShapesDataStructure& PDS) +{ + myPNMTPS=PDS; + SetDataStructure(myPNMTPS); +} +//======================================================================= +// function: Initialize +// purpose: +//======================================================================= + void NMTTools_IteratorOfCoupleOfShape::Initialize(const TopAbs_ShapeEnum Type1, + const TopAbs_ShapeEnum Type2) +{ + if(myPDS==NULL) { + Standard_NoSuchObject::Raise("NMTTools_IteratorOfCoupleOfShape::Initialize: myPDS==NULL"); + } + // + myType1 = Type1; + myType2 = Type2; + myCurrentIndex1 = -1; + myCurrentIndex2 = -1; + // + myFirstLowerIndex=1; + myFirstUpperIndex=myPNMTPS->NumberOfShapesOfTheObject(); + mySecondLowerIndex=myFirstUpperIndex+1; + mySecondUpperIndex=myFirstUpperIndex+myPNMTPS->NumberOfShapesOfTheTool(); + // + Standard_Integer n1, n2, aIR1, aIR2;//, aN1, aN2, aNS; + // + const NMTDS_CArray1OfIndexRange& aRanges=myPNMTPS->Ranges(); + // + //aNS=myPNMTPS->NumberOfShapesOfTheObject(); + myIndex1=0; + myIndex2=0; + myWithSubShapeFlag=Standard_False; + // + myListOfCouple.Clear(); + myMap.Clear(); + // + NextP(); + for (; MoreP(); NextP()) { + CurrentP(n1, n2); + // + aIR1=myPNMTPS->ShapeRangeIndex(n1); + aIR2=myPNMTPS->ShapeRangeIndex(n2); + if (aIR1==aIR2){ + continue; + } + // + BOPTools_CoupleOfInteger aCouple(n1, n2); + myListOfCouple.Append(aCouple); + // + /* + aN1=(n1>aNS)? n1-aNS : n1; + aN2=(n2>aNS)? n2-aNS : n2; + BOPTools_CoupleOfInteger aCoupleX(aN1, aN2); + myMap.Add(aCoupleX); + */ + } + myIterator.Initialize(myListOfCouple); +} +//======================================================================= +// function: Current +// purpose: +//======================================================================= + void NMTTools_IteratorOfCoupleOfShape::Current(Standard_Integer& aIndex1, + Standard_Integer& aIndex2, + Standard_Boolean& aWithSubShape) const +{ + aIndex1=myIndex1; + aIndex2=myIndex2; + aWithSubShape=myWithSubShapeFlag; +} +//======================================================================= +// function: More +// purpose: +//======================================================================= + Standard_Boolean NMTTools_IteratorOfCoupleOfShape::More()const +{ + Standard_Boolean bMore, bWithSubShape; + Standard_Integer n1, n2, aNS, aN1, aN2; + BOPTools_CoupleOfInteger aCoupleX; + NMTTools_IteratorOfCoupleOfShape* pIt=(NMTTools_IteratorOfCoupleOfShape*)this; + // + aNS=myPNMTPS->NumberOfShapesOfTheObject(); + pIt->myIndex1=0; + pIt->myIndex2=0; + pIt->myWithSubShapeFlag=Standard_False; + // + while (1) { + bMore=myIterator.More(); + if (!bMore) { + break; + } + // + BOPTools_IteratorOfCoupleOfShape::Current(n1, n2, bWithSubShape); + aN1=(n1>aNS)? n1-aNS : n1; + aN2=(n2>aNS)? n2-aNS : n2; + aCoupleX.SetCouple(aN1, aN2); + if (!myMap.Contains(aCoupleX)) { + pIt->myMap.Add(aCoupleX); + // + pIt->myIndex1=aN1; + pIt->myIndex2=aN2; + pIt->myWithSubShapeFlag=bWithSubShape; + break; + } + // + pIt->Next(); + } + return bMore; +} diff --git a/src/NMTTools/NMTTools_IteratorOfCoupleOfShape.hxx b/src/NMTTools/NMTTools_IteratorOfCoupleOfShape.hxx new file mode 100644 index 000000000..bcd6d0ef0 --- /dev/null +++ b/src/NMTTools/NMTTools_IteratorOfCoupleOfShape.hxx @@ -0,0 +1,111 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _NMTTools_IteratorOfCoupleOfShape_HeaderFile +#define _NMTTools_IteratorOfCoupleOfShape_HeaderFile + +#ifndef _NMTDS_PShapesDataStructure_HeaderFile +#include +#endif +#ifndef _BOPTools_IndexedMapOfCoupleOfInteger_HeaderFile +#include +#endif +#ifndef _Standard_Integer_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +#ifndef _BOPTools_IteratorOfCoupleOfShape_HeaderFile +#include +#endif +#ifndef _TopAbs_ShapeEnum_HeaderFile +#include +#endif +class Standard_NoSuchObject; +class NMTDS_ShapesDataStructure; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class NMTTools_IteratorOfCoupleOfShape : public BOPTools_IteratorOfCoupleOfShape { + +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 NMTTools_IteratorOfCoupleOfShape(); +Standard_EXPORT void SetDS(const NMTDS_PShapesDataStructure& pDS) ; +Standard_EXPORT virtual void Initialize(const TopAbs_ShapeEnum Type1,const TopAbs_ShapeEnum Type2) ; +Standard_EXPORT virtual void Current(Standard_Integer& Index1,Standard_Integer& Index2,Standard_Boolean& WithSubShape) const; +Standard_EXPORT virtual Standard_Boolean More() const; +Standard_EXPORT const NMTDS_ShapesDataStructure& DS() const; + + + + + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // +NMTDS_PShapesDataStructure myPNMTPS; +BOPTools_IndexedMapOfCoupleOfInteger myMap; +Standard_Integer myIndex1; +Standard_Integer myIndex2; +Standard_Boolean myWithSubShapeFlag; + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // + + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/NMTTools/NMTTools_IteratorOfCoupleOfShape.ixx b/src/NMTTools/NMTTools_IteratorOfCoupleOfShape.ixx new file mode 100644 index 000000000..f83e9fb6a --- /dev/null +++ b/src/NMTTools/NMTTools_IteratorOfCoupleOfShape.ixx @@ -0,0 +1,19 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include + + + + diff --git a/src/NMTTools/NMTTools_IteratorOfCoupleOfShape.jxx b/src/NMTTools/NMTTools_IteratorOfCoupleOfShape.jxx new file mode 100644 index 000000000..de093960b --- /dev/null +++ b/src/NMTTools/NMTTools_IteratorOfCoupleOfShape.jxx @@ -0,0 +1,9 @@ +#ifndef _Standard_NoSuchObject_HeaderFile +#include +#endif +#ifndef _NMTDS_ShapesDataStructure_HeaderFile +#include +#endif +#ifndef _NMTTools_IteratorOfCoupleOfShape_HeaderFile +#include +#endif diff --git a/src/NMTTools/NMTTools_ListIteratorOfListOfCommonBlock.hxx b/src/NMTTools/NMTTools_ListIteratorOfListOfCommonBlock.hxx new file mode 100644 index 000000000..362033001 --- /dev/null +++ b/src/NMTTools/NMTTools_ListIteratorOfListOfCommonBlock.hxx @@ -0,0 +1,124 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _NMTTools_ListIteratorOfListOfCommonBlock_HeaderFile +#define _NMTTools_ListIteratorOfListOfCommonBlock_HeaderFile + +#ifndef _Standard_Address_HeaderFile +#include +#endif +#ifndef _Handle_NMTTools_ListNodeOfListOfCommonBlock_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +class Standard_NoMoreObject; +class Standard_NoSuchObject; +class NMTTools_ListOfCommonBlock; +class NMTTools_CommonBlock; +class NMTTools_ListNodeOfListOfCommonBlock; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class NMTTools_ListIteratorOfListOfCommonBlock { + +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 NMTTools_ListIteratorOfListOfCommonBlock(); +Standard_EXPORT NMTTools_ListIteratorOfListOfCommonBlock(const NMTTools_ListOfCommonBlock& L); +Standard_EXPORT void Initialize(const NMTTools_ListOfCommonBlock& L) ; + Standard_Boolean More() const; +Standard_EXPORT void Next() ; +Standard_EXPORT NMTTools_CommonBlock& Value() const; + + +friend class NMTTools_ListOfCommonBlock; + + + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // +Standard_Address current; +Standard_Address previous; + + +}; + +#define Item NMTTools_CommonBlock +#define Item_hxx +#define TCollection_ListNode NMTTools_ListNodeOfListOfCommonBlock +#define TCollection_ListNode_hxx +#define TCollection_ListIterator NMTTools_ListIteratorOfListOfCommonBlock +#define TCollection_ListIterator_hxx +#define Handle_TCollection_ListNode Handle_NMTTools_ListNodeOfListOfCommonBlock +#define TCollection_ListNode_Type_() NMTTools_ListNodeOfListOfCommonBlock_Type_() +#define TCollection_List NMTTools_ListOfCommonBlock +#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/NMTTools/NMTTools_ListIteratorOfListOfCommonBlock_0.cxx b/src/NMTTools/NMTTools_ListIteratorOfListOfCommonBlock_0.cxx new file mode 100644 index 000000000..10f53977d --- /dev/null +++ b/src/NMTTools/NMTTools_ListIteratorOfListOfCommonBlock_0.cxx @@ -0,0 +1,45 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include + +#ifndef _Standard_NoMoreObject_HeaderFile +#include +#endif +#ifndef _Standard_NoSuchObject_HeaderFile +#include +#endif +#ifndef _NMTTools_ListOfCommonBlock_HeaderFile +#include +#endif +#ifndef _NMTTools_CommonBlock_HeaderFile +#include +#endif +#ifndef _NMTTools_ListNodeOfListOfCommonBlock_HeaderFile +#include +#endif + + +#define Item NMTTools_CommonBlock +#define Item_hxx +#define TCollection_ListNode NMTTools_ListNodeOfListOfCommonBlock +#define TCollection_ListNode_hxx +#define TCollection_ListIterator NMTTools_ListIteratorOfListOfCommonBlock +#define TCollection_ListIterator_hxx +#define Handle_TCollection_ListNode Handle_NMTTools_ListNodeOfListOfCommonBlock +#define TCollection_ListNode_Type_() NMTTools_ListNodeOfListOfCommonBlock_Type_() +#define TCollection_List NMTTools_ListOfCommonBlock +#define TCollection_List_hxx +#include + diff --git a/src/NMTTools/NMTTools_ListIteratorOfListOfCoupleOfShape.hxx b/src/NMTTools/NMTTools_ListIteratorOfListOfCoupleOfShape.hxx new file mode 100644 index 000000000..3430c79f8 --- /dev/null +++ b/src/NMTTools/NMTTools_ListIteratorOfListOfCoupleOfShape.hxx @@ -0,0 +1,124 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _NMTTools_ListIteratorOfListOfCoupleOfShape_HeaderFile +#define _NMTTools_ListIteratorOfListOfCoupleOfShape_HeaderFile + +#ifndef _Standard_Address_HeaderFile +#include +#endif +#ifndef _Handle_NMTTools_ListNodeOfListOfCoupleOfShape_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +class Standard_NoMoreObject; +class Standard_NoSuchObject; +class NMTTools_ListOfCoupleOfShape; +class NMTTools_CoupleOfShape; +class NMTTools_ListNodeOfListOfCoupleOfShape; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class NMTTools_ListIteratorOfListOfCoupleOfShape { + +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 NMTTools_ListIteratorOfListOfCoupleOfShape(); +Standard_EXPORT NMTTools_ListIteratorOfListOfCoupleOfShape(const NMTTools_ListOfCoupleOfShape& L); +Standard_EXPORT void Initialize(const NMTTools_ListOfCoupleOfShape& L) ; + Standard_Boolean More() const; +Standard_EXPORT void Next() ; +Standard_EXPORT NMTTools_CoupleOfShape& Value() const; + + +friend class NMTTools_ListOfCoupleOfShape; + + + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // +Standard_Address current; +Standard_Address previous; + + +}; + +#define Item NMTTools_CoupleOfShape +#define Item_hxx +#define TCollection_ListNode NMTTools_ListNodeOfListOfCoupleOfShape +#define TCollection_ListNode_hxx +#define TCollection_ListIterator NMTTools_ListIteratorOfListOfCoupleOfShape +#define TCollection_ListIterator_hxx +#define Handle_TCollection_ListNode Handle_NMTTools_ListNodeOfListOfCoupleOfShape +#define TCollection_ListNode_Type_() NMTTools_ListNodeOfListOfCoupleOfShape_Type_() +#define TCollection_List NMTTools_ListOfCoupleOfShape +#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/NMTTools/NMTTools_ListIteratorOfListOfCoupleOfShape_0.cxx b/src/NMTTools/NMTTools_ListIteratorOfListOfCoupleOfShape_0.cxx new file mode 100644 index 000000000..9cba93370 --- /dev/null +++ b/src/NMTTools/NMTTools_ListIteratorOfListOfCoupleOfShape_0.cxx @@ -0,0 +1,45 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include + +#ifndef _Standard_NoMoreObject_HeaderFile +#include +#endif +#ifndef _Standard_NoSuchObject_HeaderFile +#include +#endif +#ifndef _NMTTools_ListOfCoupleOfShape_HeaderFile +#include +#endif +#ifndef _NMTTools_CoupleOfShape_HeaderFile +#include +#endif +#ifndef _NMTTools_ListNodeOfListOfCoupleOfShape_HeaderFile +#include +#endif + + +#define Item NMTTools_CoupleOfShape +#define Item_hxx +#define TCollection_ListNode NMTTools_ListNodeOfListOfCoupleOfShape +#define TCollection_ListNode_hxx +#define TCollection_ListIterator NMTTools_ListIteratorOfListOfCoupleOfShape +#define TCollection_ListIterator_hxx +#define Handle_TCollection_ListNode Handle_NMTTools_ListNodeOfListOfCoupleOfShape +#define TCollection_ListNode_Type_() NMTTools_ListNodeOfListOfCoupleOfShape_Type_() +#define TCollection_List NMTTools_ListOfCoupleOfShape +#define TCollection_List_hxx +#include + diff --git a/src/NMTTools/NMTTools_ListNodeOfListOfCommonBlock.hxx b/src/NMTTools/NMTTools_ListNodeOfListOfCommonBlock.hxx new file mode 100644 index 000000000..88cf5854a --- /dev/null +++ b/src/NMTTools/NMTTools_ListNodeOfListOfCommonBlock.hxx @@ -0,0 +1,123 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#ifndef _NMTTools_ListNodeOfListOfCommonBlock_HeaderFile +#define _NMTTools_ListNodeOfListOfCommonBlock_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Handle_NMTTools_ListNodeOfListOfCommonBlock_HeaderFile +#include +#endif + +#ifndef _NMTTools_CommonBlock_HeaderFile +#include +#endif +#ifndef _TCollection_MapNode_HeaderFile +#include +#endif +#ifndef _TCollection_MapNodePtr_HeaderFile +#include +#endif +class NMTTools_CommonBlock; +class NMTTools_ListOfCommonBlock; +class NMTTools_ListIteratorOfListOfCommonBlock; + + +class NMTTools_ListNodeOfListOfCommonBlock : 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 + // +NMTTools_ListNodeOfListOfCommonBlock(const NMTTools_CommonBlock& I,const TCollection_MapNodePtr& n); + NMTTools_CommonBlock& Value() const; +Standard_EXPORT ~NMTTools_ListNodeOfListOfCommonBlock(); + + + + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& NMTTools_ListNodeOfListOfCommonBlock_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 + // +NMTTools_CommonBlock myValue; + + +}; + +#define Item NMTTools_CommonBlock +#define Item_hxx +#define TCollection_ListNode NMTTools_ListNodeOfListOfCommonBlock +#define TCollection_ListNode_hxx +#define TCollection_ListIterator NMTTools_ListIteratorOfListOfCommonBlock +#define TCollection_ListIterator_hxx +#define Handle_TCollection_ListNode Handle_NMTTools_ListNodeOfListOfCommonBlock +#define TCollection_ListNode_Type_() NMTTools_ListNodeOfListOfCommonBlock_Type_() +#define TCollection_List NMTTools_ListOfCommonBlock +#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/NMTTools/NMTTools_ListNodeOfListOfCommonBlock_0.cxx b/src/NMTTools/NMTTools_ListNodeOfListOfCommonBlock_0.cxx new file mode 100644 index 000000000..ad488952f --- /dev/null +++ b/src/NMTTools/NMTTools_ListNodeOfListOfCommonBlock_0.cxx @@ -0,0 +1,91 @@ +// File generated by CPPExt (Transient) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _NMTTools_CommonBlock_HeaderFile +#include +#endif +#ifndef _NMTTools_ListOfCommonBlock_HeaderFile +#include +#endif +#ifndef _NMTTools_ListIteratorOfListOfCommonBlock_HeaderFile +#include +#endif +NMTTools_ListNodeOfListOfCommonBlock::~NMTTools_ListNodeOfListOfCommonBlock() {} + + + +Standard_EXPORT Handle_Standard_Type& NMTTools_ListNodeOfListOfCommonBlock_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("NMTTools_ListNodeOfListOfCommonBlock", + sizeof(NMTTools_ListNodeOfListOfCommonBlock), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + + +// DownCast method +// allow safe downcasting +// +const Handle(NMTTools_ListNodeOfListOfCommonBlock) Handle(NMTTools_ListNodeOfListOfCommonBlock)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(NMTTools_ListNodeOfListOfCommonBlock) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(NMTTools_ListNodeOfListOfCommonBlock))) { + _anOtherObject = Handle(NMTTools_ListNodeOfListOfCommonBlock)((Handle(NMTTools_ListNodeOfListOfCommonBlock)&)AnObject); + } + } + + return _anOtherObject ; +} +const Handle(Standard_Type)& NMTTools_ListNodeOfListOfCommonBlock::DynamicType() const +{ + return STANDARD_TYPE(NMTTools_ListNodeOfListOfCommonBlock) ; +} +Standard_Boolean NMTTools_ListNodeOfListOfCommonBlock::IsKind(const Handle(Standard_Type)& AType) const +{ + return (STANDARD_TYPE(NMTTools_ListNodeOfListOfCommonBlock) == AType || TCollection_MapNode::IsKind(AType)); +} +Handle_NMTTools_ListNodeOfListOfCommonBlock::~Handle_NMTTools_ListNodeOfListOfCommonBlock() {} +#define Item NMTTools_CommonBlock +#define Item_hxx +#define TCollection_ListNode NMTTools_ListNodeOfListOfCommonBlock +#define TCollection_ListNode_hxx +#define TCollection_ListIterator NMTTools_ListIteratorOfListOfCommonBlock +#define TCollection_ListIterator_hxx +#define Handle_TCollection_ListNode Handle_NMTTools_ListNodeOfListOfCommonBlock +#define TCollection_ListNode_Type_() NMTTools_ListNodeOfListOfCommonBlock_Type_() +#define TCollection_List NMTTools_ListOfCommonBlock +#define TCollection_List_hxx +#include + diff --git a/src/NMTTools/NMTTools_ListNodeOfListOfCoupleOfShape.hxx b/src/NMTTools/NMTTools_ListNodeOfListOfCoupleOfShape.hxx new file mode 100644 index 000000000..cde01ee9b --- /dev/null +++ b/src/NMTTools/NMTTools_ListNodeOfListOfCoupleOfShape.hxx @@ -0,0 +1,123 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#ifndef _NMTTools_ListNodeOfListOfCoupleOfShape_HeaderFile +#define _NMTTools_ListNodeOfListOfCoupleOfShape_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Handle_NMTTools_ListNodeOfListOfCoupleOfShape_HeaderFile +#include +#endif + +#ifndef _NMTTools_CoupleOfShape_HeaderFile +#include +#endif +#ifndef _TCollection_MapNode_HeaderFile +#include +#endif +#ifndef _TCollection_MapNodePtr_HeaderFile +#include +#endif +class NMTTools_CoupleOfShape; +class NMTTools_ListOfCoupleOfShape; +class NMTTools_ListIteratorOfListOfCoupleOfShape; + + +class NMTTools_ListNodeOfListOfCoupleOfShape : 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 + // +NMTTools_ListNodeOfListOfCoupleOfShape(const NMTTools_CoupleOfShape& I,const TCollection_MapNodePtr& n); + NMTTools_CoupleOfShape& Value() const; +Standard_EXPORT ~NMTTools_ListNodeOfListOfCoupleOfShape(); + + + + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& NMTTools_ListNodeOfListOfCoupleOfShape_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 + // +NMTTools_CoupleOfShape myValue; + + +}; + +#define Item NMTTools_CoupleOfShape +#define Item_hxx +#define TCollection_ListNode NMTTools_ListNodeOfListOfCoupleOfShape +#define TCollection_ListNode_hxx +#define TCollection_ListIterator NMTTools_ListIteratorOfListOfCoupleOfShape +#define TCollection_ListIterator_hxx +#define Handle_TCollection_ListNode Handle_NMTTools_ListNodeOfListOfCoupleOfShape +#define TCollection_ListNode_Type_() NMTTools_ListNodeOfListOfCoupleOfShape_Type_() +#define TCollection_List NMTTools_ListOfCoupleOfShape +#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/NMTTools/NMTTools_ListNodeOfListOfCoupleOfShape_0.cxx b/src/NMTTools/NMTTools_ListNodeOfListOfCoupleOfShape_0.cxx new file mode 100644 index 000000000..296236fcb --- /dev/null +++ b/src/NMTTools/NMTTools_ListNodeOfListOfCoupleOfShape_0.cxx @@ -0,0 +1,91 @@ +// File generated by CPPExt (Transient) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _NMTTools_CoupleOfShape_HeaderFile +#include +#endif +#ifndef _NMTTools_ListOfCoupleOfShape_HeaderFile +#include +#endif +#ifndef _NMTTools_ListIteratorOfListOfCoupleOfShape_HeaderFile +#include +#endif +NMTTools_ListNodeOfListOfCoupleOfShape::~NMTTools_ListNodeOfListOfCoupleOfShape() {} + + + +Standard_EXPORT Handle_Standard_Type& NMTTools_ListNodeOfListOfCoupleOfShape_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("NMTTools_ListNodeOfListOfCoupleOfShape", + sizeof(NMTTools_ListNodeOfListOfCoupleOfShape), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + + +// DownCast method +// allow safe downcasting +// +const Handle(NMTTools_ListNodeOfListOfCoupleOfShape) Handle(NMTTools_ListNodeOfListOfCoupleOfShape)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(NMTTools_ListNodeOfListOfCoupleOfShape) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(NMTTools_ListNodeOfListOfCoupleOfShape))) { + _anOtherObject = Handle(NMTTools_ListNodeOfListOfCoupleOfShape)((Handle(NMTTools_ListNodeOfListOfCoupleOfShape)&)AnObject); + } + } + + return _anOtherObject ; +} +const Handle(Standard_Type)& NMTTools_ListNodeOfListOfCoupleOfShape::DynamicType() const +{ + return STANDARD_TYPE(NMTTools_ListNodeOfListOfCoupleOfShape) ; +} +Standard_Boolean NMTTools_ListNodeOfListOfCoupleOfShape::IsKind(const Handle(Standard_Type)& AType) const +{ + return (STANDARD_TYPE(NMTTools_ListNodeOfListOfCoupleOfShape) == AType || TCollection_MapNode::IsKind(AType)); +} +Handle_NMTTools_ListNodeOfListOfCoupleOfShape::~Handle_NMTTools_ListNodeOfListOfCoupleOfShape() {} +#define Item NMTTools_CoupleOfShape +#define Item_hxx +#define TCollection_ListNode NMTTools_ListNodeOfListOfCoupleOfShape +#define TCollection_ListNode_hxx +#define TCollection_ListIterator NMTTools_ListIteratorOfListOfCoupleOfShape +#define TCollection_ListIterator_hxx +#define Handle_TCollection_ListNode Handle_NMTTools_ListNodeOfListOfCoupleOfShape +#define TCollection_ListNode_Type_() NMTTools_ListNodeOfListOfCoupleOfShape_Type_() +#define TCollection_List NMTTools_ListOfCoupleOfShape +#define TCollection_List_hxx +#include + diff --git a/src/NMTTools/NMTTools_ListOfCommonBlock.hxx b/src/NMTTools/NMTTools_ListOfCommonBlock.hxx new file mode 100644 index 000000000..372139c0a --- /dev/null +++ b/src/NMTTools/NMTTools_ListOfCommonBlock.hxx @@ -0,0 +1,150 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _NMTTools_ListOfCommonBlock_HeaderFile +#define _NMTTools_ListOfCommonBlock_HeaderFile + +#ifndef _Standard_Address_HeaderFile +#include +#endif +#ifndef _Handle_NMTTools_ListNodeOfListOfCommonBlock_HeaderFile +#include +#endif +#ifndef _Standard_Integer_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +class Standard_NoSuchObject; +class NMTTools_ListIteratorOfListOfCommonBlock; +class NMTTools_CommonBlock; +class NMTTools_ListNodeOfListOfCommonBlock; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class NMTTools_ListOfCommonBlock { + +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 NMTTools_ListOfCommonBlock(); +Standard_EXPORT void Assign(const NMTTools_ListOfCommonBlock& Other) ; + void operator=(const NMTTools_ListOfCommonBlock& Other) +{ + Assign(Other); +} + +Standard_EXPORT Standard_Integer Extent() const; +Standard_EXPORT void Clear() ; +~NMTTools_ListOfCommonBlock() +{ + Clear(); +} + + Standard_Boolean IsEmpty() const; +Standard_EXPORT void Prepend(const NMTTools_CommonBlock& I) ; +Standard_EXPORT void Prepend(const NMTTools_CommonBlock& I,NMTTools_ListIteratorOfListOfCommonBlock& theIt) ; +Standard_EXPORT void Prepend(NMTTools_ListOfCommonBlock& Other) ; +Standard_EXPORT void Append(const NMTTools_CommonBlock& I) ; +Standard_EXPORT void Append(const NMTTools_CommonBlock& I,NMTTools_ListIteratorOfListOfCommonBlock& theIt) ; +Standard_EXPORT void Append(NMTTools_ListOfCommonBlock& Other) ; +Standard_EXPORT NMTTools_CommonBlock& First() const; +Standard_EXPORT NMTTools_CommonBlock& Last() const; +Standard_EXPORT void RemoveFirst() ; +Standard_EXPORT void Remove(NMTTools_ListIteratorOfListOfCommonBlock& It) ; +Standard_EXPORT void InsertBefore(const NMTTools_CommonBlock& I,NMTTools_ListIteratorOfListOfCommonBlock& It) ; +Standard_EXPORT void InsertBefore(NMTTools_ListOfCommonBlock& Other,NMTTools_ListIteratorOfListOfCommonBlock& It) ; +Standard_EXPORT void InsertAfter(const NMTTools_CommonBlock& I,NMTTools_ListIteratorOfListOfCommonBlock& It) ; +Standard_EXPORT void InsertAfter(NMTTools_ListOfCommonBlock& Other,NMTTools_ListIteratorOfListOfCommonBlock& It) ; + + +friend class NMTTools_ListIteratorOfListOfCommonBlock; + + + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // +Standard_EXPORT NMTTools_ListOfCommonBlock(const NMTTools_ListOfCommonBlock& Other); + + + // Fields PRIVATE + // +Standard_Address myFirst; +Standard_Address myLast; + + +}; + +#define Item NMTTools_CommonBlock +#define Item_hxx +#define TCollection_ListNode NMTTools_ListNodeOfListOfCommonBlock +#define TCollection_ListNode_hxx +#define TCollection_ListIterator NMTTools_ListIteratorOfListOfCommonBlock +#define TCollection_ListIterator_hxx +#define Handle_TCollection_ListNode Handle_NMTTools_ListNodeOfListOfCommonBlock +#define TCollection_ListNode_Type_() NMTTools_ListNodeOfListOfCommonBlock_Type_() +#define TCollection_List NMTTools_ListOfCommonBlock +#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/NMTTools/NMTTools_ListOfCommonBlock_0.cxx b/src/NMTTools/NMTTools_ListOfCommonBlock_0.cxx new file mode 100644 index 000000000..d90f47b4c --- /dev/null +++ b/src/NMTTools/NMTTools_ListOfCommonBlock_0.cxx @@ -0,0 +1,42 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include + +#ifndef _Standard_NoSuchObject_HeaderFile +#include +#endif +#ifndef _NMTTools_ListIteratorOfListOfCommonBlock_HeaderFile +#include +#endif +#ifndef _NMTTools_CommonBlock_HeaderFile +#include +#endif +#ifndef _NMTTools_ListNodeOfListOfCommonBlock_HeaderFile +#include +#endif + + +#define Item NMTTools_CommonBlock +#define Item_hxx +#define TCollection_ListNode NMTTools_ListNodeOfListOfCommonBlock +#define TCollection_ListNode_hxx +#define TCollection_ListIterator NMTTools_ListIteratorOfListOfCommonBlock +#define TCollection_ListIterator_hxx +#define Handle_TCollection_ListNode Handle_NMTTools_ListNodeOfListOfCommonBlock +#define TCollection_ListNode_Type_() NMTTools_ListNodeOfListOfCommonBlock_Type_() +#define TCollection_List NMTTools_ListOfCommonBlock +#define TCollection_List_hxx +#include + diff --git a/src/NMTTools/NMTTools_ListOfCoupleOfShape.hxx b/src/NMTTools/NMTTools_ListOfCoupleOfShape.hxx new file mode 100644 index 000000000..f92f99443 --- /dev/null +++ b/src/NMTTools/NMTTools_ListOfCoupleOfShape.hxx @@ -0,0 +1,150 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _NMTTools_ListOfCoupleOfShape_HeaderFile +#define _NMTTools_ListOfCoupleOfShape_HeaderFile + +#ifndef _Standard_Address_HeaderFile +#include +#endif +#ifndef _Handle_NMTTools_ListNodeOfListOfCoupleOfShape_HeaderFile +#include +#endif +#ifndef _Standard_Integer_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +class Standard_NoSuchObject; +class NMTTools_ListIteratorOfListOfCoupleOfShape; +class NMTTools_CoupleOfShape; +class NMTTools_ListNodeOfListOfCoupleOfShape; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class NMTTools_ListOfCoupleOfShape { + +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 NMTTools_ListOfCoupleOfShape(); +Standard_EXPORT void Assign(const NMTTools_ListOfCoupleOfShape& Other) ; + void operator=(const NMTTools_ListOfCoupleOfShape& Other) +{ + Assign(Other); +} + +Standard_EXPORT Standard_Integer Extent() const; +Standard_EXPORT void Clear() ; +~NMTTools_ListOfCoupleOfShape() +{ + Clear(); +} + + Standard_Boolean IsEmpty() const; +Standard_EXPORT void Prepend(const NMTTools_CoupleOfShape& I) ; +Standard_EXPORT void Prepend(const NMTTools_CoupleOfShape& I,NMTTools_ListIteratorOfListOfCoupleOfShape& theIt) ; +Standard_EXPORT void Prepend(NMTTools_ListOfCoupleOfShape& Other) ; +Standard_EXPORT void Append(const NMTTools_CoupleOfShape& I) ; +Standard_EXPORT void Append(const NMTTools_CoupleOfShape& I,NMTTools_ListIteratorOfListOfCoupleOfShape& theIt) ; +Standard_EXPORT void Append(NMTTools_ListOfCoupleOfShape& Other) ; +Standard_EXPORT NMTTools_CoupleOfShape& First() const; +Standard_EXPORT NMTTools_CoupleOfShape& Last() const; +Standard_EXPORT void RemoveFirst() ; +Standard_EXPORT void Remove(NMTTools_ListIteratorOfListOfCoupleOfShape& It) ; +Standard_EXPORT void InsertBefore(const NMTTools_CoupleOfShape& I,NMTTools_ListIteratorOfListOfCoupleOfShape& It) ; +Standard_EXPORT void InsertBefore(NMTTools_ListOfCoupleOfShape& Other,NMTTools_ListIteratorOfListOfCoupleOfShape& It) ; +Standard_EXPORT void InsertAfter(const NMTTools_CoupleOfShape& I,NMTTools_ListIteratorOfListOfCoupleOfShape& It) ; +Standard_EXPORT void InsertAfter(NMTTools_ListOfCoupleOfShape& Other,NMTTools_ListIteratorOfListOfCoupleOfShape& It) ; + + +friend class NMTTools_ListIteratorOfListOfCoupleOfShape; + + + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // +Standard_EXPORT NMTTools_ListOfCoupleOfShape(const NMTTools_ListOfCoupleOfShape& Other); + + + // Fields PRIVATE + // +Standard_Address myFirst; +Standard_Address myLast; + + +}; + +#define Item NMTTools_CoupleOfShape +#define Item_hxx +#define TCollection_ListNode NMTTools_ListNodeOfListOfCoupleOfShape +#define TCollection_ListNode_hxx +#define TCollection_ListIterator NMTTools_ListIteratorOfListOfCoupleOfShape +#define TCollection_ListIterator_hxx +#define Handle_TCollection_ListNode Handle_NMTTools_ListNodeOfListOfCoupleOfShape +#define TCollection_ListNode_Type_() NMTTools_ListNodeOfListOfCoupleOfShape_Type_() +#define TCollection_List NMTTools_ListOfCoupleOfShape +#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/NMTTools/NMTTools_ListOfCoupleOfShape_0.cxx b/src/NMTTools/NMTTools_ListOfCoupleOfShape_0.cxx new file mode 100644 index 000000000..047fbfa59 --- /dev/null +++ b/src/NMTTools/NMTTools_ListOfCoupleOfShape_0.cxx @@ -0,0 +1,42 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include + +#ifndef _Standard_NoSuchObject_HeaderFile +#include +#endif +#ifndef _NMTTools_ListIteratorOfListOfCoupleOfShape_HeaderFile +#include +#endif +#ifndef _NMTTools_CoupleOfShape_HeaderFile +#include +#endif +#ifndef _NMTTools_ListNodeOfListOfCoupleOfShape_HeaderFile +#include +#endif + + +#define Item NMTTools_CoupleOfShape +#define Item_hxx +#define TCollection_ListNode NMTTools_ListNodeOfListOfCoupleOfShape +#define TCollection_ListNode_hxx +#define TCollection_ListIterator NMTTools_ListIteratorOfListOfCoupleOfShape +#define TCollection_ListIterator_hxx +#define Handle_TCollection_ListNode Handle_NMTTools_ListNodeOfListOfCoupleOfShape +#define TCollection_ListNode_Type_() NMTTools_ListNodeOfListOfCoupleOfShape_Type_() +#define TCollection_List NMTTools_ListOfCoupleOfShape +#define TCollection_List_hxx +#include + diff --git a/src/NMTTools/NMTTools_PCurveMaker.cdl b/src/NMTTools/NMTTools_PCurveMaker.cdl new file mode 100644 index 000000000..0211e9d6e --- /dev/null +++ b/src/NMTTools/NMTTools_PCurveMaker.cdl @@ -0,0 +1,35 @@ +-- File: NMTTools_PCurveMaker.cdl +-- Created: +-- Author: Peter KURNEV +-- + +class PCurveMaker from NMTTools + + ---Purpose: + -- Class provides computation p-curves for the edges and theirs + --- split parts + +uses + PDSFiller from NMTTools + +is + Create (aFiller:out PDSFiller from NMTTools) + returns PCurveMaker from NMTTools; + ---Purpose: + --- Constructor + --- + Do(me:out); + ---Purpose: + --- Launch the processor + --- + IsDone(me) + returns Boolean from Standard; + ---Purpose: + --- Returns TRUE if Ok + --- + +fields + myDSFiller: PDSFiller from NMTTools is protected; + myIsDone : Boolean from Standard is protected; + +end PCurveMaker; diff --git a/src/NMTTools/NMTTools_PCurveMaker.cxx b/src/NMTTools/NMTTools_PCurveMaker.cxx new file mode 100644 index 000000000..aa85b1fec --- /dev/null +++ b/src/NMTTools/NMTTools_PCurveMaker.cxx @@ -0,0 +1,109 @@ +// File: NMTTools_PCurveMaker.cxx +// Created: +// 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: NMTTools_PCurveMaker +// purpose: +//======================================================================= + NMTTools_PCurveMaker::NMTTools_PCurveMaker(NMTTools_PDSFiller& pDSFiller) +: + myIsDone(Standard_False) +{ + myDSFiller=pDSFiller; +} +//======================================================================= +// function: IsDone +// purpose: +//======================================================================= + Standard_Boolean NMTTools_PCurveMaker::IsDone() const +{ + return myIsDone; +} +//======================================================================= +// function: Do +// purpose: +//======================================================================= + void NMTTools_PCurveMaker::Do() +{ + Standard_Integer i, aNb, nF1, nF2, nE; + BOPTools_ListIteratorOfListOfPaveBlock anIt; + TopoDS_Face aF1FWD, aF2FWD; + // + NMTTools_PaveFiller *pFiller=(NMTTools_PaveFiller*) &(myDSFiller->PaveFiller()); + NMTDS_ShapesDataStructure *pDS=pFiller->DS(); + // + BOPTools_CArray1OfSSInterference& aFFs=(pFiller->InterfPool())->SSInterferences(); + // + aNb=aFFs.Extent(); + for (i=1; i<=aNb; ++i) { + BOPTools_SSInterference& aFF=aFFs(i); + // Faces + aFF.Indices(nF1, nF2); + const TopoDS_Face& aF1=TopoDS::Face(pDS->Shape(nF1)); + const TopoDS_Face& aF2=TopoDS::Face(pDS->Shape(nF2)); + // + // 1.Forwarding the Faces + aF1FWD=aF1; + aF1FWD.Orientation(TopAbs_FORWARD); + aF2FWD=aF2; + aF2FWD.Orientation(TopAbs_FORWARD); + // + // 2. In, On parts processing + const BOPTools_ListOfPaveBlock& aLPBInOn=aFF.PaveBlocks(); + anIt.Initialize(aLPBInOn); + for (; anIt.More(); anIt.Next()) { + const BOPTools_PaveBlock& aPB=anIt.Value(); + const BOPTools_PaveBlock& aPBInOn=pFiller->RealPaveBlock(aPB); + // + nE=aPBInOn.Edge(); + const TopoDS_Edge& aE=TopoDS::Edge(pDS->Shape(nE)); + + BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aE, aF1FWD); + BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aE, aF2FWD); + } + } // for (i=1; i<=aNb; i++) + myIsDone=Standard_True; +} + diff --git a/src/NMTTools/NMTTools_PCurveMaker.hxx b/src/NMTTools/NMTTools_PCurveMaker.hxx new file mode 100644 index 000000000..5a5397802 --- /dev/null +++ b/src/NMTTools/NMTTools_PCurveMaker.hxx @@ -0,0 +1,91 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _NMTTools_PCurveMaker_HeaderFile +#define _NMTTools_PCurveMaker_HeaderFile + +#ifndef _NMTTools_PDSFiller_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class NMTTools_PCurveMaker { + +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 NMTTools_PCurveMaker(NMTTools_PDSFiller& aFiller); +Standard_EXPORT void Do() ; +Standard_EXPORT Standard_Boolean IsDone() const; + + + + + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // +NMTTools_PDSFiller myDSFiller; +Standard_Boolean myIsDone; + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // + + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/NMTTools/NMTTools_PCurveMaker.ixx b/src/NMTTools/NMTTools_PCurveMaker.ixx new file mode 100644 index 000000000..28e9ca58d --- /dev/null +++ b/src/NMTTools/NMTTools_PCurveMaker.ixx @@ -0,0 +1,19 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include + + + + diff --git a/src/NMTTools/NMTTools_PCurveMaker.jxx b/src/NMTTools/NMTTools_PCurveMaker.jxx new file mode 100644 index 000000000..48e34586c --- /dev/null +++ b/src/NMTTools/NMTTools_PCurveMaker.jxx @@ -0,0 +1,3 @@ +#ifndef _NMTTools_PCurveMaker_HeaderFile +#include +#endif diff --git a/src/NMTTools/NMTTools_PDSFiller.hxx b/src/NMTTools/NMTTools_PDSFiller.hxx new file mode 100644 index 000000000..5cc952848 --- /dev/null +++ b/src/NMTTools/NMTTools_PDSFiller.hxx @@ -0,0 +1,22 @@ +// File generated by CPPExt (Pointer) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#ifndef _NMTTools_PDSFiller_HeaderFile +#define _NMTTools_PDSFiller_HeaderFile + +class NMTTools_DSFiller; + +typedef NMTTools_DSFiller* NMTTools_PDSFiller; + +#endif diff --git a/src/NMTTools/NMTTools_PPaveFiller.hxx b/src/NMTTools/NMTTools_PPaveFiller.hxx new file mode 100644 index 000000000..eddf3ed10 --- /dev/null +++ b/src/NMTTools/NMTTools_PPaveFiller.hxx @@ -0,0 +1,22 @@ +// File generated by CPPExt (Pointer) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#ifndef _NMTTools_PPaveFiller_HeaderFile +#define _NMTTools_PPaveFiller_HeaderFile + +class NMTTools_PaveFiller; + +typedef NMTTools_PaveFiller* NMTTools_PPaveFiller; + +#endif diff --git a/src/NMTTools/NMTTools_PaveFiller.cdl b/src/NMTTools/NMTTools_PaveFiller.cdl new file mode 100644 index 000000000..5013a1085 --- /dev/null +++ b/src/NMTTools/NMTTools_PaveFiller.cdl @@ -0,0 +1,430 @@ +-- File: NMTTools_PaveFiller.cdl +-- Created: Fri Dec 5 14:35:00 2003 +-- Author: Peter KURNEV +-- +---Copyright: Matra Datavision 2003 + + +class PaveFiller from NMTTools + + ---Purpose: + +uses + ListOfInteger from TColStd, + Pnt from gp, + ShapeEnum from TopAbs, + Vertex from TopoDS, + Face from TopoDS, + + Context from IntTools, + ShrunkRange from IntTools, + + IndexedDataMapOfShapeInteger from BooleanOperations, + + InterferencePool from BOPTools, + PInterferencePool from BOPTools, + PavePool from BOPTools, + PaveBlock from BOPTools, + ListOfPaveBlock from BOPTools, + SplitShapesPool from BOPTools, + Pave from BOPTools, + PaveSet from BOPTools, + Curve from BOPTools, + SSInterference from BOPTools, + + IDMapOfPaveBlockIMapOfPaveBlock from BOPTools, + IDMapOfPaveBlockIMapOfInteger from BOPTools, + SSIntersectionAttribute from BOPTools, + + CommonBlockPool from NMTTools, + CommonBlock from NMTTools, + ListOfCommonBlock from NMTTools, + IteratorOfCoupleOfShape from NMTTools, + + ShapesDataStructure from NMTDS, + PShapesDataStructure from NMTDS + +--raises + +is + Create + returns PaveFiller from NMTTools; + + Create(aIP:InterferencePool from BOPTools) + returns PaveFiller from NMTTools; + + Destroy (me: in out) + is virtual; + ---C++: alias "Standard_EXPORT virtual ~NMTTools_PaveFiller(){Destroy();}" + -- + -- Selectors/Modifiers + SetInterferencePool(me:out; + aIP:InterferencePool from BOPTools); + + InterfPool(me:out) + returns PInterferencePool from BOPTools; + -- + -- Perform the algo + Init (me:out) + is protected; + + Perform (me:out) + is virtual; + + PerformVV (me:out) + is virtual protected; + + PerformVE (me:out) + is virtual protected; + + PerformVF (me:out) + is virtual protected; + + PerformEE (me:out) + is virtual protected; + + PerformEF (me:out) + is virtual protected; + + PerformFF (me:out) + is virtual protected; + + MakeSplitEdges(me:out) + is protected; + + PreparePaveBlocks (me:out; + aType1: ShapeEnum from TopAbs; + aType2: ShapeEnum from TopAbs) + is virtual protected; + + CorrectShrunkRanges(me:out; + aSide: Integer from Standard; + aPave: Pave from BOPTools; + aSR : out ShrunkRange from IntTools) + is protected; + + PreparePaveBlocks (me:out; + anE:Integer from Standard) + is virtual protected; + + PerformNewVertices (me:out) + is virtual protected; + + PrepareEdges (me:out) + is virtual protected; + + SortTypes (me; + anInd1:in out Integer from Standard; + anInd2:in out Integer from Standard) + is protected; + + ExpectedPoolLength(me) + returns Integer from Standard + is protected; + -- + -- Query section + IsDone(me) + returns Boolean from Standard; + + DS(me:out) + returns PShapesDataStructure from NMTDS; + + Context(me) + returns Context from IntTools; + ---C++:return const & + + ChangeContext(me:out) + returns Context from IntTools; + ---C++:return & + + PavePool(me) + returns PavePool from BOPTools; + ---C++:return const & + + ChangePavePool(me:out) + returns PavePool from BOPTools; + ---C++:return & + + CommonBlockPool(me) + returns CommonBlockPool from NMTTools; + ---C++:return const & + + ChangeCommonBlockPool(me:out) + returns CommonBlockPool from NMTTools; + ---C++:return & + + SplitShapesPool(me) + returns SplitShapesPool from BOPTools; + ---C++:return const & + + ChangeSplitShapesPool(me:out) + returns SplitShapesPool from BOPTools; + ---C++:return & + + FindSDVertex (me; + nV: Integer from Standard) + returns Integer from Standard; + + IsSuccesstorsComputed (me; + iF1:Integer from Standard; + iF2:Integer from Standard) + returns Boolean from Standard + is protected; + + IsBlocksCoinside (me; + aPB1:PaveBlock from BOPTools; + aPB2:PaveBlock from BOPTools) + returns Boolean from Standard + is protected; + + RefinePavePool(me:out) + is protected; + + CheckFacePaves(me:out; + aV : Vertex from TopoDS; + nF: Integer from Standard) + returns Integer from Standard + is protected; + + ReplaceCommonBlocks (me:out; + aLCB: ListOfCommonBlock from NMTTools) + is protected; + + RemoveCommonBlocks (me:out; + aLCB: ListOfCommonBlock from NMTTools) + is protected; + + SplitCommonBlocks (me:out; + aLCB: ListOfCommonBlock from NMTTools) + is protected; + + SplitCommonBlock (me:out; + aCB : CommonBlock from NMTTools; + aLCB: out ListOfCommonBlock from NMTTools) + is protected; + + EECommonBlocks(me:out; + aM:IDMapOfPaveBlockIMapOfPaveBlock from BOPTools) + is protected; + + EFCommonBlocks(me:out; + aMapCB:IDMapOfPaveBlockIMapOfInteger from BOPTools) + is protected; + + EENewVertices (me:out; + aM:IndexedDataMapOfShapeInteger from BooleanOperations) + is protected; + + EENewVertices (me:out; + aV:Vertex from TopoDS; + aM:IndexedDataMapOfShapeInteger from BooleanOperations) + is protected; + + EFNewVertices (me:out; + aM:IndexedDataMapOfShapeInteger from BooleanOperations) + is protected; + + EFNewVertices (me:out; + aV:Vertex from TopoDS; + aM:IndexedDataMapOfShapeInteger from BooleanOperations) + is protected; + + UpdateCommonBlocks(me:out) + is protected; + + UpdatePaveBlocks(me:out) + is protected; + + SplitIndex(me; + aPB:PaveBlock from BOPTools) + returns Integer from Standard + is protected; + + MakeBlocks(me:out) + is protected; + + -------------------------------------------------------------- + --- + --- Some API FUNCTIONS + --- + SplitsInFace(me:out; + aBid:Integer from Standard; + nF1 :Integer from Standard; + nF2 :Integer from Standard; + aLs :out ListOfInteger from TColStd) + returns Integer from Standard; + + SplitsInFace(me:out; + nE1 :Integer from Standard; + nF2 :Integer from Standard; + aLs :out ListOfInteger from TColStd) + returns Integer from Standard; + + SplitsOnEdge(me:out; + nE1 :Integer from Standard; + nE2 :Integer from Standard; + aLs :out ListOfInteger from TColStd) + returns Integer from Standard; + + SplitsOnFace(me:out; + nE1 :Integer from Standard; + nF2 :Integer from Standard; + aLs :out ListOfInteger from TColStd) + returns Integer from Standard; + + SplitsOnFace(me:out; + aBid:Integer from Standard; + nF1 :Integer from Standard; + nF2 :Integer from Standard; + aLs :out ListOfInteger from TColStd) + returns Integer from Standard; + + SplitsInFace(me:out; + aBid:Integer from Standard; + nF1 :Integer from Standard; + nF2 :Integer from Standard; + aLs :out ListOfPaveBlock from BOPTools) + returns Integer from Standard; + + SplitsInFace(me:out; + nE1 :Integer from Standard; + nF2 :Integer from Standard; + aLs :out ListOfPaveBlock from BOPTools) + returns Integer from Standard; + + SplitsOnEdge(me:out; + nE1 :Integer from Standard; + nE2 :Integer from Standard; + aLs :out ListOfPaveBlock from BOPTools) + returns Integer from Standard; + + SplitsOnFace(me:out; + nE1 :Integer from Standard; + nF2 :Integer from Standard; + aLs :out ListOfPaveBlock from BOPTools) + returns Integer from Standard; + + SplitsOnFace(me:out; + aBid:Integer from Standard; + nF1 :Integer from Standard; + nF2 :Integer from Standard; + aLs :out ListOfPaveBlock from BOPTools) + returns Integer from Standard; + -- + SplitsFace (me:out; + nF2 :Integer from Standard; + aLs :out ListOfPaveBlock from BOPTools) + returns Integer from Standard; + + SplitsFace (me:out; + nF2 :Integer from Standard; + aLs :out ListOfInteger from TColStd) + returns Integer from Standard; + + CommonBlocksFace (me:out; + nF :Integer from Standard; + aLCB:out ListOfCommonBlock from NMTTools) + returns Integer from Standard; + + PrepareFace(me:out; + nF : Integer from Standard; + aF : out Face from TopoDS); + + -- + RealPaveBlock(me:out; + aPB:PaveBlock from BOPTools) + returns PaveBlock from BOPTools; + ---C++: return const & + -- + RealSplitsFace (me:out; + nF2 :Integer from Standard; + aLs :out ListOfPaveBlock from BOPTools); + + HasRealSplitsInOnFace (me:out; + nF1 :Integer from Standard; + nF2 :Integer from Standard) + returns Boolean from Standard; + + RealSplitsInFace(me:out; + aBid:Integer from Standard; + nF1 :Integer from Standard; + nF2 :Integer from Standard; + aLs :out ListOfPaveBlock from BOPTools); + + RealSplitsInFace(me:out; + nE1 :Integer from Standard; + nF2 :Integer from Standard; + aLs :out ListOfPaveBlock from BOPTools); + + RealSplitsOnEdge(me:out; + nE1 :Integer from Standard; + nE2 :Integer from Standard; + aLs :out ListOfPaveBlock from BOPTools); + + RealSplitsOnFace(me:out; + nE1 :Integer from Standard; + nF2 :Integer from Standard; + aLs :out ListOfPaveBlock from BOPTools); + + RealSplitsOnFace(me:out; + aBid:Integer from Standard; + nF1 :Integer from Standard; + nF2 :Integer from Standard; + aLs :out ListOfPaveBlock from BOPTools); + -- + PrepareSetForFace(me:out; + nF1 :Integer from Standard; + nF2 :Integer from Standard; + aPSF:out PaveSet from BOPTools); + + PutPaveOnCurve(me:out; + aPSF: PaveSet from BOPTools; + aTol: Real from Standard; + aBC : out Curve from BOPTools); + + PutBoundPaveOnCurve (me:out; + aBC :out Curve from BOPTools; + aFF :out SSInterference from BOPTools); + + PutBoundPaveOnCurve (me:out; + aP : Pnt from gp; + aT : Real from Standard; + aBC :out Curve from BOPTools; + aFF :out SSInterference from BOPTools); + + FindPave (me:out; + aP : Pnt from gp; + aTpV: Real from Standard; + aPS : PaveSet from BOPTools; + aPV :out Pave from BOPTools) + returns Boolean from Standard; + + CheckIntermediatePoint(me:out; + aPB : PaveBlock from BOPTools; + aPBR: PaveBlock from BOPTools; + aTol: Real from Standard) + returns Integer from Standard; + + IsExistingPaveBlock (me:out; + aPB : PaveBlock from BOPTools; + aFF : SSInterference from BOPTools) + returns Boolean from Standard; + + MakePCurves (me:out); + +fields + myIntrPool : PInterferencePool from BOPTools is protected; + myDS : PShapesDataStructure from NMTDS is protected; + myIsDone : Boolean from Standard is protected; + myNbSources : Integer from Standard is protected; + myNbEdges : Integer from Standard is protected; + myDSIt : IteratorOfCoupleOfShape from NMTTools is protected; + -- + myPavePool : PavePool from BOPTools is protected; + myPavePoolNew : PavePool from BOPTools is protected; + myCommonBlockPool : CommonBlockPool from NMTTools is protected; + mySplitShapesPool : SplitShapesPool from BOPTools is protected; + -- + myContext : Context from IntTools is protected; + mySectionAttribute : SSIntersectionAttribute from BOPTools is protected; +end PaveFiller; diff --git a/src/NMTTools/NMTTools_PaveFiller.cxx b/src/NMTTools/NMTTools_PaveFiller.cxx new file mode 100644 index 000000000..231482f38 --- /dev/null +++ b/src/NMTTools/NMTTools_PaveFiller.cxx @@ -0,0 +1,211 @@ +// File: NMTTools_PaveFiller.cxx +// Created: Fri Dec 5 14:58:54 2003 +// Author: Peter KURNEV +// +// +#include +// +#include +#include +#include +#include "utilities.h" + +//======================================================================= +// function: NMTTools_PaveFiller::NMTTools_PaveFiller +// purpose: +//======================================================================= + NMTTools_PaveFiller::NMTTools_PaveFiller() +{ + myIntrPool=NULL; + myDS=NULL; + myIsDone=Standard_False; + myNbSources=0; + myNbEdges=0; +} +//======================================================================= +// function:NMTTools_PaveFiller::NMTTools_PaveFiller +// purpose: +//======================================================================= + NMTTools_PaveFiller::NMTTools_PaveFiller(const BOPTools_InterferencePool& aIP) +{ + SetInterferencePool(aIP); +} +//======================================================================= +// function: Destroy +// purpose: +//======================================================================= + void NMTTools_PaveFiller::Destroy() +{ +} +//======================================================================= +// function: SetInterferencePool +// purpose: +//======================================================================= + void NMTTools_PaveFiller::SetInterferencePool(const BOPTools_InterferencePool& aIP) +{ + myIsDone=Standard_False; + // + myIntrPool=(BOPTools_InterferencePool*)&aIP; + myDS=(NMTDS_ShapesDataStructure*)myIntrPool->DS(); + myNbSources=myDS->NumberOfShapesOfTheObject()+myDS->NumberOfShapesOfTheTool(); + myNbEdges=myDS->NbEdges(); +} +//======================================================================= +// function: InterfPool +// purpose: +//======================================================================= + BOPTools_PInterferencePool NMTTools_PaveFiller::InterfPool() +{ + return myIntrPool; +} +//======================================================================= +// function:IsDone +// purpose: +//======================================================================= + Standard_Boolean NMTTools_PaveFiller::IsDone() const +{ + return myIsDone; +} +//======================================================================= +// function: DS +// purpose: +//======================================================================= + NMTDS_PShapesDataStructure NMTTools_PaveFiller::DS() +{ + return myDS; +} +//======================================================================= +// function: Context +// purpose: +//======================================================================= + const IntTools_Context& NMTTools_PaveFiller::Context() const +{ + return myContext; +} +//======================================================================= +// function: ChangeContext +// purpose: +//======================================================================= + IntTools_Context& NMTTools_PaveFiller::ChangeContext() +{ + return myContext; +} +//======================================================================= +// function: PavePool +// purpose: +//======================================================================= + const BOPTools_PavePool& NMTTools_PaveFiller::PavePool() const +{ + return myPavePool; +} +//======================================================================= +// function: ChangePavePool +// purpose: +//======================================================================= + BOPTools_PavePool& NMTTools_PaveFiller::ChangePavePool() +{ + return myPavePool; +} +//======================================================================= +// function: CommonBlockPool +// purpose: +//======================================================================= + const NMTTools_CommonBlockPool& NMTTools_PaveFiller::CommonBlockPool() const +{ + return myCommonBlockPool; +} +//======================================================================= +// function: ChangeCommonBlockPool +// purpose: +//======================================================================= + NMTTools_CommonBlockPool& NMTTools_PaveFiller::ChangeCommonBlockPool() +{ + return myCommonBlockPool; +} +//======================================================================= +// function: SplitShapesPool +// purpose: +//======================================================================= + const BOPTools_SplitShapesPool& NMTTools_PaveFiller::SplitShapesPool() const +{ + return mySplitShapesPool; +} + +//======================================================================= +// function: ChangeSplitShapesPool +// purpose: +//======================================================================= + BOPTools_SplitShapesPool& NMTTools_PaveFiller::ChangeSplitShapesPool() +{ + return mySplitShapesPool; +} +//======================================================================= +// function: Init +// purpose: +//======================================================================= + void NMTTools_PaveFiller::Init() +{ + myDSIt.SetDS(myDS); +} +//======================================================================= +// function: Perform +// purpose: +//======================================================================= + void NMTTools_PaveFiller::Perform() +{ + try { + // 0. + Init();//myDSIt.SetDS(myDS); + // + //1.VV + PerformVV(); + PerformNewVertices(); + // + // 2.VE + myPavePool.Resize (myNbEdges); + PrepareEdges(); + PerformVE(); + // + // 3.VF + PerformVF(); + // + // 4.EE + myCommonBlockPool.Resize (myNbEdges); + mySplitShapesPool.Resize (myNbEdges); + myPavePoolNew .Resize (myNbEdges); + + PreparePaveBlocks(TopAbs_VERTEX, TopAbs_EDGE); + PreparePaveBlocks(TopAbs_EDGE, TopAbs_EDGE); + // + PerformEE(); + // + RefinePavePool (); + // + myPavePoolNew.Destroy(); + myPavePoolNew.Resize (myNbEdges); + // + // 5.EF + PreparePaveBlocks(TopAbs_EDGE, TopAbs_FACE); + PerformEF(); + RefinePavePool(); + // + myPavePoolNew.Destroy(); + MakeSplitEdges(); + UpdateCommonBlocks(); + // + // 6. FF + PerformFF (); + MakeBlocks(); + MakePCurves(); + // + // 7.Postprocessing + UpdatePaveBlocks(); + // + NMTTools_DEProcessor aDEP(*this); + aDEP.Do(); + // + } + catch (BOPTColStd_Failure& x) { + MESSAGE(x.Message() << flush); + } +} diff --git a/src/NMTTools/NMTTools_PaveFiller.hxx b/src/NMTTools/NMTTools_PaveFiller.hxx new file mode 100644 index 000000000..5b5563563 --- /dev/null +++ b/src/NMTTools/NMTTools_PaveFiller.hxx @@ -0,0 +1,230 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _NMTTools_PaveFiller_HeaderFile +#define _NMTTools_PaveFiller_HeaderFile + +#ifndef _BOPTools_PInterferencePool_HeaderFile +#include +#endif +#ifndef _NMTDS_PShapesDataStructure_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +#ifndef _Standard_Integer_HeaderFile +#include +#endif +#ifndef _NMTTools_IteratorOfCoupleOfShape_HeaderFile +#include +#endif +#ifndef _BOPTools_PavePool_HeaderFile +#include +#endif +#ifndef _NMTTools_CommonBlockPool_HeaderFile +#include +#endif +#ifndef _BOPTools_SplitShapesPool_HeaderFile +#include +#endif +#ifndef _IntTools_Context_HeaderFile +#include +#endif +#ifndef _BOPTools_SSIntersectionAttribute_HeaderFile +#include +#endif +#ifndef _TopAbs_ShapeEnum_HeaderFile +#include +#endif +#ifndef _Standard_Real_HeaderFile +#include +#endif +class BOPTools_InterferencePool; +class BOPTools_Pave; +class IntTools_ShrunkRange; +class IntTools_Context; +class BOPTools_PavePool; +class NMTTools_CommonBlockPool; +class BOPTools_SplitShapesPool; +class BOPTools_PaveBlock; +class TopoDS_Vertex; +class NMTTools_ListOfCommonBlock; +class NMTTools_CommonBlock; +class BOPTools_IDMapOfPaveBlockIMapOfPaveBlock; +class BOPTools_IDMapOfPaveBlockIMapOfInteger; +class BooleanOperations_IndexedDataMapOfShapeInteger; +class TColStd_ListOfInteger; +class BOPTools_ListOfPaveBlock; +class TopoDS_Face; +class BOPTools_PaveSet; +class BOPTools_Curve; +class BOPTools_SSInterference; +class gp_Pnt; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class NMTTools_PaveFiller { + +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 NMTTools_PaveFiller(); +Standard_EXPORT NMTTools_PaveFiller(const BOPTools_InterferencePool& aIP); +Standard_EXPORT virtual void Destroy() ; +Standard_EXPORT virtual ~NMTTools_PaveFiller(){Destroy();} +Standard_EXPORT void SetInterferencePool(const BOPTools_InterferencePool& aIP) ; +Standard_EXPORT BOPTools_PInterferencePool InterfPool() ; +Standard_EXPORT virtual void Perform() ; +Standard_EXPORT Standard_Boolean IsDone() const; +Standard_EXPORT NMTDS_PShapesDataStructure DS() ; +Standard_EXPORT const IntTools_Context& Context() const; +Standard_EXPORT IntTools_Context& ChangeContext() ; +Standard_EXPORT const BOPTools_PavePool& PavePool() const; +Standard_EXPORT BOPTools_PavePool& ChangePavePool() ; +Standard_EXPORT const NMTTools_CommonBlockPool& CommonBlockPool() const; +Standard_EXPORT NMTTools_CommonBlockPool& ChangeCommonBlockPool() ; +Standard_EXPORT const BOPTools_SplitShapesPool& SplitShapesPool() const; +Standard_EXPORT BOPTools_SplitShapesPool& ChangeSplitShapesPool() ; +Standard_EXPORT Standard_Integer FindSDVertex(const Standard_Integer nV) const; +Standard_EXPORT Standard_Integer SplitsInFace(const Standard_Integer aBid,const Standard_Integer nF1,const Standard_Integer nF2,TColStd_ListOfInteger& aLs) ; +Standard_EXPORT Standard_Integer SplitsInFace(const Standard_Integer nE1,const Standard_Integer nF2,TColStd_ListOfInteger& aLs) ; +Standard_EXPORT Standard_Integer SplitsOnEdge(const Standard_Integer nE1,const Standard_Integer nE2,TColStd_ListOfInteger& aLs) ; +Standard_EXPORT Standard_Integer SplitsOnFace(const Standard_Integer nE1,const Standard_Integer nF2,TColStd_ListOfInteger& aLs) ; +Standard_EXPORT Standard_Integer SplitsOnFace(const Standard_Integer aBid,const Standard_Integer nF1,const Standard_Integer nF2,TColStd_ListOfInteger& aLs) ; +Standard_EXPORT Standard_Integer SplitsInFace(const Standard_Integer aBid,const Standard_Integer nF1,const Standard_Integer nF2,BOPTools_ListOfPaveBlock& aLs) ; +Standard_EXPORT Standard_Integer SplitsInFace(const Standard_Integer nE1,const Standard_Integer nF2,BOPTools_ListOfPaveBlock& aLs) ; +Standard_EXPORT Standard_Integer SplitsOnEdge(const Standard_Integer nE1,const Standard_Integer nE2,BOPTools_ListOfPaveBlock& aLs) ; +Standard_EXPORT Standard_Integer SplitsOnFace(const Standard_Integer nE1,const Standard_Integer nF2,BOPTools_ListOfPaveBlock& aLs) ; +Standard_EXPORT Standard_Integer SplitsOnFace(const Standard_Integer aBid,const Standard_Integer nF1,const Standard_Integer nF2,BOPTools_ListOfPaveBlock& aLs) ; +Standard_EXPORT Standard_Integer SplitsFace(const Standard_Integer nF2,BOPTools_ListOfPaveBlock& aLs) ; +Standard_EXPORT Standard_Integer SplitsFace(const Standard_Integer nF2,TColStd_ListOfInteger& aLs) ; +Standard_EXPORT Standard_Integer CommonBlocksFace(const Standard_Integer nF,NMTTools_ListOfCommonBlock& aLCB) ; +Standard_EXPORT void PrepareFace(const Standard_Integer nF,TopoDS_Face& aF) ; +Standard_EXPORT const BOPTools_PaveBlock& RealPaveBlock(const BOPTools_PaveBlock& aPB) ; +Standard_EXPORT void RealSplitsFace(const Standard_Integer nF2,BOPTools_ListOfPaveBlock& aLs) ; +Standard_EXPORT Standard_Boolean HasRealSplitsInOnFace(const Standard_Integer nF1,const Standard_Integer nF2) ; +Standard_EXPORT void RealSplitsInFace(const Standard_Integer aBid,const Standard_Integer nF1,const Standard_Integer nF2,BOPTools_ListOfPaveBlock& aLs) ; +Standard_EXPORT void RealSplitsInFace(const Standard_Integer nE1,const Standard_Integer nF2,BOPTools_ListOfPaveBlock& aLs) ; +Standard_EXPORT void RealSplitsOnEdge(const Standard_Integer nE1,const Standard_Integer nE2,BOPTools_ListOfPaveBlock& aLs) ; +Standard_EXPORT void RealSplitsOnFace(const Standard_Integer nE1,const Standard_Integer nF2,BOPTools_ListOfPaveBlock& aLs) ; +Standard_EXPORT void RealSplitsOnFace(const Standard_Integer aBid,const Standard_Integer nF1,const Standard_Integer nF2,BOPTools_ListOfPaveBlock& aLs) ; +Standard_EXPORT void PrepareSetForFace(const Standard_Integer nF1,const Standard_Integer nF2,BOPTools_PaveSet& aPSF) ; +Standard_EXPORT void PutPaveOnCurve(const BOPTools_PaveSet& aPSF,const Standard_Real aTol,BOPTools_Curve& aBC) ; +Standard_EXPORT void PutBoundPaveOnCurve(BOPTools_Curve& aBC,BOPTools_SSInterference& aFF) ; +Standard_EXPORT void PutBoundPaveOnCurve(const gp_Pnt& aP,const Standard_Real aT,BOPTools_Curve& aBC,BOPTools_SSInterference& aFF) ; +Standard_EXPORT Standard_Boolean FindPave(const gp_Pnt& aP,const Standard_Real aTpV,const BOPTools_PaveSet& aPS,BOPTools_Pave& aPV) ; +Standard_EXPORT Standard_Integer CheckIntermediatePoint(const BOPTools_PaveBlock& aPB,const BOPTools_PaveBlock& aPBR,const Standard_Real aTol) ; +Standard_EXPORT Standard_Boolean IsExistingPaveBlock(const BOPTools_PaveBlock& aPB,const BOPTools_SSInterference& aFF) ; +Standard_EXPORT void MakePCurves() ; + + + + + +protected: + + // Methods PROTECTED + // +Standard_EXPORT void Init() ; +Standard_EXPORT virtual void PerformVV() ; +Standard_EXPORT virtual void PerformVE() ; +Standard_EXPORT virtual void PerformVF() ; +Standard_EXPORT virtual void PerformEE() ; +Standard_EXPORT virtual void PerformEF() ; +Standard_EXPORT virtual void PerformFF() ; +Standard_EXPORT void MakeSplitEdges() ; +Standard_EXPORT virtual void PreparePaveBlocks(const TopAbs_ShapeEnum aType1,const TopAbs_ShapeEnum aType2) ; +Standard_EXPORT void CorrectShrunkRanges(const Standard_Integer aSide,const BOPTools_Pave& aPave,IntTools_ShrunkRange& aSR) ; +Standard_EXPORT virtual void PreparePaveBlocks(const Standard_Integer anE) ; +Standard_EXPORT virtual void PerformNewVertices() ; +Standard_EXPORT virtual void PrepareEdges() ; +Standard_EXPORT void SortTypes(Standard_Integer& anInd1,Standard_Integer& anInd2) const; +Standard_EXPORT Standard_Integer ExpectedPoolLength() const; +Standard_EXPORT Standard_Boolean IsSuccesstorsComputed(const Standard_Integer iF1,const Standard_Integer iF2) const; +Standard_EXPORT Standard_Boolean IsBlocksCoinside(const BOPTools_PaveBlock& aPB1,const BOPTools_PaveBlock& aPB2) const; +Standard_EXPORT void RefinePavePool() ; +Standard_EXPORT Standard_Integer CheckFacePaves(const TopoDS_Vertex& aV,const Standard_Integer nF) ; +Standard_EXPORT void ReplaceCommonBlocks(const NMTTools_ListOfCommonBlock& aLCB) ; +Standard_EXPORT void RemoveCommonBlocks(const NMTTools_ListOfCommonBlock& aLCB) ; +Standard_EXPORT void SplitCommonBlocks(const NMTTools_ListOfCommonBlock& aLCB) ; +Standard_EXPORT void SplitCommonBlock(const NMTTools_CommonBlock& aCB,NMTTools_ListOfCommonBlock& aLCB) ; +Standard_EXPORT void EECommonBlocks(const BOPTools_IDMapOfPaveBlockIMapOfPaveBlock& aM) ; +Standard_EXPORT void EFCommonBlocks(const BOPTools_IDMapOfPaveBlockIMapOfInteger& aMapCB) ; +Standard_EXPORT void EENewVertices(const BooleanOperations_IndexedDataMapOfShapeInteger& aM) ; +Standard_EXPORT void EENewVertices(const TopoDS_Vertex& aV,const BooleanOperations_IndexedDataMapOfShapeInteger& aM) ; +Standard_EXPORT void EFNewVertices(const BooleanOperations_IndexedDataMapOfShapeInteger& aM) ; +Standard_EXPORT void EFNewVertices(const TopoDS_Vertex& aV,const BooleanOperations_IndexedDataMapOfShapeInteger& aM) ; +Standard_EXPORT void UpdateCommonBlocks() ; +Standard_EXPORT void UpdatePaveBlocks() ; +Standard_EXPORT Standard_Integer SplitIndex(const BOPTools_PaveBlock& aPB) const; +Standard_EXPORT void MakeBlocks() ; + + + // Fields PROTECTED + // +BOPTools_PInterferencePool myIntrPool; +NMTDS_PShapesDataStructure myDS; +Standard_Boolean myIsDone; +Standard_Integer myNbSources; +Standard_Integer myNbEdges; +NMTTools_IteratorOfCoupleOfShape myDSIt; +BOPTools_PavePool myPavePool; +BOPTools_PavePool myPavePoolNew; +NMTTools_CommonBlockPool myCommonBlockPool; +BOPTools_SplitShapesPool mySplitShapesPool; +IntTools_Context myContext; +BOPTools_SSIntersectionAttribute mySectionAttribute; + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // + + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/NMTTools/NMTTools_PaveFiller.ixx b/src/NMTTools/NMTTools_PaveFiller.ixx new file mode 100644 index 000000000..1ef3b7ab3 --- /dev/null +++ b/src/NMTTools/NMTTools_PaveFiller.ixx @@ -0,0 +1,19 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include + + + + diff --git a/src/NMTTools/NMTTools_PaveFiller.jxx b/src/NMTTools/NMTTools_PaveFiller.jxx new file mode 100644 index 000000000..9e8e7ce2a --- /dev/null +++ b/src/NMTTools/NMTTools_PaveFiller.jxx @@ -0,0 +1,66 @@ +#ifndef _BOPTools_InterferencePool_HeaderFile +#include +#endif +#ifndef _BOPTools_Pave_HeaderFile +#include +#endif +#ifndef _IntTools_ShrunkRange_HeaderFile +#include +#endif +#ifndef _IntTools_Context_HeaderFile +#include +#endif +#ifndef _BOPTools_PavePool_HeaderFile +#include +#endif +#ifndef _NMTTools_CommonBlockPool_HeaderFile +#include +#endif +#ifndef _BOPTools_SplitShapesPool_HeaderFile +#include +#endif +#ifndef _BOPTools_PaveBlock_HeaderFile +#include +#endif +#ifndef _TopoDS_Vertex_HeaderFile +#include +#endif +#ifndef _NMTTools_ListOfCommonBlock_HeaderFile +#include +#endif +#ifndef _NMTTools_CommonBlock_HeaderFile +#include +#endif +#ifndef _BOPTools_IDMapOfPaveBlockIMapOfPaveBlock_HeaderFile +#include +#endif +#ifndef _BOPTools_IDMapOfPaveBlockIMapOfInteger_HeaderFile +#include +#endif +#ifndef _BooleanOperations_IndexedDataMapOfShapeInteger_HeaderFile +#include +#endif +#ifndef _TColStd_ListOfInteger_HeaderFile +#include +#endif +#ifndef _BOPTools_ListOfPaveBlock_HeaderFile +#include +#endif +#ifndef _TopoDS_Face_HeaderFile +#include +#endif +#ifndef _BOPTools_PaveSet_HeaderFile +#include +#endif +#ifndef _BOPTools_Curve_HeaderFile +#include +#endif +#ifndef _BOPTools_SSInterference_HeaderFile +#include +#endif +#ifndef _gp_Pnt_HeaderFile +#include +#endif +#ifndef _NMTTools_PaveFiller_HeaderFile +#include +#endif diff --git a/src/NMTTools/NMTTools_PaveFiller_0.cxx b/src/NMTTools/NMTTools_PaveFiller_0.cxx new file mode 100644 index 000000000..d6b3251a3 --- /dev/null +++ b/src/NMTTools/NMTTools_PaveFiller_0.cxx @@ -0,0 +1,118 @@ +// File: NMTTools_PaveFiller_0.cxx +// Created: Mon Dec 8 11:45:51 2003 +// Author: Peter KURNEV +// + + +#include + +#include +#include +#include +#include + +//======================================================================= +//function : SortTypes +//purpose : +//======================================================================= + void NMTTools_PaveFiller::SortTypes(Standard_Integer& theWhat, + Standard_Integer& theWith)const +{ + Standard_Boolean aReverseFlag=Standard_True; + + TopAbs_ShapeEnum aType1= myDS->GetShapeType(theWhat), + aType2= myDS->GetShapeType(theWith); + + if (aType1==aType2) + return; + + if (aType1==TopAbs_EDGE && aType2==TopAbs_FACE){ + aReverseFlag=Standard_False; + } + + if (aType1==TopAbs_VERTEX && + (aType2==TopAbs_FACE || aType2==TopAbs_EDGE)) { + aReverseFlag=Standard_False; + } + + Standard_Integer aWhat, aWith; + aWhat=(aReverseFlag) ? theWith : theWhat; + aWith=(aReverseFlag) ? theWhat : theWith; + + theWhat=aWhat; + theWith=aWith; +} +//======================================================================= +// function: ExpectedPoolLength +// purpose: +//======================================================================= + Standard_Integer NMTTools_PaveFiller::ExpectedPoolLength()const +{ + Standard_Integer aNbIIs; + Standard_Real aCfPredict=.5; + + const BOPTools_ListOfCoupleOfInteger& aLC=myDSIt.ListOfCouple(); + aNbIIs=aLC.Extent(); + // + if (aNbIIs==1) { + return aNbIIs; + } + // + aNbIIs=(Standard_Integer) (aCfPredict*(Standard_Real)aNbIIs); + + return aNbIIs; +} +//======================================================================= +// function:IsSuccesstorsComputed +// purpose: +//======================================================================= + Standard_Boolean NMTTools_PaveFiller::IsSuccesstorsComputed(const Standard_Integer aN1, + const Standard_Integer aN2)const +{ + Standard_Integer nSuc, n1, n2; + + BooleanOperations_OnceExplorer aExp(*myDS); + TopAbs_ShapeEnum aType=myDS->GetShapeType(aN1); + + n1=aN1; + n2=aN2; + + if (aType!=TopAbs_VERTEX) { + Standard_Integer ntmp=n1; + n1=n2; + n2=ntmp; + } + + aType=myDS->GetShapeType(n2); + if (aType==TopAbs_EDGE) { + aExp.Init(n2, TopAbs_VERTEX); + for (; aExp.More(); aExp.Next()) { + nSuc=aExp.Current(); + if (myIntrPool->IsComputed(n1, nSuc)) { + return Standard_True; + } + } + return Standard_False; + } + + else if (aType==TopAbs_FACE) { + aExp.Init(n2, TopAbs_VERTEX); + for (; aExp.More(); aExp.Next()) { + nSuc=aExp.Current(); + if (myIntrPool->IsComputed(n1, nSuc)) { + return Standard_True; + } + } + + aExp.Init(n2, TopAbs_EDGE); + for (; aExp.More(); aExp.Next()) { + nSuc=aExp.Current(); + if (myIntrPool->IsComputed(n1, nSuc)) { + return Standard_True; + } + } + return Standard_False; + } + + return Standard_False; +} diff --git a/src/NMTTools/NMTTools_PaveFiller_1.cxx b/src/NMTTools/NMTTools_PaveFiller_1.cxx new file mode 100644 index 000000000..5d1fa79cc --- /dev/null +++ b/src/NMTTools/NMTTools_PaveFiller_1.cxx @@ -0,0 +1,170 @@ +// File: NMTTools_PaveFiller_1.cxx +// Created: Mon Dec 8 11:47:55 2003 +// Author: Peter KURNEV +// + + +#include + +#include + +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + + + +//======================================================================= +// function: PerformVV +// purpose: +//======================================================================= + void NMTTools_PaveFiller::PerformVV() +{ + myIsDone=Standard_False; + // + Standard_Integer n1, n2,anIndexIn, aFlag, aWhat, aWith, aNbVVs, aBlockLength; + Standard_Boolean bJustAddInterference; + // + BOPTools_CArray1OfVVInterference& aVVs=myIntrPool->VVInterferences(); + // + // BlockLength correction + aNbVVs=ExpectedPoolLength(); + aBlockLength=aVVs.BlockLength(); + if (aNbVVs > aBlockLength) { + aVVs.SetBlockLength(aNbVVs); + } + // + // V/V BooleanOperations_VertexVertex + myDSIt.Initialize(TopAbs_VERTEX, TopAbs_VERTEX); + // + for (; myDSIt.More(); myDSIt.Next()) { + myDSIt.Current(n1, n2, bJustAddInterference); + // + if (!myIntrPool->IsComputed(n1, n2)) { + anIndexIn=0; + aWhat=n1; + aWith=n2; + SortTypes(aWhat, aWith); + if (!bJustAddInterference) { + const TopoDS_Shape& aS1=myDS->GetShape(aWhat); + const TopoDS_Shape& aS2=myDS->GetShape(aWith); + // + const TopoDS_Vertex& aV1=TopoDS::Vertex(aS1); + const TopoDS_Vertex& aV2=TopoDS::Vertex(aS2); + aFlag=IntTools_Tools::ComputeVV (aV1, aV2); + // + if (!aFlag) { + BOPTools_VVInterference anInterf (aWhat, aWith); + anIndexIn=aVVs.Append(anInterf); + } + } + myIntrPool->AddInterference(aWhat, aWith, BooleanOperations_VertexVertex, anIndexIn); + } + } + myIsDone=Standard_True; +} +//======================================================================= +// function: PerformNewVertices +// purpose: +//======================================================================= + void NMTTools_PaveFiller::PerformNewVertices() +{ + myIsDone=Standard_False; + // + Standard_Integer i, aNb, anIndex1, anIndex2, aNewShape; + TopoDS_Vertex aNewVertex; + BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq; + // + Standard_Integer aNbChains, j, aNbV, aIdV, aNbL; + TColStd_IndexedMapOfInteger aMapWhole; + BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger aMapChains;//aMCV + TopTools_ListOfShape aLV; + TopTools_IndexedMapOfShape aM; + // + // 1. VV Interferences + BOPTools_CArray1OfVVInterference& VVs=myIntrPool->VVInterferences(); + // + NMTTools_Tools::FindChains(VVs, aMapChains); + // + aNbChains=aMapChains.Extent(); + for (i=1; i<=aNbChains; ++i) { + const TColStd_IndexedMapOfInteger& aChain=aMapChains(i); + // + aM.Clear(); + aLV.Clear(); + aNbV=aChain.Extent(); + for (j=1; j<=aNbV; ++j) { + aIdV=aChain(j); + const TopoDS_Shape& aV=myDS->Shape(aIdV); + if (!aM.Contains(aV)) { + aM.Add(aV); + aLV.Append(aV); + } + } + // + aNbL=aLV.Extent(); + if (aNbL==1){ + aNewShape=aChain(1); + } + else if (aNbL>1) { + // + // Make new Vertex + NMTTools_Tools::MakeNewVertex(aLV, aNewVertex); + // Insert New Vertex in DS; + // aNewShape is # of DS-line, where aNewVertex is kept + myDS->InsertShapeAndAncestorsSuccessors(aNewVertex, anASSeq); + aNewShape=myDS->NumberOfInsertedShapes(); + // + // State of New Vertex is ON + myDS->SetState (aNewShape, BooleanOperations_ON); + } + // + // Insert New Vertex in Interference + aNb=VVs.Extent(); + for (j=1; j<=aNb; ++j) { + BOPTools_VVInterference& VV=VVs(j); + anIndex1=VV.Index1(); + anIndex2=VV.Index2(); + if (aChain.Contains(anIndex1) || aChain.Contains(anIndex2)) { + VV.SetNewShape(aNewShape); + } + } + } + myIsDone=Standard_True; +} + +//======================================================================= +// function: FindSDVertex +// purpose: +//======================================================================= + Standard_Integer NMTTools_PaveFiller::FindSDVertex(const Standard_Integer nV)const +{ + Standard_Integer i, aNb, anIndex1, anIndex2, aNewShape=0; + + BOPTools_CArray1OfVVInterference& VVs=myIntrPool->VVInterferences(); + aNb=VVs.Extent(); + + for (i=1; i<=aNb; i++) { + const BOPTools_VVInterference& VV=VVs(i); + anIndex1=VV.Index1(); + anIndex2=VV.Index2(); + if (nV==anIndex1 || nV==anIndex2) { + aNewShape=VV.NewShape(); + return aNewShape; + } + } + return aNewShape; +} diff --git a/src/NMTTools/NMTTools_PaveFiller_2.cxx b/src/NMTTools/NMTTools_PaveFiller_2.cxx new file mode 100644 index 000000000..041519246 --- /dev/null +++ b/src/NMTTools/NMTTools_PaveFiller_2.cxx @@ -0,0 +1,211 @@ +// File: NMTTools_PaveFiller_2.cxx +// Created: Mon Dec 8 12:02:56 2003 +// Author: Peter KURNEV +// + + +#include + +#include + +#include + +#include + +#include + +#include +#include +#include + +#include +#include + +#include +#include +#include +#include + +#include + +#include +// +#include +#include + +//======================================================================= +// function: PrepareEdges +// purpose: +//======================================================================= + void NMTTools_PaveFiller::PrepareEdges() +{ + Standard_Integer i, nV, ii, aNBSuc, ip, aNbShapesObject; + Standard_Real aT; + TopAbs_Orientation anOr; + TopoDS_Edge aE; + TopoDS_Vertex aV; + // + aNbShapesObject=myDS->NumberOfShapesOfTheObject(); + for (i=1; i<=myNbSources; ++i) { + if (myDS->GetShapeType(i)==TopAbs_EDGE) { + aE=TopoDS::Edge(myDS->Shape(i)); + // + if (BRep_Tool::Degenerated(aE)){ + continue; + } + // + BOPTools_PaveSet& aPaveSet=myPavePool(myDS->RefEdge(i)); + // + // A <- + aNBSuc=myDS->NumberOfSuccessors(i); + for (ii=1; ii <=aNBSuc; ii++) { + nV=myDS->GetSuccessor(i, ii); + anOr=myDS->GetOrientation(i, ii); + aV=TopoDS::Vertex(myDS->Shape(nV)); + aV.Orientation(anOr); + aT=BRep_Tool::Parameter(aV, aE); + // + ip=FindSDVertex(nV); + if (ip) { + aV=TopoDS::Vertex(myDS->Shape(ip)); + aV.Orientation(anOr);// XX ? if the edge is closed it'll be amazing result + nV=ip; + } + // + BOPTools_Pave aPave(nV, aT); + aPaveSet.Append (aPave); + } + } + } +} +//======================================================================= +// function: PerformVE +// purpose: +//======================================================================= + void NMTTools_PaveFiller::PerformVE() +{ + myIsDone=Standard_False; + // + Standard_Boolean bJustAddInterference; + Standard_Integer n1, n2, anIndexIn, aFlag, aWhat, aWith, aNbVEs, aBlockLength, iSDV, nV1; + Standard_Real aT; + TopoDS_Vertex aV1; + TopoDS_Edge aE2; + BOPTools_IndexedMapOfCoupleOfInteger aSnareMap; + BOPTools_CoupleOfInteger aCouple; + // + BOPTools_CArray1OfVEInterference& aVEs=myIntrPool->VEInterferences(); + // + myDSIt.Initialize (TopAbs_VERTEX, TopAbs_EDGE); + // + // BlockLength correction + aNbVEs=ExpectedPoolLength(); + aBlockLength=aVEs.BlockLength(); + if (aNbVEs > aBlockLength) { + aVEs.SetBlockLength(aNbVEs); + } + // + for (; myDSIt.More(); myDSIt.Next()) { + myDSIt.Current(n1, n2, bJustAddInterference); + // + if (! myIntrPool->IsComputed(n1, n2)) { + if (! IsSuccesstorsComputed(n1, n2)) { + anIndexIn=0; + aWhat=n1; // Vertex + aWith=n2; // Edge + SortTypes(aWhat, aWith); + // + if(bJustAddInterference) { + myIntrPool->AddInterference(aWhat, aWith, BooleanOperations_VertexEdge, anIndexIn); + continue; + } + // Edge + aE2=TopoDS::Edge(myDS->Shape(aWith)); + // + if (BRep_Tool::Degenerated(aE2)){ + continue; + } + // Vertex + nV1=aWhat; + aV1=TopoDS::Vertex(myDS->Shape(aWhat)); + // + iSDV=FindSDVertex(aWhat); + if (iSDV) { + nV1=iSDV; + aV1=TopoDS::Vertex(myDS->Shape(nV1)); + } + // + aFlag=myContext.ComputeVE (aV1, aE2, aT); + // + if (!aFlag) { + // + // Add Interference to the Pool + BOPTools_VEInterference anInterf (aWhat, aWith, aT); + anIndexIn=aVEs.Append(anInterf); + // + // Add Pave to the Edge's myPavePool + aCouple.SetCouple(nV1, aWith); + if (!aSnareMap.Contains(aCouple)){ + aSnareMap.Add(aCouple); + // + BOPTools_Pave aPave(nV1, aT, BooleanOperations_VertexEdge); + aPave.SetInterference(anIndexIn); + BOPTools_PaveSet& aPaveSet= myPavePool(myDS->RefEdge(aWith)); + aPaveSet.Append(aPave); + } + // + // State for the Vertex in DS; + myDS->SetState (aWhat, BooleanOperations_ON); + // Insert Vertex in Interference Object + BOPTools_VEInterference& aVE=aVEs(anIndexIn); + aVE.SetNewShape(aWhat); + } + myIntrPool->AddInterference(aWhat, aWith, BooleanOperations_VertexEdge, anIndexIn); + } + } + } + myIsDone=Standard_True; +} + +/* +// A +// + // cto900/M2 + // Some of Edges can be [Semi] Infinite. Such Edges have no + // vertices on correspondant INF ends. So we must provide + // these vertices formally (to obtain Shrunk Ranges for e.g). + // In reality this vertex(-es) does not belong to the INF Edge. + // It just has reference in the DS. + // PKV Tue Apr 23 10:21:45 2002 + { + Standard_Real aT1, aT2, aTolE; + Standard_Boolean bInf1, bInf2; + gp_Pnt aPx; + TopoDS_Vertex aVx; + BRep_Builder aBB; + BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq; + // + aTolE=BRep_Tool::Tolerance(aE); + Handle(Geom_Curve) aC3D=BRep_Tool::Curve (aE, aT1, aT2); + bInf1=Precision::IsNegativeInfinite(aT1); + bInf2=Precision::IsPositiveInfinite(aT2); + + if (bInf1) { + aC3D->D0(aT1, aPx); + aBB.MakeVertex(aVx, aPx, aTolE); + myDS->InsertShapeAndAncestorsSuccessors(aVx, anASSeq); + nV=myDS->NumberOfInsertedShapes(); + BOPTools_Pave aPave(nV, aT1); + aPaveSet.Append (aPave); + } + + if (bInf2) { + aC3D->D0(aT2, aPx); + aBB.MakeVertex(aVx, aPx, aTolE); + myDS->InsertShapeAndAncestorsSuccessors(aVx, anASSeq); + nV=myDS->NumberOfInsertedShapes(); + BOPTools_Pave aPave(nV, aT2); + aPaveSet.Append (aPave); + } + } +*/ diff --git a/src/NMTTools/NMTTools_PaveFiller_3.cxx b/src/NMTTools/NMTTools_PaveFiller_3.cxx new file mode 100644 index 000000000..149eed7fc --- /dev/null +++ b/src/NMTTools/NMTTools_PaveFiller_3.cxx @@ -0,0 +1,88 @@ +// File: NMTTools_PaveFiller_3.cxx +// Created: Mon Dec 8 16:06:56 2003 +// Author: Peter KURNEV +// + + +#include + +#include +#include +#include +#include + +#include +#include + +#include + +//======================================================================= +// function: PerformVF +// purpose: +//======================================================================= + void NMTTools_PaveFiller::PerformVF() +{ + myIsDone=Standard_False; + // + Standard_Boolean aJustAddInterference; + Standard_Integer n1, n2, anIndexIn, aFlag, aWhat, aWith, aNbVSs, aBlockLength, iSDV; + Standard_Real aU, aV; + TopoDS_Vertex aV1; + TopoDS_Face aF2; + // + BOPTools_CArray1OfVSInterference& aVSs=myIntrPool->VSInterferences(); + // + // V/E Interferences + myDSIt.Initialize(TopAbs_VERTEX, TopAbs_FACE); + // + // BlockLength correction + aNbVSs=ExpectedPoolLength(); + aBlockLength=aVSs.BlockLength(); + if (aNbVSs > aBlockLength) { + aVSs.SetBlockLength(aNbVSs); + } + // + for (; myDSIt.More(); myDSIt.Next()) { + myDSIt.Current(n1, n2, aJustAddInterference); + // + if (! myIntrPool->IsComputed(n1, n2)) { + if (! IsSuccesstorsComputed(n1, n2)) { + anIndexIn=0; + aWhat=n1; // Vertex + aWith=n2; // Face + SortTypes(aWhat, aWith); + // + iSDV=FindSDVertex(aWhat); + // + if(aJustAddInterference) { + myIntrPool->AddInterference(aWhat, aWith, BooleanOperations_VertexSurface, anIndexIn); + continue; + } + // + aV1=TopoDS::Vertex(myDS->Shape(aWhat)); + if (iSDV) { + aV1=TopoDS::Vertex(myDS->Shape(iSDV)); + } + // + aF2=TopoDS::Face(myDS->Shape(aWith)); + // + aFlag=myContext.ComputeVS (aV1, aF2, aU, aV); + // + if (!aFlag) { + // + // Add Interference to the Pool + BOPTools_VSInterference anInterf (aWhat, aWith, aU, aV); + anIndexIn=aVSs.Append(anInterf); + // + // SetState for Vertex in DS; + myDS->SetState (aWhat, BooleanOperations_ON); + // Insert Vertex in Interference Object + BOPTools_VSInterference& aVS=aVSs(anIndexIn); + aVS.SetNewShape(aWhat); + } + myIntrPool->AddInterference(aWhat, aWith, BooleanOperations_VertexSurface, anIndexIn); + } + } + } + myIsDone=Standard_True; +} diff --git a/src/NMTTools/NMTTools_PaveFiller_4.cxx b/src/NMTTools/NMTTools_PaveFiller_4.cxx new file mode 100644 index 000000000..65baf7b9c --- /dev/null +++ b/src/NMTTools/NMTTools_PaveFiller_4.cxx @@ -0,0 +1,1079 @@ +// File: NMTTools_PaveFiller_4.cxx +// Created: Mon Dec 8 17:08:58 2003 +// 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 + +// +static + void VertexParameters(const IntTools_CommonPrt& aCPart, + Standard_Real& aT1, + Standard_Real& aT2); +static + Standard_Boolean IsOnPave(const Standard_Real& aT1, + const IntTools_Range& aRange, + const Standard_Real& aTolerance); +static + void EECommonBlocks(const BOPTools_IDMapOfPaveBlockIMapOfPaveBlock& aMapCB); + +static + void ProcessBlock(const BOPTools_PaveBlock& aPB, + const BOPTools_IDMapOfPaveBlockIMapOfPaveBlock& aMapCB, + BOPTools_IMapOfPaveBlock& aProcessedBlocks, + BOPTools_IMapOfPaveBlock& aChain); +static + void FindChains(const BOPTools_IDMapOfPaveBlockIMapOfPaveBlock& aMapCB, + NMTTools_ListOfCommonBlock& aLCB); + +//======================================================================= +// function: PerformEE +// purpose: +//======================================================================= + void NMTTools_PaveFiller::PerformEE() +{ + myIsDone=Standard_False; + // + Standard_Boolean bJustAdd; + Standard_Integer n1, n2, anIndexIn, nE1, nE2, aNbVEs, aBlockLength; + Standard_Integer aTmp, aWhat, aWith, i, aNbCPrts, aDiscretize=30; + Standard_Real aTolE1, aTolE2, aDeflection=0.01; + BOPTools_ListIteratorOfListOfPaveBlock anIt1, anIt2; + TopoDS_Edge aEWhat, aEWith; + TopoDS_Vertex aNewVertex; + BooleanOperations_IndexedDataMapOfShapeInteger aMapVI; + BOPTools_IDMapOfPaveBlockIMapOfPaveBlock aMapCB; + // + BOPTools_CArray1OfEEInterference& aEEs=myIntrPool->EEInterferences(); + // + // BlockLength correction + aNbVEs=ExpectedPoolLength(); + aBlockLength=aEEs.BlockLength(); + if (aNbVEs > aBlockLength) { + aEEs.SetBlockLength(aNbVEs); + } + // + myDSIt.Initialize(TopAbs_EDGE, TopAbs_EDGE); + // + for (; myDSIt.More(); myDSIt.Next()) { + myDSIt.Current(n1, n2, bJustAdd); + anIndexIn = 0; + // + if (myIntrPool->IsComputed(n1, n2)) { + continue; + } + // + nE1=n1; + nE2=n2; + SortTypes(nE1, nE2); + // + if(bJustAdd) { + myIntrPool->AddInterference (nE1, nE2, BooleanOperations_EdgeEdge, anIndexIn); + continue; + } + // + const TopoDS_Edge& aE1=TopoDS::Edge(myDS->Shape(nE1)); + const TopoDS_Edge& aE2=TopoDS::Edge(myDS->Shape(nE2)); + // + if (BRep_Tool::Degenerated(aE1) || BRep_Tool::Degenerated(aE2)){ + continue; + } + // + aTolE1=BRep_Tool::Tolerance(aE1); + aTolE2=BRep_Tool::Tolerance(aE2); + // + BOPTools_ListOfPaveBlock& aLPB1=mySplitShapesPool(myDS->RefEdge(nE1)); + // + for (anIt1.Initialize(aLPB1); anIt1.More(); anIt1.Next()) { + BOPTools_PaveBlock& aPB1=anIt1.Value(); + const IntTools_ShrunkRange& aShrunkRange1=aPB1.ShrunkRange(); + // + const IntTools_Range& aSR1=aShrunkRange1.ShrunkRange(); + const Bnd_Box& aBB1=aShrunkRange1.BndBox(); + // + BOPTools_ListOfPaveBlock& aLPB2=mySplitShapesPool(myDS->RefEdge(nE2)); + // + for (anIt2.Initialize(aLPB2); anIt2.More(); anIt2.Next()) { + BOPTools_PaveBlock& aPB2=anIt2.Value(); + const IntTools_ShrunkRange& aShrunkRange2=aPB2.ShrunkRange(); + + const IntTools_Range& aSR2=aShrunkRange2.ShrunkRange(); + const Bnd_Box& aBB2=aShrunkRange2.BndBox(); + // + if (aBB1.IsOut (aBB2)) { + continue; + } + // + // EE + IntTools_EdgeEdge aEE; + aEE.SetEdge1 (aE1); + aEE.SetEdge2 (aE2); + aEE.SetTolerance1 (aTolE1); + aEE.SetTolerance2 (aTolE2); + aEE.SetDiscretize (aDiscretize); + aEE.SetDeflection (aDeflection); + // + IntTools_Range anewSR1 = aSR1; + IntTools_Range anewSR2 = aSR2; + // + BOPTools_Tools::CorrectRange (aE1, aE2, aSR1, anewSR1); + BOPTools_Tools::CorrectRange (aE2, aE1, aSR2, anewSR2); + // + aEE.SetRange1(anewSR1); + aEE.SetRange2(anewSR2); + + aEE.Perform(); + // + anIndexIn=0; + // + if (aEE.IsDone()) { + // reverse order if it is necessary + aEWhat=aE1; + aEWith=aE2; + aWhat=nE1; + aWith=nE2; + if (aEE.Order()) { + aTmp=aWhat; + aWhat=aWith; + aWith=aTmp; + aEWhat=aE2; + aEWith=aE1; + } + // + const IntTools_SequenceOfCommonPrts& aCPrts=aEE.CommonParts(); + aNbCPrts=aCPrts.Length(); + for (i=1; i<=aNbCPrts; i++) { + const IntTools_CommonPrt& aCPart=aCPrts(i); + const IntTools_SequenceOfRanges& aRanges2=aCPart.Ranges2(); + // + anIndexIn=0; + // + TopAbs_ShapeEnum aType=aCPart.Type(); + switch (aType) { + case TopAbs_VERTEX: { + Standard_Real aT1, aT2, aTol=Precision::PConfusion(); + Standard_Boolean bIsOnPave1, bIsOnPave2; + IntTools_Range aR1, aR2; + // + VertexParameters(aCPart, aT1, aT2); + // + //decide to keep the pave or not + aR1 = (aEE.Order()) ? anewSR2 : anewSR1; + aR2 = (aEE.Order()) ? anewSR1 : anewSR2; + // + bIsOnPave1=IsOnPave(aT1, aR1, aTol); + bIsOnPave2=IsOnPave(aT2, aR2, aTol); + // + if(bIsOnPave1 || bIsOnPave2) { + myIntrPool->AddInterference (aWhat, aWith, BooleanOperations_EdgeEdge, anIndexIn); + continue; + } + // + BOPTools_Tools::MakeNewVertex(aEWhat, aT1, aEWith, aT2, aNewVertex); + // + // Add Interference to the Pool + BOPTools_EEInterference anInterf (aWhat, aWith, aCPart); + // + anIndexIn=aEEs.Append(anInterf); + myIntrPool->AddInterference (aWhat, aWith, BooleanOperations_EdgeEdge, anIndexIn); + // + // Collect + aMapVI.Add(aNewVertex, anIndexIn); + } + break; + + case TopAbs_EDGE: { + Standard_Integer aNbComPrt2; + Standard_Boolean aCoinsideFlag; + // + aNbComPrt2=aRanges2.Length(); + aCoinsideFlag=IsBlocksCoinside(aPB1, aPB2); + // + if (aNbComPrt2>1 || !aCoinsideFlag) { + myIntrPool->AddInterference (aWhat, aWith, BooleanOperations_EdgeEdge, anIndexIn); + break; + } + // + // Fill aMapCB + if (aMapCB.Contains(aPB1)) { + BOPTools_IMapOfPaveBlock& aMapPB=aMapCB.ChangeFromKey(aPB1); + aMapPB.Add(aPB1); + aMapPB.Add(aPB2); + } + else { + BOPTools_IMapOfPaveBlock aMapPB; + aMapPB.Add(aPB1); + aMapPB.Add(aPB2); + aMapCB.Add(aPB1, aMapPB); + } + // + if (aMapCB.Contains(aPB2)) { + BOPTools_IMapOfPaveBlock& aMapPB=aMapCB.ChangeFromKey(aPB2); + aMapPB.Add(aPB1); + aMapPB.Add(aPB2); + } + else { + BOPTools_IMapOfPaveBlock aMapPB; + aMapPB.Add(aPB1); + aMapPB.Add(aPB2); + aMapCB.Add(aPB2, aMapPB); + } + } + break; + default: + break; + } // switch (aType) + } // for (i=1; i<=aNbCPrts; i++) + }// if (aEE.IsDone()) + } // for (; anIt2.More(); anIt2.Next()) + } // for (; anIt1.More(); anIt1.Next()) + }// for (; myDSIt.More(); myDSIt.Next()) + // + EENewVertices (aMapVI); + EECommonBlocks(aMapCB); + // + myIsDone=Standard_True; +} +//======================================================================= +// function:EECommonBlocks +// purpose: +//======================================================================= + void NMTTools_PaveFiller::EECommonBlocks(const BOPTools_IDMapOfPaveBlockIMapOfPaveBlock& aMapCB) +{ + NMTTools_ListOfCommonBlock aLCB; + // + FindChains(aMapCB, aLCB); + ReplaceCommonBlocks(aLCB); +} +//======================================================================= +// function:EENewVertices +// purpose: +//======================================================================= + void NMTTools_PaveFiller::EENewVertices (const BooleanOperations_IndexedDataMapOfShapeInteger& aMapVI) +{ + Standard_Integer aNb, i, j, aNewShape, aNbEdges, aNbIEE, aNbVV, aNbSimple; + Standard_Integer aWhat, aWith, i1, i2, nE1, nE2, nE, nV, aFlag; + Standard_Real aT; + TopoDS_Compound aCompound; + BRep_Builder aBB; + NMTTools_IndexedDataMapOfIndexedMapOfInteger aMNVE, aMNVIEE; + BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq; + BOPTools_Pave aPave; + TopoDS_Vertex aNewVertex; + TopTools_IndexedMapOfShape aMNVComplex, aMNVSimple; + // + BOPTools_CArray1OfEEInterference& aEEs=myIntrPool->EEInterferences(); + // + aNb=aMapVI.Extent(); + // + if (!aNb) { // no new vertices, no new problems + return; + } + // + // 0. + if (aNb==1) { + aNewVertex=TopoDS::Vertex(aMapVI.FindKey(1)); + EENewVertices(aNewVertex, aMapVI); + return; + } + // + // 1. Make compound from new vertices + aBB.MakeCompound(aCompound); + for (i=1; i<=aNb; ++i) { + const TopoDS_Shape& aV=aMapVI.FindKey(i); + aBB.Add(aCompound, aV); + } + // + // 2. VV intersection between these vertices + // using the auxiliary Filler + NMTDS_ShapesDataStructure tDS; + // + tDS.SetCompositeShape(aCompound); + tDS.Init(); + // + BOPTools_InterferencePool tInterfPool(tDS); + NMTTools_PaveFiller tPaveFiller(tInterfPool); + // + tPaveFiller.Init(); + // + tPaveFiller.PerformVV(); + tPaveFiller.PerformNewVertices(); + // + const BOPTools_CArray1OfVVInterference& aVVInterfs=tInterfPool.VVInterfs(); + // + // 3. Separate Comlex and Simple new vertices + aNbVV=aVVInterfs.Extent(); + for (i=1; i<=aNbVV; ++i) { + const BOPTools_VVInterference& aVV=aVVInterfs(i); + aVV.Indices(aWhat, aWith); + const TopoDS_Shape& aV1=tDS.Shape(aWhat); + const TopoDS_Shape& aV2=tDS.Shape(aWith); + aMNVComplex.Add(aV1); + aMNVComplex.Add(aV2); + } + // + for (i=1; i<=aNb; ++i) { + const TopoDS_Shape& aV=aMapVI.FindKey(i); + if (!aMNVComplex.Contains(aV)) { + aMNVSimple.Add(aV); + } + } + // + // 4. Treat Simple new Vertices + aNbSimple=aMNVSimple.Extent(); + for (i=1; i<=aNbSimple; ++i) { + const TopoDS_Vertex& aV=TopoDS::Vertex(aMNVSimple(i)); + EENewVertices(aV, aMapVI); + } + // + // 3. Fill Maps : NewVertex-edges (aMNVE) + // NewVertex-interferences (aMNVIEE) + for (i=1; i<=aNbVV; ++i) { + const BOPTools_VVInterference& aVV=aVVInterfs(i); + aNewShape=aVV.NewShape(); + if (!aNewShape) { + continue; + } + // + if (!aMNVE.Contains(aNewShape)) { + TColStd_IndexedMapOfInteger aMx; + aMNVE.Add(aNewShape, aMx); + } + if (!aMNVIEE.Contains(aNewShape)) { + TColStd_IndexedMapOfInteger aMx; + aMNVIEE.Add(aNewShape, aMx); + } + // + TColStd_IndexedMapOfInteger& aME=aMNVE.ChangeFromKey(aNewShape); + TColStd_IndexedMapOfInteger& aMIEE=aMNVIEE.ChangeFromKey(aNewShape); + // + aVV.Indices(aWhat, aWith); + //aWhat + const TopoDS_Shape& aV1=tDS.Shape(aWhat); + i1=aMapVI.FindFromKey(aV1); + const BOPTools_EEInterference& aEE1=aEEs(i1); + aEE1.Indices(nE1, nE2); + aME.Add(nE1); + aME.Add(nE2); + aMIEE.Add(i1); + //aWith + const TopoDS_Shape& aV2=tDS.Shape(aWith); + i2=aMapVI.FindFromKey(aV2); + const BOPTools_EEInterference& aEE2=aEEs(i2); + aEE2.Indices(nE1, nE2); + aME.Add(nE1); + aME.Add(nE2); + aMIEE.Add(i2); + // + //printf(" VV: (%d, %d) -> %d\n", aWhat, aWith, aNewShape); + } + // + // 4. Process new vertices + aNb=aMNVE.Extent(); + for (i=1; i<=aNb; ++i) { // xx + // + // new Vertex + nV=aMNVE.FindKey(i); + aNewVertex=TopoDS::Vertex(tDS.Shape(nV)); + // + // Insert New Vertex in DS; + myDS->InsertShapeAndAncestorsSuccessors(aNewVertex, anASSeq); + aNewShape=myDS->NumberOfInsertedShapes(); + myDS->SetState (aNewShape, BooleanOperations_ON); + // + // Update index of NewShape in EE interferences + const TColStd_IndexedMapOfInteger& aMIEE=aMNVIEE.FindFromKey(nV);//(i); + aNbIEE=aMIEE.Extent(); + for (j=1; j<=aNbIEE; ++j) { + i1=aMIEE(j); + BOPTools_EEInterference& aEE1=aEEs(i1); + aEE1.SetNewShape(aNewShape); + } + // + // Update Paves on edges + const TColStd_IndexedMapOfInteger& aME=aMNVE(i); + aNbEdges=aME.Extent(); + for (j=1; j<=aNbEdges; ++j) { + nE=aME(j); + const TopoDS_Edge& aE=TopoDS::Edge(myDS->Shape(nE)); + // + aFlag=myContext.ComputeVE (aNewVertex, aE, aT); + // + if (!aFlag) { + aPave.SetInterference(-1); + aPave.SetType (BooleanOperations_EdgeEdge); + aPave.SetIndex(aNewShape); + aPave.SetParam(aT); + // + BOPTools_PaveSet& aPaveSet=myPavePoolNew(myDS->RefEdge(nE)); + aPaveSet.Append(aPave); + } + } + }// for (i=1; i<=aNb; ++i) {// xx +} +//======================================================================= +// function:EENewVertices +// purpose: +//======================================================================= + void NMTTools_PaveFiller::EENewVertices (const TopoDS_Vertex& aNewVertex, + const BooleanOperations_IndexedDataMapOfShapeInteger& aMapVI) +{ + Standard_Integer i, aNewShape, nE1, nE2; + Standard_Real aT1, aT2; + BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq; + BOPTools_Pave aPave; + // + BOPTools_CArray1OfEEInterference& aEEs=myIntrPool->EEInterferences(); + // + // one new vertex case is treated in usual way + // + // Insert New Vertex in DS; + myDS->InsertShapeAndAncestorsSuccessors(aNewVertex, anASSeq); + aNewShape=myDS->NumberOfInsertedShapes(); + myDS->SetState (aNewShape, BooleanOperations_ON); + // Insert New Vertex in EE Interference + i=aMapVI.FindFromKey(aNewVertex); + BOPTools_EEInterference& aEEInterf= aEEs(i); + aEEInterf.SetNewShape(aNewShape); + // Extact interference info + aEEInterf.Indices(nE1, nE2); + const IntTools_CommonPrt& aCPart=aEEInterf.CommonPrt(); + VertexParameters(aCPart, aT1, aT2); + // + // Add Paves to the myPavePoolNew + aPave.SetInterference(i); + aPave.SetType (BooleanOperations_EdgeEdge); + aPave.SetIndex(aNewShape); + // Pave for edge nE1 + aPave.SetParam(aT1); + BOPTools_PaveSet& aPaveSet1=myPavePoolNew(myDS->RefEdge(nE1)); + aPaveSet1.Append(aPave); + // Pave for edge nE2 + aPave.SetParam(aT2); + BOPTools_PaveSet& aPaveSet2=myPavePoolNew(myDS->RefEdge(nE2)); + aPaveSet2.Append(aPave); +} +//======================================================================= +// function: RefinePavePool +// purpose: +//======================================================================= + void NMTTools_PaveFiller::RefinePavePool() +{ + Standard_Integer i, aNbNew; + + for (i=1; i<=myNbSources; i++) { + + if ((myDS->GetShape(i)).ShapeType()==TopAbs_EDGE) { + BOPTools_PaveSet& aPS= myPavePool(myDS->RefEdge(i)); + // + BOPTools_PaveSet& aNewPS= myPavePoolNew(myDS->RefEdge(i)); + BOPTools_ListOfPave& aNewLP=aNewPS.ChangeSet(); + // + aNbNew=aNewLP.Extent(); + if (aNbNew) { + BOPTools_ListIteratorOfListOfPave anIt(aNewLP); + for (; anIt.More(); anIt.Next()) { + const BOPTools_Pave& aPave=anIt.Value(); + aPS.Append(aPave); + } + // Clear the ListOfPaveBlock + BOPTools_ListOfPaveBlock& aLPB=mySplitShapesPool(myDS->RefEdge(i)); + aLPB.Clear(); + // Prepare the paveBlocks for that egde again + PreparePaveBlocks(i); + } + aNewLP.Clear(); + } + } +} +//======================================================================= +// function: PreparePaveBlocks +// purpose: +//======================================================================= + void NMTTools_PaveFiller::PreparePaveBlocks(const TopAbs_ShapeEnum aType1, + const TopAbs_ShapeEnum aType2) +{ + myIsDone=Standard_False; + // + Standard_Boolean Ok1, Ok2, Ok3; + Ok1= (aType1==TopAbs_VERTEX) && (aType2==TopAbs_EDGE) ; + Ok2= (aType1==TopAbs_EDGE) && (aType2==TopAbs_EDGE) ; + Ok3= (aType1==TopAbs_EDGE) && (aType2==TopAbs_FACE) ; + if (!Ok1 && !Ok2 && !Ok3) { + // error: Type mismatch + return; + } + // + Standard_Boolean aFlag = Standard_False; + Standard_Integer n1, n2, nE1, nE2, aNbSplits; + TColStd_MapOfInteger aMap; + // + myDSIt.Initialize(aType1, aType2); + // + for (; myDSIt.More(); myDSIt.Next()) { + myDSIt.Current(n1, n2, aFlag); + nE1=n1; + nE2=n2; + SortTypes(nE1, nE2); + // + if (aType1==TopAbs_EDGE) { + BOPTools_ListOfPaveBlock& aLPB1=mySplitShapesPool(myDS->RefEdge(nE1)); + aNbSplits=aLPB1.Extent(); + if (!aNbSplits) { + if (!aMap.Contains(nE1)) { + aMap.Add(nE1); + PreparePaveBlocks(nE1); + // + if (!myIsDone) { + return; + } + } + } + } + // + if (aType2==TopAbs_EDGE) { + BOPTools_ListOfPaveBlock& aLPB2=mySplitShapesPool(myDS->RefEdge(nE2)); + aNbSplits=aLPB2.Extent(); + if (!aNbSplits) { + if (!aMap.Contains(nE2)) { + aMap.Add(nE2); + PreparePaveBlocks(nE2); + // + if (!myIsDone) { + return; + } + } + } + }// if (aType2==TopAbs_EDGE) + }// for (; myDSIt.More(); myDSIt.Next()) + + myIsDone=Standard_True; +} +//======================================================================= +// function: PreparePaveBlocks +// purpose: +//======================================================================= + void NMTTools_PaveFiller::PreparePaveBlocks(const Standard_Integer nE) +{ + myIsDone=Standard_False; + + Standard_Integer nV1, nV2; + + TopoDS_Edge aE; + TopoDS_Vertex aV1, aV2; + + // SplitShapesPool + BOPTools_ListOfPaveBlock& aLPB=mySplitShapesPool(myDS->RefEdge(nE)); + // Edge + aE=TopoDS::Edge(myDS->Shape(nE)); + // + if (!BRep_Tool::Degenerated(aE)){ + // + BOPTools_PaveSet& aPS=myPavePool(myDS->RefEdge(nE)); + + BOPTools_PaveBlockIterator aPBIt(nE, aPS); + for (; aPBIt.More(); aPBIt.Next()) { + BOPTools_PaveBlock& aPB=aPBIt.Value(); + + const IntTools_Range& aRange=aPB.Range(); + + const BOPTools_Pave& aPave1=aPB.Pave1(); + nV1=aPave1.Index(); + aV1=TopoDS::Vertex(myDS->GetShape(nV1)); + + const BOPTools_Pave& aPave2=aPB.Pave2(); + nV2=aPave2.Index(); + aV2=TopoDS::Vertex(myDS->GetShape(nV2)); + // + // ShrunkRange + IntTools_ShrunkRange aSR (aE, aV1, aV2, aRange, myContext); + // + Standard_Integer anErrorStatus; + anErrorStatus=aSR.ErrorStatus(); + + char buf[512]; + if (!aSR.IsDone()) { + sprintf (buf, "Can not obtain ShrunkRange for Edge %d\n", nE); + BOPTColStd_Dump::PrintMessage(buf); + sprintf (buf, "Can not obtain ShrunkRange for Edge %d", nE); + throw + BOPTColStd_Failure(buf) ; + } + // + if (anErrorStatus==6) { + sprintf(buf, + "Warning: [PreparePaveBlocks()] Max.Dummy Shrunk Range for Edge %d\n", nE); + BOPTColStd_Dump::PrintMessage(buf); + } + else { + // Check left paves and correct ShrunkRange if it is necessary + CorrectShrunkRanges (0, aPave1, aSR); + CorrectShrunkRanges (1, aPave2, aSR); + } + // + aPB.SetShrunkRange(aSR); + aLPB.Append(aPB); + } //for (; aPBIt1.More(); aPBIt1.Next()) + } + myIsDone=Standard_True; +} +//======================================================================= +// function: CorrectShrunkRanges +// purpose: +//======================================================================= + void NMTTools_PaveFiller::CorrectShrunkRanges(const Standard_Integer aSide, + const BOPTools_Pave& aPave, + IntTools_ShrunkRange& aShrunkRange) +{ + BooleanOperations_KindOfInterference aType; + Standard_Integer anIndexInterf ; + // + aType=aPave.Type(); + if (aType!=BooleanOperations_EdgeEdge) { + return; + } + // + anIndexInterf=aPave.Interference(); + if (anIndexInterf<0) { + // it can be EE interf between E and (e1,e2,..en) -> vertex + // so we can't decide which aEE.CommonPrt() we should take. + return; + } + + BOPTools_CArray1OfEEInterference& aEEs=myIntrPool->EEInterferences(); + const BOPTools_EEInterference& aEE=aEEs(anIndexInterf); + const IntTools_CommonPrt& aCP=aEE.CommonPrt(); + const TopoDS_Edge& aE1=aCP.Edge1(); + const TopoDS_Edge& aE2=aCP.Edge2(); + + const IntTools_Range& aSR=aShrunkRange.ShrunkRange(); + const TopoDS_Edge& aE=aShrunkRange.Edge(); + + IntTools_Range aNewRange; + IntTools_Range aCPRange; + + if (aE1.IsSame(aE)) { + const IntTools_Range& aR1=aCP.Range1(); + aCPRange=aR1; + } + if (aE2.IsSame(aE)) { + const IntTools_SequenceOfRanges& aSeqR=aCP.Ranges2(); + const IntTools_Range& aR2=aSeqR(1); + aCPRange=aR2; + } + // + Standard_Real aCoeff=1.05, tV, tNV; + tV=aPave.Param(); + if (aSide==0) { // Left + if (aCPRange.Last() > aSR.First()) { + tNV=aCPRange.Last(); + tNV=tV+aCoeff*(tNV-tV); + aNewRange.SetFirst(tNV); + aNewRange.SetLast (aSR.Last()); + + if(aNewRange.First() > aNewRange.Last()) { + aShrunkRange.SetShrunkRange(aNewRange); + } + } + } + else { // Right + if (aCPRange.First() < aSR.Last()) { + tNV=aCPRange.First(); + tNV=tV-aCoeff*(tV-tNV); + aNewRange.SetFirst(aSR.First()); + aNewRange.SetLast (tNV); + + if(aNewRange.First() < aNewRange.Last()) { + aShrunkRange.SetShrunkRange(aNewRange); + } + } + } +} +//======================================================================= +// function: IsBlocksCoinside +// purpose: +//======================================================================= + Standard_Boolean + NMTTools_PaveFiller::IsBlocksCoinside(const BOPTools_PaveBlock& aPB1, + const BOPTools_PaveBlock& aPB2) const +{ + Standard_Boolean bRetFlag=Standard_True; + Standard_Real aTolV11, aTolV12, aTolV21, aTolV22; + Standard_Real d1121, d1122, d1222, d1221, aTolSum, aCoeff=1.05; + gp_Pnt aP11, aP12, aP21, aP22; + + const TopoDS_Vertex& aV11=TopoDS::Vertex(myDS->Shape(aPB1.Pave1().Index())); + const TopoDS_Vertex& aV12=TopoDS::Vertex(myDS->Shape(aPB1.Pave2().Index())); + const TopoDS_Vertex& aV21=TopoDS::Vertex(myDS->Shape(aPB2.Pave1().Index())); + const TopoDS_Vertex& aV22=TopoDS::Vertex(myDS->Shape(aPB2.Pave2().Index())); + + aTolV11=BRep_Tool::Tolerance(aV11); + aTolV12=BRep_Tool::Tolerance(aV12); + aTolV21=BRep_Tool::Tolerance(aV21); + aTolV22=BRep_Tool::Tolerance(aV22); + + aP11=BRep_Tool::Pnt(aV11); + aP12=BRep_Tool::Pnt(aV12); + aP21=BRep_Tool::Pnt(aV21); + aP22=BRep_Tool::Pnt(aV22); + + d1121=aP11.Distance(aP21); + aTolSum=aCoeff*(aTolV11+aTolV21); + if (d1121RefEdge(nE)); + aLCBE.Append(aCBx); + } + } + } +} +//======================================================================= +// function: RemoveCommonBlocks +// purpose: +//======================================================================= + void NMTTools_PaveFiller::RemoveCommonBlocks(const NMTTools_ListOfCommonBlock& aLCB) +{ + Standard_Integer nE; + NMTTools_ListOfCommonBlock aLCBx; + NMTTools_ListIteratorOfListOfCommonBlock anItCB, anItCBE; + BOPTools_ListIteratorOfListOfPaveBlock anItLPB; + // + anItCB.Initialize(aLCB); + for (; anItCB.More(); anItCB.Next()) { + const NMTTools_CommonBlock& aCB=anItCB.Value(); + const BOPTools_ListOfPaveBlock& aLPB=aCB.PaveBlocks(); + // + // Remove aCB from each edge + anItLPB.Initialize(aLPB); + for (; anItLPB.More(); anItLPB.Next()) { + const BOPTools_PaveBlock& aPB=anItLPB.Value(); + nE=aPB.OriginalEdge(); + // + NMTTools_ListOfCommonBlock& aLCBE=myCommonBlockPool(myDS->RefEdge(nE)); + anItCBE.Initialize(aLCBE); + for (; anItCBE.More(); anItCBE.Next()) { + const NMTTools_CommonBlock& aCBE=anItCBE.Value(); + if (aCBE.IsEqual(aCB)) { + aLCBE.Remove(anItCBE); + break; + } + } + } + } +} +//======================================================================= +// function: SplitCommonBlock +// purpose: +//======================================================================= + void NMTTools_PaveFiller::SplitCommonBlock(const NMTTools_CommonBlock& aCB, + NMTTools_ListOfCommonBlock& aLCBx) +{ + Standard_Integer i, j, k, nE, aNbE, aNbSPBx, aNbPB; + BOPTools_SequenceOfPaveBlock aSPBx; + BOPTools_ListIteratorOfListOfPaveBlock anItLPB; + BOPTools_ListIteratorOfListOfPave anIt; + + BOPTools_PaveBlockIterator anPBIt; + // + const BOPTools_ListOfPaveBlock& aLPB=aCB.PaveBlocks(); + aNbE=aLPB.Extent(); + // + // 1. Whether we realy need to split the common block ? + anItLPB.Initialize(aLPB); + for (; anItLPB.More(); anItLPB.Next()) { + const BOPTools_PaveBlock& aPB=anItLPB.Value(); + nE=aPB.OriginalEdge(); + BOPTools_PaveSet& aPSE=myPavePoolNew(myDS->RefEdge(nE)); + aPSE.SortSet(); + // + BOPTools_PaveSet aPSx; + // + const BOPTools_ListOfPave& aLPE=aPSE.Set(); + anIt.Initialize(aLPE); + for (; anIt.More(); anIt.Next()) { + const BOPTools_Pave& aPx=anIt.Value(); + if (aPB.IsInBlock(aPx)) { + aPSx.Append(aPx); + } + } + aNbPB=aPSx.Set().Extent(); + break; + } + // + if (!aNbPB) { + // we need not split it + aLCBx.Append(aCB); + return; + } + // + // 2. Get sequence of pave Blocks containing all new pave blocks + // for each edges's source pave Block + anItLPB.Initialize(aLPB); + for (; anItLPB.More(); anItLPB.Next()) { + const BOPTools_PaveBlock& aPB=anItLPB.Value(); + const BOPTools_Pave& aPave1=aPB.Pave1(); + const BOPTools_Pave& aPave2=aPB.Pave2(); + nE=aPB.OriginalEdge(); + // + BOPTools_PaveSet aPSx; + // + // the set aPsx will contain bounadry paves aPave1, aPave2 and + // all paves of the edge nE that are inside block aPB + aPSx.Append(aPave1); + aPSx.Append(aPave2); + // + BOPTools_PaveSet& aPSE=myPavePoolNew(myDS->RefEdge(nE)); + aPSE.SortSet(); + // + const BOPTools_ListOfPave& aLPE=aPSE.Set(); + anIt.Initialize(aLPE); + for (; anIt.More(); anIt.Next()) { + const BOPTools_Pave& aPx=anIt.Value(); + if (aPB.IsInBlock(aPx)) { + aPSx.Append(aPx); + } + } + // + // Form pave blocks from aPSx and collect them in aSPBx + anPBIt.Initialize(nE, aPSx); + for (; anPBIt.More(); anPBIt.Next()) { + const BOPTools_PaveBlock& aPBx=anPBIt.Value(); + aSPBx.Append(aPBx); + } + } + // + // 3. Do new common blocks + // + const TColStd_ListOfInteger& aLF=aCB.Faces(); + aNbSPBx=aSPBx.Length(); + aNbPB=aNbSPBx/aNbE; + // + for (i=1; i<=aNbPB; ++i) { + NMTTools_CommonBlock aCBx; + // + aCBx.AddFaces(aLF); + // + for (j=1; j<=aNbE; ++j) { + k=i+(j-1)*aNbPB; + const BOPTools_PaveBlock& aPB=aSPBx(k); + aCBx.AddPaveBlock(aPB); + } + aLCBx.Append(aCBx); + } +} + +//======================================================================= +// function: VertexParameters +// purpose: +//======================================================================= +void VertexParameters(const IntTools_CommonPrt& aCPart, + Standard_Real& aT1, + Standard_Real& aT2) +{ + const IntTools_Range& aR1=aCPart.Range1(); + aT1=0.5*(aR1.First()+aR1.Last()); + // + if((aCPart.VertexParameter1() >= aR1.First()) && + (aCPart.VertexParameter1() <= aR1.Last())) { + aT1 = aCPart.VertexParameter1(); + } + // + const IntTools_SequenceOfRanges& aRanges2=aCPart.Ranges2(); + const IntTools_Range& aR2=aRanges2(1); + aT2=0.5*(aR2.First()+aR2.Last()); + // + if((aCPart.VertexParameter2() >= aR2.First()) && + (aCPart.VertexParameter2() <= aR2.Last())) { + aT2 = aCPart.VertexParameter2(); + } +} +//======================================================================= +// function: KeepPave +// purpose: +//======================================================================= +Standard_Boolean IsOnPave(const Standard_Real& aT1, + const IntTools_Range& aRange, + const Standard_Real& aTolerance) +{ + Standard_Boolean firstisonpave1, firstisonpave2, bIsOnPave; + // + firstisonpave1 = (Abs(aRange.First() - aT1) < aTolerance); + firstisonpave2 = (Abs(aRange.Last() - aT1) < aTolerance); + bIsOnPave=(firstisonpave1 || firstisonpave2); + return bIsOnPave; +} + +//======================================================================= +// function:FindChains +// purpose: +//======================================================================= +void FindChains(const BOPTools_IDMapOfPaveBlockIMapOfPaveBlock& aMapCB, + NMTTools_ListOfCommonBlock& aLCB) +{ + Standard_Integer i, j, aNbCB, aNbPB; + BOPTools_IMapOfPaveBlock aProcessedBlocks, aChain; + // + aNbCB=aMapCB.Extent(); + for (i=1; i<=aNbCB; ++i) { + const BOPTools_PaveBlock& aPB=aMapCB.FindKey(i); + if (aProcessedBlocks.Contains(aPB)) { + continue; + } + // + aProcessedBlocks.Add(aPB); + aChain.Add(aPB); + // + const BOPTools_IMapOfPaveBlock& aMapPB=aMapCB(i); + aNbPB=aMapPB.Extent(); + for (j=1; j<=aNbPB; ++j) { + const BOPTools_PaveBlock& aPBx=aMapPB(j); + ProcessBlock(aPBx, aMapCB, aProcessedBlocks, aChain); + } + // + NMTTools_CommonBlock aCB; + // + aNbPB=aChain.Extent(); + for (j=1; j<=aNbPB; ++j) { + const BOPTools_PaveBlock& aPBx=aChain(j); + aCB.AddPaveBlock(aPBx); + } + aLCB.Append(aCB); + aChain.Clear(); + } +} +//======================================================================= +// function:ProcessBlock +// purpose: +//======================================================================= +void ProcessBlock(const BOPTools_PaveBlock& aPB, + const BOPTools_IDMapOfPaveBlockIMapOfPaveBlock& aMapCB, + BOPTools_IMapOfPaveBlock& aProcessedBlocks, + BOPTools_IMapOfPaveBlock& aChain) +{ + Standard_Integer j, aNbPB; + // + if (aProcessedBlocks.Contains(aPB)) { + return; + } + aProcessedBlocks.Add(aPB); + aChain.Add(aPB); + // + const BOPTools_IMapOfPaveBlock& aMapPB=aMapCB.FindFromKey(aPB); + aNbPB=aMapPB.Extent(); + for (j=1; j<=aNbPB; ++j) { + const BOPTools_PaveBlock& aPBx=aMapPB(j); + ProcessBlock(aPBx, aMapCB, aProcessedBlocks, aChain); + } +} diff --git a/src/NMTTools/NMTTools_PaveFiller_5.cxx b/src/NMTTools/NMTTools_PaveFiller_5.cxx new file mode 100644 index 000000000..392267f3d --- /dev/null +++ b/src/NMTTools/NMTTools_PaveFiller_5.cxx @@ -0,0 +1,605 @@ +// File: NMTTools_PaveFiller_5.cxx +// Created: Mon Dec 15 11:28:33 2003 +// 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 + +static + void VertexParameter(const IntTools_CommonPrt& aCPart, + Standard_Real& aT); +static + Standard_Boolean IsOnPave(const Standard_Real& aTR, + const IntTools_Range& aCPRange, + const Standard_Real& aTolerance); + +//======================================================================= +// function: PerformEF +// purpose: +//======================================================================= + void NMTTools_PaveFiller::PerformEF() +{ + myIsDone=Standard_False; + + Standard_Integer n1, n2, anIndexIn=0, nE, nF, aNbEFs, aBlockLength; + Standard_Boolean bJustAdd; + Standard_Real aTolE, aTolF, aDeflection=0.01; + Standard_Integer aDiscretize=35; + BooleanOperations_IndexedDataMapOfShapeInteger aMapVI; + BOPTools_IDMapOfPaveBlockIMapOfInteger aMapCB; + BOPTools_IMapOfPaveBlock aIMPBx; + + // + BOPTools_CArray1OfESInterference& aEFs=myIntrPool->ESInterferences(); + // + myDSIt.Initialize(TopAbs_EDGE, TopAbs_FACE); + // + // BlockLength correction + aNbEFs=ExpectedPoolLength(); + aBlockLength=aEFs.BlockLength(); + if (aNbEFs > aBlockLength) { + aEFs.SetBlockLength(aNbEFs); + } + // + for (; myDSIt.More(); myDSIt.Next()) { + myDSIt.Current(n1, n2, bJustAdd); + anIndexIn = 0; + // + if (myIntrPool->IsComputed(n1, n2)) { + continue; + } + // + nE=n1; + nF=n2; + SortTypes(nE, nF); + // + // all Common Blocks for face nF + //XXX + NMTTools_ListOfCommonBlock aLCBF; + CommonBlocksFace(nF, aLCBF); + NMTTools_CommonBlockAPI aCBAPIF(aLCBF); + //XXX + if(bJustAdd) { + myIntrPool->AddInterference (nE, nF, BooleanOperations_EdgeSurface, anIndexIn); + continue; + } + // Edge + const TopoDS_Edge& aE=TopoDS::Edge(myDS->GetShape(nE)); + if (BRep_Tool::Degenerated(aE)){ + continue; + } + aTolE=BRep_Tool::Tolerance(aE); + // Face + const TopoDS_Face& aF=TopoDS::Face(myDS->GetShape(nF)); + aTolF=BRep_Tool::Tolerance(aF); + const Bnd_Box& aBBF=myDS->GetBoundingBox(nF); + // + // Process each PaveBlock on edge nE + BOPTools_ListOfPaveBlock& aLPB=mySplitShapesPool(myDS->RefEdge(nE)); + // + BOPTools_ListIteratorOfListOfPaveBlock anIt(aLPB); + for (; anIt.More(); anIt.Next()) { + BOPTools_PaveBlock& aPB=anIt.Value(); + //XXX + if (aCBAPIF.IsCommonBlock(aPB)) { + continue; + } + //XXX + const IntTools_ShrunkRange& aShrunkRange=aPB.ShrunkRange(); + const IntTools_Range& aSR =aShrunkRange.ShrunkRange(); + const Bnd_Box& aBBE=aShrunkRange.BndBox(); + // + if (aBBF.IsOut (aBBE)) { + continue; + } + // + // EF + IntTools_EdgeFace aEF; + aEF.SetEdge (aE); + aEF.SetFace (aF); + aEF.SetTolE (aTolE); + aEF.SetTolF (aTolF); + aEF.SetDiscretize (aDiscretize); + aEF.SetDeflection (aDeflection); + // + aEF.SetContext((IntTools_PContext)&myContext); + // + IntTools_Range anewSR = aSR; + // + // Correction of the Shrunk Range + BOPTools_Tools::CorrectRange(aE, aF, aSR, anewSR); + aEF.SetRange (anewSR); + // + aEF.Perform(); + // + if (aEF.IsDone()) { + const IntTools_SequenceOfCommonPrts& aCPrts=aEF.CommonParts(); + Standard_Integer i, aNbCPrts; + aNbCPrts=aCPrts.Length(); + for (i=1; i<=aNbCPrts; i++) { + // + anIndexIn=0; + // + const IntTools_CommonPrt& aCPart=aCPrts(i); + TopAbs_ShapeEnum aType=aCPart.Type(); + switch (aType) { + + case TopAbs_VERTEX: { + Standard_Boolean bIsOnPave1, bIsOnPave2; + Standard_Integer nVF; + Standard_Real aT, aTolToDecide; + TopoDS_Vertex aNewVertex; + // + const IntTools_Range& aR=aCPart.Range1(); + // + // New Vertex + VertexParameter(aCPart, aT); + BOPTools_Tools::MakeNewVertex(aE, aT, aF, aNewVertex); + // + //decide to add pave or not + aTolToDecide=5.e-8; + // + bIsOnPave1=IsOnPave(anewSR.First(), aR, aTolToDecide); + bIsOnPave2=IsOnPave(anewSR.Last() , aR, aTolToDecide); + // + if (!bIsOnPave1 && !bIsOnPave2) { + nVF=CheckFacePaves(aNewVertex, nF); + if (!nVF) { + // really new vertex + // Add Interference to the Pool + BOPTools_ESInterference anInterf (nE, nF, aCPart); + anIndexIn=aEFs.Append(anInterf); + anInterf.SetNewShape(0); + // + aMapVI.Add(aNewVertex, anIndexIn); + aIMPBx.Add(aPB); + // + }// if (!nVF) + }// if (!bIsOnPave1 && !bIsOnPave2) + myIntrPool->AddInterference (nE, nF, BooleanOperations_EdgeSurface, anIndexIn); + }// case TopAbs_VERTEX: + break; + // + case TopAbs_EDGE: { + Standard_Boolean aCoinsideFlag; + // + aCoinsideFlag=BOPTools_Tools::IsBlockInOnFace(aPB, aF, myContext); + if (!aCoinsideFlag) { + myIntrPool->AddInterference (nE, nF, BooleanOperations_EdgeSurface, anIndexIn); + break; + } + // + // Fill aMapCB + if (aMapCB.Contains(aPB)) { + TColStd_IndexedMapOfInteger& aMapF=aMapCB.ChangeFromKey(aPB); + aMapF.Add(nF); + } + else { + TColStd_IndexedMapOfInteger aMapF; + aMapF.Add(nF); + aMapCB.Add(aPB, aMapF); + } + //modified by NIZNHY-PKV Fri Jan 23 14:13:08 2004 f + aIMPBx.Add(aPB); + //modified by NIZNHY-PKV Fri Jan 23 14:13:10 2004 t + }// case TopAbs_EDGE: + break; + + default: + break; + } // switch (aType) + } // for (i=1; i<=aNbCPrts; i++) + } //if (aEF.IsDone()) + } // for (; anIt.More(); anIt.Next()) + }// for (; myDSIt.More(); myDSIt.Next()) + // + // Treat New vertices + EFNewVertices(aMapVI); + // + // Add draft Common Blocks of EF type + EFCommonBlocks(aMapCB); + // + // Collect all CB we suspected to split by new vertices + NMTTools_ListOfCommonBlock aLCBx; + { + Standard_Integer i, aNbPBx, nEx; + BOPTools_IMapOfPaveBlock aMx; + // + aNbPBx=aIMPBx.Extent(); + for (i=1; i<=aNbPBx; ++i) { + const BOPTools_PaveBlock& aPBx=aIMPBx(i); + nEx=aPBx.OriginalEdge(); + NMTTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nEx)); + if (aLCB.Extent()) { + NMTTools_CommonBlockAPI aCBAPIx(aLCB); + if (aCBAPIx.IsCommonBlock(aPBx)) { + NMTTools_CommonBlock& aCBx=aCBAPIx.CommonBlock(aPBx); + const BOPTools_PaveBlock& aPB1=aCBx.PaveBlock1(); + if (!aMx.Contains(aPB1)){ + aMx.Add(aPB1); + aLCBx.Append(aCBx); + } + } + } + } + } + // + // Split the common blocks above + if (aLCBx.Extent()) { + ReplaceCommonBlocks(aLCBx); + } + // + myIsDone=Standard_True; +} +//======================================================================= +// function:EFCommonBlocks +// purpose: +//======================================================================= + void NMTTools_PaveFiller::EFCommonBlocks(const BOPTools_IDMapOfPaveBlockIMapOfInteger& aMapCB) +{ + Standard_Integer i, aNbPB, nE, j, aNbF, nF; + // + aNbPB=aMapCB.Extent(); + // + for (i=1; i<=aNbPB; ++i) { + const BOPTools_PaveBlock& aPB=aMapCB.FindKey(i); + const TColStd_IndexedMapOfInteger& aMapF=aMapCB.FindFromIndex(i); + aNbF=aMapF.Extent(); + // + nE=aPB.OriginalEdge(); + // + NMTTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nE)); + // + NMTTools_CommonBlockAPI aCBAPI(aLCB); + if (aCBAPI.IsCommonBlock(aPB)) { + NMTTools_CommonBlock& aCB=aCBAPI.CommonBlock(aPB); + for (j=1; j<=aNbF; ++j) { + nF=aMapF(j); + aCB.AddFace(nF); + } + } + else { + NMTTools_CommonBlock aCB; + // + aCB.AddPaveBlock(aPB); + for (j=1; j<=aNbF; ++j) { + nF=aMapF(j); + aCB.AddFace(nF); + } + aLCB.Append(aCB); + } + } +} +//======================================================================= +// function:EFNewVertices +// purpose: +//======================================================================= + void NMTTools_PaveFiller::EFNewVertices (const BooleanOperations_IndexedDataMapOfShapeInteger& aMapVI) +{ + Standard_Integer i, j, aNb, aNewShape, aFlag, iX, aNbVV, aNbSimple; + Standard_Integer aWhat, aWith, nE, nF, nV, aNbIEF, aNbEdges; + Standard_Real aT; + TopoDS_Compound aCompound; + TopoDS_Vertex aNewVertex; + BRep_Builder aBB; + BOPTools_Pave aPave; + NMTTools_IndexedDataMapOfIndexedMapOfInteger aMNVE, aMNVIEF; + BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq; + TopTools_IndexedMapOfShape aMNVComplex, aMNVSimple; + // + BOPTools_CArray1OfESInterference& aEFs=myIntrPool->ESInterferences(); + // + aNb=aMapVI.Extent(); + // + if (!aNb) { // no new vertices, no new problems + return; + } + // + // 0. + if (aNb==1) { + aNewVertex=TopoDS::Vertex(aMapVI.FindKey(1)); + EFNewVertices(aNewVertex, aMapVI); + return; + } + // + // 1. Make compound from new vertices + aBB.MakeCompound(aCompound); + for (i=1; i<=aNb; ++i) { + const TopoDS_Shape& aV=aMapVI.FindKey(i); + aBB.Add(aCompound, aV); + } + // + // 2. VV intersection between these vertices + // using the auxiliary Filler + NMTDS_ShapesDataStructure tDS; + // + tDS.SetCompositeShape(aCompound); + tDS.Init(); + // + BOPTools_InterferencePool tInterfPool(tDS); + NMTTools_PaveFiller tPaveFiller(tInterfPool); + // + tPaveFiller.Init(); + // + tPaveFiller.PerformVV(); + tPaveFiller.PerformNewVertices(); + // + const BOPTools_CArray1OfVVInterference& aVVInterfs=tInterfPool.VVInterfs(); + // + // 3. Separate Comlex and Simple new vertices + aNbVV=aVVInterfs.Extent(); + for (i=1; i<=aNbVV; ++i) { + const BOPTools_VVInterference& aVV=aVVInterfs(i); + aVV.Indices(aWhat, aWith); + const TopoDS_Shape& aV1=tDS.Shape(aWhat); + const TopoDS_Shape& aV2=tDS.Shape(aWith); + aMNVComplex.Add(aV1); + aMNVComplex.Add(aV2); + } + // + for (i=1; i<=aNb; ++i) { + const TopoDS_Shape& aV=aMapVI.FindKey(i); + if (!aMNVComplex.Contains(aV)) { + aMNVSimple.Add(aV); + } + } + // + // 4. Treat Simple new Vertices + aNbSimple=aMNVSimple.Extent(); + for (i=1; i<=aNbSimple; ++i) { + const TopoDS_Vertex& aV=TopoDS::Vertex(aMNVSimple(i)); + EFNewVertices(aV, aMapVI); + } + // + // 3. Fill Maps : NewVertex-edges (aMNVE) + // NewVertex-interferences (aMNVIEE) + aNb=aVVInterfs.Extent(); + for (i=1; i<=aNb; ++i) { + const BOPTools_VVInterference& aVV=aVVInterfs(i); + aNewShape=aVV.NewShape(); + if (!aNewShape) { + continue; + } + // + if (!aMNVE.Contains(aNewShape)) { + TColStd_IndexedMapOfInteger aMx; + aMNVE.Add(aNewShape, aMx); + } + if (!aMNVIEF.Contains(aNewShape)) { + TColStd_IndexedMapOfInteger aMx; + aMNVIEF.Add(aNewShape, aMx); + } + // + TColStd_IndexedMapOfInteger& aME=aMNVE.ChangeFromKey(aNewShape); + TColStd_IndexedMapOfInteger& aMIEF=aMNVIEF.ChangeFromKey(aNewShape); + // + aVV.Indices(aWhat, aWith); + //aWhat + const TopoDS_Shape& aV1=tDS.Shape(aWhat); + iX=aMapVI.FindFromKey(aV1); + const BOPTools_ESInterference& aEF1=aEFs(iX); + aEF1.Indices(nE, nF); + SortTypes(nE, nF); + aME.Add(nE); + aMIEF.Add(iX); + //aWith + const TopoDS_Shape& aV2=tDS.Shape(aWith); + iX=aMapVI.FindFromKey(aV2); + const BOPTools_ESInterference& aEF2=aEFs(iX); + aEF2.Indices(nE, nF); + SortTypes(nE, nF); + aME.Add(nE); + aMIEF.Add(iX); + } + // 4. Process new vertices + aNb=aMNVE.Extent(); + for (i=1; i<=aNb; ++i) { // xx + // + // new Vertex + nV=aMNVE.FindKey(i); + aNewVertex=TopoDS::Vertex(tDS.Shape(nV)); + // + // Insert New Vertex in DS; + myDS->InsertShapeAndAncestorsSuccessors(aNewVertex, anASSeq); + aNewShape=myDS->NumberOfInsertedShapes(); + myDS->SetState (aNewShape, BooleanOperations_ON); + // + // Update index of NewShape in EF interferences + const TColStd_IndexedMapOfInteger& aMIEF=aMNVIEF.FindFromKey(nV); + aNbIEF=aMIEF.Extent(); + for (j=1; j<=aNbIEF; ++j) { + iX=aMIEF(j); + BOPTools_ESInterference& aEF=aEFs(iX); + aEF.SetNewShape(aNewShape); + } + // + // Update Paves on all edges + const TColStd_IndexedMapOfInteger& aME=aMNVE(i); + aNbEdges=aME.Extent(); + for (j=1; j<=aNbEdges; ++j) { + nE=aME(j); + const TopoDS_Edge& aE=TopoDS::Edge(myDS->Shape(nE)); + // + aFlag=myContext.ComputeVE (aNewVertex, aE, aT); + // + if (!aFlag) { + aPave.SetInterference(-1); + aPave.SetType (BooleanOperations_EdgeSurface); + aPave.SetIndex(aNewShape); + aPave.SetParam(aT); + // + BOPTools_PaveSet& aPaveSet=myPavePoolNew(myDS->RefEdge(nE)); + aPaveSet.Append(aPave); + } + } + } +} +//======================================================================= +// function:EFNewVertices +// purpose: +//======================================================================= + void NMTTools_PaveFiller::EFNewVertices (const TopoDS_Vertex& aNewVertex, + const BooleanOperations_IndexedDataMapOfShapeInteger& aMapVI) +{ + Standard_Integer i, aNewShape, nE, nF; + Standard_Real aT; + BOPTools_Pave aPave; + BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq; + // + BOPTools_CArray1OfESInterference& aEFs=myIntrPool->ESInterferences(); + // + // Insert New Vertex in DS; + myDS->InsertShapeAndAncestorsSuccessors(aNewVertex, anASSeq); + aNewShape=myDS->NumberOfInsertedShapes(); + myDS->SetState (aNewShape, BooleanOperations_ON); + // Insert New Vertex in EFInterference + i=aMapVI.FindFromKey(aNewVertex); + BOPTools_ESInterference& aEFInterf= aEFs(i); + aEFInterf.SetNewShape(aNewShape); + // Extract interference info + aEFInterf.Indices(nE, nF); + SortTypes(nE, nF); + const IntTools_CommonPrt& aCPart=aEFInterf.CommonPrt(); + VertexParameter(aCPart, aT); + // + // Pave for edge nE + aPave.SetInterference(i); + aPave.SetType (BooleanOperations_EdgeSurface); + aPave.SetIndex(aNewShape); + aPave.SetParam(aT); + // Append the Pave to the myPavePoolNew + BOPTools_PaveSet& aPaveSet=myPavePoolNew(myDS->RefEdge(nE)); + aPaveSet.Append(aPave); + // +} +//======================================================================= +// function: CheckFacePaves +// purpose: +//======================================================================= + Standard_Integer NMTTools_PaveFiller::CheckFacePaves (const TopoDS_Vertex& aNewVertex, + const Standard_Integer nF) +{ + Standard_Integer nEF, nVF, iFlag, i, aNbV; + BOPTools_ListIteratorOfListOfPave anIt; + TColStd_IndexedMapOfInteger aMVF; + // + BooleanOperations_OnceExplorer aExp(*myDS); + // + aExp.Init(nF, TopAbs_EDGE); + for (; aExp.More(); aExp.Next()) { + nEF=aExp.Current(); + BOPTools_PaveSet& aPaveSet=myPavePool(myDS->RefEdge(nEF)); + const BOPTools_ListOfPave& aLP=aPaveSet.Set(); + anIt.Initialize(aLP); + for (; anIt.More(); anIt.Next()) { + const BOPTools_Pave& aPave=anIt.Value(); + nVF=aPave.Index(); + aMVF.Add(nVF); + } + } + // + aNbV=aMVF.Extent(); + for (i=1; i<=aNbV; ++i) { + nVF=aMVF(i); + const TopoDS_Vertex& aVF=TopoDS::Vertex(myDS->Shape(nVF)); + iFlag=IntTools_Tools::ComputeVV(aNewVertex, aVF); + if (!iFlag) { + return nVF; + } + } + return 0; +} + +// +//======================================================================= +// function: VertexParameter +// purpose: +//======================================================================= +void VertexParameter(const IntTools_CommonPrt& aCPart, + Standard_Real& aT) +{ + const IntTools_Range& aR=aCPart.Range1(); + aT=0.5*(aR.First()+aR.Last()); + // + if((aCPart.VertexParameter1() >= aR.First()) && + (aCPart.VertexParameter1() <= aR.Last())) { + aT = aCPart.VertexParameter1(); + } +} +//======================================================================= +// function: IsOnPave +// purpose: +//======================================================================= +Standard_Boolean IsOnPave(const Standard_Real& aTR, + const IntTools_Range& aCPRange, + const Standard_Real& aTolerance) +{ + Standard_Boolean bIsOnPave; + Standard_Real aT1, aT2, dT1, dT2; + // + aT1=aCPRange.First(); + aT2=aCPRange.Last(); + bIsOnPave=(aTR>=aT1 && aTR<=aT1); + if (bIsOnPave) { + return bIsOnPave; + } + dT1=Abs(aTR-aT1); + dT2=Abs(aTR-aT2); + bIsOnPave=(dT1<=aTolerance || dT2<=aTolerance); + return bIsOnPave; +} diff --git a/src/NMTTools/NMTTools_PaveFiller_6.cxx b/src/NMTTools/NMTTools_PaveFiller_6.cxx new file mode 100644 index 000000000..d308457f9 --- /dev/null +++ b/src/NMTTools/NMTTools_PaveFiller_6.cxx @@ -0,0 +1,1151 @@ +// File: NMTTools_PaveFiller_6.cxx +// Created: Fri Dec 19 10:27:31 2003 +// 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 + +static + Standard_Boolean IsPairFound(const Standard_Integer nF1, + const Standard_Integer nF2, + BOPTools_InterferencePool* myIntrPool, + BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMapWhat, + BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMapWith); + +static + void FMapWhat(const Standard_Integer nF, + BOPTools_InterferencePool* myIntrPool, + TColStd_IndexedMapOfInteger& aMapWhat); +static + void FMapWith(const Standard_Integer nF, + BOPTools_InterferencePool* myIntrPool, + TColStd_IndexedMapOfInteger& aMapWith); +static + Standard_Boolean IsFound(const TColStd_IndexedMapOfInteger& aMapWhat, + const TColStd_IndexedMapOfInteger& aMapWith); + +//======================================================================= +// function: PerformFF +// purpose: +//======================================================================= + void NMTTools_PaveFiller::PerformFF() +{ + myIsDone=Standard_False; + // + Standard_Boolean bIsFound, bJustAdd, bIsComputed; + Standard_Integer n1, n2, anIndexIn, nF1, nF2, aBlockLength, aNbFFs; + Standard_Boolean bToApproxC3d, bToApproxC2dOnS1, bToApproxC2dOnS2, bIsDone; + Standard_Integer aNbCurves, aNbPoints; + Standard_Real anApproxTol, aTolR3D, aTolR2D; + BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger aMapWhat, aMapWith; + IntTools_SequenceOfPntOn2Faces aPnts; + IntTools_SequenceOfCurves aCvs; + BooleanOperations_KindOfInterference aTypeFF=BooleanOperations_SurfaceSurface; + // + BOPTools_CArray1OfSSInterference& aFFs=myIntrPool->SSInterferences(); + // + // F/F Interferences [BooleanOperations_SurfaceSurface] + myDSIt.Initialize(TopAbs_FACE, TopAbs_FACE); + // + // BlockLength correction + aNbFFs=ExpectedPoolLength(); + aBlockLength=aFFs.BlockLength(); + if (aNbFFs > aBlockLength) { + aFFs.SetBlockLength(aNbFFs); + } + // + for (; myDSIt.More(); myDSIt.Next()) { + myDSIt.Current(n1, n2, bJustAdd); + // + bIsComputed=myIntrPool->IsComputed(n1, n2); + if (bIsComputed) { + continue; + } + // + nF1 = n2; + nF2 = n1; + if(n1 < n2) { + nF1 = n1; + nF2 = n2; + } + anIndexIn=0; + aPnts.Clear(); + aCvs.Clear(); + // + bIsFound=IsPairFound(nF1, nF2, myIntrPool, aMapWhat, aMapWith); + // + if (bJustAdd) { + if (!bIsFound) { + myIntrPool->AddInterference (nF1, nF2, aTypeFF, anIndexIn); + } + else{ + BOPTools_SSInterference anInterf (nF1, nF2, 1.e-07, 1.e-07, aCvs, aPnts); + anIndexIn=aFFs.Append(anInterf); + myIntrPool->AddInterference (nF1, nF2, aTypeFF, anIndexIn); + } + continue; + } + // + const TopoDS_Face& aF1=TopoDS::Face(myDS->Shape(nF1)); + const TopoDS_Face& aF2=TopoDS::Face(myDS->Shape(nF2)); + // + // FF + bToApproxC3d = mySectionAttribute.Approximation(); + bToApproxC2dOnS1 = mySectionAttribute.PCurveOnS1(); + bToApproxC2dOnS2 = mySectionAttribute.PCurveOnS2(); + // + anApproxTol=1.e-7; + // + IntTools_FaceFace aFF; + // + aFF.SetParameters (bToApproxC3d, bToApproxC2dOnS1, + bToApproxC2dOnS2, anApproxTol); + // + aFF.Perform(aF1, aF2); + // + bIsDone=aFF.IsDone(); + // + if (!bIsDone) { + if (!bIsFound) { + myIntrPool->AddInterference (nF1, nF2, aTypeFF, anIndexIn); + } + else { + BOPTools_SSInterference anInterf (nF1, nF2, 1.e-07, 1.e-07, aCvs, aPnts); + anIndexIn=aFFs.Append(anInterf); + myIntrPool->AddInterference (nF1, nF2, aTypeFF, anIndexIn); + } + continue; + } + // + aTolR3D=aFF.TolReached3d(); + aTolR2D=aFF.TolReached2d(); + if (aTolR3D < 1.e-7){ + aTolR3D=1.e-7; + } + // + aFF.PrepareLines3D(); + // + const IntTools_SequenceOfCurves& aCvsX=aFF.Lines(); + const IntTools_SequenceOfPntOn2Faces& aPntsX=aFF.Points(); + // + aNbCurves=aCvsX.Length(); + aNbPoints=aPntsX.Length(); + // + if (!aNbCurves && !aNbPoints) { + BOPTools_SSInterference anInterf (nF1, nF2, 1.e-07, 1.e-07, aCvs, aPnts); + anIndexIn=aFFs.Append(anInterf); + myIntrPool->AddInterference (nF1, nF2, aTypeFF, anIndexIn); + continue; + } + // + { + BOPTools_SSInterference anInterf (nF1, nF2, aTolR3D, aTolR2D, aCvsX, aPntsX); + anIndexIn=aFFs.Append(anInterf); + myIntrPool->AddInterference (nF1, nF2, aTypeFF, anIndexIn); + } + // + }// for (; myDSIt.More(); myDSIt.Next()) + // + myIsDone=Standard_True; +} +//======================================================================= +// function: MakeBlocks +// purpose: +//======================================================================= + void NMTTools_PaveFiller::MakeBlocks() +{ + myIsDone=Standard_False; + // + Standard_Boolean bIsExistingPaveBlock, bIsValidIn2D; + Standard_Integer i, aNbFFs, nF1, nF2, aBid=0; + Standard_Integer nV1, nV2, j, aNbCurves; + Standard_Real aTolR3D, aTol2D, aT1, aT2, aTolPPC=Precision::PConfusion(); + TColStd_MapOfInteger aMap; + NMTTools_IndexedDataMapOfShapePaveBlock aMEPB; + BooleanOperations_IndexedDataMapOfShapeInteger aMapEI; + // + BOPTools_CArray1OfSSInterference& aFFs=myIntrPool->SSInterferences(); + // + // 1. Produce Section Edges from intersection curves + // between each pair of faces + // + aNbFFs=aFFs.Extent(); + for (i=1; i<=aNbFFs; ++i) { + BOPTools_SSInterference& aFFi=aFFs(i); + // + // Faces + aFFi.Indices(nF1, nF2); + const TopoDS_Face& aF1=TopoDS::Face(myDS->Shape(nF1)); + const TopoDS_Face& aF2=TopoDS::Face(myDS->Shape(nF2)); + // + // Add blocks that are existing ones for this FF-interference + BOPTools_ListOfPaveBlock aLPB; + RealSplitsInFace (aBid, nF1, nF2, aLPB); + RealSplitsInFace (aBid, nF2, nF1, aLPB); + RealSplitsOnFace (aBid, nF1, nF2, aLPB); + // + aMap.Clear(); + BOPTools_ListIteratorOfListOfPaveBlock anIt(aLPB); + for (; anIt.More(); anIt.Next()) { + const BOPTools_PaveBlock& aPB=anIt.Value(); + aFFi.AppendBlock(aPB); + nV1=aPB.Pave1().Index(); + nV2=aPB.Pave2().Index(); + aMap.Add(nV1); + aMap.Add(nV2); + } + // + BOPTools_SequenceOfCurves& aSCvs=aFFi.Curves(); + aNbCurves=aSCvs.Length(); + if (!aNbCurves) { + continue; + } + // + aTolR3D=aFFi.TolR3D(); + aTol2D=(aTolR3D < 1.e-3) ? 1.e-3 : aTolR3D; + // + BOPTools_PaveSet aPSF; + // + PrepareSetForFace (nF1, nF2, aPSF); + // + // Put Paves On Curves + for (j=1; j<=aNbCurves; ++j) { + BOPTools_Curve& aBC=aSCvs(j); + // DEBUG + const IntTools_Curve& aC=aBC.Curve(); + Handle (Geom_Curve) aC3D= aC.Curve(); + // + PutPaveOnCurve (aPSF, aTolR3D, aBC); + } + // + // Put bounding paves on curves + for (j=1; j<=aNbCurves; ++j) { + BOPTools_Curve& aBC=aSCvs(j); + PutBoundPaveOnCurve (aBC, aFFi); + } + // + // Pave Blocks on Curves + for (j=1; j<=aNbCurves; ++j) { + BOPTools_Curve& aBC=aSCvs(j); + const IntTools_Curve& aIC= aBC.Curve(); + BOPTools_PaveSet& aPaveSet=aBC.Set(); + // + BOPTools_PaveBlockIterator aPBIter(0, aPaveSet); + for (; aPBIter.More(); aPBIter.Next()) { + BOPTools_PaveBlock& aPBNew=aPBIter.Value(); + aPBNew.SetCurve(aIC); + aPBNew.SetFace1(nF1); + aPBNew.SetFace2(nF2); + // + nV1=aPBNew.Pave1().Index(); + nV2=aPBNew.Pave2().Index(); + aT1=aPBNew.Pave1().Param(); + aT2=aPBNew.Pave2().Param(); + // ??? + if((nV1==nV2) && (Abs(aT2 - aT1) < aTolPPC)) { + continue;// mkk ft + } + // + bIsExistingPaveBlock=IsExistingPaveBlock(aPBNew, aFFi); + if (bIsExistingPaveBlock) { + // aPBNew was (or just lays) boundary PB + continue; + } + // Checking of validity in 2D + // + bIsValidIn2D=myContext.IsValidBlockForFaces(aT1, aT2, aIC, aF1, aF2, aTol2D); + if (!bIsValidIn2D) { + continue; + } + // + //aBC.AppendNewBlock(aPBNew); + // + // Make Section Edge + TopoDS_Edge aES; + // + const TopoDS_Vertex& aV1=TopoDS::Vertex(myDS->Shape(nV1)); + const TopoDS_Vertex& aV2=TopoDS::Vertex(myDS->Shape(nV2)); + // + BOPTools_Tools::MakeSectEdge (aIC, aV1, aT1, aV2, aT2, aES); + // + { + Standard_Real aTolR2D; + // + aTolR2D=aFFi.TolR2D(); + Handle(Geom2d_Curve) aC2D1=aIC.FirstCurve2d(); + Handle(Geom2d_Curve) aC2D2=aIC.SecondCurve2d(); + // + NMTTools_Tools::MakePCurve(aES, aF1, aC2D1, aTolR2D); + NMTTools_Tools::MakePCurve(aES, aF2, aC2D2, aTolR2D); + } + // + aMEPB.Add(aES, aPBNew); + aMapEI.Add(aES, i); + } + } // end of for (j=1; j<=aNbCurves; ++j) + }// for (i=1; i<=aNbFFs; ++i) + //============================================================= + // + // II. Post treatment + // + // Input data: aMEPB, aMapEI + // Result : section edges in myDS + // + Standard_Integer aNbSE; + // + aNbSE=aMEPB.Extent(); + if (!aNbSE) { + // there is nothing to do here + return; + } + // + BRep_Builder aBB; + TopoDS_Compound aCompound; + // + // 1. Make compound from SE + aBB.MakeCompound(aCompound); + for (i=1; i<=aNbSE; ++i) { + const TopoDS_Shape& aSE=aMEPB.FindKey(i); + aBB.Add(aCompound, aSE); + } + // + // + // 2. Intersect SE using auxiliary Filler + NMTDS_ShapesDataStructure tDS; + // + tDS.SetCompositeShape(aCompound); + tDS.Init(); + // + BOPTools_InterferencePool tIP(tDS); + NMTTools_PaveFiller tPF(tIP); + // + // 2.1.VV + tPF.Init(); + tPF.PerformVV(); + tPF.PerformNewVertices(); + // + // 2.2.VE + tPF.myPavePool.Resize (tPF.myNbEdges); + tPF.PrepareEdges(); + tPF.PerformVE(); + // + // 2.3.VF + tPF.PerformVF(); + // + // 2.4.EE + tPF.myCommonBlockPool.Resize (tPF.myNbEdges); + tPF.mySplitShapesPool.Resize (tPF.myNbEdges); + tPF.myPavePoolNew .Resize (tPF.myNbEdges); + + tPF.PreparePaveBlocks(TopAbs_VERTEX, TopAbs_EDGE); + tPF.PreparePaveBlocks(TopAbs_EDGE, TopAbs_EDGE); + // + tPF.PerformEE(); + // + tPF.RefinePavePool (); + // + tPF.myPavePoolNew.Destroy(); + // + tPF.MakeSplitEdges(); + tPF.UpdateCommonBlocks(); + // + // 3. Treatment of the result of intersection + // + Standard_Integer aNbOld, aNbLines, aNbPB, mV1, mV2, nE, mE, iFF; + TopAbs_ShapeEnum aType; + BOPTools_ListIteratorOfListOfPaveBlock aIt; + BOPTColStd_IndexedDataMapOfIntegerInteger aMNewOld; + // + const BOPTools_SplitShapesPool& aSSP=tPF.mySplitShapesPool; + const NMTTools_CommonBlockPool& aCBP=tPF.myCommonBlockPool; + // + aNbLines=tDS.NumberOfInsertedShapes(); + aNbOld=tDS.NumberOfShapesOfTheObject(); + // + // 3.1 Links between indices in tDS and DS (kept in aMNewOld) + // + // 3.1.1.Old vertices [ links ] + for (i=1; i<=aNbOld; ++i) { + const TopoDS_Shape& aV=tDS.Shape(i); + aType=aV.ShapeType(); + if (aType!=TopAbs_VERTEX) { + continue; + } + // + for (j=1; j<=aNbSE; ++j) { + const BOPTools_PaveBlock& aPBSE=aMEPB(j); + nV1=aPBSE.Pave1().Index(); + const TopoDS_Shape& aV1=myDS->Shape(nV1); + if (aV1.IsSame(aV)) { + aMNewOld.Add(i, nV1); + break; + } + nV2=aPBSE.Pave2().Index(); + const TopoDS_Shape& aV2=myDS->Shape(nV2); + if (aV2.IsSame(aV)) { + aMNewOld.Add(i, nV2); + break; + } + } + } + // + // 3.1.2. New vertices [ links ] + i=tDS.NumberOfSourceShapes()+1; + for (; i<=aNbLines; ++i) { + const TopoDS_Shape& aV=tDS.Shape(i); + aType=aV.ShapeType(); + if (aType!=TopAbs_VERTEX) { + continue; + } + // + // Insert new vertex in myDS + BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq; + myDS->InsertShapeAndAncestorsSuccessors(aV, anASSeq); + nV1=myDS->NumberOfInsertedShapes(); + // link + aMNewOld.Add(i, nV1); + } + // + // 3.2. Treatment of section edges (SE) + for (i=1; i<=aNbOld; ++i) { + const TopoDS_Shape& aE=tDS.Shape(i); + aType=aE.ShapeType(); + if (aType!=TopAbs_EDGE) { + continue; + } + // + // block of section edge that we already have for this SE + BOPTools_PaveBlock& aPBSE=aMEPB.ChangeFromKey(aE); + // + // Corresponding FF-interference + iFF=aMapEI.FindFromKey(aE); + BOPTools_SSInterference& aFFi=aFFs(iFF); + BOPTools_SequenceOfCurves& aSCvs=aFFi.Curves(); + // + BOPTools_Curve& aBC=aSCvs(1); + // + const BOPTools_ListOfPaveBlock& aLPB=aSSP(tDS.RefEdge(i)); + aNbPB=aLPB.Extent(); + // + if (!aNbPB) { + // no pave blocks -> use aPBSE and whole edge aE + BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq; + // + nV1=aPBSE.Pave1().Index(); + const TopoDS_Shape& aV1=myDS->Shape(nV1); + nV2=aPBSE.Pave2().Index(); + const TopoDS_Shape& aV2=myDS->Shape(nV2); + // + anASSeq.SetNewSuccessor(nV1); + anASSeq.SetNewOrientation(aV1.Orientation()); + anASSeq.SetNewSuccessor(nV2); + anASSeq.SetNewOrientation(aV2.Orientation()); + // + myDS->InsertShapeAndAncestorsSuccessors(aE, anASSeq); + nE=myDS->NumberOfInsertedShapes(); + // + aPBSE.SetEdge(nE); + aBC.AppendNewBlock(aPBSE); + // + continue; + } + // + nF1=aPBSE.Face1(); + nF2=aPBSE.Face2(); + const TopoDS_Face& aF1=TopoDS::Face(myDS->Shape(nF1)); + const TopoDS_Face& aF2=TopoDS::Face(myDS->Shape(nF2)); + // + const NMTTools_ListOfCommonBlock& aLCB=aCBP(tDS.RefEdge(i)); + NMTTools_CommonBlockAPI aCBAPI(aLCB); + // + aIt.Initialize(aLPB); + for (; aIt.More(); aIt.Next()) { + BOPTools_PaveBlock aPB=aIt.Value(); + // + if (aCBAPI.IsCommonBlock(aPB)) { + // it can be Common Block + Standard_Boolean bHasPCOnF, bFound; + Standard_Integer nF, k, nEOrx, nF1x, nF2x; + Standard_Real aTolEx, aT1x, aT2x; + BOPTools_ListIteratorOfListOfPaveBlock aItPBx; + // + NMTTools_CommonBlock& aCB=aCBAPI.CommonBlock(aPB); + const BOPTools_ListOfPaveBlock& aLPBx=aCB.PaveBlocks(); + // + aPB=aCB.PaveBlock1(); + mE=aPB.Edge(); // index of edge in tDS + const TopoDS_Edge& aEx=TopoDS::Edge(tDS.Shape(mE)); + aTolEx=BRep_Tool::Tolerance(aEx); + // + for (k=0; k<2; ++k) { + nF=(!k) ? nF1 : nF2; + const TopoDS_Face& aF=TopoDS::Face(myDS->Shape(nF)); + // + bHasPCOnF=BOPTools_Tools2D::HasCurveOnSurface(aEx, aF); + if (bHasPCOnF) { + continue; + } + // + bFound=Standard_False; + aItPBx.Initialize(aLPBx); + for (; aItPBx.More(); aItPBx.Next()) { + BOPTools_PaveBlock& aPBx=aIt.Value(); + nEOrx=aPBx.OriginalEdge(); + const TopoDS_Shape& aEOrx=tDS.Shape(nEOrx); + BOPTools_PaveBlock& aPBSEx=aMEPB.ChangeFromKey(aEOrx); + aT1x=aPBSEx.Pave1().Param(); + aT2x=aPBSEx.Pave2().Param(); + const IntTools_Curve& aICx=aPBSEx.Curve(); + // + nF1x=aPBSEx.Face1(); + nF2x=aPBSEx.Face2(); + // + if (nF1x==nF) { + Handle(Geom2d_Curve) aC2D1x=aICx.FirstCurve2d(); + Handle(Geom2d_TrimmedCurve)aC2D1xT =new Geom2d_TrimmedCurve(aC2D1x, aT1x, aT2x); + aBB.UpdateEdge(aEx, aC2D1xT, aF, aTolEx); + bFound=!bFound; + break; + } + // + if (nF2x==nF) { + Handle(Geom2d_Curve) aC2D2x=aICx.SecondCurve2d(); + Handle(Geom2d_TrimmedCurve)aC2D2xT =new Geom2d_TrimmedCurve(aC2D2x, aT1x, aT2x); + aBB.UpdateEdge(aEx, aC2D2xT, aF, aTolEx); + bFound=!bFound; + break; + } + } + if (bFound){ + BRepLib::SameParameter(aEx, aTolEx, Standard_True); + } + } + } //if (aCBAPI.IsCommonBlock(aPB)) + // + // new SE + mE=aPB.Edge(); // index of edge in tDS + const TopoDS_Shape& aSp=tDS.Shape(mE); + // + const BOPTools_Pave& aPave1=aPB.Pave1(); + aT1=aPave1.Param(); + mV1=aPave1.Index(); // index in tDS + nV1=aMNewOld.FindFromKey(mV1); // index in myDS + const TopoDS_Shape& aV1=myDS->Shape(nV1); + // + const BOPTools_Pave& aPave2=aPB.Pave2(); + aT2=aPave2.Param(); + mV2=aPave2.Index(); + nV2=aMNewOld.FindFromKey(mV2); + const TopoDS_Shape& aV2=myDS->Shape(nV2); + // + if (!aMNewOld.Contains(mE)) { + // add new SE to the myDS + BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq; + // + anASSeq.SetNewSuccessor(nV1); + anASSeq.SetNewOrientation(aV1.Orientation()); + + anASSeq.SetNewSuccessor(nV2); + anASSeq.SetNewOrientation(aV2.Orientation()); + + myDS->InsertShapeAndAncestorsSuccessors(aSp, anASSeq); + nE=myDS->NumberOfInsertedShapes(); + // + aMNewOld.Add(mE, nE); + } + else { + nE=aMNewOld.FindFromKey(mE); + } + // Form PaveBlock; + BOPTools_PaveBlock aPBx; + BOPTools_Pave aP1, aP2; + // + aPBx.SetFace1(nF1); + aPBx.SetFace1(nF2); + // + aP1.SetIndex(nV1); + aP1.SetParam(aT1); + // + aP2.SetIndex(nV2); + aP2.SetParam(aT2); + // + aPBx.SetPave1(aP1); + aPBx.SetPave2(aP2); + // + aPBx.SetEdge(nE); + // + aBC.AppendNewBlock(aPBx); + }// for (; aIt.More(); aIt.Next()) + }// for (i=1; i<=aNbOld; ++i) + // + myIsDone=Standard_True; +} +//======================================================================= +// function: MakePCurves +// purpose: +//======================================================================= + void NMTTools_PaveFiller::MakePCurves() +{ + Standard_Integer i, aNb, nF1, nF2, nE; + TopoDS_Face aF1FWD, aF2FWD; + BOPTools_ListIteratorOfListOfPaveBlock anIt; + // + BOPTools_CArray1OfSSInterference& aFFs=myIntrPool->SSInterferences(); + // + aNb=aFFs.Extent(); + for (i=1; i<=aNb; i++) { + BOPTools_SSInterference& aFF=aFFs(i); + aFF.Indices(nF1, nF2); + // + const TopoDS_Face& aF1=TopoDS::Face(myDS->Shape(nF1)); + const TopoDS_Face& aF2=TopoDS::Face(myDS->Shape(nF2)); + // + aF1FWD=aF1; + aF1FWD.Orientation(TopAbs_FORWARD); + aF2FWD=aF2; + aF2FWD.Orientation(TopAbs_FORWARD); + // + // In, On parts processing + const BOPTools_ListOfPaveBlock& aLPBInOn=aFF.PaveBlocks(); + // + anIt.Initialize(aLPBInOn); + for (; anIt.More(); anIt.Next()) { + const BOPTools_PaveBlock& aPB=anIt.Value(); + nE=aPB.Edge(); + const TopoDS_Edge& aE=TopoDS::Edge(myDS->Shape(nE)); + + BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aE, aF1FWD); + BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aE, aF2FWD); + } + // + // Section Edges processing + /* + Standard_Integer aNbCurves, k, aNbV; + Standard_Real aTolEdge, aTolR2D, aTolFact, aTolV, aTolVmax; + BRep_Builder aBB; + // + BOPTools_SequenceOfCurves& aSC=aFF.Curves(); + aNbCurves=aSC.Length(); + if (!aNbCurves) { + continue; + } + // + const BOPTools_Curve& aBC=aSC(1); + const BOPTools_ListOfPaveBlock& aLPB=aBC.NewPaveBlocks(); + anIt.Initialize(aLPB); + for (; anIt.More(); anIt.Next()) { + const BOPTools_PaveBlock& aPB=anIt.Value(); + nE=aPB.Edge(); + const TopoDS_Edge& aE=TopoDS::Edge(myDS->Shape(nE)); + // + aTolEdge=BRep_Tool::Tolerance(aE); + aTolR2D=aFF.TolR2D(); + aTolFact=Max(aTolEdge, aTolR2D); + // + // Check vertices tolerances and correct them if necessary + // to prevent situation when TolE > TolV + // + TopTools_IndexedMapOfShape aVMap; + TopExp::MapShapes(aE, TopAbs_VERTEX, aVMap); + + aTolVmax=-1.; + aNbV=aVMap.Extent(); + for (k=1; k<=aNbV; ++k) { + const TopoDS_Vertex& aV=TopoDS::Vertex(aVMap(k)); + aTolV=BRep_Tool::Tolerance(aV); + if (aTolV>aTolVmax) { + aTolVmax=aTolV; + } + } + // + if (aTolFact>aTolVmax) { + aTolFact=aTolVmax; + } + // + Standard_Real aTFirst, aTLast, aOutFirst, aOutLast, aOutTol; + Handle(Geom2d_Curve) aC2D1, aC2D1A, aC2D2, aC2D2A; + Handle(Geom_TrimmedCurve)aC3DETrim; + // + const Handle(Geom_Curve)& aC3DE=BRep_Tool::Curve(aE, aTFirst, aTLast); + aC3DETrim=new Geom_TrimmedCurve(aC3DE, aTFirst, aTLast); + // + // first P-Curve + BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aE, aF1FWD); + BOPTools_Tools2D::CurveOnSurface(aE, aF1FWD, aC2D1, aOutFirst, aOutLast, aOutTol, Standard_True); + // + if (aC3DE->IsPeriodic()) { + BOPTools_Tools2D::AdjustPCurveOnFace(aF1FWD, aTFirst, aTLast, aC2D1, aC2D1A); + } + else { + BOPTools_Tools2D::AdjustPCurveOnFace(aF1FWD, aC3DETrim, aC2D1, aC2D1A); + } + // + aBB.UpdateEdge(aE, aC2D1A, aF1FWD, aTolFact); + // + // second P-Curve + BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aE, aF2FWD); + BOPTools_Tools2D::CurveOnSurface(aE, aF2FWD, aC2D2, aOutFirst, aOutLast, aOutTol, Standard_True); + // + if (aC3DE->IsPeriodic()) { + BOPTools_Tools2D::AdjustPCurveOnFace(aF2FWD, aTFirst, aTLast, aC2D2, aC2D2A); + } + else { + BOPTools_Tools2D::AdjustPCurveOnFace(aF2FWD, aC3DETrim, aC2D2, aC2D2A); + } + // + aBB.UpdateEdge(aE, aC2D2A, aF2FWD, aTolFact); + } + */ + } + +} +//======================================================================= +// function: IsExistingPaveBlock +// purpose: +//======================================================================= + Standard_Boolean NMTTools_PaveFiller::IsExistingPaveBlock(const BOPTools_PaveBlock& aPBNew, + const BOPTools_SSInterference& aFFi) +{ + Standard_Boolean bFlag=Standard_False; + Standard_Integer nVNew1, nVNew2, nV1, nV2, iC; + Standard_Real aTolR3D; + BOPTools_ListIteratorOfListOfPaveBlock anIt; + // + aTolR3D=aFFi.TolR3D(); + // + nVNew1=aPBNew.Pave1().Index(); + nVNew2=aPBNew.Pave2().Index(); + // + const BOPTools_ListOfPaveBlock& aLPBR=aFFi.PaveBlocks(); + anIt.Initialize(aLPBR); + for (; anIt.More(); anIt.Next()) { + const BOPTools_PaveBlock& aPBR=anIt.Value(); + nV1=aPBR.Pave1().Index(); + nV2=aPBR.Pave2().Index(); + if (nVNew1==nV1 || nVNew1==nV2 || nVNew2==nV1 || nVNew2==nV2) { + // + iC=CheckIntermediatePoint(aPBNew, aPBR, aTolR3D); + if (!iC) { + return !bFlag; + } + } + } + return bFlag; +} +//======================================================================= +// function: CheckIntermediatePoint +// purpose: +//======================================================================= + Standard_Integer NMTTools_PaveFiller::CheckIntermediatePoint(const BOPTools_PaveBlock& aPB, + const BOPTools_PaveBlock& aPBR, + const Standard_Real aTolC) + +{ + Standard_Real aT11, aT12, aTM, aTmp; + Standard_Integer iVM, nE2; + gp_Pnt aPM; + BRep_Builder aBB; + TopoDS_Vertex aVM; + // + // Vertex + const BOPTools_Pave& aPave11=aPB.Pave1(); + aT11=aPave11.Param(); + // + const BOPTools_Pave& aPave12=aPB.Pave2(); + aT12=aPave12.Param(); + // + aTM=IntTools_Tools::IntermediatePoint (aT11, aT12); + // + const IntTools_Curve& aIC=aPB.Curve(); + aIC.D0(aTM, aPM); + // + aBB.MakeVertex (aVM, aPM, aTolC); + // + //Edge + nE2=aPBR.Edge(); + const TopoDS_Edge& aE2=TopoDS::Edge(myDS->GetShape(nE2)); + // VE + iVM=myContext.ComputeVE(aVM, aE2, aTmp); + // + return iVM; +} +//======================================================================= +// function: PutBoundPaveOnCurve +// purpose: +//======================================================================= + void NMTTools_PaveFiller::PutBoundPaveOnCurve(BOPTools_Curve& aBC, + BOPTools_SSInterference& aFFi) +{ + Standard_Boolean bHasBounds, bVF; + Standard_Integer nF1, nF2; + Standard_Real aT1, aT2, aTolR3D; + gp_Pnt aP1, aP2; + // + const IntTools_Curve& aIC=aBC.Curve(); + bHasBounds=aIC.HasBounds (); + if (!bHasBounds){ + return; + } + // + // Bounds + aIC.Bounds (aT1, aT2, aP1, aP2); + // + // Faces + aFFi.Indices(nF1, nF2); + aTolR3D=aFFi.TolR3D(); + // + const TopoDS_Face& aF1=TopoDS::Face(myDS->GetShape(nF1)); + const TopoDS_Face& aF2=TopoDS::Face(myDS->GetShape(nF2)); + // + bVF=myContext.IsValidPointForFaces (aP1, aF1, aF2, aTolR3D); + if (bVF) { + PutBoundPaveOnCurve (aP1, aT1, aBC, aFFi); + } + // + bVF=myContext.IsValidPointForFaces (aP2, aF1, aF2, aTolR3D); + if (bVF) { + PutBoundPaveOnCurve (aP2, aT2, aBC, aFFi); + } +} +//======================================================================= +// function: PutBoundPaveOnCurve +// purpose: +//======================================================================= + void NMTTools_PaveFiller::PutBoundPaveOnCurve(const gp_Pnt& aP, + const Standard_Real aT, + BOPTools_Curve& aBC, + BOPTools_SSInterference& aFFi) +{ + Standard_Boolean bFound1, bFound2; + Standard_Integer nV; + Standard_Real aTolV=aFFi.TolR3D(); + + BOPTools_Pave aPave1, aPave2, aPave; + BOPTools_PaveSet& aCPS=aBC.Set(); + BOPTools_PaveSet& aFFiPS=aFFi.NewPaveSet(); + const IntTools_Curve& aIC=aBC.Curve(); + // + bFound1=FindPave(aP, aTolV, aCPS , aPave1); + bFound2=FindPave(aP, aTolV, aFFiPS, aPave2); + // + if (!bFound1 && !bFound2) { + TopoDS_Vertex aNewVertex; + BOPTools_Tools::MakeNewVertex(aP, aTolV, aNewVertex); + // + BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq; + myDS->InsertShapeAndAncestorsSuccessors(aNewVertex, anASSeq); + nV=myDS->NumberOfInsertedShapes(); + aPave.SetIndex(nV); + aPave.SetParam(aT); + + aCPS.Append(aPave); + aFFiPS.Append(aPave); + // + // Append Techno Vertex to the Curve + TColStd_ListOfInteger& aTVs=aBC.TechnoVertices(); + aTVs.Append(nV); + } + + if (bFound1 && !bFound2) { + nV=aPave1.Index(); + aPave.SetIndex(nV); + aPave.SetParam(aT); + aFFiPS.Append(aPave); + // + const TopoDS_Vertex& aV=TopoDS::Vertex(myDS->Shape(nV)); + BOPTools_Tools::UpdateVertex (aIC, aT, aV); + } + + if (!bFound1 && bFound2) { + nV=aPave2.Index(); + aPave.SetIndex(nV); + aPave.SetParam(aT); + aCPS.Append(aPave); + // + const TopoDS_Vertex& aV=TopoDS::Vertex(myDS->Shape(nV)); + BOPTools_Tools::UpdateVertex (aIC, aT, aV); + } +} +//======================================================================= +// function: FindPave +// purpose: +//======================================================================= + Standard_Boolean NMTTools_PaveFiller::FindPave(const gp_Pnt& aP, + const Standard_Real aTolPV, + const BOPTools_PaveSet& aPS, + BOPTools_Pave& aPave) +{ + Standard_Integer nV; + Standard_Boolean bIsVertex=Standard_False; + + const BOPTools_ListOfPave& aLP=aPS.Set(); + BOPTools_ListIteratorOfListOfPave anIt(aLP); + for (; anIt.More(); anIt.Next()) { + const BOPTools_Pave& aPC=anIt.Value(); + nV=aPC.Index(); + const TopoDS_Vertex& aV=TopoDS::Vertex(myDS->Shape(nV)); + bIsVertex=IntTools_Tools::IsVertex (aP, aTolPV, aV); + if (bIsVertex) { + aPave=aPC; + return bIsVertex; + } + } + return bIsVertex; +} +//======================================================================= +// function: PrepareSetForFace +// purpose: +//======================================================================= + void NMTTools_PaveFiller::PrepareSetForFace(const Standard_Integer nF1, + const Standard_Integer nF2, + BOPTools_PaveSet& aPSF) +{ + Standard_Integer nV1, nV2; + TColStd_MapOfInteger aMap; + BOPTools_ListOfPaveBlock aLPB1, aLPB2; + BOPTools_ListIteratorOfListOfPaveBlock anIt; + // + RealSplitsFace(nF1, aLPB1); + RealSplitsFace(nF2, aLPB2); + // + aLPB1.Append(aLPB2); + // + anIt.Initialize(aLPB1); + for (; anIt.More(); anIt.Next()) { + const BOPTools_PaveBlock& aPB=anIt.Value(); + const BOPTools_Pave& aPave1=aPB.Pave1(); + nV1=aPave1.Index(); + if (!aMap.Contains(nV1)) { + aMap.Add(nV1); + aPSF.Append(aPave1); + } + const BOPTools_Pave& aPave2=aPB.Pave2(); + nV2=aPave2.Index(); + if (!aMap.Contains(nV2)) { + aMap.Add(nV2); + aPSF.Append(aPave2); + } + } +} +//======================================================================= +// function: PutPaveOnCurve +// purpose: +//======================================================================= + void NMTTools_PaveFiller::PutPaveOnCurve(const BOPTools_PaveSet& aPaveSet, + const Standard_Real aTolR3D, + BOPTools_Curve& aBC) +{ + Standard_Integer nV; + Standard_Boolean bIsVertexOnLine; + Standard_Real aT; + BOPTools_ListIteratorOfListOfPave anIt; + Bnd_Box aBBC; + GeomAdaptor_Curve aGAC; + // + const IntTools_Curve& aC=aBC.Curve(); + Handle (Geom_Curve) aC3D= aC.Curve(); + aGAC.Load(aC3D); + BndLib_Add3dCurve::Add(aGAC, aTolR3D, aBBC); + // + const BOPTools_ListOfPave& aLP=aPaveSet.Set(); + anIt.Initialize(aLP); + for (; anIt.More(); anIt.Next()) { + const BOPTools_Pave& aPave=anIt.Value(); + // + nV=aPave.Index(); + const TopoDS_Vertex& aV=TopoDS::Vertex(myDS->Shape(nV)); + // + Bnd_Box aBBV; + BRepBndLib::Add(aV, aBBV); + if (aBBC.IsOut(aBBV)){ + continue; + } + // + bIsVertexOnLine=myContext.IsVertexOnLine(aV, aC, aTolR3D, aT); + // + if (bIsVertexOnLine) { + BOPTools_Pave aPaveNew(nV, aT, BooleanOperations_SurfaceSurface); + BOPTools_PaveSet& aPS=aBC.Set(); + aPS.Append(aPaveNew); + //<-B + BOPTools_Tools::UpdateVertex (aC, aT, aV); + } + } +} +///////////// +//======================================================================= +// function: IsPairFound +// purpose: +//======================================================================= +Standard_Boolean IsPairFound(const Standard_Integer nF1, + const Standard_Integer nF2, + BOPTools_InterferencePool* myIntrPool, + BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMapWhat, + BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMapWith) +{ + Standard_Boolean bIsFound; + // + if (!aMapWhat.Contains(nF1)) { + TColStd_IndexedMapOfInteger aMWhat; + FMapWhat(nF1, myIntrPool, aMWhat); + aMapWhat.Add(nF1, aMWhat); + } + // + if (!aMapWith.Contains(nF2)) { + TColStd_IndexedMapOfInteger aMWith; + FMapWith(nF2, myIntrPool, aMWith); + aMapWith.Add(nF2, aMWith); + } + // + const TColStd_IndexedMapOfInteger& aMWht=aMapWhat.FindFromKey(nF1); + const TColStd_IndexedMapOfInteger& aMWit=aMapWith.FindFromKey(nF2); + // + bIsFound=IsFound(aMWht, aMWit); + // + return bIsFound; +} +//======================================================================= +// function: FMapWhat +// purpose: +//======================================================================= +void FMapWhat(const Standard_Integer nF, + BOPTools_InterferencePool* myIntrPool, + TColStd_IndexedMapOfInteger& aMapWhat) + +{ + Standard_Integer nE, nV; + + + + BooleanOperations_ShapesDataStructure* myDS=myIntrPool->DS(); + BooleanOperations_OnceExplorer aExp(*myDS); + // + // What + aMapWhat.Add(nF); + aExp.Init(nF, TopAbs_VERTEX); + for (; aExp.More(); aExp.Next()) { + nV=aExp.Current(); + aMapWhat.Add(nV); + } + // + aExp.Init(nF, TopAbs_EDGE); + for (; aExp.More(); aExp.Next()) { + nE=aExp.Current(); + aMapWhat.Add(nE); + } +} +//======================================================================= +// function: FMapWith +// purpose: +//======================================================================= +void FMapWith(const Standard_Integer nF, + BOPTools_InterferencePool* myIntrPool, + TColStd_IndexedMapOfInteger& aMapWith) +{ + TColStd_IndexedMapOfInteger aMapWhat; + + FMapWhat(nF, myIntrPool, aMapWhat); + // + // With + Standard_Integer i, aNb, anIndex, aWhat, aWith; + BOPTools_ListIteratorOfListOfInterference anIt; + + const BOPTools_CArray1OfInterferenceLine& anArrIL= myIntrPool->InterferenceTable(); + + aNb=aMapWhat.Extent(); + for (i=1; i<=aNb; i++) { + aWhat=aMapWhat(i); + + const BOPTools_InterferenceLine& aWithLine=anArrIL(aWhat); + + const BOPTools_ListOfInterference& aLI=aWithLine.List(); + anIt.Initialize(aLI); + for (; anIt.More(); anIt.Next()) { + const BOPTools_Interference& anIntf=anIt.Value(); + anIndex=anIntf.Index(); + if (anIndex) { + aWith=anIntf.With(); + aMapWith.Add(aWith); + } + } + } +} +//======================================================================= +// function: IsFound +// purpose: +//======================================================================= +Standard_Boolean IsFound(const TColStd_IndexedMapOfInteger& aMapWhat, + const TColStd_IndexedMapOfInteger& aMapWith) +{ + Standard_Boolean bFlag=Standard_False; + Standard_Integer i, aNb, aWhat; + + aNb=aMapWhat.Extent(); + for (i=1; i<=aNb; i++) { + aWhat=aMapWhat(i); + if (aMapWith.Contains(aWhat)) { + return !bFlag; + } + } + return bFlag; +} diff --git a/src/NMTTools/NMTTools_PaveFiller_7.cxx b/src/NMTTools/NMTTools_PaveFiller_7.cxx new file mode 100644 index 000000000..5f8f5fe66 --- /dev/null +++ b/src/NMTTools/NMTTools_PaveFiller_7.cxx @@ -0,0 +1,261 @@ +// File: NMTTools_PaveFiller_7.cxx +// Created: Thu Dec 18 15:14:55 2003 +// Author: Peter KURNEV +// + + +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//======================================================================= +// function: MakeSplitEdges +// purpose: +//======================================================================= + void NMTTools_PaveFiller::MakeSplitEdges() +{ + myIsDone=Standard_False; + // + Standard_Boolean bIsNewVertex1, bIsNewVertex2; + Standard_Integer i, aNbS, nV1, nV2, aNbPaveBlocks, aNewShapeIndex; + Standard_Real t1, t2; + TopAbs_Orientation anOri; + TopoDS_Edge aE, aESplit; + TopoDS_Vertex aV1, aV2; + // + aNbS=myDS->NumberOfShapesOfTheObject(); + for (i=1; i<=aNbS; ++i) { + if (myDS->GetShapeType(i) != TopAbs_EDGE) + continue; + // + // Original Edge + aE=TopoDS::Edge(myDS->Shape(i)); + if (BRep_Tool::Degenerated(aE)){ + continue; + } + // + anOri=aE.Orientation(); + aE.Orientation(TopAbs_FORWARD); + // + // Making Split Edges + // + // Split Set for the Original Edge i + BOPTools_ListOfPaveBlock& aSplitEdges=mySplitShapesPool(myDS->RefEdge(i)); + BOPTools_ListIteratorOfListOfPaveBlock aPBIt(aSplitEdges); + // + aNbPaveBlocks=aSplitEdges.Extent(); + + for (; aPBIt.More(); aPBIt.Next()) { + BOPTools_PaveBlock& aPB=aPBIt.Value(); + // aPave1 + const BOPTools_Pave& aPave1=aPB.Pave1(); + nV1=aPave1.Index(); + t1=aPave1.Param(); + aV1=TopoDS::Vertex(myDS->GetShape(nV1)); + aV1.Orientation(TopAbs_FORWARD); + // aPave2 + const BOPTools_Pave& aPave2=aPB.Pave2(); + nV2=aPave2.Index(); + t2=aPave2.Param(); + aV2=TopoDS::Vertex(myDS->GetShape(nV2)); + aV2.Orientation(TopAbs_REVERSED); + //xx + if (aNbPaveBlocks==1) { + bIsNewVertex1=myDS->IsNewShape (nV1); + bIsNewVertex2=myDS->IsNewShape (nV2); + if (!bIsNewVertex1 && !bIsNewVertex2) { + aPB.SetEdge(i); + continue; + } + } + //xx + BOPTools_Tools::MakeSplitEdge(aE, aV1, t1, aV2, t2, aESplit); + // + // Add Split Part of the Original Edge to the DS + BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq; + + anASSeq.SetNewSuccessor(nV1); + anASSeq.SetNewOrientation(aV1.Orientation()); + + anASSeq.SetNewSuccessor(nV2); + anASSeq.SetNewOrientation(aV2.Orientation()); + // + if (anOri==TopAbs_INTERNAL) { + anASSeq.SetNewAncestor(i); + aESplit.Orientation(anOri); + } + // + myDS->InsertShapeAndAncestorsSuccessors(aESplit, anASSeq); + aNewShapeIndex=myDS->NumberOfInsertedShapes(); + myDS->SetState(aNewShapeIndex, BooleanOperations_UNKNOWN); + // + // Fill Split Set for the Original Edge + aPB.SetEdge(aNewShapeIndex); + // + } + } + myIsDone=Standard_True; +} +//======================================================================= +// function: UpdateCommonBlocks +// purpose: +//======================================================================= + void NMTTools_PaveFiller::UpdateCommonBlocks() +{ + myIsDone=Standard_False; + // + Standard_Integer nE, aNbS, nSp, nEx, nSpx; + NMTTools_ListIteratorOfListOfCommonBlock aCBIt; + BOPTools_ListIteratorOfListOfPaveBlock aPBIt; + // + aNbS=myDS->NumberOfShapesOfTheObject(); + // + for (nE=1; nE<=aNbS; ++nE) { + if (myDS->GetShapeType(nE)!=TopAbs_EDGE){ + continue; + } + if (BRep_Tool::Degenerated(TopoDS::Edge(myDS->Shape(nE)))){ + continue; + } + // + NMTTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nE)); + BOPTools_ListOfPaveBlock& aLPB=mySplitShapesPool (myDS->RefEdge(nE)); + // + aCBIt.Initialize(aLCB); + for (; aCBIt.More(); aCBIt.Next()) { + NMTTools_CommonBlock& aCB=aCBIt.Value(); + BOPTools_PaveBlock& aPB=aCB.PaveBlock1(nE); + nSp=SplitIndex(aPB); + aPB.SetEdge(nSp); + // + const BOPTools_ListOfPaveBlock& aCBLPB=aCB.PaveBlocks(); + aPBIt.Initialize(aCBLPB); + for (; aPBIt.More(); aPBIt.Next()) { + BOPTools_PaveBlock& aPBx=aPBIt.Value(); + nEx=aPBx.OriginalEdge(); + if (nEx==nE) { + continue; + } + // + nSpx=SplitIndex(aPBx); + aPBx.SetEdge(nSpx); + } + // + } + } +} +//======================================================================= +// function: SplitIndex +// purpose: +//======================================================================= + Standard_Integer NMTTools_PaveFiller::SplitIndex(const BOPTools_PaveBlock& aPBx)const +{ + Standard_Integer anOriginalEdge, anEdgeIndex=0; + + anOriginalEdge=aPBx.OriginalEdge(); + + const BOPTools_ListOfPaveBlock& aLPB=mySplitShapesPool(myDS->RefEdge(anOriginalEdge)); + // + BOPTools_ListIteratorOfListOfPaveBlock anIt(aLPB); + for (; anIt.More(); anIt.Next()) { + BOPTools_PaveBlock& aPB=anIt.Value(); + if (aPB.IsEqual(aPBx)) { + anEdgeIndex=aPB.Edge(); + return anEdgeIndex; + } + } + return anEdgeIndex; +} +//======================================================================= +// function: UpdatePaveBlocks +// purpose: +//======================================================================= + void NMTTools_PaveFiller::UpdatePaveBlocks() +{ + myIsDone=Standard_False; + // + + Standard_Integer i, aNbFFs, nF1, nF2, aNbF, nF, iRankF, nE, nV1, nV2, aNbPB; + Standard_Real aT1, aT2; + TColStd_IndexedMapOfInteger aMF, aME; + TopExp_Explorer aExp; + TopoDS_Vertex aV1, aV2; + TopoDS_Edge aE; + BOPTools_Pave aPave1, aPave2; + BOPTools_PaveBlock aPB; + // + BOPTools_CArray1OfSSInterference& aFFs=myIntrPool->SSInterferences(); + // + aNbFFs=aFFs.Extent(); + for (i=1; i<=aNbFFs; ++i) { + BOPTools_SSInterference& aFFi=aFFs(i); + aFFi.Indices(nF1, nF2); + aMF.Add(nF1); + aMF.Add(nF2); + } + // + aNbF=aMF.Extent(); + for(i=1; i<=aNbF; ++i) { + nF=aMF(i); + iRankF=myDS->Rank(nF); + const TopoDS_Shape& aF=myDS->Shape(nF); + aExp.Init(aF, TopAbs_EDGE); + for(; aExp.More(); aExp.Next()) { + aE=TopoDS::Edge(aExp.Current()); + // + if (BRep_Tool::Degenerated(aE)) { + continue; + } + // + nE=myDS->ShapeIndex(aE, iRankF); + // + if (aME.Contains(nE)) { + continue; + } + aME.Add(nE); + // + BOPTools_ListOfPaveBlock& aLPB=mySplitShapesPool(myDS->RefEdge(nE)); + aNbPB=aLPB.Extent(); + if (aNbPB) { + continue; + } + TopExp::Vertices(aE, aV1, aV2); + // + nV1=myDS->ShapeIndex(aV1, iRankF); + aT1=BRep_Tool::Parameter(aV1, aE); + aPave1.SetIndex(nV1); + aPave1.SetParam(aT1); + // + nV2=myDS->ShapeIndex(aV2, iRankF); + aT2=BRep_Tool::Parameter(aV2, aE); + aPave2.SetIndex(nV2); + aPave2.SetParam(aT2); + // + aPB.SetEdge(nE); + aPB.SetOriginalEdge(nE); + aPB.SetPave1(aPave1); + aPB.SetPave2(aPave2); + // + aLPB.Append(aPB); + } + } +} diff --git a/src/NMTTools/NMTTools_PaveFiller_8.cxx b/src/NMTTools/NMTTools_PaveFiller_8.cxx new file mode 100644 index 000000000..174c52379 --- /dev/null +++ b/src/NMTTools/NMTTools_PaveFiller_8.cxx @@ -0,0 +1,595 @@ +// File: NMTTools_PaveFiller_8.cxx +// Created: Fri Dec 19 11:15:53 2003 +// Author: Peter KURNEV +// + + +#include + +#include +#include + +#include +#include + +#include +#include +#include + +#include + +#include +#include +#include +#include + +//======================================================================= +// function: RealPaveBlock +// purpose: +//======================================================================= + const BOPTools_PaveBlock& NMTTools_PaveFiller::RealPaveBlock(const BOPTools_PaveBlock& aPB) +{ + Standard_Integer nE; + // + nE=aPB.OriginalEdge(); + const NMTTools_ListOfCommonBlock& aLCBE=myCommonBlockPool(myDS->RefEdge(nE)); + NMTTools_CommonBlockAPI aCBAPI(aLCBE); + if (aCBAPI.IsCommonBlock(aPB)) { + NMTTools_CommonBlock& aCB=aCBAPI.CommonBlock(aPB); + const BOPTools_PaveBlock& aPBx=aCB.PaveBlock1(); + return aPBx; + } + return aPB; +} +//======================================================================= +// function: CommonBlocksFace +// purpose: +//======================================================================= + Standard_Integer NMTTools_PaveFiller::CommonBlocksFace(const Standard_Integer nF, + NMTTools_ListOfCommonBlock& aLCB) +{ + Standard_Integer nE; + TopAbs_ShapeEnum aT; + NMTTools_ListIteratorOfListOfCommonBlock anIt; + // + aT=myDS->GetShapeType(nF); + // + if (aT!=TopAbs_FACE) { + return 1; // Type mismatch + } + // + BooleanOperations_ShapesDataStructure *pDS=myDS; + BooleanOperations_OnceExplorer aExp(*pDS); + // + aExp.Init(nF, TopAbs_EDGE); + for (; aExp.More(); aExp.Next()) { + nE=aExp.Current(); + const NMTTools_ListOfCommonBlock& aLCBE=myCommonBlockPool(myDS->RefEdge(nE)); + anIt.Initialize(aLCBE); + for (; anIt.More(); anIt.Next()) { + const NMTTools_CommonBlock& aCBE=anIt.Value(); + aLCB.Append(aCBE); + } + } + return 0; //Ok +} +// +// 1 RealSplits +// +// +//======================================================================= +// function: RealSplitsFace +// purpose: +//======================================================================= + void NMTTools_PaveFiller::RealSplitsFace(const Standard_Integer nF, + BOPTools_ListOfPaveBlock& aLPB) +{ + Standard_Integer nE; + BOPTools_ListIteratorOfListOfPaveBlock anIt; + // + BooleanOperations_ShapesDataStructure *pDS=myDS; + BooleanOperations_OnceExplorer aExp(*pDS); + // + aExp.Init(nF, TopAbs_EDGE); + for (; aExp.More(); aExp.Next()) { + nE=aExp.Current(); + const BOPTools_ListOfPaveBlock& aLPBE=mySplitShapesPool(myDS->RefEdge(nE)); + anIt.Initialize(aLPBE); + for (; anIt.More(); anIt.Next()) { + const BOPTools_PaveBlock& aPB=anIt.Value(); + const BOPTools_PaveBlock& aPBR=RealPaveBlock(aPB); + aLPB.Append(aPBR); + } + } +} +//======================================================================= +// function: HasRealSplitsInOnFace +// purpose: +//======================================================================= + Standard_Boolean NMTTools_PaveFiller::HasRealSplitsInOnFace(const Standard_Integer nF1, + const Standard_Integer nF2) +{ + Standard_Boolean bFlag; + BOPTools_ListOfPaveBlock aLPB; + // + RealSplitsInFace(0, nF1, nF2, aLPB); + // + bFlag=!aLPB.IsEmpty(); + if (bFlag) { + return bFlag; + } + // + RealSplitsInFace(0, nF1, nF2, aLPB); + // + bFlag=!aLPB.IsEmpty(); + return bFlag; +} +//======================================================================= +// function: RealSplitsInFace +// purpose: +//======================================================================= + void NMTTools_PaveFiller::RealSplitsInFace(const Standard_Integer ,//for overriding + const Standard_Integer nF1, + const Standard_Integer nF2, + BOPTools_ListOfPaveBlock& aLPB) +{ + Standard_Integer nE1; + // + BooleanOperations_ShapesDataStructure *pDS=myDS; + BooleanOperations_OnceExplorer aExp(*pDS); + aExp.Init(nF1, TopAbs_EDGE); + for (; aExp.More(); aExp.Next()) { + nE1=aExp.Current(); + RealSplitsInFace (nE1, nF2, aLPB); + } +} +//======================================================================= +// function: RealSplitsInFace +// purpose: +//======================================================================= + void NMTTools_PaveFiller::RealSplitsInFace(const Standard_Integer nE1, + const Standard_Integer nF2, + BOPTools_ListOfPaveBlock& aLPB) +{ + Standard_Integer nF1; + // + TColStd_ListIteratorOfListOfInteger anItLFCB; + NMTTools_ListIteratorOfListOfCommonBlock anItCB; + // + const NMTTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nE1)); + // + anItCB.Initialize(aLCB); + for (; anItCB.More(); anItCB.Next()) { + NMTTools_CommonBlock& aCB=anItCB.Value(); + const BOPTools_PaveBlock& aPB1=aCB.PaveBlock1(nE1); + const BOPTools_PaveBlock& aPB1R=RealPaveBlock(aPB1); + + const TColStd_ListOfInteger& aLFCB=aCB.Faces(); + anItLFCB.Initialize(aLFCB); + for (; anItLFCB.More(); anItLFCB.Next()) { + nF1=anItLFCB.Value(); + if (nF1==nF2) { + aLPB.Append(aPB1R); + } + } + } +} +//======================================================================= +// function: RealSplitsOnEdge +// purpose: +//======================================================================= + void NMTTools_PaveFiller::RealSplitsOnEdge(const Standard_Integer nE1, + const Standard_Integer nE2, + BOPTools_ListOfPaveBlock& aLPB) +{ + Standard_Integer nE; + // + BOPTools_ListIteratorOfListOfPaveBlock anIt; + NMTTools_ListIteratorOfListOfCommonBlock anItCB; + // + const NMTTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nE1)); + + anItCB.Initialize(aLCB); + for (; anItCB.More(); anItCB.Next()) { + NMTTools_CommonBlock& aCB=anItCB.Value(); + const BOPTools_PaveBlock& aPB1=aCB.PaveBlock1(nE1); + const BOPTools_PaveBlock& aPB1R=RealPaveBlock(aPB1); + // + const BOPTools_ListOfPaveBlock& aLPBx=aCB.PaveBlocks(); + anIt.Initialize(aLPBx); + for (; anIt.More(); anIt.Next()) { + const BOPTools_PaveBlock& aPB2=anIt.Value(); + nE=aPB2.OriginalEdge(); + if (nE==nE2) { + aLPB.Append(aPB1R); + } + } + } +} +//======================================================================= +// function: RealSplitsOnFace +// purpose: +//======================================================================= + void NMTTools_PaveFiller::RealSplitsOnFace(const Standard_Integer nE1, + const Standard_Integer nF2, + BOPTools_ListOfPaveBlock& aLPB) +{ + Standard_Integer nE2; + // + BooleanOperations_ShapesDataStructure *pDS=myDS; + BooleanOperations_OnceExplorer aExp(*pDS); + aExp.Init(nF2, TopAbs_EDGE); + for (; aExp.More(); aExp.Next()) { + nE2=aExp.Current(); + RealSplitsOnEdge(nE1, nE2, aLPB); + } +} +//======================================================================= +// function: RealSplitsOnFace +// purpose: +//======================================================================= + void NMTTools_PaveFiller::RealSplitsOnFace(const Standard_Integer ,//for overriding + const Standard_Integer nF1, + const Standard_Integer nF2, + BOPTools_ListOfPaveBlock& aLPB) +{ + Standard_Integer nE1; + // + BooleanOperations_ShapesDataStructure *pDS=myDS; + BooleanOperations_OnceExplorer aExp(*myDS); + aExp.Init(nF1, TopAbs_EDGE); + for (; aExp.More(); aExp.Next()) { + nE1=aExp.Current(); + RealSplitsOnFace(nE1, nF2, aLPB); + } +} + +// 2 SimpleSplits +//======================================================================= +// function: SplitsFace +// purpose: +//======================================================================= + Standard_Integer NMTTools_PaveFiller::SplitsFace(const Standard_Integer nF, + BOPTools_ListOfPaveBlock& aLPB) +{ + Standard_Integer nE; + TopAbs_ShapeEnum aT; + BOPTools_ListIteratorOfListOfPaveBlock anIt; + // + aT=myDS->GetShapeType(nF); + // + if (aT!=TopAbs_FACE) { + return 1; // Type mismatch + } + // + BooleanOperations_ShapesDataStructure *pDS=myDS; + BooleanOperations_OnceExplorer aExp(*pDS); + // + aExp.Init(nF, TopAbs_EDGE); + for (; aExp.More(); aExp.Next()) { + nE=aExp.Current(); + const BOPTools_ListOfPaveBlock& aLPBE=mySplitShapesPool(myDS->RefEdge(nE)); + anIt.Initialize(aLPBE); + for (; anIt.More(); anIt.Next()) { + const BOPTools_PaveBlock& aPBE=anIt.Value(); + aLPB.Append(aPBE); + } + } + return 0; //Ok +} + +//======================================================================= +// function: SplitsInFace +// purpose: splits of edges from nF1 in nF2 +//======================================================================= + Standard_Integer NMTTools_PaveFiller::SplitsInFace(const Standard_Integer ,//for overriding + const Standard_Integer nF1, + const Standard_Integer nF2, + BOPTools_ListOfPaveBlock& aLPB) +{ + Standard_Integer nE1; + TopAbs_ShapeEnum aT1, aT2; + + aT1=myDS->GetShapeType(nF1); + aT2=myDS->GetShapeType(nF2); + + if (aT1!=TopAbs_FACE || aT2!=TopAbs_FACE) { + return 1; // Type mismatch + } + BooleanOperations_ShapesDataStructure *pDS=myDS; + BooleanOperations_OnceExplorer aExp(*pDS); + aExp.Init(nF1, TopAbs_EDGE); + for (; aExp.More(); aExp.Next()) { + nE1=aExp.Current(); + SplitsInFace (nE1, nF2, aLPB); + } + return 0; //Ok +} +//======================================================================= +// function: SplitsInFace +// purpose: splits of edge nE1 in aFace2 +//======================================================================= + Standard_Integer NMTTools_PaveFiller::SplitsInFace(const Standard_Integer nE1, + const Standard_Integer nF2, + BOPTools_ListOfPaveBlock& aLPB) +{ + Standard_Integer nF1; + TopAbs_ShapeEnum aT1, aT2; + + aT1=myDS->GetShapeType(nE1); + aT2=myDS->GetShapeType(nF2); + + if (aT1!=TopAbs_EDGE || aT2!=TopAbs_FACE) { + return 1; // Type mismatch + } + // + TColStd_ListIteratorOfListOfInteger anItLFCB; + NMTTools_ListIteratorOfListOfCommonBlock anItCB; + // + const NMTTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nE1)); + // + anItCB.Initialize(aLCB); + for (; anItCB.More(); anItCB.Next()) { + NMTTools_CommonBlock& aCB=anItCB.Value(); + const BOPTools_PaveBlock& aPB1=aCB.PaveBlock1(nE1); + + const TColStd_ListOfInteger& aLFCB=aCB.Faces(); + anItLFCB.Initialize(aLFCB); + for (; anItLFCB.More(); anItLFCB.Next()) { + nF1=anItLFCB.Value(); + if (nF1==nF2) { + aLPB.Append(aPB1); + } + } + } + return 0; //Ok +} +//======================================================================= +// function: SplitsOnEdge +// purpose: splits of edge nE1 on nE2 +//======================================================================= + Standard_Integer NMTTools_PaveFiller::SplitsOnEdge(const Standard_Integer nE1, + const Standard_Integer nE2, + BOPTools_ListOfPaveBlock& aLPB) +{ + Standard_Integer nE; + TopAbs_ShapeEnum aT1, aT2; + + aT1=myDS->GetShapeType(nE1); + aT2=myDS->GetShapeType(nE2); + + if (aT1!=TopAbs_EDGE || aT2!=TopAbs_EDGE) { + return 1; // Type mismatch + } + // + BOPTools_ListIteratorOfListOfPaveBlock anIt; + NMTTools_ListIteratorOfListOfCommonBlock anItCB; + // + const NMTTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nE1)); + + anItCB.Initialize(aLCB); + for (; anItCB.More(); anItCB.Next()) { + NMTTools_CommonBlock& aCB=anItCB.Value(); + const BOPTools_PaveBlock& aPB1=aCB.PaveBlock1(nE1);//XXX + // + const BOPTools_ListOfPaveBlock& aLPBx=aCB.PaveBlocks(); + anIt.Initialize(aLPBx); + for (; anIt.More(); anIt.Next()) { + const BOPTools_PaveBlock& aPB2=anIt.Value(); + nE=aPB2.OriginalEdge(); + if (nE==nE2) { + aLPB.Append(aPB1); + } + } + } + return 0; //Ok +} +//======================================================================= +// function: SplitsOnFace +// purpose: splits of edge nE1 on face nF2 +//======================================================================= + Standard_Integer NMTTools_PaveFiller::SplitsOnFace(const Standard_Integer nE1, + const Standard_Integer nF2, + BOPTools_ListOfPaveBlock& aLPB) +{ + Standard_Integer nE2, ip; + TopAbs_ShapeEnum aT1, aT2; + + aT1=myDS->GetShapeType(nE1); + aT2=myDS->GetShapeType(nF2); + + if (aT1!=TopAbs_EDGE || aT2!=TopAbs_FACE) { + return 1; // Type mismatch + } + BooleanOperations_ShapesDataStructure *pDS=myDS; + BooleanOperations_OnceExplorer aExp(*pDS); + aExp.Init(nF2, TopAbs_EDGE); + for (; aExp.More(); aExp.Next()) { + nE2=aExp.Current(); + ip=SplitsOnEdge(nE1, nE2, aLPB); + if (ip) { + return ip; + } + } + return 0; //Ok +} +//======================================================================= +// function: SplitsOnFace +// purpose: splits of edges from face nF1 on face nF2 +//======================================================================= + Standard_Integer NMTTools_PaveFiller::SplitsOnFace(const Standard_Integer ,//for overriding + const Standard_Integer nF1, + const Standard_Integer nF2, + BOPTools_ListOfPaveBlock& aLPB) +{ + Standard_Integer nE1, ip; + TopAbs_ShapeEnum aT1, aT2; + + aT1=myDS->GetShapeType(nF1); + aT2=myDS->GetShapeType(nF2); + + if (aT1!=TopAbs_FACE || aT2!=TopAbs_FACE) { + return 1; // Type mismatch + } + BooleanOperations_ShapesDataStructure *pDS=myDS; + BooleanOperations_OnceExplorer aExp(*myDS); + aExp.Init(nF1, TopAbs_EDGE); + for (; aExp.More(); aExp.Next()) { + nE1=aExp.Current(); + ip=SplitsOnFace(nE1, nF2, aLPB); + if (ip) { + return ip; + } + } + return 0; //Ok +} + +// 3 Simple Splits indices +//======================================================================= +// function: SplitsFace +// purpose: +//======================================================================= + Standard_Integer NMTTools_PaveFiller::SplitsFace(const Standard_Integer nF, + TColStd_ListOfInteger& aSplits) +{ + Standard_Integer nE, iErr; + BOPTools_ListIteratorOfListOfPaveBlock aIt; + BOPTools_ListOfPaveBlock aLPB; + // + iErr=SplitsFace(nF, aLPB); + if (iErr) { + return iErr; + } + + aIt.Initialize(aLPB); + for (; aIt.More(); aIt.Next()) { + const BOPTools_PaveBlock& aPB=aIt.Value(); + nE=aPB.Edge(); + aSplits.Append(nE); + } + return 0; //Ok +} + +//======================================================================= +// function: SplitsInFace +// purpose: splits of edges from nF1 in nF2 +//======================================================================= + Standard_Integer NMTTools_PaveFiller::SplitsInFace(const Standard_Integer ,//for overriding + const Standard_Integer nF1, + const Standard_Integer nF2, + TColStd_ListOfInteger& aSplits) +{ + Standard_Integer nE, iErr; + BOPTools_ListIteratorOfListOfPaveBlock aIt; + BOPTools_ListOfPaveBlock aLPB; + // + iErr=SplitsInFace(0, nF1, nF2, aLPB); + if (iErr) { + return iErr; + } + aIt.Initialize(aLPB); + for (; aIt.More(); aIt.Next()) { + const BOPTools_PaveBlock& aPB=aIt.Value(); + nE=aPB.Edge(); + aSplits.Append(nE); + } + return iErr; +} +//======================================================================= +// function: SplitsInFace +// purpose: splits of edge nE1 in aFace2 +//======================================================================= + Standard_Integer NMTTools_PaveFiller::SplitsInFace(const Standard_Integer nE1, + const Standard_Integer nF2, + TColStd_ListOfInteger& aSplits) +{ + Standard_Integer nE, iErr; + BOPTools_ListIteratorOfListOfPaveBlock aIt; + BOPTools_ListOfPaveBlock aLPB; + // + iErr=SplitsInFace(nE1, nF2, aLPB); + if (iErr) { + return iErr; + } + aIt.Initialize(aLPB); + for (; aIt.More(); aIt.Next()) { + const BOPTools_PaveBlock& aPB=aIt.Value(); + nE=aPB.Edge(); + aSplits.Append(nE); + } + return iErr; +} +//======================================================================= +// function: SplitsOnEdge +// purpose: splits of edge nE1 on nE2 +//======================================================================= + Standard_Integer NMTTools_PaveFiller::SplitsOnEdge(const Standard_Integer nE1, + const Standard_Integer nE2, + TColStd_ListOfInteger& aSplits) +{ + Standard_Integer nE, iErr; + BOPTools_ListIteratorOfListOfPaveBlock aIt; + BOPTools_ListOfPaveBlock aLPB; + // + iErr=SplitsOnEdge(nE1, nE2, aLPB); + if (iErr) { + return iErr; + } + aIt.Initialize(aLPB); + for (; aIt.More(); aIt.Next()) { + const BOPTools_PaveBlock& aPB=aIt.Value(); + nE=aPB.Edge(); + aSplits.Append(nE); + } + return iErr; +} +//======================================================================= +// function: SplitsOnFace +// purpose: splits of edge nE1 on face nF2 +//======================================================================= + Standard_Integer NMTTools_PaveFiller::SplitsOnFace(const Standard_Integer nE1, + const Standard_Integer nF2, + TColStd_ListOfInteger& aSplits) +{ + Standard_Integer nE, iErr; + BOPTools_ListIteratorOfListOfPaveBlock aIt; + BOPTools_ListOfPaveBlock aLPB; + // + iErr=SplitsOnEdge(nE1, nF2, aLPB); + if (iErr) { + return iErr; + } + aIt.Initialize(aLPB); + for (; aIt.More(); aIt.Next()) { + const BOPTools_PaveBlock& aPB=aIt.Value(); + nE=aPB.Edge(); + aSplits.Append(nE); + } + return iErr; +} +//======================================================================= +// function: SplitsOnFace +// purpose: splits of edges from face nF1 on face nF2 +//======================================================================= + Standard_Integer NMTTools_PaveFiller::SplitsOnFace(const Standard_Integer ,//for overriding + const Standard_Integer nF1, + const Standard_Integer nF2, + TColStd_ListOfInteger& aSplits) +{ + Standard_Integer nE, iErr; + BOPTools_ListIteratorOfListOfPaveBlock aIt; + BOPTools_ListOfPaveBlock aLPB; + // + iErr=SplitsOnFace(0, nF1, nF2, aLPB); + if (iErr) { + return iErr; + } + + aIt.Initialize(aLPB); + for (; aIt.More(); aIt.Next()) { + const BOPTools_PaveBlock& aPB=aIt.Value(); + nE=aPB.Edge(); + aSplits.Append(nE); + } + return 0; //Ok +} diff --git a/src/NMTTools/NMTTools_PaveFiller_9.cxx b/src/NMTTools/NMTTools_PaveFiller_9.cxx new file mode 100644 index 000000000..2e525fd26 --- /dev/null +++ b/src/NMTTools/NMTTools_PaveFiller_9.cxx @@ -0,0 +1,105 @@ +// File: NMTTools_PaveFiller_9.cxx +// Created: Fri Dec 19 11:15:53 2003 +// Author: Peter KURNEV +// + +#include + +#include + +#include +#include + +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include +#include +#include +#include + +#include + +#include +#include + + +//======================================================================= +// function: PrepareFace +// purpose: +//======================================================================= + void NMTTools_PaveFiller::PrepareFace(const Standard_Integer nF, + TopoDS_Face& newFace) +{ + Standard_Boolean bToReverse, bIsDegenerated; + Standard_Integer iRankF, nE, nSp, aNbPB; + Standard_Real aTol; + TopLoc_Location aLoc; + TopoDS_Face aF; + TopoDS_Wire newWire; + TopoDS_Edge aSp; + TopAbs_Orientation anOrF, anOrE; + BRep_Builder aBB; + TopExp_Explorer aExpW, aExpE; + BOPTools_ListIteratorOfListOfPaveBlock aItPB; + // + iRankF=myDS->Rank(nF); + aF=TopoDS::Face(myDS->Shape(nF)); + anOrF=aF.Orientation(); + aF.Orientation(TopAbs_FORWARD); + // + Handle(Geom_Surface) aS=BRep_Tool::Surface(aF, aLoc); + aTol=BRep_Tool::Tolerance(aF); + // + aBB.MakeFace (newFace, aS, aLoc, aTol); + // + aExpW.Init(aF, TopAbs_WIRE); + for (; aExpW.More(); aExpW.Next()) { + const TopoDS_Shape& aW=aExpW.Current(); + aBB.MakeWire(newWire); + // + aExpE.Init(aW, TopAbs_EDGE); + for (; aExpE.More(); aExpE.Next()) { + const TopoDS_Edge& aE=TopoDS::Edge(aExpE.Current()); + bIsDegenerated=BRep_Tool::Degenerated(aE); + anOrE=aE.Orientation(); + // + nE=myDS->ShapeIndex(aE, iRankF); + const BOPTools_ListOfPaveBlock& aLPB=mySplitShapesPool(myDS->RefEdge(nE)); + aNbPB=aLPB.Extent(); + if (!aNbPB) { + aBB.Add(newWire, aE); + continue; + } + // + aItPB.Initialize(aLPB); + for (; aItPB.More(); aItPB.Next()) { + const BOPTools_PaveBlock& aPB=aItPB.Value(); + const BOPTools_PaveBlock& aPBR=RealPaveBlock(aPB); + nSp=aPBR.Edge(); + // + aSp=TopoDS::Edge(myDS->Shape(nSp)); + if (!bIsDegenerated) { + bToReverse=BOPTools_Tools3D::IsSplitToReverse1(aSp, aE, myContext); + if (bToReverse) { + aSp.Reverse(); + } + } + else { + aSp.Orientation(anOrE); + } + aBB.Add(newWire, aSp); + } + } + aBB.Add(newFace, newWire); + } + newFace.Orientation(anOrF); +} diff --git a/src/NMTTools/NMTTools_Tools.cdl b/src/NMTTools/NMTTools_Tools.cdl new file mode 100644 index 000000000..5e6e5cf63 --- /dev/null +++ b/src/NMTTools/NMTTools_Tools.cdl @@ -0,0 +1,72 @@ +-- File: NMTTools_Tools.cdl +-- Created: Mon Dec 8 10:32:34 2003 +-- Author: Peter KURNEV +-- +---Copyright: Matra Datavision 2003 + + +class Tools from NMTTools + + ---Purpose: + +uses + Vertex from TopoDS, + Edge from TopoDS, + Face from TopoDS, + Context from IntTools, + Curve from Geom2d, + + ListOfShape from TopTools, + IndexedDataMapOfIntegerIndexedMapOfInteger from BOPTColStd, + CArray1OfVVInterference from BOPTools, + CArray1OfSSInterference from BOPTools, + ListOfCoupleOfShape from NMTTools, + IndexedDataMapOfShapeIndexedMapOfShape from NMTTools + +--raises + +is + MakeNewVertex (myclass; + aLV : ListOfShape from TopTools; + aNewVertex: out Vertex from TopoDS); + FindChains(myclass; + aVVs:CArray1OfVVInterference from BOPTools; + aMCX: out IndexedDataMapOfIntegerIndexedMapOfInteger from BOPTColStd); + + FindChains(myclass; + aVVs:CArray1OfSSInterference from BOPTools; + aMCX: out IndexedDataMapOfIntegerIndexedMapOfInteger from BOPTColStd); + + FindChains(myclass; + aMCV: IndexedDataMapOfIntegerIndexedMapOfInteger from BOPTColStd; + aMCX: out IndexedDataMapOfIntegerIndexedMapOfInteger from BOPTColStd); + + + IsSplitInOnFace(myclass; + aE : Edge from TopoDS; + aF : Face from TopoDS; + aCtx:out Context from IntTools) + returns Boolean from Standard; + + AreFacesSameDomain(myclass; + aF1 : Face from TopoDS; + aF2 : Face from TopoDS; + aCtx : out Context from IntTools) + returns Boolean from Standard; + + FindChains(myclass; + aLCS:ListOfCoupleOfShape from NMTTools; + aM :out IndexedDataMapOfShapeIndexedMapOfShape from NMTTools); + + FindChains(myclass; + aM1: IndexedDataMapOfShapeIndexedMapOfShape from NMTTools; + aM2:out IndexedDataMapOfShapeIndexedMapOfShape from NMTTools); + + MakePCurve(myclass; + aE : Edge from TopoDS; + aF : Face from TopoDS; + aC2D: Curve from Geom2d; + aTolR2D: Real from Standard); +--fields + +end Tools; diff --git a/src/NMTTools/NMTTools_Tools.cxx b/src/NMTTools/NMTTools_Tools.cxx new file mode 100644 index 000000000..40cc24aab --- /dev/null +++ b/src/NMTTools/NMTTools_Tools.cxx @@ -0,0 +1,550 @@ +// File: NMTTools_Tools.cxx +// Created: Mon Dec 8 10:35:15 2003 +// 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 + +static + void ProcessBlock(const Standard_Integer iV, + const BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMCV, + TColStd_IndexedMapOfInteger& aProcessed, + TColStd_IndexedMapOfInteger& aChain); +static + void ProcessBlock(const TopoDS_Shape& aF, + const NMTTools_IndexedDataMapOfShapeIndexedMapOfShape& aMCV, + TopTools_IndexedMapOfShape& aProcessed, + TopTools_IndexedMapOfShape& aChain); + +//======================================================================= +// function: MakePCurve +// purpose: +//======================================================================= + void NMTTools_Tools::MakePCurve(const TopoDS_Edge& aE, + const TopoDS_Face& aF, + const Handle(Geom2d_Curve)& aC2Dx, + const Standard_Real aTolR2D) +{ + Standard_Integer k, aNbV; + Standard_Real aTolEdge, aTolFact, aTolV, aTolVmax; + Standard_Real aTFirst, aTLast, aOutFirst, aOutLast, aOutTol; + TopoDS_Face aFFWD; + TopTools_IndexedMapOfShape aVMap; + BRep_Builder aBB; + // + aFFWD=aF; + aFFWD.Orientation(TopAbs_FORWARD); + // + aTolEdge=BRep_Tool::Tolerance(aE); + aTolFact=Max(aTolEdge, aTolR2D); + // + TopExp::MapShapes(aE, TopAbs_VERTEX, aVMap); + // + aTolVmax=-1.; + aNbV=aVMap.Extent(); + for (k=1; k<=aNbV; ++k) { + const TopoDS_Vertex& aV=TopoDS::Vertex(aVMap(k)); + aTolV=BRep_Tool::Tolerance(aV); + if (aTolV>aTolVmax) { + aTolVmax=aTolV; + } + } + // + if (aTolFact>aTolVmax) { + aTolFact=aTolVmax; + } + // + const Handle(Geom_Curve)& aC3DE=BRep_Tool::Curve(aE, aTFirst, aTLast); + Handle(Geom_TrimmedCurve)aC3DETrim=new Geom_TrimmedCurve(aC3DE, aTFirst, aTLast); + // + Handle(Geom2d_Curve) aC2D, aC2DA; + // + aC2D=aC2Dx; + if (aC2D.IsNull()) { + BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aE, aFFWD); + BOPTools_Tools2D::CurveOnSurface(aE, aFFWD, aC2D, aOutFirst, aOutLast, aOutTol, Standard_True); + } + if (aC3DE->IsPeriodic()) { + BOPTools_Tools2D::AdjustPCurveOnFace(aFFWD, aTFirst, aTLast, aC2D, aC2DA); + } + else { + BOPTools_Tools2D::AdjustPCurveOnFace(aFFWD, aC3DETrim, aC2D, aC2DA); + } + // + aBB.UpdateEdge(aE, aC2DA, aFFWD, aTolFact); + BRepLib::SameParameter(aE); +} + +//======================================================================= +// function: IsSplitInOnFace +// purpose: +//======================================================================= + Standard_Boolean NMTTools_Tools::IsSplitInOnFace(const TopoDS_Edge& aE, + const TopoDS_Face& aF, + IntTools_Context& aContext) +{ + Standard_Boolean bFlag; + Standard_Real aT, aTolE, aTolF, aTol, aDist, aU, aV; + gp_Pnt aP; + gp_Pnt2d aP2D; + // + aTolE=BRep_Tool::Tolerance(aE); + aTolF=BRep_Tool::Tolerance(aF); + aTol=aTolE+aTolF; + // + GeomAPI_ProjectPointOnSurf& aProjector=aContext.ProjPS(aF); + // + aT=BOPTools_Tools2D::IntermediatePoint(aE); + BOPTools_Tools::PointOnEdge(aE, aT, aP); + // + aProjector.Perform(aP); + bFlag=aProjector.IsDone(); + if (!bFlag) { + return bFlag; + } + // + aDist=aProjector.LowerDistance(); + bFlag=(aDist <= aTol); + if (!bFlag) { + return bFlag; + } + // + aProjector.LowerDistanceParameters(aU, aV); + aP2D.SetCoord(aU, aV); + bFlag=aContext.IsPointInOnFace (aF, aP2D); + return bFlag; +} +//======================================================================= +// function: NMTTools_Tools::MakeNewVertex +// purpose : +//======================================================================= + void NMTTools_Tools::MakeNewVertex(const TopTools_ListOfShape& aLVs, + TopoDS_Vertex& aNewVertex) +{ + Standard_Integer aNb; + Standard_Real aTi, aDi, aDmax=-1.e5; + gp_Pnt aPi, aP; + gp_XYZ aXYZ(0.,0.,0.), aXYZi; + TopTools_ListIteratorOfListOfShape anIt; + // + aNb=aLVs.Extent(); + if (!aNb) { + return; + } + // + anIt.Initialize(aLVs); + for (; anIt.More(); anIt.Next()) { + TopoDS_Vertex aVi=TopoDS::Vertex(anIt.Value()); + aPi=BRep_Tool::Pnt(aVi); + aXYZi=aPi.XYZ(); + aXYZ=aXYZ+aXYZi; + } + // + aXYZ.Divide((Standard_Real)aNb); + aP.SetXYZ(aXYZ); + // + anIt.Initialize(aLVs); + for (; anIt.More(); anIt.Next()) { + TopoDS_Vertex aVi=TopoDS::Vertex(anIt.Value()); + aPi=BRep_Tool::Pnt(aVi); + aTi=BRep_Tool::Tolerance(aVi); + aDi=aP.Distance(aPi); + aDi=aDi+aTi; + if (aDi > aDmax) { + aDmax=aDi; + } + } + BRep_Builder aBB; + aBB.MakeVertex (aNewVertex, aP, aDmax); +} +//======================================================================= +// function: FindChains +// purpose : +//======================================================================= + void NMTTools_Tools::FindChains(const BOPTools_CArray1OfSSInterference& FFs, + BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMapChains) +{ + Standard_Boolean bIsTangentFaces; + Standard_Integer j, aNb, anIndex1, anIndex2; + BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger aMCV; + // + aNb=FFs.Extent(); + for (j=1; j<=aNb; ++j) { + const BOPTools_SSInterference& aFF=FFs(j); + // + bIsTangentFaces=aFF.IsTangentFaces(); + if (!bIsTangentFaces) { + continue; + } + // + aFF.Indices(anIndex1, anIndex2); + // + if (aMCV.Contains(anIndex1)) { + TColStd_IndexedMapOfInteger& aMV=aMCV.ChangeFromKey(anIndex1); + aMV.Add(anIndex1); + aMV.Add(anIndex2); + } + else { + TColStd_IndexedMapOfInteger aMV; + aMV.Add(anIndex1); + aMV.Add(anIndex2); + aMCV.Add(anIndex1, aMV); + } + // + if (aMCV.Contains(anIndex2)) { + TColStd_IndexedMapOfInteger& aMV=aMCV.ChangeFromKey(anIndex2); + aMV.Add(anIndex1); + aMV.Add(anIndex2); + } + else { + TColStd_IndexedMapOfInteger aMV; + aMV.Add(anIndex1); + aMV.Add(anIndex2); + aMCV.Add(anIndex2, aMV); + } + } + NMTTools_Tools::FindChains(aMCV, aMapChains); +} +//======================================================================= +// function: FindChains +// purpose : +//======================================================================= + void NMTTools_Tools::FindChains(const BOPTools_CArray1OfVVInterference& VVs, + BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMapChains) +{ + Standard_Integer j, aNb, anIndex1, anIndex2; + BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger aMCV; + // + aNb=VVs.Extent(); + for (j=1; j<=aNb; ++j) { + const BOPTools_VVInterference& VV=VVs(j); + VV.Indices(anIndex1, anIndex2); + // + if (aMCV.Contains(anIndex1)) { + TColStd_IndexedMapOfInteger& aMV=aMCV.ChangeFromKey(anIndex1); + aMV.Add(anIndex1); + aMV.Add(anIndex2); + } + else { + TColStd_IndexedMapOfInteger aMV; + aMV.Add(anIndex1); + aMV.Add(anIndex2); + aMCV.Add(anIndex1, aMV); + } + // + if (aMCV.Contains(anIndex2)) { + TColStd_IndexedMapOfInteger& aMV=aMCV.ChangeFromKey(anIndex2); + aMV.Add(anIndex1); + aMV.Add(anIndex2); + } + else { + TColStd_IndexedMapOfInteger aMV; + aMV.Add(anIndex1); + aMV.Add(anIndex2); + aMCV.Add(anIndex2, aMV); + } + } + NMTTools_Tools::FindChains(aMCV, aMapChains); +} + +//======================================================================= +// function: FindChains +// purpose : +//======================================================================= + void NMTTools_Tools::FindChains(const BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMCV, + BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMapChains) +{ + Standard_Integer i, j, aNbCV, aNbV, iV, iVx; + TColStd_IndexedMapOfInteger aProcessed, aChain; + // + aNbCV=aMCV.Extent(); + for (i=1; i<=aNbCV; ++i) { + iV=aMCV.FindKey(i); + if (aProcessed.Contains(iV)) { + continue; + } + // + aProcessed.Add(iV); + aChain.Add(iV); + // + const TColStd_IndexedMapOfInteger& aMV=aMCV(i); + aNbV=aMV.Extent(); + for (j=1; j<=aNbV; ++j) { + iVx=aMV(j); + ProcessBlock(iVx, aMCV, aProcessed, aChain); + } + aMapChains.Add(i, aChain); + aChain.Clear(); + } +} +//======================================================================= +// function: ProcessBlock +// purpose: +//======================================================================= +void ProcessBlock(const Standard_Integer iV, + const BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMCV, + TColStd_IndexedMapOfInteger& aProcessed, + TColStd_IndexedMapOfInteger& aChain) +{ + Standard_Integer j, aNbV, iVx; + // + if (aProcessed.Contains(iV)) { + return; + } + aProcessed.Add(iV); + aChain.Add(iV); + // + const TColStd_IndexedMapOfInteger& aMV=aMCV.FindFromKey(iV); + aNbV=aMV.Extent(); + for (j=1; j<=aNbV; ++j) { + iVx=aMV(j); + ProcessBlock(iVx, aMCV, aProcessed, aChain); + } +} +//======================================================================= +// function: AreFacesSameDomain +// purpose : +//======================================================================= + Standard_Boolean NMTTools_Tools::AreFacesSameDomain(const TopoDS_Face& aF1x, + const TopoDS_Face& aF2y, + IntTools_Context& aCtx) +{ + Standard_Boolean bFlag; + Standard_Integer i, aNbE1, aNbE2; + + TopTools_IndexedMapOfShape aME1, aME2; + TopoDS_Edge aEF1, aEF2; + TopoDS_Face aF1, aF2; + // + aF1=aF1x; + aF1.Orientation(TopAbs_FORWARD); + aF2=aF2y; + aF2.Orientation(TopAbs_FORWARD); + // + TopExp::MapShapes(aF1, TopAbs_EDGE, aME1); + TopExp::MapShapes(aF2, TopAbs_EDGE, aME2); + // + bFlag=Standard_False; + // + aNbE1=aME1.Extent(); + aNbE2=aME2.Extent(); + // + if(!aNbE1 || !aNbE2){ + return bFlag; + } + // + if(aNbE1!=aNbE2) { + return bFlag; + } + // + for (i=1; i<=aNbE1; ++i) { + const TopoDS_Edge& aE1=TopoDS::Edge(aME1(i)); + if (BRep_Tool::Degenerated(aE1)) { + // not try to compare deg edges because it + // can not have same TShape on different faces at all + continue; + } + if (!aME2.Contains(aE1)) { + return bFlag; + } + } + // + Standard_Real aTolF1, aTolF2, aTol; + gp_Pnt2d aP2D; + gp_Pnt aP; + TopExp_Explorer anExp; + // + aTolF1=BRep_Tool::Tolerance(aF1); + aTolF2=BRep_Tool::Tolerance(aF2); + aTol=aTolF1+aTolF2; + // + anExp.Init(aF1, TopAbs_EDGE); + for (; anExp.More(); anExp.Next()) { + const TopoDS_Edge& aE1=TopoDS::Edge(anExp.Current()); + if (!BRep_Tool::Degenerated(aE1)) { + BOPTools_Tools3D::PointNearEdge(aE1, aF1, aP2D, aP); + bFlag=aCtx.IsValidPointForFace(aP, aF2, aTol); + break; + } + } + return bFlag; + /* + // + Standard_Real aU1, aU2, aV1, aV2; + Standard_Real dU, dV, aU, aV; + Standard_Integer aNbP=5, aNbP1, j; + gp_Pnt2d aP2D; + gp_Pnt aP; + // + aTolF1=BRep_Tool::Tolerance(aF1); + aTolF2=BRep_Tool::Tolerance(aF2); + aTol=aTolF1+aTolF2; + // + BRepTools::UVBounds(aF1, aU1, aU2, aV1, aV2); + Handle(Geom_Surface) aS1=BRep_Tool::Surface(aF1); + // + aNbP1=aNbP+1; + dU=(aU2-aU1)/aNbP1; + dV=(aV2-aV1)/aNbP1; + // + for (i=1; i<=aNbP; ++i) { + aU=aU1+i*dU; + for (j=1; j<=aNbP; ++j) { + aV=aV1+j*dV; + aP2D.SetCoord(aU, aV); + // + if(aCtx.IsPointInFace(aF1, aP2D)) { + aP=aS1->Value(aU, aV); + bFlag=aCtx.IsValidPointForFace(aP, aF2, aTol); + if (!bFlag) { + return bFlag; + } + } + } + } + */ + // + return bFlag; +} +//======================================================================= +// function: FindChains +// purpose : +//======================================================================= + void NMTTools_Tools::FindChains(const NMTTools_ListOfCoupleOfShape& aLCS, + NMTTools_IndexedDataMapOfShapeIndexedMapOfShape& aMapChains) +{ + NMTTools_ListIteratorOfListOfCoupleOfShape aItCS; + NMTTools_IndexedDataMapOfShapeIndexedMapOfShape aMCV; + // + aItCS.Initialize(aLCS); + for (; aItCS.More(); aItCS.Next()) { + const NMTTools_CoupleOfShape& aCS=aItCS.Value(); + // + const TopoDS_Shape& aF1=aCS.Shape1(); + const TopoDS_Shape& aF2=aCS.Shape2(); + // + // + if (aMCV.Contains(aF1)) { + TopTools_IndexedMapOfShape& aMV=aMCV.ChangeFromKey(aF1); + aMV.Add(aF1); + aMV.Add(aF2); + } + else { + TopTools_IndexedMapOfShape aMV; + aMV.Add(aF1); + aMV.Add(aF2); + aMCV.Add(aF1, aMV); + } + // + if (aMCV.Contains(aF2)) { + TopTools_IndexedMapOfShape& aMV=aMCV.ChangeFromKey(aF2); + aMV.Add(aF1); + aMV.Add(aF2); + } + else { + TopTools_IndexedMapOfShape aMV; + aMV.Add(aF1); + aMV.Add(aF2); + aMCV.Add(aF2, aMV); + } + } + NMTTools_Tools::FindChains(aMCV, aMapChains); +} +//======================================================================= +// function: FindChains +// purpose : +//======================================================================= + void NMTTools_Tools::FindChains(const NMTTools_IndexedDataMapOfShapeIndexedMapOfShape& aMCV, + NMTTools_IndexedDataMapOfShapeIndexedMapOfShape& aMapChains) +{ + Standard_Integer i, j, aNbCV, aNbV; + TopTools_IndexedMapOfShape aProcessed, aChain; + // + aNbCV=aMCV.Extent(); + for (i=1; i<=aNbCV; ++i) { + const TopoDS_Shape& aF=aMCV.FindKey(i); + if (aProcessed.Contains(aF)) { + continue; + } + // + aProcessed.Add(aF); + aChain.Add(aF); + // + const TopTools_IndexedMapOfShape& aMV=aMCV(i); + aNbV=aMV.Extent(); + for (j=1; j<=aNbV; ++j) { + const TopoDS_Shape& aFx=aMV(j); + ProcessBlock(aFx, aMCV, aProcessed, aChain); + } + aMapChains.Add(aF, aChain); + aChain.Clear(); + } +} +//======================================================================= +// function: ProcessBlock +// purpose: +//======================================================================= +void ProcessBlock(const TopoDS_Shape& aF, + const NMTTools_IndexedDataMapOfShapeIndexedMapOfShape& aMCV, + TopTools_IndexedMapOfShape& aProcessed, + TopTools_IndexedMapOfShape& aChain) +{ + Standard_Integer j, aNbV; + // + if (aProcessed.Contains(aF)) { + return; + } + aProcessed.Add(aF); + aChain.Add(aF); + // + const TopTools_IndexedMapOfShape& aMV=aMCV.FindFromKey(aF); + aNbV=aMV.Extent(); + for (j=1; j<=aNbV; ++j) { + const TopoDS_Shape& aFx=aMV(j); + ProcessBlock(aFx, aMCV, aProcessed, aChain); + } +} diff --git a/src/NMTTools/NMTTools_Tools.hxx b/src/NMTTools/NMTTools_Tools.hxx new file mode 100644 index 000000000..73236fe90 --- /dev/null +++ b/src/NMTTools/NMTTools_Tools.hxx @@ -0,0 +1,109 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _NMTTools_Tools_HeaderFile +#define _NMTTools_Tools_HeaderFile + +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +#ifndef _Handle_Geom2d_Curve_HeaderFile +#include +#endif +#ifndef _Standard_Real_HeaderFile +#include +#endif +class TopTools_ListOfShape; +class TopoDS_Vertex; +class BOPTools_CArray1OfVVInterference; +class BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger; +class BOPTools_CArray1OfSSInterference; +class TopoDS_Edge; +class TopoDS_Face; +class IntTools_Context; +class NMTTools_ListOfCoupleOfShape; +class NMTTools_IndexedDataMapOfShapeIndexedMapOfShape; +class Geom2d_Curve; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class NMTTools_Tools { + +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 void MakeNewVertex(const TopTools_ListOfShape& aLV,TopoDS_Vertex& aNewVertex) ; +Standard_EXPORT static void FindChains(const BOPTools_CArray1OfVVInterference& aVVs,BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMCX) ; +Standard_EXPORT static void FindChains(const BOPTools_CArray1OfSSInterference& aVVs,BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMCX) ; +Standard_EXPORT static void FindChains(const BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMCV,BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMCX) ; +Standard_EXPORT static Standard_Boolean IsSplitInOnFace(const TopoDS_Edge& aE,const TopoDS_Face& aF,IntTools_Context& aCtx) ; +Standard_EXPORT static Standard_Boolean AreFacesSameDomain(const TopoDS_Face& aF1,const TopoDS_Face& aF2,IntTools_Context& aCtx) ; +Standard_EXPORT static void FindChains(const NMTTools_ListOfCoupleOfShape& aLCS,NMTTools_IndexedDataMapOfShapeIndexedMapOfShape& aM) ; +Standard_EXPORT static void FindChains(const NMTTools_IndexedDataMapOfShapeIndexedMapOfShape& aM1,NMTTools_IndexedDataMapOfShapeIndexedMapOfShape& aM2) ; +Standard_EXPORT static void MakePCurve(const TopoDS_Edge& aE,const TopoDS_Face& aF,const Handle(Geom2d_Curve)& aC2D,const Standard_Real aTolR2D) ; + + + + + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // + + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/NMTTools/NMTTools_Tools.ixx b/src/NMTTools/NMTTools_Tools.ixx new file mode 100644 index 000000000..80f2f41e7 --- /dev/null +++ b/src/NMTTools/NMTTools_Tools.ixx @@ -0,0 +1,19 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include + + + + diff --git a/src/NMTTools/NMTTools_Tools.jxx b/src/NMTTools/NMTTools_Tools.jxx new file mode 100644 index 000000000..13f814d4e --- /dev/null +++ b/src/NMTTools/NMTTools_Tools.jxx @@ -0,0 +1,36 @@ +#ifndef _TopTools_ListOfShape_HeaderFile +#include +#endif +#ifndef _TopoDS_Vertex_HeaderFile +#include +#endif +#ifndef _BOPTools_CArray1OfVVInterference_HeaderFile +#include +#endif +#ifndef _BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger_HeaderFile +#include +#endif +#ifndef _BOPTools_CArray1OfSSInterference_HeaderFile +#include +#endif +#ifndef _TopoDS_Edge_HeaderFile +#include +#endif +#ifndef _TopoDS_Face_HeaderFile +#include +#endif +#ifndef _IntTools_Context_HeaderFile +#include +#endif +#ifndef _NMTTools_ListOfCoupleOfShape_HeaderFile +#include +#endif +#ifndef _NMTTools_IndexedDataMapOfShapeIndexedMapOfShape_HeaderFile +#include +#endif +#ifndef _Geom2d_Curve_HeaderFile +#include +#endif +#ifndef _NMTTools_Tools_HeaderFile +#include +#endif diff --git a/src/OBJECT/GEOM_AISShape.cxx b/src/OBJECT/GEOM_AISShape.cxx index 81c83d1d3..e847b2175 100644 --- a/src/OBJECT/GEOM_AISShape.cxx +++ b/src/OBJECT/GEOM_AISShape.cxx @@ -39,15 +39,79 @@ using namespace std; // Open CASCADE Includes #include +#include +#include #include #include #include #include +#include +#include +#include +#include #include #include #include +#include +#include +#include +#include +#include +#include + +static void getEntityOwners( const Handle(AIS_InteractiveObject)& theObj, + const Handle(AIS_InteractiveContext)& theIC, + SelectMgr_IndexedMapOfOwner& theMap ) +{ + if ( theObj.IsNull() || theIC.IsNull() ) + return; -#include + TColStd_ListOfInteger modes; + theIC->ActivatedModes( theObj, modes ); + + TColStd_ListIteratorOfListOfInteger itr( modes ); + for (; itr.More(); itr.Next() ) { + int m = itr.Value(); + if ( !theObj->HasSelection( m ) ) + continue; + + Handle(SelectMgr_Selection) sel = theObj->Selection( m ); + + for ( sel->Init(); sel->More(); sel->Next() ) { + Handle(SelectBasics_SensitiveEntity) entity = sel->Sensitive(); + if ( entity.IsNull() ) + continue; + + Handle(SelectMgr_EntityOwner) owner = + Handle(SelectMgr_EntityOwner)::DownCast(entity->OwnerId()); + if ( !owner.IsNull() ) + theMap.Add( owner ); + } + } +} + +static void indicesToOwners( const TColStd_IndexedMapOfInteger& aIndexMap, + const TopoDS_Shape& aMainShape, + const SelectMgr_IndexedMapOfOwner& anAllMap, + SelectMgr_IndexedMapOfOwner& aToHiliteMap ) +{ + TopTools_IndexedMapOfShape aMapOfShapes; + TopExp::MapShapes(aMainShape, aMapOfShapes); + + for ( Standard_Integer i = 1, n = anAllMap.Extent(); i <= n; i++ ) { + Handle(SelectMgr_EntityOwner) anOwner = anAllMap( i ); + if ( anOwner.IsNull() || !anOwner->HasShape() ) + continue; + + const TopoDS_Shape& aSubShape = anOwner->Shape(); + Standard_Integer aSubShapeId = aMapOfShapes.FindIndex( aSubShape ); + if ( !aSubShapeId || !aIndexMap.Contains( aSubShapeId ) ) + continue; + + if ( !aToHiliteMap.Contains( anOwner ) ) + aToHiliteMap.Add( anOwner ); + } +} GEOM_AISShape::GEOM_AISShape(const TopoDS_Shape& shape, const Standard_CString aName): SALOME_AISShape(shape) @@ -68,7 +132,7 @@ Handle(SALOME_InteractiveObject) GEOM_AISShape::getIO(){ } Standard_Boolean GEOM_AISShape::hasIO(){ - return !( myIO == NULL ) ; + return !myIO.IsNull(); } void GEOM_AISShape::setName(const Standard_CString aName) @@ -153,3 +217,34 @@ void GEOM_AISShape::SetShadingColor(const Quantity_Color &aCol) { myShadingColor = aCol; } + +void GEOM_AISShape::highlightSubShapes(const TColStd_IndexedMapOfInteger& aIndexMap, + const Standard_Boolean aHighlight ) +{ + Handle(AIS_InteractiveObject) anObj = this; + Handle(AIS_InteractiveContext) anIC = GetContext(); + if ( anIC.IsNull() || !anIC->HasOpenedContext() ) + return; + + Standard_Boolean isAutoHilight = anIC->AutomaticHilight(); + anIC->SetAutomaticHilight( false ); + + anIC->ClearSelected( false ); + + if ( aHighlight ) { + SelectMgr_IndexedMapOfOwner anAllMap, aToHiliteMap; + + // Get entity owners for all activated selection modes + getEntityOwners( anObj, anIC, anAllMap ); + + // Convert into the map of owners to highlight/unhighlight + indicesToOwners( aIndexMap, Shape(), anAllMap, aToHiliteMap ); + + + for ( Standard_Integer i = 1, n = aToHiliteMap.Extent(); i <= n; i++ ) + anIC->AddOrRemoveSelected( aToHiliteMap( i ), false ); + } + + anIC->SetAutomaticHilight( isAutoHilight ); + anIC->HilightSelected( false ); +} diff --git a/src/OBJECT/GEOM_AISShape.hxx b/src/OBJECT/GEOM_AISShape.hxx index d809c0dbb..617c6f9be 100644 --- a/src/OBJECT/GEOM_AISShape.hxx +++ b/src/OBJECT/GEOM_AISShape.hxx @@ -87,6 +87,7 @@ Standard_EXPORT void setIO(const Handle(SALOME_InteractiveObject)& name) ; Standard_EXPORT void setName(const Standard_CString aName) ; Standard_EXPORT Standard_CString getName() ; Standard_EXPORT Handle_SALOME_InteractiveObject getIO() ; +Standard_EXPORT void highlightSubShapes(const TColStd_IndexedMapOfInteger& aIndexMap, const Standard_Boolean aHighlight ); Standard_EXPORT ~GEOM_AISShape(); Standard_EXPORT void SetTransparency(const Standard_Real aValue); diff --git a/src/OBJECT/GEOM_AISShape.jxx b/src/OBJECT/GEOM_AISShape.jxx index c3d2a67e9..8f66299fd 100644 --- a/src/OBJECT/GEOM_AISShape.jxx +++ b/src/OBJECT/GEOM_AISShape.jxx @@ -38,4 +38,4 @@ #endif #ifndef _Prs3d_Presentation_HeaderFile #include -#endif +#endif \ No newline at end of file diff --git a/src/OBJECT/GEOM_AISTrihedron.cxx b/src/OBJECT/GEOM_AISTrihedron.cxx new file mode 100755 index 000000000..5ca66f7fa --- /dev/null +++ b/src/OBJECT/GEOM_AISTrihedron.cxx @@ -0,0 +1,72 @@ +// GEOM_AISTrihedron : Filter for VTK viewer +// +// 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 : GEOM_AISTrihedron.cxx +// Author : Sergey LITONIN +// Module : SALOME + +#include "GEOM_AISTrihedron.hxx" +#include + +IMPLEMENT_STANDARD_HANDLE(GEOM_AISTrihedron, AIS_Trihedron) +IMPLEMENT_STANDARD_RTTIEXT(GEOM_AISTrihedron, AIS_Trihedron) + +/* + Class : GEOM_AISTrihedron + Description : Interactive object for displaying local CS +*/ + +GEOM_AISTrihedron::GEOM_AISTrihedron( const Handle(Geom_Axis2Placement)& thePlc ) +: AIS_Trihedron( thePlc ) +{ + +} +Handle(SALOME_InteractiveObject) GEOM_AISTrihedron::getIO() +{ + return myObject; +} +Standard_Boolean GEOM_AISTrihedron::hasIO() +{ + return !myObject.IsNull(); +} + +Standard_CString GEOM_AISTrihedron::getName() +{ + return myName.ToCString(); +} +void GEOM_AISTrihedron::setName( Standard_CString aName ) +{ + myName = TCollection_AsciiString( aName ); +} + +void GEOM_AISTrihedron::setIO( const Handle(SALOME_InteractiveObject)& theIO ) +{ + myObject = theIO; +} + + + + + + + \ No newline at end of file diff --git a/src/OBJECT/GEOM_AISTrihedron.hxx b/src/OBJECT/GEOM_AISTrihedron.hxx new file mode 100755 index 000000000..bd38a7067 --- /dev/null +++ b/src/OBJECT/GEOM_AISTrihedron.hxx @@ -0,0 +1,81 @@ +// GEOM_AISTrihedron : Filter for VTK viewer +// +// 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 : GEOM_AISTrihedron.hxx +// Author : Sergey LITONIN +// Module : SALOME + +#ifndef GEOM_AISTrihedron_HeaderFile +#define GEOM_AISTrihedron_HeaderFile + +#include + +#include +#include +#include + +class Handle(Geom_Axis2Placement); + +DEFINE_STANDARD_HANDLE(GEOM_AISTrihedron, AIS_Trihedron) + +/* + Class : GEOM_AISTrihedron + Description : Interactive object for displaying local CS +*/ + +class GEOM_AISTrihedron : public AIS_Trihedron +{ +public: + + Standard_EXPORT GEOM_AISTrihedron( const Handle(Geom_Axis2Placement)& ); + + Standard_EXPORT Handle(SALOME_InteractiveObject) getIO(); + Standard_EXPORT void setIO( const Handle(SALOME_InteractiveObject)& ); + Standard_EXPORT Standard_Boolean hasIO(); + Standard_EXPORT Standard_CString getName(); + Standard_EXPORT void setName( Standard_CString aName ); + +private: + + TCollection_AsciiString myName; + Handle(SALOME_InteractiveObject) myObject; + +public: + DEFINE_STANDARD_RTTI(GEOM_AISTrihedron) +}; + +#endif + + + + + + + + + + + + + + diff --git a/src/OBJECT/GEOM_Actor.cxx b/src/OBJECT/GEOM_Actor.cxx index dde683ac8..0ebbf32f4 100644 --- a/src/OBJECT/GEOM_Actor.cxx +++ b/src/OBJECT/GEOM_Actor.cxx @@ -26,7 +26,6 @@ // Module : GEOM // $Header$ -using namespace std; /*! \class GEOM_Actor GEOM_Actor.h \brief This class allows to display an OpenCASCADE CAD model in a VTK viewer. @@ -34,10 +33,24 @@ using namespace std; #include "GEOM_Actor.h" +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + // OpenCASCADE Includes #include "GEOM_OCCReader.h" #include +using namespace std; + //------------------------------------------------------------- // Main methods //------------------------------------------------------------- @@ -73,7 +86,7 @@ GEOM_Actor::GEOM_Actor() this->myName = ""; this->HighlightProperty = NULL; - this->ishighlighted = false; + this->myIsHighlighted = false; this->subshape = false; this->myIsInfinite = false; @@ -221,8 +234,8 @@ void GEOM_Actor::Render(vtkRenderer *ren, vtkMapper *Mapper) this->Property->SetSpecularColor(0.99,0.98,0.83); } - if(!ishighlighted) { - if ( ispreselected ) + if(!myIsHighlighted) { + if ( myIsPreselected ) this->Property = PreviewProperty; else if(myDisplayMode >= 1) { // SHADING @@ -314,20 +327,20 @@ void GEOM_Actor::SetColor(float r,float g,float b) { void GEOM_Actor::GetColor(float& r,float& g,float& b) { float color[3]; - ShadingProperty->GetColor(color); - r = color[0]; - g = color[1]; - b = color[2]; + ShadingProperty->GetColor(color); + r = color[0]; + g = color[1]; + b = color[2]; } //------------------------------------------------------------- // Highlight methods //------------------------------------------------------------- -void GEOM_Actor::highlight(Standard_Boolean highlight) { +void GEOM_Actor::highlight(bool highlight) { - if(highlight && !ishighlighted) { - ishighlighted=true; + if(highlight && !myIsHighlighted) { + myIsHighlighted=true; // build highlight property is necessary if(HighlightProperty==NULL) { HighlightProperty = vtkProperty::New(); @@ -344,8 +357,8 @@ void GEOM_Actor::highlight(Standard_Boolean highlight) { } else if (!highlight) { - if(ishighlighted) { - ishighlighted=false; + if(myIsHighlighted) { + myIsHighlighted=false; if(myDisplayMode==1) { //unhilight in shading this->Property = ShadingProperty; @@ -358,11 +371,6 @@ void GEOM_Actor::highlight(Standard_Boolean highlight) { } } -bool GEOM_Actor::hasHighlight() -{ - return true; -} - void GEOM_Actor::SetHighlightProperty(vtkProperty* Prop) { this->HighlightProperty = Prop; } diff --git a/src/OBJECT/GEOM_Actor.h b/src/OBJECT/GEOM_Actor.h index cc6295159..ebd49b780 100644 --- a/src/OBJECT/GEOM_Actor.h +++ b/src/OBJECT/GEOM_Actor.h @@ -35,7 +35,7 @@ #include #include - +class vtkCamera; class TopoDS_Shape; #ifdef _WIN_32 @@ -43,9 +43,8 @@ class TopoDS_Shape; #else #define VTKOCC_EXPORT #endif -class VTKOCC_EXPORT GEOM_Actor : public SALOME_Actor { - +class VTKOCC_EXPORT GEOM_Actor : public SALOME_Actor { public: vtkTypeMacro(GEOM_Actor,SALOME_Actor); @@ -73,11 +72,11 @@ class VTKOCC_EXPORT GEOM_Actor : public SALOME_Actor { void SubShapeOff(); // Display Mode - void setDisplayMode(int); + virtual void setDisplayMode(int); // Highlight - void highlight(Standard_Boolean highlight); - bool hasHighlight(); + virtual void highlight(bool theHighlight); + virtual bool hasHighlight() { return true; } void ShallowCopy(vtkProp *prop); @@ -122,6 +121,8 @@ class VTKOCC_EXPORT GEOM_Actor : public SALOME_Actor { vtkProperty* ShadingProperty; vtkProperty* WireframeProperty; vtkProperty* HighlightProperty; - }; + + #endif //GEOM_ACTOR_H + diff --git a/src/OBJECT/GEOM_InteractiveObject.cxx b/src/OBJECT/GEOM_InteractiveObject.cxx index 892cd143c..00c179a21 100644 --- a/src/OBJECT/GEOM_InteractiveObject.cxx +++ b/src/OBJECT/GEOM_InteractiveObject.cxx @@ -41,34 +41,33 @@ GEOM_InteractiveObject::GEOM_InteractiveObject() myFatherIOR = ""; } -GEOM_InteractiveObject::GEOM_InteractiveObject(const Standard_CString anIOR, - const Standard_CString aFatherIOR, - const Standard_CString aComponentDataType, - const Standard_CString anEntry) +GEOM_InteractiveObject::GEOM_InteractiveObject(const char* anIOR, + const char* aFatherIOR, + const char* aComponentDataType, + const char* anEntry) : SALOME_InteractiveObject(anEntry,aComponentDataType) { - myIOR = new char [strlen(anIOR)+1]; - strcpy( myIOR, anIOR); - myFatherIOR = new char [strlen(aFatherIOR)+1]; - strcpy( myFatherIOR, aFatherIOR); + myIOR = anIOR; + myFatherIOR = aFatherIOR; } -Standard_CString GEOM_InteractiveObject::getIOR(){ - return myIOR; +const char* GEOM_InteractiveObject::getIOR(){ + return myIOR.c_str(); } -Standard_CString GEOM_InteractiveObject::getFatherIOR(){ - return myFatherIOR; + +const char* GEOM_InteractiveObject::getFatherIOR(){ + return myFatherIOR.c_str(); } Standard_Boolean GEOM_InteractiveObject::isSame(const Handle(SALOME_InteractiveObject)& anIO ){ if ( anIO->hasEntry() && this->hasEntry() ) { - if ( strcmp(myEntry, anIO->getEntry() ) == 0 ) + if ( myEntry == anIO->getEntry() ) return Standard_True; } if ( anIO->IsKind(STANDARD_TYPE(GEOM_InteractiveObject))) { Handle(GEOM_InteractiveObject) theIO = Handle(GEOM_InteractiveObject)::DownCast( anIO ); - if ( strcmp(myIOR, theIO->getIOR() ) == 0 ) + if ( myIOR == theIO->getIOR() ) return Standard_True; } diff --git a/src/OBJECT/GEOM_InteractiveObject.hxx b/src/OBJECT/GEOM_InteractiveObject.hxx index a14c40783..93911dfe0 100644 --- a/src/OBJECT/GEOM_InteractiveObject.hxx +++ b/src/OBJECT/GEOM_InteractiveObject.hxx @@ -72,14 +72,14 @@ public: // Methods PUBLIC // Standard_EXPORT GEOM_InteractiveObject(); -Standard_EXPORT GEOM_InteractiveObject(const Standard_CString anIOR, - const Standard_CString aFatherIOR, - const Standard_CString aComponentDataType, - const Standard_CString anEntry = ""); -Standard_EXPORT void setIOR(const Standard_CString anEntry) ; -Standard_EXPORT Standard_CString getIOR() ; -Standard_EXPORT void setFatherIOR(const Standard_CString anEntry) ; -Standard_EXPORT Standard_CString getFatherIOR() ; +Standard_EXPORT GEOM_InteractiveObject(const char* anIOR, + const char* aFatherIOR, + const char* aComponentDataType, + const char* anEntry = ""); +Standard_EXPORT void setIOR(const char* anEntry) ; +Standard_EXPORT const char* getIOR() ; +Standard_EXPORT void setFatherIOR(const char* anEntry) ; +Standard_EXPORT const char* getFatherIOR() ; Standard_EXPORT virtual Standard_Boolean isSame(const Handle(SALOME_InteractiveObject)& anIO) ; Standard_EXPORT ~GEOM_InteractiveObject(); @@ -110,8 +110,8 @@ private: // Fields PRIVATE // -Standard_CString myIOR; -Standard_CString myFatherIOR; +std::string myIOR; +std::string myFatherIOR; }; diff --git a/src/OBJECT/GEOM_OCCReader.cxx b/src/OBJECT/GEOM_OCCReader.cxx index 500fdd356..933c670e9 100644 --- a/src/OBJECT/GEOM_OCCReader.cxx +++ b/src/OBJECT/GEOM_OCCReader.cxx @@ -26,16 +26,20 @@ // Module : GEOM // $Header$ -using namespace std; #include "GEOM_OCCReader.h" -// SALOME Includes -#include "utilities.h" - // VTK Includes -#include "VTKViewer_Common.h" +#include +#include + +#include +#include +#include #include +#include +#include + // OpenCASCADE Includes #include #include @@ -71,6 +75,9 @@ using namespace std; #include #include +#include "utilities.h" + +using namespace std; #define MAX2(X, Y) ( Abs(X) > Abs(Y)? Abs(X) : Abs(Y) ) #define MAX3(X, Y, Z) ( MAX2 ( MAX2(X,Y) , Z) ) diff --git a/src/OBJECT/GEOM_OCCReader.h b/src/OBJECT/GEOM_OCCReader.h index 87247f3ec..e10ce3cda 100644 --- a/src/OBJECT/GEOM_OCCReader.h +++ b/src/OBJECT/GEOM_OCCReader.h @@ -34,8 +34,10 @@ #ifndef GEOM_OCCREADER_H #define GEOM_OCCREADER_H -// VTK -#include "VTKViewer_Common.h" +#include + +class vtkPoints; +class vtkCellArray; // OpenCASCADE #include @@ -50,6 +52,7 @@ #else #define VTKOCC_EXPORT #endif + class VTKOCC_EXPORT GEOM_OCCReader : public vtkPolyDataSource { // methods diff --git a/src/OBJECT/GEOM_VTKTrihedron.cxx b/src/OBJECT/GEOM_VTKTrihedron.cxx new file mode 100644 index 000000000..67e32cedd --- /dev/null +++ b/src/OBJECT/GEOM_VTKTrihedron.cxx @@ -0,0 +1,396 @@ +// SALOME GEOM : +// +// 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 : GEOM_VTKTrihedron.cxx +// Author : Sergey LITONIN +// Module : SALOME +// $Header: + +#include "GEOM_VTKTrihedron.hxx" +#include "utilities.h" +#include "GEOM_OCCReader.h" + +#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 "VTKViewer_VectorText.h" + + + +/* + Class : GEOM_VTKTrihedron + Description : Class for displaying axis of trihedron in VTK viewer. + Placement of trihedron is chahged with SetPlacement() method +*/ +class GEOM_VTKTrihedronAxis : public VTKViewer_Axis +{ +protected: + + GEOM_VTKTrihedronAxis(); + GEOM_VTKTrihedronAxis( const GEOM_VTKTrihedronAxis& ); + ~GEOM_VTKTrihedronAxis(); + +public: + + vtkTypeMacro( GEOM_VTKTrihedronAxis, VTKViewer_Axis ); + static GEOM_VTKTrihedronAxis* New(); + + void SetAxis( const gp_Ax1& theAxis, const int theRot, float theColor[ 3 ] ); + virtual void Render( vtkRenderer* theRenderer ); + virtual void SetSize( float theSize ); + gp_Pnt GetOri() const; + void SetColor( const float theColor[ 3 ] ); + +private: + + float myOri[ 3 ]; + vtkMatrix4x4* myMatrix; + vtkTransform* myTrsf; +}; + +vtkStandardNewMacro( GEOM_VTKTrihedronAxis ); + +GEOM_VTKTrihedronAxis::GEOM_VTKTrihedronAxis() +{ + vtkProperty* aProperty = vtkProperty::New(); + aProperty->SetColor( 0.0, 0.0, 1.0 ); + SetProperty( aProperty ); + aProperty->Delete(); + myMatrix = vtkMatrix4x4::New(); + myTrsf = vtkTransform::New(); +} + +GEOM_VTKTrihedronAxis::~GEOM_VTKTrihedronAxis() +{ + myMatrix->Delete(); + myTrsf->Delete(); +} + +void GEOM_VTKTrihedronAxis::SetSize( float theSize ) +{ + float aPosition[ 3 ] = { myOri[ 0 ] + myDir[ 0 ] * theSize, + myOri[ 1 ] + myDir[ 1 ] * theSize, + myOri[ 2 ] + myDir[ 2 ] * theSize }; + + myLineSource->SetPoint1( myOri[ 0 ], myOri[ 1 ], myOri[ 2 ] ); + myLineSource->SetPoint2( aPosition ); + + myArrowActor->SetPosition( 0, 0, 0 ); + myArrowActor->SetOrientation( 0, 0, 0 ); + myArrowActor->SetUserMatrix( 0 ); + + + gp_Trsf aTrsf; + aTrsf.SetDisplacement( gp_Ax3( gp_Pnt( 0, 0, 0 ), gp_Dir( 1, 0, 0 ) ), + gp_Ax3( GetOri(), gp_Dir( myDir[ 0 ], myDir[ 1 ], myDir[ 2 ] ) ) ); + + const gp_XYZ& aTrans = aTrsf.TranslationPart(); + gp_Mat aRot = aTrsf.VectorialPart(); + + for ( int i = 1; i <= 3; i++ ) + for ( int j = 1; j <= 3; j++ ) + myMatrix->SetElement( i - 1, j - 1, aRot( i, j ) ); + + myArrowActor->SetUserMatrix( myMatrix ); + myArrowActor->SetPosition( aPosition ); + + myLabelActor->SetPosition( 0, 0, 0 ); + myLabelActor->AddPosition( aPosition ); +} + +void GEOM_VTKTrihedronAxis::Render(vtkRenderer* theRenderer) +{ + myLineActor->Render( theRenderer ); + myArrowActor->Render( theRenderer ); + myLabelActor->Render( theRenderer ); + + vtkCamera* aCamera = theRenderer->GetActiveCamera(); + SetCamera( aCamera ); +} + +gp_Pnt GEOM_VTKTrihedronAxis::GetOri() const +{ + return gp_Pnt( myOri[ 0 ], myOri[ 1 ], myOri[ 2 ] ); +} + +void GEOM_VTKTrihedronAxis::SetAxis( const gp_Ax1& theAxis, + const int theRot, + float theColor[ 3 ] ) +{ + gp_Pnt aLoc = theAxis.Location(); + gp_Dir aDir = theAxis.Direction(); + + myOri[ 0 ] = aLoc.X(); + myOri[ 1 ] = aLoc.Y(); + myOri[ 2 ] = aLoc.Z(); + + myDir[ 0 ] = aDir.X(); + myDir[ 1 ] = aDir.Y(); + myDir[ 2 ] = aDir.Z(); + + float aColor[ 3 ] = { 0, 0, 0 }; + aColor[ theRot ] = 1; + vtkProperty* aProperty = vtkProperty::New(); + if ( theColor[ 0 ] == -1 ) + aProperty->SetColor( aColor[ 0 ], aColor[ 1 ], aColor[ 2 ] ); + else + aProperty->SetColor( theColor[ 0 ], theColor[ 1 ], theColor[ 2 ] ); + SetProperty( aProperty ); + aProperty->Delete(); + + if ( theRot == 0 ) myVectorText->SetText( "X" ); + else if ( theRot == 1 ) myVectorText->SetText( "Y" ); + else if ( theRot == 2 ) myVectorText->SetText( "Z" ); +} + +void GEOM_VTKTrihedronAxis::SetColor( const float theColor[ 3 ] ) +{ + vtkProperty* aProperty = vtkProperty::New(); + aProperty->SetColor( theColor[ 0 ], theColor[ 1 ], theColor[ 2 ] ); + SetProperty( aProperty ); + aProperty->Delete(); +} + + +/* + Class : GEOM_VTKTrihedron + Description : Class for displaying trihedron of local CS in VTK viewer. + Placement of trihedron is chahged with SetPlacement() method +*/ + +vtkStandardNewMacro( GEOM_VTKTrihedron ); + +GEOM_VTKTrihedron::GEOM_VTKTrihedron() +{ + myMapper = vtkPolyDataMapper::New(); + myAxis[ 0 ] = myAxis[ 1 ] = myAxis[ 2 ] = 0; + myPresent = vtkActorCollection::New(); + mySize = 100; + SetInfinitive( true ); + myColor[ 0 ] = myColor[ 1 ] = myColor[ 1 ] = -1; + SetInfinitive( true ); +} + +GEOM_VTKTrihedron::~GEOM_VTKTrihedron() +{ + myPresent->RemoveAllItems(); + myPresent->Delete(); + for ( int i = 0; i < 3; i++ ) + myAxis[i]->Delete(); + + if ( myMapper ) + myMapper->Delete(); +} + +void GEOM_VTKTrihedron::SetSize( float theSize ) +{ + mySize = theSize; + for ( int i = 0; i < 3; i++ ) + myAxis[i]->SetSize( theSize ); + + + // Calculate new sensitive area + gp_Pnt anOri = ( (GEOM_VTKTrihedronAxis*)myAxis[ 0 ] )->GetOri(); + gp_Pnt aEndX( myLocation.XYZ() + myDirX.XYZ() * mySize ); + gp_Pnt aEndY( myLocation.XYZ() + myDirY.XYZ() * mySize ); + gp_Pnt aEndZ( myLocation.XYZ() + myDirZ.XYZ() * mySize ); + + vtkLineSource* aSrcX = vtkLineSource::New(); + vtkLineSource* aSrcY = vtkLineSource::New(); + vtkLineSource* aSrcZ = vtkLineSource::New(); + + aSrcX->SetPoint1( anOri.X(), anOri.Y(), anOri.Z() ); + aSrcX->SetPoint2( aEndX.X(), aEndX.Y(), aEndX.Z() ); + + aSrcY->SetPoint1( anOri.X(), anOri.Y(), anOri.Z() ); + aSrcY->SetPoint2( aEndY.X(), aEndY.Y(), aEndY.Z() ); + + aSrcZ->SetPoint1( anOri.X(), anOri.Y(), anOri.Z() ); + aSrcZ->SetPoint2( aEndZ.X(), aEndZ.Y(), aEndZ.Z() ); + + vtkAppendPolyData* aRes = vtkAppendPolyData::New(); + aRes->AddInput( aSrcX->GetOutput() ); + aRes->AddInput( aSrcY->GetOutput() ); + aRes->AddInput( aSrcZ->GetOutput() ); + + myMapper->SetInput( aRes->GetOutput() ); + SALOME_Actor::SetMapper( myMapper ); + + aSrcX->Delete(); + aSrcY->Delete(); + aSrcZ->Delete(); + aRes->Delete(); +} + +void GEOM_VTKTrihedron::SetVisibility( VTKViewer_Trihedron::TVisibility theVis ) +{ + for ( int i = 0; i < 3; i++ ) + myAxis[i]->SetVisibility( theVis ); +} + +void GEOM_VTKTrihedron::AddToRender( vtkRenderer* theRenderer ) +{ + vtkCamera* aCamera = theRenderer->GetActiveCamera(); + for(int i = 0; i < 3; i++) + { + myAxis[i]->AddToRender(theRenderer); + myAxis[i]->SetCamera(aCamera); + } + + theRenderer->AddActor( this ); +} + +void GEOM_VTKTrihedron::RemoveFromRender( vtkRenderer* theRenderer ) +{ + myPresent->InitTraversal(); + while(vtkActor* anActor = myPresent->GetNextActor()) + theRenderer->RemoveActor(anActor); +} + +int GEOM_VTKTrihedron::GetVisibleActorCount(vtkRenderer* theRenderer) +{ + vtkActorCollection* aCollection = theRenderer->GetActors(); + aCollection->InitTraversal(); + int aCount = 0; + while( vtkActor* prop = aCollection->GetNextActor() ) + if ( prop->GetVisibility() ) + if ( SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( prop ) ) + if ( !anActor->IsInfinitive() ) + aCount++; + + vtkCamera* aCamera = theRenderer->GetActiveCamera(); + for(int i = 0; i < 3; i++) + myAxis[i]->SetCamera( aCamera ); + + return aCount; +} + +void GEOM_VTKTrihedron::SetCamera( vtkCamera* theCamera ) +{ + for(int i = 0; i < 3; i++) + myAxis[i]->SetCamera( theCamera ); +} + +void GEOM_VTKTrihedron::SetPlacement( const Handle(Geom_Axis2Placement)& thePlc ) +{ + gp_Ax2 anAx2 = thePlc->Ax2(); + + myDirX = anAx2.XDirection(); + myDirY = anAx2.YDirection(); + myDirZ = anAx2.Direction(); + + myLocation = anAx2.Axis().Location(); + + if ( myAxis[ 0 ] != 0 ) myAxis[ 0 ]->Delete(); + if ( myAxis[ 1 ] != 0 ) myAxis[ 1 ]->Delete(); + if ( myAxis[ 2 ] != 0 ) myAxis[ 2 ]->Delete(); + + myAxis[ 0 ] = GEOM_VTKTrihedronAxis::New(); + myAxis[ 1 ] = GEOM_VTKTrihedronAxis::New(); + myAxis[ 2 ] = GEOM_VTKTrihedronAxis::New(); + + ( (GEOM_VTKTrihedronAxis*)myAxis[ 0 ] )->SetAxis( gp_Ax1( myLocation, myDirX ), 0, myColor ); + ( (GEOM_VTKTrihedronAxis*)myAxis[ 1 ] )->SetAxis( gp_Ax1( myLocation, myDirY ), 1, myColor ); + ( (GEOM_VTKTrihedronAxis*)myAxis[ 2 ] )->SetAxis( gp_Ax1( myLocation, myDirZ ), 2, myColor ); + + SetSize( mySize ); +} + +vtkMapper* GEOM_VTKTrihedron::GetMapper() +{ + return myMapper; +} + +void GEOM_VTKTrihedron::Render(vtkRenderer* r, vtkMapper *) +{ + ( (GEOM_VTKTrihedronAxis*)myAxis[ 0 ] )->Render( r ); + ( (GEOM_VTKTrihedronAxis*)myAxis[ 1 ] )->Render( r ); + ( (GEOM_VTKTrihedronAxis*)myAxis[ 2 ] )->Render( r ); +} + +void GEOM_VTKTrihedron::SetColor( float r, float g, float b ) +{ + myColor[ 0 ] = r; + myColor[ 1 ] = g; + myColor[ 2 ] = b; + + if ( myAxis[ 0 ] ) ( (GEOM_VTKTrihedronAxis*)myAxis[ 0 ] )->SetColor( myColor ); + if ( myAxis[ 1 ] ) ( (GEOM_VTKTrihedronAxis*)myAxis[ 1 ] )->SetColor( myColor ); + if ( myAxis[ 2 ] ) ( (GEOM_VTKTrihedronAxis*)myAxis[ 2 ] )->SetColor( myColor ); +} + +void GEOM_VTKTrihedron::GetColor( float& r, float& g, float& b ) +{ + r = myColor[ 0 ]; + g = myColor[ 1 ]; + b = myColor[ 2 ]; +} + +bool GEOM_VTKTrihedron::IsSetCamera() const +{ + return true; +} + +bool GEOM_VTKTrihedron::IsResizable() const +{ + return true; +} + + + + + + + + + + + + + + + + diff --git a/src/OBJECT/GEOM_VTKTrihedron.hxx b/src/OBJECT/GEOM_VTKTrihedron.hxx new file mode 100644 index 000000000..165fbe8e6 --- /dev/null +++ b/src/OBJECT/GEOM_VTKTrihedron.hxx @@ -0,0 +1,94 @@ +// SALOME GEOM : +// +// 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 : GEOM_VTKTrihedron.h +// Author : Sergey LITONIN +// Module : SALOME +// $Header: + +#ifndef GEOM_VTKTrihedron_H +#define GEOM_VTKTrihedron_H + +#include +#include "SALOME_Actor.h" +#include "VTKViewer_Trihedron.h" + +class vtkActorCollection; +class vtkRenderer; +class vtkPolyDataMapper; + +/* + Class : GEOM_VTKTrihedron + Description : Class for displaying trihedron of local CS in VTK viewer. + Placement of trihedron is chahged with SetPlacement() method +*/ + +class GEOM_VTKTrihedron : public SALOME_Actor +{ + +protected: + GEOM_VTKTrihedron(); + GEOM_VTKTrihedron( const GEOM_VTKTrihedron& ); + virtual ~GEOM_VTKTrihedron(); + +public: + vtkTypeMacro( GEOM_VTKTrihedron, SALOME_Actor ); + static GEOM_VTKTrihedron* New(); + + virtual float GetSize() { return mySize;} + + virtual void SetVisibility( VTKViewer_Trihedron::TVisibility theVis ); + virtual void VisibilityOff() { SetVisibility( VTKViewer_Trihedron::eOff ); } + virtual void VisibilityOn() { SetVisibility( VTKViewer_Trihedron::eOn ); } + + virtual void AddToRender( vtkRenderer* theRenderer ); + virtual void RemoveFromRender( vtkRenderer* theRenderer ); + + virtual int GetVisibleActorCount( vtkRenderer* theRenderer ); + + void SetPlacement( const Handle(Geom_Axis2Placement)& ); + + virtual vtkMapper* GetMapper(); + + virtual void Render(vtkRenderer *, vtkMapper *); + virtual bool IsSetCamera() const; + virtual bool IsResizable() const; + virtual void SetSize( float ); + virtual void SetCamera( vtkCamera* ); + + void SetColor( float r, float g, float b ); + void GetColor( float& r, float& g, float& b ); + + virtual bool hasHighlight() { return false; } + +protected: + vtkActorCollection* myPresent; + VTKViewer_Axis* myAxis[3]; + vtkPolyDataMapper* myMapper; + float mySize; + gp_Pnt myLocation; + gp_Dir myDirX, myDirY, myDirZ; + float myColor[ 3 ]; +}; + +#endif diff --git a/src/OBJECT/Makefile.in b/src/OBJECT/Makefile.in index 29da193a2..459e098a8 100644 --- a/src/OBJECT/Makefile.in +++ b/src/OBJECT/Makefile.in @@ -37,8 +37,9 @@ EXPORT_HEADERS = GEOM_Actor.h \ GEOM_AISShape.hxx \ Handle_GEOM_AISShape.hxx \ GEOM_InteractiveObject.hxx \ - Handle_GEOM_InteractiveObject.hxx - + Handle_GEOM_InteractiveObject.hxx \ + GEOM_AISTrihedron.hxx \ + GEOM_VTKTrihedron.hxx # Libraries targets @@ -47,8 +48,10 @@ LIB_SRC = GEOM_Actor.cxx \ GEOM_OCCReader.cxx \ GEOM_AssemblyBuilder.cxx \ GEOM_AISShape.cxx \ - GEOM_InteractiveObject.cxx - + GEOM_InteractiveObject.cxx \ + GEOM_AISTrihedron.cxx \ + GEOM_VTKTrihedron.cxx + LIB_CLIENT_IDL = # Executables targets @@ -57,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+=$(PYTHON_LIBS) $(QT_MT_LIBS) $(VTK_LIBS) $(OGL_LIBS) -lSalomeObject -L${KERNEL_ROOT_DIR}/lib/salome +LDFLAGS+=$(QT_MT_LIBS) $(VTK_LIBS) $(OGL_LIBS) $(PYTHON_LIBS) -lSalomeObject -L${KERNEL_ROOT_DIR}/lib/salome %_moc.cxx: %.h $(MOC) $< -o $@ diff --git a/src/OperationGUI/Makefile.in b/src/OperationGUI/Makefile.in index fe9386d87..04a05bbf9 100644 --- a/src/OperationGUI/Makefile.in +++ b/src/OperationGUI/Makefile.in @@ -43,25 +43,28 @@ LIB = libOperationGUI.la LIB_SRC = OperationGUI.cxx \ OperationGUI_ArchimedeDlg.cxx \ OperationGUI_PartitionDlg.cxx \ + OperationGUI_MaterialDlg.cxx \ OperationGUI_FilletDlg.cxx \ - OperationGUI_ChamferDlg.cxx + OperationGUI_ChamferDlg.cxx \ + OperationGUI_ClippingDlg.cxx LIB_MOC = \ - OperationGUI.h \ OperationGUI_ArchimedeDlg.h \ OperationGUI_PartitionDlg.h \ + OperationGUI_MaterialDlg.h \ OperationGUI_FilletDlg.h \ - OperationGUI_ChamferDlg.h + OperationGUI_ChamferDlg.h \ + OperationGUI_ClippingDlg.h -LIB_CLIENT_IDL = +LIB_CLIENT_IDL = SALOME_GenericObj.idl SALOME_Component.idl -LIB_SERVER_IDL = +LIB_SERVER_IDL = # additionnal information to compil and link file CPPFLAGS += $(QT_INCLUDES) $(VTK_INCLUDES) $(OCC_INCLUDES) $(PYTHON_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome CXXFLAGS += -I${KERNEL_ROOT_DIR}/include/salome -LDFLAGS += -lDisplayGUI $(CAS_LDPATH) -lTKFillet +LDFLAGS += $(CAS_LDPATH) -lTKFillet -lGEOMBase @CONCLUDE@ diff --git a/src/OperationGUI/OperationGUI.cxx b/src/OperationGUI/OperationGUI.cxx index 842a5a12f..e784ac282 100644 --- a/src/OperationGUI/OperationGUI.cxx +++ b/src/OperationGUI/OperationGUI.cxx @@ -24,14 +24,13 @@ // File : OperationGUI.cxx // Author : Damien COQUERET // Module : GEOM -// $Header: +// $Header$ using namespace std; #include "OperationGUI.h" -#include "DisplayGUI.h" - #include "QAD_RightFrame.h" +#include "QAD_Desktop.h" #include "OCCViewer_Viewer3d.h" #include "OCCViewer_ViewFrame.h" #include "SALOMEGUI_QtCatchCorbaException.hxx" @@ -45,16 +44,29 @@ using namespace std; #include "OperationGUI_FilletDlg.h" // Method FILLET #include "OperationGUI_ChamferDlg.h" // Method CHAMFER +#include "OperationGUI_ClippingDlg.h" + +OperationGUI* OperationGUI::myGUIObject = 0; + +//======================================================================= +// function : GetOperationGUI() +// purpose : Get the only OperationGUI object [ static ] +//======================================================================= +OperationGUI* OperationGUI::GetOperationGUI() +{ + if ( myGUIObject == 0 ) { + // init OperationGUI only once + myGUIObject = new OperationGUI(); + } + return myGUIObject; +} + //======================================================================= // function : OperationGUI() // purpose : Constructor //======================================================================= -OperationGUI::OperationGUI() : - QObject() +OperationGUI::OperationGUI() : GEOMGUI() { - myGeomBase = new GEOMBase(); - myGeomGUI = GEOMContext::GetGeomGUI(); - myGeom = myGeomGUI->myComponentGeom; } @@ -71,385 +83,45 @@ OperationGUI::~OperationGUI() // function : OnGUIEvent() // purpose : //======================================================================= -bool OperationGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) +bool OperationGUI::OnGUIEvent( int theCommandID, QAD_Desktop* parent ) { - OperationGUI* myOperationGUI = new OperationGUI(); - myOperationGUI->myGeomGUI->EmitSignalDeactivateDialog(); - SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection()); - - switch (theCommandID) - { + OperationGUI* myOperationGUI = GetOperationGUI(); + GeometryGUI::GetGeomGUI()->EmitSignalDeactivateDialog(); + SALOME_Selection* Sel = SALOME_Selection::Selection( + QAD_Application::getDesktop()->getActiveStudy()->getSelection() ); + + switch ( theCommandID ) + { case 503: // PARTITION - { - OperationGUI_PartitionDlg *aDlg = new OperationGUI_PartitionDlg(parent, "", myOperationGUI, Sel); - break; - } + ( new OperationGUI_PartitionDlg( parent, "", Sel ) )->show(); + break; case 504: // ARCHIMEDE - { - OperationGUI_ArchimedeDlg *aDlg = new OperationGUI_ArchimedeDlg(parent, "", myOperationGUI, Sel); - break; - } + new OperationGUI_ArchimedeDlg( parent, Sel ); + break; case 505: // FILLET - { - Handle(AIS_InteractiveContext) ic; - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - ic = v3d->getAISContext(); - } - OperationGUI_FilletDlg *aDlg = new OperationGUI_FilletDlg(parent, "", myOperationGUI, Sel, ic); - break; - } + new OperationGUI_FilletDlg( parent, Sel ); + break; case 506: // CHAMFER - { - Handle(AIS_InteractiveContext) ic; - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - ic = v3d->getAISContext(); - } - OperationGUI_ChamferDlg *aDlg = new OperationGUI_ChamferDlg(parent, "", myOperationGUI, Sel, ic); - break; - } + new OperationGUI_ChamferDlg( parent, Sel ); + break; + case 507: // CLIPPING RANGE + ( new OperationGUI_ClippingDlg( parent, "" ) )->show(); + break; default: - { - parent->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); - break; - } - } - return true; -} - - -//===================================================================================== -// function : MakePartitionAndDisplay() -// purpose : -//===================================================================================== -void OperationGUI::MakePartitionAndDisplay(const GEOM::GEOM_Gen::ListOfIOR& listShapesIOR, - const GEOM::GEOM_Gen::ListOfIOR& listToolsIOR, - const GEOM::GEOM_Gen::ListOfIOR& listKeepInsIOR, - const GEOM::GEOM_Gen::ListOfIOR& listRemoveInsIOR, - const GEOM::shape_type limit) -{ - try { - GEOM::GEOM_Shape_var result = myGeom->Partition(listShapesIOR, listToolsIOR, - listKeepInsIOR, listRemoveInsIOR, - (CORBA::Short) limit); - if(result->_is_nil()) { - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_NULLSHAPE")); - return; - } - result->NameType(tr("GEOM_PARTITION")); - if(myGeomBase->Display(result)) - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); - return; - } - catch(const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } -} - - -//======================================================================= -// function : Archimede() -// purpose : -//======================================================================= -void OperationGUI::Archimede(const Handle(SALOME_InteractiveObject)& IO, const double aWeight, - const double aWaterDensity, const double aMeshingDeflection) -{ - try { - if(IO->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject))) { - Handle(GEOM_InteractiveObject) GIO = Handle(GEOM_InteractiveObject)::DownCast(IO); - GEOM::GEOM_Shape_var Shape = myGeom->GetIORFromString(GIO->getIOR()); - - GEOM::GEOM_Shape_var Result = myGeom->Archimede(Shape, aWeight, aWaterDensity, aMeshingDeflection); - Result->NameType(tr("GEOM_PLANE")); - if(myGeomBase->Display(Result)) { - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); - } - return; - } - if(IO->hasEntry()) { - SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument(); - SALOMEDS::SObject_var obj = aStudy->FindObjectID( IO->getEntry()); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeIOR_var anIOR; - if(!obj->_is_nil()) { - if(obj->FindAttribute(anAttr, "AttributeIOR")) { - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - GEOM::GEOM_Shape_var Shape = myGeom->GetIORFromString(anIOR->Value()); - GEOM::GEOM_Shape_var Result = myGeom->Archimede(Shape, aWeight, aWaterDensity, aMeshingDeflection); - Result->NameType(tr("GEOM_PLANE")); - if (myGeomBase->Display(Result)) { - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); - } - } - } - } - } - catch(const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } -} - - -//===================================================================================== -// function : OnFilletGetAll() -// purpose : -//===================================================================================== -bool OperationGUI::OnFilletGetAll(const TopoDS_Shape& ShapeTopo, const double Radius, - const int SubShapeType, const char* ShapeTopoIOR) -{ - GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID; - ListOfID->length(0); - - SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument(); - SALOMEDS::SObject_var theObj = aStudy->FindObjectIOR(ShapeTopoIOR); - if(theObj->_is_nil()) { - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY")); - return false; + parent->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); + break; } - try { - if(Radius <= Precision::Confusion()) - return false; - - GEOM::GEOM_Shape_var aShape = myGeom->GetIORFromString(ShapeTopoIOR); - GEOM::GEOM_Shape_var result = myGeom->MakeFillet(aShape, Radius, SubShapeType, ListOfID); - if(result->_is_nil()) { - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_ABORT")); - return false; - } - TopoDS_Shape S = myGeomGUI->GetShapeReader().GetShape(myGeom, result); - Standard_CString type; - myGeomBase->GetShapeTypeString(S,type); - result->NameType(type); - - if(myGeomBase->Display(result)) - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } return true; } - -//===================================================================================== -// function : OnFilletGetSelected() -// purpose : -//===================================================================================== -bool OperationGUI::OnFilletGetSelected(const TopoDS_Shape& ShapeTopo, const char* ShapeTopoIOR, - const double Radius, const int SubShapeType, - Standard_Integer& aLocalContextId, bool& myUseLocalContext) -{ - if (QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC) - return false; - - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - Handle(AIS_InteractiveContext) ic = v3d->getAISContext(); - - if(myUseLocalContext == false) { - /* No local context opened for fillet method */ - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_ABORT")); - return false; - } - - GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID; - ic->InitSelected(); - int nbSelected = ic->NbSelected(); - int i = 0; - ic->InitSelected(); - - while(ic->MoreSelected()) { - TopoDS_Shape s = ic->SelectedShape(); - if(s.ShapeType() == TopAbs_FACE) { - TopExp_Explorer Exp(s, TopAbs_EDGE); - TopTools_MapOfShape M; - while(Exp.More()) { - if(M.Add(Exp.Current())) { /* if a new edge : do not add doublons indices */ - ListOfID->length(i + 1); - ListOfID[i] = myGeomBase->GetIndex(Exp.Current(), ShapeTopo, (int)TopAbs_EDGE); - i++; - } - Exp.Next(); - } - } - else { - ListOfID->length(i + 1); - ListOfID[i] = myGeomBase->GetIndex(ic->SelectedShape(), ShapeTopo, SubShapeType); - i++; - } - ic->NextSelected(); - } - - GEOM::GEOM_Shape_var aShape = myGeom->GetIORFromString(ShapeTopoIOR); - GEOM::GEOM_Shape_var aResult; - try { - aResult = myGeom->MakeFillet(aShape, Radius, 6, ListOfID); - - /* local context from DialogBox */ - ic->CloseLocalContext(aLocalContextId); - myUseLocalContext = false; - - TopoDS_Shape S = myGeomGUI->GetShapeReader().GetShape(myGeom, aResult); - Standard_CString type; - myGeomBase->GetShapeTypeString(S,type); - aResult->NameType(type); - - if(myGeomBase->Display(aResult)) - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); - } - catch(const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - - if(myUseLocalContext) { - /* local context from DialogBox */ - ic->CloseLocalContext(aLocalContextId); - myUseLocalContext = false; - } - - DisplayGUI* myDisplayGUI = new DisplayGUI(); - myDisplayGUI->OnDisplayAll(true) ; - QAD_Application::getDesktop()->getActiveStudy()->updateObjBrowser(); - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_READY")); - - return true; -} - - -//===================================================================================== -// function : OnChamferGetAll() -// purpose : -//===================================================================================== -bool OperationGUI::OnChamferGetAll(const TopoDS_Shape& ShapeTopo, const double D1, const double D2, const int SubShapeType, const char* ShapeTopoIOR) -{ - GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID; - ListOfID->length(0); - - SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument(); - SALOMEDS::SObject_var theObj = aStudy->FindObjectIOR(ShapeTopoIOR); - if(theObj->_is_nil()) { - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY")); - return false; - } - - try { - if(D1 <= Precision::Confusion()) - return false; - if(D2 <= Precision::Confusion()) - return false; - - GEOM::GEOM_Shape_var aShape = myGeom->GetIORFromString(ShapeTopoIOR); - GEOM::GEOM_Shape_var result = myGeom->MakeChamfer(aShape, D1, D2, SubShapeType, ListOfID); - if(result->_is_nil()) { - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_ABORT")); - return false; - } - - TopoDS_Shape S = myGeomGUI->GetShapeReader().GetShape(myGeom, result); - Standard_CString type; - myGeomBase->GetShapeTypeString(S,type); - result->NameType(type); - - if(myGeomBase->Display(result)) - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return true; -} - - -//===================================================================================== -// function : OnChamferGetSelected() -// purpose : -//===================================================================================== -bool OperationGUI::OnChamferGetSelected(const TopoDS_Shape& ShapeTopo, const char* ShapeTopoIOR, - const double D1, const double D2, const int SubShapeType, - Standard_Integer& aLocalContextId, bool& myUseLocalContext) -{ - if (QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC) - return false; - - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - Handle (AIS_InteractiveContext) ic = v3d->getAISContext(); - - if(myUseLocalContext == false) { - /* No local context opened for chamfer method */ - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_ABORT")); - return false; - } - - GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID; - ic->InitSelected(); - int nbSelected = ic->NbSelected(); - int i = 0; - ic->InitSelected(); - - while(ic->MoreSelected()) { - TopoDS_Shape s = ic->SelectedShape(); - if (s.ShapeType() == TopAbs_FACE) { - TopExp_Explorer Exp(s, TopAbs_EDGE); - TopTools_MapOfShape M; - while(Exp.More()) { - if(M.Add(Exp.Current())) { /* if a new edge : do not add doublons indices */ - ListOfID->length(i + 1); - ListOfID[i] = myGeomBase->GetIndex(Exp.Current(), ShapeTopo, (int)TopAbs_EDGE); - i++; - } - Exp.Next(); - } - } - else { - ListOfID->length(i + 1); - ListOfID[i] = myGeomBase->GetIndex(ic->SelectedShape(), ShapeTopo, SubShapeType); - i++; - } - ic->NextSelected(); - } - - GEOM::GEOM_Shape_var aShape = myGeom->GetIORFromString(ShapeTopoIOR); - GEOM::GEOM_Shape_var aResult; - try { - aResult = myGeom->MakeChamfer(aShape, D1, D2, 6, ListOfID); - - /* local context from DialogBox */ - ic->CloseLocalContext(aLocalContextId); - myUseLocalContext = false; - - TopoDS_Shape S = myGeomGUI->GetShapeReader().GetShape(myGeom, aResult); - Standard_CString type; - myGeomBase->GetShapeTypeString(S,type); - aResult->NameType(type); - - if(myGeomBase->Display(aResult)) - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); - } - catch(const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - - if (myUseLocalContext) { - /* local context from DialogBox */ - ic->CloseLocalContext(aLocalContextId); - myUseLocalContext = false; - } - - DisplayGUI* myDisplayGUI = new DisplayGUI(); - myDisplayGUI->OnDisplayAll(true) ; - QAD_Application::getDesktop()->getActiveStudy()->updateObjBrowser(); - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_READY")); - - return true; -} - - //===================================================================================== // EXPORTED METHODS //===================================================================================== extern "C" { - bool OnGUIEvent(int theCommandID, QAD_Desktop* parent) - {return OperationGUI::OnGUIEvent(theCommandID, parent);} + GEOMGUI* GetLibGUI() + { + return OperationGUI::GetOperationGUI(); + } } diff --git a/src/OperationGUI/OperationGUI.h b/src/OperationGUI/OperationGUI.h index c30dc16f7..17786bb80 100644 --- a/src/OperationGUI/OperationGUI.h +++ b/src/OperationGUI/OperationGUI.h @@ -24,55 +24,33 @@ // File : OperationGUI.h // Author : Damien COQUERET // Module : GEOM -// $Header: +// $Header$ #ifndef OPERATIONGUI_H #define OPERATIONGUI_H +#include "GEOMGUI.h" #include "GEOMBase.h" //================================================================================= // class : OperationGUI // purpose : //================================================================================= -class OperationGUI : public QObject +class OperationGUI : public GEOMGUI { - Q_OBJECT /* for QT compatibility */ +protected: + OperationGUI(); // hide constructor to avoid direct creation public : - OperationGUI(); ~OperationGUI(); - static bool OnGUIEvent(int theCommandID, QAD_Desktop* parent); + // Get the only OperationGUI object + static OperationGUI* GetOperationGUI(); - void MakePartitionAndDisplay(const GEOM::GEOM_Gen::ListOfIOR& listShapesIOR, - const GEOM::GEOM_Gen::ListOfIOR& listToolsIOR, - const GEOM::GEOM_Gen::ListOfIOR& listKeepInsIOR, - const GEOM::GEOM_Gen::ListOfIOR& listRemoveInsIOR, - const GEOM::shape_type limit ) ; - void Archimede(const Handle(SALOME_InteractiveObject)& IO, const double aWeight, - const double aWaterDensity, const double aMeshingDeflection); - - /* Method for Fillet */ - bool OnFilletGetAll(const TopoDS_Shape& ShapeTopo, const double Radius, - const int SubShapeType, const char* ShapeTopoIOR); - bool OnFilletGetSelected(const TopoDS_Shape& ShapeTopo, const char* ShapeTopoIOR, - const double Radius, const int SubShapeType, - Standard_Integer& aLocalContextId, bool& myUseLocalContext); - - /* Methods for Chamfer */ - bool OnChamferGetAll(const TopoDS_Shape& ShapeTopo, const double D1, const double D2, - const int SubShapeType, const char* ShapeTopoIOR); - bool OnChamferGetSelected(const TopoDS_Shape& ShapeTopo, - const char* ShapeTopoIOR, - const double D1, const double D2, const int SubShapeType, - Standard_Integer& aLocalContextId, - bool& myUseLocalContext); - - GEOMBase* myGeomBase; - GEOMContext* myGeomGUI; - GEOM::GEOM_Gen_var myGeom; /* Current Geom Component */ + bool OnGUIEvent(int theCommandID, QAD_Desktop* parent); +private: + static OperationGUI* myGUIObject; // the only OperationGUI object }; #endif diff --git a/src/OperationGUI/OperationGUI_ArchimedeDlg.cxx b/src/OperationGUI/OperationGUI_ArchimedeDlg.cxx index 7e272e91d..26a867ae2 100644 --- a/src/OperationGUI/OperationGUI_ArchimedeDlg.cxx +++ b/src/OperationGUI/OperationGUI_ArchimedeDlg.cxx @@ -26,10 +26,11 @@ // Module : GEOM // $Header$ -using namespace std; #include "OperationGUI_ArchimedeDlg.h" +#include "DlgRef_1Sel3Spin.h" #include "QAD_Config.h" +#include "QAD_Desktop.h" //================================================================================= // class : OperationGUI_ArchimedeDlg() @@ -38,9 +39,12 @@ using namespace std; // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -OperationGUI_ArchimedeDlg::OperationGUI_ArchimedeDlg(QWidget* parent, const char* name, OperationGUI* theOperationGUI, SALOME_Selection* Sel, bool modal, WFlags fl) - :GEOMBase_Skeleton(parent, name, Sel, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) +OperationGUI_ArchimedeDlg::OperationGUI_ArchimedeDlg( QWidget* parent, SALOME_Selection* Sel ) +: GEOMBase_Skeleton( parent, "ArchimedeDlg", Sel, false, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) { + mySelection = Sel; + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_ARCHIMEDE"))); QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); @@ -59,13 +63,13 @@ OperationGUI_ArchimedeDlg::OperationGUI_ArchimedeDlg(QWidget* parent, const cha GroupPoints->TextLabel3->setText(tr("GEOM_WATER_DENSITY")); GroupPoints->TextLabel4->setText(tr("GEOM_MESHING_DEFLECTION")); GroupPoints->PushButton1->setPixmap(image1); + GroupPoints->LineEdit1->setReadOnly( true ); - Layout1->addWidget(GroupPoints, 1, 0); + Layout1->addWidget(GroupPoints, 2, 0); /***************************************************************/ /* Initialisations */ - myOperationGUI = theOperationGUI; - Init(); + Init( mySelection ); } @@ -83,54 +87,49 @@ OperationGUI_ArchimedeDlg::~OperationGUI_ArchimedeDlg() // function : Init() // purpose : //================================================================================= -void OperationGUI_ArchimedeDlg::Init() +void OperationGUI_ArchimedeDlg::Init( SALOME_Selection* Sel ) { + mySelection = Sel; + /* init variables */ myEditCurrentArgument = GroupPoints->LineEdit1; - myWeight = 100.0; - myWaterDensity = 1.0; - myMeshingDeflection = 0.01; - myOkIO = false; - - /* Get setting of step value from file configuration */ - QString St = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep"); - step = St.toDouble(); - + /* Get setting of myStep value from file configuration */ + QString St = QAD_CONFIG->getSetting( "Geometry:SettingsGeomStep" ); + myStep = !St.isEmpty() ? St.toDouble() : 100; double SpecificStep1 = 0.1; double SpecificStep2 = 0.01; - /* min, max, step and decimals for spin boxes & initial values */ - GroupPoints->SpinBox_DX->RangeStepAndValidator(0.001, 999.999, step, 3); + /* min, max, myStep and decimals for spin boxes & initial values */ + GroupPoints->SpinBox_DX->RangeStepAndValidator(0.001, 999.999, myStep, 3); GroupPoints->SpinBox_DY->RangeStepAndValidator(0.001, 999.999, SpecificStep1, 3); GroupPoints->SpinBox_DZ->RangeStepAndValidator(0.001, 999.999, SpecificStep2, 3); - GroupPoints->SpinBox_DX->SetValue(myWeight); - GroupPoints->SpinBox_DY->SetValue(myWaterDensity); - GroupPoints->SpinBox_DZ->SetValue(myMeshingDeflection); + GroupPoints->SpinBox_DX->SetValue( 100.0 ); + GroupPoints->SpinBox_DY->SetValue( 1.0 ); + GroupPoints->SpinBox_DZ->SetValue( 0.01 ); /* signals and slots connections */ connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); - connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(GroupPoints->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(GroupPoints->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox_DX, SLOT(SetStep(double))); connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox_DY, SLOT(SetStep(double))); connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox_DZ, SLOT(SetStep(double))); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ; + initName( tr( "GEOM_ARCHIMEDE" ) ); + + globalSelection( GEOM_ALLSHAPES ); + + SelectionIntoArgument(); + /* displays Dialog */ GroupPoints->show(); this->show(); - - return; } @@ -140,9 +139,8 @@ void OperationGUI_ArchimedeDlg::Init() //================================================================================= void OperationGUI_ArchimedeDlg::ClickOnOk() { - this->ClickOnApply(); - ClickOnCancel(); - return; + if ( ClickOnApply() ) + ClickOnCancel(); } @@ -150,13 +148,13 @@ void OperationGUI_ArchimedeDlg::ClickOnOk() // function : ClickOnApply() // purpose : //================================================================================= -void OperationGUI_ArchimedeDlg::ClickOnApply() +bool OperationGUI_ArchimedeDlg::ClickOnApply() { - buttonApply->setFocus(); - QAD_Application::getDesktop()->putInfo(tr("")); - if(myOkIO) - myOperationGUI->Archimede(myIO, myWeight, myWaterDensity, myMeshingDeflection); - return; + if ( !onAccept() ) + return false; + + initName(); + return true; } @@ -166,20 +164,22 @@ void OperationGUI_ArchimedeDlg::ClickOnApply() //================================================================================= void OperationGUI_ArchimedeDlg::SelectionIntoArgument() { - myEditCurrentArgument->setText(""); - QString aString = ""; /* name of selection */ + myEditCurrentArgument->setText( "" ); + myShape = GEOM::GEOM_Object::_nil(); + + if ( mySelection->IObjectCount() != 1 ) + return; - int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString); - if (nbSel != 1) { - myOkIO = false; + Standard_Boolean testResult = Standard_False; + myShape = GEOMBase::ConvertIOinGEOMObject( mySelection->firstIObject(), testResult ); + + if ( !testResult || myShape->_is_nil() || !GEOMBase::IsShape( myShape ) ) + { + myShape = GEOM::GEOM_Object::_nil(); return; } - else { - myEditCurrentArgument->setText(aString); - myIO = mySelection->firstIObject(); - myOkIO = true; - } - return; + + myEditCurrentArgument->setText( GEOMBase::GetName( myShape ) ); } @@ -199,25 +199,6 @@ void OperationGUI_ArchimedeDlg::LineEditReturnPressed() return; } - -//================================================================================= -// function : SetEditCurrentArgument() -// purpose : -//================================================================================= -void OperationGUI_ArchimedeDlg::SetEditCurrentArgument() -{ - QPushButton* send = (QPushButton*)sender(); - - if(send == GroupPoints->PushButton1) { - GroupPoints->LineEdit1->setFocus(); - myEditCurrentArgument = GroupPoints->LineEdit1; - this->SelectionIntoArgument(); - } - - return; -} - - //================================================================================= // function : ActivateThisDialog() // purpose : @@ -225,6 +206,7 @@ void OperationGUI_ArchimedeDlg::SetEditCurrentArgument() void OperationGUI_ArchimedeDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); + globalSelection( GEOM_ALLSHAPES ); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); return; } @@ -244,19 +226,40 @@ void OperationGUI_ArchimedeDlg::enterEvent(QEvent* e) //================================================================================= -// function : ValueChangedInSpinBox() +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr OperationGUI_ArchimedeDlg::createOperation() +{ + return getGeomEngine()->GetILocalOperations( getStudyId() ); +} + +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool OperationGUI_ArchimedeDlg::isValid( QString& ) +{ + return !myShape->_is_nil(); +} + +//================================================================================= +// function : execute // purpose : //================================================================================= -void OperationGUI_ArchimedeDlg::ValueChangedInSpinBox(double newValue) +bool OperationGUI_ArchimedeDlg::execute( ObjectList& objects ) { - QObject* send = (QObject*)sender(); + GEOM::GEOM_Object_var anObj; - if(send == GroupPoints->SpinBox_DX) - myWeight = newValue; - else if(send == GroupPoints->SpinBox_DY) - myWaterDensity = newValue; - else if(send == GroupPoints->SpinBox_DZ) - myMeshingDeflection = newValue; + double aWeight = GroupPoints->SpinBox_DX->GetValue(); + double aWaterDensity = GroupPoints->SpinBox_DY->GetValue(); + double aMeshDeflection = GroupPoints->SpinBox_DZ->GetValue(); + + anObj = GEOM::GEOM_ILocalOperations::_narrow( + getOperation() )->MakeArchimede( myShape, aWeight, aWaterDensity, aMeshDeflection ); - return; + if ( !anObj->_is_nil() ) + objects.push_back( anObj._retn() ); + + return true; } diff --git a/src/OperationGUI/OperationGUI_ArchimedeDlg.h b/src/OperationGUI/OperationGUI_ArchimedeDlg.h index a9a14a1fe..b11b6fd8d 100644 --- a/src/OperationGUI/OperationGUI_ArchimedeDlg.h +++ b/src/OperationGUI/OperationGUI_ArchimedeDlg.h @@ -30,11 +30,8 @@ #define DIALOGBOX_ARCHIMEDE_H #include "GEOMBase_Skeleton.h" -#include "DlgRef_1Sel3Spin.h" -#include "OperationGUI.h" - -//#include "SALOME_InteractiveObject.hxx" +class DlgRef_1Sel3Spin; //================================================================================= // class : OperationGUI_ArchimedeDlg @@ -45,34 +42,33 @@ class OperationGUI_ArchimedeDlg : public GEOMBase_Skeleton Q_OBJECT public: - OperationGUI_ArchimedeDlg(QWidget* parent = 0, const char* name = 0, OperationGUI* theOperationGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); - ~OperationGUI_ArchimedeDlg(); - -private: - void Init(); - void enterEvent(QEvent* e); + OperationGUI_ArchimedeDlg( QWidget* parent, + SALOME_Selection* Sel ); + ~OperationGUI_ArchimedeDlg(); - double step; +protected: - OperationGUI* myOperationGUI; + // redefined from GEOMBase_Helper + + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& msg ); + virtual bool execute( ObjectList& objects ); - Handle(SALOME_InteractiveObject) myIO; - Standard_Real myWeight; - Standard_Real myWaterDensity; - Standard_Real myMeshingDeflection; - bool myOkIO; +private: + void Init( SALOME_Selection* ); + void enterEvent(QEvent* e); - DlgRef_1Sel3Spin* GroupPoints; +private: + GEOM::GEOM_Object_var myShape; + DlgRef_1Sel3Spin* GroupPoints; + double myStep; private slots: - void ClickOnOk(); - void ClickOnApply(); - void ActivateThisDialog(); - void LineEditReturnPressed(); - void SelectionIntoArgument(); - void SetEditCurrentArgument(); - void ValueChangedInSpinBox(double newValue); - + void ClickOnOk(); + bool ClickOnApply(); + void ActivateThisDialog(); + void LineEditReturnPressed(); + void SelectionIntoArgument(); }; #endif // DIALOGBOX_ARCHIMEDE_H diff --git a/src/OperationGUI/OperationGUI_ChamferDlg.cxx b/src/OperationGUI/OperationGUI_ChamferDlg.cxx index b4a171f40..856d941d1 100644 --- a/src/OperationGUI/OperationGUI_ChamferDlg.cxx +++ b/src/OperationGUI/OperationGUI_ChamferDlg.cxx @@ -24,62 +24,126 @@ // File : OperationGUI_ChamferDlg.cxx // Author : Damien COQUERET // Module : GEOM + // $Header$ -using namespace std; #include "OperationGUI_ChamferDlg.h" +#include "DlgRef_SpinBox.h" +#include "QAD_Desktop.h" +#include "qpixmap.h" +#include -#include "DisplayGUI.h" -#include "QAD_MessageBox.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include +#include "GEOMImpl_Types.hxx" //================================================================================= // class : OperationGUI_ChamferDlg() -// purpose : Constructs a OperationGUI_ChamferDlg which is a child of 'parent', with the +// purpose : Constructs a OperationGUI_ChamferDlg 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. //================================================================================= -OperationGUI_ChamferDlg::OperationGUI_ChamferDlg(QWidget* parent, const char* name, OperationGUI* theOperationGUI, SALOME_Selection* Sel, Handle(AIS_InteractiveContext) ic, bool modal, WFlags fl) - :GEOMBase_Skeleton(parent, name, Sel, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) +OperationGUI_ChamferDlg::OperationGUI_ChamferDlg( QWidget* parent, SALOME_Selection* Sel ) +: GEOMBase_Skeleton(parent, "ChamferDlg", Sel, false, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) { - QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_CHAMFER_ALL"))); - QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_CHAMFER_EDGE"))); - QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_CHAMFER_FACE"))); - QPixmap image3(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); - setCaption(tr("GEOM_CHAMFER_TITLE")); + mySelection = Sel; + myConstructorId = -1; + + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_CHAMFER_ALL"))); + QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_CHAMFER_EDGE"))); + QPixmap image3(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_CHAMFER_FACE"))); + QPixmap iconSelect(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); + + setCaption( tr( "GEOM_CHAMFER_TITLE" ) ); + + GroupConstructors->setTitle( tr( "GEOM_CHAMFER" ) ); + + RadioButton1->setPixmap( image1 ); + RadioButton2->setPixmap( image2 ); + RadioButton3->setPixmap( image3 ); + + // Create first group + + myGrp1 = new QGroupBox( 1, Qt::Horizontal, tr( "GEOM_CHAMFER_ALL" ), this ); + + QGroupBox* aSelGrp1 = new QGroupBox( 3, Qt::Horizontal, myGrp1 ); + aSelGrp1->setFrameStyle( QFrame::NoFrame ); + aSelGrp1->setInsideMargin( 0 ); + + createSelWg( tr( "GEOM_MAIN_OBJECT" ), iconSelect, aSelGrp1, MainObj1 ); + + QGroupBox* aSpinGrp = new QGroupBox( 1, Qt::Vertical, myGrp1 ); + aSpinGrp->setFrameStyle( QFrame::NoFrame ); + aSpinGrp->setInsideMargin( 0 ); + + new QLabel( tr( "D" ), aSpinGrp ); + mySpinBox[ SpinBox1 ] = new DlgRef_SpinBox( aSpinGrp ); + + ( new QFrame( myGrp1 ) )->setSizePolicy( + QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); + + // Create second group + + myGrp2 = new QGroupBox( 1, Qt::Horizontal, tr( "GEOM_CHAMFER_EDGES" ), this ); + + QGroupBox* aSelGrp2 = new QGroupBox( 3, Qt::Horizontal, myGrp2 ); + aSelGrp2->setFrameStyle( QFrame::NoFrame ); + aSelGrp2->setInsideMargin( 0 ); + + createSelWg( tr( "GEOM_MAIN_OBJECT" ), iconSelect, aSelGrp2, MainObj2 ); + createSelWg( tr( "FACE_1" ), iconSelect, aSelGrp2, Face1 ); + createSelWg( tr( "FACE_2" ), iconSelect, aSelGrp2, Face2 ); + + aSpinGrp = new QGroupBox( 1, Qt::Vertical, myGrp2 ); + aSpinGrp->setFrameStyle( QFrame::NoFrame ); + aSpinGrp->setInsideMargin( 0 ); + + new QLabel( tr( "GEOM_D1" ), aSpinGrp ); + mySpinBox[ SpinBox21 ] = new DlgRef_SpinBox( aSpinGrp ); - /***************************************************************/ - GroupConstructors->setTitle(tr("GEOM_CHAMFER")); - RadioButton1->setPixmap(image0); - RadioButton2->setPixmap(image1); - RadioButton3->setPixmap(image2); + new QLabel( tr( "GEOM_D2" ), aSpinGrp ); + mySpinBox[ SpinBox22 ] = new DlgRef_SpinBox( aSpinGrp ); - Group1 = new DlgRef_1Sel2Spin(this, "Group1"); - Group1->GroupBox1->setTitle(tr("GEOM_CHAMFER_ALL")); - Group1->TextLabel1->setText(tr("GEOM_MAIN_OBJECT")); - Group1->TextLabel2->setText(tr("GEOM_D1")); - Group1->TextLabel3->setText(tr("GEOM_D2")); - Group1->PushButton1->setPixmap(image3); + // Create third group - Layout1->addWidget(Group1, 1, 0); - /***************************************************************/ + myGrp3 = new QGroupBox( 1, Qt::Horizontal, tr( "GEOM_CHAMFER_FACES" ), this ); + + QGroupBox* aSelGrp3 = new QGroupBox( 3, Qt::Horizontal, myGrp3 ); + aSelGrp3->setFrameStyle( QFrame::NoFrame ); + aSelGrp3->setInsideMargin( 0 ); + + createSelWg( tr( "GEOM_MAIN_OBJECT" ), iconSelect, aSelGrp3, MainObj3 ); + createSelWg( tr( "SELECTED_FACES" ), iconSelect, aSelGrp3, Faces ); + + aSpinGrp = new QGroupBox( 1, Qt::Vertical, myGrp3 ); + aSpinGrp->setFrameStyle( QFrame::NoFrame ); + aSpinGrp->setInsideMargin( 0 ); + + new QLabel( tr( "GEOM_D1" ), aSpinGrp ); + mySpinBox[ SpinBox31 ] = new DlgRef_SpinBox( aSpinGrp ); + + new QLabel( tr( "GEOM_D2" ), aSpinGrp ); + mySpinBox[ SpinBox32 ] = new DlgRef_SpinBox( aSpinGrp ); + + ( new QLabel( myGrp3 ) )->setSizePolicy( + QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); + + // Add groups to layout + + Layout1->addWidget( myGrp1, 2, 0 ); + Layout1->addWidget( myGrp2, 2, 0 ); + Layout1->addWidget( myGrp3, 2, 0 ); + + // Set range of spinboxes + + double SpecificStep = 10.0; + QMap< int, DlgRef_SpinBox* >::iterator anIter; + for ( anIter = mySpinBox.begin(); anIter != mySpinBox.end(); ++anIter ) + anIter.data()->RangeStepAndValidator( 0.001, 999.999, SpecificStep, 3 ); /* Initialisations */ - myOperationGUI = theOperationGUI; - Init(ic); + Init( mySelection ); } @@ -88,8 +152,7 @@ OperationGUI_ChamferDlg::OperationGUI_ChamferDlg(QWidget* parent, const char* na // purpose : Destroys the object and frees any allocated resources //================================================================================= OperationGUI_ChamferDlg::~OperationGUI_ChamferDlg() -{ - /* no need to delete child widgets, Qt does it all for us */ +{ } @@ -97,51 +160,53 @@ OperationGUI_ChamferDlg::~OperationGUI_ChamferDlg() // function : Init() // purpose : //================================================================================= -void OperationGUI_ChamferDlg::Init(Handle (AIS_InteractiveContext) ic) +void OperationGUI_ChamferDlg::Init( SALOME_Selection* Sel ) { - /* init variables */ - myConstructorId = 0; - myEditCurrentArgument = Group1->LineEdit1; + mySelection = Sel; + myConstructorId = -1; + reset(); + RadioButton1->setChecked( true ); + myEditCurrentArgument = mySelName[ MainObj1 ]; - myD1 = 5.0; - myD2 = 5.0; - myOkShape = false; - myIC = ic; - myLocalContextId = -1; - myUseLocalContext = false; + /* signals and slots connections */ - double SpecificStep = 10.0; - /* min, max, step and decimals for spin boxes */ - Group1->SpinBox_DX->RangeStepAndValidator(0.001, 999.999, SpecificStep, 3); - Group1->SpinBox_DY->RangeStepAndValidator(0.001, 999.999, SpecificStep, 3); + // main buttons + connect( buttonOk , SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); + connect( buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) ); - Group1->SpinBox_DX->SetValue(myD1); - Group1->SpinBox_DY->SetValue(myD2); + // group box + connect( GroupConstructors, SIGNAL( clicked( int ) ), + this, SLOT( ConstructorsClicked( int ) ) ); - /* 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())); + // push buttons + QMap< int, QPushButton* >::iterator anIterBtn; + for ( anIterBtn = mySelBtn.begin(); anIterBtn != mySelBtn.end(); ++anIterBtn ) + connect( anIterBtn.data(), SIGNAL( clicked() ), + this, SLOT( SetEditCurrentArgument() ) ); - connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); - connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); - connect(GroupConstructors, SIGNAL(clicked(int)), this, SLOT(ConstructorsClicked(int))); + // line edits + QMap< int, QLineEdit* >::iterator anIterLE2; + for ( anIterLE2 = mySelName.begin(); anIterLE2 != mySelName.end(); ++anIterLE2 ) + connect( anIterLE2.data(), SIGNAL( returnPressed() ), + this, SLOT( LineEditReturnPressed() ) ); - connect(Group1->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect(Group1->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + // spin boxes + QMap< int, DlgRef_SpinBox* >::iterator anIterSpin; + for ( anIterSpin = mySpinBox.begin(); anIterSpin != mySpinBox.end(); ++anIterSpin ) + connect( anIterSpin.data(), SIGNAL( valueChanged( double ) ), + this, SLOT( ValueChangedInSpinBox( double ) ) ); - connect(Group1->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(Group1->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group1->SpinBox_DX, SLOT(SetStep(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group1->SpinBox_DY, SLOT(SetStep(double))); + // selection + connect( mySelection, SIGNAL( currentSelectionChanged() ), + this, SLOT( SelectionIntoArgument() ) ); - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + initName( tr( "GEOM_CHAMFER" ) ); - /* displays Dialog */ - Group1->show(); - this->show(); + myGrp2->hide(); + myGrp3->hide(); + myGrp1->show(); - return; + this->show(); } @@ -149,54 +214,77 @@ void OperationGUI_ChamferDlg::Init(Handle (AIS_InteractiveContext) ic) // function : ConstructorsClicked() // purpose : Radio button management //================================================================================= -void OperationGUI_ChamferDlg::ConstructorsClicked(int constructorId) +void OperationGUI_ChamferDlg::ConstructorsClicked( int constructorId ) { + // Activate next widget + if ( QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_OCC ) + { + RadioButton1->setChecked( true ); + return; + } + + if ( myConstructorId == constructorId ) + return; + + // Get values from previous widget + double D1 = 5, D2 = 5; + if ( myConstructorId == 0 ) + D1 = D2 = mySpinBox[ SpinBox1 ]->GetValue(); + else if ( myConstructorId == 1 ) + { + D1 = mySpinBox[ SpinBox21 ]->GetValue(); + D2 = mySpinBox[ SpinBox22 ]->GetValue(); + } + else if ( myConstructorId == 2 ) + { + D1 = mySpinBox[ SpinBox31 ]->GetValue(); + D2 = mySpinBox[ SpinBox32 ]->GetValue(); + } + myConstructorId = constructorId; - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); - disconnect(mySelection, 0, this, 0); - myOkShape = false; - myD1 = 5.0; - myD2 = 5.0; - - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC && myUseLocalContext) { - myIC->CloseLocalContext(myLocalContextId); - DisplayGUI* myDisplayGUI = new DisplayGUI(); - myDisplayGUI->OnDisplayAll(true); - myUseLocalContext = false; + + switch ( constructorId ) + { + case 0: + myGrp1->show(); + myGrp2->hide(); + myGrp3->hide(); + mySpinBox[ SpinBox1 ]->SetValue( D1 ); + break; + case 1: + myGrp1->hide(); + myGrp2->show(); + myGrp3->hide(); + mySpinBox[ SpinBox21 ]->SetValue( D1 ); + mySpinBox[ SpinBox22 ]->SetValue( D2 ); + break; + case 2: + myGrp1->hide(); + myGrp2->hide(); + myGrp3->show(); + mySpinBox[ SpinBox31 ]->SetValue( D1 ); + mySpinBox[ SpinBox32 ]->SetValue( D2 ); + break; + default: + break; } - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_OCC) { - myConstructorId = constructorId = 0; //No subshape selection if viewer is not OCC - RadioButton1->setChecked(TRUE); + if ( constructorId == 0 ) myEditCurrentArgument = mySelName[ MainObj1 ]; + else if ( constructorId == 1 ) myEditCurrentArgument = mySelName[ MainObj2 ]; + else myEditCurrentArgument = mySelName[ MainObj3 ]; + + activateSelection(); + enableWidgets(); + + if ( !myShape->_is_nil() ) + { + myEditCurrentArgument->setText( GEOMBase::GetName( myShape ) ); + GEOMBase_Skeleton::LineEditReturnPressed(); } + else + myEditCurrentArgument->setText( "" ); - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - Group1->LineEdit1->setText(""); - Group1->SpinBox_DX->SetValue(myD1); - Group1->SpinBox_DY->SetValue(myD2); - switch (constructorId) - { - case 0: /* Chamfer All */ - { - Group1->GroupBox1->setTitle(tr("GEOM_CHAMFER_ALL")); - myShapeType = -1; - break; - } - case 1: /* Chamfer edges */ - { - Group1->GroupBox1->setTitle(tr("GEOM_CHAMFER_EDGES")); - myShapeType = 6; - break; - } - case 2: /* Chamfer Faces */ - { - Group1->GroupBox1->setTitle(tr("GEOM_CHAMFER_FACES")); - myShapeType = 4; - break; - } - } - return; + displayPreview(); } @@ -206,69 +294,21 @@ void OperationGUI_ChamferDlg::ConstructorsClicked(int constructorId) //================================================================================= void OperationGUI_ChamferDlg::ClickOnOk() { - this->ClickOnApply(); - this->ClickOnCancel(); - return; + if ( ClickOnApply() ) + ClickOnCancel(); } - //================================================================================= // function : ClickOnApply() // purpose : //================================================================================= -void OperationGUI_ChamferDlg::ClickOnApply() +bool OperationGUI_ChamferDlg::ClickOnApply() { - buttonApply->setFocus(); - QApplication::setOverrideCursor(Qt::waitCursor); - QAD_Application::getDesktop()->putInfo(tr("")); - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); - - bool testResult = false; - switch(myConstructorId) - { - case 0 : /* Chamfer All */ - { - if(myOkShape) - testResult = myOperationGUI->OnChamferGetAll(myShape, myD1, myD2, myShapeType, myShapeIOR); - break; - } - case 1 : /* Chamfer Edge */ - { - if(myOkShape) - testResult = myOperationGUI->OnChamferGetSelected(myShape, myShapeIOR, myD1, myD2, myShapeType, - myLocalContextId, myUseLocalContext); - break; - } - case 2 : /* Chamfer Face */ - { - if(myOkShape) - testResult = myOperationGUI->OnChamferGetSelected(myShape, myShapeIOR, myD1, myD2, myShapeType, - myLocalContextId, myUseLocalContext); - break; - } - } - - if(!testResult) - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_ABORT")); - else - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); - /* Reset all arguments and local context to allow user a new selection ...*/ - this->ResetStateOfDialog(); - QApplication::restoreOverrideCursor(); - return; -} + if ( !onAccept() ) + return false; - -//================================================================================= -// function : ClickOnCancel() -// purpose : -//================================================================================= -void OperationGUI_ChamferDlg::ClickOnCancel() -{ - this->ResetStateOfDialog(); - GEOMBase_Skeleton::ClickOnCancel(); - return; + initName(); + return true; } @@ -278,77 +318,141 @@ void OperationGUI_ChamferDlg::ClickOnCancel() //================================================================================= void OperationGUI_ChamferDlg::SelectionIntoArgument() { - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); - myEditCurrentArgument->setText(""); - this->ResetStateOfDialog(); - QString aString = ""; /* name of selection */ - - int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString); - if (nbSel == 1) { - TopoDS_Shape S; - Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); - if(!myGeomBase->GetTopoFromSelection(mySelection, S)) - return; - if(!IO->hasEntry()) { - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY")); - return; + erasePreview(); + myEditCurrentArgument->setText( "" ); + + // Get index of current selection focus + int aCurrFocus = -1; + QMap< int, QLineEdit* >::iterator anIter; + for ( anIter = mySelName.begin(); anIter != mySelName.end(); ++anIter ) + if ( myEditCurrentArgument == anIter.data() ) + { + aCurrFocus = anIter.key(); + break; } - if(!S.IsNull() && S.ShapeType() <= 2) { - if(IO->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject))) { - Handle(GEOM_InteractiveObject) GIObject = Handle(GEOM_InteractiveObject)::DownCast(IO); - myShapeIOR = GIObject->getIOR(); /* the Geom IOR string of selection */ - myEditCurrentArgument->setText(aString); - myShape = S; - myOkShape = true; + // If selection of main object is activated + if ( aCurrFocus == MainObj1 || aCurrFocus == MainObj2 || aCurrFocus == MainObj3 ) + { + if ( mySelection->IObjectCount() == 1 ) + { + Standard_Boolean aResult = Standard_False; + GEOM::GEOM_Object_var anObj = + GEOMBase::ConvertIOinGEOMObject( mySelection->firstIObject(), aResult ); + + if ( aResult && !anObj->_is_nil() ) + { + myShape = anObj; + mySelName[ aCurrFocus ]->setText( GEOMBase::GetName( anObj ) ); + displayPreview(); + enableWidgets(); + return; } - - if(IO->hasEntry()) { - SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument(); - SALOMEDS::SObject_var obj = aStudy->FindObjectID(IO->getEntry()); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeIOR_var anIOR; - if(!obj->_is_nil()) { - if(obj->FindAttribute(anAttr, "AttributeIOR")) { - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - myShapeIOR = anIOR->Value(); - myOkShape = true; - myShape = S; - myEditCurrentArgument->setText(aString); - } - } + } + + myShape = GEOM::GEOM_Object::_nil(); + enableWidgets(); + } + // If face selection of second tab is activated + else if ( aCurrFocus == Face1 || aCurrFocus == Face2 ) + { + if ( mySelection->IObjectCount() == 1 ) + { + Standard_Boolean aResult = Standard_False; + GEOM::GEOM_Object_var anObj = + GEOMBase::ConvertIOinGEOMObject( mySelection->firstIObject(), aResult ); + + if ( aResult && !anObj->_is_nil() ) + { + TColStd_IndexedMapOfInteger anIndexes; + mySelection->GetIndex( mySelection->firstIObject(), anIndexes ); + + if ( anIndexes.Extent() == 1 ) + { + int anIndex = anIndexes( 1 ); + QString aFaceName = QString( GEOMBase::GetName( anObj ) ) + ":%1"; + myEditCurrentArgument->setText( aFaceName.arg( anIndex ) ); + myFace[ aCurrFocus ] = anIndex; + displayPreview(); + return; + } } } - if(myOkShape && QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC && myConstructorId == 0) - this->MakePreview(); + myFace[ aCurrFocus ] = -1; } - else - return; - - if(myOkShape && myShapeType!=-1 && myConstructorId != 0) { - /* local context is defined into the method */ - DisplayGUI* myDisplayGUI = new DisplayGUI(); - myDisplayGUI->PrepareSubShapeSelection(myShapeType, myLocalContextId); - myUseLocalContext = true; + // If face selection of third tab is activated + else if ( aCurrFocus == Faces ) + { + if ( mySelection->IObjectCount() == 1 ) + { + Standard_Boolean aResult = Standard_False; + GEOM::GEOM_Object_var anObj = + GEOMBase::ConvertIOinGEOMObject( mySelection->firstIObject(), aResult ); + + if ( aResult && !anObj->_is_nil() ) + { + TColStd_IndexedMapOfInteger anIndexes; + mySelection->GetIndex( mySelection->firstIObject(), anIndexes ); + + if ( anIndexes.Extent() > 0 ) + { + QString aFaceName; + if ( anIndexes.Extent() == 1 ) + { + int anIndex = anIndexes( 1 ); + + aFaceName = QString( GEOMBase::GetName( anObj ) ) + QString( ":%1" ).arg( anIndex ); + } + else + aFaceName = tr( "GEOM_MEN_POPUP_NAME" ).arg( anIndexes.Extent() ); + + myEditCurrentArgument->setText( aFaceName ); + myFaces = anIndexes; + displayPreview(); + return; + } + } + } + myFaces.Clear(); } } +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void OperationGUI_ChamferDlg::LineEditReturnPressed() +{ + QLineEdit* aSender = ( QLineEdit* )sender(); + + QMap< int, QLineEdit* >::iterator anIterLE; + for ( anIterLE = mySelName.begin(); anIterLE != mySelName.end(); ++anIterLE ) + if ( anIterLE.data() == aSender ) + myEditCurrentArgument = anIterLE.data(); + + GEOMBase_Skeleton::LineEditReturnPressed(); +} + + //================================================================================= // function : SetEditCurrentArgument() // purpose : //================================================================================= void OperationGUI_ChamferDlg::SetEditCurrentArgument() { - QPushButton* send = (QPushButton*)sender(); + QPushButton* aSender = ( QPushButton* )sender(); - if(send == Group1->PushButton1) - Group1->LineEdit1->setFocus(); + QMap< int, QPushButton* >::iterator anIter; + for ( anIter = mySelBtn.begin(); anIter != mySelBtn.end(); ++anIter ) + if ( anIter.data() == aSender ) + { + mySelName[ anIter.key() ]->setFocus(); + myEditCurrentArgument = mySelName[ anIter.key() ]; + } - this->SelectionIntoArgument(); - return; + activateSelection(); } @@ -358,9 +462,8 @@ void OperationGUI_ChamferDlg::SetEditCurrentArgument() //================================================================================= void OperationGUI_ChamferDlg::DeactivateActiveDialog() { - this->ResetStateOfDialog(); + // disconnect selection GEOMBase_Skeleton::DeactivateActiveDialog(); - return; } @@ -371,10 +474,12 @@ void OperationGUI_ChamferDlg::DeactivateActiveDialog() void OperationGUI_ChamferDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - if(!mySimulationTopoDs.IsNull()) - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - return; + + connect( mySelection, SIGNAL(currentSelectionChanged()), + this, SLOT( SelectionIntoArgument() ) ); + + activateSelection(); + displayPreview(); } @@ -384,113 +489,213 @@ void OperationGUI_ChamferDlg::ActivateThisDialog() //================================================================================= void OperationGUI_ChamferDlg::enterEvent(QEvent* e) { - if(GroupConstructors->isEnabled()) - return; - this->ActivateThisDialog(); - return; + if ( !GroupConstructors->isEnabled() ) + this->ActivateThisDialog(); } //================================================================================= -// function : closeEvent() +// function : ValueChangedInSpinBox() // purpose : //================================================================================= -void OperationGUI_ChamferDlg::closeEvent(QCloseEvent* e) -{ - /* same than click on cancel button */ - this->ClickOnCancel(); - return; +void OperationGUI_ChamferDlg::ValueChangedInSpinBox( double newValue ) +{ + displayPreview(); } //================================================================================= -// function : ValueChangedInSpinBox() +// function : createSelWg() // purpose : //================================================================================= -void OperationGUI_ChamferDlg::ValueChangedInSpinBox(double newValue) +void OperationGUI_ChamferDlg::createSelWg( const QString& theLbl, + QPixmap& thePix, + QWidget* theParent, + const int theId ) { - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); + new QLabel( theLbl, theParent ); + mySelBtn[ theId ] = new QPushButton( theParent ); + mySelBtn[ theId ]->setPixmap( thePix ); + mySelName[ theId ] = new QLineEdit( theParent ); + mySelName[ theId ]->setReadOnly( true ); +} - QObject* send = (QObject*)sender(); - if(send == Group1->SpinBox_DX) /* D1 */ - myD1 = newValue; - else if(send == Group1->SpinBox_DY) /* D2 */ - myD2 = newValue; +//================================================================================= +// function : reset() +// purpose : +//================================================================================= +void OperationGUI_ChamferDlg::reset() +{ + // Set Initial values of spinboxes + QMap< int, DlgRef_SpinBox* >::iterator anIter; + for ( anIter = mySpinBox.begin(); anIter != mySpinBox.end(); ++anIter ) + anIter.data()->SetValue( 5 ); - if(myOkShape && QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC && myConstructorId == 0) - this->MakePreview(); + // clear line edits + QMap< int, QLineEdit* >::iterator anIterLE; + for ( anIterLE = mySelName.begin(); anIterLE != mySelName.end(); ++anIterLE ) + anIterLE.data()->setText( "" ); - return; -} + // constructor id + int aConstructorId = getConstructorId(); + if ( aConstructorId == 0 ) myEditCurrentArgument = mySelName[ MainObj1 ]; + else if ( aConstructorId == 1 ) myEditCurrentArgument = mySelName[ MainObj2 ]; + else myEditCurrentArgument = mySelName[ MainObj3 ]; + + myShape = GEOM::GEOM_Object::_nil(); + + myFaces.Clear(); + myFace[ Face1 ] = -1; + myFace[ Face2 ] = -1; + + erasePreview( true ); + + activateSelection(); + + enableWidgets(); +} //================================================================================= -// function : ResetStateOfDialog() +// function : getConstructorId() // purpose : //================================================================================= -void OperationGUI_ChamferDlg::ResetStateOfDialog() +int OperationGUI_ChamferDlg::getConstructorId() const +{ + return GroupConstructors->id( GroupConstructors->selected() ); +} + +//================================================================================= +// function : activateSelection +// purpose : Activate selection in accordance with myEditCurrentArgument +//================================================================================= +void OperationGUI_ChamferDlg::activateSelection() { - myOkShape = false; - myEditCurrentArgument->setText(""); - QApplication::restoreOverrideCursor(); - - /* Close its local contact if opened */ - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC && myUseLocalContext) { - myIC->CloseLocalContext(myLocalContextId); - myUseLocalContext = false; - DisplayGUI* myDisplayGUI = new DisplayGUI(); - myDisplayGUI->OnDisplayAll(true); + if ( !myShape->_is_nil() && + ( myEditCurrentArgument == mySelName[ Face1 ] || + myEditCurrentArgument == mySelName[ Face2 ] || + myEditCurrentArgument == mySelName[ Faces ] ) ) + localSelection( myShape, TopAbs_FACE ); + else + { + TColStd_MapOfInteger aMap; + aMap.Add( GEOM_SHELL ); + aMap.Add( GEOM_SOLID ); + aMap.Add( GEOM_COMPOUND ); + globalSelection( aMap ); } - return; + + SelectionIntoArgument(); } +//================================================================================= +// function : enableWidgets +// purpose : Enable widgets of faces in accordance with value of main object +//================================================================================= +void OperationGUI_ChamferDlg::enableWidgets() +{ + int anId = getConstructorId(); + + bool toEnable = !myShape->_is_nil(); + + if ( anId == 1 ) + { + mySelName[ Face1 ]->setEnabled( toEnable ); + mySelName[ Face2 ]->setEnabled( toEnable ); + mySelBtn[ Face1 ]->setEnabled( toEnable ); + mySelBtn[ Face2 ]->setEnabled( toEnable ); + + if ( !toEnable ) + { + mySelName[ Face1 ]->setText( "" ); + mySelName[ Face2 ]->setText( "" ); + myFace[ Face1 ] = -1; + myFace[ Face2 ] = -1; + } + } + else if ( anId == 2 ) + { + mySelName[ Faces ]->setEnabled( toEnable ); + + if ( !toEnable ) + myFaces.Clear(); + } +} //================================================================================= -// function : MakePreview() +// function : createOperation // purpose : //================================================================================= -void OperationGUI_ChamferDlg::MakePreview() +GEOM::GEOM_IOperations_ptr OperationGUI_ChamferDlg::createOperation() { - QApplication::setOverrideCursor(Qt::waitCursor); - TopoDS_Shape tds; - - try { - BRepFilletAPI_MakeChamfer MC(myShape); - switch(myConstructorId) - { - case 0: /* Chamfer All */ - { - TopTools_IndexedDataMapOfShapeListOfShape M; - TopExp::MapShapesAndAncestors(myShape, TopAbs_EDGE, TopAbs_FACE, M); - for(int i = 1; i <= M.Extent(); i++) { - TopoDS_Edge E = TopoDS::Edge(M.FindKey(i)); - TopoDS_Face F = TopoDS::Face(M.FindFromIndex(i).First()); - if(!BRepTools::IsReallyClosed(E, F) && !BRep_Tool::Degenerated(E)) - MC.Add(myD1, myD2, E, F); - } - tds = MC.Shape(); - break; - } - // case 1: /* Chamfer edges */ - // case 2: /* Chamfer Faces */ - } + return getGeomEngine()->GetILocalOperations( getStudyId() ); +} - if(!tds.IsNull()) { - mySimulationTopoDs = tds; - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - } +//================================================================================= +// function : ClickOnApply() +// purpose : Verify validity of input data +//================================================================================= +bool OperationGUI_ChamferDlg::isValid( QString& ) +{ + switch ( getConstructorId() ) + { + case 0: return !myShape->_is_nil(); + case 1: return !myShape->_is_nil() && myFace[ Face1 ] > 0 && myFace[ Face2 ] > 0; + case 2: return !myShape->_is_nil() && myFaces.Extent() > 0; + default: return false; } - catch(Standard_Failure) { - QApplication::restoreOverrideCursor(); - QAD_MessageBox::warn1 (QAD_Application::getDesktop(), tr("GEOM_WRN_WARNING"), tr("GEOM_CHAMFER_ABORT").arg(myD1).arg(myD2), tr("GEOM_BUT_OK")); - QApplication::setOverrideCursor(Qt::waitCursor); - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); - Group1->SpinBox_DX->SetValue(5.0); - Group1->SpinBox_DY->SetValue(5.0); +} + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool OperationGUI_ChamferDlg::execute( ObjectList& objects ) +{ + GEOM::GEOM_Object_var anObj; + + int anId = getConstructorId(); + if ( anId == 0 ) + anObj = GEOM::GEOM_ILocalOperations::_narrow( + getOperation() )->MakeChamferAll( myShape, + mySpinBox[ SpinBox1 ]->GetValue() ); + else if ( anId == 1 ) + anObj = GEOM::GEOM_ILocalOperations::_narrow( + getOperation() )->MakeChamferEdge( myShape, + mySpinBox[ SpinBox21 ]->GetValue(), + mySpinBox[ SpinBox22 ]->GetValue(), + myFace[ Face1 ], + myFace[ Face2 ] ); + else if ( anId == 2 ) + { + + int i = 0; + GEOM::ListOfLong_var anArray = new GEOM::ListOfLong; + anArray->length( myFaces.Extent() ); + + + for ( int i = 1, n = myFaces.Extent(); i <= n; i++ ) + anArray[ i - 1 ] = myFaces( i ); + + anObj = GEOM::GEOM_ILocalOperations::_narrow( + getOperation() )->MakeChamferFaces( myShape, + mySpinBox[ SpinBox31 ]->GetValue(), + mySpinBox[ SpinBox32 ]->GetValue(), + anArray ); } - QApplication::restoreOverrideCursor(); - return; + + if ( !anObj->_is_nil() ) + objects.push_back( anObj._retn() ); + + return true; } + + + + + + + + + diff --git a/src/OperationGUI/OperationGUI_ChamferDlg.h b/src/OperationGUI/OperationGUI_ChamferDlg.h index 320bc37c9..1291337bc 100644 --- a/src/OperationGUI/OperationGUI_ChamferDlg.h +++ b/src/OperationGUI/OperationGUI_ChamferDlg.h @@ -30,9 +30,9 @@ #define DIALOGBOX_CHAMFER_H #include "GEOMBase_Skeleton.h" -#include "DlgRef_1Sel2Spin.h" +#include -#include "OperationGUI.h" +class DlgRef_SpinBox; //================================================================================= // class : OperationGUI_ChamferDlg @@ -42,48 +42,57 @@ class OperationGUI_ChamferDlg : public GEOMBase_Skeleton { Q_OBJECT + enum { MainObj1, MainObj2, Face1, Face2, MainObj3, Faces }; + enum { SpinBox1, SpinBox21, SpinBox22, SpinBox31, SpinBox32 }; + public: - OperationGUI_ChamferDlg(QWidget* parent = 0, const char* name = 0, OperationGUI* theOperationGUI = 0, SALOME_Selection* Sel = 0, Handle(AIS_InteractiveContext) ic = 0, bool modal = FALSE, WFlags fl = 0); - ~OperationGUI_ChamferDlg(); + OperationGUI_ChamferDlg( QWidget* parent, + SALOME_Selection* Sel ); + virtual ~OperationGUI_ChamferDlg(); -private : - void Init(Handle(AIS_InteractiveContext) ic); - void enterEvent(QEvent* e); - void closeEvent(QCloseEvent* e); - void MakeFilletSimulationAndDisplay(); +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& msg ); + virtual bool execute( ObjectList& objects ); + +private slots: - void ResetStateOfDialog(); - void MakePreview(); + void ClickOnOk(); + bool ClickOnApply(); + void ActivateThisDialog(); + void DeactivateActiveDialog(); + void LineEditReturnPressed(); + void SelectionIntoArgument(); + void SetEditCurrentArgument(); + void ValueChangedInSpinBox( double newValue ); + void ConstructorsClicked( int constructorId ); - OperationGUI* myOperationGUI; +private : - int myConstructorId; /* Current constructor id = radio button id */ + void Init( SALOME_Selection* ); + void enterEvent( QEvent* e ); + void reset(); + void createSelWg( const QString&, QPixmap&, QWidget*, const int ); + int getConstructorId() const; + void activateSelection(); + void enableWidgets(); - /* Interactive and local context management see also : bool myUseLocalContext() */ - Handle(AIS_InteractiveContext) myIC; /* Interactive context */ - Standard_Integer myLocalContextId; /* identify a local context used by this method */ - bool myUseLocalContext; /* true when this method as opened a local context */ +private: - TopoDS_Shape myShape; - bool myOkShape; - char* myShapeIOR; - int myShapeType; - double myD1; - double myD2; - - DlgRef_1Sel2Spin* Group1; + int myConstructorId; -private slots: - void ClickOnOk(); - void ClickOnApply(); - void ClickOnCancel(); - void ActivateThisDialog(); - void DeactivateActiveDialog(); - void SelectionIntoArgument(); - void SetEditCurrentArgument(); - void ValueChangedInSpinBox(double newValue); - void ConstructorsClicked(int constructorId); + GEOM::GEOM_Object_var myShape; + QMap< int, int > myFace; // indexes of faces from second tab ( Face1,2 ) + TColStd_IndexedMapOfInteger myFaces; // indexes of faces from first tab ( Faces ) + + QFrame* myGrp1; + QFrame* myGrp2; + QFrame* myGrp3; + QMap< int, QPushButton* > mySelBtn; + QMap< int, QLineEdit* > mySelName; + QMap< int, DlgRef_SpinBox* > mySpinBox; }; #endif // DIALOGBOX_CHAMFER_H diff --git a/src/OperationGUI/OperationGUI_ClippingDlg.cxx b/src/OperationGUI/OperationGUI_ClippingDlg.cxx new file mode 100644 index 000000000..932627e35 --- /dev/null +++ b/src/OperationGUI/OperationGUI_ClippingDlg.cxx @@ -0,0 +1,392 @@ +// 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 : OperationGUI_ClippingDlg.cxx +// Author : Michael Zorin +// Module : GEOM +// $Header: + +#include "OperationGUI_ClippingDlg.h" +#include "DlgRef_SpinBox.h" + +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "QAD_RightFrame.h" +#include "VTKViewer_ViewFrame.h" +#include "OCCViewer_ViewFrame.h" +#include "QAD_MessageBox.h" +#include "utilities.h" +#include "OCCViewer_ViewPort3d.h" +#include "OCCViewer_Viewer3d.h" +#include +#include + +//#include + +// QT Includes +#include +#include +#include +#include +#include + +// VTK Includes +#include +#include + +//================================================================================= +// class : OperationGUI_ClippingDlg() +// purpose : +//================================================================================= +OperationGUI_ClippingDlg::OperationGUI_ClippingDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl ) + : GEOMBase_Skeleton( parent, "OperationGUI_ClippingDlg", 0, false, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) +{ + setCaption( tr( "Change clipping range" ) ); + + GroupConstructors->close(); + GroupBoxName->close(); + + /***************************************************************/ + GroupArguments = new QGroupBox( this, "GroupArguments" ); + GroupArguments->setColumnLayout(0, Qt::Vertical ); + GroupArguments->layout()->setSpacing( 0 ); + GroupArguments->layout()->setMargin( 0 ); + QGridLayout* GroupArgumentsLayout = new QGridLayout( GroupArguments->layout() ); + GroupArgumentsLayout->setAlignment( Qt::AlignTop ); + GroupArgumentsLayout->setSpacing( 6 ); + GroupArgumentsLayout->setMargin( 11 ); + + // Controls + TextLabelNear = new QLabel( GroupArguments, "TextLabelNear" ); + TextLabelNear->setText( tr( "Near" ) ); + //mzn TextLabelNear->setFixedWidth(74); + GroupArgumentsLayout->addWidget( TextLabelNear, 0, 0 ); + + SpinBox_Near = new DlgRef_SpinBox( GroupArguments, "SpinBox_Near"); + GroupArgumentsLayout->addWidget( SpinBox_Near, 0, 1 ); + + TextLabelFar = new QLabel( GroupArguments, "TextLabelFar" ); + TextLabelFar->setText( tr( "Far" ) ); + //mzn TextLabelFar->setFixedWidth(74); + GroupArgumentsLayout->addWidget( TextLabelFar, 0, 2 ); + + SpinBox_Far = new DlgRef_SpinBox( GroupArguments, "SpinBox_Far"); + GroupArgumentsLayout->addWidget( SpinBox_Far, 0, 3 ); + + resetButton = new QPushButton( GroupArguments, "resetButton" ); + resetButton->setText( tr( "Reset" ) ); + GroupArgumentsLayout->addWidget( resetButton, 0, 4 ); + + TypeCB = new QComboBox( GroupArguments, "TypeCB" ); + TypeCB->insertItem(tr("OFF")); + TypeCB->insertItem(tr("BACK")); + TypeCB->insertItem(tr("FRONT")); + TypeCB->insertItem(tr("SLICE")); + GroupArgumentsLayout->addMultiCellWidget( TypeCB, 1, 1, 0, 4 ); + + Layout1->addWidget( GroupArguments, 2, 0 ); + + /* Initialisations */ + SpinBox_Near->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); + SpinBox_Far->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); + + //GeometryGUI* aGeomGUI = GeometryGUI::GetGeomGUI(); + + /* signals and slots connections */ + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; + connect( buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) ); + + connect( resetButton, SIGNAL (clicked() ), this, SLOT( onReset() ) ) ; + + // connect( aGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( onDeactivate() ) ) ; + //connect( aGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; + + Init(); +} + +//================================================================================= +// function : ~ OperationGUI_ClippingDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +OperationGUI_ClippingDlg::~ OperationGUI_ClippingDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void OperationGUI_ClippingDlg::Init() +{ + QAD_ViewFrame* aFrame = QAD_Application::getDesktop()->getActiveApp()-> + getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame(); + + VTKViewer_ViewFrame* aVTKFrame = dynamic_cast( aFrame ); + if ( aVTKFrame ) + { + TextLabelNear->setText( tr( "Near" ) ); + TextLabelFar->setText( tr( "Far" ) ); + + TypeCB->hide(); + + vtkRenderer* aRenderer = aVTKFrame->getRenderer(); + if(!aRenderer) return; + + vtkCamera* anActiveCamera = aRenderer->GetActiveCamera(); + if( anActiveCamera == NULL ){ + MESSAGE("Trying to reset clipping range of non-existant camera"); + return; + } + + // Find the plane equation for the camera view plane + double vn[3]; + anActiveCamera->GetViewPlaneNormal(vn); + double position[3]; + anActiveCamera->GetPosition(position); + + float bounds[6]; + aRenderer->ComputeVisiblePropBounds(bounds); + + double center[3]; + center[0] = (bounds[0] + bounds[1])/2.0; + center[1] = (bounds[2] + bounds[3])/2.0; + center[2] = (bounds[4] + bounds[5])/2.0; + + double width = sqrt((bounds[1]-bounds[0])*(bounds[1]-bounds[0]) + + (bounds[3]-bounds[2])*(bounds[3]-bounds[2]) + + (bounds[5]-bounds[4])*(bounds[5]-bounds[4])); + + double distance = sqrt((position[0]-center[0])*(position[0]-center[0]) + + (position[1]-center[1])*(position[1]-center[1]) + + (position[2]-center[2])*(position[2]-center[2])); + + float range[2] = {distance - width/2.0, distance + width/2.0}; + + SpinBox_Near->SetValue(range[0]); + SpinBox_Far->SetValue(range[1]); + + return; + } + + OCCViewer_ViewFrame* aOCCFrame = dynamic_cast( aFrame ); + if ( aOCCFrame ) + { + TextLabelNear->setText( tr( "Depth" ) ); + TextLabelFar->setText( tr( "Thickness" ) ); + + Handle(V3d_View) view3d = ((OCCViewer_ViewPort3d*)aOCCFrame->getViewPort())->getView(); + + double depth, thickness; + int ztype= view3d->ZClipping(depth, thickness); + SpinBox_Near->SetValue(depth); + SpinBox_Far->SetValue(thickness); + TypeCB->setCurrentItem(ztype); + + //Handle(V3d_Plane) aPlane = new V3d_Plane( aOCCFrame->getViewer()->getViewer3d() ,0, 0, 1, -100); + //aPlane->Display(view3d); + } +} + + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +bool OperationGUI_ClippingDlg::ClickOnApply() +{ + QAD_ViewFrame* aFrame = QAD_Application::getDesktop()->getActiveApp()-> + getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame(); + + VTKViewer_ViewFrame* aVTKFrame = dynamic_cast( aFrame ); + if ( aVTKFrame ) + { + vtkRenderer* aRenderer = aVTKFrame->getRenderer(); + if(!aRenderer) return false; + + vtkCamera* anActiveCamera = aRenderer->GetActiveCamera(); + if( anActiveCamera == NULL ){ + MESSAGE("Trying to reset clipping range of non-existant camera"); + return false; + } + + float range[2] = { SpinBox_Near->GetValue(), SpinBox_Far->GetValue() }; + if (range[0] < 0.0) range[0] = 0.0; + anActiveCamera->SetClippingRange( range ); + + return true; + } + + OCCViewer_ViewFrame* aOCCFrame = dynamic_cast( aFrame ); + if ( aOCCFrame ) + { + Handle(V3d_View) view3d = ((OCCViewer_ViewPort3d*)aOCCFrame->getViewPort())->getView(); + + double depth = SpinBox_Near->GetValue(); + double thickness = SpinBox_Far->GetValue(); + int aType = TypeCB->currentItem(); + + view3d->SetZClippingType(V3d_TypeOfZclipping(aType)); + view3d->SetZClippingDepth(depth); + view3d->SetZClippingWidth(thickness); + } + + return true; +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void OperationGUI_ClippingDlg::ClickOnOk() +{ + ClickOnApply(); + ClickOnCancel(); +} + + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void OperationGUI_ClippingDlg::ClickOnCancel() +{ + GEOMBase_Skeleton::ClickOnCancel(); +} + + +//================================================================================= +// function : onActivate() +// purpose : +//================================================================================= +void OperationGUI_ClippingDlg::onActivate() +{ + GEOMBase_Skeleton::ActivateThisDialog(); +} + + +//================================================================================= +// function : onDeactivate() +// purpose : public slot to deactivate if active +//================================================================================= +void OperationGUI_ClippingDlg::DeactivateActiveDialog() +{ + return; +} + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void OperationGUI_ClippingDlg::enterEvent(QEvent* e) +{ + this->setEnabled(true); + return; +} + + +//================================================================================= +// function : closeEvent +// purpose : +//================================================================================= +void OperationGUI_ClippingDlg::closeEvent( QCloseEvent* e ) +{ + QDialog::closeEvent( e ); +} + + +//================================================================================= +// function : onReset() +// purpose : +//================================================================================= +void OperationGUI_ClippingDlg::onReset() +{ + QAD_ViewFrame* aFrame = QAD_Application::getDesktop()->getActiveApp()-> + getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame(); + + VTKViewer_ViewFrame* aVTKFrame = dynamic_cast( aFrame ); + if ( aVTKFrame ) + { + vtkRenderer* aRenderer = aVTKFrame->getRenderer(); + if(!aRenderer) return; + + vtkCamera* anActiveCamera = aRenderer->GetActiveCamera(); + if( anActiveCamera == NULL ){ + MESSAGE("Trying to reset clipping range of non-existant camera"); + return; + } + + // Find the plane equation for the camera view plane + double vn[3]; + anActiveCamera->GetViewPlaneNormal(vn); + double position[3]; + anActiveCamera->GetPosition(position); + + float bounds[6]; + aRenderer->ComputeVisiblePropBounds(bounds); + + double center[3]; + center[0] = (bounds[0] + bounds[1])/2.0; + center[1] = (bounds[2] + bounds[3])/2.0; + center[2] = (bounds[4] + bounds[5])/2.0; + + double width = sqrt((bounds[1]-bounds[0])*(bounds[1]-bounds[0]) + + (bounds[3]-bounds[2])*(bounds[3]-bounds[2]) + + (bounds[5]-bounds[4])*(bounds[5]-bounds[4])); + + double distance = sqrt((position[0]-center[0])*(position[0]-center[0]) + + (position[1]-center[1])*(position[1]-center[1]) + + (position[2]-center[2])*(position[2]-center[2])); + + float range[2] = {distance - width/2.0, distance + width/2.0}; + + SpinBox_Near->SetValue(range[0]); + SpinBox_Far->SetValue(range[1]); + + return; + } + + OCCViewer_ViewFrame* aOCCFrame = dynamic_cast( aFrame ); + if ( aOCCFrame ) + { + TextLabelNear->setText( tr( "Depth" ) ); + TextLabelFar->setText( tr( "Thickness" ) ); + + Handle(V3d_View) view3d = ((OCCViewer_ViewPort3d*)aOCCFrame->getViewPort())->getView(); + + view3d->SetZClippingType(V3d_TypeOfZclipping(0)); + view3d->ZFitAll(); + double depth, thickness; + int ztype= view3d->ZClipping(depth, thickness); + SpinBox_Near->SetValue(0); + SpinBox_Far->SetValue(1000); + TypeCB->setCurrentItem(ztype); + } + + + + return; +} diff --git a/src/OperationGUI/OperationGUI_ClippingDlg.h b/src/OperationGUI/OperationGUI_ClippingDlg.h new file mode 100644 index 000000000..b59306ef7 --- /dev/null +++ b/src/OperationGUI/OperationGUI_ClippingDlg.h @@ -0,0 +1,81 @@ +// 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 : OperationGUI_ClippingDlg.h +// Author : Michael Zorin +// Module : GEOM +// $Header: + +#ifndef DIALOGBOX_CLIPPINGRANGE_H +#define DIALOGBOX_CLIPPING_H + +#include "GEOMBase_Skeleton.h" + +class QGroupBox; +class QLabel; +class QPushButton; +class QComboBox; +class DlgRef_SpinBox; + +enum ViewerTypes { VTK, OCC, OTHER }; + +//================================================================================= +// class : OperationGUI_ClippingDlg +// purpose : +//================================================================================= +class OperationGUI_ClippingDlg : public GEOMBase_Skeleton +{ + Q_OBJECT + + public: + OperationGUI_ClippingDlg(QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + ~OperationGUI_ClippingDlg(); + +private : + + void Init(); + + ViewerTypes myViewerType; + + virtual void closeEvent( QCloseEvent* e ); + void enterEvent(QEvent* e); + + QGroupBox* GroupArguments; + QLabel* TextLabelNear; + DlgRef_SpinBox* SpinBox_Near; + QLabel* TextLabelFar; + DlgRef_SpinBox* SpinBox_Far; + QPushButton* resetButton; + QComboBox* TypeCB; + +private slots: + void ClickOnOk(); + bool ClickOnApply(); + void ClickOnCancel(); + void onActivate(); + void DeactivateActiveDialog(); + + void onReset(); +}; + +#endif // DIALOGBOX_CLIPPINGRANGE_H diff --git a/src/OperationGUI/OperationGUI_FilletDlg.cxx b/src/OperationGUI/OperationGUI_FilletDlg.cxx index 470d0e226..ae49d6c2e 100644 --- a/src/OperationGUI/OperationGUI_FilletDlg.cxx +++ b/src/OperationGUI/OperationGUI_FilletDlg.cxx @@ -26,20 +26,15 @@ // Module : GEOM // $Header$ -using namespace std; #include "OperationGUI_FilletDlg.h" +#include "DlgRef_1Sel1Spin.h" +#include "DlgRef_2Sel1Spin.h" +#include "QAD_Desktop.h" +#include "qpixmap.h" +#include +#include -#include "DisplayGUI.h" -#include "QAD_MessageBox.h" - -#include -#include -#include -#include -#include - -#include -#include +#include "GEOMImpl_Types.hxx" //================================================================================= // class : OperationGUI_FilletDlg() @@ -48,34 +43,66 @@ using namespace std; // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -OperationGUI_FilletDlg::OperationGUI_FilletDlg(QWidget* parent, const char* name, OperationGUI* theOperationGUI, SALOME_Selection* Sel, Handle(AIS_InteractiveContext) ic, bool modal, WFlags fl) - :GEOMBase_Skeleton(parent, name, Sel, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) +OperationGUI_FilletDlg::OperationGUI_FilletDlg( QWidget* parent, SALOME_Selection* Sel ) + :GEOMBase_Skeleton( parent, "OperationGUI_FilletDlg", Sel, false, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) { - QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_FILLET_ALL"))); - QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_FILLET_EDGE"))); - QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_FILLET_FACE"))); - QPixmap image3(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); + myConstructorId = -1; + mySelection = Sel; + + QPixmap image0( QAD_Desktop::getResourceManager()->loadPixmap( "GEOM", tr( "ICON_DLG_FILLET_ALL" ) ) ); + QPixmap image1( QAD_Desktop::getResourceManager()->loadPixmap( "GEOM", tr( "ICON_DLG_FILLET_EDGE" ) ) ); + QPixmap image2( QAD_Desktop::getResourceManager()->loadPixmap( "GEOM", tr( "ICON_DLG_FILLET_FACE" ) ) ); + + QPixmap iconSelect( QAD_Desktop::getResourceManager()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) ); - setCaption(tr("GEOM_FILLET_TITLE")); + setCaption( tr( "GEOM_FILLET_TITLE" ) ); /***************************************************************/ - GroupConstructors->setTitle(tr("GEOM_FILLET")); - RadioButton1->setPixmap(image0); - RadioButton2->setPixmap(image1); - RadioButton3->setPixmap(image2); - - Group1 = new DlgRef_1Sel1Spin(this, "Group1"); - Group1->GroupBox1->setTitle(tr("GEOM_FILLET_ALL")); - Group1->TextLabel1->setText(tr("GEOM_MAIN_OBJECT")); - Group1->TextLabel2->setText(tr("GEOM_RADIUS")); - Group1->PushButton1->setPixmap(image3); - - Layout1->addWidget(Group1, 1, 0); + GroupConstructors->setTitle( tr( "GEOM_FILLET" ) ); + RadioButton1->setPixmap( image0 ); + RadioButton2->setPixmap( image1 ); + RadioButton3->setPixmap( image2 ); + + Group1 = new DlgRef_1Sel1Spin( this, "Group1" ); + Group1->GroupBox1->setTitle( tr( "GEOM_FILLET_ALL" ) ); + Group1->TextLabel1->setText( tr( "GEOM_MAIN_OBJECT" ) ); + Group1->TextLabel2->setText( tr( "GEOM_RADIUS" ) ); + Group1->PushButton1->setPixmap( iconSelect ); + Group1->LineEdit1->setReadOnly( true ); + + Group2 = new DlgRef_2Sel1Spin( this, "Group2" ); + Group2->GroupBox1->setTitle( tr( "GEOM_FILLET_EDGES" ) ); + Group2->TextLabel1->setText( tr( "GEOM_MAIN_OBJECT" ) ); + Group2->TextLabel2->setText( tr( "SELECTED_EDGES" ) ); + Group2->TextLabel3->setText( tr( "GEOM_RADIUS" ) ); + Group2->PushButton1->setPixmap( iconSelect ); + Group2->PushButton2->setPixmap( iconSelect ); + Group2->LineEdit1->setReadOnly( true ); + Group2->LineEdit2->setReadOnly( true ); + + Group3 = new DlgRef_2Sel1Spin( this, "Group3" ); + Group3->GroupBox1->setTitle(tr( "GEOM_FILLET_FACES" ) ); + Group3->TextLabel1->setText(tr( "GEOM_MAIN_OBJECT" ) ); + Group3->TextLabel2->setText(tr( "SELECTED_FACES" ) ); + Group3->TextLabel3->setText(tr( "GEOM_RADIUS" ) ); + Group3->PushButton1->setPixmap( iconSelect ); + Group3->PushButton2->setPixmap( iconSelect ); + Group3->LineEdit1->setReadOnly( true ); + Group3->LineEdit2->setReadOnly( true ); + + Layout1->addWidget( Group1, 2, 0 ); + Layout1->addWidget( Group2, 2, 0 ); + Layout1->addWidget( Group3, 2, 0 ); /***************************************************************/ + double SpecificStep = 10.0; + Group1->SpinBox_DX->RangeStepAndValidator(0.001, 999.999, SpecificStep, 3); + Group2->SpinBox_DX->RangeStepAndValidator(0.001, 999.999, SpecificStep, 3); + Group3->SpinBox_DX->RangeStepAndValidator(0.001, 999.999, SpecificStep, 3); + /* Initialisations */ - myOperationGUI = theOperationGUI; - Init(ic); + Init( mySelection ); } @@ -85,7 +112,6 @@ OperationGUI_FilletDlg::OperationGUI_FilletDlg(QWidget* parent, const char* name //================================================================================= OperationGUI_FilletDlg::~OperationGUI_FilletDlg() { - /* no need to delete child widgets, Qt does it all for us */ } @@ -93,45 +119,49 @@ OperationGUI_FilletDlg::~OperationGUI_FilletDlg() // function : Init() // purpose : //================================================================================= -void OperationGUI_FilletDlg::Init(Handle(AIS_InteractiveContext) ic) +void OperationGUI_FilletDlg::Init( SALOME_Selection* Sel ) { - /* init variables */ - myConstructorId = 0; + mySelection = Sel; + myConstructorId = -1; + reset(); + RadioButton1->setChecked( true ); myEditCurrentArgument = Group1->LineEdit1; - myRadius = 5.0; - myOkShape = false; - myIC = ic; - myLocalContextId = -1; - myUseLocalContext = false; - - double SpecificStep = 10.0; - /* min, max, step and decimals for spin boxes */ - Group1->SpinBox_DX->RangeStepAndValidator(0.001, 999.999, SpecificStep, 3); - Group1->SpinBox_DX->SetValue(myRadius); - - /* 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())); + // main buttons + connect( buttonOk , SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); + connect( buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) ); - connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); - connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); - connect(GroupConstructors, SIGNAL(clicked(int)), this, SLOT(ConstructorsClicked(int))); + // group box + connect( GroupConstructors, SIGNAL( clicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) ); + // push buttons connect(Group1->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(Group2->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(Group3->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(Group2->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(Group3->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + + // line edits connect(Group1->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(Group2->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(Group3->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + // spin boxes connect(Group1->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), Group1->SpinBox_DX, SLOT(SetStep(double))); + connect(Group2->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(Group3->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + // selection + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + - /* displays Dialog */ + initName( tr( "GEOM_FILLET" ) ); + + Group2->hide(); + Group3->hide(); Group1->show(); - this->show(); - return; + this->show(); } @@ -139,52 +169,65 @@ void OperationGUI_FilletDlg::Init(Handle(AIS_InteractiveContext) ic) // function : ConstructorsClicked() // purpose : Radio button management //================================================================================= -void OperationGUI_FilletDlg::ConstructorsClicked(int constructorId) +void OperationGUI_FilletDlg::ConstructorsClicked( int constructorId ) { + if ( QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_OCC ) + { + RadioButton1->setChecked( true ); + return; + } + + if ( myConstructorId == constructorId ) + return; + + // Get radius from previous widget + double R = 5; + if ( myConstructorId == 0 ) R = Group1->SpinBox_DX->GetValue(); + else if ( myConstructorId == 1 ) R = Group2->SpinBox_DX->GetValue(); + else R = Group3->SpinBox_DX->GetValue(); + myConstructorId = constructorId; - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); - disconnect(mySelection, 0, this, 0); - myOkShape = false; - myRadius = 5.0; - - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC && myUseLocalContext) { - myIC->CloseLocalContext(myLocalContextId); - DisplayGUI* myDisplayGUI = new DisplayGUI(); - myDisplayGUI->OnDisplayAll(true); - myUseLocalContext = false; + + switch ( constructorId ) + { + case 0: + Group1->show(); + Group2->hide(); + Group3->hide(); + Group1->SpinBox_DX->SetValue( R ); + break; + case 1: + Group1->hide(); + Group2->show(); + Group3->hide(); + Group2->SpinBox_DX->SetValue( R ); + break; + case 2: + Group1->hide(); + Group2->hide(); + Group3->show(); + Group3->SpinBox_DX->SetValue( R ); + break; + default: + break; } - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_OCC) { - myConstructorId = constructorId = 0; //No subshape selection if viewer is not OCC - RadioButton1->setChecked(TRUE); + if ( constructorId == 0 ) myEditCurrentArgument = Group1->LineEdit1; + else if ( constructorId == 1 ) myEditCurrentArgument = Group2->LineEdit1; + else myEditCurrentArgument = Group3->LineEdit1; + + activateSelection(); + enableWidgets(); + + if ( !myShape->_is_nil() ) + { + myEditCurrentArgument->setText( GEOMBase::GetName( myShape ) ); + GEOMBase_Skeleton::LineEditReturnPressed(); } - - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - Group1->LineEdit1->setText(""); - Group1->SpinBox_DX->SetValue(myRadius); - switch (constructorId) - { - case 0: /* Fillet All */ - { - Group1->GroupBox1->setTitle(tr("GEOM_FILLET_ALL")); - myShapeType = -1; - break; - } - case 1: /* Fillet edges */ - { - Group1->GroupBox1->setTitle(tr("GEOM_FILLET_EDGES")); - myShapeType = 6; - break; - } - case 2: /* Fillet Faces */ - { - Group1->GroupBox1->setTitle(tr("GEOM_FILLET_FACES")); - myShapeType = 4; - break; - } - } - return; + else + myEditCurrentArgument->setText( "" ); + + displayPreview(); } @@ -194,9 +237,8 @@ void OperationGUI_FilletDlg::ConstructorsClicked(int constructorId) //================================================================================= void OperationGUI_FilletDlg::ClickOnOk() { - this->ClickOnApply(); - this->ClickOnCancel(); - return; + if ( ClickOnApply() ) + ClickOnCancel(); } @@ -204,120 +246,111 @@ void OperationGUI_FilletDlg::ClickOnOk() // function : ClickOnApply() // purpose : //================================================================================= -void OperationGUI_FilletDlg::ClickOnApply() +bool OperationGUI_FilletDlg::ClickOnApply() { - buttonApply->setFocus(); - QApplication::setOverrideCursor(Qt::waitCursor); - QAD_Application::getDesktop()->putInfo(tr("")); - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); - - bool testResult = false; - switch(myConstructorId) - { - case 0 : /* Fillet All */ - { - if(myOkShape) - testResult = myOperationGUI->OnFilletGetAll(myShape, myRadius, myShapeType, myShapeIOR); - break; - } - case 1 : /* Fillet Edge */ - { - if(myOkShape) - testResult = myOperationGUI->OnFilletGetSelected(myShape, myShapeIOR, myRadius, myShapeType, myLocalContextId, myUseLocalContext); - break; - } - case 2 : /* Fillet Face */ - { - if(myOkShape) - testResult = myOperationGUI->OnFilletGetSelected(myShape, myShapeIOR, myRadius, myShapeType, myLocalContextId, myUseLocalContext); - break; - } - } - - if(!testResult) - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_ABORT")); - else - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); - /* Reset all arguments and local context to allow user a new selection ...*/ - this->ResetStateOfDialog(); - QApplication::restoreOverrideCursor(); - return; -} - + if ( !onAccept() ) + return false; -//================================================================================= -// function : ClickOnCancel() -// purpose : -//================================================================================= -void OperationGUI_FilletDlg::ClickOnCancel() -{ - this->ResetStateOfDialog(); - GEOMBase_Skeleton::ClickOnCancel(); - return; + initName(); + return true; } - //================================================================================= // function : SelectionIntoArgument() // purpose : Called when selection has changed //================================================================================= void OperationGUI_FilletDlg::SelectionIntoArgument() { - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); - myEditCurrentArgument->setText(""); - this->ResetStateOfDialog(); - QString aString = ""; /* name of selection */ - - int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString); - if (nbSel == 1) { - TopoDS_Shape S; - Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); - if(!myGeomBase->GetTopoFromSelection(mySelection, S)) - return; - if(!IO->hasEntry()) { - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY")); - return; - } - - if(!S.IsNull() && S.ShapeType() <= 2) { - if(IO->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject))) { - Handle(GEOM_InteractiveObject) GIObject = Handle(GEOM_InteractiveObject)::DownCast(IO); - myShapeIOR = GIObject->getIOR(); /* the Geom IOR string of selection */ - myEditCurrentArgument->setText(aString); - myShape = S; - myOkShape = true; + erasePreview(); + myEditCurrentArgument->setText( "" ); + + // If selection of main object is activated + if ( myEditCurrentArgument == Group1->LineEdit1 || + myEditCurrentArgument == Group2->LineEdit1 || + myEditCurrentArgument == Group3->LineEdit1 ) + { + if ( mySelection->IObjectCount() == 1 ) + { + Standard_Boolean aResult = Standard_False; + GEOM::GEOM_Object_var anObj = + GEOMBase::ConvertIOinGEOMObject( mySelection->firstIObject(), aResult ); + + if ( aResult && !anObj->_is_nil() ) + { + myShape = anObj; + myEditCurrentArgument->setText( GEOMBase::GetName( anObj ) ); + displayPreview(); + enableWidgets(); + return; } - - if(IO->hasEntry()) { - SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument(); - SALOMEDS::SObject_var obj = aStudy->FindObjectID(IO->getEntry()); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeIOR_var anIOR; - if(!obj->_is_nil()) { - if(obj->FindAttribute(anAttr, "AttributeIOR")) { - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - myShapeIOR = anIOR->Value(); - myOkShape = true; - myShape = S; - myEditCurrentArgument->setText(aString); - } - } + } + + myShape = GEOM::GEOM_Object::_nil(); + enableWidgets(); + } + // If face or edge selection is activated + else if ( myEditCurrentArgument == Group2->LineEdit2 || + myEditCurrentArgument == Group3->LineEdit2 ) + { + if ( mySelection->IObjectCount() == 1 ) + { + Standard_Boolean aResult = Standard_False; + GEOM::GEOM_Object_var anObj = + GEOMBase::ConvertIOinGEOMObject( mySelection->firstIObject(), aResult ); + + if ( aResult && !anObj->_is_nil() ) + { + TColStd_IndexedMapOfInteger anIndexes; + mySelection->GetIndex( mySelection->firstIObject(), anIndexes ); + + if ( anIndexes.Extent() > 0 ) + { + QString aName; + if ( anIndexes.Extent() == 1 ) + { + int anIndex = anIndexes( 1 ); + + aName = QString( GEOMBase::GetName( anObj ) ) + QString( ":%1" ).arg( anIndex ); + } + else + aName = tr( "GEOM_MEN_POPUP_NAME" ).arg( anIndexes.Extent() ); + + myEditCurrentArgument->setText( aName ); + + if ( myConstructorId == 1 ) + myEdges = anIndexes; + else + myFaces = anIndexes; + + displayPreview(); + return; + } } } - if(myOkShape && QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC && myConstructorId == 0) - this->MakePreview(); + myFaces.Clear(); } - else - return; +} + + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void OperationGUI_FilletDlg::LineEditReturnPressed() +{ + QLineEdit* send = ( QLineEdit* )sender(); - if(myOkShape && myShapeType!=-1 && myConstructorId != 0) { - /* local context is defined into the method */ - DisplayGUI* myDisplayGUI = new DisplayGUI(); - myDisplayGUI->PrepareSubShapeSelection(myShapeType, myLocalContextId); - myUseLocalContext = true; - } + if ( send == Group1->LineEdit1 ) + myEditCurrentArgument = Group1->LineEdit1; + else if ( send == Group2->LineEdit1 ) + myEditCurrentArgument = Group2->LineEdit1; + else if ( send == Group3->LineEdit1 ) + myEditCurrentArgument = Group3->LineEdit1; + else + return; + + GEOMBase_Skeleton::LineEditReturnPressed(); + return; } @@ -327,13 +360,35 @@ void OperationGUI_FilletDlg::SelectionIntoArgument() //================================================================================= void OperationGUI_FilletDlg::SetEditCurrentArgument() { - QPushButton* send = (QPushButton*)sender(); + QPushButton* send = (QPushButton*)sender(); - if(send == Group1->PushButton1) + if ( send == Group1->PushButton1 ) + { Group1->LineEdit1->setFocus(); + myEditCurrentArgument = Group1->LineEdit1; + } + else if( send == Group2->PushButton1 ) + { + Group2->LineEdit1->setFocus(); + myEditCurrentArgument = Group2->LineEdit1; + } + else if( send == Group2->PushButton2 ) + { + Group2->LineEdit2->setFocus(); + myEditCurrentArgument = Group2->LineEdit2; + } + else if ( send == Group3->PushButton1 ) + { + Group3->LineEdit1->setFocus(); + myEditCurrentArgument = Group3->LineEdit1; + } + else if( send == Group3->PushButton2 ) + { + Group3->LineEdit1->setFocus(); + myEditCurrentArgument = Group3->LineEdit2; + } - this->SelectionIntoArgument(); - return; + activateSelection(); } @@ -343,7 +398,6 @@ void OperationGUI_FilletDlg::SetEditCurrentArgument() //================================================================================= void OperationGUI_FilletDlg::DeactivateActiveDialog() { - this->ResetStateOfDialog(); GEOMBase_Skeleton::DeactivateActiveDialog(); return; } @@ -356,10 +410,12 @@ void OperationGUI_FilletDlg::DeactivateActiveDialog() void OperationGUI_FilletDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - if(!mySimulationTopoDs.IsNull()) - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - return; + + connect( mySelection, SIGNAL(currentSelectionChanged()), + this, SLOT( SelectionIntoArgument() ) ); + + activateSelection(); + displayPreview(); } @@ -367,126 +423,205 @@ void OperationGUI_FilletDlg::ActivateThisDialog() // function : enterEvent() // purpose : //================================================================================= -void OperationGUI_FilletDlg::enterEvent(QEvent* e) +void OperationGUI_FilletDlg::enterEvent( QEvent* e ) { - if(GroupConstructors->isEnabled()) - return; - this->ActivateThisDialog(); - return; + if ( !GroupConstructors->isEnabled() ) + this->ActivateThisDialog(); } - //================================================================================= -// function : closeEvent() +// function : ValueChangedInSpinBox() // purpose : //================================================================================= -void OperationGUI_FilletDlg::closeEvent(QCloseEvent* e) -{ - /* same than click on cancel button */ - this->ClickOnCancel(); - return; +void OperationGUI_FilletDlg::ValueChangedInSpinBox( double newValue ) +{ + displayPreview(); } +//================================================================================= +// function : reset() +// purpose : +//================================================================================= +void OperationGUI_FilletDlg::reset() +{ + // Set Initial values of spinboxes + Group1->SpinBox_DX->SetValue( 5 ); + Group2->SpinBox_DX->SetValue( 5 ); + Group3->SpinBox_DX->SetValue( 5 ); + + Group1->LineEdit1->setText( "" ); + Group2->LineEdit1->setText( "" ); + Group2->LineEdit2->setText( "" ); + Group3->LineEdit1->setText( "" ); + Group3->LineEdit2->setText( "" ); + + // constructor id + int aConstructorId = getConstructorId(); + + if ( aConstructorId == 0 ) myEditCurrentArgument = Group1->LineEdit1; + else if ( aConstructorId == 1 ) myEditCurrentArgument = Group2->LineEdit1; + else myEditCurrentArgument = Group3->LineEdit1; + + myShape = GEOM::GEOM_Object::_nil(); + + myFaces.Clear(); + myEdges.Clear(); + + erasePreview( true ); + + activateSelection(); + + enableWidgets(); +} //================================================================================= -// function : ResetStateOfDialog() +// function : getConstructorId() // purpose : //================================================================================= -void OperationGUI_FilletDlg::ResetStateOfDialog() +int OperationGUI_FilletDlg::getConstructorId() const { - myOkShape = false; - myEditCurrentArgument->setText(""); - QApplication::restoreOverrideCursor(); - - /* Close its local contact if opened */ - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC && myUseLocalContext) { - myIC->CloseLocalContext(myLocalContextId); - myUseLocalContext = false; - DisplayGUI* myDisplayGUI = new DisplayGUI(); - myDisplayGUI->OnDisplayAll(true); - } - return; + return GroupConstructors->id( GroupConstructors->selected() ); } +//================================================================================= +// function : activateSelection +// purpose : Activate selection in accordance with myEditCurrentArgument +//================================================================================= +void OperationGUI_FilletDlg::activateSelection() +{ + + if ( !myShape->_is_nil() && myEditCurrentArgument == Group2->LineEdit2 ) + localSelection( myShape, TopAbs_EDGE ); + else if ( !myShape->_is_nil() && myEditCurrentArgument == Group3->LineEdit2 ) + localSelection( myShape, TopAbs_FACE ); + else + { + TColStd_MapOfInteger aMap; + aMap.Add( GEOM_SHELL ); + aMap.Add( GEOM_SOLID ); + aMap.Add( GEOM_COMPOUND ); + globalSelection( aMap ); + } + + SelectionIntoArgument(); +} //================================================================================= -// function : ValueChangedInSpinBox() -// purpose : +// function : enableWidgets +// purpose : Enable widgets of faces in accordance with value of main object //================================================================================= -void OperationGUI_FilletDlg::ValueChangedInSpinBox(double newValue) +void OperationGUI_FilletDlg::enableWidgets() { - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); + int anId = getConstructorId(); - myRadius = newValue; + bool toEnable = !myShape->_is_nil(); - if(myOkShape && QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC && myConstructorId == 0) - this->MakePreview(); - return; + if ( anId == 1 ) + { + Group2->LineEdit2->setEnabled( toEnable ); + Group2->PushButton2->setEnabled( toEnable ); + + if ( !toEnable ) + { + Group2->LineEdit2->setText( "" ); + myEdges.Clear(); + } + } + else if ( anId == 2 ) + { + Group3->LineEdit2->setEnabled( toEnable ); + Group3->PushButton2->setEnabled( toEnable ); + + if ( !toEnable ) + { + Group3->LineEdit2->setText( "" ); + myFaces.Clear(); + } + } } +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr OperationGUI_FilletDlg::createOperation() +{ + return getGeomEngine()->GetILocalOperations( getStudyId() ); +} //================================================================================= -// function : MakePreview() +// function : ClickOnApply() +// purpose : Verify validity of input data +//================================================================================= +bool OperationGUI_FilletDlg::isValid( QString& ) +{ + switch ( getConstructorId() ) + { + case 0: return !myShape->_is_nil(); + case 1: return !myShape->_is_nil() && myEdges.Extent() > 0; + case 2: return !myShape->_is_nil() && myFaces.Extent() > 0; + default: return false; + } +} + +//================================================================================= +// function : execute // purpose : //================================================================================= -void OperationGUI_FilletDlg::MakePreview() +bool OperationGUI_FilletDlg::execute( ObjectList& objects ) { - QApplication::setOverrideCursor(Qt::waitCursor); - TopoDS_Shape tds; + GEOM::GEOM_Object_var anObj; + + int anId = getConstructorId(); + if ( anId == 0 ) + anObj = GEOM::GEOM_ILocalOperations::_narrow( + getOperation() )->MakeFilletAll( myShape, + getRadius() ); + else if ( anId == 1 ) + { + GEOM::ListOfLong_var aList = new GEOM::ListOfLong; + aList->length( myEdges.Extent() ); + + for ( int i = 1, n = myEdges.Extent(); i <= n; i++ ) + aList[ i - 1 ] = myEdges( i ); + + anObj = GEOM::GEOM_ILocalOperations::_narrow( + getOperation() )->MakeFilletEdges( myShape, getRadius(), aList ); + } + else if ( anId == 2 ) + { + int i = 0; + GEOM::ListOfLong_var aList = new GEOM::ListOfLong; + aList->length( myFaces.Extent() ); - try { - BRepFilletAPI_MakeFillet fill(myShape); - switch(myConstructorId) - { - case 0: /* Fillet All */ - { - TopExp_Explorer Exp(myShape, TopAbs_EDGE); - for(Exp; Exp.More(); Exp.Next()) { - TopoDS_Edge E = TopoDS::Edge(Exp.Current()); - fill.Add(E); - } - - for(int i = 1; i <= fill.NbContours(); i++) { - try { -#if OCC_VERSION_MAJOR >= 5 - fill.SetRadius(myRadius,i,i); -#else - fill.SetRadius(myRadius,i); -#endif - } - catch(Standard_Failure) { - QApplication::restoreOverrideCursor(); - QAD_MessageBox::warn1 (QAD_Application::getDesktop(), tr("GEOM_WRN_WARNING"), tr("GEOM_FILLET_ABORT").arg(myRadius), tr("GEOM_BUT_OK")); - QApplication::setOverrideCursor(Qt::waitCursor); - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); - Group1->SpinBox_DX->SetValue(5.0); - QApplication::restoreOverrideCursor(); - return; - } - } - tds = fill.Shape(); - break; - } - // case 1: /* Fillet edges */ - // case 2: /* Fillet Faces */ - } + for ( int i = 1, n = myFaces.Extent(); i <= n; i++ ) + aList[ i - 1 ] = myFaces( i ); - if(!tds.IsNull()) { - mySimulationTopoDs = tds; - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - } - } - catch(Standard_Failure) { - QApplication::restoreOverrideCursor(); - QAD_MessageBox::warn1 (QAD_Application::getDesktop(), tr("GEOM_WRN_WARNING"), tr("GEOM_FILLET_ABORT").arg(myRadius), tr("GEOM_BUT_OK")); - QApplication::setOverrideCursor(Qt::waitCursor); - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); - Group1->SpinBox_DX->SetValue(5.0); + anObj = GEOM::GEOM_ILocalOperations::_narrow( + getOperation() )->MakeFilletFaces( myShape, getRadius(), aList ); } - QApplication::restoreOverrideCursor(); - return; + if ( !anObj->_is_nil() ) + objects.push_back( anObj._retn() ); + + return true; } + +//================================================================================= +// function : getRadius +// purpose : Get radius +//================================================================================= +double OperationGUI_FilletDlg::getRadius() const +{ + int anId = getConstructorId(); + if ( anId == 0 ) return Group1->SpinBox_DX->GetValue(); + else if ( anId == 1 ) return Group2->SpinBox_DX->GetValue(); + else return Group3->SpinBox_DX->GetValue(); +} + + + + + + + diff --git a/src/OperationGUI/OperationGUI_FilletDlg.h b/src/OperationGUI/OperationGUI_FilletDlg.h index 3756f82b2..b18f85863 100644 --- a/src/OperationGUI/OperationGUI_FilletDlg.h +++ b/src/OperationGUI/OperationGUI_FilletDlg.h @@ -30,9 +30,11 @@ #define DIALOGBOX_FILLET_H #include "GEOMBase_Skeleton.h" -#include "DlgRef_1Sel1Spin.h" -#include "OperationGUI.h" +#include + +class DlgRef_1Sel1Spin; +class DlgRef_2Sel1Spin; //================================================================================= // class : OperationGUI_FilletDlg @@ -43,46 +45,49 @@ class OperationGUI_FilletDlg : public GEOMBase_Skeleton Q_OBJECT public: - OperationGUI_FilletDlg(QWidget* parent = 0, const char* name = 0, OperationGUI* theOperationGUI = 0, SALOME_Selection* Sel = 0, Handle(AIS_InteractiveContext) ic = 0, bool modal = FALSE, WFlags fl = 0); - ~OperationGUI_FilletDlg(); + OperationGUI_FilletDlg( QWidget* parent, + SALOME_Selection* Sel ); + ~OperationGUI_FilletDlg(); -private : - void Init(Handle(AIS_InteractiveContext) ic); - void enterEvent(QEvent* e); - void closeEvent(QCloseEvent* e); - void MakeFilletSimulationAndDisplay(); +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& msg ); + virtual bool execute( ObjectList& objects ); - void ResetStateOfDialog(); - void MakePreview(); +private slots: - OperationGUI* myOperationGUI; + void ClickOnOk(); + bool ClickOnApply(); + void ActivateThisDialog(); + void DeactivateActiveDialog(); + void LineEditReturnPressed(); + void SelectionIntoArgument(); + void SetEditCurrentArgument(); + void ValueChangedInSpinBox( double newValue ); + void ConstructorsClicked( int constructorId ); - int myConstructorId; /* Current constructor id = radio button id */ +private : - /* Interactive and local context management see also : bool myUseLocalContext() */ - Handle(AIS_InteractiveContext) myIC; /* Interactive context */ - Standard_Integer myLocalContextId; /* identify a local context used by this method */ - bool myUseLocalContext; /* true when this method as opened a local context */ + void Init( SALOME_Selection* ); + void enterEvent( QEvent* e ); + void reset(); + int getConstructorId() const; + void activateSelection(); + void enableWidgets(); + double getRadius() const; - TopoDS_Shape myShape; - bool myOkShape; - char* myShapeIOR; - int myShapeType; - double myRadius; - - DlgRef_1Sel1Spin* Group1; +private : -private slots: - void ClickOnOk(); - void ClickOnApply(); - void ClickOnCancel(); - void ActivateThisDialog(); - void DeactivateActiveDialog(); - void SelectionIntoArgument(); - void SetEditCurrentArgument(); - void ValueChangedInSpinBox(double newValue); - void ConstructorsClicked(int constructorId); + int myConstructorId; + GEOM::GEOM_Object_var myShape; + TColStd_IndexedMapOfInteger myEdges; + TColStd_IndexedMapOfInteger myFaces; + + DlgRef_1Sel1Spin* Group1; + DlgRef_2Sel1Spin* Group2; + DlgRef_2Sel1Spin* Group3; }; #endif // DIALOGBOX_FILLET_H diff --git a/src/OperationGUI/OperationGUI_MaterialDlg.cxx b/src/OperationGUI/OperationGUI_MaterialDlg.cxx new file mode 100644 index 000000000..bb2231281 --- /dev/null +++ b/src/OperationGUI/OperationGUI_MaterialDlg.cxx @@ -0,0 +1,232 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 CEA +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org or email : webmaster.salome@opencascade.org +// +// +// +// File : OperationGUI_MaterialDlg.cxx +// Author : Julia DOROVSKIKH +// Module : GEOM +// $Header$ + +using namespace std; +#include "OperationGUI_MaterialDlg.h" +#include "OperationGUI_PartitionDlg.h" + +#include "utilities.h" +#include "QAD_Desktop.h" + +#include +#include + +//================================================================================= +// class : OperationGUI_MaterialDlg() +// purpose : Constructs a OperationGUI_MaterialDlg 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. +//================================================================================= +OperationGUI_MaterialDlg::OperationGUI_MaterialDlg (QWidget* parent, const char* name, + SALOME_Selection* Sel, + GEOM::ListOfGO ListShapes, + bool modal, WFlags fl) + :GEOMBase_Skeleton(parent, name, Sel, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) +{ + myListShapes = ListShapes; + myParentDlg = parent; + + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_PARTITION"))); + + setCaption(tr("GEOM_MATERIAL_TITLE")); + + /***************************************************************/ + GroupConstructors->setTitle(tr("GEOM_PARTITION")); + RadioButton1->setPixmap(image0); + RadioButton2->close(TRUE); + RadioButton3->close(TRUE); + + GroupPoints = new DlgRef_1List1Spin1Btn_QTD(this, "GroupPoints"); + GroupPoints->GroupBox1->setTitle(tr("GEOM_PARTITION")); + + myShapeCol = GroupPoints->ListView1->addColumn(tr("GEOM_MATERIAL_SHAPE")); + myMaterCol = GroupPoints->ListView1->addColumn(tr("GEOM_MATERIAL_MATERIAL")); + GroupPoints->ListView1->setSelectionMode(QListView::Extended); + + GroupPoints->TextLabel1->setText(tr("GEOM_MATERIAL_ID")); + GroupPoints->PushButton1->setText(tr("GEOM_MATERIAL_SET")); + + Layout1->addWidget(GroupPoints, 1, 0); + /***************************************************************/ + + Init(); +} + + +//================================================================================= +// function : ~OperationGUI_MaterialDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +OperationGUI_MaterialDlg::~OperationGUI_MaterialDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void OperationGUI_MaterialDlg::Init() +{ + // get materials list from the parent dialog + OperationGUI_PartitionDlg* aParentDlg = + dynamic_cast(myParentDlg); + if (aParentDlg) + myListMaterials = aParentDlg->GetListMaterials(); + + /* list filling */ + MESSAGE("Filling list with " << myListShapes.length() << " objects"); + QString aMaterialId; + for (int ind = 0; ind < myListShapes.length(); ind++) { + GEOM::GEOM_Object_var anObject = myListShapes[ind]; + if (!anObject->_is_nil()) { + MESSAGE("Insert " << GEOMBase::GetName( anObject )); + if (ind < myListMaterials.length()) + aMaterialId = QString::number(myListMaterials[ind]); + else + aMaterialId = "0"; + QListViewItem* aItem = + new QListViewItem(GroupPoints->ListView1, GEOMBase::GetName( anObject ), aMaterialId); + } + } + MESSAGE("Filled"); + + /* signals and slots connections */ + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + buttonApply->close(TRUE); + buttonCancel->setText(tr("GEOM_BUT_CANCEL")); + + connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetMaterial())); + +// connect(GroupPoints->ListView1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); +// connect(GroupPoints->SpinBox1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + + /* displays Dialog */ + MESSAGE("GroupPoints->show() ..."); + GroupPoints->show(); + MESSAGE("this->show() ..."); + this->show(); + MESSAGE("return"); + + return; +} + + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void OperationGUI_MaterialDlg::ClickOnOk() +{ + QAD_Application::getDesktop()->putInfo(tr("")); + + int nbSh = myListShapes.length(); + myListMaterials.length(nbSh); + + QListViewItemIterator it (GroupPoints->ListView1); + for (int i = 0; it.current() != 0; it++, i++) { + QString aMatIdStr = it.current()->text(myMaterCol); + myListMaterials[i] = aMatIdStr.toInt(); + MESSAGE("For shape # " << i << " material ID = " << myListMaterials[i]); + } + + // set materials list to the parent dialog + OperationGUI_PartitionDlg* aParentDlg = + dynamic_cast(myParentDlg); + if (aParentDlg) + { + aParentDlg->SetListMaterials(myListMaterials); + } + + ClickOnCancel(); + return; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void OperationGUI_MaterialDlg::SelectionIntoArgument() +{ + QString aString = ""; /* name of selection */ + + int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString); + if(nbSel < 1) { + return; + } + +// myGeomBase->ConvertListOfIOInListOfIOR(mySelection->StoredIObjects(), myListShapes); + + /* no simulation */ + return; +} + + +//================================================================================= +// function : SetMaterial() +// purpose : +//================================================================================= +void OperationGUI_MaterialDlg::SetMaterial() +{ + int aMatId = GroupPoints->SpinBox1->value(); + QString aMatIdStr; + aMatIdStr.setNum(aMatId); + QListViewItemIterator it (GroupPoints->ListView1); + for (; it.current() != 0; it++) { + if (it.current()->isSelected()) + it.current()->setText(myMaterCol, aMatIdStr); + } + return; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void OperationGUI_MaterialDlg::ActivateThisDialog() +{ + GEOMBase_Skeleton::ActivateThisDialog(); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + return; +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void OperationGUI_MaterialDlg::enterEvent(QEvent* e) +{ + if(!GroupConstructors->isEnabled()) + this->ActivateThisDialog(); +} diff --git a/src/OperationGUI/OperationGUI_MaterialDlg.h b/src/OperationGUI/OperationGUI_MaterialDlg.h new file mode 100644 index 000000000..9c1bd46ed --- /dev/null +++ b/src/OperationGUI/OperationGUI_MaterialDlg.h @@ -0,0 +1,72 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 CEA +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org or email : webmaster.salome@opencascade.org +// +// +// +// File : OperationGUI_MaterialDlg.h +// Author : Julia DOROVSKIKH +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_MATERIAL_H +#define DIALOGBOX_MATERIAL_H + +#include "GEOMBase_Skeleton.h" +#include "DlgRef_1List1Spin1Btn_QTD.h" + + +//================================================================================= +// class : OperationGUI_MaterialDlg +// purpose : +//================================================================================= +class OperationGUI_MaterialDlg : public GEOMBase_Skeleton +{ + Q_OBJECT + +public: + OperationGUI_MaterialDlg (QWidget* parent, const char* name, + SALOME_Selection* Sel, + GEOM::ListOfGO ListShapes, + bool modal = FALSE, WFlags fl = 0); + ~OperationGUI_MaterialDlg(); + +private: + void Init(); + void enterEvent(QEvent* e); + + QWidget* myParentDlg; + + GEOM::ListOfGO myListShapes; + GEOM::ListOfLong myListMaterials; + + DlgRef_1List1Spin1Btn_QTD* GroupPoints; + + int myShapeCol; + int myMaterCol; + +private slots: + void ClickOnOk(); + void ActivateThisDialog(); + void SelectionIntoArgument(); + void SetMaterial(); + +}; + +#endif // DIALOGBOX_MATERIAL_H diff --git a/src/OperationGUI/OperationGUI_PartitionDlg.cxx b/src/OperationGUI/OperationGUI_PartitionDlg.cxx index 3fbcb8705..be89f1131 100644 --- a/src/OperationGUI/OperationGUI_PartitionDlg.cxx +++ b/src/OperationGUI/OperationGUI_PartitionDlg.cxx @@ -26,8 +26,16 @@ // Module : GEOM // $Header$ -using namespace std; #include "OperationGUI_PartitionDlg.h" +#include "OperationGUI_MaterialDlg.h" + +#include "GEOMImpl_Types.hxx" + +#include "QAD_Desktop.h" + +#include + +#include "utilities.h" //================================================================================= // class : OperationGUI_PartitionDlg() @@ -36,21 +44,23 @@ using namespace std; // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -OperationGUI_PartitionDlg::OperationGUI_PartitionDlg(QWidget* parent, const char* name, OperationGUI* theOperationGUI, SALOME_Selection* Sel, bool modal, WFlags fl) +OperationGUI_PartitionDlg::OperationGUI_PartitionDlg(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_PARTITION"))); - QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_PARTITION_PLANE"))); + QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); setCaption(tr("GEOM_PARTITION_TITLE")); /***************************************************************/ GroupConstructors->setTitle(tr("GEOM_PARTITION")); RadioButton1->setPixmap(image0); - RadioButton2->close(TRUE); + RadioButton2->setPixmap(image1); RadioButton3->close(TRUE); - GroupPoints = new DlgRef_4Sel1List_QTD(this, "GroupPoints"); + // Full partition (contains half-space partition) + GroupPoints = new DlgRef_4Sel1List1Check_QTD(this, "GroupPoints"); GroupPoints->GroupBox1->setTitle(tr("GEOM_PARTITION")); GroupPoints->GroupBox2->setTitle(tr("SUPPRESS_RESULT")); GroupPoints->TextLabel1->setText(tr("GEOM_OBJECTS")); @@ -58,16 +68,20 @@ OperationGUI_PartitionDlg::OperationGUI_PartitionDlg(QWidget* parent, const char GroupPoints->TextLabel3->setText(tr("GEOM_RECONSTRUCTION_LIMIT")); GroupPoints->TextLabel4->setText(tr("GEOM_SUPPRESS_RESULT_INSIDE")); GroupPoints->TextLabel5->setText(tr("GEOM_SUPPRESS_RESULT_OUTSIDE")); - GroupPoints->PushButton1->setPixmap(image1); - GroupPoints->PushButton2->setPixmap(image1); - GroupPoints->PushButton3->setPixmap(image1); - GroupPoints->PushButton4->setPixmap(image1); - - Layout1->addWidget(GroupPoints, 1, 0); + GroupPoints->CheckBox1->setText(tr("GEOM_REMOVE_WEBS")); + GroupPoints->PushButton1->setPixmap(image2); + GroupPoints->PushButton2->setPixmap(image2); + GroupPoints->PushButton3->setPixmap(image2); + GroupPoints->PushButton4->setPixmap(image2); + GroupPoints->PushButton5->setText(tr("GEOM_SET_MATERIALS")); + GroupPoints->LineEdit1->setReadOnly( true ); + GroupPoints->LineEdit2->setReadOnly( true ); + GroupPoints->LineEdit3->setReadOnly( true ); + GroupPoints->LineEdit4->setReadOnly( true ); + + Layout1->addWidget(GroupPoints, 2, 0); /***************************************************************/ - - /* Initialisations */ - myOperationGUI = theOperationGUI; + Init(); } @@ -88,11 +102,6 @@ OperationGUI_PartitionDlg::~OperationGUI_PartitionDlg() //================================================================================= void OperationGUI_PartitionDlg::Init() { - /* init variables */ - myEditCurrentArgument = GroupPoints->LineEdit1; - - myOkListShapes = myOkListTools = myOkKeepShape = myOkRemoveShape = false; - /* type for sub shape selection */ GroupPoints->ComboBox1->insertItem(tr("GEOM_RECONSTRUCTION_LIMIT_SOLID")); GroupPoints->ComboBox1->insertItem(tr("GEOM_RECONSTRUCTION_LIMIT_SHELL")); @@ -100,34 +109,86 @@ void OperationGUI_PartitionDlg::Init() GroupPoints->ComboBox1->insertItem(tr("GEOM_RECONSTRUCTION_LIMIT_WIRE")); GroupPoints->ComboBox1->insertItem(tr("GEOM_RECONSTRUCTION_LIMIT_EDGE")); GroupPoints->ComboBox1->insertItem(tr("GEOM_RECONSTRUCTION_LIMIT_VERTEX")); - - /* Current item is 'Shape' */ - GroupPoints->ComboBox1->setCurrentItem(0); - myLimit = GroupPoints->ComboBox1->currentItem(); - + /* signals and slots connections */ connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); - + connect(GroupConstructors, SIGNAL(clicked(int)), this, SLOT(ConstructorsClicked(int))); + connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(GroupPoints->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(GroupPoints->PushButton4, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - + connect(GroupPoints->PushButton5, SIGNAL(clicked()), this, SLOT(SetMaterials())); + connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); connect(GroupPoints->LineEdit3, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); connect(GroupPoints->LineEdit4, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - + + connect(GroupPoints->CheckBox1, SIGNAL(toggled(bool)), this, SLOT(onRemoveWebs(bool))); + connect(GroupPoints->ComboBox1, SIGNAL(activated(int)), this, SLOT(ComboTextChanged())); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + + initName( tr( "GEOM_PARTITION" ) ); + ConstructorsClicked( 0 ); +} - /* displays Dialog */ - GroupPoints->show(); - this->show(); - return; +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void OperationGUI_PartitionDlg::ConstructorsClicked(int constructorId) +{ + disconnect(mySelection, 0, this, 0); + globalSelection(); + + myListShapes.length(0); + myListTools.length(0); + myListKeepInside.length(0); + myListRemoveInside.length(0); + myListMaterials.length(0); + + switch (constructorId) + { + case 0: /*Full partition */ + { + GroupPoints->GroupBox1->setTitle(tr("GEOM_PARTITION")); + GroupPoints->TextLabel2->setText(tr("GEOM_TOOL_OBJECT")); + resize(0, 0); + GroupPoints->TextLabel3->show(); + GroupPoints->ComboBox1->show(); + GroupPoints->GroupBox2->show(); + + GroupPoints->ComboBox1->setCurrentItem(0); + GroupPoints->LineEdit3->clear(); + GroupPoints->LineEdit4->clear(); + break; + } + case 1: /*Half-space partition */ + { + + GroupPoints->GroupBox1->setTitle(tr("GEOM_PARTITION_HALFSPACE")); + GroupPoints->GroupBox2->hide(); + GroupPoints->TextLabel3->hide(); + GroupPoints->ComboBox1->hide(); + GroupPoints->TextLabel2->setText(tr("GEOM_PLANE")); + resize(0, 0); + break; + } + } + + myEditCurrentArgument = GroupPoints->LineEdit1; + GroupPoints->LineEdit1->clear(); + GroupPoints->LineEdit2->clear(); + onRemoveWebs(false); + + myEditCurrentArgument->setFocus(); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + MESSAGE(width()<<" "<ClickOnApply(); - ClickOnCancel(); - return; + if ( ClickOnApply() ) + ClickOnCancel(); } @@ -147,51 +207,24 @@ void OperationGUI_PartitionDlg::ClickOnOk() // function : ClickOnApply() // purpose : //================================================================================= -void OperationGUI_PartitionDlg::ClickOnApply() +bool OperationGUI_PartitionDlg::ClickOnApply() { - QAD_Application::getDesktop()->putInfo(tr("")); + if ( !onAccept() ) + return false; + + initName(); + ConstructorsClicked( getConstructorId() ); + return true; +} - if(myOkListShapes || myOkListTools || myOkKeepShape || myOkRemoveShape) { - GEOM::shape_type limit; - switch(myLimit) - { - case 0 : - { - limit = GEOM::SHAPE; - break; - } - case 1 : - { - limit = GEOM::SHELL; - break; - } - case 2 : - { - limit = GEOM::FACE; - break; - } - case 3 : - { - limit = GEOM::WIRE; - break; - } - case 4 : - { - limit = GEOM::EDGE; - break; - } - case 5 : - { - limit = GEOM::VERTEX; - break; - } - default : - limit = GEOM::SHAPE; - } - myOperationGUI->MakePartitionAndDisplay(myListShapes, myListTools, myListKeepInside, myListRemoveInside, limit); - } - return; +//======================================================================= +// function : ClickOnCancel() +// purpose : +//======================================================================= +void OperationGUI_PartitionDlg::ClickOnCancel() +{ + GEOMBase_Skeleton::ClickOnCancel(); } @@ -201,50 +234,61 @@ void OperationGUI_PartitionDlg::ClickOnApply() //================================================================================= void OperationGUI_PartitionDlg::SelectionIntoArgument() { - myEditCurrentArgument->setText(""); - QString aString = ""; /* name of selection */ - - int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString); - if(nbSel < 1) { - if(myEditCurrentArgument == GroupPoints->LineEdit1) { - myListShapes.length(0); - myOkListShapes = false; - } else if(myEditCurrentArgument == GroupPoints->LineEdit2) { - myListTools.length(0); - myOkListTools = false; - } else if(myEditCurrentArgument == GroupPoints->LineEdit3) { - myListRemoveInside.length(0); - myOkKeepShape = false; - } else if(myEditCurrentArgument == GroupPoints->LineEdit4) { - myListKeepInside.length(0); - myOkRemoveShape = false; + myEditCurrentArgument->setText( "" ); + QString aString = ""; + + int nbSel = GEOMBase::GetNameOfSelectedIObjects( mySelection, aString, true ); + + if ( nbSel < 1 ) + { + if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) + { + myListShapes.length( 0 ); + myListMaterials.length( 0 ); } + else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) + myListTools.length( 0 ); + else if ( myEditCurrentArgument == GroupPoints->LineEdit3 ) + myListRemoveInside.length( 0 ); + else if ( myEditCurrentArgument == GroupPoints->LineEdit4 ) + myListKeepInside.length( 0 ); + } + + // One and only one plane can be selected + + if ( getConstructorId() == 1 && myEditCurrentArgument == GroupPoints->LineEdit2 && nbSel != 1 ) + { + myListTools.length( 0 ); return; } - - if(myEditCurrentArgument == GroupPoints->LineEdit1) { - myGeomBase->ConvertListOfIOInListOfIOR(mySelection->StoredIObjects(), myListShapes); - myEditCurrentArgument->setText(aString); - myOkListShapes = true; + + if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) + { + GEOMBase::ConvertListOfIOInListOfGO( mySelection->StoredIObjects(), myListShapes, true ); + myListMaterials.length( 0 ); + if ( !myListShapes.length() ) + return; } - else if(myEditCurrentArgument == GroupPoints->LineEdit2) { - myGeomBase->ConvertListOfIOInListOfIOR(mySelection->StoredIObjects(), myListTools); - myEditCurrentArgument->setText(aString); - myOkListTools = true; + else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) + { + GEOMBase::ConvertListOfIOInListOfGO( mySelection->StoredIObjects(), myListTools, true ); + if ( !myListTools.length() ) + return; } - else if(myEditCurrentArgument == GroupPoints->LineEdit3) { - myGeomBase->ConvertListOfIOInListOfIOR(mySelection->StoredIObjects(), myListRemoveInside); - myEditCurrentArgument->setText(aString); - myOkKeepShape = true; + else if(myEditCurrentArgument == GroupPoints->LineEdit3) + { + GEOMBase::ConvertListOfIOInListOfGO( mySelection->StoredIObjects(), myListRemoveInside, true ); + if (!myListRemoveInside.length()) + return; } - else if(myEditCurrentArgument == GroupPoints->LineEdit4) { - myGeomBase->ConvertListOfIOInListOfIOR(mySelection->StoredIObjects(), myListKeepInside); - myEditCurrentArgument->setText(aString); - myOkRemoveShape = true; + else if(myEditCurrentArgument == GroupPoints->LineEdit4) + { + GEOMBase::ConvertListOfIOInListOfGO( mySelection->StoredIObjects(), myListKeepInside, true ); + if ( !myListKeepInside.length() ) + return; } - - /* no simulation */ - return; + + myEditCurrentArgument->setText( aString ); } @@ -255,26 +299,24 @@ void OperationGUI_PartitionDlg::SelectionIntoArgument() void OperationGUI_PartitionDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); - - if(send == GroupPoints->PushButton1) { - GroupPoints->LineEdit1->setFocus(); + + if(send == GroupPoints->PushButton1) myEditCurrentArgument = GroupPoints->LineEdit1; - } - else if(send == GroupPoints->PushButton2) { - GroupPoints->LineEdit2->setFocus(); + else if(send == GroupPoints->PushButton2) + { myEditCurrentArgument = GroupPoints->LineEdit2; + if( getConstructorId()==1 ) + globalSelection( GEOM_PLANE ); } - else if(send == GroupPoints->PushButton3) { - GroupPoints->LineEdit3->setFocus(); + else if(send == GroupPoints->PushButton3) myEditCurrentArgument = GroupPoints->LineEdit3; - } - else if(send == GroupPoints->PushButton4) { - GroupPoints->LineEdit4->setFocus(); + else if(send == GroupPoints->PushButton4) myEditCurrentArgument = GroupPoints->LineEdit4; - } - this->SelectionIntoArgument(); - - return; + + globalSelection( GEOM_ALLSHAPES ); + + myEditCurrentArgument->setFocus(); + SelectionIntoArgument(); } @@ -285,19 +327,15 @@ void OperationGUI_PartitionDlg::SetEditCurrentArgument() void OperationGUI_PartitionDlg::LineEditReturnPressed() { QLineEdit* send = (QLineEdit*)sender(); - if(send == GroupPoints->LineEdit1) - myEditCurrentArgument = GroupPoints->LineEdit1; - else if (send == GroupPoints->LineEdit2) - myEditCurrentArgument = GroupPoints->LineEdit2; - else if (send == GroupPoints->LineEdit3) - myEditCurrentArgument = GroupPoints->LineEdit3; - else if (send == GroupPoints->LineEdit4) - myEditCurrentArgument = GroupPoints->LineEdit4; - else - return; - - GEOMBase_Skeleton::LineEditReturnPressed(); - return; + + if(send == GroupPoints->LineEdit1 || + send == GroupPoints->LineEdit2 || + send == GroupPoints->LineEdit3 || + send == GroupPoints->LineEdit4 ) + { + myEditCurrentArgument = send; + GEOMBase_Skeleton::LineEditReturnPressed(); + } } @@ -309,7 +347,18 @@ void OperationGUI_PartitionDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - return; + + ConstructorsClicked( getConstructorId() ); +} + + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : public slot to deactivate if active +//================================================================================= +void OperationGUI_PartitionDlg::DeactivateActiveDialog() +{ + GEOMBase_Skeleton::DeactivateActiveDialog(); } @@ -319,10 +368,79 @@ void OperationGUI_PartitionDlg::ActivateThisDialog() //================================================================================= void OperationGUI_PartitionDlg::enterEvent(QEvent* e) { - if(GroupConstructors->isEnabled()) - return; - this->ActivateThisDialog(); - return; + if(!GroupConstructors->isEnabled()) + this->ActivateThisDialog(); +} + + +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr OperationGUI_PartitionDlg::createOperation() +{ + return getGeomEngine()->GetIBooleanOperations( getStudyId() ); +} + + +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool OperationGUI_PartitionDlg::isValid( QString& msg ) +{ + return (myListShapes.length() || myListTools.length() || + myListKeepInside.length() || myListRemoveInside.length()); +} + + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool OperationGUI_PartitionDlg::execute( ObjectList& objects ) +{ + bool res = false; + + GEOM::GEOM_Object_var anObj; + QString msg; + + int aLimit = GetLimit(); + int aConstructorId = getConstructorId(); + + if (aConstructorId==1) + aLimit = GEOM::SHAPE; + + if (isValid( msg )) + { + + if ( aConstructorId==0 && !toRemoveWebs() ) + myListMaterials.length(0); + + anObj = GEOM::GEOM_IBooleanOperations::_narrow( getOperation() )->MakePartition(myListShapes, + myListTools, + myListKeepInside, + myListRemoveInside, + aLimit, + toRemoveWebs(), + myListMaterials); + res = true; + } + + if ( !anObj->_is_nil() ) + objects.push_back( anObj._retn() ); + + return res; +} + + +//================================================================================= +// function : closeEvent +// purpose : +//================================================================================= +void OperationGUI_PartitionDlg::closeEvent( QCloseEvent* e ) +{ + GEOMBase_Skeleton::closeEvent( e ); } @@ -333,14 +451,98 @@ void OperationGUI_PartitionDlg::enterEvent(QEvent* e) void OperationGUI_PartitionDlg::ComboTextChanged() { - myLimit = GroupPoints->ComboBox1->currentItem(); - - bool IsEnabled = GroupPoints->ComboBox1->currentItem() < 3; - GroupPoints->LineEdit3->setEnabled(IsEnabled); - GroupPoints->LineEdit4->setEnabled(IsEnabled); - GroupPoints->TextLabel4->setEnabled(IsEnabled); - GroupPoints->TextLabel5->setEnabled(IsEnabled); - GroupPoints->PushButton3->setEnabled(IsEnabled); - GroupPoints->PushButton4->setEnabled(IsEnabled); - return; + bool IsEnabled = GroupPoints->ComboBox1->currentItem() < 3; + GroupPoints->LineEdit3->setEnabled(IsEnabled); + GroupPoints->LineEdit4->setEnabled(IsEnabled); + GroupPoints->TextLabel4->setEnabled(IsEnabled); + GroupPoints->TextLabel5->setEnabled(IsEnabled); + GroupPoints->PushButton3->setEnabled(IsEnabled); + GroupPoints->PushButton4->setEnabled(IsEnabled); +} + + +//================================================================================= +// function : SetMaterials() +// purpose : +//================================================================================= +void OperationGUI_PartitionDlg::SetMaterials() +{ + SALOME_Selection* Sel = + SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection()); + MESSAGE("OperationGUI_MaterialDlg ..."); + OperationGUI_MaterialDlg *aDlg = + new OperationGUI_MaterialDlg(this, "", Sel, myListShapes, true); + MESSAGE("OperationGUI_MaterialDlg"); + return; +} + + +//================================================================================= +// function : onRemoveWebs() +// purpose : +//================================================================================= +void OperationGUI_PartitionDlg::onRemoveWebs(bool isChecked) +{ + if (GroupPoints->CheckBox1->isChecked() != isChecked) + GroupPoints->CheckBox1->setChecked(isChecked); + + GroupPoints->PushButton5->setEnabled(isChecked); +} + + +//================================================================================= +// function : toRemoveWebs() +// purpose : +//================================================================================= +bool OperationGUI_PartitionDlg::toRemoveWebs() const +{ + return GroupPoints->CheckBox1->isChecked(); +} + + +//================================================================================= +// function : GetLimit() +// purpose : +//================================================================================= +int OperationGUI_PartitionDlg::GetLimit() const +{ + int aLimit = GroupPoints->ComboBox1->currentItem(); + + switch(aLimit) + { + case 0 : + { + aLimit = GEOM::SOLID; + break; + } + case 1 : + { + aLimit = GEOM::SHELL; + break; + } + case 2 : + { + aLimit = GEOM::FACE; + break; + } + case 3 : + { + aLimit = GEOM::WIRE; + break; + } + case 4 : + { + aLimit = GEOM::EDGE; + break; + } + case 5 : + { + aLimit = GEOM::VERTEX; + break; + } + default : + aLimit = GEOM::SHAPE; + } + + return aLimit; } diff --git a/src/OperationGUI/OperationGUI_PartitionDlg.h b/src/OperationGUI/OperationGUI_PartitionDlg.h index 20673e83e..d6d35ded3 100644 --- a/src/OperationGUI/OperationGUI_PartitionDlg.h +++ b/src/OperationGUI/OperationGUI_PartitionDlg.h @@ -30,9 +30,8 @@ #define DIALOGBOX_PARTITION_H #include "GEOMBase_Skeleton.h" -#include "DlgRef_4Sel1List_QTD.h" +#include "DlgRef_4Sel1List1Check_QTD.h" -#include "OperationGUI.h" //================================================================================= // class : OperationGUI_PartitionDlg @@ -43,37 +42,50 @@ class OperationGUI_PartitionDlg : public GEOMBase_Skeleton Q_OBJECT public: - OperationGUI_PartitionDlg(QWidget* parent = 0, const char* name = 0, OperationGUI* theOperationGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + OperationGUI_PartitionDlg(QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); ~OperationGUI_PartitionDlg(); -private: - void Init(); - void enterEvent(QEvent* e); + void SetListMaterials(GEOM::ListOfLong ListMaterials) + { myListMaterials = ListMaterials; } - OperationGUI* myOperationGUI; + GEOM::ListOfLong GetListMaterials() + { return myListMaterials; } - GEOM::GEOM_Gen::ListOfIOR myListShapes; - GEOM::GEOM_Gen::ListOfIOR myListTools; - GEOM::GEOM_Gen::ListOfIOR myListRemoveInside; - GEOM::GEOM_Gen::ListOfIOR myListKeepInside; +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& ); + virtual bool execute( ObjectList& objects ); - bool myOkListShapes; /* to check when argument is defined */ - bool myOkListTools; /* to check when argument is defined */ - bool myOkKeepShape; /* to check when argument is defined */ - bool myOkRemoveShape; /* to check when argument is defined */ - int myLimit; + virtual void closeEvent( QCloseEvent* e ); - DlgRef_4Sel1List_QTD* GroupPoints; +private: + void Init(); + void enterEvent(QEvent* e); + bool toRemoveWebs() const; + int GetLimit() const; + + GEOM::ListOfGO myListShapes; + GEOM::ListOfLong myListMaterials; + GEOM::ListOfGO myListTools; + GEOM::ListOfGO myListRemoveInside; + GEOM::ListOfGO myListKeepInside; + + DlgRef_4Sel1List1Check_QTD* GroupPoints; private slots: void ClickOnOk(); - void ClickOnApply(); + bool ClickOnApply(); + void ClickOnCancel(); void ActivateThisDialog(); + void DeactivateActiveDialog(); void LineEditReturnPressed(); void SelectionIntoArgument(); void SetEditCurrentArgument(); void ComboTextChanged(); - + void onRemoveWebs(bool); + void SetMaterials(); + void ConstructorsClicked(int constructorId); }; #endif // DIALOGBOX_PARTITION_H diff --git a/src/PARTITION/Partition_Inter2d.cxx b/src/PARTITION/Partition_Inter2d.cxx index f8fa4931e..54a270e44 100644 --- a/src/PARTITION/Partition_Inter2d.cxx +++ b/src/PARTITION/Partition_Inter2d.cxx @@ -142,7 +142,7 @@ static Standard_Boolean findVOnE(const TopoDS_Vertex & theV, return Standard_False; #ifdef DEB - cout << "findVOnE: found MinDist = " << sqrt (MinDist2) << endl; + MESSAGE("findVOnE: found MinDist = " << sqrt (MinDist2)); #endif return Standard_True; diff --git a/src/PARTITION/Partition_Loop2d.cxx b/src/PARTITION/Partition_Loop2d.cxx index 9b229f979..05e01771a 100644 --- a/src/PARTITION/Partition_Loop2d.cxx +++ b/src/PARTITION/Partition_Loop2d.cxx @@ -1111,7 +1111,7 @@ void Partition_Loop2d::WiresToFaces(const BRepAlgo_Image& ) { // error: pb with wires classification #ifdef DEB - cout << "Partition_Loop2d::WiresToFaces(), pb with wires classification" << endl; + MESSAGE("Partition_Loop2d::WiresToFaces(), pb with wires classification"); #endif break; } diff --git a/src/PARTITION/Partition_Spliter.cxx b/src/PARTITION/Partition_Spliter.cxx index dc4900963..8f4793909 100644 --- a/src/PARTITION/Partition_Spliter.cxx +++ b/src/PARTITION/Partition_Spliter.cxx @@ -270,7 +270,7 @@ void Partition_Spliter::Compute(const TopAbs_ShapeEnum Limit) myInter3d.CompletPart3d(aListFaces, myFaceShapeMap); #ifdef PART_PERF - cout << "+++ CompletPart3d()" << endl; + MESSAGE("+++ CompletPart3d()"); aCron.Show( cout ); aCron.Reset(); aCron.Start(); @@ -283,7 +283,7 @@ void Partition_Spliter::Compute(const TopAbs_ShapeEnum Limit) FindToolsToReconstruct(); #ifdef PART_PERF - cout << "+++ FindToolsToReconstruct()" << endl; + MESSAGE("+++ FindToolsToReconstruct()"); aCron.Show( cout ); aCron.Reset(); aCron.Start(); @@ -319,7 +319,7 @@ void Partition_Spliter::Compute(const TopAbs_ShapeEnum Limit) myDoneStep = TopAbs_VERTEX; #ifdef PART_PERF - cout << "+++ CompletPart2d()" << endl; + MESSAGE("+++ CompletPart2d()"); aCron.Show( cout ); aCron.Reset(); aCron.Start(); @@ -428,7 +428,7 @@ void Partition_Spliter::Compute(const TopAbs_ShapeEnum Limit) } } #ifdef PART_PERF - cout << "+++ Cut Edges" << endl; + MESSAGE("+++ Cut Edges"); aCron.Show( cout ); aCron.Reset(); aCron.Start(); @@ -440,7 +440,7 @@ void Partition_Spliter::Compute(const TopAbs_ShapeEnum Limit) myDoneStep = TopAbs_EDGE; #ifdef PART_PERF - cout << "+++ MergeEqualEdges()" << endl; + MESSAGE("+++ MergeEqualEdges()"); aCron.Show( cout ); aCron.Reset(); aCron.Start(); @@ -485,7 +485,7 @@ void Partition_Spliter::Compute(const TopAbs_ShapeEnum Limit) myDoneStep = TopAbs_FACE; #ifdef PART_PERF - cout << "+++ MakeFaces()" << endl; + MESSAGE("+++ MakeFaces()"); aCron.Show( cout ); aCron.Reset(); aCron.Start(); @@ -528,7 +528,7 @@ void Partition_Spliter::Compute(const TopAbs_ShapeEnum Limit) myBuilder.Add (myShape, itNSL.Value()); } #ifdef PART_PERF - cout << "+++ MakeShells()" << endl; + MESSAGE("+++ MakeShells()"); aCron.Show( cout ); #endif diff --git a/src/PrimitiveGUI/Makefile.in b/src/PrimitiveGUI/Makefile.in index d7407c810..78c535dc7 100644 --- a/src/PrimitiveGUI/Makefile.in +++ b/src/PrimitiveGUI/Makefile.in @@ -48,16 +48,15 @@ LIB_SRC = PrimitiveGUI.cxx \ PrimitiveGUI_ConeDlg.cxx LIB_MOC = \ - PrimitiveGUI.h \ PrimitiveGUI_BoxDlg.h \ PrimitiveGUI_CylinderDlg.h \ PrimitiveGUI_SphereDlg.h \ PrimitiveGUI_TorusDlg.h \ PrimitiveGUI_ConeDlg.h -LIB_CLIENT_IDL = +LIB_CLIENT_IDL = SALOME_GenericObj.idl SALOME_Component.idl -LIB_SERVER_IDL = +LIB_SERVER_IDL = # additionnal information to compil and link file diff --git a/src/PrimitiveGUI/PrimitiveGUI.cxx b/src/PrimitiveGUI/PrimitiveGUI.cxx index e28c3f6f6..0304e194f 100644 --- a/src/PrimitiveGUI/PrimitiveGUI.cxx +++ b/src/PrimitiveGUI/PrimitiveGUI.cxx @@ -24,13 +24,16 @@ // File : PrimitiveGUI.cxx // Author : Damien COQUERET // Module : GEOM -// $Header: +// $Header$ using namespace std; #include "PrimitiveGUI.h" +#include "GeometryGUI.h" + +#include "QAD_Application.h" +#include "QAD_Desktop.h" #include "SALOMEGUI_QtCatchCorbaException.hxx" -#include #include "PrimitiveGUI_BoxDlg.h" // Method BOX #include "PrimitiveGUI_CylinderDlg.h" // Method CYLINDER @@ -38,21 +41,32 @@ using namespace std; #include "PrimitiveGUI_TorusDlg.h" // Method TORUS #include "PrimitiveGUI_ConeDlg.h" // Method CONE +PrimitiveGUI* PrimitiveGUI::myGUIObject = 0; + +//======================================================================= +// function : GetPrimitiveGUI() +// purpose : Get the only PrimitiveGUI object [ static ] +//======================================================================= +PrimitiveGUI* PrimitiveGUI::GetPrimitiveGUI() +{ + if ( myGUIObject == 0 ) { + // init PrimitiveGUI only once + myGUIObject = new PrimitiveGUI(); + } + return myGUIObject; +} + //======================================================================= // function : PrimitiveGUI() // purpose : Constructor //======================================================================= -PrimitiveGUI::PrimitiveGUI() : - QObject() +PrimitiveGUI::PrimitiveGUI() : GEOMGUI() { - myGeomBase = new GEOMBase(); - myGeomGUI = GEOMContext::GetGeomGUI(); - myGeom = myGeomGUI->myComponentGeom; } //======================================================================= -// function : ~PrimitiveGUI() +// function : ~PrimitiveGUI // purpose : Destructor //======================================================================= PrimitiveGUI::~PrimitiveGUI() @@ -66,34 +80,37 @@ PrimitiveGUI::~PrimitiveGUI() //======================================================================= bool PrimitiveGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) { - PrimitiveGUI* aPrimitiveGUI = new PrimitiveGUI(); - aPrimitiveGUI->myGeomGUI->EmitSignalDeactivateDialog(); + PrimitiveGUI* aPrimitiveGUI = GetPrimitiveGUI(); + GeometryGUI::GetGeomGUI()->EmitSignalDeactivateDialog(); SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection()); + + QDialog* aDlg = NULL; + switch (theCommandID) { case 4021: // BOX { - PrimitiveGUI_BoxDlg* aDlg = new PrimitiveGUI_BoxDlg(parent, "", aPrimitiveGUI, Sel); + aDlg = new PrimitiveGUI_BoxDlg(parent, "", Sel); break; } case 4022: // CYLINDER { - PrimitiveGUI_CylinderDlg* aDlg = new PrimitiveGUI_CylinderDlg(parent, "", aPrimitiveGUI, Sel); + aDlg = new PrimitiveGUI_CylinderDlg(parent, "", Sel); break; } case 4023: // SPHERE { - PrimitiveGUI_SphereDlg* aDlg = new PrimitiveGUI_SphereDlg(parent, "", aPrimitiveGUI, Sel); + aDlg = new PrimitiveGUI_SphereDlg(parent, "", Sel); break; } case 4024: // TORUS { - PrimitiveGUI_TorusDlg* aDlg = new PrimitiveGUI_TorusDlg(parent, "", aPrimitiveGUI, Sel); + aDlg = new PrimitiveGUI_TorusDlg(parent, "", Sel); break; } case 4025: // CONE { - PrimitiveGUI_ConeDlg* aDlg = new PrimitiveGUI_ConeDlg(parent, "", aPrimitiveGUI, Sel); + aDlg = new PrimitiveGUI_ConeDlg(parent, "", Sel); break; } default: @@ -102,143 +119,11 @@ bool PrimitiveGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) break; } } - return true; -} - - -//======================================================================= -// function : MakeBoxAndDisplay() -// purpose : -//======================================================================= -void PrimitiveGUI::MakeBoxAndDisplay(const gp_Pnt P1, const gp_Pnt P2) -{ - try { - GEOM::GEOM_Shape_var box = myGeom->MakeBox(P1.X(), P1.Y(), P1.Z(), P2.X(), P2.Y(), P2.Z()); - box->NameType(tr("GEOM_BOX")); - if(myGeomBase->Display(box)) - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); - } - catch(const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } -} - - -//===================================================================================== -// function : MakeCylinderAndDisplay() -// purpose : -//===================================================================================== -void PrimitiveGUI::MakeCylinderAndDisplay(const gp_Pnt BasePoint, const gp_Dir aDir, - const double Radius, const double aHeight) -{ - try { - if(Radius <= Precision::Confusion() || aHeight <= Precision::Confusion()) - return; - - GEOM::PointStruct pstruct = myGeom->MakePointStruct(BasePoint.X(), BasePoint.Y(), BasePoint.Z()); - GEOM::PointStruct d = myGeom->MakePointStruct(aDir.X(), aDir.Y(), aDir.Z()); - GEOM::DirStruct dstruct = myGeom->MakeDirection(d); - - GEOM::GEOM_Shape_var result = myGeom->MakeCylinder(pstruct, dstruct, Radius, aHeight); - if (result->_is_nil()) { - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_ABORT")); - return; - } - result->NameType(tr("GEOM_CYLINDER")); - if(myGeomBase->Display(result)) - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); - } - catch(const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return; -} - - -//===================================================================================== -// function : MakeSphere() -// purpose : -//===================================================================================== -void PrimitiveGUI::MakeSphereAndDisplay(const gp_Pnt aCenterPoint, const double aRadius) -{ - try { - if(aRadius <= Precision::Confusion()) - return; - - GEOM::GEOM_Shape_ptr result = myGeom->MakeSphere(aCenterPoint.X(),aCenterPoint.Y(),aCenterPoint.Z(), aRadius); - result->NameType(tr("GEOM_SPHERE")); - if (myGeomBase->Display(result)) - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); - } - catch (const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return; -} - - -//===================================================================================== -// function : MakeTorusAndDisplay() -// purpose : -//===================================================================================== -void PrimitiveGUI::MakeTorusAndDisplay(const gp_Pnt BasePoint, const gp_Dir aDir, - const double Radius1, const double Radius2) -{ - try { - if(Radius1 <= Precision::Confusion() || Radius2 <= Precision::Confusion()) - return; - - GEOM::PointStruct pstruct = myGeom->MakePointStruct(BasePoint.X(), BasePoint.Y(), BasePoint.Z()); - GEOM::PointStruct d = myGeom ->MakePointStruct(aDir.X(), aDir.Y(), aDir.Z()); - GEOM::DirStruct dstruct = myGeom->MakeDirection(d); - - GEOM::GEOM_Shape_var result = myGeom->MakeTorus(pstruct, dstruct, Radius1, Radius2); - if(result->_is_nil()) { - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_ABORT")); - return; - } - result->NameType(tr("GEOM_TORUS")); - if(myGeomBase->Display(result)) - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); - } - catch(const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return; -} - - -//===================================================================================== -// function : MakeConeAndDisplay() -// purpose : -//===================================================================================== -void PrimitiveGUI::MakeConeAndDisplay(const gp_Pnt BasePoint, const gp_Dir aDir, - const double Radius1, const double Radius2, const double aHeight) -{ - try { - double myRadius2 = Radius2; - if(myRadius2 < Precision::Confusion()) - myRadius2 = Precision::Confusion(); - if(Radius1 <= Precision::Confusion() || aHeight <= Precision::Confusion()) - return; - GEOM::PointStruct pstruct = myGeom->MakePointStruct(BasePoint.X(), BasePoint.Y(), BasePoint.Z()); - GEOM::PointStruct d = myGeom->MakePointStruct(aDir.X(), aDir.Y(), aDir.Z()); - GEOM::DirStruct dstruct = myGeom->MakeDirection(d); - - GEOM::GEOM_Shape_var result = myGeom->MakeCone(pstruct, dstruct, Radius1, myRadius2, aHeight); - if(result->_is_nil()) { - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_ABORT")); - return; - } - result->NameType(tr("GEOM_CONE")); - if(myGeomBase->Display(result)) - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); - } - catch(const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return; + if ( aDlg != NULL ) + aDlg->show(); + + return true; } @@ -247,6 +132,8 @@ void PrimitiveGUI::MakeConeAndDisplay(const gp_Pnt BasePoint, const gp_Dir aDir, //===================================================================================== extern "C" { - bool OnGUIEvent(int theCommandID, QAD_Desktop* parent) - {return PrimitiveGUI::OnGUIEvent(theCommandID, parent);} + GEOMGUI* GetLibGUI() + { + return PrimitiveGUI::GetPrimitiveGUI(); + } } diff --git a/src/PrimitiveGUI/PrimitiveGUI.h b/src/PrimitiveGUI/PrimitiveGUI.h index f85e68815..3276c5ed6 100644 --- a/src/PrimitiveGUI/PrimitiveGUI.h +++ b/src/PrimitiveGUI/PrimitiveGUI.h @@ -24,40 +24,33 @@ // File : PrimitiveGUI.h // Author : Damien COQUERET // Module : GEOM -// $Header: +// $Header$ #ifndef PRIMITIVEGUI_H #define PRIMITIVEGUI_H -#include "GEOMBase.h" +#include "GEOMGUI.h" + //================================================================================= // class : PrimitiveGUI // purpose : //================================================================================= -class PrimitiveGUI : public QObject +class PrimitiveGUI : public GEOMGUI { - Q_OBJECT /* for QT compatibility */ +protected: + PrimitiveGUI(); // hide constructor to avoid direct creation public : - PrimitiveGUI(); ~PrimitiveGUI(); - static bool OnGUIEvent(int theCommandID, QAD_Desktop* parent); + // Get the only PrimitiveGUI object + static PrimitiveGUI* GetPrimitiveGUI(); - void MakeBoxAndDisplay(const gp_Pnt P1, const gp_Pnt P2); - void MakeCylinderAndDisplay(const gp_Pnt BasePoint, const gp_Dir aDir, - const double Radius, const double aHeight); - void MakeSphereAndDisplay(const gp_Pnt aCenterPoint, const double aRadius); - void MakeTorusAndDisplay(const gp_Pnt BasePoint, const gp_Dir aDir, - const double Radius1, const double Radius2); - void MakeConeAndDisplay(const gp_Pnt BasePoint, const gp_Dir aDir, - const double Radius1, const double Radius2, const double aHeight); - - GEOMBase* myGeomBase; - GEOMContext* myGeomGUI; - GEOM::GEOM_Gen_var myGeom; /* Current Geom Component */ + bool OnGUIEvent(int theCommandID, QAD_Desktop* parent); +private: + static PrimitiveGUI* myGUIObject; // the only PrimitiveGUI object }; #endif diff --git a/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.cxx b/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.cxx index 24b638432..de16e300b 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.cxx +++ b/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.cxx @@ -26,12 +26,17 @@ // Module : GEOM // $Header$ -using namespace std; #include "PrimitiveGUI_BoxDlg.h" -#include -#include #include "QAD_Config.h" +#include "QAD_Desktop.h" + +#include "GEOMImpl_Types.hxx" + +#include "utilities.h" + +using namespace std; + //================================================================================= // class : PrimitiveGUI_BoxDlg() @@ -40,7 +45,7 @@ using namespace std; // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -PrimitiveGUI_BoxDlg::PrimitiveGUI_BoxDlg(QWidget* parent, const char* name, PrimitiveGUI* thePrimitiveGUI, SALOME_Selection* Sel, bool modal, WFlags fl) +PrimitiveGUI_BoxDlg::PrimitiveGUI_BoxDlg(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_BOX_2P"))); @@ -68,12 +73,10 @@ PrimitiveGUI_BoxDlg::PrimitiveGUI_BoxDlg(QWidget* parent, const char* name, Prim GroupDimensions->TextLabel2->setText(tr("GEOM_DY")); GroupDimensions->TextLabel3->setText(tr("GEOM_DZ")); - Layout1->addWidget(GroupPoints, 1, 0); - Layout1->addWidget(GroupDimensions, 1, 0); + Layout1->addWidget(GroupPoints, 2, 0); + Layout1->addWidget(GroupDimensions, 2, 0); /***************************************************************/ - - /* Initialisations */ - myPrimitiveGUI = thePrimitiveGUI; + Init(); } @@ -95,20 +98,15 @@ PrimitiveGUI_BoxDlg::~PrimitiveGUI_BoxDlg() void PrimitiveGUI_BoxDlg::Init() { /* init variables */ - myConstructorId = 0; myEditCurrentArgument = GroupPoints->LineEdit1; - - myPoint1.SetCoord(0.0, 0.0, 0.0); - myPoint2.SetCoord(0.0, 0.0, 0.0); - myOkPoint1 = myOkPoint2 = false; - - /* Vertices Filter for all arguments */ - myVertexFilter = new GEOM_ShapeTypeFilter(TopAbs_VERTEX, myGeom); - mySelection->AddFilter(myVertexFilter); - + GroupPoints->LineEdit1->setReadOnly( true ); + GroupPoints->LineEdit2->setReadOnly( true ); + + myPoint1 = myPoint2 = GEOM::GEOM_Object::_nil(); + /* Get setting of step value from file configuration */ QString St = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep"); - step = St.toDouble(); + double step = St.toDouble(); /* min, max, step and decimals for spin boxes */ GroupDimensions->SpinBox_DX->RangeStepAndValidator(-999.999, 999.999, step, 3); @@ -131,9 +129,9 @@ void PrimitiveGUI_BoxDlg::Init() connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupDimensions->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(GroupDimensions->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(GroupDimensions->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupDimensions->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); + connect(GroupDimensions->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); + connect(GroupDimensions->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupDimensions->SpinBox_DX, SLOT(SetStep(double))); connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupDimensions->SpinBox_DY, SLOT(SetStep(double))); @@ -141,12 +139,8 @@ void PrimitiveGUI_BoxDlg::Init() connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - /* displays Dialog */ - GroupDimensions->hide(); - GroupPoints->show(); - this->show(); - - return; + initName( tr( "GEOM_BOX" ) ); + ConstructorsClicked(0); } @@ -156,27 +150,23 @@ void PrimitiveGUI_BoxDlg::Init() //================================================================================= void PrimitiveGUI_BoxDlg::ConstructorsClicked(int constructorId) { - myConstructorId = constructorId; - mySelection->ClearFilters(); - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); disconnect(mySelection, 0, this, 0); - myOkPoint1 = myOkPoint2 = false; - + switch (constructorId) { case 0: { + globalSelection( GEOM_POINT ); + GroupDimensions->hide(); resize(0, 0); GroupPoints->show(); - + myEditCurrentArgument = GroupPoints->LineEdit1; GroupPoints->LineEdit1->setText(""); GroupPoints->LineEdit2->setText(""); - - /* filter for next selection */ - mySelection->AddFilter(myVertexFilter); + myPoint1 = myPoint2 = GEOM::GEOM_Object::_nil(); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); break; } @@ -185,21 +175,11 @@ void PrimitiveGUI_BoxDlg::ConstructorsClicked(int constructorId) GroupPoints->hide(); resize(0, 0); GroupDimensions->show(); - - double initValue = 200.0; - GroupDimensions->SpinBox_DX->SetValue(initValue); - GroupDimensions->SpinBox_DY->SetValue(initValue); - GroupDimensions->SpinBox_DZ->SetValue(initValue); - - myPoint1.SetCoord(0.0, 0.0, 0.0) ; - myPoint2.SetCoord(initValue, initValue, initValue); - - mySimulationTopoDs = BRepPrimAPI_MakeBox(myPoint1, myPoint2).Shape(); - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); + break; } } - return; + displayPreview(); } @@ -209,9 +189,8 @@ void PrimitiveGUI_BoxDlg::ConstructorsClicked(int constructorId) //================================================================================= void PrimitiveGUI_BoxDlg::ClickOnOk() { - this->ClickOnApply(); - ClickOnCancel(); - return; + if ( ClickOnApply() ) + ClickOnCancel(); } @@ -219,36 +198,24 @@ void PrimitiveGUI_BoxDlg::ClickOnOk() // function : ClickOnApply() // purpose : //================================================================================= -void PrimitiveGUI_BoxDlg::ClickOnApply() +bool PrimitiveGUI_BoxDlg::ClickOnApply() { - buttonApply->setFocus(); - QAD_Application::getDesktop()->putInfo(tr("")); - if (mySimulationTopoDs.IsNull()) - return; - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); + if ( !onAccept() ) + return false; + + initName(); + ConstructorsClicked( getConstructorId() ); + return true; +} - switch(myConstructorId) - { - case 0 : - { - if(myOkPoint1 && myOkPoint2) - myPrimitiveGUI->MakeBoxAndDisplay(myPoint1, myPoint2); - break; - } - case 1 : - { - /* Recup args and call method */ - double vx = GroupDimensions->SpinBox_DX->GetValue(); - double vy = GroupDimensions->SpinBox_DY->GetValue(); - double vz = GroupDimensions->SpinBox_DZ->GetValue(); - myPoint1.SetCoord(0.0, 0.0, 0.0); - myPoint2.SetCoord(vx, vy, vz); - myPrimitiveGUI->MakeBoxAndDisplay(myPoint1, myPoint2); - break; - } - } - return; + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void PrimitiveGUI_BoxDlg::ClickOnCancel() +{ + GEOMBase_Skeleton::ClickOnCancel(); } @@ -258,38 +225,35 @@ void PrimitiveGUI_BoxDlg::ClickOnApply() //================================================================================= void PrimitiveGUI_BoxDlg::SelectionIntoArgument() { - myGeomBase->EraseSimulationShape(); - myEditCurrentArgument->setText(""); - QString aString = ""; /* name of selection */ - - int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString); - if (nbSel != 1) { - if (myEditCurrentArgument == GroupPoints->LineEdit1) - myOkPoint1 = false; - else if ( myEditCurrentArgument == GroupPoints->LineEdit2) - myOkPoint2 = false; + if ( getConstructorId() != 0 ) return; - } + + myEditCurrentArgument->setText(""); + + if (mySelection->IObjectCount() != 1) + { + if (myEditCurrentArgument == GroupPoints->LineEdit1) + myPoint1 = GEOM::GEOM_Object::_nil(); + else if ( myEditCurrentArgument == GroupPoints->LineEdit2) + myPoint2 = GEOM::GEOM_Object::_nil(); + return; + } // nbSel == 1 - TopoDS_Shape S; - if(!myGeomBase->GetTopoFromSelection(mySelection, S)) + Standard_Boolean testResult = Standard_False; + GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(mySelection->firstIObject(), testResult ); + + if(!testResult || CORBA::is_nil( aSelectedObject )) return; - - if(myEditCurrentArgument == GroupPoints->LineEdit1 && myGeomBase->VertexToPoint(S, myPoint1)) { - myEditCurrentArgument->setText(aString); - myOkPoint1 = true; - } - else if(myEditCurrentArgument == GroupPoints->LineEdit2 && myGeomBase->VertexToPoint(S, myPoint2)) { - myEditCurrentArgument->setText(aString); - myOkPoint2 = true; - } - - if(myOkPoint1 && myOkPoint2 && TestBoxDimensions(myPoint1, myPoint2)) { - mySimulationTopoDs = BRepPrimAPI_MakeBox(myPoint1, myPoint2).Shape(); - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - } - return; + + if(myEditCurrentArgument == GroupPoints->LineEdit1) + myPoint1 = aSelectedObject; + else if(myEditCurrentArgument == GroupPoints->LineEdit2) + myPoint2 = aSelectedObject; + + myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) ); + + displayPreview(); } @@ -299,23 +263,17 @@ void PrimitiveGUI_BoxDlg::SelectionIntoArgument() //================================================================================= void PrimitiveGUI_BoxDlg::SetEditCurrentArgument() { - if(myConstructorId != 0) - return; - QPushButton* send = (QPushButton*)sender(); - - if(send == GroupPoints->PushButton1) { - GroupPoints->LineEdit1->setFocus(); + + if(send == GroupPoints->PushButton1) myEditCurrentArgument = GroupPoints->LineEdit1; - } - else if(send == GroupPoints->PushButton2) { - GroupPoints->LineEdit2->setFocus(); + else if(send == GroupPoints->PushButton2) myEditCurrentArgument = GroupPoints->LineEdit2; - } - mySelection->AddFilter(myVertexFilter); - this->SelectionIntoArgument(); - - return; + + globalSelection( GEOM_POINT ); + + myEditCurrentArgument->setFocus(); + SelectionIntoArgument(); } @@ -326,15 +284,11 @@ void PrimitiveGUI_BoxDlg::SetEditCurrentArgument() void PrimitiveGUI_BoxDlg::LineEditReturnPressed() { QLineEdit* send = (QLineEdit*)sender(); - if(send == GroupPoints->LineEdit1) - myEditCurrentArgument = GroupPoints->LineEdit1; - else if (send == GroupPoints->LineEdit2) - myEditCurrentArgument = GroupPoints->LineEdit2; - else - return; - - GEOMBase_Skeleton::LineEditReturnPressed(); - return; + if(send == GroupPoints->LineEdit1 || send == GroupPoints->LineEdit2) + { + myEditCurrentArgument = send; + GEOMBase_Skeleton::LineEditReturnPressed(); + } } @@ -346,11 +300,8 @@ void PrimitiveGUI_BoxDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - if(myConstructorId == 0) - mySelection->AddFilter(myVertexFilter); - if(!mySimulationTopoDs.IsNull()) - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - return; + + ConstructorsClicked( getConstructorId() ); } @@ -360,10 +311,18 @@ void PrimitiveGUI_BoxDlg::ActivateThisDialog() //================================================================================= void PrimitiveGUI_BoxDlg::enterEvent(QEvent* e) { - if(GroupConstructors->isEnabled()) - return; - this->ActivateThisDialog(); - return; + if ( !GroupConstructors->isEnabled() ) + ActivateThisDialog(); +} + + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : public slot to deactivate if active +//================================================================================= +void PrimitiveGUI_BoxDlg::DeactivateActiveDialog() +{ + GEOMBase_Skeleton::DeactivateActiveDialog(); } @@ -371,49 +330,77 @@ void PrimitiveGUI_BoxDlg::enterEvent(QEvent* e) // function : ValueChangedInSpinBox() // purpose : //================================================================================= -void PrimitiveGUI_BoxDlg::ValueChangedInSpinBox(double newValue) +void PrimitiveGUI_BoxDlg::ValueChangedInSpinBox() { - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); - QObject* send = (QObject*)sender(); - double vx, vy, vz; - - if(send == GroupDimensions->SpinBox_DX) { - vx = newValue; - vy = GroupDimensions->SpinBox_DY->GetValue(); - vz = GroupDimensions->SpinBox_DZ->GetValue(); - } - else if(send == GroupDimensions->SpinBox_DY) { - vx = GroupDimensions->SpinBox_DX->GetValue(); - vy = newValue; - vz = GroupDimensions->SpinBox_DZ->GetValue(); - } - else if(send == GroupDimensions->SpinBox_DZ) { - vx = GroupDimensions->SpinBox_DX->GetValue(); - vy = GroupDimensions->SpinBox_DY->GetValue(); - vz = newValue; - } + displayPreview(); +} - myPoint1.SetCoord(0.0, 0.0, 0.0); - myPoint2.SetCoord(vx, vy, vz); - if(TestBoxDimensions(myPoint1, myPoint2)) { - mySimulationTopoDs = BRepPrimAPI_MakeBox(myPoint1, myPoint2).Shape(); - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - } - return; +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr PrimitiveGUI_BoxDlg::createOperation() +{ + return getGeomEngine()->GetI3DPrimOperations( getStudyId() ); } //================================================================================= -// function : TestBoxDimensions() +// function : isValid +// purpose : +//================================================================================= +bool PrimitiveGUI_BoxDlg::isValid( QString& msg ) +{ + return getConstructorId() == 0 ? !(myPoint1->_is_nil() || myPoint2->_is_nil()) : true; +} + + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool PrimitiveGUI_BoxDlg::execute( ObjectList& objects ) +{ + bool res = false; + + GEOM::GEOM_Object_var anObj; + + switch ( getConstructorId() ) + { + case 0 : + { + if ( !CORBA::is_nil( myPoint1 ) && !CORBA::is_nil( myPoint2 ) ) { + anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeBoxTwoPnt( myPoint1, myPoint2 ); + res = true; + } + + break; + } + case 1 : + { + double x = GroupDimensions->SpinBox_DX->GetValue(); + double y = GroupDimensions->SpinBox_DY->GetValue(); + double z = GroupDimensions->SpinBox_DZ->GetValue(); + + anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeBoxDXDYDZ( x, y, z ); + res = true; + + break; + } + } + + if ( !anObj->_is_nil() ) + objects.push_back( anObj._retn() ); + + return res; +} + +//================================================================================= +// function : closeEvent // purpose : //================================================================================= -bool PrimitiveGUI_BoxDlg::TestBoxDimensions(gp_Pnt P1, gp_Pnt P2) +void PrimitiveGUI_BoxDlg::closeEvent( QCloseEvent* e ) { - if ((fabs(P1.X() - P2.X()) > Precision::Confusion()) && - (fabs(P1.Y() - P2.Y()) > Precision::Confusion()) && - (fabs(P1.Z() - P2.Z()) > Precision::Confusion())) - return true; - return false; + GEOMBase_Skeleton::closeEvent( e ); } diff --git a/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.h b/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.h index 0638af8fe..1756b3984 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.h +++ b/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.h @@ -33,10 +33,7 @@ #include "DlgRef_2Sel_QTD.h" #include "DlgRef_3Spin.h" -#include "PrimitiveGUI.h" - -#include "GEOM_ShapeTypeFilter.hxx" -#include +using namespace std; //================================================================================= // class : PrimitiveGUI_BoxDlg @@ -45,40 +42,40 @@ class PrimitiveGUI_BoxDlg : public GEOMBase_Skeleton { Q_OBJECT - -public: - PrimitiveGUI_BoxDlg(QWidget* parent = 0, const char* name = 0, PrimitiveGUI* thePrimitiveGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + + public: + PrimitiveGUI_BoxDlg(QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); ~PrimitiveGUI_BoxDlg(); + +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& ); + virtual bool execute( ObjectList& objects ); + + virtual void closeEvent( QCloseEvent* e ); private : void Init(); void enterEvent(QEvent* e); - bool TestBoxDimensions(gp_Pnt P1, gp_Pnt P2); - - PrimitiveGUI* myPrimitiveGUI; - - double step; - int myConstructorId; - Handle(GEOM_ShapeTypeFilter) myVertexFilter; /* filter for selection */ - - gp_Pnt myPoint1; /* Points containing the vector */ - gp_Pnt myPoint2; - bool myOkPoint1; /* true when myPoint is defined */ - bool myOkPoint2; - + + GEOM::GEOM_Object_var myPoint1, myPoint2; /* Points containing the vector */ + DlgRef_2Sel_QTD* GroupPoints; DlgRef_3Spin* GroupDimensions; private slots: void ClickOnOk(); - void ClickOnApply(); + bool ClickOnApply(); + void ClickOnCancel(); void ActivateThisDialog(); + void DeactivateActiveDialog(); void LineEditReturnPressed(); void SelectionIntoArgument(); void SetEditCurrentArgument(); - void ConstructorsClicked(int constructorId); - void ValueChangedInSpinBox(double newValue); - + void ConstructorsClicked(int); + void ValueChangedInSpinBox(); + }; #endif // DIALOGBOX_BOX_H diff --git a/src/PrimitiveGUI/PrimitiveGUI_ConeDlg.cxx b/src/PrimitiveGUI/PrimitiveGUI_ConeDlg.cxx index f9af4748d..2a4055a6b 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_ConeDlg.cxx +++ b/src/PrimitiveGUI/PrimitiveGUI_ConeDlg.cxx @@ -28,12 +28,10 @@ #include "PrimitiveGUI_ConeDlg.h" -#include -#include -#include -#include -#include #include "QAD_Config.h" +#include "QAD_Desktop.h" + +#include "GEOMImpl_Types.hxx" #include "utilities.h" @@ -46,7 +44,7 @@ using namespace std; // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -PrimitiveGUI_ConeDlg::PrimitiveGUI_ConeDlg(QWidget* parent, const char* name, PrimitiveGUI* thePrimitiveGUI, SALOME_Selection* Sel, bool modal, WFlags fl) +PrimitiveGUI_ConeDlg::PrimitiveGUI_ConeDlg(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_CONE_PV"))); @@ -77,12 +75,10 @@ PrimitiveGUI_ConeDlg::PrimitiveGUI_ConeDlg(QWidget* parent, const char* name, Pr GroupDimensions->TextLabel2->setText(tr("GEOM_RADIUS_I").arg("2")); GroupDimensions->TextLabel3->setText(tr("GEOM_HEIGHT")); - Layout1->addWidget(GroupPoints, 1, 0); - Layout1->addWidget(GroupDimensions, 1, 0); + Layout1->addWidget(GroupPoints, 2, 0); + Layout1->addWidget(GroupDimensions, 2, 0); /***************************************************************/ - /* Initialisations */ - myPrimitiveGUI = thePrimitiveGUI; Init(); } @@ -104,23 +100,15 @@ PrimitiveGUI_ConeDlg::~PrimitiveGUI_ConeDlg() void PrimitiveGUI_ConeDlg::Init() { /* init variables */ - myConstructorId = 0; myEditCurrentArgument = GroupPoints->LineEdit1; - - myRadius1 = 100.0; - myRadius2 = 0.0; - myHeight = 300.0; - - myOkRadius1 = myOkRadius2 = myOkHeight = true; - myOkPoint1 = myOkDir = false; - - myEdgeFilter = new GEOM_EdgeFilter(StdSelect_Line, myGeom); - myVertexFilter = new GEOM_ShapeTypeFilter(TopAbs_VERTEX, myGeom); - mySelection->AddFilter(myVertexFilter); - + GroupPoints->LineEdit1->setReadOnly( true ); + GroupPoints->LineEdit2->setReadOnly( true ); + + myPoint = myDir = GEOM::GEOM_Object::_nil(); + /* Get setting of step value from file configuration */ QString St = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep"); - step = St.toDouble(); + double step = St.toDouble(); /* min, max, step and decimals for spin boxes & initial values */ GroupPoints->SpinBox_DX->RangeStepAndValidator(0.000, 999.999, step, 3); @@ -130,12 +118,13 @@ void PrimitiveGUI_ConeDlg::Init() GroupDimensions->SpinBox_DY->RangeStepAndValidator(0.000, 999.999, step, 3); GroupDimensions->SpinBox_DZ->RangeStepAndValidator(-999.999, 999.999, step, 3); - GroupPoints->SpinBox_DX->SetValue(myRadius1); - GroupPoints->SpinBox_DY->SetValue(myRadius2); - GroupPoints->SpinBox_DZ->SetValue(myHeight); - GroupDimensions->SpinBox_DX->SetValue(myRadius1); - GroupDimensions->SpinBox_DY->SetValue(myRadius2); - GroupDimensions->SpinBox_DZ->SetValue(myHeight); + double aRadius1(100.0), aRadius2(0.0), aHeight(300.0); + GroupPoints->SpinBox_DX->SetValue(aRadius1); + GroupPoints->SpinBox_DY->SetValue(aRadius2); + GroupPoints->SpinBox_DZ->SetValue(aHeight); + GroupDimensions->SpinBox_DX->SetValue(aRadius1); + GroupDimensions->SpinBox_DY->SetValue(aRadius2); + GroupDimensions->SpinBox_DZ->SetValue(aHeight); /* signals and slots connections */ connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); @@ -148,12 +137,12 @@ void PrimitiveGUI_ConeDlg::Init() connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(GroupPoints->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(GroupPoints->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(GroupDimensions->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(GroupDimensions->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(GroupDimensions->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); + connect(GroupPoints->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); + connect(GroupPoints->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); + connect(GroupDimensions->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); + connect(GroupDimensions->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); + connect(GroupDimensions->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox_DX, SLOT(SetStep(double))); connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox_DY, SLOT(SetStep(double))); @@ -163,13 +152,9 @@ void PrimitiveGUI_ConeDlg::Init() connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupDimensions->SpinBox_DZ, SLOT(SetStep(double))); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ; - - /* displays Dialog */ - GroupDimensions->hide(); - GroupPoints->show(); - this->show(); - - return ; + + initName( tr( "GEOM_CONE" ) ); + ConstructorsClicked(0); } @@ -179,34 +164,22 @@ void PrimitiveGUI_ConeDlg::Init() //================================================================================= void PrimitiveGUI_ConeDlg::ConstructorsClicked(int constructorId) { - myConstructorId = constructorId; - mySelection->ClearFilters(); - myGeomBase->EraseSimulationShape(); disconnect(mySelection, 0, this, 0); - myOkHeight = myOkRadius1 = myOkRadius2 = true; - myRadius1 = 100.0; - myRadius2 = 0.0; - myHeight = 300.0; - - switch(myConstructorId) + + switch(constructorId) { case 0 : { + globalSelection( GEOM_POINT ); GroupDimensions->hide(); resize(0, 0); GroupPoints->show(); - myOkPoint1 = myOkDir = false; - + myEditCurrentArgument = GroupPoints->LineEdit1; GroupPoints->LineEdit1->setText(tr("")); GroupPoints->LineEdit2->setText(tr("")); + myPoint = myDir = GEOM::GEOM_Object::_nil(); - GroupPoints->SpinBox_DX->SetValue(myRadius1); - GroupPoints->SpinBox_DY->SetValue(myRadius2); - GroupPoints->SpinBox_DZ->SetValue(myHeight); - - /* filter for next selection */ - mySelection->AddFilter(myVertexFilter); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); break; } @@ -215,20 +188,11 @@ void PrimitiveGUI_ConeDlg::ConstructorsClicked(int constructorId) GroupPoints->hide(); resize( 0, 0 ); GroupDimensions->show(); - myOkPoint1 = myOkDir = true; - - GroupDimensions->SpinBox_DX->SetValue(myRadius1); - GroupDimensions->SpinBox_DY->SetValue(myRadius2); - GroupDimensions->SpinBox_DZ->SetValue(myHeight); - myPoint1.SetCoord(0.0, 0.0, 0.0); - myDir.SetCoord(0.0, 0.0, 1.0); - - MakeConeSimulationAndDisplay(); break; } } - return ; + displayPreview(); } @@ -238,9 +202,8 @@ void PrimitiveGUI_ConeDlg::ConstructorsClicked(int constructorId) //================================================================================= void PrimitiveGUI_ConeDlg::ClickOnOk() { - this->ClickOnApply(); - ClickOnCancel(); - return; + if ( ClickOnApply() ) + ClickOnCancel(); } @@ -248,23 +211,24 @@ void PrimitiveGUI_ConeDlg::ClickOnOk() // function : ClickOnApply() // purpose : //================================================================================= -void PrimitiveGUI_ConeDlg::ClickOnApply() +bool PrimitiveGUI_ConeDlg::ClickOnApply() { - buttonApply->setFocus(); - QAD_Application::getDesktop()->putInfo(tr("")); - if (mySimulationTopoDs.IsNull()) - return; - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); - - if(myOkPoint1 && myOkDir && myOkRadius1 && myOkRadius2 && myOkHeight) { - gp_Dir aDir = myDir; - /* allows user to reverse direction of construction with a negative height */ - if(this->myHeight < -Precision::Confusion()) - aDir.Reverse(); - myPrimitiveGUI->MakeConeAndDisplay(myPoint1, aDir, myRadius1, myRadius2, fabs(myHeight)); - } - return ; + if ( !onAccept() ) + return false; + + initName(); + ConstructorsClicked( getConstructorId() ); + return true; +} + + +//======================================================================= +// function : ClickOnCancel() +// purpose : +//======================================================================= +void PrimitiveGUI_ConeDlg::ClickOnCancel() +{ + GEOMBase_Skeleton::ClickOnCancel(); } @@ -274,39 +238,33 @@ void PrimitiveGUI_ConeDlg::ClickOnApply() //================================================================================= void PrimitiveGUI_ConeDlg::SelectionIntoArgument() { - myGeomBase->EraseSimulationShape(); - myEditCurrentArgument->setText(""); - QString aString = ""; /* name of selection */ - - int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString); - if(nbSel != 1) { - if(myEditCurrentArgument == GroupPoints->LineEdit1) - myOkPoint1 = false; - else if (myEditCurrentArgument == GroupPoints->LineEdit2) - myOkDir = false; + if ( getConstructorId() != 0 ) return; - } + + if(mySelection->IObjectCount() != 1) + { + if(myEditCurrentArgument == GroupPoints->LineEdit1) + myPoint = GEOM::GEOM_Object::_nil(); + else if (myEditCurrentArgument == GroupPoints->LineEdit2) + myDir = GEOM::GEOM_Object::_nil(); + return; + } /* nbSel == 1 */ - TopoDS_Shape S; - if(!myGeomBase->GetTopoFromSelection(mySelection, S)) + Standard_Boolean testResult = Standard_False; + GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( mySelection->firstIObject(), testResult ); + + if(!testResult || CORBA::is_nil( aSelectedObject )) return; - /* gp_Pnt : not used */ - if (myEditCurrentArgument == GroupPoints->LineEdit1 && myGeomBase->VertexToPoint(S, myPoint1)) { - GroupPoints->LineEdit1->setText(aString); - myOkPoint1 = true; - } - else if (myEditCurrentArgument == GroupPoints->LineEdit2) { - BRepAdaptor_Curve curv(TopoDS::Edge(S)); - myDir = curv.Line().Direction(); - GroupPoints->LineEdit2->setText(aString); - myOkDir = true; - } - - if(myOkPoint1 && myOkDir && myOkRadius1 && myOkRadius2 && myOkHeight) - MakeConeSimulationAndDisplay(); - return; + if (myEditCurrentArgument == GroupPoints->LineEdit1) + myPoint = aSelectedObject; + else if (myEditCurrentArgument == GroupPoints->LineEdit2) + myDir = aSelectedObject; + + + myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) ); + displayPreview(); } @@ -316,25 +274,19 @@ void PrimitiveGUI_ConeDlg::SelectionIntoArgument() //================================================================================= void PrimitiveGUI_ConeDlg::SetEditCurrentArgument() { - if(myConstructorId != 0) - return; - QPushButton* send = (QPushButton*)sender(); - mySelection->ClearFilters(); - + if(send == GroupPoints->PushButton1) { - GroupPoints->LineEdit1->setFocus(); myEditCurrentArgument = GroupPoints->LineEdit1; - mySelection->AddFilter(myVertexFilter); + globalSelection( GEOM_POINT ); } else if(send == GroupPoints->PushButton2) { - GroupPoints->LineEdit2->setFocus(); myEditCurrentArgument = GroupPoints->LineEdit2; - mySelection->AddFilter(myEdgeFilter); + globalSelection( GEOM_LINE ); } - this->SelectionIntoArgument(); - - return; + + myEditCurrentArgument->setFocus(); + SelectionIntoArgument(); } @@ -345,15 +297,12 @@ void PrimitiveGUI_ConeDlg::SetEditCurrentArgument() void PrimitiveGUI_ConeDlg::LineEditReturnPressed() { QLineEdit* send = (QLineEdit*)sender(); - if(send == GroupPoints->LineEdit1) - myEditCurrentArgument = GroupPoints->LineEdit1; - else if (send == GroupPoints->LineEdit2) - myEditCurrentArgument = GroupPoints->LineEdit2; - else - return; - - GEOMBase_Skeleton::LineEditReturnPressed(); - return; + if(send == GroupPoints->LineEdit1 || + send == GroupPoints->LineEdit2) + { + myEditCurrentArgument = send; + GEOMBase_Skeleton::LineEditReturnPressed(); + } } @@ -365,14 +314,18 @@ void PrimitiveGUI_ConeDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - if(myConstructorId == 0) { - GroupPoints->LineEdit1->setFocus(); - myEditCurrentArgument = GroupPoints->LineEdit1; - mySelection->AddFilter(myVertexFilter); - } - if(!mySimulationTopoDs.IsNull()) - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - return; + + ConstructorsClicked( getConstructorId() ); +} + + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : public slot to deactivate if active +//================================================================================= +void PrimitiveGUI_ConeDlg::DeactivateActiveDialog() +{ + GEOMBase_Skeleton::DeactivateActiveDialog(); } @@ -382,10 +335,8 @@ void PrimitiveGUI_ConeDlg::ActivateThisDialog() //================================================================================= void PrimitiveGUI_ConeDlg::enterEvent(QEvent* e) { - if (GroupConstructors->isEnabled()) - return; - this->ActivateThisDialog(); - return; + if ( !GroupConstructors->isEnabled() ) + ActivateThisDialog(); } @@ -393,58 +344,121 @@ void PrimitiveGUI_ConeDlg::enterEvent(QEvent* e) // function : ValueChangedInSpinBox() // purpose : //================================================================================= -void PrimitiveGUI_ConeDlg::ValueChangedInSpinBox(double newValue) +void PrimitiveGUI_ConeDlg::ValueChangedInSpinBox() { - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); - QObject* send = (QObject*)sender(); - - if(send == GroupPoints->SpinBox_DX || send == GroupDimensions->SpinBox_DX) { - myRadius1 = newValue; - myOkRadius1 = true; - } - else if(send == GroupPoints->SpinBox_DY || send == GroupDimensions->SpinBox_DY) { - myRadius2 = newValue; - myOkRadius2 = true; - } - else if(send == GroupPoints->SpinBox_DZ || send == GroupDimensions->SpinBox_DZ) { - myHeight = newValue; - myOkHeight = true; - } + displayPreview(); +} + - if (myOkPoint1 && myOkDir && myOkRadius1 && myOkRadius2 && myOkHeight) - MakeConeSimulationAndDisplay(); - return; +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr PrimitiveGUI_ConeDlg::createOperation() +{ + return getGeomEngine()->GetI3DPrimOperations( getStudyId() ); } +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool PrimitiveGUI_ConeDlg::isValid( QString& msg ) +{ + return getConstructorId() == 0 ? !(myPoint->_is_nil() || myDir->_is_nil()) : true; +} //================================================================================= -// function : MakeConeSimulationAndDisplay() +// function : execute // purpose : //================================================================================= -void PrimitiveGUI_ConeDlg::MakeConeSimulationAndDisplay() +bool PrimitiveGUI_ConeDlg::execute( ObjectList& objects ) { - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); - gp_Dir aDir = myDir; + bool res = false; - try { - /* allows user to reverse direction of construction with a negative height */ - if(this->myHeight < -Precision::Confusion()) - aDir.Reverse(); - - gp_Ax2 anAxis(this->myPoint1, aDir); - - if(fabs(myRadius1 - myRadius2) <= Precision::Confusion()) - mySimulationTopoDs = BRepPrimAPI_MakeCylinder(anAxis, (myRadius1+myRadius2)/2.0, fabs(myHeight)).Shape(); - else { - if(fabs(myHeight) > Precision::Confusion()) - mySimulationTopoDs = BRepPrimAPI_MakeCone(anAxis, myRadius1, myRadius2, fabs(myHeight)).Shape(); + GEOM::GEOM_Object_var anObj; + + switch ( getConstructorId() ) + { + case 0 : + { + if ( !CORBA::is_nil( myPoint ) && !CORBA::is_nil( myDir ) ){ + anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeConePntVecR1R2H( myPoint, + myDir, + getRadius1(), + getRadius2(), + getHeight()); + res = true; } - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); + break; } - catch(Standard_Failure) { - MESSAGE("Exception catched in MakeConeSimulationAndDisplay"); + case 1 : + { + anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeConeR1R2H( getRadius1(), + getRadius2(), + getHeight()); + res = true; + break; + } } - return; + + if ( !anObj->_is_nil() ) + objects.push_back( anObj._retn() ); + + return res; +} + +//================================================================================= +// function : closeEvent +// purpose : +//================================================================================= +void PrimitiveGUI_ConeDlg::closeEvent( QCloseEvent* e ) +{ + myGeomGUI->SetState( -1 ); + GEOMBase_Skeleton::closeEvent( e ); +} + + +//================================================================================= +// function : getRadius1() +// purpose : +//================================================================================= +double PrimitiveGUI_ConeDlg::getRadius1() const +{ + int aConstructorId = getConstructorId(); + if (aConstructorId == 0) + return GroupPoints->SpinBox_DX->GetValue(); + else if (aConstructorId == 1) + return GroupDimensions->SpinBox_DX->GetValue(); + return 0; +} + + +//================================================================================= +// function : getRadius2() +// purpose : +//================================================================================= +double PrimitiveGUI_ConeDlg::getRadius2() const +{ + int aConstructorId = getConstructorId(); + if (aConstructorId == 0) + return GroupPoints->SpinBox_DY->GetValue(); + else if (aConstructorId == 1) + return GroupDimensions->SpinBox_DY->GetValue(); + return 0; +} + + +//================================================================================= +// function : getRadius2() +// purpose : +//================================================================================= +double PrimitiveGUI_ConeDlg::getHeight() const +{ + int aConstructorId = getConstructorId(); + if (aConstructorId == 0) + return GroupPoints->SpinBox_DZ->GetValue(); + else if (aConstructorId == 1) + return GroupDimensions->SpinBox_DZ->GetValue(); + return 0; } diff --git a/src/PrimitiveGUI/PrimitiveGUI_ConeDlg.h b/src/PrimitiveGUI/PrimitiveGUI_ConeDlg.h index 20ea84f88..4cd7f5b88 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_ConeDlg.h +++ b/src/PrimitiveGUI/PrimitiveGUI_ConeDlg.h @@ -33,14 +33,6 @@ #include "DlgRef_2Sel3Spin.h" #include "DlgRef_3Spin.h" -#include "PrimitiveGUI.h" - -#include "GEOM_EdgeFilter.hxx" -#include "GEOM_ShapeTypeFilter.hxx" - -#include -#include - //================================================================================= // class : PrimitiveGUI_ConeDlg // purpose : @@ -50,45 +42,40 @@ class PrimitiveGUI_ConeDlg : public GEOMBase_Skeleton Q_OBJECT public: - PrimitiveGUI_ConeDlg(QWidget* parent = 0, const char* name = 0, PrimitiveGUI* thePrimitiveGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + PrimitiveGUI_ConeDlg(QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); ~PrimitiveGUI_ConeDlg(); +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& ); + virtual bool execute( ObjectList& objects ); + + virtual void closeEvent( QCloseEvent* e ); + private: void Init(); void enterEvent(QEvent* e); - void MakeConeSimulationAndDisplay(); - - PrimitiveGUI* myPrimitiveGUI; - - double step; - int myConstructorId; - Handle(GEOM_ShapeTypeFilter) myVertexFilter; - Handle(GEOM_EdgeFilter) myEdgeFilter; /* Filter selection */ - - gp_Pnt myPoint1; /* topology used */ - gp_Dir myDir; - bool myOkPoint1; /* to check when arguments is defined */ - bool myOkDir; - - Standard_Real myRadius1; - Standard_Real myRadius2; - Standard_Real myHeight; - bool myOkRadius1; - bool myOkRadius2; - bool myOkHeight; - + double getRadius1() const; + double getRadius2() const; + double getHeight() const; + + GEOM::GEOM_Object_var myPoint, myDir; + DlgRef_2Sel3Spin* GroupPoints; DlgRef_3Spin* GroupDimensions; private slots: void ClickOnOk(); - void ClickOnApply(); + bool ClickOnApply(); + void ClickOnCancel(); void ActivateThisDialog(); + void DeactivateActiveDialog(); void LineEditReturnPressed(); void SelectionIntoArgument(); void SetEditCurrentArgument(); - void ConstructorsClicked(int constructorId); - void ValueChangedInSpinBox(double newValue); + void ConstructorsClicked(int); + void ValueChangedInSpinBox(); }; diff --git a/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.cxx b/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.cxx index d12e8dc42..4da544407 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.cxx +++ b/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.cxx @@ -28,11 +28,10 @@ #include "PrimitiveGUI_CylinderDlg.h" -#include -#include -#include -#include #include "QAD_Config.h" +#include "QAD_Desktop.h" + +#include "GEOMImpl_Types.hxx" #include "utilities.h" @@ -45,7 +44,7 @@ using namespace std; // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -PrimitiveGUI_CylinderDlg::PrimitiveGUI_CylinderDlg(QWidget* parent, const char* name, PrimitiveGUI* thePrimitiveGUI, SALOME_Selection* Sel, bool modal, WFlags fl) +PrimitiveGUI_CylinderDlg::PrimitiveGUI_CylinderDlg(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_CYLINDER_PV"))); @@ -74,12 +73,10 @@ PrimitiveGUI_CylinderDlg::PrimitiveGUI_CylinderDlg(QWidget* parent, const char* GroupDimensions->TextLabel1->setText(tr("GEOM_RADIUS")); GroupDimensions->TextLabel2->setText(tr("GEOM_HEIGHT")); - Layout1->addWidget(GroupPoints, 1, 0); - Layout1->addWidget(GroupDimensions, 1, 0); + Layout1->addWidget(GroupPoints, 2, 0); + Layout1->addWidget(GroupDimensions, 2, 0); /***************************************************************/ - /* Initialisations */ - myPrimitiveGUI = thePrimitiveGUI; Init(); } @@ -101,21 +98,15 @@ PrimitiveGUI_CylinderDlg::~PrimitiveGUI_CylinderDlg() void PrimitiveGUI_CylinderDlg::Init() { /* init variables */ - myConstructorId = 0; myEditCurrentArgument = GroupPoints->LineEdit1; + GroupPoints->LineEdit1->setReadOnly( true ); + GroupPoints->LineEdit2->setReadOnly( true ); - myRadius = 100.0; - myHeight = 300.0; - myOkRadius = myOkHeight = true; - myOkPoint1 = myOkDir = false; - - myEdgeFilter = new GEOM_EdgeFilter(StdSelect_Line, myGeom); - myVertexFilter = new GEOM_ShapeTypeFilter(TopAbs_VERTEX, myGeom); - mySelection->AddFilter(myVertexFilter); - + myPoint = myDir = GEOM::GEOM_Object::_nil(); + /* Get setting of step value from file configuration */ QString St = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep"); - step = St.toDouble(); + double step = St.toDouble(); /* min, max, step and decimals for spin boxes & initial values */ /* First constructor : radius */ @@ -127,10 +118,10 @@ void PrimitiveGUI_CylinderDlg::Init() /* Second constructor : algebric height */ GroupDimensions->SpinBox_DY->RangeStepAndValidator(-999.999, 999.999, step, 3); - GroupPoints->SpinBox_DX->SetValue(myRadius); - GroupPoints->SpinBox_DY->SetValue(myHeight); - GroupDimensions->SpinBox_DX->SetValue(myRadius); - GroupDimensions->SpinBox_DY->SetValue(myHeight); + GroupPoints->SpinBox_DX->SetValue(100.0); + GroupPoints->SpinBox_DY->SetValue(300.0); + GroupDimensions->SpinBox_DX->SetValue(100.0); + GroupDimensions->SpinBox_DY->SetValue(300.0); /* signals and slots connections */ connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); @@ -143,10 +134,10 @@ void PrimitiveGUI_CylinderDlg::Init() connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(GroupPoints->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(GroupDimensions->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(GroupDimensions->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); + connect(GroupPoints->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); + connect(GroupDimensions->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); + connect(GroupDimensions->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox_DX, SLOT(SetStep(double))); connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox_DY, SLOT(SetStep(double))); @@ -154,13 +145,9 @@ void PrimitiveGUI_CylinderDlg::Init() connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupDimensions->SpinBox_DY, SLOT(SetStep(double))); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ; - - /* displays Dialog */ - GroupDimensions->hide(); - GroupPoints->show(); - this->show(); - - return ; + + initName( tr( "GEOM_CYLINDER" ) ); + ConstructorsClicked(0); } @@ -170,32 +157,23 @@ void PrimitiveGUI_CylinderDlg::Init() //================================================================================= void PrimitiveGUI_CylinderDlg::ConstructorsClicked(int constructorId) { - myConstructorId = constructorId; - mySelection->ClearFilters(); - myGeomBase->EraseSimulationShape(); disconnect(mySelection, 0, this, 0); - myOkHeight = myOkRadius = true; - myRadius = 100.0; - myHeight = 300.0; - - switch(myConstructorId) + + switch(constructorId) { case 0 : { + globalSelection( GEOM_POINT ); + GroupDimensions->hide(); resize(0, 0); GroupPoints->show(); - myOkPoint1 = myOkDir = false; - + myEditCurrentArgument = GroupPoints->LineEdit1; GroupPoints->LineEdit1->setText(tr("")); GroupPoints->LineEdit2->setText(tr("")); - - GroupPoints->SpinBox_DX->SetValue(myRadius); - GroupPoints->SpinBox_DY->SetValue(myHeight); + myPoint = myDir = GEOM::GEOM_Object::_nil(); - /* filter for next selection */ - mySelection->AddFilter(myVertexFilter); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); break; } @@ -204,18 +182,11 @@ void PrimitiveGUI_CylinderDlg::ConstructorsClicked(int constructorId) GroupPoints->hide(); resize( 0, 0 ); GroupDimensions->show(); - myOkPoint1 = myOkDir = true; - - GroupDimensions->SpinBox_DX->SetValue(myRadius); - GroupDimensions->SpinBox_DY->SetValue(myHeight); - myPoint1.SetCoord(0.0, 0.0, 0.0); - myDir.SetCoord(0.0, 0.0, 1.0); - - MakeCylinderSimulationAndDisplay(); + break; } } - return ; + displayPreview(); } @@ -225,9 +196,8 @@ void PrimitiveGUI_CylinderDlg::ConstructorsClicked(int constructorId) //================================================================================= void PrimitiveGUI_CylinderDlg::ClickOnOk() { - this->ClickOnApply(); - ClickOnCancel(); - return; + if ( ClickOnApply() ) + ClickOnCancel(); } @@ -235,23 +205,24 @@ void PrimitiveGUI_CylinderDlg::ClickOnOk() // function : ClickOnApply() // purpose : //================================================================================= -void PrimitiveGUI_CylinderDlg::ClickOnApply() +bool PrimitiveGUI_CylinderDlg::ClickOnApply() { - buttonApply->setFocus(); - QAD_Application::getDesktop()->putInfo(tr("")); - if (mySimulationTopoDs.IsNull()) - return; - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); - - if(myOkPoint1 && myOkDir && myOkRadius && myOkHeight) { - gp_Dir aDir = myDir; - /* allows user to reverse direction of construction with a negative height */ - if(this->myHeight < -Precision::Confusion()) - aDir.Reverse(); - myPrimitiveGUI->MakeCylinderAndDisplay(myPoint1, aDir, myRadius, fabs(myHeight)); - } - return; + if ( !onAccept() ) + return false; + + initName(); + ConstructorsClicked( getConstructorId() ); + return true; +} + + +//======================================================================= +// function : ClickOnCancel() +// purpose : +//======================================================================= +void PrimitiveGUI_CylinderDlg::ClickOnCancel() +{ + GEOMBase_Skeleton::ClickOnCancel(); } @@ -261,39 +232,35 @@ void PrimitiveGUI_CylinderDlg::ClickOnApply() //================================================================================= void PrimitiveGUI_CylinderDlg::SelectionIntoArgument() { - myGeomBase->EraseSimulationShape(); - myEditCurrentArgument->setText(""); - QString aString = ""; /* name of selection */ - - int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString); - if(nbSel != 1) { - if(myEditCurrentArgument == GroupPoints->LineEdit1) - myOkPoint1 = false; - else if (myEditCurrentArgument == GroupPoints->LineEdit2) - myOkDir = false; + if ( getConstructorId() != 0 ) return; - } + myEditCurrentArgument->setText(""); + + if(mySelection->IObjectCount() != 1) + { + if(myEditCurrentArgument == GroupPoints->LineEdit1) + myPoint = GEOM::GEOM_Object::_nil(); + else if (myEditCurrentArgument == GroupPoints->LineEdit2) + myDir = GEOM::GEOM_Object::_nil(); + return; + } + /* nbSel == 1 */ - TopoDS_Shape S; - if(!myGeomBase->GetTopoFromSelection(mySelection, S)) + Standard_Boolean testResult = Standard_False; + GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( mySelection->firstIObject(), testResult ); + + if(!testResult || CORBA::is_nil( aSelectedObject )) return; - - /* gp_Pnt : not used */ - if (myEditCurrentArgument == GroupPoints->LineEdit1 && myGeomBase->VertexToPoint(S, myPoint1)) { - GroupPoints->LineEdit1->setText(aString); - myOkPoint1 = true; - } - else if (myEditCurrentArgument == GroupPoints->LineEdit2) { - BRepAdaptor_Curve curv(TopoDS::Edge(S)); - myDir = curv.Line().Direction(); - GroupPoints->LineEdit2->setText(aString); - myOkDir = true; - } - if(myOkPoint1 && myOkDir && myOkRadius && myOkHeight) - MakeCylinderSimulationAndDisplay(); - return; + if (myEditCurrentArgument == GroupPoints->LineEdit1) + myPoint = aSelectedObject; + else if (myEditCurrentArgument == GroupPoints->LineEdit2) + myDir = aSelectedObject; + + myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) ); + + displayPreview(); } @@ -303,25 +270,19 @@ void PrimitiveGUI_CylinderDlg::SelectionIntoArgument() //================================================================================= void PrimitiveGUI_CylinderDlg::SetEditCurrentArgument() { - if(myConstructorId != 0) - return; - QPushButton* send = (QPushButton*)sender(); - mySelection->ClearFilters(); - + if(send == GroupPoints->PushButton1) { - GroupPoints->LineEdit1->setFocus(); myEditCurrentArgument = GroupPoints->LineEdit1; - mySelection->AddFilter(myVertexFilter); + globalSelection( GEOM_POINT ); } else if(send == GroupPoints->PushButton2) { - GroupPoints->LineEdit2->setFocus(); myEditCurrentArgument = GroupPoints->LineEdit2; - mySelection->AddFilter(myEdgeFilter); + globalSelection( GEOM_LINE ); } - this->SelectionIntoArgument(); - - return; + + myEditCurrentArgument->setFocus(); + SelectionIntoArgument(); } @@ -332,15 +293,12 @@ void PrimitiveGUI_CylinderDlg::SetEditCurrentArgument() void PrimitiveGUI_CylinderDlg::LineEditReturnPressed() { QLineEdit* send = (QLineEdit*)sender(); - if(send == GroupPoints->LineEdit1) - myEditCurrentArgument = GroupPoints->LineEdit1; - else if (send == GroupPoints->LineEdit2) - myEditCurrentArgument = GroupPoints->LineEdit2; - else - return; - - GEOMBase_Skeleton::LineEditReturnPressed(); - return; + if(send == GroupPoints->LineEdit1 || + send == GroupPoints->LineEdit2) + { + myEditCurrentArgument = send; + GEOMBase_Skeleton::LineEditReturnPressed(); + } } @@ -352,14 +310,8 @@ void PrimitiveGUI_CylinderDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - if(myConstructorId == 0) { - GroupPoints->LineEdit1->setFocus(); - myEditCurrentArgument = GroupPoints->LineEdit1; - mySelection->AddFilter(myVertexFilter); - } - if(!mySimulationTopoDs.IsNull()) - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - return; + + ConstructorsClicked( getConstructorId() ); } @@ -369,10 +321,18 @@ void PrimitiveGUI_CylinderDlg::ActivateThisDialog() //================================================================================= void PrimitiveGUI_CylinderDlg::enterEvent(QEvent* e) { - if (GroupConstructors->isEnabled()) - return; - this->ActivateThisDialog(); - return; + if ( !GroupConstructors->isEnabled() ) + ActivateThisDialog(); +} + + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : public slot to deactivate if active +//================================================================================= +void PrimitiveGUI_CylinderDlg::DeactivateActiveDialog() +{ + GEOMBase_Skeleton::DeactivateActiveDialog(); } @@ -380,50 +340,101 @@ void PrimitiveGUI_CylinderDlg::enterEvent(QEvent* e) // function : ValueChangedInSpinBox // purpose : //================================================================================= -void PrimitiveGUI_CylinderDlg::ValueChangedInSpinBox( double newValue ) +void PrimitiveGUI_CylinderDlg::ValueChangedInSpinBox( ) { - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); - QObject* send = (QObject*)sender(); - - /* radius */ - if(send == GroupPoints->SpinBox_DX || send == GroupDimensions->SpinBox_DX) { - myRadius = newValue; - myOkRadius = true; - } /* algebric height */ - else if(send == GroupPoints->SpinBox_DY || send == GroupDimensions->SpinBox_DY) { - myHeight = newValue; - myOkHeight = true; - } + displayPreview(); +} + - if (myOkPoint1 && myOkDir && myOkRadius && myOkHeight) - MakeCylinderSimulationAndDisplay(); - return; +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr PrimitiveGUI_CylinderDlg::createOperation() +{ + return getGeomEngine()->GetI3DPrimOperations( getStudyId() ); } //================================================================================= -// function : MakeCylinderSimulationAndDisplay() +// function : isValid // purpose : //================================================================================= -void PrimitiveGUI_CylinderDlg::MakeCylinderSimulationAndDisplay() +bool PrimitiveGUI_CylinderDlg::isValid( QString& msg ) { - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); - gp_Dir aDir = this->myDir; + return getConstructorId() == 0 ? !(myPoint->_is_nil() || myDir->_is_nil() ) : true; +} + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool PrimitiveGUI_CylinderDlg::execute( ObjectList& objects ) +{ + bool res = false; + + GEOM::GEOM_Object_var anObj; + + switch ( getConstructorId() ) + { + case 0 : + { + if ( !CORBA::is_nil( myPoint ) && !CORBA::is_nil( myDir )) { + anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeCylinderPntVecRH(myPoint, myDir, getRadius(), getHeight()); + res = true; + } + break; + } + case 1 : + { + anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeCylinderRH(getRadius(), getHeight()); + res = true; + + break; + } + } - try { - /* allows user to reverse direction of construction with a negative height */ - if(this->myHeight < -Precision::Confusion()) - aDir.Reverse(); + if ( !anObj->_is_nil() ) + objects.push_back( anObj._retn() ); + + return res; +} - gp_Ax2 anAxis(this->myPoint1, aDir); +//================================================================================= +// function : closeEvent +// purpose : +//================================================================================= +void PrimitiveGUI_CylinderDlg::closeEvent( QCloseEvent* e ) +{ + GEOMBase_Skeleton::closeEvent( e ); +} - mySimulationTopoDs = BRepPrimAPI_MakeCylinder(anAxis, this->myRadius, fabs(myHeight)).Shape(); - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - } - catch(Standard_Failure) { - MESSAGE("Exception catched in MakeCylinderSimulationAndDisplay"); - } - return; + +//================================================================================= +// function : getRadius() +// purpose : +//================================================================================= +double PrimitiveGUI_CylinderDlg::getRadius() const +{ + int aConstructorId = getConstructorId(); + if (aConstructorId == 0) + return GroupPoints->SpinBox_DX->GetValue(); + else if (aConstructorId == 1) + return GroupDimensions->SpinBox_DX->GetValue(); + return 0; +} + + +//================================================================================= +// function : getHeight() +// purpose : +//================================================================================= +double PrimitiveGUI_CylinderDlg::getHeight() const +{ + int aConstructorId = getConstructorId(); + if (aConstructorId == 0) + return GroupPoints->SpinBox_DY->GetValue(); + else if (aConstructorId == 1) + return GroupDimensions->SpinBox_DY->GetValue(); + return 0; } diff --git a/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.h b/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.h index 47cc31526..6a182ef13 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.h +++ b/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.h @@ -33,13 +33,6 @@ #include "DlgRef_2Sel2Spin.h" #include "DlgRef_2Spin.h" -#include "PrimitiveGUI.h" - -#include "GEOM_EdgeFilter.hxx" -#include "GEOM_ShapeTypeFilter.hxx" - -#include -#include //================================================================================= // class : PrimitiveGUI_CylinderDlg @@ -50,44 +43,39 @@ class PrimitiveGUI_CylinderDlg : public GEOMBase_Skeleton Q_OBJECT public: - PrimitiveGUI_CylinderDlg(QWidget* parent = 0, const char* name = 0, PrimitiveGUI* thePrimitiveGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + PrimitiveGUI_CylinderDlg(QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); ~PrimitiveGUI_CylinderDlg(); +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& ); + virtual bool execute( ObjectList& objects ); + + virtual void closeEvent( QCloseEvent* e ); + private: void Init(); void enterEvent(QEvent* e); - void MakeCylinderSimulationAndDisplay(); - - PrimitiveGUI* myPrimitiveGUI; - - double step; - int myConstructorId; - Handle(GEOM_ShapeTypeFilter) myVertexFilter; - Handle(GEOM_EdgeFilter) myEdgeFilter; /* Filter selection */ - - gp_Pnt myPoint1; /* topology used */ - gp_Dir myDir; - bool myOkPoint1; /* to check when arguments is defined */ - bool myOkDir; - - Standard_Real myRadius; - Standard_Real myHeight; - bool myOkRadius; - bool myOkHeight; - + double getRadius() const; + double getHeight() const; + + GEOM::GEOM_Object_var myPoint, myDir; + DlgRef_2Sel2Spin* GroupPoints; DlgRef_2Spin* GroupDimensions; private slots: void ClickOnOk(); - void ClickOnApply(); + bool ClickOnApply(); + void ClickOnCancel(); void ActivateThisDialog(); + void DeactivateActiveDialog(); void LineEditReturnPressed(); void SelectionIntoArgument(); void SetEditCurrentArgument(); - void ConstructorsClicked(int constructorId); - void ValueChangedInSpinBox(double newValue); - + void ConstructorsClicked(int); + void ValueChangedInSpinBox(); }; #endif // DIALOGBOX_CYLINDER_H diff --git a/src/PrimitiveGUI/PrimitiveGUI_SphereDlg.cxx b/src/PrimitiveGUI/PrimitiveGUI_SphereDlg.cxx index d13352dc2..f1dbaf002 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_SphereDlg.cxx +++ b/src/PrimitiveGUI/PrimitiveGUI_SphereDlg.cxx @@ -29,8 +29,14 @@ using namespace std; #include "PrimitiveGUI_SphereDlg.h" -#include #include "QAD_Config.h" +#include "QAD_Desktop.h" + +#include "GEOMImpl_Types.hxx" + +#include "utilities.h" + +using namespace std; //================================================================================= // class : PrimitiveGUI_SphereDlg() @@ -39,7 +45,7 @@ using namespace std; // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -PrimitiveGUI_SphereDlg::PrimitiveGUI_SphereDlg(QWidget* parent, const char* name, PrimitiveGUI* thePrimitiveGUI, SALOME_Selection* Sel, bool modal, WFlags fl) +PrimitiveGUI_SphereDlg::PrimitiveGUI_SphereDlg(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_SPHERE_P"))); @@ -64,12 +70,10 @@ PrimitiveGUI_SphereDlg::PrimitiveGUI_SphereDlg(QWidget* parent, const char* nam GroupDimensions->GroupBox1->setTitle(tr("GEOM_SPHERE_RO")); GroupDimensions->TextLabel1->setText(tr("GEOM_RADIUS")); - Layout1->addWidget(GroupPoints, 1, 0); - Layout1->addWidget(GroupDimensions, 1, 0); + Layout1->addWidget(GroupPoints, 2, 0); + Layout1->addWidget(GroupDimensions, 2, 0); /***************************************************************/ - /* Initialisations */ - myPrimitiveGUI = thePrimitiveGUI; Init(); } @@ -91,26 +95,20 @@ PrimitiveGUI_SphereDlg::~PrimitiveGUI_SphereDlg() void PrimitiveGUI_SphereDlg::Init() { /* init variables */ - myConstructorId = 0; myEditCurrentArgument = GroupPoints->LineEdit1; - - myPoint1.SetCoord(0.0, 0.0, 0.0); - myRadius = 100.0; - myOkPoint1 = false; - - /* Vertices Filter for all arguments */ - myVertexFilter = new GEOM_ShapeTypeFilter(TopAbs_VERTEX, myGeom); - mySelection->AddFilter(myVertexFilter); - + GroupPoints->LineEdit1->setReadOnly( true ); + + myPoint = GEOM::GEOM_Object::_nil(); + /* Get setting of step value from file configuration */ QString St = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep"); - step = St.toDouble(); + double step = St.toDouble(); /* min, max, step and decimals for spin boxes */ GroupPoints->SpinBox_DX->RangeStepAndValidator(0.001, 999.999, step, 3); GroupDimensions->SpinBox_DX->RangeStepAndValidator(0.001, 999.999, step, 3); - GroupPoints->SpinBox_DX->SetValue(myRadius); - GroupDimensions->SpinBox_DX->SetValue(myRadius); + GroupPoints->SpinBox_DX->SetValue(100.0); + GroupDimensions->SpinBox_DX->SetValue(100.0); /* signals and slots connections */ connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); @@ -120,20 +118,16 @@ void PrimitiveGUI_SphereDlg::Init() connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupDimensions->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupDimensions->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); + connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox_DX, SLOT(SetStep(double))); connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupDimensions->SpinBox_DX, SLOT(SetStep(double))); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - /* displays Dialog */ - GroupDimensions->hide(); - GroupPoints->show(); - this->show(); - - return; + initName(tr("GEOM_SPHERE")); + ConstructorsClicked(0); } @@ -143,28 +137,21 @@ void PrimitiveGUI_SphereDlg::Init() //================================================================================= void PrimitiveGUI_SphereDlg::ConstructorsClicked(int constructorId) { - myConstructorId = constructorId; - mySelection->ClearFilters(); - myGeomBase->EraseSimulationShape(); disconnect(mySelection, 0, this, 0); - myRadius = 100.0; - + switch (constructorId) { case 0: { + globalSelection( GEOM_POINT ); GroupDimensions->hide(); resize(0, 0); GroupPoints->show(); myEditCurrentArgument = GroupPoints->LineEdit1; GroupPoints->LineEdit1->setText(""); + myPoint = GEOM::GEOM_Object::_nil(); - GroupPoints->SpinBox_DX->SetValue(myRadius); - myOkPoint1 = false; - - /* filter for next selections */ - mySelection->AddFilter(myVertexFilter); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); break; } @@ -173,17 +160,11 @@ void PrimitiveGUI_SphereDlg::ConstructorsClicked(int constructorId) GroupPoints->hide(); resize(0, 0); GroupDimensions->show(); - - GroupDimensions->SpinBox_DX->SetValue(myRadius); - myPoint1.SetCoord(0.0, 0.0, 0.0); /* at origin */ - myOkPoint1 = true; - - mySimulationTopoDs = BRepPrimAPI_MakeSphere(myPoint1, myRadius).Shape(); - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); + break; } } - return ; + displayPreview(); } @@ -193,9 +174,8 @@ void PrimitiveGUI_SphereDlg::ConstructorsClicked(int constructorId) //================================================================================= void PrimitiveGUI_SphereDlg::ClickOnOk() { - this->ClickOnApply(); - ClickOnCancel(); - return; + if ( ClickOnApply() ) + ClickOnCancel(); } @@ -203,18 +183,25 @@ void PrimitiveGUI_SphereDlg::ClickOnOk() // function : ClickOnApply() // purpose : //================================================================================= -void PrimitiveGUI_SphereDlg::ClickOnApply() +bool PrimitiveGUI_SphereDlg::ClickOnApply() { - buttonApply->setFocus(); - QAD_Application::getDesktop()->putInfo(tr("")); - if(mySimulationTopoDs.IsNull()) - return; - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); + if ( !onAccept() ) + return false; + + initName(); + ConstructorsClicked( getConstructorId() ); + return true; +} - if(myOkPoint1) - myPrimitiveGUI->MakeSphereAndDisplay(myPoint1, myRadius); - return; + + +//======================================================================= +// function : ClickOnCancel() +// purpose : +//======================================================================= +void PrimitiveGUI_SphereDlg::ClickOnCancel() +{ + GEOMBase_Skeleton::ClickOnCancel(); } @@ -224,35 +211,28 @@ void PrimitiveGUI_SphereDlg::ClickOnApply() //================================================================================= void PrimitiveGUI_SphereDlg::SelectionIntoArgument() { - myGeomBase->EraseSimulationShape(); + if ( getConstructorId() != 0 ) + return; + myEditCurrentArgument->setText(""); - QString aString = ""; /* name of selection */ - - int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString); - if(nbSel != 1) { - if(myEditCurrentArgument == GroupPoints->LineEdit1) { - GroupPoints->LineEdit1->setText(""); - myOkPoint1 = false; + + if(mySelection->IObjectCount() != 1) + { + myPoint = GEOM::GEOM_Object::_nil(); + return; } - return; - } /* nbSel == 1 ! */ - TopoDS_Shape S; - if(!myGeomBase->GetTopoFromSelection(mySelection, S)) + Standard_Boolean testResult = Standard_False; + GEOM::GEOM_Object_ptr aSelectedObject = GEOMBase::ConvertIOinGEOMObject( mySelection->firstIObject(), testResult ); + + if (!testResult || CORBA::is_nil( aSelectedObject )) return; - /* Constructor 1 treatment */ - if(myEditCurrentArgument == GroupPoints->LineEdit1 && myGeomBase->VertexToPoint(S, myPoint1)) { - GroupPoints->LineEdit1->setText(aString); - myOkPoint1 = true; - } + myPoint = aSelectedObject; + myEditCurrentArgument->setText( GEOMBase::GetName( myPoint ) ); - if(myOkPoint1) { - mySimulationTopoDs = BRepPrimAPI_MakeSphere(myPoint1, myRadius).Shape(); - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - } - return ; + displayPreview(); } @@ -264,12 +244,10 @@ void PrimitiveGUI_SphereDlg::LineEditReturnPressed() { QLineEdit* send = (QLineEdit*)sender(); if(send == GroupPoints->LineEdit1) - myEditCurrentArgument = GroupPoints->LineEdit1; - else - return; - - GEOMBase_Skeleton::LineEditReturnPressed(); - return; + { + myEditCurrentArgument = send; + GEOMBase_Skeleton::LineEditReturnPressed(); + } } @@ -279,18 +257,14 @@ void PrimitiveGUI_SphereDlg::LineEditReturnPressed() //================================================================================= void PrimitiveGUI_SphereDlg::SetEditCurrentArgument() { - if(myConstructorId != 0) - return; - QPushButton* send = (QPushButton*)sender(); - + if(send == GroupPoints->PushButton1) { GroupPoints->LineEdit1->setFocus(); myEditCurrentArgument = GroupPoints->LineEdit1; - mySelection->AddFilter(myVertexFilter); - this->SelectionIntoArgument(); + globalSelection( GEOM_POINT ); + SelectionIntoArgument(); } - return; } @@ -302,11 +276,18 @@ void PrimitiveGUI_SphereDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - if(myConstructorId == 0) - mySelection->AddFilter(myVertexFilter); - if(!mySimulationTopoDs.IsNull()) - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - return; + + ConstructorsClicked( getConstructorId() ); +} + + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : public slot to deactivate if active +//================================================================================= +void PrimitiveGUI_SphereDlg::DeactivateActiveDialog() +{ + GEOMBase_Skeleton::DeactivateActiveDialog(); } @@ -316,10 +297,8 @@ void PrimitiveGUI_SphereDlg::ActivateThisDialog() //================================================================================= void PrimitiveGUI_SphereDlg::enterEvent(QEvent* e) { - if(GroupConstructors->isEnabled()) - return; - this->ActivateThisDialog(); - return; + if ( !GroupConstructors->isEnabled() ) + ActivateThisDialog(); } @@ -327,15 +306,87 @@ void PrimitiveGUI_SphereDlg::enterEvent(QEvent* e) // function : ValueChangedInSpinBox() // purpose : //================================================================================= -void PrimitiveGUI_SphereDlg::ValueChangedInSpinBox(double newValue) +void PrimitiveGUI_SphereDlg::ValueChangedInSpinBox() +{ + displayPreview(); +} + + +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr PrimitiveGUI_SphereDlg::createOperation() +{ + return getGeomEngine()->GetI3DPrimOperations( getStudyId() ); +} + + +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool PrimitiveGUI_SphereDlg::isValid( QString& msg ) +{ + return getConstructorId() == 0 ? !myPoint->_is_nil() : true; +} + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool PrimitiveGUI_SphereDlg::execute( ObjectList& objects ) { - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); - myRadius = newValue; + bool res = false; - if(myOkPoint1) { - mySimulationTopoDs = BRepPrimAPI_MakeSphere(myPoint1, myRadius).Shape(); - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); + GEOM::GEOM_Object_var anObj; + + switch ( getConstructorId() ) + { + case 0 : + { + if ( !CORBA::is_nil( myPoint ) ) { + anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeSpherePntR( myPoint, getRadius() ); + res = true; + } + break; + } + case 1 : + { + anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeSphereR( getRadius() ); + res = true; + break; + } } - return; + + if ( !anObj->_is_nil() ) + objects.push_back( anObj._retn() ); + + return res; +} + +//================================================================================= +// function : closeEvent +// purpose : +//================================================================================= +void PrimitiveGUI_SphereDlg::closeEvent( QCloseEvent* e ) +{ + myGeomGUI->SetState( -1 ); + GEOMBase_Skeleton::closeEvent( e ); +} + + + +//================================================================================= +// function : getRadius() +// purpose : +//================================================================================= +double PrimitiveGUI_SphereDlg::getRadius() const +{ + int aConstructorId = getConstructorId(); + if (aConstructorId == 0) + return GroupPoints->SpinBox_DX->GetValue(); + else if (aConstructorId == 1) + return GroupDimensions->SpinBox_DX->GetValue(); + return 0; } diff --git a/src/PrimitiveGUI/PrimitiveGUI_SphereDlg.h b/src/PrimitiveGUI/PrimitiveGUI_SphereDlg.h index c09fe193c..af41f7dcf 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_SphereDlg.h +++ b/src/PrimitiveGUI/PrimitiveGUI_SphereDlg.h @@ -33,10 +33,6 @@ #include "DlgRef_1Sel1Spin.h" #include "DlgRef_1Spin.h" -#include "PrimitiveGUI.h" - -#include "GEOM_ShapeTypeFilter.hxx" -#include //================================================================================= // class : PrimitiveGUI_SphereDlg @@ -47,36 +43,38 @@ class PrimitiveGUI_SphereDlg : public GEOMBase_Skeleton Q_OBJECT public: - PrimitiveGUI_SphereDlg(QWidget* parent = 0, const char* name = 0, PrimitiveGUI* thePrimitiveGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + PrimitiveGUI_SphereDlg(QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); ~PrimitiveGUI_SphereDlg(); +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& ); + virtual bool execute( ObjectList& objects ); + + virtual void closeEvent( QCloseEvent* e ); + private : void Init(); void enterEvent(QEvent* e); - - PrimitiveGUI* myPrimitiveGUI; - - double step; - int myConstructorId; - Handle(GEOM_ShapeTypeFilter) myVertexFilter; /* filter for selection */ - - gp_Pnt myPoint1; /* Points containing the vector */ - Standard_Real myRadius; - bool myOkPoint1; - + double getRadius() const; + + GEOM::GEOM_Object_var myPoint; /* Center point */ + DlgRef_1Sel1Spin* GroupPoints; DlgRef_1Spin* GroupDimensions; private slots: void ClickOnOk(); - void ClickOnApply(); + bool ClickOnApply(); + void ClickOnCancel(); void ActivateThisDialog(); + void DeactivateActiveDialog(); void LineEditReturnPressed(); void SelectionIntoArgument(); void SetEditCurrentArgument(); - void ConstructorsClicked(int constructorId); - void ValueChangedInSpinBox(double newValue); - + void ConstructorsClicked(int); + void ValueChangedInSpinBox(); }; #endif // DIALOGBOX_SPHERE_H diff --git a/src/PrimitiveGUI/PrimitiveGUI_TorusDlg.cxx b/src/PrimitiveGUI/PrimitiveGUI_TorusDlg.cxx index 90aa6db8b..3c622ef4d 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_TorusDlg.cxx +++ b/src/PrimitiveGUI/PrimitiveGUI_TorusDlg.cxx @@ -28,10 +28,10 @@ #include "PrimitiveGUI_TorusDlg.h" -#include -#include -#include #include "QAD_Config.h" +#include "QAD_Desktop.h" + +#include "GEOMImpl_Types.hxx" #include "utilities.h" @@ -44,7 +44,7 @@ using namespace std; // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -PrimitiveGUI_TorusDlg::PrimitiveGUI_TorusDlg(QWidget* parent, const char* name, PrimitiveGUI* thePrimitiveGUI, SALOME_Selection* Sel, bool modal, WFlags fl) +PrimitiveGUI_TorusDlg::PrimitiveGUI_TorusDlg(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_TORUS_PV"))); @@ -73,12 +73,10 @@ PrimitiveGUI_TorusDlg::PrimitiveGUI_TorusDlg(QWidget* parent, const char* name, GroupDimensions->TextLabel1->setText(tr("GEOM_RADIUS_I").arg("1")); GroupDimensions->TextLabel2->setText(tr("GEOM_RADIUS_I").arg("2")); - Layout1->addWidget(GroupPoints, 1, 0); - Layout1->addWidget(GroupDimensions, 1, 0); + Layout1->addWidget(GroupPoints, 2, 0); + Layout1->addWidget(GroupDimensions, 2, 0); /***************************************************************/ - - /* Initialisations */ - myPrimitiveGUI = thePrimitiveGUI; + Init(); } @@ -100,20 +98,15 @@ PrimitiveGUI_TorusDlg::~PrimitiveGUI_TorusDlg() void PrimitiveGUI_TorusDlg::Init() { /* init variables */ - myConstructorId = 0; myEditCurrentArgument = GroupPoints->LineEdit1; - - myRadius1 = 300.0; - myRadius2 = 100.0; - myOkPoint1 = myOkDir = false; - - myEdgeFilter = new GEOM_EdgeFilter(StdSelect_Line, myGeom); - myVertexFilter = new GEOM_ShapeTypeFilter(TopAbs_VERTEX, myGeom); - mySelection->AddFilter(myVertexFilter); + GroupPoints->LineEdit1->setReadOnly( true ); + GroupPoints->LineEdit2->setReadOnly( true ); + + myPoint = myDir = GEOM::GEOM_Object::_nil(); /* Get setting of step value from file configuration */ QString St = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep"); - step = St.toDouble(); + double step = St.toDouble(); /* min, max, step and decimals for spin boxes & initial values */ GroupPoints->SpinBox_DX->RangeStepAndValidator(0.001, 999.999, step, 3); @@ -121,10 +114,10 @@ void PrimitiveGUI_TorusDlg::Init() GroupDimensions->SpinBox_DX->RangeStepAndValidator(0.001, 999.999, step, 3); GroupDimensions->SpinBox_DY->RangeStepAndValidator(0.001, 999.999, step, 3); - GroupPoints->SpinBox_DX->SetValue(myRadius1); - GroupPoints->SpinBox_DY->SetValue(myRadius2); - GroupDimensions->SpinBox_DX->SetValue(myRadius1); - GroupDimensions->SpinBox_DY->SetValue(myRadius2); + GroupPoints->SpinBox_DX->SetValue(300.0); + GroupPoints->SpinBox_DY->SetValue(100.0); + GroupDimensions->SpinBox_DX->SetValue(300.0); + GroupDimensions->SpinBox_DY->SetValue(100.0); /* signals and slots connections */ connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); @@ -137,10 +130,10 @@ void PrimitiveGUI_TorusDlg::Init() connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(GroupPoints->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(GroupDimensions->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(GroupDimensions->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); + connect(GroupPoints->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); + connect(GroupDimensions->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); + connect(GroupDimensions->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox_DX, SLOT(SetStep(double))); connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox_DY, SLOT(SetStep(double))); @@ -148,13 +141,9 @@ void PrimitiveGUI_TorusDlg::Init() connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupDimensions->SpinBox_DY, SLOT(SetStep(double))); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ; - - /* displays Dialog */ - GroupDimensions->hide(); - GroupPoints->show(); - this->show(); - - return; + + initName( tr( "GEOM_TORUS" ) ); + ConstructorsClicked(0); } @@ -165,31 +154,23 @@ void PrimitiveGUI_TorusDlg::Init() //================================================================================= void PrimitiveGUI_TorusDlg::ConstructorsClicked(int constructorId) { - myConstructorId = constructorId; - mySelection->ClearFilters(); - myGeomBase->EraseSimulationShape(); disconnect(mySelection, 0, this, 0); - myRadius1 = 300.0; - myRadius2 = 100.0; - - switch(myConstructorId) + + switch(constructorId) { case 0 : { + globalSelection( GEOM_LINE ); + GroupDimensions->hide(); resize(0, 0); GroupPoints->show(); - myOkPoint1 = myOkDir = false; - + myEditCurrentArgument = GroupPoints->LineEdit1; GroupPoints->LineEdit1->setText(tr("")); GroupPoints->LineEdit2->setText(tr("")); + myPoint = myDir = GEOM::GEOM_Object::_nil(); - GroupPoints->SpinBox_DX->SetValue(myRadius1); - GroupPoints->SpinBox_DY->SetValue(myRadius2); - - /* filter for next selection */ - mySelection->AddFilter(myVertexFilter); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); break ; } @@ -198,18 +179,11 @@ void PrimitiveGUI_TorusDlg::ConstructorsClicked(int constructorId) GroupPoints->hide(); resize( 0, 0 ); GroupDimensions->show(); - myOkPoint1 = myOkDir = true; - - GroupDimensions->SpinBox_DX->SetValue(myRadius1); - GroupDimensions->SpinBox_DY->SetValue(myRadius2); - myPoint1.SetCoord(0.0, 0.0, 0.0); - myDir.SetCoord(0.0, 0.0, 1.0); - - MakeTorusSimulationAndDisplay(); + break ; } } - return ; + displayPreview(); } @@ -219,9 +193,8 @@ void PrimitiveGUI_TorusDlg::ConstructorsClicked(int constructorId) //================================================================================= void PrimitiveGUI_TorusDlg::ClickOnOk() { - this->ClickOnApply(); - ClickOnCancel(); - return; + if ( ClickOnApply() ) + ClickOnCancel(); } @@ -229,18 +202,24 @@ void PrimitiveGUI_TorusDlg::ClickOnOk() // function : ClickOnApply() // purpose : //================================================================================= -void PrimitiveGUI_TorusDlg::ClickOnApply() +bool PrimitiveGUI_TorusDlg::ClickOnApply() { - buttonApply->setFocus(); - QAD_Application::getDesktop()->putInfo(tr("")); - if (mySimulationTopoDs.IsNull()) - return; - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); + if ( !onAccept() ) + return false; - if(myOkPoint1 && myOkDir) - myPrimitiveGUI->MakeTorusAndDisplay(myPoint1, myDir, myRadius1, myRadius2); - return ; + initName(); + ConstructorsClicked( getConstructorId() ); + return true; +} + + +//======================================================================= +// function : ClickOnCancel() +// purpose : +//======================================================================= +void PrimitiveGUI_TorusDlg::ClickOnCancel() +{ + GEOMBase_Skeleton::ClickOnCancel(); } @@ -250,39 +229,35 @@ void PrimitiveGUI_TorusDlg::ClickOnApply() //================================================================================= void PrimitiveGUI_TorusDlg::SelectionIntoArgument() { - myGeomBase->EraseSimulationShape(); + if ( getConstructorId() != 0 ) + return; + myEditCurrentArgument->setText(""); - QString aString = ""; /* name of selection */ - int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString); - if(nbSel != 1) { - if(myEditCurrentArgument == GroupPoints->LineEdit1) - myOkPoint1 = false; - else if(myEditCurrentArgument == GroupPoints->LineEdit2) - myOkDir = false; - return; - } - + if(mySelection->IObjectCount() != 1) + { + if(myEditCurrentArgument == GroupPoints->LineEdit1) + myPoint = GEOM::GEOM_Object::_nil(); + else if(myEditCurrentArgument == GroupPoints->LineEdit2) + myDir = GEOM::GEOM_Object::_nil(); + return; + } + + /* nbSel == 1 */ - TopoDS_Shape S; - if(!myGeomBase->GetTopoFromSelection(mySelection, S)) - return; - - /* gp_Pnt : not used */ - if(myEditCurrentArgument == GroupPoints->LineEdit1 && myGeomBase->VertexToPoint(S, myPoint1)) { - GroupPoints->LineEdit1->setText(aString); - myOkPoint1 = true; - } - else if(myEditCurrentArgument == GroupPoints->LineEdit2) { - BRepAdaptor_Curve curv(TopoDS::Edge(S)); - myDir = curv.Line().Direction(); - GroupPoints->LineEdit2->setText(aString); - myOkDir = true; - } - - if(myOkPoint1 && myOkDir) - MakeTorusSimulationAndDisplay(); - return; + Standard_Boolean testResult = Standard_False; + GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( mySelection->firstIObject(), testResult ); + + if(!testResult || CORBA::is_nil( aSelectedObject )) + return; + + if(myEditCurrentArgument == GroupPoints->LineEdit1) + myPoint = aSelectedObject; + else if(myEditCurrentArgument == GroupPoints->LineEdit2) + myDir = aSelectedObject; + + myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) ); + displayPreview(); } @@ -292,25 +267,19 @@ void PrimitiveGUI_TorusDlg::SelectionIntoArgument() //================================================================================= void PrimitiveGUI_TorusDlg::SetEditCurrentArgument() { - if(myConstructorId != 0) - return; - QPushButton* send = (QPushButton*)sender(); - mySelection->ClearFilters(); - + if(send == GroupPoints->PushButton1) { - GroupPoints->LineEdit1->setFocus(); myEditCurrentArgument = GroupPoints->LineEdit1; - mySelection->AddFilter(myVertexFilter); + globalSelection( GEOM_POINT ); } else if(send == GroupPoints->PushButton2) { - GroupPoints->LineEdit2->setFocus(); myEditCurrentArgument = GroupPoints->LineEdit2; - mySelection->AddFilter(myEdgeFilter); + globalSelection( GEOM_LINE ); } - this->SelectionIntoArgument(); - - return; + + myEditCurrentArgument->setFocus(); + SelectionIntoArgument(); } @@ -321,15 +290,12 @@ void PrimitiveGUI_TorusDlg::SetEditCurrentArgument() void PrimitiveGUI_TorusDlg::LineEditReturnPressed() { QLineEdit* send = (QLineEdit*)sender(); - if(send == GroupPoints->LineEdit1) - myEditCurrentArgument = GroupPoints->LineEdit1; - else if (send == GroupPoints->LineEdit2) - myEditCurrentArgument = GroupPoints->LineEdit2; - else - return; - - GEOMBase_Skeleton::LineEditReturnPressed(); - return; + if(send == GroupPoints->LineEdit1 || + send == GroupPoints->LineEdit2) + { + myEditCurrentArgument = send; + GEOMBase_Skeleton::LineEditReturnPressed(); + } } @@ -341,14 +307,8 @@ void PrimitiveGUI_TorusDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - if(myConstructorId == 1) { - GroupPoints->LineEdit1->setFocus(); - myEditCurrentArgument = GroupPoints->LineEdit1; - mySelection->AddFilter(myVertexFilter); - } - if(!mySimulationTopoDs.IsNull()) - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - return; + + ConstructorsClicked( getConstructorId() ); } @@ -358,10 +318,18 @@ void PrimitiveGUI_TorusDlg::ActivateThisDialog() //================================================================================= void PrimitiveGUI_TorusDlg::enterEvent(QEvent* e) { - if (GroupConstructors->isEnabled()) - return; - this->ActivateThisDialog(); - return; + if ( !GroupConstructors->isEnabled() ) + ActivateThisDialog(); +} + + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : public slot to deactivate if active +//================================================================================= +void PrimitiveGUI_TorusDlg::DeactivateActiveDialog() +{ + GEOMBase_Skeleton::DeactivateActiveDialog(); } @@ -369,51 +337,102 @@ void PrimitiveGUI_TorusDlg::enterEvent(QEvent* e) // function : ValueChangedInSpinBox // purpose : //================================================================================= -void PrimitiveGUI_TorusDlg::ValueChangedInSpinBox(double newValue) +void PrimitiveGUI_TorusDlg::ValueChangedInSpinBox() { - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); - QObject* send = (QObject*)sender(); + displayPreview(); +} + + +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr PrimitiveGUI_TorusDlg::createOperation() +{ + return getGeomEngine()->GetI3DPrimOperations( getStudyId() ); +} + + +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool PrimitiveGUI_TorusDlg::isValid( QString& msg ) +{ + return getConstructorId() == 0 ? !(myPoint->_is_nil() || myDir->_is_nil()) : true; +} + + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool PrimitiveGUI_TorusDlg::execute( ObjectList& objects ) +{ + bool res = false; - if(send == GroupPoints->SpinBox_DX || send == GroupDimensions->SpinBox_DX) { - if(newValue > myRadius2) - myRadius1 = newValue; - else { - GroupPoints->SpinBox_DX->SetValue(myRadius1); - GroupDimensions->SpinBox_DX->SetValue(myRadius1); + GEOM::GEOM_Object_var anObj; + + switch ( getConstructorId() ) + { + case 0 : + { + if (!CORBA::is_nil( myPoint ) && !CORBA::is_nil( myDir )){ + anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeTorusPntVecRR(myPoint, myDir, getRadius1(), getRadius2()); + res = true; } + break; } - else if(send == GroupPoints->SpinBox_DY || send == GroupDimensions->SpinBox_DY) { - if(newValue < myRadius1) - myRadius2 = newValue; - else { - GroupPoints->SpinBox_DY->SetValue(myRadius2); - GroupDimensions->SpinBox_DY->SetValue(myRadius2); + case 1 : + { + anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeTorusRR(getRadius1(), getRadius2()); + res = true; + break; } } - - if(myOkPoint1 && myOkDir) - MakeTorusSimulationAndDisplay(); - return; + + if ( !anObj->_is_nil() ) + objects.push_back( anObj._retn() ); + + return res; } //================================================================================= -// function : MakeTorusSimulationAndDisplay() +// function : closeEvent // purpose : //================================================================================= -void PrimitiveGUI_TorusDlg::MakeTorusSimulationAndDisplay() +void PrimitiveGUI_TorusDlg::closeEvent( QCloseEvent* e ) { - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); + GEOMBase_Skeleton::closeEvent( e ); +} - try { - gp_Ax2 anAxis(myPoint1, myDir); - mySimulationTopoDs = BRepPrimAPI_MakeTorus(anAxis, myRadius1, myRadius2).Shape(); - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - } - catch(Standard_Failure) { - MESSAGE("Exception catched in MakeTorusSimulationAndDisplay"); - } - return; + +//================================================================================= +// function : getRadius1() +// purpose : +//================================================================================= +double PrimitiveGUI_TorusDlg::getRadius1() const +{ + int aConstructorId = getConstructorId(); + if (aConstructorId == 0) + return GroupPoints->SpinBox_DX->GetValue(); + else if (aConstructorId == 1) + return GroupDimensions->SpinBox_DX->GetValue(); + return 0; +} + + +//================================================================================= +// function : getRadius2() +// purpose : +//================================================================================= +double PrimitiveGUI_TorusDlg::getRadius2() const +{ + int aConstructorId = getConstructorId(); + if (aConstructorId == 0) + return GroupPoints->SpinBox_DY->GetValue(); + else if (aConstructorId == 1) + return GroupDimensions->SpinBox_DY->GetValue(); + return 0; } diff --git a/src/PrimitiveGUI/PrimitiveGUI_TorusDlg.h b/src/PrimitiveGUI/PrimitiveGUI_TorusDlg.h index 84068f432..b61b0e289 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_TorusDlg.h +++ b/src/PrimitiveGUI/PrimitiveGUI_TorusDlg.h @@ -33,13 +33,6 @@ #include "DlgRef_2Sel2Spin.h" #include "DlgRef_2Spin.h" -#include "PrimitiveGUI.h" - -#include "GEOM_EdgeFilter.hxx" -#include "GEOM_ShapeTypeFilter.hxx" - -#include -#include //================================================================================= // class : PrimitiveGUI_TorusDlg @@ -50,41 +43,39 @@ class PrimitiveGUI_TorusDlg : public GEOMBase_Skeleton Q_OBJECT public: - PrimitiveGUI_TorusDlg(QWidget* parent = 0, const char* name = 0, PrimitiveGUI* thePrimitiveGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + PrimitiveGUI_TorusDlg(QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); ~PrimitiveGUI_TorusDlg(); +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& ); + virtual bool execute( ObjectList& objects ); + + virtual void closeEvent( QCloseEvent* e ); + private: void Init(); void enterEvent(QEvent* e); - void MakeTorusSimulationAndDisplay(); - - PrimitiveGUI* myPrimitiveGUI; - - double step; - int myConstructorId; - Handle(GEOM_ShapeTypeFilter) myVertexFilter; - Handle(GEOM_EdgeFilter) myEdgeFilter; /* Filter selection */ - - gp_Pnt myPoint1; /* topology used */ - gp_Dir myDir; - bool myOkPoint1; /* to check when arguments is defined */ - bool myOkDir; - - Standard_Real myRadius1; - Standard_Real myRadius2; - + double getRadius1() const; + double getRadius2() const; + + GEOM::GEOM_Object_var myPoint, myDir; + DlgRef_2Sel2Spin* GroupPoints; DlgRef_2Spin* GroupDimensions; - -private slots: + + private slots: void ClickOnOk(); - void ClickOnApply(); + bool ClickOnApply(); + void ClickOnCancel(); void ActivateThisDialog(); + void DeactivateActiveDialog(); void LineEditReturnPressed(); void SelectionIntoArgument(); void SetEditCurrentArgument(); - void ConstructorsClicked(int constructorId); - void ValueChangedInSpinBox(double newValue); + void ConstructorsClicked(int); + void ValueChangedInSpinBox(); }; diff --git a/src/RepairGUI/Makefile.in b/src/RepairGUI/Makefile.in index 3b4d328f1..8bd14a9a5 100644 --- a/src/RepairGUI/Makefile.in +++ b/src/RepairGUI/Makefile.in @@ -42,26 +42,35 @@ LIB = libRepairGUI.la LIB_SRC = RepairGUI.cxx \ RepairGUI_SewingDlg.cxx \ - RepairGUI_OrientationDlg.cxx \ RepairGUI_SuppressFacesDlg.cxx \ - RepairGUI_SuppressHoleDlg.cxx - + RepairGUI_ShapeProcessDlg.cxx \ + RepairGUI_CloseContourDlg.cxx \ + RepairGUI_RemoveIntWiresDlg.cxx \ + RepairGUI_RemoveHolesDlg.cxx \ + RepairGUI_DivideEdgeDlg.cxx \ + RepairGUI_FreeBoundDlg.cxx \ + RepairGUI_GlueDlg.cxx + LIB_MOC = \ - RepairGUI.h \ RepairGUI_SewingDlg.h \ - RepairGUI_OrientationDlg.h \ RepairGUI_SuppressFacesDlg.h \ - RepairGUI_SuppressHoleDlg.h + RepairGUI_ShapeProcessDlg.h \ + RepairGUI_CloseContourDlg.h \ + RepairGUI_RemoveIntWiresDlg.h \ + RepairGUI_RemoveHolesDlg.h \ + RepairGUI_DivideEdgeDlg.h \ + RepairGUI_FreeBoundDlg.h \ + RepairGUI_GlueDlg.h -LIB_CLIENT_IDL = +LIB_CLIENT_IDL = SALOME_GenericObj.idl SALOME_Component.idl -LIB_SERVER_IDL = +LIB_SERVER_IDL = # additionnal information to compil and link file CPPFLAGS += $(QT_INCLUDES) $(VTK_INCLUDES) $(OCC_INCLUDES) $(PYTHON_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome CXXFLAGS += -I${KERNEL_ROOT_DIR}/include/salome -LDFLAGS += -lDisplayGUI +LDFLAGS += -lGEOMBase @CONCLUDE@ diff --git a/src/RepairGUI/RepairGUI.cxx b/src/RepairGUI/RepairGUI.cxx index ab9be2e20..5b97e0d78 100644 --- a/src/RepairGUI/RepairGUI.cxx +++ b/src/RepairGUI/RepairGUI.cxx @@ -24,35 +24,50 @@ // File : RepairGUI.cxx // Author : Damien COQUERET // Module : GEOM -// $Header: +// $Header$ #include "RepairGUI.h" #include "QAD_RightFrame.h" +#include "QAD_Desktop.h" #include "OCCViewer_Viewer3d.h" #include "SALOMEGUI_QtCatchCorbaException.hxx" #include "RepairGUI_SewingDlg.h" // Method SEWING -#include "RepairGUI_OrientationDlg.h" // Method ORIENTATION #include "RepairGUI_SuppressFacesDlg.h" // Method SUPPRESS FACES -#include "RepairGUI_SuppressHoleDlg.h" // Method SUPPRESS HOLE +#include "RepairGUI_RemoveHolesDlg.h" // Method SUPPRESS HOLE +#include "RepairGUI_ShapeProcessDlg.h" // Method PROCESS SHAPE +#include "RepairGUI_CloseContourDlg.h" // Method CLOSE CONTOUR +#include "RepairGUI_RemoveIntWiresDlg.h"// Method REMOVE INTERNAL WIRES +#include "RepairGUI_DivideEdgeDlg.h" // Method DEVIDE EDGE +#include "RepairGUI_FreeBoundDlg.h" // Method FREE BOUNDARIES +#include "RepairGUI_GlueDlg.h" // Method GLUE FACES #include "utilities.h" using namespace std; +RepairGUI* RepairGUI::myGUIObject = 0; + +//======================================================================= +// function : GetRepairGUI() +// purpose : Get the only RepairGUI object [ static ] +//======================================================================= +RepairGUI* RepairGUI::GetRepairGUI() +{ + if ( myGUIObject == 0 ) { + // init RepairGUI only once + myGUIObject = new RepairGUI(); + } + return myGUIObject; +} + //======================================================================= // function : RepairGUI() // purpose : Constructor //======================================================================= -RepairGUI::RepairGUI() : - QObject() +RepairGUI::RepairGUI() : GEOMGUI() { - myGeomBase = new GEOMBase(); - myGeomGUI = GEOMContext::GetGeomGUI(); -// Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM"); -// myGeom = GEOM::GEOM_Gen::_narrow(comp); - myGeom = myGeomGUI->myComponentGeom; } @@ -71,264 +86,46 @@ RepairGUI::~RepairGUI() //======================================================================= bool RepairGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) { - RepairGUI* myRepairGUI = new RepairGUI(); - myRepairGUI->myGeomGUI->EmitSignalDeactivateDialog(); + GeometryGUI::GetGeomGUI()->EmitSignalDeactivateDialog(); SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection()); - switch (theCommandID) - { + QDialog* aDlg = NULL; + switch (theCommandID) { case 601: // SEWING - { - RepairGUI_SewingDlg *aDlg = new RepairGUI_SewingDlg(parent, "", myRepairGUI, Sel); - break; - } - case 602: // ORIENTATION - { - RepairGUI_OrientationDlg *aDlg = new RepairGUI_OrientationDlg(parent, "", myRepairGUI, Sel); - break; - } - case 603: // SUPPRESS FACES : use ic - { - Handle(AIS_InteractiveContext) ic; - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - ic = v3d->getAISContext(); - } - RepairGUI_SuppressFacesDlg *aDlg = new RepairGUI_SuppressFacesDlg(parent, "", myRepairGUI, Sel, ic); - break; - } - case 604: // SUPPRESS HOLES : use ic - { - Handle(AIS_InteractiveContext) ic; - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - ic = v3d->getAISContext(); - } - RepairGUI_SuppressHoleDlg *aDlg = new RepairGUI_SuppressHoleDlg(parent, "", myRepairGUI, Sel, ic); - break; - } + aDlg = new RepairGUI_SewingDlg( parent, "", Sel ); + break; + case 602: // GLUE FACES + aDlg = new RepairGUI_GlueDlg( parent, "", Sel ); + break; + case 603: // SUPPRESS FACES + aDlg = new RepairGUI_SuppressFacesDlg( parent, "", Sel); + break; + case 604: // SUPPRESS HOLES + aDlg = new RepairGUI_RemoveHolesDlg( parent, "", Sel ); + break; + case 605: // SHAPE PROCESSING + aDlg = new RepairGUI_ShapeProcessDlg( parent, "", Sel ); + break; + case 606: // CLOSE CONTOUR + aDlg = new RepairGUI_CloseContourDlg( parent, "", Sel ); + break; + case 607: // REMOVE INTERNAL WIRES + aDlg = new RepairGUI_RemoveIntWiresDlg( parent, "", Sel ); + break; + case 608: // ADD POINT ON EDGE + aDlg = new RepairGUI_DivideEdgeDlg( parent, "", Sel ); + break; + case 609: // FREE BOUNDARIES + aDlg = new RepairGUI_FreeBoundDlg( parent, Sel ); + break; default: - { - parent->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); - break; - } - } - return true; -} - - -//===================================================================================== -// function : MakeSewingAndDisplay() -// purpose : -//===================================================================================== -void RepairGUI::MakeSewingAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR, - const Standard_Real precision) -{ - try { - GEOM::GEOM_Shape_var result = myGeom->MakeSewing(listShapesIOR, precision); - if(result->_is_nil()) { - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_NULLSHAPE")); - return; - } - - TopoDS_Shape S = myGeomGUI->GetShapeReader().GetShape(myGeom, result); - Standard_CString type; - myGeomBase->GetShapeTypeString(S,type); - result->NameType(type); - - if(myGeomBase->Display(result)) - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); - return; + parent->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); + break; } - catch(const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return; -} - - -//===================================================================================== -// function : MakeOrientationChangeAndDisplay() -// purpose : -//===================================================================================== -void RepairGUI::MakeOrientationChangeAndDisplay(GEOM::GEOM_Shape_ptr Shape) -{ - try { - GEOM::GEOM_Shape_var result = myGeom->OrientationChange(Shape); - if(result->_is_nil()) { - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_NULLSHAPE")); - return; - } - result->NameType(Shape->NameType()); - if(myGeomBase->Display(result)) - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); - return; - } - catch(const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return; -} - - -//===================================================================================== -// function : OnSuppressHole() -// purpose : To suppress an hole on a shape 'ShapeTopo'. -// : 'ListOfIdEndFace' may be an empty list. -// : This means that hole do not traverse ShapeTopo. -// : Warning : the hole to be suppressed must be defined by one or two single closed wires ! -//===================================================================================== -bool RepairGUI::OnSuppressHole(const char* ShapeTopoIOR, - const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdFace, - const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdWire, - const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdEndFace) -{ - /* Test the type of viewer */ - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) - return false; - - try { - GEOM::GEOM_Shape_var aShape = myGeom->GetIORFromString(ShapeTopoIOR); - GEOM::GEOM_Shape_var aResult = myGeom->SuppressHole(aShape, ListOfIdFace, ListOfIdWire, ListOfIdEndFace); - - TopoDS_Shape S = myGeomGUI->GetShapeReader().GetShape(myGeom, aResult); - Standard_CString type; - myGeomBase->GetShapeTypeString(S,type); - aResult->NameType(type); - if(myGeomBase->Display(aResult)) - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); - } - catch(const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return true; -} - - -//===================================================================================== -// function : OnSuppressHolesInFaceOrShell() -// purpose : To suppress one or more holes on a face -// : 'ListOfIdWires' contains indices or wires/holes. -//===================================================================================== -bool RepairGUI::OnSuppressHolesInFaceOrShell(const char* ShapeTopoIOR, - const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdWires) -{ - /* Test the type of viewer */ - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC) - return false; - - try { - GEOM::GEOM_Shape_var aShape = myGeom->GetIORFromString(ShapeTopoIOR); - GEOM::GEOM_Shape_var aResult = myGeom->SuppressHolesInFaceOrShell(aShape, ListOfIdWires); + if ( aDlg ) + aDlg->show(); - TopoDS_Shape S = myGeomGUI->GetShapeReader().GetShape(myGeom, aResult); - Standard_CString type; - myGeomBase->GetShapeTypeString(S,type); - aResult->NameType(type); - - if(myGeomBase->Display(aResult)) - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); - } - catch(const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return true; -} - - -//===================================================================================== -// function : OnSuppressFaces() -// purpose : To suppress faces from a shape -// : The result is one or more shells/faces as main shapes ! -//===================================================================================== -bool RepairGUI::OnSuppressFaces(const TopoDS_Shape& ShapeTopo, const char* ShapeTopoIOR, - const Standard_Integer& aLocalContextId, bool& myUseLocalContext) -{ - /* Test the type of viewer */ - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC) - return false; - - SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument(); - SALOMEDS::SObject_var theObj = aStudy->FindObjectIOR(ShapeTopoIOR); - if(theObj->_is_nil()) { - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY")); - return false; - } - - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - Handle(AIS_InteractiveContext) ic = v3d->getAISContext(); - - if(myUseLocalContext == false) { - /* local context is from DialogBox */ - MESSAGE("Error : No local context opened for suppress faces method" << endl); - return false; - } - - GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID; - ic->InitSelected(); - int nbSelected = ic->NbSelected(); - ListOfID->length(nbSelected); - - /* Create a list of indices of faces to be suppressed */ - int i = 0; - const int SubShapeType = 4; /* GEOM::FACE type */ - ic->InitSelected(); /* to repositioning at beginning */ - while(ic->MoreSelected()) { - int index = myGeomBase->GetIndex(ic->SelectedShape(), ShapeTopo, SubShapeType); - ListOfID[i] = index; - i++; - ic->NextSelected(); - } - - /* Close local context opened in DialogBox */ - ic->CloseLocalContext(aLocalContextId); - myUseLocalContext = false; - - /* Here is the main shape */ - GEOM::GEOM_Shape_var aShape = myGeom->GetIORFromString(ShapeTopoIOR); - GEOM::GEOM_Gen::ListOfGeomShapes_var listGeomShapes = new GEOM::GEOM_Gen::ListOfGeomShapes; - - /* Call geom method that return a list of shells/faces as result of suppress */ - try { - listGeomShapes = myGeom->SuppressFaces(aShape, ListOfID); - } - catch(const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - - /* Test list of shells/faces */ - if(listGeomShapes->length() < 1) { - return false; - } - - /* Loop on each object created */ - for(int i=0; ilength(); i++) { - GEOM::GEOM_Shape_var aShellOrFace = listGeomShapes[i]; - TopoDS_Shape S = myGeomGUI->GetShapeReader().GetShape(myGeom, aShellOrFace); - - if(S.IsNull()) - return false; - - char* nameG = (char *)malloc(20); - Standard_CString Type; - if(myGeomBase->GetShapeTypeString(S, Type)) { - aShellOrFace->NameType(Type); - sprintf (nameG, "%s_%d", Type, myGeomGUI->myNbGeom++); - } - else { - aShellOrFace->NameType(tr("GEOM_SHAPE")); - sprintf (nameG, "%s_%d", tr("GEOM_SHAPE").latin1(), myGeomGUI->myNbGeom++); - } - - /* Display with name */ - if(!myGeomBase->Display(aShellOrFace, nameG)) { - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_ABORT")); - return false; - } - } - - QAD_Application::getDesktop()->putInfo (tr("GEOM_PRP_READY")); return true; } @@ -338,6 +135,8 @@ bool RepairGUI::OnSuppressFaces(const TopoDS_Shape& ShapeTopo, const char* Shape //===================================================================================== extern "C" { - bool OnGUIEvent(int theCommandID, QAD_Desktop* parent) - {return RepairGUI::OnGUIEvent(theCommandID, parent);} + GEOMGUI* GetLibGUI() + { + return RepairGUI::GetRepairGUI(); + } } diff --git a/src/RepairGUI/RepairGUI.h b/src/RepairGUI/RepairGUI.h index 1afe5a85f..2454b406c 100644 --- a/src/RepairGUI/RepairGUI.h +++ b/src/RepairGUI/RepairGUI.h @@ -24,45 +24,34 @@ // File : RepairGUI.h // Author : Damien COQUERET // Module : GEOM -// $Header: +// $Header$ #ifndef REPAIRGUI_H #define REPAIRGUI_H +#include "GEOMGUI.h" #include "GEOMBase.h" //================================================================================= // class : RepairGUI // purpose : //================================================================================= -class RepairGUI : public QObject +class RepairGUI : public GEOMGUI { - Q_OBJECT /* for QT compatibility */ +protected: + RepairGUI(); // hide constructor to avoid direct creation public : - RepairGUI(); ~RepairGUI(); - static bool OnGUIEvent(int theCommandID, QAD_Desktop* parent); + // Get the only RepairGUI object + static RepairGUI* GetRepairGUI(); - void MakeSewingAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR, - const Standard_Real precision); - void MakeOrientationChangeAndDisplay(GEOM::GEOM_Shape_ptr Shape); - bool OnSuppressHole(const char* ShapeTopoIOR, - const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdFace, - const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdWire, - const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdEndFace); - bool OnSuppressHolesInFaceOrShell(const char* ShapeTopoIOR, - const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdWires); - bool OnSuppressFaces(const TopoDS_Shape& ShapeTopo, - const char* ShapeTopoIOR, - const Standard_Integer& aLocalContextId, - bool& myUseLocalContext); - - GEOMBase* myGeomBase; - GEOMContext* myGeomGUI; - GEOM::GEOM_Gen_var myGeom; /* Current Geom Component */ + bool OnGUIEvent(int theCommandID, QAD_Desktop* parent); +private: + static RepairGUI* myGUIObject; // the only RepairGUI object + }; #endif diff --git a/src/RepairGUI/RepairGUI_CloseContourDlg.cxx b/src/RepairGUI/RepairGUI_CloseContourDlg.cxx new file mode 100644 index 000000000..46721ef62 --- /dev/null +++ b/src/RepairGUI/RepairGUI_CloseContourDlg.cxx @@ -0,0 +1,392 @@ +// 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_CloseContourDlg.cxx +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +using namespace std; +#include "RepairGUI_CloseContourDlg.h" + +#include "QAD_RightFrame.h" +#include "QAD_Desktop.h" +#include "OCCViewer_Viewer3d.h" +#include "SALOME_ListIteratorOfListIO.hxx" + +#include "GEOMImpl_Types.hxx" + +#include + + +//================================================================================= +// class : RepairGUI_CloseContourDlg() +// purpose : Constructs a RepairGUI_CloseContourDlg 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_CloseContourDlg::RepairGUI_CloseContourDlg(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_CLOSECONTOUR"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); + + setCaption(tr("GEOM_CLOSECONTOUR_TITLE")); + + /***************************************************************/ + GroupConstructors->setTitle(tr("GEOM_CLOSECONTOUR_TITLE")); + RadioButton1->setPixmap(image0); + RadioButton2->close(TRUE); + RadioButton3->close(TRUE); + + GroupPoints = new DlgRef_1Sel_Ext(this, "GroupPoints"); + GroupPoints->GroupBox1->setTitle(tr("Contour to close")); + GroupPoints->TextLabel1->setText(tr("GEOM_SELECTED_SHAPE")); + GroupPoints->PushButton1->setPixmap(image1); + GroupPoints->LineEdit1->setReadOnly( true ); + + QGridLayout* aSelectWiresLay = new QGridLayout( 0, 1, 1, 0, 6, "aSelectWiresLay"); + + mySelectWiresBtn = new QPushButton( GroupPoints->GroupBox1, "mySelectWiresBtn" ); + mySelectWiresBtn->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, mySelectWiresBtn->sizePolicy().hasHeightForWidth() ) ); + mySelectWiresBtn->setText( trUtf8( "" ) ); + mySelectWiresBtn->setPixmap(image1); + + mySelectWiresEdt = new QLineEdit( GroupPoints->GroupBox1, "mySelectWiresEdt" ); + mySelectWiresEdt->setReadOnly( true ); + + mySelectWiresLbl = new QLabel( tr( "Contour to close" ), GroupPoints->GroupBox1, "ContourLbl" ); + mySelectWiresLbl->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, mySelectWiresLbl->sizePolicy().hasHeightForWidth() ) ); + + aSelectWiresLay->addWidget( mySelectWiresLbl, 0, 0 ); + aSelectWiresLay->addWidget( mySelectWiresBtn, 0, 1 ); + aSelectWiresLay->addWidget( mySelectWiresEdt, 0, 2 ); + QSpacerItem* spacer = new QSpacerItem( 0, 16, QSizePolicy::Minimum, QSizePolicy::Expanding ); + aSelectWiresLay->addItem( spacer, 1, 2 ); + + myIsVertexGr = new QButtonGroup( 2, Qt::Vertical, GroupPoints ); + myIsVertexGr->setFrameStyle( QFrame::NoFrame ); + myIsVertexGr->setRadioButtonExclusive( true ); + myIsVertexGr->insert( new QRadioButton( tr( "Close by common vertex" ), myIsVertexGr ), 0 ); + myIsVertexGr->insert( new QRadioButton( tr( "Close by new edge" ), myIsVertexGr ), 1 ); + myIsVertexGr->find( 0 )->toggle(); + + Layout1->addWidget(GroupPoints, 2, 0); + GroupPoints->getGroupBoxLayout()->addLayout( aSelectWiresLay, 1, 0 ); + GroupPoints->getGroupBoxLayout()->addMultiCellWidget(myIsVertexGr, 2, 2, 0, 2); + /***************************************************************/ + + Init(); +} + + +//================================================================================= +// function : ~RepairGUI_CloseContourDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +RepairGUI_CloseContourDlg::~RepairGUI_CloseContourDlg() +{ +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void RepairGUI_CloseContourDlg::Init() +{ + /* init variables */ + myEditCurrentArgument = GroupPoints->LineEdit1; + + myObject = GEOM::GEOM_Object::_nil(); + myWiresInd = new GEOM::short_array(); + myWiresInd->length( 0 ); + + myGeomGUI->SetState( 0 ); + initSelection(); + + /* 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(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(mySelectWiresBtn, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(mySelectWiresEdt, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + + initName( tr( "CLOSE_CONTOUR_NEW_OBJ_NAME" ) ); +} + + +//================================================================================= +// function : ClickOnOk() +// purpose : Same than click on apply but close this dialog. +//================================================================================= +void RepairGUI_CloseContourDlg::ClickOnOk() +{ + if ( ClickOnApply() ) + ClickOnCancel(); +} + + + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +bool RepairGUI_CloseContourDlg::ClickOnApply() +{ + if ( !onAccept() ) + return false; + + initName(); + + myEditCurrentArgument = GroupPoints->LineEdit1; + myEditCurrentArgument->setText(""); + myObject = GEOM::GEOM_Object::_nil(); + myWiresInd->length( 0 ); + + initSelection(); + + return true; +} + + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void RepairGUI_CloseContourDlg::ClickOnCancel() +{ + GEOMBase_Skeleton::ClickOnCancel(); +} + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +// : used only by SelectButtonC1A1 (LineEditC1A1) +//================================================================================= +void RepairGUI_CloseContourDlg::SelectionIntoArgument() +{ + erasePreview(); + myEditCurrentArgument->setText( "" ); + mySelectWiresEdt->setText( "" ); + + if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) + myObject = GEOM::GEOM_Object::_nil(); + else if ( myEditCurrentArgument == mySelectWiresEdt ) + myWiresInd->length( 0 ); + + if ( mySelection->IObjectCount() == 1 ) + { + Handle(SALOME_InteractiveObject) anIO = mySelection->firstIObject(); + + if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) // face selection + { + Standard_Boolean aRes; + myObject = GEOMBase::ConvertIOinGEOMObject( anIO, aRes ); + if ( aRes && GEOMBase::IsShape( myObject ) ) + { + myEditCurrentArgument->setText( GEOMBase::GetName( myObject ) ); + TopoDS_Shape aShape; + if ( myGeomBase->GetShape( myObject, aShape, TopAbs_WIRE ) ) + mySelectWiresEdt->setText( myEditCurrentArgument->text() ); + } + else + myObject = GEOM::GEOM_Object::_nil(); + } + else if ( myEditCurrentArgument == mySelectWiresEdt ) + { + TColStd_IndexedMapOfInteger aMap; + mySelection->GetIndex( anIO, aMap ); + const int n = aMap.Extent(); + myWiresInd->length( n ); + for ( int i = 1; i <= n; i++ ) + myWiresInd[ i-1 ] = aMap( i ); + if ( n ) + myEditCurrentArgument->setText( QString::number( n ) + "_" + tr( "GEOM_WIRE" ) + tr( "_S_" ) ); + } + } +} + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void RepairGUI_CloseContourDlg::SetEditCurrentArgument() +{ + const QObject* send = sender(); + if ( send == GroupPoints->PushButton1 ) + myEditCurrentArgument = GroupPoints->LineEdit1; + else if ( send == mySelectWiresBtn && !myObject->_is_nil() ) + myEditCurrentArgument = mySelectWiresEdt; + if ( myEditCurrentArgument ) + { + initSelection(); + myEditCurrentArgument->setFocus(); + SelectionIntoArgument(); + } +} + + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void RepairGUI_CloseContourDlg::LineEditReturnPressed() +{ + const QObject* send = sender(); + if( send == GroupPoints->LineEdit1 || send == mySelectWiresEdt ) + { + myEditCurrentArgument = (QLineEdit*)send; + GEOMBase_Skeleton::LineEditReturnPressed(); + } +} + + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void RepairGUI_CloseContourDlg::DeactivateActiveDialog() +{ + myGeomGUI->SetState( -1 ); + GEOMBase_Skeleton::DeactivateActiveDialog(); +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void RepairGUI_CloseContourDlg::ActivateThisDialog() +{ + GEOMBase_Skeleton::ActivateThisDialog(); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + + myEditCurrentArgument = GroupPoints->LineEdit1; + myEditCurrentArgument->setText(""); + mySelectWiresEdt->setText(""); + myObject = GEOM::GEOM_Object::_nil(); + myWiresInd->length( 0 ); + + myGeomGUI->SetState( 0 ); + initSelection(); +} + + +//================================================================================= +// function : enterEvent() +// purpose : Mouse enter onto the dialog to activate it +//================================================================================= +void RepairGUI_CloseContourDlg::enterEvent(QEvent* e) +{ + if ( !GroupConstructors->isEnabled() ) + ActivateThisDialog(); +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void RepairGUI_CloseContourDlg::closeEvent(QCloseEvent* e) +{ + myGeomGUI->SetState( -1 ); + GEOMBase_Skeleton::closeEvent( e ); +} + +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr RepairGUI_CloseContourDlg::createOperation() +{ + return getGeomEngine()->GetIHealingOperations( getStudyId() ); +} + +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool RepairGUI_CloseContourDlg::isValid( QString& msg ) +{ + TopoDS_Shape aTmpShape; + return !myObject->_is_nil() && ( myWiresInd->length() || myGeomBase->GetShape( myObject, aTmpShape, TopAbs_WIRE ) ); +} + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool RepairGUI_CloseContourDlg::execute( ObjectList& objects ) +{ + GEOM::GEOM_Object_var anObj = GEOM::GEOM_IHealingOperations::_narrow( getOperation() )->CloseContour( myObject, myWiresInd, getIsByVertex() ); + bool aResult = !anObj->_is_nil(); + if ( aResult ) + objects.push_back( anObj._retn() ); + + return aResult; +} + +//================================================================================= +// function : getIsByVertex +// purpose : +//================================================================================= +bool RepairGUI_CloseContourDlg::getIsByVertex() const +{ + return myIsVertexGr->find( 0 )->isOn(); +} + +//================================================================================= +// function : initSelection +// purpose : +//================================================================================= +void RepairGUI_CloseContourDlg::initSelection() +{ + if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) + { + TColStd_MapOfInteger aTypes; + aTypes.Add( GEOM_COMPOUND ); + aTypes.Add( GEOM_SOLID ); + aTypes.Add( GEOM_SHELL ); + aTypes.Add( GEOM_FACE ); + aTypes.Add( GEOM_WIRE ); + + globalSelection( aTypes ); + } + else if ( myEditCurrentArgument == mySelectWiresEdt ) + { + localSelection( myObject, TopAbs_EDGE ); + localSelection( myObject, TopAbs_WIRE ); + } +} + + diff --git a/src/RepairGUI/RepairGUI_CloseContourDlg.h b/src/RepairGUI/RepairGUI_CloseContourDlg.h new file mode 100644 index 000000000..6b66cb4e2 --- /dev/null +++ b/src/RepairGUI/RepairGUI_CloseContourDlg.h @@ -0,0 +1,88 @@ +// 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_CloseContourDlg.h +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_CloseContour_H +#define DIALOGBOX_CloseContour_H + +#include "GEOMBase_Skeleton.h" +#include "DlgRef_1Sel_Ext.h" + +#include + +#include +#include + +//================================================================================= +// class : RepairGUI_CloseContourDlg +// purpose : +//================================================================================= +class RepairGUI_CloseContourDlg : public GEOMBase_Skeleton +{ + Q_OBJECT + +public: + RepairGUI_CloseContourDlg(QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + ~RepairGUI_CloseContourDlg(); + +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& ); + virtual bool execute( ObjectList& objects ); + +private : + void Init(); + void enterEvent(QEvent* e); + void closeEvent(QCloseEvent* e); + void initSelection(); + + bool getIsByVertex() const; + + GEOM::GEOM_Object_var myObject; + GEOM::short_array_var myWiresInd; + + DlgRef_1Sel_Ext* GroupPoints; + QButtonGroup* myIsVertexGr; + QLabel* mySelectWiresLbl; + QPushButton* mySelectWiresBtn; + QLineEdit* mySelectWiresEdt; + +private slots: + void ClickOnOk(); + bool ClickOnApply(); + void ClickOnCancel(); + + void ActivateThisDialog(); + void DeactivateActiveDialog(); + + void LineEditReturnPressed(); + void SelectionIntoArgument(); + void SetEditCurrentArgument(); +}; + +#endif // DIALOGBOX_CloseContour_H diff --git a/src/RepairGUI/RepairGUI_DivideEdgeDlg.cxx b/src/RepairGUI/RepairGUI_DivideEdgeDlg.cxx new file mode 100644 index 000000000..acd54e86d --- /dev/null +++ b/src/RepairGUI/RepairGUI_DivideEdgeDlg.cxx @@ -0,0 +1,358 @@ +// 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_DivideEdgeDlg.cxx +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +using namespace std; +#include "RepairGUI_DivideEdgeDlg.h" + +#include "QAD_RightFrame.h" +#include "QAD_Desktop.h" +#include "OCCViewer_Viewer3d.h" +#include "SALOME_ListIteratorOfListIO.hxx" + +#include "GEOMImpl_Types.hxx" + +#include + + +//================================================================================= +// class : RepairGUI_DivideEdgeDlg() +// purpose : Constructs a RepairGUI_DivideEdgeDlg 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_DivideEdgeDlg::RepairGUI_DivideEdgeDlg(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_DIVIDE_EDGE"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); + + setCaption(tr("GEOM_DIVIDE_EDGE_TITLE")); + + /***************************************************************/ + GroupConstructors->setTitle(tr("GEOM_DIVIDE_EDGE_TITLE")); + RadioButton1->setPixmap(image0); + RadioButton2->close(TRUE); + RadioButton3->close(TRUE); + + GroupPoints = new DlgRef_1Sel_Ext(this, "GroupPoints"); + GroupPoints->GroupBox1->setTitle(tr("GEOM_ADD_POINT")); + GroupPoints->TextLabel1->setText(tr("GEOM_EDGE")); + GroupPoints->PushButton1->setPixmap(image1); + GroupPoints->LineEdit1->setReadOnly( true ); + + myIsParameterGr = new QButtonGroup( 2, Qt::Vertical, GroupPoints ); + myIsParameterGr->setFrameStyle( QFrame::NoFrame ); + myIsParameterGr->setRadioButtonExclusive( true ); + myIsParameterGr->insert( new QRadioButton( tr( "GEOM_BY_PARAMETER" ), myIsParameterGr ), 0 ); + myIsParameterGr->insert( new QRadioButton( tr( "GEOM_BY_LENGTH" ), myIsParameterGr ), 1 ); + myIsParameterGr->find( 0 )->toggle(); + + QGridLayout* aLay = new QGridLayout( 0, 1, 2, 0, 6, "aLay" ); + myValEdt = new QAD_SpinBoxDbl( GroupPoints->GroupBox1, 0., 1., 0.1, 3 ); + myValEdt->setValue( 0.5 ); + QLabel* aLbl1 = new QLabel( tr( "GEOM_VALUE" ), GroupPoints->GroupBox1 ); + aLay->addWidget( aLbl1, 0, 0 ); + aLay->addWidget( myValEdt, 0, 1 ); + + Layout1->addWidget(GroupPoints, 2, 0); + GroupPoints->getGroupBoxLayout()->addMultiCellWidget(myIsParameterGr, 1, 1, 0, 2); + GroupPoints->getGroupBoxLayout()->addLayout( aLay, 2, 0 ); + /***************************************************************/ + + Init(); +} + + +//================================================================================= +// function : ~RepairGUI_DivideEdgeDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +RepairGUI_DivideEdgeDlg::~RepairGUI_DivideEdgeDlg() +{ +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void RepairGUI_DivideEdgeDlg::Init() +{ + /* init variables */ + myEditCurrentArgument = GroupPoints->LineEdit1; + + myObject = GEOM::GEOM_Object::_nil(); + myIndex = -1; + + myGeomGUI->SetState( 0 ); + initSelection(); + + /* 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(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + + initName( tr( "DEVIDE_EDGE_NEW_OBJECT_NAME" ) ); +} + + +//================================================================================= +// function : ClickOnOk() +// purpose : Same than click on apply but close this dialog. +//================================================================================= +void RepairGUI_DivideEdgeDlg::ClickOnOk() +{ + if ( ClickOnApply() ) + ClickOnCancel(); +} + + + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +bool RepairGUI_DivideEdgeDlg::ClickOnApply() +{ + if ( !onAccept() ) + return false; + + initName(); + + myEditCurrentArgument->setText(""); + myObject = GEOM::GEOM_Object::_nil(); + myIndex = -1; + + initSelection(); + + return true; +} + + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void RepairGUI_DivideEdgeDlg::ClickOnCancel() +{ + GEOMBase_Skeleton::ClickOnCancel(); +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +// : used only by SelectButtonC1A1 (LineEditC1A1) +//================================================================================= +void RepairGUI_DivideEdgeDlg::SelectionIntoArgument() +{ + myEditCurrentArgument->setText(""); + + myObject = GEOM::GEOM_Object::_nil(); + myIndex = -1; + + if ( mySelection->IObjectCount() == 1 ) + { + Handle(SALOME_InteractiveObject) anIO = mySelection->firstIObject(); + Standard_Boolean aRes; + GEOM::GEOM_Object_var aSelectedObj = GEOMBase::ConvertIOinGEOMObject( anIO, aRes ); + if ( !CORBA::is_nil( aSelectedObj ) && aRes ) + { + TopoDS_Shape aShape; + if ( myGeomBase->GetShape( aSelectedObj, aShape, TopAbs_SHAPE ) ) + { + const int aType = aShape.ShapeType(); + if ( aType <= TopAbs_EDGE ) // edge, wire, face, shell, solid, compound + { + GEOM::short_array anIndexes; + if ( mySelection->HasIndex( anIO ) ) // subshape selection + { + TColStd_IndexedMapOfInteger aMap; + mySelection->GetIndex( anIO, aMap ); + myIndex = aMap( 1 ); + myObject = aSelectedObj; + myEditCurrentArgument->setText( tr( "GEOM_EDGE" ) + "_1" ); + } + else if ( aType == TopAbs_EDGE ) // single shape selection + { + myIndex = -1; + myObject = aSelectedObj; + myEditCurrentArgument->setText( GEOMBase::GetName( myObject ) ); + } + else // face, shell, solid or compound was selected, and NOT its subshape. + { + myIndex = -1; + myObject = GEOM::GEOM_Object::_nil(); + } + } + } + } + } +} + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void RepairGUI_DivideEdgeDlg::SetEditCurrentArgument() +{ + if( sender() == GroupPoints->PushButton1 ) + { + GroupPoints->LineEdit1->setFocus(); + myEditCurrentArgument = GroupPoints->LineEdit1; + } + SelectionIntoArgument(); +} + + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void RepairGUI_DivideEdgeDlg::LineEditReturnPressed() +{ + if( sender() == GroupPoints->LineEdit1 ) + { + myEditCurrentArgument = GroupPoints->LineEdit1; + GEOMBase_Skeleton::LineEditReturnPressed(); + } +} + + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void RepairGUI_DivideEdgeDlg::DeactivateActiveDialog() +{ + myGeomGUI->SetState( -1 ); + GEOMBase_Skeleton::DeactivateActiveDialog(); +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void RepairGUI_DivideEdgeDlg::ActivateThisDialog() +{ + GEOMBase_Skeleton::ActivateThisDialog(); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + + myObject = GEOM::GEOM_Object::_nil(); + myIndex = -1; + + myGeomGUI->SetState( 0 ); + initSelection(); +} + + +//================================================================================= +// function : enterEvent() +// purpose : Mouse enter onto the dialog to activate it +//================================================================================= +void RepairGUI_DivideEdgeDlg::enterEvent(QEvent* e) +{ + if ( !GroupConstructors->isEnabled() ) + ActivateThisDialog(); +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void RepairGUI_DivideEdgeDlg::closeEvent(QCloseEvent* e) +{ + myGeomGUI->SetState( -1 ); + GEOMBase_Skeleton::closeEvent( e ); +} + +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr RepairGUI_DivideEdgeDlg::createOperation() +{ + return getGeomEngine()->GetIHealingOperations( getStudyId() ); +} + +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool RepairGUI_DivideEdgeDlg::isValid( QString& msg ) +{ + return !myObject->_is_nil(); +} + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool RepairGUI_DivideEdgeDlg::execute( ObjectList& objects ) +{ + GEOM::GEOM_Object_var anObj = GEOM::GEOM_IHealingOperations::_narrow( getOperation() )->DivideEdge( + myObject, myIndex, myValEdt->value(), getIsByParameter() ); + bool aResult = !anObj->_is_nil(); + if ( aResult ) + objects.push_back( anObj._retn() ); + + return aResult; +} + +//================================================================================= +// function : getIsByParameter +// purpose : +//================================================================================= +bool RepairGUI_DivideEdgeDlg::getIsByParameter() const +{ + return myIsParameterGr->find( 0 )->isOn(); +} + +//================================================================================= +// function : initSelection +// purpose : +//================================================================================= +void RepairGUI_DivideEdgeDlg::initSelection() +{ + GEOM::GEOM_Object_var aNullGeomObject; + localSelection( aNullGeomObject, TopAbs_EDGE ); // load local selection on ALL objects +} + + + diff --git a/src/RepairGUI/RepairGUI_DivideEdgeDlg.h b/src/RepairGUI/RepairGUI_DivideEdgeDlg.h new file mode 100644 index 000000000..33b63916e --- /dev/null +++ b/src/RepairGUI/RepairGUI_DivideEdgeDlg.h @@ -0,0 +1,87 @@ +// 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_DivideEdgeDlg.h +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_DivideEdge_H +#define DIALOGBOX_DivideEdge_H + +#include "GEOMBase_Skeleton.h" +#include "DlgRef_1Sel_Ext.h" +#include "QAD_SpinBoxDbl.h" + +#include + +#include +#include + +//================================================================================= +// class : RepairGUI_DivideEdgeDlg +// purpose : +//================================================================================= +class RepairGUI_DivideEdgeDlg : public GEOMBase_Skeleton +{ + Q_OBJECT + +public: + RepairGUI_DivideEdgeDlg(QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + ~RepairGUI_DivideEdgeDlg(); + +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& ); + virtual bool execute( ObjectList& objects ); + +private : + void Init(); + void enterEvent(QEvent* e); + void closeEvent(QCloseEvent* e); + void initSelection(); + + bool getIsByParameter() const; + + GEOM::GEOM_Object_var myObject; + int myIndex; + + DlgRef_1Sel_Ext* GroupPoints; + QButtonGroup* myIsParameterGr; + QAD_SpinBoxDbl* myValEdt; + +private slots: + void ClickOnOk(); + bool ClickOnApply(); + void ClickOnCancel(); + + void ActivateThisDialog(); + void DeactivateActiveDialog(); + + void LineEditReturnPressed(); + void SelectionIntoArgument(); + void SetEditCurrentArgument(); +}; + +#endif // DIALOGBOX_DivideEdge_H diff --git a/src/RepairGUI/RepairGUI_FillingHoleDlg.cxx b/src/RepairGUI/RepairGUI_FillingHoleDlg.cxx deleted file mode 100644 index a591937a3..000000000 --- a/src/RepairGUI/RepairGUI_FillingHoleDlg.cxx +++ /dev/null @@ -1,544 +0,0 @@ -// 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 : GeometryGUI_FillingHoleDlg.cxx -// Author : Lucien PIGNOLONI -// Module : GEOM -// $Header$ - -using namespace std; -#include "GeometryGUI_FillingHoleDlg.h" - -#include "GeometryGUI.h" -#include "QAD_Application.h" -#include "QAD_Desktop.h" -#include "utilities.h" - - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//================================================================================= -// class : GeometryGUI_FillingHoleDlg() -// purpose : Constructs a GeometryGUI_FillingHoleDlg 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. -//================================================================================= -GeometryGUI_FillingHoleDlg::GeometryGUI_FillingHoleDlg( QWidget* parent, - const char* name, - SALOME_Selection* Sel, - Handle (AIS_InteractiveContext) ic, - bool modal, - WFlags fl ) - : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) -{ - - QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_DLG_SEWING"))); - QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr("ICON_SELECT"))); - - if ( !name ) - setName( "GeometryGUI_FillingHoleDlg" ); - resize( 303, 203 ); - setCaption( tr( "Filling hole" ) ); - setSizeGripEnabled( TRUE ); - GeometryGUI_FillingHoleDlgLayout = new QGridLayout( this ); - GeometryGUI_FillingHoleDlgLayout->setSpacing( 6 ); - GeometryGUI_FillingHoleDlgLayout->setMargin( 11 ); - - /***************************************************************/ - GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); - GroupConstructors->setTitle( tr( "" ) ); - GroupConstructors->setExclusive( TRUE ); - GroupConstructors->setColumnLayout(0, Qt::Vertical ); - GroupConstructors->layout()->setSpacing( 0 ); - GroupConstructors->layout()->setMargin( 0 ); - GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); - GroupConstructorsLayout->setAlignment( Qt::AlignTop ); - GroupConstructorsLayout->setSpacing( 6 ); - GroupConstructorsLayout->setMargin( 11 ); - Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" ); - Constructor1->setText( tr( "" ) ); - Constructor1->setPixmap( image0 ); - Constructor1->setChecked( TRUE ); - Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) ); - Constructor1->setMinimumSize( QSize( 50, 0 ) ); - GroupConstructorsLayout->addWidget( Constructor1, 0, 0 ); - QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupConstructorsLayout->addItem( spacer, 0, 1 ); - GeometryGUI_FillingHoleDlgLayout->addWidget( GroupConstructors, 0, 0 ); - - /***************************************************************/ - GroupC1 = new QGroupBox( this, "GroupC1" ); - GroupC1->setTitle( tr( "" ) ); - GroupC1->setMinimumSize( QSize( 0, 0 ) ); - GroupC1->setFrameShape( QGroupBox::Box ); - GroupC1->setFrameShadow( QGroupBox::Sunken ); - GroupC1->setColumnLayout(0, Qt::Vertical ); - GroupC1->layout()->setSpacing( 0 ); - GroupC1->layout()->setMargin( 0 ); - GroupC1Layout = new QGridLayout( GroupC1->layout() ); - GroupC1Layout->setAlignment( Qt::AlignTop ); - GroupC1Layout->setSpacing( 6 ); - GroupC1Layout->setMargin( 11 ); - Layout2 = new QHBoxLayout; - Layout2->setSpacing( 6 ); - Layout2->setMargin( 0 ); - TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" ); - TextLabelC1A1->setText( tr( "Main object" ) ); - TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) ); - TextLabelC1A1->setFrameShape( QLabel::NoFrame ); - TextLabelC1A1->setFrameShadow( QLabel::Plain ); - Layout2->addWidget( TextLabelC1A1 ); - SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" ); - SelectButtonC1A1->setText( tr( "" ) ); - SelectButtonC1A1->setPixmap( image1 ); - SelectButtonC1A1->setToggleButton( FALSE ); - SelectButtonC1A1->setMaximumSize( QSize( 28, 32767 ) ); - Layout2->addWidget( SelectButtonC1A1 ); - LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" ); - LineEditC1A1->setAlignment( int( QLineEdit::AlignLeft ) ); - Layout2->addWidget( LineEditC1A1 ); - GroupC1Layout->addLayout( Layout2, 0, 0 ); - CheckBox1 = new QCheckBox( GroupC1, "CheckBox1" ); - CheckBox1->setText( tr( "Select edges of hole on main object" ) ); - CheckBox1->setChecked( FALSE ); - GroupC1Layout->addWidget( CheckBox1, 1, 0 ); - GeometryGUI_FillingHoleDlgLayout->addWidget( GroupC1, 1, 0 ); - - /***************************************************************/ - GroupButtons = new QGroupBox( this, "GroupButtons" ); - GroupButtons->setTitle( tr( "" ) ); - GroupButtons->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, GroupButtons->sizePolicy().hasHeightForWidth() ) ); - GroupButtons->setColumnLayout(0, Qt::Vertical ); - GroupButtons->layout()->setSpacing( 0 ); - GroupButtons->layout()->setMargin( 0 ); - GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); - GroupButtonsLayout->setAlignment( Qt::AlignTop ); - GroupButtonsLayout->setSpacing( 6 ); - GroupButtonsLayout->setMargin( 11 ); - buttonClose = new QPushButton( GroupButtons, "buttonClose" ); - buttonClose->setText( tr( "&Close" ) ); - buttonClose->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonClose, 0, 3 ); - buttonOk = new QPushButton( GroupButtons, "buttonOk" ); - buttonOk->setText( tr( "&Ok" ) ); - buttonOk->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); - buttonApply = new QPushButton( GroupButtons, "buttonApply" ); - buttonApply->setText( tr( "&Apply" ) ); - buttonApply->setAutoDefault( TRUE ); - buttonApply->setDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); - QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupButtonsLayout->addItem( spacer_2, 0, 2 ); - GeometryGUI_FillingHoleDlgLayout->addWidget( GroupButtons, 2, 0 ); - - /* Initialisations */ - Init(Sel, ic) ; - -} - - -//================================================================================= -// function : ~GeometryGUI_FillingHoleDlg() -// purpose : Destroys the object and frees any allocated resources -//================================================================================= -GeometryGUI_FillingHoleDlg::~GeometryGUI_FillingHoleDlg() -{ - // no need to delete child widgets, Qt does it all for us -} - - - -//================================================================================= -// function : Init() -// purpose : -//================================================================================= -void GeometryGUI_FillingHoleDlg::Init( SALOME_Selection* Sel, Handle (AIS_InteractiveContext) ic ) -{ - - GroupC1->show(); - myConstructorId = 0 ; - Constructor1->setChecked( TRUE ); - myEditCurrentArgument = LineEditC1A1 ; - mySelection = Sel; - myShape.Nullify() ; - - myIC = ic ; - myUseLocalContext = false ; - myOkShape = false ; - myGeomGUI = GeometryGUI::GetGeometryGUI() ; - - /* Select sub shapes mode not checked */ - CheckBox1->setChecked( FALSE ); - myOkSelectSubMode = false ; - - // TODO : previous selection into argument ? - - /* Filter definitions */ - Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM"); - myGeom = GEOM::GEOM_Gen::_narrow(comp); - - /* signals and slots connections */ - connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); - connect( buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) ); - connect( buttonClose, SIGNAL( clicked() ), this, SLOT( ClickOnClose() ) ); - connect( GroupConstructors, SIGNAL( clicked(int) ), this, SLOT( ConstructorsClicked(int) )); - - connect( LineEditC1A1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ; - connect( SelectButtonC1A1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() )); - connect( CheckBox1, SIGNAL( stateChanged(int) ), this, SLOT( ActivateUserSelection() )); - - connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() )); - connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; - connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnClose() )); - - /* Move widget on the botton right corner of main widget */ - int x, y ; - myGeomGUI->DefineDlgPosition( this, x, y ) ; - this->move( x, y ) ; - this->show() ; /* display Dialog */ - - return ; -} - - -//================================================================================= -// function : ConstructorsClicked() -// purpose : Radio button management -//================================================================================= -void GeometryGUI_FillingHoleDlg::ConstructorsClicked(int constructorId) -{ - return ; -} - - -//================================================================================= -// function : ClickOnOk() -// purpose : Same than click on apply but close this dialog. -//================================================================================= -void GeometryGUI_FillingHoleDlg::ClickOnOk() -{ - this->ClickOnApply() ; - accept(); - - return ; -} - - - -//================================================================================= -// function : ClickOnApply() -// purpose : -//================================================================================= -void GeometryGUI_FillingHoleDlg::ClickOnApply() -{ - bool testResult = false ; - QAD_Application::getDesktop()->putInfo( tr("") ) ; - - switch(myConstructorId) - { - case 0 : - { - if( myOkShape && myOkSelectSubMode ) { - testResult = myGeomGUI->OnFillingHole( myShape, myShapeIOR, myLocalContextId, myUseLocalContext ) ; - } - if( !testResult ) { - QAD_Application::getDesktop()->putInfo(tr("Operation aborted")) ; - } - else { - QAD_Application::getDesktop()->putInfo(tr("Operation done")); - } - /* Reset arguments to allow a new selection */ - this->ResetStateOfDialog() ; - break ; - } - } - return ; -} - - - -//================================================================================= -// function : ClickOnClose() -// purpose : -//================================================================================= -void GeometryGUI_FillingHoleDlg::ClickOnClose() -{ - disconnect( mySelection, 0, this, 0 ); - myGeomGUI->ResetState() ; - - if(myUseLocalContext) { - myIC->CloseLocalContext(myLocalContextId) ; - this->myUseLocalContext = false ; - myGeomGUI->OnDisplayAll(true) ; - } - reject() ; - return ; -} - - -//================================================================================= -// function : SelectionIntoArgument() -// purpose : Called when selection as changed or other case -// : used only by SelectButtonC1A1 (LineEditC1A1) -//================================================================================= -void GeometryGUI_FillingHoleDlg::SelectionIntoArgument() -{ - - /* Reset argument and local context when selection as changed */ - this->ResetStateOfDialog() ; - - QString aString = ""; /* name of selection */ - - int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ; - if ( nbSel != 1 ) - return ; - - /* nbSel == 1 */ - TopoDS_Shape S ; - Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ; - - if( !myGeomGUI->GetTopoFromSelection(mySelection, S) ) - return ; - -// if( !IO->hasEntry() ) { -// QAD_Application::getDesktop()->putInfo(tr("Main shape must be in the study before")) ; -// return ; -// } - - /* Test the exact type of topology to fill an hole */ - if ( !S.IsNull() && ( S.ShapeType() == TopAbs_SOLID || S.ShapeType() == TopAbs_SHELL || S.ShapeType() == TopAbs_COMPOUND ) ) { - - if ( IO->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject)) ) { - Handle(GEOM_InteractiveObject) GIObject = Handle(GEOM_InteractiveObject)::DownCast( IO ); - myShapeIOR = GIObject->getIOR(); /* the Geom IOR string of selection */ - LineEditC1A1->setText(aString) ; - myShape = S ; - myOkShape = true ; - return; - } - - if ( IO->hasEntry() ) { - SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument(); - SALOMEDS::SObject_var obj = aStudy->FindObjectID( IO->getEntry() ); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeIOR_var anIOR; - if ( !obj->_is_nil() ) { - if (obj->FindAttribute(anAttr, "AttributeIOR")) { - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - myShapeIOR = anIOR->Value(); - myOkShape = true ; - myShape = S ; - LineEditC1A1->setText(aString) ; - return; - } - } - } - - } - return ; -} - - -//================================================================================= -// function : SetEditCurrentArgument() -// purpose : -//================================================================================= -void GeometryGUI_FillingHoleDlg::SetEditCurrentArgument() -{ - QPushButton* send = (QPushButton*)sender(); - switch (myConstructorId) - { - case 0: /* default constructor */ - { - if(send == SelectButtonC1A1) { - LineEditC1A1->setFocus() ; - myEditCurrentArgument = LineEditC1A1; - SelectionIntoArgument() ; - } - break; - } - } - return ; -} - - -//================================================================================= -// function : LineEditReturnPressed() -// purpose : -//================================================================================= -void GeometryGUI_FillingHoleDlg::LineEditReturnPressed() -{ - QLineEdit* send = (QLineEdit*)sender(); - if( send == LineEditC1A1 ) - myEditCurrentArgument = LineEditC1A1 ; - else - return ; - - /* User name of object input management */ - /* If successfull the selection is changed and signal emitted... */ - /* so SelectionIntoArgument() is automatically called. */ - const QString objectUserName = myEditCurrentArgument->text() ; - QWidget* thisWidget = (QWidget*)this ; - if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) { - myEditCurrentArgument->setText( objectUserName ) ; - } - return ; -} - - -//================================================================================= -// function : DeactivateActiveDialog() -// purpose : -//================================================================================= -void GeometryGUI_FillingHoleDlg::DeactivateActiveDialog() -{ - if ( GroupConstructors->isEnabled() ) { - - this->ResetStateOfDialog() ; - - disconnect( mySelection, 0, this, 0 ); - GroupConstructors->setEnabled(false) ; - GroupC1->setEnabled(false) ; - GroupButtons->setEnabled(false) ; - myGeomGUI->ResetState() ; - myGeomGUI->SetActiveDialogBox(0) ; - myGeomGUI->OnDisplayAll(true) ; - } - return ; -} - - -//================================================================================= -// function : ActivateThisDialog() -// purpose : -//================================================================================= -void GeometryGUI_FillingHoleDlg::ActivateThisDialog() -{ - /* Emit a signal to deactivate other active dialog */ - myGeomGUI->EmitSignalDeactivateDialog() ; - GroupConstructors->setEnabled(true) ; - GroupC1->setEnabled(true) ; - GroupButtons->setEnabled(true) ; - connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ; - return ; -} - - -//================================================================================= -// function : enterEvent() -// purpose : Mouse enter onto the dialog to activate it -//================================================================================= -void GeometryGUI_FillingHoleDlg::enterEvent(QEvent* e) -{ - if ( GroupConstructors->isEnabled() ) - return ; - ActivateThisDialog() ; - return ; -} - - -//================================================================================= -// function : closeEvent() -// purpose : -//================================================================================= -void GeometryGUI_FillingHoleDlg::closeEvent( QCloseEvent* e ) -{ - /* same than click on cancel button */ - this->ClickOnClose() ; - return ; -} - - -//================================================================================= -// function : ActivateUserSelection() -// purpose : Activate selection of faces when CheckBox1->isChecked()... -//================================================================================= -void GeometryGUI_FillingHoleDlg::ActivateUserSelection() -{ - - if( !this->myOkShape ) { - this->ResetStateOfDialog() ; - QAD_Application::getDesktop()->putInfo(tr("Select main shape first")) ; - return ; - } - - this->myOkSelectSubMode = CheckBox1->isChecked() ; - - if( this->myUseLocalContext ) { - myIC->CloseLocalContext(myLocalContextId) ; - this->myUseLocalContext = false ; - myGeomGUI->OnDisplayAll(true) ; - } - - if( myOkShape && myOkSelectSubMode ) { - /* local context is defined into the method : GEOM::EDGE sub selection */ - TopAbs_ShapeEnum aType = TopAbs_EDGE ; - myGeomGUI->PrepareSubShapeSelection( int(aType), this->myLocalContextId ) ; - myUseLocalContext = true ; - QAD_Application::getDesktop()->putInfo(tr("Select edges to fill an hole and click on Ok/Apply")) ; - } - return ; -} - - - -//================================================================================= -// function : ResetStateOfDialog() -// purpose : Completely reset the state of method including local context -//================================================================================= -void GeometryGUI_FillingHoleDlg::ResetStateOfDialog() -{ - this->myOkShape = false ; - this->myEditCurrentArgument->setText("") ; - - /* Select sub shapes mode not checked */ - this->myOkSelectSubMode = false ; - this->CheckBox1->setChecked( FALSE ); - - /* Close its local contact if opened */ - if( this->myUseLocalContext ) { - myIC->CloseLocalContext(this->myLocalContextId) ; - this->myUseLocalContext = false ; - myGeomGUI->OnDisplayAll(true) ; - } - return ; -} - - - diff --git a/src/RepairGUI/RepairGUI_FillingHoleDlg.h b/src/RepairGUI/RepairGUI_FillingHoleDlg.h deleted file mode 100644 index 8e0b758df..000000000 --- a/src/RepairGUI/RepairGUI_FillingHoleDlg.h +++ /dev/null @@ -1,133 +0,0 @@ -// 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 : GeometryGUI_FillingHoleDlg.h -// Author : Lucien PIGNOLONI -// Module : GEOM -// $Header$ - -#ifndef GEOMETRYGUI_FILLINGHOLE_H -#define GEOMETRYGUI_FILLINGHOLE_H - -#include "SALOME_Selection.h" -#include "GEOM_ShapeTypeFilter.hxx" - -#include -#include - -#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) - -class QVBoxLayout; -class QHBoxLayout; -class QGridLayout; -class QButtonGroup; -class QCheckBox; -class QGroupBox; -class QLabel; -class QLineEdit; -class QPushButton; -class QRadioButton; -class GeometryGUI; - - -//================================================================================= -// class : GeometryGUI_FillingHoleDlg -// purpose : -//================================================================================= -class GeometryGUI_FillingHoleDlg : public QDialog -{ - Q_OBJECT - -public : - GeometryGUI_FillingHoleDlg( QWidget* parent = 0, - const char* name = 0, - SALOME_Selection* Sel = 0, - Handle (AIS_InteractiveContext) ic = 0, - bool modal = FALSE, - WFlags fl = 0 ); - - ~GeometryGUI_FillingHoleDlg(); - -private : - - void Init( SALOME_Selection* Sel, Handle (AIS_InteractiveContext) ic ) ; - void closeEvent( QCloseEvent* e ) ; - void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ - void ResetStateOfDialog() ; - - /* Interactive and local context management see also : bool myUseLocalContext() */ - Handle (AIS_InteractiveContext) myIC ; /* Interactive context */ - Standard_Integer myLocalContextId ; /* identify a local context used by this method */ - bool myUseLocalContext ; /* true when this method as opened a local context */ - - GEOM::GEOM_Gen_var myGeom ; /* Current Geom object */ - GeometryGUI* myGeomGUI ; /* Current GeomGUI object */ - SALOME_Selection* mySelection ; /* User shape selection */ - - TopoDS_Shape myShape ; - char* myShapeIOR ; - bool myOkShape ; - - bool myOkSelectSubMode ; /* true = sub mode selection activated */ - QLineEdit* myEditCurrentArgument; /* Current LineEdit */ - int myConstructorId ; /* Current constructor id = radio button id */ - - QButtonGroup* GroupConstructors; - QRadioButton* Constructor1; - - QGroupBox* GroupC1; - QLabel* TextLabelC1A1; - QPushButton* SelectButtonC1A1; - QLineEdit* LineEditC1A1; - QCheckBox* CheckBox1; - - QGroupBox* GroupButtons; - QPushButton* buttonOk; - QPushButton* buttonApply; - QPushButton* buttonClose; - - -private slots: - - void ConstructorsClicked(int constructorId); - void ClickOnOk(); - void ClickOnApply() ; - void ClickOnClose(); - - void LineEditReturnPressed() ; - void SetEditCurrentArgument() ; - void SelectionIntoArgument() ; - void DeactivateActiveDialog() ; - void ActivateThisDialog() ; - void ActivateUserSelection() ; - -protected: - - QGridLayout* GeometryGUI_FillingHoleDlgLayout; - QGridLayout* GroupConstructorsLayout; - QGridLayout* GroupC1Layout; - QHBoxLayout* Layout2; - QGridLayout* GroupButtonsLayout; -}; - -#endif // GEOMETRYGUI_FILLINGHOLE_H diff --git a/src/RepairGUI/RepairGUI_FreeBoundDlg.cxx b/src/RepairGUI/RepairGUI_FreeBoundDlg.cxx new file mode 100644 index 000000000..ca9930705 --- /dev/null +++ b/src/RepairGUI/RepairGUI_FreeBoundDlg.cxx @@ -0,0 +1,289 @@ +// 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_FreeBoundDlg.cxx +// Author : Sergey LITONIN +// Module : GEOM +// $Header$ + +#include "RepairGUI_FreeBoundDlg.h" +#include "QAD_Desktop.h" +#include "GEOMBase.h" +#include "GeometryGUI.h" +#include "GEOM_Displayer.h" +#include "SALOMEGUI_QtCatchCorbaException.hxx" +#include "GEOMImpl_Types.hxx" +#include "SALOME_Prs.h" +#include "SALOME_Selection.h" + +#include +#include +#include +#include +#include + +#define SPACING 5 +#define MARGIN 10 + +/* + Calss : RepairGUI_FreeBoundDlg + Description : Dialog for displaying free boundaries of selected face, shell or solid +*/ + + +//================================================================================= +// function : RepairGUI_FreeBoundDlg +// purpose : Constructor +//================================================================================= +RepairGUI_FreeBoundDlg::RepairGUI_FreeBoundDlg( QWidget* theParen, SALOME_Selection* theSelection ) +: QDialog( theParen, "RepairGUI_FreeBoundDlg", false, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ) +{ + setCaption( tr( "CAPTION" ) ); + + QPixmap iconSelect( QAD_Desktop::getResourceManager()->loadPixmap( "GEOM",tr( "ICON_SELECT" ) ) ); + + QGroupBox* aMainGrp = new QGroupBox( 1, Qt::Horizontal, tr( "FREE_BOUND" ), this ); + + QGroupBox* aSelGrp = new QGroupBox( 1, Qt::Vertical, aMainGrp ); + aSelGrp->setInsideMargin( 0 ); + aSelGrp->setFrameStyle( QFrame::NoFrame ); + new QLabel( tr( "GEOM_OBJECT" ), aSelGrp ); + ( new QPushButton( aSelGrp ) )->setPixmap( iconSelect ); + myEdit = new QLineEdit( aSelGrp ); + myEdit->setReadOnly( true ); + myEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + + myClosedLbl = new QLabel( tr( "NUMBER_CLOSED" ), aMainGrp ); + myOpenLbl = new QLabel( tr( "NUMBER_OPEN" ), aMainGrp ); + + 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->addWidget( aFrame ); + + connect( aCloseBtn, SIGNAL( clicked() ), SLOT( onClose() ) ); + + Init( theSelection ); +} + +//================================================================================= +// function : ~RepairGUI_FreeBoundDlg +// purpose : Destructor +//================================================================================= +RepairGUI_FreeBoundDlg::~RepairGUI_FreeBoundDlg() +{ +} + +//================================================================================= +// function : onClose +// purpose : SLOT. Called when "close" button pressed. Close dialog +//================================================================================= +void RepairGUI_FreeBoundDlg::onClose() +{ + globalSelection(); + disconnect( mySelection, 0, this, 0 ); + GeometryGUI::GetGeomGUI()->SetActiveDialogBox( 0 ); + reject(); + erasePreview(); +} + +//================================================================================= +// function : onDeactivate +// purpose : Deactivate this dialog +//================================================================================= +void RepairGUI_FreeBoundDlg::onDeactivate() +{ + setEnabled(false); + globalSelection(); + disconnect( mySelection, 0, this, 0 ); + GeometryGUI::GetGeomGUI()->SetActiveDialogBox( 0 ); +} + +//================================================================================= +// function : onActivate +// purpose : Activate this dialog +//================================================================================= +void RepairGUI_FreeBoundDlg::onActivate() +{ + GeometryGUI::GetGeomGUI()->EmitSignalDeactivateDialog(); + setEnabled( true ); + GeometryGUI::GetGeomGUI()->SetActiveDialogBox( this ); + connect( mySelection, SIGNAL( currentSelectionChanged() ), SLOT ( onSelectionDone() ) ); + activateSelection(); + onSelectionDone(); +} + +//================================================================================= +// function : onSelectionDone +// purpose : SLOT. Called when selection changed. +//================================================================================= +void RepairGUI_FreeBoundDlg::onSelectionDone() +{ + if( mySelection->IObjectCount() != 1 ) + return; + + Standard_Boolean isOk = Standard_False; + GEOM::GEOM_Object_var anObj = + GEOMBase::ConvertIOinGEOMObject( mySelection->firstIObject(), isOk ); + + if ( !isOk || anObj->_is_nil() || !GEOMBase::IsShape( anObj ) ) + return; + else + { + myObj = anObj; + displayPreview( false, true, true, 3 ); + } + +} + +//================================================================================= +// function : Init +// purpose : Initialize dialog fields +//================================================================================= +void RepairGUI_FreeBoundDlg::Init( SALOME_Selection* theSel ) +{ + myNbClosed = myNbOpen = 0; + myObj = GEOM::GEOM_Object::_nil(); + mySelection = theSel; + + GeometryGUI* aGeomGUI = GeometryGUI::GetGeomGUI(); + connect( aGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), SLOT ( onDeactivate() ) ); + connect( mySelection, SIGNAL( currentSelectionChanged() ), SLOT ( onSelectionDone() ) ); + + activateSelection(); + onSelectionDone(); +} + +//================================================================================= +// function : enterEvent +// purpose : Activate dialog +//================================================================================= +void RepairGUI_FreeBoundDlg::enterEvent( QEvent* e ) +{ + onActivate(); +} + +//================================================================================= +// function : closeEvent +// purpose : Close dialog +//================================================================================= +void RepairGUI_FreeBoundDlg::closeEvent( QCloseEvent* e ) +{ + onClose(); +} + +//================================================================================= +// function : activateSelection +// purpose : activate selection of faces, shells, and solids +//================================================================================= +void RepairGUI_FreeBoundDlg::activateSelection() +{ + TColStd_MapOfInteger aMap; + aMap.Add( GEOM_FACE ); + aMap.Add( GEOM_SHELL ); + aMap.Add( GEOM_SOLID ); + aMap.Add( GEOM_COMPOUND ); + globalSelection( aMap ); +} + +//================================================================================= +// function : createOperation +// purpose : Create operation +//================================================================================= +GEOM::GEOM_IOperations_ptr RepairGUI_FreeBoundDlg::createOperation() +{ + return getGeomEngine()->GetIHealingOperations( getStudyId() ); +} + +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool RepairGUI_FreeBoundDlg::isValid( QString& msg ) +{ + return !myObj->_is_nil(); +} + +//================================================================================= +// function : execute +// purpose : Get free boundaries +//================================================================================= +bool RepairGUI_FreeBoundDlg::execute( ObjectList& objects ) +{ + if ( !IsPreview() || myObj->_is_nil() ) + return false; + + GEOM::ListOfGO_var aClosed, anOpen; + + bool result = GEOM::GEOM_IHealingOperations::_narrow( + getOperation() )->GetFreeBoundary( myObj, aClosed, anOpen ); + + if ( result ) + { + myNbClosed = aClosed->length(); + myNbOpen = anOpen->length(); + int i; + for ( i = 0; i < myNbClosed; i++ ) + objects.push_back( aClosed[i]._retn() ); + for ( i = 0; i < myNbOpen; i++ ) + objects.push_back( anOpen[i]._retn() ); + + myEdit->setText( GEOMBase::GetName( myObj ) ); + QString aLabelText = tr( "NUMBER_CLOSED" ) + QString( "%1" ).arg( myNbClosed ); + myClosedLbl->setText( aLabelText ); + aLabelText = tr( "NUMBER_OPEN" ) + QString( "%1" ).arg( myNbOpen ); + myOpenLbl->setText( aLabelText ); + } + else + { + myEdit->setText( GEOMBase::GetName( myObj ) ); + myClosedLbl->setText( tr( "NUMBER_CLOSED" ) ); + myOpenLbl->setText( tr( "NUMBER_OPEN" ) ); + } + + return result; +} + + + + + + + + + + + + + + diff --git a/src/RepairGUI/RepairGUI_FreeBoundDlg.h b/src/RepairGUI/RepairGUI_FreeBoundDlg.h new file mode 100644 index 000000000..ae7a6c4b7 --- /dev/null +++ b/src/RepairGUI/RepairGUI_FreeBoundDlg.h @@ -0,0 +1,93 @@ +// 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_FreeBoundDlg.h +// Author : Sergey LITONIN +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_WHATIS_H +#define DIALOGBOX_WHATIS_H + +#include +#include "GEOMBase_Helper.h" + +class SALOME_Prs; +class SALOME_Selection; +class QLineEdit; +class QLabel; +class GEOM_Displayer; + +//================================================================================= +// class : RepairGUI_FreeBoundDlg +// purpose : Dialog for displaying free boundaries of selected face, shell or solid +//================================================================================= +class RepairGUI_FreeBoundDlg : public QDialog, + public GEOMBase_Helper +{ + Q_OBJECT + +public: + RepairGUI_FreeBoundDlg( QWidget*, SALOME_Selection* ); + ~RepairGUI_FreeBoundDlg(); + +private slots: + + void onClose(); + void onDeactivate(); + void onActivate(); + void onSelectionDone(); + +private: + + void Init( SALOME_Selection* ); + void enterEvent( QEvent* e ); + void closeEvent( QCloseEvent* e ); + void activateSelection(); + + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool execute( ObjectList& objects ); + virtual bool isValid( QString& ); + +private: + + QLineEdit* myEdit; + QLabel* myClosedLbl; + QLabel* myOpenLbl; + GEOM::GEOM_Object_var myObj; + SALOME_Selection* mySelection; + int myNbClosed; + int myNbOpen; +}; + +#endif // DIALOGBOX_WHATIS_H + + + + + + + + + + diff --git a/src/RepairGUI/RepairGUI_GlueDlg.cxx b/src/RepairGUI/RepairGUI_GlueDlg.cxx new file mode 100644 index 000000000..11e585864 --- /dev/null +++ b/src/RepairGUI/RepairGUI_GlueDlg.cxx @@ -0,0 +1,297 @@ +// 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_GlueDlg.cxx +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +using namespace std; +#include "RepairGUI_GlueDlg.h" + +#include "QAD_Desktop.h" +#include "QAD_SpinBoxDbl.h" + +#include "OCCViewer_Viewer3d.h" +#include "DlgRef_1Sel_Ext.h" +#include "SALOME_ListIteratorOfListIO.hxx" + +#include "GEOMImpl_Types.hxx" + +#define DEFAULT_TOLERANCE_VALUE 1e-07 + + +//================================================================================= +// class : RepairGUI_GlueDlg() +// purpose : Constructs a RepairGUI_GlueDlg 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_GlueDlg::RepairGUI_GlueDlg(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_GLUE_FACES"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); + + setCaption(tr("GEOM_GLUE_TITLE")); + + /***************************************************************/ + GroupConstructors->setTitle(tr("GEOM_GLUE_TITLE")); + RadioButton1->setPixmap(image0); + RadioButton2->close(TRUE); + RadioButton3->close(TRUE); + + GroupPoints = new DlgRef_1Sel_Ext(this, "GroupPoints"); + GroupPoints->GroupBox1->setTitle(tr("GEOM_GLUE")); + GroupPoints->TextLabel1->setText(tr("GEOM_SELECTED_SHAPE")); + GroupPoints->PushButton1->setPixmap(image1); + GroupPoints->LineEdit1->setReadOnly( true ); + + Layout1->addWidget(GroupPoints, 2, 0); + + QGridLayout* aLay = new QGridLayout( 0, 2, 2, 0, 6, "aLay" ); + QLabel* aLbl1 = new QLabel( tr( "GEOM_TOLERANCE" ), GroupPoints->GroupBox1 ); + myTolEdt = new QAD_SpinBoxDbl( GroupPoints->GroupBox1, 0, 100, 1e-7, 10, 1e-10 ); + myTolEdt->setValue( DEFAULT_TOLERANCE_VALUE ); + + aLay->addWidget( aLbl1, 0, 0 ); + aLay->addWidget( myTolEdt, 0, 1 ); + + GroupPoints->getGroupBoxLayout()->addLayout( aLay, 3, 0 ); + /***************************************************************/ + + Init(); +} + + +//================================================================================= +// function : ~RepairGUI_GlueDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +RepairGUI_GlueDlg::~RepairGUI_GlueDlg() +{ +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void RepairGUI_GlueDlg::Init() +{ + /* init variables */ + myEditCurrentArgument = GroupPoints->LineEdit1; + + myObject = GEOM::GEOM_Object::_nil(); + + myGeomGUI->SetState( 0 ); + globalSelection( GEOM_COMPOUND ); + + /* 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(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + + initName( tr( "GLUE_NEW_OBJ_NAME" ) ); +} + + +//================================================================================= +// function : ClickOnOk() +// purpose : Same than click on apply but close this dialog. +//================================================================================= +void RepairGUI_GlueDlg::ClickOnOk() +{ + if ( ClickOnApply() ) + ClickOnCancel(); +} + + + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +bool RepairGUI_GlueDlg::ClickOnApply() +{ + if ( !onAccept() ) + return false; + + initName(); + + GroupPoints->LineEdit1->setText(""); + myObject = GEOM::GEOM_Object::_nil(); + + globalSelection( GEOM_COMPOUND ); + + return true; +} + + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void RepairGUI_GlueDlg::ClickOnCancel() +{ + GEOMBase_Skeleton::ClickOnCancel(); +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection +//================================================================================= +void RepairGUI_GlueDlg::SelectionIntoArgument() +{ + erasePreview(); + myEditCurrentArgument->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 ) + myEditCurrentArgument->setText( GEOMBase::GetName( myObject ) ); + } +} + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void RepairGUI_GlueDlg::SetEditCurrentArgument() +{ + const QObject* send = sender(); + if ( send == GroupPoints->PushButton1 ) { + myEditCurrentArgument->setFocus(); + SelectionIntoArgument(); + } +} + + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void RepairGUI_GlueDlg::LineEditReturnPressed() +{ + const QObject* send = sender(); + if( send == GroupPoints->LineEdit1 ) { + myEditCurrentArgument = GroupPoints->LineEdit1; + GEOMBase_Skeleton::LineEditReturnPressed(); + } +} + + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void RepairGUI_GlueDlg::DeactivateActiveDialog() +{ + myGeomGUI->SetState( -1 ); + GEOMBase_Skeleton::DeactivateActiveDialog(); +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void RepairGUI_GlueDlg::ActivateThisDialog() +{ + GEOMBase_Skeleton::ActivateThisDialog(); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + + GroupPoints->LineEdit1->setText(""); + myObject = GEOM::GEOM_Object::_nil(); + + myGeomGUI->SetState( 0 ); + globalSelection( GEOM_COMPOUND ); +} + + +//================================================================================= +// function : enterEvent() +// purpose : Mouse enter onto the dialog to activate it +//================================================================================= +void RepairGUI_GlueDlg::enterEvent(QEvent* e) +{ + if ( !GroupConstructors->isEnabled() ) + ActivateThisDialog(); +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void RepairGUI_GlueDlg::closeEvent(QCloseEvent* e) +{ + myGeomGUI->SetState( -1 ); + GEOMBase_Skeleton::closeEvent( e ); +} + +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr RepairGUI_GlueDlg::createOperation() +{ + return getGeomEngine()->GetIShapesOperations( getStudyId() ); +} + +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool RepairGUI_GlueDlg::isValid( QString& msg ) +{ + return !myObject->_is_nil() && ( IsPreview() || myTolEdt->value() > 0. ); +} + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool RepairGUI_GlueDlg::execute( ObjectList& objects ) +{ + bool aResult = false; + 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; +} diff --git a/src/RepairGUI/RepairGUI_GlueDlg.h b/src/RepairGUI/RepairGUI_GlueDlg.h new file mode 100644 index 000000000..41aba949a --- /dev/null +++ b/src/RepairGUI/RepairGUI_GlueDlg.h @@ -0,0 +1,79 @@ +// 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_GlueDlg.h +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_Glue_H +#define DIALOGBOX_Glue_H + +#include "GEOMBase_Skeleton.h" + +class QAD_SpinBoxDbl; +class DlgRef_1Sel_Ext; + +//================================================================================= +// class : RepairGUI_GlueDlg +// purpose : +//================================================================================= +class RepairGUI_GlueDlg : public GEOMBase_Skeleton +{ + Q_OBJECT + +public: + RepairGUI_GlueDlg(QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + ~RepairGUI_GlueDlg(); + +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& ); + virtual bool execute( ObjectList& objects ); + +private : + void Init(); + void enterEvent(QEvent* e); + void closeEvent(QCloseEvent* e); + void initSelection(); + + GEOM::GEOM_Object_var myObject; + + DlgRef_1Sel_Ext* GroupPoints; + QAD_SpinBoxDbl* myTolEdt; + +private slots: + void ClickOnOk(); + bool ClickOnApply(); + void ClickOnCancel(); + + void ActivateThisDialog(); + void DeactivateActiveDialog(); + + void LineEditReturnPressed(); + void SelectionIntoArgument(); + void SetEditCurrentArgument(); +}; + +#endif // DIALOGBOX_Glue_H diff --git a/src/RepairGUI/RepairGUI_OrientationDlg.cxx b/src/RepairGUI/RepairGUI_OrientationDlg.cxx deleted file mode 100644 index fd88ba8ab..000000000 --- a/src/RepairGUI/RepairGUI_OrientationDlg.cxx +++ /dev/null @@ -1,404 +0,0 @@ -// 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_OrientationDlg.cxx -// Author : Lucien PIGNOLONI -// Module : GEOM -// $Header$ - -#include "RepairGUI_OrientationDlg.h" - -#include -#include -#include -#include -#include -#include - -#include "utilities.h" - -using namespace std; - -//================================================================================= -// class : RepairGUI_OrientationDlg() -// purpose : Constructs a RepairGUI_OrientationDlg 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_OrientationDlg::RepairGUI_OrientationDlg(QWidget* parent, const char* name, RepairGUI* theRepairGUI, 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_ORIENTATION"))); - QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); - - setCaption(tr("GEOM_ORIENTATION_TITLE")); - - /***************************************************************/ - GroupConstructors->setTitle(tr("GEOM_ORIENTATION")); - RadioButton1->setPixmap(image0); - RadioButton2->close(TRUE); - RadioButton3->close(TRUE); - - GroupPoints = new DlgRef_1Sel1Spin1Check(this, "GroupPoints"); - GroupPoints->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); - GroupPoints->TextLabel1->setText(tr("GEOM_OBJECT")); - GroupPoints->TextLabel2->setText(tr("GEOM_VECTOR_LENGTH")); - GroupPoints->CheckButton1->setText(tr("GEOM_ORIENTATION_OPT")); - GroupPoints->PushButton1->setPixmap(image1); - - Layout1->addWidget(GroupPoints, 1, 0); - /***************************************************************/ - - /* Initialisations */ - myRepairGUI = theRepairGUI; - Init(); -} - - -//================================================================================= -// function : ~RepairGUI_OrientationDlg() -// purpose : Destroys the object and frees any allocated resources -//================================================================================= -RepairGUI_OrientationDlg::~RepairGUI_OrientationDlg() -{ - // no need to delete child widgets, Qt does it all for us -} - - -//================================================================================= -// function : Init() -// purpose : -//================================================================================= -void RepairGUI_OrientationDlg::Init() -{ - /* init variables */ - myEditCurrentArgument = GroupPoints->LineEdit1; - - myLength = 25.0; - myOkShape = false; - - double SpecificStep = 10; - /* min, max, step and decimals for spin boxes & initial values */ - GroupPoints->SpinBox_DX->RangeStepAndValidator(0.001, 999.999, SpecificStep, 3); - GroupPoints->SpinBox_DX->SetValue(myLength); - - /* signals and slots connections */ - connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); - connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); - - connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - - connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox_DX, SLOT(SetStep(double))); - - connect(GroupPoints->CheckButton1, SIGNAL(stateChanged(int)), this, SLOT(ReverseAngle(int))); - - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - - /* displays Dialog */ - GroupPoints->show(); - this->show(); - - return; -} - - -//================================================================================= -// function : ClickOnOk() -// purpose : -//================================================================================= -void RepairGUI_OrientationDlg::ClickOnOk() -{ - this->ClickOnApply(); - ClickOnCancel(); - return; -} - - -//================================================================================= -// function : ClickOnApply() -// purpose : -//================================================================================= -void RepairGUI_OrientationDlg::ClickOnApply() -{ - buttonApply->setFocus(); - QAD_Application::getDesktop()->putInfo(tr("")); - if (mySimulationTopoDs.IsNull()) - return; - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); - - if(myOkShape && GroupPoints->CheckButton1->isChecked()) { - myRepairGUI->MakeOrientationChangeAndDisplay(myGeomShape); - GroupPoints->CheckButton1->setChecked(FALSE); - } - return; -} - - -//================================================================================= -// function : SelectionIntoArgument() -// purpose : Called when selection as changed or other case -//================================================================================= -void RepairGUI_OrientationDlg::SelectionIntoArgument() -{ - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); - myEditCurrentArgument->setText(""); - QString aString = ""; /* name of selection */ - - int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString); - if(nbSel != 1) { - if(myEditCurrentArgument == GroupPoints->LineEdit1) - myOkShape = false; - return; - } - - // nbSel == 1 - TopoDS_Shape S; - Standard_Boolean testResult; - Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); - if(!myGeomBase->GetTopoFromSelection(mySelection, S)) - return; - - if(myEditCurrentArgument == GroupPoints->LineEdit1) { - myGeomShape = myGeomBase->ConvertIOinGEOMShape(IO, testResult); - if(!testResult) - return; - myEditCurrentArgument->setText(aString); - myShape = S; - myOkShape = true; - } - - if(myOkShape) - this->MakeOrientationSimulationAndDisplay(); - return; -} - - -//================================================================================= -// function : LineEditReturnPressed() -// purpose : -//================================================================================= -void RepairGUI_OrientationDlg::LineEditReturnPressed() -{ - QLineEdit* send = (QLineEdit*)sender(); - if(send == GroupPoints->LineEdit1) - myEditCurrentArgument = GroupPoints->LineEdit1; - else - return; - - GEOMBase_Skeleton::LineEditReturnPressed(); - return; -} - - -//================================================================================= -// function : SetEditCurrentArgument() -// purpose : -//================================================================================= -void RepairGUI_OrientationDlg::SetEditCurrentArgument() -{ - QPushButton* send = (QPushButton*)sender(); - - if(send == GroupPoints->PushButton1) { - GroupPoints->LineEdit1->setFocus(); - myEditCurrentArgument = GroupPoints->LineEdit1; - } - this->SelectionIntoArgument(); - - return; -} - - -//================================================================================= -// function : ActivateThisDialog() -// purpose : -//================================================================================= -void RepairGUI_OrientationDlg::ActivateThisDialog() -{ - GEOMBase_Skeleton::ActivateThisDialog(); - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - GroupPoints->LineEdit1->setFocus(); - myEditCurrentArgument = GroupPoints->LineEdit1; - if(!mySimulationTopoDs.IsNull()) - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - return; -} - - -//================================================================================= -// function : enterEvent() -// purpose : -//================================================================================= -void RepairGUI_OrientationDlg::enterEvent(QEvent* e) -{ - if (GroupConstructors->isEnabled()) - return; - this->ActivateThisDialog(); - return; -} - - -//================================================================================= -// function : ValueChangedInSpinBox() -// purpose : -//================================================================================= -void RepairGUI_OrientationDlg::ValueChangedInSpinBox(double newValue) -{ - myLength = newValue; - if(myOkShape) - this->MakeOrientationSimulationAndDisplay(); - return; -} - - -//================================================================================= -// function : ReverseOrientation() -// purpose : -//================================================================================= -void RepairGUI_OrientationDlg::ReverseAngle(int state) -{ - if(myOkShape) - this->MakeOrientationSimulationAndDisplay(); - return; -} - - -//================================================================================== -// function : MakeOrientationSimulationAndDisplay() -// purpose : Create 'aCompound1' and 'aCompound2' each contains edges oriented -// : respectively FORWARD and REVERSE for all faces of 'aTopoDS' -// : These edges represent normal vectors on faces of 'aTopoDS' -// : For a unique edge an arrow is displayed to show its orientation. -//================================================================================== -void RepairGUI_OrientationDlg::MakeOrientationSimulationAndDisplay() -{ - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); - - TopoDS_Compound aCompound1, aCompound2; - TopoDS_Compound NullComp; - BRep_Builder aBuilder1, aBuilder2; - aCompound1 = aCompound2 = NullComp; - aBuilder1.MakeCompound(aCompound1); - aBuilder2.MakeCompound(aCompound2); - - if(myShape.IsNull()) - return; - - try { - /* Case of an edge */ - if(myShape.ShapeType() == TopAbs_EDGE) { - /* Try to display a cone simulation shape to show direction of edge */ - TopoDS_Shape tmpShape = myShape ; - if(GroupPoints->CheckButton1->isChecked()) { - if(myShape.Orientation() == TopAbs_FORWARD) - tmpShape.Orientation(TopAbs_REVERSED); - else - tmpShape.Orientation(TopAbs_FORWARD); - } - if(myGeomBase->CreateArrowForLinearEdge(tmpShape, mySimulationTopoDs)) - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - return; - } - - gp_Pnt P1, P2 ; - gp_Vec V, V1, V2; - TopExp_Explorer ex(myShape, TopAbs_FACE); - int test = 0; - while(ex.More()) { - const TopoDS_Face& F = TopoDS::Face(ex.Current()); - /* find the center of the minmax */ - BRepAdaptor_Surface SF(F); - Standard_Real u, v, x; - - u = SF.FirstUParameter(); - x = SF.LastUParameter(); - if(Precision::IsInfinite(u)) { - if(Precision::IsInfinite(x)) - u = 0.0; - else - u = x; - } - else if(!Precision::IsInfinite(x)) - u = (u+x) / 2.0; - - v = SF.FirstVParameter(); - x = SF.LastVParameter(); - if(Precision::IsInfinite(v)) { - if(Precision::IsInfinite(x)) - v = 0.0; - else - v = x; - } - else if(!Precision::IsInfinite(x)) - v = (v+x) / 2.0; - - SF.D1(u, v, P1, V1, V2); - V = V1.Crossed(V2); - x = V.Magnitude(); - if(x > 1.e-10) - V.Multiply(myLength/x); - else { - V.SetCoord(myLength/2.0, 0.0, 0.0); - MESSAGE ("Null normal in Orientation " << endl); - } - - P2 = P1; - /* test orientation of each face and displays forward (aCompound1) */ - if(F.Orientation() == TopAbs_FORWARD) - P2.Translate(V); - else - P2.Translate(-V); - BRepBuilderAPI_MakeEdge anEdge(P1, P2); - aBuilder1.Add(aCompound1, anEdge); - - P2 = P1; - /* test orientation of each face and displays forward (aCompound2) */ - if(F.Orientation() == TopAbs_FORWARD) - P2.Translate(-V); - else - P2.Translate(V); - anEdge = BRepBuilderAPI_MakeEdge(P1, P2); - aBuilder2.Add(aCompound2, anEdge); - - ex.Next(); - test++; - } - - /* display simulation compounds */ - if(test > 0 && GroupPoints->CheckButton1->isChecked()) - mySimulationTopoDs = aCompound1; - else if(test > 0 && !GroupPoints->CheckButton1->isChecked()) - mySimulationTopoDs = aCompound2; - - if(!mySimulationTopoDs.IsNull()) - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - } - catch(Standard_Failure) - MESSAGE("Exception catched in MakeOrientationSimulationAndDisplay"); - return; -} diff --git a/src/RepairGUI/RepairGUI_OrientationDlg.h b/src/RepairGUI/RepairGUI_OrientationDlg.h deleted file mode 100644 index 49f54a5da..000000000 --- a/src/RepairGUI/RepairGUI_OrientationDlg.h +++ /dev/null @@ -1,75 +0,0 @@ -// 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_OrientationDlg.h -// Author : Lucien PIGNOLONI -// Module : GEOM -// $Header$ - -#ifndef DIALOGBOX_ORIENTATION_H -#define DIALOGBOX_ORIENTATION_H - -#include "GEOMBase_Skeleton.h" -#include "DlgRef_1Sel1Spin1Check.h" - -#include "RepairGUI.h" - -//================================================================================= -// class : DialogBox_ORIENTATION -// purpose : -//================================================================================= -class RepairGUI_OrientationDlg : public GEOMBase_Skeleton -{ - Q_OBJECT - -public: - RepairGUI_OrientationDlg(QWidget* parent = 0, const char* name = 0, RepairGUI* theRepairGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); - ~RepairGUI_OrientationDlg(); - -private : - void Init(); - void enterEvent(QEvent* e); - void MakeOrientationSimulationAndDisplay(); - - RepairGUI* myRepairGUI; - - GEOM::GEOM_Shape_var myGeomShape; /* is myShape */ - TopoDS_Shape myShape; /* topology used */ - Standard_Real myLength; /* to simulate normal vector */ - bool myOkShape; - - DlgRef_1Sel1Spin1Check* GroupPoints; - -private slots: - void ClickOnOk(); - void ClickOnApply(); - void ActivateThisDialog(); - void LineEditReturnPressed(); - void SelectionIntoArgument(); - void SetEditCurrentArgument(); - void ReverseAngle(int state); - void ValueChangedInSpinBox(double newValue); - -}; - -#endif // DIALOGBOX_ORIENTATION_H diff --git a/src/RepairGUI/RepairGUI_RemoveHolesDlg.cxx b/src/RepairGUI/RepairGUI_RemoveHolesDlg.cxx new file mode 100644 index 000000000..8572c9fbc --- /dev/null +++ b/src/RepairGUI/RepairGUI_RemoveHolesDlg.cxx @@ -0,0 +1,446 @@ +// 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_RemoveHolesDlg.cxx +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +using namespace std; +#include "RepairGUI_RemoveHolesDlg.h" + +#include "QAD_RightFrame.h" +#include "QAD_Desktop.h" +#include "QAD_MessageBox.h" + +#include "GEOM_Displayer.h" +#include "OCCViewer_Viewer3d.h" +#include "SALOME_ListIteratorOfListIO.hxx" + +#include "GEOMImpl_Types.hxx" + +#include + + +//================================================================================= +// class : RepairGUI_RemoveHolesDlg() +// purpose : Constructs a RepairGUI_RemoveHolesDlg 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_RemoveHolesDlg::RepairGUI_RemoveHolesDlg(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_SUPPRESS_HOLES"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); + + setCaption(tr("GEOM_REMOVE_HOLES_TITLE")); + + /***************************************************************/ + GroupConstructors->setTitle(tr("GEOM_REMOVE_HOLES_TITLE")); + RadioButton1->setPixmap(image0); + RadioButton2->close(TRUE); + RadioButton3->close(TRUE); + + GroupPoints = new DlgRef_1Sel_Ext(this, "GroupPoints"); + GroupPoints->GroupBox1->setTitle(tr("GEOM_HOLES")); + GroupPoints->TextLabel1->setText(tr("GEOM_SELECTED_SHAPE")); + GroupPoints->PushButton1->setPixmap(image1); + GroupPoints->LineEdit1->setReadOnly( true ); + + Layout1->addWidget(GroupPoints, 2, 0); + + myAllChk = new QCheckBox( tr( "GEOM_REMOVE_ALL_HOLES" ), GroupPoints->GroupBox1 ); + + QGridLayout* aSelectWiresLay = new QGridLayout( 0, 1, 1, 0, 6, "aSelectWiresLay"); + + mySelectWiresBtn = new QPushButton( GroupPoints->GroupBox1, "mySelectWiresBtn" ); + mySelectWiresBtn->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, mySelectWiresBtn->sizePolicy().hasHeightForWidth() ) ); + mySelectWiresBtn->setText( trUtf8( "" ) ); + mySelectWiresBtn->setPixmap(image1); + + mySelectWiresEdt = new QLineEdit( GroupPoints->GroupBox1, "mySelectWiresEdt" ); + mySelectWiresEdt->setReadOnly( true ); + + mySelectWiresLbl = new QLabel( tr( "GEOM_WIRES_TO_REMOVE" ), GroupPoints->GroupBox1, "TextLabel1" ); + mySelectWiresLbl->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, mySelectWiresLbl->sizePolicy().hasHeightForWidth() ) ); + + aSelectWiresLay->addWidget( mySelectWiresLbl, 0, 0 ); + aSelectWiresLay->addWidget( mySelectWiresBtn, 0, 1 ); + aSelectWiresLay->addWidget( mySelectWiresEdt, 0, 2 ); + QSpacerItem* spacer = new QSpacerItem( 0, 16, QSizePolicy::Minimum, QSizePolicy::Expanding ); + aSelectWiresLay->addItem( spacer, 1, 2 ); + + QGridLayout* aDetectLay = new QGridLayout( 0, 1, 1, 0, 6, "aDetectLay" ); + myFreeBoundBtn = new QPushButton( tr( "GEOM_DETECT" ), GroupPoints->GroupBox1 ); + QLabel* aLbl = new QLabel( tr( "GEOM_FREE_BOUNDARIES" ), GroupPoints->GroupBox1 ); + aDetectLay->addWidget( aLbl, 0, 0 ); + aDetectLay->addWidget( myFreeBoundBtn, 0, 1 ); + + GroupPoints->getGroupBoxLayout()->addMultiCellWidget( myAllChk, 1, 1, 0, 2 ); + GroupPoints->getGroupBoxLayout()->addLayout( aSelectWiresLay, 2, 0 ); + GroupPoints->getGroupBoxLayout()->addLayout( aDetectLay, 3, 0 ); + /***************************************************************/ + + Init(); +} + + +//================================================================================= +// function : ~RepairGUI_RemoveHolesDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +RepairGUI_RemoveHolesDlg::~RepairGUI_RemoveHolesDlg() +{ +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void RepairGUI_RemoveHolesDlg::Init() +{ + /* init variables */ + myEditCurrentArgument = GroupPoints->LineEdit1; + + myObject = GEOM::GEOM_Object::_nil(); + myWiresInd = new GEOM::short_array(); + myWiresInd->length( 0 ); + + myGeomGUI->SetState( 0 ); + initSelection(); + + myClosed = -1; + myOpen = -1; + + /* 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(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(mySelectWiresBtn, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(mySelectWiresEdt, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + + connect( myAllChk, SIGNAL( clicked() ), this, SLOT( onRemoveAllClicked() ) ); + connect( myFreeBoundBtn, SIGNAL(clicked()), this, SLOT(onDetect()) ); + + initName( tr( "REMOVE_HOLES_NEW_OBJ_NAME" ) ); +} + + +//================================================================================= +// function : ClickOnOk() +// purpose : Same than click on apply but close this dialog. +//================================================================================= +void RepairGUI_RemoveHolesDlg::ClickOnOk() +{ + if ( ClickOnApply() ) + ClickOnCancel(); +} + + + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +bool RepairGUI_RemoveHolesDlg::ClickOnApply() +{ + if ( !onAccept() ) + return false; + + initName(); + + myEditCurrentArgument = GroupPoints->LineEdit1; + myEditCurrentArgument->setText(""); + mySelectWiresEdt->setText(""); + myObject = GEOM::GEOM_Object::_nil(); + myWiresInd->length( 0 ); + + initSelection(); + + return true; +} + + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void RepairGUI_RemoveHolesDlg::ClickOnCancel() +{ + GEOMBase_Skeleton::ClickOnCancel(); +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection +//================================================================================= +void RepairGUI_RemoveHolesDlg::SelectionIntoArgument() +{ + erasePreview(); + myEditCurrentArgument->setText(""); + if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) myObject = GEOM::GEOM_Object::_nil(); + else if ( myEditCurrentArgument == mySelectWiresEdt ) myWiresInd->length( 0 ); + + if ( mySelection->IObjectCount() == 1 ) + { + Handle(SALOME_InteractiveObject) anIO = mySelection->firstIObject(); + + if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) // face selection + { + Standard_Boolean aRes; + myObject = GEOMBase::ConvertIOinGEOMObject( anIO, aRes ); + if ( aRes && GEOMBase::IsShape( myObject ) ) + myEditCurrentArgument->setText( GEOMBase::GetName( myObject ) ); + else + myObject = GEOM::GEOM_Object::_nil(); + } + else if ( myEditCurrentArgument == mySelectWiresEdt && !myAllChk->isChecked() ) + { + TColStd_IndexedMapOfInteger aMap; + mySelection->GetIndex( anIO, aMap ); + const int n = aMap.Extent(); + myWiresInd->length( n ); + for ( int i = 1; i <= n; i++ ) + myWiresInd[i-1] = aMap( i ); + if ( n ) + myEditCurrentArgument->setText( QString::number( n ) + "_" + tr( "GEOM_WIRE" ) + tr( "_S_" ) ); + } + } +} + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void RepairGUI_RemoveHolesDlg::SetEditCurrentArgument() +{ + const QObject* send = sender(); + if ( send == GroupPoints->PushButton1 ) + myEditCurrentArgument = GroupPoints->LineEdit1; + else if ( send == mySelectWiresBtn && !myObject->_is_nil() ) + myEditCurrentArgument = mySelectWiresEdt; + if ( myEditCurrentArgument ) + { + initSelection(); + myEditCurrentArgument->setFocus(); + SelectionIntoArgument(); + } +} + + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void RepairGUI_RemoveHolesDlg::LineEditReturnPressed() +{ + const QObject* send = sender(); + if( send == GroupPoints->LineEdit1 || send == mySelectWiresEdt ) + { + myEditCurrentArgument = (QLineEdit*)send; + GEOMBase_Skeleton::LineEditReturnPressed(); + } +} + + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void RepairGUI_RemoveHolesDlg::DeactivateActiveDialog() +{ + myGeomGUI->SetState( -1 ); + GEOMBase_Skeleton::DeactivateActiveDialog(); +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void RepairGUI_RemoveHolesDlg::ActivateThisDialog() +{ + GEOMBase_Skeleton::ActivateThisDialog(); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + + myEditCurrentArgument = GroupPoints->LineEdit1; + myEditCurrentArgument->setText(""); + mySelectWiresEdt->setText(""); + myObject = GEOM::GEOM_Object::_nil(); + myWiresInd->length( 0 ); + + myClosed = -1; + myOpen = -1; + + myGeomGUI->SetState( 0 ); + initSelection(); +} + + +//================================================================================= +// function : enterEvent() +// purpose : Mouse enter onto the dialog to activate it +//================================================================================= +void RepairGUI_RemoveHolesDlg::enterEvent(QEvent* e) +{ + if ( !GroupConstructors->isEnabled() ) + ActivateThisDialog(); +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void RepairGUI_RemoveHolesDlg::closeEvent(QCloseEvent* e) +{ + myGeomGUI->SetState( -1 ); + GEOMBase_Skeleton::closeEvent( e ); +} + +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr RepairGUI_RemoveHolesDlg::createOperation() +{ + return getGeomEngine()->GetIHealingOperations( getStudyId() ); +} + +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool RepairGUI_RemoveHolesDlg::isValid( QString& msg ) +{ + myClosed = -1; + return !myObject->_is_nil() && ( IsPreview() || myAllChk->isChecked() || myWiresInd->length() ); +} + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool RepairGUI_RemoveHolesDlg::execute( ObjectList& objects ) +{ + bool aResult = false; + if ( IsPreview() ) // called from onDetect(): detect free boundary edges, highlight them (add to objects), display message dialog + { + GEOM::ListOfGO_var aClosed, anOpen; + + aResult = GEOM::GEOM_IHealingOperations::_narrow( getOperation() )->GetFreeBoundary( myObject, aClosed, anOpen ); + + if ( aResult ) + { + myClosed = aClosed->length(); + myOpen = anOpen->length(); + int i; + for ( i = 0; i < myClosed; i++ ) + objects.push_back( aClosed[i]._retn() ); + for ( i = 0; i < myOpen; i++ ) + objects.push_back( anOpen[i]._retn() ); + } + else + myClosed = -1; + } + else + { + GEOM::GEOM_Object_var anObj = GEOM::GEOM_IHealingOperations::_narrow( getOperation() )->FillHoles( myObject, myWiresInd ); + aResult = !anObj->_is_nil(); + if ( aResult ) + objects.push_back( anObj._retn() ); + } + + return aResult; +} + +//================================================================================= +// function : onRemoveAllClicked +// purpose : +//================================================================================= +void RepairGUI_RemoveHolesDlg::onRemoveAllClicked() +{ + bool b = myAllChk->isOn(); + mySelectWiresLbl->setEnabled( !b ); + mySelectWiresBtn->setEnabled( !b ); + mySelectWiresEdt->setEnabled( !b ); + if ( b ) + { + mySelectWiresEdt->setText( "" ); + myWiresInd->length( 0 ); + } +} + +//================================================================================= +// function : initSelection +// purpose : +//================================================================================= +void RepairGUI_RemoveHolesDlg::initSelection() +{ + if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) + { + TColStd_MapOfInteger aTypes; + aTypes.Add( GEOM_COMPOUND ); + aTypes.Add( GEOM_SOLID ); + aTypes.Add( GEOM_SHELL ); + aTypes.Add( GEOM_FACE ); + + globalSelection( aTypes ); + } + else if ( myEditCurrentArgument == mySelectWiresEdt ) + { + localSelection( myObject, TopAbs_EDGE ); + localSelection( myObject, TopAbs_WIRE ); + } +} + + +//================================================================================= +// function : onDetect +// purpose : +//================================================================================= +void RepairGUI_RemoveHolesDlg::onDetect() +{ + displayPreview( false, true, true, 3 ); + + // field myClosed,myOpen is initialized in execute() method, called by displayPreview(). + QString msg; + if ( myClosed != -1 ) + msg = tr( "GEOM_FREE_BOUNDS_MSG" ).arg( myClosed + myOpen ).arg( myClosed ).arg( myOpen ); + else + msg = tr( "GEOM_FREE_BOUNDS_ERROR" ); + QAD_MessageBox::info1( this, tr( "GEOM_FREE_BOUNDS_TLT" ), msg, "Close" ); +} + diff --git a/src/RepairGUI/RepairGUI_RemoveHolesDlg.h b/src/RepairGUI/RepairGUI_RemoveHolesDlg.h new file mode 100644 index 000000000..12c85fdfd --- /dev/null +++ b/src/RepairGUI/RepairGUI_RemoveHolesDlg.h @@ -0,0 +1,95 @@ +// 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_RemoveHolesDlg.h +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_RemoveHoles_H +#define DIALOGBOX_RemoveHoles_H + +#include "GEOMBase_Skeleton.h" +#include "DlgRef_1Sel_Ext.h" + +#include + +#include +#include +#include +#include + +//================================================================================= +// class : RepairGUI_RemoveHolesDlg +// purpose : +//================================================================================= +class RepairGUI_RemoveHolesDlg : public GEOMBase_Skeleton +{ + Q_OBJECT + +public: + RepairGUI_RemoveHolesDlg(QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + ~RepairGUI_RemoveHolesDlg(); + +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& ); + virtual bool execute( ObjectList& objects ); + +private : + void Init(); + void enterEvent(QEvent* e); + void closeEvent(QCloseEvent* e); + void initSelection(); + + GEOM::GEOM_Object_var myObject; + GEOM::short_array_var myWiresInd; + + DlgRef_1Sel_Ext* GroupPoints; + QCheckBox* myAllChk; + QLabel* mySelectWiresLbl; + QPushButton* mySelectWiresBtn; + QLineEdit* mySelectWiresEdt; + QPushButton* myFreeBoundBtn; + + int myClosed; // number of free closed boundaries detected. calculated in execute(), used in onDetect(). + int myOpen; // number of free open boundaries detected. calculated in execute(), used in onDetect(). + +private slots: + void ClickOnOk(); + bool ClickOnApply(); + void ClickOnCancel(); + + void ActivateThisDialog(); + void DeactivateActiveDialog(); + + void LineEditReturnPressed(); + void SelectionIntoArgument(); + void SetEditCurrentArgument(); + + void onRemoveAllClicked(); + void onDetect(); +}; + +#endif // DIALOGBOX_RemoveHoles_H diff --git a/src/RepairGUI/RepairGUI_RemoveIntWiresDlg.cxx b/src/RepairGUI/RepairGUI_RemoveIntWiresDlg.cxx new file mode 100644 index 000000000..e865a125d --- /dev/null +++ b/src/RepairGUI/RepairGUI_RemoveIntWiresDlg.cxx @@ -0,0 +1,388 @@ +// 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_RemoveIntWiresDlg.cxx +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +using namespace std; +#include "RepairGUI_RemoveIntWiresDlg.h" + +#include "QAD_RightFrame.h" +#include "QAD_Desktop.h" +#include "OCCViewer_Viewer3d.h" +#include "SALOME_ListIteratorOfListIO.hxx" + +#include "GEOMImpl_Types.hxx" + +#include + + +//================================================================================= +// class : RepairGUI_RemoveIntWiresDlg() +// purpose : Constructs a RepairGUI_RemoveIntWiresDlg 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_RemoveIntWiresDlg::RepairGUI_RemoveIntWiresDlg(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_SUPPRESS_INT_WIRES"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); + + setCaption(tr("GEOM_REMOVE_INTERNAL_WIRES_TITLE")); + + /***************************************************************/ + GroupConstructors->setTitle(tr("GEOM_REMOVE_INTERNAL_WIRES_TITLE")); + RadioButton1->setPixmap(image0); + RadioButton2->close(TRUE); + RadioButton3->close(TRUE); + + GroupPoints = new DlgRef_1Sel_Ext(this, "GroupPoints"); + GroupPoints->GroupBox1->setTitle(tr("GEOM_INTERNAL_WIRES")); + GroupPoints->TextLabel1->setText(tr("GEOM_SELECTED_FACE")); + GroupPoints->PushButton1->setPixmap(image1); + GroupPoints->LineEdit1->setReadOnly( true ); + + Layout1->addWidget(GroupPoints, 2, 0); + + myAllChk = new QCheckBox( tr( "GEOM_REMOVE_ALL_INT_WIRES" ), GroupPoints->GroupBox1 ); + + QGridLayout* aSelectWiresLay = new QGridLayout( 0, 1, 1, 0, 6, "aSelectWiresLay"); + + mySelectWiresBtn = new QPushButton( GroupPoints->GroupBox1, "mySelectWiresBtn" ); + mySelectWiresBtn->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, mySelectWiresBtn->sizePolicy().hasHeightForWidth() ) ); + mySelectWiresBtn->setText( trUtf8( "" ) ); + mySelectWiresBtn->setPixmap(image1); + + mySelectWiresEdt = new QLineEdit( GroupPoints->GroupBox1, "mySelectWiresEdt" ); + mySelectWiresEdt->setReadOnly( true ); + + mySelectWiresLbl = new QLabel( tr( "GEOM_WIRES_TO_REMOVE" ), GroupPoints->GroupBox1, "TextLabel1" ); + mySelectWiresLbl->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, mySelectWiresLbl->sizePolicy().hasHeightForWidth() ) ); + + aSelectWiresLay->addWidget( mySelectWiresLbl, 0, 0 ); + aSelectWiresLay->addWidget( mySelectWiresBtn, 0, 1 ); + aSelectWiresLay->addWidget( mySelectWiresEdt, 0, 2 ); + QSpacerItem* spacer = new QSpacerItem( 0, 16, QSizePolicy::Minimum, QSizePolicy::Expanding ); + aSelectWiresLay->addItem( spacer, 1, 2 ); + + GroupPoints->getGroupBoxLayout()->addMultiCellWidget( myAllChk, 1, 1, 0, 2 ); + GroupPoints->getGroupBoxLayout()->addLayout( aSelectWiresLay, 2, 0 ); + /***************************************************************/ + + Init(); +} + + +//================================================================================= +// function : ~RepairGUI_RemoveIntWiresDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +RepairGUI_RemoveIntWiresDlg::~RepairGUI_RemoveIntWiresDlg() +{ +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void RepairGUI_RemoveIntWiresDlg::Init() +{ + /* init variables */ + myEditCurrentArgument = GroupPoints->LineEdit1; + + myObject = GEOM::GEOM_Object::_nil(); + myWiresInd = new GEOM::short_array(); + myWiresInd->length( 0 ); + + myGeomGUI->SetState( 0 ); + initSelection(); + + /* 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(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(mySelectWiresBtn, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(mySelectWiresEdt, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + + connect( myAllChk, SIGNAL( clicked() ), this, SLOT( onRemoveAllClicked() ) ); + + initName( tr( "REMOVE_INT_WIRES_NEW_OBJ_NAME" ) ); +} + + +//================================================================================= +// function : ClickOnOk() +// purpose : Same than click on apply but close this dialog. +//================================================================================= +void RepairGUI_RemoveIntWiresDlg::ClickOnOk() +{ + if ( ClickOnApply() ) + ClickOnCancel(); +} + + + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +bool RepairGUI_RemoveIntWiresDlg::ClickOnApply() +{ + if ( !onAccept() ) + return false; + + initName(); + + myEditCurrentArgument = GroupPoints->LineEdit1; + myEditCurrentArgument->setText(""); + mySelectWiresEdt->setText(""); + myObject = GEOM::GEOM_Object::_nil(); + myWiresInd->length( 0 ); + + initSelection(); + + return true; +} + + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void RepairGUI_RemoveIntWiresDlg::ClickOnCancel() +{ + GEOMBase_Skeleton::ClickOnCancel(); +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection +//================================================================================= +void RepairGUI_RemoveIntWiresDlg::SelectionIntoArgument() +{ + myEditCurrentArgument->setText(""); + if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) myObject = GEOM::GEOM_Object::_nil(); + else if ( myEditCurrentArgument == mySelectWiresEdt ) myWiresInd->length( 0 ); + + if ( mySelection->IObjectCount() == 1 ) + { + Handle(SALOME_InteractiveObject) anIO = mySelection->firstIObject(); + + if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) // face selection + { + Standard_Boolean aRes; + myObject = GEOMBase::ConvertIOinGEOMObject( anIO, aRes ); + if ( aRes && GEOMBase::IsShape( myObject ) ) + myEditCurrentArgument->setText( GEOMBase::GetName( myObject ) ); + else + myObject = GEOM::GEOM_Object::_nil(); + } + else if ( myEditCurrentArgument == mySelectWiresEdt && !myAllChk->isChecked() ) + { + TColStd_IndexedMapOfInteger aMap; + mySelection->GetIndex( anIO, aMap ); + const int n = aMap.Extent(); + myWiresInd->length( n ); + for ( int i = 1; i <= n; i++ ) + myWiresInd[i-1] = aMap( i ); + if ( n ) + myEditCurrentArgument->setText( QString::number( n ) + "_" + tr( "GEOM_WIRE" ) + tr( "_S_" ) ); + } + } +} + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void RepairGUI_RemoveIntWiresDlg::SetEditCurrentArgument() +{ + const QObject* send = sender(); + if ( send == GroupPoints->PushButton1 ) + myEditCurrentArgument = GroupPoints->LineEdit1; + else if ( send == mySelectWiresBtn && !myObject->_is_nil() ) + myEditCurrentArgument = mySelectWiresEdt; + + if ( myEditCurrentArgument ) + { + initSelection(); + myEditCurrentArgument->setFocus(); + SelectionIntoArgument(); + } +} + + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void RepairGUI_RemoveIntWiresDlg::LineEditReturnPressed() +{ + const QObject* send = sender(); + if( send == GroupPoints->LineEdit1 || send == mySelectWiresEdt ) + { + myEditCurrentArgument = (QLineEdit*)send; + GEOMBase_Skeleton::LineEditReturnPressed(); + } +} + + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void RepairGUI_RemoveIntWiresDlg::DeactivateActiveDialog() +{ + myGeomGUI->SetState( -1 ); + GEOMBase_Skeleton::DeactivateActiveDialog(); +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void RepairGUI_RemoveIntWiresDlg::ActivateThisDialog() +{ + GEOMBase_Skeleton::ActivateThisDialog(); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + + myEditCurrentArgument = GroupPoints->LineEdit1; + myEditCurrentArgument->setText(""); + mySelectWiresEdt->setText(""); + myObject = GEOM::GEOM_Object::_nil(); + myWiresInd->length( 0 ); + + myGeomGUI->SetState( 0 ); + initSelection(); +} + + +//================================================================================= +// function : enterEvent() +// purpose : Mouse enter onto the dialog to activate it +//================================================================================= +void RepairGUI_RemoveIntWiresDlg::enterEvent(QEvent* e) +{ + if ( !GroupConstructors->isEnabled() ) + ActivateThisDialog(); +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void RepairGUI_RemoveIntWiresDlg::closeEvent(QCloseEvent* e) +{ + myGeomGUI->SetState( -1 ); + GEOMBase_Skeleton::closeEvent( e ); +} + +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr RepairGUI_RemoveIntWiresDlg::createOperation() +{ + return getGeomEngine()->GetIHealingOperations( getStudyId() ); +} + +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool RepairGUI_RemoveIntWiresDlg::isValid( QString& msg ) +{ + return !myObject->_is_nil() && ( myAllChk->isChecked() || myWiresInd->length() ); +} + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool RepairGUI_RemoveIntWiresDlg::execute( ObjectList& objects ) +{ + GEOM::GEOM_Object_var anObj = GEOM::GEOM_IHealingOperations::_narrow( getOperation() )->RemoveIntWires( myObject, myWiresInd ); + bool aResult = !anObj->_is_nil(); + if ( aResult ) + objects.push_back( anObj._retn() ); + + return aResult; +} + +//================================================================================= +// function : onRemoveAllClicked +// purpose : +//================================================================================= +void RepairGUI_RemoveIntWiresDlg::onRemoveAllClicked() +{ + bool b = myAllChk->isOn(); + mySelectWiresLbl->setEnabled( !b ); + mySelectWiresBtn->setEnabled( !b ); + mySelectWiresEdt->setEnabled( !b ); + if ( b ) + { + mySelectWiresEdt->setText( "" ); + myWiresInd->length( 0 ); + } +} + +//================================================================================= +// function : initSelection +// purpose : +//================================================================================= +void RepairGUI_RemoveIntWiresDlg::initSelection() +{ + if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) + { + TColStd_MapOfInteger aTypes; + aTypes.Add( GEOM_COMPOUND ); + aTypes.Add( GEOM_SOLID ); + aTypes.Add( GEOM_SHELL ); + aTypes.Add( GEOM_FACE ); + + globalSelection( aTypes ); + } + else if ( myEditCurrentArgument == mySelectWiresEdt ) + { + //localSelection( myObject, TopAbs_EDGE ); + localSelection( myObject, TopAbs_WIRE ); + } +} + + diff --git a/src/RepairGUI/RepairGUI_RemoveIntWiresDlg.h b/src/RepairGUI/RepairGUI_RemoveIntWiresDlg.h new file mode 100644 index 000000000..4880e97a8 --- /dev/null +++ b/src/RepairGUI/RepairGUI_RemoveIntWiresDlg.h @@ -0,0 +1,90 @@ +// 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_RemoveIntWiresDlg.h +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_RemoveIntWires_H +#define DIALOGBOX_RemoveIntWires_H + +#include "GEOMBase_Skeleton.h" +#include "DlgRef_1Sel_Ext.h" + +#include + +#include +#include +#include +#include + +//================================================================================= +// class : RepairGUI_RemoveIntWiresDlg +// purpose : +//================================================================================= +class RepairGUI_RemoveIntWiresDlg : public GEOMBase_Skeleton +{ + Q_OBJECT + +public: + RepairGUI_RemoveIntWiresDlg(QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + ~RepairGUI_RemoveIntWiresDlg(); + +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& ); + virtual bool execute( ObjectList& objects ); + +private : + void Init(); + void enterEvent(QEvent* e); + void closeEvent(QCloseEvent* e); + void initSelection(); + + GEOM::GEOM_Object_var myObject; + GEOM::short_array_var myWiresInd; + + DlgRef_1Sel_Ext* GroupPoints; + QCheckBox* myAllChk; + QLabel* mySelectWiresLbl; + QPushButton* mySelectWiresBtn; + QLineEdit* mySelectWiresEdt; + +private slots: + void ClickOnOk(); + bool ClickOnApply(); + void ClickOnCancel(); + + void ActivateThisDialog(); + void DeactivateActiveDialog(); + + void LineEditReturnPressed(); + void SelectionIntoArgument(); + void SetEditCurrentArgument(); + + void onRemoveAllClicked(); +}; + +#endif // DIALOGBOX_RemoveIntWires_H diff --git a/src/RepairGUI/RepairGUI_SewingDlg.cxx b/src/RepairGUI/RepairGUI_SewingDlg.cxx index d36dedea0..79e78405b 100644 --- a/src/RepairGUI/RepairGUI_SewingDlg.cxx +++ b/src/RepairGUI/RepairGUI_SewingDlg.cxx @@ -1,23 +1,23 @@ // 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 +// 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 // // // @@ -29,16 +29,27 @@ using namespace std; #include "RepairGUI_SewingDlg.h" -#include "QAD_Config.h" +#include "QAD_RightFrame.h" +#include "QAD_Desktop.h" +#include "QAD_MessageBox.h" +#include "OCCViewer_Viewer3d.h" +#include "SALOME_ListIteratorOfListIO.hxx" + +#include "GEOMImpl_Types.hxx" + +#include + +#define DEFAULT_TOLERANCE_VALUE 1e-07 + //================================================================================= // class : RepairGUI_SewingDlg() -// purpose : Constructs a RepairGUI_SewingDlg which is a child of 'parent', with the +// purpose : Constructs a RepairGUI_SewingDlg 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_SewingDlg::RepairGUI_SewingDlg(QWidget* parent, const char* name, RepairGUI* theRepairGUI, SALOME_Selection* Sel, bool modal, WFlags fl) +RepairGUI_SewingDlg::RepairGUI_SewingDlg(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_SEWING"))); @@ -47,22 +58,33 @@ RepairGUI_SewingDlg::RepairGUI_SewingDlg(QWidget* parent, const char* name, Rep setCaption(tr("GEOM_SEWING_TITLE")); /***************************************************************/ - GroupConstructors->setTitle(tr("GEOM_SEWING")); + GroupConstructors->setTitle(tr("GEOM_SEWING_TITLE")); RadioButton1->setPixmap(image0); RadioButton2->close(TRUE); RadioButton3->close(TRUE); - GroupPoints = new DlgRef_1Sel1Spin(this, "GroupPoints"); - GroupPoints->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); - GroupPoints->TextLabel1->setText(tr("GEOM_OBJECTS")); - GroupPoints->TextLabel2->setText(tr("GEOM_PRECISION")); + GroupPoints = new DlgRef_1Sel_Ext(this, "GroupPoints"); + GroupPoints->GroupBox1->setTitle(tr("GEOM_SEWING")); + GroupPoints->TextLabel1->setText(tr("GEOM_SELECTED_SHAPE")); GroupPoints->PushButton1->setPixmap(image1); - - Layout1->addWidget(GroupPoints, 1, 0); + GroupPoints->LineEdit1->setReadOnly( true ); + + Layout1->addWidget(GroupPoints, 2, 0); + + QGridLayout* aLay = new QGridLayout( 0, 2, 2, 0, 6, "aLay" ); + myTolEdt = new QAD_SpinBoxDbl( GroupPoints->GroupBox1, 0, 100, 1e-7, 10, 1e-10 ); + myTolEdt->setValue( DEFAULT_TOLERANCE_VALUE ); + QLabel* aLbl1 = new QLabel( tr( "GEOM_TOLERANCE" ), GroupPoints->GroupBox1 ); + myFreeBoundBtn = new QPushButton( tr( "GEOM_DETECT" ), GroupPoints->GroupBox1 ); + QLabel* aLbl2 = new QLabel( tr( "GEOM_FREE_BOUNDARIES" ), GroupPoints->GroupBox1 ); + aLay->addWidget( aLbl1, 0, 0 ); + aLay->addWidget( myTolEdt, 0, 1 ); + aLay->addWidget( aLbl2, 1, 0 ); + aLay->addWidget( myFreeBoundBtn, 1, 1 ); + + GroupPoints->getGroupBoxLayout()->addLayout( aLay, 3, 0 ); /***************************************************************/ - /* Initialisations */ - myRepairGUI = theRepairGUI; Init(); } @@ -73,7 +95,6 @@ RepairGUI_SewingDlg::RepairGUI_SewingDlg(QWidget* parent, const char* name, Rep //================================================================================= RepairGUI_SewingDlg::~RepairGUI_SewingDlg() { - // no need to delete child widgets, Qt does it all for us } @@ -86,98 +107,133 @@ void RepairGUI_SewingDlg::Init() /* init variables */ myEditCurrentArgument = GroupPoints->LineEdit1; - myOkListShapes = false; - myPrecision = 0.00001; + myObject = GEOM::GEOM_Object::_nil(); - /* Get setting of step value from file configuration */ - QString St = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep"); - step = St.toDouble(); + myGeomGUI->SetState( 0 ); + initSelection(); - /* min, max, step and decimals for spin boxes */ - GroupPoints->SpinBox_DX->RangeStepAndValidator(0.00001, 999.99999, step, 5); - GroupPoints->SpinBox_DX->SetValue(myPrecision); - + myClosed = -1; + myOpen = -1; + /* 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(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox_DX, SLOT(SetStep(double))); - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - /* displays Dialog */ - GroupPoints->show(); - this->show(); + connect(myFreeBoundBtn, SIGNAL(clicked()), this, SLOT(onDetect())); - return; + initName( tr( "SEWING_NEW_OBJ_NAME" ) ); } //================================================================================= // function : ClickOnOk() -// purpose : +// purpose : Same than click on apply but close this dialog. //================================================================================= void RepairGUI_SewingDlg::ClickOnOk() { - this->ClickOnApply(); - ClickOnCancel(); - return; + if ( ClickOnApply() ) + ClickOnCancel(); } + //================================================================================= // function : ClickOnApply() // purpose : //================================================================================= -void RepairGUI_SewingDlg::ClickOnApply() +bool RepairGUI_SewingDlg::ClickOnApply() { - buttonApply->setFocus(); - QAD_Application::getDesktop()->putInfo(tr("")); - if(myOkListShapes) - myRepairGUI->MakeSewingAndDisplay(myListShapes, myPrecision); - return; + if ( !onAccept() ) + return false; + + initName(); + + GroupPoints->LineEdit1->setText(""); + myObject = GEOM::GEOM_Object::_nil(); + + initSelection(); + + return true; +} + + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void RepairGUI_SewingDlg::ClickOnCancel() +{ + GEOMBase_Skeleton::ClickOnCancel(); } //================================================================================= // function : SelectionIntoArgument() -// purpose : Called when selection as changed or other case +// purpose : Called when selection //================================================================================= void RepairGUI_SewingDlg::SelectionIntoArgument() { + erasePreview(); myEditCurrentArgument->setText(""); - QString aString = ""; /* name of selection */ - myOkListShapes = false; - - int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString); - if(nbSel < 2) - return; - - myGeomBase->ConvertListOfIOInListOfIOR(mySelection->StoredIObjects(), myListShapes); - myEditCurrentArgument->setText(aString); - myOkListShapes = true; - /* no simulation */ - return; + 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 ) + myEditCurrentArgument->setText( GEOMBase::GetName( myObject ) ); + } } - //================================================================================= // function : SetEditCurrentArgument() // purpose : //================================================================================= void RepairGUI_SewingDlg::SetEditCurrentArgument() { - QPushButton* send = (QPushButton*)sender(); + const QObject* send = sender(); + if ( send == GroupPoints->PushButton1 ) + { + myEditCurrentArgument->setFocus(); + SelectionIntoArgument(); + } +} + - if(send == GroupPoints->PushButton1) { - GroupPoints->LineEdit1->setFocus(); +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void RepairGUI_SewingDlg::LineEditReturnPressed() +{ + const QObject* send = sender(); + if( send == GroupPoints->LineEdit1 ) + { myEditCurrentArgument = GroupPoints->LineEdit1; - this->SelectionIntoArgument(); + GEOMBase_Skeleton::LineEditReturnPressed(); } - return; +} + + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void RepairGUI_SewingDlg::DeactivateActiveDialog() +{ + myGeomGUI->SetState( -1 ); + GEOMBase_Skeleton::DeactivateActiveDialog(); } @@ -189,29 +245,121 @@ void RepairGUI_SewingDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - return; + + GroupPoints->LineEdit1->setText(""); + myObject = GEOM::GEOM_Object::_nil(); + + myClosed = -1; + myOpen = -1; + + myGeomGUI->SetState( 0 ); + initSelection(); } //================================================================================= // function : enterEvent() -// purpose : +// purpose : Mouse enter onto the dialog to activate it //================================================================================= void RepairGUI_SewingDlg::enterEvent(QEvent* e) { - if(GroupConstructors->isEnabled()) - return; - this->ActivateThisDialog(); - return; + if ( !GroupConstructors->isEnabled() ) + ActivateThisDialog(); +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void RepairGUI_SewingDlg::closeEvent(QCloseEvent* e) +{ + myGeomGUI->SetState( -1 ); + GEOMBase_Skeleton::closeEvent( e ); +} + +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr RepairGUI_SewingDlg::createOperation() +{ + return getGeomEngine()->GetIHealingOperations( getStudyId() ); } +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool RepairGUI_SewingDlg::isValid( QString& msg ) +{ + myClosed = -1; + return !myObject->_is_nil() && ( IsPreview() || myTolEdt->value() > 0. ); +} + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool RepairGUI_SewingDlg::execute( ObjectList& objects ) +{ + bool aResult = false; + if ( IsPreview() ) // called from onDetect(): detect free boundary edges, highlight them (add to objects), display message dialog + { + GEOM::ListOfGO_var aClosed, anOpen; + + aResult = GEOM::GEOM_IHealingOperations::_narrow( getOperation() )->GetFreeBoundary( myObject, aClosed, anOpen ); + + if ( aResult ) + { + myClosed = aClosed->length(); + myOpen = anOpen->length(); + int i; + for ( i = 0; i < myClosed; i++ ) + objects.push_back( aClosed[i]._retn() ); + for ( i = 0; i < myOpen; i++ ) + objects.push_back( anOpen[i]._retn() ); + } + else + myClosed = -1; + } + else + { + GEOM::GEOM_Object_var anObj = GEOM::GEOM_IHealingOperations::_narrow( getOperation() )->Sew( myObject, myTolEdt->value() ); + aResult = !anObj->_is_nil(); + if ( aResult ) + objects.push_back( anObj._retn() ); + } + + return aResult; +} + +//================================================================================= +// function : initSelection +// purpose : +//================================================================================= +void RepairGUI_SewingDlg::initSelection() +{ + TColStd_MapOfInteger aTypes; + aTypes.Add( GEOM_SHELL ); + aTypes.Add( GEOM_SOLID ); + aTypes.Add( GEOM_COMPOUND ); + globalSelection( aTypes ); +} //================================================================================= -// function : ValueChangedInSpinBox() +// function : onDetect // purpose : //================================================================================= -void RepairGUI_SewingDlg::ValueChangedInSpinBox(double newValue) +void RepairGUI_SewingDlg::onDetect() { - myPrecision = newValue; - return; + displayPreview( false, true, true, 3 ); + + // field myClosed,myOpen is initialized in execute() method, called by displayPreview(). + QString msg; + if ( myClosed != -1 ) + msg = tr( "GEOM_FREE_BOUNDS_MSG" ).arg( myClosed + myOpen ).arg( myClosed ).arg( myOpen ); + else + msg = tr( "GEOM_FREE_BOUNDS_ERROR" ); + QAD_MessageBox::info1( this, tr( "GEOM_FREE_BOUNDS_TLT" ), msg, "Close" ); } diff --git a/src/RepairGUI/RepairGUI_SewingDlg.h b/src/RepairGUI/RepairGUI_SewingDlg.h index 7e55b400b..eaaa5de7f 100644 --- a/src/RepairGUI/RepairGUI_SewingDlg.h +++ b/src/RepairGUI/RepairGUI_SewingDlg.h @@ -1,23 +1,23 @@ // 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 +// 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 // // // @@ -26,48 +26,66 @@ // Module : GEOM // $Header$ -#ifndef DIALOGBOX_SEWING_H -#define DIALOGBOX_SEWING_H +#ifndef DIALOGBOX_Sewing_H +#define DIALOGBOX_Sewing_H #include "GEOMBase_Skeleton.h" -#include "DlgRef_1Sel1Spin.h" +#include "DlgRef_1Sel_Ext.h" +#include "QAD_SpinBoxDbl.h" + +#include -#include "RepairGUI.h" +#include +#include +#include +#include //================================================================================= // class : RepairGUI_SewingDlg // purpose : //================================================================================= class RepairGUI_SewingDlg : public GEOMBase_Skeleton -{ +{ Q_OBJECT public: - RepairGUI_SewingDlg(QWidget* parent = 0, const char* name = 0, RepairGUI* theRepairGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + RepairGUI_SewingDlg(QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); ~RepairGUI_SewingDlg(); -private: +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& ); + virtual bool execute( ObjectList& objects ); + +private : void Init(); void enterEvent(QEvent* e); + void closeEvent(QCloseEvent* e); + void initSelection(); - RepairGUI* myRepairGUI; - - double step; + GEOM::GEOM_Object_var myObject; - GEOM::GEOM_Gen::ListOfIOR myListShapes; - Standard_Real myPrecision; - bool myOkListShapes; /* to check when arguments is defined */ + DlgRef_1Sel_Ext* GroupPoints; + QAD_SpinBoxDbl* myTolEdt; + QPushButton* myFreeBoundBtn; - DlgRef_1Sel1Spin* GroupPoints; + int myClosed; // number of free closed boundaries detected. calculated in execute(), used in onDetect(). + int myOpen; // number of free open boundaries detected. calculated in execute(), used in onDetect(). private slots: void ClickOnOk(); - void ClickOnApply(); + bool ClickOnApply(); + void ClickOnCancel(); + void ActivateThisDialog(); + void DeactivateActiveDialog(); + + void LineEditReturnPressed(); void SelectionIntoArgument(); void SetEditCurrentArgument(); - void ValueChangedInSpinBox(double newValue); + void onDetect(); }; -#endif // DIALOGBOX_SEWING_H +#endif // DIALOGBOX_Sewing_H diff --git a/src/RepairGUI/RepairGUI_ShapeProcessDlg.cxx b/src/RepairGUI/RepairGUI_ShapeProcessDlg.cxx new file mode 100755 index 000000000..cc1fb4f54 --- /dev/null +++ b/src/RepairGUI/RepairGUI_ShapeProcessDlg.cxx @@ -0,0 +1,807 @@ +// 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_ShapeProcessDlg.cxx +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +using namespace std; + +#include "RepairGUI_ShapeProcessDlg.h" + +#include "SALOME_ListIteratorOfListIO.hxx" +#include "SALOME_ListIO.hxx" + +#include "GEOMImpl_Types.hxx" + +#include +#include "QAD_Desktop.h" +#include + + +//================================================================================= +// class : RepairGUI_ShapeProcessDlg() +// purpose : Constructs a RepairGUI_ShapeProcessDlg 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_ShapeProcessDlg::RepairGUI_ShapeProcessDlg(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) +{ + init(); +} + + +//================================================================================= +// function : ~RepairGUI_ShapeProcessDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +RepairGUI_ShapeProcessDlg::~RepairGUI_ShapeProcessDlg() +{ +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void RepairGUI_ShapeProcessDlg::init() +{ + myGeomGUI->SetState( 0 ); + + initParamsValues(); + initSelection(); + + setCaption(tr("GEOM_SHAPEPROCESS_TITLE")); + + GroupConstructors->hide(); + + // select widget on the top + mySelectWdgt = new DlgRef_1Sel_QTD( this, "SelectedObjects" ); + mySelectWdgt->GroupBox1->setTitle( tr("GEOM_SHAPE") ); + mySelectWdgt->TextLabel1->setText( tr("GEOM_SELECTED_OBJECTS") ); + mySelectWdgt->PushButton1->setPixmap( QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT")) ); + mySelectWdgt->LineEdit1->setReadOnly( true ); + + Layout1->addWidget( mySelectWdgt, 0, 0 ); + + // layout the two group boxes in the middle, add a list of operations + QFrame* aMidFrame = new QFrame( this ); + QGridLayout* aMidLay = new QGridLayout( aMidFrame, 1, 3, 0, 5 ); + QGroupBox* anOperGr = new QGroupBox( tr("GEOM_OPERATIONS"), aMidFrame ); + QVBoxLayout* aOperLay = new QVBoxLayout( anOperGr, 0, 0 ); + + myOpList = new QListView( anOperGr ); + myOpList->setSorting( -1 ); + myOpList->addColumn( "Operations" ); + myOpList->header()->hide(); + aOperLay->addWidget( myOpList ); + QStringList::ConstIterator it = myOpLst.end(); + do // iterating from end to begin so to keep the order of items in the listview. + new QCheckListItem ( myOpList, *(--it), QCheckListItem::CheckBox ); + while ( it != myOpLst.begin() ); + + QGroupBox* aParamsGr = new QGroupBox( tr("GEOM_PARAMETERS"), aMidFrame ); + aMidLay->addWidget( anOperGr, 0, 0 ); + aMidLay->addMultiCellWidget( aParamsGr, 0, 0, 1, 3 ); + aMidLay->setColStretch( 0, 1 ); + aMidLay->setColStretch( 1, 2 ); + + Layout1->addWidget( aMidFrame, 2, 0 ); + Layout1->setRowStretch( 0, 0 ); + Layout1->setRowStretch( 1, 1 ); + + // add a widget stack to the parameters group box + myStack = new QWidgetStack( aParamsGr ); + QVBoxLayout* aVParamsLay = new QVBoxLayout( aParamsGr ); + aVParamsLay->addWidget( myStack ); + + // continueties values.. + QStringList aContinueties = QStringList::split( ",", "C0,G1,C1,G2,C2,C3,CN" ); + + // FixShape + QFrame* aFrame = new QFrame( myStack ); + QGridLayout* aLay = new QGridLayout( aFrame, 10, 2, 0, 5 ); + + myFixShapeTol3D = new QAD_SpinBoxDbl( aFrame, 0, 100, 1e-7, 10, 1e-10 ); + myFixShapeMaxTol3D = new QAD_SpinBoxDbl( aFrame, 0, 100, 1e-7, 10, 1e-10 ); + + aLay->addWidget( new QLabel( tr("GEOM_3D_TOLERANCE"), aFrame ), 0, 0 ); + aLay->addWidget( myFixShapeTol3D, 0, 1 ); + aLay->addWidget( new QLabel( tr("GEOM_MAX_3D_TOLERANCE"), aFrame ), 1, 0 ); + aLay->addWidget( myFixShapeMaxTol3D, 1, 1 ); + aLay->setRowStretch( 9, 2 ); + + myStack->addWidget( aFrame, myOpLst.findIndex( "FixShape" ) ); + + // FixFaceSize + aFrame = new QFrame( myStack ); + aLay = new QGridLayout( aFrame, 10, 2, 0, 5 ); + + myFixFaceSizeTol = new QAD_SpinBoxDbl( aFrame, 0, 100, 1e-7, 10, 1e-10 ); + + aLay->addWidget( new QLabel( tr("GEOM_TOLERANCE"), aFrame ), 0, 0 ); + aLay->addWidget( myFixFaceSizeTol, 0, 1 ); + aLay->setRowStretch( 9, 2 ); + + myStack->addWidget( aFrame, myOpLst.findIndex( "FixFaceSize" ) ); + + // DropSmallEdges + aFrame = new QFrame( myStack ); + aLay = new QGridLayout( aFrame, 10, 2, 0, 5 ); + + myDropSmallEdgesTol3D = new QAD_SpinBoxDbl( aFrame, 0, 100, 1e-7, 10, 1e-10 ); + + aLay->addWidget( new QLabel( tr("GEOM_3D_TOLERANCE"), aFrame ), 0, 0 ); + aLay->addWidget( myDropSmallEdgesTol3D, 0, 1 ); + aLay->setRowStretch( 9, 2 ); + + myStack->addWidget( aFrame, myOpLst.findIndex( "DropSmallEdges" ) ); + + // SplitAngle + aFrame = new QFrame( myStack ); + aLay = new QGridLayout( aFrame, 10, 2, 0, 5 ); + + mySplitAngleAngle = new QAD_SpinBoxDbl( aFrame, 0, 360, 1 ); + mySplitAngleMaxTol = new QAD_SpinBoxDbl( aFrame, 0, 100, 1e-7, 10, 1e-10 ); + + aLay->addWidget( new QLabel( tr("GEOM_ANGLE_1"), aFrame ), 0, 0 ); + aLay->addWidget( mySplitAngleAngle, 0, 1 ); + aLay->addWidget( new QLabel( tr("GEOM_MAX_TOLERANCE"), aFrame ), 1, 0 ); + aLay->addWidget( mySplitAngleMaxTol, 1, 1 ); + aLay->setRowStretch( 9, 2 ); + + myStack->addWidget( aFrame, myOpLst.findIndex( "SplitAngle" ) ); + + // SplitClosedFaces + aFrame = new QFrame( myStack ); + aLay = new QGridLayout( aFrame, 10, 2, 0, 5 ); + + mySplitClosedFacesNum = new QSpinBox( aFrame ); + + aLay->addWidget( new QLabel( tr("GEOM_NUM_SPLIT_POINTS"), aFrame ), 0, 0 ); + aLay->addWidget( mySplitClosedFacesNum, 0, 1 ); + aLay->setRowStretch( 9, 2 ); + + myStack->addWidget( aFrame, myOpLst.findIndex( "SplitClosedFaces" ) ); + + // SplitContinuity + aFrame = new QFrame( myStack ); + aLay = new QGridLayout( aFrame, 10, 2, 0, 5 ); + + mySplitContTol3D = new QAD_SpinBoxDbl( aFrame, 0, 100, 1e-7, 10, 1e-10 ); + mySplitContSurfCont = new QComboBox( aFrame ); + mySplitContSurfCont->insertStringList( aContinueties ); + mySplitContCurvCont = new QComboBox( aFrame ); + mySplitContCurvCont->insertStringList( aContinueties ); + + aLay->addWidget( new QLabel( tr("GEOM_3D_TOLERANCE"), aFrame ), 0, 0 ); + aLay->addWidget( mySplitContTol3D, 0, 1 ); + aLay->addWidget( new QLabel( tr("GEOM_SURFACE_CONTINUTY"), aFrame ), 1, 0 ); + aLay->addWidget( mySplitContSurfCont, 1, 1 ); + aLay->addWidget( new QLabel( tr("GEOM_CURVE_CONTINUTY"), aFrame ), 2, 0 ); + aLay->addWidget( mySplitContCurvCont, 2, 1 ); + aLay->setRowStretch( 9, 2 ); + + myStack->addWidget( aFrame, myOpLst.findIndex( "SplitContinuity" ) ); + + // BSplineRestriction + aFrame = new QFrame( myStack ); + aLay = new QGridLayout( aFrame, 10, 2, 0, 5 ); + + myBSplineSurfModeChk = new QCheckBox( tr("GEOM_SURFACE_MODE"), aFrame ); + myBSpline3DCurveChk = new QCheckBox( tr("GEOM_3D_CURVE_MODE"), aFrame ); + myBSpline2DCurveChk = new QCheckBox( tr("GEOM_2D_CURVE_MODE"), aFrame ); + myBSplineTol3D = new QAD_SpinBoxDbl( aFrame, 0, 100, 1e-7, 10, 1e-10 ); + myBSplineTol2D = new QAD_SpinBoxDbl( aFrame, 0, 100, 1e-7, 10, 1e-10 ); + myBSplineDegree = new QSpinBox( aFrame ); + myBSplineSegments = new QSpinBox( aFrame ); + myBSpline2DCont = new QComboBox( aFrame ); + myBSpline2DCont->insertStringList( aContinueties ); + myBSpline3DCont = new QComboBox( aFrame ); + myBSpline3DCont->insertStringList( aContinueties ); + + myBSplineSurfModeChk->setChecked( true ); + myBSpline3DCurveChk->setChecked( true ); + myBSpline2DCurveChk->setChecked( true ); + + aLay->addWidget( myBSplineSurfModeChk, 0, 0 ); + aLay->addWidget( myBSpline3DCurveChk, 1, 0 ); + aLay->addWidget( myBSpline2DCurveChk, 2, 0 ); + aLay->addWidget( new QLabel( tr("GEOM_3D_TOLERANCE"), aFrame), 3, 0 ); + aLay->addWidget( myBSplineTol3D, 3, 1 ); + aLay->addWidget( new QLabel( tr("GEOM_2D_TOLERANCE"), aFrame), 4, 0 ); + aLay->addWidget( myBSplineTol2D, 4, 1 ); + aLay->addWidget( new QLabel( tr("GEOM_REQUIRED_DEGREE"), aFrame), 5, 0 ); + aLay->addWidget( myBSplineDegree, 5, 1 ); + aLay->addWidget( new QLabel( tr("GEOM_REQUIRED_NUM_SEGMENTS"), aFrame), 6, 0 ); + aLay->addWidget( myBSplineSegments, 6, 1 ); + aLay->addWidget( new QLabel( tr("GEOM_3D_CONTINUTY"), aFrame), 7, 0 ); + aLay->addWidget( myBSpline3DCont, 7, 1 ); + aLay->addWidget( new QLabel( tr("GEOM_2D_CONTINUTY"), aFrame), 8, 0 ); + aLay->addWidget( myBSpline2DCont, 8, 1 ); + aLay->setRowStretch( 9, 2 ); + + myStack->addWidget( aFrame, myOpLst.findIndex( "BSplineRestriction" ) ); + + // ToBezier + aFrame = new QFrame( myStack ); + aLay = new QGridLayout( aFrame, 10, 2, 0, 5 ); + + myToBezierSurfModeChk = new QCheckBox( tr("GEOM_SURFACE_MODE"), aFrame ); + myToBezier3DCurveChk = new QCheckBox( tr("GEOM_3D_CURVE_MODE"), aFrame ); + myToBezier2DCurveChk = new QCheckBox( tr("GEOM_2D_CURVE_MODE"), aFrame ); + myToBezierMaxTol = new QAD_SpinBoxDbl( aFrame, 0, 100, 1e-7, 10, 1e-10 ); + + aLay->addWidget( myToBezierSurfModeChk, 0, 0 ); + aLay->addWidget( myToBezier3DCurveChk, 1, 0 ); + aLay->addWidget( myToBezier2DCurveChk, 2, 0 ); + aLay->addWidget( new QLabel( tr("GEOM_MAX_TOLERANCE"), aFrame), 3, 0 ); + aLay->addWidget( myToBezierMaxTol, 3, 1 ); + aLay->setRowStretch( 9, 2 ); + + myStack->addWidget( aFrame, myOpLst.findIndex( "ToBezier" ) ); + + // SameParameter + aFrame = new QFrame( myStack ); + aLay = new QGridLayout( aFrame, 10, 2, 0, 5 ); + + mySameParameterTol3D = new QAD_SpinBoxDbl( aFrame, 0, 100, 1e-7, 10, 1e-10 ); + + aLay->addWidget( new QLabel( tr("GEOM_3D_TOLERANCE"), aFrame ), 0, 0 ); + aLay->addWidget( mySameParameterTol3D, 0, 1 ); + aLay->setRowStretch( 9, 2 ); + + myStack->addWidget( aFrame, myOpLst.findIndex( "SameParameter" ) ); + + // signals and slots connections + connect( myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(deactivate()) ); + connect( myGeomGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(onCancel()) ); + + connect( buttonCancel, SIGNAL(clicked()), this, SLOT(onCancel()) ); + connect( buttonOk, SIGNAL(clicked()), this, SLOT(onOk()) ); + connect( buttonApply, SIGNAL(clicked()), this, SLOT(onApply()) ); + + connect( mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(selectionChanged()) ); + connect( myOpList, SIGNAL(selectionChanged()), this, SLOT(operationChanged()) ); + + connect( mySelectWdgt->PushButton1, SIGNAL(clicked()), this, SLOT(selectClicked()) ); + connect( mySelectWdgt->LineEdit1, SIGNAL(returnPressed()), this, SLOT(lineEditReturnPressed()) ); + + adjustSize(); + loadDefaults(); // init dialog fields with values from resource file + myOpList->setSelected( myOpList->findItem( "FixShape", 0 ), true ); + reset(); + + initName( tr( "PROCESS_SHAPE_NEW_OBJ_NAME" ) ); +} + +//================================================================================= +// function : operationChanged() +// purpose : +//================================================================================= +void RepairGUI_ShapeProcessDlg::operationChanged() +{ + QListViewItem* anItem = myOpList->selectedItem(); + if ( anItem ) + { + int id = myOpLst.findIndex( anItem->text(0) ); + if ( id > -1 ) + myStack->raiseWidget( id ); + } +} + +//================================================================================= +// function : onOk() +// purpose : Same than click on apply but close this dialog. +//================================================================================= +void RepairGUI_ShapeProcessDlg::onOk() +{ + if ( onApply() ) + onCancel(); +} + + + +//================================================================================= +// function : onApply() +// purpose : +//================================================================================= +bool RepairGUI_ShapeProcessDlg::onApply() +{ + if ( !onAccept() ) + return false; + + initName(); + + reset(); + initSelection(); + + return true; +} + + +//================================================================================= +// function : onCancel() +// purpose : +//================================================================================= +void RepairGUI_ShapeProcessDlg::onCancel() +{ + GEOMBase_Skeleton::ClickOnCancel(); +} + + +//================================================================================= +// function : selectionChanged() +// purpose : Called when selection as changed or other case +// : used only by SelectButtonC1A1 (LineEditC1A1) +//================================================================================= +void RepairGUI_ShapeProcessDlg::selectionChanged() +{ + reset(); + + Standard_Boolean aRes = Standard_False; + int i = 0; + myObjects->length( mySelection->IObjectCount() ); + for ( SALOME_ListIteratorOfListIO anIt( mySelection->StoredIObjects() ); anIt.More(); anIt.Next() ) + { + GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( anIt.Value(), aRes ); + if ( !CORBA::is_nil( aSelectedObject ) && aRes ) + myObjects[i++] = aSelectedObject; + } + myObjects->length( i ); + if ( i == 1 ) + mySelectWdgt->LineEdit1->setText( GEOMBase::GetName( myObjects[0] ) ); + else if ( i > 0 ) + mySelectWdgt->LineEdit1->setText( QString::number( i ) + "_" + tr( "GEOM_OBJECTS" ) ); +} + + +//================================================================================= +// function : selectClicked() +// purpose : +//================================================================================= +void RepairGUI_ShapeProcessDlg::selectClicked() +{ + mySelectWdgt->LineEdit1->setFocus(); + selectionChanged(); +} + + +//================================================================================= +// function : lineEditReturnPressed() +// purpose : +//================================================================================= +void RepairGUI_ShapeProcessDlg::lineEditReturnPressed() +{ + GEOMBase_Skeleton::LineEditReturnPressed(); +} + + +//================================================================================= +// function : deactivate() +// purpose : +//================================================================================= +void RepairGUI_ShapeProcessDlg::deactivate() +{ + myGeomGUI->SetState( -1 ); + GEOMBase_Skeleton::DeactivateActiveDialog(); +} + + +//================================================================================= +// function : activate() +// purpose : +//================================================================================= +void RepairGUI_ShapeProcessDlg::activate() +{ + GEOMBase_Skeleton::ActivateThisDialog(); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(selectionChanged())); + + reset(); + myGeomGUI->SetState( 0 ); + initSelection(); +} + + +//================================================================================= +// function : enterEvent() +// purpose : Mouse enter onto the dialog to activate it +//================================================================================= +void RepairGUI_ShapeProcessDlg::enterEvent(QEvent* e) +{ + if ( !GroupConstructors->isEnabled() ) + activate(); +} + + +//================================================================================= +// function : closeEvent() +// purpose : same than click on cancel button +//================================================================================= +void RepairGUI_ShapeProcessDlg::closeEvent(QCloseEvent* e) +{ + myGeomGUI->SetState( -1 ); + GEOMBase_Skeleton::closeEvent( e ); +} + + +//================================================================================= +// function : reset() +// purpose : Completely reset the state of method including local context +//================================================================================= +void RepairGUI_ShapeProcessDlg::reset() +{ + myObjects = new GEOM::ListOfGO(); + myObjects->length( 0 ); + mySelectWdgt->LineEdit1->setText(""); +} + + +//================================================================================= +// function : get_convert +// purpose : conversion of angle values to radians (non-angle values are not converted) +//================================================================================= +const char* get_convert( const char* theParam, const char* theValue ) +{ + if ( !strcmp( theParam, "SplitAngle.Angle" ) ) + { + double doubleValue = atof( theValue ) * PI / 180; + TCollection_AsciiString str( doubleValue ); + return CORBA::string_dup( str.ToCString() ); + } + return CORBA::string_dup( theValue ); +} + +//================================================================================= +// function : set_convert +// purpose : conversion of angle values to degrees (non-angle values are not converted) +//================================================================================= +const char* set_convert( const char* theParam, const char* theValue ) +{ + if ( !strcmp( theParam, "SplitAngle.Angle" ) ) + { + double doubleValue = atof( theValue ) * 180 / PI; + TCollection_AsciiString str( doubleValue ); + return CORBA::string_dup( str.ToCString() ); + } + return CORBA::string_dup( theValue ); +} + +//================================================================================= +// function : loadDefaults() +// purpose : initialize "values"-fields with default values retrieved from IHealingOperations +//================================================================================= +void RepairGUI_ShapeProcessDlg::loadDefaults() +{ + const int aStudyId = QAD_Application::getDesktop()->getActiveStudy()->getStudyId(); + GEOM::GEOM_IHealingOperations_var anOp = myGeomGUI->GetGeomGen()->GetIHealingOperations( aStudyId ); + GEOM::string_array_var anOperators, aParams, aValues; + anOp->GetShapeProcessParameters( anOperators, aParams, aValues ); + + + // check the default items-operators + int i; + for ( i = 0; i < anOperators->length(); i++ ) + { + //MESSAGE("-->"<<(const char*)anOperators[i]); + QListViewItem* anItem = myOpList->findItem( (const char*)anOperators[i], 0 ); + if ( anItem /*&& anItem->inherits( "QCheckListItem" )*/ ) + ((QCheckListItem*) anItem)->setOn( true ); + } + + // set default values of parameters + if ( aParams->length() != aValues->length() ) + return; + for ( i = 0; i < aParams->length(); i++ ) + { + QWidget* aCtrl = getControl( (const char*)aParams[i] ); + const char* aValue = set_convert( (const char*)aParams[i], aValues[i] ); + setValue( aCtrl, aValue ); + } +} + +//================================================================================= +// function : setValue() +// purpose : set value in the proper way +//================================================================================= +void RepairGUI_ShapeProcessDlg::setValue( QWidget* theControl, const char* theValue ) +{ + if ( theControl == NULL || theValue == NULL ) + return; + + if ( theControl->isA( "QAD_SpinBoxDbl" ) ) + ((QAD_SpinBoxDbl*)theControl)->setValue( QString( theValue ).toDouble() ); + else if ( theControl->isA( "QSpinBox" ) ) + ((QSpinBox*)theControl)->setValue( QString( theValue ).toInt() ); + else if ( theControl->isA( "QComboBox" ) ) + ((QComboBox*)theControl)->setCurrentText( QString( theValue ) ); + else if ( theControl->isA( "QCheckBox" ) ) + ((QCheckBox*)theControl)->setChecked( QString( theValue ).toInt() != 0 ); +} + +//================================================================================= +// function : getValue() +// purpose : get value in the proper way +//================================================================================= +const char* RepairGUI_ShapeProcessDlg::getValue( QWidget* theControl ) const +{ + if ( theControl == NULL ) + return ""; + + if ( theControl->isA( "QAD_SpinBoxDbl" ) ) + return ((QAD_SpinBoxDbl*)theControl)->text().latin1(); + else if ( theControl->isA( "QSpinBox" ) ) + return ((QSpinBox*)theControl)->text().latin1(); + else if ( theControl->isA( "QComboBox" ) ) + return ((QComboBox*)theControl)->currentText().latin1(); + else if ( theControl->isA( "QCheckBox" ) ) + return ((QCheckBox*)theControl)->isChecked() ? "1" : "0"; + + return ""; +} + +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr RepairGUI_ShapeProcessDlg::createOperation() +{ + return getGeomEngine()->GetIHealingOperations( getStudyId() ); +} + +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool RepairGUI_ShapeProcessDlg::isValid( QString& msg ) +{ + bool error = false; + GEOM::string_array_var anOperators = getActiveOperators(); + if ( !myObjects->length() ) + { + msg += tr( "ERROR_NO_OBJECTS" ); + error = true; + } + if ( !anOperators->length() ) + { + if ( error ) + msg += "\n"; + msg += tr( "ERROR_NO_OPERATORS" ); + error = true; + } + return !error; +} + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool RepairGUI_ShapeProcessDlg::execute( ObjectList& objects ) +{ + GEOM::string_array_var anOperators = getActiveOperators(); + GEOM::string_array_var aParams = getParameters( anOperators ); + GEOM::string_array_var aValues = getValues( aParams ); + + /*//-- check -- + int z; + MESSAGE("Objects : "); + for ( z = 0; z < myObjects->length(); z++ ) + MESSAGE(myObjects[z]->GetName() << " "); + MESSAGE("\nOperators : "); + for ( z = 0; z < anOperators->length(); z++ ) + MESSAGE(anOperators[z] << " "); + MESSAGE("\nParameters : "); + for ( z = 0; z < aParams->length(); z++ ) + MESSAGE(aParams[z] << " "); + MESSAGE("\nValues : "); + for ( z = 0; z < aValues->length(); z ++ ) + MESSAGE(aValues[z] << " "); + MESSAGE("\n"); + */// ----------- + + QStringList anErrorObjNames; + for ( int i = 0; i < myObjects->length(); i++ ) + { + GEOM::GEOM_Object_var obj = myObjects[i]; + GEOM::GEOM_Object_var anObj = GEOM::GEOM_IHealingOperations::_narrow( getOperation() )->ProcessShape( + obj, anOperators, aParams, aValues ); + if ( anObj->_is_nil() ) + anErrorObjNames << GEOMBase::GetName( obj ); + else + objects.push_back( anObj._retn() ); + } + + if ( !anErrorObjNames.empty() ) + MESSAGE("ERRORS occured while processing the following objects: " << anErrorObjNames.join( " " )); + + return anErrorObjNames.size() < myObjects->length(); // true if at least one object was OK, false if ALL objects were nil after Healing. +} + +//================================================================================= +// function : getActiveOperators +// purpose : +//================================================================================= +GEOM::string_array* RepairGUI_ShapeProcessDlg::getActiveOperators() +{ + GEOM::string_array_var anOperators = new GEOM::string_array(); + QStringList aCheckedList; + QStringList::Iterator it; + for ( it = myOpLst.begin(); it != myOpLst.end(); ++it ) + if ( ((QCheckListItem*)myOpList->findItem( *it, 0 ))->isOn() ) + aCheckedList << *it; + anOperators->length( aCheckedList.size() ); + int i = 0; + for ( it = aCheckedList.begin(); it != aCheckedList.end(); ++it ) + anOperators[i++] = CORBA::string_dup( (*it).latin1() ); + + return anOperators._retn(); +} + +//================================================================================= +// function : getcontrol +// purpose : +//================================================================================= +QWidget* RepairGUI_ShapeProcessDlg::getControl( const char* theParam ) +{ + string aParam = theParam; + if ( aParam == "SplitAngle.Angle" ) return mySplitAngleAngle; + else if ( aParam == "SplitAngle.MaxTolerance" ) return mySplitAngleMaxTol; + else if ( aParam == "SplitClosedFaces.NbSplitPoints" ) return mySplitClosedFacesNum; + else if ( aParam == "FixFaceSize.Tolerance" ) return myFixFaceSizeTol; + else if ( aParam == "DropSmallEdges.Tolerance3d" ) return myDropSmallEdgesTol3D; + else if ( aParam == "BSplineRestriction.SurfaceMode" ) return myBSplineSurfModeChk; + else if ( aParam == "BSplineRestriction.Curve3dMode" ) return myBSpline3DCurveChk; + else if ( aParam == "BSplineRestriction.Curve2dMode" ) return myBSpline2DCurveChk; + else if ( aParam == "BSplineRestriction.Tolerance3d" ) return myBSplineTol3D; + else if ( aParam == "BSplineRestriction.Tolerance2d" ) return myBSplineTol2D; + else if ( aParam == "BSplineRestriction.RequiredDegree" ) return myBSplineDegree; + else if ( aParam == "BSplineRestriction.RequiredNbSegments" ) return myBSplineSegments; + else if ( aParam == "BSplineRestriction.Continuity3d" ) return myBSpline3DCont; + else if ( aParam == "BSplineRestriction.Continuity2d" ) return myBSpline2DCont; + else if ( aParam == "SplitContinuity.Tolerance3d" ) return mySplitContTol3D; + else if ( aParam == "SplitContinuity.SurfaceContinuity" ) return mySplitContSurfCont; + else if ( aParam == "SplitContinuity.CurveContinuity" ) return mySplitContCurvCont; + else if ( aParam == "ToBezier.SurfaceMode" ) return myToBezierSurfModeChk; + else if ( aParam == "ToBezier.Curve3dMode" ) return myToBezier3DCurveChk; + else if ( aParam == "ToBezier.Curve2dMode" ) return myToBezier2DCurveChk; + else if ( aParam == "ToBezier.MaxTolerance" ) return myToBezierMaxTol; + else if ( aParam == "SameParameter.Tolerance3d" ) return mySameParameterTol3D; + else if ( aParam == "FixShape.Tolerance3d" ) return myFixShapeTol3D; + else if ( aParam == "FixShape.MaxTolerance3d" ) return myFixShapeMaxTol3D; + return NULL; +} + +//================================================================================= +// function : getParameters +// purpose : +//================================================================================= +void RepairGUI_ShapeProcessDlg::initParamsValues() +{ + myOpLst << "FixShape"; + myValMap["FixShape"] << "FixShape.Tolerance3d"; + myValMap["FixShape"] << "FixShape.MaxTolerance3d"; + + myOpLst << "FixFaceSize"; + myValMap["FixFaceSize"] << "FixFaceSize.Tolerance"; + + myOpLst << "DropSmallEdges"; + myValMap["DropSmallEdges"] << "DropSmallEdges.Tolerance3d"; + + myOpLst << "SplitAngle"; + myValMap["SplitAngle"] << "SplitAngle.Angle"; + myValMap["SplitAngle"] << "SplitAngle.MaxTolerance"; + + myOpLst << "SplitClosedFaces"; + myValMap["SplitClosedFaces"] << "SplitClosedFaces.NbSplitPoints"; + + myOpLst << "SplitContinuity"; + myValMap["SplitContinuity"] << "SplitContinuity.Tolerance3d"; + myValMap["SplitContinuity"] << "SplitContinuity.SurfaceContinuity"; + myValMap["SplitContinuity"] << "SplitContinuity.CurveContinuity"; + + myOpLst << "BSplineRestriction"; + myValMap["BSplineRestriction"] << "BSplineRestriction.SurfaceMode"; + myValMap["BSplineRestriction"] << "BSplineRestriction.Curve3dMode"; + myValMap["BSplineRestriction"] << "BSplineRestriction.Curve2dMode"; + myValMap["BSplineRestriction"] << "BSplineRestriction.Tolerance3d"; + myValMap["BSplineRestriction"] << "BSplineRestriction.Tolerance2d"; + myValMap["BSplineRestriction"] << "BSplineRestriction.RequiredDegree"; + myValMap["BSplineRestriction"] << "BSplineRestriction.RequiredNbSegments"; + myValMap["BSplineRestriction"] << "BSplineRestriction.Continuity3d"; + myValMap["BSplineRestriction"] << "BSplineRestriction.Continuity2d"; + + myOpLst << "ToBezier"; + myValMap["ToBezier"] << "ToBezier.SurfaceMode"; + myValMap["ToBezier"] << "ToBezier.Curve3dMode"; + myValMap["ToBezier"] << "ToBezier.Curve2dMode"; + myValMap["ToBezier"] << "ToBezier.MaxTolerance"; + + myOpLst << "SameParameter"; + myValMap["SameParameter"] << "SameParameter.Tolerance3d"; +} + +//================================================================================= +// function : getParameters +// purpose : +//================================================================================= +GEOM::string_array* RepairGUI_ShapeProcessDlg::getParameters( const GEOM::string_array& theOperators ) +{ + GEOM::string_array_var aParams = new GEOM::string_array(); + int i( 0 ), j( 0 ); + + // calculate the length of parameters + for ( i = 0, j = 0; i < theOperators.length(); i++ ) + j+= myValMap[QString((const char*)theOperators[i])].size(); + + // set the new length of paremeters + aParams->length( j ); + + // fill the parameters + for ( i = 0, j = 0; i < theOperators.length(); i++ ) + { + QStringList aValLst = myValMap[QString( (const char*)theOperators[i] )]; + for ( QStringList::Iterator it = aValLst.begin(); it != aValLst.end(); ++it ) + aParams[j++] = CORBA::string_dup( (*it).latin1() ); + } + + return aParams._retn(); +} + + +//================================================================================= +// function : getValues +// purpose : +//================================================================================= +GEOM::string_array* RepairGUI_ShapeProcessDlg::getValues( const GEOM::string_array& theParams ) +{ + GEOM::string_array_var aValues = new GEOM::string_array(); + aValues->length( theParams.length() ); + + for ( int i = 0; i < theParams.length(); i++ ) + { + QWidget* aCtrl = getControl( (const char*)theParams[i] ); + if ( aCtrl ) + aValues[i] = get_convert( (const char*)theParams[i], getValue( aCtrl ) ); + } + + return aValues._retn(); +} + +//================================================================================= +// function : initSelection +// purpose : set selection of ALL shape types except vertexes +//================================================================================= +void RepairGUI_ShapeProcessDlg::initSelection() +{ + TColStd_MapOfInteger aTypes; + aTypes.Add( GEOM_COMPOUND ); + aTypes.Add( GEOM_SOLID ); + aTypes.Add( GEOM_SHELL ); + aTypes.Add( GEOM_FACE ); + aTypes.Add( GEOM_WIRE ); + aTypes.Add( GEOM_EDGE ); + globalSelection( aTypes ); +} diff --git a/src/RepairGUI/RepairGUI_ShapeProcessDlg.h b/src/RepairGUI/RepairGUI_ShapeProcessDlg.h new file mode 100755 index 000000000..98112c4bd --- /dev/null +++ b/src/RepairGUI/RepairGUI_ShapeProcessDlg.h @@ -0,0 +1,141 @@ +// 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_ShapeProcessDlg.h +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_ShapeProcess_H +#define DIALOGBOX_ShapeProcess_H + +#include "GEOMBase_Skeleton.h" +#include "DlgRef_1Sel_QTD.h" +#include "RepairGUI.h" +#include "QAD_SpinBoxDbl.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +//================================================================================= +// class : RepairGUI_ShapeProcessDlg +// purpose : +//================================================================================= +class RepairGUI_ShapeProcessDlg : public GEOMBase_Skeleton +{ + Q_OBJECT + +public: + RepairGUI_ShapeProcessDlg(QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + ~RepairGUI_ShapeProcessDlg(); + +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& ); + virtual bool execute( ObjectList& objects ); + + virtual void closeEvent( QCloseEvent* e ); + +private : + void init(); + void reset(); + void loadDefaults(); // initialize all controls with default values (from resource file) + GEOM::string_array* getActiveOperators(); + GEOM::string_array* getParameters( const GEOM::string_array& theOperators ); + GEOM::string_array* getValues( const GEOM::string_array& theParameters ); + + void enterEvent(QEvent* e); + + QWidget* getControl( const char* ); + void setValue( QWidget*, const char* ); // initialize the given control in the proper way + // (analize its class and convert the value string) + const char* getValue( QWidget* theControl ) const; // retrieve value of the control in the proper way + + QStringList myOpLst; // list of available Shape Healing Operators + QMap myValMap; // map of parameters of operators + //QDict myCtrlMap; // map of controls (values) of parameters + void initParamsValues(); // initialize the data structures + void initSelection(); + + GEOM::ListOfGO_var myObjects; // selected objects + + DlgRef_1Sel_QTD* mySelectWdgt; + QListView* myOpList; + QWidgetStack* myStack; + + QAD_SpinBoxDbl* myFixShapeTol3D; + QAD_SpinBoxDbl* myFixShapeMaxTol3D; + + QAD_SpinBoxDbl* myFixFaceSizeTol; + + QAD_SpinBoxDbl* myDropSmallEdgesTol3D; + + QAD_SpinBoxDbl* mySplitAngleAngle; + QAD_SpinBoxDbl* mySplitAngleMaxTol; + + QSpinBox* mySplitClosedFacesNum; + + QAD_SpinBoxDbl* mySplitContTol3D; + QComboBox* mySplitContSurfCont; + QComboBox* mySplitContCurvCont; + + QCheckBox* myBSplineSurfModeChk; + QCheckBox* myBSpline3DCurveChk; + QCheckBox* myBSpline2DCurveChk; + QAD_SpinBoxDbl* myBSplineTol3D; + QAD_SpinBoxDbl* myBSplineTol2D; + QSpinBox* myBSplineDegree; + QSpinBox* myBSplineSegments; + QComboBox* myBSpline2DCont; + QComboBox* myBSpline3DCont; + + QCheckBox* myToBezierSurfModeChk; + QCheckBox* myToBezier3DCurveChk; + QCheckBox* myToBezier2DCurveChk; + QAD_SpinBoxDbl* myToBezierMaxTol; + + QAD_SpinBoxDbl* mySameParameterTol3D; + +private slots: + void onOk(); + bool onApply(); + void onCancel(); + + void activate(); + void deactivate(); + + void lineEditReturnPressed(); + void selectionChanged(); + void selectClicked(); + void activateSelection(); + void operationChanged(); +}; + +#endif // DIALOGBOX_ShapeProcess_H diff --git a/src/RepairGUI/RepairGUI_SuppressFacesDlg.cxx b/src/RepairGUI/RepairGUI_SuppressFacesDlg.cxx index e7923e8e2..55b5d0cd6 100644 --- a/src/RepairGUI/RepairGUI_SuppressFacesDlg.cxx +++ b/src/RepairGUI/RepairGUI_SuppressFacesDlg.cxx @@ -29,9 +29,15 @@ using namespace std; #include "RepairGUI_SuppressFacesDlg.h" -#include "DisplayGUI.h" #include "QAD_RightFrame.h" +#include "QAD_Desktop.h" #include "OCCViewer_Viewer3d.h" +#include "SALOME_ListIteratorOfListIO.hxx" + +#include "GEOMImpl_Types.hxx" + +#include + //================================================================================= // class : RepairGUI_SuppressFacesDlg() @@ -40,7 +46,7 @@ using namespace std; // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -RepairGUI_SuppressFacesDlg::RepairGUI_SuppressFacesDlg(QWidget* parent, const char* name, RepairGUI* theRepairGUI, SALOME_Selection* Sel, Handle(AIS_InteractiveContext) ic, bool modal, WFlags fl) +RepairGUI_SuppressFacesDlg::RepairGUI_SuppressFacesDlg(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_SUPRESS_FACE"))); @@ -54,18 +60,16 @@ RepairGUI_SuppressFacesDlg::RepairGUI_SuppressFacesDlg(QWidget* parent, const ch RadioButton2->close(TRUE); RadioButton3->close(TRUE); - GroupPoints = new DlgRef_1Sel1Check_QTD(this, "GroupPoints"); - GroupPoints->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); - GroupPoints->TextLabel1->setText(tr("GEOM_MAIN_OBJECT")); - GroupPoints->CheckButton1->setText(tr("GEOM_SUPRESSFACE_SELECT")); + GroupPoints = new DlgRef_1Sel_QTD(this, "GroupPoints"); + GroupPoints->GroupBox1->setTitle(tr("Faces to remove")); + GroupPoints->TextLabel1->setText(tr("Faces")); GroupPoints->PushButton1->setPixmap(image1); + GroupPoints->LineEdit1->setReadOnly( true ); - Layout1->addWidget(GroupPoints, 1, 0); + Layout1->addWidget(GroupPoints, 2, 0); /***************************************************************/ - /* Initialisations */ - myRepairGUI = theRepairGUI; - Init(ic); + Init(); } @@ -75,7 +79,6 @@ RepairGUI_SuppressFacesDlg::RepairGUI_SuppressFacesDlg(QWidget* parent, const ch //================================================================================= RepairGUI_SuppressFacesDlg::~RepairGUI_SuppressFacesDlg() { - // no need to delete child widgets, Qt does it all for us } @@ -83,16 +86,17 @@ RepairGUI_SuppressFacesDlg::~RepairGUI_SuppressFacesDlg() // function : Init() // purpose : //================================================================================= -void RepairGUI_SuppressFacesDlg::Init(Handle(AIS_InteractiveContext) ic) +void RepairGUI_SuppressFacesDlg::Init() { /* init variables */ myEditCurrentArgument = GroupPoints->LineEdit1; - myOkSelectSubMode = false; - myOkShape = myUseLocalContext = false; - myIC = ic; - myLocalContextId = -1; + myObjects = new GEOM::ListOfGO(); + myObjects->length( 0 ); + myGeomGUI->SetState( 0 ); + initSelection(); + /* signals and slots connections */ connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel())); connect(myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog())); @@ -104,15 +108,9 @@ void RepairGUI_SuppressFacesDlg::Init(Handle(AIS_InteractiveContext) ic) connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupPoints->CheckButton1, SIGNAL(stateChanged(int)), this, SLOT(ActivateUserSelection())); - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - /* displays Dialog */ - GroupPoints->show(); - this->show(); - - return; + initName( tr( "SUPRESS_FACE_NEW_OBJ_NAME" ) ); } @@ -122,9 +120,8 @@ void RepairGUI_SuppressFacesDlg::Init(Handle(AIS_InteractiveContext) ic) //================================================================================= void RepairGUI_SuppressFacesDlg::ClickOnOk() { - this->ClickOnApply(); - this->ClickOnCancel(); - return; + if ( ClickOnApply() ) + ClickOnCancel(); } @@ -133,22 +130,20 @@ void RepairGUI_SuppressFacesDlg::ClickOnOk() // function : ClickOnApply() // purpose : //================================================================================= -void RepairGUI_SuppressFacesDlg::ClickOnApply() +bool RepairGUI_SuppressFacesDlg::ClickOnApply() { - QAD_Application::getDesktop()->putInfo(tr("")); - bool testResult = false; + if ( !onAccept() ) + return false; - if(myOkShape && myOkSelectSubMode) - testResult = myRepairGUI->OnSuppressFaces(myShape, myShapeIOR, myLocalContextId, myUseLocalContext); + initName(); - if(!testResult) - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_ABORT")); - else - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); + myEditCurrentArgument->setText(""); + myObjects->length( 0 ); + myFaces.clear(); - /* Reset arguments to allow a new selection */ - this->ResetStateOfDialog(); - return ; + initSelection(); + + return true; } @@ -158,18 +153,7 @@ void RepairGUI_SuppressFacesDlg::ClickOnApply() //================================================================================= void RepairGUI_SuppressFacesDlg::ClickOnCancel() { - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - myIC = v3d->getAISContext(); - if(myUseLocalContext) { - myIC->CloseLocalContext(myLocalContextId); - myUseLocalContext = false; - } - DisplayGUI* myDisplayGUI = new DisplayGUI(); - myDisplayGUI->OnDisplayAll(true); - } GEOMBase_Skeleton::ClickOnCancel(); - return; } @@ -181,58 +165,53 @@ void RepairGUI_SuppressFacesDlg::ClickOnCancel() void RepairGUI_SuppressFacesDlg::SelectionIntoArgument() { myEditCurrentArgument->setText(""); - this->ResetStateOfDialog(); - QString aString = ""; /* name of selection */ - - int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString); - if(nbSel != 1) { - myOkShape = false; - return; - } - - /* nbSel == 1 */ - TopoDS_Shape S; - Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); - if(!myGeomBase->GetTopoFromSelection(mySelection, S)) - return; - - if(!IO->hasEntry()) { - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY")); - return; - } - /* Test the exact type of topology to suppress faces into */ - if(!S.IsNull() && (S.ShapeType() == TopAbs_SOLID || S.ShapeType() == TopAbs_SHELL || S.ShapeType() == TopAbs_COMPOUND)) { - if(IO->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject))) { - Handle(GEOM_InteractiveObject) GIObject = Handle(GEOM_InteractiveObject)::DownCast(IO); - myShapeIOR = GIObject->getIOR(); /* the Geom IOR string of selection */ - myEditCurrentArgument->setText(aString); - myShape = S; - myOkShape = true; - return; - } - - if(IO->hasEntry()) { - SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument(); - SALOMEDS::SObject_var obj = aStudy->FindObjectID(IO->getEntry()); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeIOR_var anIOR; - if(!obj->_is_nil()) { - if(obj->FindAttribute(anAttr, "AttributeIOR")) { - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - myShapeIOR = anIOR->Value(); - myOkShape = true; - myShape = S; - myEditCurrentArgument->setText(aString); - return; + Standard_Boolean aRes = Standard_False; + int i = 0; + int numFaces = 0; + myObjects->length( mySelection->IObjectCount() ); + myFaces.clear(); + for ( SALOME_ListIteratorOfListIO anIt( mySelection->StoredIObjects() ); anIt.More(); anIt.Next() ) + { + Handle(SALOME_InteractiveObject) anIO = anIt.Value(); + GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( anIO, aRes ); + if ( !CORBA::is_nil( aSelectedObject ) && aRes ) + { + TopoDS_Shape aShape; + if ( myGeomBase->GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) ) + { + if ( aShape.ShapeType() <= TopAbs_FACE ) // FACE, SHELL, SOLID, COMPOUND + { + GEOM::short_array anIndexes; + if ( mySelection->HasIndex( anIO ) ) + { + TColStd_IndexedMapOfInteger aMap; + mySelection->GetIndex( anIO, aMap ); + Convert( aMap, anIndexes ); + myObjects[i++] = aSelectedObject; // append the object + myFaces.append( anIndexes ); // append faces' indexes + numFaces += anIndexes.length();// just for text field output + } } } } - } - return; + myObjects->length( i ); // this is the right length, smaller of equal to the previously set + if ( numFaces ) + myEditCurrentArgument->setText( QString::number( numFaces ) + "_" + tr( "GEOM_FACE" ) + tr( "_S_" ) ); } +//================================================================================= +// function : Convert() +// purpose : +//================================================================================= +void RepairGUI_SuppressFacesDlg::Convert( const TColStd_IndexedMapOfInteger& theMap, GEOM::short_array& theOutSeq ) +{ + const int n = theMap.Extent(); + theOutSeq.length( n ); + for ( int i = 0; i < n; i++ ) + theOutSeq[i] = theMap( i+1 ); +} //================================================================================= // function : SetEditCurrentArgument() @@ -240,15 +219,12 @@ void RepairGUI_SuppressFacesDlg::SelectionIntoArgument() //================================================================================= void RepairGUI_SuppressFacesDlg::SetEditCurrentArgument() { - QPushButton* send = (QPushButton*)sender(); - - if(send == GroupPoints->PushButton1) { + if( sender() == GroupPoints->PushButton1 ) + { GroupPoints->LineEdit1->setFocus(); myEditCurrentArgument = GroupPoints->LineEdit1; } - this->SelectionIntoArgument(); - - return; + SelectionIntoArgument(); } @@ -258,14 +234,11 @@ void RepairGUI_SuppressFacesDlg::SetEditCurrentArgument() //================================================================================= void RepairGUI_SuppressFacesDlg::LineEditReturnPressed() { - QLineEdit* send = (QLineEdit*)sender(); - if(send == GroupPoints->LineEdit1) + if( sender() == GroupPoints->LineEdit1 ) + { myEditCurrentArgument = GroupPoints->LineEdit1; - else - return; - - GEOMBase_Skeleton::LineEditReturnPressed(); - return; + GEOMBase_Skeleton::LineEditReturnPressed(); + } } @@ -275,11 +248,8 @@ void RepairGUI_SuppressFacesDlg::LineEditReturnPressed() //================================================================================= void RepairGUI_SuppressFacesDlg::DeactivateActiveDialog() { - if(GroupConstructors->isEnabled()) { - this->ResetStateOfDialog(); - GEOMBase_Skeleton::DeactivateActiveDialog(); - } - return; + myGeomGUI->SetState( -1 ); + GEOMBase_Skeleton::DeactivateActiveDialog(); } @@ -291,7 +261,9 @@ void RepairGUI_SuppressFacesDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - return; + + myGeomGUI->SetState( 0 ); + initSelection(); } @@ -301,10 +273,8 @@ void RepairGUI_SuppressFacesDlg::ActivateThisDialog() //================================================================================= void RepairGUI_SuppressFacesDlg::enterEvent(QEvent* e) { - if(GroupConstructors->isEnabled()) - return; - this->ActivateThisDialog(); - return; + if ( !GroupConstructors->isEnabled() ) + ActivateThisDialog(); } @@ -314,76 +284,60 @@ void RepairGUI_SuppressFacesDlg::enterEvent(QEvent* e) //================================================================================= void RepairGUI_SuppressFacesDlg::closeEvent(QCloseEvent* e) { - /* same than click on cancel button */ - this->ClickOnCancel(); - return; + myGeomGUI->SetState( -1 ); + GEOMBase_Skeleton::closeEvent( e ); } +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr RepairGUI_SuppressFacesDlg::createOperation() +{ + return getGeomEngine()->GetIHealingOperations( getStudyId() ); +} //================================================================================= -// function : ActivateUserSelection() -// purpose : Activate selection of faces when CheckBox1->isChecked()... +// function : isValid +// purpose : //================================================================================= -void RepairGUI_SuppressFacesDlg::ActivateUserSelection() +bool RepairGUI_SuppressFacesDlg::isValid( QString& msg ) { - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { - if(!myOkShape) { - this->ResetStateOfDialog(); - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_SELECT_FIRST")); - return; - } - - myOkSelectSubMode = GroupPoints->CheckButton1->isChecked(); - - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - myIC = v3d->getAISContext(); - if(myUseLocalContext) { - myIC->CloseLocalContext(myLocalContextId); - myUseLocalContext = false; - } - DisplayGUI* myDisplayGUI = new DisplayGUI(); - myDisplayGUI->OnDisplayAll(true); - } - - if(myOkShape && myOkSelectSubMode) { - /* local context is defined into the method : 4 = FACES sub selection */ - DisplayGUI* myDisplayGUI = new DisplayGUI(); - myDisplayGUI->PrepareSubShapeSelection(int(TopAbs_FACE), myLocalContextId); - myUseLocalContext = true; - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_SELECT_FACE")); - } - } - else - GroupPoints->CheckButton1->setChecked(false); - return; + const int objL = myObjects->length(), facesL = myFaces.size(); + return ( objL && objL == facesL ); } +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool RepairGUI_SuppressFacesDlg::execute( ObjectList& objects ) +{ + QStringList anErrorObjNames; + for ( int i = 0; i < myObjects->length(); i++ ) + { + GEOM::GEOM_Object_var obj = myObjects[i]; + GEOM::short_array faces = myFaces[i]; + //MESSAGE(">>>> Dlg, passing faces.. len = " << faces.length()); + GEOM::GEOM_Object_var anObj = GEOM::GEOM_IHealingOperations::_narrow( getOperation() )->SuppressFaces( obj, faces ); + if ( anObj->_is_nil() ) + anErrorObjNames << GEOMBase::GetName( obj ); + else + objects.push_back( anObj._retn() ); + } + if ( !anErrorObjNames.empty() ) + MESSAGE("ERRORS occured while processing the following objects: " << anErrorObjNames.join( " " )); + + return anErrorObjNames.size() < myObjects->length(); // true if at least one object was OK, false if ALL objects were nil after Healing. +} //================================================================================= -// function : ResetStateOfDialog() -// purpose : Completely reset the state of method including local context +// function : initSelection +// purpose : //================================================================================= -void RepairGUI_SuppressFacesDlg::ResetStateOfDialog() +void RepairGUI_SuppressFacesDlg::initSelection() { - myOkShape = false ; - myEditCurrentArgument->setText(""); - - /* Select sub shapes mode not checked */ - myOkSelectSubMode = false; - GroupPoints->CheckButton1->setChecked(FALSE); - - /* Close its local contact if opened */ - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - myIC = v3d->getAISContext(); - if(myUseLocalContext) { - myIC->CloseLocalContext(myLocalContextId); - myUseLocalContext = false; - } - DisplayGUI* myDisplayGUI = new DisplayGUI(); - myDisplayGUI->OnDisplayAll(true); - } - return; + GEOM::GEOM_Object_var aNullGeomObject; + localSelection( aNullGeomObject, TopAbs_FACE ); // load local selection on ALL objects } diff --git a/src/RepairGUI/RepairGUI_SuppressFacesDlg.h b/src/RepairGUI/RepairGUI_SuppressFacesDlg.h index 4c92a694c..a164e3577 100644 --- a/src/RepairGUI/RepairGUI_SuppressFacesDlg.h +++ b/src/RepairGUI/RepairGUI_SuppressFacesDlg.h @@ -30,9 +30,9 @@ #define DIALOGBOX_SUPPRESSFACES_H #include "GEOMBase_Skeleton.h" -#include "DlgRef_1Sel1Check_QTD.h" +#include "DlgRef_1Sel_QTD.h" -#include "RepairGUI.h" +#include //================================================================================= // class : RepairGUI_SuppressFacesDlg @@ -43,42 +43,43 @@ class RepairGUI_SuppressFacesDlg : public GEOMBase_Skeleton Q_OBJECT public: - RepairGUI_SuppressFacesDlg(QWidget* parent = 0, const char* name = 0, RepairGUI* theRepairGUI = 0, SALOME_Selection* Sel = 0, Handle(AIS_InteractiveContext) ic = 0, bool modal = FALSE, WFlags fl = 0); - + RepairGUI_SuppressFacesDlg(QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); ~RepairGUI_SuppressFacesDlg(); +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& ); + virtual bool execute( ObjectList& objects ); + private : - void Init(Handle(AIS_InteractiveContext) ic); + void Init(); void enterEvent(QEvent* e); void closeEvent(QCloseEvent* e); - void ResetStateOfDialog(); - - RepairGUI* myRepairGUI; - - /* Interactive and local context management see also : bool myUseLocalContext() */ - Handle(AIS_InteractiveContext) myIC; /* Interactive context */ - Standard_Integer myLocalContextId; /* identify a local context used by this method */ - bool myUseLocalContext; /* true when this method as opened a local context */ + GEOM::ListOfGO_var myObjects; + QValueList myFaces; + // GEOM::short_array-s contain indexes of selected faces, + // index of a GEOM::short_array in myFaces list equals to index of + // GEOM::GEOM_Object in myObjects list to which the faces belong to. + + void Convert( const TColStd_IndexedMapOfInteger&, GEOM::short_array& ); - TopoDS_Shape myShape; - char* myShapeIOR; - bool myOkShape; - bool myOkSelectSubMode; /* true = sub mode selection activated */ - - DlgRef_1Sel1Check_QTD* GroupPoints; + void initSelection(); + + DlgRef_1Sel_QTD* GroupPoints; private slots: void ClickOnOk(); - void ClickOnApply(); + bool ClickOnApply(); void ClickOnCancel(); + void ActivateThisDialog(); void DeactivateActiveDialog(); + void LineEditReturnPressed(); void SelectionIntoArgument(); void SetEditCurrentArgument(); - void ActivateUserSelection(); - }; #endif // DIALOGBOX_SUPPRESSFACES_H diff --git a/src/RepairGUI/RepairGUI_SuppressHoleDlg.cxx b/src/RepairGUI/RepairGUI_SuppressHoleDlg.cxx deleted file mode 100644 index 8a7a36b1e..000000000 --- a/src/RepairGUI/RepairGUI_SuppressHoleDlg.cxx +++ /dev/null @@ -1,748 +0,0 @@ -// 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_SuppressHoleDlg.cxx -// Author : Lucien PIGNOLONI -// Module : GEOM -// $Header$ - -using namespace std; -#include "RepairGUI_SuppressHoleDlg.h" - -#include "DisplayGUI.h" - -#include "QAD_RightFrame.h" -#include "OCCViewer_Viewer3d.h" - -#include - -//================================================================================= -// class : RepairGUI_SuppressHoleDlg() -// purpose : Constructs a RepairGUI_SuppressHoleDlg 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_SuppressHoleDlg::RepairGUI_SuppressHoleDlg(QWidget* parent, const char* name, RepairGUI* theRepairGUI, SALOME_Selection* Sel, Handle(AIS_InteractiveContext) ic, 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_SUPRESS_HOLE"))); - QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_SUPRESS_HOLE_FACE_SHELL"))); - QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); - - setCaption(tr("GEOM_SUPPRESSHOLE_TITLE")); - - /***************************************************************/ - GroupConstructors->setTitle(tr("")); - RadioButton1->setPixmap(image0); - RadioButton2->setPixmap(image1); - RadioButton3->close(TRUE); - - Group1 = new DlgRef_1Sel3Check_QTD(this, "Group1"); - Group1->GroupBox1->setTitle(tr("")); - Group1->TextLabel1->setText(tr("GEOM_MAIN_OBJECT")); - Group1->CheckButton1->setText(tr("GEOM_SUPPRESSHOLE_SELECTFACE")); - Group1->CheckButton2->setText(tr("GEOM_SUPPRESSHOLE_SELECTWIRE")); - Group1->CheckButton3->setText(tr("GEOM_SUPPRESSHOLE_SELECTFACE_END")); - Group1->PushButton1->setPixmap(image2); - - Group2 = new DlgRef_1Sel1Check_QTD(this, "Group2"); - Group2->GroupBox1->setTitle(tr("")); - Group2->TextLabel1->setText(tr("GEOM_SUPPRESSHOLE_FACE_SHELL")); - Group2->CheckButton1->setText(tr("GEOM_SUPPRESSHOLE_SELECT_HOLES_ON_FACE")); - Group2->PushButton1->setPixmap(image2); - - Layout1->addWidget(Group1, 1, 0); - Layout1->addWidget(Group2, 1, 0); - /***************************************************************/ - - /* Initialisations */ - myRepairGUI = theRepairGUI; - Init(ic); -} - - -//================================================================================= -// function : ~RepairGUI_SuppressHoleDlg() -// purpose : Destroys the object and frees any allocated resources -//================================================================================= -RepairGUI_SuppressHoleDlg::~RepairGUI_SuppressHoleDlg() -{ - // no need to delete child widgets, Qt does it all for us -} - - -//================================================================================= -// function : Init() -// purpose : -//================================================================================= -void RepairGUI_SuppressHoleDlg::Init(Handle (AIS_InteractiveContext) ic) -{ - /* init variables */ - myConstructorId = 0; - myEditCurrentArgument = Group1->LineEdit1; - - myIC = ic; - myUseLocalContext = myOkShape = myOkSelectFace = false; - myLocalContextId = -1; - - myListOfIdFace = new GEOM::GEOM_Shape::ListOfSubShapeID; - myListOfIdWire = new GEOM::GEOM_Shape::ListOfSubShapeID; - myListOfIdEndFace = new GEOM::GEOM_Shape::ListOfSubShapeID; - - myListOfIdFace->length(0); - myListOfIdWire->length(0); - myListOfIdEndFace->length(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(GroupConstructors, SIGNAL(clicked(int)), this, SLOT(ConstructorsClicked(int))); - - connect(Group1->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect(Group2->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect(Group1->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(Group2->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - - connect(Group1->CheckButton1, SIGNAL(stateChanged(int)), this, SLOT(ActivateUserFaceSelection())); - connect(Group1->CheckButton2, SIGNAL(stateChanged(int)), this, SLOT(ActivateUserWireSelection())); - connect(Group1->CheckButton3, SIGNAL(stateChanged(int)), this, SLOT(ActivateUserEndFaceSelection())); - connect(Group2->CheckButton1, SIGNAL(stateChanged(int)), this, SLOT(ActivateUserWiresOnFaceShellSelection())); - - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - - /* displays Dialog */ - Group2->hide(); - Group1->show(); - this->show(); - - return; -} - - -//================================================================================= -// function : ConstructorsClicked() -// purpose : Radio button management -//================================================================================= -void RepairGUI_SuppressHoleDlg::ConstructorsClicked(int constructorId) -{ - myConstructorId = constructorId; - disconnect(mySelection, 0, this, 0); - myOkShape = false; - - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC && myUseLocalContext) { - myIC->CloseLocalContext(myLocalContextId); - DisplayGUI* myDisplayGUI = new DisplayGUI(); - myDisplayGUI->OnDisplayAll(true); - myUseLocalContext = false; - } - - switch (constructorId) - { - case 0: - { - Group2->hide(); - resize(0, 0); - Group1->show(); - - myEditCurrentArgument = Group1->LineEdit1; - Group1->LineEdit1->setText(""); - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - - myOkSelectFace = false; - this->ResetPartial(); - break; - } - case 1: - { - Group1->hide(); - resize(0, 0); - Group2->show(); - - myEditCurrentArgument = Group2->LineEdit1; - Group2->LineEdit1->setText(""); - - this->ResetPartial(); - connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - this->ResetPartial(); - break; - } - } - return; -} - - -//================================================================================= -// function : ClickOnOk() -// purpose : Same than click on apply but close this dialog. -//================================================================================= -void RepairGUI_SuppressHoleDlg::ClickOnOk() -{ - this->ClickOnApply(); - this->ClickOnCancel(); - return; -} - - -//================================================================================= -// function : ClickOnApply() -// purpose : -//================================================================================= -void RepairGUI_SuppressHoleDlg::ClickOnApply() -{ - QAD_Application::getDesktop()->putInfo(tr("")); - bool testResult = false; - - if(!myOkShape) - return; - - switch (myConstructorId) - { - case 0: /* default constructor */ - { - if(!myOkSelectFace) - return; - - if(Group1->CheckButton2->isChecked()) { - if(!Group1->CheckButton3->isChecked()) { - /* Call method to get sub shape selection of GEOM::WIRE */ - bool aTest = this->GetIndexSubShapeSelected(myFace, int(TopAbs_WIRE), myListOfIdWire, myLocalContextId, myUseLocalContext); - - /* Display all objects so that next method using ic can memorize them */ - DisplayGUI* myDisplayGUI = new DisplayGUI(); - myDisplayGUI->OnDisplayAll(true); - - if(!aTest || myListOfIdWire->length() != 1) { - Group1->CheckButton2->setChecked(FALSE); - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_ABORT")); - } - else { - myListOfIdEndFace->length(0); /* no end face */ - QApplication::setOverrideCursor(Qt::waitCursor); - testResult = myRepairGUI->OnSuppressHole(myShapeIOR, myListOfIdFace, myListOfIdWire, myListOfIdEndFace); - QApplication::restoreOverrideCursor(); - } - } - else { /* Group1->CheckButton3->isChecked() */ - - /* Call method to get sub shape selection of END GEOM::FACE */ - bool aTest = this->GetIndexSubShapeSelected(myShape, int(TopAbs_FACE), myListOfIdEndFace, myLocalContextId, myUseLocalContext); - - /* Display all objects so that next method using ic can memorize them */ - DisplayGUI* myDisplayGUI = new DisplayGUI(); - myDisplayGUI->OnDisplayAll(true); - - if(!aTest || myListOfIdEndFace->length() != 1) { - Group1->CheckButton3->setChecked(FALSE); - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_ABORT")); - } - else { - QApplication::setOverrideCursor(Qt::waitCursor); - testResult = myRepairGUI->OnSuppressHole(myShapeIOR, myListOfIdFace, myListOfIdWire, myListOfIdEndFace); - QApplication::restoreOverrideCursor(); - } - } - } - break; - } - case 1: /* second constructor */ - { - if(Group2->CheckButton1->isChecked()) { - /* Call method to get sub shape selection of one or more GEOM::WIRE(s) on a face or a shell */ - bool aTest = this->GetIndexSubShapeSelected(myShape, int(TopAbs_WIRE), myListOfIdWire, myLocalContextId, myUseLocalContext); - - /* Display all objects so that next method using ic can memorize them */ - DisplayGUI* myDisplayGUI = new DisplayGUI(); - myDisplayGUI->OnDisplayAll(true); - - if(!aTest || myListOfIdWire->length() < 1) { - Group2->CheckButton1->setChecked(FALSE); - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_ABORT")); - } - else { - QApplication::setOverrideCursor(Qt::waitCursor); - testResult = myRepairGUI->OnSuppressHolesInFaceOrShell(myShapeIOR, myListOfIdWire); - QApplication::restoreOverrideCursor(); - } - } - break; - } - } - - - if(!testResult) - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_ABORT")); - else - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); - - /* Reset arguments to allow a new selection */ - this->ResetStateOfDialog(); - return; -} - - -//================================================================================= -// function : ClickOnCancel() -// purpose : -//================================================================================= -void RepairGUI_SuppressHoleDlg::ClickOnCancel() -{ - this->ResetStateOfDialog(); - GEOMBase_Skeleton::ClickOnCancel(); - return; -} - - -//================================================================================= -// function : SelectionIntoArgument() -// purpose : Called when selection as changed or other case -// : used only by SelectButtonC1A1 and SelectButtonC2A1 -//================================================================================= -void RepairGUI_SuppressHoleDlg::SelectionIntoArgument() -{ - myEditCurrentArgument->setText(""); - this->ResetStateOfDialog(); - QString aString = ""; /* name of selection */ - - int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString); - if(nbSel != 1) - return; - - /* nbSel == 1 */ - TopoDS_Shape S; - Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); - - if(!myGeomBase->GetTopoFromSelection(mySelection, S)) - return; - - if(S.IsNull() || S.ShapeType() == TopAbs_VERTEX || S.ShapeType() == TopAbs_EDGE || S.ShapeType() == TopAbs_WIRE) - return; - - /* Test the exact type of topology to suppress faces into. */ - /* For the second constructor a face or shell selection is needed */ - if(myConstructorId == 0 || (myConstructorId == 1 && (S.ShapeType() == TopAbs_FACE || S.ShapeType() == TopAbs_SHELL))) { - if(IO->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject))) { - Handle(GEOM_InteractiveObject) GIObject = Handle(GEOM_InteractiveObject)::DownCast(IO); - - /* The Geom IOR string of selection */ - myShapeIOR = GIObject->getIOR(); - myEditCurrentArgument->setText(aString); - myShape = S; - myOkShape = true; - return; - } - - if(IO->hasEntry()) { - SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument(); - SALOMEDS::SObject_var obj = aStudy->FindObjectID(IO->getEntry()); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeIOR_var anIOR; - if(!obj->_is_nil()) { - if(obj->FindAttribute(anAttr, "AttributeIOR")) { - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - myShapeIOR = anIOR->Value(); - myOkShape = true; - myShape = S; - myEditCurrentArgument->setText(aString); - return; - } - } - } - - } - return; -} - - -//================================================================================= -// function : SetEditCurrentArgument() -// purpose : -//================================================================================= -void RepairGUI_SuppressHoleDlg::SetEditCurrentArgument() -{ - QPushButton* send = (QPushButton*)sender(); - - if(send == Group1->PushButton1) { - Group1->LineEdit1->setFocus(); - myEditCurrentArgument = Group1->LineEdit1; - } - else if(send == Group2->PushButton1) { - Group2->LineEdit1->setFocus(); - myEditCurrentArgument = Group2->LineEdit1; - } - this->SelectionIntoArgument(); - return; -} - - -//================================================================================= -// function : LineEditReturnPressed() -// purpose : -//================================================================================= -void RepairGUI_SuppressHoleDlg::LineEditReturnPressed() -{ - QLineEdit* send = (QLineEdit*)sender(); - if(send == Group1->LineEdit1) - myEditCurrentArgument = Group1->LineEdit1; - else if (send == Group2->LineEdit1) - myEditCurrentArgument = Group2->LineEdit1; - else - return; - - GEOMBase_Skeleton::LineEditReturnPressed(); - return; -} - - -//================================================================================= -// function : DeactivateActiveDialog() -// purpose : -//================================================================================= -void RepairGUI_SuppressHoleDlg::DeactivateActiveDialog() -{ - this->ResetStateOfDialog(); - GEOMBase_Skeleton::DeactivateActiveDialog(); - return; -} - - -//================================================================================= -// function : ActivateThisDialog() -// purpose : -//================================================================================= -void RepairGUI_SuppressHoleDlg::ActivateThisDialog() -{ - GEOMBase_Skeleton::ActivateThisDialog(); - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - return; -} - - -//================================================================================= -// function : enterEvent() -// purpose : Mouse enter onto the dialog to activate it -//================================================================================= -void RepairGUI_SuppressHoleDlg::enterEvent(QEvent* e) -{ - if(GroupConstructors->isEnabled()) - return; - this->ActivateThisDialog(); - return; -} - - -//================================================================================= -// function : closeEvent() -// purpose : -//================================================================================= -void RepairGUI_SuppressHoleDlg::closeEvent(QCloseEvent* e) -{ - /* same than click on cancel button */ - this->ClickOnCancel(); - return; -} - - -//================================================================================= -// function : ActivateUserFaceSelection() -// purpose : Called when CheckBox1 state has changed. (Face selection is ckecked) -// : Be careful user must first select a face then a wire ! -//================================================================================= -void RepairGUI_SuppressHoleDlg::ActivateUserFaceSelection() -{ - if(!this->myOkShape) { - this->ResetStateOfDialog(); - QAD_Application::getDesktop()->putInfo(tr("GEOM_MAIN_OBJECT")); - return; - } - - if(Group1->CheckButton1->isChecked()) { - /* local context is opened into the method : Prepare GEOM::FACE sub selection */ - DisplayGUI* myDisplayGUI = new DisplayGUI(); - myDisplayGUI->PrepareSubShapeSelection(int(TopAbs_FACE), myLocalContextId); - myUseLocalContext = true; - QAD_Application::getDesktop()->putInfo(tr("GEOM_SUPPRESSHOLE_SELECTFACE")); - } - else - this->ResetPartial(); - - return; -} - - -//================================================================================= -// function : ActivateUserWireSelection() -// purpose : Called when CheckBox2 state has changed. (Wire selection is ckecked) -// : Be careful user must first select a face then a wire ! -//================================================================================= -void RepairGUI_SuppressHoleDlg::ActivateUserWireSelection() -{ - - if(!myOkShape) { - this->ResetStateOfDialog(); - QAD_Application::getDesktop()->putInfo(tr("GEOM_MAIN_OBJECT")); - return; - } - - if(Group1->CheckButton1->isChecked()) { - /* Get sub shape selection GEOM::FACE : local context is closed */ - bool aTest = this->GetIndexSubShapeSelected(myShape, int(TopAbs_FACE), myListOfIdFace, myLocalContextId, myUseLocalContext); - - /* Display all objects so that next method using ic can memorize them */ - DisplayGUI* myDisplayGUI = new DisplayGUI(); - myDisplayGUI->OnDisplayAll(true); - if(!aTest || myListOfIdFace->length() != 1) { - Group1->CheckButton1->setChecked(FALSE); - myOkSelectFace = false; - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_ABORT")); - } - else - myOkSelectFace = true; - } - else { - this->ResetPartial(); - return; - } - - - if(Group1->CheckButton2->isChecked()) { - /* Get the face selection */ - myFace = FaceFromList(myShape, myListOfIdFace); - /* Local context is opened into the method : Prepare GEOM::WIRE sub selection into a face */ - DisplayGUI* myDisplayGUI = new DisplayGUI(); - myDisplayGUI->PrepareSubShapeSelectionArgumentShape(myFace, int(TopAbs_WIRE), myLocalContextId); - myUseLocalContext = true; - QAD_Application::getDesktop()->putInfo(tr("GEOM_SUPPRESSHOLE_SELECTWIRE")); - } - else { - this->ResetPartial(); - } - return; -} - - -//================================================================================= -// function : ActivateUserlEndFaceSelection() -// purpose : Called when CheckBox3 state has changed. ( Optional End Face selection ) -// : Be careful user must first select a face then a wire then this optional end face ! -//================================================================================= -void RepairGUI_SuppressHoleDlg::ActivateUserEndFaceSelection() -{ - - if(!myOkShape) { - this->ResetStateOfDialog(); - QAD_Application::getDesktop()->putInfo(tr("GEOM_MAIN_OBJECT")); - return; - } - - if(Group1->CheckButton2->isChecked()) { - /* Call method to get sub shape selection for the GEOM::WIRE into myFace : local context is closed */ - bool aTest = this->GetIndexSubShapeSelected(myFace, int(TopAbs_WIRE), myListOfIdWire, myLocalContextId, myUseLocalContext); - - /* Display all objects so that next method using ic can memorize them */ - DisplayGUI* myDisplayGUI = new DisplayGUI(); - myDisplayGUI->OnDisplayAll(true); - - if(!aTest || myListOfIdWire->length() != 1) { - Group1->CheckButton2->setChecked(FALSE); - Group1->CheckButton3->setChecked(FALSE); - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_ABORT")); - return; - } - } - else { - this->ResetPartial(); - return; - } - - - if(Group1->CheckButton3->isChecked()) { - /* Local context is opened into the method : prepare GEOM::FACE(end) into myShape sub selection */ - DisplayGUI* myDisplayGUI = new DisplayGUI(); - myDisplayGUI->PrepareSubShapeSelectionArgumentShape(myShape, int(TopAbs_FACE), myLocalContextId); - myUseLocalContext = true; - QAD_Application::getDesktop()->putInfo(tr("GEOM_SUPPRESSHOLE_SELECTFACE_END")); - } - else - this->ResetPartial(); - return; -} - - -//================================================================================= -// function : ActivateUserWiresOnFaceShellSelection() -// purpose : Called when CheckBoxC2_1 state has changed. -// : Only for second constructor ! -// : Prepare selection for wire(s) on main object that is a face or a shell -//================================================================================= -void RepairGUI_SuppressHoleDlg::ActivateUserWiresOnFaceShellSelection() -{ - - if(!myOkShape) { - this->ResetStateOfDialog(); - QAD_Application::getDesktop()->putInfo(tr("GEOM_MAIN_OBJECT")); - return; - } - - if(Group2->CheckButton1->isChecked()) { - /* Local context is opened to prepare GEOM::WIRE(S) selection into 'myShape' that is a (main) face */ - DisplayGUI* myDisplayGUI = new DisplayGUI(); - myDisplayGUI->PrepareSubShapeSelectionArgumentShape(myShape, int(TopAbs_WIRE), myLocalContextId); - myUseLocalContext = true; - QAD_Application::getDesktop()->putInfo(tr("GEOM_SUPPRESSHOLE_SELECT_HOLES_ON_FACE")); - } - else - this->ResetPartial(); - return; -} - - -//================================================================================= -// function : FaceFromList() -// purpose : Return the face (selected by user) that is a sub shape of 'aShape' -// : and which unique index is in 'ListOfSub'. -// : This allows opening a local context with this face loaded. -// : See : myGeomBase->PrepareSubShapeSelectionArgumentShape(...) -//================================================================================= -TopoDS_Shape RepairGUI_SuppressHoleDlg::FaceFromList(const TopoDS_Shape& aShape, - const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfSub) -{ - TopoDS_Shape tds; - tds.Nullify(); - if(ListOfSub.length() != 1 || aShape.IsNull()) - return tds; - - int i = ListOfSub[0]; - TopExp_Explorer exp; - int j = 1; - for(exp.Init(aShape, TopAbs_FACE); exp.More(); exp.Next()) { - if(j == i) - return exp.Current(); - j++; - } - return tds; -} - - -//================================================================================= -// function : ResetStateOfDialog() -// purpose : Completely reset the state of method including local context -//================================================================================= -void RepairGUI_SuppressHoleDlg::ResetStateOfDialog() -{ - myOkShape = false; - myEditCurrentArgument->setText(""); - QApplication::restoreOverrideCursor(); - - /* Partial reset and more ...*/ - this->ResetPartial(); - - return; -} - - -//================================================================================= -// function : ResetPartial() -// purpose : Partially reset to keep only main selection -//================================================================================= -void RepairGUI_SuppressHoleDlg::ResetPartial() -{ - /* Select sub shape modes not checked */ - myOkSelectFace = false ; - Group1->CheckButton1->setChecked(FALSE); - Group1->CheckButton2->setChecked(FALSE); - Group1->CheckButton3->setChecked(FALSE); - Group2->CheckButton1->setChecked(FALSE); - - myListOfIdFace->length(0); - myListOfIdWire->length(0); - myListOfIdEndFace->length(0); - - /* Close its local contact if opened */ - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC && myUseLocalContext) { - myIC->CloseLocalContext(myLocalContextId); - myUseLocalContext = false; - DisplayGUI* myDisplayGUI = new DisplayGUI(); - myDisplayGUI->OnDisplayAll(true); - } - return; -} - - -//===================================================================================== -// function : GetIndexSubShapeSelected() -// purpose : Define a ListOfID of sub shapes selected in ShapeTopo with SubShapeType -// : Method used by Dialogs -//===================================================================================== -bool RepairGUI_SuppressHoleDlg::GetIndexSubShapeSelected(const TopoDS_Shape& ShapeTopo, const int SubShapeType, GEOM::GEOM_Shape::ListOfSubShapeID& ListOfID, Standard_Integer& aLocalContextId, bool& myUseLocalContext) -{ - //* Test the type of viewer */ - if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC) - return false; - - OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - Handle(AIS_InteractiveContext) ic = v3d->getAISContext(); - - ic->InitSelected(); - int nbSelected = ic->NbSelected(); - ListOfID.length(nbSelected); - - //***************** DEFINE INDEX OF EACH SELECTION *********************// - int i = 0; - ic->InitSelected(); /* to restart */ - while(ic->MoreSelected()) { - /* Find index of sub shape into main shape */ - TopExp_Explorer Exp (ShapeTopo, TopAbs_ShapeEnum(SubShapeType)); - int index = 1; - bool found = false; - while( Exp.More()) { - if((Exp.Current()).IsSame(ic->SelectedShape())) { - found = true; - break; - } - index++; - Exp.Next(); - } - if(!found) { - /* Manage local context from DialogBox */ - ic->CloseLocalContext(aLocalContextId); - myUseLocalContext = false; - return false; - } - ListOfID[i] = index; - i++; - ic->NextSelected(); - } - //***************** END *********************// - - /* Manage local context from DialogBox */ - ic->CloseLocalContext(aLocalContextId); - myUseLocalContext = false; - - return true; -} diff --git a/src/RepairGUI/RepairGUI_SuppressHoleDlg.h b/src/RepairGUI/RepairGUI_SuppressHoleDlg.h deleted file mode 100644 index ddc476099..000000000 --- a/src/RepairGUI/RepairGUI_SuppressHoleDlg.h +++ /dev/null @@ -1,112 +0,0 @@ -// 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_SuppressHoleDlg.h -// Author : Lucien PIGNOLONI -// Module : GEOM -// $Header$ - -#ifndef GEOMETRYGUI_SUPPRESSHOLE_H -#define GEOMETRYGUI_SUPPRESSHOLE_H - -#include "GEOMBase_Skeleton.h" -#include "DlgRef_1Sel1Check_QTD.h" -#include "DlgRef_1Sel3Check_QTD.h" - -#include "RepairGUI.h" - -//================================================================================= -// class : RepairGUI_SuppressHoleDlg -// purpose : -//================================================================================= -class RepairGUI_SuppressHoleDlg : public GEOMBase_Skeleton -{ - Q_OBJECT - -public: - RepairGUI_SuppressHoleDlg(QWidget* parent = 0, const char* name = 0, RepairGUI* theRepairGUI = 0, SALOME_Selection* Sel = 0, Handle(AIS_InteractiveContext) ic = 0, bool modal = FALSE, WFlags fl = 0); - ~RepairGUI_SuppressHoleDlg(); - -private : - void Init(Handle(AIS_InteractiveContext) ic); - void enterEvent(QEvent* e); - void closeEvent(QCloseEvent* e); - - void ResetStateOfDialog(); - void ResetPartial(); - - RepairGUI* myRepairGUI; - - int myConstructorId; /* Current constructor id = radio button id */ - - /* Define a list of indices of sub shapes selected in a local context */ - bool GetIndexSubShapeSelected(const TopoDS_Shape& ShapeTopo, const int SubShapeType, - GEOM::GEOM_Shape::ListOfSubShapeID& ListOfID, - Standard_Integer& aLocalContextId, bool& myUseLocalContext); - - /* Return the face selected by user from the main shape and index in a ListOfSub */ - TopoDS_Shape FaceFromList(const TopoDS_Shape& aShape, - const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfSub); - - /* Interactive and local context management see also : bool myUseLocalContext() */ - Handle(AIS_InteractiveContext) myIC; /* Interactive context */ - Standard_Integer myLocalContextId; /* identify a local context used by this method */ - bool myUseLocalContext; /* true when this method as opened a local context */ - - TopoDS_Shape myShape; /* Main shape selected */ - TopoDS_Shape myFace; /* Face selected */ - - char* myShapeIOR; - bool myOkShape; - - bool myOkSelectFace; /* true = sub mode GEOM::FACE selection done */ - bool myOkSelectWire; /* true = sub mode GEOM::WIRE selection done (first wire) */ - - /* After selection contains index of face into myShape, wire into myFace, end face into myShape*/ - GEOM::GEOM_Shape::ListOfSubShapeID_var myListOfIdFace; - GEOM::GEOM_Shape::ListOfSubShapeID_var myListOfIdWire; - GEOM::GEOM_Shape::ListOfSubShapeID_var myListOfIdEndFace; - - DlgRef_1Sel3Check_QTD* Group1; - DlgRef_1Sel1Check_QTD* Group2; - -private slots: - void ClickOnOk(); - void ClickOnApply(); - void ClickOnCancel(); - void ActivateThisDialog(); - void DeactivateActiveDialog(); - void LineEditReturnPressed(); - void SelectionIntoArgument(); - void SetEditCurrentArgument(); - void ConstructorsClicked(int constructorId); - void ActivateUserFaceSelection(); - void ActivateUserWireSelection(); - void ActivateUserEndFaceSelection(); - - /* For the second constructor */ - void ActivateUserWiresOnFaceShellSelection() ; - -}; - -#endif // GEOMETRYGUI_SUPPRESSHOLE_H diff --git a/src/SKETCHER/Sketcher_Profile.cxx b/src/SKETCHER/Sketcher_Profile.cxx index 4df75a7bf..acd72451f 100644 --- a/src/SKETCHER/Sketcher_Profile.cxx +++ b/src/SKETCHER/Sketcher_Profile.cxx @@ -49,6 +49,8 @@ using namespace std; #include #include CORBA_SERVER_HEADER(SALOMEDS) +#include "utilities.h" + //======================================================================= // profile // command to build a profile @@ -116,7 +118,7 @@ Sketcher_Profile::Sketcher_Profile(const char* aCmd) { if (n1 != 3) goto badargs; if (!first) { - cout<<"profile : The F instruction must precede all moves"<D1(angle,p,v); @@ -360,14 +368,25 @@ Sketcher_Profile::Sketcher_Profile(const char* aCmd) } // get the result, face or wire - if (move == none) + if (move == none) { return; - else if (move == point) + } else if (move == point) { S = MP; - else if (face) - S = BRepBuilderAPI_MakeFace(P, MW.Wire()); - else + } else if (face) { + if (!MW.IsDone()) { + return; + } + BRepBuilderAPI_MakeFace MF (P, MW.Wire()); + if (!MF.IsDone()) { + return; + } + S = MF; + } else { + if (!MW.IsDone()) { + return; + } S = MW; + } if(!TheLocation.IsIdentity()) S.Move(TheLocation); @@ -377,6 +396,6 @@ Sketcher_Profile::Sketcher_Profile(const char* aCmd) return; badargs : - cout<<"profile : bad number of arguments"< + +#include "utilities.h" + +#include + +#include + +#include +#include + +//============================================================================= +/*! + * + */ +//============================================================================= + +extern "C" +{ +#ifdef WNT + __declspec(__dllexport) +#endif + int Export(const TopoDS_Shape& theShape, const TCollection_AsciiString& theFileName) + { + MESSAGE("Export STEP into file " << theFileName.ToCString()); + + try + { + IFSelect_ReturnStatus status ; + //VRV: OCC 4.0 migration + STEPControl_Writer aWriter; +//JFA: PAL6162 status = aWriter.Transfer( theShape, STEPControl_ManifoldSolidBrep ); + status = aWriter.Transfer( theShape, STEPControl_AsIs ); + //VRV: OCC 4.0 migration + if ( status == IFSelect_RetDone ) + status = aWriter.Write( theFileName.ToCString() ) ; + if ( status == IFSelect_RetDone ) + return 1; + } + catch(Standard_Failure) + { + //THROW_SALOME_CORBA_EXCEPTION("Exception catched in STEPExport", SALOME::BAD_PARAM); + } + return 0; + } +} diff --git a/src/STEPImport/Makefile.in b/src/STEPImport/Makefile.in new file mode 100644 index 000000000..4881cc07b --- /dev/null +++ b/src/STEPImport/Makefile.in @@ -0,0 +1,45 @@ +# Copyright (C) 2003 CEA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org or email : webmaster.salome@opencascade.org +# +# +# +# File : Makefile.in +# Author : Pavel TELKOV +# Module : GEOM +# $Header$ + +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + +@COMMENCE@ + +# Libraries targets + +LIB= libSTEPImport.la + +LIB_SRC = STEPImport.cxx + +# additionnal information to compil and link file +CPPFLAGS+= $(OCC_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome +CXXFLAGS+= $(OCC_CXXFLAGS) -I${KERNEL_ROOT_DIR}/include/salome + +LDFLAGS+= $(CAS_LDPATH) -lTKSTEP -L${KERNEL_ROOT_DIR}/lib/salome + +@CONCLUDE@ diff --git a/src/STEPImport/STEPImport.cxx b/src/STEPImport/STEPImport.cxx new file mode 100644 index 000000000..02a0dd823 --- /dev/null +++ b/src/STEPImport/STEPImport.cxx @@ -0,0 +1,110 @@ +// File: STEPImport.cxx +// Created: Wed May 19 14:41:10 2004 +// Author: Pavel TELKOV +// + +#include "utilities.h" + +#include + +#include + +#include + +#include +#include +#include + +#include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC + +//============================================================================= +/*! + * Import() + */ +//============================================================================= + +extern "C" +{ +#ifdef WNT + __declspec(__dllexport) +#endif + TopoDS_Shape Import (const TCollection_AsciiString& theFileName, + TCollection_AsciiString& theError) + { + MESSAGE("Import STEP model from file " << theFileName.ToCString()); + TopoDS_Shape aResShape; + //VRV: OCC 4.0 migration + STEPControl_Reader aReader; + //VRV: OCC 4.0 migration + TopoDS_Compound compound; + BRep_Builder B; + B.MakeCompound( compound ); + try { + IFSelect_ReturnStatus status = aReader.ReadFile(theFileName.ToCString()); + + if (status == IFSelect_RetDone) { + Standard_Boolean failsonly = Standard_False ; + aReader.PrintCheckLoad (failsonly, IFSelect_ItemsByEntity); + /* Root transfers */ + Standard_Integer nbr = aReader.NbRootsForTransfer(); + aReader.PrintCheckTransfer (failsonly, IFSelect_ItemsByEntity); + + for ( Standard_Integer n=1; n <= nbr; n++) { + Standard_Boolean ok = aReader.TransferRoot(n); + /* Collecting resulting entities */ + Standard_Integer nbs = aReader.NbShapes(); + if (!ok || nbs == 0) + { + // THROW_SALOME_CORBA_EXCEPTION("Exception catched in GEOM_Gen_i::ImportStep", SALOME::BAD_PARAM); + continue; // skip empty root + } + /* For a single entity */ + else if (nbr == 1 && nbs == 1) { + aResShape = aReader.Shape(1); + break; + } + + for ( Standard_Integer i=1; i<=nbs; i++ ) { + TopoDS_Shape aShape = aReader.Shape(i); + if ( aShape.IsNull() ) { + // THROW_SALOME_CORBA_EXCEPTION("Null shape in GEOM_Gen_i::ImportStep", SALOME::BAD_PARAM) ; + //return aResShape; + continue; + } + else { + B.Add( compound, aShape ) ; + } + } + } + if ( aResShape.IsNull() ) + aResShape = compound; + + } else { +// switch (status) { +// case IFSelect_RetVoid: +// theError = "Nothing created or No data to process"; +// break; +// case IFSelect_RetError: +// theError = "Error in command or input data"; +// break; +// case IFSelect_RetFail: +// theError = "Execution was run, but has failed"; +// break; +// case IFSelect_RetStop: +// theError = "Execution has been stopped. Quite possible, an exception was raised"; +// break; +// default: +// break; +// } + theError = "Wrong format of the imported file. Can't import file."; + aResShape.Nullify(); + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + theError = aFail->GetMessageString(); + aResShape.Nullify(); + } + return aResShape; + } +} diff --git a/src/ShHealOper/Makefile.in b/src/ShHealOper/Makefile.in new file mode 100644 index 000000000..efaf07c3c --- /dev/null +++ b/src/ShHealOper/Makefile.in @@ -0,0 +1,80 @@ +# GEOM ShHealOper : Shape Healing +# +# 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.salome-platform.org or email : webmaster.salome@opencascade.org +# +# +# +# File : Makefile.in +# Author : Alexander SLADKOV +# Module : GEOM +# $Header: + +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@ + + +@COMMENCE@ + +# Libraries targets +LIB = libShHealOper.la + +LIB_SRC = \ + ShHealOper_CloseContour.cxx \ + ShHealOper_EdgeDivide.cxx \ + ShHealOper_FillHoles.cxx \ + ShHealOper_RemoveFace.cxx \ + ShHealOper_RemoveInternalWires.cxx \ + ShHealOper_Sewing.cxx \ + ShHealOper_ShapeProcess.cxx \ + ShHealOper_SplitCurve2d.cxx \ + ShHealOper_SplitCurve3d.cxx \ + ShHealOper_Tool.cxx \ + +LIB_CLIENT_IDL = +LIB_SERVER_IDL = + +# header files +EXPORT_HEADERS = \ + ShHealOper_CloseContour.hxx \ + ShHealOper_EdgeDivide.hxx \ + ShHealOper_FillHoles.hxx \ + ShHealOper_RemoveFace.hxx \ + ShHealOper_RemoveInternalWires.hxx \ + ShHealOper_Sewing.hxx \ + ShHealOper_ShapeProcess.hxx \ + ShHealOper_SpiltCurve2d.hxx \ + ShHealOper_SplitCurve2d.hxx \ + ShHealOper_SplitCurve3d.hxx \ + ShHealOper_Tool.hxx + +# idl files +EXPORT_IDLS= + +CPPFLAGS += $(OCC_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome +CXXFLAGS += $(OCC_CXXFLAGS) -I${KERNEL_ROOT_DIR}/include/salome + +LDFLAGS += $(CAS_LDPATH) -lTKernel -lTKGeomAlgo -lTKG3d -lTKG2d -lTKGeomBase -lTKShHealing -lTKMath -lTKBRep -lTKTopAlgo -lTKBool + +%_moc.cxx: %.h + $(MOC) $< -o $@ + +@CONCLUDE@ diff --git a/src/ShHealOper/ShHealOper_CloseContour.cxx b/src/ShHealOper/ShHealOper_CloseContour.cxx new file mode 100644 index 000000000..e5f008393 --- /dev/null +++ b/src/ShHealOper/ShHealOper_CloseContour.cxx @@ -0,0 +1,407 @@ +// File: ShHealOper_CloseContour.cxx +// Created: 20.04.04 11:36:01 +// Author: Galina KULIKOVA +// Copyright: Airbus Industries 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 +//======================================================================= +//function : ShHealOper_CloseContour() +//purpose : Constructor +//======================================================================= + +ShHealOper_CloseContour::ShHealOper_CloseContour (const TopoDS_Shape& theShape ) +{ + Init(theShape); +} +//======================================================================= +//function : Init +//purpose : +//======================================================================= + +void ShHealOper_CloseContour::Init(const TopoDS_Shape& theShape) +{ + ShHealOper_Tool::Init(theShape); + myTolerance = Precision::Confusion(); + myMaxTolerance = 1.0; + TopExp::MapShapesAndAncestors(theShape,TopAbs_EDGE,TopAbs_FACE,myMapEdgesFace); +} +//======================================================================= +//function : Perform +//purpose : +//======================================================================= + +Standard_Boolean ShHealOper_CloseContour::Perform(const TopTools_SequenceOfShape& theSeqEdges, + const Standard_Boolean theModeVertex, + const Standard_Boolean theModeFixGapsCurves) +{ + myFreeEdges.Clear(); + myDone = Standard_False; + myErrorStatus =ShHealOper_NotError; + if(myInitShape.IsNull()) { + myErrorStatus = ShHealOper_InvalidParameters; + return myDone; + } + Handle(ShapeExtend_WireData) asewd = new ShapeExtend_WireData; + Standard_Integer i =1; + for ( ; i <= theSeqEdges.Length(); i++) + asewd->Add(theSeqEdges.Value(i)); + + myModeVertex = theModeVertex; + myModeFixGapsCurves = theModeFixGapsCurves; + + build(asewd); + + return myDone; +} +//======================================================================= +//function : Perform +//purpose : +//======================================================================= + +Standard_Boolean ShHealOper_CloseContour::Perform(const TopoDS_Wire& theWire, + const Standard_Boolean theModeVertex, + const Standard_Boolean theModeFixGapsCurves) +{ + myFreeEdges.Clear(); + myDone = Standard_False; + if(myInitShape.IsNull()) { + myErrorStatus = ShHealOper_InvalidParameters; + return myDone; + } + Handle(ShapeExtend_WireData) asewd = new ShapeExtend_WireData(theWire); + myModeVertex = theModeVertex; + myModeFixGapsCurves = theModeFixGapsCurves; + build(asewd); + return myDone; +} +//======================================================================= +//function : Build +//purpose : +//======================================================================= + +void ShHealOper_CloseContour::build(Handle(ShapeExtend_WireData)& theSewd) +{ + TopTools_SequenceOfShape aCommonFaces; + //checks that all specified edges belong the one face or not. + Standard_Boolean isOneFace = checkOneFace(theSewd,aCommonFaces); + + //add edge or increase max tolerance in dependance on specified VertexMode. + //if all edges belong the one face that gap will be closed in the 2D by line + //else gap will be closed in the 3D by line. + myDone = fixGaps(theSewd,aCommonFaces); + updateWire(theSewd); + Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire; + sfw->SetContext(myContext); + sfw->Load(theSewd); + + sfw->ClosedWireMode() = Standard_True; + sfw->SetPrecision(myTolerance); + sfw->SetMaxTolerance(myMaxTolerance); + + if(isOneFace) { + Standard_Integer ii =1; + for( ; ii <= aCommonFaces.Length(); ii++) { + TopoDS_Face aFace = TopoDS::Face(aCommonFaces.Value(ii)); + sfw->SetFace(aFace); + myDone = (sfw->Perform() || myDone); + //if Mode for fix gaps is equal to true that + //curve 3D and curve 2D will be pull to each other. + if(myModeFixGapsCurves) { + Standard_Boolean isFixgaps = Standard_False; + if(ii ==1) { + sfw->FixGaps3d(); + isFixgaps = sfw->StatusGaps3d(ShapeExtend_DONE); + if(!isFixgaps && sfw->StatusGaps3d(ShapeExtend_FAIL)) + myErrorStatus = ShHealOper_ErrorExecution; + } + if(sfw->FixGaps2d()) + sfw->FixSelfIntersection(); + else if(sfw->StatusGaps2d(ShapeExtend_FAIL)) + myErrorStatus = ShHealOper_ErrorExecution; + + isFixgaps = (isFixgaps || sfw->StatusGaps2d(ShapeExtend_DONE)); + myDone = (myDone || isFixgaps); + if(isFixgaps) { + Handle(ShapeExtend_WireData) sbwd = sfw->WireData(); + Handle(ShapeFix_Edge) sfe = new ShapeFix_Edge; + for (Standard_Integer iedge = 1; iedge <= sbwd->NbEdges(); iedge++) { + TopoDS_Edge aEdge = TopoDS::Edge(sbwd->Edge(iedge)); + sfe->FixVertexTolerance(aEdge,aFace); + sfe->FixSameParameter(aEdge); + } + } + } + } + } + else { + myDone = (sfw->Perform() || myDone); + if(myModeFixGapsCurves) { + //if Mode for fix gaps is equal to true that + //curve 3D will be pull to each other. + if(sfw->FixGaps3d()) { + Handle(ShapeExtend_WireData) sbwd = sfw->WireData(); + Handle(ShapeFix_Edge) sfe = new ShapeFix_Edge; + for (Standard_Integer iedge = 1; iedge <= sbwd->NbEdges(); iedge++) { + TopoDS_Edge aEdge = TopoDS::Edge(sbwd->Edge(iedge)); + sfe->FixVertexTolerance(aEdge); + sfe->FixSameParameter(aEdge); + } + } + else if(sfw->StatusGaps3d(ShapeExtend_FAIL)) + myErrorStatus = ShHealOper_ErrorExecution; + myDone = (sfw->StatusGaps3d(ShapeExtend_DONE) || myDone); + } + } + + if(myDone) { + TopoDS_Shape aoldShape = myInitShape; + //if free edges were added they will be added to the result shape + //and type of result shape should be change if initial shape is not COMPOUND. + if( myFreeEdges.Length()) { + BRep_Builder aB; + TopoDS_Compound aComp; + aB.MakeCompound(aComp); + if(aoldShape.ShapeType() == TopAbs_COMPOUND) { + TopoDS_Iterator aIt(aoldShape); + for( ;aIt.More();aIt.Next() ) + aB.Add(aComp,aIt.Value()); + } + else + aB.Add(aComp,aoldShape); + + Standard_Integer i=1; + for ( ; i <= myFreeEdges.Length(); i++ ) + aB.Add(aComp,myFreeEdges.Value(i)); + aoldShape = aComp; + + } + myResultShape = myContext->Apply(aoldShape); + } + return; +} +//======================================================================= +//function : checkGaps +//purpose : +//======================================================================= + +Standard_Boolean ShHealOper_CloseContour::fixGaps(const Handle(ShapeExtend_WireData)& theWire, + const TopTools_SequenceOfShape& theCommonFaces) +{ + Handle(ShapeAnalysis_Wire) asaw = new ShapeAnalysis_Wire; + asaw->Load(theWire); + + Standard_Integer i =1; + Standard_Boolean hasGaps = Standard_False; + for ( ; i <= asaw->NbEdges(); i++) { + if(asaw->CheckGap3d(i)) { + Standard_Real dist = asaw->MinDistance3d(); + if(dist > myMaxTolerance) { + hasGaps = Standard_True; + Standard_Integer ind2 = (i ==0 ? theWire->NbEdges() :i); + Standard_Integer ind1 = (ind2 >1 ? ind2 -1 : theWire->NbEdges()); + TopoDS_Edge aE1= theWire->Edge(ind1); + TopoDS_Edge aE2= theWire->Edge(ind2); + if(!myModeVertex) + buildEdge(aE1,aE2,theCommonFaces); + else + myMaxTolerance = RealLast(); + if(ind2 == ind1) break; + } + } + + } + return hasGaps; +} + +//======================================================================= +//function : checkOneFace +//purpose : +//======================================================================= + +Standard_Boolean ShHealOper_CloseContour::checkOneFace(const Handle(ShapeExtend_WireData)& theSewd, + TopTools_SequenceOfShape& theCommonFaces) const +{ + + TopTools_IndexedMapOfShape amapfaces; + TopoDS_Edge aEdge1 = theSewd->Edge(1); + Standard_Boolean isOneFace = myMapEdgesFace.Contains(aEdge1 ); + if(!isOneFace) + return isOneFace; + + //check that all specified edges belong to one face. + const TopTools_ListOfShape& alfaces = myMapEdgesFace.FindFromKey(aEdge1); + isOneFace = isOneFace && (!alfaces.IsEmpty()); + if(!isOneFace) + return Standard_False; + + TopTools_ListIteratorOfListOfShape litr(alfaces); + for( ; litr.More();litr.Next() ) + amapfaces.Add(litr.Value()); + + TColStd_MapOfInteger amapIndex; + Standard_Integer ind =0; + Standard_Integer i =2; + for( ; i <= theSewd->NbEdges() && isOneFace; i++) { + isOneFace = myMapEdgesFace.Contains(theSewd->Edge(i)); + if(isOneFace) { + const TopTools_ListOfShape& alfaces1 = myMapEdgesFace.FindFromKey(theSewd->Edge(i)); + + TColStd_MapOfInteger aTmpInd; + for(litr.Initialize(alfaces1) ; litr.More() ;litr.Next() ) { + if(amapfaces.Contains(litr.Value())) { + ind = amapfaces.FindIndex(litr.Value()); + if( i == 2) + amapIndex.Add(ind); + else + aTmpInd.Add(ind); + } + } + if(i ==2) { + isOneFace = (amapIndex.Extent()); + continue; + } + else { + TColStd_MapIteratorOfMapOfInteger aMi(amapIndex); + for( ; aMi.More();aMi.Next()) { + if(!aTmpInd.Contains(aMi.Key())) + amapIndex.Remove(aMi.Key()); + } + isOneFace = (amapIndex.Extent()); + + } + } + } + if(theSewd->NbEdges() >1) { + Standard_Integer j =1; + for( ; j <= amapfaces.Extent(); j++) { + if(!amapIndex.Contains(j)) continue; + TopoDS_Shape aF = amapfaces.FindKey(j); + theCommonFaces.Append(aF); + } + } + return isOneFace; +} +//======================================================================= +//function : buildEdge +//purpose : +//======================================================================= + +void ShHealOper_CloseContour::buildEdge(const TopoDS_Edge& aE1, + const TopoDS_Edge& aE2, + const TopTools_SequenceOfShape& theCommonFaces) +{ + ShapeAnalysis_Edge asae; + TopoDS_Vertex aV1 = asae.LastVertex(aE1); + TopoDS_Vertex aV2 = asae.FirstVertex(aE2); + gp_Pnt p1 = BRep_Tool::Pnt(aV1); + gp_Pnt p2 = BRep_Tool::Pnt(aV2); + BRepBuilderAPI_MakeVertex mkver1( p1 ); + TopoDS_Vertex newV1 = mkver1.Vertex(); + + BRepBuilderAPI_MakeVertex mkver2( p2 ); + TopoDS_Vertex newV2 = mkver2.Vertex(); + BRep_Builder B; + B.UpdateVertex ( newV1,Precision::Confusion()); + B.UpdateVertex ( newV2, Precision::Confusion()); + Standard_Boolean isBuild = Standard_False; + TopoDS_Edge edge; + B.MakeEdge ( edge ); + ShapeBuild_Edge sbe; + //if all edges belong to one face that gap will be closed in the 2D by line + //than 3D curve will be built by 2D curve + if(theCommonFaces.Length()) { + + TopoDS_Face aF1 = TopoDS::Face(theCommonFaces.Value(1)); + Handle(Geom2d_Curve) c2d1,c2d2; + gp_Pnt2d p2d1,p2d2; + Standard_Real a1, b1,a2, b2; + if ( asae.PCurve ( aE1, aF1, c2d1, a1, b1, Standard_True ) && + asae.PCurve ( aE2, aF1, c2d2, a2, b2, Standard_True )) { + + c2d1->D0 ( b1, p2d1); + c2d2->D0 ( a2, p2d2); + gp_Vec2d v12 ( p2d1, p2d2 ); + + Handle(Geom2d_Line) aLine2d = new Geom2d_Line ( p2d1, gp_Dir2d ( v12 ) ); + B.UpdateEdge ( edge, aLine2d, aF1, ::Precision::Confusion() ); + B.Range ( edge, aF1, 0.0, v12.Magnitude() ); + + isBuild = sbe.BuildCurve3d ( edge ); + } + } + //else gap will be closed in the 3D by line. + if(!isBuild) { + gp_Vec v1 ( p1, p2 ); + Handle(Geom_Line) aLine = new Geom_Line ( p1, gp_Dir ( v1 ) ); + B.UpdateEdge ( edge, aLine, ::Precision::Confusion() ); + B.Range ( edge,0.0, v1.Magnitude()); + } + B.Add ( edge, newV1.Oriented ( TopAbs_FORWARD ) ); + B.Add ( edge, newV2.Oriented ( TopAbs_REVERSED ) ); + myContext->Replace(aV1, newV1.Oriented (aV1.Orientation())); + myContext->Replace(aV2, newV2.Oriented (aV2.Orientation())); + if(isBuild) { + newV1.Orientation(aV1.Orientation()); + TopoDS_Edge newEdge = sbe.CopyReplaceVertices ( aE1,TopoDS_Vertex(), newV1); + TopoDS_Wire aw; + B.MakeWire(aw); + B.Add(aw,newEdge); + B.Add(aw,edge); + TopoDS_Shape anE1 = myContext->Apply(aE1); + myContext->Replace(anE1,aw); + } + else { + myFreeEdges.Append(edge); + } +} +//======================================================================= +//function : UpdateWire +//purpose : +//======================================================================= + +void ShHealOper_CloseContour::updateWire (Handle(ShapeExtend_WireData)& sbwd) +{ + Standard_Integer i=1; + for ( ; i <= sbwd->NbEdges(); i++ ) { + TopoDS_Edge E = sbwd->Edge(i); + TopoDS_Shape S = myContext->Apply ( E ); + if ( S == E ) continue; + for ( TopExp_Explorer exp(S,TopAbs_EDGE); exp.More(); exp.Next() ) + sbwd->Add ( exp.Current(), i++ ); + sbwd->Remove ( i-- ); + } + for ( i =1; i <= myFreeEdges.Length(); i++ ) { + sbwd->Add(TopoDS::Edge(myFreeEdges.Value(i))); + } +} diff --git a/src/ShHealOper/ShHealOper_CloseContour.hxx b/src/ShHealOper/ShHealOper_CloseContour.hxx new file mode 100644 index 000000000..aab0fa3dd --- /dev/null +++ b/src/ShHealOper/ShHealOper_CloseContour.hxx @@ -0,0 +1,140 @@ +// File: ShHealOper_CloseContour.hxx +// Created: 20.04.04 10:25:46 +// Author: Galina KULIKOVA +// < MODULE = KERNEL> : +// Copyright (C) 2003 CEA +// +// 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 +// + + +#ifndef ShHealOper_CloseContour_HeaderFile +#define ShHealOper_CloseContour_HeaderFile + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +/// Class ShHealOper_CloseContour +// + +class ShHealOper_CloseContour : public ShHealOper_Tool +{ + public: + // ---------- PUBLIC METHODS ---------- + Standard_EXPORT ShHealOper_CloseContour() : ShHealOper_Tool() {} + + Standard_EXPORT ShHealOper_CloseContour (const TopoDS_Shape& theShape); + //Initalizes by whole shape. + + Standard_EXPORT virtual void Init(const TopoDS_Shape& theShape); + //Method for initalization by whole shape. + + Standard_EXPORT Standard_Boolean Perform(const TopTools_SequenceOfShape& theSeqEdges, + const Standard_Boolean theModeVertex = Standard_False, + const Standard_Boolean theModeFixGapsCurves = Standard_True); + + //Build wire from specified edges and close gap between edges by segment of line + // or by vertex in according to specified mode. + + Standard_EXPORT Standard_Boolean Perform(const TopoDS_Wire& theWire, + const Standard_Boolean theModeVertex= Standard_False, + const Standard_Boolean theModeFixGapsCurves = Standard_True); + + //Close gap into specified wire by segment of line or by vertex in according + //to specified mode. + + inline void SetTolerance(const Standard_Real theTolerance) + { + myTolerance = theTolerance; + } + //Sets tolerance for checking closure of the contour. + + inline Standard_Real GetTolerance() + { + return myTolerance; + } + //Returns value of the tolerance. + + inline void SetMaxTolerance(const Standard_Real theMaxTolerance) + { + myMaxTolerance = theMaxTolerance; + } + //Sets tolerance for checking closure of the contour. + + inline Standard_Real GetMaxTolerance() + { + return myMaxTolerance; + } + //Returns value of the tolerance. + + inline void SetModeVertex(const Standard_Boolean theModeVertex) + { + myModeVertex = theModeVertex; + } + //Sets mode for closure of the contour. + + inline Standard_Boolean GetModeVertex() + { + return myModeVertex; + } + //Get mode for closure of the contour. + + + private: + // ---------- PRIVATE METHODS ---------- + + void build(Handle(ShapeExtend_WireData)& theSewd); + + Standard_Boolean fixGaps(const Handle(ShapeExtend_WireData)& theWire, + const TopTools_SequenceOfShape& theCommonFaces); + + Standard_Boolean checkOneFace(const Handle(ShapeExtend_WireData)& theSewd, + TopTools_SequenceOfShape& theCommonFaces) const; + + void buildEdge(const TopoDS_Edge& aE1, + const TopoDS_Edge& aE2, + const TopTools_SequenceOfShape& theCommonFaces); + + void updateWire (Handle(ShapeExtend_WireData)& sbwd); + private: + // ---------- PRIVATE FIELDS ---------- + + + Standard_Boolean myModeVertex; + Standard_Boolean myModeFixGapsCurves; + + Standard_Real myMaxTolerance; + Standard_Real myTolerance; + TopTools_IndexedDataMapOfShapeListOfShape myMapEdgesFace; + TopTools_SequenceOfShape myFreeEdges; + public: +// Declaration of CASCADE RTTI +//DEFINE_STANDARD_RTTI (ShHealOper_CloseContour) +}; + +// Definition of HANDLE object using Standard_DefineHandle.hxx +//DEFINE_STANDARD_HANDLE (ShHealOper_CloseContour, ) + + +#endif diff --git a/src/ShHealOper/ShHealOper_EdgeDivide.cxx b/src/ShHealOper/ShHealOper_EdgeDivide.cxx new file mode 100644 index 000000000..183b68d32 --- /dev/null +++ b/src/ShHealOper/ShHealOper_EdgeDivide.cxx @@ -0,0 +1,256 @@ +// File: ShHealOper_EdgeDivide.cxx +// Created: 30.04.04 16:44:47 +// Author: Galina KULIKOVA +// < MODULE = KERNEL> : +// Copyright (C) 2003 CEA +// +// 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 +// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +//#include <.hxx> +//#include <.hxx> +//======================================================================= +//function : ShHealOper_EdgeDivide() +//purpose : Constructor +//======================================================================= + +ShHealOper_EdgeDivide::ShHealOper_EdgeDivide (const TopoDS_Shape& theShape) +{ + Init(theShape); +} +//======================================================================= +//function : Init +//purpose : +//======================================================================= + +void ShHealOper_EdgeDivide::Init(const TopoDS_Shape& theShape) +{ + ShHealOper_Tool::Init(theShape); + myDivideParamMode = Standard_True; + myMapEdgesFace.Clear(); + TopExp::MapShapesAndAncestors(theShape,TopAbs_EDGE,TopAbs_FACE,myMapEdgesFace); + +} + +//======================================================================= +//function : Perform +//purpose : +//======================================================================= +Standard_Boolean ShHealOper_EdgeDivide::Perform(const TopoDS_Shape& theEdge, + const TColStd_SequenceOfReal& theValues, + const Standard_Boolean theDivideParamMode) +{ + myDone = Standard_False; + myDivideParamMode = theDivideParamMode; + if(theEdge.ShapeType() != TopAbs_EDGE) { + myErrorStatus = ShHealOper_InvalidParameters; + return myDone; + } + myEdge = TopoDS::Edge(theEdge); + Standard_Integer i =1; + Handle(TColStd_HSequenceOfReal) aSeqValues = new TColStd_HSequenceOfReal; + for( ; i <= theValues.Length(); i++) + aSeqValues->Append(theValues.Value(i)); + myDone = build(aSeqValues); + return myDone; + +} +//======================================================================= +//function : Perform +//purpose : +//======================================================================= + +Standard_Boolean ShHealOper_EdgeDivide::Perform(const TopoDS_Shape& theEdge, + const Standard_Real theValue, + const Standard_Boolean theDivideParamMode) +{ + myDone = Standard_False; + myErrorStatus = ShHealOper_NotError; + if(theEdge.ShapeType() != TopAbs_EDGE) { + myErrorStatus = ShHealOper_InvalidParameters; + return myDone; + } + myDivideParamMode = theDivideParamMode; + myEdge = TopoDS::Edge(theEdge); + Handle(TColStd_HSequenceOfReal) aSeqValues = new TColStd_HSequenceOfReal; + aSeqValues->Append(theValue); + myDone = build(aSeqValues); + return myDone; +} +//======================================================================= +//function : build +//purpose : +//======================================================================= + +Standard_Boolean ShHealOper_EdgeDivide::build(const Handle(TColStd_HSequenceOfReal)& theValues) +{ + if(myEdge.IsNull() || !theValues->Length()) { + myErrorStatus = ShHealOper_InvalidParameters; + return Standard_False; + } + + Standard_Boolean has3d = Standard_False, + has2d = Standard_False, + hasPCurves = Standard_False; + + //computation of the split values in dependance from specified mode and values. + if(!computeValues(theValues, has3d,has2d,hasPCurves)) { + myErrorStatus = ShHealOper_InvalidParameters; + return Standard_False; + } + + //setting split values in the splitting curve tools. + Handle(ShapeUpgrade_WireDivide) aSplitTool = new ShapeUpgrade_WireDivide; + aSplitTool->Load(myEdge); + aSplitTool->SetContext(myContext); + if(has3d) { + Handle(ShHealOper_SplitCurve3d) aSplitCurve3d = new ShHealOper_SplitCurve3d; + aSplitCurve3d->SetValues(theValues); + aSplitTool->SetSplitCurve3dTool(aSplitCurve3d); + } + else if(has2d) { + Handle(ShHealOper_SplitCurve2d) aSplitCurve2d = new ShHealOper_SplitCurve2d; + aSplitCurve2d->SetValues(theValues); + aSplitTool->SetSplitCurve2dTool(aSplitCurve2d); + } + else { + myErrorStatus = ShHealOper_InvalidParameters; + return Standard_False; + } + + //split 3d curve and pcurve for each face reffering to edge. + Standard_Boolean isDone = Standard_True; + if(hasPCurves) { + const TopTools_ListOfShape& lfaces = myMapEdgesFace.FindFromKey(myEdge); + TopTools_ListIteratorOfListOfShape aItf(lfaces); + for( ; aItf.More() && isDone; aItf.Next()) { + TopoDS_Face aFace = TopoDS::Face(aItf.Value()); + aSplitTool->SetFace(aFace); + aSplitTool->Perform(); + isDone = aSplitTool->Status( ShapeExtend_DONE ); + if( aSplitTool->Status( ShapeExtend_FAIL )) + myErrorStatus = ShHealOper_ErrorExecution; + } + } + else { + aSplitTool->Perform(); + isDone = aSplitTool->Status( ShapeExtend_DONE ); + if( aSplitTool->Status( ShapeExtend_FAIL )) + myErrorStatus = ShHealOper_ErrorExecution; + } + if(isDone) + myResultShape = myContext->Apply(myInitShape); + return isDone; + +} +//======================================================================= +//function : computeValues +//purpose : +//======================================================================= + +Standard_Boolean ShHealOper_EdgeDivide::computeValues(const Handle(TColStd_HSequenceOfReal)& theValues, + Standard_Boolean& theHas3d, + Standard_Boolean& theHas2d, + Standard_Boolean& hasPCurves) +{ + hasPCurves = (myMapEdgesFace.Contains(myEdge) && + myMapEdgesFace.FindFromKey(myEdge).Extent()); + if(hasPCurves && (!BRep_Tool::SameRange(myEdge) || !BRep_Tool::SameParameter(myEdge))) { + ShapeFix_Edge sfe; + sfe.FixSameParameter(myEdge); + } + + Standard_Real aFirst =0.,aLast=0.; + + //computation of the split values if edge should be splitted by parameter. + if(myDivideParamMode) { + BRep_Tool::Range(myEdge,aFirst,aLast); + Handle(Geom_Curve) aCurve = BRep_Tool::Curve(myEdge,aFirst,aLast); + + theHas3d = (!aCurve.IsNull()); + theHas2d = (aCurve.IsNull() && (fabs(aLast-aFirst) > Precision::PConfusion() )); + Standard_Integer i = 1; + for( ; i <= theValues->Length();i++) { + Standard_Real aVal = theValues->Value(i); + theValues->ChangeValue(i) = aFirst+ aVal*fabs(aLast - aFirst); + } + } + else { + //computation of the split values if edge should be splitted by length. + ShapeAnalysis_Edge sae; + Handle(Geom_Curve) aCurve; + Standard_Real aCurLen =0.; + GeomAdaptor_Curve aAdC; + Geom2dAdaptor_Curve aAdC2d; + if(sae.Curve3d(myEdge,aCurve,aFirst,aLast,Standard_False)) { + aAdC.Load(aCurve,aFirst,aLast); + aCurLen = GCPnts_AbscissaPoint::Length(aAdC,aFirst,aLast); + theHas3d = Standard_True; + } + else { + if(hasPCurves) { + TopoDS_Face aFace = TopoDS::Face(myMapEdgesFace.FindFromKey(myEdge).First()); + Handle(Geom2d_Curve) aCurve2d; + if(sae.PCurve(myEdge,aFace,aCurve2d,aFirst,aLast)) { + aAdC2d.Load(aCurve2d,aFirst,aLast); + aCurLen = GCPnts_AbscissaPoint::Length(aAdC,aFirst,aLast); + theHas2d = Standard_True; + } + + } + } + if(!theHas3d && !theHas2d) + return Standard_False; + + Standard_Integer i = 1; + for( ; i <= theValues->Length();i++) { + Standard_Real aLen = theValues->Value(i)*aCurLen; + if(theHas3d) { + GCPnts_AbscissaPoint anAbsc(aAdC,aLen,aFirst); + if(anAbsc.IsDone()) + theValues->ChangeValue(i) = anAbsc.Parameter(); + else + theValues->Remove(i--); + } + else if(theHas2d) { + GCPnts_AbscissaPoint anAbsc(aAdC2d,aLen,aFirst); + if(anAbsc.IsDone()) + theValues->ChangeValue(i) = anAbsc.Parameter(); + else + theValues->Remove(i--); + } + } + } + return (theValues->Length()); +} diff --git a/src/ShHealOper/ShHealOper_EdgeDivide.hxx b/src/ShHealOper/ShHealOper_EdgeDivide.hxx new file mode 100644 index 000000000..37b40e751 --- /dev/null +++ b/src/ShHealOper/ShHealOper_EdgeDivide.hxx @@ -0,0 +1,94 @@ +// File: ShHealOper_EdgeDivide.hxx +// Created: 30.04.04 16:06:25 +// Author: Galina KULIKOVA +// < MODULE = KERNEL> : +// Copyright (C) 2003 CEA +// +// 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 +// + + +#ifndef ShHealOper_EdgeDivide_HeaderFile +#define ShHealOper_EdgeDivide_HeaderFile + +#include +#include +#include +#include +#include +#include + +/// Class ShHealOper_EdgeDivide +//Intended for spitting edge in accordance to the specified mode and value. + +class ShHealOper_EdgeDivide : public ShHealOper_Tool +{ + public: + // ---------- PUBLIC METHODS ---------- + + + Standard_EXPORT ShHealOper_EdgeDivide () : ShHealOper_Tool() {} + /// Empty constructor + + Standard_EXPORT ShHealOper_EdgeDivide (const TopoDS_Shape& theShape); + /// Constructor initializes by shape. + + Standard_EXPORT virtual void Init(const TopoDS_Shape& theShape); + //Method for initalization by whole shape. + + Standard_EXPORT Standard_Boolean Perform(const TopoDS_Shape& theEdge, + const Standard_Real theValue, + const Standard_Boolean theDivideParamMode = Standard_True); + //Performs spitting of the specified edge in the accoradnce to + //specified mode and value. + //If theDivideParamMode is equal to true edge will be splitted by parameter. + //Else edge will be spliited by length (default true). + //theValue is koefficient for splitting from 0 to 1. + + Standard_EXPORT Standard_Boolean Perform(const TopoDS_Shape& theEdge, + const TColStd_SequenceOfReal& theValues, + const Standard_Boolean theDivideParamMode = Standard_True); + //Performs spitting of the specified edge in the accoradnce to + //specified mode and sequence of values the same way as previous. + + protected: + // ---------- PROTECTED METHODS ---------- + + + Standard_Boolean build(const Handle(TColStd_HSequenceOfReal)& theValues); + + Standard_Boolean computeValues(const Handle(TColStd_HSequenceOfReal)& theValues, + Standard_Boolean& theHas3d, + Standard_Boolean& theHas2d, + Standard_Boolean& hasPCurves); + + private: + // ---------- PRIVATE FIELDS ---------- + + TopTools_IndexedDataMapOfShapeListOfShape myMapEdgesFace; + Standard_Boolean myDivideParamMode; + TopoDS_Edge myEdge; + + public: +// Declaration of CASCADE RTTI +//DEFINE_STANDARD_RTTI (ShHealOper_EdgeDivide) +}; + +// Definition of HANDLE object using Standard_DefineHandle.hxx +//DEFINE_STANDARD_HANDLE (ShHealOper_EdgeDivide, ) + + +#endif diff --git a/src/ShHealOper/ShHealOper_FillHoles.cxx b/src/ShHealOper/ShHealOper_FillHoles.cxx new file mode 100644 index 000000000..d80857e74 --- /dev/null +++ b/src/ShHealOper/ShHealOper_FillHoles.cxx @@ -0,0 +1,468 @@ +// File: ShHealOper_FillHoles.cxx +// Created: 26.04.04 17:35:30 +// Author: Galina KULIKOVA +// < MODULE = KERNEL> : +// Copyright (C) 2003 CEA +// +// 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 +// + + +#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 : ShHealOper_FillHoles() +//purpose : Constructor +//======================================================================= +ShHealOper_FillHoles::ShHealOper_FillHoles () +{ + InitParameters(); +} + +//======================================================================= +//function : ShHealOper_FillHoles +//purpose : +//======================================================================= + +ShHealOper_FillHoles::ShHealOper_FillHoles (const TopoDS_Shape& theShape) +{ + + Init(theShape); + InitParameters(); +} +//======================================================================= +//function : Init +//purpose : +//======================================================================= + +void ShHealOper_FillHoles::Init(const TopoDS_Shape& theShape) +{ + ShHealOper_Tool::Init(theShape); + TopExp::MapShapesAndAncestors( myInitShape, TopAbs_EDGE,TopAbs_SHELL , myEdgeShells); + TopExp::MapShapesAndAncestors ( myInitShape, TopAbs_EDGE,TopAbs_COMPOUND, myEdgeComps ); + + TopExp::MapShapesAndAncestors ( myInitShape, TopAbs_EDGE,TopAbs_FACE, myEdgeFaces ); +} +//======================================================================= +//function : InitParameters +//purpose : +//======================================================================= + +void ShHealOper_FillHoles::InitParameters(Standard_Integer theDegree, + Standard_Integer theNbPtsOnCur, + Standard_Integer theNbIter, + Standard_Real theTol3d, + Standard_Real theTol2d, + Standard_Real theTolAng, + Standard_Real theTolCrv, + Standard_Integer theMaxDeg, + Standard_Integer theMaxSeg) +{ + myNbPtsOnCur = theNbPtsOnCur; + myNbIter = theNbIter; + myDegree =theDegree; + myTol2d = theTol2d; + myTol3d = theTol3d; + myTolAng = theTolAng; + myTolCrv = theTolCrv; + myMaxDeg = theMaxDeg; + myMaxSeg =theMaxSeg; +} +//======================================================================= +//function : Fill +//purpose : +//======================================================================= + +Standard_Boolean ShHealOper_FillHoles::Fill() +{ + ShapeAnalysis_FreeBounds sab(myInitShape); + TopoDS_Compound aCompClosed = sab.GetClosedWires(); + TopoDS_Compound aCompOpen = sab.GetOpenWires(); + TopTools_SequenceOfShape aFillWires; + if(!aCompClosed.IsNull()) { + TopoDS_Iterator aIt(aCompClosed); + + for( ; aIt.More(); aIt.Next()) + aFillWires.Append(aIt.Value()); + } + if(!aCompOpen.IsNull()) { + TopoDS_Iterator aIt(aCompOpen); + for( ; aIt.More(); aIt.Next()) + aFillWires.Append(aIt.Value()); + } + + TopExp_Explorer aExp(myInitShape,TopAbs_EDGE,TopAbs_FACE); + + for( ; aExp.More(); aExp.Next()) + aFillWires.Append(aExp.Current()); + + return Fill(aFillWires); +} + +//======================================================================= +//function : Fill +//purpose : +//======================================================================= + +Standard_Boolean ShHealOper_FillHoles::Fill(const TopTools_SequenceOfShape& theFillShapes) +{ + myDone = Standard_False; + myErrorStatus = ShHealOper_NotError; + if(myInitShape.IsNull()) { + myErrorStatus = ShHealOper_InvalidParameters; + return myDone; + } + if(!theFillShapes.Length()) { + return myDone; + } + + Handle(TopTools_HSequenceOfShape) aSeqWires = new TopTools_HSequenceOfShape; + if(!prepareWires(theFillShapes,aSeqWires)) { + myErrorStatus = ShHealOper_InvalidParameters; + return myDone; + } + + myResultShape = myInitShape; + Standard_Integer i =1; + for( ; i <= aSeqWires->Length(); i++) { + TopoDS_Wire aWire = TopoDS::Wire(aSeqWires->Value(i)); + Handle(TColGeom2d_HArray1OfCurve) aCurves2d; + Handle(TColStd_HArray1OfInteger) aOrders; + Handle(TColStd_HArray1OfInteger) aSenses; + Handle(Geom_Surface) aSurf = buildSurface(aWire,aCurves2d,aOrders,aSenses); + if(aSurf.IsNull()) + myErrorStatus = ShHealOper_ErrorExecution; + else + myDone = (addFace(aSurf,aWire,aCurves2d,aOrders,aSenses) || myDone); + } + if(myDone) + myResultShape = myContext->Apply(myResultShape); + return myDone; +} +//======================================================================= +//function : isCircle +//purpose : +//======================================================================= +static Standard_Boolean isCircle(const TopoDS_Edge theEdge) +{ + Standard_Real aFirst, aLast; + Handle(Geom_Curve) aC3D = BRep_Tool::Curve(theEdge,aFirst, aLast ); + if(aC3D.IsNull()) return Standard_False; + Standard_Boolean isCirc = (aC3D->Value(aFirst).Distance(aC3D->Value(aLast)) < + aC3D->Value(aFirst).Distance(aC3D->Value((aFirst +aLast)/2))); + return isCirc; +} +//======================================================================= +//function : prepareWires +//purpose : +//======================================================================= + +Standard_Boolean ShHealOper_FillHoles::prepareWires(const TopTools_SequenceOfShape& theFillShapes, + Handle(TopTools_HSequenceOfShape)& theSeqWires) +{ + Handle(TopTools_HSequenceOfShape) aSeqEdges = new TopTools_HSequenceOfShape; + BRep_Builder aB; + Standard_Integer i =1; + for( ; i <= theFillShapes.Length(); i++) { + TopExp_Explorer aExp; + for (aExp.Init (theFillShapes.Value(i),TopAbs_WIRE); aExp.More(); aExp.Next()) { + TopoDS_Iterator aIt(aExp.Current()); + Standard_Boolean isAdd = Standard_True; + for( ; aIt.More() && isAdd; aIt.Next()) { + if(myEdgeFaces.Contains(aIt.Value())) + isAdd = (myEdgeFaces.FindFromKey(aIt.Value()).Extent() <2); + } + if(isAdd) + theSeqWires->Append(aExp.Current()); + } + for (aExp.Init (theFillShapes.Value(i),TopAbs_EDGE, TopAbs_WIRE); aExp.More(); aExp.Next()) { + if (!BRep_Tool::Degenerated (TopoDS::Edge (aExp.Current()))) + if(myEdgeFaces.Contains(aExp.Current()) && myEdgeFaces.FindFromKey(aExp.Current()).Extent() >1) + continue; + aSeqEdges->Append(aExp.Current()); + } + } + + if(aSeqEdges->Length()) + { + Standard_Real aTol = 0.; + Standard_Boolean aShared = Standard_True; + Handle(TopTools_HSequenceOfShape) aTmpWires = new TopTools_HSequenceOfShape; + ShapeAnalysis_FreeBounds::ConnectEdgesToWires(aSeqEdges, aTol, aShared, aTmpWires); + Handle(TopTools_HSequenceOfShape) anWiresClosed = new TopTools_HSequenceOfShape, + anWiresOpen = new TopTools_HSequenceOfShape; + ShapeAnalysis_FreeBounds::SplitWires(aTmpWires, aTol, aShared, anWiresClosed, anWiresOpen); + + for (i = 1; i <= anWiresClosed->Length(); i++) + theSeqWires->Append (anWiresClosed->Value (i)); + for (i = 1; i <= anWiresOpen->Length(); i++) + theSeqWires->Append (anWiresOpen->Value (i)); + } + + + + for( i =1; i <= theSeqWires->Length(); i++) { + TopoDS_Wire aWire = TopoDS::Wire(theSeqWires->Value(i)); + + TopoDS_Iterator aIt(aWire); + Standard_Integer ne =0; + TopoDS_Edge ae; + for( ; aIt.More(); aIt.Next(), ne++) + ae = TopoDS::Edge(aIt.Value()); + if((ne == 1) && ( !isCircle(ae))) { + theSeqWires->Remove(i--); + continue; + } + } + return (theSeqWires->Length()); +} +//======================================================================= +//function : buildSurface +//purpose : +//======================================================================= + +Handle(Geom_Surface) ShHealOper_FillHoles::buildSurface(const TopoDS_Wire& theWire, + Handle(TColGeom2d_HArray1OfCurve)& theCurves2d, + Handle(TColStd_HArray1OfInteger)& theOrders, + Handle(TColStd_HArray1OfInteger)& theSenses) +{ + Handle(Geom_BSplineSurface) aSurf; + try { + + GeomPlate_BuildPlateSurface aBuilder(myDegree, myNbPtsOnCur, myNbIter, + myTol2d, myTol3d, myTolAng, myTolCrv); + TopoDS_Iterator aIter; + for(aIter.Initialize (theWire); aIter.More(); aIter.Next()) { + + TopoDS_Edge ae = TopoDS::Edge(aIter.Value()); + BRepAdaptor_Curve adC(ae); + Handle(BRepAdaptor_HCurve) aHAD= new BRepAdaptor_HCurve(adC); + Handle(BRepFill_CurveConstraint) aConst = + new BRepFill_CurveConstraint (aHAD, (Standard_Integer) GeomAbs_C0, myNbPtsOnCur, myTol3d); + //Handle(GeomPlate_CurveConstraint) aConst = + // new GeomPlate_CurveConstraint(aHAD, (Standard_Integer) GeomAbs_C0, myNbPtsOnCur, myTol3d); + aBuilder.Add (aConst); + } + aBuilder.Perform(); + if(!aBuilder.IsDone()) + return aSurf; + Handle(GeomPlate_Surface) aPlSurf = aBuilder.Surface(); + + //for filling holes without initial specified surface + //the initial surface should be build by GeomPlate itself + //following code was taken from BRepFill_Filling::Build + + Standard_Real aDist = aBuilder.G0Error(); + TColgp_SequenceOfXY S2d; + TColgp_SequenceOfXYZ S3d; + S2d.Clear(); + S3d.Clear(); + aBuilder.Disc2dContour(4,S2d); + aBuilder.Disc3dContour(4,0,S3d); + Standard_Real amaxTol = Max( myTol3d, 10* aDist); + GeomPlate_PlateG0Criterion Criterion( S2d, S3d, amaxTol ); + GeomPlate_MakeApprox Approx( aPlSurf, Criterion, myTol3d, myMaxSeg, myMaxDeg ); + aSurf = Approx.Surface(); + if(aSurf.IsNull()) + return aSurf; + + theCurves2d = aBuilder.Curves2d(); + theOrders = aBuilder.Order(); + theSenses = aBuilder.Sense(); + + } + + catch (Standard_Failure) { + aSurf.Nullify(); + return aSurf; + } + return aSurf; +} + +//======================================================================= +//function : addFace +//purpose : +//======================================================================= + +Standard_Boolean ShHealOper_FillHoles::addFace(const Handle(Geom_Surface)& theSurf, + const TopoDS_Wire& theWire, + const Handle(TColGeom2d_HArray1OfCurve)& theCurves2d, + const Handle(TColStd_HArray1OfInteger)& theOrders, + const Handle(TColStd_HArray1OfInteger)& theSenses) +{ + BRepBuilderAPI_MakeFace aMakeFace (theSurf); + TopoDS_Face aFace = aMakeFace.Face(); + aFace.EmptyCopy(); + + + TopoDS_Wire aWire; + BRep_Builder aB; + aB.MakeWire(aWire); + + TopTools_IndexedMapOfShape aMapParent; + Standard_Integer aInd = 1; + Standard_Boolean hasShell = Standard_False; + TopoDS_Iterator aIter(theWire); + for ( ; aIter.More(); aIter.Next(), aInd++) { + TopoDS_Edge anEdge = TopoDS::Edge (aIter.Value()); + Standard_Real aF, aL; + BRep_Tool::Range (anEdge, aF, aL); + TopLoc_Location aLoc; + aB.UpdateEdge (anEdge, theCurves2d->Value (aInd),aFace, 0.); + + aB.Range (anEdge, aFace, aF, aL); + + // Set orientation of the edge: orientation should be changed + // if its orientation does not make sence with curve orientation + // recommended by GeomPlate + if ((anEdge.Orientation() == TopAbs_FORWARD) == + (theSenses->Value (theOrders->Value (aInd)) == 1)) { + anEdge.Reverse(); + } + aB.SameParameter(anEdge,Standard_False); + aB.Add (aWire, anEdge); + Standard_Boolean isAdd = Standard_False; + TopoDS_Shape aParent; + if(!myEdgeFaces.Contains(anEdge)) + continue; + + if(myEdgeFaces.FindFromKey(anEdge).Extent() >1) + continue; + + if(myEdgeShells.Contains(anEdge)) { + if(myEdgeShells.FindFromKey(anEdge).Extent()) { + aParent = myEdgeShells.FindFromKey(anEdge).First(); + hasShell = Standard_True; + aMapParent.Add(aParent); + } + } + else if(myEdgeComps.Contains(anEdge)) { + if(myEdgeComps.FindFromKey(anEdge).Extent()) { + aParent = myEdgeComps.FindFromKey(anEdge).First(); + aMapParent.Add(aParent); + } + } + + } + aB.Add(aFace,aWire); + Handle(ShapeFix_Face) aSff = new ShapeFix_Face(aFace); + aSff->SetContext(myContext); + aSff->SetPrecision(myTol3d); + aSff->Perform(); + if(aSff->Status(ShapeExtend_FAIL)) { + myErrorStatus = ShHealOper_ErrorExecution; + return Standard_False; + } + //theFace = aSff->Face(); + TopoDS_Shape aResShape = aSff->Result(); + getResShape(aResShape,aMapParent,hasShell); + return Standard_True; +} + +//======================================================================= +//function : getResShape +//purpose : +//======================================================================= + +void ShHealOper_FillHoles::getResShape(const TopoDS_Shape& theAddShape, + const TopTools_IndexedMapOfShape& aMapParent, + const Standard_Boolean theHasShell) +{ + BRep_Builder aB; + + if(!aMapParent.Extent()) { + TopoDS_Compound aComp; + aB.MakeCompound(aComp); + TopoDS_Shape aresShape = myContext->Apply(myResultShape); + aB.Add(aComp,aresShape); + aB.Add(aComp,theAddShape); + myResultShape = aComp; + return ; + } + Standard_Boolean anhasShell = theHasShell; + TopoDS_Shell aTmpShell; + aB.MakeShell(aTmpShell); + TopTools_SequenceOfShape aseqShells; + if(anhasShell) { + + aB.Add(aTmpShell,theAddShape); + Standard_Integer i =1; + for( ; i <= aMapParent.Extent(); i++) { + TopoDS_Shape aParShape = myContext->Apply(aMapParent.FindKey(i)); + if(aParShape.ShapeType() == TopAbs_SHELL) { + TopExp_Explorer aexp(aParShape,TopAbs_FACE); + for( ; aexp.More(); aexp.Next()) + aB.Add(aTmpShell,aexp.Current()); + aseqShells.Append(aParShape); + } + } + anhasShell = aseqShells.Length(); + } + if(anhasShell) { + Handle(ShapeFix_Shell) asfs = new ShapeFix_Shell; + asfs->FixFaceOrientation(aTmpShell); + TopoDS_Shape anshape = asfs->Shape(); + myContext->Replace(aseqShells.Value(1),anshape); + Standard_Integer i =2; + for( ; i<= aseqShells.Length(); i++) + myContext->Remove(aseqShells.Value(i)); + + } + else { + TopoDS_Compound aComp; + aB.MakeCompound(aComp); + TopoDS_Shape oldshape = myContext->Apply(aMapParent.FindKey(1)); + TopoDS_Iterator aIt(oldshape); + for( ; aIt.More(); aIt.Next()) + aB.Add(aComp,aIt.Value()); + aB.Add(aComp,theAddShape); + myContext->Replace( oldshape,aComp); + + } +} diff --git a/src/ShHealOper/ShHealOper_FillHoles.hxx b/src/ShHealOper/ShHealOper_FillHoles.hxx new file mode 100644 index 000000000..9d43402ab --- /dev/null +++ b/src/ShHealOper/ShHealOper_FillHoles.hxx @@ -0,0 +1,119 @@ +// File: ShHealOper_FillHoles.hxx +// Created: 26.04.04 17:15:10 +// Author: Galina KULIKOVA +// < MODULE = KERNEL> : +// Copyright (C) 2003 CEA +// +// 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 +// + + + +#ifndef ShHealOper_FillHoles_HeaderFile +#define ShHealOper_FillHoles_HeaderFile + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/// Class ShHealOper_FillHoles +//Intended for filling holes. + +class ShHealOper_FillHoles : public ShHealOper_Tool +{ + public: + // ---------- PUBLIC METHODS ---------- + + Standard_EXPORT ShHealOper_FillHoles (); + // Empty constructor initializes class by default parameters. + + Standard_EXPORT ShHealOper_FillHoles (const TopoDS_Shape& theShape); + + Standard_EXPORT virtual void Init(const TopoDS_Shape& theShape); + //Method for initalization by whole shape. + + Standard_EXPORT void InitParameters(Standard_Integer theDegree = 3,//3(2) + Standard_Integer theNbPtsOnCur =5,//3, + Standard_Integer theNbIter = 12,//3 + Standard_Real theTol3d = 0.0001,//0.001, + Standard_Real theTol2d = 1.e-5, + Standard_Real theTolAng = 0.01, + Standard_Real theTolCrv = 0.01, + Standard_Integer theMaxDeg = 8, + Standard_Integer theMaxSeg =9); + //Initialization of the parameters for creation of the surface by GeomPlate. + + Standard_EXPORT Standard_Boolean Fill(); + //Fill all holes detectected as free boundaries. + + Standard_EXPORT Standard_Boolean Fill(const TopTools_SequenceOfShape& theFillShapes); + //Fill hole specified by wires or edges. + + + private: + // ---------- PRIVATE METHODS ---------- + + Standard_Boolean prepareWires(const TopTools_SequenceOfShape& theFillShapes, + Handle(TopTools_HSequenceOfShape)& theSeqWires); + + Handle(Geom_Surface) buildSurface(const TopoDS_Wire& theWire, + Handle(TColGeom2d_HArray1OfCurve)& theCurves2d, + Handle(TColStd_HArray1OfInteger)& theOrders, + Handle(TColStd_HArray1OfInteger)& theSenses); + + Standard_Boolean addFace(const Handle(Geom_Surface)& theSurf, + const TopoDS_Wire& theWire, + const Handle(TColGeom2d_HArray1OfCurve)& theCurves2d, + const Handle(TColStd_HArray1OfInteger)& theOrders, + const Handle(TColStd_HArray1OfInteger)& theSenses); + + void getResShape(const TopoDS_Shape& theAddShape, + const TopTools_IndexedMapOfShape& aMapParent, + const Standard_Boolean theHasShell); + private: + // ---------- PRIVATE FIELDS ---------- + + TopTools_IndexedDataMapOfShapeListOfShape myEdgeShells; + + TopTools_IndexedDataMapOfShapeListOfShape myEdgeComps; + TopTools_IndexedDataMapOfShapeListOfShape myEdgeFaces; + Standard_Integer myNbPtsOnCur; + Standard_Integer myNbIter; + Standard_Integer myDegree; + Standard_Real myTol2d; + Standard_Real myTol3d; + Standard_Real myTolAng; + Standard_Real myTolCrv; + Standard_Integer myMaxDeg; + Standard_Integer myMaxSeg; + public: +// Declaration of CASCADE RTTI +//DEFINE_STANDARD_RTTI (ShHealOper_FillHoles) +}; + +// Definition of HANDLE object using Standard_DefineHandle.hxx +//DEFINE_STANDARD_HANDLE (ShHealOper_FillHoles, ) + + +#endif diff --git a/src/ShHealOper/ShHealOper_RemoveFace.cxx b/src/ShHealOper/ShHealOper_RemoveFace.cxx new file mode 100644 index 000000000..3501fe024 --- /dev/null +++ b/src/ShHealOper/ShHealOper_RemoveFace.cxx @@ -0,0 +1,444 @@ +// File: ShHealOper_RemoveFace.cxx +// Created: 16.04.04 12:12:38 +// Author: Galina KULIKOVA +// < MODULE = KERNEL> : +// Copyright (C) 2003 CEA +// +// 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 +// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +//======================================================================= +//function : ShHealOper_RemoveFace() +//purpose : Constructor +//======================================================================= +ShHealOper_RemoveFace::ShHealOper_RemoveFace () : + ShHealOper_Tool() +{ +} +//======================================================================= +//function : ShHealOper_RemoveFace +//purpose : +//======================================================================= + +ShHealOper_RemoveFace::ShHealOper_RemoveFace ( const TopoDS_Shape& theShape ) + //ShHealOper_Tool(theShape) +{ + Init(theShape); +} +//======================================================================= +//function : Init +//purpose : +//======================================================================= + +void ShHealOper_RemoveFace::Init(const TopoDS_Shape& theShape) +{ + //myDone = Standard_False; + //myInitShape = theShape; + //myContext->Apply(myInitShape); + ShHealOper_Tool::Init(theShape); + myMapEdgesFace.Clear(); + TopExp::MapShapesAndAncestors(theShape,TopAbs_EDGE,TopAbs_FACE,myMapEdgesFace); +} +//======================================================================= +//function : Perform +//purpose : remove all faces from initial shape +//======================================================================= + +Standard_Boolean ShHealOper_RemoveFace::Perform() +{ + myDone = Standard_False; + myErrorStatus = ShHealOper_NotError; + if(myInitShape.IsNull()) { + myErrorStatus = ShHealOper_InvalidParameters; + return myDone; + } + TopExp_Explorer aExp(myInitShape,TopAbs_FACE); + for( ; aExp.More(); aExp.Next()) { + removePCurve(TopoDS::Face(aExp.Current())); + myContext->Remove(aExp.Current()); + myDone = Standard_True; + } + if(myDone) { + TopoDS_Shape aNewShape = myContext->Apply(myInitShape); + isReplace(aNewShape,myResultShape); + myContext->Replace(aNewShape,myResultShape); + } + return myDone; +} +//======================================================================= +//function : Perform +//purpose : remove faces specified by sequence of faces from initial shape. +//======================================================================= + +Standard_Boolean ShHealOper_RemoveFace::Perform(const TopTools_SequenceOfShape& theRemoveFaces) +{ + myDone = Standard_False; + myErrorStatus = ShHealOper_NotError; + if(myInitShape.IsNull()) { + myErrorStatus = ShHealOper_InvalidParameters; + return myDone; + } + if(theRemoveFaces.IsEmpty()) + return Standard_False; + myMapFaces.Clear(); + + Standard_Integer i=1; + for( ; i <= theRemoveFaces.Length(); i++) + myMapFaces.Add(theRemoveFaces.Value(i)); + + myDone = removeFaces(myInitShape,myResultShape); + return myDone; +} + +//======================================================================= +//function : removeFaces +//purpose : +//======================================================================= + +Standard_Boolean ShHealOper_RemoveFace::removeFaces(const TopoDS_Shape& theShape, + TopoDS_Shape& theNewShape) +{ + Standard_Boolean isDone = Standard_False; + + TopAbs_ShapeEnum aType = theShape.ShapeType(); + theNewShape = theShape; + if(!myMapFaces.Extent()) + return isDone; + if( aType == TopAbs_WIRE || aType == TopAbs_EDGE || aType == TopAbs_VERTEX) + return isDone; + if(aType == TopAbs_FACE && myMapFaces.Contains(theShape)) { + removePCurve(TopoDS::Face(theShape)); + + myContext->Remove(theShape); + myMapFaces.Remove(theShape); + //theNewShape = TopoDS_Shape(); + theNewShape.Nullify(); + isDone = Standard_True; + } + else if(aType == TopAbs_SHELL) { + isDone = removeFaces(TopoDS::Shell(theShape),theNewShape); + return isDone; + } + else if(aType == TopAbs_SOLID) { + isDone = removeFaces(TopoDS::Solid(theShape),theNewShape); + myContext->Replace(theShape,theNewShape); + } + else if(aType == TopAbs_COMPSOLID) { + + //in the case of compsolid method for removing faces for solid + //will be used. + + TopExp_Explorer aExpShell(theShape,TopAbs_SHELL); + TopoDS_Solid aSol; + BRep_Builder aB; + aB.MakeSolid(aSol); + for( ; aExpShell.More(); aExpShell.Next()) { + aB.Add(aSol,aExpShell.Current()); + } + TopoDS_Shape aNewShape; + isDone = removeFaces(aSol,aNewShape); + if(isDone) + myContext->Replace(theShape,theNewShape); + + } + else if(aType == TopAbs_COMPOUND) { + //in the case of compounf faces will be removed from each part of compound separately + + TopoDS_Compound aComp; + TopoDS_Iterator aItShape(theShape,Standard_False); + BRep_Builder aB; + aB.MakeCompound(aComp); + Standard_Integer nbs =0; + for( ; aItShape.More() ; aItShape.Next()) { + + TopoDS_Shape aNShape; + if( removeFaces(aItShape.Value(),aNShape)) { + isDone = Standard_True; + myContext->Replace(aItShape.Value(),aNShape); + } + if(!aNShape.IsNull()) { + aB.Add(aComp,aNShape); + nbs++; + } + } + if(isDone) { + if(nbs) + theNewShape = aComp; + else + theNewShape =TopoDS_Shape(); + myContext->Replace(theShape,theNewShape); + } + + } + return isDone; +} +//======================================================================= +//function : removeFaces +//purpose : function for removing faces from solid +//======================================================================= + +Standard_Boolean ShHealOper_RemoveFace::removeFaces(const TopoDS_Solid& theShape, + TopoDS_Shape& theNewShape) +{ + Standard_Boolean isDone = Standard_False; + TopoDS_Solid aSol; + BRep_Builder aB; + aB.MakeSolid(aSol); + TopoDS_Compound aComp; + aB.MakeCompound(aComp); + Standard_Boolean isAddSol = Standard_False, isAddComp = Standard_False; + + //firslty faces will be deleted from each shell. + TopoDS_Iterator aItSol(theShape,Standard_False); + for( ; aItSol.More(); aItSol.Next()) { + TopoDS_Shape aSh = aItSol.Value(); + TopoDS_Shape aNewShape; + if(removeFaces(aSh,aNewShape)) + isDone = Standard_True; + + if(aNewShape.IsNull()) + continue; + else if(aNewShape.ShapeType() == TopAbs_SHELL ) { + aB.Add(aSol,aNewShape); + isAddSol = Standard_True; + } + else { + aB.Add(aComp,aNewShape); + isAddComp = Standard_True; + } + + } + if(isDone) { + //for getting correct solids class ShapeFix_Solid will be used. + if(isAddSol) { + Handle(ShapeFix_Solid) aSfSol = new ShapeFix_Solid(aSol); + aSfSol->FixShellMode()= Standard_False; + aSfSol->Perform(); + TopoDS_Shape aresSol = aSfSol->Shape(); + if(!isAddComp) + theNewShape = aresSol; + else + aB.Add(aComp,aresSol); + } + else if(isAddComp) + theNewShape = aComp; + else + theNewShape.Nullify(); + } + else + theNewShape = theShape; + return isDone; +} +//======================================================================= +//function : IsManifold +//purpose : function for definition manifold shell +//======================================================================= +Standard_Boolean ShHealOper_RemoveFace::isManifold(const TopoDS_Shell& aShell) +{ + Standard_Boolean IsManifold = Standard_True; + TopExp_Explorer aExp(aShell,TopAbs_EDGE); + for( ; aExp.More() && IsManifold; aExp.Next()) { + const TopTools_ListOfShape& als = myMapEdgesFace.FindFromKey(aExp.Current()); + IsManifold = (als.Extent() <=2 ); + } + return IsManifold; +} + +//======================================================================= +//function : getResultShell +//purpose : function for avoiding empty shall or shell containing one face. +//======================================================================= +static TopoDS_Shape getResultShell(const TopoDS_Shape& theNewShell) +{ + TopoDS_Shape rs; + Standard_Integer NbFacesShell =0; + TopoDS_Shape aF; + TopoDS_Iterator aI(theNewShell,Standard_False); + for(; aI.More(); aI.Next(),NbFacesShell++) + aF = aI.Value(); + if(NbFacesShell >1) + rs = theNewShell; + else if(!aF.IsNull()) + rs = aF; + return rs; +} + +//======================================================================= +//function : removeFaces +//purpose : function for removing faces from shell +//======================================================================= + +Standard_Boolean ShHealOper_RemoveFace::removeFaces(const TopoDS_Shell& theShell, + TopoDS_Shape& theNewShape) +{ + + Standard_Boolean aIsRemove = Standard_False; + //TopoDS_Shape aShape = myReShape->Apply(theShape); + //removing faces from shell. + TopoDS_Iterator aIterFaces(theShell,Standard_False); + for(; aIterFaces.More() && myMapFaces.Extent(); aIterFaces.Next()) { + + if(!myMapFaces.Contains(aIterFaces.Value())) + continue; + TopoDS_Face aFace = TopoDS::Face( aIterFaces.Value()); + removePCurve(aFace); + aIsRemove = Standard_True; + myContext->Remove(aFace); + myMapFaces.Remove(aFace); + } + if(aIsRemove) { + TopoDS_Shape aNewShape = myContext->Apply(theShell); + //avoiding empty shell and shell containing one face. + TopoDS_Shape aresShape = getResultShell(aNewShape); + if(aresShape.IsNull()) { + myContext->Remove(aNewShape); + theNewShape.Nullify(); + } + else if(aresShape.ShapeType() == TopAbs_FACE) { + myContext->Replace(aNewShape,aresShape); + theNewShape = aresShape; + } + else if(aresShape.ShapeType() == TopAbs_SHELL) { + //obtaining correct shell or compound with help class ShapeFix_Shell. + Standard_Boolean isManifShell = isManifold(theShell); + Handle(ShapeFix_Shell) aFixShell = new ShapeFix_Shell; + aFixShell->FixFaceOrientation(TopoDS::Shell(aresShape),Standard_True,!isManifShell); + TopoDS_Shape aFixShape = aFixShell->Shape(); + TopoDS_Shape areplShape; + isReplace(aFixShape,areplShape); + myContext->Replace(aNewShape,areplShape); + theNewShape = areplShape; + } + } + else theNewShape = theShell; + return aIsRemove; +} +//======================================================================= +//function : isReplace +//purpose : method to avoiding empty compounds and shells. +//======================================================================= + +Standard_Boolean ShHealOper_RemoveFace::isReplace(const TopoDS_Shape& theShape, + TopoDS_Shape& theNewShape) +{ + + Standard_Boolean isChange = Standard_False; + TopTools_SequenceOfShape aSeqShapes; + if(theShape.ShapeType() == TopAbs_COMPOUND || theShape.ShapeType() == TopAbs_COMPSOLID || + theShape.ShapeType() == TopAbs_SOLID) { + TopoDS_Iterator aEs(theShape); + for( ; aEs.More(); aEs.Next()) { + TopoDS_Shape aNewShell = aEs.Value(); + if(aNewShell.ShapeType()!= TopAbs_SHELL) { + aSeqShapes.Append(aNewShell); + continue; + } + TopoDS_Shape as = getResultShell(TopoDS::Shell(aNewShell)); + isChange = (as.IsNull() || (as.ShapeType() == TopAbs_FACE)); + if(!as.IsNull()) { + aSeqShapes.Append(as); + } + } + } + else if(theShape.ShapeType() == TopAbs_SHELL) { + TopoDS_Shape aSh = getResultShell(TopoDS::Shell(theShape)); + isChange = (aSh.IsNull() || (aSh.ShapeType() == TopAbs_FACE)); + if(!aSh.IsNull()) + aSeqShapes.Append(aSh); + } + else aSeqShapes.Append(theShape); + + if(aSeqShapes.IsEmpty()) + return Standard_True; + + if(isChange) { + if(aSeqShapes.Length() == 1) + theNewShape = aSeqShapes.Value(1); + else if (aSeqShapes.Length() > 1) { + TopoDS_Compound aComp1; + BRep_Builder aBB; + aBB.MakeCompound(aComp1); + Standard_Integer kk =1; + for( ; kk <= aSeqShapes.Length(); kk++) + aBB.Add(aComp1,aSeqShapes.Value(kk)); + if(aSeqShapes.Length()) + theNewShape = aComp1; + } + } + else + theNewShape = theShape; + return isChange; +} +//======================================================================= +//function : removePCurve +//purpose : +//======================================================================= + +void ShHealOper_RemoveFace::removePCurve(const TopoDS_Face& theFace) +{ + //removing pcurves belonging removed face. + Handle(Geom_Surface) aSurfDel = BRep_Tool::Surface(theFace); + for(TopExp_Explorer aExpEdges(theFace,TopAbs_EDGE); aExpEdges.More(); aExpEdges.Next()) { + const TopTools_ListOfShape& alFaces = myMapEdgesFace.FindFromKey(aExpEdges.Current()); + Standard_Boolean aIsDeleted = Standard_True; + + //pcurve will be removed if containing this edge faces have different surfaces. + TopTools_ListIteratorOfListOfShape aIterOtherFace(alFaces); + for(; aIterOtherFace.More() && aIsDeleted ; aIterOtherFace.Next()) { + if(aIterOtherFace.Value().IsSame(theFace)) + continue; + TopoDS_Face aFaceOther = TopoDS::Face(aIterOtherFace.Value()); + Handle(Geom_Surface) aSurf = BRep_Tool::Surface( aFaceOther); + aIsDeleted = (aSurf != aSurfDel); + } + + TopoDS_Edge aEdge = TopoDS::Edge(myContext->Apply(aExpEdges.Current())); + ShapeBuild_Edge aSbe; + TopoDS_Edge aNewEdge = aSbe.Copy(aEdge,Standard_False); + if(aIsDeleted) { + aSbe.RemovePCurve(aNewEdge,aSurfDel); + myContext->Replace(aEdge,aNewEdge); + + } + + } +} + diff --git a/src/ShHealOper/ShHealOper_RemoveFace.hxx b/src/ShHealOper/ShHealOper_RemoveFace.hxx new file mode 100644 index 000000000..22b2923e8 --- /dev/null +++ b/src/ShHealOper/ShHealOper_RemoveFace.hxx @@ -0,0 +1,86 @@ +// File: ShHealOper_RemoveFace.hxx +// Created: 15.04.04 18:10:16 +// Author: Galina KULIKOVA +// < MODULE = KERNEL> : +// Copyright (C) 2003 CEA +// +// 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 +// + + + +#ifndef ShHealOper_RemoveFace_HeaderFile +#define ShHealOper_RemoveFace_HeaderFile + +#include +#include +#include +#include +#include +#include +#include +#include +#include +/// Class ShHealOper_RemoveFace +//Class intended to removing faces from shape. + +class ShHealOper_RemoveFace : public ShHealOper_Tool +{ + public: + // ---------- PUBLIC METHODS ---------- + + Standard_EXPORT ShHealOper_RemoveFace (); + //Empty constructor. + + Standard_EXPORT ShHealOper_RemoveFace (const TopoDS_Shape& theShape); + // Constructor initialized by shape from which faces will be removed. + Standard_EXPORT virtual void Init(const TopoDS_Shape& theShape); + //Method for initalization by whole shape. + Standard_EXPORT Standard_Boolean Perform(); + //Removes all faces from specified shape. + + Standard_EXPORT Standard_Boolean Perform(const TopTools_SequenceOfShape& theRemovedFaces); + //Removes faces specified in the sequence of faces from specified shape. + + + private: + + Standard_Boolean removeFaces(const TopoDS_Shape& theShape,TopoDS_Shape& theNewShape); + Standard_Boolean removeFaces(const TopoDS_Solid& theShape,TopoDS_Shape& theNewShape); + Standard_Boolean removeFaces(const TopoDS_Shell& theShell,TopoDS_Shape& theNewShape); + Standard_Boolean isReplace(const TopoDS_Shape& theOldShape,TopoDS_Shape& theNewShape); + //Methods for removing faces from sub-shapes. + + void removePCurve(const TopoDS_Face& theFace); + //method for removing pcurves belonging to face + + Standard_Boolean isManifold(const TopoDS_Shell& aShell); + //denenes manifold shell. + private: + // ---------- PRIVATE FIELDS ---------- + + TopTools_MapOfShape myMapFaces; + TopTools_IndexedDataMapOfShapeListOfShape myMapEdgesFace; + public: +// Declaration of CASCADE RTTI +//DEFINE_STANDARD_RTTI (ShHealOper_RemoveFace) +}; + +// Definition of HANDLE object using Standard_DefineHandle.hxx +//DEFINE_STANDARD_HANDLE (ShHealOper_RemoveFace, ) + + +#endif diff --git a/src/ShHealOper/ShHealOper_RemoveInternalWires.cxx b/src/ShHealOper/ShHealOper_RemoveInternalWires.cxx new file mode 100644 index 000000000..9fbb71c5f --- /dev/null +++ b/src/ShHealOper/ShHealOper_RemoveInternalWires.cxx @@ -0,0 +1,154 @@ +// File: ShHealOper_RemoveInternalWires.cxx +// Created: 26.04.04 14:46:45 +// Author: Galina KULIKOVA +// < MODULE = KERNEL> : +// Copyright (C) 2003 CEA +// +// 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 +// + + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//======================================================================= +//function : ShHealOper_RemoveInternalWires() +//purpose : Constructor +//======================================================================= + +ShHealOper_RemoveInternalWires::ShHealOper_RemoveInternalWires ( const TopoDS_Shape& theShape ) +{ + Init(theShape); +} +//======================================================================= +//function : Init +//purpose : +//======================================================================= + +void ShHealOper_RemoveInternalWires::Init(const TopoDS_Shape& theShape) +{ + ShHealOper_Tool::Init(theShape); + myMapWiresFace.Clear(); + TopExp::MapShapesAndAncestors(theShape,TopAbs_WIRE,TopAbs_FACE,myMapWiresFace); +} +//======================================================================= +//function : Remove +//purpose : +//======================================================================= + +Standard_Boolean ShHealOper_RemoveInternalWires::Remove() +{ + TopExp_Explorer aexpFaces(myInitShape,TopAbs_FACE); + //removes internal wires from all faces in the shape + Standard_Boolean isDone = Standard_False; + for( ; aexpFaces.More(); aexpFaces.Next()) + isDone = removeWire(TopoDS::Face(aexpFaces.Current()),TopoDS_Wire()) || isDone; + if(isDone ) { + TopoDS_Shape aNewShape = myContext->Apply(myInitShape); + //fix not-connected shell and solids obtained after removing wires + fixShape(aNewShape); + } + myDone = isDone; + return myDone; +} +//======================================================================= +//function : Remove +//purpose : +//======================================================================= + +Standard_Boolean ShHealOper_RemoveInternalWires::Remove(const TopTools_SequenceOfShape& theRemovedShapes) +{ + myDone = Standard_False; + + Standard_Integer i =1; + for( ; i <= theRemovedShapes.Length(); i++) { + //removes internal wires from specified faces. + if(theRemovedShapes.Value(i).ShapeType() == TopAbs_FACE) + myDone = (removeWire(TopoDS::Face(theRemovedShapes.Value(i)),TopoDS_Wire()) || myDone) ; + else if(theRemovedShapes.Value(i).ShapeType() == TopAbs_WIRE) + { + //removes specified internal wires. + TopoDS_Wire awire = TopoDS::Wire(theRemovedShapes.Value(i)); + if(myMapWiresFace.Contains(awire)) { + const TopTools_ListOfShape& aLfaces = myMapWiresFace.FindFromKey(awire); + TopTools_ListIteratorOfListOfShape liter(aLfaces); + for( ; liter.More(); liter.Next()) + myDone = (removeWire(TopoDS::Face(liter.Value()),awire) || myDone); + } + } + } + if(myDone ) { + TopoDS_Shape aNewShape = myContext->Apply(myInitShape); + + //fix not-connected shell and solids obtained after removing wires + fixShape(aNewShape); + + } + return myDone; +} +//======================================================================= +//function : removeWire +//purpose : +//======================================================================= + +Standard_Boolean ShHealOper_RemoveInternalWires::removeWire(const TopoDS_Face& theFace, + const TopoDS_Wire& theWire) +{ + TopoDS_Wire aBoundWire = ShapeAnalysis::OuterWire(theFace); + if(!theWire.IsNull() && aBoundWire.IsSame(theWire)) { + myErrorStatus = ShHealOper_InvalidParameters; + return Standard_False; + } + + Standard_Boolean isremove = Standard_False; + if(!theWire.IsNull()) { + myContext->Remove(theWire); + isremove= Standard_True; + } + else { + TopExp_Explorer aExpW(theFace,TopAbs_WIRE); + for( ; aExpW.More(); aExpW.Next()) { + if(!aBoundWire.IsSame(aExpW.Current())) { + myContext->Remove(aExpW.Current()); + isremove= Standard_True; + } + } + } + return isremove; +} +//======================================================================= +//function : fixShape +//purpose : +//======================================================================= + +void ShHealOper_RemoveInternalWires::fixShape(const TopoDS_Shape& theShape ) +{ + Handle(ShapeFix_Shape) aFixTool = new ShapeFix_Shape(theShape); + aFixTool->SetContext(myContext); + aFixTool->FixShellTool()->FixFaceMode() = Standard_False; + aFixTool->FixFreeFaceMode() = Standard_False; + aFixTool->FixFreeWireMode() = Standard_False; + aFixTool->FixSameParameterMode() = Standard_False; + aFixTool->Perform(); + myResultShape = aFixTool->Shape(); +} diff --git a/src/ShHealOper/ShHealOper_RemoveInternalWires.hxx b/src/ShHealOper/ShHealOper_RemoveInternalWires.hxx new file mode 100644 index 000000000..fec59375c --- /dev/null +++ b/src/ShHealOper/ShHealOper_RemoveInternalWires.hxx @@ -0,0 +1,83 @@ +// File: ShHealOper_RemoveInternalWires.hxx +// Created: 26.04.04 11:22:26 +// Author: Galina KULIKOVA +// < MODULE = KERNEL> : +// Copyright (C) 2003 CEA +// +// 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 +// + + +#ifndef ShHealOper_RemoveInternalWires_HeaderFile +#define ShHealOper_RemoveInternalWires_HeaderFile + +#include +#include +#include +#include +#include +#include +#include + +/// Class ShHealOper_RemoveInternalWires +// Intended for removing internal wires from faces. + +class ShHealOper_RemoveInternalWires : public ShHealOper_Tool +{ + public: + // ---------- PUBLIC METHODS ---------- + + /// Empty constructor + Standard_EXPORT ShHealOper_RemoveInternalWires () {} + + /// Copy constructor + Standard_EXPORT ShHealOper_RemoveInternalWires (const TopoDS_Shape& theShape); + //Method for initalization by whole shape. + + Standard_EXPORT virtual void Init(const TopoDS_Shape& theShape); + //Method for initalization by whole shape. + + Standard_EXPORT Standard_Boolean Remove(); + //Removes all internal wires from all faces of the shape + + Standard_EXPORT Standard_Boolean Remove(const TopTools_SequenceOfShape& theRemovedShapes); + //Removes wires specified in the sequence of shapes or internal wires + //belonging faces specified in the sequence of shape. + + + private: + // ---------- PRIVATE METHODS ---------- + + Standard_Boolean removeWire(const TopoDS_Face& theFace, + const TopoDS_Wire& theWire); + void fixShape(const TopoDS_Shape& theShape ); + + private: + // ---------- PRIVATE FIELDS ---------- + TopTools_IndexedDataMapOfShapeListOfShape myMapWiresFace; + + + + public: +// Declaration of CASCADE RTTI +//DEFINE_STANDARD_RTTI (ShHealOper_RemoveInternalWires) +}; + +// Definition of HANDLE object using Standard_DefineHandle.hxx +//DEFINE_STANDARD_HANDLE (ShHealOper_RemoveInternalWires, ) + + +#endif diff --git a/src/ShHealOper/ShHealOper_Sewing.cxx b/src/ShHealOper/ShHealOper_Sewing.cxx new file mode 100644 index 000000000..b0f8e4206 --- /dev/null +++ b/src/ShHealOper/ShHealOper_Sewing.cxx @@ -0,0 +1,282 @@ +// File: ShHealOper_Sewing.cxx +// Created: 29.04.04 15:07:10 +// Author: Galina KULIKOVA +// < MODULE = KERNEL> : +// Copyright (C) 2003 CEA +// +// 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 +// + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +//======================================================================= +//function : ShHealOper_Sewing() +//purpose : Constructor +//======================================================================= + + +ShHealOper_Sewing::ShHealOper_Sewing (const TopoDS_Shape& theShape, + const Standard_Real theTolerance) +{ + Init(theShape); + myTolerance = theTolerance; +} +//======================================================================= +//function : Init +//purpose : +//======================================================================= + +void ShHealOper_Sewing::Init(const TopoDS_Shape& theShape) +{ + ShHealOper_Tool::Init(theShape); + myTolerance = Precision::Confusion(); + myEdgesMode = Standard_False; + myFacesMode = Standard_True; + myNonManifoldMode = Standard_False; + myHistoryLevel = TopAbs_FACE; +} +//======================================================================= +//function : Perform +//purpose : +//======================================================================= + +Standard_Boolean ShHealOper_Sewing::Perform() +{ + TopTools_SequenceOfShape theSeqShapes; + return sewing(theSeqShapes); +} +//======================================================================= +//function : Perform +//purpose : +//======================================================================= + +Standard_Boolean ShHealOper_Sewing::Perform(const TopTools_SequenceOfShape& theSeqShapes) +{ + return sewing(theSeqShapes); +} + +//======================================================================= +//function : sewing +//purpose : +//======================================================================= + +Standard_Boolean ShHealOper_Sewing::sewing(const TopTools_SequenceOfShape& theSeqShapes) +{ + myDone = Standard_False; + myErrorStatus = ShHealOper_NotError; + if(myInitShape.IsNull()) { + myErrorStatus = ShHealOper_InvalidParameters; + return myDone; + } + //sewing shape + Handle(BRepAlgo_Sewing) aSewing = new BRepAlgo_Sewing; + aSewing->Load(myInitShape); + aSewing->SetTolerance(myTolerance); + aSewing->SetFaceMode(myFacesMode); + aSewing->SetFloatingEdgesMode(myEdgesMode); + aSewing->SetNonManifoldMode(myNonManifoldMode); + Standard_Integer j =1; + for( ; j <= theSeqShapes.Length();j++) + aSewing->Add(theSeqShapes.Value(j)); + + aSewing->Perform(); + const TopoDS_Shape aSewShape = aSewing->SewedShape(); + if(aSewShape.IsNull()) { + myErrorStatus = ShHealOper_ErrorExecution; + return myDone; + } + if(aSewShape.IsSame(myInitShape)) + return myDone; + + //analysis either sewing was made by changing number of shells + myDone = isSewed(aSewShape); + + //keep modification of the subshapes in the Context. + TopExp_Explorer aExp(myInitShape,TopAbs_FACE); + for( ; aExp.More(); aExp.Next()) + myDone = (getModifications( aExp.Current(),aSewing) || myDone); + + TopoDS_Shape aTempShape = myContext->Apply(aSewShape); + //obtained shells with fixed orientation for manifold and nonmanifold shells + if(myFacesMode) + myDone = getShells(aTempShape) || myDone; + + //obtained manifold wires if sewing edges was performed. + if(myEdgesMode) + myDone = getWires(aTempShape) || myDone; + + if(myDone) + myResultShape = myContext->Apply(aTempShape); + + return myDone; +} +//======================================================================= +//function : getShells +//purpose : +//======================================================================= + +Standard_Boolean ShHealOper_Sewing::getShells(const TopoDS_Shape& theSewShape) const +{ + Standard_Boolean isDone = Standard_False; + TopoDS_Shape aTmpShape = theSewShape; + if(myNonManifoldMode) { + TopoDS_Shell tempShell; + BRep_Builder aB; + aB.MakeShell(tempShell); + + for(TopExp_Explorer aExpf(theSewShape,TopAbs_FACE);aExpf.More(); aExpf.Next()) + aB.Add(tempShell,aExpf.Current()); + aTmpShape = tempShell; + myContext->Replace(theSewShape,aTmpShape); + } + + Handle(ShapeFix_Shell) asfs = new ShapeFix_Shell; + asfs->SetContext(myContext); + TopExp_Explorer aexpShell(aTmpShape,TopAbs_SHELL); + for ( ; aexpShell.More(); aexpShell.Next()) + isDone = (asfs->FixFaceOrientation(TopoDS::Shell(aexpShell.Current()), + Standard_True,myNonManifoldMode) || isDone); + + return isDone; +} +//======================================================================= +//function : getWires +//purpose : +//======================================================================= + +Standard_Boolean ShHealOper_Sewing::getWires(const TopoDS_Shape& theSewShape) const +{ + if(theSewShape.ShapeType() != TopAbs_COMPOUND) + return Standard_False; + + Handle(TopTools_HSequenceOfShape) aSeqEdges = new TopTools_HSequenceOfShape; + TopExp_Explorer aexpEdges(theSewShape,TopAbs_EDGE,TopAbs_WIRE); + for ( ; aexpEdges.More(); aexpEdges.Next()) { + aSeqEdges->Append(aexpEdges.Current()); + } + if(aSeqEdges->Length() <2) + return Standard_False; + //get manifold wires from sewed edges. + Standard_Real aTol = 0.; + Standard_Boolean aShared = Standard_True; + Handle(TopTools_HSequenceOfShape) aTmpWires = new TopTools_HSequenceOfShape; + ShapeAnalysis_FreeBounds::ConnectEdgesToWires(aSeqEdges, aTol, aShared, aTmpWires); + + TopTools_MapOfShape aMapEdges; + Standard_Integer i =1; + for( ; i <= aSeqEdges->Length(); i++) + aMapEdges.Add(aSeqEdges->Value(i)); + + //remove free edges from result shape. + TopoDS_Compound aNewComp; + deleteFreeEdges(theSewShape,aMapEdges,aNewComp); + + //add new wires in the result shape. + BRep_Builder aB; + for( i =1; i <= aTmpWires->Length(); i++) { + TopoDS_Iterator aite(aTmpWires->Value(i)); + Standard_Integer nbe =0; + TopoDS_Shape aE; + for( ; aite.More() && nbe < 3; aite.Next(),nbe++) + aE = aite.Value(); + if(!nbe) + continue; + else if(nbe ==1) + aB.Add(aNewComp,aE); + else + aB.Add(aNewComp,aTmpWires->Value(i)); + } + + myContext->Replace(theSewShape,aNewComp); + return Standard_True; +} +//======================================================================= +//function : getHistory +//purpose : +//======================================================================= + +Standard_Boolean ShHealOper_Sewing::getModifications(const TopoDS_Shape& theShape, + const Handle(BRepAlgo_Sewing)& theSewing) const +{ + if((Standard_Integer)theShape.ShapeType() > (Standard_Integer)myHistoryLevel) + return Standard_False; + + Standard_Boolean isDone = theSewing->IsModifiedSubShape(theShape); + if(isDone) { + TopoDS_Shape aNewShape = theSewing->ModifiedSubShape(theShape); + myContext->Replace(theShape,aNewShape); + } + TopoDS_Iterator aIt(theShape); + for( ; aIt.More(); aIt.Next()) { + isDone = (getModifications( aIt.Value(),theSewing) || isDone); + } + return isDone; + +} +//======================================================================= +//function : isSewed +//purpose : +//======================================================================= + +Standard_Boolean ShHealOper_Sewing::isSewed(const TopoDS_Shape& theShape) const +{ + Standard_Integer nbNewShells =0; + Standard_Integer nbOldShells =0; + TopExp_Explorer aExpShells(theShape,TopAbs_SHELL); + for( ; aExpShells.More(); aExpShells.Next()) + nbNewShells++; + for( aExpShells.Init(myInitShape,TopAbs_SHELL); aExpShells.More(); aExpShells.Next()) + nbOldShells++; + return (nbNewShells != nbOldShells); +} +//======================================================================= +//function : deleteFreeEdges +//purpose : +//======================================================================= + +void ShHealOper_Sewing::deleteFreeEdges(const TopoDS_Shape& theSewShape, + TopTools_MapOfShape& theMapEdges, + TopoDS_Compound& theNewComp) const +{ + + BRep_Builder aB; + aB.MakeCompound(theNewComp); + TopoDS_Iterator aIt(theSewShape); + + for( ; aIt.More(); aIt.Next()) { + if((aIt.Value().ShapeType() == TopAbs_EDGE ) && theMapEdges.Contains(aIt.Value())) + continue; + else if(aIt.Value().ShapeType() == TopAbs_COMPOUND) { + TopoDS_Compound aC; + deleteFreeEdges(aIt.Value(),theMapEdges,aC); + aB.Add(theNewComp,aC); + } + else + aB.Add(theNewComp,aIt.Value()); + } +} diff --git a/src/ShHealOper/ShHealOper_Sewing.hxx b/src/ShHealOper/ShHealOper_Sewing.hxx new file mode 100644 index 000000000..e7244b227 --- /dev/null +++ b/src/ShHealOper/ShHealOper_Sewing.hxx @@ -0,0 +1,152 @@ +// File: ShHealOper_Sewing.hxx +// Created: 29.04.04 13:29:10 +// Author: Galina KULIKOVA +// < MODULE = KERNEL> : +// Copyright (C) 2003 CEA +// +// 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 +// + + +#ifndef ShHealOper_Sewing_HeaderFile +#define ShHealOper_Sewing_HeaderFile + +#include +#include +#include +#include +#include +#include +#include +#include + +/// Class ShHealOper_Sewing +//Intended for sewing of shapes. + +class ShHealOper_Sewing : public ShHealOper_Tool +{ + public: + // ---------- PUBLIC METHODS ---------- + + + Standard_EXPORT ShHealOper_Sewing () : ShHealOper_Tool() {} + // Empty constructor + + Standard_EXPORT ShHealOper_Sewing (const TopoDS_Shape& theShape, + const Standard_Real theTolerance); + //Constructor for initalization by shape and tolerance. + + Standard_EXPORT virtual void Init(const TopoDS_Shape& theShape); + //Method for initalization by whole shape. + + Standard_EXPORT Standard_Boolean Perform(); + //Performs sewing specified whole shape. + + Standard_EXPORT Standard_Boolean Perform(const TopTools_SequenceOfShape& theSeqShapes); + //Performs local sewing specified sub-shapes from whole shape. + + inline void SetFacesMode(const Standard_Boolean theFacesMode ) + { + myFacesMode = theFacesMode; + } + //Set mode for sewing faces.(by default true) + + inline Standard_Boolean GetFacesMode( ) + { + return myFacesMode; + } + //Get mode for sewing of faces. + + inline void SetFloatingEdgesMode(const Standard_Boolean theEdgesMode ) + { + myEdgesMode = theEdgesMode; + } + //Set mode for sewing floating edges.(by default false) + + inline Standard_Boolean GetFloatingEdgesMode( ) + { + return myEdgesMode; + } + //Get mode for sewing of floating edges. + + inline void SetNonManifoldMode(const Standard_Boolean theNonManifoldMode ) + { + myNonManifoldMode = theNonManifoldMode; + } + //Set NonManifoldMode mode for sewing (by default false) + + inline Standard_Boolean GetNonManifoldMode( ) + { + return myNonManifoldMode; + } + //Get NonManifoldMode mode for sewing. + + inline void SetTolerance(const Standard_Real theToler) + { + myTolerance = theToler; + } + //set tolerance for sewing. + + inline Standard_Real GetTolerance() + { + return myTolerance; + } + //get tolerance set for sewing. + + inline void SetHistoryLevel(TopAbs_ShapeEnum theHistLevel) + { + myHistoryLevel =theHistLevel; + } + //set shape level (default TopAbs_FACE) for keeping modifications of the shapes. + + inline TopAbs_ShapeEnum GetHistoryLevel() + { + return myHistoryLevel; + } + //get specified shape level for keeping history. + + private: + // ---------- PRIVATE METHODS ---------- + + Standard_Boolean sewing(const TopTools_SequenceOfShape& theSeqShapes); + Standard_Boolean getShells(const TopoDS_Shape& theSewShape) const; + Standard_Boolean getWires(const TopoDS_Shape& theSewShape) const; + Standard_Boolean getModifications(const TopoDS_Shape& theShape, + const Handle(BRepAlgo_Sewing)& theSewing) const; + + Standard_Boolean isSewed(const TopoDS_Shape& theShape) const; + + void deleteFreeEdges(const TopoDS_Shape& theSewShape, + TopTools_MapOfShape& theMapEdges, + TopoDS_Compound& theNewComp) const; + private: + // ---------- PRIVATE FIELDS ---------- + + Standard_Boolean myNonManifoldMode; + Standard_Boolean myEdgesMode; + Standard_Boolean myFacesMode; + Standard_Real myTolerance; + TopAbs_ShapeEnum myHistoryLevel; + public: +// Declaration of CASCADE RTTI +//DEFINE_STANDARD_RTTI (ShHealOper_Sewing) +}; + +// Definition of HANDLE object using Standard_DefineHandle.hxx +//DEFINE_STANDARD_HANDLE (ShHealOper_Sewing, ) + + +#endif diff --git a/src/ShHealOper/ShHealOper_ShapeProcess.cxx b/src/ShHealOper/ShHealOper_ShapeProcess.cxx new file mode 100644 index 000000000..56503fbb4 --- /dev/null +++ b/src/ShHealOper/ShHealOper_ShapeProcess.cxx @@ -0,0 +1,161 @@ +// File: ShHealOper_ShapeProcess.cxx +// Created: 14.04.04 10:58:04 +// Author: Galina KULIKOVA +// < MODULE = KERNEL> : +// Copyright (C) 2003 CEA +// +// 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 +// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +//======================================================================= +//function : ShHealOper_ShapeProcess() +//purpose : Constructor +//======================================================================= + +ShHealOper_ShapeProcess::ShHealOper_ShapeProcess ( ) : + myOperations(TCollection_AsciiString("ShHealing").ToCString(), + TCollection_AsciiString("ShapeProcess").ToCString()) +{ + //myResource = new Resource_Manager("ShHealing"); + myPrefix = "ShapeProcess"; + mySaveHistoryMode = Standard_False; + myLevel = TopAbs_FACE; + myDone = Standard_False; +} + +//======================================================================= +//function : ShHealOper_ShapeProcess +//purpose : +//======================================================================= + +ShHealOper_ShapeProcess::ShHealOper_ShapeProcess (const TCollection_AsciiString& theNameResource, + const TCollection_AsciiString& thePrefix ) : + myOperations(theNameResource.ToCString(),thePrefix.ToCString()) +{ + //myResource = new Resource_Manager(theNameResource); + myPrefix = thePrefix; + mySaveHistoryMode = Standard_False; + myLevel = TopAbs_FACE; + myDone = Standard_False; +} + +//======================================================================= +//function : Perform +//purpose : +//======================================================================= +void ShHealOper_ShapeProcess::Perform(const TopoDS_Shape& theOldShape, + TopoDS_Shape& theNewShape) +{ + + myMapModifications.Clear(); + //ShapeProcessAPI_ApplySequence aOperations(myResource,myPrefix.ToCString()); + //myDone = Standard_False; + myOperations.ClearMap(); + + theNewShape = myOperations.PrepareShape(theOldShape,mySaveHistoryMode,myLevel); + if(mySaveHistoryMode) + myMapModifications = myOperations.Map(); + myDone = !theOldShape.IsSame(theNewShape); +} +//======================================================================= +//function : SetOperators +//purpose : +//======================================================================= + +void ShHealOper_ShapeProcess::SetOperators(const TColStd_SequenceOfAsciiString& theSeqOperators) +{ + + TCollection_AsciiString anameParam(myPrefix); + anameParam += "."; + anameParam += "exec.op"; + TCollection_AsciiString aseq; + Standard_Integer i =1; + for( ; i <= theSeqOperators.Length(); i++) { + aseq += theSeqOperators.Value(i); + aseq += " "; + } + + myOperations.Context()->ResourceManager()->SetResource(anameParam.ToCString(),aseq.ToCString()); +} +//======================================================================= +//function : SetParameter +//purpose : +//======================================================================= + +void ShHealOper_ShapeProcess::SetParameter(const TCollection_AsciiString& theNameParam, + const TCollection_AsciiString& theVal) +{ + TCollection_AsciiString anameParam(myPrefix); + anameParam += "."; + anameParam+= theNameParam; + if(theVal.IsIntegerValue()) + myOperations.Context()->ResourceManager()-> + SetResource(anameParam.ToCString(),theVal.IntegerValue()); + else if(theVal.IsRealValue()) + myOperations.Context()->ResourceManager()-> + SetResource(anameParam.ToCString(),theVal.RealValue()); + else + myOperations.Context()->ResourceManager()-> + SetResource(anameParam.ToCString(),theVal.ToCString()); + +} +//======================================================================= +//function : GetOperators +//purpose : +//======================================================================= + +Standard_Boolean ShHealOper_ShapeProcess::GetOperators(TColStd_SequenceOfAsciiString& theSeqOperators) +{ + TCollection_AsciiString nameSeq(myPrefix); + nameSeq +=".exec.op"; + if(!myOperations.Context()->ResourceManager()->Find(nameSeq.ToCString())) + return Standard_False; + + TCollection_AsciiString seqoper = myOperations.Context()->ResourceManager()->Value(nameSeq.ToCString()); + Standard_Integer i; + for ( i=1; ; i++ ) { + TCollection_AsciiString anOper = seqoper.Token ( " \t,;", i ); + if ( anOper.Length() <=0 ) break; + theSeqOperators.Append(anOper); + } + return (theSeqOperators.Length()); +} +//======================================================================= +//function : GetParameter +//purpose : +//======================================================================= + +Standard_Boolean ShHealOper_ShapeProcess::GetParameter(const TCollection_AsciiString& theNameParam, + TCollection_AsciiString& theVal) +{ + TCollection_AsciiString namePar(myPrefix); + namePar += "."; + namePar += theNameParam; + if(!myOperations.Context()->ResourceManager()->Find(namePar.ToCString())) + return Standard_False; + + theVal = myOperations.Context()->ResourceManager()->Value(namePar.ToCString()); + return Standard_True; +} diff --git a/src/ShHealOper/ShHealOper_ShapeProcess.hxx b/src/ShHealOper/ShHealOper_ShapeProcess.hxx new file mode 100644 index 000000000..62f2c3abb --- /dev/null +++ b/src/ShHealOper/ShHealOper_ShapeProcess.hxx @@ -0,0 +1,131 @@ +// File: ShHealOper_ShapeProcess.hxx +// Created: 13.04.04 11:45:20 +// Author: Galina KULIKOVA +// < MODULE = KERNEL> : +// Copyright (C) 2003 CEA +// +// 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 +// + + +#ifndef ShHealOper_ShapeProcess_HeaderFile +#define ShHealOper_ShapeProcess_HeaderFile + +#include +#include +#include +#include +#include +#include +#include + +/// Class ShHealOper_ShapeProcess +//Class for performing Shape healing operations on the shape. + +class ShHealOper_ShapeProcess +{ + public: + // ---------- PUBLIC METHODS ---------- + + /// Empty constructor + Standard_EXPORT ShHealOper_ShapeProcess(); + //Constuctor initializes by defaults parameters + // (name of resource file - ShHealing, prefix - ShapeProcess, + // SaveHistory = Standard_False, level = TopAbs_FACE) + + /// Copy constructor + Standard_EXPORT ShHealOper_ShapeProcess + (const TCollection_AsciiString& theNameResource, + const TCollection_AsciiString& thePrefix = "ShapeProcess"); + //Constuctor initializes by specified name of resource file and prefix + + Standard_EXPORT void Perform(const TopoDS_Shape& theOldShape, + TopoDS_Shape& theNewShape); + //Perform modifications of specified shape. + + Standard_EXPORT void SetOperators(const TColStd_SequenceOfAsciiString& theSeqOperators); + //Set sequence of operatotrs different than sequence written in the resourse file. + + Standard_EXPORT Standard_Boolean GetOperators(TColStd_SequenceOfAsciiString& theSeqOperators); + //Get sequence of operators. + + Standard_EXPORT void SetParameter(const TCollection_AsciiString& theNameParam, + const TCollection_AsciiString& theVal); + //Set value of specified parameter different than value written in the resourse file. + + Standard_EXPORT Standard_Boolean GetParameter(const TCollection_AsciiString& theNameParam, + TCollection_AsciiString& theVal); + //Get value of parameter by it's name. + + inline void SetSaveHistoryMode(const Standard_Boolean theSaveHistory, + TopAbs_ShapeEnum theuntil = TopAbs_FACE) + { + mySaveHistoryMode = theSaveHistory; + myLevel = theuntil; + } + //Set SaveHistoryMode nnd level of the shapes until history will be saved to the + //specified values. + + + inline Standard_Boolean GetSaveHistoryMode() + { + return mySaveHistoryMode; + } + //Returns SaveHistoryMode. + + inline Standard_Boolean GetModifiedShape(const TopoDS_Shape& theOldShape, + TopoDS_Shape& theNewShape) + { + Standard_Boolean isModif = (!myMapModifications.IsEmpty() && + myMapModifications.IsBound(theOldShape)); + if(isModif) + theNewShape = myMapModifications.Find(theOldShape); + else + theNewShape = theOldShape; + return isModif; + } + //Get modified shape for any specified shape + + inline Standard_Boolean isDone() + { + return myDone; + } + //returns status of operation. + protected: + // ---------- PROTECTED METHODS ---------- + + + + private: + // ---------- PRIVATE FIELDS ---------- + + //Handle(Resource_Manager) myResource; + ShapeProcessAPI_ApplySequence myOperations; + TCollection_AsciiString myPrefix; + TopTools_DataMapOfShapeShape myMapModifications; + Standard_Boolean mySaveHistoryMode; + TopAbs_ShapeEnum myLevel; + Standard_Boolean myDone; + public: +// Declaration of CASCADE RTTI +//DEFINE_STANDARD_RTTI (ShHealOper_ShapeProcess) +}; + +// Definition of HANDLE object using Standard_DefineHandle.hxx +//DEFINE_STANDARD_HANDLE (ShHealOper_ShapeProcess, ) + + +#endif diff --git a/src/ShHealOper/ShHealOper_SpiltCurve2d.hxx b/src/ShHealOper/ShHealOper_SpiltCurve2d.hxx new file mode 100644 index 000000000..e7cd704a1 --- /dev/null +++ b/src/ShHealOper/ShHealOper_SpiltCurve2d.hxx @@ -0,0 +1,66 @@ +// File: ShHealOper_SplitCurve2d.hxx +// Created: 05.05.04 12:56:01 +// Author: Galina KULIKOVA +// < MODULE = KERNEL> : +// Copyright (C) 2003 CEA +// +// 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 +// + + +#ifndef ShHealOper_SplitCurve2d_HeaderFile +#define ShHealOper_SplitCurve2d_HeaderFile + +#include +#include + +/// Class ShHealOper_SplitCurve2d +//Auxiliary class for class ShHealOper_EdgeDivide + +class ShHealOper_SplitCurve2d : public ShapeUpgrade_SplitCurve2d +{ + public: + // ---------- PUBLIC METHODS ---------- + + + Standard_EXPORT ShHealOper_SplitCurve2d () : ShapeUpgrade_SplitCurve2d {} + // Empty constructor + + Standard_EXPORT virtual void Compute(); + + inline void SetValues(const Handle(TColStd_HSequenceOfReal)& theValues) + { + myValues = theValues; + } + + + + private: + // ---------- PRIVATE FIELDS ---------- + + Handle(TColStd_HSequenceOfReal) myValues; + + + public: +// Declaration of CASCADE RTTI +DEFINE_STANDARD_RTTI (ShHealOper_SplitCurve2d) +}; + +// Definition of HANDLE object using Standard_DefineHandle.hxx +DEFINE_STANDARD_HANDLE (ShHealOper_SplitCurve2d,ShapeUpgrade_SplitCurve2d ) + + +#endif diff --git a/src/ShHealOper/ShHealOper_SplitCurve2d.cxx b/src/ShHealOper/ShHealOper_SplitCurve2d.cxx new file mode 100644 index 000000000..2cc261fa2 --- /dev/null +++ b/src/ShHealOper/ShHealOper_SplitCurve2d.cxx @@ -0,0 +1,47 @@ +// File: ShHealOper_SplitCurve2d.cxx +// Created: 05.05.04 13:03:10 +// Author: Galina KULIKOVA +// < MODULE = KERNEL> : +// Copyright (C) 2003 CEA +// +// 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 +// + + +#include +#include +#include + +IMPLEMENT_STANDARD_HANDLE (ShHealOper_SplitCurve2d,ShapeUpgrade_SplitCurve2d) +IMPLEMENT_STANDARD_RTTIEXT(ShHealOper_SplitCurve2d,ShapeUpgrade_SplitCurve2d) + +//======================================================================= +//function : Compute +//purpose : +//======================================================================= + +void ShHealOper_SplitCurve2d::Compute() +{ + if(myValues.IsNull()) + myStatus = ShapeExtend::EncodeStatus (ShapeExtend_FAIL); + else { + SetSplitValues(myValues); + myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE1); + } +} + + + diff --git a/src/ShHealOper/ShHealOper_SplitCurve2d.hxx b/src/ShHealOper/ShHealOper_SplitCurve2d.hxx new file mode 100644 index 000000000..ca1f7aa35 --- /dev/null +++ b/src/ShHealOper/ShHealOper_SplitCurve2d.hxx @@ -0,0 +1,66 @@ +// File: ShHealOper_SplitCurve2d.hxx +// Created: 05.05.04 12:56:01 +// Author: Galina KULIKOVA +// < MODULE = KERNEL> : +// Copyright (C) 2003 CEA +// +// 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 +// + + +#ifndef ShHealOper_SplitCurve2d_HeaderFile +#define ShHealOper_SplitCurve2d_HeaderFile + +#include +#include +#include +/// Class ShHealOper_SplitCurve2d +//Auxiliary class for class ShHealOper_EdgeDivide + +class ShHealOper_SplitCurve2d : public ShapeUpgrade_SplitCurve2d +{ + public: + // ---------- PUBLIC METHODS ---------- + + + Standard_EXPORT ShHealOper_SplitCurve2d () : ShapeUpgrade_SplitCurve2d() {} + // Empty constructor + + Standard_EXPORT virtual void Compute(); + + inline void SetValues(const Handle(TColStd_HSequenceOfReal)& theValues) + { + myValues = theValues; + } + + + + private: + // ---------- PRIVATE FIELDS ---------- + + Handle(TColStd_HSequenceOfReal) myValues; + + + public: +// Declaration of CASCADE RTTI +DEFINE_STANDARD_RTTI (ShHealOper_SplitCurve2d) +}; + +// Definition of HANDLE object using Standard_DefineHandle.hxx +DEFINE_STANDARD_HANDLE (ShHealOper_SplitCurve2d,ShapeUpgrade_SplitCurve2d ) + + +#endif diff --git a/src/ShHealOper/ShHealOper_SplitCurve3d.cxx b/src/ShHealOper/ShHealOper_SplitCurve3d.cxx new file mode 100644 index 000000000..67405daea --- /dev/null +++ b/src/ShHealOper/ShHealOper_SplitCurve3d.cxx @@ -0,0 +1,46 @@ +// File: ShHealOper_SplitCurve3d.cxx +// Created: 05.05.04 12:48:36 +// Author: Galina KULIKOVA +// < MODULE = KERNEL> : +// Copyright (C) 2003 CEA +// +// 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 +// + + +#include +#include +#include + +IMPLEMENT_STANDARD_HANDLE (ShHealOper_SplitCurve3d,ShapeUpgrade_SplitCurve3d) +IMPLEMENT_STANDARD_RTTIEXT(ShHealOper_SplitCurve3d,ShapeUpgrade_SplitCurve3d) + +//======================================================================= +//function : Compute +//purpose : +//======================================================================= + +void ShHealOper_SplitCurve3d::Compute() +{ + if(myValues.IsNull()) + myStatus = ShapeExtend::EncodeStatus (ShapeExtend_FAIL); + else { + SetSplitValues(myValues); + myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE1); + } +} + + diff --git a/src/ShHealOper/ShHealOper_SplitCurve3d.hxx b/src/ShHealOper/ShHealOper_SplitCurve3d.hxx new file mode 100644 index 000000000..97feb74f8 --- /dev/null +++ b/src/ShHealOper/ShHealOper_SplitCurve3d.hxx @@ -0,0 +1,66 @@ +// File: ShHealOper_SplitCurve3d.hxx +// Created: 05.05.04 12:28:13 +// Author: Galina KULIKOVA +// < MODULE = KERNEL> : +// Copyright (C) 2003 CEA +// +// 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 +// + + +#ifndef ShHealOper_SplitCurve3d_HeaderFile +#define ShHealOper_SplitCurve3d_HeaderFile + +#include +#include +#include + +/// Class ShHealOper_SplitCurve3d +//Auxiliary class for class ShHealOper_EdgeDivide + +class ShHealOper_SplitCurve3d : public ShapeUpgrade_SplitCurve3d +{ + public: + // ---------- PUBLIC METHODS ---------- + + + Standard_EXPORT ShHealOper_SplitCurve3d () : ShapeUpgrade_SplitCurve3d() {} + // Empty constructor + + Standard_EXPORT virtual void Compute(); + + inline void SetValues(const Handle(TColStd_HSequenceOfReal)& theValues) + { + myValues = theValues; + } + + + private: + // ---------- PRIVATE FIELDS ---------- + Handle(TColStd_HSequenceOfReal) myValues; + + + + public: +// Declaration of CASCADE RTTI +DEFINE_STANDARD_RTTI (ShHealOper_SplitCurve3d) +}; + +// Definition of HANDLE object using Standard_DefineHandle.hxx +DEFINE_STANDARD_HANDLE (ShHealOper_SplitCurve3d,ShapeUpgrade_SplitCurve3d) + + +#endif diff --git a/src/ShHealOper/ShHealOper_Tool.cxx b/src/ShHealOper/ShHealOper_Tool.cxx new file mode 100644 index 000000000..dd3164d73 --- /dev/null +++ b/src/ShHealOper/ShHealOper_Tool.cxx @@ -0,0 +1,60 @@ +// File: ShHealOper_Tool.cxx +// Created: 26.04.04 12:11:33 +// Author: Galina KULIKOVA +// < MODULE = KERNEL> : +// Copyright (C) 2003 CEA +// +// 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 +// + + + +#include + +//======================================================================= +//function : ShHealOper_Tool() +//purpose : Constructor +//======================================================================= + +ShHealOper_Tool::ShHealOper_Tool ( ) +{ + myContext = new ShapeBuild_ReShape; + myDone = Standard_False; + myErrorStatus =ShHealOper_NotError; +} +//======================================================================= +//function : ShHealOper_Tool +//purpose : +//======================================================================= + +ShHealOper_Tool::ShHealOper_Tool ( const TopoDS_Shape& theShape ) +{ + + myContext = new ShapeBuild_ReShape; + Init(theShape); +} +//======================================================================= +//function : Init +//purpose : +//======================================================================= + +void ShHealOper_Tool::Init(const TopoDS_Shape& theShape) +{ + myDone = Standard_False; + myErrorStatus =ShHealOper_NotError; + myInitShape = theShape; + myContext->Apply(myInitShape); +} diff --git a/src/ShHealOper/ShHealOper_Tool.hxx b/src/ShHealOper/ShHealOper_Tool.hxx new file mode 100644 index 000000000..7ec0febed --- /dev/null +++ b/src/ShHealOper/ShHealOper_Tool.hxx @@ -0,0 +1,108 @@ +// File: ShHealOper_Tool.hxx +// Created: 26.04.04 11:36:04 +// Author: Galina KULIKOVA +// < MODULE = KERNEL> : +// Copyright (C) 2003 CEA +// +// 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 +// + + +#ifndef ShHealOper_Tool_HeaderFile +#define ShHealOper_Tool_HeaderFile + +#include +#include +#include + +/// Class ShHealOper_Tool +// +//enumeration for definition of the status of the error if operation failed +enum ShHealOper_Error { + ShHealOper_NotError, + ShHealOper_InvalidParameters, + ShHealOper_ErrorExecution +}; + +class ShHealOper_Tool +{ + public: + // ---------- PUBLIC METHODS ---------- + + /// Empty constructor + Standard_EXPORT ShHealOper_Tool () ; + + Standard_EXPORT ShHealOper_Tool (const TopoDS_Shape& theShape); + // Constructor initialized by shape from which faces will be removed. + + Standard_EXPORT virtual void Init(const TopoDS_Shape& theShape); + //Method for initalization by whole shape. + + inline const TopoDS_Shape& GetResultShape() const + { + return myResultShape; + + } + //Returns result shape. + + inline Standard_Boolean GetModifiedShape(const TopoDS_Shape& theOldShape, + TopoDS_Shape& theNewShape) const + { + theNewShape = myContext->Apply(theOldShape); + return (!theNewShape.IsSame(theOldShape)); + } + //Returns modified shape obtained after operation from initial shape. + + inline Standard_Boolean IsDone() const + { + return myDone; + } + //Returns status of the operation. + + inline void SetContext(Handle(ShapeBuild_ReShape)& theContext) + { + myContext = theContext; + } + //Initialization by context keeping modification of sub-shapes. + + inline Handle(ShapeBuild_ReShape) Context() + { + return myContext; + } + //Returns context keeping modification of sub-shapes + + inline Standard_Integer GetErrorStatus() + { + return myErrorStatus; + } + protected: + // ---------- PROTECTED FIELDS ---------- + + Handle(ShapeBuild_ReShape) myContext; + TopoDS_Shape myInitShape; + TopoDS_Shape myResultShape; + Standard_Boolean myDone; + ShHealOper_Error myErrorStatus; + public: +// Declaration of CASCADE RTTI +//DEFINE_STANDARD_RTTI (ShHealOper_Tool) +}; + +// Definition of HANDLE object using Standard_DefineHandle.hxx +//DEFINE_STANDARD_HANDLE (ShHealOper_Tool, ) + + +#endif diff --git a/src/TransformationGUI/Makefile.in b/src/TransformationGUI/Makefile.in index bf544b577..c68291361 100644 --- a/src/TransformationGUI/Makefile.in +++ b/src/TransformationGUI/Makefile.in @@ -46,18 +46,21 @@ LIB_SRC = TransformationGUI.cxx \ TransformationGUI_TranslationDlg.cxx \ TransformationGUI_RotationDlg.cxx \ TransformationGUI_MirrorDlg.cxx \ - TransformationGUI_ScaleDlg.cxx + TransformationGUI_ScaleDlg.cxx \ + TransformationGUI_OffsetDlg.cxx \ + TransformationGUI_PositionDlg.cxx LIB_MOC = \ - TransformationGUI.h \ TransformationGUI_MultiTranslationDlg.h \ TransformationGUI_MultiRotationDlg.h \ TransformationGUI_TranslationDlg.h \ TransformationGUI_RotationDlg.h \ TransformationGUI_MirrorDlg.h \ - TransformationGUI_ScaleDlg.h + TransformationGUI_ScaleDlg.h \ + TransformationGUI_OffsetDlg.h \ + TransformationGUI_PositionDlg.h -LIB_CLIENT_IDL = +LIB_CLIENT_IDL = SALOME_GenericObj.idl SALOME_Component.idl LIB_SERVER_IDL = diff --git a/src/TransformationGUI/TransformationGUI.cxx b/src/TransformationGUI/TransformationGUI.cxx index 54ea7d019..38e863d13 100644 --- a/src/TransformationGUI/TransformationGUI.cxx +++ b/src/TransformationGUI/TransformationGUI.cxx @@ -24,10 +24,11 @@ // File : TransformationGUI.cxx // Author : Damien COQUERET // Module : GEOM -// $Header: +// $Header$ using namespace std; #include "TransformationGUI.h" +#include "QAD_Desktop.h" #include "SALOMEGUI_QtCatchCorbaException.hxx" @@ -37,17 +38,30 @@ using namespace std; #include "TransformationGUI_RotationDlg.h" // Method ROTATION #include "TransformationGUI_MirrorDlg.h" // Method MIRROR #include "TransformationGUI_ScaleDlg.h" // Method SCALE +#include "TransformationGUI_OffsetDlg.h" // Method OFFSET +#include "TransformationGUI_PositionDlg.h" // Method POSITION + +TransformationGUI* TransformationGUI::myGUIObject = 0; + +//======================================================================= +// function : GetTransformationGUI() +// purpose : Get the only TransformationGUI object [ static ] +//======================================================================= +TransformationGUI* TransformationGUI::GetTransformationGUI() +{ + if ( myGUIObject == 0 ) { + // init TransformationGUI only once + myGUIObject = new TransformationGUI(); + } + return myGUIObject; +} //======================================================================= // function : TransformationGUI() // purpose : Constructor //======================================================================= -TransformationGUI::TransformationGUI() : - QObject() +TransformationGUI::TransformationGUI() : GEOMGUI() { - myGeomBase = new GEOMBase(); - myGeomGUI = GEOMContext::GetGeomGUI(); - myGeom = myGeomGUI->myComponentGeom; } @@ -66,40 +80,50 @@ TransformationGUI::~TransformationGUI() //======================================================================= bool TransformationGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) { - TransformationGUI* myTransformationGUI = new TransformationGUI(); - myTransformationGUI->myGeomGUI->EmitSignalDeactivateDialog(); + GeometryGUI::GetGeomGUI()->EmitSignalDeactivateDialog(); SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection()); + QDialog* aDlg = NULL; switch (theCommandID) { case 5021: // TRANSLATION { - TransformationGUI_TranslationDlg *aDlg = new TransformationGUI_TranslationDlg(parent, "", myTransformationGUI, Sel); + aDlg = new TransformationGUI_TranslationDlg(parent, "", Sel); break; } case 5022: // ROTATION { - TransformationGUI_RotationDlg *aDlg = new TransformationGUI_RotationDlg(parent, "", myTransformationGUI, Sel); + aDlg = new TransformationGUI_RotationDlg(parent, "", Sel); + break; + } + case 5023: // POSITION + { + aDlg = new TransformationGUI_PositionDlg(parent, "", Sel); break; } - case 5023: // MIRROR + case 5024: // MIRROR { - TransformationGUI_MirrorDlg *aDlg = new TransformationGUI_MirrorDlg(parent, "", myTransformationGUI, Sel); + aDlg = new TransformationGUI_MirrorDlg(parent, "", Sel); break; } - case 5024: // SCALE + case 5025: // SCALE { - TransformationGUI_ScaleDlg *aDlg = new TransformationGUI_ScaleDlg(parent, "", myTransformationGUI, Sel ); + aDlg = new TransformationGUI_ScaleDlg(parent, "", Sel ); break; } - case 5025: // MULTI TRANSLATION + case 5026: // OFFSET + { + aDlg = new TransformationGUI_OffsetDlg(parent, "", Sel ); + break; + } + case 5027: // MULTI TRANSLATION { - TransformationGUI_MultiTranslationDlg *aDlg = new TransformationGUI_MultiTranslationDlg(parent, "", myTransformationGUI, Sel); + aDlg = new TransformationGUI_MultiTranslationDlg(parent, "", Sel); break; } - case 5026: // MULTI ROTATION + case 5028: // MULTI ROTATION { - TransformationGUI_MultiRotationDlg *aDlg = new TransformationGUI_MultiRotationDlg(parent, "", myTransformationGUI, Sel); + aDlg = new TransformationGUI_MultiRotationDlg(parent, "", Sel); break; } default: @@ -108,218 +132,11 @@ bool TransformationGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) break; } } - return true; -} + if ( aDlg != NULL ) + aDlg->show(); -//================================================================================= -// function : MakeTranslationAndDisplay() -// purpose : Translate a shape -//================================================================================= -void TransformationGUI::MakeTranslationAndDisplay(GEOM::GEOM_Shape_ptr Shape, gp_Vec V) -{ - try { - GEOM::GEOM_Shape_var result = myGeom->MakeTranslation(Shape, V.X(), V.Y(), V.Z()); - if(result->_is_nil()) { - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_ABORT")); - return; - } - result->NameType(Shape->NameType()); - if(myGeomBase->Display(result)) - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); - } - catch(const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return; -} - - -//======================================================================================= -// function : MakeRotationAndDisplay() -// purpose : -//======================================================================================= -void TransformationGUI::MakeRotationAndDisplay(GEOM::GEOM_Shape_ptr Shape, const gp_Pnt loc, - const gp_Dir dir, const Standard_Real angle) -{ - try { - const GEOM::AxisStruct axis = myGeom->MakeAxisStruct(loc.X(), loc.Y(), loc.Z(), - dir.X(), dir.Y(), dir.Z()); - GEOM::GEOM_Shape_var result = myGeom->MakeRotation(Shape, axis, angle); - if(result->_is_nil()) { - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_ABORT")); - return ; - } - result->NameType(Shape->NameType()); - if(myGeomBase->Display(result)) - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); - } - catch(const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return; -} - - -//===================================================================================== -// function : MakeMirrorAndDisplay() -// purpose : -//===================================================================================== -void TransformationGUI::MakeMirrorAndDisplay(GEOM::GEOM_Shape_ptr Shape1, GEOM::GEOM_Shape_ptr Shape2) -{ - try { - GEOM::GEOM_Shape_var result = myGeom->MakeMirrorByPlane(Shape1, Shape2); - if(result->_is_nil()) { - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_NULLSHAPE")); - return; - } - result->NameType(Shape1->NameType()); - if(myGeomBase->Display(result)) - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); - } - catch(const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return; -} - - -//===================================================================================== -// function : MakeScaleAndDisplay() -// purpose : -//===================================================================================== -void TransformationGUI::MakeScaleAndDisplay(GEOM::GEOM_Shape_ptr Shape, const gp_Pnt centralPoint, - const Standard_Real factor) -{ - try { - GEOM::PointStruct P = myGeom->MakePointStruct(centralPoint.X(), centralPoint.Y(), centralPoint.Z()); - GEOM::GEOM_Shape_var result = myGeom->MakeScaleTransform(Shape, P, factor); - result->NameType(Shape->NameType()); - if(myGeomBase->Display(result)) - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); - else - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_NULLSHAPE")); - } - catch(const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return; -} - - -//================================================================================= -// function : MakeMultiTranslation1DAndDisplay() -// purpose : Multi-Translate a shape -//================================================================================= -void TransformationGUI::MakeMultiTranslation1DAndDisplay(GEOM::GEOM_Shape_ptr Shape, const gp_Dir Dir, - const double Step, const short NbTimes) -{ - try { - GEOM::PointStruct d = myGeom->MakePointStruct(Dir.X(), Dir.Y(), Dir.Z()); - GEOM::DirStruct dstruct = myGeom->MakeDirection(d); - - GEOM::GEOM_Shape_var result = myGeom->MakeMultiTranslation1D(Shape, dstruct, Step, NbTimes); - if(result->_is_nil()) { - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_ABORT")); - return; - } - result->NameType(tr("GEOM_COMPOUND")); - if(myGeomBase->Display(result)) - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); - } - catch(const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return; -} - - -//================================================================================= -// function : MakeMultiTranslation2DAndDisplay() -// purpose : Multi-Translate a shape -//================================================================================= -void TransformationGUI::MakeMultiTranslation2DAndDisplay(GEOM::GEOM_Shape_ptr Shape, - const gp_Dir Dir1,const double Step1, const short NbTimes1, - const gp_Dir Dir2, const double Step2, const short NbTimes2) -{ - try { - GEOM::PointStruct d1 = myGeom->MakePointStruct(Dir1.X(), Dir1.Y(), Dir1.Z()); - GEOM::DirStruct dstruct1 = myGeom->MakeDirection(d1); - GEOM::PointStruct d2 = myGeom->MakePointStruct(Dir2.X(), Dir2.Y(), Dir2.Z()); - GEOM::DirStruct dstruct2 = myGeom->MakeDirection(d2); - - GEOM::GEOM_Shape_var result = myGeom->MakeMultiTranslation2D(Shape, dstruct1, Step1, NbTimes1, - dstruct2, Step2, NbTimes2); - if(result->_is_nil()) { - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_ABORT")); - return; - } - result->NameType(tr("GEOM_COMPOUND")); - if(myGeomBase->Display(result)) - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); - } - catch(const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return; -} - - -//================================================================================= -// function : MakeMultiRotation1DAndDisplay() -// purpose : Multi-Rotate a shape -//================================================================================= -void TransformationGUI::MakeMultiRotation1DAndDisplay(GEOM::GEOM_Shape_ptr Shape, const gp_Dir Dir, - const gp_Pnt Loc, const short NbTimes) -{ - try { - GEOM::PointStruct d = myGeom->MakePointStruct(Dir.X(), Dir.Y(), Dir.Z()); - GEOM::DirStruct dstruct = myGeom->MakeDirection(d) ; - GEOM::PointStruct pstruct = myGeom->MakePointStruct(Loc.X(), Loc.Y(), Loc.Z()); - - GEOM::GEOM_Shape_var result = myGeom->MakeMultiRotation1D(Shape, dstruct, pstruct, NbTimes); - if(result->_is_nil()) { - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_ABORT")); - return; - } - result->NameType(tr("GEOM_COMPOUND")); - if(myGeomBase->Display(result)) - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); - } - catch(const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return; -} - - -//================================================================================= -// function : MakeMultiRotation2DAndDisplay() -// purpose : Multi-Rotate a shape -//================================================================================= -void TransformationGUI::MakeMultiRotation2DAndDisplay(GEOM::GEOM_Shape_ptr Shape, const gp_Dir Dir, - const gp_Pnt Loc, const double Ang, const short NbTimes1, - const double Step, const short NbTimes2) -{ - try { - GEOM::PointStruct d = myGeom->MakePointStruct(Dir.X(), Dir.Y(), Dir.Z()); - GEOM::DirStruct dstruct = myGeom->MakeDirection(d); - GEOM::PointStruct pstruct = myGeom->MakePointStruct(Loc.X(), Loc.Y(), Loc.Z()); - - GEOM::GEOM_Shape_var result = myGeom->MakeMultiRotation2D(Shape, dstruct, pstruct, - Ang, NbTimes1, Step, NbTimes2); - if(result->_is_nil()) { - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_ABORT")); - return; - } - result->NameType(tr("GEOM_COMPOUND")); - if(myGeomBase->Display(result)) - QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE")); - } - catch(const SALOME::SALOME_Exception& S_ex) { - QtCatchCorbaException(S_ex); - } - return; + return true; } @@ -328,6 +145,8 @@ void TransformationGUI::MakeMultiRotation2DAndDisplay(GEOM::GEOM_Shape_ptr Shape //===================================================================================== extern "C" { - bool OnGUIEvent(int theCommandID, QAD_Desktop* parent) - {return TransformationGUI::OnGUIEvent(theCommandID, parent);} + GEOMGUI* GetLibGUI() + { + return TransformationGUI::GetTransformationGUI(); + } } diff --git a/src/TransformationGUI/TransformationGUI.h b/src/TransformationGUI/TransformationGUI.h index f8451c60e..65a4bd999 100644 --- a/src/TransformationGUI/TransformationGUI.h +++ b/src/TransformationGUI/TransformationGUI.h @@ -24,49 +24,33 @@ // File : TransformationGUI.h // Author : Damien COQUERET // Module : GEOM -// $Header: +// $Header$ #ifndef TRANSFORMATIONGUI_H #define TRANSFORMATIONGUI_H -#include "GEOMBase.h" -#include +#include "GEOMGUI.h" + //================================================================================= // class : TransformationGUI // purpose : //================================================================================= -class TransformationGUI : public QObject +class TransformationGUI : public GEOMGUI { - Q_OBJECT /* for QT compatibility */ +protected: + TransformationGUI(); // hide constructor to avoid direct creation public : - TransformationGUI(); ~TransformationGUI(); - static bool OnGUIEvent(int theCommandID, QAD_Desktop* parent); - - void MakeTranslationAndDisplay(GEOM::GEOM_Shape_ptr Shape, const gp_Vec V); - void MakeRotationAndDisplay(GEOM::GEOM_Shape_ptr Shape, const gp_Pnt loc, - const gp_Dir dir, const Standard_Real angle); - void MakeMirrorAndDisplay(GEOM::GEOM_Shape_ptr Shape1, GEOM::GEOM_Shape_ptr Shape2); - void MakeScaleAndDisplay(GEOM::GEOM_Shape_ptr Shape, const gp_Pnt centralPoint, - const Standard_Real factor); - void MakeMultiTranslation1DAndDisplay(GEOM::GEOM_Shape_ptr Shape, - const gp_Dir Dir, const double Step, const short NbTimes); - void MakeMultiTranslation2DAndDisplay(GEOM::GEOM_Shape_ptr Shape, - const gp_Dir Dir1, const double Step1, const short NbTimes1, - const gp_Dir Dir2, const double Step2, const short NbTimes2); - void MakeMultiRotation1DAndDisplay(GEOM::GEOM_Shape_ptr Shape, - const gp_Dir Dir, const gp_Pnt Loc, const short NbTimes); - void MakeMultiRotation2DAndDisplay(GEOM::GEOM_Shape_ptr Shape, - const gp_Dir Dir, const gp_Pnt Loc, const double Ang, - const short NbTimes1, const double Step, const short NbTimes2); + // Get the only TransformationGUI object + static TransformationGUI* GetTransformationGUI(); - GEOMBase* myGeomBase; - GEOMContext* myGeomGUI; - GEOM::GEOM_Gen_var myGeom; /* Current Geom Component */ + bool OnGUIEvent(int theCommandID, QAD_Desktop* parent); +private: + static TransformationGUI* myGUIObject; // the only TransformationGUI object }; #endif diff --git a/src/TransformationGUI/TransformationGUI_MirrorDlg.cxx b/src/TransformationGUI/TransformationGUI_MirrorDlg.cxx index 5b9d8126f..b56df85cb 100644 --- a/src/TransformationGUI/TransformationGUI_MirrorDlg.cxx +++ b/src/TransformationGUI/TransformationGUI_MirrorDlg.cxx @@ -28,9 +28,11 @@ #include "TransformationGUI_MirrorDlg.h" -#include -#include -#include +#include "QAD_Desktop.h" + +#include + +#include "GEOMImpl_Types.hxx" #include "utilities.h" @@ -43,32 +45,37 @@ using namespace std; // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -TransformationGUI_MirrorDlg::TransformationGUI_MirrorDlg(QWidget* parent, const char* name, TransformationGUI* theTransformationGUI, SALOME_Selection* Sel, bool modal, WFlags fl) +TransformationGUI_MirrorDlg::TransformationGUI_MirrorDlg(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_MIRROR"))); - QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_MIRROR_POINT"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_MIRROR_AXE"))); + QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_MIRROR_PLANE"))); + QPixmap image3(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); setCaption(tr("GEOM_MIRROR_TITLE")); /***************************************************************/ GroupConstructors->setTitle(tr("GEOM_MIRROR")); RadioButton1->setPixmap(image0); - RadioButton2->close(TRUE); - RadioButton3->close(TRUE); - - GroupPoints = new DlgRef_2Sel_QTD(this, "GroupPoints"); + RadioButton2->setPixmap(image1); + RadioButton3->setPixmap(image2); + + GroupPoints = new DlgRef_2Sel1Spin2Check(this, "GroupPoints"); + GroupPoints->SpinBox_DX->hide(); + GroupPoints->TextLabel3->hide(); + GroupPoints->CheckButton2->hide(); GroupPoints->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); - GroupPoints->TextLabel1->setText(tr("GEOM_OBJECT")); - GroupPoints->TextLabel2->setText(tr("GEOM_PLANE_MIRROR")); - GroupPoints->PushButton1->setPixmap(image1); - GroupPoints->PushButton2->setPixmap(image1); - - Layout1->addWidget(GroupPoints, 1, 0); + GroupPoints->TextLabel1->setText(tr("GEOM_OBJECTS")); + GroupPoints->TextLabel2->setText(tr("GEOM_POINT_MIRROR")); + GroupPoints->TextLabel2->setFixedWidth(74); + GroupPoints->PushButton1->setPixmap(image3); + GroupPoints->PushButton2->setPixmap(image3); + GroupPoints->CheckButton1->setText(tr("GEOM_CREATE_COPY")); + Layout1->addWidget(GroupPoints, 2, 0); + /***************************************************************/ - - /* Initialisations */ - myTransformationGUI = theTransformationGUI; + Init(); } @@ -91,59 +98,105 @@ void TransformationGUI_MirrorDlg::Init() { /* init variables */ myEditCurrentArgument = GroupPoints->LineEdit1; - - myOkShape1 = myOkShape2 = false; - - /* Vertices Filter for all arguments */ - myFaceFilter = new GEOM_FaceFilter(StdSelect_Plane, myGeom); + GroupPoints->LineEdit1->setReadOnly(true); + GroupPoints->LineEdit2->setReadOnly(true); + + myArgument = GEOM::GEOM_Object::_nil(); + + // Activate Create a Copy mode + GroupPoints->CheckButton1->setChecked(true); + CreateCopyModeChanged(true); /* signals and slots connections */ connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + connect(GroupConstructors, SIGNAL(clicked(int)), SLOT(ConstructorsClicked(int))); connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - + + connect(GroupPoints->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(CreateCopyModeChanged(bool))); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - /* displays Dialog */ - GroupPoints->show(); - this->show(); + initName( tr( "GEOM_MIRROR" ) ); + ConstructorsClicked( 0 ); +} + + - return; +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void TransformationGUI_MirrorDlg::ConstructorsClicked(int constructorId) +{ + disconnect( mySelection, 0, this, 0 ); + + globalSelection(); + myEditCurrentArgument = GroupPoints->LineEdit1; + GroupPoints->LineEdit2->clear(); + myArgument = GEOM::GEOM_Object::_nil(); + + switch (constructorId) + { + case 0: /* mirror an object by point */ + { + GroupPoints->TextLabel2->setText(tr("GEOM_POINT_MIRROR")); + break; + } + case 1: /* mirror an object by axe */ + { + GroupPoints->TextLabel2->setText(tr("GEOM_AXE_MIRROR")); + break; + } + case 2: /* mirror an object by plane */ + { + GroupPoints->TextLabel2->setText(tr("GEOM_PLANE_MIRROR")); + break; + } + } + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); } + //================================================================================= // function : ClickOnOk() // purpose : //================================================================================= void TransformationGUI_MirrorDlg::ClickOnOk() { - this->ClickOnApply(); - ClickOnCancel(); - return; + if ( ClickOnApply() ) + ClickOnCancel(); } + //================================================================================= // function : ClickOnApply() // purpose : //================================================================================= -void TransformationGUI_MirrorDlg::ClickOnApply() +bool TransformationGUI_MirrorDlg::ClickOnApply() +{ + if ( !onAccept(GroupPoints->CheckButton1->isChecked()) ) + return false; + + initName(); + ConstructorsClicked( getConstructorId() ); + return true; +} + + +//======================================================================= +// function : ClickOnCancel() +// purpose : +//======================================================================= +void TransformationGUI_MirrorDlg::ClickOnCancel() { - buttonApply->setFocus(); - QAD_Application::getDesktop()->putInfo(tr("")); - if (mySimulationTopoDs.IsNull()) - return; - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); - - if(myOkShape1 && myOkShape2) - myTransformationGUI->MakeMirrorAndDisplay(myGeomShape1, myGeomShape2); - return; + GEOMBase_Skeleton::ClickOnCancel(); } @@ -153,47 +206,55 @@ void TransformationGUI_MirrorDlg::ClickOnApply() //================================================================================= void TransformationGUI_MirrorDlg::SelectionIntoArgument() { - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); myEditCurrentArgument->setText(""); - QString aString = ""; /* name of selection */ - - int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString); - if(nbSel != 1) { - if(myEditCurrentArgument == GroupPoints->LineEdit1) - myOkShape1 = false; - else if(myEditCurrentArgument == GroupPoints->LineEdit2) - myOkShape2 = false; - return; - } + QString aName; + + if(myEditCurrentArgument == GroupPoints->LineEdit1) + { + int aNbSel = GEOMBase::GetNameOfSelectedIObjects(mySelection, aName); + if(aNbSel < 1) + { + myObjects.length(0); + return; + } + GEOMBase::ConvertListOfIOInListOfGO(mySelection->StoredIObjects(), myObjects); + if (!myObjects.length()) + return; + if(aNbSel != 1) + aName = tr("%1_objects").arg(aNbSel); + } + else if(myEditCurrentArgument == GroupPoints->LineEdit2) + { + if(mySelection->IObjectCount() != 1) + { + myArgument = GEOM::GEOM_Object::_nil(); + return; + } + Standard_Boolean testResult = Standard_False; + myArgument = GEOMBase::ConvertIOinGEOMObject(mySelection->firstIObject(), testResult ); + if(!testResult || CORBA::is_nil( myArgument )) + return; + aName = GEOMBase::GetName( myArgument ); + } + myEditCurrentArgument->setText( aName ); + + displayPreview(); +} - // nbSel == 1 - TopoDS_Shape S; - Standard_Boolean testResult; - Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); - if(!myGeomBase->GetTopoFromSelection(mySelection, S)) - return; - - if(myEditCurrentArgument == GroupPoints->LineEdit1) { - myGeomShape1 = myGeomBase->ConvertIOinGEOMShape(IO, testResult); - if(!testResult) - return; - myShape1 = S; - myEditCurrentArgument->setText(aString); - myOkShape1 = true; - } - else if(myEditCurrentArgument == GroupPoints->LineEdit2) { - myGeomShape2 = myGeomBase->ConvertIOinGEOMShape(IO, testResult); - if(!testResult) - return ; - myShape2 = S; - myEditCurrentArgument->setText(aString); - myOkShape2 = true; - } - if(myOkShape1 && myOkShape2) - MakeMirrorSimulationAndDisplay(); - return; +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void TransformationGUI_MirrorDlg::LineEditReturnPressed() +{ + QLineEdit* send = (QLineEdit*)sender(); + if(send == GroupPoints->LineEdit1 || + send == GroupPoints->LineEdit2) + { + myEditCurrentArgument = send; + GEOMBase_Skeleton::LineEditReturnPressed(); + } } @@ -204,39 +265,57 @@ void TransformationGUI_MirrorDlg::SelectionIntoArgument() void TransformationGUI_MirrorDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); - mySelection->ClearFilters(); - - if(send == GroupPoints->PushButton1) { - GroupPoints->LineEdit1->setFocus(); + + if(send == GroupPoints->PushButton1){ myEditCurrentArgument = GroupPoints->LineEdit1; + globalSelection(); } else if(send == GroupPoints->PushButton2) { - GroupPoints->LineEdit2->setFocus(); myEditCurrentArgument = GroupPoints->LineEdit2; - mySelection->AddFilter(myFaceFilter); + switch(getConstructorId()) + { + case 0: + { + globalSelection( GEOM_POINT ); + break; + } + case 1: + { + globalSelection( GEOM_LINE ); + break; + } + case 2: + { + globalSelection( GEOM_PLANE ); + break; + } + } } - this->SelectionIntoArgument(); - return; + myEditCurrentArgument->setFocus(); + SelectionIntoArgument(); } //================================================================================= -// function : LineEditReturnPressed() +// function : ActivateThisDialog() // purpose : //================================================================================= -void TransformationGUI_MirrorDlg::LineEditReturnPressed() +void TransformationGUI_MirrorDlg::ActivateThisDialog() { - QLineEdit* send = (QLineEdit*)sender(); - if(send == GroupPoints->LineEdit1) - myEditCurrentArgument = GroupPoints->LineEdit1; - else if(send == GroupPoints->LineEdit2) - myEditCurrentArgument = GroupPoints->LineEdit2; - else - return; + GEOMBase_Skeleton::ActivateThisDialog(); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + ConstructorsClicked( getConstructorId() ); +} + - GEOMBase_Skeleton::LineEditReturnPressed(); - return; +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : public slot to deactivate if active +//================================================================================= +void TransformationGUI_MirrorDlg::DeactivateActiveDialog() +{ + GEOMBase_Skeleton::DeactivateActiveDialog(); } @@ -246,60 +325,121 @@ void TransformationGUI_MirrorDlg::LineEditReturnPressed() //================================================================================= void TransformationGUI_MirrorDlg::enterEvent(QEvent * e) { - if(GroupConstructors->isEnabled()) - return; - this->ActivateThisDialog(); - return; + if(!GroupConstructors->isEnabled()) + ActivateThisDialog(); } //================================================================================= -// function : ActivateThisDialog() +// function : createOperation // purpose : //================================================================================= -void TransformationGUI_MirrorDlg::ActivateThisDialog() +GEOM::GEOM_IOperations_ptr TransformationGUI_MirrorDlg::createOperation() { - GEOMBase_Skeleton::ActivateThisDialog(); - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - GroupPoints->LineEdit1->setFocus(); - myEditCurrentArgument = GroupPoints->LineEdit1; - if(!mySimulationTopoDs.IsNull()) - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - return; + return getGeomEngine()->GetITransformOperations( getStudyId() ); +} + + +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool TransformationGUI_MirrorDlg::isValid( QString& msg ) +{ + return !(myObjects.length() == 0 || myArgument->_is_nil()); } //================================================================================= -// function : MakeMirrorSimulationAndDisplay() -// purpose : S1 is a shape and S2 a mirror. +// function : execute +// purpose : //================================================================================= -void TransformationGUI_MirrorDlg::MakeMirrorSimulationAndDisplay() +bool TransformationGUI_MirrorDlg::execute( ObjectList& objects ) { - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); + bool res = false; + bool toCreateCopy = IsPreview() || GroupPoints->CheckButton1->isChecked(); - try { - Handle(Geom_Surface) surf = BRep_Tool::Surface(TopoDS::Face(myShape2)); - Handle(Geom_Plane) myPlane = Handle(Geom_Plane)::DownCast(surf); - const gp_Ax3 pos = myPlane->Position(); - const gp_Pnt loc = pos.Location(); /* location of the plane */ - const gp_Dir dir = pos.Direction(); /* Main direction of the plane (Z axis) */ - - /* plane used for mirroring */ - gp_Ax2 pln(loc, dir); - gp_Trsf theTransformation; - theTransformation.SetMirror(pln); - BRepBuilderAPI_Transform myBRepTransformation(myShape1, theTransformation, Standard_False); - - this->mySimulationTopoDs = myBRepTransformation.Shape(); - if(mySimulationTopoDs.IsNull()) - return; - else - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - } - catch(Standard_Failure) { - MESSAGE("Exception catched in MakeMirrorSimulationAndDisplay"); - return; - } - return; + GEOM::GEOM_Object_var anObj; + + switch ( getConstructorId() ) + { + case 0 : + { + if (toCreateCopy) + for (int i = 0; i < myObjects.length(); i++) + { + anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->MirrorPointCopy( myObjects[i], myArgument ); + if ( !anObj->_is_nil() ) + objects.push_back( anObj._retn() ); + } + else + for (int i = 0; i < myObjects.length(); i++) + { + anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->MirrorPoint( myObjects[i], myArgument ); + if ( !anObj->_is_nil() ) + objects.push_back( anObj._retn() ); + } + res = true; + break; + } + case 1 : + { + if (toCreateCopy) + for (int i = 0; i < myObjects.length(); i++) + { + anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->MirrorAxisCopy( myObjects[i], myArgument ); + if ( !anObj->_is_nil() ) + objects.push_back( anObj._retn() ); + } + else + for (int i = 0; i < myObjects.length(); i++) + { + anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->MirrorAxis( myObjects[i], myArgument ); + if ( !anObj->_is_nil() ) + objects.push_back( anObj._retn() ); + } + res = true; + break; + } + case 2: + { + if (toCreateCopy) + for (int i = 0; i < myObjects.length(); i++) + { + anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->MirrorPlaneCopy( myObjects[i], myArgument ); + if ( !anObj->_is_nil() ) + objects.push_back( anObj._retn() ); + } + else + for (int i = 0; i < myObjects.length(); i++) + { + anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->MirrorPlane( myObjects[i], myArgument ); + if ( !anObj->_is_nil() ) + objects.push_back( anObj._retn() ); + } + res = true; + break; + } + } + + return res; +} + +//================================================================================= +// function : closeEvent +// purpose : +//================================================================================= +void TransformationGUI_MirrorDlg::closeEvent( QCloseEvent* e ) +{ + GEOMBase_Skeleton::closeEvent( e ); +} + + +//================================================================================= +// function : CreateCopyModeChanged() +// purpose : +//================================================================================= +void TransformationGUI_MirrorDlg::CreateCopyModeChanged(bool isCreateCopy) +{ + this->GroupBoxName->setEnabled(isCreateCopy); } diff --git a/src/TransformationGUI/TransformationGUI_MirrorDlg.h b/src/TransformationGUI/TransformationGUI_MirrorDlg.h index 71c118981..4b2bea586 100644 --- a/src/TransformationGUI/TransformationGUI_MirrorDlg.h +++ b/src/TransformationGUI/TransformationGUI_MirrorDlg.h @@ -30,11 +30,10 @@ #define DIALOGBOX_MIRROR_H #include "GEOMBase_Skeleton.h" -#include "DlgRef_2Sel_QTD.h" +#include "DlgRef_2Sel1Spin2Check.h" #include "TransformationGUI.h" - -#include "GEOM_FaceFilter.hxx" + //================================================================================= // class : TransformationGUI_MirrorDlg @@ -45,35 +44,37 @@ class TransformationGUI_MirrorDlg : public GEOMBase_Skeleton Q_OBJECT public: - TransformationGUI_MirrorDlg(QWidget* parent = 0, const char* name = 0, TransformationGUI* theTransformationGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + TransformationGUI_MirrorDlg(QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); ~TransformationGUI_MirrorDlg(); +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& ); + virtual bool execute( ObjectList& objects ); + + virtual void closeEvent( QCloseEvent* e ); + private : void Init(); void enterEvent(QEvent* e); - void MakeMirrorSimulationAndDisplay(); - - TransformationGUI* myTransformationGUI; - - Handle(GEOM_FaceFilter) myFaceFilter; /* To filter selections */ - - TopoDS_Shape myShape1; /* topology used */ - TopoDS_Shape myShape2; /* topology used */ - GEOM::GEOM_Shape_var myGeomShape1; /* is myShape1 */ - GEOM::GEOM_Shape_var myGeomShape2; /* is myShape2 */ - bool myOkShape1; - bool myOkShape2; /* to check when arguments are defined */ - - DlgRef_2Sel_QTD* GroupPoints; - + + GEOM::GEOM_Object_var myArgument; + GEOM::ListOfGO myObjects; + + DlgRef_2Sel1Spin2Check* GroupPoints; + private slots : void ClickOnOk(); - void ClickOnApply(); + bool ClickOnApply(); + void ClickOnCancel(); void ActivateThisDialog(); + void DeactivateActiveDialog(); void LineEditReturnPressed(); void SelectionIntoArgument(); void SetEditCurrentArgument(); - + void ConstructorsClicked(int constructorId); + void CreateCopyModeChanged(bool isCreateCopy); }; #endif // DIALOGBOX_MIRROR_H diff --git a/src/TransformationGUI/TransformationGUI_MultiRotationDlg.cxx b/src/TransformationGUI/TransformationGUI_MultiRotationDlg.cxx index 2d7b5aae1..441abea0a 100644 --- a/src/TransformationGUI/TransformationGUI_MultiRotationDlg.cxx +++ b/src/TransformationGUI/TransformationGUI_MultiRotationDlg.cxx @@ -21,25 +21,19 @@ // // // -// File : TransformationGUI_MultiTranslationDlg.cxx +// File : TransformationGUI_MultiRotationDlg.cxx // Author : Damien COQUERET // Module : GEOM // $Header$ #include "TransformationGUI_MultiRotationDlg.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "GEOMImpl_Types.hxx" + #include "QAD_Config.h" +#include "QAD_Desktop.h" + +#include #include "utilities.h" @@ -52,7 +46,7 @@ using namespace std; // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -TransformationGUI_MultiRotationDlg::TransformationGUI_MultiRotationDlg(QWidget* parent, const char* name, TransformationGUI* theTransformationGUI, SALOME_Selection* Sel, bool modal, WFlags fl) +TransformationGUI_MultiRotationDlg::TransformationGUI_MultiRotationDlg(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_MULTIROTATION_SIMPLE"))); @@ -74,6 +68,8 @@ TransformationGUI_MultiRotationDlg::TransformationGUI_MultiRotationDlg(QWidget* GroupPoints->TextLabel3->setText(tr("GEOM_NB_TIMES")); GroupPoints->PushButton1->setPixmap(image2); GroupPoints->PushButton2->setPixmap(image2); + GroupPoints->LineEdit1->setReadOnly(true); + GroupPoints->LineEdit2->setReadOnly(true); GroupDimensions = new DlgRef_2Sel4Spin1Check(this, "GroupDimensions"); GroupDimensions->GroupBox1->setTitle(tr("GEOM_MULTIROTATION_DOUBLE")); @@ -86,13 +82,13 @@ TransformationGUI_MultiRotationDlg::TransformationGUI_MultiRotationDlg(QWidget* GroupDimensions->CheckButton1->setText(tr("GEOM_REVERSE")); GroupDimensions->PushButton1->setPixmap(image2); GroupDimensions->PushButton2->setPixmap(image2); + GroupDimensions->LineEdit1->setReadOnly(true); + GroupDimensions->LineEdit2->setReadOnly(true); - Layout1->addWidget(GroupPoints, 1, 0); - Layout1->addWidget(GroupDimensions, 1, 0); + Layout1->addWidget(GroupPoints, 2, 0); + Layout1->addWidget(GroupDimensions, 2, 0); /***************************************************************/ - /* Initialisations */ - myTransformationGUI = theTransformationGUI; Init(); } @@ -113,21 +109,9 @@ TransformationGUI_MultiRotationDlg::~TransformationGUI_MultiRotationDlg() //================================================================================= void TransformationGUI_MultiRotationDlg::Init() { - /* init variables */ - myConstructorId = 0; - myEditCurrentArgument = GroupPoints->LineEdit1; - - myAng = 45.0; - myStep = 50.0; - myNbTimes1 = 2; - myNbTimes2 = 2; - myOkBase = myOkDir = false; - - myEdgeFilter = new GEOM_ShapeTypeFilter(TopAbs_EDGE, myGeom); - /* Get setting of step value from file configuration */ QString St = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep"); - step = St.toDouble(); + double step = St.toDouble(); double SpecificStep1 = 5; double SpecificStep2 = 1; @@ -171,16 +155,12 @@ void TransformationGUI_MultiRotationDlg::Init() connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupDimensions->SpinBox_DX2, SLOT(SetStep(double))); connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupDimensions->SpinBox_DY2, SLOT(SetStep(double))); - connect(GroupDimensions->CheckButton1, SIGNAL(stateChanged(int)), this, SLOT(ReverseAngle(int))); + connect(GroupDimensions->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(ReverseAngle())); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - /* displays Dialog */ - GroupDimensions->hide(); - GroupPoints->show(); - this->show(); - - return; + initName( tr( "GEOM_MULTIROTATION" ) ); + ConstructorsClicked( 0 ); } @@ -190,16 +170,13 @@ void TransformationGUI_MultiRotationDlg::Init() //================================================================================= void TransformationGUI_MultiRotationDlg::ConstructorsClicked(int constructorId) { - myConstructorId = constructorId; - mySelection->ClearFilters(); - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); disconnect(mySelection, 0, this, 0); + myAng = 45.0; myStep = 50.0; - myNbTimes1 = 2; - myNbTimes2 = 2; - myOkBase = myOkDir = false; + myNbTimes1 = myNbTimes2 = 2; + + globalSelection( GEOM_ALLSHAPES ); switch (constructorId) { @@ -215,8 +192,6 @@ void TransformationGUI_MultiRotationDlg::ConstructorsClicked(int constructorId) GroupPoints->SpinBox_DX->SetValue(myNbTimes1); - /* filter for next selection */ - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); break; } case 1: /* Rotate double */ @@ -234,12 +209,13 @@ void TransformationGUI_MultiRotationDlg::ConstructorsClicked(int constructorId) GroupDimensions->SpinBox_DX2->SetValue(myStep); GroupDimensions->SpinBox_DY2->SetValue(myNbTimes2); - /* filter for next selection */ - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); break; } } - return; + + myEditCurrentArgument->setFocus(); + myBase = myVector = GEOM::GEOM_Object::_nil(); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); } @@ -249,9 +225,8 @@ void TransformationGUI_MultiRotationDlg::ConstructorsClicked(int constructorId) //================================================================================= void TransformationGUI_MultiRotationDlg::ClickOnOk() { - this->ClickOnApply(); - ClickOnCancel(); - return; + if ( ClickOnApply() ) + ClickOnCancel(); } @@ -259,24 +234,24 @@ void TransformationGUI_MultiRotationDlg::ClickOnOk() // function : ClickOnApply() // purpose : //================================================================================= -void TransformationGUI_MultiRotationDlg::ClickOnApply() +bool TransformationGUI_MultiRotationDlg::ClickOnApply() { - buttonApply->setFocus(); - QAD_Application::getDesktop()->putInfo(tr("")); - if (mySimulationTopoDs.IsNull()) - return; - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); + if ( !onAccept() ) + return false; + + initName(); + ConstructorsClicked( getConstructorId() ); + return true; +} - if(myConstructorId == 0) { - if(myOkBase && myOkDir) - myTransformationGUI->MakeMultiRotation1DAndDisplay(myGeomShape, myDir, myLoc, myNbTimes1); - } - else if(myConstructorId == 1) { - if(myOkBase && myOkDir) - myTransformationGUI->MakeMultiRotation2DAndDisplay(myGeomShape, myDir, myLoc, myAng, myNbTimes1, myStep, myNbTimes2); - } - return; + +//======================================================================= +// function : ClickOnCancel() +// purpose : +//======================================================================= +void TransformationGUI_MultiRotationDlg::ClickOnCancel() +{ + GEOMBase_Skeleton::ClickOnCancel(); } @@ -286,46 +261,32 @@ void TransformationGUI_MultiRotationDlg::ClickOnApply() //================================================================================= void TransformationGUI_MultiRotationDlg::SelectionIntoArgument() { - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); myEditCurrentArgument->setText(""); - QString aString = ""; /* name of selection */ - - int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString); - if(nbSel != 1) { + + if(mySelection->IObjectCount() != 1) { if(myEditCurrentArgument == GroupPoints->LineEdit1 || myEditCurrentArgument == GroupDimensions->LineEdit1) - myOkBase = false; + myBase = GEOM::GEOM_Object::_nil(); else if(myEditCurrentArgument == GroupPoints->LineEdit2 || myEditCurrentArgument == GroupDimensions->LineEdit2) - myOkDir = false; + myVector = GEOM::GEOM_Object::_nil(); return; } - + // nbSel == 1 - TopoDS_Shape S; - Standard_Boolean testResult; - Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); - if(!myGeomBase->GetTopoFromSelection(mySelection, S)) + Standard_Boolean testResult = Standard_False;; + GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(mySelection->firstIObject(), testResult ); + + if ( !testResult || CORBA::is_nil( aSelectedObject ) || !GEOMBase::IsShape( aSelectedObject ) ) return; - if(myEditCurrentArgument == GroupPoints->LineEdit1 || myEditCurrentArgument == GroupDimensions->LineEdit1) { - myGeomShape = myGeomBase->ConvertIOinGEOMShape(IO, testResult); - if(!testResult) - return; - myEditCurrentArgument->setText(aString); - myBase = S; - myOkBase = true; - } - else if(myEditCurrentArgument == GroupPoints->LineEdit2 || myEditCurrentArgument == GroupDimensions->LineEdit2) { - BRepAdaptor_Curve curv(TopoDS::Edge(S)); - myDir = curv.Line().Direction(); - myLoc = curv.Line().Location(); - myEditCurrentArgument->setText(aString); - myOkDir = true; - } - if(myOkBase && myOkDir) - this->MakeMultiRotationSimulationAndDisplay(); - return; + if(myEditCurrentArgument == GroupPoints->LineEdit1 || myEditCurrentArgument == GroupDimensions->LineEdit1) + myBase = aSelectedObject; + else if(myEditCurrentArgument == GroupPoints->LineEdit2 || myEditCurrentArgument == GroupDimensions->LineEdit2) + myVector = aSelectedObject; + + myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) ); + + displayPreview(); } @@ -336,29 +297,26 @@ void TransformationGUI_MultiRotationDlg::SelectionIntoArgument() void TransformationGUI_MultiRotationDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); - mySelection->ClearFilters(); - + if(send == GroupPoints->PushButton1) { - GroupPoints->LineEdit1->setFocus(); myEditCurrentArgument = GroupPoints->LineEdit1; + globalSelection( GEOM_ALLSHAPES ); } else if(send == GroupPoints->PushButton2) { - GroupPoints->LineEdit2->setFocus(); myEditCurrentArgument = GroupPoints->LineEdit2; - mySelection->AddFilter(myEdgeFilter); + globalSelection( GEOM_LINE ); } else if(send == GroupDimensions->PushButton1) { - GroupDimensions->LineEdit1->setFocus(); myEditCurrentArgument = GroupDimensions->LineEdit1; + globalSelection( GEOM_ALLSHAPES ); } else if(send == GroupDimensions->PushButton2) { - GroupDimensions->LineEdit2->setFocus(); myEditCurrentArgument = GroupDimensions->LineEdit2; - mySelection->AddFilter(myEdgeFilter); + globalSelection( GEOM_LINE ); } - this->SelectionIntoArgument(); - return; + myEditCurrentArgument->setFocus(); + SelectionIntoArgument(); } @@ -369,19 +327,12 @@ void TransformationGUI_MultiRotationDlg::SetEditCurrentArgument() void TransformationGUI_MultiRotationDlg::LineEditReturnPressed() { QLineEdit* send = (QLineEdit*)sender(); - if(send == GroupPoints->LineEdit1) - myEditCurrentArgument = GroupPoints->LineEdit1; - else if (send == GroupPoints->LineEdit2) - myEditCurrentArgument = GroupPoints->LineEdit2; - else if (send == GroupDimensions->LineEdit1) - myEditCurrentArgument = GroupDimensions->LineEdit1; - else if (send == GroupDimensions->LineEdit2) - myEditCurrentArgument = GroupDimensions->LineEdit2; - else - return; - - GEOMBase_Skeleton::LineEditReturnPressed(); - return; + if(send == GroupPoints->LineEdit1 || send == GroupDimensions->LineEdit1 || + send == GroupPoints->LineEdit2 || send == GroupDimensions->LineEdit2) + { + myEditCurrentArgument = send; + GEOMBase_Skeleton::LineEditReturnPressed(); + } } @@ -393,19 +344,18 @@ void TransformationGUI_MultiRotationDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + + ConstructorsClicked( getConstructorId() ); +} - if(myConstructorId == 0) { - GroupPoints->LineEdit1->setFocus(); - myEditCurrentArgument = GroupPoints->LineEdit1; - } - else if(myConstructorId == 1) { - GroupDimensions->LineEdit1->setFocus(); - myEditCurrentArgument = GroupDimensions->LineEdit1; - } - if(!mySimulationTopoDs.IsNull()) - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - return; +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : public slot to deactivate if active +//================================================================================= +void TransformationGUI_MultiRotationDlg::DeactivateActiveDialog() +{ + GEOMBase_Skeleton::DeactivateActiveDialog(); } @@ -415,10 +365,8 @@ void TransformationGUI_MultiRotationDlg::ActivateThisDialog() //================================================================================= void TransformationGUI_MultiRotationDlg::enterEvent(QEvent* e) { - if (GroupConstructors->isEnabled()) - return; - this->ActivateThisDialog(); - return; + if(!GroupConstructors->isEnabled()) + ActivateThisDialog(); } @@ -428,8 +376,6 @@ void TransformationGUI_MultiRotationDlg::enterEvent(QEvent* e) //================================================================================= void TransformationGUI_MultiRotationDlg::ValueChangedInSpinBox(double newValue) { - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); QObject* send = (QObject*)sender(); if(send == GroupPoints->SpinBox_DX || send == GroupDimensions->SpinBox_DY1) @@ -440,10 +386,8 @@ void TransformationGUI_MultiRotationDlg::ValueChangedInSpinBox(double newValue) myStep = newValue; else if(send == GroupDimensions->SpinBox_DY2) myNbTimes2 = (int)newValue; - - if(myOkBase && myOkDir) - this->MakeMultiRotationSimulationAndDisplay(); - return; + + displayPreview(); } @@ -451,108 +395,84 @@ void TransformationGUI_MultiRotationDlg::ValueChangedInSpinBox(double newValue) // function : ReverseAngle() // purpose : 'state' not used here //================================================================================= -void TransformationGUI_MultiRotationDlg::ReverseAngle(int state) +void TransformationGUI_MultiRotationDlg::ReverseAngle() { myAng = -myAng; - if(myConstructorId == 0) + + int aConstructorId = getConstructorId(); + + if(aConstructorId == 0) GroupPoints->SpinBox_DX->SetValue(myAng); - else if(myConstructorId == 1) + else if(aConstructorId == 1) GroupDimensions->SpinBox_DX1->SetValue(myAng); - if(myOkBase && myOkDir) - this->MakeMultiRotationSimulationAndDisplay(); - return; + displayPreview(); } //================================================================================= -// function : MakeMultiRotationSimulationAndDisplay() +// function : createOperation // purpose : //================================================================================= -void TransformationGUI_MultiRotationDlg::MakeMultiRotationSimulationAndDisplay() +GEOM::GEOM_IOperations_ptr TransformationGUI_MultiRotationDlg::createOperation() { - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); - - int i, j; - Standard_Real DX, DY, DZ; - gp_Trsf theTransformation; - gp_Trsf theTransformation1; - gp_Trsf theTransformation2; - gp_Pnt myPoint; - GProp_GProps System; - TopoDS_Compound compound; - - BRep_Builder B; - B.MakeCompound(compound); - - if(myBase.ShapeType() == TopAbs_VERTEX) - myGeomBase->VertexToPoint(myBase, myPoint); - else if(myBase.ShapeType() == TopAbs_EDGE || myBase.ShapeType() == TopAbs_WIRE) { - BRepGProp::LinearProperties(myBase, System); - myPoint = System.CentreOfMass(); - } - else if(myBase.ShapeType() == TopAbs_FACE || myBase.ShapeType() == TopAbs_SHELL) { - BRepGProp::SurfaceProperties(myBase, System); - myPoint = System.CentreOfMass(); - } - else { - BRepGProp::VolumeProperties(myBase, System); - myPoint = System.CentreOfMass(); - } + return getGeomEngine()->GetITransformOperations( getStudyId() ); +} - TopoDS_Shape S = BRepBuilderAPI_MakeVertex(myPoint).Shape(); - try { - switch (myConstructorId) +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool TransformationGUI_MultiRotationDlg::isValid( QString& msg ) +{ + return !(myBase->_is_nil() || myVector->_is_nil()); +} + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool TransformationGUI_MultiRotationDlg::execute( ObjectList& objects ) +{ + bool res = false; + + GEOM::GEOM_Object_var anObj; + + switch ( getConstructorId() ) + { + case 0 : { - case 0 : - { - gp_Ax1 AX1(myLoc, myDir); - Standard_Real angle = 360/myNbTimes1; - for(i = 0; i < myNbTimes1; i++) { - theTransformation.SetRotation(AX1, i*angle*PI180); - BRepBuilderAPI_Transform myBRepTransformation(S, theTransformation, Standard_False); - B.Add(compound, myBRepTransformation.Shape()); - } - mySimulationTopoDs = compound; - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - break; + if ( !CORBA::is_nil( myBase ) && !CORBA::is_nil( myVector ) ) { + anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->MultiRotate1D( myBase, myVector, myNbTimes1 ); + res = true; } - case 1 : - { - gp_Ax1 AX2(myLoc, myDir); - Handle(Geom_Line) Line = new Geom_Line(AX2); - gp_Pnt P2 = GeomAPI_ProjectPointOnCurve(myPoint, Line); - if(myPoint.IsEqual(P2, Precision::Confusion())) - return; - - gp_Vec Vec(P2, myPoint); - Vec.Normalize(); - - for(i = 0; i < myNbTimes2; i++) { - for(j = 0; j < myNbTimes1; j++) { - DX = i * myStep * Vec.X(); - DY = i * myStep * Vec.Y(); - DZ = i * myStep * Vec.Z(); - myVec.SetCoord(DX, DY, DZ); - - theTransformation1.SetTranslation(myVec); - theTransformation2.SetRotation(AX2, j*myAng*PI180); - BRepBuilderAPI_Transform myBRepTransformation1(S, theTransformation1, Standard_False); - BRepBuilderAPI_Transform myBRepTransformation2(myBRepTransformation1.Shape(), theTransformation2, Standard_False); - B.Add(compound, myBRepTransformation2.Shape()); - } + break; + } + case 1 : + { + if ( !CORBA::is_nil( myBase ) && !CORBA::is_nil( myVector ) ) + { + anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->MultiRotate2D( myBase, myVector, myAng, myNbTimes1, myStep, myNbTimes2 ); + res = true; } - mySimulationTopoDs = compound; - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - break; - } + break; } - } - catch(Standard_Failure) { - MESSAGE("Exception catched in MakeMultitranslationSimulationAndDisplay"); - return; - } - return; + } + + if ( !anObj->_is_nil() ) + objects.push_back( anObj._retn() ); + + return res; +} + + +//================================================================================= +// function : closeEvent +// purpose : +//================================================================================= +void TransformationGUI_MultiRotationDlg::closeEvent( QCloseEvent* e ) +{ + myGeomGUI->SetState( -1 ); + GEOMBase_Skeleton::closeEvent( e ); } diff --git a/src/TransformationGUI/TransformationGUI_MultiRotationDlg.h b/src/TransformationGUI/TransformationGUI_MultiRotationDlg.h index 10a4a401e..06d10be13 100644 --- a/src/TransformationGUI/TransformationGUI_MultiRotationDlg.h +++ b/src/TransformationGUI/TransformationGUI_MultiRotationDlg.h @@ -33,11 +33,6 @@ #include "DlgRef_2Sel4Spin1Check.h" #include "DlgRef_2Sel1Spin.h" -#include "TransformationGUI.h" - -#include "GEOM_ShapeTypeFilter.hxx" -#include -#include //================================================================================= // class : TransformationGUI_MultiRotationDlg @@ -48,43 +43,40 @@ class TransformationGUI_MultiRotationDlg : public GEOMBase_Skeleton Q_OBJECT public: - TransformationGUI_MultiRotationDlg(QWidget* parent = 0, const char* name = 0, TransformationGUI* theTransformationGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + TransformationGUI_MultiRotationDlg(QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); ~TransformationGUI_MultiRotationDlg(); +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& ); + virtual bool execute( ObjectList& objects ); + + virtual void closeEvent( QCloseEvent* e ); + private : void Init(); void enterEvent(QEvent* e); - void MakeMultiRotationSimulationAndDisplay(); - - TransformationGUI* myTransformationGUI; - - double step; - int myConstructorId; /* Current constructor id = radio button id */ - Handle(GEOM_ShapeTypeFilter) myEdgeFilter; /* Filters selection */ - - TopoDS_Shape myBase; - GEOM::GEOM_Shape_var myGeomShape; /* is myBase */ - gp_Vec myVec; + + GEOM::GEOM_Object_var myBase, myVector; int myNbTimes1; int myNbTimes2; Standard_Real myAng; Standard_Real myStep; - gp_Dir myDir; - gp_Pnt myLoc; - bool myOkBase; - bool myOkDir; - + DlgRef_2Sel1Spin* GroupPoints; DlgRef_2Sel4Spin1Check* GroupDimensions; private slots: void ClickOnOk(); - void ClickOnApply(); + bool ClickOnApply(); + void ClickOnCancel(); void ActivateThisDialog(); + void DeactivateActiveDialog(); void LineEditReturnPressed(); void SelectionIntoArgument(); void SetEditCurrentArgument(); - void ReverseAngle(int state); + void ReverseAngle(); void ValueChangedInSpinBox(double newValue); void ConstructorsClicked(int constructorId); diff --git a/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.cxx b/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.cxx index 9a78c2ecb..108dbb1dd 100644 --- a/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.cxx +++ b/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.cxx @@ -28,15 +28,12 @@ #include "TransformationGUI_MultiTranslationDlg.h" -#include -#include -#include -#include -#include -#include -#include -#include +#include "GEOMImpl_Types.hxx" + #include "QAD_Config.h" +#include "QAD_Desktop.h" + +#include #include "utilities.h" @@ -49,7 +46,7 @@ using namespace std; // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -TransformationGUI_MultiTranslationDlg::TransformationGUI_MultiTranslationDlg(QWidget* parent, const char* name, TransformationGUI* theTransformationGUI, SALOME_Selection* Sel, bool modal, WFlags fl) +TransformationGUI_MultiTranslationDlg::TransformationGUI_MultiTranslationDlg(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_MULTITRANSLATION_SIMPLE"))); @@ -73,6 +70,8 @@ TransformationGUI_MultiTranslationDlg::TransformationGUI_MultiTranslationDlg(QWi GroupPoints->CheckButton1->setText(tr("GEOM_REVERSE_U")); GroupPoints->PushButton1->setPixmap(image2); GroupPoints->PushButton2->setPixmap(image2); + GroupPoints->LineEdit1->setReadOnly(true); + GroupPoints->LineEdit2->setReadOnly(true); GroupDimensions = new DlgRef_3Sel4Spin2Check(this, "GroupDimensions"); GroupDimensions->GroupBox1->setTitle(tr("GEOM_MULTITRANSLATION_DOUBLE")); @@ -88,13 +87,14 @@ TransformationGUI_MultiTranslationDlg::TransformationGUI_MultiTranslationDlg(QWi GroupDimensions->PushButton1->setPixmap(image2); GroupDimensions->PushButton2->setPixmap(image2); GroupDimensions->PushButton3->setPixmap(image2); + GroupDimensions->LineEdit1->setReadOnly(true); + GroupDimensions->LineEdit2->setReadOnly(true); + GroupDimensions->LineEdit3->setReadOnly(true); - Layout1->addWidget(GroupPoints, 1, 0); - Layout1->addWidget(GroupDimensions, 1, 0); + Layout1->addWidget(GroupPoints, 2, 0); + Layout1->addWidget(GroupDimensions, 2, 0); /***************************************************************/ - /* Initialisations */ - myTransformationGUI = theTransformationGUI; Init(); } @@ -115,37 +115,25 @@ TransformationGUI_MultiTranslationDlg::~TransformationGUI_MultiTranslationDlg() //================================================================================= void TransformationGUI_MultiTranslationDlg::Init() { - /* init variables */ - myConstructorId = 0; - myEditCurrentArgument = GroupPoints->LineEdit1; - - myStep1 = 50.0; - myStep2 = 50.0; - myNbTimes1 = 2; - myNbTimes2 = 2; - myOkBase = myOkDir1 = myOkDir2 = false; - - myEdgeFilter = new GEOM_ShapeTypeFilter(TopAbs_EDGE, myGeom); - /* Get setting of step value from file configuration */ QString St = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep"); - step = St.toDouble(); + double step = St.toDouble(); double SpecificStep = 1; /* min, max, step and decimals for spin boxes & initial values */ GroupPoints->SpinBox_DX->RangeStepAndValidator(-999.999, 999.999, step, 3); GroupPoints->SpinBox_DY->RangeStepAndValidator(1.0, 999.999, SpecificStep, 3); - GroupPoints->SpinBox_DX->SetValue(myStep1); - GroupPoints->SpinBox_DY->SetValue(myNbTimes1); + GroupPoints->SpinBox_DX->SetValue(myStepU); + GroupPoints->SpinBox_DY->SetValue(myNbTimesU); GroupDimensions->SpinBox_DX1->RangeStepAndValidator(-999.999, 999.999, step, 3); GroupDimensions->SpinBox_DY1->RangeStepAndValidator(1.0, 999.999, SpecificStep, 3); GroupDimensions->SpinBox_DX2->RangeStepAndValidator(-999.999, 999.999, step, 3); GroupDimensions->SpinBox_DY2->RangeStepAndValidator(1.0, 999.999, SpecificStep, 3); - GroupDimensions->SpinBox_DX1->SetValue(myStep1); - GroupDimensions->SpinBox_DY1->SetValue(myNbTimes1); - GroupDimensions->SpinBox_DX2->SetValue(myStep2); - GroupDimensions->SpinBox_DY2->SetValue(myNbTimes2); + GroupDimensions->SpinBox_DX1->SetValue(myStepU); + GroupDimensions->SpinBox_DY1->SetValue(myNbTimesU); + GroupDimensions->SpinBox_DX2->SetValue(myStepV); + GroupDimensions->SpinBox_DY2->SetValue(myNbTimesV); /* signals and slots connections */ connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); @@ -178,18 +166,15 @@ void TransformationGUI_MultiTranslationDlg::Init() connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupDimensions->SpinBox_DX2, SLOT(SetStep(double))); connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupDimensions->SpinBox_DY2, SLOT(SetStep(double))); - connect(GroupPoints->CheckButton1, SIGNAL(stateChanged(int)), this, SLOT(ReverseAngle1(int))); - connect(GroupDimensions->CheckButton1, SIGNAL(stateChanged(int)), this, SLOT(ReverseAngle1(int))); - connect(GroupDimensions->CheckButton2, SIGNAL(stateChanged(int)), this, SLOT(ReverseAngle2(int))); + connect(GroupPoints->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(ReverseStepU())); + connect(GroupDimensions->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(ReverseStepU())); + connect(GroupDimensions->CheckButton2, SIGNAL(toggled(bool)), this, SLOT(ReverseStepV())); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - /* displays Dialog */ - GroupDimensions->hide(); - GroupPoints->show(); - this->show(); - - return; + + initName( tr( "GEOM_MULTITRANSLATION" ) ); + ConstructorsClicked( 0 ); } @@ -199,16 +184,12 @@ void TransformationGUI_MultiTranslationDlg::Init() //================================================================================= void TransformationGUI_MultiTranslationDlg::ConstructorsClicked(int constructorId) { - myConstructorId = constructorId; - mySelection->ClearFilters(); - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); disconnect(mySelection, 0, this, 0); - myStep1 = 50.0; - myStep2 = 50.0; - myNbTimes1 = 2; - myNbTimes2 = 2; - myOkBase = myOkDir1 = myOkDir2 = false; + + myStepU = myStepV = 50.0; + myNbTimesU = myNbTimesV = 2; + + globalSelection( GEOM_ALLSHAPES ); switch (constructorId) { @@ -222,11 +203,9 @@ void TransformationGUI_MultiTranslationDlg::ConstructorsClicked(int constructorI GroupPoints->LineEdit1->setText(""); GroupPoints->LineEdit2->setText(""); - GroupPoints->SpinBox_DX->SetValue(myStep1); - GroupPoints->SpinBox_DY->SetValue(myNbTimes1); - - /* filter for next selection */ - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + GroupPoints->SpinBox_DX->SetValue(myStepU); + GroupPoints->SpinBox_DY->SetValue(myNbTimesU); + break; } case 1: /* Translate double */ @@ -240,17 +219,19 @@ void TransformationGUI_MultiTranslationDlg::ConstructorsClicked(int constructorI GroupDimensions->LineEdit2->setText(""); GroupDimensions->LineEdit3->setText(""); - GroupDimensions->SpinBox_DX1->SetValue(myStep1); - GroupDimensions->SpinBox_DY1->SetValue(myNbTimes1); - GroupDimensions->SpinBox_DX2->SetValue(myStep2); - GroupDimensions->SpinBox_DY2->SetValue(myNbTimes2); - - /* filter for next selection */ - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + GroupDimensions->SpinBox_DX1->SetValue(myStepU); + GroupDimensions->SpinBox_DY1->SetValue(myNbTimesU); + GroupDimensions->SpinBox_DX2->SetValue(myStepV); + GroupDimensions->SpinBox_DY2->SetValue(myNbTimesV); + + myVectorV = GEOM::GEOM_Object::_nil(); break; } } - return; + + myEditCurrentArgument->setFocus(); + myBase = myVectorU = GEOM::GEOM_Object::_nil(); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); } @@ -260,9 +241,8 @@ void TransformationGUI_MultiTranslationDlg::ConstructorsClicked(int constructorI //================================================================================= void TransformationGUI_MultiTranslationDlg::ClickOnOk() { - this->ClickOnApply(); - ClickOnCancel(); - return; + if ( ClickOnApply() ) + ClickOnCancel(); } @@ -270,24 +250,24 @@ void TransformationGUI_MultiTranslationDlg::ClickOnOk() // function : ClickOnApply() // purpose : //================================================================================= -void TransformationGUI_MultiTranslationDlg::ClickOnApply() +bool TransformationGUI_MultiTranslationDlg::ClickOnApply() { - buttonApply->setFocus(); - QAD_Application::getDesktop()->putInfo(tr("")); - if (mySimulationTopoDs.IsNull()) - return; - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); + if ( !onAccept() ) + return false; + + initName(); + ConstructorsClicked( getConstructorId() ); + return true; +} - if(myConstructorId == 0) { - if(myOkBase && myOkDir1) - myTransformationGUI->MakeMultiTranslation1DAndDisplay(myGeomShape, myDir1, myStep1, myNbTimes1); - } - else if(myConstructorId == 1) { - if(myOkBase && myOkDir1 && myOkDir2) - myTransformationGUI->MakeMultiTranslation2DAndDisplay(myGeomShape, myDir1, myStep1, myNbTimes1, myDir2, myStep2, myNbTimes2); - } - return; + +//======================================================================= +// function : ClickOnCancel() +// purpose : +//======================================================================= +void TransformationGUI_MultiTranslationDlg::ClickOnCancel() +{ + GEOMBase_Skeleton::ClickOnCancel(); } @@ -297,81 +277,35 @@ void TransformationGUI_MultiTranslationDlg::ClickOnApply() //================================================================================= void TransformationGUI_MultiTranslationDlg::SelectionIntoArgument() { - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); myEditCurrentArgument->setText(""); - QString aString = ""; /* name of selection */ - - int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString); - if(nbSel != 1) { + + if(mySelection->IObjectCount() != 1) { if(myEditCurrentArgument == GroupPoints->LineEdit1 || myEditCurrentArgument == GroupDimensions->LineEdit1) - myOkBase = false; + myBase = GEOM::GEOM_Object::_nil(); else if(myEditCurrentArgument == GroupPoints->LineEdit2 || myEditCurrentArgument == GroupDimensions->LineEdit2) - myOkDir1 = false; + myVectorU = GEOM::GEOM_Object::_nil(); else if(myEditCurrentArgument == GroupDimensions->LineEdit3) - myOkDir2 = false; + myVectorV = GEOM::GEOM_Object::_nil(); return; } // nbSel == 1 - TopoDS_Shape S; - Standard_Boolean testResult; - Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); - if(!myGeomBase->GetTopoFromSelection(mySelection, S)) - return; + Standard_Boolean testResult = Standard_False;; + GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(mySelection->firstIObject(), testResult ); - switch(myConstructorId) - { - case 0 : - { - if(myEditCurrentArgument == GroupPoints->LineEdit1) { - myGeomShape = myGeomBase->ConvertIOinGEOMShape(IO, testResult); - if(!testResult) - return; - myEditCurrentArgument->setText(aString); - myBase = S; - myOkBase = true; - } - else if(myEditCurrentArgument == GroupPoints->LineEdit2) { - BRepAdaptor_Curve curv(TopoDS::Edge(S)); - myDir1 = curv.Line().Direction(); - myEditCurrentArgument->setText(aString); - myOkDir1 = true; - } + if ( !testResult || CORBA::is_nil( aSelectedObject ) || !GEOMBase::IsShape( aSelectedObject ) ) + return; - if(myOkBase && myOkDir1) - this->MakeMultiTranslationSimulationAndDisplay(); - break; - } - case 1 : - { - if(myEditCurrentArgument == GroupDimensions->LineEdit1) { - myGeomShape = myGeomBase->ConvertIOinGEOMShape(IO, testResult); - if(!testResult) - return; - myEditCurrentArgument->setText(aString); - myBase = S; - myOkBase = true; - } - else if(myEditCurrentArgument == GroupDimensions->LineEdit2) { - BRepAdaptor_Curve curv(TopoDS::Edge(S)); - myDir1 = curv.Line().Direction(); - myEditCurrentArgument->setText(aString); - myOkDir1 = true; - } - else if(myEditCurrentArgument == GroupDimensions->LineEdit3) { - BRepAdaptor_Curve curv(TopoDS::Edge(S)); - myDir2 = curv.Line().Direction(); - myEditCurrentArgument->setText(aString); - myOkDir2 = true; - } + if(myEditCurrentArgument == GroupPoints->LineEdit1 || myEditCurrentArgument == GroupDimensions->LineEdit1) + myBase = aSelectedObject; + else if(myEditCurrentArgument == GroupPoints->LineEdit2 || myEditCurrentArgument == GroupDimensions->LineEdit2) + myVectorU = aSelectedObject; + else if(myEditCurrentArgument == GroupDimensions->LineEdit3) + myVectorV = aSelectedObject; - if(myOkBase && myOkDir1 && myOkDir2) - this->MakeMultiTranslationSimulationAndDisplay(); - break; - } - } - return; + myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) ); + + displayPreview(); } @@ -382,34 +316,31 @@ void TransformationGUI_MultiTranslationDlg::SelectionIntoArgument() void TransformationGUI_MultiTranslationDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); - mySelection->ClearFilters(); + if(send == GroupPoints->PushButton1) { - GroupPoints->LineEdit1->setFocus(); myEditCurrentArgument = GroupPoints->LineEdit1; + globalSelection( GEOM_ALLSHAPES ); } else if(send == GroupPoints->PushButton2) { - GroupPoints->LineEdit2->setFocus(); myEditCurrentArgument = GroupPoints->LineEdit2; - mySelection->AddFilter(myEdgeFilter); + globalSelection( GEOM_LINE ); } else if(send == GroupDimensions->PushButton1) { - GroupDimensions->LineEdit1->setFocus(); myEditCurrentArgument = GroupDimensions->LineEdit1; + globalSelection( GEOM_ALLSHAPES ); } else if(send == GroupDimensions->PushButton2) { - GroupDimensions->LineEdit2->setFocus(); myEditCurrentArgument = GroupDimensions->LineEdit2; - mySelection->AddFilter(myEdgeFilter); + globalSelection( GEOM_LINE ); } else if(send == GroupDimensions->PushButton3) { - GroupDimensions->LineEdit3->setFocus(); myEditCurrentArgument = GroupDimensions->LineEdit3; - mySelection->AddFilter(myEdgeFilter); + globalSelection( GEOM_LINE ); } - this->SelectionIntoArgument(); - - return; + + myEditCurrentArgument->setFocus(); + SelectionIntoArgument(); } @@ -420,21 +351,13 @@ void TransformationGUI_MultiTranslationDlg::SetEditCurrentArgument() void TransformationGUI_MultiTranslationDlg::LineEditReturnPressed() { QLineEdit* send = (QLineEdit*)sender(); - if(send == GroupPoints->LineEdit1) - myEditCurrentArgument = GroupPoints->LineEdit1; - else if (send == GroupPoints->LineEdit2) - myEditCurrentArgument = GroupPoints->LineEdit2; - else if (send == GroupDimensions->LineEdit1) - myEditCurrentArgument = GroupDimensions->LineEdit1; - else if (send == GroupDimensions->LineEdit2) - myEditCurrentArgument = GroupDimensions->LineEdit2; - else if (send == GroupDimensions->LineEdit3) - myEditCurrentArgument = GroupDimensions->LineEdit3; - else - return; - - GEOMBase_Skeleton::LineEditReturnPressed(); - return; + if(send == GroupPoints->LineEdit1 || send == GroupDimensions->LineEdit1 || + send == GroupPoints->LineEdit2 || send == GroupDimensions->LineEdit2 || + send == GroupDimensions->LineEdit3) + { + myEditCurrentArgument = send; + GEOMBase_Skeleton::LineEditReturnPressed(); + } } @@ -447,18 +370,17 @@ void TransformationGUI_MultiTranslationDlg::ActivateThisDialog() GEOMBase_Skeleton::ActivateThisDialog(); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - if(myConstructorId == 0) { - GroupPoints->LineEdit1->setFocus(); - myEditCurrentArgument = GroupPoints->LineEdit1; - } - else if(myConstructorId == 1) { - GroupDimensions->LineEdit1->setFocus(); - myEditCurrentArgument = GroupDimensions->LineEdit1; - } + ConstructorsClicked( getConstructorId() ); +} - if(!mySimulationTopoDs.IsNull()) - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - return; + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : public slot to deactivate if active +//================================================================================= +void TransformationGUI_MultiTranslationDlg::DeactivateActiveDialog() +{ + GEOMBase_Skeleton::DeactivateActiveDialog(); } @@ -468,10 +390,8 @@ void TransformationGUI_MultiTranslationDlg::ActivateThisDialog() //================================================================================= void TransformationGUI_MultiTranslationDlg::enterEvent(QEvent* e) { - if (GroupConstructors->isEnabled()) - return; - this->ActivateThisDialog(); - return; + if(!GroupConstructors->isEnabled()) + ActivateThisDialog(); } @@ -481,148 +401,139 @@ void TransformationGUI_MultiTranslationDlg::enterEvent(QEvent* e) //================================================================================= void TransformationGUI_MultiTranslationDlg::ValueChangedInSpinBox(double newValue) { - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); QObject* send = (QObject*)sender(); - switch(myConstructorId) + switch(getConstructorId()) { case 0 : { if(send == GroupPoints->SpinBox_DX) - myStep1 = newValue; + myStepU = newValue; else if(send == GroupPoints->SpinBox_DY) - myNbTimes1 = (int)newValue; - if(myOkBase && myOkDir1) - this->MakeMultiTranslationSimulationAndDisplay(); + myNbTimesU = (int)newValue; break; } case 1 : { if(send == GroupDimensions->SpinBox_DX1) - myStep1 = newValue; + myStepU = newValue; else if(send == GroupDimensions->SpinBox_DY1) - myNbTimes1 = (int)newValue; + myNbTimesU = (int)newValue; else if(send == GroupDimensions->SpinBox_DX2) - myStep2 = newValue; + myStepV = newValue; else if(send == GroupDimensions->SpinBox_DY2) - myNbTimes2 = (int)newValue; - if(myOkBase && myOkDir1 && myOkDir2) - this->MakeMultiTranslationSimulationAndDisplay(); + myNbTimesV = (int)newValue; break; } } - return; + + displayPreview(); } //================================================================================= -// function : ReverseAngle1() +// function : ReverseStepU() // purpose : 'state' not used here //================================================================================= -void TransformationGUI_MultiTranslationDlg::ReverseAngle1(int state) +void TransformationGUI_MultiTranslationDlg::ReverseStepU() { - myStep1 = -myStep1; - if(myConstructorId == 0) { - GroupPoints->SpinBox_DX->SetValue(myStep1); - if(myOkBase && myOkDir1) - this->MakeMultiTranslationSimulationAndDisplay(); - } - else if(myConstructorId == 1) { - GroupDimensions->SpinBox_DX1->SetValue(myStep1); - if(myOkBase && myOkDir1 && myOkDir2) - this->MakeMultiTranslationSimulationAndDisplay(); - } - return; + myStepU = -myStepU; + + int aConstructorId = getConstructorId(); + + if(aConstructorId == 0) + GroupPoints->SpinBox_DX->SetValue(myStepU); + else if(aConstructorId == 1) + GroupDimensions->SpinBox_DX1->SetValue(myStepU); + + displayPreview(); } //================================================================================= -// function : ReverseAngle2() +// function : ReverseStepV // purpose : 'state' not used here //================================================================================= -void TransformationGUI_MultiTranslationDlg::ReverseAngle2(int state) +void TransformationGUI_MultiTranslationDlg::ReverseStepV() { - myStep2 = -myStep2; - GroupDimensions->SpinBox_DX2->SetValue(myStep2); - if(myOkBase && myOkDir1 && myOkDir2) - MakeMultiTranslationSimulationAndDisplay(); - return; + myStepV = -myStepV; + + GroupDimensions->SpinBox_DX2->SetValue(myStepV); + + displayPreview(); } //================================================================================= -// function : MakeMultiTranslationSimulationAndDisplay() +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr TransformationGUI_MultiTranslationDlg::createOperation() +{ + return getGeomEngine()->GetITransformOperations( getStudyId() ); +} + + +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool TransformationGUI_MultiTranslationDlg::isValid( QString& msg ) +{ + int aConstructorId = getConstructorId(); + + if(aConstructorId == 0) + return !(myBase->_is_nil() || myVectorU->_is_nil()); + else if(aConstructorId == 1) + return !(myBase->_is_nil() || myVectorU->_is_nil() || myVectorV->_is_nil()); + return 0; +} + +//================================================================================= +// function : execute // purpose : //================================================================================= -void TransformationGUI_MultiTranslationDlg::MakeMultiTranslationSimulationAndDisplay() +bool TransformationGUI_MultiTranslationDlg::execute( ObjectList& objects ) { - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); - - int i, j; - Standard_Real DX, DY, DZ; - gp_Trsf theTransformation; - GProp_GProps System; - TopoDS_Compound compound; - - BRep_Builder B; - B.MakeCompound(compound); - - try { - BRepGProp::LinearProperties(myBase, System); - gp_Pnt myPoint = System.CentreOfMass(); - TopoDS_Shape S = BRepBuilderAPI_MakeVertex(myPoint).Shape(); - - switch (myConstructorId) + bool res = false; + + GEOM::GEOM_Object_var anObj; + + switch ( getConstructorId() ) + { + case 0 : { - case 0 : - { - gp_Vec Vec(myDir1); - Vec.Normalize(); - - for(i = 0; i < myNbTimes1; i++) { - DX = i * myStep1 * Vec.X(); - DY = i * myStep1 * Vec.Y(); - DZ = i * myStep1 * Vec.Z(); - myVec.SetCoord(DX, DY, DZ); - - theTransformation.SetTranslation(myVec); - BRepBuilderAPI_Transform myBRepTransformation(S, theTransformation, Standard_False); - B.Add(compound, myBRepTransformation.Shape()); - } - mySimulationTopoDs = compound; - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - break; + if ( !CORBA::is_nil( myBase ) && !CORBA::is_nil( myVectorU ) ) { + anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->MultiTranslate1D( myBase, myVectorU, myStepU, myNbTimesU ); + res = true; } - case 1 : - { - gp_Vec Vec1(myDir1); - Vec1.Normalize(); - gp_Vec Vec2(myDir2); - Vec2.Normalize(); - - for(i = 0; i < myNbTimes1; i++) { - for(j = 0; j < myNbTimes2; j++) { - DX = i * myStep1 * Vec1.X() + j * myStep2 * Vec2.X(); - DY = i * myStep1 * Vec1.Y() + j * myStep2 * Vec2.Y(); - DZ = i * myStep1 * Vec1.Z() + j * myStep2 * Vec2.Z(); - myVec.SetCoord(DX, DY, DZ); - - theTransformation.SetTranslation(myVec); - BRepBuilderAPI_Transform myBRepTransformation(S, theTransformation, Standard_False); - B.Add(compound, myBRepTransformation.Shape()); - } + break; + } + case 1 : + { + if ( !CORBA::is_nil( myBase ) && !CORBA::is_nil( myVectorU ) && !CORBA::is_nil( myVectorV ) ) + { + anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->MultiTranslate2D( myBase, myVectorU, myStepU, myNbTimesU, + myVectorV, myStepV, myNbTimesV ); + res = true; } - mySimulationTopoDs = compound; - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - break; - } + break; } - } - catch(Standard_Failure) { - MESSAGE("Exception catched in MakeMultitranslationSimulationAndDisplay"); - return; - } - return; + } + + if ( !anObj->_is_nil() ) + objects.push_back( anObj._retn() ); + + return res; +} + + +//================================================================================= +// function : closeEvent +// purpose : +//================================================================================= +void TransformationGUI_MultiTranslationDlg::closeEvent( QCloseEvent* e ) +{ + myGeomGUI->SetState( -1 ); + GEOMBase_Skeleton::closeEvent( e ); } diff --git a/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.h b/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.h index 26b39d78a..1440ab66f 100644 --- a/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.h +++ b/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.h @@ -33,11 +33,6 @@ #include "DlgRef_2Sel2Spin1Check.h" #include "DlgRef_3Sel4Spin2Check.h" -#include "TransformationGUI.h" - -#include "GEOM_ShapeTypeFilter.hxx" -#include -#include //================================================================================= // class : TransformationGUI_MultiTranslationDlg @@ -48,45 +43,41 @@ class TransformationGUI_MultiTranslationDlg : public GEOMBase_Skeleton Q_OBJECT public: - TransformationGUI_MultiTranslationDlg(QWidget* parent = 0, const char* name = 0, TransformationGUI* theTransformationGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + TransformationGUI_MultiTranslationDlg(QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); ~TransformationGUI_MultiTranslationDlg(); +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& ); + virtual bool execute( ObjectList& objects ); + + virtual void closeEvent( QCloseEvent* e ); + private : void Init(); void enterEvent(QEvent* e); - void MakeMultiTranslationSimulationAndDisplay(); - - TransformationGUI* myTransformationGUI; - - double step; - int myConstructorId; /* Current constructor id = radio button id */ - Handle(GEOM_ShapeTypeFilter) myEdgeFilter; /* Filters selection */ - - TopoDS_Shape myBase; - GEOM::GEOM_Shape_var myGeomShape; /* is myBase */ - gp_Vec myVec; - int myNbTimes1; - int myNbTimes2; - Standard_Real myStep1; - Standard_Real myStep2; - gp_Dir myDir1; - gp_Dir myDir2; - bool myOkBase; - bool myOkDir1; - bool myOkDir2; - + + GEOM::GEOM_Object_var myBase, myVectorU, myVectorV ; + int myNbTimesU; + int myNbTimesV; + Standard_Real myStepU; + Standard_Real myStepV; + DlgRef_2Sel2Spin1Check* GroupPoints; DlgRef_3Sel4Spin2Check* GroupDimensions; private slots: void ClickOnOk(); - void ClickOnApply(); + bool ClickOnApply(); + void ClickOnCancel(); void ActivateThisDialog(); + void DeactivateActiveDialog(); void LineEditReturnPressed(); void SelectionIntoArgument(); void SetEditCurrentArgument(); - void ReverseAngle1(int state); - void ReverseAngle2(int state); + void ReverseStepU(); + void ReverseStepV(); void ValueChangedInSpinBox(double newValue); void ConstructorsClicked(int constructorId); diff --git a/src/TransformationGUI/TransformationGUI_OffsetDlg.cxx b/src/TransformationGUI/TransformationGUI_OffsetDlg.cxx new file mode 100644 index 000000000..ba0cd6381 --- /dev/null +++ b/src/TransformationGUI/TransformationGUI_OffsetDlg.cxx @@ -0,0 +1,346 @@ +// 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 : TransformationGUI_OffsetDlg.cxx +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +#include "TransformationGUI_OffsetDlg.h" +#include +#include "utilities.h" + +#include + +using namespace std; + +//================================================================================= +// class : TransformationGUI_OffsetDlg() +// purpose : Constructs a TransformationGUI_OffsetDlg 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. +//================================================================================= +TransformationGUI_OffsetDlg::TransformationGUI_OffsetDlg(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_OFFSET"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); + + setCaption(tr("GEOM_OFFSET_TITLE")); + + /***************************************************************/ + GroupConstructors->setTitle(tr("GEOM_OFFSET")); + RadioButton1->setPixmap(image0); + RadioButton2->close(TRUE); + RadioButton3->close(TRUE); + + GroupPoints = new DlgRef_1Sel1Spin1Check(this, "GroupPoints"); + GroupPoints->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); + GroupPoints->TextLabel1->setText(tr("GEOM_OBJECTS")); + GroupPoints->TextLabel2->setText(tr("GEOM_OFFSET")); + GroupPoints->CheckButton1->setText(tr("GEOM_CREATE_COPY")); + + // san -- modification of an exisitng object by offset is not allowed + GroupPoints->CheckButton1->hide(); + + GroupPoints->PushButton1->setPixmap(image1); + + Layout1->addWidget(GroupPoints, 2, 0); + + /***************************************************************/ + + Init(); +} + + +//================================================================================= +// function : ~TransformationGUI_OffsetDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +TransformationGUI_OffsetDlg::~TransformationGUI_OffsetDlg() +{ + /* no need to delete child widgets, Qt does it all for us */ +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void TransformationGUI_OffsetDlg::Init() +{ + /* init variables */ + myEditCurrentArgument = GroupPoints->LineEdit1; + GroupPoints->LineEdit1->setReadOnly( true ); + + /* Get setting of step value from file configuration */ + double step = 1; + + /* min, max, step and decimals for spin boxes & initial values */ + GroupPoints->SpinBox_DX->RangeStepAndValidator(-999.999, 999.999, step, 3); + GroupPoints->SpinBox_DX->setPrecision(5); + GroupPoints->SpinBox_DX->setDblPrecision(1e-05); + GroupPoints->SpinBox_DX->SetValue(1e-05); + + // Activate Create a Copy mode + GroupPoints->CheckButton1->setChecked(true); + CreateCopyModeChanged(true); + + /* signals and slots connections */ + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + + connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + + connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); + connect(GroupPoints->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(CreateCopyModeChanged(bool))); + + initName( tr( "GEOM_OFFSET" ) ); + + globalSelection( GEOM_ALLSHAPES ); + +} + + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void TransformationGUI_OffsetDlg::ClickOnOk() +{ + if ( ClickOnApply() ) + ClickOnCancel(); +} + + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +bool TransformationGUI_OffsetDlg::ClickOnApply() +{ + if ( !onAccept( GroupPoints->CheckButton1->isChecked() ) ) + return false; + + initName(); + return true; +} + + +//======================================================================= +// function : ClickOnCancel() +// purpose : +//======================================================================= +void TransformationGUI_OffsetDlg::ClickOnCancel() +{ + GEOMBase_Skeleton::ClickOnCancel(); +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection has changed +//================================================================================= +void TransformationGUI_OffsetDlg::SelectionIntoArgument() +{ + myEditCurrentArgument->setText(""); + QString aName; + + int aNbSel = GEOMBase::GetNameOfSelectedIObjects(mySelection, aName); + if(aNbSel < 1) + { + myObjects.length(0); + return; + } + + // nbSel > 0 + GEOMBase::ConvertListOfIOInListOfGO(mySelection->StoredIObjects(), myObjects); + if (!myObjects.length()) + return; + if(aNbSel != 1) + aName = tr("%1_objects").arg(aNbSel); + + myEditCurrentArgument->setText( aName ); + + displayPreview(); +} + + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void TransformationGUI_OffsetDlg::LineEditReturnPressed() +{ + QLineEdit* send = (QLineEdit*)sender(); + if ( send == GroupPoints->LineEdit1 ) + { + myEditCurrentArgument = GroupPoints->LineEdit1; + GEOMBase_Skeleton::LineEditReturnPressed(); + } +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void TransformationGUI_OffsetDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + + if(send == GroupPoints->PushButton1) + { + myEditCurrentArgument = GroupPoints->LineEdit1; + myEditCurrentArgument->setFocus(); + SelectionIntoArgument(); + } +} + + +//================================================================================= +// function : enterEvent() +// purpose : when mouse enter onto the QWidget +//================================================================================= +void TransformationGUI_OffsetDlg::enterEvent(QEvent * e) +{ + if ( !GroupConstructors->isEnabled() ) + ActivateThisDialog(); +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void TransformationGUI_OffsetDlg::ActivateThisDialog() +{ + GEOMBase_Skeleton::ActivateThisDialog(); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + globalSelection( GEOM_ALLSHAPES ); + myEditCurrentArgument = GroupPoints->LineEdit1; + myEditCurrentArgument->setFocus(); +} + + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : public slot to deactivate if active +//================================================================================= +void TransformationGUI_OffsetDlg::DeactivateActiveDialog() +{ + GEOMBase_Skeleton::DeactivateActiveDialog(); +} + + +//================================================================================= +// function : ValueChangedInSpinBox() +// purpose : +//================================================================================= +void TransformationGUI_OffsetDlg::ValueChangedInSpinBox() +{ + displayPreview(); +} + + +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr TransformationGUI_OffsetDlg::createOperation() +{ + return getGeomEngine()->GetITransformOperations( getStudyId() ); +} + +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool TransformationGUI_OffsetDlg::isValid( QString& msg ) +{ + return !(myObjects.length() == 0); +} + + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool TransformationGUI_OffsetDlg::execute( ObjectList& objects ) +{ + bool res = false; + + GEOM::GEOM_Object_var anObj; + + + if (GroupPoints->CheckButton1->isChecked() || IsPreview()) + for (int i = 0; i < myObjects.length(); i++) + { + anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->OffsetShapeCopy( myObjects[i], GetOffset() ); + if ( !anObj->_is_nil() ) + objects.push_back( anObj._retn() ); + } + else + for (int i = 0; i < myObjects.length(); i++) + { + anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->OffsetShape( myObjects[i], GetOffset() ); + if ( !anObj->_is_nil() ) + objects.push_back( anObj._retn() ); + } + + res = true; + + return res; +} + +//================================================================================= +// function : closeEvent +// purpose : +//================================================================================= +void TransformationGUI_OffsetDlg::closeEvent( QCloseEvent* e ) +{ + myGeomGUI->SetState( -1 ); + GEOMBase_Skeleton::closeEvent( e ); +} + + +//================================================================================= +// function : GetOffset() +// purpose : +//================================================================================= +double TransformationGUI_OffsetDlg::GetOffset() const +{ + return GroupPoints->SpinBox_DX->GetValue(); +} + + +//================================================================================= +// function : CreateCopyModeChanged() +// purpose : +//================================================================================= +void TransformationGUI_OffsetDlg::CreateCopyModeChanged(bool isCreateCopy) +{ + this->GroupBoxName->setEnabled(isCreateCopy); +} diff --git a/src/TransformationGUI/TransformationGUI_OffsetDlg.h b/src/TransformationGUI/TransformationGUI_OffsetDlg.h new file mode 100644 index 000000000..e14ccc4cf --- /dev/null +++ b/src/TransformationGUI/TransformationGUI_OffsetDlg.h @@ -0,0 +1,79 @@ +// 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 : TransformationGUI_OffsetDlg.h +// Author : Michael Zorin +// Module : GEOM +// $Header: /dn05/salome/PAL/GEOM/GEOM_SRC/src/TransformationGUI/TransformationGUI_Offset.h + +#ifndef DIALOGBOX_OFFSET_H +#define DIALOGBOX_OFFSET_H + +#include "GEOMBase_Skeleton.h" +#include "DlgRef_1Sel1Spin1Check.h" + + +//================================================================================= +// class : TransformationGUI_OffsetDlg +// purpose : +//================================================================================= +class TransformationGUI_OffsetDlg : public GEOMBase_Skeleton +{ + Q_OBJECT + +public: + TransformationGUI_OffsetDlg(QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + ~TransformationGUI_OffsetDlg(); + +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& ); + virtual bool execute( ObjectList& objects ); + + virtual void closeEvent( QCloseEvent* e ); + +private : + void Init(); + void enterEvent(QEvent* e); + double GetOffset() const; + + GEOM::ListOfGO myObjects; + + DlgRef_1Sel1Spin1Check* GroupPoints; + +private slots : + void ClickOnOk(); + bool ClickOnApply(); + void ClickOnCancel(); + void ActivateThisDialog(); + void DeactivateActiveDialog(); + void SelectionIntoArgument(); + void LineEditReturnPressed(); + void SetEditCurrentArgument(); + void ValueChangedInSpinBox(); + void CreateCopyModeChanged(bool isCreateCopy); +}; + +#endif // DIALOGBOX_OFFSET_H + diff --git a/src/TransformationGUI/TransformationGUI_PositionDlg.cxx b/src/TransformationGUI/TransformationGUI_PositionDlg.cxx new file mode 100644 index 000000000..d6fca9051 --- /dev/null +++ b/src/TransformationGUI/TransformationGUI_PositionDlg.cxx @@ -0,0 +1,438 @@ +// 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 : TransformationGUI_PositionDlg.cxx +// Author : Damien COQUERET +// Module : GEOM +// $Header$ + +#include "TransformationGUI_PositionDlg.h" + +#include "QAD_Desktop.h" + +#include + +#include "GEOMImpl_Types.hxx" + +#include "utilities.h" + +using namespace std; + +//================================================================================= +// class : TransformationGUI_PositionDlg() +// purpose : Constructs a TransformationGUI_PositionDlg 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. +//================================================================================= +TransformationGUI_PositionDlg::TransformationGUI_PositionDlg(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_POSITION"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_POSITION2"))); + QPixmap imageselect(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); + + setCaption(tr("GEOM_POSITION_TITLE")); + + /***************************************************************/ + GroupConstructors->setTitle(tr("GEOM_POSITION")); + RadioButton1->setPixmap(image0); + RadioButton2->setPixmap(image1); + RadioButton3->close(TRUE); + + Group1 = new DlgRef_3Sel3Spin1Check(this, "Group1"); + Group1->SpinBox1->hide(); + Group1->SpinBox2->hide(); + Group1->SpinBox3->hide(); + Group1->TextLabel4->hide(); + Group1->TextLabel5->hide(); + Group1->TextLabel6->hide(); + Group1->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); + Group1->TextLabel1->setText(tr("GEOM_OBJECTS")); + Group1->TextLabel2->setText(tr("GEOM_START_LCS")); + Group1->TextLabel3->setText(tr("GEOM_END_LCS")); + Group1->PushButton1->setPixmap(imageselect); + Group1->PushButton2->setPixmap(imageselect); + Group1->PushButton3->setPixmap(imageselect); + Group1->CheckBox1->setText(tr("GEOM_CREATE_COPY")); + + Layout1->addWidget(Group1, 2, 0); + + /***************************************************************/ + + Init(); +} + + +//================================================================================= +// function : ~TransformationGUI_PositionDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +TransformationGUI_PositionDlg::~TransformationGUI_PositionDlg() +{ + /* no need to delete child widgets, Qt does it all for us */ +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void TransformationGUI_PositionDlg::Init() +{ + /* init variables */ + Group1->LineEdit1->setReadOnly(true); + Group1->LineEdit2->setReadOnly(true); + Group1->LineEdit3->setReadOnly(true); + + myStartLCS = GEOM::GEOM_Object::_nil(); + myEndLCS = GEOM::GEOM_Object::_nil(); + + // Activate Create a Copy mode + Group1->CheckBox1->setChecked(true); + CreateCopyModeChanged(true); + + /* signals and slots connections */ + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + connect(GroupConstructors, SIGNAL(clicked(int)), SLOT(ConstructorsClicked(int))); + + connect(Group1->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(Group1->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(Group1->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + + connect(Group1->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(Group1->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(Group1->LineEdit3, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + + connect(Group1->CheckBox1, SIGNAL(toggled(bool)), this, SLOT(CreateCopyModeChanged(bool))); + + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + + initName( tr( "GEOM_POSITION" ) ); + ConstructorsClicked( 0 ); +} + + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void TransformationGUI_PositionDlg::ConstructorsClicked(int constructorId) +{ + disconnect( mySelection, 0, this, 0 ); + + globalSelection(); + myEditCurrentArgument = Group1->LineEdit1; + Group1->LineEdit2->clear(); + Group1->LineEdit3->clear(); + myStartLCS = GEOM::GEOM_Object::_nil(); + myEndLCS = GEOM::GEOM_Object::_nil(); + + switch (constructorId) + { + case 0: + { + Group1->LineEdit2->hide(); + Group1->TextLabel2->hide(); + Group1->PushButton2->hide(); + break; + } + case 1: + { + Group1->LineEdit2->show(); + Group1->TextLabel2->show(); + Group1->PushButton2->show(); + break; + } + } + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + SelectionIntoArgument(); +} + + + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void TransformationGUI_PositionDlg::ClickOnOk() +{ + if ( ClickOnApply() ) + ClickOnCancel(); +} + + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +bool TransformationGUI_PositionDlg::ClickOnApply() +{ + if ( !onAccept(Group1->CheckBox1->isChecked()) ) + return false; + + initName(); + ConstructorsClicked( getConstructorId() ); + return true; +} + + +//======================================================================= +// function : ClickOnCancel() +// purpose : +//======================================================================= +void TransformationGUI_PositionDlg::ClickOnCancel() +{ + GEOMBase_Skeleton::ClickOnCancel(); +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection has changed +//================================================================================= +void TransformationGUI_PositionDlg::SelectionIntoArgument() +{ + myEditCurrentArgument->setText(""); + QString aName; + + if(myEditCurrentArgument == Group1->LineEdit1) { + int aNbSel = GEOMBase::GetNameOfSelectedIObjects(mySelection, aName); + if(aNbSel < 1) { + myObjects.length(0); + displayPreview(); + return; + } + GEOMBase::ConvertListOfIOInListOfGO(mySelection->StoredIObjects(), myObjects); + if (!myObjects.length()) { + displayPreview(); + return; + } + if(aNbSel != 1) + aName = tr("%1_objects").arg(aNbSel); + } + else if(myEditCurrentArgument == Group1->LineEdit2) { + myStartLCS = GEOM::GEOM_Object::_nil(); + if(mySelection->IObjectCount() != 1) { + displayPreview(); + return; + } + + Standard_Boolean testResult = Standard_False; + myStartLCS = GEOMBase::ConvertIOinGEOMObject(mySelection->firstIObject(), testResult ); + if(!testResult || CORBA::is_nil( myStartLCS )) { + displayPreview(); + return; + } + aName = GEOMBase::GetName( myStartLCS ); + } + else if(myEditCurrentArgument == Group1->LineEdit3) { + myEndLCS = GEOM::GEOM_Object::_nil(); + if(mySelection->IObjectCount() != 1) { + displayPreview(); + return; + } + + Standard_Boolean testResult = Standard_False; + myEndLCS = GEOMBase::ConvertIOinGEOMObject(mySelection->firstIObject(), testResult ); + if(!testResult || CORBA::is_nil( myEndLCS )) { + displayPreview(); + return; + } + aName = GEOMBase::GetName( myEndLCS ); + } + + myEditCurrentArgument->setText( aName ); + displayPreview(); +} + + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void TransformationGUI_PositionDlg::LineEditReturnPressed() +{ + QLineEdit* send = (QLineEdit*)sender(); + if(send == Group1->LineEdit1 || send == Group1->LineEdit2 || send == Group1->LineEdit3) { + myEditCurrentArgument = send; + GEOMBase_Skeleton::LineEditReturnPressed(); + } +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void TransformationGUI_PositionDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + + if(send == Group1->PushButton1){ + myEditCurrentArgument = Group1->LineEdit1; + globalSelection(); + } + else if(send == Group1->PushButton2) { + myEditCurrentArgument = Group1->LineEdit2; + TColStd_MapOfInteger aMap; + aMap.Add( GEOM_PLANE ); + aMap.Add( GEOM_MARKER ); + globalSelection( aMap ); + } + else if(send == Group1->PushButton3) { + myEditCurrentArgument = Group1->LineEdit3; + TColStd_MapOfInteger aMap; + aMap.Add( GEOM_PLANE ); + aMap.Add( GEOM_MARKER ); + globalSelection( aMap ); + } + + myEditCurrentArgument->setFocus(); + SelectionIntoArgument(); +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void TransformationGUI_PositionDlg::ActivateThisDialog() +{ + GEOMBase_Skeleton::ActivateThisDialog(); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + ConstructorsClicked( getConstructorId() ); +} + + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : public slot to deactivate if active +//================================================================================= +void TransformationGUI_PositionDlg::DeactivateActiveDialog() +{ + GEOMBase_Skeleton::DeactivateActiveDialog(); +} + + +//================================================================================= +// function : enterEvent() +// purpose : when mouse enter onto the QWidget +//================================================================================= +void TransformationGUI_PositionDlg::enterEvent(QEvent * e) +{ + if(!GroupConstructors->isEnabled()) + ActivateThisDialog(); +} + + +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr TransformationGUI_PositionDlg::createOperation() +{ + return getGeomEngine()->GetITransformOperations( getStudyId() ); +} + + +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool TransformationGUI_PositionDlg::isValid( QString& msg ) +{ + bool res; + if (getConstructorId() == 0) + res = !(myObjects.length() == 0 || myEndLCS->_is_nil()); + else + res = !(myObjects.length() == 0 || myStartLCS->_is_nil() || myEndLCS->_is_nil()); + + return res; +} + + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool TransformationGUI_PositionDlg::execute( ObjectList& objects ) +{ + bool res = false; + bool toCreateCopy = IsPreview() || Group1->CheckBox1->isChecked(); + GEOM::GEOM_Object_var anObj; + + switch ( getConstructorId() ) + { + case 0 : + { + for (int i = 0; i < myObjects.length(); i++) { + if (toCreateCopy) + anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->PositionShapeCopy( myObjects[i], myObjects[i], myEndLCS ); + else + anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->PositionShape( myObjects[i], myObjects[i], myEndLCS ); + + if ( !anObj->_is_nil() ) + objects.push_back( anObj._retn() ); + } + res = true; + break; + } + case 1 : + { + for (int i = 0; i < myObjects.length(); i++) { + if (toCreateCopy) + anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->PositionShapeCopy( myObjects[i], myStartLCS, myEndLCS ); + else + anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->PositionShape( myObjects[i], myStartLCS, myEndLCS ); + if ( !anObj->_is_nil() ) + objects.push_back( anObj._retn() ); + } + res = true; + break; + } + } + + return res; +} + +//================================================================================= +// function : closeEvent +// purpose : +//================================================================================= +void TransformationGUI_PositionDlg::closeEvent( QCloseEvent* e ) +{ + GEOMBase_Skeleton::closeEvent( e ); +} + + +//================================================================================= +// function : CreateCopyModeChanged() +// purpose : +//================================================================================= +void TransformationGUI_PositionDlg::CreateCopyModeChanged(bool isCreateCopy) +{ + this->GroupBoxName->setEnabled(isCreateCopy); +} diff --git a/src/TransformationGUI/TransformationGUI_PositionDlg.h b/src/TransformationGUI/TransformationGUI_PositionDlg.h new file mode 100644 index 000000000..cda05c5d9 --- /dev/null +++ b/src/TransformationGUI/TransformationGUI_PositionDlg.h @@ -0,0 +1,81 @@ +// 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 : TransformationGUI_PositionDlg.h +// Author : Lucien PIGNOLONI +// Module : GEOM +// $Header$ + +#ifndef DIALOGBOX_POSITION_H +#define DIALOGBOX_POSITION_H + +#include "GEOMBase_Skeleton.h" +#include "DlgRef_3Sel3Spin1Check.h" + +#include "TransformationGUI.h" + + +//================================================================================= +// class : TransformationGUI_PositionDlg +// purpose : +//================================================================================= +class TransformationGUI_PositionDlg : public GEOMBase_Skeleton +{ + Q_OBJECT + +public: + TransformationGUI_PositionDlg(QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + ~TransformationGUI_PositionDlg(); + +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& ); + virtual bool execute( ObjectList& objects ); + + virtual void closeEvent( QCloseEvent* e ); + +private : + void Init(); + void enterEvent(QEvent* e); + + GEOM::GEOM_Object_var myStartLCS; + GEOM::GEOM_Object_var myEndLCS; + GEOM::ListOfGO myObjects; + + DlgRef_3Sel3Spin1Check* Group1; + +private slots : + void ClickOnOk(); + bool ClickOnApply(); + void ClickOnCancel(); + void ActivateThisDialog(); + void DeactivateActiveDialog(); + void LineEditReturnPressed(); + void SelectionIntoArgument(); + void SetEditCurrentArgument(); + void ConstructorsClicked(int constructorId); + void CreateCopyModeChanged(bool isCreateCopy); +}; + +#endif // DIALOGBOX_MIRROR_H diff --git a/src/TransformationGUI/TransformationGUI_RotationDlg.cxx b/src/TransformationGUI/TransformationGUI_RotationDlg.cxx index 6d61325c3..66fde50d0 100644 --- a/src/TransformationGUI/TransformationGUI_RotationDlg.cxx +++ b/src/TransformationGUI/TransformationGUI_RotationDlg.cxx @@ -27,10 +27,13 @@ // $Header$ #include "TransformationGUI_RotationDlg.h" +#include -#include -#include -#include +#include "QAD_Desktop.h" + +#include "GEOMImpl_Types.hxx" + +#include #include "utilities.h" @@ -43,7 +46,7 @@ using namespace std; // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -TransformationGUI_RotationDlg::TransformationGUI_RotationDlg(QWidget* parent, const char* name, TransformationGUI* theTransformationGUI, SALOME_Selection* Sel, bool modal, WFlags fl) +TransformationGUI_RotationDlg::TransformationGUI_RotationDlg(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_ROTATION"))); @@ -57,20 +60,46 @@ TransformationGUI_RotationDlg::TransformationGUI_RotationDlg(QWidget* parent, c RadioButton2->close(TRUE); RadioButton3->close(TRUE); - GroupPoints = new DlgRef_2Sel1Spin1Check(this, "GroupPoints"); + GroupPoints = new DlgRef_2Sel1Spin2Check(this, "GroupPoints"); GroupPoints->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); - GroupPoints->TextLabel1->setText(tr("GEOM_OBJECT")); + GroupPoints->TextLabel1->setText(tr("GEOM_OBJECTS")); GroupPoints->TextLabel2->setText(tr("GEOM_AXIS")); GroupPoints->TextLabel3->setText(tr("GEOM_ANGLE")); - GroupPoints->CheckButton1->setText(tr("GEOM_REVERSE")); + GroupPoints->LineEdit1->setReadOnly(true); + GroupPoints->LineEdit2->setReadOnly(true); GroupPoints->PushButton1->setPixmap(image1); GroupPoints->PushButton2->setPixmap(image1); + GroupPoints->CheckButton1->setText(tr("GEOM_CREATE_COPY")); + GroupPoints->CheckButton2->setText(tr("GEOM_REVERSE")); - Layout1->addWidget(GroupPoints, 1, 0); + Layout1->addWidget(GroupPoints, 2, 0); /***************************************************************/ + double anAngle = 0; + double SpecificStep = 5; + /* min, max, step and decimals for spin boxes & initial values */ + GroupPoints->SpinBox_DX->RangeStepAndValidator(-999.999, 999.999, SpecificStep, 3); + GroupPoints->SpinBox_DX->SetValue(anAngle); + + // Activate Create a Copy mode + GroupPoints->CheckButton1->setChecked(true); + CreateCopyModeChanged(true); + + /* signals and slots connections */ + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + + connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + + connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + + connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); + connect(GroupPoints->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(CreateCopyModeChanged(bool))); + connect(GroupPoints->CheckButton2, SIGNAL(toggled(bool)), this, SLOT(onReverse())); + + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ; - /* Initialisations */ - myTransformationGUI = theTransformationGUI; Init(); } @@ -93,37 +122,11 @@ void TransformationGUI_RotationDlg::Init() { /* init variables */ myEditCurrentArgument = GroupPoints->LineEdit1; - - myAngle = 0.0; - myOkBase = myOkAxis = false; - - myEdgeFilter = new GEOM_ShapeTypeFilter(TopAbs_EDGE, myGeom); - - double SpecificStep = 5; - /* min, max, step and decimals for spin boxes & initial values */ - GroupPoints->SpinBox_DX->RangeStepAndValidator(-999.999, 999.999, SpecificStep, 3); - GroupPoints->SpinBox_DX->SetValue(myAngle); - - /* signals and slots connections */ - connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); - connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); - - connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - - connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - - connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(GroupPoints->CheckButton1, SIGNAL(stateChanged(int)), this, SLOT(ReverseAngle(int))); + GroupPoints->LineEdit2->clear(); - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ; - - /* displays Dialog */ - GroupPoints->show(); - this->show(); - - return; + myAxis = GEOM::GEOM_Object::_nil(); + + initName( tr( "GEOM_ROTATION" ) ); } @@ -133,9 +136,8 @@ void TransformationGUI_RotationDlg::Init() //================================================================================= void TransformationGUI_RotationDlg::ClickOnOk() { - this->ClickOnApply(); - ClickOnCancel(); - return; + if ( ClickOnApply() ) + ClickOnCancel(); } @@ -143,18 +145,23 @@ void TransformationGUI_RotationDlg::ClickOnOk() // function : ClickOnApply() // purpose : //================================================================================= -void TransformationGUI_RotationDlg::ClickOnApply() +bool TransformationGUI_RotationDlg::ClickOnApply() { - buttonApply->setFocus(); - QAD_Application::getDesktop()->putInfo(tr("")); - if (mySimulationTopoDs.IsNull()) - return; - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); - - if(myOkBase && myOkAxis) - myTransformationGUI->MakeRotationAndDisplay(myGeomShape, myLoc, myDir, myAngle*PI180); - return; + if ( !onAccept( GroupPoints->CheckButton1->isChecked()) ) + return false; + + Init(); + return true; +} + + +//======================================================================= +// function : ClickOnCancel() +// purpose : +//======================================================================= +void TransformationGUI_RotationDlg::ClickOnCancel() +{ + GEOMBase_Skeleton::ClickOnCancel(); } @@ -164,46 +171,39 @@ void TransformationGUI_RotationDlg::ClickOnApply() //================================================================================= void TransformationGUI_RotationDlg::SelectionIntoArgument() { - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); myEditCurrentArgument->setText(""); - QString aString = ""; /* name of selection */ + QString aName; - int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString); - if(nbSel != 1) { - if(myEditCurrentArgument == GroupPoints->LineEdit1) - myOkBase = false; - else if(myEditCurrentArgument == GroupPoints->LineEdit2) - myOkAxis = false; - return; - } + if(myEditCurrentArgument == GroupPoints->LineEdit1) + { + int aNbSel = GEOMBase::GetNameOfSelectedIObjects(mySelection, aName); + if(aNbSel < 1) + { + myObjects.length(0); + return; + } + GEOMBase::ConvertListOfIOInListOfGO(mySelection->StoredIObjects(), myObjects); + if (!myObjects.length()) + return; + if(aNbSel != 1) + aName = tr("%1_objects").arg(aNbSel); + } + else if(myEditCurrentArgument == GroupPoints->LineEdit2) + { + if(mySelection->IObjectCount() != 1) + { + myAxis = GEOM::GEOM_Object::_nil(); + return; + } + Standard_Boolean testResult = Standard_False; + myAxis = GEOMBase::ConvertIOinGEOMObject(mySelection->firstIObject(), testResult ); + if(!testResult || CORBA::is_nil( myAxis )) + return; + aName = GEOMBase::GetName( myAxis ); + } + myEditCurrentArgument->setText( aName ); - // nbSel == 1 - TopoDS_Shape S; - Standard_Boolean testResult; - Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); - if(!myGeomBase->GetTopoFromSelection(mySelection, S)) - return; - - if(myEditCurrentArgument == GroupPoints->LineEdit1) { - myGeomShape = myGeomBase->ConvertIOinGEOMShape(IO, testResult); - if(!testResult) - return; - myEditCurrentArgument->setText(aString); - myOkBase = true; - myBase = S; - } - else if(myEditCurrentArgument == GroupPoints->LineEdit2) { - BRepAdaptor_Curve curv(TopoDS::Edge(S)); - myDir = curv.Line().Direction(); - myLoc = curv.Line().Location(); - myEditCurrentArgument->setText(aString); - myOkAxis = true; - } - - if(myOkBase && myOkAxis) - this->MakeRotationSimulationAndDisplay(); - return; + displayPreview(); } @@ -214,20 +214,18 @@ void TransformationGUI_RotationDlg::SelectionIntoArgument() void TransformationGUI_RotationDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); - mySelection->ClearFilters(); - + if(send == GroupPoints->PushButton1) { - GroupPoints->LineEdit1->setFocus(); myEditCurrentArgument = GroupPoints->LineEdit1; + globalSelection(); } else if(send == GroupPoints->PushButton2) { - GroupPoints->LineEdit2->setFocus(); myEditCurrentArgument = GroupPoints->LineEdit2; - mySelection->AddFilter(myEdgeFilter); + globalSelection( GEOM_LINE ); } - this->SelectionIntoArgument(); - - return; + + myEditCurrentArgument->setFocus(); + SelectionIntoArgument(); } @@ -238,15 +236,12 @@ void TransformationGUI_RotationDlg::SetEditCurrentArgument() void TransformationGUI_RotationDlg::LineEditReturnPressed() { QLineEdit* send = (QLineEdit*)sender(); - if(send == GroupPoints->LineEdit1) - myEditCurrentArgument = GroupPoints->LineEdit1; - else if (send == GroupPoints->LineEdit2) - myEditCurrentArgument = GroupPoints->LineEdit2; - else - return; - - GEOMBase_Skeleton::LineEditReturnPressed(); - return; + if(send == GroupPoints->LineEdit1 || + send == GroupPoints->LineEdit2) + { + myEditCurrentArgument = send; + GEOMBase_Skeleton::LineEditReturnPressed(); + } } @@ -258,11 +253,21 @@ void TransformationGUI_RotationDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + globalSelection(); GroupPoints->LineEdit1->setFocus(); myEditCurrentArgument = GroupPoints->LineEdit1; - if(!mySimulationTopoDs.IsNull()) - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - return; + GroupPoints->LineEdit2->clear(); + myAxis = GEOM::GEOM_Object::_nil(); +} + + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : public slot to deactivate if active +//================================================================================= +void TransformationGUI_RotationDlg::DeactivateActiveDialog() +{ + GEOMBase_Skeleton::DeactivateActiveDialog(); } @@ -272,10 +277,8 @@ void TransformationGUI_RotationDlg::ActivateThisDialog() //================================================================================= void TransformationGUI_RotationDlg::enterEvent(QEvent* e) { - if (GroupConstructors->isEnabled()) - return; - this->ActivateThisDialog(); - return; + if (!GroupConstructors->isEnabled()) + ActivateThisDialog(); } @@ -283,49 +286,98 @@ void TransformationGUI_RotationDlg::enterEvent(QEvent* e) // function : ValueChangedInSpinBox() // purpose : //================================================================================= -void TransformationGUI_RotationDlg::ValueChangedInSpinBox(double newValue) +void TransformationGUI_RotationDlg::ValueChangedInSpinBox() { - myAngle = newValue; - if(myOkBase && myOkAxis) - MakeRotationSimulationAndDisplay(); - return; + displayPreview(); } //================================================================================= -// function : MakeRotationSimulationAndDisplay() +// function : createOperation // purpose : //================================================================================= -void TransformationGUI_RotationDlg::MakeRotationSimulationAndDisplay() +GEOM::GEOM_IOperations_ptr TransformationGUI_RotationDlg::createOperation() { - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); - - try { - gp_Ax1 AX(myLoc, myDir); - gp_Trsf theTransformation; - theTransformation.SetRotation(AX, myAngle*PI180); - BRepBuilderAPI_Transform myBRepTransformation(myBase, theTransformation, Standard_False); - this->mySimulationTopoDs = myBRepTransformation.Shape(); - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - } - catch(Standard_Failure) { - MESSAGE("Exception catched in MakeRotationSimulationAndDisplay"); - return; - } - return; + return getGeomEngine()->GetITransformOperations( getStudyId() ); } //================================================================================= -// function : ReverseAngle() -// purpose : 'state' not used here +// function : isValid +// purpose : +//================================================================================= +bool TransformationGUI_RotationDlg::isValid( QString& msg ) +{ + return !(myObjects.length() == 0 || myAxis->_is_nil()); +} + + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool TransformationGUI_RotationDlg::execute( ObjectList& objects ) +{ + bool res = false; + + GEOM::GEOM_Object_var anObj; + + if (GroupPoints->CheckButton1->isChecked() || IsPreview()) + for (int i = 0; i < myObjects.length(); i++) + { + anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->RotateCopy( myObjects[i], myAxis, GetAngle() * PI180 ); + if ( !anObj->_is_nil() ) + objects.push_back( anObj._retn() ); + } + else + for (int i = 0; i < myObjects.length(); i++) + { + anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->Rotate( myObjects[i], myAxis, GetAngle() * PI180 ); + if ( !anObj->_is_nil() ) + objects.push_back( anObj._retn() ); + } + res = true; + + return res; +} + + +//================================================================================= +// function : closeEvent +// purpose : +//================================================================================= +void TransformationGUI_RotationDlg::closeEvent( QCloseEvent* e ) +{ + GEOMBase_Skeleton::closeEvent( e ); +} + + +//================================================================================= +// function : GetAngle() +// purpose : +//================================================================================= +double TransformationGUI_RotationDlg::GetAngle() const +{ + return GroupPoints->SpinBox_DX->GetValue(); +} + + +//================================================================================= +// function : CreateCopyModeChanged() +// purpose : +//================================================================================= +void TransformationGUI_RotationDlg::CreateCopyModeChanged(bool isCreateCopy) +{ + this->GroupBoxName->setEnabled(isCreateCopy); +} + + +//================================================================================= +// function : onReverse() +// purpose : //================================================================================= -void TransformationGUI_RotationDlg::ReverseAngle(int state) +void TransformationGUI_RotationDlg::onReverse() { - myAngle = -myAngle; - GroupPoints->SpinBox_DX->SetValue(myAngle); - if(myOkBase && myOkAxis) - MakeRotationSimulationAndDisplay(); - return; + double anOldValue = GroupPoints->SpinBox_DX->GetValue(); + GroupPoints->SpinBox_DX->SetValue( -anOldValue ); } diff --git a/src/TransformationGUI/TransformationGUI_RotationDlg.h b/src/TransformationGUI/TransformationGUI_RotationDlg.h index c0cda42cc..ab3dc222e 100644 --- a/src/TransformationGUI/TransformationGUI_RotationDlg.h +++ b/src/TransformationGUI/TransformationGUI_RotationDlg.h @@ -30,13 +30,8 @@ #define DIALOGBOX_ROTATION_H #include "GEOMBase_Skeleton.h" -#include "DlgRef_2Sel1Spin1Check.h" - -#include "TransformationGUI.h" - -#include "GEOM_ShapeTypeFilter.hxx" -#include - +#include "DlgRef_2Sel1Spin2Check.h" + //================================================================================= // class : TransformationGUI_RotationDlg // purpose : @@ -46,38 +41,39 @@ class TransformationGUI_RotationDlg : public GEOMBase_Skeleton Q_OBJECT public: - TransformationGUI_RotationDlg(QWidget* parent = 0, const char* name = 0, TransformationGUI* theTransformationGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + TransformationGUI_RotationDlg(QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); ~TransformationGUI_RotationDlg(); +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& ); + virtual bool execute( ObjectList& objects ); + + virtual void closeEvent( QCloseEvent* e ); + private : void Init(); void enterEvent(QEvent* e); - void MakeRotationSimulationAndDisplay(); + double GetAngle() const; - TransformationGUI* myTransformationGUI; - - Handle(GEOM_ShapeTypeFilter) myEdgeFilter; /* Filters selection */ - - TopoDS_Shape myBase; - GEOM::GEOM_Shape_var myGeomShape; /* is myBase */ - gp_Pnt myLoc; - gp_Dir myDir; - Standard_Real myAngle; - bool myOkBase; - bool myOkAxis; - - DlgRef_2Sel1Spin1Check* GroupPoints; + GEOM::ListOfGO myObjects; + GEOM::GEOM_Object_var myAxis; + + DlgRef_2Sel1Spin2Check* GroupPoints; private slots: void ClickOnOk(); - void ClickOnApply(); + bool ClickOnApply(); + void ClickOnCancel(); void ActivateThisDialog(); + void DeactivateActiveDialog(); void LineEditReturnPressed(); void SelectionIntoArgument(); void SetEditCurrentArgument(); - void ReverseAngle(int state); - void ValueChangedInSpinBox(double newValue); - + void ValueChangedInSpinBox(); + void CreateCopyModeChanged(bool isCreateCopy); + void onReverse(); }; #endif // DIALOGBOX_ROTATION_H diff --git a/src/TransformationGUI/TransformationGUI_ScaleDlg.cxx b/src/TransformationGUI/TransformationGUI_ScaleDlg.cxx index 96b875d8b..bcfec2b55 100644 --- a/src/TransformationGUI/TransformationGUI_ScaleDlg.cxx +++ b/src/TransformationGUI/TransformationGUI_ScaleDlg.cxx @@ -28,7 +28,11 @@ #include "TransformationGUI_ScaleDlg.h" -#include +#include "QAD_Desktop.h" + +#include "GEOMImpl_Types.hxx" + +#include #include "utilities.h" @@ -41,7 +45,7 @@ using namespace std; // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -TransformationGUI_ScaleDlg::TransformationGUI_ScaleDlg(QWidget* parent, const char* name, TransformationGUI* theTransformationGUI, SALOME_Selection* Sel, bool modal, WFlags fl) +TransformationGUI_ScaleDlg::TransformationGUI_ScaleDlg(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_SCALE"))); @@ -55,19 +59,49 @@ TransformationGUI_ScaleDlg::TransformationGUI_ScaleDlg(QWidget* parent, const ch RadioButton2->close(TRUE); RadioButton3->close(TRUE); - GroupPoints = new DlgRef_2Sel1Spin(this, "GroupPoints"); + GroupPoints = new DlgRef_2Sel1Spin2Check(this, "GroupPoints"); + GroupPoints->CheckButton2->hide(); GroupPoints->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); - GroupPoints->TextLabel1->setText(tr("GEOM_OBJECT")); + GroupPoints->TextLabel1->setText(tr("GEOM_OBJECTS")); GroupPoints->TextLabel2->setText(tr("GEOM_CENTRAL_POINT")); GroupPoints->TextLabel3->setText(tr("GEOM_SCALE_FACTOR")); + GroupPoints->LineEdit1->setReadOnly( true ); + GroupPoints->LineEdit2->setReadOnly( true ); GroupPoints->PushButton1->setPixmap(image1); GroupPoints->PushButton2->setPixmap(image1); + GroupPoints->CheckButton1->setText(tr("GEOM_CREATE_COPY")); - Layout1->addWidget(GroupPoints, 1, 0); + // san -- modification of an exisitng object by offset is not allowed + GroupPoints->CheckButton1->hide(); + + Layout1->addWidget(GroupPoints, 2, 0); /***************************************************************/ + double aFactor = 2.0; + double SpecificStep = 0.5; + /* min, max, step and decimals for spin boxes & initial values */ + GroupPoints->SpinBox_DX->RangeStepAndValidator(-999.999, 999.999, SpecificStep, 3); + GroupPoints->SpinBox_DX->SetValue(aFactor); + + // Activate Create a Copy mode + GroupPoints->CheckButton1->setChecked(true); + CreateCopyModeChanged(true); + + /* signals and slots connections */ + connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + + connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + + connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + + connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox_DX, SLOT(SetStep(double))); + connect(GroupPoints->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(CreateCopyModeChanged(bool))); + + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ; - /* Initialisations */ - myTransformationGUI = theTransformationGUI; Init(); } @@ -88,40 +122,12 @@ TransformationGUI_ScaleDlg::~TransformationGUI_ScaleDlg() //================================================================================= void TransformationGUI_ScaleDlg::Init() { - /* init variables */ myEditCurrentArgument = GroupPoints->LineEdit1; - - myPoint1.SetCoord(0.0, 0.0, 0.0); - myOkPoint1 = myOkBaseTopo = false; - myFactor = 2.0; - - myVertexFilter = new GEOM_ShapeTypeFilter(TopAbs_VERTEX, myGeom); - - double SpecificStep = 0.5; - /* min, max, step and decimals for spin boxes & initial values */ - GroupPoints->SpinBox_DX->RangeStepAndValidator(-999.999, 999.999, SpecificStep, 3); - GroupPoints->SpinBox_DX->SetValue(myFactor); - - /* signals and slots connections */ - connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); - connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); - - connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - - connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - - connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox_DX, SLOT(SetStep(double))); + GroupPoints->LineEdit2->clear(); - connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ; - - /* displays Dialog */ - GroupPoints->show(); - this->show(); - - return; + myPoint = GEOM::GEOM_Object::_nil(); + + initName( tr( "GEOM_SCALE" ) ); } @@ -131,9 +137,8 @@ void TransformationGUI_ScaleDlg::Init() //================================================================================= void TransformationGUI_ScaleDlg::ClickOnOk() { - this->ClickOnApply(); - ClickOnCancel(); - return; + if ( ClickOnApply() ) + ClickOnCancel(); } @@ -141,18 +146,23 @@ void TransformationGUI_ScaleDlg::ClickOnOk() // function : ClickOnApply() // purpose : //================================================================================= -void TransformationGUI_ScaleDlg::ClickOnApply() +bool TransformationGUI_ScaleDlg::ClickOnApply() { - buttonApply->setFocus(); - QAD_Application::getDesktop()->putInfo(tr("")); - if (mySimulationTopoDs.IsNull()) - return; - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); - - if(myOkBaseTopo && myOkPoint1) - myTransformationGUI->MakeScaleAndDisplay(myGeomShape, myPoint1, myFactor); - return; + if ( !onAccept(GroupPoints->CheckButton1->isChecked()) ) + return false; + + Init(); + return true; +} + + +//======================================================================= +// function : ClickOnCancel() +// purpose : +//======================================================================= +void TransformationGUI_ScaleDlg::ClickOnCancel() +{ + GEOMBase_Skeleton::ClickOnCancel(); } @@ -162,44 +172,39 @@ void TransformationGUI_ScaleDlg::ClickOnApply() //================================================================================= void TransformationGUI_ScaleDlg::SelectionIntoArgument() { - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); myEditCurrentArgument->setText(""); - QString aString = ""; /* name of selection */ + QString aName; + + if(myEditCurrentArgument == GroupPoints->LineEdit1) + { + int aNbSel = GEOMBase::GetNameOfSelectedIObjects(mySelection, aName); + if(aNbSel < 1) + { + myObjects.length(0); + return; + } + GEOMBase::ConvertListOfIOInListOfGO(mySelection->StoredIObjects(), myObjects); + if (!myObjects.length()) + return; + if(aNbSel != 1) + aName = tr("%1_objects").arg(aNbSel); + } + else if(myEditCurrentArgument == GroupPoints->LineEdit2) + { + if(mySelection->IObjectCount() != 1) + { + myPoint = GEOM::GEOM_Object::_nil(); + return; + } + Standard_Boolean testResult = Standard_False; + myPoint = GEOMBase::ConvertIOinGEOMObject(mySelection->firstIObject(), testResult ); + if(!testResult || CORBA::is_nil( myPoint )) + return; + aName = GEOMBase::GetName( myPoint ); + } + myEditCurrentArgument->setText( aName ); - int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString); - if (nbSel != 1) { - if(myEditCurrentArgument == GroupPoints->LineEdit1) - myOkBaseTopo = false; - else if (myEditCurrentArgument == GroupPoints->LineEdit2) - myOkPoint1 = false; - return; - } - - /* nbSel == 1 */ - TopoDS_Shape S; - Standard_Boolean testResult; - Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); - if(!myGeomBase->GetTopoFromSelection(mySelection, S)) - return; - - /* gp_Pnt : not used */ - if(myEditCurrentArgument == GroupPoints->LineEdit1) { - myGeomShape = myGeomBase->ConvertIOinGEOMShape(IO, testResult); - if(!testResult) - return ; - GroupPoints->LineEdit1->setText(aString); - myBaseTopo = S; - myOkBaseTopo = true; - } - else if(myEditCurrentArgument == GroupPoints->LineEdit2 && myGeomBase->VertexToPoint(S, myPoint1)) { - GroupPoints->LineEdit2->setText(aString); - myOkPoint1 = true; - } - - if(myOkPoint1 && myOkBaseTopo) - this->MakeScaleSimulationAndDisplay(); - return; + displayPreview(); } @@ -210,15 +215,12 @@ void TransformationGUI_ScaleDlg::SelectionIntoArgument() void TransformationGUI_ScaleDlg::LineEditReturnPressed() { QLineEdit* send = (QLineEdit*)sender(); - if(send == GroupPoints->LineEdit1) - myEditCurrentArgument = GroupPoints->LineEdit1; - else if (send == GroupPoints->LineEdit2) - myEditCurrentArgument = GroupPoints->LineEdit2; - else - return; - - GEOMBase_Skeleton::LineEditReturnPressed(); - return; + if(send == GroupPoints->LineEdit1 || + send == GroupPoints->LineEdit2) + { + myEditCurrentArgument = send; + GEOMBase_Skeleton::LineEditReturnPressed(); + } } @@ -229,20 +231,18 @@ void TransformationGUI_ScaleDlg::LineEditReturnPressed() void TransformationGUI_ScaleDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); - mySelection->ClearFilters(); - + if(send == GroupPoints->PushButton1) { - GroupPoints->LineEdit1->setFocus(); myEditCurrentArgument = GroupPoints->LineEdit1; + globalSelection(); } else if(send == GroupPoints->PushButton2) { - GroupPoints->LineEdit2->setFocus(); myEditCurrentArgument = GroupPoints->LineEdit2; - mySelection->AddFilter(myVertexFilter); + globalSelection( GEOM_POINT ); } - this->SelectionIntoArgument(); - - return; + + myEditCurrentArgument->setFocus(); + SelectionIntoArgument(); } @@ -254,11 +254,19 @@ void TransformationGUI_ScaleDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + globalSelection(); GroupPoints->LineEdit1->setFocus(); myEditCurrentArgument = GroupPoints->LineEdit1; - if(!mySimulationTopoDs.IsNull()) - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - return; +} + + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : public slot to deactivate if active +//================================================================================= +void TransformationGUI_ScaleDlg::DeactivateActiveDialog() +{ + GEOMBase_Skeleton::DeactivateActiveDialog(); } @@ -268,10 +276,8 @@ void TransformationGUI_ScaleDlg::ActivateThisDialog() //================================================================================= void TransformationGUI_ScaleDlg::enterEvent(QEvent* e) { - if(GroupConstructors->isEnabled()) - return; - this->ActivateThisDialog(); - return; + if( !GroupConstructors->isEnabled() ) + ActivateThisDialog(); } @@ -279,37 +285,86 @@ void TransformationGUI_ScaleDlg::enterEvent(QEvent* e) // function : ValueChangedInSpinBox() // purpose : //================================================================================= -void TransformationGUI_ScaleDlg::ValueChangedInSpinBox(double newValue) +void TransformationGUI_ScaleDlg::ValueChangedInSpinBox() +{ + displayPreview(); +} + + +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr TransformationGUI_ScaleDlg::createOperation() +{ + return getGeomEngine()->GetITransformOperations( getStudyId() ); +} + +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool TransformationGUI_ScaleDlg::isValid( QString& msg ) { - myFactor = newValue; - if(fabs(myFactor) > 0.00001 && myOkPoint1 && myOkBaseTopo) - MakeScaleSimulationAndDisplay(); - return; + return !(myObjects.length() == 0 || myPoint->_is_nil() || fabs(GetFactor()) <= 0.00001); } //================================================================================= -// function : MakeScaleSimulationAndDisplay() +// function : execute // purpose : //================================================================================= -void TransformationGUI_ScaleDlg::MakeScaleSimulationAndDisplay() +bool TransformationGUI_ScaleDlg::execute( ObjectList& objects ) { - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); + bool res = false; - try { - gp_Trsf theTransformation; - theTransformation.SetScale(myPoint1, myFactor); - BRepBuilderAPI_Transform myBRepTransformation(myBaseTopo, theTransformation, Standard_False); - mySimulationTopoDs = myBRepTransformation.Shape(); - if(mySimulationTopoDs.IsNull()) - return; - else - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - } - catch(Standard_Failure) { - MESSAGE("Exception catched in MakeScaleSimulationAndDisplay"); - return; - } - return; + GEOM::GEOM_Object_var anObj; + + if (GroupPoints->CheckButton1->isChecked() || IsPreview()) + for (int i = 0; i < myObjects.length(); i++) + { + anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->ScaleShapeCopy( myObjects[i], myPoint, GetFactor() ); + if ( !anObj->_is_nil() ) + objects.push_back( anObj._retn() ); + } + else + for (int i = 0; i < myObjects.length(); i++) + { + anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->ScaleShape( myObjects[i], myPoint, GetFactor() ); + if ( !anObj->_is_nil() ) + objects.push_back( anObj._retn() ); + } + res = true; + + return res; +} + + +//================================================================================= +// function : closeEvent +// purpose : +//================================================================================= +void TransformationGUI_ScaleDlg::closeEvent( QCloseEvent* e ) +{ + GEOMBase_Skeleton::closeEvent( e ); +} + + +//================================================================================= +// function : GetFactor() +// purpose : +//================================================================================= +double TransformationGUI_ScaleDlg::GetFactor() const +{ + return GroupPoints->SpinBox_DX->GetValue(); +} + + +//================================================================================= +// function : CreateCopyModeChanged() +// purpose : +//================================================================================= +void TransformationGUI_ScaleDlg::CreateCopyModeChanged(bool isCreateCopy) +{ + this->GroupBoxName->setEnabled(isCreateCopy); } diff --git a/src/TransformationGUI/TransformationGUI_ScaleDlg.h b/src/TransformationGUI/TransformationGUI_ScaleDlg.h index bb7c59c51..b2894a805 100644 --- a/src/TransformationGUI/TransformationGUI_ScaleDlg.h +++ b/src/TransformationGUI/TransformationGUI_ScaleDlg.h @@ -30,12 +30,9 @@ #define DIALOGBOX_SCALE_H #include "GEOMBase_Skeleton.h" -#include "DlgRef_2Sel1Spin.h" - -#include "TransformationGUI.h" - -#include "GEOM_ShapeTypeFilter.hxx" - +#include "DlgRef_2Sel1Spin2Check.h" + + //================================================================================= // class : TransformationGUI_ScaleDlg // purpose : @@ -45,36 +42,38 @@ class TransformationGUI_ScaleDlg : public GEOMBase_Skeleton Q_OBJECT public: - TransformationGUI_ScaleDlg(QWidget* parent = 0, const char* name = 0, TransformationGUI* theTransformationGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + TransformationGUI_ScaleDlg(QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); ~TransformationGUI_ScaleDlg(); +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& ); + virtual bool execute( ObjectList& objects ); + + virtual void closeEvent( QCloseEvent* e ); + private : void Init(); void enterEvent(QEvent* e); - void MakeScaleSimulationAndDisplay(); - - TransformationGUI* myTransformationGUI; - - Handle(GEOM_ShapeTypeFilter) myVertexFilter; - - gp_Pnt myPoint1; /* Points containing the vector */ - bool myOkPoint1; /* true when myPoint1 is defined */ - TopoDS_Shape myBaseTopo; - bool myOkBaseTopo; /* true when myBaseTopo is defined */ - GEOM::GEOM_Shape_var myGeomShape; /* is myBaseTopo */ - Standard_Real myFactor; - - DlgRef_2Sel1Spin* GroupPoints; + double GetFactor() const; + + GEOM::ListOfGO myObjects; + GEOM::GEOM_Object_var myPoint; /* Central Point */ + + DlgRef_2Sel1Spin2Check* GroupPoints; private slots : void ClickOnOk(); - void ClickOnApply(); + bool ClickOnApply(); + void ClickOnCancel(); void ActivateThisDialog(); + void DeactivateActiveDialog(); void LineEditReturnPressed(); void SelectionIntoArgument(); void SetEditCurrentArgument(); - void ValueChangedInSpinBox(double newValue); - + void ValueChangedInSpinBox(); + void CreateCopyModeChanged(bool isCreateCopy); }; #endif // DIALOGBOX_SCALE_H diff --git a/src/TransformationGUI/TransformationGUI_TranslationDlg.cxx b/src/TransformationGUI/TransformationGUI_TranslationDlg.cxx index 59f6e60d1..0654d2ad4 100644 --- a/src/TransformationGUI/TransformationGUI_TranslationDlg.cxx +++ b/src/TransformationGUI/TransformationGUI_TranslationDlg.cxx @@ -28,8 +28,12 @@ #include "TransformationGUI_TranslationDlg.h" -#include #include "QAD_Config.h" +#include "QAD_Desktop.h" + +#include + +#include "GEOMImpl_Types.hxx" #include "utilities.h" @@ -42,33 +46,39 @@ using namespace std; // The dialog will by default be modeless, unless you set 'modal' to // TRUE to construct a modal dialog. //================================================================================= -TransformationGUI_TranslationDlg::TransformationGUI_TranslationDlg(QWidget* parent, const char* name, TransformationGUI* theTransformationGUI, SALOME_Selection* Sel, bool modal, WFlags fl) +TransformationGUI_TranslationDlg::TransformationGUI_TranslationDlg(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_TRANSLATION"))); - QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_TRANSLATION_DXYZ"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_TRANSLATION_POINTS"))); + QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_TRANSLATION_VECTOR"))); + QPixmap image3(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); setCaption(tr("GEOM_TRANSLATION_TITLE")); /***************************************************************/ GroupConstructors->setTitle(tr("GEOM_TRANSLATION")); RadioButton1->setPixmap(image0); - RadioButton2->close(TRUE); - RadioButton3->close(TRUE); + RadioButton2->setPixmap(image1); + RadioButton3->setPixmap(image2); - GroupPoints = new DlgRef_1Sel3Spin(this, "GroupPoints"); - GroupPoints->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); - GroupPoints->TextLabel1->setText(tr("GEOM_OBJECT")); - GroupPoints->TextLabel2->setText(tr("GEOM_DX")); - GroupPoints->TextLabel3->setText(tr("GEOM_DY")); - GroupPoints->TextLabel4->setText(tr("GEOM_DZ")); - GroupPoints->PushButton1->setPixmap(image1); + RadioButton1->setChecked(true); - Layout1->addWidget(GroupPoints, 1, 0); + GroupPoints = new DlgRef_3Sel3Spin1Check(this, "GroupPoints"); + GroupPoints->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); + GroupPoints->TextLabel1->setText(tr("GEOM_OBJECTS")); + GroupPoints->TextLabel3->setText(tr("GEOM_POINT_I").arg("2")); + GroupPoints->TextLabel4->setText(tr("GEOM_DX")); + GroupPoints->TextLabel5->setText(tr("GEOM_DY")); + GroupPoints->TextLabel6->setText(tr("GEOM_DZ")); + GroupPoints->PushButton1->setPixmap(image3); + GroupPoints->PushButton2->setPixmap(image3); + GroupPoints->PushButton3->setPixmap(image3); + GroupPoints->CheckBox1->setText(tr("GEOM_CREATE_COPY")); + + Layout1->addWidget(GroupPoints, 2, 0); /***************************************************************/ - - /* Initialisations */ - myTransformationGUI = theTransformationGUI; + Init(); } @@ -91,45 +101,102 @@ void TransformationGUI_TranslationDlg::Init() { /* init variables */ myEditCurrentArgument = GroupPoints->LineEdit1; - - myVec.SetCoord(0.0, 0.0, 0.0); - myOkBase = false; - + GroupPoints->LineEdit1->setReadOnly(true); + GroupPoints->LineEdit2->setReadOnly(true); + GroupPoints->LineEdit3->setReadOnly(true); + + myVector = myPoint1 = myPoint2 = GEOM::GEOM_Object::_nil(); + + // Activate Create a Copy mode + GroupPoints->CheckBox1->setChecked(true); + CreateCopyModeChanged(true); + /* Get setting of step value from file configuration */ QString St = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep"); - step = St.toDouble(); - + double step = St.toDouble(); + /* min, max, step and decimals for spin boxes & initial values */ - GroupPoints->SpinBox_DX->RangeStepAndValidator(-999.999, 999.999, step, 3); - GroupPoints->SpinBox_DY->RangeStepAndValidator(-999.999, 999.999, step, 3); - GroupPoints->SpinBox_DZ->RangeStepAndValidator(-999.999, 999.999, step, 3); - - GroupPoints->SpinBox_DX->SetValue(0.0); - GroupPoints->SpinBox_DY->SetValue(0.0); - GroupPoints->SpinBox_DZ->SetValue(0.0); - + GroupPoints->SpinBox1->RangeStepAndValidator(-999.999, 999.999, step, 3); + GroupPoints->SpinBox2->RangeStepAndValidator(-999.999, 999.999, step, 3); + GroupPoints->SpinBox3->RangeStepAndValidator(-999.999, 999.999, step, 3); + + GroupPoints->SpinBox1->SetValue(0.0); + GroupPoints->SpinBox2->SetValue(0.0); + GroupPoints->SpinBox3->SetValue(0.0); + /* signals and slots connections */ connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + connect(GroupConstructors, SIGNAL(clicked(int)), SLOT(ConstructorsClicked(int))); connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupPoints->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(GroupPoints->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(GroupPoints->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); // MZN: Delete ? - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox_DX, SLOT(SetStep(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox_DY, SLOT(SetStep(double))); - connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox_DZ, SLOT(SetStep(double))); + connect(GroupPoints->SpinBox1, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); + connect(GroupPoints->SpinBox2, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); + connect(GroupPoints->SpinBox3, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); + + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox1, SLOT(SetStep(double))); + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox2, SLOT(SetStep(double))); + connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox3, SLOT(SetStep(double))); + + connect(GroupPoints->CheckBox1, SIGNAL(toggled(bool)), this, SLOT(CreateCopyModeChanged(bool))); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ; - /* displays Dialog */ - GroupPoints->show(); - this->show(); + initName( tr( "GEOM_TRANSLATION" ) ); + ConstructorsClicked( 0 ); +} + - return; +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void TransformationGUI_TranslationDlg::ConstructorsClicked(int constructorId) +{ + disconnect( mySelection, 0, this, 0 ); + + myEditCurrentArgument = GroupPoints->LineEdit1; + globalSelection(); + + switch (constructorId) + { + case 0: /* translation an object by dx, dy, dz */ + { + GroupPoints->ShowRows(1,2,false); + resize(0,0); + GroupPoints->ShowRows(3,5,true); + break; + } + case 1: /* translation an object by 2 points */ + { + GroupPoints->ShowRows(3,5,false); + resize(0,0); + GroupPoints->ShowRows(0,2,true); + GroupPoints->TextLabel2->setText(tr("GEOM_POINT_I").arg("1")); + GroupPoints->LineEdit2->clear(); + GroupPoints->LineEdit3->clear(); + myPoint1 = myPoint2 = GEOM::GEOM_Object::_nil(); + break; + } + case 2: /* translation an object by vector */ + { + GroupPoints->ShowRows(2,5,false); + resize(0,0); + GroupPoints->ShowRows(0,1,true); + GroupPoints->TextLabel2->setText(tr("GEOM_VECTOR")); + GroupPoints->LineEdit2->clear(); + myVector = GEOM::GEOM_Object::_nil(); + break; + } + } + + myEditCurrentArgument->setFocus(); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); } @@ -139,9 +206,8 @@ void TransformationGUI_TranslationDlg::Init() //================================================================================= void TransformationGUI_TranslationDlg::ClickOnOk() { - this->ClickOnApply(); - ClickOnCancel(); - return; + if ( ClickOnApply() ) + ClickOnCancel(); } @@ -149,18 +215,24 @@ void TransformationGUI_TranslationDlg::ClickOnOk() // function : ClickOnApply() // purpose : //================================================================================= -void TransformationGUI_TranslationDlg::ClickOnApply() +bool TransformationGUI_TranslationDlg::ClickOnApply() { - buttonApply->setFocus(); - QAD_Application::getDesktop()->putInfo(tr("")); - if (mySimulationTopoDs.IsNull()) - return; - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); - - if(myOkBase) - myTransformationGUI->MakeTranslationAndDisplay(myGeomShape, myVec); - return; + if ( !onAccept(GroupPoints->CheckBox1->isChecked()) ) + return false; + + initName(); + ConstructorsClicked( getConstructorId() ); + return true; +} + + +//======================================================================= +// function : ClickOnCancel() +// purpose : +//======================================================================= +void TransformationGUI_TranslationDlg::ClickOnCancel() +{ + GEOMBase_Skeleton::ClickOnCancel(); } @@ -170,73 +242,99 @@ void TransformationGUI_TranslationDlg::ClickOnApply() //================================================================================= void TransformationGUI_TranslationDlg::SelectionIntoArgument() { - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); myEditCurrentArgument->setText(""); - QString aString = ""; /* name of selection */ + QString aName; + + if(myEditCurrentArgument == GroupPoints->LineEdit1) + { + int aNbSel = GEOMBase::GetNameOfSelectedIObjects(mySelection, aName); + if(aNbSel < 1) + { + myObjects.length(0); + return; + } + GEOMBase::ConvertListOfIOInListOfGO(mySelection->StoredIObjects(), myObjects); + if (!myObjects.length()) + return; + if(aNbSel != 1) + aName = tr("%1_objects").arg(aNbSel); + } + else + { + if (mySelection->IObjectCount() != 1) { + if(myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 1) + myPoint1 = GEOM::GEOM_Object::_nil(); + else if(myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 2) + myVector = GEOM::GEOM_Object::_nil(); + else if(myEditCurrentArgument == GroupPoints->LineEdit3) + myPoint2 = GEOM::GEOM_Object::_nil(); + return; + } + + Standard_Boolean testResult = Standard_False;; + GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(mySelection->firstIObject(), testResult ); + + if (!testResult || CORBA::is_nil( aSelectedObject )) + return; + + if(myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 1) + myPoint1 = aSelectedObject; + else if(myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 2) + myVector = aSelectedObject; + else if(myEditCurrentArgument == GroupPoints->LineEdit3) + myPoint2 = aSelectedObject; + + aName = GEOMBase::GetName( aSelectedObject ); + } + + myEditCurrentArgument->setText( aName ); - int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString); - if (nbSel != 1) { - if(myEditCurrentArgument == GroupPoints->LineEdit1) - myOkBase = false; - return; - } - - /* nbSel == 1 */ - TopoDS_Shape S; - Standard_Boolean testResult; - Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); - if(!myGeomBase->GetTopoFromSelection(mySelection, S)) - return; - - /* gp_Pnt : not used */ - if(myEditCurrentArgument == GroupPoints->LineEdit1) { - myGeomShape = myGeomBase->ConvertIOinGEOMShape(IO, testResult); - if(!testResult) - return ; - GroupPoints->LineEdit1->setText(aString); - myBase = S; - myOkBase = true; - } - - if(myOkBase) - this->MakeTranslationSimulationAndDisplay(); - return; + displayPreview(); } //================================================================================= -// function : SetEditCurrentArgument() +// function : LineEditReturnPressed() // purpose : //================================================================================= void TransformationGUI_TranslationDlg::LineEditReturnPressed() { QLineEdit* send = (QLineEdit*)sender(); if(send == GroupPoints->LineEdit1) - myEditCurrentArgument = GroupPoints->LineEdit1; - else - return; - - GEOMBase_Skeleton::LineEditReturnPressed(); - return; + { + myEditCurrentArgument = send; + GEOMBase_Skeleton::LineEditReturnPressed(); + } } //================================================================================= -// function : LineEditReturnPressed() +// function : SetEditCurrentArgument() // purpose : //================================================================================= void TransformationGUI_TranslationDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); - - if(send == GroupPoints->PushButton1) { - GroupPoints->LineEdit1->setFocus(); - myEditCurrentArgument = GroupPoints->LineEdit1; - this->SelectionIntoArgument(); - } - - return; + + if(send == GroupPoints->PushButton1) + { + myEditCurrentArgument = GroupPoints->LineEdit1; + globalSelection(); + } + else if (send == GroupPoints->PushButton2) + { + myEditCurrentArgument = GroupPoints->LineEdit2; + getConstructorId() == 1 ? globalSelection( GEOM_POINT ) : + globalSelection( GEOM_LINE ); + } + else if (send == GroupPoints->PushButton3) + { + myEditCurrentArgument = GroupPoints->LineEdit3; + globalSelection( GEOM_POINT ); + } + + myEditCurrentArgument->setFocus(); + SelectionIntoArgument(); } @@ -248,9 +346,18 @@ void TransformationGUI_TranslationDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - if(!mySimulationTopoDs.IsNull()) - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - return; + + ConstructorsClicked( getConstructorId() ); +} + + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : public slot to deactivate if active +//================================================================================= +void TransformationGUI_TranslationDlg::DeactivateActiveDialog() +{ + GEOMBase_Skeleton::DeactivateActiveDialog(); } @@ -260,10 +367,8 @@ void TransformationGUI_TranslationDlg::ActivateThisDialog() //================================================================================= void TransformationGUI_TranslationDlg::enterEvent(QEvent* e) { - if(GroupConstructors->isEnabled()) - return; - this->ActivateThisDialog(); - return; + if(!GroupConstructors->isEnabled()) + ActivateThisDialog(); } @@ -271,56 +376,147 @@ void TransformationGUI_TranslationDlg::enterEvent(QEvent* e) // function : ValueChangedInSpinBox() // purpose : //================================================================================= -void TransformationGUI_TranslationDlg::ValueChangedInSpinBox(double newValue) +void TransformationGUI_TranslationDlg::ValueChangedInSpinBox() +{ + displayPreview(); +} + + +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr TransformationGUI_TranslationDlg::createOperation() { - QObject* send = (QObject*)sender(); - Standard_Real Dx, Dy, Dz; - - if(send == GroupPoints->SpinBox_DX) { - Dx = newValue; - Dy = GroupPoints->SpinBox_DY->GetValue(); - Dz = GroupPoints->SpinBox_DZ->GetValue(); - } - else if(send == GroupPoints->SpinBox_DY) { - Dx = GroupPoints->SpinBox_DX->GetValue(); - Dy = newValue; - Dz = GroupPoints->SpinBox_DZ->GetValue(); - } - else if(send == GroupPoints->SpinBox_DZ) { - Dx = GroupPoints->SpinBox_DX->GetValue(); - Dy = GroupPoints->SpinBox_DY->GetValue(); - Dz = newValue; - } - - myVec.SetCoord(Dx, Dy, Dz); - if(myOkBase) - MakeTranslationSimulationAndDisplay(); - return; + return getGeomEngine()->GetITransformOperations( getStudyId() ); } //================================================================================= -// function : MakeTranslationSimulationAndDisplay() +// function : isValid // purpose : //================================================================================= -void TransformationGUI_TranslationDlg::MakeTranslationSimulationAndDisplay() +bool TransformationGUI_TranslationDlg::isValid( QString& msg ) { - myGeomBase->EraseSimulationShape(); - mySimulationTopoDs.Nullify(); + int aConstructorId = getConstructorId(); - try { - gp_Trsf theTransformation; - theTransformation.SetTranslation(myVec); - BRepBuilderAPI_Transform myBRepTransformation(myBase, theTransformation, Standard_False); - mySimulationTopoDs = myBRepTransformation.Shape(); - if(mySimulationTopoDs.IsNull()) - return; - else - myGeomBase->DisplaySimulationShape(mySimulationTopoDs); - } - catch(Standard_Failure) { - MESSAGE("Exception catched in MakeTranslationSimulationAndDisplay"); - return; - } - return; + switch (aConstructorId) + { + case 0: + { + return !(myObjects.length() == 0 ); + break; + } + case 1: + { + return !(myObjects.length() == 0 || myPoint1->_is_nil() || myPoint2->_is_nil() ); + break; + } + case 2: + { + return !(myObjects.length() == 0 || myVector->_is_nil()); + break; + } + default: return false; + } +} + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool TransformationGUI_TranslationDlg::execute( ObjectList& objects ) +{ + bool res = false; + bool toCreateCopy = IsPreview() || GroupPoints->CheckBox1->isChecked(); + + GEOM::GEOM_Object_var anObj; + + switch ( getConstructorId() ) + { + case 0 : + { + double dx = GroupPoints->SpinBox1->GetValue(); + double dy = GroupPoints->SpinBox2->GetValue(); + double dz = GroupPoints->SpinBox3->GetValue(); + + if (toCreateCopy) + for (int i = 0; i < myObjects.length(); i++) + { + anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->TranslateDXDYDZCopy( myObjects[i], dx, dy, dz ); + if ( !anObj->_is_nil() ) + objects.push_back( anObj._retn() ); + } + else + for (int i = 0; i < myObjects.length(); i++) + { + anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->TranslateDXDYDZ( myObjects[i], dx, dy, dz ); + if ( !anObj->_is_nil() ) + objects.push_back( anObj._retn() ); + } + res = true; + break; + } + case 1 : + { + if (toCreateCopy) + for (int i = 0; i < myObjects.length(); i++) + { + anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->TranslateTwoPointsCopy( myObjects[i], myPoint1, myPoint2 ); + if ( !anObj->_is_nil() ) + objects.push_back( anObj._retn() ); + } + else + for (int i = 0; i < myObjects.length(); i++) + { + anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->TranslateTwoPoints( myObjects[i], myPoint1, myPoint2 ); + if ( !anObj->_is_nil() ) + objects.push_back( anObj._retn() ); + } + res = true; + break; + } + case 2: + { + if (toCreateCopy) + for (int i = 0; i < myObjects.length(); i++) + { + anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->TranslateVectorCopy( myObjects[i], myVector ); + if ( !anObj->_is_nil() ) + objects.push_back( anObj._retn() ); + } + else + for (int i = 0; i < myObjects.length(); i++) + { + anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->TranslateVector( myObjects[i], myVector ); + if ( !anObj->_is_nil() ) + objects.push_back( anObj._retn() ); + } + res = true; + break; + } + } + + return res; +} + + +//================================================================================= +// function : closeEvent +// purpose : +//================================================================================= +void TransformationGUI_TranslationDlg::closeEvent( QCloseEvent* e ) +{ + myGeomGUI->SetState( -1 ); + GEOMBase_Skeleton::closeEvent( e ); +} + + +//================================================================================= +// function : CreateCopyModeChanged() +// purpose : +//================================================================================= +void TransformationGUI_TranslationDlg::CreateCopyModeChanged(bool isCreateCopy) +{ + GroupBoxName->setEnabled(isCreateCopy); } diff --git a/src/TransformationGUI/TransformationGUI_TranslationDlg.h b/src/TransformationGUI/TransformationGUI_TranslationDlg.h index 52334bc22..48050c84c 100644 --- a/src/TransformationGUI/TransformationGUI_TranslationDlg.h +++ b/src/TransformationGUI/TransformationGUI_TranslationDlg.h @@ -30,11 +30,8 @@ #define DIALOGBOX_TRANSLATION_H #include "GEOMBase_Skeleton.h" -#include "DlgRef_1Sel3Spin.h" +#include "DlgRef_3Sel3Spin1Check.h" -#include "TransformationGUI.h" - -#include //================================================================================= // class : TransformationGUI_TranslationDlg @@ -45,33 +42,38 @@ class TransformationGUI_TranslationDlg : public GEOMBase_Skeleton Q_OBJECT public: - TransformationGUI_TranslationDlg(QWidget* parent = 0, const char* name = 0, TransformationGUI* theTransformationGUI = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); + TransformationGUI_TranslationDlg(QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0); ~TransformationGUI_TranslationDlg(); +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& ); + virtual bool execute( ObjectList& objects ); + + virtual void closeEvent( QCloseEvent* e ); + private : void Init(); void enterEvent(QEvent* e); - void MakeTranslationSimulationAndDisplay(); + + GEOM::GEOM_Object_var myVector, myPoint1, myPoint2; + GEOM::ListOfGO myObjects; - TransformationGUI* myTransformationGUI; - double step; - - TopoDS_Shape myBase; /* is myBase */ - GEOM::GEOM_Shape_var myGeomShape; - bool myOkBase; - gp_Vec myVec; - - DlgRef_1Sel3Spin* GroupPoints; + DlgRef_3Sel3Spin1Check* GroupPoints; private slots : void ClickOnOk(); - void ClickOnApply(); + bool ClickOnApply(); + void ClickOnCancel(); void ActivateThisDialog(); + void DeactivateActiveDialog(); void LineEditReturnPressed(); void SelectionIntoArgument(); void SetEditCurrentArgument(); - void ValueChangedInSpinBox(double newValue); - + void ValueChangedInSpinBox(); + void ConstructorsClicked(int constructorId); + void CreateCopyModeChanged(bool isCreateCopy); }; #endif // DIALOGBOX_TRANSLATION_H