From: vsr Date: Tue, 12 Feb 2013 11:35:16 +0000 (+0000) Subject: Merge from V6_main 11/02/2013 X-Git-Tag: Delivery_V1_0_2013_07_12~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=465e84c52edb243fa36d581abc659b1c97156c64;p=modules%2Fgeom.git Merge from V6_main 11/02/2013 --- diff --git a/build_configure b/build_configure index 8d2bef16f..dca23c575 100755 --- a/build_configure +++ b/build_configure @@ -26,7 +26,6 @@ # Author : Marc Tajchman - CEA # Date : 10/10/2002 # Modified by : Alexander BORODIN (OCN) - autotools usage -# $Header$ # 13/03/2007: Alexander BORODIN - OCN # Reorganization for usage of autotools # diff --git a/configure.ac b/configure.ac index 2ba331467..921fd1cc7 100644 --- a/configure.ac +++ b/configure.ac @@ -476,6 +476,7 @@ AC_OUTPUT([ \ doc/docutils/Makefile \ doc/docutils/conf.py \ doc/salome/Makefile \ + doc/salome/examples/Makefile \ doc/salome/gui/Makefile \ doc/salome/gui/GEOM/Makefile \ doc/salome/gui/GEOM/doxyfile \ @@ -499,12 +500,14 @@ AC_OUTPUT([ \ src/DlgRef/Makefile \ src/EntityGUI/Makefile \ src/GEOM/Makefile \ + src/BlockFix/Makefile \ src/GEOMAlgo/Makefile \ src/GEOMBase/Makefile \ src/GEOMClient/Makefile \ src/GEOMFiltersSelection/Makefile \ src/Material/Makefile \ src/GEOMGUI/Makefile \ + src/GEOMUtils/Makefile \ src/GEOMImpl/Makefile \ src/GEOMToolsGUI/Makefile \ src/GEOM_I/Makefile \ diff --git a/doc/salome/Makefile.am b/doc/salome/Makefile.am index 8bf9f392d..18bd13960 100644 --- a/doc/salome/Makefile.am +++ b/doc/salome/Makefile.am @@ -20,10 +20,9 @@ # -* Makefile *- # Author : Patrick GOLDBRONN (CEA) # Date : 30/11/2001 -# Modified by : Alexander BORODIN (OCN) - autotools usage -# $Header: +# Modified by : Alexander BORODIN (OCN) - autotools usage # -SUBDIRS = tui gui +SUBDIRS = tui gui examples SUBDIRSTUI = tui SUBDIRSGUI = gui diff --git a/doc/salome/examples/3dsketcher.py b/doc/salome/examples/3dsketcher.py new file mode 100644 index 000000000..84dc28112 --- /dev/null +++ b/doc/salome/examples/3dsketcher.py @@ -0,0 +1,43 @@ +# 3D Sketcher + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# Create a 3D sketcher (wire) on the given points coordinates +sketcher1 = geompy.Make3DSketcher([ 0,0,0, 50,50,50, 0,50,0, 50,0,50, 10,20,100, 0,0,0 ]) + +# add object in the study +id_sketcher1 = geompy.addToStudy(sketcher1, "Sketcher1") + +# display the sketcher +gg.createAndDisplayGO(id_sketcher1) + +# Create a 3D sketcher (wire) with Sketcher3D interface + +# get the interface instance +sk = geompy.Sketcher3D() + +# add three points with absolute coordinates +# the first point will be the start point of sketcher +# two segments will be added by this command +sk.addPointsAbsolute(1,2,3, 7,0,0, 10,-3.5,-11) + +# add one segment, defined by two angles in "OXY" coordinate system and length +sk.addPointAnglesLength("OXY", 45, 0, 100) + +# add three points with relative coordinates +# three segments will be added by this command +sk.addPointsRelative(20,0,0, 20,0,100, -40,0,-50) + +# set to close the sketcher +sk.close() + +# obtain the sketcher result +sketcher2 = sk.wire() + +# add object in the study +id_sketcher2 = geompy.addToStudy(sketcher2, "Sketcher2") + +# display the sketcher +gg.createAndDisplayGO(id_sketcher2) diff --git a/doc/salome/examples/Makefile.am b/doc/salome/examples/Makefile.am new file mode 100644 index 000000000..1174f0114 --- /dev/null +++ b/doc/salome/examples/Makefile.am @@ -0,0 +1,141 @@ +# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +# File : Makefile +# Author : Alexander KOVALEV (Open Cascade NN) +# Modified by : +# Module : doc +# +include $(top_srcdir)/adm_local/unix/make_common_starter.am + +pyexamplesdir = $(docdir)/examples/GEOM + +BAD_TESTS = + +GOOD_TESTS = \ + 3dsketcher.py \ + advanced_geom_objs_ex01.py \ + advanced_geom_objs_ex02.py \ + advanced_geom_objs_ex03.py \ + angle.py \ + basic_geom_objs_ex01.py \ + basic_geom_objs_ex02.py \ + basic_geom_objs_ex03.py \ + basic_geom_objs_ex04.py \ + basic_geom_objs_ex05.py \ + basic_geom_objs_ex06.py \ + basic_geom_objs_ex07.py \ + basic_geom_objs_ex08.py \ + basic_geom_objs_ex09.py \ + basic_operations_ex01.py \ + basic_operations_ex02.py \ + basic_operations_ex03.py \ + basic_properties.py \ + blocks_operations_ex01.py \ + blocks_operations_ex02.py \ + blocks_operations_ex03.py \ + boolean_operations_ex01.py \ + boolean_operations_ex02.py \ + boolean_operations_ex03.py \ + boolean_operations_ex04.py \ + bounding_box.py \ + building_by_blocks_ex01.py \ + building_by_blocks_ex02.py \ + center_of_mass.py \ + check_compound_of_blocks.py \ + check_self_intersections.py \ + check_shape.py \ + complex_objs_ex01.py \ + complex_objs_ex02.py \ + complex_objs_ex03.py \ + complex_objs_ex04.py \ + complex_objs_ex05.py \ + complex_objs_ex06.py \ + complex_objs_ex07.py \ + complex_objs_ex08.py \ + complex_objs_ex09.py \ + complex_objs_ex10.py \ + free_boundaries.py \ + free_faces.py \ + get_non_blocks.py \ + import_export.py \ + inertia.py \ + min_distance.py \ + normal_face.py \ + notebook_geom.py \ + point_coordinates.py \ + primitives_ex01.py \ + primitives_ex02.py \ + primitives_ex03.py \ + primitives_ex04.py \ + primitives_ex05.py \ + primitives_ex06.py \ + primitives_ex07.py \ + repairing_operations_ex01.py \ + repairing_operations_ex02.py \ + repairing_operations_ex03.py \ + repairing_operations_ex04.py \ + repairing_operations_ex05.py \ + repairing_operations_ex06.py \ + repairing_operations_ex07.py \ + repairing_operations_ex08.py \ + repairing_operations_ex09.py \ + repairing_operations_ex10.py \ + repairing_operations_ex11.py \ + sketcher.py \ + tolerance.py \ + topological_geom_objs_ex01.py \ + topological_geom_objs_ex02.py \ + topological_geom_objs_ex03.py \ + topological_geom_objs_ex04.py \ + topological_geom_objs_ex05.py \ + topological_geom_objs_ex06.py \ + transformation_operations_ex01.py \ + transformation_operations_ex02.py \ + transformation_operations_ex03.py \ + transformation_operations_ex04.py \ + transformation_operations_ex05.py \ + transformation_operations_ex06.py \ + transformation_operations_ex07.py \ + transformation_operations_ex08.py \ + transformation_operations_ex09.py \ + transformation_operations_ex10.py \ + transformation_operations_ex11.py \ + transformation_operations_ex12.py \ + transformation_operations_ex13.py \ + viewing_geom_objs_ex01.py \ + viewing_geom_objs_ex02.py \ + viewing_geom_objs_ex03.py \ + viewing_geom_objs_ex04.py \ + whatis.py \ + working_with_groups_ex01.py \ + working_with_groups_ex02.py \ + working_with_groups_ex03.py \ + working_with_groups_ex04.py \ + working_with_groups_ex05.py \ + working_with_groups_ex06.py + +pyexamples_SCRIPTS = $(BAD_TESTS) $(GOOD_TESTS) + +EXTRA_DIST += $(pyexamples_SCRIPTS) testme.py + +check-local: + @for f in $(GOOD_TESTS) ; do \ + python $(top_srcdir)/doc/salome/examples/testme.py $(top_srcdir)/doc/salome/examples/$$f || exit 1; \ + done diff --git a/doc/salome/examples/advanced_geom_objs_ex01.py b/doc/salome/examples/advanced_geom_objs_ex01.py new file mode 100644 index 000000000..eb3db5fe5 --- /dev/null +++ b/doc/salome/examples/advanced_geom_objs_ex01.py @@ -0,0 +1,73 @@ +# Creation of PipeTShape + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create PipeTShape object +pipetshape = geompy.MakePipeTShape(80.0, 20.0, 200.0, 50.0, 20.0, 200.0) + +# add object in the study +id_pipetshape = geompy.addToStudy(pipetshape[0],"PipeTShape") +# add groups in the study +for g in pipetshape[1:]: + geompy.addToStudyInFather(pipetshape[0], g, g.GetName()) + +# Create junction vertices +P1 = geompy.MakeVertex(0.0, 0.0, 0.0) +P2 = geompy.MakeVertex(400.0, 0.0, 0.0) +P3 = geompy.MakeVertex(200.0, 0.0, 200.0) + +# create PipeTShape object with position +pipetshape_position = geompy.MakePipeTShape(80.0, 20.0, 200.0, 50.0, 20.0, 200.0, True, P1, P2, P3) + +# add object in the study +id_pipetshape_position = geompy.addToStudy(pipetshape_position[0],"PipeTShape_position") +# add groups in the study +for g in pipetshape_position[1:]: + geompy.addToStudyInFather(pipetshape_position[0], g, g.GetName()) + +# create PipeTShape with chamfer object +pipetshapechamfer = geompy.MakePipeTShapeChamfer(80.0, 20.0, 200.0, 50.0, 20.0, 200.0, 20.0, 20.0) + +# add object in the study +id_pipetshapechamfer = geompy.addToStudy(pipetshapechamfer[0],"PipeTShapeChamfer") +# add groups in the study +for g in pipetshapechamfer[1:]: + geompy.addToStudyInFather(pipetshapechamfer[0], g, g.GetName()) + +# create PipeTShape with chamfer object with position +pipetshapechamfer_position = geompy.MakePipeTShapeChamfer(80.0, 20.0, 200.0, 50.0, 20.0, 200.0, 20.0, 20.0, True, P1, P2, P3) + +# add object in the study +id_pipetshapechamfer_position = geompy.addToStudy(pipetshapechamfer_position[0],"PipeTShapeChamfer_position") +# add groups in the study +for g in pipetshapechamfer_position[1:]: + geompy.addToStudyInFather(pipetshapechamfer_position[0], g, g.GetName()) + +# create PipeTShape with fillet object +pipetshapefillet = geompy.MakePipeTShapeFillet(80.0, 20.0, 200.0, 50.0, 20.0, 200.0, 5.0) + +# add object in the study +id_pipetshapefillet = geompy.addToStudy(pipetshapefillet[0],"PipeTShapeFillet") +# add groups in the study +for g in pipetshapefillet[1:]: + geompy.addToStudyInFather(pipetshapefillet[0], g, g.GetName()) + +# create PipeTShape with fillet object with position +pipetshapefillet_position = geompy.MakePipeTShapeFillet(80.0, 20.0, 200.0, 50.0, 20.0, 200.0, 5.0, True, P1, P2, P3) + +# add object in the study +id_pipetshapefillet_position = geompy.addToStudy(pipetshapefillet_position[0],"PipeTShapeFillet_position") +# add groups in the study +for g in pipetshapefillet_position[1:]: + geompy.addToStudyInFather(pipetshapefillet_position[0], g, g.GetName()) + + +# display pipetshapes +gg.createAndDisplayGO(id_pipetshape) +gg.createAndDisplayGO(id_pipetshape_position) +gg.createAndDisplayGO(id_pipetshapechamfer) +gg.createAndDisplayGO(id_pipetshapechamfer_position) +gg.createAndDisplayGO(id_pipetshapefillet) +gg.createAndDisplayGO(id_pipetshapefillet_position) diff --git a/doc/salome/examples/advanced_geom_objs_ex02.py b/doc/salome/examples/advanced_geom_objs_ex02.py new file mode 100644 index 000000000..2ee301688 --- /dev/null +++ b/doc/salome/examples/advanced_geom_objs_ex02.py @@ -0,0 +1,15 @@ +# Creation of DividedDisk + +import geompy +import salome +import GEOM +gg = salome.ImportComponentGUI("GEOM") + +# create DividedDisk object +divideddisk = geompy.MakeDividedDisk(100, 1, GEOM.SQUARE) + +# add object in the study +id_divideddisk = geompy.addToStudy(divideddisk,"DividedDisk") + +# display divideddisk +gg.createAndDisplayGO(id_divideddisk) diff --git a/doc/salome/examples/advanced_geom_objs_ex03.py b/doc/salome/examples/advanced_geom_objs_ex03.py new file mode 100644 index 000000000..195cda0dd --- /dev/null +++ b/doc/salome/examples/advanced_geom_objs_ex03.py @@ -0,0 +1,15 @@ +# Creation of DividedCylinder + +import geompy +import salome +import GEOM +gg = salome.ImportComponentGUI("GEOM") + +# create DividedCylinder object +dividedcylinder = geompy.MakeDividedCylinder(100, 300, GEOM.SQUARE) + +# add object in the study +id_dividedcylinder = geompy.addToStudy(dividedcylinder,"DividedCylinder") + +# display dividedcylinder +gg.createAndDisplayGO(id_dividedcylinder) diff --git a/doc/salome/examples/angle.py b/doc/salome/examples/angle.py new file mode 100644 index 000000000..547db7184 --- /dev/null +++ b/doc/salome/examples/angle.py @@ -0,0 +1,60 @@ +# Angle + +import salome +salome.salome_init() + +import math +import geompy +geompy.init_geom(salome.myStudy) + +OX = geompy.MakeVectorDXDYDZ(10, 0,0) +OXY = geompy.MakeVectorDXDYDZ(10,10,0) + +# in one plane +Angle = geompy.GetAngle(OX, OXY) + +print "\nAngle between OX and OXY = ", Angle +if math.fabs(Angle - 45.0) > 1e-05: + print " Error: returned angle is", Angle, "while must be 45.0" + pass + +Angle = geompy.GetAngleRadians(OX, OXY) + +print "\nAngle between OX and OXY in radians = ", Angle +if math.fabs(Angle - math.pi/4) > 1e-05: + print " Error: returned angle is", Angle, "while must be pi/4" + pass + +Angle = geompy.GetAngleVectors(OX, OXY, True) + +print "\nAngle between vectors OX and OXY = ", Angle +if math.fabs(Angle - 45.0) > 1e-05: + print " Error: returned angle is", Angle, "while must be 45.0" + pass + +Angle = geompy.GetAngleRadiansVectors(OX, OXY, False) + +print "\nBig angle between vectors OX and OXY in radians = ", Angle +if math.fabs(Angle - math.pi*7./4.) > 1e-05: + print " Error: returned angle is", Angle, "while must be 7*pi/4" + pass + +# not in one plane +OXY_shift = geompy.MakeTranslation(OXY,10,-10,20) +Angle = geompy.GetAngle(OX, OXY_shift) + +print "\nAngle between OX and OXY_shift = ", Angle +if math.fabs(Angle - 45.0) > 1e-05: + print " Error: returned angle is", Angle, "while must be 45.0" + pass + +# not linear +pnt1 = geompy.MakeVertex(0, 0, 0) +pnt2 = geompy.MakeVertex(10, 0, 0) +pnt3 = geompy.MakeVertex(20, 10, 0) +arc = geompy.MakeArc(pnt1, pnt2, pnt3) +Angle = geompy.GetAngle(OX, arc) + +if (math.fabs(Angle + 1.0) > 1e-6 or geompy.MeasuOp.IsDone()): + print "Error. Angle must not be computed on curvilinear edges" + pass diff --git a/doc/salome/examples/basic_geom_objs_ex01.py b/doc/salome/examples/basic_geom_objs_ex01.py new file mode 100644 index 000000000..05abb799d --- /dev/null +++ b/doc/salome/examples/basic_geom_objs_ex01.py @@ -0,0 +1,61 @@ +# Creation of a Point + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create vertices +p0 = geompy.MakeVertex(0., 0., 0.) +p100 = geompy.MakeVertexWithRef(p0, 100., 100., 100.) +px = geompy.MakeVertex(100., 0., 0.) +py = geompy.MakeVertex(0., 100., 0.) +pz = geompy.MakeVertex(0., 0., 100.) +p1 = geompy.MakeVertex(50., 50., 30.) + +# create a curve and vertices on it +Arc = geompy.MakeArc(py, pz, px) +# create a vertex by parameter +p_on_arc = geompy.MakeVertexOnCurve(Arc, 0.25) +# create a vertex by length +p_on_arc2 = geompy.MakeVertexOnCurveByLength(Arc, 50., None) +#create a vertex by point projection +p_on_arc3 = geompy.MakeVertexOnCurveByCoord(Arc, 100, -10, 10) + +# create 2 lines and make a point on its intersection +line_1 = geompy.MakeLineTwoPnt(p0, p100) +line_2 = geompy.MakeLineTwoPnt(p1, pz) +p_inter = geompy.MakeVertexOnLinesIntersection(line_1, line_2) + +# create a face and vertices on it +Add_line = geompy.MakeLineTwoPnt(px, py) +arc_face = geompy.MakeFaceWires([Arc, Add_line], 1) +p_on_face1 = geompy.MakeVertexOnSurface(arc_face, 0.5, 0.5) +p_on_face2 = geompy.MakeVertexOnSurfaceByCoord(arc_face, 35, 35, 35) +p_on_face3 = geompy.MakeVertexInsideFace(arc_face) + + +# add objects in the study +id_p0 = geompy.addToStudy(p0, "Vertex 0") +id_p100 = geompy.addToStudy(p100, "Vertex 100") +id_px = geompy.addToStudy(px, "Vertex X") +id_py = geompy.addToStudy(py, "Vertex Y") +id_pz = geompy.addToStudy(pz, "Vertex Z") +id_Arc = geompy.addToStudy(Arc, "Arc") +id_line_1 = geompy.addToStudy(line_1, "Line 1") +id_line_2 = geompy.addToStudy(line_2, "Line 2") +id_p_on_arc = geompy.addToStudy(p_on_arc, "Vertex on Arc by parameter") +id_p_on_arc2 = geompy.addToStudy(p_on_arc2, "Vertex on Arc by length") +id_p_on_arc3 = geompy.addToStudy(p_on_arc3, "Vertex on Arc by point projection") +id_p_inter = geompy.addToStudy(p_inter, "Vertex on Lines Intersection") +id_p_on_face1 = geompy.addToStudy(p_on_face1, "Vertex on face by parameter") +id_p_on_face2 = geompy.addToStudy(p_on_face2, "Vertex on face by point projection") +id_p_on_face3 = geompy.addToStudy(p_on_face3, "Vertex inside face") + +# display vertices +gg.createAndDisplayGO(id_p0) +gg.createAndDisplayGO(id_p100) +gg.createAndDisplayGO(id_Arc) +gg.createAndDisplayGO(id_p_inter) +gg.createAndDisplayGO(id_p_on_arc) +gg.createAndDisplayGO(id_p_on_arc2) +gg.createAndDisplayGO(id_p_on_arc3) diff --git a/doc/salome/examples/basic_geom_objs_ex02.py b/doc/salome/examples/basic_geom_objs_ex02.py new file mode 100644 index 000000000..02f87e910 --- /dev/null +++ b/doc/salome/examples/basic_geom_objs_ex02.py @@ -0,0 +1,31 @@ +# Creation of a Line + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create vertices +p0 = geompy.MakeVertex(0., 0., 0.) +p100 = geompy.MakeVertexWithRef(p0, 100., 100., 100.) +px = geompy.MakeVertex(100., 0. , 0. ) +py = geompy.MakeVertex(0. , 100., 0. ) +pz = geompy.MakeVertex(0. , 0. , 100.) + +# create a vector from two points +vxy = geompy.MakeVector(px, py) + +# create a line from a point and a vector +line1 = geompy.MakeLine(pz, vxy) + +#create a line from two points +line2 = geompy.MakeLineTwoPnt(p0, p100) + +# add objects in the study +id_vxy = geompy.addToStudy(vxy, "Vector") +id_line1 = geompy.addToStudy(line1,"Line1") +id_line2 = geompy.addToStudy(line2,"Line2") + +# display lines +gg.createAndDisplayGO(id_vxy) +gg.createAndDisplayGO(id_line1) +gg.createAndDisplayGO(id_line2) diff --git a/doc/salome/examples/basic_geom_objs_ex03.py b/doc/salome/examples/basic_geom_objs_ex03.py new file mode 100644 index 000000000..510ae18fc --- /dev/null +++ b/doc/salome/examples/basic_geom_objs_ex03.py @@ -0,0 +1,30 @@ +# Creation of a Circle + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create vertices +p0 = geompy.MakeVertex(0., 0., 0.) +px = geompy.MakeVertex(100., 0. , 0. ) +py = geompy.MakeVertex(0. , 100., 0. ) +pz = geompy.MakeVertex(0. , 0. , 100.) + +# create a vector on two points +vxy = geompy.MakeVector(px, py) + +# create a circle from a point, a vector and a radius +circle1 = geompy.MakeCircle(pz, vxy, 30) + +#create a circle from three points +circle2 = geompy.MakeCircleThreePnt(p0, px, py) + +# add objects in the study +id_vxy = geompy.addToStudy(vxy, "Vector") +id_circle1 = geompy.addToStudy(circle1,"Circle1") +id_circle2 = geompy.addToStudy(circle2,"Circle2") + +# display circles +gg.createAndDisplayGO(id_vxy) +gg.createAndDisplayGO(id_circle1) +gg.createAndDisplayGO(id_circle2) diff --git a/doc/salome/examples/basic_geom_objs_ex04.py b/doc/salome/examples/basic_geom_objs_ex04.py new file mode 100644 index 000000000..bf7d3e870 --- /dev/null +++ b/doc/salome/examples/basic_geom_objs_ex04.py @@ -0,0 +1,34 @@ +# Creation of an Ellipse + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create vertices +p0 = geompy.MakeVertex(0., 0., 0.) +p1 = geompy.MakeVertex(50., 50., 50.) +p2 = geompy.MakeVertex(0., 50., 0.) + +# create a normal vector from two points +normal = geompy.MakeVector(p0, p1) + +# create a major axis vector from two points +major = geompy.MakeVector(p0, p2) + +# create an ellipse from a point, a vector and radiuses +ellipse1 = geompy.MakeEllipse(p1, normal, 50, 25) + +# create an ellipse from a point, a normal vector, radiuses and a major axis vector +ellipse2 = geompy.MakeEllipse(p1, normal, 50, 25, major) + +# add objects in the study +id_normal = geompy.addToStudy(normal, "Normal") +id_major = geompy.addToStudy(major, "Major Axis") +id_ellipse1 = geompy.addToStudy(ellipse1, "Ellipse 1") +id_ellipse2 = geompy.addToStudy(ellipse2, "Ellipse 2") + +# display the ellipse and its normal vector +gg.createAndDisplayGO(id_normal) +gg.createAndDisplayGO(id_major) +gg.createAndDisplayGO(id_ellipse1) +gg.createAndDisplayGO(id_ellipse2) diff --git a/doc/salome/examples/basic_geom_objs_ex05.py b/doc/salome/examples/basic_geom_objs_ex05.py new file mode 100644 index 000000000..5a82c3b1b --- /dev/null +++ b/doc/salome/examples/basic_geom_objs_ex05.py @@ -0,0 +1,29 @@ +# Creation of an Arc + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create vertices +p0 = geompy.MakeVertex(0., 0., 0.) +p1 = geompy.MakeVertex(100., 0., 0.) +p2 = geompy.MakeVertex(50., 0., 50.) + +# create an arc from a three points +arc1 = geompy.MakeArc(p0, p1, p2) + +# create an arc from a center point, a start point and end point +arc2 = geompy.MakeArcCenter(p0, p1, p2, 1) + +# create an arc from a center point, a major point and minor point +arc3 = geompy.MakeArcOfEllipse(p0, p1, p2) + +# add objects in the study +id_arc1 = geompy.addToStudy(arc1, "Arc 1") +id_arc2 = geompy.addToStudy(arc2, "Arc 2") +id_arc3 = geompy.addToStudy(arc3, "Arc 3") + +# display the arcs +gg.createAndDisplayGO(id_arc1) +gg.createAndDisplayGO(id_arc2) +gg.createAndDisplayGO(id_arc3) diff --git a/doc/salome/examples/basic_geom_objs_ex06.py b/doc/salome/examples/basic_geom_objs_ex06.py new file mode 100644 index 000000000..ba4940c14 --- /dev/null +++ b/doc/salome/examples/basic_geom_objs_ex06.py @@ -0,0 +1,68 @@ +# Creation of a Curve + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create vertices and vectors +p0 = geompy.MakeVertex(0. , 0. , 0. ) +p1 = geompy.MakeVertex(50. , 100., 200.) +p2 = geompy.MakeVertex(150., 50., 100.) +p3 = geompy.MakeVertex(100., 150., 170.) +p4 = geompy.MakeVertex(200., 200., 150.) + +v1 = geompy.MakeVectorDXDYDZ(0, 1, 0) +v2 = geompy.MakeVectorDXDYDZ(1, 0, 0) + +# create a polyline from a list of points +polyline = geompy.MakePolyline([p0, p1, p2, p3, p4]) + +# create a bezier curve from a list of points +bezier = geompy.MakeBezier([p0, p1, p2, p3, p4]) + +#create a b-spline curve from a list of points +interpol = geompy.MakeInterpol([p0, p1, p2, p3, p4], False) + +#create a b-spline curve with defined directions at the ends +interpol_tangents = geompy.MakeInterpolWithTangents([p0, p1, p2, p3, p4], v1, v2) + +#create a polyline using parametric definition of the basic points +param_polyline = geompy.MakeCurveParametric("t", "sin(t)", "cos(t)", 0., 100., 100, geompy.GEOM.Polyline, theNewMethod=True) + +# create a bezier curve using parametric definition of the basic points +param_bezier = geompy.MakeCurveParametric("t", "sin(t)", "cos(t)", 0., 100., 20, geompy.GEOM.Bezier, theNewMethod=True) + +#create a b-spline curve using parametric definition of the basic points +param_interpol = geompy.MakeCurveParametric("t", "sin(t)", "cos(t)", 0., 100., 100, geompy.GEOM.Interpolation, theNewMethod=True) + + +# add objects in the study +id_p0 = geompy.addToStudy(p0, "Point1") +id_p1 = geompy.addToStudy(p1, "Point2") +id_p2 = geompy.addToStudy(p2, "Point3") +id_p3 = geompy.addToStudy(p3, "Point4") +id_p4 = geompy.addToStudy(p4, "Point5") +id_v1 = geompy.addToStudy(v1, "Vector1") +id_v2 = geompy.addToStudy(v2, "Vector2") +id_polyline = geompy.addToStudy(polyline, "Polyline") +id_bezier = geompy.addToStudy(bezier, "Bezier") +id_interpol = geompy.addToStudy(interpol, "Interpol") +id_interpol_tangents = geompy.addToStudy(interpol_tangents, "Interpol Tangents") +id_param_polyline = geompy.addToStudy(param_polyline, "Polyline Parametric") +id_param_bezier = geompy.addToStudy(param_bezier, "Bezier Parametric") +id_param_interpol = geompy.addToStudy(param_interpol, "Interpol Parametric") + + +# display the points and the curves +gg.createAndDisplayGO(id_p0) +gg.createAndDisplayGO(id_p1) +gg.createAndDisplayGO(id_p2) +gg.createAndDisplayGO(id_p3) +gg.createAndDisplayGO(id_p4) +gg.createAndDisplayGO(id_polyline) +gg.createAndDisplayGO(id_bezier) +gg.createAndDisplayGO(id_interpol) +gg.createAndDisplayGO(id_interpol_tangents) +gg.createAndDisplayGO(id_param_polyline) +gg.createAndDisplayGO(id_param_bezier) +gg.createAndDisplayGO(id_param_interpol) diff --git a/doc/salome/examples/basic_geom_objs_ex07.py b/doc/salome/examples/basic_geom_objs_ex07.py new file mode 100644 index 000000000..2de687af0 --- /dev/null +++ b/doc/salome/examples/basic_geom_objs_ex07.py @@ -0,0 +1,27 @@ +# Creation of a Vector + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create vertices +p1 = geompy.MakeVertex(10., 50., 20.) +p2 = geompy.MakeVertex(70., 70., 70.) + +# create a vector from two points +vector1 = geompy.MakeVector(p1, p2) + +# create a vector from the given components +vector2 = geompy.MakeVectorDXDYDZ(30, 30, 100) + +# add objects in the study +id_p1 = geompy.addToStudy(p1, "Point1") +id_p2 = geompy.addToStudy(p2, "Point2") +id_vector1 = geompy.addToStudy(vector1,"Vector1") +id_vector2 = geompy.addToStudy(vector2,"Vector2") + +# display the points and the vectors +gg.createAndDisplayGO(id_p1) +gg.createAndDisplayGO(id_p2) +gg.createAndDisplayGO(id_vector1) +gg.createAndDisplayGO(id_vector2) diff --git a/doc/salome/examples/basic_geom_objs_ex08.py b/doc/salome/examples/basic_geom_objs_ex08.py new file mode 100644 index 000000000..81a8745c5 --- /dev/null +++ b/doc/salome/examples/basic_geom_objs_ex08.py @@ -0,0 +1,75 @@ +# Creation of a Plane + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create vertices +p1 = geompy.MakeVertex( 0., 0., 100.) +p2 = geompy.MakeVertex(100., 0., 0.) +p3 = geompy.MakeVertex(200., 200., 200.) +p4 = geompy.MakeVertex(100., 100., 0.) +p5 = geompy.MakeVertex(0. , 100., 0.) + +# create a vectors from the given components +vector1 = geompy.MakeVectorDXDYDZ(100., 100., 100.) +vector2 = geompy.MakeVectorDXDYDZ(-100., 0., 100.) + +# create a vector from two points +vector_arc = geompy.MakeVector(p2, p5) + +# create an arc from three points +arc = geompy.MakeArc(p2, p4, p5) + +# create a wire +wire = geompy.MakeWire([vector_arc, arc]) + +# create a face +isPlanarWanted = 1 +face = geompy.MakeFace(wire, isPlanarWanted) +trimsize = 1000. + +# create a Local Coordinate System + +LCS = geompy.MakeMarker(100., 100., 101., 1, 0, 0, 0, 1, 0) + +# create a plane from a point, a vector and a trimsize +plane1 = geompy.MakePlane(p1, vector1, trimsize) + +# create a plane from three points and a trimsize +plane2 = geompy.MakePlaneThreePnt(p1, p2, p3, trimsize) + +# create a plane from the given face +plane3 = geompy.MakePlaneFace(face, trimsize) + +# create a plane from two vectors and a trimsize +plane4 = geompy.MakePlane2Vec(vector1, vector2, trimsize) + +# create a plane with the Local Coordinate System and a trimsize +plane5 = geompy.MakePlaneLCS(LCS, trimsize, 1) + +# add objects in the study +id_face = geompy.addToStudy(face, "Face") +id_plane1 = geompy.addToStudy(plane1,"Plane1") +id_plane2 = geompy.addToStudy(plane2,"Plane2") +id_plane3 = geompy.addToStudy(plane3,"Plane3") +id_plane4 = geompy.addToStudy(plane4,"Plane4") +id_plane5 = geompy.addToStudy(plane5,"Plane5") + +# display the points and the vectors +gg.createAndDisplayGO(id_face) +gg.createAndDisplayGO(id_plane1) +gg.createAndDisplayGO(id_plane2) +gg.createAndDisplayGO(id_plane3) +gg.createAndDisplayGO(id_plane4) +gg.createAndDisplayGO(id_plane5) +gg.setDisplayMode(id_plane1,1) +gg.setTransparency(id_plane1,0.5) +gg.setDisplayMode(id_plane2,1) +gg.setTransparency(id_plane2,0.5) +gg.setDisplayMode(id_plane3,1) +gg.setTransparency(id_plane3,0.5) +gg.setDisplayMode(id_plane4,1) +gg.setTransparency(id_plane4,0.5) +gg.setDisplayMode(id_plane5,1) +gg.setTransparency(id_plane5,0.5) diff --git a/doc/salome/examples/basic_geom_objs_ex09.py b/doc/salome/examples/basic_geom_objs_ex09.py new file mode 100644 index 000000000..3934410ee --- /dev/null +++ b/doc/salome/examples/basic_geom_objs_ex09.py @@ -0,0 +1,38 @@ +# Creation of a Local Coordinate System + +import GEOM +import geompy +import math +import SALOMEDS + +#Create vertexes, vectors and shapes to construct local CS +Vertex_1 = geompy.MakeVertex(50, 50, 50) +Vertex_2 = geompy.MakeVertex(70, 70, 70) +Vertex_3 = geompy.MakeVertex(0, 0, 0) +Vector_X = geompy.MakeVectorDXDYDZ(50, 0, 0) +Vector_Y = geompy.MakeVectorDXDYDZ(0, 50, 0) +Face_1 = geompy.MakeFaceHW(100, 100, 1) +Box_1 = geompy.MakeBoxTwoPnt(Vertex_1, Vertex_2) + +#Construct local CS by manual definition +LocalCS_1 = geompy.MakeMarker(0, 0, 0, 1, 0, 0, 0, 1, 0) + +#Construct local CS by center point and two vectors (X and Y directions) +LocalCS_2 = geompy.MakeMarkerPntTwoVec(Vertex_3, Vector_X, Vector_Y) + +#Construct local CS from shape orientation +LocalCS_FACE = geompy.MakeMarkerFromShape(Face_1) +LocalCS_BOX = geompy.MakeMarkerFromShape(Box_1) + +#Add created object to study +geompy.addToStudy( Face_1, "Face_1" ) +geompy.addToStudy( Vertex_1, "Vertex_1" ) +geompy.addToStudy( Vertex_2, "Vertex_2" ) +geompy.addToStudy( Box_1, "Box_1" ) +geompy.addToStudy( Vertex_3, "Vertex_3" ) +geompy.addToStudy( Vector_X, "Vector_X" ) +geompy.addToStudy( Vector_Y, "Vector_Y" ) +geompy.addToStudy( LocalCS_1, "LocalCS_1" ) +geompy.addToStudy( LocalCS_2, "LocalCS_3" ) +geompy.addToStudy( LocalCS_FACE, "LocalCS_FACE" ) +geompy.addToStudy( LocalCS_BOX, "LocalCS_BOX" ) diff --git a/doc/salome/examples/basic_operations_ex01.py b/doc/salome/examples/basic_operations_ex01.py new file mode 100644 index 000000000..bed9e1c86 --- /dev/null +++ b/doc/salome/examples/basic_operations_ex01.py @@ -0,0 +1,41 @@ +# Partition + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create a vertex and a vector +p0 = geompy.MakeVertex( 0., 0., 0.) +p200 = geompy.MakeVertex(200., 200., 200.) +pz = geompy.MakeVertex( 0., 0., 100.) + +# create a vector +vxyz = geompy.MakeVectorDXDYDZ(100., 100., 100.) + +# create a box from two points +box = geompy.MakeBoxTwoPnt(p0, p200) + +# create a plane +trimsize = 500. +plane = geompy.MakePlane(pz, vxyz, trimsize) + +# create partition objects +partition1 = geompy.MakePartition([box], [plane]) +partition2 = geompy.Partition([box], [plane]) +partition3 = geompy.MakeHalfPartition(box, plane) + +# add objects in the study +id_box = geompy.addToStudy(box,"Box") +id_plane = geompy.addToStudy(plane,"Plane") +id_partition1 = geompy.addToStudy(partition1,"MakePartition") +id_partition2 = geompy.addToStudy(partition2,"Partition") +id_partition3 = geompy.addToStudy(partition3,"MakeHalfPartition") + +# display the partition objects and the plane +gg.createAndDisplayGO(id_box) +gg.setDisplayMode(id_box,1) +gg.createAndDisplayGO(id_plane) +gg.setDisplayMode(id_plane,1) +gg.createAndDisplayGO(id_partition1) +gg.createAndDisplayGO(id_partition2) +gg.createAndDisplayGO(id_partition3) diff --git a/doc/salome/examples/basic_operations_ex02.py b/doc/salome/examples/basic_operations_ex02.py new file mode 100644 index 000000000..ac9b77b9d --- /dev/null +++ b/doc/salome/examples/basic_operations_ex02.py @@ -0,0 +1,28 @@ +# Archimede + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create a vertex and a vector +p0 = geompy.MakeVertex( 0., 0., 0.) +p200 = geompy.MakeVertex(200., 200., 200.) + +# create a box from two points +box = geompy.MakeBoxTwoPnt(p0, p200) + +# perform an Archimede operation on the selected shape with selected parameters +weight = 1000000. +waterdensity = 1. +meshingdeflection = 0.01 +archimede = geompy.Archimede(box, weight, waterdensity, meshingdeflection) + +# add objects in the study +id_box = geompy.addToStudy(box,"Box") +id_archimede = geompy.addToStudy(archimede,"Archimede") + +# display the box and the result of Archimede operation +gg.createAndDisplayGO(id_box) +gg.setDisplayMode(id_box,1) +gg.createAndDisplayGO(id_archimede) +gg.setDisplayMode(id_archimede,1) diff --git a/doc/salome/examples/basic_operations_ex03.py b/doc/salome/examples/basic_operations_ex03.py new file mode 100644 index 000000000..39b1dd22b --- /dev/null +++ b/doc/salome/examples/basic_operations_ex03.py @@ -0,0 +1,55 @@ +# Restore presentation parameters and sub-shapes + +import geompy +import GEOM +import SALOMEDS + +# create a box and a cylinder +box = geompy.MakeBoxDXDYDZ(200, 200, 200) +cyl = geompy.MakeCylinderRH(100, 300) + +# create translated box +vec = geompy.MakeVectorDXDYDZ(100, 50, 0) +tra = geompy.MakeTranslationVector(box, vec) + +# create partition objects +partition1 = geompy.MakePartition([box, cyl]) +partition2 = geompy.MakePartition([box], [cyl]) +partition3 = geompy.MakePartition([box], [tra]) + +# set colours +box.SetColor(SALOMEDS.Color(1,0,0)) +cyl.SetColor(SALOMEDS.Color(0,1,0)) + +# add objects in the study +geompy.addToStudy(box, "Box") +geompy.addToStudy(cyl, "Cylinder") +geompy.addToStudy(vec, "Vector") +geompy.addToStudy(tra, "Translation") +geompy.addToStudy(partition1, "Partition_1") +geompy.addToStudy(partition2, "Partition_2") +geompy.addToStudy(partition3, "Partition_3") + +# Restore presentation parameters and sub-shapes +# different methods can be used to find the sub-shapes in the result: +# GetInPlace, GetSame, GetInPlaceByHistory, GetShapesOnShape. +# By default, GetInPlace method is used (GEOM.FSM_GetInPlace) +geompy.RestoreSubShapes(partition1) + +geompy.RestoreSubShapes(partition2, [], GEOM.FSM_GetInPlace) + +# The list of arguments can be used to avoid restoring all arguments, +# but restore only the passed. +geompy.RestoreSubShapes(partition3, [tra], GEOM.FSM_GetInPlaceByHistory) + +# To find sub-shapes in a transformed shape only one method could be +# used: pass GEOM.FSM_Transformed for that. +# True passed for the last argument, means that the transformed shape +# will inherit colour and sub-shapes from its first argument (see above +# MakeTranslation). +geompy.RestoreSubShapes(tra, [], GEOM.FSM_Transformed, True) + +# Also we could do this directly with method addToStudy: +partition4 = geompy.MakePartition([box, tra]) +geompy.addToStudy(partition4, "Partition_4", True, [], + GEOM.FSM_GetInPlaceByHistory, False) diff --git a/doc/salome/examples/basic_properties.py b/doc/salome/examples/basic_properties.py new file mode 100644 index 000000000..239655901 --- /dev/null +++ b/doc/salome/examples/basic_properties.py @@ -0,0 +1,20 @@ +# Basic Properties + +import geompy +import math + +# create a box +box = geompy.MakeBoxDXDYDZ(100,30,100) +props = geompy.BasicProperties(box) +print "\nBox 100x30x100 Basic Properties:" +print " Wires length: ", props[0] +print " Surface area: ", props[1] +print " Volume : ", props[2] +length = math.sqrt((props[0] - 1840)*(props[0] - 1840)) +area = math.sqrt((props[1] - 32000)*(props[1] - 32000)) +volume = math.sqrt((props[2] - 300000)*(props[2] - 300000)) +if length > 1e-7 or area > 1e-7 or volume > 1e-7: + print "While must be:" + print " Wires length: ", 1840 + print " Surface area: ", 32000 + print " Volume : ", 300000. diff --git a/doc/salome/examples/blocks_operations_ex01.py b/doc/salome/examples/blocks_operations_ex01.py new file mode 100644 index 000000000..5535f121d --- /dev/null +++ b/doc/salome/examples/blocks_operations_ex01.py @@ -0,0 +1,35 @@ +# Multi Transformation + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create vertices +p_25_25_50 = geompy.MakeVertex(25., 25., 50.) +p_50_25_25 = geompy.MakeVertex(50., 25., 25.) +p_25_50_25 = geompy.MakeVertex(25., 50., 25.) + +box = geompy.MakeBoxDXDYDZ(50, 50, 50) + +top_face = geompy.GetFaceNearPoint(box, p_25_25_50) +yz_face = geompy.GetFaceNearPoint(box, p_50_25_25) +xz_face = geompy.GetFaceNearPoint(box, p_25_50_25) + +top_face_ind = geompy.GetSubShapeID(box, top_face) +yz_face_ind = geompy.GetSubShapeID(box, yz_face) +xz_face_ind = geompy.GetSubShapeID(box, xz_face) + +# Multi-transformate block and glue the result +box_tr1 = geompy.MakeMultiTransformation1D(box, yz_face_ind, top_face_ind, 3) +box_tr2 = geompy.MakeMultiTransformation2D(box, xz_face_ind, yz_face_ind, 3, top_face_ind, 0, 2) + +# add objects in the study +id_box = geompy.addToStudy(box, "Box") +id_box_tr1 = geompy.addToStudy(box_tr1, "Multi-transformed Block 1D") +id_box_tr2 = geompy.addToStudy(box_tr2, "Multi-transformed Block 2D") + +# display the results +gg.createAndDisplayGO(id_box) +gg.setDisplayMode(id_box,1) +gg.createAndDisplayGO(id_box_tr1) +gg.createAndDisplayGO(id_box_tr2) diff --git a/doc/salome/examples/blocks_operations_ex02.py b/doc/salome/examples/blocks_operations_ex02.py new file mode 100644 index 000000000..68fbb01a6 --- /dev/null +++ b/doc/salome/examples/blocks_operations_ex02.py @@ -0,0 +1,26 @@ +# Explode on Blocks + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create a box and a sphere +box = geompy.MakeBoxDXDYDZ(200, 200, 200) +sphere = geompy.MakeSphereR(100) + +# make a compound +compound = geompy.MakeCompound([box, sphere]) + +# get all the blocks of the given compound, by criteria: min_nb_faces <= nb. of faces <= max_nb_faces +min_nb_faces = 6 +max_nb_faces = 6 +make_block_explode = geompy.MakeBlockExplode(compound, min_nb_faces, max_nb_faces) + +# add objects in the study +id_compound = geompy.addToStudy(compound, "Compound") +id_make_block_explode = geompy.addToStudyInFather(compound, make_block_explode[0], "MakeBlockExplode") + +# display the results +gg.createAndDisplayGO(id_compound) +gg.createAndDisplayGO(id_make_block_explode) +gg.setDisplayMode(id_make_block_explode,1) diff --git a/doc/salome/examples/blocks_operations_ex03.py b/doc/salome/examples/blocks_operations_ex03.py new file mode 100644 index 000000000..546bc2274 --- /dev/null +++ b/doc/salome/examples/blocks_operations_ex03.py @@ -0,0 +1,20 @@ +# Propagate + +import geompy +import salome + +# create a box +box = geompy.MakeBoxDXDYDZ(200, 200, 200) + +# build all possible propagation groups +listChains = geompy.Propagate(check_box) + +# add objects in the study +geompy.addToStudy(check_box, "Box") +ii = 1 +for chain in listChains: + geompy.addToStudyInFather(check_box, chain, "propagation chain " + `ii`) + ii = ii + 1 + pass + +salome.sg.updateObjBrowser(1) diff --git a/doc/salome/examples/boolean_operations_ex01.py b/doc/salome/examples/boolean_operations_ex01.py new file mode 100644 index 000000000..5f52542c6 --- /dev/null +++ b/doc/salome/examples/boolean_operations_ex01.py @@ -0,0 +1,38 @@ +# Fuse + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create a vertex and a vector +p1 = geompy.MakeVertex(25, 55, 0) +p2 = geompy.MakeVertex( 0, 0, 0) +v = geompy.MakeVector(p1, p2) + +# create a cylinder +height = 35 +radius1 = 20 +cylinder = geompy.MakeCylinder(p1, v, radius1, height) + +# create a sphere +sphere = geompy.MakeSphereR(40) + +# fuse +fuse1 = geompy.MakeFuse(cylinder, sphere) +fuse2 = geompy.MakeBoolean(cylinder, sphere, 3) + +# add objects in the study +id_cylinder = geompy.addToStudy(cylinder, "Cylinder") +id_sphere = geompy.addToStudy(sphere, "Sphere") +id_fuse1 = geompy.addToStudy(fuse1, "Fuse_1") +id_fuse2 = geompy.addToStudy(fuse2, "Fuse_2") + +# display results +gg.createAndDisplayGO(id_cylinder) +gg.setDisplayMode(id_cylinder,1) +gg.createAndDisplayGO(id_sphere) +gg.setDisplayMode(id_sphere,1) +gg.createAndDisplayGO(id_fuse1) +gg.setDisplayMode(id_fuse1,1) +gg.createAndDisplayGO(id_fuse2) +gg.setDisplayMode(id_fuse2,1) diff --git a/doc/salome/examples/boolean_operations_ex02.py b/doc/salome/examples/boolean_operations_ex02.py new file mode 100644 index 000000000..b7e73b727 --- /dev/null +++ b/doc/salome/examples/boolean_operations_ex02.py @@ -0,0 +1,28 @@ +# Common + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create a vertex and a vector +p1 = geompy.MakeVertex(25, 55, 0) +p2 = geompy.MakeVertex( 0, 0, 0) +v = geompy.MakeVector(p1, p2) + +# create a cylinder +height = 35 +radius1 = 20 +cylinder = geompy.MakeCylinder(p1, v, radius1, height) + +# create a sphere +sphere = geompy.MakeSphereR(40) + +# make common +common = geompy.MakeCommon(cylinder, sphere) + +# add objects in the study +id_common = geompy.addToStudy(common, "Common") + +# display the results +gg.createAndDisplayGO(id_common) +gg.setDisplayMode(id_common,1) diff --git a/doc/salome/examples/boolean_operations_ex03.py b/doc/salome/examples/boolean_operations_ex03.py new file mode 100644 index 000000000..44c597405 --- /dev/null +++ b/doc/salome/examples/boolean_operations_ex03.py @@ -0,0 +1,28 @@ +# Cut + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create a vertex and a vector +p1 = geompy.MakeVertex(25, 55, 0) +p2 = geompy.MakeVertex( 0, 0, 0) +v = geompy.MakeVector(p1, p2) + +# create a cylinder +height = 35 +radius1 = 20 +cylinder = geompy.MakeCylinder(p1, v, radius1, height) + +# create a sphere +sphere = geompy.MakeSphereR(40) + +#cut +cut = geompy.MakeCut(cylinder, sphere) + +# add objects in the study +id_cut = geompy.addToStudy(cut, "Cut") + +# display the results +gg.createAndDisplayGO(id_cut) +gg.setDisplayMode(id_cut,1) diff --git a/doc/salome/examples/boolean_operations_ex04.py b/doc/salome/examples/boolean_operations_ex04.py new file mode 100644 index 000000000..9472f7aa1 --- /dev/null +++ b/doc/salome/examples/boolean_operations_ex04.py @@ -0,0 +1,28 @@ +# Section + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create a vertex and a vector +p1 = geompy.MakeVertex(25, 55, 0) +p2 = geompy.MakeVertex( 0, 0, 0) +v = geompy.MakeVector(p1, p2) + +# create a cylinder +height = 35 +radius1 = 20 +cylinder = geompy.MakeCylinder(p1, v, radius1, height) + +# create a sphere +sphere = geompy.MakeSphereR(40) + +# make a section +section = geompy.MakeSection(cylinder, sphere) + +# add objects in the study +id_section = geompy.addToStudy(section, "Section") + +# display the results +gg.createAndDisplayGO(id_section) +gg.setDisplayMode(id_section,1) diff --git a/doc/salome/examples/bounding_box.py b/doc/salome/examples/bounding_box.py new file mode 100644 index 000000000..d6480aeac --- /dev/null +++ b/doc/salome/examples/bounding_box.py @@ -0,0 +1,17 @@ +# Bounding Box + +import geompy + +# create a box +box = geompy.MakeBoxDXDYDZ(100,30,100) + +bb = geompy.BoundingBox(box) +print "\nBounding Box of box 100x30x100:" +print " Xmin = ", bb[0], ", Xmax = ", bb[1] +print " Ymin = ", bb[2], ", Ymax = ", bb[3] +print " Zmin = ", bb[4], ", Zmax = ", bb[5] + +aBB = geompy.MakeBoundingBox(box) + +geompy.addToStudy(box, "box 100x30x100") +geompy.addToStudy(aBB, "Bounding box of box 100x30x100") diff --git a/doc/salome/examples/building_by_blocks_ex01.py b/doc/salome/examples/building_by_blocks_ex01.py new file mode 100644 index 000000000..16b02d75b --- /dev/null +++ b/doc/salome/examples/building_by_blocks_ex01.py @@ -0,0 +1,55 @@ +# Quadrangle Face + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create vertices +p1 = geompy.MakeVertex( 0., 0., 0.) +p2 = geompy.MakeVertex(150., 30., 0.) +p3 = geompy.MakeVertex( 0., 120., 50.) +p4 = geompy.MakeVertex( 0., 40., 70.) + +# create edges +edge1 = geompy.MakeEdge(p1, p2) +edge2 = geompy.MakeEdge(p2, p3) +edge3 = geompy.MakeEdge(p3, p4) +edge4 = geompy.MakeEdge(p4, p1) + +# create a quadrangle face from four edges +qface1 = geompy.MakeQuad(edge1, edge2, edge3, edge4) + +# create a quadrangle face from two edges +qface2 = geompy.MakeQuad2Edges(edge1, edge3) + +# create a quadrangle from four points in its corners +qface3 = geompy.MakeQuad4Vertices(p1, p2, p3, p4) + +# add objects in the study +id_p1 = geompy.addToStudy(p1,"Point1") +id_p2 = geompy.addToStudy(p2,"Point2") +id_p3 = geompy.addToStudy(p3,"Point3") +id_p4 = geompy.addToStudy(p4,"Point4") +id_edge1 = geompy.addToStudy(edge1,"Edge1") +id_edge2 = geompy.addToStudy(edge2,"Edge2") +id_edge3 = geompy.addToStudy(edge3,"Edge3") +id_edge4 = geompy.addToStudy(edge4,"Edge4") +id_qface1 = geompy.addToStudy(qface1,"Qface1") +id_qface2 = geompy.addToStudy(qface2,"Qface2") +id_qface3 = geompy.addToStudy(qface3,"Qface3") + +# display the vertices, the edges and the quadrangle faces +gg.createAndDisplayGO(id_p1) +gg.createAndDisplayGO(id_p2) +gg.createAndDisplayGO(id_p3) +gg.createAndDisplayGO(id_p4) +gg.createAndDisplayGO(id_edge1) +gg.createAndDisplayGO(id_edge2) +gg.createAndDisplayGO(id_edge3) +gg.createAndDisplayGO(id_edge4) +gg.createAndDisplayGO(id_qface1) +gg.setDisplayMode(id_qface1,1) +gg.createAndDisplayGO(id_qface2) +gg.setDisplayMode(id_qface2,1) +gg.createAndDisplayGO(id_qface3) +gg.setDisplayMode(id_qface3,1) diff --git a/doc/salome/examples/building_by_blocks_ex02.py b/doc/salome/examples/building_by_blocks_ex02.py new file mode 100644 index 000000000..ed81f4233 --- /dev/null +++ b/doc/salome/examples/building_by_blocks_ex02.py @@ -0,0 +1,54 @@ +# Hexagonal Solid + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create vertices +p0 = geompy.MakeVertex( 0., 0., 0.) +p1 = geompy.MakeVertex( 0., 0., 40.) +p2 = geompy.MakeVertex( 70., -15., 0.) +p3 = geompy.MakeVertex( 70., -15., 70.) + +p4 = geompy.MakeVertex( 0., 70., 0.) +p5 = geompy.MakeVertex( 0., 70., 40.) +p6 = geompy.MakeVertex( 70., 70., 0.) +p7 = geompy.MakeVertex( 70., 70., 70.) + +p8 = geompy.MakeVertex( 0., -50., 0.) +p9 = geompy.MakeVertex( 0., -50., 40.) +p10 = geompy.MakeVertex( 70., -35., 0.) +p11 = geompy.MakeVertex( 70., -35., 70.) + +# create faces +qface1 = geompy.MakeQuad4Vertices(p0, p1, p2, p3) +qface2 = geompy.MakeQuad4Vertices(p4, p5, p6, p7) +qface3 = geompy.MakeQuad4Vertices(p0, p1, p4, p5) +qface4 = geompy.MakeQuad4Vertices(p2, p3, p6, p7) +qface5 = geompy.MakeQuad4Vertices(p0, p2, p4, p6) +qface6 = geompy.MakeQuad4Vertices(p1, p3, p5, p7) +qface7 = geompy.MakeQuad4Vertices(p8, p9, p10, p11) + +# create a hexahedral solid between two given faces +solid1 = geompy.MakeHexa2Faces(qface1, qface7) + +# create a hexahedral solid, bounded by six given faces +solid2 = geompy.MakeHexa(qface1, qface2, qface3, qface4, qface5, qface6) + +# add objects in the study +geompy.addToStudy(qface1,"qface1") +geompy.addToStudy(qface2,"qface2") +geompy.addToStudy(qface3,"qface3") +geompy.addToStudy(qface4,"qface4") +geompy.addToStudy(qface5,"qface5") +geompy.addToStudy(qface6,"qface6") +geompy.addToStudy(qface7,"qface7") + +id_solid1 = geompy.addToStudy(solid1,"Solid1") +id_solid2 = geompy.addToStudy(solid2,"Solid2") + +# display solids +gg.createAndDisplayGO(id_solid1) +gg.setDisplayMode(id_solid1, 1) +gg.createAndDisplayGO(id_solid2) +gg.setDisplayMode(id_solid2, 1) diff --git a/doc/salome/examples/center_of_mass.py b/doc/salome/examples/center_of_mass.py new file mode 100644 index 000000000..acf5962ff --- /dev/null +++ b/doc/salome/examples/center_of_mass.py @@ -0,0 +1,19 @@ +# Center of masses + +import geompy +import math + +# create a box +box = geompy.MakeBoxDXDYDZ(100,30,100) +cm = geompy.MakeCDG(box) +if cm is None: + raise RuntimeError, "MakeCDG(box) failed" +else: + print "\nCentre of gravity of box has been successfully obtained:" + coords = geompy.PointCoordinates(cm) + print "(", coords[0], ", ", coords[1], ", ", coords[2], ")" + dx = math.sqrt((coords[0] - 50)*(coords[0] - 50)) + dy = math.sqrt((coords[1] - 15)*(coords[1] - 15)) + dz = math.sqrt((coords[2] - 50)*(coords[2] - 50)) + if dx > 1e-7 or dy > 1e-7 or dz > 1e-7: + print "But must be (50, 15, 50)" diff --git a/doc/salome/examples/check_compound_of_blocks.py b/doc/salome/examples/check_compound_of_blocks.py new file mode 100644 index 000000000..2f1ba9850 --- /dev/null +++ b/doc/salome/examples/check_compound_of_blocks.py @@ -0,0 +1,21 @@ +# Check Compound of Blocks + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create boxes +box1 = geompy.MakeBox(0,0,0,100,50,100) +box2 = geompy.MakeBox(100,0,0,250,50,100) + +# make a compound +compound = geompy.MakeCompound([box1, box2]) + +# glue the faces of the compound +tolerance = 1e-5 +glue = geompy.MakeGlueFaces(compound, tolerance) +IsValid = geompy.CheckCompoundOfBlocks(glue) +if IsValid == 0: + raise RuntimeError, "Invalid compound created" +else: + print "\nCompound is valid" diff --git a/doc/salome/examples/check_self_intersections.py b/doc/salome/examples/check_self_intersections.py new file mode 100644 index 000000000..44c55d257 --- /dev/null +++ b/doc/salome/examples/check_self_intersections.py @@ -0,0 +1,11 @@ +# Detect Self-intersections + +import geompy + +# create a box +box = geompy.MakeBoxDXDYDZ(100,30,100) +IsValid = geompy.CheckSelfIntersections(box) +if IsValid == 0: + raise RuntimeError, "Box with self-intersections created" +else: + print "\nBox is valid" diff --git a/doc/salome/examples/check_shape.py b/doc/salome/examples/check_shape.py new file mode 100644 index 000000000..b708494b3 --- /dev/null +++ b/doc/salome/examples/check_shape.py @@ -0,0 +1,11 @@ +# Check Shape + +import geompy + +# create a box +box = geompy.MakeBoxDXDYDZ(100,30,100) +IsValid = geompy.CheckShape(box) +if IsValid == 0: + raise RuntimeError, "Invalid box created" +else: + print "\nBox is valid" diff --git a/doc/salome/examples/complex_objs_ex01.py b/doc/salome/examples/complex_objs_ex01.py new file mode 100644 index 000000000..a5cf102c8 --- /dev/null +++ b/doc/salome/examples/complex_objs_ex01.py @@ -0,0 +1,61 @@ +# Creation of a Prism + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create a vertex and a vector +p1 = geompy.MakeVertex( 0., 0., 0.) +p2 = geompy.MakeVertex( 100., 0., 0.) +p3 = geompy.MakeVertex( 100., 100., 0.) +p4 = geompy.MakeVertex( 0., 100., 0.) +p5 = geompy.MakeVertex( 0., 0., 60.) +p6 = geompy.MakeVertex(-100., 0., 0.) +p7 = geompy.MakeVertex(-100.,-100., 0.) +p8 = geompy.MakeVertex( 0.,-100., 0.) + +# create a vector from the given components +vector = geompy.MakeVectorDXDYDZ(50., 50., 50.) + +#create vectors from two points +vector1_arc1 = geompy.MakeVector(p1, p2) +vector2_arc1 = geompy.MakeVector(p1, p4) +vector1_arc2 = geompy.MakeVector(p1, p6) +vector2_arc2 = geompy.MakeVector(p1, p8) + +# create arcs from three points +arc1 = geompy.MakeArc(p2, p3, p4) +arc2 = geompy.MakeArc(p6, p7, p8) + +# create wires +wire1 = geompy.MakeWire([vector1_arc1, arc1, vector2_arc1]) +wire2 = geompy.MakeWire([vector1_arc2, arc2, vector2_arc2]) + +# create faces +isPlanarWanted = 1 +face1 = geompy.MakeFace(wire1, isPlanarWanted) +face2 = geompy.MakeFace(wire2, isPlanarWanted) + +# create prisms +prism1 = geompy.MakePrism(face2, p1, p5) +prism2 = geompy.MakePrismVecH(face1, vector, 50) +prism3 = geompy.MakePrismVecH2Ways(face1, vector, 50) + +# add objects in the study +id_face1 = geompy.addToStudy(face1,"Face1") +id_face2 = geompy.addToStudy(face2,"Face2") +id_prism1 = geompy.addToStudy(prism1,"Prism1") +id_prism2 = geompy.addToStudy(prism2,"Prism2") +id_prism3 = geompy.addToStudy(prism3,"Prism3") + +# display cylinders +gg.createAndDisplayGO(id_face1) +gg.setDisplayMode(id_face1,1) +gg.createAndDisplayGO(id_face2) +gg.setDisplayMode(id_face2,1) +gg.createAndDisplayGO(id_prism1) +gg.setDisplayMode(id_prism1,1) +gg.createAndDisplayGO(id_prism2) +gg.setDisplayMode(id_prism2,1) +gg.createAndDisplayGO(id_prism3) +gg.setDisplayMode(id_prism3,1) diff --git a/doc/salome/examples/complex_objs_ex02.py b/doc/salome/examples/complex_objs_ex02.py new file mode 100644 index 000000000..e096551fd --- /dev/null +++ b/doc/salome/examples/complex_objs_ex02.py @@ -0,0 +1,34 @@ +# Creation of a Revolution + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create a vertex and a vector +p1 = geompy.MakeVertex( 10., 10., 10.) +p2 = geompy.MakeVertex( 15., 15., 50.) +p3 = geompy.MakeVertex( 40., 40., 0.) + +#create vectors from two points +vector1 = geompy.MakeVector(p1, p2) +vector2 = geompy.MakeVector(p1, p3) + +# create a vector from the given components +vector3 = geompy.MakeVectorDXDYDZ(-20., -20., 100.) + +# create a wire +wire = geompy.MakeWire([vector1, vector2]) + +# create a revolution +revolution = geompy.MakeRevolution(wire, vector3, 2.3) + +# add objects in the study +id_vector3 = geompy.addToStudy(vector3,"Axis") +id_wire = geompy.addToStudy(wire,"Wire") +id_revolution = geompy.addToStudy(revolution,"Revolution") + +# display the vector, the wire and the revolution +gg.createAndDisplayGO(id_vector3) +gg.createAndDisplayGO(id_wire) +gg.createAndDisplayGO(id_revolution) +gg.setDisplayMode(id_revolution,1) diff --git a/doc/salome/examples/complex_objs_ex03.py b/doc/salome/examples/complex_objs_ex03.py new file mode 100644 index 000000000..ec7767b2a --- /dev/null +++ b/doc/salome/examples/complex_objs_ex03.py @@ -0,0 +1,39 @@ +# Creation of a Filling + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +mindeg = 2 +maxdeg = 5 +tol3d = 0.0001 +tol2d = 0.0001 +nbiter = 5 + +# create a vertex and a vector +p1 = geompy.MakeVertex( -30., -30., 50.) +p2 = geompy.MakeVertex( -60., -60., 30.) +p3 = geompy.MakeVertex( -30., -30., 10.) + +# create an arc from three points +arc = geompy.MakeArc(p1, p2, p3) +ShapeListCompound = [] +i = 0 +while i <= 3 : + S = geompy.MakeTranslation(arc, i * 50., 0., 0.) + ShapeListCompound.append(S) + i = i + 1 + +compound = geompy.MakeCompound(ShapeListCompound) + +# create a filling +filling = geompy.MakeFilling(compound, mindeg, maxdeg, tol3d, tol2d, nbiter) + +# add objects in the study +id_compound = geompy.addToStudy(compound,"Compound") +id_filling = geompy.addToStudy(filling,"Filling") + +# display the compound and the filling +gg.createAndDisplayGO(id_compound) +gg.createAndDisplayGO(id_filling) +gg.setDisplayMode(id_filling,1) diff --git a/doc/salome/examples/complex_objs_ex04.py b/doc/salome/examples/complex_objs_ex04.py new file mode 100644 index 000000000..72af08f29 --- /dev/null +++ b/doc/salome/examples/complex_objs_ex04.py @@ -0,0 +1,38 @@ +# Creation of a Pipe + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create vertices +p0 = geompy.MakeVertex(0. , 0. , 0. ) +px = geompy.MakeVertex(100., 0. , 0. ) +py = geompy.MakeVertex(0. , 100., 0. ) +pz = geompy.MakeVertex(0. , 0. , 100.) +pxyz = geompy.MakeVertex(100., 100., 100.) + +# create a vector from two points +vxy = geompy.MakeVector(px, py) + +# create an arc from three points +arc = geompy.MakeArc(py, pz, px) + +# create a wire +wire = geompy.MakeWire([vxy, arc]) + +# create an edge +edge = geompy.MakeEdge(p0, pxyz) + +# create a pipe +pipe = geompy.MakePipe(wire, edge) + +# add objects in the study +id_wire = geompy.addToStudy(wire,"Wire") +id_edge = geompy.addToStudy(edge,"Edge") +id_pipe = geompy.addToStudy(pipe,"Pipe") + +# display the wire, the edge (path) and the pipe +gg.createAndDisplayGO(id_wire) +gg.createAndDisplayGO(id_edge) +gg.createAndDisplayGO(id_pipe) +gg.setDisplayMode(id_pipe,1) diff --git a/doc/salome/examples/complex_objs_ex05.py b/doc/salome/examples/complex_objs_ex05.py new file mode 100644 index 000000000..724810c58 --- /dev/null +++ b/doc/salome/examples/complex_objs_ex05.py @@ -0,0 +1,32 @@ +# Creation of a PipeWithDifferentSections + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +Wire_1 = geompy.MakeSketcher("Sketcher:F 0 0:TT 100 0:R 0:C 100 90:T 0 200", [0, 0, 0, 0, 0, 1, 1, 0, -0]) +edges = geompy.SubShapeAll(Wire_1, geompy.ShapeType["EDGE"]) +vertices = geompy.SubShapeAll(Wire_1, geompy.ShapeType["VERTEX"]) + +# create sections +circles=[] +circles.append(geompy.MakeCircle(vertices[0], edges[0], 20)) +circles.append(geompy.MakeCircle(vertices[1], edges[0], 40)) +circles.append(geompy.MakeCircle(vertices[2], edges[2], 30)) +circles.append(geompy.MakeCircle(vertices[3], edges[2], 20)) + +# create pipe +Pipe = geompy.MakePipeWithDifferentSections(circles, vertices, Wire_1, 0, 0) + +# add objects in the study +geompy.addToStudy(circles[0], "circles1") +geompy.addToStudy(circles[1], "circles2") +geompy.addToStudy(circles[2], "circles3") +geompy.addToStudy(circles[3], "circles4") +id_wire = geompy.addToStudy(Wire_1, "Path") +id_pipe = geompy.addToStudy(Pipe, "Pipe") + +# display the wire(path) and the pipe +gg.createAndDisplayGO(id_wire) +gg.createAndDisplayGO(id_pipe) +gg.setDisplayMode(id_pipe,1) diff --git a/doc/salome/examples/complex_objs_ex06.py b/doc/salome/examples/complex_objs_ex06.py new file mode 100644 index 000000000..a836b35fc --- /dev/null +++ b/doc/salome/examples/complex_objs_ex06.py @@ -0,0 +1,192 @@ +# Creation of a PipeWithShellSections + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create path +WirePath = geompy.MakeSketcher("Sketcher:F 0 0:TT 100 0:R 0:C 100 90:T 0 200", [0, 0, 0, 0, 0, 1, 1, 0, -0]) + +#======================================================= +# Create shell sections +#======================================================= +ps = [Vertex_1,Vertex_2,Vertex_3,Vertex_4] +theLocations = [Vertex_1, Vertex_2, Vertex_3, Vertex_4] +VC = geompy.MakeCompound(theLocations) +geompy.addToStudy(VC,"VC") +vs = [Edge_1,Edge_1,Edge_3,Edge_3] +hs = [20,40,30,20] +shells = [] +subbases = [] + +# 1 section +c0 = geompy.PointCoordinates(ps[0]) +c1 = geompy.PointCoordinates(ps[1]) +nx = c1[0] - c0[0] +ny = c1[1] - c0[1] +nz = c1[2] - c0[2] + +faces = [] +f1 = geompy.MakeSketcher("Sketcher:F 0 0:TT 20 0:TT 20 20:TT 0 20:WF", + [c0[0], c0[1], c0[2], nx, ny, nz, 0, 0, 1]) +f2 = geompy.MakeSketcher("Sketcher:F 0 0:TT 0 20:TT -20 20:TT -20 0:WF", + [c0[0], c0[1], c0[2], nx, ny, nz, 0, 0, 1]) +f3 = geompy.MakeSketcher("Sketcher:F 0 0:TT -20 0:TT -20 -20:TT 0 -20:WF", + [c0[0], c0[1], c0[2], nx, ny, nz, 0, 0, 1]) +f4 = geompy.MakeSketcher("Sketcher:F 0 0:TT 0 -20:TT 20 -20:TT 20 0:WF", + [c0[0], c0[1], c0[2], nx, ny, nz, 0, 0, 1]) +faces.append(f1) +faces.append(f2) +faces.append(f3) +faces.append(f4) +shell = geompy.MakeSewing(faces,1.e-6) +shells.append(shell) +faces = geompy.SubShapeAllSortedCentres(shell, geompy.ShapeType["FACE"]) +subbases.append(faces[0]) + +# 2 section +faces = [] + +w = geompy.MakeSketcher("Sketcher:F 20 20:TT 0 20:TT 0 0:TT 20 0", + [c1[0], c1[1], c1[2], nx, ny, nz, 0, 0, 1]) +[e1,e2,e3] = geompy.SubShapeAll(w, geompy.ShapeType["EDGE"]) +arc = MakeArc(w,3,-1) +w = geompy.MakeWire([e1,e2,e3,arc]) +f1 = geompy.MakeFace(w,1) + +w = geompy.MakeSketcher("Sketcher:F -20 0:TT 0 0:TT 0 20:TT -20 20", + [c1[0], c1[1], c1[2], nx, ny, nz, 0, 0, 1]) +[e1,e2,e3] = geompy.SubShapeAll(w, geompy.ShapeType["EDGE"]) +arc = MakeArc(w,3,-1) +w = geompy.MakeWire([e1,e2,e3,arc]) +f2 = geompy.MakeFace(w,1) + +w = geompy.MakeSketcher("Sketcher:F 20 0:TT 0 0:TT 0 -20:TT 20 -20", + [c1[0], c1[1], c1[2], nx, ny, nz, 0, 0, 1]) +[e1,e2,e3] = geompy.SubShapeAll(w, geompy.ShapeType["EDGE"]) +arc = MakeArc(w,3,-1) +w = geompy.MakeWire([e1,e2,e3,arc]) +f3 = geompy.MakeFace(w,1) + +w = geompy.MakeSketcher("Sketcher:F -20 -20:TT 0 -20:TT 0 0:TT -20 0", + [c1[0], c1[1], c1[2], nx, ny, nz, 0, 0, 1]) +[e1,e2,e3] = geompy.SubShapeAll(w, geompy.ShapeType["EDGE"]) +arc = MakeArc(w,3,-1) +w = geompy.MakeWire([e1,e2,e3,arc]) +f4 = geompy.MakeFace(w,1) + +faces.append(f1) +faces.append(f2) +faces.append(f3) +faces.append(f4) +shell = geompy.MakeSewing(faces,1.e-6) +shells.append(shell) +faces = geompy.SubShapeAllSortedCentres(shell, geompy.ShapeType["FACE"]) +subbases.append(faces[0]) + +# 3 section +faces = [] +c2 = geompy.PointCoordinates(ps[2]) +c3 = geompy.PointCoordinates(ps[3]) +nx = c3[0] - c2[0] +ny = c3[1] - c2[1] +nz = c3[2] - c2[2] + +w = geompy.MakeSketcher("Sketcher:F 20 20:TT 0 20:TT 0 0:TT 20 0", + [c2[0], c2[1], c2[2], nx, ny, nz, 0, 0, 1]) +[e1,e2,e3] = geompy.SubShapeAll(w, geompy.ShapeType["EDGE"]) +arc = MakeArc(w,3,1) +w = geompy.MakeWire([e1,e2,e3,arc]) +f1 = geompy.MakeFace(w,1) + +w = geompy.MakeSketcher("Sketcher:F -20 0:TT 0 0:TT 0 20:TT -20 20", + [c2[0], c2[1], c2[2], nx, ny, nz, 0, 0, 1]) +[e1,e2,e3] = geompy.SubShapeAll(w, geompy.ShapeType["EDGE"]) +arc = MakeArc(w,3,1) +w = geompy.MakeWire([e1,e2,e3,arc]) +f2 = geompy.MakeFace(w,1) + +w = geompy.MakeSketcher("Sketcher:F 20 0:TT 0 0:TT 0 -20:TT 20 -20", + [c2[0], c2[1], c2[2], nx, ny, nz, 0, 0, 1]) +[e1,e2,e3] = geompy.SubShapeAll(w, geompy.ShapeType["EDGE"]) +arc = MakeArc(w,3,1) +w = geompy.MakeWire([e1,e2,e3,arc]) +f3 = geompy.MakeFace(w,1) + +w = geompy.MakeSketcher("Sketcher:F -20 -20:TT 0 -20:TT 0 0:TT -20 0", + [c2[0], c2[1], c2[2], nx, ny, nz, 0, 0, 1]) +[e1,e2,e3] = geompy.SubShapeAll(w, geompy.ShapeType["EDGE"]) +arc = MakeArc(w,3,1) +w = geompy.MakeWire([e1,e2,e3,arc]) +f4 = geompy.MakeFace(w,1) + +faces.append(f1) +faces.append(f2) +faces.append(f3) +faces.append(f4) +shell = geompy.MakeSewing(faces,1.e-6) +shells.append(shell) +faces = geompy.SubShapeAllSortedCentres(shell, geompy.ShapeType["FACE"]) +subbases.append(faces[2]) + +# 4 section +faces = [] + +kk = 4 +dx = c3[0] - nx/kk +dy = c3[1] - ny/kk +dz = c3[2] - nz/kk +rad = math.sqrt(nx*nx+ny*ny+nz*nz) +vc = geompy.MakeVertex(dx,dy,dz) +sph = geompy.MakeSpherePntR(vc,rad/kk) +shellsph = geompy.SubShapeAll(sph, geompy.ShapeType["SHELL"]) + +fs = [] +vec = geompy.MakeVectorDXDYDZ(0,0,1) +ff = geompy.MakePlane(ps[3],vec,40) +fs.append(ff) +vp = geompy.MakeVertex(c3[0],c3[1],c3[2]+20) +ff = geompy.MakePlane(vp,vec,40) +fs.append(ff) +vp = geompy.MakeVertex(c3[0],c3[1],c3[2]-20) +ff = geompy.MakePlane(vp,vec,40) +fs.append(ff) +vec = geompy.MakeVectorDXDYDZ(1,0,0) +ff = geompy.MakePlane(ps[3],vec,40) +fs.append(ff) +vp = geompy.MakeVertex(c3[0]+20,c3[1],c3[2]) +ff = geompy.MakePlane(vp,vec,40) +fs.append(ff) +vp = geompy.MakeVertex(c3[0]-20,c3[1],c3[2]) +ff = geompy.MakePlane(vp,vec,40) +fs.append(ff) +aPartition = geompy.MakePartition(shellsph,fs) +fs = geompy.SubShapeAllSortedCentres(aPartition, geompy.ShapeType["FACE"]) + +faces.append(fs[0]) +faces.append(fs[1]) +faces.append(fs[2]) +faces.append(fs[3]) +shell = geompy.MakeSewing(faces,1.e-6) +shells.append(shell) +faces = geompy.SubShapeAllSortedCentres(shell, geompy.ShapeType["FACE"]) + + +#=========================================================== +# Create Pipe +#=========================================================== +subbases = [] +Pipe = geompy.MakePipeWithShellSections(shells, subbases, theLocations, WirePath, + theWithContact=0, theWithCorrection=0) + +# add objects in the study +resc = geompy.MakeCompound(shells) +id_sec = geompy.addToStudy(resc,"sections") +id_wire = geompy.addToStudy(WirePath,"WirePath") +id_pipe = geompy.addToStudy(Pipe, "Pipe") + +# display the wire(path), sections and the pipe +gg.createAndDisplayGO(id_wire) +gg.createAndDisplayGO(id_sec) +gg.createAndDisplayGO(id_pipe) +gg.setDisplayMode(id_pipe,1) diff --git a/doc/salome/examples/complex_objs_ex07.py b/doc/salome/examples/complex_objs_ex07.py new file mode 100644 index 000000000..1b37a2e39 --- /dev/null +++ b/doc/salome/examples/complex_objs_ex07.py @@ -0,0 +1,116 @@ +# Creation of a PipeShellsWithoutPath + +import geompy +import math +import salome +gg = salome.ImportComponentGUI("GEOM") + +# Add a section based on quadrangles +# ---------------------------------- +def section(s, p1, p2=None, p3=None, p4=None): + if p2==None: + q = p1 + else: + q = geompy.MakeQuad4Vertices(p1, p2, p3, p4) + pass + s.append(q) + publish(q, "section") + return q + + +# find distance between two points +# ------------------------------- +def Dist(p1,p2): + c1 = geompy.PointCoordinates(p1) + c2 = geompy.PointCoordinates(p2) + return math.sqrt( (c2[0]-c1[0])*(c2[0]-c1[0]) + + (c2[1]-c1[1])*(c2[1]-c1[1]) + + (c2[2]-c1[2])*(c2[2]-c1[2]) ) + + +# return middle point +# ------------------------------- +def MiddleVert(p1,p2): + c1 = geompy.PointCoordinates(p1) + c2 = geompy.PointCoordinates(p2) + return geompy.MakeVertex( (c2[0]+c1[0])/2, (c2[1]+c1[1])/2, (c2[2]+c1[2])/2 ) + + +# Complex section +# result - 16 quads from lines +# pnt - point from path +# vec - direction from path +def MakeComplexSect(pnt,vec,rmax,rmin,nb): + dang = 1.0/nb/2 + cmax = geompy.MakeCircle(pnt,vec,rmax) + cmin = geompy.MakeCircle(pnt,vec,rmin) + faces = [] + for i in range(0,2*nb,2): + p1 = geompy.MakeVertexOnCurve(cmin,dang*i) + p2 = geompy.MakeVertexOnCurve(cmax,dang*(i+1)) + p3 = geompy.MakeVertexOnCurve(cmin,dang*(i+2)) + f = geompy.MakeQuad4Vertices(pnt,p1,p2,p3) + faces.append(f) + pass + shell = geompy.MakeSewing(faces,1.e-6) + return shell + + +#======================================================= +# Create simple path and recieve points +# for section creation +#======================================================= +WirePath = geompy.MakeSketcher("Sketcher:F 0 0:T 60 0:T 40 0:R 0:C 100 90:", + [0, 0, 0, 0, 0, 1, 1, 0, 0]) +vs = geompy.SubShapeAll(WirePath, geompy.ShapeType["VERTEX"]) + +#======================================================= +# Create shell sections +#======================================================= +shells = [] +subbases = [] +locs = [] + +# 1 section +shell = MakeComplexSect(vs[0], geompy.MakeVectorDXDYDZ(1,0,0), 60, 40, 16) +shells.append(shell) +vs1 = geompy.SubShapeAllSortedCentres(shell,geompy.ShapeType["VERTEX"]) +locs.append(vs1[17]) + +# 2 section +shell = MakeComplexSect(vs[1], geompy.MakeVectorDXDYDZ(1,0,0), 80, 30, 16) +shells.append(shell) +vs2 = geompy.SubShapeAllSortedCentres(shell,geompy.ShapeType["VERTEX"]) +locs.append(vs2[17]) + +# 3 section +shell = MakeComplexSect(vs[2], geompy.MakeVectorDXDYDZ(1,0,0), 60, 40, 16) +shells.append(shell) +vs3 = geompy.SubShapeAllSortedCentres(shell,geompy.ShapeType["VERTEX"]) +locs.append(vs3[17]) + +# 4 section +shell = MakeComplexSect(vs[3], geompy.MakeVectorDXDYDZ(0,1,0), 40, 35, 16) +shells.append(shell) +vs4 = geompy.SubShapeAllSortedCentres(shell,geompy.ShapeType["VERTEX"]) +locs.append(vs4[17]) + + +#=========================================================== +# Create Pipe +#=========================================================== + +Pipe = geompy.MakePipeShellsWithoutPath(shells,locs) + +# add objects in the study +resc = geompy.MakeCompound(shells) +id_sec = geompy.addToStudy(resc,"sections") +resl = geompy.MakeCompound(locs) +id_loc = geompy.addToStudy(resl,"locations") +id_pipe = geompy.addToStudy(Pipe, "Pipe") + +# display the sections, locations and pipe +gg.createAndDisplayGO(id_sec) +gg.createAndDisplayGO(id_loc) +gg.createAndDisplayGO(id_pipe) +gg.setDisplayMode(id_pipe,1) diff --git a/doc/salome/examples/complex_objs_ex08.py b/doc/salome/examples/complex_objs_ex08.py new file mode 100644 index 000000000..4777e071b --- /dev/null +++ b/doc/salome/examples/complex_objs_ex08.py @@ -0,0 +1,76 @@ +# Creation of a PipeBiNormalAlongVector + +def MakeHelix(radius, height, rotation, direction): + # - create a helix - + radius = 1.0 * radius + height = 1.0 * height + rotation = 1.0 * rotation + if direction > 0: + direction = +1 + else: + direction = -1 + pass + from math import sqrt + length_z = height + length_xy = radius*rotation + length = sqrt(length_z*length_z + length_xy*length_xy) + import geompy + nb_steps = 1 + epsilon = 1.0e-6 + while 1: + z_step = height / nb_steps + angle_step = rotation / nb_steps + z = 0.0 + angle = 0.0 + helix_points = [] + for n in range(nb_steps+1): + from math import cos, sin + x = radius * cos(angle) + y = radius * sin(angle) + p = geompy.MakeVertex(x, y, z) + helix_points.append( p ) + z += z_step + angle += direction * angle_step + pass + helix = geompy.MakeInterpol(helix_points) + length_test = geompy.BasicProperties(helix)[0] + prec = abs(length-length_test)/length + # print nb_steps, length_test, prec + if prec < epsilon: + break + nb_steps *= 2 + pass + return helix + +def MakeSpring(radius, height, rotation, direction, thread_radius, base_rotation=0.0): + # - create a pipe - + thread_radius = 1.0 * thread_radius + # create a helix + helix = MakeHelix(radius, height, rotation, direction) + # base in the (Ox, Oz) plane + import geompy + p0 = geompy.MakeVertex(radius-3*thread_radius, 0.0, -thread_radius) + p1 = geompy.MakeVertex(radius+3*thread_radius, 0.0, -thread_radius) + p2 = geompy.MakeVertex(radius+3*thread_radius, 0.0, +thread_radius) + p3 = geompy.MakeVertex(radius-3*thread_radius, 0.0, +thread_radius) + e0 = geompy.MakeEdge(p0, p1) + e1 = geompy.MakeEdge(p1, p2) + e2 = geompy.MakeEdge(p2, p3) + e3 = geompy.MakeEdge(p3, p0) + w = geompy.MakeWire([e0, e1, e2, e3]) + # create a base face + base = geompy.MakeFace(w, True) + # create a binormal vector + binormal = geompy.MakeVectorDXDYDZ(0.0, 0.0, 10.0) + # create a pipe + spring = geompy.MakePipeBiNormalAlongVector(base, helix, binormal) + # Publish in the study + geompy.addToStudy(base, "base") + geompy.addToStudy(helix, "helix") + geompy.addToStudy(binormal, "binormal") + geompy.addToStudy(spring, "spring") + return spring + +from math import pi + +spring = MakeSpring(50, 100, 2*pi, 1, 5, pi/2) diff --git a/doc/salome/examples/complex_objs_ex09.py b/doc/salome/examples/complex_objs_ex09.py new file mode 100644 index 000000000..55c347a1f --- /dev/null +++ b/doc/salome/examples/complex_objs_ex09.py @@ -0,0 +1,43 @@ +# Creation of a Middle Path + +import salome +import geompy + +# Create a box +Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200) + +# Get two opposite faces +[Face_1,Face_2] = geompy.SubShapes(Box_1, [31, 33]) + +# Get edges +Box_1_edge_12 = geompy.GetSubShape(Box_1, [12]) +Box_1_edge_22 = geompy.GetSubShape(Box_1, [22]) +Box_1_edge_25 = geompy.GetSubShape(Box_1, [25]) +Box_1_edge_29 = geompy.GetSubShape(Box_1, [29]) +Box_1_edge_8 = geompy.GetSubShape(Box_1, [8]) +Box_1_edge_18 = geompy.GetSubShape(Box_1, [18]) +Box_1_edge_26 = geompy.GetSubShape(Box_1, [26]) +Box_1_edge_30 = geompy.GetSubShape(Box_1, [30]) + +# These three calls to RestorePath return the same result +Path_1 = geompy.RestorePath(Box_1, Face_1, Face_2) +Path_2 = geompy.RestorePathEdges(Box_1, [Face_1], [Face_2]) +Path_3 = geompy.RestorePathEdges(Box_1, + [Box_1_edge_12, Box_1_edge_22, Box_1_edge_25, Box_1_edge_29], + [Box_1_edge_8, Box_1_edge_18, Box_1_edge_26, Box_1_edge_30]) + +# Publish created objects +geompy.addToStudy( Box_1, 'Box_1' ) +geompy.addToStudyInFather( Box_1, Face_1, 'Face_1' ) +geompy.addToStudyInFather( Box_1, Face_2, 'Face_2' ) +geompy.addToStudyInFather( Box_1, Box_1_edge_25, 'Box_1:edge_25' ) +geompy.addToStudyInFather( Box_1, Box_1_edge_22, 'Box_1:edge_22' ) +geompy.addToStudyInFather( Box_1, Box_1_edge_12, 'Box_1:edge_12' ) +geompy.addToStudyInFather( Box_1, Box_1_edge_29, 'Box_1:edge_29' ) +geompy.addToStudyInFather( Box_1, Box_1_edge_18, 'Box_1:edge_18' ) +geompy.addToStudyInFather( Box_1, Box_1_edge_26, 'Box_1:edge_26' ) +geompy.addToStudyInFather( Box_1, Box_1_edge_8, 'Box_1:edge_8' ) +geompy.addToStudyInFather( Box_1, Box_1_edge_30, 'Box_1:edge_30' ) +geompy.addToStudy( Path_1, 'Path_1' ) +geompy.addToStudy( Path_2, 'Path_2' ) +geompy.addToStudy( Path_3, 'Path_3' ) diff --git a/doc/salome/examples/complex_objs_ex10.py b/doc/salome/examples/complex_objs_ex10.py new file mode 100644 index 000000000..8a14455ef --- /dev/null +++ b/doc/salome/examples/complex_objs_ex10.py @@ -0,0 +1,24 @@ +# Creation of Tangent Plane On Face + +import salome +import geompy + +# Create Vertexes for curve +Vertex_1 = geompy.MakeVertex(0, 0, 0) +Vertex_2 = geompy.MakeVertex(0, 90, 30) +Vertex_3 = geompy.MakeVertex(100, 90, 0) +Vertex_4 = geompy.MakeVertex(-100, 90, 0) +# Create curve +Curve_1 = geompy.MakeInterpol([Vertex_4, Vertex_2, Vertex_3, Vertex_1]) +# Create Face by Extrusion of the Curve +Extrusion_1 = geompy.MakePrismDXDYDZ(Curve_1, 0, 30, -60) +# Make Tangent on this Extrusion (Face) +Tangent_1 = geompy.MakeTangentPlaneOnFace(Extrusion_1, 0.7, 0.5, 150) +# Publish in the study +geompy.addToStudy( Vertex_1, "Vertex_1" ) +geompy.addToStudy( Vertex_2, "Vertex_2" ) +geompy.addToStudy( Vertex_3, "Vertex_3" ) +geompy.addToStudy( Vertex_4, "Vertex_4" ) +geompy.addToStudy( Curve_1, "Curve_1" ) +geompy.addToStudy( Extrusion_1, "Extrusion_1" ) +geompy.addToStudy( Tangent_1, "Tangent_1" ) diff --git a/doc/salome/examples/free_boundaries.py b/doc/salome/examples/free_boundaries.py new file mode 100644 index 000000000..7582f79dc --- /dev/null +++ b/doc/salome/examples/free_boundaries.py @@ -0,0 +1,79 @@ +# Check Free Boundaries + +import os +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create boxes +box1 = geompy.MakeBox(0,0,0,100,50,100) +box2 = geompy.MakeBox(100,0,0,250,50,100) + +# make a compound +compound = geompy.MakeCompound([box1, box2]) + +# import from *.brep +ImportFromBREP = geompy.ImportBREP(os.getenv("DATA_DIR")+"/Shapes/Brep/flight_solid.brep") + +# get a face +faces = geompy.SubShapeAllSortedCentres(ImportFromBREP, geompy.ShapeType["FACE"]) + +# get the free boundary for face 32 +Res = geompy.GetFreeBoundary(faces[32]) +isSuccess = Res[0] +ClosedWires = Res[1] +OpenWires = Res[2] + +if isSuccess == 1 : + print "Checking free boudaries is OK." +else : + print "Checking free boudaries is KO!" +print "len(ClosedWires) = ", len(ClosedWires) + +i = 0 +for wire in ClosedWires : + wire_name = "Face 32 -> Close wires : WIRE %d"%(i+1) + geompy.addToStudy(ClosedWires[i], wire_name) + if i < len(ClosedWires) : + i = i+ 1 + +print "len(OpenWires) = ", len(OpenWires) + +i = 0 +for wire in OpenWires : + wire_name = "Face 32 -> Open wires : WIRE %d"%(i+1) + geompy.addToStudy(OpenWires[i], wire_name) + if i < len(OpenWires) : + i = i+ 1 + +# get the free boundary for face 41 +Res = geompy.GetFreeBoundary(faces[41]) +isSuccess = Res[0] +ClosedWires = Res[1] +OpenWires = Res[2] + +if isSuccess == 1 : + print "Checking free boudaries is OK." +else : + print "Checking free boudaries is KO!" +print "len(ClosedWires) = ", len(ClosedWires) + +i = 0 +for wire in ClosedWires : + wire_name = "Face 41 -> Close wires : WIRE %d"%(i+1) + geompy.addToStudy(ClosedWires[i], wire_name) + if i < len(ClosedWires) : + i = i+ 1 + +print "len(OpenWires) = ", len(OpenWires) + +i = 0 +for wire in OpenWires : + wire_name = "Face 41 -> Open wires : WIRE %d"%(i+1) + geompy.addToStudy(OpenWires[i], wire_name) + if i < len(OpenWires) : + i = i+ 1 + +# add the imported object to the study +id_ImportFromBREP = geompy.addToStudy(ImportFromBREP, "ImportFromBREP") +salome.sg.updateObjBrowser(1) diff --git a/doc/salome/examples/free_faces.py b/doc/salome/examples/free_faces.py new file mode 100644 index 000000000..16d705614 --- /dev/null +++ b/doc/salome/examples/free_faces.py @@ -0,0 +1,46 @@ +# Check Free Faces + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create a vertex and a vector +p1 = geompy.MakeVertex(35, 35, 0) +p2 = geompy.MakeVertex(35, 35, 50) +v = geompy.MakeVector(p1, p2) + +# create a cylinder +cylinder = geompy.MakeCone(p1, v, 30, 20, 20) + +# create a cone +cone = geompy.MakeCone(p1, v, 70, 40, 60) + +# make cut +cut = geompy.MakeCut(cone, cylinder) + +# get faces as sub-shapes +faces = [] +faces = geompy.SubShapeAllSortedCentres(cut, geompy.ShapeType["FACE"]) +f_2 = geompy.GetSubShapeID(cut, faces[0]) + +# remove one face from the shape +cut_without_f_2 = geompy.SuppressFaces(cut, [f_2]) + +# suppress the specified wire +result = geompy.GetFreeFacesIDs(cut_without_f_2) +print "A number of free faces is ", len(result) + +# add objects in the study +all_faces = geompy.SubShapeAllSortedCentres(cut_without_f_2, geompy.ShapeType["FACE"]) +for face in all_faces : + sub_shape_id = geompy.GetSubShapeID(cut_without_f_2, face) + if result.count(sub_shape_id) > 0 : + face_name = "Free face %d"%(sub_shape_id) + geompy.addToStudy(face, face_name) + +# in this example all faces from cut_without_f_2 are free +id_cut_without_f_2 = geompy.addToStudy(cut_without_f_2, "Cut without f_2") + +# display the results +gg.createAndDisplayGO(id_cut_without_f_2) +gg.setDisplayMode(id_cut_without_f_2,1) diff --git a/doc/salome/examples/get_non_blocks.py b/doc/salome/examples/get_non_blocks.py new file mode 100644 index 000000000..267fa870a --- /dev/null +++ b/doc/salome/examples/get_non_blocks.py @@ -0,0 +1,26 @@ +# Get Non Blocks + +import geompy +import salome + +# create solids +box = geompy.MakeBoxDXDYDZ(100, 100, 100) +cyl = geompy.MakeCylinderRH(100, 200) + +geompy.addToStudy(box, 'box') +geompy.addToStudy(cyl, 'cyl') + +# make a compound +compound = geompy.MakeCompound([box, cyl]) +geompy.addToStudy(compound, 'compound') + +# explore the compound +pair = geompy.GetNonBlocks(compound) + +if pair[0] is not None: + geompy.addToStudyInFather(compound, pair[0], "GrNonBlocks") + pass + +if pair[1] is not None: + geompy.addToStudyInFather(compound, pair[1], "GrNonQuads") + pass diff --git a/doc/salome/examples/import_export.py b/doc/salome/examples/import_export.py new file mode 100644 index 000000000..ecde2442f --- /dev/null +++ b/doc/salome/examples/import_export.py @@ -0,0 +1,40 @@ +# Import/Export + +import geompy +import salome + +# Example of import from IGES using various formats + +# get a path to SAMPLES_SRC +import os +thePath = os.getenv("DATA_DIR") +# create filenames +theFileName1 = thePath + "/Shapes/Iges/boite-3Dipsos_m.igs" +theFileName2 = thePath + "/Shapes/Iges/boite-3Dipsos_mm.igs" +#print "thePath = ", thePath + +# get units from files +UnitName1 = geompy.GetIGESUnit(theFileName1) +UnitName2 = geompy.GetIGESUnit(theFileName2) +print "UnitName1 = ", UnitName1 +print "UnitName2 = ", UnitName2 + +# import shapes +Shape1 = geompy.ImportIGES(theFileName1) +Shape2 = geompy.ImportIGES(theFileName2) +Shape3 = geompy.ImportFile(theFileName2,"IGES_SCALE") +[Xmin1,Xmax1, Ymin1,Ymax1, Zmin1,Zmax1] = geompy.BoundingBox(Shape1) +[Xmin2,Xmax2, Ymin2,Ymax2, Zmin2,Zmax2] = geompy.BoundingBox(Shape2) +[Xmin3,Xmax3, Ymin3,Ymax3, Zmin3,Zmax3] = geompy.BoundingBox(Shape3) +geompy.addToStudy(Shape1, "3Dipsos_m") +geompy.addToStudy(Shape2, "3Dipsos_mm") +geompy.addToStudy(Shape3, "3Dipsos_mm_scaled") +d1 = (Xmax1-Xmin1)*(Xmax1-Xmin1) + (Ymax1-Ymin1)*(Ymax1-Ymin1) + (Zmax1-Zmin1)*(Zmax1-Zmin1) +d2 = (Xmax2-Xmin2)*(Xmax2-Xmin2) + (Ymax2-Ymin2)*(Ymax2-Ymin2) + (Zmax2-Zmin2)*(Zmax2-Zmin2) +d3 = (Xmax3-Xmin3)*(Xmax3-Xmin3) + (Ymax3-Ymin3)*(Ymax3-Ymin3) + (Zmax3-Zmin3)*(Zmax3-Zmin3) +import math +dd32 = math.sqrt(d3/d2) +dd12 = math.sqrt(d1/d2) +dd31 = math.sqrt(d3/d1) +# values dd31, dd12 and dd31 can be using for checking +print "dd32 = ",dd32," dd12 = ",dd12," dd31 = ",dd31 diff --git a/doc/salome/examples/inertia.py b/doc/salome/examples/inertia.py new file mode 100644 index 000000000..203a39436 --- /dev/null +++ b/doc/salome/examples/inertia.py @@ -0,0 +1,14 @@ +# Inertia + +import geompy +import math + +# create a box +box = geompy.MakeBoxDXDYDZ(100,30,100) +In = geompy.Inertia(box) +print "\nInertia matrix of box 100x30x100:" +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 100x30x100:" +print " Ix = ", In[9], ", Iy = ", In[10], ", Iz = ", In[11] diff --git a/doc/salome/examples/min_distance.py b/doc/salome/examples/min_distance.py new file mode 100644 index 000000000..e6048bba2 --- /dev/null +++ b/doc/salome/examples/min_distance.py @@ -0,0 +1,49 @@ +# Minimal Distance + +import geompy + +# Create two curves with three closest points +Vertex_1 = geompy.MakeVertex(0, 0, 0) +Vertex_2 = geompy.MakeVertex(0, 70, 0) +Vertex_3 = geompy.MakeVertex(30, 100, 0) +Vertex_4 = geompy.MakeVertex(60, 70, 0) +Vertex_5 = geompy.MakeVertex(90, 100, 0) +Vertex_6 = geompy.MakeVertex(120, 70, 0) +Vertex_7 = geompy.MakeVertex(120, 0, 0) +Vertex_8 = geompy.MakeVertex(90, -30, 0) +Vertex_9 = geompy.MakeVertex(60, 0, 0) +Vertex_10 = geompy.MakeVertex(30, -30, 0) + +geompy.addToStudy( Vertex_1, 'Vertex_1' ) +geompy.addToStudy( Vertex_2, 'Vertex_2' ) +geompy.addToStudy( Vertex_3, 'Vertex_3' ) +geompy.addToStudy( Vertex_4, 'Vertex_4' ) +geompy.addToStudy( Vertex_5, 'Vertex_5' ) +geompy.addToStudy( Vertex_6, 'Vertex_6' ) +geompy.addToStudy( Vertex_7, 'Vertex_7' ) +geompy.addToStudy( Vertex_8, 'Vertex_8' ) +geompy.addToStudy( Vertex_9, 'Vertex_9' ) +geompy.addToStudy( Vertex_10, 'Vertex_10' ) + +Curve_a = geompy.MakeInterpol([Vertex_2, Vertex_3, Vertex_4, Vertex_5, Vertex_6], False, True) +Curve_b = geompy.MakeInterpol([Vertex_1, Vertex_7, Vertex_8, Vertex_9, Vertex_10], False, True) + +geompy.addToStudy( Curve_a, 'Curve_a' ) +geompy.addToStudy( Curve_b, 'Curve_b' ) + +# Get all closest points +[nbSols, listCoords] = geompy.ClosestPoints(Curve_a, Curve_b) + +for i in range(nbSols): + v1 = geompy.MakeVertex(listCoords[i*6 + 0], listCoords[i*6 + 1], listCoords[i*6 + 2]) + v2 = geompy.MakeVertex(listCoords[i*6 + 3], listCoords[i*6 + 4], listCoords[i*6 + 5]) + + geompy.addToStudy(v1, 'MinDist_%d_Curve_a'%(i+1)) + geompy.addToStudy(v2, 'MinDist_%d_Curve_b'%(i+1)) + +# Get minimum distance +print "Minimal distance between Curve_a and Curve_b is", geompy.MinDistance(Curve_a, Curve_b) + +# Get minimum distance with components along axes +[aDist, DX, DY, DZ] = geompy.MinDistanceComponents(Curve_a, Curve_b) +print "Minimal distance between Curve_a and Curve_b is (", DX, ",", DY, ",", DZ, ")" diff --git a/doc/salome/examples/normal_face.py b/doc/salome/examples/normal_face.py new file mode 100644 index 000000000..572b0f9f8 --- /dev/null +++ b/doc/salome/examples/normal_face.py @@ -0,0 +1,17 @@ +# Normal to a Face + +import geompy +import math + +# create a box +box = geompy.MakeBoxDXDYDZ(100,30,100) + +faces = geompy.SubShapeAllSortedCentres(box, geompy.ShapeType["FACE"]) +face0 = faces[0] +vnorm = geompy.GetNormal(face0) +if vnorm is None: + raise RuntimeError, "GetNormal(face0) failed" +else: + geompy.addToStudy(face0, "Face0") + geompy.addToStudy(vnorm, "Normale to Face0") + print "\nNormale of face has been successfully obtained" diff --git a/doc/salome/examples/notebook_geom.py b/doc/salome/examples/notebook_geom.py new file mode 100644 index 000000000..a84ae87de --- /dev/null +++ b/doc/salome/examples/notebook_geom.py @@ -0,0 +1,21 @@ +# Using SALOME NoteBook + +import geompy +import salome +import salome_notebook +gg = salome.ImportComponentGUI("GEOM") + +# set variables +notebook = salome_notebook.notebook +notebook.set("Length", 150) +notebook.set("Width", 100) + +# create box +box = geompy.MakeBoxDXDYDZ("Length", "Width", 200) + +# add object in the study +id_box = geompy.addToStudy(box,"Box") + +# display the boxes +gg.createAndDisplayGO(id_box) +gg.setDisplayMode(id_box,1) diff --git a/doc/salome/examples/point_coordinates.py b/doc/salome/examples/point_coordinates.py new file mode 100644 index 000000000..802c88ca5 --- /dev/null +++ b/doc/salome/examples/point_coordinates.py @@ -0,0 +1,21 @@ +# Point Coordinates + +import math +import geompy + +# create a point +point = geompy.MakeVertex(15., 23., 80.) + +# get the coordinates of the point and check its values +coords = geompy.PointCoordinates(point) + +# check the obtained coordinate values +tolerance = 1.e-07 +def IsEqual(val1, val2): return (math.fabs(val1 - val2) < tolerance) + +if IsEqual(coords[0], 15.) and IsEqual(coords[1], 23.) and IsEqual(coords[2], 80.): + print "All values are OK." +else : + print "Coordinates of point must be (15, 23, 80), but returned (", + print coords[0], ", ", coords[1], ", ", coords[2], ")" + pass diff --git a/doc/salome/examples/primitives_ex01.py b/doc/salome/examples/primitives_ex01.py new file mode 100644 index 000000000..77db019cd --- /dev/null +++ b/doc/salome/examples/primitives_ex01.py @@ -0,0 +1,27 @@ +# Creation of a Box + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create vertices +p0 = geompy.MakeVertex(15, 25, 35) +p70 = geompy.MakeVertex(70, 70, 70) + +# create boxes +box1 = geompy.MakeBoxDXDYDZ(10, 20, 30) +box2 = geompy.MakeBox(10,20,30, 15,25,35) +box3 = geompy.MakeBoxTwoPnt(p0, p70) + +# add objects in the study +id_box1 = geompy.addToStudy(box1,"Box1") +id_box2 = geompy.addToStudy(box2,"Box2") +id_box3 = geompy.addToStudy(box3,"Box3") + +# display the boxes +gg.createAndDisplayGO(id_box1) +gg.setDisplayMode(id_box1,1) +gg.createAndDisplayGO(id_box2) +gg.setDisplayMode(id_box2,1) +gg.createAndDisplayGO(id_box3) +gg.setDisplayMode(id_box3,1) diff --git a/doc/salome/examples/primitives_ex02.py b/doc/salome/examples/primitives_ex02.py new file mode 100644 index 000000000..ed6a6f9a6 --- /dev/null +++ b/doc/salome/examples/primitives_ex02.py @@ -0,0 +1,30 @@ +# Creation of a Cylinder + +import geompy +import salome + +gg = salome.ImportComponentGUI("GEOM") + +# create a vertex and a vector +p1 = geompy.MakeVertex(25, 35, 45) +p2 = geompy.MakeVertex(70, 70, 70) +v = geompy.MakeVector(p1, p2) + +# create cylinders +height = 40 + +radius1 = 15 +cylinder1 = geompy.MakeCylinder(p1, v, radius1, height) + +radius2 = 30 +cylinder2 = geompy.MakeCylinderRH(radius2, height) + +# add objects in the study +id_cylinder1 = geompy.addToStudy(cylinder1,"Cylinder1") +id_cylinder2 = geompy.addToStudy(cylinder2,"Cylinder2") + +# display the cylinders +gg.createAndDisplayGO(id_cylinder1) +gg.setDisplayMode(id_cylinder1,1) +gg.createAndDisplayGO(id_cylinder2) +gg.setDisplayMode(id_cylinder2,1) diff --git a/doc/salome/examples/primitives_ex03.py b/doc/salome/examples/primitives_ex03.py new file mode 100644 index 000000000..21dbc9e7e --- /dev/null +++ b/doc/salome/examples/primitives_ex03.py @@ -0,0 +1,29 @@ +# Creation of a Sphere + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create a vertex +p = geompy.MakeVertex(55, 45, 25) + +# create spheres +radius1 = 20 +sphere1 = geompy.MakeSpherePntR(p, radius1) +radius2 = 15 +sphere2 = geompy.MakeSphere(0, 0, 45, radius2) +radius3 = 30 +sphere3 = geompy.MakeSphereR(radius3) + +# add objects in the study +id_sphere1 = geompy.addToStudy(sphere1,"Sphere1") +id_sphere2 = geompy.addToStudy(sphere2,"Sphere2") +id_sphere3 = geompy.addToStudy(sphere3,"Sphere3") + +# display spheres +gg.createAndDisplayGO(id_sphere1) +gg.setDisplayMode(id_sphere1,1) +gg.createAndDisplayGO(id_sphere2) +gg.setDisplayMode(id_sphere2,1) +gg.createAndDisplayGO(id_sphere3) +gg.setDisplayMode(id_sphere3,1) diff --git a/doc/salome/examples/primitives_ex04.py b/doc/salome/examples/primitives_ex04.py new file mode 100644 index 000000000..99a003a4b --- /dev/null +++ b/doc/salome/examples/primitives_ex04.py @@ -0,0 +1,24 @@ +# Creation of a Torus + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create a vertex and a vector +p1 = geompy.MakeVertex(35, 40, 45) +p2 = geompy.MakeVertex(35, 45, 70) +v = geompy.MakeVector(p1, p2) + +# create toruses +torus1 = geompy.MakeTorus(p1, v, 20, 10) +torus2 = geompy.MakeTorusRR(30, 15) + +# add objects in the study +id_torus1 = geompy.addToStudy(torus1,"Torus1") +id_torus2 = geompy.addToStudy(torus2,"Torus2") + +# display toruses +gg.createAndDisplayGO(id_torus1) +gg.setDisplayMode(id_torus1,1) +gg.createAndDisplayGO(id_torus2) +gg.setDisplayMode(id_torus2,1) diff --git a/doc/salome/examples/primitives_ex05.py b/doc/salome/examples/primitives_ex05.py new file mode 100644 index 000000000..b563303b2 --- /dev/null +++ b/doc/salome/examples/primitives_ex05.py @@ -0,0 +1,24 @@ +# Creation of a Cone + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create a vertex and a vector +p1 = geompy.MakeVertex(35, 35, 0) +p2 = geompy.MakeVertex(35, 35, 70) +v = geompy.MakeVector(p1, p2) + +# create cones +cone1 = geompy.MakeCone(p1, v, 17, 1, 20) +cone2 = geompy.MakeConeR1R2H(30, 10, 30) + +# add objects in the study +id_cone1 = geompy.addToStudy(cone1,"Cone1") +id_cone2 = geompy.addToStudy(cone2,"Cone2") + +# display cones +gg.createAndDisplayGO(id_cone1) +gg.setDisplayMode(id_cone1,1) +gg.createAndDisplayGO(id_cone2) +gg.setDisplayMode(id_cone2,1) diff --git a/doc/salome/examples/primitives_ex06.py b/doc/salome/examples/primitives_ex06.py new file mode 100644 index 000000000..c558eafb8 --- /dev/null +++ b/doc/salome/examples/primitives_ex06.py @@ -0,0 +1,35 @@ +# Creation of a Disk + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create vertices +p0 = geompy.MakeVertex(0., 0., 0.) +px = geompy.MakeVertex(100., 0. , 0. ) +py = geompy.MakeVertex(0. , 100., 0. ) +pz = geompy.MakeVertex(0. , 0. , 100.) + +# create a vector on two points +vxy = geompy.MakeVector(px, py) + +# create a disk in OXY plane +disk1 = geompy.MakeDiskR(100, 1) + +# create a disk from a point, a vector and a radius +disk2 = geompy.MakeDiskPntVecR(pz, vxy, 30) + +#create a circle from three points +disk3 = geompy.MakeDiskThreePnt(p0, px, py) + +# add objects in the study +id_vxy = geompy.addToStudy(vxy, "Vector") +id_disk1 = geompy.addToStudy(disk1,"Disk1") +id_disk2 = geompy.addToStudy(disk2,"Disk2") +id_disk3 = geompy.addToStudy(disk3,"Disk3") + +# display disks +gg.createAndDisplayGO(id_vxy) +gg.createAndDisplayGO(id_disk1) +gg.createAndDisplayGO(id_diks2) +gg.createAndDisplayGO(id_diks3) diff --git a/doc/salome/examples/primitives_ex07.py b/doc/salome/examples/primitives_ex07.py new file mode 100644 index 000000000..75dad1e94 --- /dev/null +++ b/doc/salome/examples/primitives_ex07.py @@ -0,0 +1,31 @@ +# Creation of a Rectangle + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create vertices +px = geompy.MakeVertex(100., 0. , 0. ) +py = geompy.MakeVertex(0. , 100., 0. ) + +# create a vector on two points +vxy = geompy.MakeVector(px, py) + +# create a rectangle in OXY plane +face1 = geompy.MakeFaceHW(100, 100, 1) + +# create a rectangle using normal vector +face2 = geompy.MakeFaceObjHW(vxy, 50, 150) + +# create a rectangle from other face +face3 = geompy.MakeFaceObjHW(face2, 150, 50) + +# add objects in the study +id_face1 = geompy.addToStudy(face1,"Face1") +id_face2 = geompy.addToStudy(face2,"Face2") +id_face3 = geompy.addToStudy(face3,"Face3") + +# display rectangles +gg.createAndDisplayGO(id_face1) +gg.createAndDisplayGO(id_face2) +gg.createAndDisplayGO(id_face3) diff --git a/doc/salome/examples/repairing_operations_ex01.py b/doc/salome/examples/repairing_operations_ex01.py new file mode 100644 index 000000000..8a57db040 --- /dev/null +++ b/doc/salome/examples/repairing_operations_ex01.py @@ -0,0 +1,46 @@ +# Shape Processing + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create vertices, an edge, an arc, a wire, a face and a prism +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 the shape at the beginning +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 the Shape +Operators = ["FixShape"] +Parameters = ["FixShape.Tolerance3d"] +Values = ["1e-7"] +PS = geompy.ProcessShape(theShape, Operators, Parameters, Values) + +# check the shape at the end +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 the study and display +Id_Shape = geompy.addToStudy(theShape, "Invalid Shape") +Id_PS = geompy.addToStudy(PS, "Processed Shape") +gg.createAndDisplayGO(Id_Shape) +gg.setDisplayMode(Id_Shape,1) +gg.createAndDisplayGO(Id_PS) +gg.setDisplayMode(Id_PS,1) diff --git a/doc/salome/examples/repairing_operations_ex02.py b/doc/salome/examples/repairing_operations_ex02.py new file mode 100644 index 000000000..f5ee65caf --- /dev/null +++ b/doc/salome/examples/repairing_operations_ex02.py @@ -0,0 +1,28 @@ +# Suppress Faces + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create a box +box = geompy.MakeBoxDXDYDZ(200, 200, 200) + +# The list of IDs (IDList) for suppress faces +sup_faces = [] +sup_faces = geompy.SubShapeAllSortedCentres(box, geompy.ShapeType["FACE"]) + +# get indices of the sub-shape +f1_id = geompy.GetSubShapeID(box, sup_faces[3]) + +# remove faces from the given object (shape) +result = geompy.SuppressFaces(box, [f1_id]) + +# add objects in the study +id_box = geompy.addToStudy(box, "Box") +id_result = geompy.addToStudy(result, "Result") + +# display the results +gg.createAndDisplayGO(id_box) +gg.setDisplayMode(id_box,1) +gg.createAndDisplayGO(id_result) +gg.setDisplayMode(id_result,1) diff --git a/doc/salome/examples/repairing_operations_ex03.py b/doc/salome/examples/repairing_operations_ex03.py new file mode 100644 index 000000000..50eec1126 --- /dev/null +++ b/doc/salome/examples/repairing_operations_ex03.py @@ -0,0 +1,30 @@ +# Close Contour + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create vertices and vectors +p0 = geompy.MakeVertex( 0., 0., 0.) +px = geompy.MakeVertex(100., 0., 0.) +py = geompy.MakeVertex( 0., 100., 0.) +py1 = geompy.MakeVertex( 0., 140., 0.) +pz = geompy.MakeVertex( 0., 0., 100.) +vxy = geompy.MakeVector(px, py) + +# create an arc +arc = geompy.MakeArc(py1, pz, px) + +# create a wire +wire = geompy.MakeWire([vxy, arc]) + +# close an open wire by creation of an edge between ends +wire_close = geompy.CloseContour(wire, [1], 0) + +# add objects in the study +id_wire = geompy.addToStudy(wire, "Wire") +id_wire_close = geompy.addToStudy(wire_close, "Wire close") + +# display the results +gg.createAndDisplayGO(id_wire) +gg.createAndDisplayGO(id_wire_close) diff --git a/doc/salome/examples/repairing_operations_ex04.py b/doc/salome/examples/repairing_operations_ex04.py new file mode 100644 index 000000000..fad69131c --- /dev/null +++ b/doc/salome/examples/repairing_operations_ex04.py @@ -0,0 +1,34 @@ +# Suppress Internal Wires + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create a vertex and a vector +p1 = geompy.MakeVertex(55, 65, 50) +p2 = geompy.MakeVertex(55, 0, 50) +v = geompy.MakeVector(p1, p2) + +# create a cylinder +height = 100 +radius1 = 40 +cylinder = geompy.MakeCylinder(p1, v, radius1, height) + +# create a box +box = geompy.MakeBoxDXDYDZ(100, 100, 100) + +# make a cut +cut = geompy.MakeCut(box, cylinder) + +# suppress all internal wires +result = geompy.SuppressInternalWires(cut, []) + +# add objects in the study +id_cut = geompy.addToStudy(cut, "Cut") +id_result = geompy.addToStudy(result, "Result") + +# display the results +gg.createAndDisplayGO(id_cut) +gg.setDisplayMode(id_cut,1) +gg.createAndDisplayGO(id_result) +gg.setDisplayMode(id_result,1) diff --git a/doc/salome/examples/repairing_operations_ex05.py b/doc/salome/examples/repairing_operations_ex05.py new file mode 100644 index 000000000..f6593b3e8 --- /dev/null +++ b/doc/salome/examples/repairing_operations_ex05.py @@ -0,0 +1,50 @@ +# Suppress Holes + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create a vertex and a vector +p1 = geompy.MakeVertex(35, 35, 0) +p2 = geompy.MakeVertex(35, 35, 50) +v = geompy.MakeVector(p1, p2) + +# create a cylinder +height = 20 +radius1 = 20 +cylinder = geompy.MakeCylinder(p1, v, radius1, height) + +# create a cone +cone = geompy.MakeCone(p1, v, 70, 0, 80) + +# make a cut +cut = geompy.MakeCut(cone, cylinder) + +# get faces as sub-shapes +faces = [] +faces = geompy.SubShapeAllSortedCentres(cut, geompy.ShapeType["FACE"]) +f_2 = geompy.GetSubShapeID(cut, faces[2]) + +# remove one face from the shape +cut_without_f_2 = geompy.SuppressFaces(cut, [f_2]) + +# get wires as sub-shapes +wires = [] +wires = geompy.SubShapeAllSortedCentres(cut_without_f_2, geompy.ShapeType["WIRE"]) +w_0 = geompy.GetSubShapeID(cut_without_f_2, wires[0]) + +# suppress the selected wire +result = geompy.SuppressHoles(cut_without_f_2, [w_0]) + +# add objects in the study +id_cut = geompy.addToStudy(cut, "Cut") +id_cut_without_f_2 = geompy.addToStudy(cut_without_f_2, "Cut without f_2") +id_result = geompy.addToStudy(result, "Result") + +# display the results +gg.createAndDisplayGO(id_cut) +gg.setDisplayMode(id_cut,1) +gg.createAndDisplayGO(id_cut_without_f_2) +gg.setDisplayMode(id_cut_without_f_2,1) +gg.createAndDisplayGO(id_result) +gg.setDisplayMode(id_result,1) diff --git a/doc/salome/examples/repairing_operations_ex06.py b/doc/salome/examples/repairing_operations_ex06.py new file mode 100644 index 000000000..e6120a7a6 --- /dev/null +++ b/doc/salome/examples/repairing_operations_ex06.py @@ -0,0 +1,39 @@ +# Sewing + +import geompy +import salome +import math +gg = salome.ImportComponentGUI("GEOM") + +# 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) +face_rot = geompy.MakeRotation(face, vector, angle) + +# make sewing +precision = 0.00001 +sewing = geompy.MakeSewing([face, face_rot], precision) + +# add objects in the study +id_face = geompy.addToStudy(face, "Face") +id_face_rot = geompy.addToStudy(face_rot, "Face rotation") +id_sewing = geompy.addToStudy(sewing, "Sewing") + +# display the results +gg.createAndDisplayGO(id_face) +gg.setDisplayMode(id_face,1) +gg.createAndDisplayGO(id_face_rot) +gg.setDisplayMode(id_face_rot,1) +gg.createAndDisplayGO(id_sewing) +gg.setDisplayMode(id_sewing,1) diff --git a/doc/salome/examples/repairing_operations_ex07.py b/doc/salome/examples/repairing_operations_ex07.py new file mode 100644 index 000000000..6cc688a4e --- /dev/null +++ b/doc/salome/examples/repairing_operations_ex07.py @@ -0,0 +1,32 @@ +# Glue Faces + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create boxes +box1 = geompy.MakeBox(0,0,0,100,50,100) +box2 = geompy.MakeBox(100,0,0,250,50,100) + +# make compound +compound = geompy.MakeCompound([box1, box2]) + +# glue compound's faces +tolerance = 1e-5 +glue = geompy.MakeGlueFaces(compound, tolerance) + +# add objects in study +id_box1 = geompy.addToStudy(box1, "Box1") +id_box2 = geompy.addToStudy(box2, "Box2") +id_compound = geompy.addToStudy(compound, "Compound") +id_glue = geompy.addToStudy(glue, "Glue faces") + +# display results +gg.createAndDisplayGO(id_box1) +gg.setDisplayMode(id_box1,1) +gg.createAndDisplayGO(id_box2) +gg.setDisplayMode(id_box2,1) +gg.createAndDisplayGO(id_compound) +gg.setDisplayMode(id_compound,1) +gg.createAndDisplayGO(id_glue) +gg.setDisplayMode(id_glue,1) diff --git a/doc/salome/examples/repairing_operations_ex08.py b/doc/salome/examples/repairing_operations_ex08.py new file mode 100644 index 000000000..a39d11088 --- /dev/null +++ b/doc/salome/examples/repairing_operations_ex08.py @@ -0,0 +1,30 @@ +# Glue Edges + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create boxes +box1 = geompy.MakeBox(0,0,0,100,50,100) +box2 = geompy.MakeBox(100,0,0,250,50,100) + +# make compound +compound = geompy.MakeCompound([box1, box2]) + +# glue all compound's edges +tolerance = 1e-5 +glue1 = geompy.MakeGlueEdges(compound, tolerance) + +# glue some compound's edges +list_edges = geompy.GetGlueEdges(compound, tolerance) +glue2 = geompy.MakeGlueEdgesByList(compound, tolerance, [list_edges[0], list_edges[2]]) + +# add objects in study +geompy.addToStudy(box1, "Box1") +geompy.addToStudy(box2, "Box2") +geompy.addToStudy(compound, "Compound") +geompy.addToStudy(glue1, "Glue all edges") +geompy.addToStudy(glue2, "Glue two edges") + +if salome.sg.hasDesktop(): + salome.sg.updateObjBrowser(1) diff --git a/doc/salome/examples/repairing_operations_ex09.py b/doc/salome/examples/repairing_operations_ex09.py new file mode 100644 index 000000000..41807fee4 --- /dev/null +++ b/doc/salome/examples/repairing_operations_ex09.py @@ -0,0 +1,33 @@ +# Limit Tolerance + +import geompy +gg = salome.ImportComponentGUI("GEOM") + +# import initial topology +shape1 = geompy.ImportBREP("my_shape_1.brep") +shape2 = geompy.ImportBREP("my_shape_2.brep") + +geompy.addToStudy(shape1, "Shape 1") +geompy.addToStudy(shape2, "Shape 2") + +# perform partition +try: + part = geompy.MakePartition([shape1, shape2]) +except: + # limit tolerance + tolerance = 1e-07 + shape1_lt = geompy.LimitTolerance(shape1, tolerance) + shape2_lt = geompy.LimitTolerance(shape2, tolerance) + + # process shape + good_shape1 = geompy.ProcessShape(shape1_lt, ["FixShape"], ["FixShape.Tolerance3d"], ["1e-7"]) + good_shape2 = geompy.ProcessShape(shape2_lt, ["FixShape"], ["FixShape.Tolerance3d"], ["1e-7"]) + + geompy.addToStudy(good_shape1, "Shape 1 corrected") + geompy.addToStudy(good_shape2, "Shape 2 corrected") + + # perform partition on corrected shapes + part = geompy.MakePartition([good_shape1, good_shape2]) + pass + +geompy.addToStudy(part, "Partition") diff --git a/doc/salome/examples/repairing_operations_ex10.py b/doc/salome/examples/repairing_operations_ex10.py new file mode 100644 index 000000000..7849a7cf5 --- /dev/null +++ b/doc/salome/examples/repairing_operations_ex10.py @@ -0,0 +1,27 @@ +# Add Point on Edge + +import geompy +import salome + +# create vertices +p1 = geompy.MakeVertex(0,0,50) +p2 = geompy.MakeVertex(60,0,50) + +# make an edge +edge = geompy.MakeEdge(p1, p2) #geompy.GetSubShape(box, edge_ind) + +# divide an edge +divide = geompy.DivideEdge(edge, -1, 0.5, 0) + +# add objects in the study +id_edge = geompy.addToStudy(edge, "Edge") +edge_points = geompy.SubShapeAllSortedCentres(edge, geompy.ShapeType["VERTEX"]) +for point in edge_points: + geompy.addToStudyInFather(edge, point, "Edge's point") + +id_divide = geompy.addToStudy(divide, "Divided edge") +edge_points = geompy.SubShapeAllSortedCentres(divide, geompy.ShapeType["VERTEX"]) +for point in edge_points: + geompy.addToStudyInFather(divide, point, "Edge's point after divide") + +salome.sg.updateObjBrowser(1) diff --git a/doc/salome/examples/repairing_operations_ex11.py b/doc/salome/examples/repairing_operations_ex11.py new file mode 100644 index 000000000..396881c72 --- /dev/null +++ b/doc/salome/examples/repairing_operations_ex11.py @@ -0,0 +1,49 @@ +# Fuse Collinear Edges within a Wire + +import geompy +import salome + +# create vertices +p1 = geompy.MakeVertex(0, 0, 0) +p2 = geompy.MakeVertex(70, 0, 0) +p3 = geompy.MakeVertex(70, 50, 0) +p4 = geompy.MakeVertex(70, 80, 0) +p5 = geompy.MakeVertex(50, 80, 0) +p6 = geompy.MakeVertex(20, 80, 0) +p7 = geompy.MakeVertex(0, 80, 0) +p8 = geompy.MakeVertex(0, 30, 0) + +points = [p1, p2, p3, p4, p5, p6, p7, p8] + +# make a wire +wire_1 = geompy.MakePolyline(points, True) + +# suppress some vertices in the wire +wire_2 = geompy.FuseCollinearEdgesWithinWire(wire_1, [p3]) +wire_3 = geompy.FuseCollinearEdgesWithinWire(wire_1, [p5, p6]) + +# suppress all suitable vertices in the wire +wire_4 = geompy.FuseCollinearEdgesWithinWire(wire_1, []) + +wires = [wire_1, wire_2, wire_3, wire_4] + +# add objects in the study +ii = 1 +for point in points: + geompy.addToStudy(point, "p%d"%ii) + ii = ii + 1 + pass + +ii = 1 +for wire in wires: + geompy.addToStudy(wire, "wire_%d"%ii) + wire_points = geompy.SubShapeAllSortedCentres(wire, geompy.ShapeType["VERTEX"]) + jj = 1 + for point in wire_points: + geompy.addToStudyInFather(wire, point, "point_%d"%jj) + jj = jj + 1 + pass + ii = ii + 1 + pass + +salome.sg.updateObjBrowser(1) diff --git a/doc/salome/examples/sketcher.py b/doc/salome/examples/sketcher.py new file mode 100644 index 000000000..8ca1f98ce --- /dev/null +++ b/doc/salome/examples/sketcher.py @@ -0,0 +1,42 @@ +# 2D Sketcher + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create vertices +p1 = geompy.MakeVertex(70., 0., 0.) +p2 = geompy.MakeVertex(70., 70., 80.) +p3 = geompy.MakeVertex( 0., 70., 0.) + +#create a vector from two points +vector_arc = geompy.MakeVector(p1, p3) + +# create an arc from three points +arc = geompy.MakeArc(p1, p2, p3) + +# create a wire +wire = geompy.MakeWire([vector_arc, arc]) + +# create a planar face +isPlanarWanted = 1 +face = geompy.MakeFace(wire, isPlanarWanted) + +# create a sketcher (face), following the textual description +sketcher1 = geompy.MakeSketcher("Sketcher:F -100 -100:TT 250 -100:R 0:C 100 150:R 0:L 300:WF", + [100,0,0, 1,1,1, -1,1,0]) + +# create a sketcher (wire) on the given face +sketcher2 = geompy.MakeSketcherOnPlane("Sketcher:F 10 -30:R 10:C 20 180:R 15:L 50:WW", face) + +# add objects in the study +id_face = geompy.addToStudy(face,"Face") +id_sketcher1 = geompy.addToStudy(sketcher1,"Sketcher1") +id_sketcher2 = geompy.addToStudy(sketcher2,"Sketcher2") + +# display the first sketcher and the second sketcher with its planar face +gg.createAndDisplayGO(id_face) +gg.setDisplayMode(id_face,1) +gg.setTransparency(id_face,0.5) +gg.createAndDisplayGO(id_sketcher1) +gg.createAndDisplayGO(id_sketcher2) diff --git a/doc/salome/examples/testme.py b/doc/salome/examples/testme.py new file mode 100755 index 000000000..d8a98200d --- /dev/null +++ b/doc/salome/examples/testme.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python + +import unittest, sys + +class SalomeSession(object): + def __init__(self, script): + import runSalome + sys.argv = ["runSalome.py"] + sys.argv += ["--terminal"] + sys.argv += ["--modules=GEOM"] + sys.argv += ["--execute=%s" % script] + clt, d = runSalome.main() + self.port = d['port'] + return + + def __del__(self): + port = self.port + import killSalomeWithPort + killSalomeWithPort.killMyPort(port) + return + pass + +class MyTest(unittest.TestCase): + def testFunction(self): + SalomeSession(sys.argv[1]) + pass + +unittest.main(argv=sys.argv[:1]) diff --git a/doc/salome/examples/tolerance.py b/doc/salome/examples/tolerance.py new file mode 100644 index 000000000..639a676cf --- /dev/null +++ b/doc/salome/examples/tolerance.py @@ -0,0 +1,14 @@ +# Tolerance + +import geompy + +# create a box +box = geompy.MakeBoxDXDYDZ(100,30,100) +Toler = geompy.Tolerance(box) +print "\nBox 100x30x100 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] diff --git a/doc/salome/examples/topological_geom_objs_ex01.py b/doc/salome/examples/topological_geom_objs_ex01.py new file mode 100644 index 000000000..77c1d1807 --- /dev/null +++ b/doc/salome/examples/topological_geom_objs_ex01.py @@ -0,0 +1,57 @@ +# Creation of an Edge + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# +# create edge by two points +# + +# create vertices +p0 = geompy.MakeVertex(0. , 0. , 0. ) +pxyz = geompy.MakeVertex(100., 100., 100.) + +# create an edge +edge = geompy.MakeEdge(p0, pxyz) + +# add object in the study +id_edge = geompy.addToStudy(edge,"Edge_1") + +# display an edge +gg.createAndDisplayGO(id_edge) + +# +# create edge from wire +# + +# create a circle +c = geompy.MakeCircle(None, None, 100) + +# create a wire +w = geompy.MakeWire([c], 1e-07) + +# create an edge from wire +edge = geompy.MakeEdgeWire(w) + +# add object in the study +id_edge = geompy.addToStudy(edge,"Edge_2") + +# display an edge +gg.createAndDisplayGO(id_edge) + +# +# create edge from existing curve and a length +# + +# create a circle +c = geompy.MakeCircle(None, None, 100) + +# create an edge of length 25.0 from the circle +edge = geompy.MakeEdgeOnCurveByLength(c, 25.0) + +# add object in the study +id_edge = geompy.addToStudy(edge,"Edge_3") + +# display an edge +gg.createAndDisplayGO(id_edge) diff --git a/doc/salome/examples/topological_geom_objs_ex02.py b/doc/salome/examples/topological_geom_objs_ex02.py new file mode 100644 index 000000000..62806d770 --- /dev/null +++ b/doc/salome/examples/topological_geom_objs_ex02.py @@ -0,0 +1,25 @@ +# Creation of a Wire + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create vertices +px = geompy.MakeVertex(100., 0. , 0. ) +py = geompy.MakeVertex(0. , 100., 0. ) +pz = geompy.MakeVertex(0. , 0. , 100.) + +# create a vector from two points +vxy = geompy.MakeVector(px, py) + +# create an arc from three points +arc = geompy.MakeArc(py, pz, px) + +# create a wire +wire = geompy.MakeWire([vxy, arc]) + +# add an object in the study +id_wire = geompy.addToStudy(wire,"Wire") + +# display the wire +gg.createAndDisplayGO(id_wire) diff --git a/doc/salome/examples/topological_geom_objs_ex03.py b/doc/salome/examples/topological_geom_objs_ex03.py new file mode 100644 index 000000000..7b1600153 --- /dev/null +++ b/doc/salome/examples/topological_geom_objs_ex03.py @@ -0,0 +1,51 @@ +# Creation of a Face + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create vertices +p0 = geompy.MakeVertex(0. , 0. , 0. ) +px = geompy.MakeVertex(100., 0. , 0. ) +py = geompy.MakeVertex(0. , 100., 0. ) +pz = geompy.MakeVertex(0. , 0. , 100.) +pxyz = geompy.MakeVertex(100., 100., 100.) + +# create a vector from two points +vxy = geompy.MakeVector(px, py) + +# create an arc from three points +arc = geompy.MakeArc(py, pz, px) + +# create a wire +wire = geompy.MakeWire([vxy, arc]) + +# create sketchers +sketcher1 = 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]) +sketcher2 = geompy.MakeSketcher("Sketcher:F 0 0:TT 70 0:TT 70 70:TT 0 70:WW") +sketcher3 = geompy.MakeSketcher("Sketcher:F 20 20:TT 50 20:TT 50 50:TT 20 50:WW") +isPlanarFace = 1 + +# create a face from the wire +face1 = geompy.MakeFace(wire, isPlanarFace) + +# create faces from two wires +face2 = geompy.MakeFaceWires([wire, sketcher1],isPlanarFace) +face3 = geompy.MakeFaces([sketcher2, sketcher3],isPlanarFace) + +# add objects in the study +id_face1 = geompy.addToStudy(face1,"Face1") +id_face2 = geompy.addToStudy(face2,"Face2") +id_face3 = geompy.addToStudy(face3,"Face3") + +# display the faces +gg.createAndDisplayGO(id_face1) +gg.setDisplayMode(id_face1,1) +gg.setTransparency(id_face1,0.2) +gg.createAndDisplayGO(id_face2) +gg.setDisplayMode(id_face2,1) +gg.setTransparency(id_face2,0.2) +gg.createAndDisplayGO(id_face3) +gg.setDisplayMode(id_face3,1) +gg.setTransparency(id_face3,0.2) diff --git a/doc/salome/examples/topological_geom_objs_ex04.py b/doc/salome/examples/topological_geom_objs_ex04.py new file mode 100644 index 000000000..b85e553f2 --- /dev/null +++ b/doc/salome/examples/topological_geom_objs_ex04.py @@ -0,0 +1,34 @@ +# Creation of a Shell + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +#create vertices +p0 = geompy.MakeVertex( 0., 0., 0.) +pxyz = geompy.MakeVertex( 5., 5., 40.) + +# create sketchers +sketcher1 = geompy.MakeSketcher("Sketcher:F 0 0:TT 70 0:TT 70 70:TT 0 70:WW") +sketcher2 = geompy.MakeSketcher("Sketcher:F 20 20:TT 50 20:TT 50 50:TT 20 50:WW") +isPlanarFace = 1 + +# create a face from two wires +face = geompy.MakeFaces([sketcher1, sketcher2],isPlanarFace) + +# create a prism +prism = geompy.MakePrism(face, p0, pxyz) + +# explode the prism into faces +prism_faces = geompy.SubShapeAllSortedCentres(prism, geompy.ShapeType["FACE"]) + +# create a shell from a set of faces +shell = geompy.MakeShell([prism_faces[0], prism_faces[2], prism_faces[3], + prism_faces[7], prism_faces[9]]) + +# add objects in the study +id_shell = geompy.addToStudy(shell,"Shell") + +# display the shell +gg.createAndDisplayGO(id_shell) +gg.setDisplayMode(id_shell,1) diff --git a/doc/salome/examples/topological_geom_objs_ex05.py b/doc/salome/examples/topological_geom_objs_ex05.py new file mode 100644 index 000000000..700236b03 --- /dev/null +++ b/doc/salome/examples/topological_geom_objs_ex05.py @@ -0,0 +1,36 @@ +# Creation of a Solid + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +#create vertices +p0 = geompy.MakeVertex( 0., 0., 0.) +pz = geompy.MakeVertex( 0., 0., 40.) + +# create sketchers +sketcher = geompy.MakeSketcher("Sketcher:F -50 -50:TT 100 -50:R 0:C 50 70:R 0:L 100:WW") + +# create faces from two wires +face = geompy.MakeFace(sketcher,1) + +# create a prism +prism = geompy.MakePrism(face, p0, pz) + +# explode the prism into faces +prism_faces = geompy.SubShapeAllSortedCentres(prism, geompy.ShapeType["FACE"]) + +# create a shell from a set of faces +shell = geompy.MakeShell([prism_faces[0], prism_faces[1], + prism_faces[3], prism_faces[4], + prism_faces[5], prism_faces[2]]) + +# create a solid, bounded by the given shells +solid = geompy.MakeSolid([shell]) + +# add objects in the study +id_solid = geompy.addToStudy(solid,"Solid") + +# display the solid +gg.createAndDisplayGO(id_solid) +gg.setDisplayMode(id_solid,1) diff --git a/doc/salome/examples/topological_geom_objs_ex06.py b/doc/salome/examples/topological_geom_objs_ex06.py new file mode 100644 index 000000000..071730b52 --- /dev/null +++ b/doc/salome/examples/topological_geom_objs_ex06.py @@ -0,0 +1,28 @@ +# Creation of a Compound + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create a vertex and a vector +p1 = geompy.MakeVertex( -30., -30., 50.) +p2 = geompy.MakeVertex( -60., -60., 30.) +p3 = geompy.MakeVertex( -30., -30., 10.) + +# create an arc from three points +arc = geompy.MakeArc(p1, p2, p3) +ShapeListCompound = [] +i = 0 +while i <= 3 : + S = geompy.MakeTranslation(arc, i * 50., 0., 0.) + ShapeListCompound.append(S) + i = i + 1 + +# create a compund of the given shapes +compound = geompy.MakeCompound(ShapeListCompound) + +# add object in the study +id_compound = geompy.addToStudy(compound,"Compound") + +# display the compound +gg.createAndDisplayGO(id_compound) diff --git a/doc/salome/examples/transformation_operations_ex01.py b/doc/salome/examples/transformation_operations_ex01.py new file mode 100644 index 000000000..678afa9e2 --- /dev/null +++ b/doc/salome/examples/transformation_operations_ex01.py @@ -0,0 +1,43 @@ +# Translation + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create a vertex and a vector +p1 = geompy.MakeVertex(10, 40, 0) +p2 = geompy.MakeVertex( 0, 0, 50) +p3 = geompy.MakeVertex(50, 80, 0) +v = geompy.MakeVector(p1, p2) +vt = geompy.MakeVector(p1, p3) + +# create a cylinder +height = 35 +radius1 = 20 +cylinder = geompy.MakeCylinder(p1, v, radius1, height) + +# translate the given object along the vector, specified by its end points +# (all three functions produce the same result) +translation1 = geompy.MakeTranslationTwoPoints(cylinder, p1, p3) +translation2 = geompy.MakeTranslation(cylinder, 40, 40, 0) +translation3 = geompy.MakeTranslationVector(cylinder, vt) +translation4 = geompy.MakeTranslationVectorDistance(cylinder, vt, 200) + +# add objects in the study +id_cylinder = geompy.addToStudy(cylinder, "Cylinder") +id_translation1 = geompy.addToStudy(translation1, "Translation1") +id_translation2 = geompy.addToStudy(translation2, "Translation2") +id_translation3 = geompy.addToStudy(translation3, "Translation3") +id_translation4 = geompy.addToStudy(translation4, "Translation4") + +# display the results +gg.createAndDisplayGO(id_cylinder) +gg.setDisplayMode(id_cylinder,1) +gg.createAndDisplayGO(id_translation1) +gg.setDisplayMode(id_translation1,1) +gg.createAndDisplayGO(id_translation2) +gg.setDisplayMode(id_translation2,1) +gg.createAndDisplayGO(id_translation3) +gg.setDisplayMode(id_translation3,1) +gg.createAndDisplayGO(id_translation4) +gg.setDisplayMode(id_translation4,1) diff --git a/doc/salome/examples/transformation_operations_ex02.py b/doc/salome/examples/transformation_operations_ex02.py new file mode 100644 index 000000000..7abbb7873 --- /dev/null +++ b/doc/salome/examples/transformation_operations_ex02.py @@ -0,0 +1,44 @@ +# Rotation + +import geompy +import salome +import math +gg = salome.ImportComponentGUI("GEOM") + +# create a vertex and a vector +p1 = geompy.MakeVertex(10, 40, 0) +p2 = geompy.MakeVertex( 0, 0, 50) +p3 = geompy.MakeVertex(10, 50,-20) +p4 = geompy.MakeVertex(10, 50, 60) +v = geompy.MakeVector(p1, p2) +vr = geompy.MakeVector(p3, p4) + +# create a cylinder +height = 35 +radius1 = 20 +cylinder = geompy.MakeCylinder(p1, v, radius1, height) + +# rotate the given object around the given axis by the given angle +rotation1 = geompy.MakeRotation(cylinder, vr, math.pi) +rotation2 = geompy.MakeRotationThreePoints(cylinder, p4, p1, p2) + +# add objects in the study +id_vr = geompy.addToStudy(vr, "Rotation 1 axis") +id_p4 = geompy.addToStudy(p4, "Rotation 2 center") +id_p1 = geompy.addToStudy(p1, "Rotation 2 point 1") +id_p2 = geompy.addToStudy(p2, "Rotation 2 point 2") +id_cylinder = geompy.addToStudy(cylinder, "Cylinder") +id_rotation1 = geompy.addToStudy(rotation1, "Rotation 1") +id_rotation2 = geompy.addToStudy(rotation2, "Rotation 2") + +# display the results +gg.createAndDisplayGO(id_vr) +gg.createAndDisplayGO(id_p4) +gg.createAndDisplayGO(id_p1) +gg.createAndDisplayGO(id_p2) +gg.createAndDisplayGO(id_cylinder) +gg.setDisplayMode(id_cylinder,1) +gg.createAndDisplayGO(id_rotation1) +gg.createAndDisplayGO(id_rotation2) +gg.setDisplayMode(id_rotation1,1) +gg.setDisplayMode(id_rotation2,1) diff --git a/doc/salome/examples/transformation_operations_ex03.py b/doc/salome/examples/transformation_operations_ex03.py new file mode 100644 index 000000000..3d250fd48 --- /dev/null +++ b/doc/salome/examples/transformation_operations_ex03.py @@ -0,0 +1,43 @@ +# Modify Location + +import geompy +import salome +import math +gg = salome.ImportComponentGUI("GEOM") + +# create a vertex and a vector +p1 = geompy.MakeVertex(10, 40, 0) +p2 = geompy.MakeVertex( 0, 0, 50) +v = geompy.MakeVector(p1, p2) + +# create a cylinder +height = 35 +radius1 = 20 +cylinder = geompy.MakeCylinder(p1, v, radius1, height) +circle = geompy.MakeCircle(p2, v, radius1) + +# create local coordinate systems +cs1 = geompy.MakeMarker( 0, 0, 0, 1,0,0, 0,1,0) +cs2 = geompy.MakeMarker(30,40,40, 1,0,0, 0,1,0) + +# modify the location of the given object +position = geompy.MakePosition(cylinder, cs1, cs2) +position2 = geompy.PositionAlongPath(position, circle, 0.75, 1, 1) + +# add objects in the study +id_cs1 = geompy.addToStudy(cs1, "Coordinate system 1") +id_cs2 = geompy.addToStudy(cs2, "Coordinate system 2") +id_cylinder = geompy.addToStudy(cylinder, "Cylinder") +id_circle = geompy.addToStudy(circle, "Circle") +id_position = geompy.addToStudy(position, "Position") +id_position2 = geompy.addToStudy(position2, "PositionAlongPath") + +# display the results +gg.createAndDisplayGO(id_cylinder) +gg.setDisplayMode(id_cylinder,1) +gg.createAndDisplayGO(id_position) +gg.setDisplayMode(id_position,1) +gg.createAndDisplayGO(id_circle) +gg.setDisplayMode(id_circle,1) +gg.createAndDisplayGO(id_position2) +gg.setDisplayMode(id_position2,1) diff --git a/doc/salome/examples/transformation_operations_ex04.py b/doc/salome/examples/transformation_operations_ex04.py new file mode 100644 index 000000000..28e8b308a --- /dev/null +++ b/doc/salome/examples/transformation_operations_ex04.py @@ -0,0 +1,46 @@ +# Mirror Image + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create a box +box = geompy.MakeBoxDXDYDZ(200, 200, 200) + +# create an object, symmetrical to another object through the given plane +p1 = geompy.MakeVertex( 0, 25, 0) +p2 = geompy.MakeVertex( 5, 25, 0) +p3 = geompy.MakeVertex( 0,-30, 40) +plane = geompy.MakePlaneThreePnt(p1, p2, p3, 1000.) +mirror1 = geompy.MakeMirrorByPlane(box, plane) + +# create an object, symmetrical to another object through the given axis +p4 = geompy.MakeVertex( 210, 210, -20) +p5 = geompy.MakeVertex( 210, 210, 220) +axis = geompy.MakeVector(p4, p5) +mirror2 = geompy.MakeMirrorByAxis(box, axis) + +# create an object, symmetrical to another object through the given point +mirror3 = geompy.MakeMirrorByPoint(box, p4) + +# add objects in the study +id_box = geompy.addToStudy(box, "Box") +id_plane = geompy.addToStudy(plane, "Plane") +id_mirror1 = geompy.addToStudy(mirror1, "Mirror plane") +id_axis = geompy.addToStudy(axis, "Axis") +id_mirror2 = geompy.addToStudy(mirror2, "Mirror axis") +id_p4 = geompy.addToStudy(p4, "Point") +id_mirror3 = geompy.addToStudy(mirror3, "Mirror point") + +# display the results +gg.createAndDisplayGO(id_box) +gg.setDisplayMode(id_box,1) +gg.createAndDisplayGO(id_plane) +gg.createAndDisplayGO(id_mirror1) +gg.setDisplayMode(id_mirror1,1) +gg.createAndDisplayGO(id_axis) +gg.createAndDisplayGO(id_mirror2) +gg.setDisplayMode(id_mirror2,1) +gg.createAndDisplayGO(id_p4) +gg.createAndDisplayGO(id_mirror3) +gg.setDisplayMode(id_mirror3,1) diff --git a/doc/salome/examples/transformation_operations_ex05.py b/doc/salome/examples/transformation_operations_ex05.py new file mode 100644 index 000000000..7b906b969 --- /dev/null +++ b/doc/salome/examples/transformation_operations_ex05.py @@ -0,0 +1,24 @@ +# Scale Transform + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create a box and a sphere +box = geompy.MakeBoxDXDYDZ(200, 200, 200) + +# scale the given object by the factor +p0 = geompy.MakeVertex(100, 100, 100) +factor = 0.5 +scale = geompy.MakeScaleTransform(box, p0, factor) + +# add objects in the study +id_box = geompy.addToStudy(box, "Box") +id_scale = geompy.addToStudy(scale, "Scale") + +# display the results +gg.createAndDisplayGO(id_box) +gg.setDisplayMode(id_box,1) +gg.setTransparency(id_box,0.5) +gg.createAndDisplayGO(id_scale) +gg.setDisplayMode(id_scale,1) diff --git a/doc/salome/examples/transformation_operations_ex06.py b/doc/salome/examples/transformation_operations_ex06.py new file mode 100644 index 000000000..f6c2adfd4 --- /dev/null +++ b/doc/salome/examples/transformation_operations_ex06.py @@ -0,0 +1,20 @@ +# Offset Surface + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create a box and a sphere +box = geompy.MakeBox(20, 20, 20, 200, 200, 200) + +# create a new object as offset of the given object +offset = geompy.MakeOffset(box, 70.) + +# add objects in the study +id_box = geompy.addToStudy(box, "Box") +id_offset = geompy.addToStudy(offset, "Offset") + +# display the results +gg.createAndDisplayGO(id_box) +gg.setDisplayMode(id_box,1) +gg.createAndDisplayGO(id_offset) diff --git a/doc/salome/examples/transformation_operations_ex07.py b/doc/salome/examples/transformation_operations_ex07.py new file mode 100644 index 000000000..c1efc39e3 --- /dev/null +++ b/doc/salome/examples/transformation_operations_ex07.py @@ -0,0 +1,31 @@ +# Projection + +import geompy +import salome + +# create a cylindric face and a curve(edge) +cylinder = geompy.MakeCylinderRH(100, 300) +[face_cyl] = geompy.SubShapes(cylinder, [3]) + +p1 = geompy.MakeVertex(200, 0, 100) +p2 = geompy.MakeVertex(200, 80, 100) +p3 = geompy.MakeVertex(200, 80, 180) +p4 = geompy.MakeVertex(130, 80, 180) +p5 = geompy.MakeVertex(90, 80, 240) + +curve = geompy.MakeInterpol([p1, p2, p3, p4, p5], False, False) + +# create a new object as projection of the +# given curve on the given cylindric face +projection = geompy.MakeProjection(curve, face_cyl) + +# add objects in the study +geompy.addToStudy(cylinder, "cylinder") +geompy.addToStudyInFather(cylinder, face_cyl, "face_cyl") +geompy.addToStudy(p1, "p1") +geompy.addToStudy(p2, "p2") +geompy.addToStudy(p3, "p3") +geompy.addToStudy(p4, "p4") +geompy.addToStudy(p5, "p5") +geompy.addToStudy(curve, "curve") +geompy.addToStudy(projection, "projection") diff --git a/doc/salome/examples/transformation_operations_ex08.py b/doc/salome/examples/transformation_operations_ex08.py new file mode 100644 index 000000000..fb103f950 --- /dev/null +++ b/doc/salome/examples/transformation_operations_ex08.py @@ -0,0 +1,48 @@ +# Multi Translation + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create vertices and vectors +p0 = geompy.MakeVertex( 0., 0., 0.) +px = geompy.MakeVertex(20., 0., 0.) +py = geompy.MakeVertex( 0., 20., 0.) +pz = geompy.MakeVertex( 0., 0., 20.) +pxy = geompy.MakeVertex( 50., 0., 0.) +pxyz = geompy.MakeVertex( 50., 50., 50.) +vz = geompy.MakeVector(p0, pz) +vxy = geompy.MakeVector(px, py) +vtr1d = geompy.MakeVector(p0, pxyz) +vtr2d = geompy.MakeVector(p0, pxy) + +# create an arc +arc = geompy.MakeArc(py, pz, px) + +# create a wire +wire = geompy.MakeWire([vxy, arc]) + +# create a planar face +face = geompy.MakeFace(wire, 1) + +# create a prism +prism = geompy.MakePrismVecH(face, vz, 20.0) + +# translate the given object along the given vector a given number of times +tr1d = geompy.MakeMultiTranslation1D(prism, vtr1d, 20, 4) + +# consequently apply two specified translations to the object a given number of times +tr2d = geompy.MakeMultiTranslation2D(prism, vtr1d, 20, 4, vtr2d, 80, 3) + +# add objects in the study +id_prism = geompy.addToStudy(prism,"Prism") +id_tr1d = geompy.addToStudy(tr1d,"Translation 1D") +id_tr2d = geompy.addToStudy(tr2d,"Translation 2D") + +# display the prism and the results of fillet operation +gg.createAndDisplayGO(id_prism) +gg.setDisplayMode(id_prism,1) +gg.createAndDisplayGO(id_tr1d) +gg.setDisplayMode(id_tr1d,1) +gg.createAndDisplayGO(id_tr2d) +gg.setDisplayMode(id_tr2d,1) diff --git a/doc/salome/examples/transformation_operations_ex09.py b/doc/salome/examples/transformation_operations_ex09.py new file mode 100644 index 000000000..665a2acb3 --- /dev/null +++ b/doc/salome/examples/transformation_operations_ex09.py @@ -0,0 +1,64 @@ +# Multi Rotation + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") +import math + +# create vertices and vectors +p0 = geompy.MakeVertex( 0., 0., 0.) +px = geompy.MakeVertex(20., 0., 0.) +py = geompy.MakeVertex( 0., 20., 0.) +pz = geompy.MakeVertex( 0., 0., 20.) +pxyz = geompy.MakeVertex( 50., 50., 10.) +vz = geompy.MakeVector(p0, pz) +vxy = geompy.MakeVector(px, py) +vrot = geompy.MakeVector(p0, pxyz) + +# create an arc +arc = geompy.MakeArc(py, pz, px) + +# create a wire +wire = geompy.MakeWire([vxy, arc]) + +# create a planar face +face = geompy.MakeFace(wire, 1) + +# create a prism +prism = geompy.MakePrismVecH(face, vz, 20.0) + +# 1. Rotate the prism around the axis vrot 4 times + +# rotation angle = 2 * PI / 4 +rot1da = geompy.MultiRotate1DNbTimes(prism, vrot, 4) + +# by the given angle of 30 degrees +rot1db = geompy.MultiRotate1DByStep(prism, vrot, math.pi/6., 4) + +# 2. Rotate the prism around the axis vrot 4 times +# and translate the result of each rotation 5 times on distance 50 + +# rotation angle = 2 * PI / 4 +rot2da = geompy.MultiRotate2DNbTimes(prism, vrot, 4, 50, 5) + +# by the given angle of 60 degrees +rot2db = geompy.MultiRotate2DByStep(prism, vrot, math.pi/3., 4, 50, 5) + +# add objects in the study +id_prism = geompy.addToStudy(prism,"Prism") +id_rot1da = geompy.addToStudy(rot1da,"Rotation 1D Nb.Times") +id_rot1db = geompy.addToStudy(rot1db,"Rotation 1D By Step") +id_rot2da = geompy.addToStudy(rot2da,"Rotation 2D Nb.Times") +id_rot2db = geompy.addToStudy(rot2db,"Rotation 2D By Step") + +# display the prism and the results of fillet operation +gg.createAndDisplayGO(id_prism) +gg.setDisplayMode(id_prism,1) +gg.createAndDisplayGO(id_rot1da) +gg.setDisplayMode(id_rot1da,1) +gg.createAndDisplayGO(id_rot1db) +gg.setDisplayMode(id_rot1db,1) +gg.createAndDisplayGO(id_rot2da) +gg.setDisplayMode(id_rot2da,1) +gg.createAndDisplayGO(id_rot2db) +gg.setDisplayMode(id_rot2db,1) diff --git a/doc/salome/examples/transformation_operations_ex10.py b/doc/salome/examples/transformation_operations_ex10.py new file mode 100644 index 000000000..cd2527331 --- /dev/null +++ b/doc/salome/examples/transformation_operations_ex10.py @@ -0,0 +1,17 @@ +# Fillet 2D + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create a face in OXY plane +face = geompy.MakeFaceHW(100, 100, 1) +fillet2d = geompy.MakeFillet2D(face, 30, [7, 9]) + +# add objects in the study +id_face = geompy.addToStudy(face,"Face_1") +id_fillet2d = geompy.addToStudy(fillet2d,"Fillet 2D_1") + +# display disks +gg.createAndDisplayGO(id_face) +gg.createAndDisplayGO(id_fillet2d) diff --git a/doc/salome/examples/transformation_operations_ex11.py b/doc/salome/examples/transformation_operations_ex11.py new file mode 100644 index 000000000..f3b4bd095 --- /dev/null +++ b/doc/salome/examples/transformation_operations_ex11.py @@ -0,0 +1,19 @@ +# Fillet 1D + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create box +Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200) +# take box edges to create custom complex wire +[Edge_1,Edge_2,Edge_3,Edge_4,Edge_5,Edge_6,Edge_7,Edge_8,Edge_9,Edge_10,Edge_11,Edge_12] = geompy.SubShapeAllSortedCentres(Box_1, geompy.ShapeType["EDGE"]) +# create wire +Wire_1 = geompy.MakeWire([Edge_12, Edge_7, Edge_11, Edge_6, Edge_1,Edge_4]) +# make fillet at given wire vertices with giver radius +Fillet_1D_1 = geompy.MakeFillet1D(Wire_1, 55, [3, 4, 6, 8, 10]) + + +# display disks +gg.createAndDisplayGO(Wire_1) +gg.createAndDisplayGO(Fillet_1D_1) diff --git a/doc/salome/examples/transformation_operations_ex12.py b/doc/salome/examples/transformation_operations_ex12.py new file mode 100644 index 000000000..1f0f31c97 --- /dev/null +++ b/doc/salome/examples/transformation_operations_ex12.py @@ -0,0 +1,53 @@ +# Fillet + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") +radius = 10. +ShapeTypeEdge = geompy.ShapeType["EDGE"] + +# create vertices and vectors +p0 = geompy.MakeVertex( 0., 0., 0.) +px = geompy.MakeVertex(100., 0., 0.) +py = geompy.MakeVertex( 0., 100., 0.) +pz = geompy.MakeVertex( 0., 0., 100.) +vz = geompy.MakeVector(p0, pz) +vxy = geompy.MakeVector(px, py) + +# create an arc +arc = geompy.MakeArc(py, pz, px) + +# create a wire +wire = geompy.MakeWire([vxy, arc]) + +# create a planar face +face = geompy.MakeFace(wire, 1) + +# create a prism +prism = geompy.MakePrismVecH(face, vz, 100.0) + +# get the list of IDs (IDList) for the fillet +prism_edges = geompy.SubShapeAllSortedCentres(prism, ShapeTypeEdge) +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])) + +# make a fillet on the specified edges of the given shape +fillet = geompy.MakeFillet(prism, radius, ShapeTypeEdge, IDlist_e) + +# make a fillet on all edges of the given shape +filletall = geompy.MakeFilletAll(prism, radius) + +# add objects in the study +id_prism = geompy.addToStudy(prism,"Prism") +id_fillet = geompy.addToStudy(fillet,"Fillet") +id_filletall = geompy.addToStudy(filletall,"Fillet all") + +# display the prism and the results of fillet operation +gg.createAndDisplayGO(id_prism) +gg.setDisplayMode(id_prism,1) +gg.createAndDisplayGO(id_fillet) +gg.setDisplayMode(id_fillet,1) +gg.createAndDisplayGO(id_filletall) +gg.setDisplayMode(id_filletall,1) diff --git a/doc/salome/examples/transformation_operations_ex13.py b/doc/salome/examples/transformation_operations_ex13.py new file mode 100644 index 000000000..ecc896e2b --- /dev/null +++ b/doc/salome/examples/transformation_operations_ex13.py @@ -0,0 +1,63 @@ +# Chamfer + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") +d1 = 10. +d2 = 10. +ShapeTypeFace = geompy.ShapeType["FACE"] + +# create vertices and vectors +p0 = geompy.MakeVertex( 0., 0., 0.) +px = geompy.MakeVertex(100., 0., 0.) +py = geompy.MakeVertex( 0., 100., 0.) +pz = geompy.MakeVertex( 0., 0., 100.) +vz = geompy.MakeVector(p0, pz) +vxy = geompy.MakeVector(px, py) + +# create an arc +arc = geompy.MakeArc(py, pz, px) + +# create a wire +wire = geompy.MakeWire([vxy, arc]) + +# create a planar face +face = geompy.MakeFace(wire, 1) + +# create a prism +prism = geompy.MakePrismVecH(face, vz, 100.0) + +# get the list of IDs (IDList) for the chamfer +prism_faces = geompy.SubShapeAllSortedCentres(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] + +# perform a chamfer on the edges common to the specified faces +chamfer_e = geompy.MakeChamferEdge(prism, d1, d2, f_ind_1, f_ind_2) + +# perform a chamfer on all edges of the specified faces +chamfer_f = geompy.MakeChamferFaces(prism, d1, d2, IDlist_f) +chamfer_f1 = geompy.MakeChamfer(prism, d1, d2, ShapeTypeFace, IDlist_f) + +# perform a symmetric chamfer on all edges of the given shape +chamfer_all = geompy.MakeChamferAll(prism, d1) + +# add objects in the study +id_prism = geompy.addToStudy(prism,"Prism") +id_chamfer_e = geompy.addToStudy(chamfer_e,"Chamfer edge") +id_chamfer_f = geompy.addToStudy(chamfer_f,"Chamfer faces") +id_chamfer_f1 = geompy.addToStudy(chamfer_f1,"Chamfer faces 1") +id_chamfer_all = geompy.addToStudy(chamfer_all,"Chamfer all") + +# display the prism and the results of chamfer operation +gg.createAndDisplayGO(id_prism) +gg.setDisplayMode(id_prism,1) +gg.createAndDisplayGO(id_chamfer_e) +gg.setDisplayMode(id_chamfer_e,1) +gg.createAndDisplayGO(id_chamfer_f) +gg.setDisplayMode(id_chamfer_f,1) +gg.createAndDisplayGO(id_chamfer_f1) +gg.setDisplayMode(id_chamfer_f1,1) +gg.createAndDisplayGO(id_chamfer_all) +gg.setDisplayMode(id_chamfer_all,1) diff --git a/doc/salome/examples/viewing_geom_objs_ex01.py b/doc/salome/examples/viewing_geom_objs_ex01.py new file mode 100644 index 000000000..473c7f15a --- /dev/null +++ b/doc/salome/examples/viewing_geom_objs_ex01.py @@ -0,0 +1,17 @@ +# Changing Display Mode + +import salome +import geompy +box = geompy.MakeBox(0,0,0, 50,50,50) +box2 = geompy.MakeBox(-50,-50,-50, 0,0,0) + +sphere = geompy.MakeSphere(50,50,50, 30) +fuse = geompy.MakeBoolean(box,sphere,3) +fuse_id = geompy.addToStudy(fuse,"Fuse") +box_id = geompy.addToStudy(box2, "Box") + +gg = salome.ImportComponentGUI("GEOM") +gg.createAndDisplayGO(fuse_id) +gg.setDisplayMode(fuse_id,1) +gg.createAndDisplayGO(box_id) +gg.setVectorsMode(box_id, 1) diff --git a/doc/salome/examples/viewing_geom_objs_ex02.py b/doc/salome/examples/viewing_geom_objs_ex02.py new file mode 100644 index 000000000..fd8243d2f --- /dev/null +++ b/doc/salome/examples/viewing_geom_objs_ex02.py @@ -0,0 +1,14 @@ +# Changing Color + +import salome +import geompy +box = geompy.MakeBox(0,0,0, 50,50,50) + +sphere = geompy.MakeSphere(50,50,50, 30) +fuse = geompy.MakeBoolean(box,sphere,3) +fuse_id = geompy.addToStudy(fuse,"Fuse") + +gg = salome.ImportComponentGUI("GEOM") +gg.createAndDisplayGO(fuse_id) +gg.setDisplayMode(fuse_id,1) +gg.setColor(fuse_id,218,165,31) diff --git a/doc/salome/examples/viewing_geom_objs_ex03.py b/doc/salome/examples/viewing_geom_objs_ex03.py new file mode 100644 index 000000000..381f0e9ae --- /dev/null +++ b/doc/salome/examples/viewing_geom_objs_ex03.py @@ -0,0 +1,16 @@ +# Changing Transparency + +import salome +import geompy + +box = geompy.MakeBox(0,0,0, 50,50,50) +sphere = geompy.MakeSphere(50,50,50, 30) + +fuse = geompy.MakeBoolean(box,sphere,3) +fuse_id = geompy.addToStudy(fuse,"Fuse") + +gg = salome.ImportComponentGUI("GEOM") +gg.createAndDisplayGO(fuse_id) +gg.setDisplayMode(fuse_id,1) +gg.setColor(fuse_id,218,165,31) +gg.setTransparency(fuse_id,0.5) diff --git a/doc/salome/examples/viewing_geom_objs_ex04.py b/doc/salome/examples/viewing_geom_objs_ex04.py new file mode 100644 index 000000000..cf521f407 --- /dev/null +++ b/doc/salome/examples/viewing_geom_objs_ex04.py @@ -0,0 +1,14 @@ +# Set Point Marker + +import salome +import geompy + +texture = geompy.LoadTexture("/users/user/mytexture.dat") + +v1 = geompy.MakeVertex(0, 0, 0) +v2 = geompy.MakeVertex(100, 0, 0) +v3 = geompy.MakeVertex(0, 100, 0) + +v1.SetMarkerStd(GEOM.MT_O_PLUS, GEOM.MS_25) +v2.SetMarkerStd(GEOM.MT_BALL, GEOM.MS_40) +v3.SetMarkerTexture(texture) diff --git a/doc/salome/examples/whatis.py b/doc/salome/examples/whatis.py new file mode 100644 index 000000000..42e7e4e4d --- /dev/null +++ b/doc/salome/examples/whatis.py @@ -0,0 +1,9 @@ +# What Is + +import geompy + +# create a box +box = geompy.MakeBoxDXDYDZ(100,30,100) +Descr = geompy.WhatIs(box) +print "\nBox 100x30x100 description:" +print Descr diff --git a/doc/salome/examples/working_with_groups_ex01.py b/doc/salome/examples/working_with_groups_ex01.py new file mode 100644 index 000000000..821862f4a --- /dev/null +++ b/doc/salome/examples/working_with_groups_ex01.py @@ -0,0 +1,37 @@ +# Creation of a group + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create two vertices +p0 = geompy.MakeVertex(0. , 0. , 0. ) +p200 = geompy.MakeVertex(200., 200., 200.) + +# create a box from two points +Box = geompy.MakeBoxTwoPnt(p0, p200) + +# create a group from the faces of the box +group = geompy.CreateGroup(Box, geompy.ShapeType["FACE"]) + +# add objects to the group +SubFaceList = geompy.SubShapeAllSortedCentres(Box, geompy.ShapeType["FACE"]) +for i in [0, 3, 5] : + FaceID = geompy.GetSubShapeID(Box, SubFaceList[i]) + geompy.AddObject(group, FaceID) + +# add all selected shapes from the list to the group +# (the program doesn't raise error, if some shapes are already included) +geompy.UnionList(group, [SubFaceList[0], SubFaceList[2], SubFaceList[5]]) + +# remove an object from the group +geompy.RemoveObject(group, FaceID) + +# remove all selected shapes from the group +# (the program doesn't raise error, if some shapes are not included) +geompy.DifferenceList(group, [SubFaceList[2], SubFaceList[3], SubFaceList[4]]) +id_group1 = geompy.addToStudy(group, "Group1") + +# display the contents of the group +gg.createAndDisplayGO(id_group1) +salome.sg.updateObjBrowser(1) diff --git a/doc/salome/examples/working_with_groups_ex02.py b/doc/salome/examples/working_with_groups_ex02.py new file mode 100644 index 000000000..4c415babe --- /dev/null +++ b/doc/salome/examples/working_with_groups_ex02.py @@ -0,0 +1,26 @@ +# Adding an object to the group + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create two vertices +p0 = geompy.MakeVertex(0. , 0. , 0. ) +p200 = geompy.MakeVertex(200., 200., 200.) + +# create a box from two points +Box = geompy.MakeBoxTwoPnt(p0, p200) + +# create a group from the faces of the box +group = geompy.CreateGroup(Box, geompy.ShapeType["FACE"]) + +# add objects to the group +SubFaceList = geompy.SubShapeAllSortedCentres(Box, geompy.ShapeType["FACE"]) +for i in [0, 3, 5] : + FaceID = geompy.GetSubShapeID(Box, SubFaceList[i]) + geompy.AddObject(group, FaceID) +id_group1 = geompy.addToStudy(group, "Group1") + +# display the contents of the group +gg.createAndDisplayGO(id_group1) +salome.sg.updateObjBrowser(1) diff --git a/doc/salome/examples/working_with_groups_ex03.py b/doc/salome/examples/working_with_groups_ex03.py new file mode 100644 index 000000000..2c8a3d5f3 --- /dev/null +++ b/doc/salome/examples/working_with_groups_ex03.py @@ -0,0 +1,33 @@ +# Removing an object from the group + +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create two vertices +p0 = geompy.MakeVertex(0. , 0. , 0. ) +p200 = geompy.MakeVertex(200., 200., 200.) + +# create a box from two points +Box = geompy.MakeBoxTwoPnt(p0, p200) + +# create a group from the faces of the box +group = geompy.CreateGroup(Box, geompy.ShapeType["FACE"]) + +# add objects to the group +SubFaceList = geompy.SubShapeAllSortedCentres(Box, geompy.ShapeType["FACE"]) +for i in [0, 3, 5] : + FaceID = geompy.GetSubShapeID(Box, SubFaceList[i]) + geompy.AddObject(group, FaceID) + +# add all selected shapes from the list to the group +# (the program doesn't raise errors, if some shapes are already included) +geompy.UnionList(group, [SubFaceList[0], SubFaceList[2], SubFaceList[5]]) + +# remove an object from the group +geompy.RemoveObject(group, FaceID) +id_group1 = geompy.addToStudy(group, "Group1") + +# display the contents of the group +gg.createAndDisplayGO(id_group1) +salome.sg.updateObjBrowser(1) diff --git a/doc/salome/examples/working_with_groups_ex04.py b/doc/salome/examples/working_with_groups_ex04.py new file mode 100644 index 000000000..945ae61fc --- /dev/null +++ b/doc/salome/examples/working_with_groups_ex04.py @@ -0,0 +1,29 @@ +# Union Groups + +import geompy +import salome + +# create a box and some groups of faces on it +Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200) +Group_1 = geompy.CreateGroup(Box_1, geompy.ShapeType["FACE"]) +geompy.UnionIDs(Group_1, [13, 23]) +Group_2 = geompy.CreateGroup(Box_1, geompy.ShapeType["FACE"]) +geompy.UnionIDs(Group_2, [3, 27]) +Group_3 = geompy.CreateGroup(Box_1, geompy.ShapeType["FACE"]) +geompy.UnionIDs(Group_3, [33, 23]) +Group_4 = geompy.CreateGroup(Box_1, geompy.ShapeType["FACE"]) +geompy.UnionIDs(Group_4, [31, 27]) + +# union groups +Group_U_1_2 = geompy.UnionGroups(Group_1, Group_2) +Group_UL_3_4 = geompy.UnionListOfGroups([Group_3, Group_4]) + +# publish shapes +geompy.addToStudy(Box_1, 'Box_1') +geompy.addToStudyInFather(Box_1, Group_1, 'Group_1') +geompy.addToStudyInFather(Box_1, Group_2, 'Group_2') +geompy.addToStudyInFather(Box_1, Group_3, 'Group_3') +geompy.addToStudyInFather(Box_1, Group_4, 'Group_4') +geompy.addToStudyInFather(Box_1, Group_U_1_2, 'Group_U_1_2') +geompy.addToStudyInFather(Box_1, Group_UL_3_4, 'Group_UL_3_4') +salome.sg.updateObjBrowser(1) diff --git a/doc/salome/examples/working_with_groups_ex05.py b/doc/salome/examples/working_with_groups_ex05.py new file mode 100644 index 000000000..422c67274 --- /dev/null +++ b/doc/salome/examples/working_with_groups_ex05.py @@ -0,0 +1,29 @@ +# Intersect Groups + +import geompy +import salome + +# create a box and some groups of faces on it +Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200) +Group_1 = geompy.CreateGroup(Box_1, geompy.ShapeType["FACE"]) +geompy.UnionIDs(Group_1, [13, 23]) +Group_2 = geompy.CreateGroup(Box_1, geompy.ShapeType["FACE"]) +geompy.UnionIDs(Group_2, [3, 27]) +Group_3 = geompy.CreateGroup(Box_1, geompy.ShapeType["FACE"]) +geompy.UnionIDs(Group_3, [33, 23]) +Group_4 = geompy.CreateGroup(Box_1, geompy.ShapeType["FACE"]) +geompy.UnionIDs(Group_4, [31, 27]) + +# intersect groups +Group_I_1_3 = geompy.IntersectGroups(Group_1, Group_3) +Group_IL_1_3 = geompy.IntersectListOfGroups([Group_1, Group_3]) + +# publish shapes +geompy.addToStudy(Box_1, 'Box_1') +geompy.addToStudyInFather(Box_1, Group_1, 'Group_1') +geompy.addToStudyInFather(Box_1, Group_2, 'Group_2') +geompy.addToStudyInFather(Box_1, Group_3, 'Group_3') +geompy.addToStudyInFather(Box_1, Group_4, 'Group_4') +geompy.addToStudyInFather(Box_1, Group_I_1_3, 'Group_I_1_3') +geompy.addToStudyInFather(Box_1, Group_IL_1_3, 'Group_IL_1_3') +salome.sg.updateObjBrowser(1) diff --git a/doc/salome/examples/working_with_groups_ex06.py b/doc/salome/examples/working_with_groups_ex06.py new file mode 100644 index 000000000..65c4fe21e --- /dev/null +++ b/doc/salome/examples/working_with_groups_ex06.py @@ -0,0 +1,29 @@ +# Cut Groups + +import geompy +import salome + +# create a box and some groups of faces on it +Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200) +Group_1 = geompy.CreateGroup(Box_1, geompy.ShapeType["FACE"]) +geompy.UnionIDs(Group_1, [13, 23]) +Group_2 = geompy.CreateGroup(Box_1, geompy.ShapeType["FACE"]) +geompy.UnionIDs(Group_2, [3, 27]) +Group_3 = geompy.CreateGroup(Box_1, geompy.ShapeType["FACE"]) +geompy.UnionIDs(Group_3, [33, 23]) +Group_4 = geompy.CreateGroup(Box_1, geompy.ShapeType["FACE"]) +geompy.UnionIDs(Group_4, [31, 27]) + +# cut groups +Group_C_2_4 = geompy.CutGroups(Group_2, Group_4) +Group_CL_2_4 = geompy.CutListOfGroups([Group_2], [Group_4]) + +# publish shapes +geompy.addToStudy(Box_1, 'Box_1') +geompy.addToStudyInFather(Box_1, Group_1, 'Group_1') +geompy.addToStudyInFather(Box_1, Group_2, 'Group_2') +geompy.addToStudyInFather(Box_1, Group_3, 'Group_3') +geompy.addToStudyInFather(Box_1, Group_4, 'Group_4') +geompy.addToStudyInFather(Box_1, Group_C_2_4, 'Group_C_2_4') +geompy.addToStudyInFather(Box_1, Group_CL_2_4, 'Group_CL_2_4') +salome.sg.updateObjBrowser(1) diff --git a/doc/salome/gui/GEOM/doxyfile.in b/doc/salome/gui/GEOM/doxyfile.in index 06d9bfd86..267b71c24 100755 --- a/doc/salome/gui/GEOM/doxyfile.in +++ b/doc/salome/gui/GEOM/doxyfile.in @@ -43,7 +43,7 @@ FILE_PATTERNS = *.doc EXCLUDE_PATTERNS = creating_adv_obj.doc EXCLUDE = IMAGE_PATH = @srcdir@/images -EXAMPLE_PATH = @top_srcdir@/src/GEOM_SWIG +EXAMPLE_PATH = @top_srcdir@/src/GEOM_SWIG @top_srcdir@/doc/salome/examples #--------------------------------------------------------------------------- #HTML related options diff --git a/doc/salome/gui/GEOM/images/curve4.png b/doc/salome/gui/GEOM/images/curve4.png index cbb60924d..2fe0db0ae 100644 Binary files a/doc/salome/gui/GEOM/images/curve4.png and b/doc/salome/gui/GEOM/images/curve4.png differ diff --git a/doc/salome/gui/GEOM/images/distance.png b/doc/salome/gui/GEOM/images/distance.png index 594bef905..31fa829fd 100755 Binary files a/doc/salome/gui/GEOM/images/distance.png and b/doc/salome/gui/GEOM/images/distance.png differ diff --git a/doc/salome/gui/GEOM/images/editgroup.png b/doc/salome/gui/GEOM/images/editgroup.png index 935fabeac..d0a3c314b 100755 Binary files a/doc/salome/gui/GEOM/images/editgroup.png and b/doc/salome/gui/GEOM/images/editgroup.png differ diff --git a/doc/salome/gui/GEOM/images/hide_predef_material.PNG b/doc/salome/gui/GEOM/images/hide_predef_material.PNG new file mode 100755 index 000000000..a9516fd00 Binary files /dev/null and b/doc/salome/gui/GEOM/images/hide_predef_material.PNG differ diff --git a/doc/salome/gui/GEOM/images/material.png b/doc/salome/gui/GEOM/images/material.png index 085921468..bcdd1db22 100644 Binary files a/doc/salome/gui/GEOM/images/material.png and b/doc/salome/gui/GEOM/images/material.png differ diff --git a/doc/salome/gui/GEOM/images/materials_library.png b/doc/salome/gui/GEOM/images/materials_library.png new file mode 100755 index 000000000..9ff8c390e Binary files /dev/null and b/doc/salome/gui/GEOM/images/materials_library.png differ diff --git a/doc/salome/gui/GEOM/images/measures5.png b/doc/salome/gui/GEOM/images/measures5.png index 13af1afdf..d2180be63 100755 Binary files a/doc/salome/gui/GEOM/images/measures5.png and b/doc/salome/gui/GEOM/images/measures5.png differ diff --git a/doc/salome/gui/GEOM/images/mtrans1.png b/doc/salome/gui/GEOM/images/mtrans1.png index f5752e4b1..2e9685574 100755 Binary files a/doc/salome/gui/GEOM/images/mtrans1.png and b/doc/salome/gui/GEOM/images/mtrans1.png differ diff --git a/doc/salome/gui/GEOM/images/mtrans2.png b/doc/salome/gui/GEOM/images/mtrans2.png index c61b1c3c1..8f051425b 100755 Binary files a/doc/salome/gui/GEOM/images/mtrans2.png and b/doc/salome/gui/GEOM/images/mtrans2.png differ diff --git a/doc/salome/gui/GEOM/images/neo-mrot1.png b/doc/salome/gui/GEOM/images/neo-mrot1.png index e94b5ab73..269fccc70 100755 Binary files a/doc/salome/gui/GEOM/images/neo-mrot1.png and b/doc/salome/gui/GEOM/images/neo-mrot1.png differ diff --git a/doc/salome/gui/GEOM/images/neo-mrot2.png b/doc/salome/gui/GEOM/images/neo-mrot2.png index f3f3c347e..b17098a75 100755 Binary files a/doc/salome/gui/GEOM/images/neo-mrot2.png and b/doc/salome/gui/GEOM/images/neo-mrot2.png differ diff --git a/doc/salome/gui/GEOM/images/pref15.png b/doc/salome/gui/GEOM/images/pref15.png index 3d9e5f628..f58d73091 100755 Binary files a/doc/salome/gui/GEOM/images/pref15.png and b/doc/salome/gui/GEOM/images/pref15.png differ diff --git a/doc/salome/gui/GEOM/images/repair9.png b/doc/salome/gui/GEOM/images/repair9.png index 72b7d32af..04c3035f2 100755 Binary files a/doc/salome/gui/GEOM/images/repair9.png and b/doc/salome/gui/GEOM/images/repair9.png differ diff --git a/doc/salome/gui/GEOM/images/show_predef_material.PNG b/doc/salome/gui/GEOM/images/show_predef_material.PNG new file mode 100755 index 000000000..922abce5a Binary files /dev/null and b/doc/salome/gui/GEOM/images/show_predef_material.PNG differ diff --git a/doc/salome/gui/GEOM/input/boudaries.doc b/doc/salome/gui/GEOM/input/boudaries.doc index 65acdc06a..de1e84a73 100644 --- a/doc/salome/gui/GEOM/input/boudaries.doc +++ b/doc/salome/gui/GEOM/input/boudaries.doc @@ -2,8 +2,10 @@ \page boundaries_page Check Free Boundaries -Detects and highlights wires and edges that are not shared between +Detects and highlights wires and edges that are not shared between two faces and are considered a shape's boundary. +
Creates corresponding objects and publishes them into the study on +"Apply" or "Apply and Close". TUI Command: (NoError, ClosedWires, OpenWires) = geompy.GetFreeBoundary(Shape), where \em Shape is a shape to be @@ -15,4 +17,4 @@ See also a \ref tui_free_boundaries_page "TUI example". \image html repair9.png -*/ \ No newline at end of file +*/ diff --git a/doc/salome/gui/GEOM/input/bounding_box.doc b/doc/salome/gui/GEOM/input/bounding_box.doc index eeb16c4ff..75b7c7eaf 100644 --- a/doc/salome/gui/GEOM/input/bounding_box.doc +++ b/doc/salome/gui/GEOM/input/bounding_box.doc @@ -2,8 +2,10 @@ \page bounding_box_page Bounding Box -Returns the dimensions of the bounding box for the selected -geometrical object. +Shows the dimensions of the bounding box for the selected +geometrical object. Creates corresponding shape (box) on "Apply". + +\image html measures5.png \note To take into account any possible shape distortion that affects the resulting bounding box, the algorithm enlarges @@ -12,14 +14,10 @@ faces (by iterating through all faces of a shape). This functionallity is implemented in such a way to have a satisfactory performance. -Result: Displays the bounding box dimensions of a -geometrical object in form of a Python Tuple (Xmin, Xmax, Ymin, -Ymax, Zmin, Zmax). -\n TUI Command: geompy.BoundingBox(Shape), where \em Shape +\n TUI Commands: [Xmin,Xmax, Ymin,Ymax, Zmin,Zmax] = geompy.BoundingBox(Shape), +BBox = geompy.MakeBoundingBox(Shape), where \em Shape is the shape for which a bounding box is computed. See also a \ref tui_bounding_box_page "TUI example". -\image html measures5.png - */ diff --git a/doc/salome/gui/GEOM/input/creating_curve.doc b/doc/salome/gui/GEOM/input/creating_curve.doc index 9c3371826..29cbbc8d1 100644 --- a/doc/salome/gui/GEOM/input/creating_curve.doc +++ b/doc/salome/gui/GEOM/input/creating_curve.doc @@ -70,10 +70,15 @@ closed edge.
  • If Reorder vertices taking into account distances is checked, the interpolation algorithm does not follow the order of vertices but searches for the closest vertex.
  • +
  • Tangents are two vectors, defining direction of curve at +its ends. Both or none vectors must be set. This option available only +if two above check boxes are not checked. +
  • \n TUI Command: -geompy.MakeInterpol(ListOfShapes,isClosed,doReordering) +
    geompy.MakeInterpol(ListOfShapes,isClosed,doReordering) +
    geompy.MakeInterpolWithTangents(ListOfShapes,Vector1,Vector2) Analytical Definition diff --git a/doc/salome/gui/GEOM/input/geometry_preferences.doc b/doc/salome/gui/GEOM/input/geometry_preferences.doc index 00301daf9..d0c94768d 100644 --- a/doc/salome/gui/GEOM/input/geometry_preferences.doc +++ b/doc/salome/gui/GEOM/input/geometry_preferences.doc @@ -36,8 +36,10 @@ of values set in spin boxes.
  • Deflection coefficient - allows to define default deflection coefficient for lines and surfaces. A smaller coefficient provides better quality of a shape in the viewer.
  • -
  • Default front material - allows to define default front face material.
  • -
  • Default back material - allows to define default back face material.
  • +
  • Show predefined materials in popup menu - allows to customize the displaying of popup menu with list of +predefined materials.
  • +
  • Default material - allows to define default material.
  • +
  • Subshapes color for editing a group - allows to select default color for subshapes in a group.
  • Edges width - allows to define default width of the edges.
  • Isolines width - allows to define default width of the isolines.
  • Preview edges width - allows to define width of the edges for preview.
  • diff --git a/doc/salome/gui/GEOM/input/geompy.doc b/doc/salome/gui/GEOM/input/geompy.doc index 1ab9a5b9d..f34f87fe1 100644 --- a/doc/salome/gui/GEOM/input/geompy.doc +++ b/doc/salome/gui/GEOM/input/geompy.doc @@ -40,6 +40,7 @@ provided by Geometry module.
  • \ref tui_test_others_page
  • \ref tui_test_spanner_page
  • \ref tui_test_all_page
  • +
  • \ref tui_test_measures_page
  • diff --git a/doc/salome/gui/GEOM/input/material.doc b/doc/salome/gui/GEOM/input/material.doc index 4960e06f3..09791f2f7 100644 --- a/doc/salome/gui/GEOM/input/material.doc +++ b/doc/salome/gui/GEOM/input/material.doc @@ -12,7 +12,21 @@ be changed in the future versions of SALOME Geometry module. \n You can change the material properties of the selected shape(s) in the dedicated dialog box. This dialog box can be invoked from the -context popup menu using "Material properties" item: +context popup menu. + +\n Appearance of popup menu can be customizable via +"Show predefined materials in popup menu" option from preferences. +If this option is switched off, only "Material properties" item will +be shown in popup menu. If this option is on (by default), "Material +properties" item in popup menu will open submenu listing predefined +materials and additionally "Custom..." item. + +\n "Show predefined materials in popup menu" option is switched off: +\image html hide_predef_material.PNG +\n "Show predefined materials in popup menu" option is switched on +\image html show_predef_material.PNG + +\n"Custom..." or "Material properties" item will open dialog box: \image html material.png @@ -22,6 +36,12 @@ shape presentation; - assign one of predefined global materials to the shape; - create a custom material model and apply it to the shape. +\n You also can work with custom materials in the "Materials library" dialog box. +This dialog box can be invoked from the "Tools" main menu using +"Materials library" item: + +\image html materials_library.png + \note This functionality is available in both OCC and VTK 3D viewers. However, note that due to the differencies between underlying API of OCC and VTK libraries the behaviour of the functionality related to @@ -80,8 +100,7 @@ scattered light tends to be red, although the light directly striking objects is white. OpenGL allows you to set the red, green, and blue values for each component of light independently. -\section material Material properties dialog box - +\section material_lib Materials library dialog box The dialog box consists of two parts: - The list box at the left shows all available material models, both predefined by the application and custom one specified by the user. @@ -98,22 +117,8 @@ it simulates light originating from an object. - \b Shininess - \b Type of material model: \em physical or \em artificial. -If the material model is specified as a \em physical one (like \em Gold, -for instance), this means that the color of the shape (more precisely -its \em ambient color) can not be modified. If you assign a physical -material model to the shape, the "Color" menu item will not be -available in the popup menu. - -If the model is non-physical (\em artificial), the color can be changed -to any appopriate one, only other attributes will be constant. In the -dialog box you will be able to modify the color of the shape via the -"Color" button. "Ambient color" button becomes disabled to signalize -that this attribute of the model is ignored. Also, it will be possible -to modify the color of the shape via the -\ref color_page "corresponding popup menu command". - All available predefined material models are shown in the list box of -the Color and Material Properties dialog: +the Materials dialog dialog: - [Current] item in the list corresponds to the material model currently assigned to the selected shape(s). This model can be freely modified by the user. @@ -130,6 +135,26 @@ is shown if the user presses right mouse button in the materials list box. An additional "Rename material" command, available in popup menu, can be used to change the name of material model. +\section material Material properties dialog box + +The dialog box looks like "Materials library" dialog box but has +some additions in the form of selection objects mechanizm and "Color" +property. + +If the material model is specified as a \em physical one (like \em Gold, +for instance), this means that the color of the shape (more precisely +its \em ambient color) can not be modified. If you assign a physical +material model to the shape, the "Color" menu item will not be +available in the popup menu. + +If the model is non-physical (\em artificial), the color can be changed +to any appopriate one, only other attributes will be constant. In the +dialog box you will be able to modify the color of the shape via the +"Color" button. "Ambient color" button becomes disabled to signalize +that this attribute of the model is ignored. Also, it will be possible +to modify the color of the shape via the +\ref color_page "corresponding popup menu command". + Examples: \image html material_OCC.png diff --git a/doc/salome/gui/GEOM/input/min_distance.doc b/doc/salome/gui/GEOM/input/min_distance.doc index 690a17f3a..9653e2210 100644 --- a/doc/salome/gui/GEOM/input/min_distance.doc +++ b/doc/salome/gui/GEOM/input/min_distance.doc @@ -3,14 +3,33 @@ \page min_distance_page Min. Distance Returns the minimum distance between two geometrical objects and -the coordinates of the vector of distance and shows the vector in the viewer. +the coordinates of the vector of distance and shows the distance in +the viewer. -TUI Command: geompy.MinDistance(Shape1, Shape2), -where \em Shape1 and \em Shape2 are shapes between which the minimal +\note The minimal distance searching task can have one or more +solutions, and also it can have an infinite set of solutions. All +found solutions are listed in dedicated combobox. When the user +selects any one of found solutions, presentation is displayed in the +OCC viewer and fields "Length", "DX", "DY" and "DZ" are filled with +corresponding values. If there are no solutions found, text "No +solution found" will be shown instead of solutions list; this could +mean what the task has an infinite number of solutions. + +\n \note Currently used OCCT functionality finds finite number of +solutions even in cases, where an infinite set of solutions exists. + +\n On \b Apply or Apply and Close it creates a set of closest +points of the shapes, corresponding to all found solutions. + +TUI Commands: +\naDist = geompy.MinDistance(Shape1, Shape2), +\n[aDist, DX, DY, DZ] = geompy.MinDistanceComponents(Shape1, Shape2), +\n[nbSols, (x11, y11, z11, x21, y21, z21, ...)] = geompy.ClosestPoints(Shape1, Shape2), +\n where \em Shape1 and \em Shape2 are shapes between which the minimal distance is computed. See also a \ref tui_min_distance_page "TUI example". \image html distance.png -*/ \ No newline at end of file +*/ diff --git a/doc/salome/gui/GEOM/input/multi_rotation_operation.doc b/doc/salome/gui/GEOM/input/multi_rotation_operation.doc index cdc6234a1..0238f6334 100644 --- a/doc/salome/gui/GEOM/input/multi_rotation_operation.doc +++ b/doc/salome/gui/GEOM/input/multi_rotation_operation.doc @@ -5,24 +5,28 @@ \n To produce a Multi Rotation in the Main Menu select Operations - > Transformation - > Multi Rotation -\n This operation creates several geometrical objects rotated in one -or two dimensions basing on the initial geometrical object. -\n The \b Result will be one or several \b GEOM_Objects (compound). +\n This operation creates a compound of several shapes rotated in one +or two dimensions basing on the initial shape. +\n The \b Result will be one \b GEOM_Object (compound). \n To produce a Simple Multi Rotation (in one dimension) you -need to define a \b Shape to be rotated, an \b Axis of rotation and a -Number of Times the shape must be rotated. Rotation Angle will -be 2 * \a PI / \a NbTimes. Number of shapes in the resulting compound will be equal -to \a NbTimes (if \a NbTimes = 1, the result will contain only the initial -non-transformed shape). -\n TUI Command: geompy.MultiRotate1D(Shape, Axis, NbTimes) -\n Arguments: Name + 1 shape + 1 vector for direction + 1 value -(repetition). +need to define a \b Shape to be rotated, an \b Axis of rotation (DZ by +default), Angle of rotation (optionally) and a Number of Times +the shape must be rotated. If Angular step is not defined +(checkbox is not checked), it will be 2 * \a PI / \a NbTimes. Number +of shape's copies in the resulting compound will be equal to +\a NbTimes (if \a NbTimes = 1, the result will contain only the +initial non-transformed shape). + +\n TUI Commands: +\n geompy.MultiRotate1DNbTimes(Shape, Axis, NbTimes) +\n geompy.MultiRotate1DByStep(Shape, Axis, AngleStep, NbTimes) \b NB! There is another way to execute a Multi-rotation operation, which is currently accessible only via TUI commands: -geompy.MakeMultiRotation1D(Shape, Dir, Point, NbTimes) which works in -the same way, but the Axis is defined by direction and point. +geompy.MakeMultiRotation1DNbTimes(Shape, Dir, Point, NbTimes), +geompy.MakeMultiRotation1DByStep(Shape, Dir, Point, AngleStep, NbTimes), +which works in the same way, but the Axis is defined by direction and point. \image html neo-mrot1.png @@ -31,23 +35,27 @@ the same way, but the Axis is defined by direction and point. \image html multi_rotation1d2.png "The result of a simple multi-rotation" \n Double Multi Rotation (in two dimensions) rotates the given -\b Object around the given \b Axis on the given \b Angle a given -Number of Times and multi-translates each rotation -result. Translation direction passes through the center of gravity of -the rotated shape and its projection on the rotation axis. Number of -shapes in the resulting compound will be equal to \a NbTimes1 x \a NbTimes2 (if -both \a NbTimes1 and \a NbTimes2 are equal to 1, the result will contain +\b Object around the given \b Axis (DZ by default) on the given +\b Angle (optional) a given Number of Times and +multi-translates each rotation result. +If Angular step is not defined (checkbox is not checked), it +will be 2 * \a PI / \a NbTimes. +Translation direction passes through the center of gravity of the +initial shape and its projection on the rotation axis. Number of +shape's copies in the resulting compound will be equal to \a NbTimes1 x \a NbTimes2 +(if both \a NbTimes1 and \a NbTimes2 are equal to 1, the result will contain only the initial non-transformed shape). \b Reverse checkbox allows to set the direction of rotation. -\n TUI Command: geompy.MultiRotate2D(Shape, Axis, Angle, NbTimes1, Step, NbTimes2) -\n Arguments: Name + 1 shape + 1 vector for direction + 1 angle -+ 1 value (repetition) + 1 step value + 1 value (repetition). + +\n TUI Commands: +\n geompy.MultiRotate2DNbTimes(Shape, Axis, NbTimes1, RadialStep, NbTimes2) +\n geompy.MultiRotate2DByStep(Shape, Axis, AngleStep, NbTimes1, RadialStep, NbTimes2) NB! There is another way to execute a Double Multi-rotation operation, which is currently accessible only via TUI commands: -geompy.MakeMultiRotation2D(Shape, Dir, Point, Angle, nbtimes1, Step,nbtimes2) -which works in the same way, -but the Axis is defined by direction and point. +geompy.MakeMultiRotation2DNbTimes(Shape, Dir, Point, NbTimes1, RadialStep, NbTimes2), +geompy.MakeMultiRotation2DByStep(Shape, Dir, Point, AngleStep, NbTimes1, RadialStep, NbTimes2), +which works in the same way, but the Axis is defined by direction and point. \image html neo-mrot2.png diff --git a/doc/salome/gui/GEOM/input/multi_translation_operation.doc b/doc/salome/gui/GEOM/input/multi_translation_operation.doc index 0d084f3c1..6274ad9b4 100644 --- a/doc/salome/gui/GEOM/input/multi_translation_operation.doc +++ b/doc/salome/gui/GEOM/input/multi_translation_operation.doc @@ -7,9 +7,8 @@ select Operations - > Transformation - > Multi Translation \n This operation makes several translations of a shape in \b one or \b two directions. -\n The \b Result will be one or several \b GEOM_Objects -(compound). The total number of shapes in the resulting compound (for -a single initial selected shape) will be equal to: +\n The \b Result will be one \b GEOM_Object (compound). The total +number of shape copies in the resulting compound will be equal to: - in case of \ref single_multi_translation "Single multi translation": \a NbTimes (if \a NbTimes parameter is equal to 1, the result will contain only the initial non-translated shape). @@ -21,14 +20,11 @@ initial shape). \anchor single_multi_translation \n To produce a Simple Multi Translation (in one direction) you need to indicate an \b Object to be translated, a \b Vector of -translation, a \b Step of translation and a Number of Times the -Object should be duplicated. If a curve has been selected instead of -the Vector, only its first and last vertices will be used to get the vector direction -and the dialog preview will display the vector along which the object will be translated. -\n TUI Command: geompy.MakeMultiTranslation1D(Shape, Dir, -Step, NbTimes) -\n Arguments: Name + 1 shape + 1 vector (for direction) + 1 -step value + 1 value (repetition). +translation (DX by default), a \b Step of translation and a Number +of Times the Object should be duplicated. If a curve has been +selected instead of the Vector, only its first and last vertices will +be used to get the vector direction and the dialog preview will +display the vector along which the object will be translated. \image html mtrans1.png @@ -36,12 +32,26 @@ step value + 1 value (repetition). \image html multi_translation1dsn.png "The result of a simple multi-translation" +\n TUI Command: geompy.MakeMultiTranslation1D(Shape, Dir, +Step, NbTimes) +\n Arguments: Name + 1 shape + 1 vector (for direction) + 1 +step value + 1 value (repetition). + \anchor double_multi_translation \n To produce a Double Multi Translation (in two directions) you need to indicate an \b Object to be translated, and, for both axes, a \b -Vector of translation, a \b Step of translation and a Number of Times the shape must be duplicated. -If a curve has been selected instead of the Vector, only its first and last vertices will be used to get the vector direction -and the dialog preview will display the vector along which the object will be translated. +Vector of translation (DX and DY by default), a \b Step of translation +and a Number of Times the shape must be duplicated. +If a curve has been selected instead of the Vector, only its first and +last vertices will be used to get the vector direction and the dialog +preview will display the vector along which the object will be +translated. + +\image html mtrans2.png + +\image html multi_translation_initialsn.png "The initial object" + +\image html multi_translation2dsn.png "The result of a double multi-translation" \n TUI Command: geompy.MakeMultiTranslation2D(Shape, Dir1, Step1, NbTimes1, Dir2, Step2, NbTimes2), where \em Shape is a shape @@ -53,12 +63,6 @@ along \em Dir2. \n Arguments: Name + 1 shape + 2 vectors defining the direction + 2 step values + 2 values (repetitions). -\image html mtrans2.png - -\image html multi_translation_initialsn.png "The initial object" - -\image html multi_translation2dsn.png "The result of a double multi-translation" - Our TUI Scripts provide you with useful examples of the use of \ref tui_multi_translation "Transformation Operations". diff --git a/doc/salome/gui/GEOM/input/tui_3dsketcher.doc b/doc/salome/gui/GEOM/input/tui_3dsketcher.doc index 4916dfce2..9afadc9ca 100755 --- a/doc/salome/gui/GEOM/input/tui_3dsketcher.doc +++ b/doc/salome/gui/GEOM/input/tui_3dsketcher.doc @@ -1,49 +1,7 @@ /*! \page tui_3dsketcher_page 3D Sketcher - -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -# Create a 3D sketcher (wire) on the given points coordinates -sketcher1 = geompy.Make3DSketcher([ 0,0,0, 50,50,50, 0,50,0, 50,0,50, 10,20,100, 0,0,0 ]) - -# add object in the study -id_sketcher1 = geompy.addToStudy(sketcher1, "Sketcher1") - -# display the sketcher -gg.createAndDisplayGO(id_sketcher1) - -# Create a 3D sketcher (wire) with Sketcher3D interface - -# get the interface instance -sk = geompy.Sketcher3D() - -# add three points with absolute coordinates -# the first point will be the start point of sketcher -# two segments will be added by this command -sk.addPointsAbsolute(1,2,3, 7,0,0, 10,-3.5,-11) - -# add one segment, defined by two angles in "OXY" coordinate system and length -sk.addPointAnglesLength("OXY", 45, 0, 100) - -# add three points with relative coordinates -# three segments will be added by this command -sk.addPointsRelative(20,0,0, 20,0,100, -40,0,-50) - -# set to close the sketcher -sk.close() - -# obtain the sketcher result -sketcher2 = sk.wire() - -# add object in the study -id_sketcher2 = geompy.addToStudy(sketcher2, "Sketcher2") - -# display the sketcher -gg.createAndDisplayGO(id_sketcher2) -\endcode +\include 3dsketcher.py +Download this script */ diff --git a/doc/salome/gui/GEOM/input/tui_advanced_geom_objs.doc b/doc/salome/gui/GEOM/input/tui_advanced_geom_objs.doc index 1d469e9e8..1f513a496 100644 --- a/doc/salome/gui/GEOM/input/tui_advanced_geom_objs.doc +++ b/doc/salome/gui/GEOM/input/tui_advanced_geom_objs.doc @@ -4,119 +4,18 @@ \anchor tui_creation_pipetshape

    Creation of PipeTShape

    - -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -# create PipeTShape object -pipetshape = geompy.MakePipeTShape(80.0, 20.0, 200.0, 50.0, 20.0, 200.0) - -# add object in the study -id_pipetshape = geompy.addToStudy(pipetshape[0],"PipeTShape") -# add groups in the study -for g in pipetshape[1:]: - geompy.addToStudyInFather(pipetshape[0], g, g.GetName()) - -# Create junction vertices -P1 = geompy.MakeVertex(0.0, 0.0, 0.0) -P2 = geompy.MakeVertex(400.0, 0.0, 0.0) -P3 = geompy.MakeVertex(200.0, 0.0, 200.0) - -# create PipeTShape object with position -pipetshape_position = geompy.MakePipeTShape(80.0, 20.0, 200.0, 50.0, 20.0, 200.0, True, P1, P2, P3) - -# add object in the study -id_pipetshape_position = geompy.addToStudy(pipetshape_position[0],"PipeTShape_position") -# add groups in the study -for g in pipetshape_position[1:]: - geompy.addToStudyInFather(pipetshape_position[0], g, g.GetName()) - -# create PipeTShape with chamfer object -pipetshapechamfer = geompy.MakePipeTShapeChamfer(80.0, 20.0, 200.0, 50.0, 20.0, 200.0, 20.0, 20.0) - -# add object in the study -id_pipetshapechamfer = geompy.addToStudy(pipetshapechamfer[0],"PipeTShapeChamfer") -# add groups in the study -for g in pipetshapechamfer[1:]: - geompy.addToStudyInFather(pipetshapechamfer[0], g, g.GetName()) - -# create PipeTShape with chamfer object with position -pipetshapechamfer_position = geompy.MakePipeTShapeChamfer(80.0, 20.0, 200.0, 50.0, 20.0, 200.0, 20.0, 20.0, True, P1, P2, P3) - -# add object in the study -id_pipetshapechamfer_position = geompy.addToStudy(pipetshapechamfer_position[0],"PipeTShapeChamfer_position") -# add groups in the study -for g in pipetshapechamfer_position[1:]: - geompy.addToStudyInFather(pipetshapechamfer_position[0], g, g.GetName()) - -# create PipeTShape with fillet object -pipetshapefillet = geompy.MakePipeTShapeFillet(80.0, 20.0, 200.0, 50.0, 20.0, 200.0, 5.0) - -# add object in the study -id_pipetshapefillet = geompy.addToStudy(pipetshapefillet[0],"PipeTShapeFillet") -# add groups in the study -for g in pipetshapefillet[1:]: - geompy.addToStudyInFather(pipetshapefillet[0], g, g.GetName()) - -# create PipeTShape with fillet object with position -pipetshapefillet_position = geompy.MakePipeTShapeFillet(80.0, 20.0, 200.0, 50.0, 20.0, 200.0, 5.0, True, P1, P2, P3) - -# add object in the study -id_pipetshapefillet_position = geompy.addToStudy(pipetshapefillet_position[0],"PipeTShapeFillet_position") -# add groups in the study -for g in pipetshapefillet_position[1:]: - geompy.addToStudyInFather(pipetshapefillet_position[0], g, g.GetName()) - - -# display pipetshapes -gg.createAndDisplayGO(id_pipetshape) -gg.createAndDisplayGO(id_pipetshape_position) -gg.createAndDisplayGO(id_pipetshapechamfer) -gg.createAndDisplayGO(id_pipetshapechamfer_position) -gg.createAndDisplayGO(id_pipetshapefillet) -gg.createAndDisplayGO(id_pipetshapefillet_position) - -\endcode +\include advanced_geom_objs_ex01.py +Download this script \anchor tui_creation_divideddisk

    Creation of DividedDisk

    - -\code -import geompy -import salome -import GEOM -gg = salome.ImportComponentGUI("GEOM") - -# create DividedDisk object -divideddisk = geompy.MakeDividedDisk(100, 1, GEOM.SQUARE) - -# add object in the study -id_divideddisk = geompy.addToStudy(divideddisk,"DividedDisk") - -# display divideddisk -gg.createAndDisplayGO(id_divideddisk) -\endcode +\include advanced_geom_objs_ex02.py +Download this script \anchor tui_creation_dividedcylinder

    Creation of DividedCylinder

    - -\code -import geompy -import salome -import GEOM -gg = salome.ImportComponentGUI("GEOM") - -# create DividedCylinder object -dividedcylinder = geompy.MakeDividedCylinder(100, 300, GEOM.SQUARE) - -# add object in the study -id_dividedcylinder = geompy.addToStudy(dividedcylinder,"DividedCylinder") - -# display dividedcylinder -gg.createAndDisplayGO(id_dividedcylinder) -\endcode +\include advanced_geom_objs_ex03.py +Download this script */ diff --git a/doc/salome/gui/GEOM/input/tui_angle.doc b/doc/salome/gui/GEOM/input/tui_angle.doc index fa459d31e..e1618fb30 100644 --- a/doc/salome/gui/GEOM/input/tui_angle.doc +++ b/doc/salome/gui/GEOM/input/tui_angle.doc @@ -1,67 +1,7 @@ /*! \page tui_angle_page Angle - -\code -import salome -salome.salome_init() - -import math -import geompy -geompy.init_geom(salome.myStudy) - -OX = geompy.MakeVectorDXDYDZ(10, 0,0) -OXY = geompy.MakeVectorDXDYDZ(10,10,0) - -# in one plane -Angle = geompy.GetAngle(OX, OXY) - -print "\nAngle between OX and OXY = ", Angle -if math.fabs(Angle - 45.0) > 1e-05: - print " Error: returned angle is", Angle, "while must be 45.0" - pass - -Angle = geompy.GetAngleRadians(OX, OXY) - -print "\nAngle between OX and OXY in radians = ", Angle -if math.fabs(Angle - math.pi/4) > 1e-05: - print " Error: returned angle is", Angle, "while must be pi/4" - pass - -Angle = geompy.GetAngleVectors(OX, OXY, True) - -print "\nAngle between vectors OX and OXY = ", Angle -if math.fabs(Angle - 45.0) > 1e-05: - print " Error: returned angle is", Angle, "while must be 45.0" - pass - -Angle = geompy.GetAngleRadiansVectors(OX, OXY, False) - -print "\nBig angle between vectors OX and OXY in radians = ", Angle -if math.fabs(Angle - math.pi*7./4.) > 1e-05: - print " Error: returned angle is", Angle, "while must be 7*pi/4" - pass - -# not in one plane -OXY_shift = geompy.MakeTranslation(OXY,10,-10,20) -Angle = geompy.GetAngle(OX, OXY_shift) - -print "\nAngle between OX and OXY_shift = ", Angle -if math.fabs(Angle - 45.0) > 1e-05: - print " Error: returned angle is", Angle, "while must be 45.0" - pass - -# not linear -pnt1 = geompy.MakeVertex(0, 0, 0) -pnt2 = geompy.MakeVertex(10, 0, 0) -pnt3 = geompy.MakeVertex(20, 10, 0) -arc = geompy.MakeArc(pnt1, pnt2, pnt3) -Angle = geompy.GetAngle(OX, arc) - -if (math.fabs(Angle + 1.0) > 1e-6 or geompy.MeasuOp.IsDone()): - print "Error. Angle must not be computed on curvilinear edges" - pass - -\endcode +\include angle.py +Download this script */ diff --git a/doc/salome/gui/GEOM/input/tui_basic_geom_objs.doc b/doc/salome/gui/GEOM/input/tui_basic_geom_objs.doc index 7f230b142..fcb21c268 100644 --- a/doc/salome/gui/GEOM/input/tui_basic_geom_objs.doc +++ b/doc/salome/gui/GEOM/input/tui_basic_geom_objs.doc @@ -4,423 +4,47 @@ \anchor tui_creation_point

    Creation of a Point

    - -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -# create vertices -p0 = geompy.MakeVertex(0., 0., 0.) -p100 = geompy.MakeVertexWithRef(p0, 100., 100., 100.) -px = geompy.MakeVertex(100., 0., 0.) -py = geompy.MakeVertex(0., 100., 0.) -pz = geompy.MakeVertex(0., 0., 100.) -p1 = geompy.MakeVertex(50., 50., 30.) - -# create a curve and vertices on it -Arc = geompy.MakeArc(py, pz, px) -# create a vertex by parameter -p_on_arc = geompy.MakeVertexOnCurve(Arc, 0.25) -# create a vertex by length -p_on_arc2 = geompy.MakeVertexOnCurveByLength(Arc, 50., None) -#create a vertex by point projection -p_on_arc3 = geompy.MakeVertexOnCurveByCoord(Arc, 100, -10, 10) - -# create 2 lines and make a point on its intersection -line_1 = geompy.MakeLineTwoPnt(p0, p100) -line_2 = geompy.MakeLineTwoPnt(p1, pz) -p_inter = geompy.MakeVertexOnLinesIntersection(line_1, line_2) - -# create a face and vertices on it -Add_line = geompy.MakeLineTwoPnt(px, py) -arc_face = geompy.MakeFaceWires([Arc, Add_line], 1) -p_on_face1 = geompy.MakeVertexOnSurface(arc_face, 0.5, 0.5) -p_on_face2 = geompy.MakeVertexOnSurfaceByCoord(arc_face, 35, 35, 35) -p_on_face3 = geompy.MakeVertexInsideFace(arc_face) - - -# add objects in the study -id_p0 = geompy.addToStudy(p0, "Vertex 0") -id_p100 = geompy.addToStudy(p100, "Vertex 100") -id_px = geompy.addToStudy(px, "Vertex X") -id_py = geompy.addToStudy(py, "Vertex Y") -id_pz = geompy.addToStudy(pz, "Vertex Z") -id_Arc = geompy.addToStudy(Arc, "Arc") -id_line_1 = geompy.addToStudy(line_1, "Line 1") -id_line_2 = geompy.addToStudy(line_2, "Line 2") -id_p_on_arc = geompy.addToStudy(p_on_arc, "Vertex on Arc by parameter") -id_p_on_arc2 = geompy.addToStudy(p_on_arc2, "Vertex on Arc by length") -id_p_on_arc3 = geompy.addToStudy(p_on_arc3, "Vertex on Arc by point projection") -id_p_inter = geompy.addToStudy(p_inter, "Vertex on Lines Intersection") -id_p_on_face1 = geompy.addToStudy(p_on_face1, "Vertex on face by parameter") -id_p_on_face2 = geompy.addToStudy(p_on_face2, "Vertex on face by point projection") -id_p_on_face3 = geompy.addToStudy(p_on_face3, "Vertex inside face") - -# display vertices -gg.createAndDisplayGO(id_p0) -gg.createAndDisplayGO(id_p100) -gg.createAndDisplayGO(id_Arc) -gg.createAndDisplayGO(id_p_inter) -gg.createAndDisplayGO(id_p_on_arc) -gg.createAndDisplayGO(id_p_on_arc2) -gg.createAndDisplayGO(id_p_on_arc3) -\endcode +\include basic_geom_objs_ex01.py +Download this script \anchor tui_creation_line

    Creation of a Line

    - -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -# create vertices -p0 = geompy.MakeVertex(0., 0., 0.) -p100 = geompy.MakeVertexWithRef(p0, 100., 100., 100.) -px = geompy.MakeVertex(100., 0. , 0. ) -py = geompy.MakeVertex(0. , 100., 0. ) -pz = geompy.MakeVertex(0. , 0. , 100.) - -# create a vector from two points -vxy = geompy.MakeVector(px, py) - -# create a line from a point and a vector -line1 = geompy.MakeLine(pz, vxy) - -#create a line from two points -line2 = geompy.MakeLineTwoPnt(p0, p100) - -# add objects in the study -id_vxy = geompy.addToStudy(vxy, "Vector") -id_line1 = geompy.addToStudy(line1,"Line1") -id_line2 = geompy.addToStudy(line2,"Line2") - -# display lines -gg.createAndDisplayGO(id_vxy) -gg.createAndDisplayGO(id_line1) -gg.createAndDisplayGO(id_line2) -\endcode +\include basic_geom_objs_ex02.py +Download this script \anchor tui_creation_circle

    Creation of a Circle

    - -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -# create vertices -p0 = geompy.MakeVertex(0., 0., 0.) -px = geompy.MakeVertex(100., 0. , 0. ) -py = geompy.MakeVertex(0. , 100., 0. ) -pz = geompy.MakeVertex(0. , 0. , 100.) - -# create a vector on two points -vxy = geompy.MakeVector(px, py) - -# create a circle from a point, a vector and a radius -circle1 = geompy.MakeCircle(pz, vxy, 30) - -#create a circle from three points -circle2 = geompy.MakeCircleThreePnt(p0, px, py) - -# add objects in the study -id_vxy = geompy.addToStudy(vxy, "Vector") -id_circle1 = geompy.addToStudy(circle1,"Circle1") -id_circle2 = geompy.addToStudy(circle2,"Circle2") - -# display circles -gg.createAndDisplayGO(id_vxy) -gg.createAndDisplayGO(id_circle1) -gg.createAndDisplayGO(id_circle2) -\endcode +\include basic_geom_objs_ex03.py +Download this script \anchor tui_creation_ellipse

    Creation of an Ellipse

    - -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -# create vertices -p0 = geompy.MakeVertex(0., 0., 0.) -p1 = geompy.MakeVertex(50., 50., 50.) -p2 = geompy.MakeVertex(0., 50., 0.) - -# create a normal vector from two points -normal = geompy.MakeVector(p0, p1) - -# create a major axis vector from two points -major = geompy.MakeVector(p0, p2) - -# create an ellipse from a point, a vector and radiuses -ellipse1 = geompy.MakeEllipse(p1, normal, 50, 25) - -# create an ellipse from a point, a normal vector, radiuses and a major axis vector -ellipse2 = geompy.MakeEllipse(p1, normal, 50, 25, major) - -# add objects in the study -id_normal = geompy.addToStudy(normal, "Normal") -id_major = geompy.addToStudy(major, "Major Axis") -id_ellipse1 = geompy.addToStudy(ellipse1, "Ellipse 1") -id_ellipse2 = geompy.addToStudy(ellipse2, "Ellipse 2") - -# display the ellipse and its normal vector -gg.createAndDisplayGO(id_normal) -gg.createAndDisplayGO(id_major) -gg.createAndDisplayGO(id_ellipse1) -gg.createAndDisplayGO(id_ellipse2) -\endcode +\include basic_geom_objs_ex04.py +Download this script \anchor tui_creation_arc

    Creation of an Arc

    +\include basic_geom_objs_ex05.py +Download this script -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -# create vertices -p0 = geompy.MakeVertex(0., 0., 0.) -p1 = geompy.MakeVertex(100., 0., 0.) -p2 = geompy.MakeVertex(50., 0., 50.) - -# create an arc from a three points -arc1 = geompy.MakeArc(p0, p1, p2) - -# create an arc from a center point, a start point and end point -arc2 = geompy.MakeArcCenter(p0, p1, p2, 1) - -# create an arc from a center point, a major point and minor point -arc3 = geompy.MakeArcOfEllipse(p0, p1, p2) - -# add objects in the study -id_arc1 = geompy.addToStudy(arc1, "Arc 1") -id_arc2 = geompy.addToStudy(arc2, "Arc 2") -id_arc3 = geompy.addToStudy(arc3, "Arc 3") - -# display the arcs -gg.createAndDisplayGO(id_arc1) -gg.createAndDisplayGO(id_arc2) -gg.createAndDisplayGO(id_arc3) -\endcode - \anchor tui_creation_curve

    Creation of a Curve

    - -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -# create vertices -p0 = geompy.MakeVertex(0. , 0. , 0. ) -p1 = geompy.MakeVertex(50. , 100., 200.) -p2 = geompy.MakeVertex(150., 50., 100.) -p3 = geompy.MakeVertex(100., 150., 170.) -p4 = geompy.MakeVertex(200., 200., 150.) - -# create a polyline from a list of points -polyline = geompy.MakePolyline([p0, p1, p2, p3, p4]) - -# create a bezier curve from a list of points -bezier = geompy.MakeBezier([p0, p1, p2, p3, p4]) - -#create a b-spline curve from a list of points -interpol = geompy.MakeInterpol([p0, p1, p2, p3, p4], False) - -#create a polyline using parametric definition of the basic points -param_polyline = geompy.MakeCurveParametric("t", "sin(t)", "cos(t)", 0., 100., 100, geompy.GEOM.Polyline, theNewMethod=True) - -# create a bezier curve using parametric definition of the basic points -param_bezier = geompy.MakeCurveParametric("t", "sin(t)", "cos(t)", 0., 100., 100, geompy.GEOM.Bezier, theNewMethod=True) - -#create a b-spline curve using parametric definition of the basic points -param_interpol = geompy.MakeCurveParametric("t", "sin(t)", "cos(t)", 0., 100., 100, geompy.GEOM.Interpolation, theNewMethod=True) - - - -# add objects in the study -id_p0 = geompy.addToStudy(p0, "Point1") -id_p1 = geompy.addToStudy(p1, "Point2") -id_p2 = geompy.addToStudy(p2, "Point3") -id_p3 = geompy.addToStudy(p3, "Point4") -id_p4 = geompy.addToStudy(p4, "Point5") -id_polyline = geompy.addToStudy(polyline, "Polyline") -id_bezier = geompy.addToStudy(bezier, "Bezier") -id_interpol = geompy.addToStudy(interpol, "Interpol") -id_param_polyline = geompy.addToStudy(param_polyline, "Polyline Parametric") -id_param_bezier = geompy.addToStudy(param_bezier, "Bezier Parametric") -id_param_interpol = geompy.addToStudy(param_interpol, "Interpol Parametric") - - - -# display the points and the curves -gg.createAndDisplayGO(id_p0) -gg.createAndDisplayGO(id_p1) -gg.createAndDisplayGO(id_p2) -gg.createAndDisplayGO(id_p3) -gg.createAndDisplayGO(id_p4) -gg.createAndDisplayGO(id_polyline) -gg.createAndDisplayGO(id_bezier) -gg.createAndDisplayGO(id_interpol) -gg.createAndDisplayGO(id_param_polyline) -gg.createAndDisplayGO(id_param_bezier) -gg.createAndDisplayGO(id_param_interpol) - -\endcode +\include basic_geom_objs_ex06.py +Download this script \anchor tui_creation_vector

    Creation of a Vector

    - -\code -mport geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -# create vertices -p1 = geompy.MakeVertex(10., 50., 20.) -p2 = geompy.MakeVertex(70., 70., 70.) - -# create a vector from two points -vector1 = geompy.MakeVector(p1, p2) - -# create a vector from the given components -vector2 = geompy.MakeVectorDXDYDZ(30, 30, 100) - -# add objects in the study -id_p1 = geompy.addToStudy(p1, "Point1") -id_p2 = geompy.addToStudy(p2, "Point2") -id_vector1 = geompy.addToStudy(vector1,"Vector1") -id_vector2 = geompy.addToStudy(vector2,"Vector2") - -# display the points and the vectors -gg.createAndDisplayGO(id_p1) -gg.createAndDisplayGO(id_p2) -gg.createAndDisplayGO(id_vector1) -gg.createAndDisplayGO(id_vector2) -\endcode +\include basic_geom_objs_ex07.py +Download this script \anchor tui_creation_plane

    Creation of a Plane

    - -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -# create vertices -p1 = geompy.MakeVertex( 0., 0., 100.) -p2 = geompy.MakeVertex(100., 0., 0.) -p3 = geompy.MakeVertex(200., 200., 200.) -p4 = geompy.MakeVertex(100., 100., 0.) -p5 = geompy.MakeVertex(0. , 100., 0.) - -# create a vectors from the given components -vector1 = geompy.MakeVectorDXDYDZ(100., 100., 100.) -vector2 = geompy.MakeVectorDXDYDZ(-100., 0., 100.) - -# create a vector from two points -vector_arc = geompy.MakeVector(p2, p5) - -# create an arc from three points -arc = geompy.MakeArc(p2, p4, p5) - -# create a wire -wire = geompy.MakeWire([vector_arc, arc]) - -# create a face -isPlanarWanted = 1 -face = geompy.MakeFace(wire, isPlanarWanted) -trimsize = 1000. - -# create a Local Coordinate System - -LCS = geompy.MakeMarker(100., 100., 101., 1, 0, 0, 0, 1, 0) - -# create a plane from a point, a vector and a trimsize -plane1 = geompy.MakePlane(p1, vector1, trimsize) - -# create a plane from three points and a trimsize -plane2 = geompy.MakePlaneThreePnt(p1, p2, p3, trimsize) - -# create a plane from the given face -plane3 = geompy.MakePlaneFace(face, trimsize) - -# create a plane from two vectors and a trimsize -plane4 = geompy.MakePlane2Vec(vector1, vector2, trimsize) - -# create a plane with the Local Coordinate System and a trimsize -plane5 = geompy.MakePlaneLCS(LCS, trimsize, 1) - -# add objects in the study -id_face = geompy.addToStudy(face, "Face") -id_plane1 = geompy.addToStudy(plane1,"Plane1") -id_plane2 = geompy.addToStudy(plane2,"Plane2") -id_plane3 = geompy.addToStudy(plane3,"Plane3") -id_plane4 = geompy.addToStudy(plane4,"Plane4") -id_plane5 = geompy.addToStudy(plane5,"Plane5") - -# display the points and the vectors -gg.createAndDisplayGO(id_face) -gg.createAndDisplayGO(id_plane1) -gg.createAndDisplayGO(id_plane2) -gg.createAndDisplayGO(id_plane3) -gg.createAndDisplayGO(id_plane4) -gg.createAndDisplayGO(id_plane5) -gg.setDisplayMode(id_plane1,1) -gg.setTransparency(id_plane1,0.5) -gg.setDisplayMode(id_plane2,1) -gg.setTransparency(id_plane2,0.5) -gg.setDisplayMode(id_plane3,1) -gg.setTransparency(id_plane3,0.5) -gg.setDisplayMode(id_plane4,1) -gg.setTransparency(id_plane4,0.5) -gg.setDisplayMode(id_plane5,1) -gg.setTransparency(id_plane5,0.5) -\endcode +\include basic_geom_objs_ex08.py +Download this script \anchor tui_creation_lcs

    Creation of a Local Coordinate System

    -\code -import GEOM -import geompy -import math -import SALOMEDS - -#Create vertexes, vectors and shapes to construct local CS -Vertex_1 = geompy.MakeVertex(50, 50, 50) -Vertex_2 = geompy.MakeVertex(70, 70, 70) -Vertex_3 = geompy.MakeVertex(0, 0, 0) -Vector_X = geompy.MakeVectorDXDYDZ(50, 0, 0) -Vector_Y = geompy.MakeVectorDXDYDZ(0, 50, 0) -Face_1 = geompy.MakeFaceHW(100, 100, 1) -Box_1 = geompy.MakeBoxTwoPnt(Vertex_1, Vertex_2) - -#Construct local CS by manual definition -LocalCS_1 = geompy.MakeMarker(0, 0, 0, 1, 0, 0, 0, 1, 0) - -#Construct local CS by center point and two vectors (X and Y directions) -LocalCS_2 = geompy.MakeMarkerPntTwoVec(Vertex_3, Vector_X, Vector_Y) - -#Construct local CS from shape orientation -LocalCS_FACE = geompy.MakeMarkerFromShape(Face_1) -LocalCS_BOX = geompy.MakeMarkerFromShape(Box_1) - -#Add created object to study -geompy.addToStudy( Face_1, "Face_1" ) -geompy.addToStudy( Vertex_1, "Vertex_1" ) -geompy.addToStudy( Vertex_2, "Vertex_2" ) -geompy.addToStudy( Box_1, "Box_1" ) -geompy.addToStudy( Vertex_3, "Vertex_3" ) -geompy.addToStudy( Vector_X, "Vector_X" ) -geompy.addToStudy( Vector_Y, "Vector_Y" ) -geompy.addToStudy( LocalCS_1, "LocalCS_1" ) -geompy.addToStudy( LocalCS_2, "LocalCS_3" ) -geompy.addToStudy( LocalCS_FACE, "LocalCS_FACE" ) -geompy.addToStudy( LocalCS_BOX, "LocalCS_BOX" ) -\endcode +\include basic_geom_objs_ex09.py +Download this script */ diff --git a/doc/salome/gui/GEOM/input/tui_basic_operations.doc b/doc/salome/gui/GEOM/input/tui_basic_operations.doc index aec3a7465..3899255b1 100644 --- a/doc/salome/gui/GEOM/input/tui_basic_operations.doc +++ b/doc/salome/gui/GEOM/input/tui_basic_operations.doc @@ -4,138 +4,17 @@ \anchor tui_partition

    Partition

    - -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -# create a vertex and a vector -p0 = geompy.MakeVertex( 0., 0., 0.) -p200 = geompy.MakeVertex(200., 200., 200.) -pz = geompy.MakeVertex( 0., 0., 100.) - -# create a vector -vxyz = geompy.MakeVectorDXDYDZ(100., 100., 100.) - -# create a box from two points -box = geompy.MakeBoxTwoPnt(p0, p200) - -# create a plane -trimsize = 500. -plane = geompy.MakePlane(pz, vxyz, trimsize) - -# create partition objects -partition1 = geompy.MakePartition([box], [plane]) -partition2 = geompy.Partition([box], [plane]) -partition3 = geompy.MakeHalfPartition(box, plane) - -# add objects in the study -id_box = geompy.addToStudy(box,"Box") -id_plane = geompy.addToStudy(plane,"Plane") -id_partition1 = geompy.addToStudy(partition1,"MakePartition") -id_partition2 = geompy.addToStudy(partition2,"Partition") -id_partition3 = geompy.addToStudy(partition3,"MakeHalfPartition") - -# display the partition objects and the plane -gg.createAndDisplayGO(id_box) -gg.setDisplayMode(id_box,1) -gg.createAndDisplayGO(id_plane) -gg.setDisplayMode(id_plane,1) -gg.createAndDisplayGO(id_partition1) -gg.createAndDisplayGO(id_partition2) -gg.createAndDisplayGO(id_partition3) -\endcode +\include basic_operations_ex01.py +Download this script \anchor tui_archimede

    Archimede

    - -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -# create a vertex and a vector -p0 = geompy.MakeVertex( 0., 0., 0.) -p200 = geompy.MakeVertex(200., 200., 200.) - -# create a box from two points -box = geompy.MakeBoxTwoPnt(p0, p200) - -# perform an Archimede operation on the selected shape with selected parameters -weight = 1000000. -waterdensity = 1. -meshingdeflection = 0.01 -archimede = geompy.Archimede(box, weight, waterdensity, meshingdeflection) - -# add objects in the study -id_box = geompy.addToStudy(box,"Box") -id_archimede = geompy.addToStudy(archimede,"Archimede") - -# display the box and the result of Archimede operation -gg.createAndDisplayGO(id_box) -gg.setDisplayMode(id_box,1) -gg.createAndDisplayGO(id_archimede) -gg.setDisplayMode(id_archimede,1) -\endcode +\include basic_operations_ex02.py +Download this script \anchor tui_restore_prs_params

    Restore presentation parameters and sub-shapes

    - -\code -import geompy -import GEOM -import SALOMEDS - -# create a box and a cylinder -box = geompy.MakeBoxDXDYDZ(200, 200, 200) -cyl = geompy.MakeCylinderRH(100, 300) - -# create translated box -vec = geompy.MakeVectorDXDYDZ(100, 50, 0) -tra = geompy.MakeTranslationVector(box, vec) - -# create partition objects -partition1 = geompy.MakePartition([box, cyl]) -partition2 = geompy.MakePartition([box], [cyl]) -partition3 = geompy.MakePartition([box], [tra]) - -# set colours -box.SetColor(SALOMEDS.Color(1,0,0)) -cyl.SetColor(SALOMEDS.Color(0,1,0)) - -# add objects in the study -geompy.addToStudy(box, "Box") -geompy.addToStudy(cyl, "Cylinder") -geompy.addToStudy(vec, "Vector") -geompy.addToStudy(tra, "Translation") -geompy.addToStudy(partition1, "Partition_1") -geompy.addToStudy(partition2, "Partition_2") -geompy.addToStudy(partition3, "Partition_3") - -# Restore presentation parameters and sub-shapes -# different methods can be used to find the sub-shapes in the result: -# GetInPlace, GetSame, GetInPlaceByHistory, GetShapesOnShape. -# By default, GetInPlace method is used (GEOM.FSM_GetInPlace) -geompy.RestoreSubShapes(partition1) - -geompy.RestoreSubShapes(partition2, [], GEOM.FSM_GetInPlace) - -# The list of arguments can be used to avoid restoring all arguments, -# but restore only the passed. -geompy.RestoreSubShapes(partition3, [tra], GEOM.FSM_GetInPlaceByHistory) - -# To find sub-shapes in a transformed shape only one method could be -# used: pass GEOM.FSM_Transformed for that. -# True passed for the last argument, means that the transformed shape -# will inherit colour and sub-shapes from its first argument (see above -# MakeTranslation). -geompy.RestoreSubShapes(tra, [], GEOM.FSM_Transformed, True) - -# Also we could do this directly with method addToStudy: -partition4 = geompy.MakePartition([box, tra]) -geompy.addToStudy(partition4, "Partition_4", True, [], - GEOM.FSM_GetInPlaceByHistory, False) -\endcode +\include basic_operations_ex03.py +Download this script */ diff --git a/doc/salome/gui/GEOM/input/tui_basic_properties.doc b/doc/salome/gui/GEOM/input/tui_basic_properties.doc index 4c01ec438..dad8e828b 100644 --- a/doc/salome/gui/GEOM/input/tui_basic_properties.doc +++ b/doc/salome/gui/GEOM/input/tui_basic_properties.doc @@ -1,26 +1,7 @@ /*! \page tui_basic_properties_page Basic Properties - -\code -import geompy -import math - -# create a box -box = geompy.MakeBoxDXDYDZ(100,30,100) -props = geompy.BasicProperties(box) -print "\nBox 100x30x100 Basic Properties:" -print " Wires length: ", props[0] -print " Surface area: ", props[1] -print " Volume : ", props[2] -length = math.sqrt((props[0] - 1840)*(props[0] - 1840)) -area = math.sqrt((props[1] - 32000)*(props[1] - 32000)) -volume = math.sqrt((props[2] - 300000)*(props[2] - 300000)) -if length > 1e-7 or area > 1e-7 or volume > 1e-7: - print "While must be:" - print " Wires length: ", 1840 - print " Surface area: ", 32000 - print " Volume : ", 300000. -\endcode +\include basic_properties.py +Download this script */ diff --git a/doc/salome/gui/GEOM/input/tui_blocks_operations.doc b/doc/salome/gui/GEOM/input/tui_blocks_operations.doc index 8544667f1..4acb44f80 100644 --- a/doc/salome/gui/GEOM/input/tui_blocks_operations.doc +++ b/doc/salome/gui/GEOM/input/tui_blocks_operations.doc @@ -4,95 +4,17 @@ \anchor tui_multi_transformation

    Multi Transformation

    - -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -# create vertices -p_25_25_50 = geompy.MakeVertex(25., 25., 50.) -p_50_25_25 = geompy.MakeVertex(50., 25., 25.) -p_25_50_25 = geompy.MakeVertex(25., 50., 25.) - -box = geompy.MakeBoxDXDYDZ(50, 50, 50) - -top_face = geompy.GetFaceNearPoint(box, p_25_25_50) -yz_face = geompy.GetFaceNearPoint(box, p_50_25_25) -xz_face = geompy.GetFaceNearPoint(box, p_25_50_25) - -top_face_ind = geompy.GetSubShapeID(box, top_face) -yz_face_ind = geompy.GetSubShapeID(box, yz_face) -xz_face_ind = geompy.GetSubShapeID(box, xz_face) - -# Multi-transformate block and glue the result -box_tr1 = geompy.MakeMultiTransformation1D(box, yz_face_ind, top_face_ind, 3) -box_tr2 = geompy.MakeMultiTransformation2D(box, xz_face_ind, yz_face_ind, 3, top_face_ind, 0, 2) - -# add objects in the study -id_box = geompy.addToStudy(box, "Box") -id_box_tr1 = geompy.addToStudy(box_tr1, "Multi-transformed Block 1D") -id_box_tr2 = geompy.addToStudy(box_tr2, "Multi-transformed Block 2D") - -# display the results -gg.createAndDisplayGO(id_box) -gg.setDisplayMode(id_box,1) -gg.createAndDisplayGO(id_box_tr1) -gg.createAndDisplayGO(id_box_tr2) -\endcode +\include blocks_operations_ex01.py +Download this script \anchor tui_explode_on_blocks

    Explode on Blocks

    - -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -# create a box and a sphere -box = geompy.MakeBoxDXDYDZ(200, 200, 200) -sphere = geompy.MakeSphereR(100) - -# make a compound -compound = geompy.MakeCompound([box, sphere]) - -# get all the blocks of the given compound, by criteria: min_nb_faces <= nb. of faces <= max_nb_faces -min_nb_faces = 6 -max_nb_faces = 6 -make_block_explode = geompy.MakeBlockExplode(compound, min_nb_faces, max_nb_faces) - -# add objects in the study -id_compound = geompy.addToStudy(compound, "Compound") -id_make_block_explode = geompy.addToStudyInFather(compound, make_block_explode[0], "MakeBlockExplode") - -# display the results -gg.createAndDisplayGO(id_compound) -gg.createAndDisplayGO(id_make_block_explode) -gg.setDisplayMode(id_make_block_explode,1) -\endcode +\include blocks_operations_ex02.py +Download this script \anchor tui_propagate

    Propagate

    +\include blocks_operations_ex03.py +Download this script -\code -import geompy -import salome - -# create a box -box = geompy.MakeBoxDXDYDZ(200, 200, 200) - -# build all possible propagation groups -listChains = geompy.Propagate(check_box) - -# add objects in the study -geompy.addToStudy(check_box, "Box") -ii = 1 -for chain in listChains: - geompy.addToStudyInFather(check_box, chain, "propagation chain " + `ii`) - ii = ii + 1 - pass - -salome.sg.updateObjBrowser(1) -\endcode - -*/ \ No newline at end of file +*/ diff --git a/doc/salome/gui/GEOM/input/tui_boolean_operations.doc b/doc/salome/gui/GEOM/input/tui_boolean_operations.doc index 60563757c..0ab8db001 100644 --- a/doc/salome/gui/GEOM/input/tui_boolean_operations.doc +++ b/doc/salome/gui/GEOM/input/tui_boolean_operations.doc @@ -4,140 +4,22 @@ \anchor tui_fuse

    Fuse

    - -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -# create a vertex and a vector -p1 = geompy.MakeVertex(25, 55, 0) -p2 = geompy.MakeVertex( 0, 0, 0) -v = geompy.MakeVector(p1, p2) - -# create a cylinder -height = 35 -radius1 = 20 -cylinder = geompy.MakeCylinder(p1, v, radius1, height) - -# create a sphere -sphere = geompy.MakeSphereR(40) - -# fuse -fuse1 = geompy.MakeFuse(cylinder, sphere) -fuse2 = geompy.MakeBoolean(cylinder, sphere, 3) - -# add objects in the study -id_cylinder = geompy.addToStudy(cylinder, "Cylinder") -id_sphere = geompy.addToStudy(sphere, "Sphere") -id_fuse1 = geompy.addToStudy(fuse1, "Fuse_1") -id_fuse2 = geompy.addToStudy(fuse2, "Fuse_2") - -# display results -gg.createAndDisplayGO(id_cylinder) -gg.setDisplayMode(id_cylinder,1) -gg.createAndDisplayGO(id_sphere) -gg.setDisplayMode(id_sphere,1) -gg.createAndDisplayGO(id_fuse1) -gg.setDisplayMode(id_fuse1,1) -gg.createAndDisplayGO(id_fuse2) -gg.setDisplayMode(id_fuse2,1) -\endcode +\include boolean_operations_ex01.py +Download this script \anchor tui_common

    Common

    - -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -# create a vertex and a vector -p1 = geompy.MakeVertex(25, 55, 0) -p2 = geompy.MakeVertex( 0, 0, 0) -v = geompy.MakeVector(p1, p2) - -# create a cylinder -height = 35 -radius1 = 20 -cylinder = geompy.MakeCylinder(p1, v, radius1, height) - -# create a sphere -sphere = geompy.MakeSphereR(40) - -# make common -common = geompy.MakeCommon(cylinder, sphere) - -# add objects in the study -id_common = geompy.addToStudy(common, "Common") - -# display the results -gg.createAndDisplayGO(id_common) -gg.setDisplayMode(id_common,1) -\endcode +\include boolean_operations_ex02.py +Download this script \anchor tui_cut

    Cut

    - -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -# create a vertex and a vector -p1 = geompy.MakeVertex(25, 55, 0) -p2 = geompy.MakeVertex( 0, 0, 0) -v = geompy.MakeVector(p1, p2) - -# create a cylinder -height = 35 -radius1 = 20 -cylinder = geompy.MakeCylinder(p1, v, radius1, height) - -# create a sphere -sphere = geompy.MakeSphereR(40) - -#cut -cut = geompy.MakeCut(cylinder, sphere) - -# add objects in the study -id_cut = geompy.addToStudy(cut, "Cut") - -# display the results -gg.createAndDisplayGO(id_cut) -gg.setDisplayMode(id_cut,1) -\endcode +\include boolean_operations_ex03.py +Download this script \anchor tui_section

    Section

    - -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -# create a vertex and a vector -p1 = geompy.MakeVertex(25, 55, 0) -p2 = geompy.MakeVertex( 0, 0, 0) -v = geompy.MakeVector(p1, p2) - -# create a cylinder -height = 35 -radius1 = 20 -cylinder = geompy.MakeCylinder(p1, v, radius1, height) - -# create a sphere -sphere = geompy.MakeSphereR(40) - -# make a section -section = geompy.MakeSection(cylinder, sphere) - -# add objects in the study -id_section = geompy.addToStudy(section, "Section") - -# display the results -gg.createAndDisplayGO(id_section) -gg.setDisplayMode(id_section,1) -\endcode +\include boolean_operations_ex04.py +Download this script */ diff --git a/doc/salome/gui/GEOM/input/tui_bounding_box.doc b/doc/salome/gui/GEOM/input/tui_bounding_box.doc index 232ab13b4..76d4b4347 100644 --- a/doc/salome/gui/GEOM/input/tui_bounding_box.doc +++ b/doc/salome/gui/GEOM/input/tui_bounding_box.doc @@ -1,17 +1,7 @@ /*! \page tui_bounding_box_page Bounding Box - -\code -import geompy - -# create a box -box = geompy.MakeBoxDXDYDZ(100,30,100) -bb = geompy.BoundingBox(box) -print "\nBounding Box of box 100x30x100:" -print " Xmin = ", bb[0], ", Xmax = ", bb[1] -print " Ymin = ", bb[2], ", Ymax = ", bb[3] -print " Zmin = ", bb[4], ", Zmax = ", bb[5] -\endcode +\include bounding_box.py +Download this script */ diff --git a/doc/salome/gui/GEOM/input/tui_building_by_blocks.doc b/doc/salome/gui/GEOM/input/tui_building_by_blocks.doc index 3584c7ef5..77f8e363b 100644 --- a/doc/salome/gui/GEOM/input/tui_building_by_blocks.doc +++ b/doc/salome/gui/GEOM/input/tui_building_by_blocks.doc @@ -3,118 +3,11 @@ \page tui_building_by_blocks_page Building by Blocks

    Quadrangle Face

    - -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -# create vertices -p1 = geompy.MakeVertex( 0., 0., 0.) -p2 = geompy.MakeVertex(150., 30., 0.) -p3 = geompy.MakeVertex( 0., 120., 50.) -p4 = geompy.MakeVertex( 0., 40., 70.) - -# create edges -edge1 = geompy.MakeEdge(p1, p2) -edge2 = geompy.MakeEdge(p2, p3) -edge3 = geompy.MakeEdge(p3, p4) -edge4 = geompy.MakeEdge(p4, p1) - -# create a quadrangle face from four edges -qface1 = geompy.MakeQuad(edge1, edge2, edge3, edge4) - -# create a quadrangle face from two edges -qface2 = geompy.MakeQuad2Edges(edge1, edge3) - -# create a quadrangle from four points in its corners -qface3 = geompy.MakeQuad4Vertices(p1, p2, p3, p4) - -# add objects in the study -id_p1 = geompy.addToStudy(p1,"Point1") -id_p2 = geompy.addToStudy(p2,"Point2") -id_p3 = geompy.addToStudy(p3,"Point3") -id_p4 = geompy.addToStudy(p4,"Point4") -id_edge1 = geompy.addToStudy(edge1,"Edge1") -id_edge2 = geompy.addToStudy(edge2,"Edge2") -id_edge3 = geompy.addToStudy(edge3,"Edge3") -id_edge4 = geompy.addToStudy(edge4,"Edge4") -id_qface1 = geompy.addToStudy(qface1,"Qface1") -id_qface2 = geompy.addToStudy(qface2,"Qface2") -id_qface3 = geompy.addToStudy(qface3,"Qface3") - -# display the vertices, the edges and the quadrangle faces -gg.createAndDisplayGO(id_p1) -gg.createAndDisplayGO(id_p2) -gg.createAndDisplayGO(id_p3) -gg.createAndDisplayGO(id_p4) -gg.createAndDisplayGO(id_edge1) -gg.createAndDisplayGO(id_edge2) -gg.createAndDisplayGO(id_edge3) -gg.createAndDisplayGO(id_edge4) -gg.createAndDisplayGO(id_qface1) -gg.setDisplayMode(id_qface1,1) -gg.createAndDisplayGO(id_qface2) -gg.setDisplayMode(id_qface2,1) -gg.createAndDisplayGO(id_qface3) -gg.setDisplayMode(id_qface3,1) -\endcode +\include building_by_blocks_ex01.py +Download this script

    Hexagonal Solid

    +\include building_by_blocks_ex02.py +Download this script -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -# create vertices -p0 = geompy.MakeVertex( 0., 0., 0.) -p1 = geompy.MakeVertex( 0., 0., 40.) -p2 = geompy.MakeVertex( 70., -15., 0.) -p3 = geompy.MakeVertex( 70., -15., 70.) - -p4 = geompy.MakeVertex( 0., 70., 0.) -p5 = geompy.MakeVertex( 0., 70., 40.) -p6 = geompy.MakeVertex( 70., 70., 0.) -p7 = geompy.MakeVertex( 70., 70., 70.) - -p8 = geompy.MakeVertex( 0., -50., 0.) -p9 = geompy.MakeVertex( 0., -50., 40.) -p10 = geompy.MakeVertex( 70., -35., 0.) -p11 = geompy.MakeVertex( 70., -35., 70.) - -# create faces -qface1 = geompy.MakeQuad4Vertices(p0, p1, p2, p3) -qface2 = geompy.MakeQuad4Vertices(p4, p5, p6, p7) -qface3 = geompy.MakeQuad4Vertices(p0, p1, p4, p5) -qface4 = geompy.MakeQuad4Vertices(p2, p3, p6, p7) -qface5 = geompy.MakeQuad4Vertices(p0, p2, p4, p6) -qface6 = geompy.MakeQuad4Vertices(p1, p3, p5, p7) -qface7 = geompy.MakeQuad4Vertices(p8, p9, p10, p11) - -# create a hexahedral solid between two given faces -solid1 = geompy.MakeHexa2Faces(qface1, qface7) - -# create a hexahedral solid, bounded by six given faces -solid2 = geompy.MakeHexa(qface1, qface2, qface3, qface4, qface5, qface6) - -# add objects in the study -geompy.addToStudy(qface1,"qface1") -geompy.addToStudy(qface2,"qface2") -geompy.addToStudy(qface3,"qface3") -geompy.addToStudy(qface4,"qface4") -geompy.addToStudy(qface5,"qface5") -geompy.addToStudy(qface6,"qface6") -geompy.addToStudy(qface7,"qface7") - -id_solid1 = geompy.addToStudy(solid1,"Solid1") -id_solid2 = geompy.addToStudy(solid2,"Solid2") - -# display solids -gg.createAndDisplayGO(id_solid1) -gg.setDisplayMode(id_solid1, 1) -gg.createAndDisplayGO(id_solid2) -gg.setDisplayMode(id_solid2, 1) -\endcode - -*/ \ No newline at end of file +*/ diff --git a/doc/salome/gui/GEOM/input/tui_center_of_mass.doc b/doc/salome/gui/GEOM/input/tui_center_of_mass.doc index 9c9b6f659..49eb49538 100644 --- a/doc/salome/gui/GEOM/input/tui_center_of_mass.doc +++ b/doc/salome/gui/GEOM/input/tui_center_of_mass.doc @@ -1,25 +1,7 @@ /*! \page tui_center_of_mass_page Center of masses - -\code -import geompy -import math - -# create a box -box = geompy.MakeBoxDXDYDZ(100,30,100) -cm = geompy.MakeCDG(box) -if cm is None: - raise RuntimeError, "MakeCDG(box) failed" -else: - print "\nCentre of gravity of box has been successfully obtained:" - coords = geompy.PointCoordinates(cm) - print "(", coords[0], ", ", coords[1], ", ", coords[2], ")" - dx = math.sqrt((coords[0] - 50)*(coords[0] - 50)) - dy = math.sqrt((coords[1] - 15)*(coords[1] - 15)) - dz = math.sqrt((coords[2] - 50)*(coords[2] - 50)) - if dx > 1e-7 or dy > 1e-7 or dz > 1e-7: - print "But must be (50, 15, 50)" -\endcode +\include center_of_mass.py +Download this script */ diff --git a/doc/salome/gui/GEOM/input/tui_check_compound_of_blocks.doc b/doc/salome/gui/GEOM/input/tui_check_compound_of_blocks.doc index 1bd2fe9bb..eeb9d92a1 100644 --- a/doc/salome/gui/GEOM/input/tui_check_compound_of_blocks.doc +++ b/doc/salome/gui/GEOM/input/tui_check_compound_of_blocks.doc @@ -1,27 +1,7 @@ /*! \page tui_check_compound_of_blocks_page Check Compound of Blocks - -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -# create boxes -box1 = geompy.MakeBox(0,0,0,100,50,100) -box2 = geompy.MakeBox(100,0,0,250,50,100) - -# make a compound -compound = geompy.MakeCompound([box1, box2]) - -# glue the faces of the compound -tolerance = 1e-5 -glue = geompy.MakeGlueFaces(compound, tolerance) -IsValid = geompy.CheckCompoundOfBlocks(glue) -if IsValid == 0: - raise RuntimeError, "Invalid compound created" -else: - print "\nCompound is valid" -\endcode +\include check_compound_of_blocks.py +Download this script */ diff --git a/doc/salome/gui/GEOM/input/tui_check_self_intersections.doc b/doc/salome/gui/GEOM/input/tui_check_self_intersections.doc index e49de0a30..346de0c2b 100644 --- a/doc/salome/gui/GEOM/input/tui_check_self_intersections.doc +++ b/doc/salome/gui/GEOM/input/tui_check_self_intersections.doc @@ -1,17 +1,7 @@ /*! \page tui_check_self_intersections_page Detect Self-intersections - -\code -import geompy - -# create a box -box = geompy.MakeBoxDXDYDZ(100,30,100) -IsValid = geompy.CheckSelfIntersections(box) -if IsValid == 0: - raise RuntimeError, "Box with self-intersections created" -else: - print "\nBox is valid" -\endcode +\include check_self_intersections.py +Download this script */ diff --git a/doc/salome/gui/GEOM/input/tui_check_shape.doc b/doc/salome/gui/GEOM/input/tui_check_shape.doc index f9ca32c97..5e11279ef 100644 --- a/doc/salome/gui/GEOM/input/tui_check_shape.doc +++ b/doc/salome/gui/GEOM/input/tui_check_shape.doc @@ -1,17 +1,7 @@ /*! \page tui_check_shape_page Check Shape - -\code -import geompy - -# create a box -box = geompy.MakeBoxDXDYDZ(100,30,100) -IsValid = geompy.CheckShape(box) -if IsValid == 0: - raise RuntimeError, "Invalid box created" -else: - print "\nBox is valid" -\endcode +\include check_shape.py +Download this script */ diff --git a/doc/salome/gui/GEOM/input/tui_complex_objs.doc b/doc/salome/gui/GEOM/input/tui_complex_objs.doc index 2cdcf156a..030943956 100644 --- a/doc/salome/gui/GEOM/input/tui_complex_objs.doc +++ b/doc/salome/gui/GEOM/input/tui_complex_objs.doc @@ -4,697 +4,51 @@ \anchor tui_creation_prism

    Creation of a Prism

    - -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -# create a vertex and a vector -p1 = geompy.MakeVertex( 0., 0., 0.) -p2 = geompy.MakeVertex( 100., 0., 0.) -p3 = geompy.MakeVertex( 100., 100., 0.) -p4 = geompy.MakeVertex( 0., 100., 0.) -p5 = geompy.MakeVertex( 0., 0., 60.) -p6 = geompy.MakeVertex(-100., 0., 0.) -p7 = geompy.MakeVertex(-100.,-100., 0.) -p8 = geompy.MakeVertex( 0.,-100., 0.) - -# create a vector from the given components -vector = geompy.MakeVectorDXDYDZ(50., 50., 50.) - -#create vectors from two points -vector1_arc1 = geompy.MakeVector(p1, p2) -vector2_arc1 = geompy.MakeVector(p1, p4) -vector1_arc2 = geompy.MakeVector(p1, p6) -vector2_arc2 = geompy.MakeVector(p1, p8) - -# create arcs from three points -arc1 = geompy.MakeArc(p2, p3, p4) -arc2 = geompy.MakeArc(p6, p7, p8) - -# create wires -wire1 = geompy.MakeWire([vector1_arc1, arc1, vector2_arc1]) -wire2 = geompy.MakeWire([vector1_arc2, arc2, vector2_arc2]) - -# create faces -isPlanarWanted = 1 -face1 = geompy.MakeFace(wire1, isPlanarWanted) -face2 = geompy.MakeFace(wire2, isPlanarWanted) - -# create prisms -prism1 = geompy.MakePrism(face2, p1, p5) -prism2 = geompy.MakePrismVecH(face1, vector, 50) -prism3 = geompy.MakePrismVecH2Ways(face1, vector, 50) - -# add objects in the study -id_face1 = geompy.addToStudy(face1,"Face1") -id_face2 = geompy.addToStudy(face2,"Face2") -id_prism1 = geompy.addToStudy(prism1,"Prism1") -id_prism2 = geompy.addToStudy(prism2,"Prism2") -id_prism3 = geompy.addToStudy(prism3,"Prism3") - -# display cylinders -gg.createAndDisplayGO(id_face1) -gg.setDisplayMode(id_face1,1) -gg.createAndDisplayGO(id_face2) -gg.setDisplayMode(id_face2,1) -gg.createAndDisplayGO(id_prism1) -gg.setDisplayMode(id_prism1,1) -gg.createAndDisplayGO(id_prism2) -gg.setDisplayMode(id_prism2,1) -gg.createAndDisplayGO(id_prism3) -gg.setDisplayMode(id_prism3,1) -\endcode +\include complex_objs_ex01.py +Download this script \anchor tui_creation_revolution

    Creation of a Revolution

    - -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -# create a vertex and a vector -p1 = geompy.MakeVertex( 10., 10., 10.) -p2 = geompy.MakeVertex( 15., 15., 50.) -p3 = geompy.MakeVertex( 40., 40., 0.) - -#create vectors from two points -vector1 = geompy.MakeVector(p1, p2) -vector2 = geompy.MakeVector(p1, p3) - -# create a vector from the given components -vector3 = geompy.MakeVectorDXDYDZ(-20., -20., 100.) - -# create a wire -wire = geompy.MakeWire([vector1, vector2]) - -# create a revolution -revolution = geompy.MakeRevolution(wire, vector3, 2.3) - -# add objects in the study -id_vector3 = geompy.addToStudy(vector3,"Axis") -id_wire = geompy.addToStudy(wire,"Wire") -id_revolution = geompy.addToStudy(revolution,"Revolution") - -# display the vector, the wire and the revolution -gg.createAndDisplayGO(id_vector3) -gg.createAndDisplayGO(id_wire) -gg.createAndDisplayGO(id_revolution) -gg.setDisplayMode(id_revolution,1) -\endcode +\include complex_objs_ex02.py +Download this script \anchor tui_creation_filling

    Creation of a Filling

    +\include complex_objs_ex03.py +Download this script -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -mindeg = 2 -maxdeg = 5 -tol3d = 0.0001 -tol2d = 0.0001 -nbiter = 5 - -# create a vertex and a vector -p1 = geompy.MakeVertex( -30., -30., 50.) -p2 = geompy.MakeVertex( -60., -60., 30.) -p3 = geompy.MakeVertex( -30., -30., 10.) - -# create an arc from three points -arc = geompy.MakeArc(p1, p2, p3) -ShapeListCompound = [] -i = 0 -while i <= 3 : - S = geompy.MakeTranslation(arc, i * 50., 0., 0.) - ShapeListCompound.append(S) - i = i + 1 - -compound = geompy.MakeCompound(ShapeListCompound) - -# create a filling -filling = geompy.MakeFilling(compound, mindeg, maxdeg, tol3d, tol2d, nbiter) - -# add objects in the study -id_compound = geompy.addToStudy(compound,"Compound") -id_filling = geompy.addToStudy(filling,"Filling") - -# display the compound and the filling -gg.createAndDisplayGO(id_compound) -gg.createAndDisplayGO(id_filling) -gg.setDisplayMode(id_filling,1) -\endcode - \anchor tui_creation_pipe

    Creation of a Pipe

    - -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -# create vertices -p0 = geompy.MakeVertex(0. , 0. , 0. ) -px = geompy.MakeVertex(100., 0. , 0. ) -py = geompy.MakeVertex(0. , 100., 0. ) -pz = geompy.MakeVertex(0. , 0. , 100.) -pxyz = geompy.MakeVertex(100., 100., 100.) - -# create a vector from two points -vxy = geompy.MakeVector(px, py) - -# create an arc from three points -arc = geompy.MakeArc(py, pz, px) - -# create a wire -wire = geompy.MakeWire([vxy, arc]) - -# create an edge -edge = geompy.MakeEdge(p0, pxyz) - -# create a pipe -pipe = geompy.MakePipe(wire, edge) - -# add objects in the study -id_wire = geompy.addToStudy(wire,"Wire") -id_edge = geompy.addToStudy(edge,"Edge") -id_pipe = geompy.addToStudy(pipe,"Pipe") - -# display the wire, the edge (path) and the pipe -gg.createAndDisplayGO(id_wire) -gg.createAndDisplayGO(id_edge) -gg.createAndDisplayGO(id_pipe) -gg.setDisplayMode(id_pipe,1) -\endcode +\include complex_objs_ex04.py +Download this script \anchor tui_creation_pipe_with_diff_sec

    Creation of a PipeWithDifferentSections

    - -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -Wire_1 = geompy.MakeSketcher("Sketcher:F 0 0:TT 100 0:R 0:C 100 90:T 0 200", [0, 0, 0, 0, 0, 1, 1, 0, -0]) -edges = geompy.SubShapeAll(Wire_1, geompy.ShapeType["EDGE"]) -vertices = geompy.SubShapeAll(Wire_1, geompy.ShapeType["VERTEX"]) - -# create sections -circles=[] -circles.append(geompy.MakeCircle(vertices[0], edges[0], 20)) -circles.append(geompy.MakeCircle(vertices[1], edges[0], 40)) -circles.append(geompy.MakeCircle(vertices[2], edges[2], 30)) -circles.append(geompy.MakeCircle(vertices[3], edges[2], 20)) - -# create pipe -Pipe = geompy.MakePipeWithDifferentSections(circles, vertices, Wire_1, 0, 0) - -# add objects in the study -geompy.addToStudy(circles[0], "circles1") -geompy.addToStudy(circles[1], "circles2") -geompy.addToStudy(circles[2], "circles3") -geompy.addToStudy(circles[3], "circles4") -id_wire = geompy.addToStudy(Wire_1, "Path") -id_pipe = geompy.addToStudy(Pipe, "Pipe") - -# display the wire(path) and the pipe -gg.createAndDisplayGO(id_wire) -gg.createAndDisplayGO(id_pipe) -gg.setDisplayMode(id_pipe,1) -\endcode +\include complex_objs_ex05.py +Download this script \anchor tui_creation_pipe_with_shell_sec

    Creation of a PipeWithShellSections

    - -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -# create path -WirePath = geompy.MakeSketcher("Sketcher:F 0 0:TT 100 0:R 0:C 100 90:T 0 200", [0, 0, 0, 0, 0, 1, 1, 0, -0]) - -#======================================================= -# Create shell sections -#======================================================= -ps = [Vertex_1,Vertex_2,Vertex_3,Vertex_4] -theLocations = [Vertex_1, Vertex_2, Vertex_3, Vertex_4] -VC = geompy.MakeCompound(theLocations) -geompy.addToStudy(VC,"VC") -vs = [Edge_1,Edge_1,Edge_3,Edge_3] -hs = [20,40,30,20] -shells = [] -subbases = [] - -# 1 section -c0 = geompy.PointCoordinates(ps[0]) -c1 = geompy.PointCoordinates(ps[1]) -nx = c1[0] - c0[0] -ny = c1[1] - c0[1] -nz = c1[2] - c0[2] - -faces = [] -f1 = geompy.MakeSketcher("Sketcher:F 0 0:TT 20 0:TT 20 20:TT 0 20:WF", - [c0[0], c0[1], c0[2], nx, ny, nz, 0, 0, 1]) -f2 = geompy.MakeSketcher("Sketcher:F 0 0:TT 0 20:TT -20 20:TT -20 0:WF", - [c0[0], c0[1], c0[2], nx, ny, nz, 0, 0, 1]) -f3 = geompy.MakeSketcher("Sketcher:F 0 0:TT -20 0:TT -20 -20:TT 0 -20:WF", - [c0[0], c0[1], c0[2], nx, ny, nz, 0, 0, 1]) -f4 = geompy.MakeSketcher("Sketcher:F 0 0:TT 0 -20:TT 20 -20:TT 20 0:WF", - [c0[0], c0[1], c0[2], nx, ny, nz, 0, 0, 1]) -faces.append(f1) -faces.append(f2) -faces.append(f3) -faces.append(f4) -shell = geompy.MakeSewing(faces,1.e-6) -shells.append(shell) -faces = geompy.SubShapeAllSortedCentres(shell, geompy.ShapeType["FACE"]) -subbases.append(faces[0]) - -# 2 section -faces = [] - -w = geompy.MakeSketcher("Sketcher:F 20 20:TT 0 20:TT 0 0:TT 20 0", - [c1[0], c1[1], c1[2], nx, ny, nz, 0, 0, 1]) -[e1,e2,e3] = geompy.SubShapeAll(w, geompy.ShapeType["EDGE"]) -arc = MakeArc(w,3,-1) -w = geompy.MakeWire([e1,e2,e3,arc]) -f1 = geompy.MakeFace(w,1) - -w = geompy.MakeSketcher("Sketcher:F -20 0:TT 0 0:TT 0 20:TT -20 20", - [c1[0], c1[1], c1[2], nx, ny, nz, 0, 0, 1]) -[e1,e2,e3] = geompy.SubShapeAll(w, geompy.ShapeType["EDGE"]) -arc = MakeArc(w,3,-1) -w = geompy.MakeWire([e1,e2,e3,arc]) -f2 = geompy.MakeFace(w,1) - -w = geompy.MakeSketcher("Sketcher:F 20 0:TT 0 0:TT 0 -20:TT 20 -20", - [c1[0], c1[1], c1[2], nx, ny, nz, 0, 0, 1]) -[e1,e2,e3] = geompy.SubShapeAll(w, geompy.ShapeType["EDGE"]) -arc = MakeArc(w,3,-1) -w = geompy.MakeWire([e1,e2,e3,arc]) -f3 = geompy.MakeFace(w,1) - -w = geompy.MakeSketcher("Sketcher:F -20 -20:TT 0 -20:TT 0 0:TT -20 0", - [c1[0], c1[1], c1[2], nx, ny, nz, 0, 0, 1]) -[e1,e2,e3] = geompy.SubShapeAll(w, geompy.ShapeType["EDGE"]) -arc = MakeArc(w,3,-1) -w = geompy.MakeWire([e1,e2,e3,arc]) -f4 = geompy.MakeFace(w,1) - -faces.append(f1) -faces.append(f2) -faces.append(f3) -faces.append(f4) -shell = geompy.MakeSewing(faces,1.e-6) -shells.append(shell) -faces = geompy.SubShapeAllSortedCentres(shell, geompy.ShapeType["FACE"]) -subbases.append(faces[0]) - -# 3 section -faces = [] -c2 = geompy.PointCoordinates(ps[2]) -c3 = geompy.PointCoordinates(ps[3]) -nx = c3[0] - c2[0] -ny = c3[1] - c2[1] -nz = c3[2] - c2[2] - -w = geompy.MakeSketcher("Sketcher:F 20 20:TT 0 20:TT 0 0:TT 20 0", - [c2[0], c2[1], c2[2], nx, ny, nz, 0, 0, 1]) -[e1,e2,e3] = geompy.SubShapeAll(w, geompy.ShapeType["EDGE"]) -arc = MakeArc(w,3,1) -w = geompy.MakeWire([e1,e2,e3,arc]) -f1 = geompy.MakeFace(w,1) - -w = geompy.MakeSketcher("Sketcher:F -20 0:TT 0 0:TT 0 20:TT -20 20", - [c2[0], c2[1], c2[2], nx, ny, nz, 0, 0, 1]) -[e1,e2,e3] = geompy.SubShapeAll(w, geompy.ShapeType["EDGE"]) -arc = MakeArc(w,3,1) -w = geompy.MakeWire([e1,e2,e3,arc]) -f2 = geompy.MakeFace(w,1) - -w = geompy.MakeSketcher("Sketcher:F 20 0:TT 0 0:TT 0 -20:TT 20 -20", - [c2[0], c2[1], c2[2], nx, ny, nz, 0, 0, 1]) -[e1,e2,e3] = geompy.SubShapeAll(w, geompy.ShapeType["EDGE"]) -arc = MakeArc(w,3,1) -w = geompy.MakeWire([e1,e2,e3,arc]) -f3 = geompy.MakeFace(w,1) - -w = geompy.MakeSketcher("Sketcher:F -20 -20:TT 0 -20:TT 0 0:TT -20 0", - [c2[0], c2[1], c2[2], nx, ny, nz, 0, 0, 1]) -[e1,e2,e3] = geompy.SubShapeAll(w, geompy.ShapeType["EDGE"]) -arc = MakeArc(w,3,1) -w = geompy.MakeWire([e1,e2,e3,arc]) -f4 = geompy.MakeFace(w,1) - -faces.append(f1) -faces.append(f2) -faces.append(f3) -faces.append(f4) -shell = geompy.MakeSewing(faces,1.e-6) -shells.append(shell) -faces = geompy.SubShapeAllSortedCentres(shell, geompy.ShapeType["FACE"]) -subbases.append(faces[2]) - -# 4 section -faces = [] - -kk = 4 -dx = c3[0] - nx/kk -dy = c3[1] - ny/kk -dz = c3[2] - nz/kk -rad = math.sqrt(nx*nx+ny*ny+nz*nz) -vc = geompy.MakeVertex(dx,dy,dz) -sph = geompy.MakeSpherePntR(vc,rad/kk) -shellsph = geompy.SubShapeAll(sph, geompy.ShapeType["SHELL"]) - -fs = [] -vec = geompy.MakeVectorDXDYDZ(0,0,1) -ff = geompy.MakePlane(ps[3],vec,40) -fs.append(ff) -vp = geompy.MakeVertex(c3[0],c3[1],c3[2]+20) -ff = geompy.MakePlane(vp,vec,40) -fs.append(ff) -vp = geompy.MakeVertex(c3[0],c3[1],c3[2]-20) -ff = geompy.MakePlane(vp,vec,40) -fs.append(ff) -vec = geompy.MakeVectorDXDYDZ(1,0,0) -ff = geompy.MakePlane(ps[3],vec,40) -fs.append(ff) -vp = geompy.MakeVertex(c3[0]+20,c3[1],c3[2]) -ff = geompy.MakePlane(vp,vec,40) -fs.append(ff) -vp = geompy.MakeVertex(c3[0]-20,c3[1],c3[2]) -ff = geompy.MakePlane(vp,vec,40) -fs.append(ff) -aPartition = geompy.MakePartition(shellsph,fs) -fs = geompy.SubShapeAllSortedCentres(aPartition, geompy.ShapeType["FACE"]) - -faces.append(fs[0]) -faces.append(fs[1]) -faces.append(fs[2]) -faces.append(fs[3]) -shell = geompy.MakeSewing(faces,1.e-6) -shells.append(shell) -faces = geompy.SubShapeAllSortedCentres(shell, geompy.ShapeType["FACE"]) - - -#=========================================================== -# Create Pipe -#=========================================================== -subbases = [] -Pipe = geompy.MakePipeWithShellSections(shells, subbases, theLocations, WirePath, - theWithContact=0, theWithCorrection=0) - -# add objects in the study -resc = geompy.MakeCompound(shells) -id_sec = geompy.addToStudy(resc,"sections") -id_wire = geompy.addToStudy(WirePath,"WirePath") -id_pipe = geompy.addToStudy(Pipe, "Pipe") - -# display the wire(path), sections and the pipe -gg.createAndDisplayGO(id_wire) -gg.createAndDisplayGO(id_sec) -gg.createAndDisplayGO(id_pipe) -gg.setDisplayMode(id_pipe,1) -\endcode - +\include complex_objs_ex06.py +Download this script \anchor tui_creation_pipe_without_path

    Creation of a PipeShellsWithoutPath

    - -\code -import geompy -import math -import salome -gg = salome.ImportComponentGUI("GEOM") - -# Add a section based on quadrangles -# ---------------------------------- -def section(s, p1, p2=None, p3=None, p4=None): - if p2==None: - q = p1 - else: - q = geompy.MakeQuad4Vertices(p1, p2, p3, p4) - pass - s.append(q) - publish(q, "section") - return q - - -# find distance between two points -# ------------------------------- -def Dist(p1,p2): - c1 = geompy.PointCoordinates(p1) - c2 = geompy.PointCoordinates(p2) - return math.sqrt( (c2[0]-c1[0])*(c2[0]-c1[0]) + - (c2[1]-c1[1])*(c2[1]-c1[1]) + - (c2[2]-c1[2])*(c2[2]-c1[2]) ) - - -# return middle point -# ------------------------------- -def MiddleVert(p1,p2): - c1 = geompy.PointCoordinates(p1) - c2 = geompy.PointCoordinates(p2) - return geompy.MakeVertex( (c2[0]+c1[0])/2, (c2[1]+c1[1])/2, (c2[2]+c1[2])/2 ) - - -# Complex section -# result - 16 quads from lines -# pnt - point from path -# vec - direction from path -def MakeComplexSect(pnt,vec,rmax,rmin,nb): - dang = 1.0/nb/2 - cmax = geompy.MakeCircle(pnt,vec,rmax) - cmin = geompy.MakeCircle(pnt,vec,rmin) - faces = [] - for i in range(0,2*nb,2): - p1 = geompy.MakeVertexOnCurve(cmin,dang*i) - p2 = geompy.MakeVertexOnCurve(cmax,dang*(i+1)) - p3 = geompy.MakeVertexOnCurve(cmin,dang*(i+2)) - f = geompy.MakeQuad4Vertices(pnt,p1,p2,p3) - faces.append(f) - pass - shell = geompy.MakeSewing(faces,1.e-6) - return shell - - -#======================================================= -# Create simple path and recieve points -# for section creation -#======================================================= -WirePath = geompy.MakeSketcher("Sketcher:F 0 0:T 60 0:T 40 0:R 0:C 100 90:", - [0, 0, 0, 0, 0, 1, 1, 0, 0]) -vs = geompy.SubShapeAll(WirePath, geompy.ShapeType["VERTEX"]) - -#======================================================= -# Create shell sections -#======================================================= -shells = [] -subbases = [] -locs = [] - -# 1 section -shell = MakeComplexSect(vs[0], geompy.MakeVectorDXDYDZ(1,0,0), 60, 40, 16) -shells.append(shell) -vs1 = geompy.SubShapeAllSortedCentres(shell,geompy.ShapeType["VERTEX"]) -locs.append(vs1[17]) - -# 2 section -shell = MakeComplexSect(vs[1], geompy.MakeVectorDXDYDZ(1,0,0), 80, 30, 16) -shells.append(shell) -vs2 = geompy.SubShapeAllSortedCentres(shell,geompy.ShapeType["VERTEX"]) -locs.append(vs2[17]) - -# 3 section -shell = MakeComplexSect(vs[2], geompy.MakeVectorDXDYDZ(1,0,0), 60, 40, 16) -shells.append(shell) -vs3 = geompy.SubShapeAllSortedCentres(shell,geompy.ShapeType["VERTEX"]) -locs.append(vs3[17]) - -# 4 section -shell = MakeComplexSect(vs[3], geompy.MakeVectorDXDYDZ(0,1,0), 40, 35, 16) -shells.append(shell) -vs4 = geompy.SubShapeAllSortedCentres(shell,geompy.ShapeType["VERTEX"]) -locs.append(vs4[17]) - - -#=========================================================== -# Create Pipe -#=========================================================== - -Pipe = geompy.MakePipeShellsWithoutPath(shells,locs) - -# add objects in the study -resc = geompy.MakeCompound(shells) -id_sec = geompy.addToStudy(resc,"sections") -resl = geompy.MakeCompound(locs) -id_loc = geompy.addToStudy(resl,"locations") -id_pipe = geompy.addToStudy(Pipe, "Pipe") - -# display the sections, locations and pipe -gg.createAndDisplayGO(id_sec) -gg.createAndDisplayGO(id_loc) -gg.createAndDisplayGO(id_pipe) -gg.setDisplayMode(id_pipe,1) -\endcode +\include complex_objs_ex07.py +Download this script \anchor tui_creation_pipe_binormal_along_vector

    Creation of a PipeBiNormalAlongVector

    - -\code -def MakeHelix(radius, height, rotation, direction): - # - create a helix - - radius = 1.0 * radius - height = 1.0 * height - rotation = 1.0 * rotation - if direction > 0: - direction = +1 - else: - direction = -1 - pass - from math import sqrt - length_z = height - length_xy = radius*rotation - length = sqrt(length_z*length_z + length_xy*length_xy) - import geompy - nb_steps = 1 - epsilon = 1.0e-6 - while 1: - z_step = height / nb_steps - angle_step = rotation / nb_steps - z = 0.0 - angle = 0.0 - helix_points = [] - for n in range(nb_steps+1): - from math import cos, sin - x = radius * cos(angle) - y = radius * sin(angle) - p = geompy.MakeVertex(x, y, z) - helix_points.append( p ) - z += z_step - angle += direction * angle_step - pass - helix = geompy.MakeInterpol(helix_points) - length_test = geompy.BasicProperties(helix)[0] - prec = abs(length-length_test)/length - # print nb_steps, length_test, prec - if prec < epsilon: - break - nb_steps *= 2 - pass - return helix - -def MakeSpring(radius, height, rotation, direction, thread_radius, base_rotation=0.0): - # - create a pipe - - thread_radius = 1.0 * thread_radius - # create a helix - helix = MakeHelix(radius, height, rotation, direction) - # base in the (Ox, Oz) plane - import geompy - p0 = geompy.MakeVertex(radius-3*thread_radius, 0.0, -thread_radius) - p1 = geompy.MakeVertex(radius+3*thread_radius, 0.0, -thread_radius) - p2 = geompy.MakeVertex(radius+3*thread_radius, 0.0, +thread_radius) - p3 = geompy.MakeVertex(radius-3*thread_radius, 0.0, +thread_radius) - e0 = geompy.MakeEdge(p0, p1) - e1 = geompy.MakeEdge(p1, p2) - e2 = geompy.MakeEdge(p2, p3) - e3 = geompy.MakeEdge(p3, p0) - w = geompy.MakeWire([e0, e1, e2, e3]) - # create a base face - base = geompy.MakeFace(w, True) - # create a binormal vector - binormal = geompy.MakeVectorDXDYDZ(0.0, 0.0, 10.0) - # create a pipe - spring = geompy.MakePipeBiNormalAlongVector(base, helix, binormal) - # Publish in the study - geompy.addToStudy(base, "base") - geompy.addToStudy(helix, "helix") - geompy.addToStudy(binormal, "binormal") - geompy.addToStudy(spring, "spring") - return spring - -from math import pi - -spring = MakeSpring(50, 100, 2*pi, 1, 5, pi/2) -\endcode - +\include complex_objs_ex08.py +Download this script \anchor tui_creation_pipe_path

    Creation of a Middle Path

    - -\code -import salome -import geompy - -# Create a box -Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200) - -# Get two opposite faces -[Face_1,Face_2] = geompy.SubShapes(Box_1, [31, 33]) - -# Get edges -Box_1_edge_12 = geompy.GetSubShape(Box_1, [12]) -Box_1_edge_22 = geompy.GetSubShape(Box_1, [22]) -Box_1_edge_25 = geompy.GetSubShape(Box_1, [25]) -Box_1_edge_29 = geompy.GetSubShape(Box_1, [29]) -Box_1_edge_8 = geompy.GetSubShape(Box_1, [8]) -Box_1_edge_18 = geompy.GetSubShape(Box_1, [18]) -Box_1_edge_26 = geompy.GetSubShape(Box_1, [26]) -Box_1_edge_30 = geompy.GetSubShape(Box_1, [30]) - -# These three calls to RestorePath return the same result -Path_1 = geompy.RestorePath(Box_1, Face_1, Face_2) -Path_2 = geompy.RestorePathEdges(Box_1, [Face_1], [Face_2]) -Path_3 = geompy.RestorePathEdges(Box_1, - [Box_1_edge_12, Box_1_edge_22, Box_1_edge_25, Box_1_edge_29], - [Box_1_edge_8, Box_1_edge_18, Box_1_edge_26, Box_1_edge_30]) - -# Publish created objects -geompy.addToStudy( Box_1, 'Box_1' ) -geompy.addToStudyInFather( Box_1, Face_1, 'Face_1' ) -geompy.addToStudyInFather( Box_1, Face_2, 'Face_2' ) -geompy.addToStudyInFather( Box_1, Box_1_edge_25, 'Box_1:edge_25' ) -geompy.addToStudyInFather( Box_1, Box_1_edge_22, 'Box_1:edge_22' ) -geompy.addToStudyInFather( Box_1, Box_1_edge_12, 'Box_1:edge_12' ) -geompy.addToStudyInFather( Box_1, Box_1_edge_29, 'Box_1:edge_29' ) -geompy.addToStudyInFather( Box_1, Box_1_edge_18, 'Box_1:edge_18' ) -geompy.addToStudyInFather( Box_1, Box_1_edge_26, 'Box_1:edge_26' ) -geompy.addToStudyInFather( Box_1, Box_1_edge_8, 'Box_1:edge_8' ) -geompy.addToStudyInFather( Box_1, Box_1_edge_30, 'Box_1:edge_30' ) -geompy.addToStudy( Path_1, 'Path_1' ) -geompy.addToStudy( Path_2, 'Path_2' ) -geompy.addToStudy( Path_3, 'Path_3' ) -\endcode +\include complex_objs_ex09.py +Download this script

    Creation of Tangent Plane On Face

    -\code -import salome -import geompy - -# Create Vertexes for curve -Vertex_1 = geompy.MakeVertex(0, 0, 0) -Vertex_2 = geompy.MakeVertex(0, 90, 30) -Vertex_3 = geompy.MakeVertex(100, 90, 0) -Vertex_4 = geompy.MakeVertex(-100, 90, 0) -# Create curve -Curve_1 = geompy.MakeInterpol([Vertex_4, Vertex_2, Vertex_3, Vertex_1]) -# Create Face by Extrusion of the Curve -Extrusion_1 = geompy.MakePrismDXDYDZ(Curve_1, 0, 30, -60) -# Make Tangent on this Extrusion (Face) -Tangent_1 = geompy.MakeTangentPlaneOnFace(Extrusion_1, 0.7, 0.5, 150) -# Publish in the study -geompy.addToStudy( Vertex_1, "Vertex_1" ) -geompy.addToStudy( Vertex_2, "Vertex_2" ) -geompy.addToStudy( Vertex_3, "Vertex_3" ) -geompy.addToStudy( Vertex_4, "Vertex_4" ) -geompy.addToStudy( Curve_1, "Curve_1" ) -geompy.addToStudy( Extrusion_1, "Extrusion_1" ) -geompy.addToStudy( Tangent_1, "Tangent_1" ) -\endcode +\include complex_objs_ex10.py +Download this script */ diff --git a/doc/salome/gui/GEOM/input/tui_free_boundaries.doc b/doc/salome/gui/GEOM/input/tui_free_boundaries.doc index b764df1b2..fb0420c6d 100644 --- a/doc/salome/gui/GEOM/input/tui_free_boundaries.doc +++ b/doc/salome/gui/GEOM/input/tui_free_boundaries.doc @@ -1,85 +1,7 @@ /*! \page tui_free_boundaries_page Check Free Boundaries - -\code -import os -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -# create boxes -box1 = geompy.MakeBox(0,0,0,100,50,100) -box2 = geompy.MakeBox(100,0,0,250,50,100) - -# make a compound -compound = geompy.MakeCompound([box1, box2]) - -# import from *.brep -ImportFromBREP = geompy.ImportBREP(os.getenv("DATA_DIR")+"/Shapes/Brep/flight_solid.brep") - -# get a face -faces = geompy.SubShapeAllSortedCentres(ImportFromBREP, geompy.ShapeType["FACE"]) - -# get the free boundary for face 32 -Res = geompy.GetFreeBoundary(faces[32]) -isSuccess = Res[0] -ClosedWires = Res[1] -OpenWires = Res[2] - -if isSuccess == 1 : - print "Checking free boudaries is OK." -else : - print "Checking free boudaries is KO!" -print "len(ClosedWires) = ", len(ClosedWires) - -i = 0 -for wire in ClosedWires : - wire_name = "Face 32 -> Close wires : WIRE %d"%(i+1) - geompy.addToStudy(ClosedWires[i], wire_name) - if i < len(ClosedWires) : - i = i+ 1 - -print "len(OpenWires) = ", len(OpenWires) - -i = 0 -for wire in OpenWires : - wire_name = "Face 32 -> Open wires : WIRE %d"%(i+1) - geompy.addToStudy(OpenWires[i], wire_name) - if i < len(OpenWires) : - i = i+ 1 - -# get the free boundary for face 41 -Res = geompy.GetFreeBoundary(faces[41]) -isSuccess = Res[0] -ClosedWires = Res[1] -OpenWires = Res[2] - -if isSuccess == 1 : - print "Checking free boudaries is OK." -else : - print "Checking free boudaries is KO!" -print "len(ClosedWires) = ", len(ClosedWires) - -i = 0 -for wire in ClosedWires : - wire_name = "Face 41 -> Close wires : WIRE %d"%(i+1) - geompy.addToStudy(ClosedWires[i], wire_name) - if i < len(ClosedWires) : - i = i+ 1 - -print "len(OpenWires) = ", len(OpenWires) - -i = 0 -for wire in OpenWires : - wire_name = "Face 41 -> Open wires : WIRE %d"%(i+1) - geompy.addToStudy(OpenWires[i], wire_name) - if i < len(OpenWires) : - i = i+ 1 - -# add the imported object to the study -id_ImportFromBREP = geompy.addToStudy(ImportFromBREP, "ImportFromBREP") -salome.sg.updateObjBrowser(1) -\endcode +\include free_boundaries.py +Download this script */ diff --git a/doc/salome/gui/GEOM/input/tui_free_faces.doc b/doc/salome/gui/GEOM/input/tui_free_faces.doc index 7fd302288..00ae5bd23 100644 --- a/doc/salome/gui/GEOM/input/tui_free_faces.doc +++ b/doc/salome/gui/GEOM/input/tui_free_faces.doc @@ -1,52 +1,7 @@ /*! \page tui_free_faces_page Check Free Faces - -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -# create a vertex and a vector -p1 = geompy.MakeVertex(35, 35, 0) -p2 = geompy.MakeVertex(35, 35, 50) -v = geompy.MakeVector(p1, p2) - -# create a cylinder -cylinder = geompy.MakeCone(p1, v, 30, 20, 20) - -# create a cone -cone = geompy.MakeCone(p1, v, 70, 40, 60) - -# make cut -cut = geompy.MakeCut(cone, cylinder) - -# get faces as sub-shapes -faces = [] -faces = geompy.SubShapeAllSortedCentres(cut, geompy.ShapeType["FACE"]) -f_2 = geompy.GetSubShapeID(cut, faces[0]) - -# remove one face from the shape -cut_without_f_2 = geompy.SuppressFaces(cut, [f_2]) - -# suppress the specified wire -result = geompy.GetFreeFacesIDs(cut_without_f_2) -print "A number of free faces is ", len(result) - -# add objects in the study -all_faces = geompy.SubShapeAllSortedCentres(cut_without_f_2, geompy.ShapeType["FACE"]) -for face in all_faces : - sub_shape_id = geompy.GetSubShapeID(cut_without_f_2, face) - if result.count(sub_shape_id) > 0 : - face_name = "Free face %d"%(sub_shape_id) - geompy.addToStudy(face, face_name) - -# in this example all faces from cut_without_f_2 are free -id_cut_without_f_2 = geompy.addToStudy(cut_without_f_2, "Cut without f_2") - -# display the results -gg.createAndDisplayGO(id_cut_without_f_2) -gg.setDisplayMode(id_cut_without_f_2,1) -\endcode +\include free_faces.py +Download this script */ diff --git a/doc/salome/gui/GEOM/input/tui_get_non_blocks.doc b/doc/salome/gui/GEOM/input/tui_get_non_blocks.doc index b83ea9647..ca7a98d8f 100644 --- a/doc/salome/gui/GEOM/input/tui_get_non_blocks.doc +++ b/doc/salome/gui/GEOM/input/tui_get_non_blocks.doc @@ -1,32 +1,7 @@ /*! \page tui_get_non_blocks_page Get Non Blocks - -\code -import geompy -import salome - -# create solids -box = geompy.MakeBoxDXDYDZ(100, 100, 100) -cyl = geompy.MakeCylinderRH(100, 200) - -geompy.addToStudy(box, 'box') -geompy.addToStudy(cyl, 'cyl') - -# make a compound -compound = geompy.MakeCompound([box, cyl]) -geompy.addToStudy(compound, 'compound') - -# explore the compound -pair = geompy.GetNonBlocks(compound) - -if pair[0] is not None: - geompy.addToStudyInFather(compound, pair[0], "GrNonBlocks") - pass - -if pair[1] is not None: - geompy.addToStudyInFather(compound, pair[1], "GrNonQuads") - pass -\endcode +\include get_non_blocks.py +Download this script */ diff --git a/doc/salome/gui/GEOM/input/tui_import_export.doc b/doc/salome/gui/GEOM/input/tui_import_export.doc index cdd8c4ea0..52adf987e 100644 --- a/doc/salome/gui/GEOM/input/tui_import_export.doc +++ b/doc/salome/gui/GEOM/input/tui_import_export.doc @@ -1,45 +1,7 @@ /*! \page tui_import_export_page Import/Export -\code -import geompy -import salome - -# Example of import from IGES using various formats - -# get a path to SAMPLES_SRC -import os -thePath = os.getenv("DATA_DIR") -# create filenames -theFileName1 = thePath + "/Shapes/Iges/boite-3Dipsos_m.igs" -theFileName2 = thePath + "/Shapes/Iges/boite-3Dipsos_mm.igs" -#print "thePath = ", thePath - -# get units from files -UnitName1 = geompy.GetIGESUnit(theFileName1) -UnitName2 = geompy.GetIGESUnit(theFileName2) -print "UnitName1 = ", UnitName1 -print "UnitName2 = ", UnitName2 - -# import shapes -Shape1 = geompy.ImportIGES(theFileName1) -Shape2 = geompy.ImportIGES(theFileName2) -Shape3 = geompy.ImportFile(theFileName2,"IGES_SCALE") -[Xmin1,Xmax1, Ymin1,Ymax1, Zmin1,Zmax1] = geompy.BoundingBox(Shape1) -[Xmin2,Xmax2, Ymin2,Ymax2, Zmin2,Zmax2] = geompy.BoundingBox(Shape2) -[Xmin3,Xmax3, Ymin3,Ymax3, Zmin3,Zmax3] = geompy.BoundingBox(Shape3) -geompy.addToStudy(Shape1, "3Dipsos_m") -geompy.addToStudy(Shape2, "3Dipsos_mm") -geompy.addToStudy(Shape3, "3Dipsos_mm_scaled") -d1 = (Xmax1-Xmin1)*(Xmax1-Xmin1) + (Ymax1-Ymin1)*(Ymax1-Ymin1) + (Zmax1-Zmin1)*(Zmax1-Zmin1) -d2 = (Xmax2-Xmin2)*(Xmax2-Xmin2) + (Ymax2-Ymin2)*(Ymax2-Ymin2) + (Zmax2-Zmin2)*(Zmax2-Zmin2) -d3 = (Xmax3-Xmin3)*(Xmax3-Xmin3) + (Ymax3-Ymin3)*(Ymax3-Ymin3) + (Zmax3-Zmin3)*(Zmax3-Zmin3) -import math -dd32 = math.sqrt(d3/d2) -dd12 = math.sqrt(d1/d2) -dd31 = math.sqrt(d3/d1) -# values dd31, dd12 and dd31 can be using for checking -print "dd32 = ",dd32," dd12 = ",dd12," dd31 = ",dd31 -\endcode +\include import_export.py +Download this script */ diff --git a/doc/salome/gui/GEOM/input/tui_inertia.doc b/doc/salome/gui/GEOM/input/tui_inertia.doc index 29530e292..a62b20784 100644 --- a/doc/salome/gui/GEOM/input/tui_inertia.doc +++ b/doc/salome/gui/GEOM/input/tui_inertia.doc @@ -1,20 +1,7 @@ /*! \page tui_inertia_page Inertia - -\code -import geompy -import math - -# create a box -box = geompy.MakeBoxDXDYDZ(100,30,100) -In = geompy.Inertia(box) -print "\nInertia matrix of box 100x30x100:" -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 100x30x100:" -print " Ix = ", In[9], ", Iy = ", In[10], ", Iz = ", In[11] -\endcode +\include inertia.py +Download this script */ diff --git a/doc/salome/gui/GEOM/input/tui_min_distance.doc b/doc/salome/gui/GEOM/input/tui_min_distance.doc index e26e219f9..db024ca4b 100644 --- a/doc/salome/gui/GEOM/input/tui_min_distance.doc +++ b/doc/salome/gui/GEOM/input/tui_min_distance.doc @@ -1,15 +1,7 @@ /*! \page tui_min_distance_page Minimal Distance - -\code -import geompy - -# create boxes -box1 = geompy.MakeBoxDXDYDZ(100,30,100) -box2 = geompy.MakeBox(105,0,0,200,30,100) -min_dist = geompy.MinDistance(box1,box2) -print "\nMinimal distance between box1 and box2 = ", min_dist -\endcode +\include min_distance.py +Download this script */ diff --git a/doc/salome/gui/GEOM/input/tui_normal_face.doc b/doc/salome/gui/GEOM/input/tui_normal_face.doc index 0c81116a8..7d31fcc26 100644 --- a/doc/salome/gui/GEOM/input/tui_normal_face.doc +++ b/doc/salome/gui/GEOM/input/tui_normal_face.doc @@ -1,23 +1,7 @@ /*! \page tui_normal_face_page Normal to a Face - -\code -import geompy -import math - -# create a box -box = geompy.MakeBoxDXDYDZ(100,30,100) - -faces = geompy.SubShapeAllSortedCentres(box, geompy.ShapeType["FACE"]) -face0 = faces[0] -vnorm = geompy.GetNormal(face0) -if vnorm is None: - raise RuntimeError, "GetNormal(face0) failed" -else: - geompy.addToStudy(face0, "Face0") - geompy.addToStudy(vnorm, "Normale to Face0") - print "\nNormale of face has been successfully obtained" -\endcode +\include normal_face.py +Download this script */ diff --git a/doc/salome/gui/GEOM/input/tui_notebook_geom.doc b/doc/salome/gui/GEOM/input/tui_notebook_geom.doc index 629ce6329..8db9c59d2 100644 --- a/doc/salome/gui/GEOM/input/tui_notebook_geom.doc +++ b/doc/salome/gui/GEOM/input/tui_notebook_geom.doc @@ -3,27 +3,7 @@ \page tui_notebook_geom_page Using SALOME NoteBook \anchor tui_notebook_geom - -\code -import geompy -import salome -import salome_notebook -gg = salome.ImportComponentGUI("GEOM") - -# set variables -notebook = salome_notebook.notebook -notebook.set("Length", 150) -notebook.set("Width", 100) - -# create box -box = geompy.MakeBoxDXDYDZ("Length", "Width", 200) - -# add object in the study -id_box = geompy.addToStudy(box,"Box") - -# display the boxes -gg.createAndDisplayGO(id_box) -gg.setDisplayMode(id_box,1) -\endcode +\include notebook_geom.py +Download this script */ diff --git a/doc/salome/gui/GEOM/input/tui_point_coordinates.doc b/doc/salome/gui/GEOM/input/tui_point_coordinates.doc index 0f138367b..6fbb9c9a6 100644 --- a/doc/salome/gui/GEOM/input/tui_point_coordinates.doc +++ b/doc/salome/gui/GEOM/input/tui_point_coordinates.doc @@ -1,27 +1,7 @@ /*! \page tui_point_coordinates_page Point Coordinates +\include point_coordinates.py +Download this script -\code -import math -import geompy - -# create a point -point = geompy.MakeVertex(15., 23., 80.) - -# get the coordinates of the point and check its values -coords = geompy.PointCoordinates(point) - -# check the obtained coordinate values -tolerance = 1.e-07 -def IsEqual(val1, val2): return (math.fabs(val1 - val2) < tolerance) - -if IsEqual(coords[0], 15.) and IsEqual(coords[1], 23.) and IsEqual(coords[2], 80.): - print "All values are OK." -else : - print "Coordinates of point must be (15, 23, 80), but returned (", - print coords[0], ", ", coords[1], ", ", coords[2], ")" - pass -\endcode - -*/ \ No newline at end of file +*/ diff --git a/doc/salome/gui/GEOM/input/tui_primitives.doc b/doc/salome/gui/GEOM/input/tui_primitives.doc index af7670ea8..9c4f49d55 100644 --- a/doc/salome/gui/GEOM/input/tui_primitives.doc +++ b/doc/salome/gui/GEOM/input/tui_primitives.doc @@ -4,230 +4,37 @@ \anchor tui_creation_box

    Creation of a Box

    - -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -# create vertices -p0 = geompy.MakeVertex(15, 25, 35) -p70 = geompy.MakeVertex(70, 70, 70) - -# create boxes -box1 = geompy.MakeBoxDXDYDZ(10, 20, 30) -box2 = geompy.MakeBox(10,20,30, 15,25,35) -box3 = geompy.MakeBoxTwoPnt(p0, p70) - -# add objects in the study -id_box1 = geompy.addToStudy(box1,"Box1") -id_box2 = geompy.addToStudy(box2,"Box2") -id_box3 = geompy.addToStudy(box3,"Box3") - -# display the boxes -gg.createAndDisplayGO(id_box1) -gg.setDisplayMode(id_box1,1) -gg.createAndDisplayGO(id_box2) -gg.setDisplayMode(id_box2,1) -gg.createAndDisplayGO(id_box3) -gg.setDisplayMode(id_box3,1) -\endcode +\include primitives_ex01.py +Download this script \anchor tui_creation_cylinder

    Creation of a Cylinder

    - -\code -import geompy -import salome - -gg = salome.ImportComponentGUI("GEOM") - -# create a vertex and a vector -p1 = geompy.MakeVertex(25, 35, 45) -p2 = geompy.MakeVertex(70, 70, 70) -v = geompy.MakeVector(p1, p2) - -# create cylinders -height = 40 - -radius1 = 15 -cylinder1 = geompy.MakeCylinder(p1, v, radius1, height) - -radius2 = 30 -cylinder2 = geompy.MakeCylinderRH(radius2, height) - -# add objects in the study -id_cylinder1 = geompy.addToStudy(cylinder1,"Cylinder1") -id_cylinder2 = geompy.addToStudy(cylinder2,"Cylinder2") - -# display the cylinders -gg.createAndDisplayGO(id_cylinder1) -gg.setDisplayMode(id_cylinder1,1) -gg.createAndDisplayGO(id_cylinder2) -gg.setDisplayMode(id_cylinder2,1) -\endcode +\include primitives_ex02.py +Download this script \anchor tui_creation_sphere

    Creation of a Sphere

    - -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -# create a vertex -p = geompy.MakeVertex(55, 45, 25) - -# create spheres -radius1 = 20 -sphere1 = geompy.MakeSpherePntR(p, radius1) -radius2 = 15 -sphere2 = geompy.MakeSphere(0, 0, 45, radius2) -radius3 = 30 -sphere3 = geompy.MakeSphereR(radius3) - -# add objects in the study -id_sphere1 = geompy.addToStudy(sphere1,"Sphere1") -id_sphere2 = geompy.addToStudy(sphere2,"Sphere2") -id_sphere3 = geompy.addToStudy(sphere3,"Sphere3") - -# display spheres -gg.createAndDisplayGO(id_sphere1) -gg.setDisplayMode(id_sphere1,1) -gg.createAndDisplayGO(id_sphere2) -gg.setDisplayMode(id_sphere2,1) -gg.createAndDisplayGO(id_sphere3) -gg.setDisplayMode(id_sphere3,1) -\endcode +\include primitives_ex03.py +Download this script \anchor tui_creation_torus

    Creation of a Torus

    - -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -# create a vertex and a vector -p1 = geompy.MakeVertex(35, 40, 45) -p2 = geompy.MakeVertex(35, 45, 70) -v = geompy.MakeVector(p1, p2) - -# create toruses -torus1 = geompy.MakeTorus(p1, v, 20, 10) -torus2 = geompy.MakeTorusRR(30, 15) - -# add objects in the study -id_torus1 = geompy.addToStudy(torus1,"Torus1") -id_torus2 = geompy.addToStudy(torus2,"Torus2") - -# display toruses -gg.createAndDisplayGO(id_torus1) -gg.setDisplayMode(id_torus1,1) -gg.createAndDisplayGO(id_torus2) -gg.setDisplayMode(id_torus2,1) -\endcode +\include primitives_ex04.py +Download this script \anchor tui_creation_cone

    Creation of a Cone

    - -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -# create a vertex and a vector -p1 = geompy.MakeVertex(35, 35, 0) -p2 = geompy.MakeVertex(35, 35, 70) -v = geompy.MakeVector(p1, p2) - -# create cones -cone1 = geompy.MakeCone(p1, v, 17, 1, 20) -cone2 = geompy.MakeConeR1R2H(30, 10, 30) - -# add objects in the study -id_cone1 = geompy.addToStudy(cone1,"Cone1") -id_cone2 = geompy.addToStudy(cone2,"Cone2") - -# display cones -gg.createAndDisplayGO(id_cone1) -gg.setDisplayMode(id_cone1,1) -gg.createAndDisplayGO(id_cone2) -gg.setDisplayMode(id_cone2,1) -\endcode +\include primitives_ex05.py +Download this script \anchor tui_creation_disk

    Creation of a Disk

    - -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -# create vertices -p0 = geompy.MakeVertex(0., 0., 0.) -px = geompy.MakeVertex(100., 0. , 0. ) -py = geompy.MakeVertex(0. , 100., 0. ) -pz = geompy.MakeVertex(0. , 0. , 100.) - -# create a vector on two points -vxy = geompy.MakeVector(px, py) - -# create a disk in OXY plane -disk1 = geompy.MakeDiskR(100, 1) - -# create a disk from a point, a vector and a radius -disk2 = geompy.MakeDiskPntVecR(pz, vxy, 30) - -#create a circle from three points -disk3 = geompy.MakeDiskThreePnt(p0, px, py) - -# add objects in the study -id_vxy = geompy.addToStudy(vxy, "Vector") -id_disk1 = geompy.addToStudy(disk1,"Disk1") -id_disk2 = geompy.addToStudy(disk2,"Disk2") -id_disk3 = geompy.addToStudy(disk3,"Disk3") - -# display disks -gg.createAndDisplayGO(id_vxy) -gg.createAndDisplayGO(id_disk1) -gg.createAndDisplayGO(id_diks2) -gg.createAndDisplayGO(id_diks3) -\endcode +\include primitives_ex06.py +Download this script \anchor tui_creation_squareface

    Creation of a Rectangle

    - -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -# create vertices -px = geompy.MakeVertex(100., 0. , 0. ) -py = geompy.MakeVertex(0. , 100., 0. ) - -# create a vector on two points -vxy = geompy.MakeVector(px, py) - -# create a rectangle in OXY plane -face1 = geompy.MakeFaceHW(100, 100, 1) - -# create a rectangle using normal vector -face2 = geompy.MakeFaceObjHW(vxy, 50, 150) - -# create a rectangle from other face -face3 = geompy.MakeFaceObjHW(face2, 150, 50) - -# add objects in the study -id_face1 = geompy.addToStudy(face1,"Face1") -id_face2 = geompy.addToStudy(face2,"Face2") -id_face3 = geompy.addToStudy(face3,"Face3") - -# display rectangles -gg.createAndDisplayGO(id_face1) -gg.createAndDisplayGO(id_face2) -gg.createAndDisplayGO(id_face3) -\endcode +\include primitives_ex07.py +Download this script */ diff --git a/doc/salome/gui/GEOM/input/tui_repairing_operations.doc b/doc/salome/gui/GEOM/input/tui_repairing_operations.doc index 0ce8b63db..286731970 100644 --- a/doc/salome/gui/GEOM/input/tui_repairing_operations.doc +++ b/doc/salome/gui/GEOM/input/tui_repairing_operations.doc @@ -4,444 +4,57 @@ \anchor tui_shape_processing

    Shape Processing

    - -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -# create vertices, an edge, an arc, a wire, a face and a prism -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 the shape at the beginning -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 the Shape -Operators = ["FixShape"] -Parameters = ["FixShape.Tolerance3d"] -Values = ["1e-7"] -PS = geompy.ProcessShape(theShape, Operators, Parameters, Values) - -# check the shape at the end -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 the study and display -Id_Shape = geompy.addToStudy(theShape, "Invalid Shape") -Id_PS = geompy.addToStudy(PS, "Processed Shape") -gg.createAndDisplayGO(Id_Shape) -gg.setDisplayMode(Id_Shape,1) -gg.createAndDisplayGO(Id_PS) -gg.setDisplayMode(Id_PS,1) -\endcode +\include repairing_operations_ex01.py +Download this script \anchor tui_suppress_faces

    Suppress Faces

    - -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -# create a box -box = geompy.MakeBoxDXDYDZ(200, 200, 200) - -# The list of IDs (IDList) for suppress faces -sup_faces = [] -sup_faces = geompy.SubShapeAllSortedCentres(box, geompy.ShapeType["FACE"]) - -# get indices of the sub-shape -f1_id = geompy.GetSubShapeID(box, sup_faces[3]) - -# remove faces from the given object (shape) -result = geompy.SuppressFaces(box, [f1_id]) - -# add objects in the study -id_box = geompy.addToStudy(box, "Box") -id_result = geompy.addToStudy(result, "Result") - -# display the results -gg.createAndDisplayGO(id_box) -gg.setDisplayMode(id_box,1) -gg.createAndDisplayGO(id_result) -gg.setDisplayMode(id_result,1) -\endcode +\include repairing_operations_ex02.py +Download this script \anchor tui_close_contour

    Close Contour

    - -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -# create vertices and vectors -p0 = geompy.MakeVertex( 0., 0., 0.) -px = geompy.MakeVertex(100., 0., 0.) -py = geompy.MakeVertex( 0., 100., 0.) -py1 = geompy.MakeVertex( 0., 140., 0.) -pz = geompy.MakeVertex( 0., 0., 100.) -vxy = geompy.MakeVector(px, py) - -# create an arc -arc = geompy.MakeArc(py1, pz, px) - -# create a wire -wire = geompy.MakeWire([vxy, arc]) - -# close an open wire by creation of an edge between ends -wire_close = geompy.CloseContour(wire, [1], 0) - -# add objects in the study -id_wire = geompy.addToStudy(wire, "Wire") -id_wire_close = geompy.addToStudy(wire_close, "Wire close") - -# display the results -gg.createAndDisplayGO(id_wire) -gg.createAndDisplayGO(id_wire_close) -\endcode +\include repairing_operations_ex03.py +Download this script \anchor tui_suppress_internal_wires

    Suppress Internal Wires

    - -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -# create a vertex and a vector -p1 = geompy.MakeVertex(55, 65, 50) -p2 = geompy.MakeVertex(55, 0, 50) -v = geompy.MakeVector(p1, p2) - -# create a cylinder -height = 100 -radius1 = 40 -cylinder = geompy.MakeCylinder(p1, v, radius1, height) - -# create a box -box = geompy.MakeBoxDXDYDZ(100, 100, 100) - -# make a cut -cut = geompy.MakeCut(box, cylinder) - -# suppress all internal wires -result = geompy.SuppressInternalWires(cut, []) - -# add objects in the study -id_cut = geompy.addToStudy(cut, "Cut") -id_result = geompy.addToStudy(result, "Result") - -# display the results -gg.createAndDisplayGO(id_cut) -gg.setDisplayMode(id_cut,1) -gg.createAndDisplayGO(id_result) -gg.setDisplayMode(id_result,1) -\endcode +\include repairing_operations_ex04.py +Download this script \anchor tui_suppress_holes

    Suppress Holes

    - -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -# create a vertex and a vector -p1 = geompy.MakeVertex(35, 35, 0) -p2 = geompy.MakeVertex(35, 35, 50) -v = geompy.MakeVector(p1, p2) - -# create a cylinder -height = 20 -radius1 = 20 -cylinder = geompy.MakeCylinder(p1, v, radius1, height) - -# create a cone -cone = geompy.MakeCone(p1, v, 70, 0, 80) - -# make a cut -cut = geompy.MakeCut(cone, cylinder) - -# get faces as sub-shapes -faces = [] -faces = geompy.SubShapeAllSortedCentres(cut, geompy.ShapeType["FACE"]) -f_2 = geompy.GetSubShapeID(cut, faces[2]) - -# remove one face from the shape -cut_without_f_2 = geompy.SuppressFaces(cut, [f_2]) - -# get wires as sub-shapes -wires = [] -wires = geompy.SubShapeAllSortedCentres(cut_without_f_2, geompy.ShapeType["WIRE"]) -w_0 = geompy.GetSubShapeID(cut_without_f_2, wires[0]) - -# suppress the selected wire -result = geompy.SuppressHoles(cut_without_f_2, [w_0]) - -# add objects in the study -id_cut = geompy.addToStudy(cut, "Cut") -id_cut_without_f_2 = geompy.addToStudy(cut_without_f_2, "Cut without f_2") -id_result = geompy.addToStudy(result, "Result") - -# display the results -gg.createAndDisplayGO(id_cut) -gg.setDisplayMode(id_cut,1) -gg.createAndDisplayGO(id_cut_without_f_2) -gg.setDisplayMode(id_cut_without_f_2,1) -gg.createAndDisplayGO(id_result) -gg.setDisplayMode(id_result,1) -\endcode +\include repairing_operations_ex05.py +Download this script \anchor tui_sewing

    Sewing

    - -\code -import geompy -import salome -import math -gg = salome.ImportComponentGUI("GEOM") - -# 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) -face_rot = geompy.MakeRotation(face, vector, angle) - -# make sewing -precision = 0.00001 -sewing = geompy.MakeSewing([face, face_rot], precision) - -# add objects in the study -id_face = geompy.addToStudy(face, "Face") -id_face_rot = geompy.addToStudy(face_rot, "Face rotation") -id_sewing = geompy.addToStudy(sewing, "Sewing") - -# display the results -gg.createAndDisplayGO(id_face) -gg.setDisplayMode(id_face,1) -gg.createAndDisplayGO(id_face_rot) -gg.setDisplayMode(id_face_rot,1) -gg.createAndDisplayGO(id_sewing) -gg.setDisplayMode(id_sewing,1) -\endcode +\include repairing_operations_ex06.py +Download this script \anchor tui_glue_faces

    Glue Faces

    - -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -# create boxes -box1 = geompy.MakeBox(0,0,0,100,50,100) -box2 = geompy.MakeBox(100,0,0,250,50,100) - -# make compound -compound = geompy.MakeCompound([box1, box2]) - -# glue compound's faces -tolerance = 1e-5 -glue = geompy.MakeGlueFaces(compound, tolerance) - -# add objects in study -id_box1 = geompy.addToStudy(box1, "Box1") -id_box2 = geompy.addToStudy(box2, "Box2") -id_compound = geompy.addToStudy(compound, "Compound") -id_glue = geompy.addToStudy(glue, "Glue faces") - -# display results -gg.createAndDisplayGO(id_box1) -gg.setDisplayMode(id_box1,1) -gg.createAndDisplayGO(id_box2) -gg.setDisplayMode(id_box2,1) -gg.createAndDisplayGO(id_compound) -gg.setDisplayMode(id_compound,1) -gg.createAndDisplayGO(id_glue) -gg.setDisplayMode(id_glue,1) -\endcode +\include repairing_operations_ex07.py +Download this script \anchor tui_glue_edges

    Glue Edges

    - -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -# create boxes -box1 = geompy.MakeBox(0,0,0,100,50,100) -box2 = geompy.MakeBox(100,0,0,250,50,100) - -# make compound -compound = geompy.MakeCompound([box1, box2]) - -# glue all compound's edges -tolerance = 1e-5 -glue1 = geompy.MakeGlueEdges(compound, tolerance) - -# glue some compound's edges -list_edges = geompy.GetGlueEdges(compound, tolerance) -glue2 = geompy.MakeGlueEdgesByList(compound, tolerance, [list_edges[0], list_edges[2]]) - -# add objects in study -geompy.addToStudy(box1, "Box1") -geompy.addToStudy(box2, "Box2") -geompy.addToStudy(compound, "Compound") -geompy.addToStudy(glue1, "Glue all edges") -geompy.addToStudy(glue2, "Glue two edges") - -if salome.sg.hasDesktop(): - salome.sg.updateObjBrowser(1) -\endcode +\include repairing_operations_ex08.py +Download this script \anchor tui_limit_tolerance

    Limit Tolerance

    - -\code -import geompy -gg = salome.ImportComponentGUI("GEOM") - -# import initial topology -shape1 = geompy.ImportBREP("my_shape_1.brep") -shape2 = geompy.ImportBREP("my_shape_2.brep") - -geompy.addToStudy(shape1, "Shape 1") -geompy.addToStudy(shape2, "Shape 2") - -# perform partition -try: - part = geompy.MakePartition([shape1, shape2]) -except: - # limit tolerance - tolerance = 1e-07 - shape1_lt = geompy.LimitTolerance(shape1, tolerance) - shape2_lt = geompy.LimitTolerance(shape2, tolerance) - - # process shape - good_shape1 = geompy.ProcessShape(shape1_lt, ["FixShape"], ["FixShape.Tolerance3d"], ["1e-7"]) - good_shape2 = geompy.ProcessShape(shape2_lt, ["FixShape"], ["FixShape.Tolerance3d"], ["1e-7"]) - - geompy.addToStudy(good_shape1, "Shape 1 corrected") - geompy.addToStudy(good_shape2, "Shape 2 corrected") - - # perform partition on corrected shapes - part = geompy.MakePartition([good_shape1, good_shape2]) - pass - -geompy.addToStudy(part, "Partition") -\endcode +\include repairing_operations_ex09.py +Download this script \anchor tui_add_point_on_edge

    Add Point on Edge

    - -\code -import geompy -import salome - -# create vertices -p1 = geompy.MakeVertex(0,0,50) -p2 = geompy.MakeVertex(60,0,50) - -# make an edge -edge = geompy.MakeEdge(p1, p2) #geompy.GetSubShape(box, edge_ind) - -# divide an edge -divide = geompy.DivideEdge(edge, -1, 0.5, 0) - -# add objects in the study -id_edge = geompy.addToStudy(edge, "Edge") -edge_points = geompy.SubShapeAllSortedCentres(edge, geompy.ShapeType["VERTEX"]) -for point in edge_points: - geompy.addToStudyInFather(edge, point, "Edge's point") - -id_divide = geompy.addToStudy(divide, "Divided edge") -edge_points = geompy.SubShapeAllSortedCentres(divide, geompy.ShapeType["VERTEX"]) -for point in edge_points: - geompy.addToStudyInFather(divide, point, "Edge's point after divide") - -salome.sg.updateObjBrowser(1) -\endcode +\include repairing_operations_ex10.py +Download this script \anchor tui_fuse_collinear_edges

    Fuse Collinear Edges within a Wire

    - -\code -import geompy -import salome - -# create vertices -p1 = geompy.MakeVertex(0, 0, 0) -p2 = geompy.MakeVertex(70, 0, 0) -p3 = geompy.MakeVertex(70, 50, 0) -p4 = geompy.MakeVertex(70, 80, 0) -p5 = geompy.MakeVertex(50, 80, 0) -p6 = geompy.MakeVertex(20, 80, 0) -p7 = geompy.MakeVertex(0, 80, 0) -p8 = geompy.MakeVertex(0, 30, 0) - -points = [p1, p2, p3, p4, p5, p6, p7, p8] - -# make a wire -wire_1 = geompy.MakePolyline(points, True) - -# suppress some vertices in the wire -wire_2 = geompy.FuseCollinearEdgesWithinWire(wire_1, [p3]) -wire_3 = geompy.FuseCollinearEdgesWithinWire(wire_1, [p5, p6]) - -# suppress all suitable vertices in the wire -wire_4 = geompy.FuseCollinearEdgesWithinWire(wire_1, []) - -wires = [wire_1, wire_2, wire_3, wire_4] - -# add objects in the study -ii = 1 -for point in points: - geompy.addToStudy(point, "p%d"%ii) - ii = ii + 1 - pass - -ii = 1 -for wire in wires: - geompy.addToStudy(wire, "wire_%d"%ii) - wire_points = geompy.SubShapeAllSortedCentres(wire, geompy.ShapeType["VERTEX"]) - jj = 1 - for point in wire_points: - geompy.addToStudyInFather(wire, point, "point_%d"%jj) - jj = jj + 1 - pass - ii = ii + 1 - pass - -salome.sg.updateObjBrowser(1) -\endcode +\include repairing_operations_ex11.py +Download this script */ diff --git a/doc/salome/gui/GEOM/input/tui_sketcher.doc b/doc/salome/gui/GEOM/input/tui_sketcher.doc index e344eae27..be24fd763 100644 --- a/doc/salome/gui/GEOM/input/tui_sketcher.doc +++ b/doc/salome/gui/GEOM/input/tui_sketcher.doc @@ -1,48 +1,7 @@ /*! \page tui_sketcher_page 2D Sketcher - -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -# create vertices -p1 = geompy.MakeVertex(70., 0., 0.) -p2 = geompy.MakeVertex(70., 70., 80.) -p3 = geompy.MakeVertex( 0., 70., 0.) - -#create a vector from two points -vector_arc = geompy.MakeVector(p1, p3) - -# create an arc from three points -arc = geompy.MakeArc(p1, p2, p3) - -# create a wire -wire = geompy.MakeWire([vector_arc, arc]) - -# create a planar face -isPlanarWanted = 1 -face = geompy.MakeFace(wire, isPlanarWanted) - -# create a sketcher (face), following the textual description -sketcher1 = geompy.MakeSketcher("Sketcher:F -100 -100:TT 250 -100:R 0:C 100 150:R 0:L 300:WF", - [100,0,0, 1,1,1, -1,1,0]) - -# create a sketcher (wire) on the given face -sketcher2 = geompy.MakeSketcherOnPlane("Sketcher:F 10 -30:R 10:C 20 180:R 15:L 50:WW", face) - -# add objects in the study -id_face = geompy.addToStudy(face,"Face") -id_sketcher1 = geompy.addToStudy(sketcher1,"Sketcher1") -id_sketcher2 = geompy.addToStudy(sketcher2,"Sketcher2") - -# display the first sketcher and the second sketcher with its planar face -gg.createAndDisplayGO(id_face) -gg.setDisplayMode(id_face,1) -gg.setTransparency(id_face,0.5) -gg.createAndDisplayGO(id_sketcher1) -gg.createAndDisplayGO(id_sketcher2) -\endcode +\include sketcher.py +Download this script */ diff --git a/doc/salome/gui/GEOM/input/tui_tolerance.doc b/doc/salome/gui/GEOM/input/tui_tolerance.doc index 55151302a..4da20b249 100644 --- a/doc/salome/gui/GEOM/input/tui_tolerance.doc +++ b/doc/salome/gui/GEOM/input/tui_tolerance.doc @@ -1,20 +1,7 @@ /*! \page tui_tolerance_page Tolerance - -\code -import geompy - -# create a box -box = geompy.MakeBoxDXDYDZ(100,30,100) -Toler = geompy.Tolerance(box) -print "\nBox 100x30x100 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] -\endcode +\include tolerance.py +Download this script */ diff --git a/doc/salome/gui/GEOM/input/tui_topological_geom_objs.doc b/doc/salome/gui/GEOM/input/tui_topological_geom_objs.doc index e314abc85..2b9f5d1c2 100644 --- a/doc/salome/gui/GEOM/input/tui_topological_geom_objs.doc +++ b/doc/salome/gui/GEOM/input/tui_topological_geom_objs.doc @@ -4,258 +4,32 @@ \anchor tui_creation_edge

    Creation of an Edge

    +\include topological_geom_objs_ex01.py +Download this script -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -# -# create edge by two points -# - -# create vertices -p0 = geompy.MakeVertex(0. , 0. , 0. ) -pxyz = geompy.MakeVertex(100., 100., 100.) - -# create an edge -edge = geompy.MakeEdge(p0, pxyz) - -# add object in the study -id_edge = geompy.addToStudy(edge,"Edge_1") - -# display an edge -gg.createAndDisplayGO(id_edge) - -# -# create edge from wire -# - -# create a circle -c = geompy.MakeCircle(None, None, 100) - -# create a wire -w = geompy.MakeWire([c], 1e-07) - -# create an edge from wire -edge = geompy.MakeEdgeWire(w) - -# add object in the study -id_edge = geompy.addToStudy(edge,"Edge_2") - -# display an edge -gg.createAndDisplayGO(id_edge) - -# -# create edge from existing curve and a length -# - -# create a circle -c = geompy.MakeCircle(None, None, 100) - -# create an edge of length 25.0 from the circle -edge = geompy.MakeEdgeOnCurveByLength(c, 25.0) - -# add object in the study -id_edge = geompy.addToStudy(edge,"Edge_3") - -# display an edge -gg.createAndDisplayGO(id_edge) - -\endcode - \anchor tui_creation_wire

    Creation of a Wire

    +\include topological_geom_objs_ex02.py +Download this script -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -# create vertices -px = geompy.MakeVertex(100., 0. , 0. ) -py = geompy.MakeVertex(0. , 100., 0. ) -pz = geompy.MakeVertex(0. , 0. , 100.) - -# create a vector from two points -vxy = geompy.MakeVector(px, py) - -# create an arc from three points -arc = geompy.MakeArc(py, pz, px) - -# create a wire -wire = geompy.MakeWire([vxy, arc]) - -# add an object in the study -id_wire = geompy.addToStudy(wire,"Wire") - -# display the wire -gg.createAndDisplayGO(id_wire) -\endcode - \anchor tui_creation_face

    Creation of a Face

    +\include topological_geom_objs_ex03.py +Download this script -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -# create vertices -p0 = geompy.MakeVertex(0. , 0. , 0. ) -px = geompy.MakeVertex(100., 0. , 0. ) -py = geompy.MakeVertex(0. , 100., 0. ) -pz = geompy.MakeVertex(0. , 0. , 100.) -pxyz = geompy.MakeVertex(100., 100., 100.) - -# create a vector from two points -vxy = geompy.MakeVector(px, py) - -# create an arc from three points -arc = geompy.MakeArc(py, pz, px) - -# create a wire -wire = geompy.MakeWire([vxy, arc]) - -# create sketchers -sketcher1 = 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]) -sketcher2 = geompy.MakeSketcher("Sketcher:F 0 0:TT 70 0:TT 70 70:TT 0 70:WW") -sketcher3 = geompy.MakeSketcher("Sketcher:F 20 20:TT 50 20:TT 50 50:TT 20 50:WW") -isPlanarFace = 1 - -# create a face from the wire -face1 = geompy.MakeFace(wire, isPlanarFace) - -# create faces from two wires -face2 = geompy.MakeFaceWires([wire, sketcher1],isPlanarFace) -face3 = geompy.MakeFaces([sketcher2, sketcher3],isPlanarFace) - -# add objects in the study -id_face1 = geompy.addToStudy(face1,"Face1") -id_face2 = geompy.addToStudy(face2,"Face2") -id_face3 = geompy.addToStudy(face3,"Face3") - -# display the faces -gg.createAndDisplayGO(id_face1) -gg.setDisplayMode(id_face1,1) -gg.setTransparency(id_face1,0.2) -gg.createAndDisplayGO(id_face2) -gg.setDisplayMode(id_face2,1) -gg.setTransparency(id_face2,0.2) -gg.createAndDisplayGO(id_face3) -gg.setDisplayMode(id_face3,1) -gg.setTransparency(id_face3,0.2) -\endcode - \anchor tui_creation_shell

    Creation of a Shell

    +\include topological_geom_objs_ex04.py +Download this script -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -#create vertices -p0 = geompy.MakeVertex( 0., 0., 0.) -pxyz = geompy.MakeVertex( 5., 5., 40.) - -# create sketchers -sketcher1 = geompy.MakeSketcher("Sketcher:F 0 0:TT 70 0:TT 70 70:TT 0 70:WW") -sketcher2 = geompy.MakeSketcher("Sketcher:F 20 20:TT 50 20:TT 50 50:TT 20 50:WW") -isPlanarFace = 1 - -# create a face from two wires -face = geompy.MakeFaces([sketcher1, sketcher2],isPlanarFace) - -# create a prism -prism = geompy.MakePrism(face, p0, pxyz) - -# explode the prism into faces -prism_faces = geompy.SubShapeAllSortedCentres(prism, geompy.ShapeType["FACE"]) - -# create a shell from a set of faces -shell = geompy.MakeShell([prism_faces[0], prism_faces[2], prism_faces[3], - prism_faces[7], prism_faces[9]]) - -# add objects in the study -id_shell = geompy.addToStudy(shell,"Shell") - -# display the shell -gg.createAndDisplayGO(id_shell) -gg.setDisplayMode(id_shell,1) -\endcode - \anchor tui_creation_solid

    Creation of a Solid

    +\include topological_geom_objs_ex05.py +Download this script -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -#create vertices -p0 = geompy.MakeVertex( 0., 0., 0.) -pz = geompy.MakeVertex( 0., 0., 40.) - -# create sketchers -sketcher = geompy.MakeSketcher("Sketcher:F -50 -50:TT 100 -50:R 0:C 50 70:R 0:L 100:WW") - -# create faces from two wires -face = geompy.MakeFace(sketcher,1) - -# create a prism -prism = geompy.MakePrism(face, p0, pz) - -# explode the prism into faces -prism_faces = geompy.SubShapeAllSortedCentres(prism, geompy.ShapeType["FACE"]) - -# create a shell from a set of faces -shell = geompy.MakeShell([prism_faces[0], prism_faces[1], - prism_faces[3], prism_faces[4], - prism_faces[5], prism_faces[2]]) - -# create a solid, bounded by the given shells -solid = geompy.MakeSolid([shell]) - -# add objects in the study -id_solid = geompy.addToStudy(solid,"Solid") - -# display the solid -gg.createAndDisplayGO(id_solid) -gg.setDisplayMode(id_solid,1) -\endcode - \anchor tui_creation_compound

    Creation of a Compound

    - -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -# create a vertex and a vector -p1 = geompy.MakeVertex( -30., -30., 50.) -p2 = geompy.MakeVertex( -60., -60., 30.) -p3 = geompy.MakeVertex( -30., -30., 10.) - -# create an arc from three points -arc = geompy.MakeArc(p1, p2, p3) -ShapeListCompound = [] -i = 0 -while i <= 3 : - S = geompy.MakeTranslation(arc, i * 50., 0., 0.) - ShapeListCompound.append(S) - i = i + 1 - -# create a compund of the given shapes -compound = geompy.MakeCompound(ShapeListCompound) - -# add object in the study -id_compound = geompy.addToStudy(compound,"Compound") - -# display the compound -gg.createAndDisplayGO(id_compound) -\endcode +\include topological_geom_objs_ex06.py +Download this script */ diff --git a/doc/salome/gui/GEOM/input/tui_transformation_operations.doc b/doc/salome/gui/GEOM/input/tui_transformation_operations.doc index 09744cddf..10e392ec0 100644 --- a/doc/salome/gui/GEOM/input/tui_transformation_operations.doc +++ b/doc/salome/gui/GEOM/input/tui_transformation_operations.doc @@ -4,552 +4,67 @@ \anchor tui_translation

    Translation

    - -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -# create a vertex and a vector -p1 = geompy.MakeVertex(10, 40, 0) -p2 = geompy.MakeVertex( 0, 0, 50) -p3 = geompy.MakeVertex(50, 80, 0) -v = geompy.MakeVector(p1, p2) -vt = geompy.MakeVector(p1, p3) - -# create a cylinder -height = 35 -radius1 = 20 -cylinder = geompy.MakeCylinder(p1, v, radius1, height) - -# translate the given object along the vector, specified by its end points -# (all three functions produce the same result) -translation1 = geompy.MakeTranslationTwoPoints(cylinder, p1, p3) -translation2 = geompy.MakeTranslation(cylinder, 40, 40, 0) -translation3 = geompy.MakeTranslationVector(cylinder, vt) -translation4 = geompy.MakeTranslationVectorDistance(cylinder, vt, 200) - -# add objects in the study -id_cylinder = geompy.addToStudy(cylinder, "Cylinder") -id_translation1 = geompy.addToStudy(translation1, "Translation1") -id_translation2 = geompy.addToStudy(translation2, "Translation2") -id_translation3 = geompy.addToStudy(translation3, "Translation3") -id_translation4 = geompy.addToStudy(translation4, "Translation4") - -# display the results -gg.createAndDisplayGO(id_cylinder) -gg.setDisplayMode(id_cylinder,1) -gg.createAndDisplayGO(id_translation1) -gg.setDisplayMode(id_translation1,1) -gg.createAndDisplayGO(id_translation2) -gg.setDisplayMode(id_translation2,1) -gg.createAndDisplayGO(id_translation3) -gg.setDisplayMode(id_translation3,1) -gg.createAndDisplayGO(id_translation4) -gg.setDisplayMode(id_translation4,1) -\endcode +\include transformation_operations_ex01.py +Download this script \anchor tui_rotation

    Rotation

    - -\code -import geompy -import salome -import math -gg = salome.ImportComponentGUI("GEOM") - -# create a vertex and a vector -p1 = geompy.MakeVertex(10, 40, 0) -p2 = geompy.MakeVertex( 0, 0, 50) -p3 = geompy.MakeVertex(10, 50,-20) -p4 = geompy.MakeVertex(10, 50, 60) -v = geompy.MakeVector(p1, p2) -vr = geompy.MakeVector(p3, p4) - -# create a cylinder -height = 35 -radius1 = 20 -cylinder = geompy.MakeCylinder(p1, v, radius1, height) - -# rotate the given object around the given axis by the given angle -rotation1 = geompy.MakeRotation(cylinder, vr, math.pi) -rotation2 = geompy.MakeRotationThreePoints(cylinder, p4, p1, p2) - -# add objects in the study -id_vr = geompy.addToStudy(vr, "Rotation 1 axis") -id_p4 = geompy.addToStudy(p4, "Rotation 2 center") -id_p1 = geompy.addToStudy(p1, "Rotation 2 point 1") -id_p2 = geompy.addToStudy(p2, "Rotation 2 point 2") -id_cylinder = geompy.addToStudy(cylinder, "Cylinder") -id_rotation1 = geompy.addToStudy(rotation1, "Rotation 1") -id_rotation2 = geompy.addToStudy(rotation2, "Rotation 2") - -# display the results -gg.createAndDisplayGO(id_vr) -gg.createAndDisplayGO(id_p4) -gg.createAndDisplayGO(id_p1) -gg.createAndDisplayGO(id_p2) -gg.createAndDisplayGO(id_cylinder) -gg.setDisplayMode(id_cylinder,1) -gg.createAndDisplayGO(id_rotation1) -gg.createAndDisplayGO(id_rotation2) -gg.setDisplayMode(id_rotation1,1) -gg.setDisplayMode(id_rotation2,1) -\endcode +\include transformation_operations_ex02.py +Download this script \anchor tui_modify_location

    Modify Location

    - -\code -import geompy -import salome -import math -gg = salome.ImportComponentGUI("GEOM") - -# create a vertex and a vector -p1 = geompy.MakeVertex(10, 40, 0) -p2 = geompy.MakeVertex( 0, 0, 50) -v = geompy.MakeVector(p1, p2) - -# create a cylinder -height = 35 -radius1 = 20 -cylinder = geompy.MakeCylinder(p1, v, radius1, height) -circle = geompy.MakeCircle(p2, v, radius1) - -# create local coordinate systems -cs1 = geompy.MakeMarker( 0, 0, 0, 1,0,0, 0,1,0) -cs2 = geompy.MakeMarker(30,40,40, 1,0,0, 0,1,0) - -# modify the location of the given object -position = geompy.MakePosition(cylinder, cs1, cs2) -position2 = geompy.PositionAlongPath(position, circle, 0.75, 1, 1) - -# add objects in the study -id_cs1 = geompy.addToStudy(cs1, "Coordinate system 1") -id_cs2 = geompy.addToStudy(cs2, "Coordinate system 2") -id_cylinder = geompy.addToStudy(cylinder, "Cylinder") -id_circle = geompy.addToStudy(circle, "Circle") -id_position = geompy.addToStudy(position, "Position") -id_position2 = geompy.addToStudy(position2, "PositionAlongPath") - -# display the results -gg.createAndDisplayGO(id_cylinder) -gg.setDisplayMode(id_cylinder,1) -gg.createAndDisplayGO(id_position) -gg.setDisplayMode(id_position,1) -gg.createAndDisplayGO(id_circle) -gg.setDisplayMode(id_circle,1) -gg.createAndDisplayGO(id_position2) -gg.setDisplayMode(id_position2,1) -\endcode +\include transformation_operations_ex03.py +Download this script \anchor tui_mirror

    Mirror Image

    - -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -# create a box -box = geompy.MakeBoxDXDYDZ(200, 200, 200) - -# create an object, symmetrical to another object through the given plane -p1 = geompy.MakeVertex( 0, 25, 0) -p2 = geompy.MakeVertex( 5, 25, 0) -p3 = geompy.MakeVertex( 0,-30, 40) -plane = geompy.MakePlaneThreePnt(p1, p2, p3, 1000.) -mirror1 = geompy.MakeMirrorByPlane(box, plane) - -# create an object, symmetrical to another object through the given axis -p4 = geompy.MakeVertex( 210, 210, -20) -p5 = geompy.MakeVertex( 210, 210, 220) -axis = geompy.MakeVector(p4, p5) -mirror2 = geompy.MakeMirrorByAxis(box, axis) - -# create an object, symmetrical to another object through the given point -mirror3 = geompy.MakeMirrorByPoint(box, p4) - -# add objects in the study -id_box = geompy.addToStudy(box, "Box") -id_plane = geompy.addToStudy(plane, "Plane") -id_mirror1 = geompy.addToStudy(mirror1, "Mirror plane") -id_axis = geompy.addToStudy(axis, "Axis") -id_mirror2 = geompy.addToStudy(mirror2, "Mirror axis") -id_p4 = geompy.addToStudy(p4, "Point") -id_mirror3 = geompy.addToStudy(mirror3, "Mirror point") - -# display the results -gg.createAndDisplayGO(id_box) -gg.setDisplayMode(id_box,1) -gg.createAndDisplayGO(id_plane) -gg.createAndDisplayGO(id_mirror1) -gg.setDisplayMode(id_mirror1,1) -gg.createAndDisplayGO(id_axis) -gg.createAndDisplayGO(id_mirror2) -gg.setDisplayMode(id_mirror2,1) -gg.createAndDisplayGO(id_p4) -gg.createAndDisplayGO(id_mirror3) -gg.setDisplayMode(id_mirror3,1) -\endcode +\include transformation_operations_ex04.py +Download this script \anchor tui_scale

    Scale Transform

    - -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -# create a box and a sphere -box = geompy.MakeBoxDXDYDZ(200, 200, 200) - -# scale the given object by the factor -p0 = geompy.MakeVertex(100, 100, 100) -factor = 0.5 -scale = geompy.MakeScaleTransform(box, p0, factor) - -# add objects in the study -id_box = geompy.addToStudy(box, "Box") -id_scale = geompy.addToStudy(scale, "Scale") - -# display the results -gg.createAndDisplayGO(id_box) -gg.setDisplayMode(id_box,1) -gg.setTransparency(id_box,0.5) -gg.createAndDisplayGO(id_scale) -gg.setDisplayMode(id_scale,1) -\endcode +\include transformation_operations_ex05.py +Download this script \anchor tui_offset

    Offset Surface

    - -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -# create a box and a sphere -box = geompy.MakeBox(20, 20, 20, 200, 200, 200) - -# create a new object as offset of the given object -offset = geompy.MakeOffset(box, 70.) - -# add objects in the study -id_box = geompy.addToStudy(box, "Box") -id_offset = geompy.addToStudy(offset, "Offset") - -# display the results -gg.createAndDisplayGO(id_box) -gg.setDisplayMode(id_box,1) -gg.createAndDisplayGO(id_offset) -\endcode +\include transformation_operations_ex06.py +Download this script \anchor tui_projection

    Projection

    - -\code -import geompy -import salome - -# create a cylindric face and a curve(edge) -cylinder = geompy.MakeCylinderRH(100, 300) -[face_cyl] = geompy.SubShapes(cylinder, [3]) - -p1 = geompy.MakeVertex(200, 0, 100) -p2 = geompy.MakeVertex(200, 80, 100) -p3 = geompy.MakeVertex(200, 80, 180) -p4 = geompy.MakeVertex(130, 80, 180) -p5 = geompy.MakeVertex(90, 80, 240) - -curve = geompy.MakeInterpol([p1, p2, p3, p4, p5], False, False) - -# create a new object as projection of the -# given curve on the given cylindric face -projection = geompy.MakeProjection(curve, face_cyl) - -# add objects in the study -geompy.addToStudy(cylinder, "cylinder") -geompy.addToStudyInFather(cylinder, face_cyl, "face_cyl") -geompy.addToStudy(p1, "p1") -geompy.addToStudy(p2, "p2") -geompy.addToStudy(p3, "p3") -geompy.addToStudy(p4, "p4") -geompy.addToStudy(p5, "p5") -geompy.addToStudy(curve, "curve") -geompy.addToStudy(projection, "projection") -\endcode +\include transformation_operations_ex07.py +Download this script \anchor tui_multi_translation

    Multi Translation

    - -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -# create vertices and vectors -p0 = geompy.MakeVertex( 0., 0., 0.) -px = geompy.MakeVertex(20., 0., 0.) -py = geompy.MakeVertex( 0., 20., 0.) -pz = geompy.MakeVertex( 0., 0., 20.) -pxy = geompy.MakeVertex( 50., 0., 0.) -pxyz = geompy.MakeVertex( 50., 50., 50.) -vz = geompy.MakeVector(p0, pz) -vxy = geompy.MakeVector(px, py) -vtr1d = geompy.MakeVector(p0, pxyz) -vtr2d = geompy.MakeVector(p0, pxy) - -# create an arc -arc = geompy.MakeArc(py, pz, px) - -# create a wire -wire = geompy.MakeWire([vxy, arc]) - -# create a planar face -face = geompy.MakeFace(wire, 1) - -# create a prism -prism = geompy.MakePrismVecH(face, vz, 20.0) - -# translate the given object along the given vector a given number of times -tr1d = geompy.MakeMultiTranslation1D(prism, vtr1d, 20, 4) - -# consequently apply two specified translations to the object a given number of times -tr2d = geompy.MakeMultiTranslation2D(prism, vtr1d, 20, 4, vtr2d, 80, 3) - -# add objects in the study -id_prism = geompy.addToStudy(prism,"Prism") -id_tr1d = geompy.addToStudy(tr1d,"Translation 1D") -id_tr2d = geompy.addToStudy(tr2d,"Translation 2D") - -# display the prism and the results of fillet operation -gg.createAndDisplayGO(id_prism) -gg.setDisplayMode(id_prism,1) -gg.createAndDisplayGO(id_tr1d) -gg.setDisplayMode(id_tr1d,1) -gg.createAndDisplayGO(id_tr2d) -gg.setDisplayMode(id_tr2d,1) -\endcode +\include transformation_operations_ex08.py +Download this script \anchor tui_multi_rotation

    Multi Rotation

    - -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -# create vertices and vectors -p0 = geompy.MakeVertex( 0., 0., 0.) -px = geompy.MakeVertex(20., 0., 0.) -py = geompy.MakeVertex( 0., 20., 0.) -pz = geompy.MakeVertex( 0., 0., 20.) -pxyz = geompy.MakeVertex( 50., 50., 10.) -vz = geompy.MakeVector(p0, pz) -vxy = geompy.MakeVector(px, py) -vrot1d = geompy.MakeVector(p0, pxyz) - -# create an arc -arc = geompy.MakeArc(py, pz, px) - -# create a wire -wire = geompy.MakeWire([vxy, arc]) - -# create a planar face -face = geompy.MakeFace(wire, 1) - -# create a prism -prism = geompy.MakePrismVecH(face, vz, 20.0) - -# rotate the given object around the given axis by the given angle a given number of times -rot1d = geompy.MultiRotate1D(prism, vrot1d, 4) - -# rotate the given object around the given axis by the given angle a given number of times -# and multi-translate the result of each rotation -rot2d = geompy.MultiRotate2D(prism, vrot1d, 60, 4, 50, 5) - -# add objects in the study -id_prism = geompy.addToStudy(prism,"Prism") -id_rot1d = geompy.addToStudy(rot1d,"Rotation 1D") -id_rot2d = geompy.addToStudy(rot2d,"Rotation 2D") - -# display the prism and the results of fillet operation -gg.createAndDisplayGO(id_prism) -gg.setDisplayMode(id_prism,1) -gg.createAndDisplayGO(id_rot1d) -gg.setDisplayMode(id_rot1d,1) -gg.createAndDisplayGO(id_rot2d) -gg.setDisplayMode(id_rot2d,1) -\endcode +\include transformation_operations_ex09.py +Download this script \anchor tui_fillet2d

    Fillet 2D

    - -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -# create a face in OXY plane -face = geompy.MakeFaceHW(100, 100, 1) -fillet2d = geompy.MakeFillet2D(face, 30, [7, 9]) - -# add objects in the study -id_face = geompy.addToStudy(face,"Face_1") -id_fillet2d = geompy.addToStudy(fillet2d,"Fillet 2D_1") - -# display disks -gg.createAndDisplayGO(id_face) -gg.createAndDisplayGO(id_fillet2d) -\endcode +\include transformation_operations_ex10.py +Download this script \anchor tui_fillet1d

    Fillet 1D

    - -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -# create box -Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200) -# take box edges to create custom complex wire -[Edge_1,Edge_2,Edge_3,Edge_4,Edge_5,Edge_6,Edge_7,Edge_8,Edge_9,Edge_10,Edge_11,Edge_12] = geompy.SubShapeAllSortedCentres(Box_1, geompy.ShapeType["EDGE"]) -# create wire -Wire_1 = geompy.MakeWire([Edge_12, Edge_7, Edge_11, Edge_6, Edge_1,Edge_4]) -# make fillet at given wire vertices with giver radius -Fillet_1D_1 = geompy.MakeFillet1D(Wire_1, 55, [3, 4, 6, 8, 10]) - - -# display disks -gg.createAndDisplayGO(Wire_1) -gg.createAndDisplayGO(Fillet_1D_1) -\endcode +\include transformation_operations_ex11.py +Download this script \anchor tui_fillet

    Fillet

    - -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") -radius = 10. -ShapeTypeEdge = geompy.ShapeType["EDGE"] - -# create vertices and vectors -p0 = geompy.MakeVertex( 0., 0., 0.) -px = geompy.MakeVertex(100., 0., 0.) -py = geompy.MakeVertex( 0., 100., 0.) -pz = geompy.MakeVertex( 0., 0., 100.) -vz = geompy.MakeVector(p0, pz) -vxy = geompy.MakeVector(px, py) - -# create an arc -arc = geompy.MakeArc(py, pz, px) - -# create a wire -wire = geompy.MakeWire([vxy, arc]) - -# create a planar face -face = geompy.MakeFace(wire, 1) - -# create a prism -prism = geompy.MakePrismVecH(face, vz, 100.0) - -# get the list of IDs (IDList) for the fillet -prism_edges = geompy.SubShapeAllSortedCentres(prism, ShapeTypeEdge) -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])) - -# make a fillet on the specified edges of the given shape -fillet = geompy.MakeFillet(prism, radius, ShapeTypeEdge, IDlist_e) - -# make a fillet on all edges of the given shape -filletall = geompy.MakeFilletAll(prism, radius) - -# add objects in the study -id_prism = geompy.addToStudy(prism,"Prism") -id_fillet = geompy.addToStudy(fillet,"Fillet") -id_filletall = geompy.addToStudy(filletall,"Fillet all") - -# display the prism and the results of fillet operation -gg.createAndDisplayGO(id_prism) -gg.setDisplayMode(id_prism,1) -gg.createAndDisplayGO(id_fillet) -gg.setDisplayMode(id_fillet,1) -gg.createAndDisplayGO(id_filletall) -gg.setDisplayMode(id_filletall,1) -\endcode +\include transformation_operations_ex12.py +Download this script \anchor tui_chamfer

    Chamfer

    - -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") -d1 = 10. -d2 = 10. -ShapeTypeFace = geompy.ShapeType["FACE"] - -# create vertices and vectors -p0 = geompy.MakeVertex( 0., 0., 0.) -px = geompy.MakeVertex(100., 0., 0.) -py = geompy.MakeVertex( 0., 100., 0.) -pz = geompy.MakeVertex( 0., 0., 100.) -vz = geompy.MakeVector(p0, pz) -vxy = geompy.MakeVector(px, py) - -# create an arc -arc = geompy.MakeArc(py, pz, px) - -# create a wire -wire = geompy.MakeWire([vxy, arc]) - -# create a planar face -face = geompy.MakeFace(wire, 1) - -# create a prism -prism = geompy.MakePrismVecH(face, vz, 100.0) - -# get the list of IDs (IDList) for the chamfer -prism_faces = geompy.SubShapeAllSortedCentres(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] - -# perform a chamfer on the edges common to the specified faces -chamfer_e = geompy.MakeChamferEdge(prism, d1, d2, f_ind_1, f_ind_2) - -# perform a chamfer on all edges of the specified faces -chamfer_f = geompy.MakeChamferFaces(prism, d1, d2, IDlist_f) -chamfer_f1 = geompy.MakeChamfer(prism, d1, d2, ShapeTypeFace, IDlist_f) - -# perform a symmetric chamfer on all edges of the given shape -chamfer_all = geompy.MakeChamferAll(prism, d1) - -# add objects in the study -id_prism = geompy.addToStudy(prism,"Prism") -id_chamfer_e = geompy.addToStudy(chamfer_e,"Chamfer edge") -id_chamfer_f = geompy.addToStudy(chamfer_f,"Chamfer faces") -id_chamfer_f1 = geompy.addToStudy(chamfer_f1,"Chamfer faces 1") -id_chamfer_all = geompy.addToStudy(chamfer_all,"Chamfer all") - -# display the prism and the results of chamfer operation -gg.createAndDisplayGO(id_prism) -gg.setDisplayMode(id_prism,1) -gg.createAndDisplayGO(id_chamfer_e) -gg.setDisplayMode(id_chamfer_e,1) -gg.createAndDisplayGO(id_chamfer_f) -gg.setDisplayMode(id_chamfer_f,1) -gg.createAndDisplayGO(id_chamfer_f1) -gg.setDisplayMode(id_chamfer_f1,1) -gg.createAndDisplayGO(id_chamfer_all) -gg.setDisplayMode(id_chamfer_all,1) -\endcode +\include transformation_operations_ex13.py +Download this script */ diff --git a/doc/salome/gui/GEOM/input/tui_viewing_geom_objs.doc b/doc/salome/gui/GEOM/input/tui_viewing_geom_objs.doc index 2573c0fa5..8505548d3 100644 --- a/doc/salome/gui/GEOM/input/tui_viewing_geom_objs.doc +++ b/doc/salome/gui/GEOM/input/tui_viewing_geom_objs.doc @@ -4,78 +4,22 @@ \anchor tui_change_disp_mode

    Changing Display Mode

    - -\code -import salome -import geompy -box = geompy.MakeBox(0,0,0, 50,50,50) -box2 = geompy.MakeBox(-50,-50,-50, 0,0,0) - -sphere = geompy.MakeSphere(50,50,50, 30) -fuse = geompy.MakeBoolean(box,sphere,3) -fuse_id = geompy.addToStudy(fuse,"Fuse") -box_id = geompy.addToStudy(box2, "Box") - -gg = salome.ImportComponentGUI("GEOM") -gg.createAndDisplayGO(fuse_id) -gg.setDisplayMode(fuse_id,1) -gg.createAndDisplayGO(box_id) -gg.setVectorsMode(box_id, 1) -\endcode +\include viewing_geom_objs_ex01.py +Download this script \anchor tui_change_color

    Changing Color

    - -\code -import salome -import geompy -box = geompy.MakeBox(0,0,0, 50,50,50) - -sphere = geompy.MakeSphere(50,50,50, 30) -fuse = geompy.MakeBoolean(box,sphere,3) -fuse_id = geompy.addToStudy(fuse,"Fuse") - -gg = salome.ImportComponentGUI("GEOM") -gg.createAndDisplayGO(fuse_id) -gg.setDisplayMode(fuse_id,1) -gg.setColor(fuse_id,218,165,31) -\endcode +\include viewing_geom_objs_ex02.py +Download this script \anchor tui_change_transparency

    Changing Transparency

    - -\code -import salome -import geompy - -box = geompy.MakeBox(0,0,0, 50,50,50) -sphere = geompy.MakeSphere(50,50,50, 30) - -fuse = geompy.MakeBoolean(box,sphere,3) -fuse_id = geompy.addToStudy(fuse,"Fuse") - -gg = salome.ImportComponentGUI("GEOM") -gg.createAndDisplayGO(fuse_id) -gg.setDisplayMode(fuse_id,1) -gg.setColor(fuse_id,218,165,31) -gg.setTransparency(fuse_id,0.5) -\endcode +\include viewing_geom_objs_ex03.py +Download this script \anchor tui_point_marker

    Set Point Marker

    +\include viewing_geom_objs_ex04.py +Download this script -\code -import salome -import geompy - -texture = geompy.LoadTexture("/users/user/mytexture.dat") - -v1 = geompy.MakeVertex(0, 0, 0) -v2 = geompy.MakeVertex(100, 0, 0) -v3 = geompy.MakeVertex(0, 100, 0) - -v1.SetMarkerStd(GEOM.MT_O_PLUS, GEOM.MS_25) -v2.SetMarkerStd(GEOM.MT_BALL, GEOM.MS_40) -v3.SetMarkerTexture(texture) -\endcode */ diff --git a/doc/salome/gui/GEOM/input/tui_whatis.doc b/doc/salome/gui/GEOM/input/tui_whatis.doc index e89e8bf18..d1c8fc911 100644 --- a/doc/salome/gui/GEOM/input/tui_whatis.doc +++ b/doc/salome/gui/GEOM/input/tui_whatis.doc @@ -1,15 +1,7 @@ /*! \page tui_whatis_page What Is - -\code -import geompy - -# create a box -box = geompy.MakeBoxDXDYDZ(100,30,100) -Descr = geompy.WhatIs(box) -print "\nBox 100x30x100 description:" -print Descr -\endcode +\include whatis.py +Download this script */ diff --git a/doc/salome/gui/GEOM/input/tui_working_with_groups.doc b/doc/salome/gui/GEOM/input/tui_working_with_groups.doc index 37813417c..4f252c2e9 100644 --- a/doc/salome/gui/GEOM/input/tui_working_with_groups.doc +++ b/doc/salome/gui/GEOM/input/tui_working_with_groups.doc @@ -5,214 +5,35 @@
    \anchor tui_create_groups_anchor

    Creation of a group

    - -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -# create two vertices -p0 = geompy.MakeVertex(0. , 0. , 0. ) -p200 = geompy.MakeVertex(200., 200., 200.) - -# create a box from two points -Box = geompy.MakeBoxTwoPnt(p0, p200) - -# create a group from the faces of the box -group = geompy.CreateGroup(Box, geompy.ShapeType["FACE"]) - -# add objects to the group -SubFaceList = geompy.SubShapeAllSortedCentres(Box, geompy.ShapeType["FACE"]) -for i in [0, 3, 5] : - FaceID = geompy.GetSubShapeID(Box, SubFaceList[i]) - geompy.AddObject(group, FaceID) - -# add all selected shapes from the list to the group -# (the program doesn't raise error, if some shapes are already included) -geompy.UnionList(group, [SubFaceList[0], SubFaceList[2], SubFaceList[5]]) - -# remove an object from the group -geompy.RemoveObject(group, FaceID) - -# remove all selected shapes from the group -# (the program doesn't raise error, if some shapes are not included) -geompy.DifferenceList(group, [SubFaceList[2], SubFaceList[3], SubFaceList[4]]) -id_group1 = geompy.addToStudy(group, "Group1") - -# display the contents of the group -gg.createAndDisplayGO(id_group1) -salome.sg.updateObjBrowser(1) -\endcode +\include working_with_groups_ex01.py +Download this script \anchor tui_edit_groups_anchor

    Adding an object to the group

    - -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -# create two vertices -p0 = geompy.MakeVertex(0. , 0. , 0. ) -p200 = geompy.MakeVertex(200., 200., 200.) - -# create a box from two points -Box = geompy.MakeBoxTwoPnt(p0, p200) - -# create a group from the faces of the box -group = geompy.CreateGroup(Box, geompy.ShapeType["FACE"]) - -# add objects to the group -SubFaceList = geompy.SubShapeAllSortedCentres(Box, geompy.ShapeType["FACE"]) -for i in [0, 3, 5] : - FaceID = geompy.GetSubShapeID(Box, SubFaceList[i]) - geompy.AddObject(group, FaceID) -id_group1 = geompy.addToStudy(group, "Group1") - -# display the contents of the group -gg.createAndDisplayGO(id_group1) -salome.sg.updateObjBrowser(1) -\endcode +\include working_with_groups_ex02.py +Download this script

    Removing an object from the group

    - -\code -import geompy -import salome -gg = salome.ImportComponentGUI("GEOM") - -# create two vertices -p0 = geompy.MakeVertex(0. , 0. , 0. ) -p200 = geompy.MakeVertex(200., 200., 200.) - -# create a box from two points -Box = geompy.MakeBoxTwoPnt(p0, p200) - -# create a group from the faces of the box -group = geompy.CreateGroup(Box, geompy.ShapeType["FACE"]) - -# add objects to the group -SubFaceList = geompy.SubShapeAllSortedCentres(Box, geompy.ShapeType["FACE"]) -for i in [0, 3, 5] : - FaceID = geompy.GetSubShapeID(Box, SubFaceList[i]) - geompy.AddObject(group, FaceID) - -# add all selected shapes from the list to the group -# (the program doesn't raise errors, if some shapes are already included) -geompy.UnionList(group, [SubFaceList[0], SubFaceList[2], SubFaceList[5]]) - -# remove an object from the group -geompy.RemoveObject(group, FaceID) -id_group1 = geompy.addToStudy(group, "Group1") - -# display the contents of the group -gg.createAndDisplayGO(id_group1) -salome.sg.updateObjBrowser(1) -\endcode +\include working_with_groups_ex03.py +Download this script
    \anchor tui_union_groups_anchor

    Union Groups

    - -\code -import geompy -import salome - -# create a box and some groups of faces on it -Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200) -Group_1 = geompy.CreateGroup(Box_1, geompy.ShapeType["FACE"]) -geompy.UnionIDs(Group_1, [13, 23]) -Group_2 = geompy.CreateGroup(Box_1, geompy.ShapeType["FACE"]) -geompy.UnionIDs(Group_2, [3, 27]) -Group_3 = geompy.CreateGroup(Box_1, geompy.ShapeType["FACE"]) -geompy.UnionIDs(Group_3, [33, 23]) -Group_4 = geompy.CreateGroup(Box_1, geompy.ShapeType["FACE"]) -geompy.UnionIDs(Group_4, [31, 27]) - -# union groups -Group_U_1_2 = geompy.UnionGroups(Group_1, Group_2) -Group_UL_3_4 = geompy.UnionListOfGroups([Group_3, Group_4]) - -# publish shapes -geompy.addToStudy(Box_1, 'Box_1') -geompy.addToStudyInFather(Box_1, Group_1, 'Group_1') -geompy.addToStudyInFather(Box_1, Group_2, 'Group_2') -geompy.addToStudyInFather(Box_1, Group_3, 'Group_3') -geompy.addToStudyInFather(Box_1, Group_4, 'Group_4') -geompy.addToStudyInFather(Box_1, Group_U_1_2, 'Group_U_1_2') -geompy.addToStudyInFather(Box_1, Group_UL_3_4, 'Group_UL_3_4') -salome.sg.updateObjBrowser(1) -\endcode +\include working_with_groups_ex04.py +Download this script
    \anchor tui_intersect_groups_anchor

    Intersect Groups

    - -\code -import geompy -import salome - -# create a box and some groups of faces on it -Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200) -Group_1 = geompy.CreateGroup(Box_1, geompy.ShapeType["FACE"]) -geompy.UnionIDs(Group_1, [13, 23]) -Group_2 = geompy.CreateGroup(Box_1, geompy.ShapeType["FACE"]) -geompy.UnionIDs(Group_2, [3, 27]) -Group_3 = geompy.CreateGroup(Box_1, geompy.ShapeType["FACE"]) -geompy.UnionIDs(Group_3, [33, 23]) -Group_4 = geompy.CreateGroup(Box_1, geompy.ShapeType["FACE"]) -geompy.UnionIDs(Group_4, [31, 27]) - -# intersect groups -Group_I_1_3 = geompy.IntersectGroups(Group_1, Group_3) -Group_IL_1_3 = geompy.IntersectListOfGroups([Group_1, Group_3]) - -# publish shapes -geompy.addToStudy(Box_1, 'Box_1') -geompy.addToStudyInFather(Box_1, Group_1, 'Group_1') -geompy.addToStudyInFather(Box_1, Group_2, 'Group_2') -geompy.addToStudyInFather(Box_1, Group_3, 'Group_3') -geompy.addToStudyInFather(Box_1, Group_4, 'Group_4') -geompy.addToStudyInFather(Box_1, Group_I_1_3, 'Group_I_1_3') -geompy.addToStudyInFather(Box_1, Group_IL_1_3, 'Group_IL_1_3') -salome.sg.updateObjBrowser(1) - -\endcode +\include working_with_groups_ex05.py +Download this script
    \anchor tui_cut_groups_anchor

    Cut Groups

    - -\code -import geompy -import salome - -# create a box and some groups of faces on it -Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200) -Group_1 = geompy.CreateGroup(Box_1, geompy.ShapeType["FACE"]) -geompy.UnionIDs(Group_1, [13, 23]) -Group_2 = geompy.CreateGroup(Box_1, geompy.ShapeType["FACE"]) -geompy.UnionIDs(Group_2, [3, 27]) -Group_3 = geompy.CreateGroup(Box_1, geompy.ShapeType["FACE"]) -geompy.UnionIDs(Group_3, [33, 23]) -Group_4 = geompy.CreateGroup(Box_1, geompy.ShapeType["FACE"]) -geompy.UnionIDs(Group_4, [31, 27]) - -# cut groups -Group_C_2_4 = geompy.CutGroups(Group_2, Group_4) -Group_CL_2_4 = geompy.CutListOfGroups([Group_2], [Group_4]) - -# publish shapes -geompy.addToStudy(Box_1, 'Box_1') -geompy.addToStudyInFather(Box_1, Group_1, 'Group_1') -geompy.addToStudyInFather(Box_1, Group_2, 'Group_2') -geompy.addToStudyInFather(Box_1, Group_3, 'Group_3') -geompy.addToStudyInFather(Box_1, Group_4, 'Group_4') -geompy.addToStudyInFather(Box_1, Group_C_2_4, 'Group_C_2_4') -geompy.addToStudyInFather(Box_1, Group_CL_2_4, 'Group_CL_2_4') -salome.sg.updateObjBrowser(1) - -\endcode +\include working_with_groups_ex06.py +Download this script */ diff --git a/doc/salome/gui/GEOM/input/working_with_groups.doc b/doc/salome/gui/GEOM/input/working_with_groups.doc index 99b98bac9..6b9d85c1c 100644 --- a/doc/salome/gui/GEOM/input/working_with_groups.doc +++ b/doc/salome/gui/GEOM/input/working_with_groups.doc @@ -103,10 +103,19 @@ To \b Edit an existing group in the main menu select New entity > Group > Edit. This menu is designed in the same way as the Create a group menu. -\n Dialog Box: +\n When a GEOM group is edited, the main shape appears in the 3D viewer in the same mode +as it is displayed in the viewer. If the main shape was not displayed in the viewer, then +the default mode defined in the preferences will be used. + +\n Working with Dialog Box: \image html editgroup.png +\n The subshapes already in the group are displayed in the 3D viewer with a specific color, +defined via preferences. The IDs of the subshapes already in the group also are displayed in +a specific color in the dialog box. When user adds some subshapes, the new IDs are +displayed in the other color. + \n The \b Result of the operation will be a \b GEOM_Object. \n TUI Command: diff --git a/doc/salome/gui/Makefile.am b/doc/salome/gui/Makefile.am index 03e3efc6e..fff0e9b64 100644 --- a/doc/salome/gui/Makefile.am +++ b/doc/salome/gui/Makefile.am @@ -20,8 +20,7 @@ # -* Makefile *- # Author : Patrick GOLDBRONN (CEA) # Date : 30/11/2001 -# Modified by : Alexander BORODIN (OCN) - autotools usage -# $Header: +# Modified by : Alexander BORODIN (OCN) - autotools usage # SUBDIRS = GEOM diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index f35c7935e..b7bcf45e2 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -804,7 +804,7 @@ module GEOM /*! * \brief 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 theVector Direction of the translation. DX if None. * \param theStep Distance to translate on. * \param theNbTimes Quantity of translations to be done. * \return New GEOM_Object, containing compound of all @@ -818,10 +818,10 @@ module GEOM /*! * \brief 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 theVector1 Direction of the first translation. DX if None. * \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 theVector2 Direction of the second translation. DY if None. * \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 @@ -888,20 +888,56 @@ module GEOM in GEOM_Object theAxis, in double theAngle); - /*! * \brief Rotate the given object around the given axis a given number times. * - * Rotation angle will be 2*PI/theNbTimes. + * Rotation angle will be 2*PI/theNbObjects. * \param theObject The object to be rotated. - * \param theAxis The rotation axis. - * \param theNbTimes Quantity of rotations to be done. + * \param theAxis The rotation axis. DZ if None. + * \param theNbObjects 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); + in long theNbObjects); + + /*! + * \brief Rotate the given object around the given axis + * a given number times on the given angle. + * + * \param theObject The object to be rotated. + * \param theAxis The rotation axis. DZ if None. + * \param theAngleStep Rotation angle in radians. + * \param theNbSteps Quantity of rotations to be done. + * \return New GEOM_Object, containing compound of all the + * shapes, obtained after each rotation. + */ + GEOM_Object MultiRotate1DByStep (in GEOM_Object theObject, + in GEOM_Object theAxis, + in double theAngleStep, + in long theNbSteps); + + /*! + * \brief Rotate the given object around the given axis + * a given number times and multi-translate each rotation result. + * + * Rotation angle will be 2*PI/theNbObjects. + * 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. DZ if None. + * \param theNbObjects Quantity of rotations to be done. + * \param theRadialStep Translation distance. + * \param theNbSteps Quantity of translations to be done. + * \return New GEOM_Object, containing compound of all the + * shapes, obtained after each transformation. + */ + GEOM_Object MultiRotate2DNbTimes (in GEOM_Object theObject, + in GEOM_Object theAxis, + in long theNbObjects, + in double theRadialStep, + in long theNbSteps); /*! * \brief Rotate the given object around the @@ -911,20 +947,43 @@ module GEOM * 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. + * \param theAxis Rotation axis. DZ if None. + * \param theAngleStep Rotation angle in radians. + * \param theNbSteps1 Quantity of rotations to be done. + * \param theRadialStep Translation distance. + * \param theNbSteps2 Quantity of translations to be done. + * \return New GEOM_Object, containing compound of all the + * shapes, obtained after each transformation. + */ + GEOM_Object MultiRotate2DByStep (in GEOM_Object theObject, + in GEOM_Object theAxis, + in double theAngleStep, + in long theNbSteps1, + in double theRadialStep, + in long theNbSteps2); + + /*! + * \brief 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. DZ if None. + * \param theAngleStep Rotation angle in degrees. + * \param theNbSteps1 Quantity of rotations to be done. + * \param theRadialStep Translation distance. + * \param theNbSteps2 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); + in double theAngleStep, + in long theNbSteps1, + in double theRadialStep, + in long theNbSteps2); /*! * \brief Replace the given object by an object, @@ -1095,17 +1154,6 @@ module GEOM in boolean theCopy, in boolean theReverse); - /*! - * \brief Transform the shape in the same way what was used for the sample shape creation. - * \param theObject The object to be transformed. - * \param theSample The object containing information about required transformation. - * \note Implementation of this method is limited by multi-transformations now. - * \note Internal method. - * \return New GEOM_Object, containing the transformed shape. - */ - GEOM_Object TransformLikeOtherCopy (in GEOM_Object theObject, - in GEOM_Object theSample); - /*! * \brief Recompute the shape from its arguments. * \param theObject The object to be recomputed. @@ -1793,6 +1841,14 @@ module GEOM */ long GetSubShapeIndex (in GEOM_Object theMainShape, in GEOM_Object theSubShape); + /*! + * Get global indices of \a theSubShapes in \a theMainShape. + * \param theMainShape Main shape. + * \param theSubShapes List of sub-shapes of the main shape. + * \return list of global indices of \a theSubShapes in \a theMainShape. + */ + ListOfLong GetSubShapesIndices (in GEOM_Object theMainShape, in ListOfGO theSubShapes); + /*! * \brief Get index of \a theSubShape in \a theMainShape, unique among sub-shapes of the same type. * @@ -2804,6 +2860,17 @@ module GEOM in boolean theIsClosed, in boolean theDoReordering); + /*! + * \brief Create B-Spline curve on the set of points. + * \param thePoints Sequence of points for the B-Spline curve. + * \param theFirstVec Vector object, defining the curve direction at its first point. + * \param theLastVec Vector object, defining the curve direction at its last point. + * \return New GEOM_Object, containing the created B-Spline curve. + */ + GEOM_Object MakeSplineInterpolWithTangents (in ListOfGO thePoints, + in GEOM_Object theFirstVec, + in GEOM_Object theLastVec); + /*! * \brief Creates a curve using the parametric definition of the basic points. * \param thexExpr parametric equation of the coordinates X. @@ -3547,6 +3614,13 @@ module GEOM out double Ymin, out double Ymax, out double Zmin, out double Zmax); + /*! + * \brief Get bounding box of the given shape + * \param theShape Shape to obtain bounding box of. + * \return New GEOM_Object, containing the created bounding box. + */ + GEOM_Object MakeBoundingBox (in GEOM_Object theShape); + /*! * \brief Get min and max tolerances of sub-shapes of theShape * \param theShape Shape, to get tolerances of. @@ -3622,6 +3696,16 @@ module GEOM out double X1, out double Y1, out double Z1, out double X2, out double Y2, out double Z2); + /*! + * \brief Get closest points of the given shapes. + * \param theShape1,theShape2 Shapes to find closest points of. + * \param theCoords Output. List of (X, Y, Z) coordinates for all couples of points. + * \return The number of found solutions (-1 in case of infinite number of solutions). + */ + long ClosestPoints (in GEOM_Object theShape1, + in GEOM_Object theShape2, + out ListOfDouble theCoords); + /*! * \brief Get angle between the given lines or linear edges. * \param theShape1,theShape2 Shapes to find angle between. Lines or linear edges. diff --git a/resources/SalomeApp.xml.in b/resources/SalomeApp.xml.in index 6fb716e5a..2925e464d 100644 --- a/resources/SalomeApp.xml.in +++ b/resources/SalomeApp.xml.in @@ -51,6 +51,7 @@ + @@ -58,10 +59,13 @@ + + + diff --git a/src/ARCHIMEDE/Archimede_VolumeSection.cxx b/src/ARCHIMEDE/Archimede_VolumeSection.cxx index 0aee99aad..2d62cdc5e 100644 --- a/src/ARCHIMEDE/Archimede_VolumeSection.cxx +++ b/src/ARCHIMEDE/Archimede_VolumeSection.cxx @@ -24,7 +24,6 @@ // File : Archimede_VolumeSection.cxx // Author : Nicolas REJNERI // Module : GEOM -// $Header$ // #include "Archimede_VolumeSection.hxx" #include "utilities.h" diff --git a/src/ARCHIMEDE/Archimede_VolumeSection.hxx b/src/ARCHIMEDE/Archimede_VolumeSection.hxx index 183443788..158a26d15 100644 --- a/src/ARCHIMEDE/Archimede_VolumeSection.hxx +++ b/src/ARCHIMEDE/Archimede_VolumeSection.hxx @@ -24,7 +24,6 @@ // File : Archimede_VolumeSection.hxx // Author : Nicolas REJNERI // Module : GEOM -// $Header$ // #ifndef ARCHIMEDE_VOLUMESECTION_HXX #define ARCHIMEDE_VOLUMESECTION_HXX diff --git a/src/ARCHIMEDE/Makefile.am b/src/ARCHIMEDE/Makefile.am index 84d1a3560..35fcf539d 100644 --- a/src/ARCHIMEDE/Makefile.am +++ b/src/ARCHIMEDE/Makefile.am @@ -22,7 +22,6 @@ # Author : Nicolas REJNERI # Modified by : Alexander BORODIN (OCN) - autotools usage # Module : GEOM -# $Header$ # include $(top_srcdir)/adm_local/unix/make_common_starter.am diff --git a/src/BREPExport/BREPExport.cxx b/src/BREPExport/BREPExport.cxx index 6c125cac0..7bd879a3a 100644 --- a/src/BREPExport/BREPExport.cxx +++ b/src/BREPExport/BREPExport.cxx @@ -58,8 +58,9 @@ extern "C" { -BREPEXPORT_EXPORT - int Export(const TopoDS_Shape& theShape, const TCollection_AsciiString& theFileName) + BREPEXPORT_EXPORT int Export (const TopoDS_Shape& theShape, + const TCollection_AsciiString& theFileName, + const TCollection_AsciiString& /*theFormatName*/) { MESSAGE("Export BREP into file " << theFileName.ToCString()); diff --git a/src/BREPExport/Makefile.am b/src/BREPExport/Makefile.am index 94f4ed160..675fe466e 100644 --- a/src/BREPExport/Makefile.am +++ b/src/BREPExport/Makefile.am @@ -21,7 +21,6 @@ # Author : Pavel TELKOV # Modified by : Alexander BORODIN (OCN) - autotools usage # Module : GEOM -# $Header$ # include $(top_srcdir)/adm_local/unix/make_common_starter.am diff --git a/src/BREPImport/Makefile.am b/src/BREPImport/Makefile.am index f531040e4..083bc7dc0 100644 --- a/src/BREPImport/Makefile.am +++ b/src/BREPImport/Makefile.am @@ -21,7 +21,6 @@ # Author : Pavel TELKOV # Modified by : Alexander BORODIN (OCN) - autotools usage # Module : GEOM -# $Header$ # include $(top_srcdir)/adm_local/unix/make_common_starter.am diff --git a/src/BasicGUI/BasicGUI_CircleDlg.cxx b/src/BasicGUI/BasicGUI_CircleDlg.cxx index b69c3660c..90488fa74 100644 --- a/src/BasicGUI/BasicGUI_CircleDlg.cxx +++ b/src/BasicGUI/BasicGUI_CircleDlg.cxx @@ -280,7 +280,6 @@ void BasicGUI_CircleDlg::ConstructorsClicked( int constructorId ) qApp->processEvents(); updateGeometry(); resize( minimumSizeHint() ); - SelectionIntoArgument(); myEditCurrentArgument->setFocus(); globalSelection(); // close local contexts, if any @@ -289,7 +288,7 @@ void BasicGUI_CircleDlg::ConstructorsClicked( int constructorId ) connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - displayPreview(true); + SelectionIntoArgument(); } //================================================================================= diff --git a/src/BasicGUI/BasicGUI_CurveDlg.cxx b/src/BasicGUI/BasicGUI_CurveDlg.cxx index c964983ae..14b23a858 100644 --- a/src/BasicGUI/BasicGUI_CurveDlg.cxx +++ b/src/BasicGUI/BasicGUI_CurveDlg.cxx @@ -18,7 +18,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// // GEOM GEOMGUI : GUI for Geometry component // File : BasicGUI_CurveDlg.cxx @@ -59,66 +58,101 @@ BasicGUI_CurveDlg::BasicGUI_CurveDlg( GeometryGUI* theGeometryGUI, QWidget* pare bool modal, Qt::WindowFlags fl ) : GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl ) { - QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_POLYLINE" ) ) ); - QPixmap image2( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_SPLINE" ) ) ); - QPixmap image3( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_BEZIER" ) ) ); - QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) ); + QPixmap image0 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_POLYLINE"))); + QPixmap image2 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_SPLINE"))); + QPixmap image3 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_BEZIER"))); + QPixmap image1 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT"))); - setWindowTitle( tr( "GEOM_CURVE_TITLE" ) ); + setWindowTitle(tr("GEOM_CURVE_TITLE")); /***************************************************************/ - mainFrame()->RadioButton1->setIcon( image0 ); - mainFrame()->RadioButton2->setIcon( image3 ); - mainFrame()->RadioButton3->setIcon( image2 ); + mainFrame()->RadioButton1->setIcon(image0); + mainFrame()->RadioButton2->setIcon(image3); + mainFrame()->RadioButton3->setIcon(image2); - QGroupBox* creationModeCroup = new QGroupBox(this); - QButtonGroup* bg = new QButtonGroup(this); + // Creation mode + QGroupBox* creationModeGroup = new QGroupBox (this); + QButtonGroup* bg = new QButtonGroup (this); - creationModeCroup->setTitle( tr( "GEOM_CURVE_CRMODE" ) ); - QHBoxLayout * creationModeLayout = new QHBoxLayout(creationModeCroup); - myBySelectionBtn = new QRadioButton( tr( "GEOM_CURVE_SELECTION" ) ,creationModeCroup ); - myAnaliticalBtn = new QRadioButton( tr( "GEOM_CURVE_ANALITICAL" ) ,creationModeCroup ); + creationModeGroup->setTitle(tr("GEOM_CURVE_CRMODE")); + QHBoxLayout * creationModeLayout = new QHBoxLayout (creationModeGroup); + myBySelectionBtn = new QRadioButton (tr("GEOM_CURVE_SELECTION") ,creationModeGroup); + myAnaliticalBtn = new QRadioButton (tr("GEOM_CURVE_ANALITICAL") ,creationModeGroup); bg->addButton(myBySelectionBtn); bg->addButton(myAnaliticalBtn); - + creationModeLayout->addWidget(myBySelectionBtn); creationModeLayout->addWidget(myAnaliticalBtn); - GroupPoints = new DlgRef_1Sel3Check( centralWidget() ); - - GroupPoints->GroupBox1->setTitle( tr( "GEOM_NODES" ) ); - GroupPoints->TextLabel1->setText( tr( "GEOM_POINTS" ) ); - GroupPoints->PushButton1->setIcon( image1 ); - GroupPoints->PushButton1->setDown( true ); - - GroupPoints->LineEdit1->setReadOnly( true ); - - GroupPoints->CheckButton1->setText( tr( "GEOM_IS_CLOSED" ) ); - GroupPoints->CheckButton1->setChecked(false); - //GroupPoints->CheckButton1->hide(); - - GroupPoints->CheckButton2->setText( tr( "GEOM_IS_REORDER" ) ); - GroupPoints->CheckButton2->setChecked(false); - GroupPoints->CheckButton2->hide(); - - GroupPoints->CheckButton3->hide(); - - myParams = new BasicGUI_ParamCurveWidget( centralWidget() ); - - QVBoxLayout* layout = new QVBoxLayout( centralWidget() ); - layout->setMargin( 0 ); layout->setSpacing( 6 ); - layout->addWidget( creationModeCroup ); - layout->addWidget( GroupPoints ); - layout->addWidget( myParams ); + // Points and flags + myGroupPoints = new DlgRef_1Sel3Check (centralWidget()); + + myGroupPoints->GroupBox1->setTitle(tr("GEOM_NODES")); + myGroupPoints->TextLabel1->setText(tr("GEOM_POINTS")); + myGroupPoints->PushButton1->setIcon(image1); + myGroupPoints->PushButton1->setDown(true); + + myGroupPoints->LineEdit1->setReadOnly( true ); + + myGroupPoints->CheckButton1->setText( tr( "GEOM_IS_CLOSED" ) ); + myGroupPoints->CheckButton1->setChecked(false); + //myGroupPoints->CheckButton1->hide(); + + myGroupPoints->CheckButton2->setText( tr( "GEOM_IS_REORDER" ) ); + myGroupPoints->CheckButton2->setChecked(false); + myGroupPoints->CheckButton2->hide(); + + myGroupPoints->CheckButton3->hide(); + + // Parametrical mode + myGroupParams = new BasicGUI_ParamCurveWidget( centralWidget() ); + + // Tangents (only for Interpolation constructor and only not closed and no reordering) + myGroupTangents = new QGroupBox (this); + myGroupTangents->setCheckable(true); + myGroupTangents->setChecked(false); + myGroupTangents->setTitle(tr("GEOM_INTERPOL_TANGENTS")); + + QGridLayout* tangentsLayout = new QGridLayout (myGroupTangents); + + myPushBtnV1 = new QPushButton (myGroupTangents); + myPushBtnV2 = new QPushButton (myGroupTangents); + myPushBtnV1->setIcon(image1); + myPushBtnV2->setIcon(image1); + + myLineEditV1 = new QLineEdit (myGroupTangents); + myLineEditV2 = new QLineEdit (myGroupTangents); + myLineEditV1->setReadOnly(true); + myLineEditV2->setReadOnly(true); + + QLabel* aTextLabelV1 = new QLabel (myGroupTangents); + QLabel* aTextLabelV2 = new QLabel (myGroupTangents); + aTextLabelV1->setText(tr("GEOM_INTERPOL_FIRST_VEC")); + aTextLabelV2->setText(tr("GEOM_INTERPOL_LAST_VEC")); + + tangentsLayout->addWidget(aTextLabelV1, 0, 0); + tangentsLayout->addWidget(myPushBtnV1 , 0, 1); + tangentsLayout->addWidget(myLineEditV1, 0, 2); + tangentsLayout->addWidget(aTextLabelV2, 1, 0); + tangentsLayout->addWidget(myPushBtnV2 , 1, 1); + tangentsLayout->addWidget(myLineEditV2, 1, 2); + + // Layout + QVBoxLayout* layout = new QVBoxLayout (centralWidget()); + layout->setMargin(0); + layout->setSpacing(6); + layout->addWidget(creationModeGroup); + layout->addWidget(myGroupPoints); + layout->addWidget(myGroupParams); + layout->addWidget(myGroupTangents); /***************************************************************/ - setHelpFileName( "create_curve_page.html" ); + setHelpFileName("create_curve_page.html"); Init(); } - //================================================================================= // function : ~BasicGUI_CurveDlg() // purpose : Destroys the object and frees any allocated resources @@ -127,7 +161,6 @@ BasicGUI_CurveDlg::~BasicGUI_CurveDlg() { } - //================================================================================= // function : Init() // purpose : @@ -135,13 +168,6 @@ BasicGUI_CurveDlg::~BasicGUI_CurveDlg() void BasicGUI_CurveDlg::Init() { /* init variables */ - myEditCurrentArgument = GroupPoints->LineEdit1; - - myPoints.clear(); - - globalSelection(); // close local contexts, if any - localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); - showOnlyPreviewControl(); myBySelectionBtn->setChecked(true); @@ -152,87 +178,95 @@ void BasicGUI_CurveDlg::Init() double aMax( 100. ), aMin( 0.0 ); /* min, max, step and decimals for spin boxes & initial values */ - initSpinBox( myParams->myPMin, COORD_MIN, COORD_MAX, step, "length_precision" ); - initSpinBox( myParams->myPMax, COORD_MIN, COORD_MAX, step, "length_precision" ); - myParams->myPStep->setValue( 10 ); - myParams->myPStep->setMaximum( 999 ); - myParams->myPStep->setSingleStep( 10 ); - myParams->myPMin->setValue( aMin ); - myParams->myPMax->setValue( aMax ); - myParams->myPStep->setValue( step ); - myParams->myXExpr->setText("t"); - myParams->myYExpr->setText("t"); - myParams->myZExpr->setText("t"); - - myParams->hide(); + initSpinBox( myGroupParams->myPMin, COORD_MIN, COORD_MAX, step, "length_precision" ); + initSpinBox( myGroupParams->myPMax, COORD_MIN, COORD_MAX, step, "length_precision" ); + myGroupParams->myPStep->setValue( 10 ); + myGroupParams->myPStep->setMaximum( 999 ); + myGroupParams->myPStep->setSingleStep( 10 ); + myGroupParams->myPMin->setValue( aMin ); + myGroupParams->myPMax->setValue( aMax ); + myGroupParams->myPStep->setValue( step ); + myGroupParams->myXExpr->setText("t"); + myGroupParams->myYExpr->setText("t"); + myGroupParams->myZExpr->setText("t"); + + myGroupParams->hide(); /* signals and slots connections */ - connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog( ) ) ); - connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ), 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(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply())); - connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) ); + connect(this, SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int))); - connect( GroupPoints->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); + connect(myGroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(myPushBtnV1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(myPushBtnV2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect( GroupPoints->CheckButton1, SIGNAL( toggled(bool) ), this, SLOT( CheckButtonToggled() ) ); - connect( GroupPoints->CheckButton2, SIGNAL( toggled(bool) ), this, SLOT( CheckButtonToggled() ) ); + connect(myGroupPoints->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(CheckButtonToggled())); + connect(myGroupPoints->CheckButton2, SIGNAL(toggled(bool)), this, SLOT(CheckButtonToggled())); + connect(myGroupTangents, SIGNAL(toggled(bool)), this, SLOT(CheckButtonToggled())); - connect( myGeomGUI->getApp()->selectionMgr(), - SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); - connect( myBySelectionBtn, SIGNAL( clicked() ), this, SLOT( CreationModeChanged() ) ); - connect( myAnaliticalBtn, SIGNAL( clicked() ), this, SLOT( CreationModeChanged() ) ); + connect(myBySelectionBtn, SIGNAL(clicked()), this, SLOT(CreationModeChanged())); + connect(myAnaliticalBtn, SIGNAL(clicked()), this, SLOT(CreationModeChanged())); - connect(myParams->myPMin, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(myParams->myPMax, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(myParams->myPStep, SIGNAL(valueChanged(int)), this, SLOT(ValueChangedInSpinBox(int))); + connect(myGroupParams->myPMin, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(myGroupParams->myPMax, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(myGroupParams->myPStep, SIGNAL(valueChanged(int)), this, SLOT(ValueChangedInSpinBox(int))); - connect(myParams->myXExpr, SIGNAL(editingFinished()), this, SLOT(OnEditingFinished())); - connect(myParams->myYExpr, SIGNAL(editingFinished()), this, SLOT(OnEditingFinished())); - connect(myParams->myZExpr, SIGNAL(editingFinished()), this, SLOT(OnEditingFinished())); + connect(myGroupParams->myXExpr, SIGNAL(editingFinished()), this, SLOT(OnEditingFinished())); + connect(myGroupParams->myYExpr, SIGNAL(editingFinished()), this, SLOT(OnEditingFinished())); + connect(myGroupParams->myZExpr, SIGNAL(editingFinished()), this, SLOT(OnEditingFinished())); - initName( tr( "GEOM_CURVE" ) ); - resize(100,100); - ConstructorsClicked( 0 ); + initName(tr("GEOM_CURVE")); + //resize(100, 100); + ConstructorsClicked(0); } //================================================================================= // function : ConstructorsClicked() // purpose : //================================================================================= -void BasicGUI_CurveDlg::ConstructorsClicked( int id ) +void BasicGUI_CurveDlg::ConstructorsClicked (int id) { - QString aTitle = tr( id == 0 ? "GEOM_POLYLINE" : id == 1 ? "GEOM_BEZIER" : "GEOM_INTERPOL" ); - mainFrame()->GroupConstructors->setTitle( aTitle ); + QString aTitle = tr(id == 0 ? "GEOM_POLYLINE" : id == 1 ? "GEOM_BEZIER" : "GEOM_INTERPOL"); + mainFrame()->GroupConstructors->setTitle(aTitle); if (id == 0) { // polyline (wire) - //GroupPoints->CheckButton1->hide(); - GroupPoints->CheckButton1->setText( tr( "GEOM_BUILD_CLOSED_WIRE" ) ); - GroupPoints->CheckButton2->hide(); + myGroupPoints->CheckButton1->setText( tr( "GEOM_BUILD_CLOSED_WIRE" ) ); + myGroupPoints->CheckButton2->hide(); + myGroupTangents->hide(); } else if (id == 1) { // bezier - //GroupPoints->CheckButton1->hide(); - GroupPoints->CheckButton1->setText( tr( "GEOM_IS_CLOSED" ) ); - GroupPoints->CheckButton2->hide(); + myGroupPoints->CheckButton1->setText( tr( "GEOM_IS_CLOSED" ) ); + myGroupPoints->CheckButton2->hide(); + myGroupTangents->hide(); } else { // b-spline - //GroupPoints->CheckButton1->show(); - GroupPoints->CheckButton1->setText( tr( "GEOM_IS_CLOSED" ) ); - GroupPoints->CheckButton2->show(); + myGroupPoints->CheckButton1->setText( tr( "GEOM_IS_CLOSED" ) ); + myGroupPoints->CheckButton2->show(); + myGroupTangents->setVisible(myBySelectionBtn->isChecked()); } myPoints.clear(); + myVec1.nullify(); + myVec2.nullify(); + + myGroupPoints->LineEdit1->setText(""); + myLineEditV1->setText(""); + myLineEditV2->setText(""); - myEditCurrentArgument->setText( "" ); qApp->processEvents(); updateGeometry(); - resize( minimumSizeHint() ); - SelectionIntoArgument(); -} + resize(minimumSizeHint()); + myGroupPoints->PushButton1->click(); +} //================================================================================= // function : SetEditCurrentArgument() @@ -240,9 +274,28 @@ void BasicGUI_CurveDlg::ConstructorsClicked( int id ) //================================================================================= void BasicGUI_CurveDlg::SetEditCurrentArgument() { - if ( sender() == GroupPoints->PushButton1 ) - myEditCurrentArgument = GroupPoints->LineEdit1; + disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); + + globalSelection(); // close local contexts, if any + + if (sender() == myGroupPoints->PushButton1) { + myEditCurrentArgument = myGroupPoints->LineEdit1; + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX); + } + else if (sender() == myPushBtnV1) { + myEditCurrentArgument = myLineEditV1; + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE); + } + else if (sender() == myPushBtnV2) { + myEditCurrentArgument = myLineEditV2; + localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE); + } + myEditCurrentArgument->setFocus(); + + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); + SelectionIntoArgument(); } @@ -252,7 +305,20 @@ void BasicGUI_CurveDlg::SetEditCurrentArgument() //================================================================================= void BasicGUI_CurveDlg::CheckButtonToggled() { - processPreview(); + if (sender() == myGroupTangents) { + if (myGroupTangents->isChecked()) + myPushBtnV1->click(); + else + myGroupPoints->PushButton1->click(); + } + else { + if (getConstructorId() == 2) { // Interpolation + bool disableTangents = (myGroupPoints->CheckButton1->isChecked() || + myGroupPoints->CheckButton2->isChecked()); + myGroupTangents->setEnabled(!disableTangents); + } + processPreview(); + } } //================================================================================= @@ -261,8 +327,8 @@ void BasicGUI_CurveDlg::CheckButtonToggled() //================================================================================= void BasicGUI_CurveDlg::ClickOnOk() { - setIsApplyAndClose( true ); - if ( ClickOnApply() ) + setIsApplyAndClose(true); + if (ClickOnApply()) ClickOnCancel(); } @@ -272,20 +338,23 @@ void BasicGUI_CurveDlg::ClickOnOk() //================================================================================= bool BasicGUI_CurveDlg::ClickOnApply() { - if ( !onAccept() ) + if (!onAccept()) return false; initName(); - globalSelection(); // close local contexts, if any - localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); + ConstructorsClicked(getConstructorId()); return true; } -static void synchronize( QList& left, QList& right ) +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +static void synchronize (QList& left, QList& right) { // 1. remove items from the "left" list that are not in the "right" list - QMutableListIterator it1( left ); - while ( it1.hasNext() ) { + QMutableListIterator it1 (left); + while (it1.hasNext()) { GEOM::GeomObjPtr o1 = it1.next(); bool found = false; QMutableListIterator it2( right ); @@ -307,22 +376,38 @@ static void synchronize( QList& left, QList& } } -//================================================================================= -// function : SelectionIntoArgument() -// purpose : Called when selection as changed or other case -//================================================================================= void BasicGUI_CurveDlg::SelectionIntoArgument() { - QList points = getSelected( TopAbs_VERTEX, -1 ); - synchronize( myPoints, points ); - if ( !myPoints.isEmpty() ) - GroupPoints->LineEdit1->setText( QString::number( myPoints.count() ) + "_" + tr( "GEOM_POINT" ) + tr( "_S_" ) ); - else - GroupPoints->LineEdit1->setText( "" ); + myEditCurrentArgument->setText(""); + + if (myEditCurrentArgument == myGroupPoints->LineEdit1) { + QList points = getSelected(TopAbs_VERTEX, -1); + synchronize(myPoints, points); + if (!myPoints.isEmpty()) + myGroupPoints->LineEdit1->setText(QString::number(myPoints.count()) + "_" + + tr("GEOM_POINT") + tr("_S_")); + } + else { + QList vecs = getSelected(TopAbs_EDGE, -1); + if (vecs.count() != 1) { + if (myEditCurrentArgument == myLineEditV1) myVec1.nullify(); + else if (myEditCurrentArgument == myLineEditV2) myVec2.nullify(); + } + else { + if (myEditCurrentArgument == myLineEditV1) { + myVec1 = vecs.first(); + } + else if (myEditCurrentArgument == myLineEditV2) { + myVec2 = vecs.first(); + } + QString aName = GEOMBase::GetName(vecs.first().get()); + myEditCurrentArgument->setText(aName); + } + } + processPreview(); } - //================================================================================= // function : ActivateThisDialog() // purpose : @@ -330,13 +415,11 @@ void BasicGUI_CurveDlg::SelectionIntoArgument() void BasicGUI_CurveDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); - connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), - this, SLOT( SelectionIntoArgument() ) ); - globalSelection(); // close local contexts, if any - localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX ); + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); - ConstructorsClicked( getConstructorId() ); + ConstructorsClicked(getConstructorId()); } //================================================================================= @@ -353,9 +436,9 @@ void BasicGUI_CurveDlg::DeactivateActiveDialog() // function : enterEvent() // purpose : //================================================================================= -void BasicGUI_CurveDlg::enterEvent( QEvent* ) +void BasicGUI_CurveDlg::enterEvent (QEvent*) { - if ( !mainFrame()->GroupConstructors->isEnabled() ) + if (!mainFrame()->GroupConstructors->isEnabled()) ActivateThisDialog(); } @@ -365,24 +448,34 @@ void BasicGUI_CurveDlg::enterEvent( QEvent* ) //================================================================================= GEOM::GEOM_IOperations_ptr BasicGUI_CurveDlg::createOperation() { - return myGeomGUI->GetGeomGen()->GetICurvesOperations( getStudyId() ); + return myGeomGUI->GetGeomGen()->GetICurvesOperations(getStudyId()); } //================================================================================= // function : isValid // purpose : //================================================================================= -bool BasicGUI_CurveDlg::isValid( QString& msg ) +bool BasicGUI_CurveDlg::isValid (QString& msg) { - if( myBySelectionBtn->isChecked() ) - return myPoints.count() > 1; + if (myBySelectionBtn->isChecked()) { + bool ok = true; + if (getConstructorId() == 2) { // Interpolation + bool disableTangents = (myGroupPoints->CheckButton1->isChecked() || + myGroupPoints->CheckButton2->isChecked()); + if (!disableTangents && myGroupTangents->isChecked()) { + ok = (myVec1 && myVec2); + if (!ok) msg = tr("GEOM_BOTH_TANGENTS_REQUIRED"); + } + } + return ok && myPoints.count() > 1; + } else { - bool ok = myParams->myPMin->isValid( msg, !IsPreview() ) && - myParams->myPMax->isValid( msg, !IsPreview() ) && - myParams->myPStep->isValid( msg, !IsPreview() ); - ok &= !myParams->myXExpr->text().isEmpty(); - ok &= !myParams->myYExpr->text().isEmpty(); - ok &= !myParams->myZExpr->text().isEmpty(); + bool ok = myGroupParams->myPMin->isValid( msg, !IsPreview() ) && + myGroupParams->myPMax->isValid( msg, !IsPreview() ) && + myGroupParams->myPStep->isValid( msg, !IsPreview() ); + ok &= !myGroupParams->myXExpr->text().isEmpty(); + ok &= !myGroupParams->myYExpr->text().isEmpty(); + ok &= !myGroupParams->myZExpr->text().isEmpty(); return ok; } } @@ -391,79 +484,85 @@ bool BasicGUI_CurveDlg::isValid( QString& msg ) // function : execute // purpose : //================================================================================= -bool BasicGUI_CurveDlg::execute( ObjectList& objects ) +bool BasicGUI_CurveDlg::execute (ObjectList& objects) { bool res = false; GEOM::GEOM_Object_var anObj; - GEOM::GEOM_ICurvesOperations_var anOper = GEOM::GEOM_ICurvesOperations::_narrow( getOperation() ); + GEOM::GEOM_ICurvesOperations_var anOper = GEOM::GEOM_ICurvesOperations::_narrow(getOperation()); GEOM::ListOfGO_var points = new GEOM::ListOfGO(); - points->length( myPoints.count() ); - for ( int i = 0; i < myPoints.count(); i++ ) + points->length(myPoints.count()); + for (int i = 0; i < myPoints.count(); i++) points[i] = myPoints[i].copy(); - switch ( getConstructorId() ) { + switch (getConstructorId()) { case 0 : - if( myBySelectionBtn->isChecked() ) - anObj = anOper->MakePolyline( points.in(), GroupPoints->CheckButton1->isChecked() ); + if (myBySelectionBtn->isChecked()) + anObj = anOper->MakePolyline(points.in(), myGroupPoints->CheckButton1->isChecked()); else - anObj = anOper->MakeCurveParametricNew(qPrintable(myParams->myXExpr->text()), - qPrintable(myParams->myYExpr->text()), - qPrintable(myParams->myZExpr->text()), - myParams->myPMin->value(), - myParams->myPMax->value(), - myParams->myPStep->value(), - GEOM::Polyline); + anObj = anOper->MakeCurveParametricNew(qPrintable(myGroupParams->myXExpr->text()), + qPrintable(myGroupParams->myYExpr->text()), + qPrintable(myGroupParams->myZExpr->text()), + myGroupParams->myPMin->value(), + myGroupParams->myPMax->value(), + myGroupParams->myPStep->value(), + GEOM::Polyline); res = true; break; case 1 : - if( myBySelectionBtn->isChecked() ) - anObj = anOper->MakeSplineBezier( points.in(), GroupPoints->CheckButton1->isChecked() ); + if (myBySelectionBtn->isChecked()) + anObj = anOper->MakeSplineBezier(points.in(), myGroupPoints->CheckButton1->isChecked()); else - anObj = anOper->MakeCurveParametricNew(qPrintable(myParams->myXExpr->text()), - qPrintable(myParams->myYExpr->text()), - qPrintable(myParams->myZExpr->text()), - myParams->myPMin->value(), - myParams->myPMax->value(), - myParams->myPStep->value(), - GEOM::Bezier); - + anObj = anOper->MakeCurveParametricNew(qPrintable(myGroupParams->myXExpr->text()), + qPrintable(myGroupParams->myYExpr->text()), + qPrintable(myGroupParams->myZExpr->text()), + myGroupParams->myPMin->value(), + myGroupParams->myPMax->value(), + myGroupParams->myPStep->value(), + GEOM::Bezier); res = true; break; case 2 : - if( myBySelectionBtn->isChecked() ) - anObj = anOper->MakeSplineInterpolation( points.in(), GroupPoints->CheckButton1->isChecked(), - GroupPoints->CheckButton2->isChecked() ); + if (myBySelectionBtn->isChecked()) { + bool disableTangents = (myGroupPoints->CheckButton1->isChecked() || + myGroupPoints->CheckButton2->isChecked()); + if (!disableTangents && myGroupTangents->isChecked()) { + anObj = anOper->MakeSplineInterpolWithTangents(points.in(), myVec1.get(), myVec2.get()); + } + else + anObj = anOper->MakeSplineInterpolation(points.in(), myGroupPoints->CheckButton1->isChecked(), + myGroupPoints->CheckButton2->isChecked()); + } else - anObj = anOper->MakeCurveParametricNew(qPrintable(myParams->myXExpr->text()), - qPrintable(myParams->myYExpr->text()), - qPrintable(myParams->myZExpr->text()), - myParams->myPMin->value(), - myParams->myPMax->value(), - myParams->myPStep->value(), - GEOM::Interpolation); + anObj = anOper->MakeCurveParametricNew(qPrintable(myGroupParams->myXExpr->text()), + qPrintable(myGroupParams->myYExpr->text()), + qPrintable(myGroupParams->myZExpr->text()), + myGroupParams->myPMin->value(), + myGroupParams->myPMax->value(), + myGroupParams->myPStep->value(), + GEOM::Interpolation); res = true; break; } - if ( !anObj->_is_nil() ) { - if(myAnaliticalBtn->isChecked() && !IsPreview()) { + if (!anObj->_is_nil()) { + if (myAnaliticalBtn->isChecked() && !IsPreview()) { QStringList aParameters; - aParameters<myPMin->text(); - aParameters<myPMax->text(); - aParameters<myPStep->text(); + aParameters<myPMin->text(); + aParameters<myPMax->text(); + aParameters<myPStep->text(); anObj->SetParameters(aParameters.join(":").toLatin1().constData()); } - objects.push_back( anObj._retn() ); + objects.push_back(anObj._retn()); } - + return res; } //================================================================================= -// function : addSubshapeToStudy +// function : addSubshapesToStudy // purpose : virtual method to add new SubObjects if local selection //================================================================================= void BasicGUI_CurveDlg::addSubshapesToStudy() @@ -476,19 +575,20 @@ void BasicGUI_CurveDlg::addSubshapesToStudy() // function : CreationModeChanged // purpose : //================================================================================= -void BasicGUI_CurveDlg::CreationModeChanged() { +void BasicGUI_CurveDlg::CreationModeChanged() +{ const QObject* s = sender(); - GroupPoints->setVisible(myBySelectionBtn == s); - myParams->setVisible(myBySelectionBtn != s); - - ConstructorsClicked( getConstructorId() ); + myGroupPoints->setVisible(myBySelectionBtn == s); + myGroupParams->setVisible(myBySelectionBtn != s); + + ConstructorsClicked(getConstructorId()); } //================================================================================= // function : ValueChangedInSpinBox() // purpose : //================================================================================= -void BasicGUI_CurveDlg::ValueChangedInSpinBox(double/*theValue*/) +void BasicGUI_CurveDlg::ValueChangedInSpinBox (double/*theValue*/) { processPreview(); } @@ -497,15 +597,16 @@ void BasicGUI_CurveDlg::ValueChangedInSpinBox(double/*theValue*/) // function : ValueChangedInSpinBox() // purpose : //================================================================================= -void BasicGUI_CurveDlg::ValueChangedInSpinBox(int/*theValue*/) +void BasicGUI_CurveDlg::ValueChangedInSpinBox (int/*theValue*/) { processPreview(); } //================================================================================= -// function : ValueChangedInSpinBox() +// function : OnEditingFinished() // purpose : //================================================================================= -void BasicGUI_CurveDlg::OnEditingFinished() { +void BasicGUI_CurveDlg::OnEditingFinished() +{ processPreview(); } diff --git a/src/BasicGUI/BasicGUI_CurveDlg.h b/src/BasicGUI/BasicGUI_CurveDlg.h index ce9a6a9e7..8d6751b5e 100644 --- a/src/BasicGUI/BasicGUI_CurveDlg.h +++ b/src/BasicGUI/BasicGUI_CurveDlg.h @@ -18,7 +18,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// // GEOM GEOMGUI : GUI for Geometry component // File : BasicGUI_CurveDlg.h @@ -34,6 +33,9 @@ class DlgRef_1Sel3Check; class QRadioButton; +class QPushButton; +class QLineEdit; +class QGroupBox; class BasicGUI_ParamCurveWidget; //================================================================================= @@ -45,26 +47,34 @@ class BasicGUI_CurveDlg : public GEOMBase_Skeleton Q_OBJECT public: - BasicGUI_CurveDlg( GeometryGUI*, QWidget* = 0, bool = false, Qt::WindowFlags = 0 ); + BasicGUI_CurveDlg (GeometryGUI*, QWidget* = 0, bool = false, Qt::WindowFlags = 0); ~BasicGUI_CurveDlg(); protected: // redefined from GEOMBase_Helper virtual GEOM::GEOM_IOperations_ptr createOperation(); - virtual bool isValid( QString& ); - virtual bool execute( ObjectList& ); + virtual bool isValid (QString&); + virtual bool execute (ObjectList&); virtual void addSubshapesToStudy(); private: void Init(); - void enterEvent( QEvent* ); + void enterEvent (QEvent*); private: - DlgRef_1Sel3Check* GroupPoints; - QList myPoints; QRadioButton* myAnaliticalBtn; QRadioButton* myBySelectionBtn; - BasicGUI_ParamCurveWidget* myParams; + DlgRef_1Sel3Check* myGroupPoints; + BasicGUI_ParamCurveWidget* myGroupParams; + QGroupBox* myGroupTangents; + + QPushButton* myPushBtnV1; + QPushButton* myPushBtnV2; + QLineEdit* myLineEditV1; + QLineEdit* myLineEditV2; + + QList myPoints; + GEOM::GeomObjPtr myVec1, myVec2; private slots: void ClickOnOk(); @@ -73,13 +83,13 @@ private slots: void ActivateThisDialog(); void DeactivateActiveDialog(); - void ConstructorsClicked( int ); + void ConstructorsClicked (int); void CheckButtonToggled(); void SelectionIntoArgument(); void SetEditCurrentArgument(); void CreationModeChanged(); - void ValueChangedInSpinBox(double/*theValue*/); - void ValueChangedInSpinBox(int /*theValue*/); + void ValueChangedInSpinBox (double/*theValue*/); + void ValueChangedInSpinBox (int /*theValue*/); void OnEditingFinished(); }; diff --git a/src/BlockFix/BlockFix.cxx b/src/BlockFix/BlockFix.cxx new file mode 100644 index 000000000..0e4f9bb21 --- /dev/null +++ b/src/BlockFix/BlockFix.cxx @@ -0,0 +1,344 @@ +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 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.com + +// File: BlockFix.cxx +// Created: Tue Dec 7 11:59:05 2004 +// Author: Pavel DURANDIN + +#include + +#include +#include + +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include +#include +#include + +#include + +#include +#include +#include + +#include +#include +#include +#include + +#include + +#include +#include + +#include + +#include +#include +#include +#include +#include + +#include + +#include + +//======================================================================= +//function : FixResult +//purpose : auxilary +//======================================================================= +static void FixResult(const TopoDS_Shape& result, + Handle(ShapeBuild_ReShape)& Context, + const Standard_Real Tol) +{ + for (TopExp_Explorer ex_f(result,TopAbs_FACE); ex_f.More(); ex_f.Next()) { + TopoDS_Shape aShape = Context->Apply(ex_f.Current().Oriented(TopAbs_FORWARD)); + // face coud not be dropped or splitted on this step + TopoDS_Face aFace = TopoDS::Face(aShape); + TopLoc_Location L; + Handle(Geom_Surface) Surf = BRep_Tool::Surface(aFace,L); + + if( Surf->IsKind(STANDARD_TYPE(Geom_SphericalSurface)) || + Surf->IsKind(STANDARD_TYPE(Geom_CylindricalSurface)) ) { + + Standard_Integer nbWires = 0; + for (TopExp_Explorer ex_w(aFace,TopAbs_WIRE); ex_w.More(); ex_w.Next()) { + nbWires++; + Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire(TopoDS::Wire(ex_w.Current()), + aFace, + Precision::Confusion()); + sfw->FixReorder(); + if(sfw->StatusReorder ( ShapeExtend_FAIL )) + continue; + + sfw->SetPrecision(2.*Tol); + sfw->FixShifted(); + + Standard_Boolean isDone = sfw->LastFixStatus ( ShapeExtend_DONE ); + isDone |= sfw->FixDegenerated(); + + // remove degenerated edges from not degenerated points + ShapeAnalysis_Edge sae; + Handle(ShapeExtend_WireData) sewd = sfw->WireData(); + Standard_Integer i; + for( i = 1; i<=sewd->NbEdges();i++) { + TopoDS_Edge E = sewd->Edge(i); + if(BRep_Tool::Degenerated(E)&&!sae.HasPCurve(E,aFace)) { + sewd->Remove(i); + isDone = Standard_True; + i--; + } + } + + //isDone |= sfw->FixLacking(); // commented by skl 22.03.2005 (PAL8395) + + // remove neighbour seam edges + if(isDone) { + for( i = 1; iNbEdges();i++) { + if(sewd->IsSeam(i) && sewd->IsSeam(i+1)) { + isDone = Standard_True; + sewd->Remove(i); + sewd->Remove(i); + i--; + } + } + if(sewd->IsSeam(1) && sewd->IsSeam(sewd->NbEdges())) { + sewd->Remove(1); + sewd->Remove(sewd->NbEdges()); + } + } + + if(isDone) { + TopoDS_Wire ResWire = sfw->Wire(); + Context->Replace(ex_w.Current(), ResWire); + }; + } + // Implement fix orientation in case of several wires + if(nbWires > 1) { + TopoDS_Face aFixedFace = TopoDS::Face(Context->Apply(aFace)); + Handle(ShapeFix_Face) sff = new ShapeFix_Face(aFixedFace); + if(sff->FixOrientation()) + Context->Replace(aFixedFace,sff->Face()); + } + } + } +} + +//======================================================================= +//function : RotateSphereSpace +//purpose : +//======================================================================= +TopoDS_Shape BlockFix::RotateSphereSpace (const TopoDS_Shape& S, + const Standard_Real Tol) +{ + // Create a modification description + Handle(BlockFix_SphereSpaceModifier) SR = new BlockFix_SphereSpaceModifier; + SR->SetTolerance(Tol); + + TopTools_DataMapOfShapeShape context; + BRepTools_Modifier MD; + TopoDS_Shape result = ShapeCustom::ApplyModifier ( S, SR, context,MD ); + + Handle(ShapeBuild_ReShape) RS = new ShapeBuild_ReShape; + FixResult(result,RS,Tol); + result = RS->Apply(result); + + ShapeFix_Edge sfe; + for(TopExp_Explorer exp(result,TopAbs_EDGE); exp.More(); exp.Next()) { + TopoDS_Edge E = TopoDS::Edge(exp.Current()); + sfe.FixVertexTolerance (E); + } + + ShapeFix::SameParameter(result,Standard_False); + return result; +} + +//======================================================================= +//function : RefillProblemFaces +//purpose : +//======================================================================= +TopoDS_Shape BlockFix::RefillProblemFaces (const TopoDS_Shape& aShape) +{ + Standard_Integer NbSamples = 10; + + TopTools_ListOfShape theFaces; + + TopExp_Explorer Explo(aShape, TopAbs_FACE); + for (; Explo.More(); Explo.Next()) + { + TopoDS_Face aFace = TopoDS::Face(Explo.Current()); + BRepAdaptor_Surface BAsurf(aFace); + GeomAbs_SurfaceType SurfType = BAsurf.GetType(); + if (SurfType >= GeomAbs_BezierSurface) + { + TopExp_Explorer fexp(aFace, TopAbs_EDGE); + for (; fexp.More(); fexp.Next()) + { + const TopoDS_Edge& anEdge = TopoDS::Edge(fexp.Current()); + if (BRep_Tool::Degenerated(anEdge)) + { + TopoDS_Vertex V1, V2; + TopExp::Vertices(anEdge, V1, V2); + if (V1.IsSame(V2)) + { + gp_Pnt aPnt = BRep_Tool::Pnt(V1); + Standard_Real TolV = BRep_Tool::Tolerance(V1); + Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aFace); + Handle(ShapeAnalysis_Surface) Analyser = new ShapeAnalysis_Surface(aSurf); + if (Analyser->IsDegenerated(aPnt, TolV)) + { + theFaces.Append(aFace); + break; + } + } + } + } + } + } + + //Now all problem faces are collected in the list "theFaces" + BRepTools_Substitution aSubst; + TopTools_ListIteratorOfListOfShape itl(theFaces); + for (; itl.More(); itl.Next()) + { + const TopoDS_Face& aFace = TopoDS::Face(itl.Value()); + BRepOffsetAPI_MakeFilling Filler; + for (Explo.Init(aFace, TopAbs_EDGE); Explo.More(); Explo.Next()) + { + const TopoDS_Edge& anEdge = TopoDS::Edge(Explo.Current()); + if (!BRep_Tool::Degenerated(anEdge)) + Filler.Add(anEdge, GeomAbs_C0); + } + Standard_Real Umin, Umax, Vmin, Vmax; + BRepTools::UVBounds(aFace, Umin, Umax, Vmin, Vmax); + //Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aFace); + Standard_Integer i, j; + for (i = 1; i < NbSamples; i++) + for (j = 1; j < NbSamples; j++) { + /* + gp_Pnt aPoint = aSurf->Value(Umin + i*(Umax-Umin)/NbSamples, + Vmin + j*(Vmax-Vmin)/NbSamples); + Filler.Add(aPoint); + */ + Filler.Add(Umin + i*(Umax-Umin)/NbSamples, + Vmin + j*(Vmax-Vmin)/NbSamples, + aFace, GeomAbs_G1); + } + + Filler.Build(); + if (Filler.IsDone()) + { + for (Explo.Init(aFace, TopAbs_EDGE); Explo.More(); Explo.Next()) + { + const TopoDS_Edge& anEdge = TopoDS::Edge(Explo.Current()); + TopTools_ListOfShape Ledge; + if (!BRep_Tool::Degenerated(anEdge)) + { + const TopTools_ListOfShape& Ledges = Filler.Generated(anEdge); + if (!Ledges.IsEmpty()) { + TopoDS_Shape NewEdge = Ledges.First(); + Ledge.Append(NewEdge.Oriented(TopAbs_FORWARD)); + } + } + aSubst.Substitute(anEdge, Ledge); + } + TopTools_ListOfShape Lface; + TopoDS_Face NewFace = TopoDS::Face(Filler.Shape()); + NewFace.Orientation(TopAbs_FORWARD); + BRepAdaptor_Surface NewBAsurf(NewFace); + gp_Pnt MidPnt; + gp_Vec D1U, D1V, Normal, NewNormal; + Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aFace); + aSurf->D1((Umin+Umax)*0.5, (Vmin+Vmax)*0.5, MidPnt, D1U, D1V); + Normal = D1U ^ D1V; + NewBAsurf.D1((NewBAsurf.FirstUParameter() + NewBAsurf.LastUParameter())*0.5, + (NewBAsurf.FirstVParameter() + NewBAsurf.LastVParameter())*0.5, + MidPnt, D1U, D1V); + NewNormal = D1U ^ D1V; + if (Normal * NewNormal < 0.) + NewFace.Reverse(); + Lface.Append(NewFace); + aSubst.Substitute(aFace, Lface); + } + } + aSubst.Build(aShape); + + TopoDS_Shape Result = aShape; + if (aSubst.IsCopied(aShape)) + Result = aSubst.Copy(aShape).First(); + + BRepTools::RemoveUnusedPCurves(Result); + + return Result; +} + +//======================================================================= +//function : FixRanges +//purpose : +//======================================================================= +TopoDS_Shape BlockFix::FixRanges (const TopoDS_Shape& S, + const Standard_Real Tol) +{ + // Create a modification description + Handle(BlockFix_PeriodicSurfaceModifier) SR = new BlockFix_PeriodicSurfaceModifier; + SR->SetTolerance(Tol); + + TopTools_DataMapOfShapeShape context; + BRepTools_Modifier MD; + TopoDS_Shape result = ShapeCustom::ApplyModifier ( S, SR, context,MD ); + + Handle(ShapeBuild_ReShape) RS = new ShapeBuild_ReShape; + FixResult(result,RS,Tol); + result = RS->Apply(result); + + ShapeFix_Edge sfe; + for(TopExp_Explorer exp(result,TopAbs_EDGE); exp.More(); exp.Next()) { + TopoDS_Edge E = TopoDS::Edge(exp.Current()); + sfe.FixVertexTolerance (E); + } + + ShapeFix::SameParameter(result,Standard_False); + + return result; +} diff --git a/src/BlockFix/BlockFix.hxx b/src/BlockFix/BlockFix.hxx new file mode 100644 index 000000000..70d37df65 --- /dev/null +++ b/src/BlockFix/BlockFix.hxx @@ -0,0 +1,56 @@ +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 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.com + +#ifndef _BlockFix_HeaderFile +#define _BlockFix_HeaderFile + +#include + +class TopoDS_Shape; +class BlockFix_SphereSpaceModifier; +class BlockFix_UnionFaces; +class BlockFix_UnionEdges; +class BlockFix_BlockFixAPI; +class BlockFix_PeriodicSurfaceModifier; +class BlockFix_CheckTool; + +#include +#include + +class BlockFix { + +public: + Standard_EXPORT static TopoDS_Shape RotateSphereSpace(const TopoDS_Shape& S,const Standard_Real Tol); + Standard_EXPORT static TopoDS_Shape RefillProblemFaces(const TopoDS_Shape& S); + Standard_EXPORT static TopoDS_Shape FixRanges(const TopoDS_Shape& S,const Standard_Real Tol); + +private: + +friend class BlockFix_SphereSpaceModifier; +friend class BlockFix_UnionFaces; +friend class BlockFix_UnionEdges; +friend class BlockFix_BlockFixAPI; +friend class BlockFix_PeriodicSurfaceModifier; +friend class BlockFix_CheckTool; + +}; + +#endif diff --git a/src/BlockFix/BlockFix_BlockFixAPI.cxx b/src/BlockFix/BlockFix_BlockFixAPI.cxx new file mode 100644 index 000000000..376632b4f --- /dev/null +++ b/src/BlockFix/BlockFix_BlockFixAPI.cxx @@ -0,0 +1,89 @@ +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 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.com + +// File: BlockFix_BlockFixAPI.cxx +// Created: Tue Dec 7 11:59:05 2004 +// Author: Pavel DURANDIN + +#include + +#include +#include +#include + +#include + +#include + +#include + +IMPLEMENT_STANDARD_HANDLE(BlockFix_BlockFixAPI, MMgt_TShared); +IMPLEMENT_STANDARD_RTTIEXT(BlockFix_BlockFixAPI, MMgt_TShared); + +//======================================================================= +//function : BlockFix_BlockFixAPI +//purpose : +//======================================================================= +BlockFix_BlockFixAPI::BlockFix_BlockFixAPI() +{ + myTolerance = Precision::Confusion(); + myOptimumNbFaces = 6; +} + +//======================================================================= +//function : ~BlockFix_BlockFixAPI +//purpose : +//======================================================================= +BlockFix_BlockFixAPI::~BlockFix_BlockFixAPI() {} + +//======================================================================= +//function : Perform +//purpose : +//======================================================================= +void BlockFix_BlockFixAPI::Perform() +{ + // processing spheres with degenerativities + TopoDS_Shape aShape = Shape(); + myShape = BlockFix::RotateSphereSpace(aShape,myTolerance); + + // try to approximate non-canonic surfaces + // with singularities on boundaries by filling + myShape = BlockFix::RefillProblemFaces(myShape); + + // faces unification + BlockFix_UnionFaces aFaceUnifier; + aFaceUnifier.GetTolerance() = myTolerance; + aFaceUnifier.GetOptimumNbFaces() = myOptimumNbFaces; + TopoDS_Shape aResult = aFaceUnifier.Perform(myShape); + + // avoid problem with degenerated edges appearance + // due to shape quality regress + ShapeUpgrade_RemoveLocations RemLoc; + RemLoc.Remove(aResult); + aResult = RemLoc.GetResult(); + + // edges unification + BlockFix_UnionEdges anEdgeUnifier; + myShape = anEdgeUnifier.Perform(aResult,myTolerance); + + TopoDS_Shape aRes = BlockFix::FixRanges(myShape,myTolerance); + myShape = aRes; +} diff --git a/src/BlockFix/BlockFix_BlockFixAPI.hxx b/src/BlockFix/BlockFix_BlockFixAPI.hxx new file mode 100644 index 000000000..84140aff5 --- /dev/null +++ b/src/BlockFix/BlockFix_BlockFixAPI.hxx @@ -0,0 +1,102 @@ +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 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.com + +#ifndef _BlockFix_BlockFixAPI_HeaderFile +#define _BlockFix_BlockFixAPI_HeaderFile + +#include +#include + +#include +#include +#include +#include + +DEFINE_STANDARD_HANDLE(BlockFix_BlockFixAPI, MMgt_TShared); + +class BlockFix_BlockFixAPI : public MMgt_TShared +{ +public: + Standard_EXPORT BlockFix_BlockFixAPI(); + Standard_EXPORT ~BlockFix_BlockFixAPI(); + + void SetShape(const TopoDS_Shape& Shape); + TopoDS_Shape Shape() const; + Handle_ShapeBuild_ReShape& Context(); + Standard_Real& Tolerance(); + Standard_Integer& OptimumNbFaces(); + Standard_EXPORT void Perform(); + + DEFINE_STANDARD_RTTI(BlockFix_BlockFixAPI); + +private: + Handle_ShapeBuild_ReShape myContext; + TopoDS_Shape myShape; + Standard_Real myTolerance; + Standard_Integer myOptimumNbFaces; +}; + +//======================================================================= +//function : SetShape +//purpose : +//======================================================================= +inline void BlockFix_BlockFixAPI::SetShape(const TopoDS_Shape& Shape) +{ + myShape = Shape; +} + +//======================================================================= +//function : Shape +//purpose : +//======================================================================= +inline TopoDS_Shape BlockFix_BlockFixAPI::Shape() const +{ + return myShape; +} + +//======================================================================= +//function : Context +//purpose : +//======================================================================= +inline Handle(ShapeBuild_ReShape)& BlockFix_BlockFixAPI::Context() +{ + return myContext; +} + +//======================================================================= +//function : Tolerance +//purpose : +//======================================================================= +inline Standard_Real& BlockFix_BlockFixAPI::Tolerance() +{ + return myTolerance; +} + +//======================================================================= +//function : OptimumNbFaces +//purpose : +//======================================================================= +inline Standard_Integer& BlockFix_BlockFixAPI::OptimumNbFaces() +{ + return myOptimumNbFaces; +} + +#endif diff --git a/src/BlockFix/BlockFix_CheckTool.cxx b/src/BlockFix/BlockFix_CheckTool.cxx new file mode 100644 index 000000000..ba1c5c6af --- /dev/null +++ b/src/BlockFix/BlockFix_CheckTool.cxx @@ -0,0 +1,266 @@ +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 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.com + +// File: BlockFix_CheckTool.cxx +// Created: 17.12.04 11:15:25 +// Author: Sergey KUUL + +#include + +#include + +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +//======================================================================= +//function : BlockFix_CheckTool() +//purpose : Constructor +//======================================================================= +BlockFix_CheckTool::BlockFix_CheckTool( ) +{ + myHasCheck = Standard_False; + myPossibleBlocks.Clear(); +} + +//======================================================================= +//function : SetShape +//purpose : +//======================================================================= +void BlockFix_CheckTool::SetShape(const TopoDS_Shape& aShape) +{ + myHasCheck = Standard_False; + myShape = aShape; + myPossibleBlocks.Clear(); +} + +//======================================================================= +//function : Perform +//purpose : +//======================================================================= +void BlockFix_CheckTool::Perform() +{ + myNbSolids=0; + myNbBlocks=0; + myNbDegen=0; + myNbUF=0; + myNbUE=0; + myNbUFUE=0; + + TopExp_Explorer exps (myShape, TopAbs_SOLID); + TopTools_MapOfShape mapS; + for (; exps.More(); exps.Next()) { + TopoDS_Solid aSolid = TopoDS::Solid(exps.Current()); + if (!mapS.Add(aSolid)) continue; + myNbSolids++; + Standard_Boolean IsBlock=Standard_True; + Standard_Boolean MayBeUF=Standard_False; + Standard_Boolean MayBeUE=Standard_False; + Standard_Integer nf=0; + TopExp_Explorer expf (aSolid, TopAbs_FACE); + TopTools_MapOfShape mapF; + for (; expf.More(); expf.Next()) { + if (mapF.Add(expf.Current())) + nf++; + } + + if (nf < 6) { + IsBlock = Standard_False; + } + else if (nf > 6) { + IsBlock = Standard_False; + // check faces unification + TopTools_SequenceOfShape faces; + mapF.Clear(); + for (expf.Init(aSolid, TopAbs_FACE); expf.More(); expf.Next()) { + if (mapF.Add(expf.Current())) { + TopoDS_Face aFace = TopoDS::Face(expf.Current()); + faces.Append(aFace); + } + } + Standard_Boolean HasFacesForUnification = Standard_False; + for (Standard_Integer i=1; i 0) { + IsBlock = Standard_False; + myNbDegen++; + myPossibleBlocks.Append(aSolid); + continue; + } + if (nbe < 12) + IsBlock = Standard_False; + if (nbe > 12) { + IsBlock = Standard_False; + // check edges unification + // creating map of edge faces + TopTools_IndexedDataMapOfShapeListOfShape aMapEdgeFaces; + TopExp::MapShapesAndAncestors(aSolid, TopAbs_EDGE, TopAbs_FACE, aMapEdgeFaces); + + mapF.Clear(); + for (expf.Init(aSolid, TopAbs_FACE); expf.More(); expf.Next()) { + TopoDS_Face aFace = TopoDS::Face(expf.Current()); + if (!mapF.Add(aFace)) continue; + TopTools_IndexedDataMapOfShapeListOfShape aMapFacesEdges; + + TopTools_MapOfShape mapEe; + for (expe.Init(aFace, TopAbs_EDGE); expe.More(); expe.Next()) { + TopoDS_Edge edge = TopoDS::Edge(expe.Current()); + if (!mapEe.Add(edge)) continue; + if (!aMapEdgeFaces.Contains(edge)) continue; + const TopTools_ListOfShape& aList = aMapEdgeFaces.FindFromKey(edge); + TopTools_ListIteratorOfListOfShape anIter (aList); + for (; anIter.More(); anIter.Next()) { + TopoDS_Face face = TopoDS::Face(anIter.Value()); + if (face.IsSame(aFace)) continue; + if (aMapFacesEdges.Contains(face)) { + aMapFacesEdges.ChangeFromKey(face).Append(edge); + } + else { + TopTools_ListOfShape ListEdges; + ListEdges.Append(edge); + aMapFacesEdges.Add(face,ListEdges); + } + } + } + Standard_Integer i = 1; + for (; i <= aMapFacesEdges.Extent(); i++) { + const TopTools_ListOfShape& ListEdges = aMapFacesEdges.FindFromIndex(i); + if (ListEdges.Extent() > 1) break; + } + if (i <= aMapFacesEdges.Extent()) { + MayBeUE = Standard_True; + break; + } + } + } + + if (IsBlock) + myNbBlocks++; + else { + if (MayBeUF) { + myPossibleBlocks.Append(aSolid); + if (MayBeUE) + myNbUFUE++; + else + myNbUF++; + } + else if (MayBeUE) { + myNbUE++; + myPossibleBlocks.Append(aSolid); + } + } + } + + myHasCheck = Standard_True; +} + +//======================================================================= +//function : NbPossibleBlocks +//purpose : +//======================================================================= +Standard_Integer BlockFix_CheckTool::NbPossibleBlocks() const +{ + return myPossibleBlocks.Length(); +} + +//======================================================================= +//function : PossibleBlock +//purpose : +//======================================================================= +TopoDS_Shape BlockFix_CheckTool::PossibleBlock(const Standard_Integer num) const +{ + TopoDS_Shape res; + if( num>0 && num<=myPossibleBlocks.Length() ) + res = myPossibleBlocks.Value(num); + return res; +} + +//======================================================================= +//function : DumpCheckResult +//purpose : +//======================================================================= +void BlockFix_CheckTool::DumpCheckResult(Standard_OStream& S) const +{ + if(!myHasCheck) + S<<"Check not performed!"<Curves() ); + for (; itr.More(); itr.Next()) + { + Handle(BRep_CurveRepresentation) CurveRep = itr.Value(); + if (CurveRep->IsCurveOnSurface()) + { + //PCurveSeq.Append(CurveRep->PCurve()); + SurfSeq.Append(CurveRep->Surface()); + /* + TopoDS_Shape aLocShape; + aLocShape.Location(CurveRep->Location()); + LocSeq.Append(aLocShape); + */ + } + } + + Standard_Real fpar, lpar; + BRep_Tool::Range(FirstEdge, fpar, lpar); + TopoDS_Edge PrevEdge = FirstEdge; + TopoDS_Vertex CV; + Standard_Real MaxTol = 0.; + + TopoDS_Edge ResEdge; + BRep_Builder BB; + + Standard_Integer nb_curve = aChain.Length(); //number of curves + TColGeom_Array1OfBSplineCurve tab_c3d(0,nb_curve-1); //array of the curves + TColStd_Array1OfReal tabtolvertex(0,nb_curve-1); //(0,nb_curve-2); //array of the tolerances + + TopoDS_Vertex PrevVertex = FirstVertex; + for (i = 1; i <= nb_curve; i++) + { + TopoDS_Edge anEdge = TopoDS::Edge(aChain(i)); + TopoDS_Vertex VF, VL; + TopExp::Vertices(anEdge, VF, VL); + Standard_Boolean ToReverse = (!VF.IsSame(PrevVertex)); + + Standard_Real Tol1 = BRep_Tool::Tolerance(VF); + Standard_Real Tol2 = BRep_Tool::Tolerance(VL); + if (Tol1 > MaxTol) + MaxTol = Tol1; + if (Tol2 > MaxTol) + MaxTol = Tol2; + + if (i > 1) + { + TopExp::CommonVertex(PrevEdge, anEdge, CV); + Standard_Real Tol = BRep_Tool::Tolerance(CV); + tabtolvertex(i-2) = Tol; + } + + Handle(Geom_Curve) aCurve = BRep_Tool::Curve(anEdge, fpar, lpar); + Handle(Geom_TrimmedCurve) aTrCurve = new Geom_TrimmedCurve(aCurve, fpar, lpar); + tab_c3d(i-1) = GeomConvert::CurveToBSplineCurve(aTrCurve); + GeomConvert::C0BSplineToC1BSplineCurve(tab_c3d(i-1), Precision::Confusion()); + if (ToReverse) + tab_c3d(i-1)->Reverse(); + PrevVertex = (ToReverse)? VF : VL; + PrevEdge = anEdge; + } + Handle(TColGeom_HArray1OfBSplineCurve) concatcurve; //array of the concatenated curves + Handle(TColStd_HArray1OfInteger) ArrayOfIndices; //array of the remining Vertex + GeomConvert::ConcatC1(tab_c3d, + tabtolvertex, + ArrayOfIndices, + concatcurve, + Standard_False, + Precision::Confusion()); //C1 concatenation + + if (concatcurve->Length() > 1) + { + GeomConvert_CompCurveToBSplineCurve Concat(concatcurve->Value(concatcurve->Lower())); + + for (i = concatcurve->Lower()+1; i <= concatcurve->Upper(); i++) + Concat.Add( concatcurve->Value(i), MaxTol, Standard_True ); + + concatcurve->SetValue(concatcurve->Lower(), Concat.BSplineCurve()); + } + Handle(Geom_BSplineCurve) ResCurve = concatcurve->Value(concatcurve->Lower()); + + TColGeom2d_SequenceOfBoundedCurve ResPCurves; + TopLoc_Location aLoc; + for (j = 1; j <= SurfSeq.Length(); j++) + { + TColGeom2d_Array1OfBSplineCurve tab_c2d(0,nb_curve-1); //array of the pcurves + + PrevVertex = FirstVertex; + PrevEdge = FirstEdge; + //TopLoc_Location theLoc = LocSeq(j).Location(); + for (i = 1; i <= nb_curve; i++) + { + TopoDS_Edge anEdge = TopoDS::Edge(aChain(i)); + TopoDS_Vertex VF, VL; + TopExp::Vertices(anEdge, VF, VL); + Standard_Boolean ToReverse = (!VF.IsSame(PrevVertex)); + + /* + Handle(Geom2d_Curve) aPCurve = + BRep_Tool::CurveOnSurface(anEdge, SurfSeq(j), anEdge.Location()*theLoc, fpar, lpar); + */ + Handle(Geom2d_Curve) aPCurve = + BRep_Tool::CurveOnSurface(anEdge, SurfSeq(j), aLoc, fpar, lpar); + Handle(Geom2d_TrimmedCurve) aTrPCurve = new Geom2d_TrimmedCurve(aPCurve, fpar, lpar); + tab_c2d(i-1) = Geom2dConvert::CurveToBSplineCurve(aTrPCurve); + Geom2dConvert::C0BSplineToC1BSplineCurve(tab_c2d(i-1), Precision::Confusion()); + if (ToReverse) + tab_c2d(i-1)->Reverse(); + PrevVertex = (ToReverse)? VF : VL; + PrevEdge = anEdge; + } + Handle(TColGeom2d_HArray1OfBSplineCurve) concatc2d; //array of the concatenated curves + Handle(TColStd_HArray1OfInteger) ArrayOfInd2d; //array of the remining Vertex + Geom2dConvert::ConcatC1(tab_c2d, + tabtolvertex, + ArrayOfInd2d, + concatc2d, + Standard_False, + Precision::Confusion()); //C1 concatenation + + if (concatc2d->Length() > 1) + { + Geom2dConvert_CompCurveToBSplineCurve Concat2d(concatc2d->Value(concatc2d->Lower())); + + for (i = concatc2d->Lower()+1; i <= concatc2d->Upper(); i++) + Concat2d.Add( concatc2d->Value(i), MaxTol, Standard_True ); + + concatc2d->SetValue(concatc2d->Lower(), Concat2d.BSplineCurve()); + } + Handle(Geom2d_BSplineCurve) aResPCurve = concatc2d->Value(concatc2d->Lower()); + ResPCurves.Append(aResPCurve); + } + + ResEdge = BRepLib_MakeEdge(ResCurve, + FirstVertex, LastVertex, + ResCurve->FirstParameter(), ResCurve->LastParameter()); + BB.SameRange(ResEdge, Standard_False); + BB.SameParameter(ResEdge, Standard_False); + for (j = 1; j <= ResPCurves.Length(); j++) + { + BB.UpdateEdge(ResEdge, ResPCurves(j), SurfSeq(j), aLoc, MaxTol); + BB.Range(ResEdge, SurfSeq(j), aLoc, ResPCurves(j)->FirstParameter(), ResPCurves(j)->LastParameter()); + } + + BRepLib::SameParameter(ResEdge, MaxTol, Standard_True); + + return ResEdge; +} + +//======================================================================= +//function : MergeEdges +//purpose : auxilary +//======================================================================= +static Standard_Boolean MergeEdges(const TopTools_SequenceOfShape& SeqEdges, + const TopoDS_Face& aFace, + const Standard_Real Tol, + TopoDS_Edge& anEdge) +{ + // make chain for union + BRep_Builder B; + ShapeAnalysis_Edge sae; + TopoDS_Edge FirstE = TopoDS::Edge(SeqEdges.Value(1)); + TopoDS_Edge LastE = FirstE; + TopoDS_Vertex VF = sae.FirstVertex(FirstE); + TopoDS_Vertex VL = sae.LastVertex(LastE); + TopTools_SequenceOfShape aChain; + aChain.Append(FirstE); + TColStd_MapOfInteger IndUsedEdges; + IndUsedEdges.Add(1); + Standard_Integer j; + for(j=2; j<=SeqEdges.Length(); j++) { + for(Standard_Integer k=2; k<=SeqEdges.Length(); k++) { + if(IndUsedEdges.Contains(k)) continue; + TopoDS_Edge edge = TopoDS::Edge(SeqEdges.Value(k)); + TopoDS_Vertex VF2 = sae.FirstVertex(edge); + TopoDS_Vertex VL2 = sae.LastVertex(edge); + if(sae.FirstVertex(edge).IsSame(VL)) { + aChain.Append(edge); + LastE = edge; + VL = sae.LastVertex(LastE); + IndUsedEdges.Add(k); + } + else if(sae.LastVertex(edge).IsSame(VF)) { + aChain.Prepend(edge); + FirstE = edge; + VF = sae.FirstVertex(FirstE); + IndUsedEdges.Add(k); + } + } + } + if(aChain.Length()IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) { + Handle(Geom_TrimmedCurve) tc = + Handle(Geom_TrimmedCurve)::DownCast(c3d1); + c3d1 = tc->BasisCurve(); + } + TopoDS_Edge edge2 = TopoDS::Edge(aChain.Value(j+1)); + Handle(Geom_Curve) c3d2 = BRep_Tool::Curve(edge2,Loc,fp2,lp2); + if(c3d2.IsNull()) break; + while(c3d2->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) { + Handle(Geom_TrimmedCurve) tc = + Handle(Geom_TrimmedCurve)::DownCast(c3d2); + c3d2 = tc->BasisCurve(); + } + if( c3d1->IsKind(STANDARD_TYPE(Geom_Line)) && c3d2->IsKind(STANDARD_TYPE(Geom_Line)) ) { + // union lines + Handle(Geom_Line) L1 = Handle(Geom_Line)::DownCast(c3d1); + Handle(Geom_Line) L2 = Handle(Geom_Line)::DownCast(c3d2); + gp_Dir Dir1 = L1->Position().Direction(); + gp_Dir Dir2 = L2->Position().Direction(); + //if(!Dir1.IsEqual(Dir2,Precision::Angular())) { + //if(!Dir1.IsParallel(Dir2,Precision::Angular())) { + if(!Dir1.IsParallel(Dir2,Tol)) { + continue; + } + // can union lines => create new edge + TopoDS_Vertex V1 = sae.FirstVertex(edge1); + gp_Pnt PV1 = BRep_Tool::Pnt(V1); + TopoDS_Vertex V2 = sae.LastVertex(edge2); + gp_Pnt PV2 = BRep_Tool::Pnt(V2); + gp_Vec Vec(PV1,PV2); + Handle(Geom_Line) L = new Geom_Line(gp_Ax1(PV1,Vec)); + Standard_Real dist = PV1.Distance(PV2); + Handle(Geom_TrimmedCurve) tc = new Geom_TrimmedCurve(L,0.0,dist); + TopoDS_Edge E; + B.MakeEdge (E,tc,Precision::Confusion()); + B.Add (E,V1); B.Add (E,V2); + B.UpdateVertex(V1, 0., E, 0.); + B.UpdateVertex(V2, dist, E, 0.); + //ShapeFix_Edge sfe; + //sfe.FixAddPCurve(E,aFace,Standard_False); + //sfe.FixSameParameter(E); + aChain.Remove(j); + aChain.SetValue(j,E); + j--; + } + if( c3d1->IsKind(STANDARD_TYPE(Geom_Circle)) && c3d2->IsKind(STANDARD_TYPE(Geom_Circle)) ) { + // union circles + Handle(Geom_Circle) C1 = Handle(Geom_Circle)::DownCast(c3d1); + Handle(Geom_Circle) C2 = Handle(Geom_Circle)::DownCast(c3d2); + gp_Pnt P01 = C1->Location(); + gp_Pnt P02 = C2->Location(); + if (P01.Distance(P02) > Precision::Confusion()) continue; + // can union circles => create new edge + TopoDS_Vertex V1 = sae.FirstVertex(edge1); + gp_Pnt PV1 = BRep_Tool::Pnt(V1); + TopoDS_Vertex V2 = sae.LastVertex(edge2); + gp_Pnt PV2 = BRep_Tool::Pnt(V2); + TopoDS_Vertex VM = sae.LastVertex(edge1); + gp_Pnt PVM = BRep_Tool::Pnt(VM); + GC_MakeCircle MC (PV1,PVM,PV2); + Handle(Geom_Circle) C = MC.Value(); + TopoDS_Edge E; + if (!MC.IsDone() || C.IsNull()) { + // jfa for Mantis issue 0020228 + if (PV1.Distance(PV2) > Precision::Confusion()) continue; + // closed chain + C = C1; + B.MakeEdge (E,C,Precision::Confusion()); + B.Add(E,V1); + B.Add(E,V2); + } + else { + gp_Pnt P0 = C->Location(); + gp_Dir D1(gp_Vec(P0,PV1)); + gp_Dir D2(gp_Vec(P0,PV2)); + Standard_Real fpar = C->XAxis().Direction().Angle(D1); + if(fabs(fpar)>Precision::Confusion()) { + // check orientation + gp_Dir ND = C->XAxis().Direction().Crossed(D1); + if(ND.IsOpposite(C->Axis().Direction(),Precision::Confusion())) { + fpar = -fpar; + } + } + Standard_Real lpar = C->XAxis().Direction().Angle(D2); + if(fabs(lpar)>Precision::Confusion()) { + // check orientation + gp_Dir ND = C->XAxis().Direction().Crossed(D2); + if(ND.IsOpposite(C->Axis().Direction(),Precision::Confusion())) { + lpar = -lpar; + } + } + if (lpar < fpar) lpar += 2*M_PI; + Handle(Geom_TrimmedCurve) tc = new Geom_TrimmedCurve(C,fpar,lpar); + B.MakeEdge (E,tc,Precision::Confusion()); + B.Add(E,V1); + B.Add(E,V2); + B.UpdateVertex(V1, fpar, E, 0.); + B.UpdateVertex(V2, lpar, E, 0.); + } + aChain.Remove(j); + aChain.SetValue(j,E); + j--; + } + } + if (j < aChain.Length()) { + MESSAGE ("null curve3d in edge..."); + return Standard_False; + } + if (aChain.Length() > 1) { + // second step: union edges with various curves + // skl for bug 0020052 from Mantis: perform such unions + // only if curves are bspline or bezier + bool NeedUnion = true; + for(j=1; j<=aChain.Length(); j++) { + TopoDS_Edge edge = TopoDS::Edge(aChain.Value(j)); + Handle(Geom_Curve) c3d = BRep_Tool::Curve(edge,Loc,fp1,lp1); + if(c3d.IsNull()) continue; + while(c3d->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) { + Handle(Geom_TrimmedCurve) tc = + Handle(Geom_TrimmedCurve)::DownCast(c3d); + c3d = tc->BasisCurve(); + } + if( ( c3d->IsKind(STANDARD_TYPE(Geom_BSplineCurve)) || + c3d->IsKind(STANDARD_TYPE(Geom_BezierCurve)) ) ) continue; + NeedUnion = false; + break; + } + if(NeedUnion) { + MESSAGE ("can not make analitical union => make approximation"); + TopoDS_Edge E = GlueEdgesWithPCurves(aChain, VF, VL); + /* + TopoDS_Wire W; + B.MakeWire(W); + for(j=1; j<=aChain.Length(); j++) { + TopoDS_Edge edge = TopoDS::Edge(aChain.Value(j)); + B.Add(W,edge); + } + Handle(BRepAdaptor_HCompCurve) Adapt = new BRepAdaptor_HCompCurve(W); + Approx_Curve3d Conv(Adapt,Tol,GeomAbs_C1,9,1000); + Handle(Geom_BSplineCurve) bc = Conv.Curve(); + TopoDS_Edge E; + B.MakeEdge (E,bc,Precision::Confusion()); + B.Add (E,VF); + B.Add (E,VL); + */ + aChain.SetValue(1,E); + } + else { + MESSAGE ("can not make approximation for such types of curves"); + return Standard_False; + } + } + + anEdge = TopoDS::Edge(aChain.Value(1)); + return Standard_True; +} + +//======================================================================= +//function : Perform +//purpose : +//======================================================================= +TopoDS_Shape BlockFix_UnionEdges::Perform(const TopoDS_Shape& Shape, + const Standard_Real Tol) +{ + myContext = new ShapeBuild_ReShape; + myTolerance = Tol; + TopoDS_Shape aResult = myContext->Apply(Shape); + + // processing each solid + TopAbs_ShapeEnum aType = TopAbs_SOLID; + TopExp_Explorer exps (Shape, aType); + if (!exps.More()) { + aType = TopAbs_SHELL; + exps.Init(Shape, aType); + } + for (; exps.More(); exps.Next()) { + //TopoDS_Solid aSolid = TopoDS::Solid(exps.Current()); + TopoDS_Shape aSolid = exps.Current(); + + TopTools_IndexedMapOfShape ChangedFaces; + + // creating map of edge faces + TopTools_IndexedDataMapOfShapeListOfShape aMapEdgeFaces; + TopExp::MapShapesAndAncestors(aSolid, TopAbs_EDGE, TopAbs_FACE, aMapEdgeFaces); + + Handle(ShapeBuild_ReShape) aContext = new ShapeBuild_ReShape; + TopoDS_Shape aRes = aSolid; + aRes = aContext->Apply(aSolid); + + // processing each face + TopExp_Explorer exp; + for (exp.Init(aRes, TopAbs_FACE); exp.More(); exp.Next()) { + TopoDS_Face aFace = + TopoDS::Face(aContext->Apply(exp.Current().Oriented(TopAbs_FORWARD))); + TopTools_IndexedDataMapOfShapeListOfShape aMapFacesEdges; + + for (TopExp_Explorer expe(aFace,TopAbs_EDGE); expe.More(); expe.Next()) { + TopoDS_Edge edge = TopoDS::Edge(expe.Current()); + if (!aMapEdgeFaces.Contains(edge)) continue; + const TopTools_ListOfShape& aList = aMapEdgeFaces.FindFromKey(edge); + TopTools_ListIteratorOfListOfShape anIter(aList); + for ( ; anIter.More(); anIter.Next()) { + TopoDS_Face face = TopoDS::Face(anIter.Value()); + TopoDS_Face face1 = TopoDS::Face(aContext->Apply(anIter.Value())); + if (face1.IsSame(aFace)) continue; + if (aMapFacesEdges.Contains(face)) { + aMapFacesEdges.ChangeFromKey(face).Append(edge); + } + else { + TopTools_ListOfShape ListEdges; + ListEdges.Append(edge); + aMapFacesEdges.Add(face,ListEdges); + } + } + } + + for (Standard_Integer i=1; i<=aMapFacesEdges.Extent(); i++) { + const TopTools_ListOfShape& ListEdges = aMapFacesEdges.FindFromIndex(i); + TopTools_SequenceOfShape SeqEdges; + TopTools_ListIteratorOfListOfShape anIter(ListEdges); + for ( ; anIter.More(); anIter.Next()) { + SeqEdges.Append(anIter.Value()); + } + if (SeqEdges.Length()==1) continue; + TopoDS_Edge E; + if ( MergeEdges(SeqEdges,aFace,Tol,E) ) { + // now we have only one edge - aChain.Value(1) + // we have to replace old ListEdges with this new edge + aContext->Replace(SeqEdges(1),E); + for (Standard_Integer j=2; j<=SeqEdges.Length(); j++) { + aContext->Remove(SeqEdges(j)); + } + TopoDS_Face tmpF = TopoDS::Face(exp.Current()); + if ( !ChangedFaces.Contains(tmpF) ) + ChangedFaces.Add(tmpF); + tmpF = TopoDS::Face(aMapFacesEdges.FindKey(i)); + if ( !ChangedFaces.Contains(tmpF) ) + ChangedFaces.Add(tmpF); + } + } + + } // end processing each face + + // fix changed faces and replace them in the local context + for (Standard_Integer i=1; i<=ChangedFaces.Extent(); i++) { + TopoDS_Face aFace = TopoDS::Face(aContext->Apply(ChangedFaces.FindKey(i))); + Handle(ShapeFix_Face) sff = new ShapeFix_Face(aFace); + sff->SetContext(myContext); + sff->SetPrecision(myTolerance); + sff->SetMinTolerance(myTolerance); + sff->SetMaxTolerance(Max(1.,myTolerance*1000.)); + sff->Perform(); + aContext->Replace(aFace,sff->Face()); + } + + if (ChangedFaces.Extent() > 0) { + // fix changed shell and replace it in the local context + TopoDS_Shape aRes1 = aContext->Apply(aRes); + TopExp_Explorer expsh; + for (expsh.Init(aRes1, TopAbs_SHELL); expsh.More(); expsh.Next()) { + TopoDS_Shell aShell = TopoDS::Shell(expsh.Current()); + Handle(ShapeFix_Shell) sfsh = new ShapeFix_Shell; + sfsh->FixFaceOrientation(aShell); + aContext->Replace(aShell,sfsh->Shell()); + } + TopoDS_Shape aRes2 = aContext->Apply(aRes1); + // put new solid into global context + myContext->Replace(aSolid,aRes2); + } + + } // end processing each solid + + aResult = myContext->Apply(Shape); + return aResult; +} diff --git a/src/BlockFix/BlockFix_UnionEdges.hxx b/src/BlockFix/BlockFix_UnionEdges.hxx new file mode 100644 index 000000000..b63f5c7e2 --- /dev/null +++ b/src/BlockFix/BlockFix_UnionEdges.hxx @@ -0,0 +1,47 @@ +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 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.com + +#ifndef _BlockFix_UnionEdges_HeaderFile +#define _BlockFix_UnionEdges_HeaderFile + +#include + +#include + +#include +#include + +class TopoDS_Shape; + +class BlockFix_UnionEdges { + +public: + Standard_EXPORT BlockFix_UnionEdges(); + + Standard_EXPORT TopoDS_Shape Perform (const TopoDS_Shape& Shape,const Standard_Real Tol); + +private: + Standard_Real myTolerance; + Handle_ShapeBuild_ReShape myContext; + +}; + +#endif diff --git a/src/BlockFix/BlockFix_UnionFaces.cxx b/src/BlockFix/BlockFix_UnionFaces.cxx new file mode 100644 index 000000000..aae28cab6 --- /dev/null +++ b/src/BlockFix/BlockFix_UnionFaces.cxx @@ -0,0 +1,709 @@ +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 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.com + +// File: BlockFix_UnionFaces.cxx +// Created: Tue Dec 7 17:15:42 2004 +// Author: Pavel DURANDIN + +#include + +#include + +#include +#include + +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include + +#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 +#include +#else +#include +#endif + +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#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 + +//======================================================================= +//function : BlockFix_UnionFaces +//purpose : +//======================================================================= +BlockFix_UnionFaces::BlockFix_UnionFaces() + : myTolerance(Precision::Confusion()), + myOptimumNbFaces(6) +{ +} + +//======================================================================= +//function : GetTolerance +//purpose : +//======================================================================= +Standard_Real& BlockFix_UnionFaces::GetTolerance() +{ + return myTolerance; +} + +//======================================================================= +//function : GetOptimumNbFaces +//purpose : +//======================================================================= +Standard_Integer& BlockFix_UnionFaces::GetOptimumNbFaces() +{ + return myOptimumNbFaces; +} + +//======================================================================= +//function : AddOrdinaryEdges +//purpose : auxilary +// adds edges from the shape to the sequence +// seams and equal edges are dropped +// Returns true if one of original edges dropped +//======================================================================= +static Standard_Boolean AddOrdinaryEdges(TopTools_SequenceOfShape& edges, + const TopoDS_Shape aShape, + Standard_Integer& anIndex) +{ + //map of edges + TopTools_MapOfShape aNewEdges; + //add edges without seams + for(TopExp_Explorer exp(aShape,TopAbs_EDGE); exp.More(); exp.Next()) { + TopoDS_Shape edge = exp.Current(); + if(aNewEdges.Contains(edge)) + aNewEdges.Remove(edge); + else + aNewEdges.Add(edge); + } + + Standard_Boolean isDropped = Standard_False; + //merge edges and drop seams + for(Standard_Integer i = 1; i <= edges.Length(); i++) { + TopoDS_Shape current = edges(i); + if(aNewEdges.Contains(current)) { + + aNewEdges.Remove(current); + edges.Remove(i); + i--; + + if(!isDropped) { + isDropped = Standard_True; + anIndex = i; + } + } + } + + //add edges to the sequemce + for(TopTools_MapIteratorOfMapOfShape anIter(aNewEdges); anIter.More(); anIter.Next()) + edges.Append(anIter.Key()); + + return isDropped; +} + +//======================================================================= +//function : ClearRts +//purpose : auxilary +//======================================================================= +static Handle(Geom_Surface) ClearRts(const Handle(Geom_Surface)& aSurface) +{ + if(aSurface->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) { + Handle(Geom_RectangularTrimmedSurface) rts = + Handle(Geom_RectangularTrimmedSurface)::DownCast(aSurface); + return rts->BasisSurface(); + } + return aSurface; +} + +//======================================================================= +//function : Perform +//purpose : +//======================================================================= +TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape) +{ + Handle(ShapeBuild_ReShape) myContext = new ShapeBuild_ReShape; + TopoDS_Shape aResShape = myContext->Apply(Shape); + + // processing each solid + TopExp_Explorer exps; + for (exps.Init(Shape, TopAbs_SOLID); exps.More(); exps.Next()) { + TopoDS_Solid aSolid = TopoDS::Solid(exps.Current()); + + // creating map of edge faces + TopTools_IndexedDataMapOfShapeListOfShape aMapEdgeFaces; + TopExp::MapShapesAndAncestors(aSolid, TopAbs_EDGE, TopAbs_FACE, aMapEdgeFaces); + + // map of processed shapes + TopTools_MapOfShape aProcessed; + + Handle(ShapeBuild_ReShape) aContext = new ShapeBuild_ReShape; + + Standard_Integer NbModif = 0; + Standard_Boolean hasFailed = Standard_False; + Standard_Real tol = Min(Max(Precision::Confusion(), myTolerance/10.), 0.1); + + // count faces + int nbf = 0; + TopExp_Explorer exp; + TopTools_MapOfShape mapF; + for (exp.Init(aSolid, TopAbs_FACE); exp.More(); exp.Next()) { + if (mapF.Add(exp.Current())) + nbf++; + } + + bool doUnion = ((myOptimumNbFaces == 0) || + ((myOptimumNbFaces > 0) && (nbf > myOptimumNbFaces))); + + // processing each face + mapF.Clear(); + for (exp.Init(aSolid, TopAbs_FACE); exp.More() && doUnion; exp.Next()) { + TopoDS_Face aFace = TopoDS::Face(exp.Current().Oriented(TopAbs_FORWARD)); + + if (aProcessed.Contains(aFace)) + continue; + + Standard_Integer dummy; + TopTools_SequenceOfShape edges; + AddOrdinaryEdges(edges,aFace,dummy); + + TopTools_SequenceOfShape faces; + faces.Append(aFace); + + //surface and location to construct result + TopLoc_Location aBaseLocation; + Handle(Geom_Surface) aBaseSurface = BRep_Tool::Surface(aFace,aBaseLocation); + aBaseSurface = ClearRts(aBaseSurface); + + // find adjacent faces to union + Standard_Integer i; + for (i = 1; i <= edges.Length(); i++) { + TopoDS_Edge edge = TopoDS::Edge(edges(i)); + if (BRep_Tool::Degenerated(edge)) + continue; + + const TopTools_ListOfShape& aList = aMapEdgeFaces.FindFromKey(edge); + TopTools_ListIteratorOfListOfShape anIter(aList); + for (; anIter.More(); anIter.Next()) { + TopoDS_Face anCheckedFace = TopoDS::Face(anIter.Value().Oriented(TopAbs_FORWARD)); + if (anCheckedFace.IsSame(aFace)) + continue; + + if (aProcessed.Contains(anCheckedFace)) + continue; + + if (IsSameDomain(aFace,anCheckedFace)) { + + if (aList.Extent() != 2) { + // non mainfold case is not processed + continue; + } + + // replacing pcurves + TopoDS_Face aMockUpFace; + BRep_Builder B; + B.MakeFace(aMockUpFace,aBaseSurface,aBaseLocation,0.); + MovePCurves(aMockUpFace,anCheckedFace); + + if (AddOrdinaryEdges(edges,aMockUpFace,dummy)) { + // sequence edges is modified + i = dummy; + } + + faces.Append(anCheckedFace); + aProcessed.Add(anCheckedFace); + break; + } + } + } + + // all faces collected in the sequence. Perform union of faces + if (faces.Length() > 1) { + NbModif++; + TopoDS_Face aResult; + BRep_Builder B; + B.MakeFace(aResult,aBaseSurface,aBaseLocation,0); + Standard_Integer nbWires = 0; + + // connecting wires + while (edges.Length()>0) { + + Standard_Boolean isEdge3d = Standard_False; + nbWires++; + TopTools_MapOfShape aVertices; + TopoDS_Wire aWire; + B.MakeWire(aWire); + + TopoDS_Edge anEdge = TopoDS::Edge(edges(1)); + edges.Remove(1); + + isEdge3d |= !BRep_Tool::Degenerated(anEdge); + B.Add(aWire,anEdge); + TopoDS_Vertex V1,V2; + TopExp::Vertices(anEdge,V1,V2); + aVertices.Add(V1); + aVertices.Add(V2); + + Standard_Boolean isNewFound = Standard_False; + do { + isNewFound = Standard_False; + for(Standard_Integer j = 1; j <= edges.Length(); j++) { + anEdge = TopoDS::Edge(edges(j)); + TopExp::Vertices(anEdge,V1,V2); + if(aVertices.Contains(V1) || aVertices.Contains(V2)) { + isEdge3d |= !BRep_Tool::Degenerated(anEdge); + aVertices.Add(V1); + aVertices.Add(V2); + B.Add(aWire,anEdge); + edges.Remove(j); + j--; + isNewFound = Standard_True; + } + } + } while (isNewFound); + + // sorting any type of edges + aWire = TopoDS::Wire(aContext->Apply(aWire)); + + TopoDS_Face tmpF = TopoDS::Face(aContext->Apply(faces(1).Oriented(TopAbs_FORWARD))); + Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire(aWire,tmpF,Precision::Confusion()); + sfw->FixReorder(); + Standard_Boolean isDegRemoved = Standard_False; + if(!sfw->StatusReorder ( ShapeExtend_FAIL )) { + // clear degenerated edges if at least one with 3d curve exist + if(isEdge3d) { + Handle(ShapeExtend_WireData) sewd = sfw->WireData(); + for(Standard_Integer j = 1; j<=sewd->NbEdges();j++) { + TopoDS_Edge E = sewd->Edge(j); + if(BRep_Tool::Degenerated(E)) { + sewd->Remove(j); + isDegRemoved = Standard_True; + j--; + } + } + } + sfw->FixShifted(); + if(isDegRemoved) + sfw->FixDegenerated(); + } + TopoDS_Wire aWireFixed = sfw->Wire(); + aContext->Replace(aWire,aWireFixed); + // add resulting wire + if(isEdge3d) { + B.Add(aResult,aWireFixed); + } + else { + // sorting edges + Handle(ShapeExtend_WireData) sbwd = sfw->WireData(); + Standard_Integer nbEdges = sbwd->NbEdges(); + // sort degenerated edges and create one edge instead of several ones + ShapeAnalysis_WireOrder sawo(Standard_False, 0); + ShapeAnalysis_Edge sae; + Standard_Integer aLastEdge = nbEdges; + for(Standard_Integer j = 1; j <= nbEdges; j++) { + Standard_Real f,l; + //smh protection on NULL pcurve + Handle(Geom2d_Curve) c2d; + if(!sae.PCurve(sbwd->Edge(j),tmpF,c2d,f,l)) { + aLastEdge--; + continue; + } + sawo.Add(c2d->Value(f).XY(),c2d->Value(l).XY()); + } + sawo.Perform(); + + // constructind one degenerative edge + gp_XY aStart, anEnd, tmp; + Standard_Integer nbFirst = sawo.Ordered(1); + TopoDS_Edge anOrigE = TopoDS::Edge(sbwd->Edge(nbFirst).Oriented(TopAbs_FORWARD)); + ShapeBuild_Edge sbe; + TopoDS_Vertex aDummyV; + TopoDS_Edge E = sbe.CopyReplaceVertices(anOrigE,aDummyV,aDummyV); + sawo.XY(nbFirst,aStart,tmp); + sawo.XY(sawo.Ordered(aLastEdge),tmp,anEnd); + + gp_XY aVec = anEnd-aStart; + Handle(Geom2d_Line) aLine = new Geom2d_Line(aStart,gp_Dir2d(anEnd-aStart)); + + B.UpdateEdge(E,aLine,tmpF,0.); + B.Range(E,tmpF,0.,aVec.Modulus()); + Handle(Geom_Curve) C3d; + B.UpdateEdge(E,C3d,0.); + B.Degenerated(E,Standard_True); + TopoDS_Wire aW; + B.MakeWire(aW); + B.Add(aW,E); + B.Add(aResult,aW); + } + } + + // perform substitution of face + aContext->Replace(aContext->Apply(aFace),aResult); + + ShapeFix_Face sff (aResult); + //Intializing by tolerances + sff.SetPrecision(myTolerance); + sff.SetMinTolerance(tol); + sff.SetMaxTolerance(Max(1.,myTolerance*1000.)); + //Setting modes + sff.FixOrientationMode() = 0; + //sff.FixWireMode() = 0; + sff.SetContext(aContext); + // Applying the fixes + sff.Perform(); + if(sff.Status(ShapeExtend_FAIL)) + hasFailed = Standard_True; + + // breaking down to several faces + TopoDS_Shape theResult = aContext->Apply(aResult); + for (TopExp_Explorer aFaceExp (theResult,TopAbs_FACE); aFaceExp.More(); aFaceExp.Next()) { + TopoDS_Face aCurrent = TopoDS::Face(aFaceExp.Current().Oriented(TopAbs_FORWARD)); + Handle(TColGeom_HArray2OfSurface) grid = new TColGeom_HArray2OfSurface ( 1, 1, 1, 1 ); + grid->SetValue ( 1, 1, aBaseSurface ); + Handle(ShapeExtend_CompositeSurface) G = new ShapeExtend_CompositeSurface ( grid ); + ShapeFix_ComposeShell CompShell; + CompShell.Init ( G, aBaseLocation, aCurrent, ::Precision::Confusion() );//myPrecision + CompShell.SetContext( aContext ); + + TopTools_SequenceOfShape parts; + ShapeFix_SequenceOfWireSegment wires; + for(TopExp_Explorer W_Exp(aCurrent,TopAbs_WIRE);W_Exp.More();W_Exp.Next()) { + Handle(ShapeExtend_WireData) sbwd = + new ShapeExtend_WireData ( TopoDS::Wire(W_Exp.Current() )); + ShapeFix_WireSegment seg ( sbwd, TopAbs_REVERSED ); + wires.Append(seg); + } + + CompShell.DispatchWires ( parts,wires ); + for (Standard_Integer j=1; j <= parts.Length(); j++ ) { + ShapeFix_Face aFixOrient(TopoDS::Face(parts(j))); + aFixOrient.SetContext(aContext); + aFixOrient.FixOrientation(); + } + + TopoDS_Shape CompRes; + if ( faces.Length() !=1 ) { + TopoDS_Shell S; + B.MakeShell ( S ); + for ( i=1; i <= parts.Length(); i++ ) + B.Add ( S, parts(i) ); + CompRes = S; + } + else CompRes = parts(1); + + aContext->Replace(aCurrent,CompRes); + } + + // remove the remaining faces + for(i = 2; i <= faces.Length(); i++) + aContext->Remove(faces(i)); + } + } // end processing each face + + //TopoDS_Shape aResult = Shape; + if (NbModif > 0 && !hasFailed) { + TopoDS_Shape aResult = aContext->Apply(aSolid); + + ShapeFix_Edge sfe; + for (exp.Init(aResult,TopAbs_EDGE); exp.More(); exp.Next()) { + TopoDS_Edge E = TopoDS::Edge(exp.Current()); + sfe.FixVertexTolerance (E); + // ptv add fix same parameter + sfe.FixSameParameter(E, myTolerance); + } + + myContext->Replace(aSolid, aResult); + } + //else + { + for (exp.Init(aSolid, TopAbs_FACE); exp.More(); exp.Next()) { + TopoDS_Face aFace = TopoDS::Face(exp.Current().Oriented(TopAbs_FORWARD)); + Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire; + sfw->SetContext(myContext); + sfw->SetPrecision(myTolerance); + sfw->SetMinTolerance(myTolerance); + sfw->SetMaxTolerance(Max(1.,myTolerance*1000.)); + sfw->SetFace(aFace); + for (TopoDS_Iterator iter (aFace,Standard_False); iter.More(); iter.Next()) { + TopoDS_Wire wire = TopoDS::Wire(iter.Value()); + sfw->Load(wire); + sfw->FixReorder(); + sfw->FixShifted(); + } + } + } + } // end processing each solid + + aResShape = myContext->Apply(Shape); + return aResShape; +} + +//======================================================================= +//function : IsSameDomain +//purpose : +//======================================================================= +bool getCylinder (Handle(Geom_Surface)& theInSurface, gp_Cylinder& theOutCylinder) +{ + bool isCylinder = false; + + if (theInSurface->IsKind(STANDARD_TYPE(Geom_CylindricalSurface))) { + Handle(Geom_CylindricalSurface) aGC = Handle(Geom_CylindricalSurface)::DownCast(theInSurface); + + theOutCylinder = aGC->Cylinder(); + isCylinder = true; + } + else if (theInSurface->IsKind(STANDARD_TYPE(Geom_SurfaceOfRevolution))) { + Handle(Geom_SurfaceOfRevolution) aRS = + Handle(Geom_SurfaceOfRevolution)::DownCast(theInSurface); + Handle(Geom_Curve) aBasis = aRS->BasisCurve(); + if (aBasis->IsKind(STANDARD_TYPE(Geom_Line))) { + Handle(Geom_Line) aBasisLine = Handle(Geom_Line)::DownCast(aBasis); + gp_Dir aDir = aRS->Direction(); + gp_Dir aBasisDir = aBasisLine->Position().Direction(); + if (aBasisDir.IsParallel(aDir, Precision::Confusion())) { + // basis line is parallel to the revolution axis: it is a cylinder + gp_Pnt aLoc = aRS->Location(); + Standard_Real aR = aBasisLine->Lin().Distance(aLoc); + gp_Ax3 aCylAx (aLoc, aDir); + + theOutCylinder = gp_Cylinder(aCylAx, aR); + isCylinder = true; + } + } + } + else if (theInSurface->IsKind(STANDARD_TYPE(Geom_SurfaceOfLinearExtrusion))) { + Handle(Geom_SurfaceOfLinearExtrusion) aLES = + Handle(Geom_SurfaceOfLinearExtrusion)::DownCast(theInSurface); + Handle(Geom_Curve) aBasis = aLES->BasisCurve(); + if (aBasis->IsKind(STANDARD_TYPE(Geom_Circle))) { + Handle(Geom_Circle) aBasisCircle = Handle(Geom_Circle)::DownCast(aBasis); + gp_Dir aDir = aLES->Direction(); + gp_Dir aBasisDir = aBasisCircle->Position().Direction(); + if (aBasisDir.IsParallel(aDir, Precision::Confusion())) { + // basis circle is normal to the extrusion axis: it is a cylinder + gp_Pnt aLoc = aBasisCircle->Location(); + Standard_Real aR = aBasisCircle->Radius(); + gp_Ax3 aCylAx (aLoc, aDir); + + theOutCylinder = gp_Cylinder(aCylAx, aR); + isCylinder = true; + } + } + } + else { + } + + return isCylinder; +} + +Standard_Boolean BlockFix_UnionFaces::IsSameDomain(const TopoDS_Face& aFace, + const TopoDS_Face& aCheckedFace) const +{ + //checking the same handles + TopLoc_Location L1, L2; + Handle(Geom_Surface) S1, S2; + + S1 = BRep_Tool::Surface(aFace,L1); + S2 = BRep_Tool::Surface(aCheckedFace,L2); + + if (S1 == S2 && L1 == L2) + return true; + + // planar and cylindrical cases (IMP 20052) + Standard_Real aPrec = Precision::Confusion(); + + S1 = BRep_Tool::Surface(aFace); + S2 = BRep_Tool::Surface(aCheckedFace); + + S1 = ClearRts(S1); + S2 = ClearRts(S2); + + //Handle(Geom_OffsetSurface) aGOFS1, aGOFS2; + //aGOFS1 = Handle(Geom_OffsetSurface)::DownCast(S1); + //aGOFS2 = Handle(Geom_OffsetSurface)::DownCast(S2); + //if (!aGOFS1.IsNull()) S1 = aGOFS1->BasisSurface(); + //if (!aGOFS2.IsNull()) S2 = aGOFS2->BasisSurface(); + + // case of two elementary surfaces: use OCCT tool + // elementary surfaces: ConicalSurface, CylindricalSurface, + // Plane, SphericalSurface and ToroidalSurface + if (S1->IsKind(STANDARD_TYPE(Geom_ElementarySurface)) && + S2->IsKind(STANDARD_TYPE(Geom_ElementarySurface))) + { + Handle(GeomAdaptor_HSurface) aGA1 = new GeomAdaptor_HSurface(S1); + Handle(GeomAdaptor_HSurface) aGA2 = new GeomAdaptor_HSurface(S2); + + Handle(BRepTopAdaptor_TopolTool) aTT1 = new BRepTopAdaptor_TopolTool(); + Handle(BRepTopAdaptor_TopolTool) aTT2 = new BRepTopAdaptor_TopolTool(); + + try { +#if OCC_VERSION_LARGE > 0x06010000 + OCC_CATCH_SIGNALS; +#endif + +#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 + IntPatch_ImpImpIntersection anIIInt (aGA1, aTT1, aGA2, aTT2, aPrec, aPrec); +#else + IntPatch_TheIIIntOfIntersection anIIInt (aGA1, aTT1, aGA2, aTT2, aPrec, aPrec); +#endif + if (!anIIInt.IsDone() || anIIInt.IsEmpty()) + return false; + + return anIIInt.TangentFaces(); + } + catch (Standard_Failure) { + return false; + } + } + + // case of two planar surfaces: + // all kinds of surfaces checked, including b-spline and bezier + GeomLib_IsPlanarSurface aPlanarityChecker1 (S1, aPrec); + if (aPlanarityChecker1.IsPlanar()) { + GeomLib_IsPlanarSurface aPlanarityChecker2 (S2, aPrec); + if (aPlanarityChecker2.IsPlanar()) { + gp_Pln aPln1 = aPlanarityChecker1.Plan(); + gp_Pln aPln2 = aPlanarityChecker2.Plan(); + + if (aPln1.Position().Direction().IsParallel(aPln2.Position().Direction(), aPrec) && + aPln1.Distance(aPln2) < aPrec) { + return true; + } + } + } + + // case of two cylindrical surfaces, at least one of which is a swept surface + // swept surfaces: SurfaceOfLinearExtrusion, SurfaceOfRevolution + if ((S1->IsKind(STANDARD_TYPE(Geom_CylindricalSurface)) || + S1->IsKind(STANDARD_TYPE(Geom_SweptSurface))) && + (S2->IsKind(STANDARD_TYPE(Geom_CylindricalSurface)) || + S2->IsKind(STANDARD_TYPE(Geom_SweptSurface)))) + { + gp_Cylinder aCyl1, aCyl2; + if (getCylinder(S1, aCyl1) && getCylinder(S2, aCyl2)) { + if (fabs(aCyl1.Radius() - aCyl2.Radius()) < aPrec) { + gp_Dir aDir1 = aCyl1.Position().Direction(); + gp_Dir aDir2 = aCyl2.Position().Direction(); + if (aDir1.IsParallel(aDir2, aPrec)) { + gp_Pnt aLoc1 = aCyl1.Location(); + gp_Pnt aLoc2 = aCyl2.Location(); + gp_Vec aVec12 (aLoc1, aLoc2); + if (aVec12.SquareMagnitude() < aPrec*aPrec || + aVec12.IsParallel(aDir1, aPrec)) { + return true; + } + } + } + } + } + + return false; +} + +//======================================================================= +//function : MovePCurves +//purpose : +//======================================================================= +void BlockFix_UnionFaces::MovePCurves(TopoDS_Face& aTarget, + const TopoDS_Face& aSource) const +{ + BRep_Builder B; + for(TopExp_Explorer wexp(aSource,TopAbs_WIRE);wexp.More();wexp.Next()) { + Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire(TopoDS::Wire(wexp.Current()), + aTarget, Precision::Confusion()); + sfw->FixReorder(); + Standard_Boolean isReoredFailed = sfw->StatusReorder ( ShapeExtend_FAIL ); + sfw->FixEdgeCurves(); + if(isReoredFailed) + continue; + + sfw->FixShifted(); + sfw->FixDegenerated(); + + // remove degenerated edges from not degenerated points + ShapeAnalysis_Edge sae; + Handle(ShapeExtend_WireData) sewd = sfw->WireData(); + for(Standard_Integer i = 1; i<=sewd->NbEdges();i++) { + TopoDS_Edge E = sewd->Edge(i); + if(BRep_Tool::Degenerated(E)&&!sae.HasPCurve(E,aTarget)) { + sewd->Remove(i); + i--; + } + } + + TopoDS_Wire ResWire = sfw->Wire(); + B.Add(aTarget,ResWire); + } +} diff --git a/src/BlockFix/BlockFix_UnionFaces.hxx b/src/BlockFix/BlockFix_UnionFaces.hxx new file mode 100644 index 000000000..83140b08b --- /dev/null +++ b/src/BlockFix/BlockFix_UnionFaces.hxx @@ -0,0 +1,65 @@ +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 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.com + +#ifndef _BlockFix_UnionFaces_HeaderFile +#define _BlockFix_UnionFaces_HeaderFile + +#include +#include +#include +#include + +class TopoDS_Shape; +class TopoDS_Face; + +class BlockFix_UnionFaces +{ +public: + Standard_EXPORT BlockFix_UnionFaces(); + + Standard_EXPORT Standard_Real& GetTolerance(); + + /* \brief To get/set the OptimumNbFaces parameter + * + * If a being processed solid has less than OptimumNbFaces + * faces, no union will be performed. + * By default this parameter is set to 6 (to correctly + * process blocks - hexahedral solids) + * Special values: 0 - do all possible unions, regardless the faces quantity, + * negative - do not perform any unions, regardless the faces quantity. + * + */ + Standard_EXPORT Standard_Integer& GetOptimumNbFaces(); + + Standard_EXPORT TopoDS_Shape Perform(const TopoDS_Shape& Shape); + + Standard_EXPORT virtual Standard_Boolean IsSameDomain(const TopoDS_Face& aFace, + const TopoDS_Face& aChekedFace) const; + + Standard_EXPORT virtual void MovePCurves(TopoDS_Face& aTarget, + const TopoDS_Face& aSource) const; + +private: + Standard_Real myTolerance; + Standard_Integer myOptimumNbFaces; +}; + +#endif diff --git a/src/BlockFix/Makefile.am b/src/BlockFix/Makefile.am new file mode 100644 index 000000000..a3b37223d --- /dev/null +++ b/src/BlockFix/Makefile.am @@ -0,0 +1,55 @@ +# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, 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.salome-platform.org/ or email : webmaster.salome@opencascade.com + +# GEOM BlockFix : tools for Blocks algorithms +# File : Makefile.am +# Author : Julia DOROVSKIKH +# Module : GEOM + +include $(top_srcdir)/adm_local/unix/make_common_starter.am + +# Libraries targets +lib_LTLIBRARIES = libBlockFix.la + +dist_libBlockFix_la_SOURCES = \ + BlockFix_BlockFixAPI.cxx \ + BlockFix_CheckTool.cxx \ + BlockFix.cxx \ + BlockFix_PeriodicSurfaceModifier.cxx \ + BlockFix_SphereSpaceModifier.cxx \ + BlockFix_UnionEdges.cxx \ + BlockFix_UnionFaces.cxx + +# header files +salomeinclude_HEADERS = \ + BlockFix.hxx \ + BlockFix_BlockFixAPI.hxx \ + BlockFix_CheckTool.hxx \ + BlockFix_PeriodicSurfaceModifier.hxx \ + BlockFix_SphereSpaceModifier.hxx \ + BlockFix_UnionEdges.hxx \ + BlockFix_UnionFaces.hxx + +libBlockFix_la_CPPFLAGS = \ + $(CAS_CPPFLAGS) \ + $(KERNEL_CXXFLAGS) + +libBlockFix_la_LDFLAGS = \ + $(STDLIB) \ + $(CAS_LDPATH) -lTKBO -lTKShHealing -lTKBool -lTKMesh -lTKOffset \ + $(KERNEL_LDFLAGS) -lSALOMELocalTrace diff --git a/src/BlocksGUI/BlocksGUI_ExplodeDlg.cxx b/src/BlocksGUI/BlocksGUI_ExplodeDlg.cxx index a03687eab..c50811b82 100644 --- a/src/BlocksGUI/BlocksGUI_ExplodeDlg.cxx +++ b/src/BlocksGUI/BlocksGUI_ExplodeDlg.cxx @@ -509,7 +509,7 @@ GEOM::GEOM_Object_ptr BlocksGUI_ExplodeDlg::getFather( GEOM::GEOM_Object_ptr ) // Function : getNewObjectName // Purpose : Redefine this method to return proper name for a new object //================================================================ -QString BlocksGUI_ExplodeDlg::getNewObjectName() const +QString BlocksGUI_ExplodeDlg::getNewObjectName (int) const { return QString::null; } diff --git a/src/BlocksGUI/BlocksGUI_ExplodeDlg.h b/src/BlocksGUI/BlocksGUI_ExplodeDlg.h index 6be87bef4..1f396ccc5 100644 --- a/src/BlocksGUI/BlocksGUI_ExplodeDlg.h +++ b/src/BlocksGUI/BlocksGUI_ExplodeDlg.h @@ -50,7 +50,7 @@ protected: virtual bool execute( ObjectList& ); virtual GEOM::GEOM_Object_ptr getFather( GEOM::GEOM_Object_ptr ); - virtual QString getNewObjectName() const; + virtual QString getNewObjectName (int CurrObj = -1) const; private: void Init(); diff --git a/src/DisplayGUI/DisplayGUI.cxx b/src/DisplayGUI/DisplayGUI.cxx index 67665f66e..0dc9455d4 100644 --- a/src/DisplayGUI/DisplayGUI.cxx +++ b/src/DisplayGUI/DisplayGUI.cxx @@ -577,10 +577,10 @@ void DisplayGUI::ChangeDisplayMode( const int mode, SUIT_ViewWindow* viewWindow } } if(mode == 0 || mode == 1 || mode == 2) { - aStudy->setObjectProperty(mgrId,It.Value()->getEntry(),DISPLAY_MODE_PROP, mode); + aStudy->setObjectProperty(mgrId,It.Value()->getEntry(),GEOM::propertyName( GEOM::DisplayMode ), mode); } else if (mode == 4) { - aStudy->setObjectProperty(mgrId, It.Value()->getEntry(),VECTOR_MODE_PROP, vectorMode); + aStudy->setObjectProperty(mgrId, It.Value()->getEntry(),GEOM::propertyName( GEOM::EdgesDirection ), vectorMode); } } } @@ -625,10 +625,10 @@ void DisplayGUI::ChangeDisplayMode( const int mode, SUIT_ViewWindow* viewWindow } } if(mode == 0 || mode == 1 || mode == 2 || mode == 3) { - aStudy->setObjectProperty(mgrId, It.Value()->getEntry(),DISPLAY_MODE_PROP, mode); + aStudy->setObjectProperty(mgrId, It.Value()->getEntry(),GEOM::propertyName( GEOM::DisplayMode ), mode); } else if (mode == 4) { - aStudy->setObjectProperty(mgrId, It.Value()->getEntry(),VECTOR_MODE_PROP, vectorMode); + aStudy->setObjectProperty(mgrId, It.Value()->getEntry(),GEOM::propertyName( GEOM::EdgesDirection ), vectorMode); } } } diff --git a/src/DlgRef/DlgRef.cxx b/src/DlgRef/DlgRef.cxx index 164f483b4..a7a551f60 100644 --- a/src/DlgRef/DlgRef.cxx +++ b/src/DlgRef/DlgRef.cxx @@ -15,7 +15,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// // File : DlgRef.cxx // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) @@ -218,34 +217,6 @@ DlgRef_1Sel3Spin1Check::~DlgRef_1Sel3Spin1Check() { } -////////////////////////////////////////// -// DlgRef_1Sel4Spin2Check -////////////////////////////////////////// - -DlgRef_1Sel4Spin2Check::DlgRef_1Sel4Spin2Check( QWidget* parent, Qt::WindowFlags f ) -: QWidget( parent, f ) -{ - setupUi( this ); -} - -DlgRef_1Sel4Spin2Check::~DlgRef_1Sel4Spin2Check() -{ -} - -////////////////////////////////////////// -// DlgRef_1Sel4Spin -////////////////////////////////////////// - -DlgRef_1Sel4Spin::DlgRef_1Sel4Spin( QWidget* parent, Qt::WindowFlags f ) -: QWidget( parent, f ) -{ - setupUi( this ); -} - -DlgRef_1Sel4Spin::~DlgRef_1Sel4Spin() -{ -} - ////////////////////////////////////////// // DlgRef_1Sel5Spin1Check ////////////////////////////////////////// @@ -260,20 +231,6 @@ DlgRef_1Sel5Spin1Check::~DlgRef_1Sel5Spin1Check() { } -////////////////////////////////////////// -// DlgRef_1Sel5Spin -////////////////////////////////////////// - -DlgRef_1Sel5Spin::DlgRef_1Sel5Spin( QWidget* parent, Qt::WindowFlags f ) -: QWidget( parent, f ) -{ - setupUi( this ); -} - -DlgRef_1Sel5Spin::~DlgRef_1Sel5Spin() -{ -} - ////////////////////////////////////////// // DlgRef_1Spin ////////////////////////////////////////// @@ -526,20 +483,6 @@ DlgRef_2Sel3Spin::~DlgRef_2Sel3Spin() { } -////////////////////////////////////////// -// DlgRef_2Sel4Spin1Check -////////////////////////////////////////// - -DlgRef_2Sel4Spin1Check::DlgRef_2Sel4Spin1Check( QWidget* parent, Qt::WindowFlags f ) -: QWidget( parent, f ) -{ - setupUi( this ); -} - -DlgRef_2Sel4Spin1Check::~DlgRef_2Sel4Spin1Check() -{ -} - ////////////////////////////////////////// // DlgRef_2Sel ////////////////////////////////////////// diff --git a/src/DlgRef/DlgRef.h b/src/DlgRef/DlgRef.h index bda6da5b5..b727e96ec 100644 --- a/src/DlgRef/DlgRef.h +++ b/src/DlgRef/DlgRef.h @@ -15,7 +15,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// // File : DlgRef.h // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) @@ -259,38 +258,6 @@ public: ~DlgRef_1Sel3Spin1Check(); }; -////////////////////////////////////////// -// DlgRef_1Sel4Spin2Check -////////////////////////////////////////// - -#include "ui_DlgRef_1Sel4Spin2Check_QTD.h" - -class DLGREF_EXPORT DlgRef_1Sel4Spin2Check : public QWidget, - public Ui::DlgRef_1Sel4Spin2Check_QTD -{ - Q_OBJECT - -public: - DlgRef_1Sel4Spin2Check( QWidget* = 0, Qt::WindowFlags = 0 ); - ~DlgRef_1Sel4Spin2Check(); -}; - -////////////////////////////////////////// -// DlgRef_1Sel4Spin -////////////////////////////////////////// - -#include "ui_DlgRef_1Sel4Spin_QTD.h" - -class DLGREF_EXPORT DlgRef_1Sel4Spin : public QWidget, - public Ui::DlgRef_1Sel4Spin_QTD -{ - Q_OBJECT - -public: - DlgRef_1Sel4Spin( QWidget* = 0, Qt::WindowFlags = 0 ); - ~DlgRef_1Sel4Spin(); -}; - ////////////////////////////////////////// // DlgRef_1Sel5Spin1Check ////////////////////////////////////////// @@ -307,22 +274,6 @@ public: ~DlgRef_1Sel5Spin1Check(); }; -////////////////////////////////////////// -// DlgRef_1Sel5Spin -////////////////////////////////////////// - -#include "ui_DlgRef_1Sel5Spin_QTD.h" - -class DLGREF_EXPORT DlgRef_1Sel5Spin : public QWidget, - public Ui::DlgRef_1Sel5Spin_QTD -{ - Q_OBJECT - -public: - DlgRef_1Sel5Spin( QWidget* = 0, Qt::WindowFlags = 0 ); - ~DlgRef_1Sel5Spin(); -}; - ////////////////////////////////////////// // DlgRef_1Spin ////////////////////////////////////////// @@ -611,22 +562,6 @@ public: ~DlgRef_2Sel3Spin(); }; -////////////////////////////////////////// -// DlgRef_2Sel4Spin1Check -////////////////////////////////////////// - -#include "ui_DlgRef_2Sel4Spin1Check_QTD.h" - -class DLGREF_EXPORT DlgRef_2Sel4Spin1Check : public QWidget, - public Ui::DlgRef_2Sel4Spin1Check_QTD -{ - Q_OBJECT - -public: - DlgRef_2Sel4Spin1Check( QWidget* = 0, Qt::WindowFlags = 0 ); - ~DlgRef_2Sel4Spin1Check(); -}; - ////////////////////////////////////////// // DlgRef_2Sel ////////////////////////////////////////// diff --git a/src/DlgRef/DlgRef_1Sel4Spin2Check_QTD.ui b/src/DlgRef/DlgRef_1Sel4Spin2Check_QTD.ui deleted file mode 100644 index a6c6a6391..000000000 --- a/src/DlgRef/DlgRef_1Sel4Spin2Check_QTD.ui +++ /dev/null @@ -1,211 +0,0 @@ - - DlgRef_1Sel4Spin2Check_QTD - - - - 0 - 0 - 156 - 120 - - - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 6 - - - 6 - - - - - - - - - 9 - - - 9 - - - 9 - - - 9 - - - 6 - - - 6 - - - - - - 0 - 0 - - - - TL1 - - - false - - - - - - - - 0 - 0 - - - - - - - - - - - - - - - - 0 - 0 - - - - TL2 - - - false - - - - - - - - - - - - 0 - 0 - - - - TL3 - - - false - - - - - - - - - - - - 0 - 0 - - - - TL4 - - - false - - - - - - - - - - - - 0 - 0 - - - - TL5 - - - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - qPixmapFromMimeSource - - - SalomeApp_DoubleSpinBox - QDoubleSpinBox -
    SalomeApp_DoubleSpinBox.h
    -
    -
    - - PushButton1 - LineEdit1 - SpinBox_DX - SpinBox_DY - SpinBox_DZ - SpinBox_SC - CheckBox1 - CheckBox2 - - - -
    diff --git a/src/DlgRef/DlgRef_1Sel4Spin_QTD.ui b/src/DlgRef/DlgRef_1Sel4Spin_QTD.ui deleted file mode 100644 index 43cbcba2b..000000000 --- a/src/DlgRef/DlgRef_1Sel4Spin_QTD.ui +++ /dev/null @@ -1,214 +0,0 @@ - - DlgRef_1Sel4Spin_QTD - - - - 0 - 0 - 271 - 117 - - - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 6 - - - 6 - - - - - - - - - 9 - - - 9 - - - 9 - - - 9 - - - 6 - - - 6 - - - - - - 0 - 0 - - - - TL6 - - - false - - - - - - - - - - - - - - 6 - - - 9 - - - 9 - - - 9 - - - 9 - - - - - - 0 - 0 - - - - TL3 - - - false - - - - - - - - - - - 0 - 0 - - - - TL4 - - - false - - - - - - - - - - - 0 - 0 - - - - TL5 - - - false - - - - - - - - - - - - - - - - - 0 - 0 - - - - - - - - - - - - 0 - 0 - - - - TL1 - - - false - - - - - - - - - - qPixmapFromMimeSource - - - SalomeApp_DoubleSpinBox - QDoubleSpinBox -
    SalomeApp_DoubleSpinBox.h
    -
    -
    - - PushButton1 - LineEdit1 - SpinBox_DX - SpinBox_DY - SpinBox_DZ - SpinBox_S - - - -
    diff --git a/src/DlgRef/DlgRef_1Sel5Spin_QTD.ui b/src/DlgRef/DlgRef_1Sel5Spin_QTD.ui deleted file mode 100644 index 1b945b5a8..000000000 --- a/src/DlgRef/DlgRef_1Sel5Spin_QTD.ui +++ /dev/null @@ -1,232 +0,0 @@ - - DlgRef_1Sel5Spin_QTD - - - - 0 - 0 - 174 - 123 - - - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - - - - 9 - - - 9 - - - 9 - - - 9 - - - 6 - - - 6 - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 6 - - - 6 - - - - - - 0 - 0 - - - - TL4 - - - false - - - - - - - - 0 - 0 - - - - TL3 - - - false - - - - - - - - - - - 0 - 0 - - - - TL2 - - - false - - - - - - - - - - - 0 - 0 - - - - TL6 - - - false - - - - - - - - - - - - - - - - - 0 - 0 - - - - TL5 - - - false - - - - - - - - - - 0 - 0 - - - - - - - - - - - - 0 - 0 - - - - TL1 - - - false - - - - - - - - - - - - - qPixmapFromMimeSource - - - SalomeApp_DoubleSpinBox - QDoubleSpinBox -
    SalomeApp_DoubleSpinBox.h
    -
    -
    - - PushButton1 - LineEdit1 - SpinBox1 - SpinBox2 - SpinBox4 - SpinBox5 - SpinBox3 - - - -
    diff --git a/src/DlgRef/DlgRef_2Sel4Spin1Check_QTD.ui b/src/DlgRef/DlgRef_2Sel4Spin1Check_QTD.ui deleted file mode 100644 index 5d0afce71..000000000 --- a/src/DlgRef/DlgRef_2Sel4Spin1Check_QTD.ui +++ /dev/null @@ -1,237 +0,0 @@ - - DlgRef_2Sel4Spin1Check_QTD - - - - 0 - 0 - 156 - 197 - - - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - - - - 9 - - - 9 - - - 9 - - - 9 - - - 6 - - - 6 - - - - - - - - - - - - - - - - - - - - - - - - - 0 - 0 - - - - TL6 - - - false - - - - - - - - 0 - 0 - - - - TL5 - - - false - - - - - - - - 0 - 0 - - - - TL4 - - - false - - - - - - - - 0 - 0 - - - - TL3 - - - false - - - - - - - - 0 - 0 - - - - TL2 - - - false - - - - - - - - 0 - 0 - - - - - - - - - - - - - - - 0 - 0 - - - - TL1 - - - false - - - - - - - - - - - 0 - 0 - - - - - - - - - - - - - - qPixmapFromMimeSource - - - SalomeApp_DoubleSpinBox - QDoubleSpinBox -
    SalomeApp_DoubleSpinBox.h
    -
    - - SalomeApp_IntSpinBox - QSpinBox -
    SalomeApp_IntSpinBox.h
    -
    -
    - - PushButton1 - LineEdit1 - PushButton2 - LineEdit2 - SpinBox_DX1 - SpinBox_DY1 - CheckButton1 - SpinBox_DX2 - SpinBox_DY2 - - - -
    diff --git a/src/DlgRef/Makefile.am b/src/DlgRef/Makefile.am index deaa27026..681636166 100644 --- a/src/DlgRef/Makefile.am +++ b/src/DlgRef/Makefile.am @@ -15,9 +15,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# -# GEOM DLGREF : # File : Makefile.am # Author : Alexander BORODIN, Open CASCADE S.A.S. (alexander.borodin@opencascade.com) # Package : DlgRef @@ -50,10 +48,7 @@ UIC_FILES = \ ui_DlgRef_1Sel3Spin_QTD.h \ ui_DlgRef_1Sel3Spin1Check_QTD.h \ ui_DlgRef_1Sel3Spin2Check1Spin_QTD.h \ - ui_DlgRef_1Sel4Spin2Check_QTD.h \ - ui_DlgRef_1Sel4Spin_QTD.h \ ui_DlgRef_1Sel5Spin1Check_QTD.h \ - ui_DlgRef_1Sel5Spin_QTD.h \ ui_DlgRef_1Sel_QTD.h \ ui_DlgRef_1SelExt_QTD.h \ ui_DlgRef_1Spin_QTD.h \ @@ -72,7 +67,6 @@ UIC_FILES = \ ui_DlgRef_2Sel2Spin2Push_QTD.h \ ui_DlgRef_2Sel3Spin2Rb_QTD.h \ ui_DlgRef_2Sel3Spin_QTD.h \ - ui_DlgRef_2Sel4Spin1Check_QTD.h \ ui_DlgRef_2Sel_QTD.h \ ui_DlgRef_2SelExt_QTD.h \ ui_DlgRef_2Spin_QTD.h \ diff --git a/src/EntityGUI/EntityGUI_SubShapeDlg.cxx b/src/EntityGUI/EntityGUI_SubShapeDlg.cxx index 5facd0411..3de5f8e89 100644 --- a/src/EntityGUI/EntityGUI_SubShapeDlg.cxx +++ b/src/EntityGUI/EntityGUI_SubShapeDlg.cxx @@ -831,7 +831,7 @@ GEOM::GEOM_Object_ptr EntityGUI_SubShapeDlg::getFather(GEOM::GEOM_Object_ptr) // Function : getNewObjectName // Purpose : //================================================================ -QString EntityGUI_SubShapeDlg::getNewObjectName() const +QString EntityGUI_SubShapeDlg::getNewObjectName (int) const { return QString::null; } diff --git a/src/EntityGUI/EntityGUI_SubShapeDlg.h b/src/EntityGUI/EntityGUI_SubShapeDlg.h index d9bf30a3f..816059e86 100644 --- a/src/EntityGUI/EntityGUI_SubShapeDlg.h +++ b/src/EntityGUI/EntityGUI_SubShapeDlg.h @@ -51,7 +51,7 @@ protected: virtual bool isValid (QString&); virtual bool execute (ObjectList&); virtual GEOM::GEOM_Object_ptr getFather (GEOM::GEOM_Object_ptr); - virtual QString getNewObjectName() const; + virtual QString getNewObjectName (int CurrObj = -1) const; void closeEvent (QCloseEvent*); diff --git a/src/GEOM/Makefile.am b/src/GEOM/Makefile.am index 68f248fb6..98fcfe532 100644 --- a/src/GEOM/Makefile.am +++ b/src/GEOM/Makefile.am @@ -21,7 +21,6 @@ # Author : Damien COQUERET (OCC) # Modified by : Alexander BORODIN (OCN) - autotools usage # Module : GEOM -# $Header: include $(top_srcdir)/adm_local/unix/make_common_starter.am diff --git a/src/GEOMAlgo/BlockFix.cdl b/src/GEOMAlgo/BlockFix.cdl deleted file mode 100644 index 961af6625..000000000 --- a/src/GEOMAlgo/BlockFix.cdl +++ /dev/null @@ -1,67 +0,0 @@ --- Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE --- --- Copyright (C) 2003-2007 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.com --- - --- File: BlockFix.cdl --- Created: Tue Dec 7 11:59:05 2004 --- Author: Pavel Durandin --- -package BlockFix - -uses - - TColStd, - gp, - Geom, - Geom2d, - GeomAbs, - TopLoc, - TopoDS, - BRepTools, - TopTools, - ShapeBuild - -is - - class SphereSpaceModifier; - - class UnionFaces; - - class UnionEdges; - - class BlockFixAPI; - ---Purpose: API class to perform the fixing of the - -- block - - class PeriodicSurfaceModifier; - - class CheckTool; - - RotateSphereSpace (S: Shape from TopoDS; Tol: Real) - returns Shape from TopoDS; - - FixRanges (S: Shape from TopoDS; Tol: Real) - returns Shape from TopoDS; - ---Purpose: checking and fixing cases where parametric - -- boundaries of face based on periodic surface are not - -- contained in the range of this surface. - -end BlockFix; diff --git a/src/GEOMAlgo/BlockFix.cxx b/src/GEOMAlgo/BlockFix.cxx deleted file mode 100644 index 0e4f9bb21..000000000 --- a/src/GEOMAlgo/BlockFix.cxx +++ /dev/null @@ -1,344 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 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.com - -// File: BlockFix.cxx -// Created: Tue Dec 7 11:59:05 2004 -// Author: Pavel DURANDIN - -#include - -#include -#include - -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include - -#include - -#include -#include -#include - -#include - -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include -#include - -#include - -#include -#include -#include -#include -#include - -#include - -#include - -//======================================================================= -//function : FixResult -//purpose : auxilary -//======================================================================= -static void FixResult(const TopoDS_Shape& result, - Handle(ShapeBuild_ReShape)& Context, - const Standard_Real Tol) -{ - for (TopExp_Explorer ex_f(result,TopAbs_FACE); ex_f.More(); ex_f.Next()) { - TopoDS_Shape aShape = Context->Apply(ex_f.Current().Oriented(TopAbs_FORWARD)); - // face coud not be dropped or splitted on this step - TopoDS_Face aFace = TopoDS::Face(aShape); - TopLoc_Location L; - Handle(Geom_Surface) Surf = BRep_Tool::Surface(aFace,L); - - if( Surf->IsKind(STANDARD_TYPE(Geom_SphericalSurface)) || - Surf->IsKind(STANDARD_TYPE(Geom_CylindricalSurface)) ) { - - Standard_Integer nbWires = 0; - for (TopExp_Explorer ex_w(aFace,TopAbs_WIRE); ex_w.More(); ex_w.Next()) { - nbWires++; - Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire(TopoDS::Wire(ex_w.Current()), - aFace, - Precision::Confusion()); - sfw->FixReorder(); - if(sfw->StatusReorder ( ShapeExtend_FAIL )) - continue; - - sfw->SetPrecision(2.*Tol); - sfw->FixShifted(); - - Standard_Boolean isDone = sfw->LastFixStatus ( ShapeExtend_DONE ); - isDone |= sfw->FixDegenerated(); - - // remove degenerated edges from not degenerated points - ShapeAnalysis_Edge sae; - Handle(ShapeExtend_WireData) sewd = sfw->WireData(); - Standard_Integer i; - for( i = 1; i<=sewd->NbEdges();i++) { - TopoDS_Edge E = sewd->Edge(i); - if(BRep_Tool::Degenerated(E)&&!sae.HasPCurve(E,aFace)) { - sewd->Remove(i); - isDone = Standard_True; - i--; - } - } - - //isDone |= sfw->FixLacking(); // commented by skl 22.03.2005 (PAL8395) - - // remove neighbour seam edges - if(isDone) { - for( i = 1; iNbEdges();i++) { - if(sewd->IsSeam(i) && sewd->IsSeam(i+1)) { - isDone = Standard_True; - sewd->Remove(i); - sewd->Remove(i); - i--; - } - } - if(sewd->IsSeam(1) && sewd->IsSeam(sewd->NbEdges())) { - sewd->Remove(1); - sewd->Remove(sewd->NbEdges()); - } - } - - if(isDone) { - TopoDS_Wire ResWire = sfw->Wire(); - Context->Replace(ex_w.Current(), ResWire); - }; - } - // Implement fix orientation in case of several wires - if(nbWires > 1) { - TopoDS_Face aFixedFace = TopoDS::Face(Context->Apply(aFace)); - Handle(ShapeFix_Face) sff = new ShapeFix_Face(aFixedFace); - if(sff->FixOrientation()) - Context->Replace(aFixedFace,sff->Face()); - } - } - } -} - -//======================================================================= -//function : RotateSphereSpace -//purpose : -//======================================================================= -TopoDS_Shape BlockFix::RotateSphereSpace (const TopoDS_Shape& S, - const Standard_Real Tol) -{ - // Create a modification description - Handle(BlockFix_SphereSpaceModifier) SR = new BlockFix_SphereSpaceModifier; - SR->SetTolerance(Tol); - - TopTools_DataMapOfShapeShape context; - BRepTools_Modifier MD; - TopoDS_Shape result = ShapeCustom::ApplyModifier ( S, SR, context,MD ); - - Handle(ShapeBuild_ReShape) RS = new ShapeBuild_ReShape; - FixResult(result,RS,Tol); - result = RS->Apply(result); - - ShapeFix_Edge sfe; - for(TopExp_Explorer exp(result,TopAbs_EDGE); exp.More(); exp.Next()) { - TopoDS_Edge E = TopoDS::Edge(exp.Current()); - sfe.FixVertexTolerance (E); - } - - ShapeFix::SameParameter(result,Standard_False); - return result; -} - -//======================================================================= -//function : RefillProblemFaces -//purpose : -//======================================================================= -TopoDS_Shape BlockFix::RefillProblemFaces (const TopoDS_Shape& aShape) -{ - Standard_Integer NbSamples = 10; - - TopTools_ListOfShape theFaces; - - TopExp_Explorer Explo(aShape, TopAbs_FACE); - for (; Explo.More(); Explo.Next()) - { - TopoDS_Face aFace = TopoDS::Face(Explo.Current()); - BRepAdaptor_Surface BAsurf(aFace); - GeomAbs_SurfaceType SurfType = BAsurf.GetType(); - if (SurfType >= GeomAbs_BezierSurface) - { - TopExp_Explorer fexp(aFace, TopAbs_EDGE); - for (; fexp.More(); fexp.Next()) - { - const TopoDS_Edge& anEdge = TopoDS::Edge(fexp.Current()); - if (BRep_Tool::Degenerated(anEdge)) - { - TopoDS_Vertex V1, V2; - TopExp::Vertices(anEdge, V1, V2); - if (V1.IsSame(V2)) - { - gp_Pnt aPnt = BRep_Tool::Pnt(V1); - Standard_Real TolV = BRep_Tool::Tolerance(V1); - Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aFace); - Handle(ShapeAnalysis_Surface) Analyser = new ShapeAnalysis_Surface(aSurf); - if (Analyser->IsDegenerated(aPnt, TolV)) - { - theFaces.Append(aFace); - break; - } - } - } - } - } - } - - //Now all problem faces are collected in the list "theFaces" - BRepTools_Substitution aSubst; - TopTools_ListIteratorOfListOfShape itl(theFaces); - for (; itl.More(); itl.Next()) - { - const TopoDS_Face& aFace = TopoDS::Face(itl.Value()); - BRepOffsetAPI_MakeFilling Filler; - for (Explo.Init(aFace, TopAbs_EDGE); Explo.More(); Explo.Next()) - { - const TopoDS_Edge& anEdge = TopoDS::Edge(Explo.Current()); - if (!BRep_Tool::Degenerated(anEdge)) - Filler.Add(anEdge, GeomAbs_C0); - } - Standard_Real Umin, Umax, Vmin, Vmax; - BRepTools::UVBounds(aFace, Umin, Umax, Vmin, Vmax); - //Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aFace); - Standard_Integer i, j; - for (i = 1; i < NbSamples; i++) - for (j = 1; j < NbSamples; j++) { - /* - gp_Pnt aPoint = aSurf->Value(Umin + i*(Umax-Umin)/NbSamples, - Vmin + j*(Vmax-Vmin)/NbSamples); - Filler.Add(aPoint); - */ - Filler.Add(Umin + i*(Umax-Umin)/NbSamples, - Vmin + j*(Vmax-Vmin)/NbSamples, - aFace, GeomAbs_G1); - } - - Filler.Build(); - if (Filler.IsDone()) - { - for (Explo.Init(aFace, TopAbs_EDGE); Explo.More(); Explo.Next()) - { - const TopoDS_Edge& anEdge = TopoDS::Edge(Explo.Current()); - TopTools_ListOfShape Ledge; - if (!BRep_Tool::Degenerated(anEdge)) - { - const TopTools_ListOfShape& Ledges = Filler.Generated(anEdge); - if (!Ledges.IsEmpty()) { - TopoDS_Shape NewEdge = Ledges.First(); - Ledge.Append(NewEdge.Oriented(TopAbs_FORWARD)); - } - } - aSubst.Substitute(anEdge, Ledge); - } - TopTools_ListOfShape Lface; - TopoDS_Face NewFace = TopoDS::Face(Filler.Shape()); - NewFace.Orientation(TopAbs_FORWARD); - BRepAdaptor_Surface NewBAsurf(NewFace); - gp_Pnt MidPnt; - gp_Vec D1U, D1V, Normal, NewNormal; - Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aFace); - aSurf->D1((Umin+Umax)*0.5, (Vmin+Vmax)*0.5, MidPnt, D1U, D1V); - Normal = D1U ^ D1V; - NewBAsurf.D1((NewBAsurf.FirstUParameter() + NewBAsurf.LastUParameter())*0.5, - (NewBAsurf.FirstVParameter() + NewBAsurf.LastVParameter())*0.5, - MidPnt, D1U, D1V); - NewNormal = D1U ^ D1V; - if (Normal * NewNormal < 0.) - NewFace.Reverse(); - Lface.Append(NewFace); - aSubst.Substitute(aFace, Lface); - } - } - aSubst.Build(aShape); - - TopoDS_Shape Result = aShape; - if (aSubst.IsCopied(aShape)) - Result = aSubst.Copy(aShape).First(); - - BRepTools::RemoveUnusedPCurves(Result); - - return Result; -} - -//======================================================================= -//function : FixRanges -//purpose : -//======================================================================= -TopoDS_Shape BlockFix::FixRanges (const TopoDS_Shape& S, - const Standard_Real Tol) -{ - // Create a modification description - Handle(BlockFix_PeriodicSurfaceModifier) SR = new BlockFix_PeriodicSurfaceModifier; - SR->SetTolerance(Tol); - - TopTools_DataMapOfShapeShape context; - BRepTools_Modifier MD; - TopoDS_Shape result = ShapeCustom::ApplyModifier ( S, SR, context,MD ); - - Handle(ShapeBuild_ReShape) RS = new ShapeBuild_ReShape; - FixResult(result,RS,Tol); - result = RS->Apply(result); - - ShapeFix_Edge sfe; - for(TopExp_Explorer exp(result,TopAbs_EDGE); exp.More(); exp.Next()) { - TopoDS_Edge E = TopoDS::Edge(exp.Current()); - sfe.FixVertexTolerance (E); - } - - ShapeFix::SameParameter(result,Standard_False); - - return result; -} diff --git a/src/GEOMAlgo/BlockFix.hxx b/src/GEOMAlgo/BlockFix.hxx deleted file mode 100644 index 34007be5c..000000000 --- a/src/GEOMAlgo/BlockFix.hxx +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 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.com -// - -#ifndef _BlockFix_HeaderFile -#define _BlockFix_HeaderFile - -#ifndef _Standard_Real_HeaderFile -#include -#endif - -class TopoDS_Shape; -class BlockFix_SphereSpaceModifier; -class BlockFix_UnionFaces; -class BlockFix_UnionEdges; -class BlockFix_BlockFixAPI; -class BlockFix_PeriodicSurfaceModifier; -class BlockFix_CheckTool; - -#ifndef _Standard_HeaderFile -#include -#endif -#ifndef _Standard_Macro_HeaderFile -#include -#endif - -class BlockFix { - -public: - - void* operator new(size_t,void* anAddress) - { - return anAddress; - } - void* operator new(size_t size) - { - return Standard::Allocate(size); - } - void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } - - Standard_EXPORT static TopoDS_Shape RotateSphereSpace(const TopoDS_Shape& S,const Standard_Real Tol); - Standard_EXPORT static TopoDS_Shape RefillProblemFaces(const TopoDS_Shape& S); - Standard_EXPORT static TopoDS_Shape FixRanges(const TopoDS_Shape& S,const Standard_Real Tol); - -protected: - -private: - -friend class BlockFix_SphereSpaceModifier; -friend class BlockFix_UnionFaces; -friend class BlockFix_UnionEdges; -friend class BlockFix_BlockFixAPI; -friend class BlockFix_PeriodicSurfaceModifier; -friend class BlockFix_CheckTool; - -}; - -// other Inline functions and methods (like "C++: function call" methods) - -#endif diff --git a/src/GEOMAlgo/BlockFix.ixx b/src/GEOMAlgo/BlockFix.ixx deleted file mode 100644 index 2ea228ff7..000000000 --- a/src/GEOMAlgo/BlockFix.ixx +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 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.com -// - -#include - - - - diff --git a/src/GEOMAlgo/BlockFix.jxx b/src/GEOMAlgo/BlockFix.jxx deleted file mode 100644 index 8649f8895..000000000 --- a/src/GEOMAlgo/BlockFix.jxx +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 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.com -// - -#ifndef _TopoDS_Shape_HeaderFile -#include -#endif -#ifndef _BlockFix_HeaderFile -#include -#endif diff --git a/src/GEOMAlgo/BlockFix_BlockFixAPI.cdl b/src/GEOMAlgo/BlockFix_BlockFixAPI.cdl deleted file mode 100644 index 8cb4c49ce..000000000 --- a/src/GEOMAlgo/BlockFix_BlockFixAPI.cdl +++ /dev/null @@ -1,68 +0,0 @@ --- Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE --- --- Copyright (C) 2003-2007 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.com --- - --- File: BlockFix_BlockFixAPI.cdl --- Created: Tue Dec 7 17:56:09 2004 --- Author: Pavel Durandin --- -class BlockFixAPI from BlockFix inherits TShared from MMgt - - ---Purpose: - -uses - - Shape from TopoDS, - ReShape from ShapeBuild - -is - Create returns BlockFixAPI from BlockFix; - ---Purpose: Empty constructor - - SetShape(me: mutable; Shape: Shape from TopoDS); - ---Purpose: Sets the shape to be operated on - ---C++: inline - - Perform(me: mutable); - ---Purpose: - - Shape(me) returns Shape from TopoDS; - ---Purpose: Returns resulting shape. - ---C++: inline - - Context(me:mutable) returns ReShape from ShapeBuild; - ---Purpose: Returns modifiable context for storing the - -- mofifications - ---C++: inline - ---C++: return & - - Tolerance (me:mutable) returns Real; - ---Purpose: Returns modifiable tolerance of recognition - ---C++: inline - ---C++: return & - -fields - - myContext : ReShape from ShapeBuild; - myShape : Shape from TopoDS; - myTolerance : Real from Standard; - -end BlockFixAPI from BlockFix; diff --git a/src/GEOMAlgo/BlockFix_BlockFixAPI.cxx b/src/GEOMAlgo/BlockFix_BlockFixAPI.cxx deleted file mode 100644 index 3c82e4a84..000000000 --- a/src/GEOMAlgo/BlockFix_BlockFixAPI.cxx +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 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.com - -// File: BlockFix_BlockFixAPI.cxx -// Created: Tue Dec 7 11:59:05 2004 -// Author: Pavel DURANDIN - -#include - -#include -#include -#include - -#include - -#include - -#include - -//======================================================================= -//function : ShapeConvert_CanonicAPI -//purpose : -//======================================================================= - -BlockFix_BlockFixAPI::BlockFix_BlockFixAPI() -{ - myTolerance = Precision::Confusion(); - myOptimumNbFaces = 6; -} - -//======================================================================= -//function : Perform -//purpose : -//======================================================================= - -void BlockFix_BlockFixAPI::Perform() -{ - // processing spheres with degenerativities - TopoDS_Shape aShape = Shape(); - myShape = BlockFix::RotateSphereSpace(aShape,myTolerance); - - // try to approximate non-canonic surfaces - // with singularities on boundaries by filling - myShape = BlockFix::RefillProblemFaces(myShape); - - // faces unification - BlockFix_UnionFaces aFaceUnifier; - aFaceUnifier.GetTolerance() = myTolerance; - aFaceUnifier.GetOptimumNbFaces() = myOptimumNbFaces; - TopoDS_Shape aResult = aFaceUnifier.Perform(myShape); - - // avoid problem with degenerated edges appearance - // due to shape quality regress - ShapeUpgrade_RemoveLocations RemLoc; - RemLoc.Remove(aResult); - aResult = RemLoc.GetResult(); - - // edges unification - BlockFix_UnionEdges anEdgeUnifier; - myShape = anEdgeUnifier.Perform(aResult,myTolerance); - - TopoDS_Shape aRes = BlockFix::FixRanges(myShape,myTolerance); - myShape = aRes; -} diff --git a/src/GEOMAlgo/BlockFix_BlockFixAPI.hxx b/src/GEOMAlgo/BlockFix_BlockFixAPI.hxx deleted file mode 100644 index 7be25cc57..000000000 --- a/src/GEOMAlgo/BlockFix_BlockFixAPI.hxx +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 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.com -// - -#ifndef _BlockFix_BlockFixAPI_HeaderFile -#define _BlockFix_BlockFixAPI_HeaderFile - -#ifndef _Standard_HeaderFile -#include -#endif -#ifndef _Handle_BlockFix_BlockFixAPI_HeaderFile -#include -#endif - -#ifndef _Handle_ShapeBuild_ReShape_HeaderFile -#include -#endif -#ifndef _TopoDS_Shape_HeaderFile -#include -#endif -#ifndef _Standard_Real_HeaderFile -#include -#endif -#ifndef _MMgt_TShared_HeaderFile -#include -#endif - -class ShapeBuild_ReShape; -class TopoDS_Shape; - - -class BlockFix_BlockFixAPI : public MMgt_TShared -{ -public: - void* operator new(size_t,void* anAddress) - { - return anAddress; - } - void* operator new(size_t size) - { - return Standard::Allocate(size); - } - void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } - - // Methods PUBLIC - // - Standard_EXPORT BlockFix_BlockFixAPI(); - void SetShape(const TopoDS_Shape& Shape); - Standard_EXPORT void Perform(); - TopoDS_Shape Shape() const; - Handle_ShapeBuild_ReShape& Context(); - Standard_Real& Tolerance(); - Standard_Integer& OptimumNbFaces(); - Standard_EXPORT ~BlockFix_BlockFixAPI(); - - // Type management - // - Standard_EXPORT friend Handle_Standard_Type& BlockFix_BlockFixAPI_Type_(); - Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; - Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; - -private: - // Fields PRIVATE - // - Handle_ShapeBuild_ReShape myContext; - TopoDS_Shape myShape; - Standard_Real myTolerance; - Standard_Integer myOptimumNbFaces; -}; - -#include - -#endif diff --git a/src/GEOMAlgo/BlockFix_BlockFixAPI.ixx b/src/GEOMAlgo/BlockFix_BlockFixAPI.ixx deleted file mode 100644 index 4d06a875e..000000000 --- a/src/GEOMAlgo/BlockFix_BlockFixAPI.ixx +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 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.com -// - -#include - -#ifndef _Standard_TypeMismatch_HeaderFile -#include -#endif - -BlockFix_BlockFixAPI::~BlockFix_BlockFixAPI() {} - - - -Standard_EXPORT Handle_Standard_Type& BlockFix_BlockFixAPI_Type_() -{ - - static Handle_Standard_Type aType1 = STANDARD_TYPE(MMgt_TShared); - if ( aType1.IsNull()) aType1 = STANDARD_TYPE(MMgt_TShared); - static Handle_Standard_Type aType2 = STANDARD_TYPE(Standard_Transient); - if ( aType2.IsNull()) aType2 = STANDARD_TYPE(Standard_Transient); - - - static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,NULL}; - static Handle_Standard_Type _aType = new Standard_Type("BlockFix_BlockFixAPI", - sizeof(BlockFix_BlockFixAPI), - 1, - (Standard_Address)_Ancestors, - (Standard_Address)NULL); - - return _aType; -} - - -// DownCast method -// allow safe downcasting -// -const Handle(BlockFix_BlockFixAPI) Handle(BlockFix_BlockFixAPI)::DownCast(const Handle(Standard_Transient)& AnObject) -{ - Handle(BlockFix_BlockFixAPI) _anOtherObject; - - if (!AnObject.IsNull()) { - if (AnObject->IsKind(STANDARD_TYPE(BlockFix_BlockFixAPI))) { - _anOtherObject = Handle(BlockFix_BlockFixAPI)((Handle(BlockFix_BlockFixAPI)&)AnObject); - } - } - - return _anOtherObject ; -} -const Handle(Standard_Type)& BlockFix_BlockFixAPI::DynamicType() const -{ - return STANDARD_TYPE(BlockFix_BlockFixAPI) ; -} -Standard_Boolean BlockFix_BlockFixAPI::IsKind(const Handle(Standard_Type)& AType) const -{ - return (STANDARD_TYPE(BlockFix_BlockFixAPI) == AType || MMgt_TShared::IsKind(AType)); -} -Handle_BlockFix_BlockFixAPI::~Handle_BlockFix_BlockFixAPI() {} - diff --git a/src/GEOMAlgo/BlockFix_BlockFixAPI.jxx b/src/GEOMAlgo/BlockFix_BlockFixAPI.jxx deleted file mode 100644 index 945a6ed88..000000000 --- a/src/GEOMAlgo/BlockFix_BlockFixAPI.jxx +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 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.com -// - -#ifndef _ShapeBuild_ReShape_HeaderFile -#include -#endif -#ifndef _TopoDS_Shape_HeaderFile -#include -#endif -#ifndef _BlockFix_BlockFixAPI_HeaderFile -#include -#endif diff --git a/src/GEOMAlgo/BlockFix_BlockFixAPI.lxx b/src/GEOMAlgo/BlockFix_BlockFixAPI.lxx deleted file mode 100644 index 5992e1794..000000000 --- a/src/GEOMAlgo/BlockFix_BlockFixAPI.lxx +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 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.com -// - -#include - -//======================================================================= -//function : SetShape -//purpose : -//======================================================================= - -inline void BlockFix_BlockFixAPI::SetShape(const TopoDS_Shape& Shape) -{ - myShape = Shape; -} - -//======================================================================= -//function : Shape -//purpose : -//======================================================================= - -inline TopoDS_Shape BlockFix_BlockFixAPI::Shape() const -{ - return myShape; -} - -//======================================================================= -//function : Context -//purpose : -//======================================================================= - -inline Handle(ShapeBuild_ReShape)& BlockFix_BlockFixAPI::Context() -{ - return myContext; -} - -//======================================================================= -//function : Tolerance -//purpose : -//======================================================================= - -inline Standard_Real& BlockFix_BlockFixAPI::Tolerance() -{ - return myTolerance; -} - -//======================================================================= -//function : OptimumNbFaces -//purpose : -//======================================================================= - -inline Standard_Integer& BlockFix_BlockFixAPI::OptimumNbFaces() -{ - return myOptimumNbFaces; -} diff --git a/src/GEOMAlgo/BlockFix_CheckTool.cdl b/src/GEOMAlgo/BlockFix_CheckTool.cdl deleted file mode 100644 index c5423377f..000000000 --- a/src/GEOMAlgo/BlockFix_CheckTool.cdl +++ /dev/null @@ -1,67 +0,0 @@ --- Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE --- --- Copyright (C) 2003-2007 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.com --- - --- File: BlockFix_CheckTool.cdl --- Created: Fri Dec 17 10:36:58 2004 --- Author: Sergey KUUL --- -class CheckTool from BlockFix - - ---Purpose: - -uses - - Shape from TopoDS, - SequenceOfShape from TopTools - -is - - Create returns CheckTool from BlockFix; - ---Purpose: Empty constructor - - SetShape(me: in out; aShape: Shape from TopoDS); - - Perform(me: in out); - ---Purpose: - - NbPossibleBlocks(me) returns Integer; - - PossibleBlock(me; num: Integer) returns Shape from TopoDS; - - DumpCheckResult(me; S : in out OStream); - ---Purpose: Dumps results of checking - - -fields - - myShape : Shape from TopoDS; - myHasCheck : Boolean; - myNbSolids : Integer; - myNbBlocks : Integer; - myPossibleBlocks : SequenceOfShape from TopTools; - myNbDegen : Integer; - myNbUF : Integer; - myNbUE : Integer; - myNbUFUE : Integer; - myBadRanges : Integer; - -end CheckTool; diff --git a/src/GEOMAlgo/BlockFix_CheckTool.cxx b/src/GEOMAlgo/BlockFix_CheckTool.cxx deleted file mode 100644 index 674ef69dd..000000000 --- a/src/GEOMAlgo/BlockFix_CheckTool.cxx +++ /dev/null @@ -1,279 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 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.com -// - -// File: BlockFix_CheckTool.cxx -// Created: 17.12.04 11:15:25 -// Author: Sergey KUUL -// -#include - -//#include -//#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -//======================================================================= -//function : BlockFix_CheckTool() -//purpose : Constructor -//======================================================================= - -BlockFix_CheckTool::BlockFix_CheckTool( ) -{ - myHasCheck = Standard_False; - myPossibleBlocks.Clear(); -} - - -//======================================================================= -//function : SetShape -//purpose : -//======================================================================= - -void BlockFix_CheckTool::SetShape(const TopoDS_Shape& aShape) -{ - myHasCheck = Standard_False; - myShape = aShape; - myPossibleBlocks.Clear(); -} - - -//======================================================================= -//function : Perform -//purpose : -//======================================================================= - -void BlockFix_CheckTool::Perform() -{ - myNbSolids=0; - myNbBlocks=0; - myNbDegen=0; - myNbUF=0; - myNbUE=0; - myNbUFUE=0; - - TopExp_Explorer exps (myShape, TopAbs_SOLID); - TopTools_MapOfShape mapS; - for (; exps.More(); exps.Next()) { - TopoDS_Solid aSolid = TopoDS::Solid(exps.Current()); - if (!mapS.Add(aSolid)) continue; - myNbSolids++; - Standard_Boolean IsBlock=Standard_True; - Standard_Boolean MayBeUF=Standard_False; - Standard_Boolean MayBeUE=Standard_False; - Standard_Integer nf=0; - TopExp_Explorer expf (aSolid, TopAbs_FACE); - TopTools_MapOfShape mapF; - for (; expf.More(); expf.Next()) { - if (mapF.Add(expf.Current())) - nf++; - } - - if (nf < 6) { - IsBlock = Standard_False; - } - else if (nf > 6) { - IsBlock = Standard_False; - // check faces unification - TopTools_SequenceOfShape faces; - mapF.Clear(); - for (expf.Init(aSolid, TopAbs_FACE); expf.More(); expf.Next()) { - if (mapF.Add(expf.Current())) { - TopoDS_Face aFace = TopoDS::Face(expf.Current()); - faces.Append(aFace); - } - } - Standard_Boolean HasFacesForUnification = Standard_False; - for (Standard_Integer i=1; i 0) { - IsBlock = Standard_False; - myNbDegen++; - myPossibleBlocks.Append(aSolid); - continue; - } - if (nbe < 12) - IsBlock = Standard_False; - if (nbe > 12) { - IsBlock = Standard_False; - // check edges unification - // creating map of edge faces - TopTools_IndexedDataMapOfShapeListOfShape aMapEdgeFaces; - TopExp::MapShapesAndAncestors(aSolid, TopAbs_EDGE, TopAbs_FACE, aMapEdgeFaces); - - mapF.Clear(); - for (expf.Init(aSolid, TopAbs_FACE); expf.More(); expf.Next()) { - TopoDS_Face aFace = TopoDS::Face(expf.Current()); - if (!mapF.Add(aFace)) continue; - TopTools_IndexedDataMapOfShapeListOfShape aMapFacesEdges; - - TopTools_MapOfShape mapEe; - for (expe.Init(aFace, TopAbs_EDGE); expe.More(); expe.Next()) { - TopoDS_Edge edge = TopoDS::Edge(expe.Current()); - if (!mapEe.Add(edge)) continue; - if (!aMapEdgeFaces.Contains(edge)) continue; - const TopTools_ListOfShape& aList = aMapEdgeFaces.FindFromKey(edge); - TopTools_ListIteratorOfListOfShape anIter (aList); - for (; anIter.More(); anIter.Next()) { - TopoDS_Face face = TopoDS::Face(anIter.Value()); - if (face.IsSame(aFace)) continue; - if (aMapFacesEdges.Contains(face)) { - aMapFacesEdges.ChangeFromKey(face).Append(edge); - } - else { - TopTools_ListOfShape ListEdges; - ListEdges.Append(edge); - aMapFacesEdges.Add(face,ListEdges); - } - } - } - Standard_Integer i = 1; - for (; i <= aMapFacesEdges.Extent(); i++) { - const TopTools_ListOfShape& ListEdges = aMapFacesEdges.FindFromIndex(i); - if (ListEdges.Extent() > 1) break; - } - if (i <= aMapFacesEdges.Extent()) { - MayBeUE = Standard_True; - break; - } - } - } - - if (IsBlock) - myNbBlocks++; - else { - if (MayBeUF) { - myPossibleBlocks.Append(aSolid); - if (MayBeUE) - myNbUFUE++; - else - myNbUF++; - } - else if (MayBeUE) { - myNbUE++; - myPossibleBlocks.Append(aSolid); - } - } - } - - myHasCheck = Standard_True; -} - - -//======================================================================= -//function : NbPossibleBlocks -//purpose : -//======================================================================= - -Standard_Integer BlockFix_CheckTool::NbPossibleBlocks() const -{ - return myPossibleBlocks.Length(); -} - - -//======================================================================= -//function : PossibleBlock -//purpose : -//======================================================================= - -TopoDS_Shape BlockFix_CheckTool::PossibleBlock(const Standard_Integer num) const -{ - TopoDS_Shape res; - if( num>0 && num<=myPossibleBlocks.Length() ) - res = myPossibleBlocks.Value(num); - return res; -} - - -//======================================================================= -//function : DumpCheckResult -//purpose : -//======================================================================= - -void BlockFix_CheckTool::DumpCheckResult(Standard_OStream& S) const -{ - if(!myHasCheck) - S<<"Check not performed!"< - - - - diff --git a/src/GEOMAlgo/BlockFix_CheckTool.jxx b/src/GEOMAlgo/BlockFix_CheckTool.jxx deleted file mode 100644 index 7574af057..000000000 --- a/src/GEOMAlgo/BlockFix_CheckTool.jxx +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 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.com -// - -#ifndef _TopoDS_Shape_HeaderFile -#include -#endif -#ifndef _BlockFix_CheckTool_HeaderFile -#include -#endif diff --git a/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.cdl b/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.cdl deleted file mode 100644 index 374af919c..000000000 --- a/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.cdl +++ /dev/null @@ -1,135 +0,0 @@ --- Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE --- --- Copyright (C) 2003-2007 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.com --- - --- File: BlockFix_PeriodicSurfaceModifier.cdl --- Created: Wed Dec 15 10:03:50 2004 --- Author: Sergey KUUL --- -class PeriodicSurfaceModifier from BlockFix inherits Modification from BRepTools - - ---Purpose: - -uses - Vertex from TopoDS, - Edge from TopoDS, - Face from TopoDS, - Location from TopLoc, - Shape from GeomAbs, - Pnt from gp, - Curve from Geom, - Curve from Geom2d, - Surface from Geom, - IndexedMapOfTransient from TColStd, - DataMapOfShapeInteger from TopTools - -is - - Create returns mutable PeriodicSurfaceModifier from BlockFix; - - SetTolerance(me: mutable; Toler: Real); - ---Purpose: Sets the tolerance for recognition of geometry - - NewSurface(me: mutable; F : Face from TopoDS; - S : out Surface from Geom; - L : out Location from TopLoc; - Tol: out Real from Standard; - RevWires : out Boolean from Standard; - RevFace : out Boolean from Standard) - returns Boolean from Standard; - ---Purpose: Returns Standard_True if the face has been - -- modified. In this case, is the new geometric - -- support of the face, the new location, - -- the new tolerance. Otherwise, returns - -- Standard_False, and , , are not - -- significant. - - NewCurve(me: mutable; E : Edge from TopoDS; - C : out Curve from Geom; - L : out Location from TopLoc; - Tol: out Real from Standard) - returns Boolean from Standard; - ---Purpose: Returns Standard_True if the edge has been - -- modified. In this case, is the new geometric - -- support of the edge, the new location, - -- the new tolerance. Otherwise, returns - -- Standard_False, and , , are not - -- significant. - - NewPoint(me: mutable; V : Vertex from TopoDS; - P : out Pnt from gp; - Tol: out Real from Standard) - returns Boolean from Standard; - ---Purpose: Returns Standard_True if the vertex has been - -- modified. In this case,

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

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

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

    , - -- are not significant. - - Continuity(me: mutable; E : Edge from TopoDS; - F1,F2 : Face from TopoDS; - NewE : Edge from TopoDS; - NewF1,NewF2: Face from TopoDS) - returns Shape from GeomAbs; - ---Purpose: Returns the continuity of between - -- and . - -- - -- is the new edge created from . - -- (resp. ) is the new face created from - -- (resp. ). - - -fields - - myTolerance : Real; - myMapOfFaces : DataMapOfShapeInteger from TopTools; - myMapOfSurfaces: IndexedMapOfTransient from TColStd; - -end PeriodicSurfaceModifier; diff --git a/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.cxx b/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.cxx deleted file mode 100644 index 1e9f33ca0..000000000 --- a/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.cxx +++ /dev/null @@ -1,251 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 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.com -// - -// File: BlockFix_PeriodicSurfaceModifier.cxx -// Created: 15.12.04 10:08:50 -// Author: Sergey KUUL - -#include - -#include -#include -#include -#include -#include -#include -#include - - -//======================================================================= -//function : BlockFix_PeriodicSurfaceModifier() -//purpose : Constructor -//======================================================================= - -BlockFix_PeriodicSurfaceModifier::BlockFix_PeriodicSurfaceModifier ( ) -{ - myMapOfFaces.Clear(); - myMapOfSurfaces.Clear(); -} - - -//======================================================================= -//function : SetTolerance -//purpose : -//======================================================================= - -void BlockFix_PeriodicSurfaceModifier::SetTolerance(const Standard_Real Tol) -{ - myTolerance = Tol; -} - - -//======================================================================= -//function : ModifySurface -//purpose : auxilary -//======================================================================= - -static Standard_Boolean ModifySurface(const TopoDS_Face& aFace, - const Handle(Geom_Surface)& aSurface, - Handle(Geom_Surface)& aNewSurface) -{ - Handle(Geom_Surface) S = aSurface; - - if(S->IsKind(STANDARD_TYPE(Geom_CylindricalSurface))) { - Handle(Geom_CylindricalSurface) aCyl = - Handle(Geom_CylindricalSurface)::DownCast(S); - Standard_Real Umin, Umax, Vmin, Vmax; - BRepTools::UVBounds(aFace, Umin, Umax, Vmin, Vmax); - if (Umin < -Precision::PConfusion() || Umax > 2*M_PI + Precision::PConfusion()) { - gp_Ax3 ax3 = aCyl->Position(); - gp_Ax1 NDir = ax3.Axis(); - gp_Ax3 newax3 = ax3.Rotated(NDir,Umin-Precision::PConfusion()); - Handle(Geom_CylindricalSurface) aNewCyl = - new Geom_CylindricalSurface(newax3,aCyl->Radius()); - aNewSurface = aNewCyl; - return Standard_True; - } - } - - if(S->IsKind(STANDARD_TYPE(Geom_SphericalSurface))) { - Handle(Geom_SphericalSurface) aSphere = Handle(Geom_SphericalSurface)::DownCast(S); - Standard_Real Umin, Umax, Vmin, Vmax; - BRepTools::UVBounds(aFace, Umin, Umax, Vmin, Vmax); - if (Umin < -Precision::PConfusion() || Umax > 2*M_PI + Precision::PConfusion()) { - gp_Ax3 ax3 = aSphere->Position(); - gp_Ax1 NDir = ax3.Axis(); - gp_Ax3 newax3 = ax3.Rotated(NDir,Umin-Precision::PConfusion()); - Handle(Geom_SphericalSurface) aNewSphere = new Geom_SphericalSurface(newax3,aSphere->Radius()); - aNewSurface = aNewSphere; - return Standard_True; - } - } - - return Standard_False; -} - - -//======================================================================= -//function : NewSurface -//purpose : -//======================================================================= - -Standard_Boolean BlockFix_PeriodicSurfaceModifier::NewSurface(const TopoDS_Face& F, - Handle(Geom_Surface)& S, - TopLoc_Location& L,Standard_Real& Tol, - Standard_Boolean& RevWires, - Standard_Boolean& RevFace) -{ - TopLoc_Location LS; - Handle(Geom_Surface) SIni = BRep_Tool::Surface(F, LS); - - if(ModifySurface(F, SIni, S)) { - - RevWires = Standard_False; - RevFace = Standard_False; - - L = LS; - Tol = BRep_Tool::Tolerance(F); - - Standard_Integer anIndex = myMapOfSurfaces.Add(S); - myMapOfFaces.Bind(F,anIndex); - return Standard_True; - } - - return Standard_False; -} - - -//======================================================================= -//function : NewCurve -//purpose : -//======================================================================= - -Standard_Boolean BlockFix_PeriodicSurfaceModifier::NewCurve(const TopoDS_Edge& /*E*/, - Handle(Geom_Curve)& /*C*/, - TopLoc_Location& /*L*/, - Standard_Real& /*Tol*/) -{ - return Standard_False; -} - - -//======================================================================= -//function : NewPoint -//purpose : -//======================================================================= - -Standard_Boolean BlockFix_PeriodicSurfaceModifier::NewPoint(const TopoDS_Vertex& /*V*/, - gp_Pnt& /*P*/, - Standard_Real& /*Tol*/) -{ - return Standard_False; -} - - -//======================================================================= -//function : NewCurve2d -//purpose : -//======================================================================= - -Standard_Boolean BlockFix_PeriodicSurfaceModifier::NewCurve2d(const TopoDS_Edge& E, - const TopoDS_Face& F, - const TopoDS_Edge& /*NewE*/, - const TopoDS_Face& /*NewF*/, - Handle(Geom2d_Curve)& C, - Standard_Real& Tol) -{ - //check if undelying surface of the face was modified - if(myMapOfFaces.IsBound(F)) { - Standard_Integer anIndex = myMapOfFaces.Find(F); - - Handle(Geom_Surface) aNewSurf = Handle(Geom_Surface)::DownCast(myMapOfSurfaces.FindKey(anIndex)); - - Standard_Real f,l; - TopLoc_Location LC, LS; - Handle(Geom_Curve) C3d = BRep_Tool::Curve ( E, LC, f, l ); - Handle(Geom_Surface) S = BRep_Tool::Surface(F, LS); - - //taking into accound the orientation of the seam - C = BRep_Tool::CurveOnSurface(E,F,f,l); - Tol = BRep_Tool::Tolerance(E); - - BRep_Builder B; - TopoDS_Edge TempE; - B.MakeEdge(TempE); - B.Add(TempE, TopExp::FirstVertex(E)); - B.Add(TempE, TopExp::LastVertex(E)); - - if(!C3d.IsNull()) - B.UpdateEdge(TempE, Handle(Geom_Curve)::DownCast(C3d->Transformed(LC.Transformation())), Precision::Confusion()); - B.Range(TempE, f, l); - - Handle(ShapeFix_Edge) sfe = new ShapeFix_Edge; - Handle(Geom_Surface) STemp = Handle(Geom_Surface)::DownCast(aNewSurf->Transformed(LS.Transformation())); - TopLoc_Location LTemp; - LTemp.Identity(); - - Standard_Boolean isClosed = BRep_Tool::IsClosed (E, F); - Standard_Real aWorkTol = 2*myTolerance+Tol; - sfe->FixAddPCurve(TempE, STemp, LTemp, isClosed, Max(Precision::Confusion(), aWorkTol)); - sfe->FixSameParameter(TempE); - - //keep the orientation of original edge - TempE.Orientation(E.Orientation()); - C = BRep_Tool::CurveOnSurface(TempE, STemp, LTemp, f, l); - - //surface was modified - return Standard_True; - } - - return Standard_False; -} - - -//======================================================================= -//function : NewParameter -//purpose : -//======================================================================= - -Standard_Boolean BlockFix_PeriodicSurfaceModifier::NewParameter(const TopoDS_Vertex& /*V*/, - const TopoDS_Edge& /*E*/, - Standard_Real& /*P*/, - Standard_Real& /*Tol*/) -{ - return Standard_False; -} - - -//======================================================================= -//function : Continuity -//purpose : -//======================================================================= - -GeomAbs_Shape BlockFix_PeriodicSurfaceModifier::Continuity(const TopoDS_Edge& E, - const TopoDS_Face& F1, - const TopoDS_Face& F2, - const TopoDS_Edge& /*NewE*/, - const TopoDS_Face& /*NewF1*/, - const TopoDS_Face& /*NewF2*/) -{ - return BRep_Tool::Continuity(E,F1,F2); -} - diff --git a/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.hxx b/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.hxx deleted file mode 100644 index 39d2062ea..000000000 --- a/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.hxx +++ /dev/null @@ -1,140 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 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.com -// - -#ifndef _BlockFix_PeriodicSurfaceModifier_HeaderFile -#define _BlockFix_PeriodicSurfaceModifier_HeaderFile - -#ifndef _Standard_HeaderFile -#include -#endif -#ifndef _Handle_BlockFix_PeriodicSurfaceModifier_HeaderFile -#include -#endif - -#ifndef _Standard_Real_HeaderFile -#include -#endif -#ifndef _TopTools_DataMapOfShapeInteger_HeaderFile -#include -#endif -#ifndef _TColStd_IndexedMapOfTransient_HeaderFile -#include -#endif -#ifndef _BRepTools_Modification_HeaderFile -#include -#endif -#ifndef _Standard_Boolean_HeaderFile -#include -#endif -#ifndef _Handle_Geom_Surface_HeaderFile -#include -#endif -#ifndef _Handle_Geom_Curve_HeaderFile -#include -#endif -#ifndef _Handle_Geom2d_Curve_HeaderFile -#include -#endif -#ifndef _GeomAbs_Shape_HeaderFile -#include -#endif -class TopoDS_Face; -class Geom_Surface; -class TopLoc_Location; -class TopoDS_Edge; -class Geom_Curve; -class TopoDS_Vertex; -class gp_Pnt; -class Geom2d_Curve; - - -class BlockFix_PeriodicSurfaceModifier : public BRepTools_Modification { - -public: - - void* operator new(size_t,void* anAddress) - { - return anAddress; - } - void* operator new(size_t size) - { - return Standard::Allocate(size); - } - void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } - // Methods PUBLIC - // -Standard_EXPORT BlockFix_PeriodicSurfaceModifier(); -Standard_EXPORT void SetTolerance(const Standard_Real Toler) ; -Standard_EXPORT Standard_Boolean NewSurface(const TopoDS_Face& F,Handle(Geom_Surface)& S,TopLoc_Location& L,Standard_Real& Tol,Standard_Boolean& RevWires,Standard_Boolean& RevFace) ; -Standard_EXPORT Standard_Boolean NewCurve(const TopoDS_Edge& E,Handle(Geom_Curve)& C,TopLoc_Location& L,Standard_Real& Tol) ; -Standard_EXPORT Standard_Boolean NewPoint(const TopoDS_Vertex& V,gp_Pnt& P,Standard_Real& Tol) ; -Standard_EXPORT Standard_Boolean NewCurve2d(const TopoDS_Edge& E,const TopoDS_Face& F,const TopoDS_Edge& NewE,const TopoDS_Face& NewF,Handle(Geom2d_Curve)& C,Standard_Real& Tol) ; -Standard_EXPORT Standard_Boolean NewParameter(const TopoDS_Vertex& V,const TopoDS_Edge& E,Standard_Real& P,Standard_Real& Tol) ; -Standard_EXPORT GeomAbs_Shape Continuity(const TopoDS_Edge& E,const TopoDS_Face& F1,const TopoDS_Face& F2,const TopoDS_Edge& NewE,const TopoDS_Face& NewF1,const TopoDS_Face& NewF2) ; -Standard_EXPORT ~BlockFix_PeriodicSurfaceModifier(); - - - - - // Type management - // - Standard_EXPORT friend Handle_Standard_Type& BlockFix_PeriodicSurfaceModifier_Type_(); - Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; - Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; - -protected: - - // Methods PROTECTED - // - - - // Fields PROTECTED - // - - -private: - - // Methods PRIVATE - // - - - // Fields PRIVATE - // -Standard_Real myTolerance; -TopTools_DataMapOfShapeInteger myMapOfFaces; -TColStd_IndexedMapOfTransient myMapOfSurfaces; - - -}; - - - - - -// other Inline functions and methods (like "C++: function call" methods) -// - - -#endif diff --git a/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.ixx b/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.ixx deleted file mode 100644 index da3bdc95e..000000000 --- a/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.ixx +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 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.com -// - -#include - -#ifndef _Standard_TypeMismatch_HeaderFile -#include -#endif - -BlockFix_PeriodicSurfaceModifier::~BlockFix_PeriodicSurfaceModifier() {} - - - -Standard_EXPORT Handle_Standard_Type& BlockFix_PeriodicSurfaceModifier_Type_() -{ - - static Handle_Standard_Type aType1 = STANDARD_TYPE(BRepTools_Modification); - if ( aType1.IsNull()) aType1 = STANDARD_TYPE(BRepTools_Modification); - static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared); - if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared); - static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient); - if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient); - - - static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL}; - static Handle_Standard_Type _aType = new Standard_Type("BlockFix_PeriodicSurfaceModifier", - sizeof(BlockFix_PeriodicSurfaceModifier), - 1, - (Standard_Address)_Ancestors, - (Standard_Address)NULL); - - return _aType; -} - - -// DownCast method -// allow safe downcasting -// -const Handle(BlockFix_PeriodicSurfaceModifier) Handle(BlockFix_PeriodicSurfaceModifier)::DownCast(const Handle(Standard_Transient)& AnObject) -{ - Handle(BlockFix_PeriodicSurfaceModifier) _anOtherObject; - - if (!AnObject.IsNull()) { - if (AnObject->IsKind(STANDARD_TYPE(BlockFix_PeriodicSurfaceModifier))) { - _anOtherObject = Handle(BlockFix_PeriodicSurfaceModifier)((Handle(BlockFix_PeriodicSurfaceModifier)&)AnObject); - } - } - - return _anOtherObject ; -} -const Handle(Standard_Type)& BlockFix_PeriodicSurfaceModifier::DynamicType() const -{ - return STANDARD_TYPE(BlockFix_PeriodicSurfaceModifier) ; -} -Standard_Boolean BlockFix_PeriodicSurfaceModifier::IsKind(const Handle(Standard_Type)& AType) const -{ - return (STANDARD_TYPE(BlockFix_PeriodicSurfaceModifier) == AType || BRepTools_Modification::IsKind(AType)); -} -Handle_BlockFix_PeriodicSurfaceModifier::~Handle_BlockFix_PeriodicSurfaceModifier() {} - diff --git a/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.jxx b/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.jxx deleted file mode 100644 index 29c1c1e34..000000000 --- a/src/GEOMAlgo/BlockFix_PeriodicSurfaceModifier.jxx +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 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.com -// - -#ifndef _TopoDS_Face_HeaderFile -#include -#endif -#ifndef _Geom_Surface_HeaderFile -#include -#endif -#ifndef _TopLoc_Location_HeaderFile -#include -#endif -#ifndef _TopoDS_Edge_HeaderFile -#include -#endif -#ifndef _Geom_Curve_HeaderFile -#include -#endif -#ifndef _TopoDS_Vertex_HeaderFile -#include -#endif -#ifndef _gp_Pnt_HeaderFile -#include -#endif -#ifndef _Geom2d_Curve_HeaderFile -#include -#endif -#ifndef _BlockFix_PeriodicSurfaceModifier_HeaderFile -#include -#endif diff --git a/src/GEOMAlgo/BlockFix_SphereSpaceModifier.cdl b/src/GEOMAlgo/BlockFix_SphereSpaceModifier.cdl deleted file mode 100644 index da614611b..000000000 --- a/src/GEOMAlgo/BlockFix_SphereSpaceModifier.cdl +++ /dev/null @@ -1,139 +0,0 @@ --- Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE --- --- Copyright (C) 2003-2007 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.com --- - --- File: BlockFix_SphereSpaceModifier.cdl --- Created: Tue Dec 7 12:01:49 2004 --- Author: Pavel Durandin --- -class SphereSpaceModifier from BlockFix inherits Modification from BRepTools - - ---Purpose: Rotation of the parametric space of the sphere in order - -- to avoid the seam and degenerared edge within it - -uses - Vertex from TopoDS, - Edge from TopoDS, - Face from TopoDS, - Location from TopLoc, - Shape from GeomAbs, - Pnt from gp, - Curve from Geom, - Curve from Geom2d, - Surface from Geom, - IndexedMapOfTransient from TColStd, - DataMapOfShapeInteger from TopTools - -is - - Create returns mutable SphereSpaceModifier from BlockFix; - - SetTolerance(me: mutable; Toler: Real); - ---Purpose: Sets the tolerance for recognition of geometry - - NewSurface(me: mutable; F : Face from TopoDS; - S : out Surface from Geom; - L : out Location from TopLoc; - Tol: out Real from Standard; - RevWires : out Boolean from Standard; - RevFace : out Boolean from Standard) - returns Boolean from Standard; - ---Purpose: Returns Standard_True if the face has been - -- modified. In this case, is the new geometric - -- support of the face, the new location, - -- the new tolerance. Otherwise, returns - -- Standard_False, and , , are not - -- significant. - - NewCurve(me: mutable; E : Edge from TopoDS; - C : out Curve from Geom; - L : out Location from TopLoc; - Tol: out Real from Standard) - returns Boolean from Standard; - ---Purpose: Returns Standard_True if the edge has been - -- modified. In this case, is the new geometric - -- support of the edge, the new location, - -- the new tolerance. Otherwise, returns - -- Standard_False, and , , are not - -- significant. - - NewPoint(me: mutable; V : Vertex from TopoDS; - P : out Pnt from gp; - Tol: out Real from Standard) - returns Boolean from Standard; - ---Purpose: Returns Standard_True if the vertex has been - -- modified. In this case,

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

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

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

    , - -- are not significant. - - Continuity(me: mutable; E : Edge from TopoDS; - F1,F2 : Face from TopoDS; - NewE : Edge from TopoDS; - NewF1,NewF2: Face from TopoDS) - returns Shape from GeomAbs; - ---Purpose: Returns the continuity of between - -- and . - -- - -- is the new edge created from . - -- (resp. ) is the new face created from - -- (resp. ). - - ForRotation(me: mutable; F: Face from TopoDS) returns Boolean; - -fields - - myTolerance : Real; - myMapOfFaces : DataMapOfShapeInteger from TopTools; - myMapOfSpheres: IndexedMapOfTransient from TColStd; - --myMapOfGeom: MapOfShapeTransient from TColStd; - -end SphereSpaceModifier; - diff --git a/src/GEOMAlgo/BlockFix_SphereSpaceModifier.cxx b/src/GEOMAlgo/BlockFix_SphereSpaceModifier.cxx deleted file mode 100644 index 2abc08316..000000000 --- a/src/GEOMAlgo/BlockFix_SphereSpaceModifier.cxx +++ /dev/null @@ -1,275 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 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.com -// - -// File: BlockFix.cxx -// Created: Tue Dec 7 11:59:05 2004 -// Author: Pavel DURANDIN - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -//======================================================================= -//function : BlockFix_SphereSpaceModifier -//purpose : -//======================================================================= - -BlockFix_SphereSpaceModifier::BlockFix_SphereSpaceModifier() -{ - myMapOfFaces.Clear(); - myMapOfSpheres.Clear(); -} - -//======================================================================= -//function : SetTolerance -//purpose : -//======================================================================= - -void BlockFix_SphereSpaceModifier::SetTolerance(const Standard_Real Tol) -{ - myTolerance = Tol; -} - - -//======================================================================= -//function : NewSurface -//purpose : -//======================================================================= - - -static Standard_Boolean ModifySurface(const TopoDS_Face& aFace, - const Handle(Geom_Surface)& aSurface, - Handle(Geom_Surface)& aNewSurface) -{ - Handle(Geom_Surface) S = aSurface; - if(S->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) { - Handle(Geom_RectangularTrimmedSurface) RTS = - Handle(Geom_RectangularTrimmedSurface)::DownCast(S); - S = RTS->BasisSurface(); - } - - if(S->IsKind(STANDARD_TYPE(Geom_SphericalSurface))) { - Standard_Real Umin, Umax, Vmin, Vmax; - ShapeAnalysis::GetFaceUVBounds(aFace,Umin, Umax, Vmin, Vmax); - Standard_Real PI2 = M_PI/2.; - if(Vmax > PI2 - Precision::PConfusion() || Vmin < -PI2+::Precision::PConfusion()) { - Handle(Geom_SphericalSurface) aSphere = Handle(Geom_SphericalSurface)::DownCast(S); - gp_Sphere sp = aSphere->Sphere(); - //modified by jgv, 12.11.2012 for issue 21777// - Standard_Real Radius = sp.Radius(); - Standard_Real HalfArea = 2.*M_PI*Radius*Radius; - GProp_GProps Properties; - BRepGProp::SurfaceProperties(aFace, Properties); - Standard_Real anArea = Properties.Mass(); - Standard_Real AreaTol = Radius*Radius*1.e-6; - if (anArea > HalfArea - AreaTol) //no chance to avoid singularity - return Standard_False; - /////////////////////////////////////////////// - gp_Ax3 ax3 = sp.Position(); - if(Abs(Vmax-Vmin) < PI2) { - gp_Ax3 axnew3(ax3.Axis().Location(), ax3.Direction()^ax3.XDirection(),ax3.XDirection()); - sp.SetPosition(axnew3); - Handle(Geom_SphericalSurface) aNewSphere = new Geom_SphericalSurface(sp); - aNewSurface = aNewSphere; - return Standard_True; - } - else { - gp_Pnt PC = ax3.Location(); - Standard_Real Vpar; - if(fabs(PI2-Vmax)>fabs(-PI2-Vmin)) - Vpar = (PI2+Vmax)/2.; - else - Vpar = (-PI2+Vmin)/2.; - Standard_Real Upar = (Umin+Umax)/2.;; - gp_Pnt PN,PX; - S->D0(Upar,Vpar,PN); - S->D0(Upar+PI2,0.,PX); - gp_Dir newNorm(gp_Vec(PC,PN)); - gp_Dir newDirX(gp_Vec(PC,PX)); - gp_Ax3 axnew3(ax3.Axis().Location(), newNorm, newDirX); - sp.SetPosition(axnew3); - Handle(Geom_SphericalSurface) aNewSphere = new Geom_SphericalSurface(sp); - aNewSurface = aNewSphere; - return Standard_True; - } - } - } - return Standard_False; -} - - -Standard_Boolean BlockFix_SphereSpaceModifier::NewSurface(const TopoDS_Face& F, - Handle(Geom_Surface)& S, - TopLoc_Location& L,Standard_Real& Tol, - Standard_Boolean& RevWires, - Standard_Boolean& RevFace) -{ - TopLoc_Location LS; - Handle(Geom_Surface) SIni = BRep_Tool::Surface(F, LS); - - //check if pole of the sphere in the parametric space - if(ModifySurface(F, SIni, S)) { - - RevWires = Standard_False; - RevFace = Standard_False; - - L = LS; - Tol = BRep_Tool::Tolerance(F); - - Standard_Integer anIndex = myMapOfSpheres.Add(S); - myMapOfFaces.Bind(F,anIndex); - return Standard_True; - } - - return Standard_False; -} - -//======================================================================= -//function : NewCurve -//purpose : -//======================================================================= - -Standard_Boolean BlockFix_SphereSpaceModifier::NewCurve(const TopoDS_Edge& /*E*/,Handle(Geom_Curve)& /*C*/, - TopLoc_Location& /*L*/,Standard_Real& /*Tol*/) -{ - return Standard_False; -} - -//======================================================================= -//function : NewPoint -//purpose : -//======================================================================= - -Standard_Boolean BlockFix_SphereSpaceModifier::NewPoint(const TopoDS_Vertex& /*V*/, - gp_Pnt& /*P*/, - Standard_Real& /*Tol*/) -{ - return Standard_False; -} - -//======================================================================= -//function : NewCurve2d -//purpose : -//======================================================================= - -Standard_Boolean BlockFix_SphereSpaceModifier::NewCurve2d(const TopoDS_Edge& E,const TopoDS_Face& F, - const TopoDS_Edge& /*NewE*/,const TopoDS_Face& /*NewF*/, - Handle(Geom2d_Curve)& C,Standard_Real& Tol) -{ - //check if undelying surface of the face was modified - if(myMapOfFaces.IsBound(F)) { - Standard_Integer anIndex = myMapOfFaces.Find(F); - - Handle(Geom_Surface) aNewSphere = Handle(Geom_Surface)::DownCast(myMapOfSpheres.FindKey(anIndex)); - - Standard_Real f,l; - TopLoc_Location LC, LS; - Handle(Geom_Curve) C3d = BRep_Tool::Curve ( E, LC, f, l ); - Handle(Geom_Surface) S = BRep_Tool::Surface(F, LS); - - //taking into accound the orientation of the seam - C = BRep_Tool::CurveOnSurface(E,F,f,l); - Tol = BRep_Tool::Tolerance(E); - - BRep_Builder B; - TopoDS_Edge TempE; - B.MakeEdge(TempE); - B.Add(TempE, TopExp::FirstVertex(E)); - B.Add(TempE, TopExp::LastVertex(E)); - - if(!C3d.IsNull()) - B.UpdateEdge(TempE, Handle(Geom_Curve)::DownCast(C3d->Transformed(LC.Transformation())), Precision::Confusion()); - B.Range(TempE, f, l); - - Handle(ShapeFix_Edge) sfe = new ShapeFix_Edge; - Handle(Geom_Surface) STemp = Handle(Geom_Surface)::DownCast(aNewSphere->Transformed(LS.Transformation())); - TopLoc_Location LTemp; - LTemp.Identity(); - - Standard_Boolean isClosed = BRep_Tool::IsClosed (E, F); - Standard_Real aWorkTol = 2*myTolerance+Tol; - sfe->FixAddPCurve(TempE, STemp, LTemp, isClosed, Max(Precision::Confusion(), aWorkTol)); - sfe->FixSameParameter(TempE); - - //keep the orientation of original edge - TempE.Orientation(E.Orientation()); - C = BRep_Tool::CurveOnSurface(TempE, STemp, LTemp, f, l); - - // shifting seam of sphere - if(isClosed && !C.IsNull()) { - Standard_Real f2,l2; - Handle(Geom2d_Curve) c22 = - BRep_Tool::CurveOnSurface(TopoDS::Edge(TempE.Reversed()),STemp, LTemp,f2,l2); - Standard_Real dPreci = Precision::PConfusion()*Precision::PConfusion(); - if((C->Value(f).SquareDistance(c22->Value(f2)) < dPreci) - ||(C->Value(l).SquareDistance(c22->Value(l2)) < dPreci)) { - gp_Vec2d shift(S->UPeriod(),0.); - C->Translate(shift); - } - } - //sphere was modified - return Standard_True; - } - - return Standard_False; -} - - -//======================================================================= -//function : NewParameter -//purpose : -//======================================================================= - -Standard_Boolean BlockFix_SphereSpaceModifier::NewParameter(const TopoDS_Vertex& /*V*/,const TopoDS_Edge& /*E*/, - Standard_Real& /*P*/,Standard_Real& /*Tol*/) -{ - return Standard_False; -} - - -//======================================================================= -//function : Continuity -//purpose : -//======================================================================= - -GeomAbs_Shape BlockFix_SphereSpaceModifier::Continuity(const TopoDS_Edge& E,const TopoDS_Face& F1, - const TopoDS_Face& F2,const TopoDS_Edge& /*NewE*/, - const TopoDS_Face& /*NewF1*/,const TopoDS_Face& /*NewF2*/) -{ - return BRep_Tool::Continuity(E,F1,F2); -} diff --git a/src/GEOMAlgo/BlockFix_SphereSpaceModifier.hxx b/src/GEOMAlgo/BlockFix_SphereSpaceModifier.hxx deleted file mode 100644 index fb11fdbae..000000000 --- a/src/GEOMAlgo/BlockFix_SphereSpaceModifier.hxx +++ /dev/null @@ -1,141 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 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.com -// - -#ifndef _BlockFix_SphereSpaceModifier_HeaderFile -#define _BlockFix_SphereSpaceModifier_HeaderFile - -#ifndef _Standard_HeaderFile -#include -#endif -#ifndef _Handle_BlockFix_SphereSpaceModifier_HeaderFile -#include -#endif - -#ifndef _Standard_Real_HeaderFile -#include -#endif -#ifndef _TopTools_DataMapOfShapeInteger_HeaderFile -#include -#endif -#ifndef _TColStd_IndexedMapOfTransient_HeaderFile -#include -#endif -#ifndef _BRepTools_Modification_HeaderFile -#include -#endif -#ifndef _Standard_Boolean_HeaderFile -#include -#endif -#ifndef _Handle_Geom_Surface_HeaderFile -#include -#endif -#ifndef _Handle_Geom_Curve_HeaderFile -#include -#endif -#ifndef _Handle_Geom2d_Curve_HeaderFile -#include -#endif -#ifndef _GeomAbs_Shape_HeaderFile -#include -#endif -class TopoDS_Face; -class Geom_Surface; -class TopLoc_Location; -class TopoDS_Edge; -class Geom_Curve; -class TopoDS_Vertex; -class gp_Pnt; -class Geom2d_Curve; - - -class BlockFix_SphereSpaceModifier : public BRepTools_Modification { - -public: - - void* operator new(size_t,void* anAddress) - { - return anAddress; - } - void* operator new(size_t size) - { - return Standard::Allocate(size); - } - void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } - // Methods PUBLIC - // -Standard_EXPORT BlockFix_SphereSpaceModifier(); -Standard_EXPORT void SetTolerance(const Standard_Real Toler) ; -Standard_EXPORT Standard_Boolean NewSurface(const TopoDS_Face& F,Handle(Geom_Surface)& S,TopLoc_Location& L,Standard_Real& Tol,Standard_Boolean& RevWires,Standard_Boolean& RevFace) ; -Standard_EXPORT Standard_Boolean NewCurve(const TopoDS_Edge& E,Handle(Geom_Curve)& C,TopLoc_Location& L,Standard_Real& Tol) ; -Standard_EXPORT Standard_Boolean NewPoint(const TopoDS_Vertex& V,gp_Pnt& P,Standard_Real& Tol) ; -Standard_EXPORT Standard_Boolean NewCurve2d(const TopoDS_Edge& E,const TopoDS_Face& F,const TopoDS_Edge& NewE,const TopoDS_Face& NewF,Handle(Geom2d_Curve)& C,Standard_Real& Tol) ; -Standard_EXPORT Standard_Boolean NewParameter(const TopoDS_Vertex& V,const TopoDS_Edge& E,Standard_Real& P,Standard_Real& Tol) ; -Standard_EXPORT GeomAbs_Shape Continuity(const TopoDS_Edge& E,const TopoDS_Face& F1,const TopoDS_Face& F2,const TopoDS_Edge& NewE,const TopoDS_Face& NewF1,const TopoDS_Face& NewF2) ; -Standard_EXPORT Standard_Boolean ForRotation(const TopoDS_Face& F) ; -Standard_EXPORT ~BlockFix_SphereSpaceModifier(); - - - - - // Type management - // - Standard_EXPORT friend Handle_Standard_Type& BlockFix_SphereSpaceModifier_Type_(); - Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; - Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; - -protected: - - // Methods PROTECTED - // - - - // Fields PROTECTED - // - - -private: - - // Methods PRIVATE - // - - - // Fields PRIVATE - // -Standard_Real myTolerance; -TopTools_DataMapOfShapeInteger myMapOfFaces; -TColStd_IndexedMapOfTransient myMapOfSpheres; - - -}; - - - - - -// other Inline functions and methods (like "C++: function call" methods) -// - - -#endif diff --git a/src/GEOMAlgo/BlockFix_SphereSpaceModifier.ixx b/src/GEOMAlgo/BlockFix_SphereSpaceModifier.ixx deleted file mode 100644 index 482241f6d..000000000 --- a/src/GEOMAlgo/BlockFix_SphereSpaceModifier.ixx +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 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.com -// - -#include - -#ifndef _Standard_TypeMismatch_HeaderFile -#include -#endif - -BlockFix_SphereSpaceModifier::~BlockFix_SphereSpaceModifier() {} - - - -Standard_EXPORT Handle_Standard_Type& BlockFix_SphereSpaceModifier_Type_() -{ - - static Handle_Standard_Type aType1 = STANDARD_TYPE(BRepTools_Modification); - if ( aType1.IsNull()) aType1 = STANDARD_TYPE(BRepTools_Modification); - static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared); - if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared); - static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient); - if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient); - - - static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL}; - static Handle_Standard_Type _aType = new Standard_Type("BlockFix_SphereSpaceModifier", - sizeof(BlockFix_SphereSpaceModifier), - 1, - (Standard_Address)_Ancestors, - (Standard_Address)NULL); - - return _aType; -} - - -// DownCast method -// allow safe downcasting -// -const Handle(BlockFix_SphereSpaceModifier) Handle(BlockFix_SphereSpaceModifier)::DownCast(const Handle(Standard_Transient)& AnObject) -{ - Handle(BlockFix_SphereSpaceModifier) _anOtherObject; - - if (!AnObject.IsNull()) { - if (AnObject->IsKind(STANDARD_TYPE(BlockFix_SphereSpaceModifier))) { - _anOtherObject = Handle(BlockFix_SphereSpaceModifier)((Handle(BlockFix_SphereSpaceModifier)&)AnObject); - } - } - - return _anOtherObject ; -} -const Handle(Standard_Type)& BlockFix_SphereSpaceModifier::DynamicType() const -{ - return STANDARD_TYPE(BlockFix_SphereSpaceModifier) ; -} -Standard_Boolean BlockFix_SphereSpaceModifier::IsKind(const Handle(Standard_Type)& AType) const -{ - return (STANDARD_TYPE(BlockFix_SphereSpaceModifier) == AType || BRepTools_Modification::IsKind(AType)); -} -Handle_BlockFix_SphereSpaceModifier::~Handle_BlockFix_SphereSpaceModifier() {} - diff --git a/src/GEOMAlgo/BlockFix_SphereSpaceModifier.jxx b/src/GEOMAlgo/BlockFix_SphereSpaceModifier.jxx deleted file mode 100644 index 050734179..000000000 --- a/src/GEOMAlgo/BlockFix_SphereSpaceModifier.jxx +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 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.com -// - -#ifndef _TopoDS_Face_HeaderFile -#include -#endif -#ifndef _Geom_Surface_HeaderFile -#include -#endif -#ifndef _TopLoc_Location_HeaderFile -#include -#endif -#ifndef _TopoDS_Edge_HeaderFile -#include -#endif -#ifndef _Geom_Curve_HeaderFile -#include -#endif -#ifndef _TopoDS_Vertex_HeaderFile -#include -#endif -#ifndef _gp_Pnt_HeaderFile -#include -#endif -#ifndef _Geom2d_Curve_HeaderFile -#include -#endif -#ifndef _BlockFix_SphereSpaceModifier_HeaderFile -#include -#endif diff --git a/src/GEOMAlgo/BlockFix_UnionEdges.cdl b/src/GEOMAlgo/BlockFix_UnionEdges.cdl deleted file mode 100644 index 05a9f3870..000000000 --- a/src/GEOMAlgo/BlockFix_UnionEdges.cdl +++ /dev/null @@ -1,49 +0,0 @@ --- Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE --- --- Copyright (C) 2003-2007 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.com --- - --- File: BlockFix_UnionEdges.cdl --- Created: Tue Dec 7 15:24:51 2004 --- Author: Sergey KUUL --- -class UnionEdges from BlockFix - - ---Purpose: - -uses - - Shape from TopoDS, - ReShape from ShapeBuild - -is - - Create returns UnionEdges from BlockFix; - - Perform(me: in out; Shape: Shape from TopoDS; - Tol : Real) - returns Shape from TopoDS; - -fields - - myTolerance : Real; - myContext : ReShape from ShapeBuild; - -end UnionEdges; diff --git a/src/GEOMAlgo/BlockFix_UnionEdges.cxx b/src/GEOMAlgo/BlockFix_UnionEdges.cxx deleted file mode 100644 index 95a1a713e..000000000 --- a/src/GEOMAlgo/BlockFix_UnionEdges.cxx +++ /dev/null @@ -1,589 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 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.com - -// File: BlockFix_UnionEdges.cxx -// Created: 07.12.04 15:27:30 -// Author: Sergey KUUL - -#include - -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "utilities.h" - -//======================================================================= -//function : BlockFix_UnionEdges() -//purpose : Constructor -//======================================================================= -BlockFix_UnionEdges::BlockFix_UnionEdges ( ) -{ -} - -//======================================================================= -//function : GlueEdgesWithPCurves -//purpose : Glues the pcurves of the sequence of edges -// and glues their 3d curves -//======================================================================= -static TopoDS_Edge GlueEdgesWithPCurves(const TopTools_SequenceOfShape& aChain, - const TopoDS_Vertex& FirstVertex, - const TopoDS_Vertex& LastVertex) -{ - Standard_Integer i, j; - - TopoDS_Edge FirstEdge = TopoDS::Edge(aChain(1)); - //TColGeom2d_SequenceOfCurve PCurveSeq; - TColGeom_SequenceOfSurface SurfSeq; - //TopTools_SequenceOfShape LocSeq; - - BRep_ListIteratorOfListOfCurveRepresentation itr( (Handle(BRep_TEdge)::DownCast(FirstEdge.TShape()))->Curves() ); - for (; itr.More(); itr.Next()) - { - Handle(BRep_CurveRepresentation) CurveRep = itr.Value(); - if (CurveRep->IsCurveOnSurface()) - { - //PCurveSeq.Append(CurveRep->PCurve()); - SurfSeq.Append(CurveRep->Surface()); - /* - TopoDS_Shape aLocShape; - aLocShape.Location(CurveRep->Location()); - LocSeq.Append(aLocShape); - */ - } - } - - Standard_Real fpar, lpar; - BRep_Tool::Range(FirstEdge, fpar, lpar); - TopoDS_Edge PrevEdge = FirstEdge; - TopoDS_Vertex CV; - Standard_Real MaxTol = 0.; - - TopoDS_Edge ResEdge; - BRep_Builder BB; - - Standard_Integer nb_curve = aChain.Length(); //number of curves - TColGeom_Array1OfBSplineCurve tab_c3d(0,nb_curve-1); //array of the curves - TColStd_Array1OfReal tabtolvertex(0,nb_curve-1); //(0,nb_curve-2); //array of the tolerances - - TopoDS_Vertex PrevVertex = FirstVertex; - for (i = 1; i <= nb_curve; i++) - { - TopoDS_Edge anEdge = TopoDS::Edge(aChain(i)); - TopoDS_Vertex VF, VL; - TopExp::Vertices(anEdge, VF, VL); - Standard_Boolean ToReverse = (!VF.IsSame(PrevVertex)); - - Standard_Real Tol1 = BRep_Tool::Tolerance(VF); - Standard_Real Tol2 = BRep_Tool::Tolerance(VL); - if (Tol1 > MaxTol) - MaxTol = Tol1; - if (Tol2 > MaxTol) - MaxTol = Tol2; - - if (i > 1) - { - TopExp::CommonVertex(PrevEdge, anEdge, CV); - Standard_Real Tol = BRep_Tool::Tolerance(CV); - tabtolvertex(i-2) = Tol; - } - - Handle(Geom_Curve) aCurve = BRep_Tool::Curve(anEdge, fpar, lpar); - Handle(Geom_TrimmedCurve) aTrCurve = new Geom_TrimmedCurve(aCurve, fpar, lpar); - tab_c3d(i-1) = GeomConvert::CurveToBSplineCurve(aTrCurve); - GeomConvert::C0BSplineToC1BSplineCurve(tab_c3d(i-1), Precision::Confusion()); - if (ToReverse) - tab_c3d(i-1)->Reverse(); - PrevVertex = (ToReverse)? VF : VL; - PrevEdge = anEdge; - } - Handle(TColGeom_HArray1OfBSplineCurve) concatcurve; //array of the concatenated curves - Handle(TColStd_HArray1OfInteger) ArrayOfIndices; //array of the remining Vertex - GeomConvert::ConcatC1(tab_c3d, - tabtolvertex, - ArrayOfIndices, - concatcurve, - Standard_False, - Precision::Confusion()); //C1 concatenation - - if (concatcurve->Length() > 1) - { - GeomConvert_CompCurveToBSplineCurve Concat(concatcurve->Value(concatcurve->Lower())); - - for (i = concatcurve->Lower()+1; i <= concatcurve->Upper(); i++) - Concat.Add( concatcurve->Value(i), MaxTol, Standard_True ); - - concatcurve->SetValue(concatcurve->Lower(), Concat.BSplineCurve()); - } - Handle(Geom_BSplineCurve) ResCurve = concatcurve->Value(concatcurve->Lower()); - - TColGeom2d_SequenceOfBoundedCurve ResPCurves; - TopLoc_Location aLoc; - for (j = 1; j <= SurfSeq.Length(); j++) - { - TColGeom2d_Array1OfBSplineCurve tab_c2d(0,nb_curve-1); //array of the pcurves - - PrevVertex = FirstVertex; - PrevEdge = FirstEdge; - //TopLoc_Location theLoc = LocSeq(j).Location(); - for (i = 1; i <= nb_curve; i++) - { - TopoDS_Edge anEdge = TopoDS::Edge(aChain(i)); - TopoDS_Vertex VF, VL; - TopExp::Vertices(anEdge, VF, VL); - Standard_Boolean ToReverse = (!VF.IsSame(PrevVertex)); - - /* - Handle(Geom2d_Curve) aPCurve = - BRep_Tool::CurveOnSurface(anEdge, SurfSeq(j), anEdge.Location()*theLoc, fpar, lpar); - */ - Handle(Geom2d_Curve) aPCurve = - BRep_Tool::CurveOnSurface(anEdge, SurfSeq(j), aLoc, fpar, lpar); - Handle(Geom2d_TrimmedCurve) aTrPCurve = new Geom2d_TrimmedCurve(aPCurve, fpar, lpar); - tab_c2d(i-1) = Geom2dConvert::CurveToBSplineCurve(aTrPCurve); - Geom2dConvert::C0BSplineToC1BSplineCurve(tab_c2d(i-1), Precision::Confusion()); - if (ToReverse) - tab_c2d(i-1)->Reverse(); - PrevVertex = (ToReverse)? VF : VL; - PrevEdge = anEdge; - } - Handle(TColGeom2d_HArray1OfBSplineCurve) concatc2d; //array of the concatenated curves - Handle(TColStd_HArray1OfInteger) ArrayOfInd2d; //array of the remining Vertex - Geom2dConvert::ConcatC1(tab_c2d, - tabtolvertex, - ArrayOfInd2d, - concatc2d, - Standard_False, - Precision::Confusion()); //C1 concatenation - - if (concatc2d->Length() > 1) - { - Geom2dConvert_CompCurveToBSplineCurve Concat2d(concatc2d->Value(concatc2d->Lower())); - - for (i = concatc2d->Lower()+1; i <= concatc2d->Upper(); i++) - Concat2d.Add( concatc2d->Value(i), MaxTol, Standard_True ); - - concatc2d->SetValue(concatc2d->Lower(), Concat2d.BSplineCurve()); - } - Handle(Geom2d_BSplineCurve) aResPCurve = concatc2d->Value(concatc2d->Lower()); - ResPCurves.Append(aResPCurve); - } - - ResEdge = BRepLib_MakeEdge(ResCurve, - FirstVertex, LastVertex, - ResCurve->FirstParameter(), ResCurve->LastParameter()); - BB.SameRange(ResEdge, Standard_False); - BB.SameParameter(ResEdge, Standard_False); - for (j = 1; j <= ResPCurves.Length(); j++) - { - BB.UpdateEdge(ResEdge, ResPCurves(j), SurfSeq(j), aLoc, MaxTol); - BB.Range(ResEdge, SurfSeq(j), aLoc, ResPCurves(j)->FirstParameter(), ResPCurves(j)->LastParameter()); - } - - BRepLib::SameParameter(ResEdge, MaxTol, Standard_True); - - return ResEdge; -} - -//======================================================================= -//function : MergeEdges -//purpose : auxilary -//======================================================================= -static Standard_Boolean MergeEdges(const TopTools_SequenceOfShape& SeqEdges, - const TopoDS_Face& aFace, - const Standard_Real Tol, - TopoDS_Edge& anEdge) -{ - // make chain for union - BRep_Builder B; - ShapeAnalysis_Edge sae; - TopoDS_Edge FirstE = TopoDS::Edge(SeqEdges.Value(1)); - TopoDS_Edge LastE = FirstE; - TopoDS_Vertex VF = sae.FirstVertex(FirstE); - TopoDS_Vertex VL = sae.LastVertex(LastE); - TopTools_SequenceOfShape aChain; - aChain.Append(FirstE); - TColStd_MapOfInteger IndUsedEdges; - IndUsedEdges.Add(1); - Standard_Integer j; - for(j=2; j<=SeqEdges.Length(); j++) { - for(Standard_Integer k=2; k<=SeqEdges.Length(); k++) { - if(IndUsedEdges.Contains(k)) continue; - TopoDS_Edge edge = TopoDS::Edge(SeqEdges.Value(k)); - TopoDS_Vertex VF2 = sae.FirstVertex(edge); - TopoDS_Vertex VL2 = sae.LastVertex(edge); - if(sae.FirstVertex(edge).IsSame(VL)) { - aChain.Append(edge); - LastE = edge; - VL = sae.LastVertex(LastE); - IndUsedEdges.Add(k); - } - else if(sae.LastVertex(edge).IsSame(VF)) { - aChain.Prepend(edge); - FirstE = edge; - VF = sae.FirstVertex(FirstE); - IndUsedEdges.Add(k); - } - } - } - if(aChain.Length()IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) { - Handle(Geom_TrimmedCurve) tc = - Handle(Geom_TrimmedCurve)::DownCast(c3d1); - c3d1 = tc->BasisCurve(); - } - TopoDS_Edge edge2 = TopoDS::Edge(aChain.Value(j+1)); - Handle(Geom_Curve) c3d2 = BRep_Tool::Curve(edge2,Loc,fp2,lp2); - if(c3d2.IsNull()) break; - while(c3d2->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) { - Handle(Geom_TrimmedCurve) tc = - Handle(Geom_TrimmedCurve)::DownCast(c3d2); - c3d2 = tc->BasisCurve(); - } - if( c3d1->IsKind(STANDARD_TYPE(Geom_Line)) && c3d2->IsKind(STANDARD_TYPE(Geom_Line)) ) { - // union lines - Handle(Geom_Line) L1 = Handle(Geom_Line)::DownCast(c3d1); - Handle(Geom_Line) L2 = Handle(Geom_Line)::DownCast(c3d2); - gp_Dir Dir1 = L1->Position().Direction(); - gp_Dir Dir2 = L2->Position().Direction(); - //if(!Dir1.IsEqual(Dir2,Precision::Angular())) { - //if(!Dir1.IsParallel(Dir2,Precision::Angular())) { - if(!Dir1.IsParallel(Dir2,Tol)) { - continue; - } - // can union lines => create new edge - TopoDS_Vertex V1 = sae.FirstVertex(edge1); - gp_Pnt PV1 = BRep_Tool::Pnt(V1); - TopoDS_Vertex V2 = sae.LastVertex(edge2); - gp_Pnt PV2 = BRep_Tool::Pnt(V2); - gp_Vec Vec(PV1,PV2); - Handle(Geom_Line) L = new Geom_Line(gp_Ax1(PV1,Vec)); - Standard_Real dist = PV1.Distance(PV2); - Handle(Geom_TrimmedCurve) tc = new Geom_TrimmedCurve(L,0.0,dist); - TopoDS_Edge E; - B.MakeEdge (E,tc,Precision::Confusion()); - B.Add (E,V1); B.Add (E,V2); - B.UpdateVertex(V1, 0., E, 0.); - B.UpdateVertex(V2, dist, E, 0.); - //ShapeFix_Edge sfe; - //sfe.FixAddPCurve(E,aFace,Standard_False); - //sfe.FixSameParameter(E); - aChain.Remove(j); - aChain.SetValue(j,E); - j--; - } - if( c3d1->IsKind(STANDARD_TYPE(Geom_Circle)) && c3d2->IsKind(STANDARD_TYPE(Geom_Circle)) ) { - // union circles - Handle(Geom_Circle) C1 = Handle(Geom_Circle)::DownCast(c3d1); - Handle(Geom_Circle) C2 = Handle(Geom_Circle)::DownCast(c3d2); - gp_Pnt P01 = C1->Location(); - gp_Pnt P02 = C2->Location(); - if (P01.Distance(P02) > Precision::Confusion()) continue; - // can union circles => create new edge - TopoDS_Vertex V1 = sae.FirstVertex(edge1); - gp_Pnt PV1 = BRep_Tool::Pnt(V1); - TopoDS_Vertex V2 = sae.LastVertex(edge2); - gp_Pnt PV2 = BRep_Tool::Pnt(V2); - TopoDS_Vertex VM = sae.LastVertex(edge1); - gp_Pnt PVM = BRep_Tool::Pnt(VM); - GC_MakeCircle MC (PV1,PVM,PV2); - Handle(Geom_Circle) C = MC.Value(); - TopoDS_Edge E; - if (!MC.IsDone() || C.IsNull()) { - // jfa for Mantis issue 0020228 - if (PV1.Distance(PV2) > Precision::Confusion()) continue; - // closed chain - C = C1; - B.MakeEdge (E,C,Precision::Confusion()); - B.Add(E,V1); - B.Add(E,V2); - } - else { - gp_Pnt P0 = C->Location(); - gp_Dir D1(gp_Vec(P0,PV1)); - gp_Dir D2(gp_Vec(P0,PV2)); - Standard_Real fpar = C->XAxis().Direction().Angle(D1); - if(fabs(fpar)>Precision::Confusion()) { - // check orientation - gp_Dir ND = C->XAxis().Direction().Crossed(D1); - if(ND.IsOpposite(C->Axis().Direction(),Precision::Confusion())) { - fpar = -fpar; - } - } - Standard_Real lpar = C->XAxis().Direction().Angle(D2); - if(fabs(lpar)>Precision::Confusion()) { - // check orientation - gp_Dir ND = C->XAxis().Direction().Crossed(D2); - if(ND.IsOpposite(C->Axis().Direction(),Precision::Confusion())) { - lpar = -lpar; - } - } - if (lpar < fpar) lpar += 2*M_PI; - Handle(Geom_TrimmedCurve) tc = new Geom_TrimmedCurve(C,fpar,lpar); - B.MakeEdge (E,tc,Precision::Confusion()); - B.Add(E,V1); - B.Add(E,V2); - B.UpdateVertex(V1, fpar, E, 0.); - B.UpdateVertex(V2, lpar, E, 0.); - } - aChain.Remove(j); - aChain.SetValue(j,E); - j--; - } - } - if (j < aChain.Length()) { - MESSAGE ("null curve3d in edge..."); - return Standard_False; - } - if (aChain.Length() > 1) { - // second step: union edges with various curves - // skl for bug 0020052 from Mantis: perform such unions - // only if curves are bspline or bezier - bool NeedUnion = true; - for(j=1; j<=aChain.Length(); j++) { - TopoDS_Edge edge = TopoDS::Edge(aChain.Value(j)); - Handle(Geom_Curve) c3d = BRep_Tool::Curve(edge,Loc,fp1,lp1); - if(c3d.IsNull()) continue; - while(c3d->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) { - Handle(Geom_TrimmedCurve) tc = - Handle(Geom_TrimmedCurve)::DownCast(c3d); - c3d = tc->BasisCurve(); - } - if( ( c3d->IsKind(STANDARD_TYPE(Geom_BSplineCurve)) || - c3d->IsKind(STANDARD_TYPE(Geom_BezierCurve)) ) ) continue; - NeedUnion = false; - break; - } - if(NeedUnion) { - MESSAGE ("can not make analitical union => make approximation"); - TopoDS_Edge E = GlueEdgesWithPCurves(aChain, VF, VL); - /* - TopoDS_Wire W; - B.MakeWire(W); - for(j=1; j<=aChain.Length(); j++) { - TopoDS_Edge edge = TopoDS::Edge(aChain.Value(j)); - B.Add(W,edge); - } - Handle(BRepAdaptor_HCompCurve) Adapt = new BRepAdaptor_HCompCurve(W); - Approx_Curve3d Conv(Adapt,Tol,GeomAbs_C1,9,1000); - Handle(Geom_BSplineCurve) bc = Conv.Curve(); - TopoDS_Edge E; - B.MakeEdge (E,bc,Precision::Confusion()); - B.Add (E,VF); - B.Add (E,VL); - */ - aChain.SetValue(1,E); - } - else { - MESSAGE ("can not make approximation for such types of curves"); - return Standard_False; - } - } - - anEdge = TopoDS::Edge(aChain.Value(1)); - return Standard_True; -} - -//======================================================================= -//function : Perform -//purpose : -//======================================================================= -TopoDS_Shape BlockFix_UnionEdges::Perform(const TopoDS_Shape& Shape, - const Standard_Real Tol) -{ - myContext = new ShapeBuild_ReShape; - myTolerance = Tol; - TopoDS_Shape aResult = myContext->Apply(Shape); - - // processing each solid - TopAbs_ShapeEnum aType = TopAbs_SOLID; - TopExp_Explorer exps (Shape, aType); - if (!exps.More()) { - aType = TopAbs_SHELL; - exps.Init(Shape, aType); - } - for (; exps.More(); exps.Next()) { - //TopoDS_Solid aSolid = TopoDS::Solid(exps.Current()); - TopoDS_Shape aSolid = exps.Current(); - - TopTools_IndexedMapOfShape ChangedFaces; - - // creating map of edge faces - TopTools_IndexedDataMapOfShapeListOfShape aMapEdgeFaces; - TopExp::MapShapesAndAncestors(aSolid, TopAbs_EDGE, TopAbs_FACE, aMapEdgeFaces); - - Handle(ShapeBuild_ReShape) aContext = new ShapeBuild_ReShape; - TopoDS_Shape aRes = aSolid; - aRes = aContext->Apply(aSolid); - - // processing each face - TopExp_Explorer exp; - for (exp.Init(aRes, TopAbs_FACE); exp.More(); exp.Next()) { - TopoDS_Face aFace = - TopoDS::Face(aContext->Apply(exp.Current().Oriented(TopAbs_FORWARD))); - TopTools_IndexedDataMapOfShapeListOfShape aMapFacesEdges; - - for (TopExp_Explorer expe(aFace,TopAbs_EDGE); expe.More(); expe.Next()) { - TopoDS_Edge edge = TopoDS::Edge(expe.Current()); - if (!aMapEdgeFaces.Contains(edge)) continue; - const TopTools_ListOfShape& aList = aMapEdgeFaces.FindFromKey(edge); - TopTools_ListIteratorOfListOfShape anIter(aList); - for ( ; anIter.More(); anIter.Next()) { - TopoDS_Face face = TopoDS::Face(anIter.Value()); - TopoDS_Face face1 = TopoDS::Face(aContext->Apply(anIter.Value())); - if (face1.IsSame(aFace)) continue; - if (aMapFacesEdges.Contains(face)) { - aMapFacesEdges.ChangeFromKey(face).Append(edge); - } - else { - TopTools_ListOfShape ListEdges; - ListEdges.Append(edge); - aMapFacesEdges.Add(face,ListEdges); - } - } - } - - for (Standard_Integer i=1; i<=aMapFacesEdges.Extent(); i++) { - const TopTools_ListOfShape& ListEdges = aMapFacesEdges.FindFromIndex(i); - TopTools_SequenceOfShape SeqEdges; - TopTools_ListIteratorOfListOfShape anIter(ListEdges); - for ( ; anIter.More(); anIter.Next()) { - SeqEdges.Append(anIter.Value()); - } - if (SeqEdges.Length()==1) continue; - TopoDS_Edge E; - if ( MergeEdges(SeqEdges,aFace,Tol,E) ) { - // now we have only one edge - aChain.Value(1) - // we have to replace old ListEdges with this new edge - aContext->Replace(SeqEdges(1),E); - for (Standard_Integer j=2; j<=SeqEdges.Length(); j++) { - aContext->Remove(SeqEdges(j)); - } - TopoDS_Face tmpF = TopoDS::Face(exp.Current()); - if ( !ChangedFaces.Contains(tmpF) ) - ChangedFaces.Add(tmpF); - tmpF = TopoDS::Face(aMapFacesEdges.FindKey(i)); - if ( !ChangedFaces.Contains(tmpF) ) - ChangedFaces.Add(tmpF); - } - } - - } // end processing each face - - // fix changed faces and replace them in the local context - for (Standard_Integer i=1; i<=ChangedFaces.Extent(); i++) { - TopoDS_Face aFace = TopoDS::Face(aContext->Apply(ChangedFaces.FindKey(i))); - Handle(ShapeFix_Face) sff = new ShapeFix_Face(aFace); - sff->SetContext(myContext); - sff->SetPrecision(myTolerance); - sff->SetMinTolerance(myTolerance); - sff->SetMaxTolerance(Max(1.,myTolerance*1000.)); - sff->Perform(); - aContext->Replace(aFace,sff->Face()); - } - - if (ChangedFaces.Extent() > 0) { - // fix changed shell and replace it in the local context - TopoDS_Shape aRes1 = aContext->Apply(aRes); - TopExp_Explorer expsh; - for (expsh.Init(aRes1, TopAbs_SHELL); expsh.More(); expsh.Next()) { - TopoDS_Shell aShell = TopoDS::Shell(expsh.Current()); - Handle(ShapeFix_Shell) sfsh = new ShapeFix_Shell; - sfsh->FixFaceOrientation(aShell); - aContext->Replace(aShell,sfsh->Shell()); - } - TopoDS_Shape aRes2 = aContext->Apply(aRes1); - // put new solid into global context - myContext->Replace(aSolid,aRes2); - } - - } // end processing each solid - - aResult = myContext->Apply(Shape); - return aResult; -} diff --git a/src/GEOMAlgo/BlockFix_UnionEdges.hxx b/src/GEOMAlgo/BlockFix_UnionEdges.hxx deleted file mode 100644 index b38e941fb..000000000 --- a/src/GEOMAlgo/BlockFix_UnionEdges.hxx +++ /dev/null @@ -1,100 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 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.com -// - -#ifndef _BlockFix_UnionEdges_HeaderFile -#define _BlockFix_UnionEdges_HeaderFile - -#ifndef _Standard_Real_HeaderFile -#include -#endif -#ifndef _Handle_ShapeBuild_ReShape_HeaderFile -#include -#endif -class ShapeBuild_ReShape; -class TopoDS_Shape; - - -#ifndef _Standard_HeaderFile -#include -#endif -#ifndef _Standard_Macro_HeaderFile -#include -#endif - -class BlockFix_UnionEdges { - -public: - - void* operator new(size_t,void* anAddress) - { - return anAddress; - } - void* operator new(size_t size) - { - return Standard::Allocate(size); - } - void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } - // Methods PUBLIC - // -Standard_EXPORT BlockFix_UnionEdges(); -Standard_EXPORT TopoDS_Shape Perform(const TopoDS_Shape& Shape,const Standard_Real Tol) ; - - - - - -protected: - - // Methods PROTECTED - // - - - // Fields PROTECTED - // - - -private: - - // Methods PRIVATE - // - - - // Fields PRIVATE - // -Standard_Real myTolerance; -Handle_ShapeBuild_ReShape myContext; - - -}; - - - - - -// other Inline functions and methods (like "C++: function call" methods) -// - - -#endif diff --git a/src/GEOMAlgo/BlockFix_UnionEdges.ixx b/src/GEOMAlgo/BlockFix_UnionEdges.ixx deleted file mode 100644 index 27e87ac6c..000000000 --- a/src/GEOMAlgo/BlockFix_UnionEdges.ixx +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 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.com -// - -#include - - - - diff --git a/src/GEOMAlgo/BlockFix_UnionEdges.jxx b/src/GEOMAlgo/BlockFix_UnionEdges.jxx deleted file mode 100644 index 558e8d82b..000000000 --- a/src/GEOMAlgo/BlockFix_UnionEdges.jxx +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 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.com -// - -#ifndef _ShapeBuild_ReShape_HeaderFile -#include -#endif -#ifndef _TopoDS_Shape_HeaderFile -#include -#endif -#ifndef _BlockFix_UnionEdges_HeaderFile -#include -#endif diff --git a/src/GEOMAlgo/BlockFix_UnionFaces.cdl b/src/GEOMAlgo/BlockFix_UnionFaces.cdl deleted file mode 100644 index 371cb25ea..000000000 --- a/src/GEOMAlgo/BlockFix_UnionFaces.cdl +++ /dev/null @@ -1,65 +0,0 @@ --- Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE --- --- Copyright (C) 2003-2007 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.com --- - --- File: BlockFix_UnionFaces.cdl --- Created: Tue Dec 7 17:15:42 2004 --- Author: Pavel Durandin --- -class UnionFaces from BlockFix - -uses - - Face from TopoDS, - Shape from TopoDS - -is - - Create returns UnionFaces from BlockFix; - ---Purpose: Empty constructor - - GetTolerance(me: in out) returns Real; - ---Purpose: Returns modifiable tolerance - ---C++: return& - - Perform (me: in out; Shape: Shape from TopoDS) returns Shape from TopoDS; - ---Purpose: Performs the unification of the fsces - -- whith the same geometry - - IsSameDomain(me; aFace : Face from TopoDS; - aChekedFace: Face from TopoDS) - returns Boolean is virtual; - ---Purpose: Returns true is surfaces have same geometrically domain - -- with given tolerance - - MovePCurves(me; aTarget: in out Face from TopoDS; - aSource: Face from TopoDS) - is virtual; - ---Purpose: Creates pcurves on aTarget face for each edge from - -- aSource one. - -fields - - myTolerance: Real; - -end; - - diff --git a/src/GEOMAlgo/BlockFix_UnionFaces.cxx b/src/GEOMAlgo/BlockFix_UnionFaces.cxx deleted file mode 100644 index c800fd421..000000000 --- a/src/GEOMAlgo/BlockFix_UnionFaces.cxx +++ /dev/null @@ -1,722 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 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.com -// - -// File: BlockFix_UnionFaces.cxx -// Created: Tue Dec 7 17:15:42 2004 -// Author: Pavel DURANDIN - -#include - -#include - -#include -#include - -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include - -#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 -#include -#else -#include -#endif - -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#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 - -//======================================================================= -//function : BlockFix_UnionFaces -//purpose : -//======================================================================= - -BlockFix_UnionFaces::BlockFix_UnionFaces() - : myTolerance(Precision::Confusion()), - myOptimumNbFaces(6) -{ -} - - -//======================================================================= -//function : GetTolerance -//purpose : -//======================================================================= - -Standard_Real& BlockFix_UnionFaces::GetTolerance() -{ - return myTolerance; -} - - -//======================================================================= -//function : GetOptimumNbFaces -//purpose : -//======================================================================= - -Standard_Integer& BlockFix_UnionFaces::GetOptimumNbFaces() -{ - return myOptimumNbFaces; -} - - -//======================================================================= -//function : AddOrdinaryEdges -//purpose : auxilary -//======================================================================= -// adds edges from the shape to the sequence -// seams and equal edges are dropped -// Returns true if one of original edges dropped -static Standard_Boolean AddOrdinaryEdges(TopTools_SequenceOfShape& edges, - const TopoDS_Shape aShape, - Standard_Integer& anIndex) -{ - //map of edges - TopTools_MapOfShape aNewEdges; - //add edges without seams - for(TopExp_Explorer exp(aShape,TopAbs_EDGE); exp.More(); exp.Next()) { - TopoDS_Shape edge = exp.Current(); - if(aNewEdges.Contains(edge)) - aNewEdges.Remove(edge); - else - aNewEdges.Add(edge); - } - - Standard_Boolean isDropped = Standard_False; - //merge edges and drop seams - for(Standard_Integer i = 1; i <= edges.Length(); i++) { - TopoDS_Shape current = edges(i); - if(aNewEdges.Contains(current)) { - - aNewEdges.Remove(current); - edges.Remove(i); - i--; - - if(!isDropped) { - isDropped = Standard_True; - anIndex = i; - } - } - } - - //add edges to the sequemce - for(TopTools_MapIteratorOfMapOfShape anIter(aNewEdges); anIter.More(); anIter.Next()) - edges.Append(anIter.Key()); - - return isDropped; -} - - -//======================================================================= -//function : ClearRts -//purpose : auxilary -//======================================================================= -static Handle(Geom_Surface) ClearRts(const Handle(Geom_Surface)& aSurface) -{ - if(aSurface->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) { - Handle(Geom_RectangularTrimmedSurface) rts = - Handle(Geom_RectangularTrimmedSurface)::DownCast(aSurface); - return rts->BasisSurface(); - } - return aSurface; -} - - -//======================================================================= -//function : Perform -//purpose : -//======================================================================= - -TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape) -{ - Handle(ShapeBuild_ReShape) myContext = new ShapeBuild_ReShape; - TopoDS_Shape aResShape = myContext->Apply(Shape); - - // processing each solid - TopExp_Explorer exps; - for (exps.Init(Shape, TopAbs_SOLID); exps.More(); exps.Next()) { - TopoDS_Solid aSolid = TopoDS::Solid(exps.Current()); - - // creating map of edge faces - TopTools_IndexedDataMapOfShapeListOfShape aMapEdgeFaces; - TopExp::MapShapesAndAncestors(aSolid, TopAbs_EDGE, TopAbs_FACE, aMapEdgeFaces); - - // map of processed shapes - TopTools_MapOfShape aProcessed; - - Handle(ShapeBuild_ReShape) aContext = new ShapeBuild_ReShape; - - Standard_Integer NbModif = 0; - Standard_Boolean hasFailed = Standard_False; - Standard_Real tol = Min(Max(Precision::Confusion(), myTolerance/10.), 0.1); - - // count faces - int nbf = 0; - TopExp_Explorer exp; - TopTools_MapOfShape mapF; - for (exp.Init(aSolid, TopAbs_FACE); exp.More(); exp.Next()) { - if (mapF.Add(exp.Current())) - nbf++; - } - - bool doUnion = ((myOptimumNbFaces == 0) || - ((myOptimumNbFaces > 0) && (nbf > myOptimumNbFaces))); - - // processing each face - mapF.Clear(); - for (exp.Init(aSolid, TopAbs_FACE); exp.More() && doUnion; exp.Next()) { - TopoDS_Face aFace = TopoDS::Face(exp.Current().Oriented(TopAbs_FORWARD)); - - if (aProcessed.Contains(aFace)) - continue; - - Standard_Integer dummy; - TopTools_SequenceOfShape edges; - AddOrdinaryEdges(edges,aFace,dummy); - - TopTools_SequenceOfShape faces; - faces.Append(aFace); - - //surface and location to construct result - TopLoc_Location aBaseLocation; - Handle(Geom_Surface) aBaseSurface = BRep_Tool::Surface(aFace,aBaseLocation); - aBaseSurface = ClearRts(aBaseSurface); - - // find adjacent faces to union - Standard_Integer i; - for (i = 1; i <= edges.Length(); i++) { - TopoDS_Edge edge = TopoDS::Edge(edges(i)); - if (BRep_Tool::Degenerated(edge)) - continue; - - const TopTools_ListOfShape& aList = aMapEdgeFaces.FindFromKey(edge); - TopTools_ListIteratorOfListOfShape anIter(aList); - for (; anIter.More(); anIter.Next()) { - TopoDS_Face anCheckedFace = TopoDS::Face(anIter.Value().Oriented(TopAbs_FORWARD)); - if (anCheckedFace.IsSame(aFace)) - continue; - - if (aProcessed.Contains(anCheckedFace)) - continue; - - if (IsSameDomain(aFace,anCheckedFace)) { - - if (aList.Extent() != 2) { - // non mainfold case is not processed - continue; - } - - // replacing pcurves - TopoDS_Face aMockUpFace; - BRep_Builder B; - B.MakeFace(aMockUpFace,aBaseSurface,aBaseLocation,0.); - MovePCurves(aMockUpFace,anCheckedFace); - - if (AddOrdinaryEdges(edges,aMockUpFace,dummy)) { - // sequence edges is modified - i = dummy; - } - - faces.Append(anCheckedFace); - aProcessed.Add(anCheckedFace); - break; - } - } - } - - // all faces collected in the sequence. Perform union of faces - if (faces.Length() > 1) { - NbModif++; - TopoDS_Face aResult; - BRep_Builder B; - B.MakeFace(aResult,aBaseSurface,aBaseLocation,0); - Standard_Integer nbWires = 0; - - // connecting wires - while (edges.Length()>0) { - - Standard_Boolean isEdge3d = Standard_False; - nbWires++; - TopTools_MapOfShape aVertices; - TopoDS_Wire aWire; - B.MakeWire(aWire); - - TopoDS_Edge anEdge = TopoDS::Edge(edges(1)); - edges.Remove(1); - - isEdge3d |= !BRep_Tool::Degenerated(anEdge); - B.Add(aWire,anEdge); - TopoDS_Vertex V1,V2; - TopExp::Vertices(anEdge,V1,V2); - aVertices.Add(V1); - aVertices.Add(V2); - - Standard_Boolean isNewFound = Standard_False; - do { - isNewFound = Standard_False; - for(Standard_Integer j = 1; j <= edges.Length(); j++) { - anEdge = TopoDS::Edge(edges(j)); - TopExp::Vertices(anEdge,V1,V2); - if(aVertices.Contains(V1) || aVertices.Contains(V2)) { - isEdge3d |= !BRep_Tool::Degenerated(anEdge); - aVertices.Add(V1); - aVertices.Add(V2); - B.Add(aWire,anEdge); - edges.Remove(j); - j--; - isNewFound = Standard_True; - } - } - } while (isNewFound); - - // sorting any type of edges - aWire = TopoDS::Wire(aContext->Apply(aWire)); - - TopoDS_Face tmpF = TopoDS::Face(aContext->Apply(faces(1).Oriented(TopAbs_FORWARD))); - Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire(aWire,tmpF,Precision::Confusion()); - sfw->FixReorder(); - Standard_Boolean isDegRemoved = Standard_False; - if(!sfw->StatusReorder ( ShapeExtend_FAIL )) { - // clear degenerated edges if at least one with 3d curve exist - if(isEdge3d) { - Handle(ShapeExtend_WireData) sewd = sfw->WireData(); - for(Standard_Integer j = 1; j<=sewd->NbEdges();j++) { - TopoDS_Edge E = sewd->Edge(j); - if(BRep_Tool::Degenerated(E)) { - sewd->Remove(j); - isDegRemoved = Standard_True; - j--; - } - } - } - sfw->FixShifted(); - if(isDegRemoved) - sfw->FixDegenerated(); - } - TopoDS_Wire aWireFixed = sfw->Wire(); - aContext->Replace(aWire,aWireFixed); - // add resulting wire - if(isEdge3d) { - B.Add(aResult,aWireFixed); - } - else { - // sorting edges - Handle(ShapeExtend_WireData) sbwd = sfw->WireData(); - Standard_Integer nbEdges = sbwd->NbEdges(); - // sort degenerated edges and create one edge instead of several ones - ShapeAnalysis_WireOrder sawo(Standard_False, 0); - ShapeAnalysis_Edge sae; - Standard_Integer aLastEdge = nbEdges; - for(Standard_Integer j = 1; j <= nbEdges; j++) { - Standard_Real f,l; - //smh protection on NULL pcurve - Handle(Geom2d_Curve) c2d; - if(!sae.PCurve(sbwd->Edge(j),tmpF,c2d,f,l)) { - aLastEdge--; - continue; - } - sawo.Add(c2d->Value(f).XY(),c2d->Value(l).XY()); - } - sawo.Perform(); - - // constructind one degenerative edge - gp_XY aStart, anEnd, tmp; - Standard_Integer nbFirst = sawo.Ordered(1); - TopoDS_Edge anOrigE = TopoDS::Edge(sbwd->Edge(nbFirst).Oriented(TopAbs_FORWARD)); - ShapeBuild_Edge sbe; - TopoDS_Vertex aDummyV; - TopoDS_Edge E = sbe.CopyReplaceVertices(anOrigE,aDummyV,aDummyV); - sawo.XY(nbFirst,aStart,tmp); - sawo.XY(sawo.Ordered(aLastEdge),tmp,anEnd); - - gp_XY aVec = anEnd-aStart; - Handle(Geom2d_Line) aLine = new Geom2d_Line(aStart,gp_Dir2d(anEnd-aStart)); - - B.UpdateEdge(E,aLine,tmpF,0.); - B.Range(E,tmpF,0.,aVec.Modulus()); - Handle(Geom_Curve) C3d; - B.UpdateEdge(E,C3d,0.); - B.Degenerated(E,Standard_True); - TopoDS_Wire aW; - B.MakeWire(aW); - B.Add(aW,E); - B.Add(aResult,aW); - } - } - - // perform substitution of face - aContext->Replace(aContext->Apply(aFace),aResult); - - ShapeFix_Face sff (aResult); - //Intializing by tolerances - sff.SetPrecision(myTolerance); - sff.SetMinTolerance(tol); - sff.SetMaxTolerance(Max(1.,myTolerance*1000.)); - //Setting modes - sff.FixOrientationMode() = 0; - //sff.FixWireMode() = 0; - sff.SetContext(aContext); - // Applying the fixes - sff.Perform(); - if(sff.Status(ShapeExtend_FAIL)) - hasFailed = Standard_True; - - // breaking down to several faces - TopoDS_Shape theResult = aContext->Apply(aResult); - for (TopExp_Explorer aFaceExp (theResult,TopAbs_FACE); aFaceExp.More(); aFaceExp.Next()) { - TopoDS_Face aCurrent = TopoDS::Face(aFaceExp.Current().Oriented(TopAbs_FORWARD)); - Handle(TColGeom_HArray2OfSurface) grid = new TColGeom_HArray2OfSurface ( 1, 1, 1, 1 ); - grid->SetValue ( 1, 1, aBaseSurface ); - Handle(ShapeExtend_CompositeSurface) G = new ShapeExtend_CompositeSurface ( grid ); - ShapeFix_ComposeShell CompShell; - CompShell.Init ( G, aBaseLocation, aCurrent, ::Precision::Confusion() );//myPrecision - CompShell.SetContext( aContext ); - - TopTools_SequenceOfShape parts; - ShapeFix_SequenceOfWireSegment wires; - for(TopExp_Explorer W_Exp(aCurrent,TopAbs_WIRE);W_Exp.More();W_Exp.Next()) { - Handle(ShapeExtend_WireData) sbwd = - new ShapeExtend_WireData ( TopoDS::Wire(W_Exp.Current() )); - ShapeFix_WireSegment seg ( sbwd, TopAbs_REVERSED ); - wires.Append(seg); - } - - CompShell.DispatchWires ( parts,wires ); - for (Standard_Integer j=1; j <= parts.Length(); j++ ) { - ShapeFix_Face aFixOrient(TopoDS::Face(parts(j))); - aFixOrient.SetContext(aContext); - aFixOrient.FixOrientation(); - } - - TopoDS_Shape CompRes; - if ( faces.Length() !=1 ) { - TopoDS_Shell S; - B.MakeShell ( S ); - for ( i=1; i <= parts.Length(); i++ ) - B.Add ( S, parts(i) ); - CompRes = S; - } - else CompRes = parts(1); - - aContext->Replace(aCurrent,CompRes); - } - - // remove the remaining faces - for(i = 2; i <= faces.Length(); i++) - aContext->Remove(faces(i)); - } - } // end processing each face - - //TopoDS_Shape aResult = Shape; - if (NbModif > 0 && !hasFailed) { - TopoDS_Shape aResult = aContext->Apply(aSolid); - - ShapeFix_Edge sfe; - for (exp.Init(aResult,TopAbs_EDGE); exp.More(); exp.Next()) { - TopoDS_Edge E = TopoDS::Edge(exp.Current()); - sfe.FixVertexTolerance (E); - // ptv add fix same parameter - sfe.FixSameParameter(E, myTolerance); - } - - myContext->Replace(aSolid, aResult); - } - //else - { - for (exp.Init(aSolid, TopAbs_FACE); exp.More(); exp.Next()) { - TopoDS_Face aFace = TopoDS::Face(exp.Current().Oriented(TopAbs_FORWARD)); - Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire; - sfw->SetContext(myContext); - sfw->SetPrecision(myTolerance); - sfw->SetMinTolerance(myTolerance); - sfw->SetMaxTolerance(Max(1.,myTolerance*1000.)); - sfw->SetFace(aFace); - for (TopoDS_Iterator iter (aFace,Standard_False); iter.More(); iter.Next()) { - TopoDS_Wire wire = TopoDS::Wire(iter.Value()); - sfw->Load(wire); - sfw->FixReorder(); - sfw->FixShifted(); - } - } - } - } // end processing each solid - - aResShape = myContext->Apply(Shape); - return aResShape; -} - - -//======================================================================= -//function : IsSameDomain -//purpose : -//======================================================================= - -bool getCylinder (Handle(Geom_Surface)& theInSurface, gp_Cylinder& theOutCylinder) -{ - bool isCylinder = false; - - if (theInSurface->IsKind(STANDARD_TYPE(Geom_CylindricalSurface))) { - Handle(Geom_CylindricalSurface) aGC = Handle(Geom_CylindricalSurface)::DownCast(theInSurface); - - theOutCylinder = aGC->Cylinder(); - isCylinder = true; - } - else if (theInSurface->IsKind(STANDARD_TYPE(Geom_SurfaceOfRevolution))) { - Handle(Geom_SurfaceOfRevolution) aRS = - Handle(Geom_SurfaceOfRevolution)::DownCast(theInSurface); - Handle(Geom_Curve) aBasis = aRS->BasisCurve(); - if (aBasis->IsKind(STANDARD_TYPE(Geom_Line))) { - Handle(Geom_Line) aBasisLine = Handle(Geom_Line)::DownCast(aBasis); - gp_Dir aDir = aRS->Direction(); - gp_Dir aBasisDir = aBasisLine->Position().Direction(); - if (aBasisDir.IsParallel(aDir, Precision::Confusion())) { - // basis line is parallel to the revolution axis: it is a cylinder - gp_Pnt aLoc = aRS->Location(); - Standard_Real aR = aBasisLine->Lin().Distance(aLoc); - gp_Ax3 aCylAx (aLoc, aDir); - - theOutCylinder = gp_Cylinder(aCylAx, aR); - isCylinder = true; - } - } - } - else if (theInSurface->IsKind(STANDARD_TYPE(Geom_SurfaceOfLinearExtrusion))) { - Handle(Geom_SurfaceOfLinearExtrusion) aLES = - Handle(Geom_SurfaceOfLinearExtrusion)::DownCast(theInSurface); - Handle(Geom_Curve) aBasis = aLES->BasisCurve(); - if (aBasis->IsKind(STANDARD_TYPE(Geom_Circle))) { - Handle(Geom_Circle) aBasisCircle = Handle(Geom_Circle)::DownCast(aBasis); - gp_Dir aDir = aLES->Direction(); - gp_Dir aBasisDir = aBasisCircle->Position().Direction(); - if (aBasisDir.IsParallel(aDir, Precision::Confusion())) { - // basis circle is normal to the extrusion axis: it is a cylinder - gp_Pnt aLoc = aBasisCircle->Location(); - Standard_Real aR = aBasisCircle->Radius(); - gp_Ax3 aCylAx (aLoc, aDir); - - theOutCylinder = gp_Cylinder(aCylAx, aR); - isCylinder = true; - } - } - } - else { - } - - return isCylinder; -} - -Standard_Boolean BlockFix_UnionFaces::IsSameDomain(const TopoDS_Face& aFace, - const TopoDS_Face& aCheckedFace) const -{ - //checking the same handles - TopLoc_Location L1, L2; - Handle(Geom_Surface) S1, S2; - - S1 = BRep_Tool::Surface(aFace,L1); - S2 = BRep_Tool::Surface(aCheckedFace,L2); - - if (S1 == S2 && L1 == L2) - return true; - - // planar and cylindrical cases (IMP 20052) - Standard_Real aPrec = Precision::Confusion(); - - S1 = BRep_Tool::Surface(aFace); - S2 = BRep_Tool::Surface(aCheckedFace); - - S1 = ClearRts(S1); - S2 = ClearRts(S2); - - //Handle(Geom_OffsetSurface) aGOFS1, aGOFS2; - //aGOFS1 = Handle(Geom_OffsetSurface)::DownCast(S1); - //aGOFS2 = Handle(Geom_OffsetSurface)::DownCast(S2); - //if (!aGOFS1.IsNull()) S1 = aGOFS1->BasisSurface(); - //if (!aGOFS2.IsNull()) S2 = aGOFS2->BasisSurface(); - - // case of two elementary surfaces: use OCCT tool - // elementary surfaces: ConicalSurface, CylindricalSurface, - // Plane, SphericalSurface and ToroidalSurface - if (S1->IsKind(STANDARD_TYPE(Geom_ElementarySurface)) && - S2->IsKind(STANDARD_TYPE(Geom_ElementarySurface))) - { - Handle(GeomAdaptor_HSurface) aGA1 = new GeomAdaptor_HSurface(S1); - Handle(GeomAdaptor_HSurface) aGA2 = new GeomAdaptor_HSurface(S2); - - Handle(BRepTopAdaptor_TopolTool) aTT1 = new BRepTopAdaptor_TopolTool(); - Handle(BRepTopAdaptor_TopolTool) aTT2 = new BRepTopAdaptor_TopolTool(); - - try { -#if OCC_VERSION_LARGE > 0x06010000 - OCC_CATCH_SIGNALS; -#endif - -#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 - IntPatch_ImpImpIntersection anIIInt (aGA1, aTT1, aGA2, aTT2, aPrec, aPrec); -#else - IntPatch_TheIIIntOfIntersection anIIInt (aGA1, aTT1, aGA2, aTT2, aPrec, aPrec); -#endif - if (!anIIInt.IsDone() || anIIInt.IsEmpty()) - return false; - - return anIIInt.TangentFaces(); - } - catch (Standard_Failure) { - return false; - } - } - - // case of two planar surfaces: - // all kinds of surfaces checked, including b-spline and bezier - GeomLib_IsPlanarSurface aPlanarityChecker1 (S1, aPrec); - if (aPlanarityChecker1.IsPlanar()) { - GeomLib_IsPlanarSurface aPlanarityChecker2 (S2, aPrec); - if (aPlanarityChecker2.IsPlanar()) { - gp_Pln aPln1 = aPlanarityChecker1.Plan(); - gp_Pln aPln2 = aPlanarityChecker2.Plan(); - - if (aPln1.Position().Direction().IsParallel(aPln2.Position().Direction(), aPrec) && - aPln1.Distance(aPln2) < aPrec) { - return true; - } - } - } - - // case of two cylindrical surfaces, at least one of which is a swept surface - // swept surfaces: SurfaceOfLinearExtrusion, SurfaceOfRevolution - if ((S1->IsKind(STANDARD_TYPE(Geom_CylindricalSurface)) || - S1->IsKind(STANDARD_TYPE(Geom_SweptSurface))) && - (S2->IsKind(STANDARD_TYPE(Geom_CylindricalSurface)) || - S2->IsKind(STANDARD_TYPE(Geom_SweptSurface)))) - { - gp_Cylinder aCyl1, aCyl2; - if (getCylinder(S1, aCyl1) && getCylinder(S2, aCyl2)) { - if (fabs(aCyl1.Radius() - aCyl2.Radius()) < aPrec) { - gp_Dir aDir1 = aCyl1.Position().Direction(); - gp_Dir aDir2 = aCyl2.Position().Direction(); - if (aDir1.IsParallel(aDir2, aPrec)) { - gp_Pnt aLoc1 = aCyl1.Location(); - gp_Pnt aLoc2 = aCyl2.Location(); - gp_Vec aVec12 (aLoc1, aLoc2); - if (aVec12.SquareMagnitude() < aPrec*aPrec || - aVec12.IsParallel(aDir1, aPrec)) { - return true; - } - } - } - } - } - - return false; -} - - -//======================================================================= -//function : MovePCurves -//purpose : -//======================================================================= - -void BlockFix_UnionFaces::MovePCurves(TopoDS_Face& aTarget, - const TopoDS_Face& aSource) const -{ - BRep_Builder B; - for(TopExp_Explorer wexp(aSource,TopAbs_WIRE);wexp.More();wexp.Next()) { - Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire(TopoDS::Wire(wexp.Current()), - aTarget, Precision::Confusion()); - sfw->FixReorder(); - Standard_Boolean isReoredFailed = sfw->StatusReorder ( ShapeExtend_FAIL ); - sfw->FixEdgeCurves(); - if(isReoredFailed) - continue; - - sfw->FixShifted(); - sfw->FixDegenerated(); - - // remove degenerated edges from not degenerated points - ShapeAnalysis_Edge sae; - Handle(ShapeExtend_WireData) sewd = sfw->WireData(); - for(Standard_Integer i = 1; i<=sewd->NbEdges();i++) { - TopoDS_Edge E = sewd->Edge(i); - if(BRep_Tool::Degenerated(E)&&!sae.HasPCurve(E,aTarget)) { - sewd->Remove(i); - i--; - } - } - - TopoDS_Wire ResWire = sfw->Wire(); - B.Add(aTarget,ResWire); - } -} diff --git a/src/GEOMAlgo/BlockFix_UnionFaces.hxx b/src/GEOMAlgo/BlockFix_UnionFaces.hxx deleted file mode 100644 index f676d5bcf..000000000 --- a/src/GEOMAlgo/BlockFix_UnionFaces.hxx +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 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.com -// - -#ifndef _BlockFix_UnionFaces_HeaderFile -#define _BlockFix_UnionFaces_HeaderFile - -#ifndef _Standard_Real_HeaderFile -#include -#endif -#ifndef _Standard_Boolean_HeaderFile -#include -#endif -#ifndef _Standard_HeaderFile -#include -#endif -#ifndef _Standard_Macro_HeaderFile -#include -#endif - -class TopoDS_Shape; -class TopoDS_Face; - -class BlockFix_UnionFaces -{ -public: - void* operator new(size_t,void* anAddress) - { - return anAddress; - } - void* operator new(size_t size) - { - return Standard::Allocate(size); - } - void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } - - // Methods PUBLIC - // - Standard_EXPORT BlockFix_UnionFaces(); - - Standard_EXPORT Standard_Real& GetTolerance(); - - /* \brief To get/set the OptimumNbFaces parameter - * - * If a being processed solid has less than OptimumNbFaces - * faces, no union will be performed. - * By default this parameter is set to 6 (to correctly - * process blocks - hexahedral solids) - * Special values: 0 - do all possible unions, regardless the faces quantity, - * negative - do not perform any unions, regardless the faces quantity. - * - */ - Standard_EXPORT Standard_Integer& GetOptimumNbFaces(); - - Standard_EXPORT TopoDS_Shape Perform(const TopoDS_Shape& Shape); - - Standard_EXPORT virtual Standard_Boolean IsSameDomain(const TopoDS_Face& aFace, - const TopoDS_Face& aChekedFace) const; - Standard_EXPORT virtual void MovePCurves(TopoDS_Face& aTarget, - const TopoDS_Face& aSource) const; - -private: - // Fields PRIVATE - // - Standard_Real myTolerance; - Standard_Integer myOptimumNbFaces; -}; - -#endif diff --git a/src/GEOMAlgo/BlockFix_UnionFaces.ixx b/src/GEOMAlgo/BlockFix_UnionFaces.ixx deleted file mode 100644 index c5299ca40..000000000 --- a/src/GEOMAlgo/BlockFix_UnionFaces.ixx +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 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.com -// - -#include - - - - diff --git a/src/GEOMAlgo/BlockFix_UnionFaces.jxx b/src/GEOMAlgo/BlockFix_UnionFaces.jxx deleted file mode 100644 index c89fc31fb..000000000 --- a/src/GEOMAlgo/BlockFix_UnionFaces.jxx +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 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.com -// - -#ifndef _TopoDS_Shape_HeaderFile -#include -#endif -#ifndef _TopoDS_Face_HeaderFile -#include -#endif -#ifndef _BlockFix_UnionFaces_HeaderFile -#include -#endif diff --git a/src/GEOMAlgo/FILES b/src/GEOMAlgo/FILES index 44aeb0c17..102101794 100644 --- a/src/GEOMAlgo/FILES +++ b/src/GEOMAlgo/FILES @@ -140,30 +140,3 @@ GEOMAlgo_IndexedDataMapOfShapeShapeInfo.hxx GEOMAlgo_IndexedDataMapOfShapeState.hxx GEOMAlgo_IndexedDataMapOfIntegerShape.hxx GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape.hxx - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/GEOMAlgo/Handle_BlockFix_BlockFixAPI.hxx b/src/GEOMAlgo/Handle_BlockFix_BlockFixAPI.hxx deleted file mode 100644 index 3fce5be46..000000000 --- a/src/GEOMAlgo/Handle_BlockFix_BlockFixAPI.hxx +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 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.com -// - -#ifndef _Handle_BlockFix_BlockFixAPI_HeaderFile -#define _Handle_BlockFix_BlockFixAPI_HeaderFile - -#ifndef _Standard_Macro_HeaderFile -#include -#endif -#ifndef _Standard_HeaderFile -#include -#endif - -#ifndef _Handle_MMgt_TShared_HeaderFile -#include -#endif - -class Standard_Transient; -class Handle_Standard_Type; -class Handle(MMgt_TShared); -class BlockFix_BlockFixAPI; -Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(BlockFix_BlockFixAPI); - -class Handle(BlockFix_BlockFixAPI) : public Handle(MMgt_TShared) { - public: - void* operator new(size_t,void* anAddress) - { - return anAddress; - } - void* operator new(size_t size) - { - return Standard::Allocate(size); - } - void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } - Handle(BlockFix_BlockFixAPI)():Handle(MMgt_TShared)() {} - Handle(BlockFix_BlockFixAPI)(const Handle(BlockFix_BlockFixAPI)& aHandle) : Handle(MMgt_TShared)(aHandle) - { - } - - Handle(BlockFix_BlockFixAPI)(const BlockFix_BlockFixAPI* anItem) : Handle(MMgt_TShared)((MMgt_TShared *)anItem) - { - } - - Handle(BlockFix_BlockFixAPI)& operator=(const Handle(BlockFix_BlockFixAPI)& aHandle) - { - Assign(aHandle.Access()); - return *this; - } - - Handle(BlockFix_BlockFixAPI)& operator=(const BlockFix_BlockFixAPI* anItem) - { - Assign((Standard_Transient *)anItem); - return *this; - } - - BlockFix_BlockFixAPI* operator->() - { - return (BlockFix_BlockFixAPI *)ControlAccess(); - } - - BlockFix_BlockFixAPI* operator->() const - { - return (BlockFix_BlockFixAPI *)ControlAccess(); - } - - Standard_EXPORT ~Handle(BlockFix_BlockFixAPI)(); - - Standard_EXPORT static const Handle(BlockFix_BlockFixAPI) DownCast(const Handle(Standard_Transient)& AnObject); -}; -#endif diff --git a/src/GEOMAlgo/Handle_BlockFix_PeriodicSurfaceModifier.hxx b/src/GEOMAlgo/Handle_BlockFix_PeriodicSurfaceModifier.hxx deleted file mode 100644 index 1cb29e022..000000000 --- a/src/GEOMAlgo/Handle_BlockFix_PeriodicSurfaceModifier.hxx +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 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.com -// - -#ifndef _Handle_BlockFix_PeriodicSurfaceModifier_HeaderFile -#define _Handle_BlockFix_PeriodicSurfaceModifier_HeaderFile - -#ifndef _Standard_Macro_HeaderFile -#include -#endif -#ifndef _Standard_HeaderFile -#include -#endif - -#ifndef _Handle_BRepTools_Modification_HeaderFile -#include -#endif - -class Standard_Transient; -class Handle_Standard_Type; -class Handle(BRepTools_Modification); -class BlockFix_PeriodicSurfaceModifier; -Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(BlockFix_PeriodicSurfaceModifier); - -class Handle(BlockFix_PeriodicSurfaceModifier) : public Handle(BRepTools_Modification) { - public: - void* operator new(size_t,void* anAddress) - { - return anAddress; - } - void* operator new(size_t size) - { - return Standard::Allocate(size); - } - void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } - Handle(BlockFix_PeriodicSurfaceModifier)():Handle(BRepTools_Modification)() {} - Handle(BlockFix_PeriodicSurfaceModifier)(const Handle(BlockFix_PeriodicSurfaceModifier)& aHandle) : Handle(BRepTools_Modification)(aHandle) - { - } - - Handle(BlockFix_PeriodicSurfaceModifier)(const BlockFix_PeriodicSurfaceModifier* anItem) : Handle(BRepTools_Modification)((BRepTools_Modification *)anItem) - { - } - - Handle(BlockFix_PeriodicSurfaceModifier)& operator=(const Handle(BlockFix_PeriodicSurfaceModifier)& aHandle) - { - Assign(aHandle.Access()); - return *this; - } - - Handle(BlockFix_PeriodicSurfaceModifier)& operator=(const BlockFix_PeriodicSurfaceModifier* anItem) - { - Assign((Standard_Transient *)anItem); - return *this; - } - - BlockFix_PeriodicSurfaceModifier* operator->() - { - return (BlockFix_PeriodicSurfaceModifier *)ControlAccess(); - } - - BlockFix_PeriodicSurfaceModifier* operator->() const - { - return (BlockFix_PeriodicSurfaceModifier *)ControlAccess(); - } - - Standard_EXPORT ~Handle(BlockFix_PeriodicSurfaceModifier)(); - - Standard_EXPORT static const Handle(BlockFix_PeriodicSurfaceModifier) DownCast(const Handle(Standard_Transient)& AnObject); -}; -#endif diff --git a/src/GEOMAlgo/Handle_BlockFix_SphereSpaceModifier.hxx b/src/GEOMAlgo/Handle_BlockFix_SphereSpaceModifier.hxx deleted file mode 100644 index 33dc8a198..000000000 --- a/src/GEOMAlgo/Handle_BlockFix_SphereSpaceModifier.hxx +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 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.com -// - -#ifndef _Handle_BlockFix_SphereSpaceModifier_HeaderFile -#define _Handle_BlockFix_SphereSpaceModifier_HeaderFile - -#ifndef _Standard_Macro_HeaderFile -#include -#endif -#ifndef _Standard_HeaderFile -#include -#endif - -#ifndef _Handle_BRepTools_Modification_HeaderFile -#include -#endif - -class Standard_Transient; -class Handle_Standard_Type; -class Handle(BRepTools_Modification); -class BlockFix_SphereSpaceModifier; -Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(BlockFix_SphereSpaceModifier); - -class Handle(BlockFix_SphereSpaceModifier) : public Handle(BRepTools_Modification) { - public: - void* operator new(size_t,void* anAddress) - { - return anAddress; - } - void* operator new(size_t size) - { - return Standard::Allocate(size); - } - void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } - Handle(BlockFix_SphereSpaceModifier)():Handle(BRepTools_Modification)() {} - Handle(BlockFix_SphereSpaceModifier)(const Handle(BlockFix_SphereSpaceModifier)& aHandle) : Handle(BRepTools_Modification)(aHandle) - { - } - - Handle(BlockFix_SphereSpaceModifier)(const BlockFix_SphereSpaceModifier* anItem) : Handle(BRepTools_Modification)((BRepTools_Modification *)anItem) - { - } - - Handle(BlockFix_SphereSpaceModifier)& operator=(const Handle(BlockFix_SphereSpaceModifier)& aHandle) - { - Assign(aHandle.Access()); - return *this; - } - - Handle(BlockFix_SphereSpaceModifier)& operator=(const BlockFix_SphereSpaceModifier* anItem) - { - Assign((Standard_Transient *)anItem); - return *this; - } - - BlockFix_SphereSpaceModifier* operator->() - { - return (BlockFix_SphereSpaceModifier *)ControlAccess(); - } - - BlockFix_SphereSpaceModifier* operator->() const - { - return (BlockFix_SphereSpaceModifier *)ControlAccess(); - } - - Standard_EXPORT ~Handle(BlockFix_SphereSpaceModifier)(); - - Standard_EXPORT static const Handle(BlockFix_SphereSpaceModifier) DownCast(const Handle(Standard_Transient)& AnObject); -}; -#endif diff --git a/src/GEOMAlgo/Makefile.am b/src/GEOMAlgo/Makefile.am index dacba0542..f54398d11 100644 --- a/src/GEOMAlgo/Makefile.am +++ b/src/GEOMAlgo/Makefile.am @@ -15,7 +15,6 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# # GEOM GEOMAlgo : tools for Glue Faces algorithm # File : Makefile.am @@ -28,13 +27,6 @@ include $(top_srcdir)/adm_local/unix/make_common_starter.am lib_LTLIBRARIES = libGEOMAlgo.la dist_libGEOMAlgo_la_SOURCES = \ - BlockFix_BlockFixAPI.cxx \ - BlockFix_CheckTool.cxx \ - BlockFix.cxx \ - BlockFix_PeriodicSurfaceModifier.cxx \ - BlockFix_SphereSpaceModifier.cxx \ - BlockFix_UnionEdges.cxx \ - BlockFix_UnionFaces.cxx \ GEOMAlgo_Algo.cxx \ GEOMAlgo_Builder_0.cxx \ GEOMAlgo_Builder_1.cxx \ @@ -96,31 +88,6 @@ dist_libGEOMAlgo_la_SOURCES = \ # header files salomeinclude_HEADERS = \ - BlockFix.hxx \ - BlockFix.ixx \ - BlockFix.jxx \ - BlockFix_BlockFixAPI.hxx \ - BlockFix_BlockFixAPI.ixx \ - BlockFix_BlockFixAPI.jxx \ - BlockFix_BlockFixAPI.lxx \ - BlockFix_CheckTool.hxx \ - BlockFix_CheckTool.ixx \ - BlockFix_CheckTool.jxx \ - BlockFix_PeriodicSurfaceModifier.hxx \ - BlockFix_PeriodicSurfaceModifier.ixx \ - BlockFix_PeriodicSurfaceModifier.jxx \ - BlockFix_SphereSpaceModifier.hxx \ - BlockFix_SphereSpaceModifier.ixx \ - BlockFix_SphereSpaceModifier.jxx \ - BlockFix_UnionEdges.hxx \ - BlockFix_UnionEdges.ixx \ - BlockFix_UnionEdges.jxx \ - BlockFix_UnionFaces.hxx \ - BlockFix_UnionFaces.ixx \ - BlockFix_UnionFaces.jxx \ - Handle_BlockFix_BlockFixAPI.hxx \ - Handle_BlockFix_SphereSpaceModifier.hxx \ - Handle_BlockFix_PeriodicSurfaceModifier.hxx \ GEOMAlgo_Algo.hxx \ GEOMAlgo_BuilderArea.hxx \ GEOMAlgo_BuilderFace.hxx \ @@ -211,15 +178,7 @@ libGEOMAlgo_la_LDFLAGS = \ $(KERNEL_LDFLAGS) -lSALOMELocalTrace # extra distributed files -CDL_FILES = \ - BlockFix.cdl \ - BlockFix_BlockFixAPI.cdl \ - BlockFix_CheckTool.cdl \ - BlockFix_PeriodicSurfaceModifier.cdl \ - BlockFix_SphereSpaceModifier.cdl \ - BlockFix_UnionEdges.cdl \ - BlockFix_UnionFaces.cdl \ - GEOMAlgo.cdl +CDL_FILES = GEOMAlgo.cdl EXTRA_DIST += \ $(CDL_FILES) \ diff --git a/src/GEOMBase/GEOMBase.cxx b/src/GEOMBase/GEOMBase.cxx index 1df7a528c..0e13b280e 100644 --- a/src/GEOMBase/GEOMBase.cxx +++ b/src/GEOMBase/GEOMBase.cxx @@ -512,7 +512,7 @@ TopoDS_Shape GEOMBase::CreateArrowForLinearEdge( const TopoDS_Shape& shape ) try { Standard_Real first, last; Handle(Geom_Curve) curv = BRep_Tool::Curve( TopoDS::Edge( shape ), first, last ); - if ( curv->IsCN(1) ) { + if ( !curv.IsNull() && curv->IsCN(1) ) { const Standard_Real param = ( first+last ) / 2.0; gp_Pnt middleParamPoint; gp_Vec V1; diff --git a/src/GEOMBase/GEOMBase_Helper.cxx b/src/GEOMBase/GEOMBase_Helper.cxx index 8fea8899a..4a051722c 100755 --- a/src/GEOMBase/GEOMBase_Helper.cxx +++ b/src/GEOMBase/GEOMBase_Helper.cxx @@ -18,12 +18,11 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// // GEOM GEOMGUI : GUI for Geometry component // File : GEOMBase_Helper.cxx // Author : Sergey ANIKIN, Open CASCADE S.A.S. (sergey.anikin@opencascade.com) -// + #include "GEOMBase_Helper.h" #include "GEOMBase.h" #include "GEOM_Operation.h" @@ -90,7 +89,7 @@ GEOM::GEOM_Gen_ptr GEOMBase_Helper::getGeomEngine() GEOMBase_Helper::GEOMBase_Helper( SUIT_Desktop* desktop ) : myDesktop( desktop ), myViewWindow( 0 ), myDisplayer( 0 ), myCommand( 0 ), isPreview( false ), myIsApplyAndClose( false ), myIsOptimizedBrowsing( false ), myIsWaitCursorEnabled( true ), - myIsDisableBrowsing(false) + myIsDisableBrowsing(false), myIsDisplayResult(true) { } @@ -319,19 +318,16 @@ void GEOMBase_Helper::displayPreview( GEOM::GEOM_Object_ptr object, const int displayMode, const int color ) { + SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); + // Set color for preview shape getDisplayer()->SetColor( color == -1 ? Quantity_NOC_VIOLET : color ); // set width of displayed shape - int lw = lineWidth; - if(lw == -1) { - SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); - lw = resMgr->integerValue("Geometry", "preview_edge_width", -1); - } - getDisplayer()->SetWidth( lw ); + getDisplayer()->SetWidth( lineWidth == -1 ? resMgr->integerValue("Geometry", "preview_edge_width", -1) : lineWidth ); // set display mode of displayed shape - int aPrevDispMode = getDisplayer()->SetDisplayMode( displayMode ); + int aPrevDispMode = getDisplayer()->SetDisplayMode( displayMode == -1 ? resMgr->integerValue( "Geometry", "display_mode", 0 ) : displayMode ); // Disable activation of selection getDisplayer()->SetToActivate( activate ); @@ -554,9 +550,10 @@ QString GEOMBase_Helper::addInStudy( GEOM::GEOM_Object_ptr theObj, const char* t getGeomEngine()->AddInStudy(aStudyDS, theObj, theName, aFatherObj); QString anEntry; - if ( !aSO->_is_nil() ) - anEntry = aSO->GetID(); - + if ( !aSO->_is_nil() ) { + CORBA::String_var entry = aSO->GetID(); + anEntry = entry.in(); + } // Each dialog is responsible for this method implementation, // default implementation does nothing restoreSubShapes(aStudyDS, aSO); @@ -770,7 +767,6 @@ bool GEOMBase_Helper::commitCommand( const char* ) //================================================================ bool GEOMBase_Helper::hasCommand() const { - bool res = (bool) myCommand; return (bool)myCommand; } @@ -858,11 +854,11 @@ bool GEOMBase_Helper::onAccept( const bool publish, const bool useTransaction, b addSubshapesToStudy(); // add Sub-shapes if local selection const int nbObjs = objects.size(); QStringList anEntryList; - int aNumber = 1; - for ( ObjectList::iterator it = objects.begin(); it != objects.end(); ++it ) { + int currObj = 1, aNumber = 1; + for ( ObjectList::iterator it = objects.begin(); it != objects.end(); ++it, currObj++ ) { GEOM::GEOM_Object_var obj=*it; if ( publish ) { - QString aName = getNewObjectName(); + QString aName = getNewObjectName(currObj); if ( nbObjs > 1 ) { if (aName.isEmpty()) aName = getPrefix(obj); @@ -880,7 +876,8 @@ bool GEOMBase_Helper::onAccept( const bool publish, const bool useTransaction, b } anEntryList << addInStudy( obj, aName.toLatin1().constData() ); // updateView=false - display( obj, false ); + if( isDisplayResult() ) + display( obj, false ); #ifdef WITHGENERICOBJ // obj has been published in study. Its refcount has been incremented. // It is safe to decrement its refcount @@ -893,7 +890,8 @@ bool GEOMBase_Helper::onAccept( const bool publish, const bool useTransaction, b // was modified, and need to be re-cached in GEOM_Client before redisplay clearShapeBuffer( obj ); // withChildren=true, updateView=false - redisplay( obj, true, false ); + if( isDisplayResult() ) + redisplay( obj, true, false ); } } @@ -1006,7 +1004,7 @@ GEOM::GEOM_Object_ptr GEOMBase_Helper::getFather( GEOM::GEOM_Object_ptr theObj ) // Function : getNewObjectName // Purpose : Redefine this method to return proper name for a new object //================================================================ -QString GEOMBase_Helper::getNewObjectName() const +QString GEOMBase_Helper::getNewObjectName (int) const { return QString::null; } @@ -1137,17 +1135,17 @@ GEOM::GEOM_Object_ptr GEOMBase_Helper::findObjectInFather( GEOM::GEOM_Object_ptr if ( sobject ) { _PTR(ChildIterator) it( studyDS->NewChildIterator( sobject ) ); for ( ; it->More() && !found; it->Next() ) { - GEOM::GEOM_Object_var cobject = GEOM::GEOM_Object::_narrow( GeometryGUI::ClientSObjectToObject( it->Value() ) ); - if ( !CORBA::is_nil( cobject ) ) { - GEOM::ListOfLong_var indices = cobject->GetSubShapeIndices(); - int length = indices->length(); - for ( int i = 0; i < length && !found; i++ ) { - if ( indices[i] == theIndex ) { - object = cobject; - found = true; - } - } - } + GEOM::GEOM_Object_var cobject = GEOM::GEOM_Object::_narrow( GeometryGUI::ClientSObjectToObject( it->Value() ) ); + if ( !CORBA::is_nil( cobject ) ) { + GEOM::ListOfLong_var indices = cobject->GetSubShapeIndices(); + int length = indices->length(); + for ( int i = 0; i < length && !found; i++ ) { + if ( indices[i] == theIndex ) { + object = cobject; + found = true; + } + } + } } } } @@ -1277,58 +1275,58 @@ QList GEOMBase_Helper::getSelected( const QListGetIndexes( IO, subShapes ); - int nbSubShapes = subShapes.Extent(); - if ( nbSubShapes == 0 ) { - // global selection - if ( typeInList( (TopAbs_ShapeEnum)(object->GetShapeType()), types ) ) { - result << object; - if ( count > 0 ) { - if ( strict && result.count() > count ) { - result.clear(); - stopped = true; - } - else if ( !strict && result.count() == count ) - stopped = true; - } - } - else if ( strict ) { - result.clear(); - stopped = true; - } - } - else { - // local selection - for ( int i = 1; i <= nbSubShapes && !stopped; i++ ) { - int idx = subShapes( i ); - GEOM::GeomObjPtr subShape = findObjectInFather( object.get(), idx ); - if ( !subShape ) { - // sub-shape is not yet published in the study - GEOM::ShapesOpPtr shapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() ); - subShape.take( shapesOp->GetSubShape( object.get(), idx ) ); // take ownership! - } - if ( typeInList( (TopAbs_ShapeEnum)(subShape->GetShapeType()), types ) ) { - result << subShape; - if ( count > 0 ) { - if ( strict && result.count() > count ) { - result.clear(); - stopped = true; - } - else if ( !strict && result.count() == count ) - stopped = true; - } - } - else if ( strict ) { - result.clear(); - stopped = true; - } - } - } - } + Handle(SALOME_InteractiveObject) IO = it.Value(); + GEOM::GeomObjPtr object = GEOMBase::ConvertIOinGEOMObject( IO ); + if ( object ) { + TColStd_IndexedMapOfInteger subShapes; + selMgr->GetIndexes( IO, subShapes ); + int nbSubShapes = subShapes.Extent(); + if ( nbSubShapes == 0 ) { + // global selection + if ( typeInList( (TopAbs_ShapeEnum)(object->GetShapeType()), types ) ) { + result << object; + if ( count > 0 ) { + if ( strict && result.count() > count ) { + result.clear(); + stopped = true; + } + else if ( !strict && result.count() == count ) + stopped = true; + } + } + else if ( strict ) { + result.clear(); + stopped = true; + } + } + else { + // local selection + for ( int i = 1; i <= nbSubShapes && !stopped; i++ ) { + int idx = subShapes( i ); + GEOM::GeomObjPtr subShape = findObjectInFather( object.get(), idx ); + if ( !subShape ) { + // sub-shape is not yet published in the study + GEOM::ShapesOpPtr shapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() ); + subShape.take( shapesOp->GetSubShape( object.get(), idx ) ); // take ownership! + } + if ( typeInList( (TopAbs_ShapeEnum)(subShape->GetShapeType()), types ) ) { + result << subShape; + if ( count > 0 ) { + if ( strict && result.count() > count ) { + result.clear(); + stopped = true; + } + else if ( !strict && result.count() == count ) + stopped = true; + } + } + else if ( strict ) { + result.clear(); + stopped = true; + } + } + } + } } } } diff --git a/src/GEOMBase/GEOMBase_Helper.h b/src/GEOMBase/GEOMBase_Helper.h index 5d32fd268..0a1ae7b6d 100755 --- a/src/GEOMBase/GEOMBase_Helper.h +++ b/src/GEOMBase/GEOMBase_Helper.h @@ -18,12 +18,11 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// // GEOM GEOMGUI : GUI for Geometry component // File : GEOMBase_Helper.h // Author : Sergey ANIKIN, Open CASCADE S.A.S. (sergey.anikin@opencascade.com) -// + #ifndef GEOMBASE_HELPER_H #define GEOMBASE_HELPER_H @@ -51,7 +50,7 @@ class TColStd_MapOfInteger; //================================================================ // Class : GEOMBase_Helper -// Description : Helper class for dialog box development, can be used as +// 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) @@ -73,24 +72,24 @@ protected: void redisplay ( GEOM::GEOM_Object_ptr, const bool = true, const bool = true ); virtual void displayPreview ( const bool display, - const bool activate = false, + const bool activate = false, const bool update = true, const bool toRemoveFromEngine = true, - const double lineWidth = -1, + const double lineWidth = -1, const int displayMode = -1, const int color = -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, + virtual void displayPreview ( GEOM::GEOM_Object_ptr obj, + const bool append = false, + const bool activate = false, const bool update = true, - const double lineWidth = -1, + const double lineWidth = -1, const int displayMode = -1, const int color = -1 ); - void displayPreview ( const SALOME_Prs* prs, - const bool append = false, + void displayPreview ( const SALOME_Prs* prs, + const bool append = false, const bool = true ); void erasePreview ( const bool = true ); @@ -105,7 +104,7 @@ protected: void prepareSelection( const ObjectList&, const int ); void prepareSelection( GEOM::GEOM_Object_ptr, const int ); - QString addInStudy ( GEOM::GEOM_Object_ptr, const char* theName ); + QString addInStudy ( GEOM::GEOM_Object_ptr, const char* theName ); bool openCommand (); bool abortCommand (); @@ -119,7 +118,7 @@ protected: bool onAccept( const bool publish = true, const bool useTransaction = true, bool erasePreviewFlag = true); // This method should be called from "OK" button handler. - // == true means that objects returned by execute() + // == true means that objects returned by execute() // should be published in a study. void showError(); @@ -134,16 +133,16 @@ protected: inline void setPrefix( const QString& prefix ) { myPrefix = prefix; } QString getPrefix( GEOM::GEOM_Object_ptr = GEOM::GEOM_Object::_nil() ) const; - + bool selectObjects( ObjectList& objects ); - // Selects list of objects + // Selects list of objects //////////////////////////////////////////////////////////////////////////// // 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 + // This method should be redefined in dialog boxes so as to return // proper GEOM_IOperation interface. // Returns nil reference by default @@ -151,9 +150,9 @@ protected: // 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. + // 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 void restoreSubShapes( SALOMEDS::Study_ptr theStudy, SALOMEDS::SObject_ptr theSObject ); // This method is called by addInStudy(). @@ -163,7 +162,7 @@ protected: // for or a nil reference if should be published // as a top-level object. - virtual QString getNewObjectName() const; + virtual QString getNewObjectName (int CurrObj = -1) const; virtual bool extractPrefix() const; virtual void addSubshapesToStudy(); @@ -187,12 +186,13 @@ protected: virtual void setIsOptimizedBrowsing( const bool theFlag ); virtual bool isOptimizedBrowsing() const; - + virtual void setIsWaitCursorEnabled( const bool theFlag ) {myIsWaitCursorEnabled = theFlag;} virtual bool isWaitCursorEnabled() const {return myIsWaitCursorEnabled ;} virtual void setIsDisableBrowsing( const bool theFlag ) { myIsDisableBrowsing = theFlag; } virtual bool isDisableBrowsing() const { return myIsDisableBrowsing; } - + virtual void setIsDisplayResult( const bool theFlag ) {myIsDisplayResult = theFlag; } + virtual bool isDisplayResult() const { return myIsDisplayResult; } private: QString getEntry( GEOM::GEOM_Object_ptr ) const; @@ -213,9 +213,9 @@ private: bool myIsApplyAndClose; bool myIsOptimizedBrowsing; bool myIsWaitCursorEnabled; - bool myIsDisableBrowsing; //This flag enable/disable selection + bool myIsDisableBrowsing; //This flag enable/disable selection //in the Object Browser newly created objects. - + bool myIsDisplayResult; //This flag display/hide newly created objects. }; #endif // GEOMBASE_HELPER_H diff --git a/src/GEOMBase/GEOMBase_Skeleton.cxx b/src/GEOMBase/GEOMBase_Skeleton.cxx index 57be34955..d6f286425 100644 --- a/src/GEOMBase/GEOMBase_Skeleton.cxx +++ b/src/GEOMBase/GEOMBase_Skeleton.cxx @@ -18,12 +18,11 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// // GEOM GEOMGUI : GUI for Geometry component // File : GEOMBase_Skeleton.cxx // Author : Damien COQUERET, Open CASCADE S.A.S. -// + #include "GEOMBase_Skeleton.h" #include "GEOMBase.h" @@ -293,7 +292,7 @@ void GEOMBase_Skeleton::initName( const QString& thePrefix ) // function : getNewObjectName() // purpose : returns contents of Name field //================================================================================= -QString GEOMBase_Skeleton::getNewObjectName() const +QString GEOMBase_Skeleton::getNewObjectName (int) const { return myMainFrame->ResultName->text(); } diff --git a/src/GEOMBase/GEOMBase_Skeleton.h b/src/GEOMBase/GEOMBase_Skeleton.h index bb6d75434..73bf0d2a2 100644 --- a/src/GEOMBase/GEOMBase_Skeleton.h +++ b/src/GEOMBase/GEOMBase_Skeleton.h @@ -18,12 +18,11 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// // GEOM GEOMGUI : GUI for Geometry component // File : GEOMBase_Skeleton.h // Author : Damine COQUERET, Open CASCADE S.A.S. -// + #ifndef GEOMBASE_SKELETON_H #define GEOMBASE_SKELETON_H @@ -74,7 +73,7 @@ protected: /*! returns contents of "Name" field */ - virtual QString getNewObjectName() const; + virtual QString getNewObjectName (int CurrObj = -1) const; /*! returns id of a selected "constructor" radio button or '-1' in case of error */ diff --git a/src/GEOMBase/GEOM_GenericObjPtr.h b/src/GEOMBase/GEOM_GenericObjPtr.h index b4ece1236..aec0ee23e 100644 --- a/src/GEOMBase/GEOM_GenericObjPtr.h +++ b/src/GEOMBase/GEOM_GenericObjPtr.h @@ -87,15 +87,15 @@ namespace GEOM void Register() { if ( !CORBA::is_nil( this->myObject ) ) - this->myObject->Register(); + this->myObject->Register(); } //! Decrement counter for the object. void UnRegister() { if ( !CORBA::is_nil( this->myObject ) ) { - this->myObject->UnRegister(); - this->myObject = TInterface::_nil(); + this->myObject->UnRegister(); + this->myObject = TInterface::_nil(); } } diff --git a/src/GEOMClient/Makefile.am b/src/GEOMClient/Makefile.am index b3addc3b2..d2775005a 100644 --- a/src/GEOMClient/Makefile.am +++ b/src/GEOMClient/Makefile.am @@ -22,7 +22,6 @@ # Author : Patrick GOLDBRONN (CEA) # Modified by : Alexander BORODIN (OCN) - autotools usage # Module : GEOM -# $Header$ # include $(top_srcdir)/adm_local/unix/make_common_starter.am diff --git a/src/GEOMGUI/GEOMGUI.cxx b/src/GEOMGUI/GEOMGUI.cxx index b87f89833..2e1021de3 100644 --- a/src/GEOMGUI/GEOMGUI.cxx +++ b/src/GEOMGUI/GEOMGUI.cxx @@ -48,6 +48,15 @@ GEOMGUI::~GEOMGUI() { } +//================================================================================= +// class : GEOMGUI::OnGUIEvent +// purpose : Main/popup menu events processing +//================================================================================= +bool GEOMGUI::OnGUIEvent( int /*theCommandID*/, SUIT_Desktop* /*parent*/, const QVariant& /*theParam*/ ) +{ + return TRUE; +} + //================================================================================= // class : GEOMGUI::OnGUIEvent // purpose : Main/popup menu events processing diff --git a/src/GEOMGUI/GEOMGUI.h b/src/GEOMGUI/GEOMGUI.h index 87b76ed24..eac15283a 100644 --- a/src/GEOMGUI/GEOMGUI.h +++ b/src/GEOMGUI/GEOMGUI.h @@ -51,6 +51,7 @@ public : // Each of this methods can be redifined by descendants virtual bool OnGUIEvent( int theCommandID, SUIT_Desktop* parent ); + virtual bool OnGUIEvent( int theCommandID, SUIT_Desktop* parent, const QVariant& theParam ); virtual bool OnMousePress( QMouseEvent* pe, SUIT_Desktop* parent, SUIT_ViewWindow* ); virtual bool OnMouseMove( QMouseEvent* pe, SUIT_Desktop* parent, SUIT_ViewWindow* ); diff --git a/src/GEOMGUI/GEOMGUI_Selection.cxx b/src/GEOMGUI/GEOMGUI_Selection.cxx index 0aa1da20a..4d7a490b0 100644 --- a/src/GEOMGUI/GEOMGUI_Selection.cxx +++ b/src/GEOMGUI/GEOMGUI_Selection.cxx @@ -213,27 +213,20 @@ int GEOMGUI_Selection::typeId( const int index ) const bool GEOMGUI_Selection::isVisible( const int index ) const { - bool res = false; - #ifdef USE_VISUAL_PROP_MAP - bool found = false; - QVariant v = visibleProperty( entry( index ), VISIBILITY_PROP ); - if ( v.canConvert( QVariant::Bool ) ) { - res = v.toBool(); - found = true; - } - - if ( !found ) { + QVariant v = visibleProperty( entry( index ), GEOM::propertyName( GEOM::Visibility ) ); + if ( v.canConvert( QVariant::Bool ) ) + return v.toBool(); #endif - GEOM::GEOM_Object_var obj = getObject( index ); - SALOME_View* view = GEOM_Displayer::GetActiveView(); - if ( !CORBA::is_nil( obj ) && view ) { - Handle(SALOME_InteractiveObject) io = new SALOME_InteractiveObject( entry( index ).toLatin1().constData(), "GEOM", "TEMP_IO" ); - res = view->isVisible( io ); - } -#ifdef USE_VISUAL_PROP_MAP + + bool res = false; + + GEOM::GEOM_Object_var obj = getObject( index ); + SALOME_View* view = GEOM_Displayer::GetActiveView(); + if ( !CORBA::is_nil( obj ) && view ) { + Handle(SALOME_InteractiveObject) io = new SALOME_InteractiveObject( entry( index ).toLatin1().constData(), "GEOM", "TEMP_IO" ); + res = view->isVisible( io ); } -#endif return res; } @@ -288,8 +281,9 @@ QString GEOMGUI_Selection::displayMode( const int index ) const { QString res; QString viewType = activeViewType(); + #ifdef USE_VISUAL_PROP_MAP - QVariant v = visibleProperty( entry( index ), DISPLAY_MODE_PROP ); + QVariant v = visibleProperty( entry( index ), GEOM::propertyName( GEOM::DisplayMode ) ); if ( v.canConvert( QVariant::Int ) ) { int dm = v.toInt(); if ( viewType == OCCViewer_Viewer::Type() ) { @@ -297,113 +291,103 @@ QString GEOMGUI_Selection::displayMode( const int index ) const } else if ( viewType == SVTK_Viewer::Type() ) { VTK_DISPLAY_MODE_TO_STRING( res, dm ); } + return res; } - - if ( res.isEmpty() ) { #endif - SALOME_View* view = GEOM_Displayer::GetActiveView(); - if ( view /*fix for 9320==>*/&& ( viewType == OCCViewer_Viewer::Type() || viewType == SVTK_Viewer::Type() ) ) { - SALOME_Prs* prs = view->CreatePrs( entry( index ).toLatin1().constData() ); - if ( prs ) { - if ( viewType == OCCViewer_Viewer::Type() ) { // assuming OCC - SOCC_Prs* occPrs = (SOCC_Prs*) prs; - AIS_ListOfInteractive lst; - occPrs->GetObjects( lst ); - if ( lst.Extent() ) { - Handle(AIS_InteractiveObject) io = lst.First(); - if ( !io.IsNull() ) { - int dm; - Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(io); - if(!aSh.IsNull()) { - dm = aSh->isTopLevel() ? aSh->prevDisplayMode() : aSh->DisplayMode(); - } else { - dm = io->DisplayMode(); - } + + SALOME_View* view = GEOM_Displayer::GetActiveView(); + if ( view /*fix for 9320==>*/&& ( viewType == OCCViewer_Viewer::Type() || viewType == SVTK_Viewer::Type() ) ) { + SALOME_Prs* prs = view->CreatePrs( entry( index ).toLatin1().constData() ); + if ( prs ) { + if ( viewType == OCCViewer_Viewer::Type() ) { // assuming OCC + SOCC_Prs* occPrs = (SOCC_Prs*) prs; + AIS_ListOfInteractive lst; + occPrs->GetObjects( lst ); + if ( lst.Extent() ) { + Handle(AIS_InteractiveObject) io = lst.First(); + if ( !io.IsNull() ) { + int dm; + Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(io); + if(!aSh.IsNull()) { + dm = aSh->isTopLevel() ? aSh->prevDisplayMode() : aSh->DisplayMode(); + } else { + dm = io->DisplayMode(); + } + OCC_DISPLAY_MODE_TO_STRING( res, dm ); + if ( res.isEmpty() ) { // return default display mode of AIS_InteractiveContext + OCCViewer_Viewer* occViewer = (OCCViewer_Viewer*)SUIT_Session::session()->activeApplication()-> + desktop()->activeWindow()->getViewManager()->getViewModel(); + Handle(AIS_InteractiveContext) ic = occViewer->getAISContext(); + dm = ic->DisplayMode(); OCC_DISPLAY_MODE_TO_STRING( res, dm ); - if ( res.isEmpty() ) { // return default display mode of AIS_InteractiveContext - OCCViewer_Viewer* occViewer = (OCCViewer_Viewer*)SUIT_Session::session()->activeApplication()-> - desktop()->activeWindow()->getViewManager()->getViewModel(); - Handle(AIS_InteractiveContext) ic = occViewer->getAISContext(); - dm = ic->DisplayMode(); - OCC_DISPLAY_MODE_TO_STRING( res, dm ); - } } } } - else if ( viewType == SVTK_Viewer::Type() ) { // assuming VTK - SVTK_Prs* vtkPrs = dynamic_cast( prs ); - vtkActorCollection* lst = vtkPrs ? vtkPrs->GetObjects() : 0; - if ( lst ) { - lst->InitTraversal(); - vtkActor* actor = lst->GetNextActor(); - if ( actor ) { - SALOME_Actor* salActor = dynamic_cast( actor ); - if ( salActor ) { - int dm = salActor->getDisplayMode(); - VTK_DISPLAY_MODE_TO_STRING( res, dm ); - } // if ( salome actor ) - } // if ( actor ) - } // if ( lst == vtkPrs->GetObjects() ) - } // if VTK } + else if ( viewType == SVTK_Viewer::Type() ) { // assuming VTK + SVTK_Prs* vtkPrs = dynamic_cast( prs ); + vtkActorCollection* lst = vtkPrs ? vtkPrs->GetObjects() : 0; + if ( lst ) { + lst->InitTraversal(); + vtkActor* actor = lst->GetNextActor(); + if ( actor ) { + SALOME_Actor* salActor = dynamic_cast( actor ); + if ( salActor ) { + int dm = salActor->getDisplayMode(); + VTK_DISPLAY_MODE_TO_STRING( res, dm ); + } // if ( salome actor ) + } // if ( actor ) + } // if ( lst == vtkPrs->GetObjects() ) + } // if VTK } - -#ifdef USE_VISUAL_PROP_MAP } -#endif return res; } bool GEOMGUI_Selection::isVectorsMode( const int index ) const { - bool res = false; - #ifdef USE_VISUAL_PROP_MAP - bool found = false; - QVariant v = visibleProperty( entry( index ), VECTOR_MODE_PROP ); - if ( v.canConvert( QVariant::Bool ) ) { - res = v.toBool(); - found = true; - } - - if ( !found ) { + QVariant v = visibleProperty( entry( index ), GEOM::propertyName( GEOM::EdgesDirection ) ); + if ( v.canConvert( QVariant::Bool ) ) + return v.toBool(); #endif - SALOME_View* view = GEOM_Displayer::GetActiveView(); - QString viewType = activeViewType(); - if ( view && ( viewType == OCCViewer_Viewer::Type() || viewType == SVTK_Viewer::Type() ) ) { - SALOME_Prs* prs = view->CreatePrs( entry( index ).toLatin1().constData() ); - if ( prs ) { - if ( viewType == OCCViewer_Viewer::Type() ) { // assuming OCC - SOCC_Prs* occPrs = (SOCC_Prs*) prs; - AIS_ListOfInteractive lst; - occPrs->GetObjects( lst ); - if ( lst.Extent() ) { - Handle(AIS_InteractiveObject) io = lst.First(); - if ( !io.IsNull() ) { - Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(io); - if ( !aSh.IsNull() ) - res = aSh->isShowVectors(); - } + + bool res = false; + + SALOME_View* view = GEOM_Displayer::GetActiveView(); + QString viewType = activeViewType(); + if ( view && ( viewType == OCCViewer_Viewer::Type() || viewType == SVTK_Viewer::Type() ) ) { + SALOME_Prs* prs = view->CreatePrs( entry( index ).toLatin1().constData() ); + if ( prs ) { + if ( viewType == OCCViewer_Viewer::Type() ) { // assuming OCC + SOCC_Prs* occPrs = (SOCC_Prs*) prs; + AIS_ListOfInteractive lst; + occPrs->GetObjects( lst ); + if ( lst.Extent() ) { + Handle(AIS_InteractiveObject) io = lst.First(); + if ( !io.IsNull() ) { + Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(io); + if ( !aSh.IsNull() ) + res = aSh->isShowVectors(); } - } else if ( viewType == SVTK_Viewer::Type() ) { // assuming VTK - SVTK_Prs* vtkPrs = dynamic_cast( prs ); - vtkActorCollection* lst = vtkPrs ? vtkPrs->GetObjects() : 0; - if ( lst ) { - lst->InitTraversal(); - vtkActor* actor = lst->GetNextActor(); - if ( actor ) { - GEOM_Actor* aGeomActor = GEOM_Actor::SafeDownCast(actor); - if ( aGeomActor ) - res = aGeomActor->GetVectorMode(); + } + } + else if ( viewType == SVTK_Viewer::Type() ) { // assuming VTK + SVTK_Prs* vtkPrs = dynamic_cast( prs ); + vtkActorCollection* lst = vtkPrs ? vtkPrs->GetObjects() : 0; + if ( lst ) { + lst->InitTraversal(); + vtkActor* actor = lst->GetNextActor(); + if ( actor ) { + GEOM_Actor* aGeomActor = GEOM_Actor::SafeDownCast(actor); + if ( aGeomActor ) + res = aGeomActor->GetVectorMode(); } - } } } } -#ifdef USE_VISUAL_PROP_MAP } -#endif return res; } @@ -548,35 +532,31 @@ QString GEOMGUI_Selection::selectionMode() const return ""; } -bool GEOMGUI_Selection::topLevel( const int index ) const { - bool res = false; - +bool GEOMGUI_Selection::topLevel( const int index ) const +{ #ifdef USE_VISUAL_PROP_MAP - bool found = false; - QVariant v = visibleProperty( entry( index ), TOP_LEVEL_PROP ); - if ( v.canConvert() ) { - res = v.toBool(); - found = true; - } - - if ( !found ) { + QVariant v = visibleProperty( entry( index ), GEOM::propertyName( GEOM::TopLevel ) ); + if ( v.canConvert() ) + return v.toBool(); #endif - SALOME_View* view = GEOM_Displayer::GetActiveView(); - QString viewType = activeViewType(); - if ( view && viewType == OCCViewer_Viewer::Type() ) { - SALOME_Prs* prs = view->CreatePrs( entry( index ).toLatin1().constData() ); - if ( prs ) { - if ( viewType == OCCViewer_Viewer::Type() ) { // assuming OCC - SOCC_Prs* occPrs = (SOCC_Prs*) prs; - AIS_ListOfInteractive lst; - occPrs->GetObjects( lst ); - if ( lst.Extent() ) { - Handle(AIS_InteractiveObject) io = lst.First(); - if ( !io.IsNull() ) { - Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(io); - if ( !aSh.IsNull() ) - res = (bool)aSh->isTopLevel(); - } + + bool res = false; + + SALOME_View* view = GEOM_Displayer::GetActiveView(); + QString viewType = activeViewType(); + if ( view && viewType == OCCViewer_Viewer::Type() ) { + SALOME_Prs* prs = view->CreatePrs( entry( index ).toLatin1().constData() ); + if ( prs ) { + if ( viewType == OCCViewer_Viewer::Type() ) { // assuming OCC + SOCC_Prs* occPrs = (SOCC_Prs*) prs; + AIS_ListOfInteractive lst; + occPrs->GetObjects( lst ); + if ( lst.Extent() ) { + Handle(AIS_InteractiveObject) io = lst.First(); + if ( !io.IsNull() ) { + Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(io); + if ( !aSh.IsNull() ) + res = (bool)aSh->isTopLevel(); } } } @@ -585,57 +565,55 @@ bool GEOMGUI_Selection::topLevel( const int index ) const { return res; } -bool GEOMGUI_Selection::isPhysicalMaterial( const int idx ) const{ - bool res = false; - +bool GEOMGUI_Selection::isPhysicalMaterial( const int idx ) const +{ #ifdef USE_VISUAL_PROP_MAP - bool found = false; - QVariant v = visibleProperty( entry( idx ), MATERIAL_PROP ); - if ( v.canConvert() ) { - Material_Model material; - material.fromProperties( v.toString() ); - res = material.isPhysical(); - found = true; - } - - if ( !found ) { + QVariant v = visibleProperty( entry( idx ), GEOM::propertyName( GEOM::Material ) ); + if ( v.canConvert() ) { + Material_Model material; + material.fromProperties( v.toString() ); + return material.isPhysical(); + } #endif - SALOME_View* view = GEOM_Displayer::GetActiveView(); - QString viewType = activeViewType(); - if ( view ) { - SALOME_Prs* prs = view->CreatePrs( entry( idx ).toLatin1().constData() ); - if ( prs ) { - if ( viewType == OCCViewer_Viewer::Type() ) { // assuming OCC - SOCC_Prs* occPrs = (SOCC_Prs*) prs; - AIS_ListOfInteractive lst; - occPrs->GetObjects( lst ); - if ( lst.Extent() ) { - Handle(AIS_InteractiveObject) io = lst.First(); - if ( !io.IsNull() ) { - Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(io); - if ( !aSh.IsNull() ) - res = (bool) aSh->Attributes()->ShadingAspect()-> - Material(Aspect_TOFM_BOTH_SIDE).MaterialType( Graphic3d_MATERIAL_PHYSIC ); - } - } - } - else if ( viewType == SVTK_Viewer::Type() ) { // assuming VTK - SVTK_Prs* vtkPrs = dynamic_cast( prs ); - vtkActorCollection* lst = vtkPrs ? vtkPrs->GetObjects() : 0; - if ( lst ) { - lst->InitTraversal(); - vtkActor* actor = lst->GetNextActor(); - if ( actor ) { - GEOM_Actor* aGeomGActor = GEOM_Actor::SafeDownCast( actor ); - if ( aGeomGActor ) { - GEOM_VTKPropertyMaterial* mat = GEOM_VTKPropertyMaterial::SafeDownCast(aGeomGActor->GetProperty()); - res = mat->GetPhysical(); - } // if ( salome actor ) - } // if ( actor ) - } // if ( lst == vtkPrs->GetObjects() ) - } - } - } - } - return res; + + bool res = false; + + SALOME_View* view = GEOM_Displayer::GetActiveView(); + QString viewType = activeViewType(); + if ( view ) { + SALOME_Prs* prs = view->CreatePrs( entry( idx ).toLatin1().constData() ); + if ( prs ) { + if ( viewType == OCCViewer_Viewer::Type() ) { // assuming OCC + SOCC_Prs* occPrs = (SOCC_Prs*) prs; + AIS_ListOfInteractive lst; + occPrs->GetObjects( lst ); + if ( lst.Extent() ) { + Handle(AIS_InteractiveObject) io = lst.First(); + if ( !io.IsNull() ) { + Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(io); + if ( !aSh.IsNull() ) + res = (bool) aSh->Attributes()->ShadingAspect()-> + Material(Aspect_TOFM_BOTH_SIDE).MaterialType( Graphic3d_MATERIAL_PHYSIC ); + } + } + } + else if ( viewType == SVTK_Viewer::Type() ) { // assuming VTK + SVTK_Prs* vtkPrs = dynamic_cast( prs ); + vtkActorCollection* lst = vtkPrs ? vtkPrs->GetObjects() : 0; + if ( lst ) { + lst->InitTraversal(); + vtkActor* actor = lst->GetNextActor(); + if ( actor ) { + GEOM_Actor* aGeomGActor = GEOM_Actor::SafeDownCast( actor ); + if ( aGeomGActor ) { + GEOM_VTKPropertyMaterial* mat = GEOM_VTKPropertyMaterial::SafeDownCast(aGeomGActor->GetProperty()); + res = mat->GetPhysical(); + } // if ( salome actor ) + } // if ( actor ) + } // if ( lst == vtkPrs->GetObjects() ) + } + } + } + + return res; } diff --git a/src/GEOMGUI/GEOM_Displayer.cxx b/src/GEOMGUI/GEOM_Displayer.cxx index 1718d7d0b..4b362a702 100644 --- a/src/GEOMGUI/GEOM_Displayer.cxx +++ b/src/GEOMGUI/GEOM_Displayer.cxx @@ -121,6 +121,9 @@ // of auto-color picking up #define SIMPLE_AUTOCOLOR +// Hard-coded value of shape deflection coefficient for VTK viewer +const double VTK_MIN_DEFLECTION = 0.001; + //================================================================ // Function : getActiveStudy // Purpose : Get active study, returns 0 if no open study frame @@ -323,6 +326,7 @@ GEOM_Displayer::GEOM_Displayer( SalomeApp_Study* st ) myShadingColor = SalomeApp_Tools::color( col ); myDisplayMode = resMgr->integerValue("Geometry", "display_mode", 0); + myHasDisplayMode = false; int aType = resMgr->integerValue("Geometry", "type_of_marker", (int)Aspect_TOM_PLUS); myWidth = resMgr->integerValue("Geometry", "edge_width", -1); @@ -342,10 +346,10 @@ GEOM_Displayer::GEOM_Displayer( SalomeApp_Study* st ) myToActivate = true; // This parameter is used for activisation/deactivisation of objects to be displayed - + #if OCC_VERSION_LARGE > 0x06050100 // Functionnality available only in OCCT 6.5.2 - // Activate parallel vizualisation only for testing purpose - // and if the corresponding env variable is set to 1 + // Activate parallel vizualisation only for testing purpose + // and if the corresponding env variable is set to 1 char* parallel_visu = getenv("PARALLEL_VISU"); if (parallel_visu && atoi(parallel_visu)) { @@ -393,7 +397,7 @@ void GEOM_Displayer::Display( const Handle(SALOME_InteractiveObject)& theIO, int aMgrId = getViewManagerId(vf); SalomeApp_Study* aStudy = getStudy(); - aStudy->setObjectProperty(aMgrId, theIO->getEntry(), VISIBILITY_PROP, 1 ); + aStudy->setObjectProperty(aMgrId, theIO->getEntry(), GEOM::propertyName( GEOM::Visibility ), 1 ); setVisibilityState(theIO->getEntry(), Qtx::ShownState); @@ -449,7 +453,7 @@ void GEOM_Displayer::Erase( const Handle(SALOME_InteractiveObject)& theIO, int aMgrId = getViewManagerId(vf); SalomeApp_Study* aStudy = getStudy(); - aStudy->setObjectProperty(aMgrId, theIO->getEntry(), VISIBILITY_PROP, 0 ); + aStudy->setObjectProperty(aMgrId, theIO->getEntry(), GEOM::propertyName( GEOM::Visibility ), 0 ); setVisibilityState(theIO->getEntry(), Qtx::HiddenState); } @@ -532,6 +536,371 @@ void GEOM_Displayer::Display( const SALOME_ListIO& theIOList, const bool updateV UpdateViewer(); } +Quantity_Color GEOM_Displayer::qColorFromResources( const QString& property, const QColor& defColor ) +{ + // VSR: this method can be improved in future: + // to improve performance, the default values from resource manager should be cached in the displayer + return SalomeApp_Tools::color( SUIT_Session::session()->resourceMgr()->colorValue( "Geometry", property, defColor ) ); +} + +QColor GEOM_Displayer::colorFromResources( const QString& property, const QColor& defColor ) +{ + // VSR: this method can be improved in future: + // to improve performance, the default values from resource manager should be cached in the displayer + return SUIT_Session::session()->resourceMgr()->colorValue( "Geometry", property, defColor ); +} + +void GEOM_Displayer::updateShapeProperties( const Handle(GEOM_AISShape)& AISShape, bool create ) +{ + // check that shape is not null + if ( AISShape.IsNull() ) return; + + // check that study is active + SalomeApp_Study* study = getStudy(); + if ( !study ) return; + + if ( myShape.ShapeType() != TopAbs_VERTEX && // fix pb with not displayed points + !TopoDS_Iterator(myShape).More() ) + return; // NPAL15983 (Bug when displaying empty groups) + + // set interactive object + + Handle( SALOME_InteractiveObject ) anIO; + + if ( !myIO.IsNull() ) { + AISShape->setIO( myIO ); + AISShape->SetOwner( myIO ); + anIO = myIO; + } + else if ( !myName.empty() ) { + // workaround to allow selection of temporary objects + static int tempId = 0; + anIO = new SALOME_InteractiveObject( QString( "TEMP_%1" ).arg( tempId++ ).toLatin1().data(), "GEOM", myName.c_str() ); + AISShape->setIO( anIO ); + AISShape->SetOwner( anIO ); + } + + // flag: only vertex or compound of vertices is processed (specific handling) + bool onlyVertex = myShape.ShapeType() == TopAbs_VERTEX || isCompoundOfVertices( myShape ); + // presentation study entry (empty for temporary objects like preview) + QString entry = !anIO.IsNull() ? QString( anIO->getEntry() ) : QString(); + // flag: temporary object + bool isTemporary = entry.isEmpty() || entry.startsWith( "TEMP_" ); + // currently active view window's ID (-1 if no active view) + int aMgrId = !anIO.IsNull() ? getViewManagerId( myViewFrame ) : -1; + + // get presentation properties + PropMap propMap = getObjectProperties( study, entry, myViewFrame ); + + // Temporary staff: vertex must be infinite for correct visualization + AISShape->SetInfiniteState( myShape.Infinite() ); // || myShape.ShapeType() == TopAbs_VERTEX // VSR: 05/04/2010: Fix 20668 (Fit All for points & lines) + + // set material + Material_Model material; + // if predefined color isn't set in displayer(via GEOM_Displayer::SetColor() function) + if( !HasColor() ) + material.fromProperties( propMap.value( GEOM::propertyName( GEOM::Material ) ).toString() ); + // - set front material properties + AISShape->SetCurrentFacingModel( Aspect_TOFM_FRONT_SIDE ); + AISShape->SetMaterial( material.getMaterialOCCAspect( true ) ); + // - set back material properties + AISShape->SetCurrentFacingModel( Aspect_TOFM_BACK_SIDE ); + AISShape->SetMaterial( material.getMaterialOCCAspect( false ) ); + // - switch to default (both sides) facing mode + AISShape->SetCurrentFacingModel( Aspect_TOFM_BOTH_SIDE ); + + // set colors + + // - shading color + if ( HasColor() ) { + // predefined color, manually set to displayer via GEOM_Displayer::SetColor() function; + // we set it to the shape not taking into account material properties + AISShape->SetShadingColor( (Quantity_NameOfColor)GetColor() ); + } + else if ( !material.isPhysical() ) { + // shading color from properties is used only for non-physical materials + AISShape->SetShadingColor( SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::ShadingColor ) ).value() ) ); + } + + // - wireframe color + Handle(Prs3d_LineAspect) anAspect = AISShape->Attributes()->LineAspect(); + anAspect->SetColor( HasColor() ? (Quantity_NameOfColor)GetColor() : + SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::WireframeColor ) ).value() ) ); + AISShape->Attributes()->SetLineAspect( anAspect ); + + // - unfree boundaries color + anAspect = AISShape->Attributes()->UnFreeBoundaryAspect(); + anAspect->SetColor( HasColor() ? (Quantity_NameOfColor)GetColor() : + SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::WireframeColor ) ).value() ) ); + AISShape->Attributes()->SetUnFreeBoundaryAspect( anAspect ); + + // - free boundaries color + anAspect = AISShape->Attributes()->FreeBoundaryAspect(); + anAspect->SetColor( HasColor() ? (Quantity_NameOfColor)GetColor() : + SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::FreeBndColor ) ).value() ) ); + AISShape->Attributes()->SetFreeBoundaryAspect( anAspect ); + + // - standalone edges color + anAspect = AISShape->Attributes()->WireAspect(); + anAspect->SetColor( HasColor() ? (Quantity_NameOfColor)GetColor() : + SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::LineColor ) ).value() ) ); + AISShape->Attributes()->SetWireAspect( anAspect ); + + // - color for edges in shading+edges mode + AISShape->SetEdgesInShadingColor( SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::OutlineColor ) ).value() ) ); + + // ??? + AISShape->storeBoundaryColors(); + + // set display mode + AISShape->SetDisplayMode( HasDisplayMode() ? + // predefined display mode, manually set to displayer via GEOM_Displayer::SetDisplayMode() function + GetDisplayMode() : + // display mode from properties + propMap.value( GEOM::propertyName( GEOM::DisplayMode ) ).toInt() ); + + // set display vectors flag + AISShape->SetDisplayVectors( propMap.value( GEOM::propertyName( GEOM::EdgesDirection ) ).toBool() ); + + // set transparency + // VSR: ??? next line is commented: transparency property is set in the AfterDisplay() function + //AISShape->SetTransparency( propMap.value( GEOM::propertyName( GEOM::Transparency ) ).toDouble() ); + + // set iso properties + int uIsos = propMap.value( GEOM::propertyName( GEOM::NbIsos ) ).toString().split( GEOM::subSectionSeparator() )[0].toInt(); + int vIsos = propMap.value( GEOM::propertyName( GEOM::NbIsos ) ).toString().split( GEOM::subSectionSeparator() )[1].toInt(); + Quantity_Color isosColor = SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::IsosColor ) ).value() ); + int isosWidth = propMap.value( GEOM::propertyName( GEOM::IsosWidth ) ).toInt(); + Handle(Prs3d_IsoAspect) uIsoAspect = AISShape->Attributes()->UIsoAspect(); + Handle(Prs3d_IsoAspect) vIsoAspect = AISShape->Attributes()->VIsoAspect(); + uIsoAspect->SetColor( isosColor ); + uIsoAspect->SetWidth( isosWidth ); + uIsoAspect->SetNumber( uIsos ); + vIsoAspect->SetColor( isosColor ); + vIsoAspect->SetWidth( isosWidth ); + vIsoAspect->SetNumber( vIsos ); + AISShape->Attributes()->SetUIsoAspect( uIsoAspect ); + AISShape->Attributes()->SetVIsoAspect( vIsoAspect ); + + // set deflection coefficient + // ... to avoid to small values of the coefficient, its lower value is limited + AISShape->SetOwnDeviationCoefficient( qMax( propMap.value( GEOM::propertyName( GEOM::Deflection ) ).toDouble(), GEOM::minDeflection() ) ); + + // set texture + if ( HasTexture() ) { + // predefined display texture, manually set to displayer via GEOM_Displayer::SetTexture() function + AISShape->SetTextureFileName( TCollection_AsciiString( GetTexture().c_str() ) ); + AISShape->SetTextureMapOn(); + AISShape->DisableTextureModulate(); + AISShape->SetDisplayMode( 3 ); + } + + // set line width + AISShape->SetWidth( HasWidth() ? + // predefined line width, manually set to displayer via GEOM_Displayer::SetLineWidth() function + GetWidth() : + // libe width from properties + propMap.value( GEOM::propertyName( GEOM::LineWidth ) ).toInt() ); + + // set top-level flag + AISShape->setTopLevel( propMap.value( GEOM::propertyName( GEOM::TopLevel ) ).toBool() ); + + // set point marker (for vertex / compound of vertices only) + if ( onlyVertex ) { + QStringList aList = propMap.value( GEOM::propertyName( GEOM::PointMarker ) ).toString().split( GEOM::subSectionSeparator() ); + if ( aList.size() == 2 ) { + // standard marker string contains "TypeOfMarker:ScaleOfMarker" + int aTypeOfMarker = aList[0].toInt(); + double aScaleOfMarker = (aList[1].toInt() + 1) * 0.5; + Handle(Prs3d_PointAspect) anAspect = AISShape->Attributes()->PointAspect(); + anAspect->SetScale( aScaleOfMarker ); + anAspect->SetTypeOfMarker( (Aspect_TypeOfMarker)( aTypeOfMarker-1 ) ); + anAspect->SetColor( HasColor() ? + // predefined color, manually set to displayer via GEOM_Displayer::SetColor() function + (Quantity_NameOfColor)GetColor() : + // color from properties + SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::PointColor ) ).value() ) ); + AISShape->Attributes()->SetPointAspect( anAspect ); + } + else if ( aList.size() == 1 ) { + // custom marker string contains "IdOfTexture" + int textureId = aList[0].toInt(); + Standard_Integer aWidth, aHeight; +#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 + Handle(TColStd_HArray1OfByte) aTexture = +#else + Handle(Graphic3d_HArray1OfBytes) aTexture = +#endif + GeometryGUI::getTexture( study, textureId, aWidth, aHeight ); + if ( !aTexture.IsNull() ) { + static int TextureId = 0; + Handle(Prs3d_PointAspect) aTextureAspect = + new Prs3d_PointAspect( HasColor() ? + // predefined color, manually set to displayer via GEOM_Displayer::SetColor() function + (Quantity_NameOfColor)GetColor() : + // color from properties + SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::PointColor ) ).value() ), + ++TextureId, + aWidth, aHeight, + aTexture ); + AISShape->Attributes()->SetPointAspect( aTextureAspect ); + } + } + } + + if ( create && !isTemporary && aMgrId != -1 ) { + // set properties to the study + study->setObjectPropMap( aMgrId, entry, propMap ); + } + + // AISShape->SetName(???); ??? necessary to set name ??? +} + +void GEOM_Displayer::updateActorProperties( GEOM_Actor* actor, bool create ) +{ + // check that actor is not null + if ( !actor ) return; + + // check that study is active + SalomeApp_Study* study = getStudy(); + if ( !study ) return; + + // set interactive object + + Handle( SALOME_InteractiveObject ) anIO; + + if ( !myIO.IsNull() ) { + actor->setIO( myIO ); + anIO = myIO; + } + else if ( !myName.empty() ) { + // workaround to allow selection of temporary objects + static int tempId = 0; + anIO = new SALOME_InteractiveObject( QString( "TEMP_VTK_%1" ).arg( tempId++ ).toLatin1().data(), "GEOM", myName.c_str() ); + actor->setIO( anIO ); + } + + // presentation study entry (empty for temporary objects like preview) + QString entry = !anIO.IsNull() ? QString( anIO->getEntry() ) : QString(); + // flag: temporary object + bool isTemporary = entry.isEmpty() || entry.startsWith( "TEMP_" ); + // currently active view window's ID (-1 if no active view) + int aMgrId = !anIO.IsNull() ? getViewManagerId( myViewFrame ) : -1; + + // get presentation properties + PropMap propMap = getObjectProperties( study, entry, myViewFrame ); + QColor c; + + ///////////////////////////////////////////////////////////////////////// + // VSR: for VTK viewer currently deflection coefficient is hardcoded + // due to performance problem + // actor->SetShape(myShape,aDefPropMap.value(GEOM::propertyName( GEOM::Deflection )).toDouble(),myType == GEOM_VECTOR); + ///////////////////////////////////////////////////////////////////////// + if ( !actor->getTopo().IsSame( myShape ) ) + actor->SetShape( myShape, VTK_MIN_DEFLECTION, myType == GEOM_VECTOR ); + + // set material + Material_Model material; + material.fromProperties( propMap.value( GEOM::propertyName( GEOM::Material ) ).toString() ); + std::vector mprops; + mprops.push_back( material.getMaterialVTKProperty( true ) ); + mprops.push_back( material.getMaterialVTKProperty( false) ); + actor->SetMaterial( mprops ); + + // set iso-lines properties + + // - set number of iso-lines + int nbIsos[2]= { 1, 1 }; + QStringList isos = propMap.value( GEOM::propertyName( GEOM::NbIsos ) ).toString().split( GEOM::subSectionSeparator() ); + nbIsos[0] = isos[0].toInt(); + nbIsos[1] = isos[1].toInt(); + actor->SetNbIsos( nbIsos ); + + // - set iso-lines width + actor->SetIsosWidth( propMap.value( GEOM::propertyName( GEOM::IsosWidth ) ).toInt() ); + + // - set iso-lines color + c = propMap.value( GEOM::propertyName( GEOM::IsosColor ) ).value(); + actor->SetIsosColor( c.redF(), c.greenF(), c.blueF() ); + + // set colors + + if ( HasColor() ) { + // - same color for all sub-actors + Quantity_Color aColor( (Quantity_NameOfColor)GetColor() ); + actor->SetColor( aColor.Red(), aColor.Green(), aColor.Blue() ); + } + else { + // shading color (for non-physical materials) + if ( !material.isPhysical() ) { + c = propMap.value( GEOM::propertyName( GEOM::ShadingColor ) ).value(); + actor->GetFrontMaterial()->SetColor( c.redF(), c.greenF(), c.blueF() ); + actor->GetBackMaterial()->SetColor( c.redF(), c.greenF(), c.blueF() ); + } + + // - standalone edge color + c = propMap.value( GEOM::propertyName( GEOM::WireframeColor ) ).value(); + actor->SetIsolatedEdgeColor( c.redF(), c.greenF(), c.blueF() ); + + c = propMap.value( GEOM::propertyName( GEOM::WireframeColor ) ).value(); + // - shared edges color ??? + actor->SetSharedEdgeColor( c.redF(), c.greenF(), c.blueF() ); + + c = propMap.value( GEOM::propertyName( GEOM::FreeBndColor ) ).value(); + // - free edges color ??? + actor->SetFreeEdgeColor( c.redF(), c.greenF(), c.blueF() ); + + // - point color + c = propMap.value( GEOM::propertyName( GEOM::PointColor ) ).value(); + actor->SetPointColor( c.redF(), c.greenF(), c.blueF() ); + } + + // - color for edges in shading+edges mode + c = propMap.value( GEOM::propertyName( GEOM::OutlineColor ) ).value(); + actor->SetEdgesInShadingColor( c.redF(), c.greenF(), c.blueF() ); + + // set opacity + actor->SetOpacity( 1.0 - propMap.value( GEOM::propertyName( GEOM::Transparency ) ).toDouble() ); + + // set line width + actor->SetWidth( HasWidth() ? + // predefined line width, manually set to displayer via GEOM_Displayer::SetLineWidth() function + GetWidth() : + // libe width from properties + propMap.value( GEOM::propertyName( GEOM::LineWidth ) ).toInt() ); + + // set display vectors flag + actor->SetVectorMode( propMap.value( GEOM::propertyName( GEOM::EdgesDirection ) ).toBool() ); + + // set display mode + int displayMode = HasDisplayMode() ? + // predefined display mode, manually set to displayer via GEOM_Displayer::SetDisplayMode() function + GetDisplayMode() : + // display mode from properties + propMap.value( GEOM::propertyName( GEOM::DisplayMode ) ).toInt(); + + // specific processing of 'shading with edges' mode, as VTK provides only the following standard display modes: + // Points - 0, Wireframe - 1, Surface - 2, Insideframe - 3, SurfaceWithEdges - 4 + // GEOM actor allows alternative display modes (see VTKViewer::Representation enum) and enum in GEOM_Actor: + // eWireframe - 0, eShading - 1, eShadingWithEdges - 3 + + if ( displayMode == 2 ) + // this is 'Shading with edges' mode => we have to do the correct mapping to EDisplayMode + // enum in GEOM_Actor (and further to VTKViewer::Representation enum) + displayMode++; + actor->setDisplayMode( displayMode ); + + if ( myToActivate ) + actor->PickableOn(); + else + actor->PickableOff(); + + if ( create && !isTemporary && aMgrId != -1 ) { + // set properties to the study + study->setObjectPropMap( aMgrId, entry, propMap ); + } +} + //================================================================= /*! * GEOM_Displayer::Erase @@ -576,11 +945,17 @@ void GEOM_Displayer::Redisplay( const SALOME_ListIO& theIOList, const bool updat void GEOM_Displayer::Update( SALOME_OCCPrs* prs ) { SOCC_Prs* occPrs = dynamic_cast( prs ); - if ( !occPrs ) + SalomeApp_Study* study = getStudy(); + + if ( !occPrs || myShape.IsNull() || !study ) return; - if ( myType == GEOM_MARKER && !myShape.IsNull() && myShape.ShapeType() == TopAbs_FACE ) + if ( myType == GEOM_MARKER && myShape.ShapeType() == TopAbs_FACE ) { + // + // specific processing for local coordinate system presentation + // + TopoDS_Face aFace = TopoDS::Face( myShape ); Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast( BRep_Tool::Surface( aFace ) ); if ( !aPlane.IsNull() ) @@ -592,450 +967,99 @@ void GEOM_Displayer::Update( SALOME_OCCPrs* prs ) if ( occPrs->IsNull() ) { + // new presentation is being created 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 { + // presentation is being updated AIS_ListOfInteractive aList; occPrs->GetObjects( aList ); AIS_ListIteratorOfListOfInteractive anIter( aList ); - for ( ; anIter.More(); anIter.Next() ) - { + for ( ; anIter.More() && aTrh.IsNull(); anIter.Next() ) { aTrh = Handle(GEOM_AISTrihedron)::DownCast( anIter.Value() ); - if ( !aTrh.IsNull() ) - { - aTrh->SetComponent( aPlc ); - aTrh->SetToUpdate(); - } + } + } + + if ( !aTrh.IsNull() ) { + // predefined color, manually set to displayer via GEOM_Displayer::SetColor() function + if ( HasColor() ) + aTrh->SetColor( (Quantity_NameOfColor)GetColor() ); + // predefined line width, manually set to displayer via GEOM_Displayer::SetLineWidth() function + if ( HasWidth() ) + aTrh->SetWidth( GetWidth() ); + + if ( !myIO.IsNull() ) + { + aTrh->setIO( myIO ); + aTrh->SetOwner( myIO ); } + aTrh->SetComponent( aPlc ); + aTrh->SetToUpdate(); } - occPrs->SetToActivate( ToActivate() ); } } else { + // + // processing for usual geometry presentation + // + // if presentation is empty we try to create new one if ( occPrs->IsNull() ) { - SalomeApp_Study* aStudy = getStudy(); - if(!aStudy) - return; - if ( !myShape.IsNull() ) { - - bool onlyVertex = (myShape.ShapeType() == TopAbs_VERTEX || isCompoundOfVertices( myShape )); - - QString anEntry; - int aMgrId = -1; - if(!myIO.IsNull()) { - aMgrId = getViewManagerId(myViewFrame); - anEntry = myIO->getEntry(); - } - bool useStudy = !anEntry.isEmpty() && aMgrId != -1; - bool useObjColor = false; - bool useObjMarker = false; - - PropMap aPropMap; - PropMap aDefPropMap; - - //Handle(GEOM_AISShape) AISShape = new GEOM_AISShape( myShape, "" ); - Handle(GEOM_AISShape) AISShape; - if (myType == GEOM_VECTOR) - AISShape = new GEOM_AISVector (myShape, ""); - else { - if (myShape.ShapeType() != TopAbs_VERTEX && // fix pb with not displayed points - !TopoDS_Iterator(myShape).More()) - return;// NPAL15983 (Bug when displaying empty groups) - AISShape = new GEOM_AISShape (myShape, ""); - } - // Temporary staff: vertex must be infinite for correct visualization - AISShape->SetInfiniteState( myShape.Infinite() ); // || myShape.ShapeType() == TopAbs_VERTEX // VSR: 05/04/2010: Fix 20668 (Fit All for points & lines) - - if(useStudy){ - aPropMap = aStudy->getObjectPropMap(aMgrId,anEntry); - aDefPropMap = getDefaultPropertyMap(SOCC_Viewer::Type()); - Quantity_Color quant_col; - if(aPropMap.contains(COLOR_PROP)) { - quant_col = SalomeApp_Tools::color( aPropMap.value(COLOR_PROP).value()); - AISShape->SetShadingColor( quant_col ); - } else - useObjColor = true; - MergePropertyMaps(aPropMap, aDefPropMap); - if(!useObjColor && aPropMap.contains(COLOR_PROP)) { - quant_col = SalomeApp_Tools::color( aPropMap.value(COLOR_PROP).value()); - AISShape->SetShadingColor( quant_col ); - } - - // Setup shape properties here ..., e.g. display mode, color, transparency, etc - Standard_Boolean isTopLevel = Standard_False; - if(aPropMap.contains(TOP_LEVEL_PROP)) { - isTopLevel = aPropMap.value(TOP_LEVEL_PROP).value(); - } - AISShape->SetDisplayMode( aPropMap.value(DISPLAY_MODE_PROP).toInt() ); - AISShape->setTopLevel(isTopLevel); - - AISShape->SetDisplayVectors(aPropMap.value(VECTOR_MODE_PROP).toInt()); - }else { - AISShape->SetDisplayMode( myDisplayMode ); - AISShape->SetShadingColor( myShadingColor ); - } - - // Set color and number for iso lines - SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); - QColor col = aResMgr->colorValue( "Geometry", "isos_color", - QColor(int(0.5*255), int(0.5*255), int(0.5*255)) ); - Quantity_Color aColor = SalomeApp_Tools::color( col ); - - //get the ISOS number, set transparency if need - int anUIsoNumber, aVIsoNumber; - if(useStudy) { - QString anIsos = aPropMap.value(ISOS_PROP).toString(); - QStringList uv = anIsos.split(DIGIT_SEPARATOR); - anUIsoNumber = uv[0].toInt(); - aVIsoNumber = uv[1].toInt(); - AISShape->SetTransparency(aPropMap.value(TRANSPARENCY_PROP).toDouble()); - } else { - anUIsoNumber = aResMgr->integerValue("OCCViewer", "iso_number_u", 1); - aVIsoNumber = aResMgr->integerValue("OCCViewer", "iso_number_v", 1); - } - - Handle(Prs3d_IsoAspect) anAspect = AISShape->Attributes()->UIsoAspect(); - anAspect->SetNumber( anUIsoNumber ); - anAspect->SetColor( aColor ); - - if(HasIsosWidth()) - anAspect->SetWidth( GetIsosWidth() ); - AISShape->Attributes()->SetUIsoAspect( anAspect ); - anAspect = AISShape->Attributes()->VIsoAspect(); - anAspect->SetNumber( aVIsoNumber ); - if(HasIsosWidth()) - anAspect->SetWidth( GetIsosWidth() ); - anAspect->SetColor( aColor ); - AISShape->Attributes()->SetVIsoAspect( anAspect ); - - if ( HasColor() ) - { - AISShape->SetColor( (Quantity_NameOfColor)GetColor() ); - if ( onlyVertex ) - { - if(aPropMap.contains(MARKER_TYPE_PROP)) { - QStringList aList = aPropMap.value(MARKER_TYPE_PROP).toString().split(DIGIT_SEPARATOR); - if(aList.size() == 2) { //Standard marker string contains "TypeOfMarker:ScaleOfMarker" - Handle(Prs3d_PointAspect) anAspect = AISShape->Attributes()->PointAspect(); - int aTypeOfMarker = aList[0].toInt(); - double aScaleOfMarker = aList[1].toDouble(); - anAspect->SetScale( aScaleOfMarker ); - anAspect->SetTypeOfMarker((Aspect_TypeOfMarker) (aTypeOfMarker-1)); - anAspect->SetColor((Quantity_NameOfColor)GetColor()); - AISShape->Attributes()->SetPointAspect(anAspect); - } else { //Custom marker string contains "IdOfTexsture" - int textureId = aList[0].toInt(); - Standard_Integer aWidth, aHeight; -#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 - Handle(TColStd_HArray1OfByte) aTexture = -#else - Handle(Graphic3d_HArray1OfBytes) aTexture = -#endif - GeometryGUI::getTexture(aStudy, textureId, aWidth, aHeight); - if (!aTexture.IsNull()) { - static int TextureId = 0; - Handle(Prs3d_PointAspect) aTextureAspect = - new Prs3d_PointAspect ((Quantity_NameOfColor)GetColor(), - ++TextureId, - aWidth, aHeight, - aTexture); - AISShape->Attributes()->SetPointAspect(aTextureAspect); - } else { - useObjMarker = true; - } - } - } else { - useObjMarker = true; - } - } - } - else - { - if ( onlyVertex ) - { - col = aResMgr->colorValue( "Geometry", "point_color", QColor( 255, 255, 0 ) ); - aColor = SalomeApp_Tools::color( col ); - - if(aPropMap.contains(MARKER_TYPE_PROP)) { - QStringList aList = aPropMap.value(MARKER_TYPE_PROP).toString().split(DIGIT_SEPARATOR); - if(aList.size() == 2) { //Standard marker string contains "TypeOfMarker:ScaleOfMarker" - int aTypeOfMarker = aList[0].toInt(); - double aScaleOfMarker = aList[1].toDouble(); - Handle(Prs3d_PointAspect) anAspect = AISShape->Attributes()->PointAspect(); - anAspect->SetScale( aScaleOfMarker ); - anAspect->SetTypeOfMarker((Aspect_TypeOfMarker) (aTypeOfMarker-1) ); - anAspect->SetColor( aColor ); - AISShape->Attributes()->SetPointAspect( anAspect ); - } else { //Custom marker string contains "IdOfTexsture" - int textureId = aList[0].toInt(); - Standard_Integer aWidth, aHeight; -#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 - Handle(TColStd_HArray1OfByte) aTexture = -#else - Handle(Graphic3d_HArray1OfBytes) aTexture = -#endif - GeometryGUI::getTexture(aStudy, textureId, aWidth, aHeight); - if (!aTexture.IsNull()) { - static int TextureId = 0; - Handle(Prs3d_PointAspect) aTextureAspect = - new Prs3d_PointAspect (aColor, ++TextureId, aWidth, aHeight, aTexture); - AISShape->Attributes()->SetPointAspect( aTextureAspect ); - } else { - useObjMarker = true; - } - } - } else { - useObjMarker = true; - } - } - else { - // Set line aspect - col = aResMgr->colorValue( "Geometry", "wireframe_color", QColor( 255, 255, 0 ) ); - aColor = SalomeApp_Tools::color( col ); - - Handle(Prs3d_LineAspect) anAspect = AISShape->Attributes()->LineAspect(); - anAspect->SetColor( aColor ); - AISShape->Attributes()->SetLineAspect( anAspect ); - - // Set unfree boundaries aspect - anAspect = AISShape->Attributes()->UnFreeBoundaryAspect(); - anAspect->SetColor( aColor ); - AISShape->Attributes()->SetUnFreeBoundaryAspect( anAspect ); - AISShape->storeBoundaryColors(); - - // Set free boundaries aspect - col = aResMgr->colorValue( "Geometry", "free_bound_color", QColor( 0, 255, 0 ) ); - aColor = SalomeApp_Tools::color( col ); - - anAspect = AISShape->Attributes()->FreeBoundaryAspect(); - anAspect->SetColor( aColor ); - AISShape->Attributes()->SetFreeBoundaryAspect( anAspect ); - - // Set wire aspect - col = aResMgr->colorValue( "Geometry", "line_color", QColor( 255, 0, 0 ) ); - aColor = SalomeApp_Tools::color( col ); - - anAspect = AISShape->Attributes()->WireAspect(); - anAspect->SetColor( aColor ); - AISShape->Attributes()->SetWireAspect( anAspect ); - - // Set color for edges in shading - col = aResMgr->colorValue( "Geometry", "edges_in_shading_color", QColor( 255, 255, 0 ) ); - aColor = SalomeApp_Tools::color( col ); - AISShape->SetEdgesInShadingColor( aColor ); - - // bug [SALOME platform 0019868] - // Set deviation angle. Default one is 12 degrees (Prs3d_Drawer.cxx:18) - //AISShape->SetOwnDeviationAngle( 10*PI/180 ); - - // IMP 0020626 - double aDC = 0; - if(useStudy) { - aDC = aPropMap.value(DEFLECTION_COEFF_PROP).toDouble(); - SetWidth(aPropMap.value(EDGE_WIDTH_PROP).toInt()); - SetIsosWidth(aPropMap.value(ISOS_WIDTH_PROP).toInt()); - } - else { - aDC = aResMgr->doubleValue("Geometry", "deflection_coeff", 0.001); - } - - aDC = std::max( aDC, DEFLECTION_MIN ); // to avoid to small values of the coefficient - AISShape->SetOwnDeviationCoefficient(aDC); - } - } - - if ( HasTexture() ) - { - AISShape->SetTextureFileName(TCollection_AsciiString(myTexture.c_str())); - AISShape->SetTextureMapOn(); - AISShape->DisableTextureModulate(); - AISShape->SetDisplayMode(3); - } - - 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 ); - } + // create presentation (specific for vectors) + Handle(GEOM_AISShape) AISShape = ( myType == GEOM_VECTOR ) ? new GEOM_AISVector( myShape, "" ) + : new GEOM_AISShape ( myShape, "" ); + // update shape properties + updateShapeProperties( AISShape, true ); - Handle( SALOME_InteractiveObject ) anIO = AISShape->getIO(); - if ( !anIO.IsNull() ) { - _PTR(SObject) SO ( aStudy->studyDS()->FindObjectID( anIO->getEntry() ) ); - if ( SO ) { - // get CORBA reference to data object - CORBA::Object_var object = GeometryGUI::ClientSObjectToObject(SO); - if ( !CORBA::is_nil( object ) ) { - // downcast to GEOM object - GEOM::GEOM_Object_var aGeomObject = GEOM::GEOM_Object::_narrow( object ); - bool hasColor = false; - SALOMEDS::Color aSColor = getColor(aGeomObject,hasColor); - if( hasColor && useObjColor) { - Quantity_Color aQuanColor( aSColor.R, aSColor.G, aSColor.B, Quantity_TOC_RGB ); - AISShape->SetColor( aQuanColor ); - AISShape->SetShadingColor( aQuanColor ); - if ( onlyVertex ) { - Handle(Prs3d_PointAspect) anAspect = AISShape->Attributes()->PointAspect(); - anAspect->SetColor( aQuanColor ); - anAspect->SetScale( myScaleOfMarker ); - anAspect->SetTypeOfMarker( myTypeOfMarker ); - AISShape->Attributes()->SetPointAspect( anAspect ); - } - aStudy->setObjectProperty( aMgrId, anIO->getEntry(), COLOR_PROP, SalomeApp_Tools::color( aQuanColor ) ); - } else if( !hasColor ) { - //In case if color wasn't defined in the property map of the object - //and GEOM_Object color also wasn't defined get default color from Resource Mgr. - QColor col = aResMgr->colorValue( "Geometry", "shading_color", QColor( 255, 0, 0 ) ); - Quantity_Color aQuanColor = SalomeApp_Tools::color( col ); - AISShape->SetShadingColor( aQuanColor ); - aStudy->setObjectProperty( aMgrId, anIO->getEntry(), COLOR_PROP, col ); - } - - // ... marker type - if(useObjMarker) { - GEOM::marker_type aType = aGeomObject->GetMarkerType(); - GEOM::marker_size aSize = aGeomObject->GetMarkerSize(); - if ( aType > GEOM::MT_NONE && aType < GEOM::MT_USER && aSize > GEOM::MS_NONE && aSize <= GEOM::MS_70 ) { - Aspect_TypeOfMarker aMType = (Aspect_TypeOfMarker)( (int)aType-1 ); - double aMSize = ((int)aSize+1)*0.5; - Handle(Prs3d_PointAspect) anAspect = AISShape->Attributes()->PointAspect(); - anAspect->SetScale( aMSize ); - anAspect->SetTypeOfMarker( aMType ); - Quantity_Color aQuanColor = SalomeApp_Tools::color( aResMgr->colorValue( "Geometry", "point_color", QColor( 255, 255, 0 ) ) ); - if ( hasColor ) - aQuanColor = Quantity_Color( aSColor.R, aSColor.G, aSColor.B, Quantity_TOC_RGB ); - anAspect->SetColor( aQuanColor ); - AISShape->Attributes()->SetPointAspect( anAspect ); - } - else if ( aType == GEOM::MT_USER ) { - int aTextureId = aGeomObject->GetMarkerTexture(); - Quantity_Color aQuanColor = SalomeApp_Tools::color( aResMgr->colorValue( "Geometry", "point_color", QColor( 255, 255, 0 ) ) ); - if ( hasColor ) aQuanColor = Quantity_Color( aSColor.R, aSColor.G, aSColor.B, Quantity_TOC_RGB ); - Standard_Integer aWidth, aHeight; -#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 - Handle(TColStd_HArray1OfByte) aTexture = -#else - Handle(Graphic3d_HArray1OfBytes) aTexture = -#endif - GeometryGUI::getTexture(getStudy(), aTextureId, aWidth, aHeight); - if (!aTexture.IsNull()) { - static int TextureId = 0; - Handle(Prs3d_PointAspect) aTextureAspect = - new Prs3d_PointAspect(aQuanColor, ++TextureId, aWidth, aHeight, aTexture ); - AISShape->Attributes()->SetPointAspect( aTextureAspect ); - } - } else { //Use marker from the preferences - Handle(Prs3d_PointAspect) anAspect = AISShape->Attributes()->PointAspect(); - anAspect->SetScale( myScaleOfMarker ); - anAspect->SetTypeOfMarker( myTypeOfMarker ); - Quantity_Color aQuanColor = SalomeApp_Tools::color( aResMgr->colorValue( "Geometry", "point_color", QColor( 255, 255, 0 ) ) ); - if ( hasColor ) - aQuanColor = Quantity_Color( aSColor.R, aSColor.G, aSColor.B, Quantity_TOC_RGB ); - anAspect->SetColor( aQuanColor ); - AISShape->Attributes()->SetPointAspect( anAspect ); - } - } - } - } + // add shape to the presentation + occPrs->AddObject( AISShape ); - // get material properties, set material - Material_Model material; - if ( useStudy ) { - // Get material property from study and construct material model - material.fromProperties( aPropMap.value(MATERIAL_PROP).toString() ); - } else { - // Get material property from study and construct material model - QString mname = aResMgr->stringValue( "Geometry", "material", "Plastic" ); - material.fromResources( mname ); - } + // In accordance with ToActivate() value object will be activated/deactivated + // when it will be displayed + occPrs->SetToActivate( ToActivate() ); - aStudy->setObjectProperty( aMgrId, anIO->getEntry(), MATERIAL_PROP, material.toProperties() ); + if ( AISShape->isTopLevel() && GEOM_AISShape::topLevelDisplayMode() == GEOM_AISShape::TopShowAdditionalWActor ) { + // 21671: EDF 1829 GEOM : Bring to front selected objects (continuation): - // Set material for the selected shape - AISShape->SetMaterial( material.getMaterialOCCAspect() ); - if(HasWidth()) - aStudy->setObjectProperty( aMgrId, anIO->getEntry(), EDGE_WIDTH_PROP, GetWidth() ); - if(HasIsosWidth()) - aStudy->setObjectProperty( aMgrId, anIO->getEntry(), ISOS_WIDTH_PROP, GetIsosWidth() ); - } + // create additional wireframe shape + Handle(GEOM_TopWireframeShape) aWirePrs = new GEOM_TopWireframeShape(myShape); + aWirePrs->SetWidth(AISShape->Width()); + if ( !myIO.IsNull() ) { + aWirePrs->setIO( myIO ); + aWirePrs->SetOwner( myIO ); + } - // 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( AISShape->isTopLevel() && AISShape->topLevelDisplayMode() == GEOM_AISShape::TopShowAdditionalWActor) { - //21671: EDF 1829 GEOM : Bring to front selected objects (continuation): - // Display wireframe presentation additionally - Handle(GEOM_TopWireframeShape) aWirePrs = new GEOM_TopWireframeShape(myShape); - aWirePrs->SetWidth(AISShape->Width()); - if ( !myIO.IsNull() ) { - aWirePrs->setIO( myIO ); - aWirePrs->SetOwner( myIO ); - } - occPrs->AddObject(aWirePrs); - } + // add shape to the presentation + occPrs->AddObject( aWirePrs ); } } // 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() ) { - 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 ); - } - } + Handle(GEOM_AISShape) AISShape = Handle(GEOM_AISShape)::DownCast( Iter.Value() ); + if ( AISShape.IsNull() ) + continue; + + // re-set shape (it might be changed) + if ( AISShape->Shape() != myShape ) + AISShape->Set( myShape ); + + // update shape properties + updateShapeProperties( AISShape, false ); + + // force updating + AISShape->UpdateSelection(); + AISShape->SetToUpdate(); } } } @@ -1050,224 +1074,99 @@ void GEOM_Displayer::Update( SALOME_OCCPrs* prs ) //================================================================= void GEOM_Displayer::Update( SALOME_VTKPrs* prs ) { - SalomeApp_Study* aStudy = getStudy(); - int aMgrId = -1; SVTK_Prs* vtkPrs = dynamic_cast( prs ); + SalomeApp_Study* study = getStudy(); - if ( !vtkPrs || myShape.IsNull() || !aStudy) + if ( !vtkPrs || myShape.IsNull() || !study ) return; - bool useStudy = false; - bool useObjCol = false; - PropMap aPropMap; - - vtkActorCollection* theActors = 0; - - QString anEntry; - if(!myIO.IsNull()) { - anEntry = myIO->getEntry(); - } - - if ( myType == GEOM_MARKER && myShape.ShapeType() == TopAbs_FACE ) { - //myToActivate = false; // ouv: commented to make the trihedron pickable (see IPAL18657) - 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 ( SVTK_Viewer* vf = dynamic_cast( GetActiveView() ) ) - // aTrh->SetSize( 0.5 * vf->GetTrihedronSize() ); - - vtkPrs->AddObject( aTrh ); + if ( myType == GEOM_MARKER && myShape.ShapeType() == TopAbs_FACE ) + { + // + // specific processing for local coordinate system presentation + // - theActors = vtkActorCollection::New(); - theActors->AddItem( aTrh ); - } - else { - PropMap aDefPropMap = getDefaultPropertyMap(SVTK_Viewer::Type()); + 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() ); - if(!myIO.IsNull()) { - aMgrId = getViewManagerId(myViewFrame); - } - useStudy = !anEntry.isEmpty() && aMgrId != -1; + GEOM_VTKTrihedron* aTrh = 0; + if ( vtkPrs->IsNull() ) { + // new presentation is being created + aTrh = GEOM_VTKTrihedron::New(); + vtkPrs->AddObject( aTrh ); + } + else { + // presentation is being updated + vtkActorCollection* actors = vtkPrs->GetObjects(); + if ( actors ) { + actors->InitTraversal(); + vtkActor* a = actors->GetNextActor(); + while ( a && !aTrh ) { + aTrh = GEOM_VTKTrihedron::SafeDownCast( a ); + a = actors->GetNextActor(); + } + } + } + + if ( aTrh ) { + // predefined color, manually set to displayer via GEOM_Displayer::SetColor() function + if ( HasColor() ) { + Quantity_Color aColor( (Quantity_NameOfColor)GetColor() ); + aTrh->SetColor( aColor.Red(), aColor.Green(), aColor.Blue() ); + } +#ifdef VTK_TRIHEDRON_WIDTH + // + // VSR: currently isn't supported + // + // predefined line width, manually set to displayer via GEOM_Displayer::SetLineWidth() function + if ( HasWidth() ) + aTrh->SetWidth( GetWidth() ); +#endif - theActors = vtkActorCollection::New(); - GEOM_Actor* aGeomActor = GEOM_Actor::New(); - aGeomActor->SetShape(myShape,aDefPropMap.value(DEFLECTION_COEFF_PROP).toDouble(),myType == GEOM_VECTOR); - theActors->AddItem(aGeomActor); - aGeomActor->Delete(); + if ( !myIO.IsNull() ) + aTrh->setIO( myIO ); - if(useStudy) { - aPropMap = aStudy->getObjectPropMap(aMgrId,anEntry); - if(!aPropMap.contains(COLOR_PROP)) - useObjCol = true; - MergePropertyMaps(aPropMap, aDefPropMap); + aTrh->SetPlacement( aPlc ); + } } } - - 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() ); - } - - while ( anActor != NULL ) + else { - SALOME_Actor* GActor = SALOME_Actor::SafeDownCast( anActor ); - - GActor->setIO( myIO ); + // + // processing for usual geometry presentation + // - if ( aProp ) + // if presentation is empty we try to create new one + if ( vtkPrs->IsNull() ) { - GActor->SetProperty( aProp ); - GActor->SetPreviewProperty( aProp ); + // create an actor + GEOM_Actor* actor = GEOM_Actor::New(); + // update actor properties + updateActorProperties( actor, true ); + // add actor to the presentation + vtkPrs->AddObject( actor ); } - - GEOM_Actor* aGeomGActor = GEOM_Actor::SafeDownCast( anActor ); - if ( aGeomGActor != 0 ) - { - if ( aProp ) { - aGeomGActor->SetShadingProperty( aProp ); - aGeomGActor->SetWireframeProperty( aProp ); - } - - // Set color for edges in shading - SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); - if(aResMgr) { - QColor c = aResMgr->colorValue( "Geometry", "edges_in_shading_color", QColor( 255, 255, 0 ) ); - aGeomGActor->SetEdgesInShadingColor( c.red()/255., c.green()/255., c.blue()/255. ); - } - - int aIsos[2]= { 1, 1 }; - if(useStudy) { - QString anIsos = aPropMap.value(ISOS_PROP).toString(); - QStringList uv = anIsos.split(DIGIT_SEPARATOR); - aIsos[0] = uv[0].toInt(); aIsos[1] = uv[1].toInt(); - aGeomGActor->SetNbIsos(aIsos); - aGeomGActor->SetOpacity(1.0 - aPropMap.value(TRANSPARENCY_PROP).toDouble()); - SetWidth(aPropMap.value(EDGE_WIDTH_PROP).toInt()); - SetIsosWidth(aPropMap.value(ISOS_WIDTH_PROP).toInt()); - aGeomGActor->SetVectorMode(aPropMap.value(VECTOR_MODE_PROP).toInt()); - int aDispModeId = aPropMap.value(DISPLAY_MODE_PROP).toInt(); - // Specially processing of 'Shading with edges' mode from preferences, - // because there is the following enum in VTK viewer: - // Points - 0, Wireframe - 1, Surface - 2, Insideframe - 3, SurfaceWithEdges - 4 - // (see VTKViewer::Representation enum) and the following enum in GEOM_Actor: - // eWireframe - 0, eShading - 1, eShadingWithEdges - 3 - if ( aDispModeId == 2 ) - // this is 'Shading with edges' mode => do the correct mapping to EDisplayMode - // enum in GEOM_Actor (and further to VTKViewer::Representation enum) - aDispModeId++; - aGeomGActor->setDisplayMode(aDispModeId); - aGeomGActor->SetDeflection(aPropMap.value(DEFLECTION_COEFF_PROP).toDouble()); - - // Create material model - Material_Model material; - material.fromProperties( aPropMap.value(MATERIAL_PROP).toString() ); - // Set material properties for the object - aStudy->setObjectProperty( aMgrId, anEntry, MATERIAL_PROP, material.toProperties() ); - // Set the same front and back materials for the selected shape - std::vector aProps; - aProps.push_back( material.getMaterialVTKProperty() ); - aGeomGActor->SetMaterial(aProps); - - vtkFloatingPointType aColor[3] = {1.,0.,0.}; - if ( useObjCol ) { //Get Color from geom object - Handle( SALOME_InteractiveObject ) anIO = aGeomGActor->getIO(); - if ( !anIO.IsNull() ) { - _PTR(SObject) SO ( aStudy->studyDS()->FindObjectID( anIO->getEntry() ) ); - if ( SO ) { - // get CORBA reference to data object - CORBA::Object_var object = GeometryGUI::ClientSObjectToObject(SO); - if ( !CORBA::is_nil( object ) ) { - // downcast to GEOM object - GEOM::GEOM_Object_var aGeomObject = GEOM::GEOM_Object::_narrow( object ); - bool hasColor = false; - SALOMEDS::Color aSColor = getColor(aGeomObject,hasColor); - if(hasColor) { - aColor[0] = aSColor.R; aColor[1] = aSColor.G; aColor[2] = aSColor.B; - } else { - SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); - if(aResMgr) { - QColor c = aResMgr->colorValue( "Geometry", "shading_color", QColor( 255, 0, 0 ) ); - aColor[0] = c.red()/255.; aColor[1] = c.green()/255.; aColor[2] = c.blue()/255.; - } - } - aStudy->setObjectProperty( aMgrId, anIO->getEntry(), COLOR_PROP, QColor( aColor[0] *255, aColor[1] * 255, aColor[2]* 255) ); - } - } - } - } else { - QColor c = aPropMap.value(COLOR_PROP).value(); - aColor[0] = c.red()/255.; aColor[1] = c.green()/255.; aColor[2] = c.blue()/255.; - } - - if ( !material.isPhysical() ) - aGeomGActor->SetColor(aColor[0],aColor[1],aColor[2]); - } - else { - SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); - if ( aResMgr ) { - // Create material model - Material_Model material; - // Get material name from resources - QString mname = aResMgr->stringValue( "Geometry", "material", "Plastic" ); - material.fromResources( mname ); - // Set material properties for the object - aStudy->setObjectProperty( aMgrId, anEntry, MATERIAL_PROP, material.toProperties() ); - // Set material for the selected shape - std::vector aProps; - aProps.push_back( material.getMaterialVTKProperty() ); - aGeomGActor->SetMaterial(aProps); - } + else { + // presentation is being updated + vtkActorCollection* actors = vtkPrs->GetObjects(); + if ( actors ) { + actors->InitTraversal(); + vtkActor* a = actors->GetNextActor(); + while ( a ) { + GEOM_Actor* actor = GEOM_Actor::SafeDownCast( a ); + if ( actor ) { + // update actor properties + updateActorProperties( actor, false ); + a = actors->GetNextActor(); + } + } } } - if ( aGeomGActor ) - { - if ( HasWidth() ) - aGeomGActor->SetWidth( GetWidth() ); - - if ( HasIsosWidth() ) - aGeomGActor->SetIsosWidth( GetIsosWidth() ); - } - - if ( myToActivate ) - GActor->PickableOn(); - else - GActor->PickableOff(); - - vtkPrs->AddObject( GActor ); - - anActor = (vtkActor*)theActors->GetNextActor(); } - - if ( aProp ) - aProp->Delete(); - - theActors->Delete(); } //================================================================= @@ -1625,8 +1524,8 @@ void GEOM_Displayer::AfterDisplay( SALOME_View* v, const SALOME_OCCPrs* p ) Handle(SALOME_InteractiveObject) IO = sh->getIO(); if ( IO.IsNull() ) continue; PropMap aPropMap = aStudy->getObjectPropMap( aMgrId, IO->getEntry() ); - if ( aPropMap.contains( TRANSPARENCY_PROP ) ) { - double transparency = aPropMap.value(TRANSPARENCY_PROP).toDouble(); + if ( aPropMap.contains( GEOM::propertyName( GEOM::Transparency ) ) ) { + double transparency = aPropMap.value(GEOM::propertyName( GEOM::Transparency )).toDouble(); ic->SetTransparency( sh, transparency, true ); } } @@ -1728,7 +1627,7 @@ int GEOM_Displayer::GetIsosWidth() const return myIsosWidth; } -void GEOM_Displayer::SetIsosWidth(const int width) +void GEOM_Displayer::SetIsosWidth(const int width) { myIsosWidth = width; } @@ -1807,12 +1706,12 @@ bool GEOM_Displayer::canBeDisplayed( const QString& entry, const QString& viewer int GEOM_Displayer::SetDisplayMode( const int theMode ) { int aPrevMode = myDisplayMode; - if ( theMode != -1 ) + if ( theMode != -1 ) { myDisplayMode = theMode; - else - { - SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); - myDisplayMode = resMgr->integerValue( "Geometry", "display_mode", 0 ); + myHasDisplayMode = true; + } + else { + UnsetDisplayMode(); } return aPrevMode; } @@ -1827,9 +1726,15 @@ int GEOM_Displayer::UnsetDisplayMode() int aPrevMode = myDisplayMode; SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); myDisplayMode = resMgr->integerValue( "Geometry", "display_mode", 0 ); + myHasDisplayMode = false; return aPrevMode; } +bool GEOM_Displayer::HasDisplayMode() const +{ + return myHasDisplayMode; +} + SALOMEDS::Color GEOM_Displayer::getPredefinedUniqueColor() { static QList colors; @@ -1918,122 +1823,171 @@ SALOMEDS::Color GEOM_Displayer::getUniqueColor( const QList& th return aSColor; } +PropMap GEOM_Displayer::getObjectProperties( SalomeApp_Study* study, + const QString& entry, + SALOME_View* view ) +{ + // get default properties for the explicitly specified default view type + PropMap propMap = GEOM_Displayer::getDefaultPropertyMap(); + if ( study && view ) { + SUIT_ViewModel* viewModel = dynamic_cast( view ); + SUIT_ViewManager* viewMgr = ( viewModel != 0 ) ? viewModel->getViewManager() : 0; + int viewId = ( viewMgr != 0 ) ? viewMgr->getGlobalId() : -1; + + if ( viewModel && viewId != -1 ) { + // get properties from the study + PropMap storedMap = study->getObjectPropMap( viewId, entry ); + // overwrite default properties from stored ones (that are specified) + for ( int prop = GEOM::Visibility; prop <= GEOM::LastProperty; prop++ ) { + if ( storedMap.contains( GEOM::propertyName( (GEOM::Property)prop ) ) ) + propMap.insert( GEOM::propertyName( (GEOM::Property)prop ), + storedMap.value( GEOM::propertyName( (GEOM::Property)prop ) ) ); + } + // ... specific processing for color + // ... current implementation is to use same stored color for all aspects + // ... (TODO) possible future improvements about free boundaries, standalone edges etc colors can be here + if ( storedMap.contains( GEOM::propertyName( GEOM::Color ) ) ) { + propMap.insert( GEOM::propertyName( GEOM::ShadingColor ), storedMap.value( GEOM::propertyName( GEOM::Color ) ) ); + propMap.insert( GEOM::propertyName( GEOM::WireframeColor ), storedMap.value( GEOM::propertyName( GEOM::Color ) ) ); + propMap.insert( GEOM::propertyName( GEOM::LineColor ), storedMap.value( GEOM::propertyName( GEOM::Color ) ) ); + propMap.insert( GEOM::propertyName( GEOM::FreeBndColor ), storedMap.value( GEOM::propertyName( GEOM::Color ) ) ); + propMap.insert( GEOM::propertyName( GEOM::PointColor ), storedMap.value( GEOM::propertyName( GEOM::Color ) ) ); + } -PropMap GEOM_Displayer::getDefaultPropertyMap(const QString& viewer_type) { - PropMap aDefaultMap; - SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); - //1. Visibility - aDefaultMap.insert(VISIBILITY_PROP , 1); - - //2. Nb Isos - int anUIsoNumber; - int aVIsoNumber; - if(viewer_type == SOCC_Viewer::Type()) { - anUIsoNumber = aResMgr->integerValue("OCCViewer", "iso_number_u", 1); - aVIsoNumber = aResMgr->integerValue("OCCViewer", "iso_number_v", 1); - } else if( viewer_type==SVTK_Viewer::Type()) { - anUIsoNumber = aResMgr->integerValue("VTKViewer", "iso_number_u", 1); - aVIsoNumber = aResMgr->integerValue("VTKViewer", "iso_number_u", 1); + if ( !entry.isEmpty() ) { + // get CORBA reference to geom object + _PTR(SObject) SO( study->studyDS()->FindObjectID( entry.toStdString() ) ); + if ( SO ) { + CORBA::Object_var object = GeometryGUI::ClientSObjectToObject( SO ); + if ( !CORBA::is_nil( object ) ) { + GEOM::GEOM_Object_var geomObject = GEOM::GEOM_Object::_narrow( object ); + // check that geom object has color properly set + bool hasColor = false; + SALOMEDS::Color aSColor = getColor( geomObject, hasColor ); + // set color from geometry object (only once, if it is not yet set in GUI) + // current implementation is to use same color for all aspects + // (TODO) possible future improvements about free boundaries, standalone edges etc colors can be here + if ( hasColor && !storedMap.contains( GEOM::propertyName( GEOM::Color ) ) ) { + QColor objColor = QColor::fromRgbF( aSColor.R, aSColor.G, aSColor.B ); + propMap.insert( GEOM::propertyName( GEOM::ShadingColor ), objColor ); + propMap.insert( GEOM::propertyName( GEOM::WireframeColor ), objColor ); + propMap.insert( GEOM::propertyName( GEOM::LineColor ), objColor ); + propMap.insert( GEOM::propertyName( GEOM::FreeBndColor ), objColor ); + propMap.insert( GEOM::propertyName( GEOM::PointColor ), objColor ); + } + // check that object has point marker properly set + GEOM::marker_type mType = geomObject->GetMarkerType(); + GEOM::marker_size mSize = geomObject->GetMarkerSize(); + int mTextureId = geomObject->GetMarkerTexture(); + bool hasMarker = ( mType > GEOM::MT_NONE && mType < GEOM::MT_USER && mSize > GEOM::MS_NONE && mSize <= GEOM::MS_70 ) || + ( mType == GEOM::MT_USER && mTextureId > 0 ); + // set point marker from geometry object (only once, if it is not yet set in GUI) + if ( hasMarker && !storedMap.contains( GEOM::propertyName( GEOM::PointMarker ) ) ) { + if ( mType > GEOM::MT_NONE && mType < GEOM::MT_USER ) { + // standard type + propMap.insert( GEOM::propertyName( GEOM::PointMarker ), + QString( "%1%2%3" ).arg( (int)mType ).arg( GEOM::subSectionSeparator() ).arg( (int)mSize ) ); + } + else if ( mType == GEOM::MT_USER ) { + // custom texture + propMap.insert( GEOM::propertyName( GEOM::PointMarker ), QString::number( mTextureId ) ); + } + } + } + } + } + } } - QString anIsos("%1%2%3"); - anIsos = anIsos.arg(anUIsoNumber);anIsos = anIsos.arg(DIGIT_SEPARATOR);anIsos = anIsos.arg(aVIsoNumber); - aDefaultMap.insert(ISOS_PROP , anIsos); + return propMap; +} - //3. Transparency - aDefaultMap.insert( TRANSPARENCY_PROP , 0.0 ); +PropMap GEOM_Displayer::getDefaultPropertyMap() +{ + PropMap propMap; - //4. Display Mode - aDefaultMap.insert( DISPLAY_MODE_PROP , aResMgr->integerValue("Geometry", "display_mode", 0)); + // get resource manager + SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); - //5. Vector Mode - aDefaultMap.insert( VECTOR_MODE_PROP , 0); + // fill in the properties map with default values - //6. Color - QColor col = aResMgr->colorValue( "Geometry", "shading_color", QColor( 255, 0, 0 ) ); - aDefaultMap.insert( COLOR_PROP , col); + // - visibility (false by default) + propMap.insert( GEOM::propertyName( GEOM::Visibility ), false ); - //7. Deflection Coeff - double aDC; + // - nb isos (take default value from preferences) + propMap.insert( GEOM::propertyName( GEOM::NbIsos ), + QString( "%1%2%3" ). + arg( resMgr->integerValue( "Geometry", "iso_number_u", 1 ) ). + arg( GEOM::subSectionSeparator() ). + arg( resMgr->integerValue( "Geometry", "iso_number_v", 1 ) ) ); - if(viewer_type == SOCC_Viewer::Type()) { - aDC = aResMgr->doubleValue("Geometry", "deflection_coeff", 0.001); - } else if( viewer_type==SVTK_Viewer::Type()) { - aDC = 0.001; - } + // - transparency (opacity = 1-transparency) + propMap.insert( GEOM::propertyName( GEOM::Transparency ), 0.0 ); - aDefaultMap.insert( DEFLECTION_COEFF_PROP , aDC); + // - display mode (take default value from preferences) + propMap.insert( GEOM::propertyName( GEOM::DisplayMode ), + resMgr->integerValue( "Geometry", "display_mode", 0 ) ); - //8. Material - Material_Model material; - QString mname = aResMgr->stringValue( "Geometry", "material", "Plastic" ); - material.fromResources( mname ); - aDefaultMap.insert( MATERIAL_PROP, material.toProperties() ); + // - show edges direction flag (false by default) + propMap.insert( GEOM::propertyName( GEOM::EdgesDirection ), false ); - //9. Width of the edges - aDefaultMap.insert( EDGE_WIDTH_PROP , aResMgr->integerValue("Geometry", "edge_width", 1)); + // - shading color (take default value from preferences) + propMap.insert( GEOM::propertyName( GEOM::ShadingColor ), + colorFromResources( "shading_color", QColor( 255, 255, 0 ) ) ); + // - wireframe color (take default value from preferences) + propMap.insert( GEOM::propertyName( GEOM::WireframeColor ), + colorFromResources( "wireframe_color", QColor( 255, 255, 0 ) ) ); - //10. Width of iso-lines - aDefaultMap.insert( ISOS_WIDTH_PROP , aResMgr->integerValue("Geometry", "isolines_width", 1)); + // - standalone edges color (take default value from preferences) + propMap.insert( GEOM::propertyName( GEOM::LineColor ), + colorFromResources( "line_color", QColor( 255, 0, 0 ) ) ); - if(viewer_type == SOCC_Viewer::Type()) { + // - free boundaries color (take default value from preferences) + propMap.insert( GEOM::propertyName( GEOM::FreeBndColor ), + colorFromResources( "free_bound_color", QColor( 0, 255, 0 ) ) ); - aDefaultMap.insert(TOP_LEVEL_PROP, Standard_False); - } + // - points color (take default value from preferences) + propMap.insert( GEOM::propertyName( GEOM::PointColor ), + colorFromResources( "point_color", QColor( 255, 255, 0 ) ) ); - return aDefaultMap; -} + // - isos color (take default value from preferences) + propMap.insert( GEOM::propertyName( GEOM::IsosColor ), + colorFromResources( "isos_color", QColor( 200, 200, 200 ) ) ); -bool GEOM_Displayer::MergePropertyMaps(PropMap& theOrigin, PropMap& theDefault) { - int nbInserted = 0; - if(!theOrigin.contains(VISIBILITY_PROP)) { - theOrigin.insert(VISIBILITY_PROP, 0); - nbInserted++; - } - if(!theOrigin.contains(TRANSPARENCY_PROP)) { - theOrigin.insert(TRANSPARENCY_PROP, theDefault.value(TRANSPARENCY_PROP)); - nbInserted++; - } - if(!theOrigin.contains(DISPLAY_MODE_PROP)) { - theOrigin.insert(DISPLAY_MODE_PROP, theDefault.value(DISPLAY_MODE_PROP)); - nbInserted++; - } - if(!theOrigin.contains(ISOS_PROP)) { - theOrigin.insert(ISOS_PROP, theDefault.value(ISOS_PROP)); - nbInserted++; - } - if(!theOrigin.contains(VECTOR_MODE_PROP)) { - theOrigin.insert(VECTOR_MODE_PROP, theDefault.value(VECTOR_MODE_PROP)); - nbInserted++; - } - if(!theOrigin.contains(DEFLECTION_COEFF_PROP)) { - theOrigin.insert(DEFLECTION_COEFF_PROP, theDefault.value(DEFLECTION_COEFF_PROP)); - nbInserted++; - } - if(!theOrigin.contains(MATERIAL_PROP)) { - theOrigin.insert(MATERIAL_PROP, theDefault.value(MATERIAL_PROP)); - nbInserted++; - } + // - outlines color (take default value from preferences) + propMap.insert( GEOM::propertyName( GEOM::OutlineColor ), + colorFromResources( "edges_in_shading_color", QColor( 180, 180, 180 ) ) ); - if(!theOrigin.contains(EDGE_WIDTH_PROP)) { - theOrigin.insert(EDGE_WIDTH_PROP, theDefault.value(EDGE_WIDTH_PROP)); - nbInserted++; - } + // - deflection coefficient (take default value from preferences) + propMap.insert( GEOM::propertyName( GEOM::Deflection ), + resMgr->doubleValue( "Geometry", "deflection_coeff", 0.001 ) ); - if(!theOrigin.contains(ISOS_WIDTH_PROP)) { - theOrigin.insert(ISOS_WIDTH_PROP, theDefault.value(ISOS_WIDTH_PROP)); - nbInserted++; - } + // - material (take default value from preferences) + Material_Model material; + material.fromResources( resMgr->stringValue( "Geometry", "material", "Plastic" ) ); + propMap.insert( GEOM::propertyName( GEOM::Material ), material.toProperties() ); - if(!theOrigin.contains(COLOR_PROP)) { - theOrigin.insert(COLOR_PROP, theDefault.value(COLOR_PROP)); - nbInserted++; - } + // - edge width (take default value from preferences) + propMap.insert( GEOM::propertyName( GEOM::LineWidth ), + resMgr->integerValue( "Geometry", "edge_width", 1 ) ); - return (nbInserted > 0); -} + // - isos width (take default value from preferences) + propMap.insert( GEOM::propertyName( GEOM::IsosWidth ), + resMgr->integerValue( "Geometry", "isolines_width", 1 ) ); + // - point marker (take default value from preferences) + propMap.insert( GEOM::propertyName( GEOM::PointMarker ), + QString( "%1%2%3" ). + arg( resMgr->integerValue( "Geometry", "type_of_marker", 1 ) + 1 ). + arg( GEOM::subSectionSeparator() ). + arg( resMgr->integerValue( "Geometry", "marker_scale", 1 ) ) ); + + // - top-level flag (false by default) + propMap.insert( GEOM::propertyName( GEOM::TopLevel ), false ); + + return propMap; +} SALOMEDS::Color GEOM_Displayer::getColor(GEOM::GEOM_Object_var theGeomObject, bool& hasColor) { SALOMEDS::Color aSColor; @@ -2073,7 +2027,7 @@ SALOMEDS::Color GEOM_Displayer::getColor(GEOM::GEOM_Object_var theGeomObject, bo GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aChildSObject)); if ( CORBA::is_nil( aChildObject ) ) continue; - + SALOMEDS::Color aReservedColor = aChildObject->GetColor(); if ( aReservedColor.R >= 0 && aReservedColor.G >= 0 && aReservedColor.B >= 0 ) aReservedColors.append( aReservedColor ); diff --git a/src/GEOMGUI/GEOM_Displayer.h b/src/GEOMGUI/GEOM_Displayer.h index 656612776..8cd96e5d1 100644 --- a/src/GEOMGUI/GEOM_Displayer.h +++ b/src/GEOMGUI/GEOM_Displayer.h @@ -31,6 +31,7 @@ #include +class GEOM_Actor; class SALOME_ListIO; class SALOME_View; class SALOME_Prs; @@ -63,6 +64,7 @@ class LightApp_SelectionMgr; class SalomeApp_Study; class SalomeApp_Application; class SUIT_SelectionFilter; +class Handle_GEOM_AISShape; //class SALOME_Selection; class GEOMGUI_EXPORT GEOM_Displayer : public LightApp_Displayer @@ -144,7 +146,7 @@ public: int SetDisplayMode( const int ); int GetDisplayMode() const; int UnsetDisplayMode(); - + bool HasDisplayMode() const; /* Sets name - for temporary objects only */ void SetName( const char* theName ); @@ -171,10 +173,6 @@ public: static SALOMEDS::Color getUniqueColor( const QList& ); static SALOMEDS::Color getPredefinedUniqueColor(); - static PropMap getDefaultPropertyMap(const QString& viewer_type); - - static bool MergePropertyMaps(PropMap& theOrigin, PropMap& theDefault); - /*Get color of the geom object*/ static SALOMEDS::Color getColor(GEOM::GEOM_Object_var aGeomObject, bool& hasColor); @@ -209,6 +207,14 @@ protected: SUIT_SelectionFilter* getFilter( const int theMode ); SUIT_SelectionFilter* getComplexFilter( const QList* ); + Quantity_Color qColorFromResources( const QString&, const QColor& ); + QColor colorFromResources( const QString&, const QColor& ); + void updateShapeProperties( const Handle(GEOM_AISShape)&, bool ); + void updateActorProperties( GEOM_Actor*, bool ); + + PropMap getObjectProperties( SalomeApp_Study*, const QString&, SALOME_View* = 0 ); + PropMap getDefaultPropertyMap(); + protected: Handle(SALOME_InteractiveObject) myIO; TopoDS_Shape myShape; @@ -224,11 +230,13 @@ protected: int myIsosWidth; bool myToActivate; int myDisplayMode; + bool myHasDisplayMode; Aspect_TypeOfMarker myTypeOfMarker; double myScaleOfMarker; private: SalomeApp_Application* myApp; + friend class GEOM_Swig; }; #endif // GEOM_DISPLAYER_H diff --git a/src/GEOMGUI/GEOM_images.ts b/src/GEOMGUI/GEOM_images.ts index 9cd7e615e..e375fc5d5 100644 --- a/src/GEOMGUI/GEOM_images.ts +++ b/src/GEOMGUI/GEOM_images.ts @@ -259,6 +259,10 @@ ICON_DLG_FREE_FACES free_faces.png + + ICON_DLG_FREE_BOUNDS + free_bound.png + ICON_DLG_FUSE fuse.png diff --git a/src/GEOMGUI/GEOM_msg_en.ts b/src/GEOMGUI/GEOM_msg_en.ts index ed57921e0..dfe43b573 100644 --- a/src/GEOMGUI/GEOM_msg_en.ts +++ b/src/GEOMGUI/GEOM_msg_en.ts @@ -125,6 +125,10 @@ Please, select face, shell or solid and try again GEOM_ANGLE_1 Angle + + GEOM_ANGLE_STEP + Angular step : + GEOM_ARC_ELLIPSE Arc of ellipse @@ -1070,6 +1074,14 @@ Please, select face, shell or solid and try again GEOM_MIN Min : + + GEOM_MINDIST_NAME + MinDist + + + GEOM_MINDIST_NO_SOL + No solution found + GEOM_MINDIST_OBJ Objects And Results @@ -1198,6 +1210,14 @@ Please, select face, shell or solid and try again GEOM_SOURCE_OBJECT Source vertex, edge or wire + + GEOM_SOLUTION + Solution : + + + GEOM_SOLUTION_I + Solution %1 + GEOM_TARGET_OBJECT Target face @@ -1950,6 +1970,10 @@ Please, select face, shell or solid and try again GEOM_STEP Step : + + GEOM_STEP_R + Radial step : + GEOM_STEP_TITLE Step value for GUI constructions @@ -2966,6 +2990,10 @@ Please, select face, shell or solid and try again MEN_TOOLS Tools + + MEN_MATERIALS_LIBRARY + Materials library + MEN_TORUS Torus @@ -3026,6 +3054,10 @@ Please, select face, shell or solid and try again MEN_POP_MATERIAL_PROPERTIES Material Properties + + MEN_POP_PREDEF_MATER_CUSTOM + Custom... + NAME_LBL Name: @@ -3170,6 +3202,14 @@ Please, select face, shell or solid and try again PREF_MATERIAL Default material + + PREF_PREDEF_MATERIALS + Show predefined materials in popup menu + + + PREF_EDITGROUP_COLOR + Subshapes color for editing a group + PREF_EDGE_WIDTH Edges width @@ -3186,10 +3226,26 @@ Please, select face, shell or solid and try again PREF_MEASURES_LINE_WIDTH Measures lines width + + PREF_ISOS + Number of isolines + + + PREF_ISOS_U + Along U + + + PREF_ISOS_V + Along V + PROCESS_SHAPE_NEW_OBJ_NAME ProcessShape + + MATERIAL_LIBRARY_TLT + Materials Library + REMOVE_HOLES_NEW_OBJ_NAME SupressHoles @@ -3602,6 +3658,14 @@ Please, select face, shell or solid and try again STB_POP_WIREFRAME Wireframe + + STB_MATERIALS_LIBRARY + Displays content of Materials library + + + STB_POP_PREDEF_MATER_CUSTOM + Custom... + STB_PROPAGATE Propagate @@ -4871,6 +4935,22 @@ be specified in meters). GEOM_IS_REORDER Reorder vertices taking into account distances + + GEOM_INTERPOL_TANGENTS + Tangents + + + GEOM_INTERPOL_FIRST_VEC + First tangent vector + + + GEOM_INTERPOL_LAST_VEC + Last tangent vector + + + GEOM_BOTH_TANGENTS_REQUIRED + Both tangent vectors must be defined + GEOM_CURVE_CRMODE Creation Mode @@ -5386,6 +5466,14 @@ Number of sketch points too small NUMBER_OPEN Number of open free boundaries: + + NAME_CLOSED + Closed_Free_Boundary_%1 + + + NAME_OPEN + Open_Free_Boundary_%1 + RepairGUI_GlueDlg @@ -5530,6 +5618,14 @@ Would you like to continue? MATERIAL_PROPERTIES_TLT Color and Material Properties + + FRONT_FACE + Front face + + + BACK_FACE + Back face + REFLECTION_0 Ambient @@ -5546,10 +5642,6 @@ Would you like to continue? REFLECTION_3 Emissive - - ENABLED - Enabled - SHININESS Shininess: diff --git a/src/GEOMGUI/GEOM_msg_fr.ts b/src/GEOMGUI/GEOM_msg_fr.ts index 81d5072c6..81418e0c8 100644 --- a/src/GEOMGUI/GEOM_msg_fr.ts +++ b/src/GEOMGUI/GEOM_msg_fr.ts @@ -2966,6 +2966,10 @@ Choisissez une face, une coque ou un solide et essayez de nouveau MEN_TOOLS Outils + + MEN_MATERIALS_LIBRARY + Materials library + MEN_TORUS Tore @@ -3026,6 +3030,10 @@ Choisissez une face, une coque ou un solide et essayez de nouveau MEN_POP_MATERIAL_PROPERTIES Propriétés des matériaux + + MEN_POP_PREDEF_MATER_CUSTOM + Custom... + NAME_LBL Nom : @@ -3170,6 +3178,14 @@ Choisissez une face, une coque ou un solide et essayez de nouveau PREF_MATERIAL Matériau + + PREF_PREDEF_MATERIALS + Show predefined materials in popup menu + + + PREF_EDITGROUP_COLOR + Subshapes color for editing a group + PREF_EDGE_WIDTH Epaisseur des arêtes @@ -3186,10 +3202,26 @@ Choisissez une face, une coque ou un solide et essayez de nouveau PREF_MEASURES_LINE_WIDTH Epaisseur des traits de mesure + + PREF_ISOS + Nombre d'isolignes + + + PREF_ISOS_U + Selon U + + + PREF_ISOS_V + Selon V + PROCESS_SHAPE_NEW_OBJ_NAME FormeRetraitee + + MATERIAL_LIBRARY_TLT + Materials Library + REMOVE_HOLES_NEW_OBJ_NAME SupprimerTrous @@ -3602,6 +3634,14 @@ Choisissez une face, une coque ou un solide et essayez de nouveau STB_POP_WIREFRAME Contours + + STB_MATERIALS_LIBRARY + Displays content of Materials library + + + STB_POP_PREDEF_MATER_CUSTOM + Custom... + STB_PROPAGATE Propager @@ -4870,6 +4910,22 @@ le paramètre '%1' aux préférences du module Géométrie.GEOM_IS_REORDER Réarranger les points en prenant en compte les distances + + GEOM_INTERPOL_TANGENTS + Tangents + + + GEOM_INTERPOL_FIRST_VEC + First tangent vector + + + GEOM_INTERPOL_LAST_VEC + Last tangent vector + + + GEOM_BOTH_TANGENTS_REQUIRED + Both tangent vectors must be defined + GEOM_CURVE_CRMODE Mode de création @@ -5385,6 +5441,14 @@ Le nombre de points n'est pas suffisant NUMBER_OPEN Nombre de contours libres ouverts + + NAME_CLOSED + Closed_Free_Boundary_%1 + + + NAME_OPEN + Open_Free_Boundary_%1 + RepairGUI_GlueDlg @@ -5529,6 +5593,14 @@ Voulez-vous continuer? MATERIAL_PROPERTIES_TLT Couleur et propriétés des matériaux + + FRONT_FACE + Front face + + + BACK_FACE + Back face + REFLECTION_0 Ambiante @@ -5545,10 +5617,6 @@ Voulez-vous continuer? REFLECTION_3 Emissive - - ENABLED - Activée - SHININESS Brillance: diff --git a/src/GEOMGUI/GeometryGUI.cxx b/src/GEOMGUI/GeometryGUI.cxx index d13a0fd99..10c4d4ec6 100644 --- a/src/GEOMGUI/GeometryGUI.cxx +++ b/src/GEOMGUI/GeometryGUI.cxx @@ -38,6 +38,7 @@ #include "GEOM_Actor.h" #include +#include #include #include @@ -84,6 +85,7 @@ #include #include #include +#include #include #include @@ -188,8 +190,7 @@ void GeometryGUI::Modified (bool theIsUpdateActions) // purpose : Constructor //======================================================================= GeometryGUI::GeometryGUI() : - SalomeApp_Module( "GEOM" ), - LightApp_Module( "GEOM" ) + SalomeApp_Module( "GEOM" ) { if ( CORBA::is_nil( myComponentGeom ) ) { @@ -206,6 +207,8 @@ GeometryGUI::GeometryGUI() : myDisplayer = 0; myLocalSelectionMode = GEOM_ALLOBJECTS; + + connect( Material_ResourceMgr::resourceMgr(), SIGNAL( changed() ), this, SLOT( updateMaterials() ) ); } //======================================================================= @@ -359,7 +362,7 @@ void GeometryGUI::OnGUIEvent() // function : GeometryGUI::OnGUIEvent() // purpose : manage all events on GUI [static] //======================================================================= -void GeometryGUI::OnGUIEvent( int id ) +void GeometryGUI::OnGUIEvent( int id, const QVariant& theParam ) { SUIT_Application* anApp = application(); if (!anApp) return; @@ -408,6 +411,7 @@ void GeometryGUI::OnGUIEvent( int id ) case GEOMOp::OpSelectAll: // POPUP MENU - SELECT ONLY - SELECT ALL case GEOMOp::OpDelete: // MENU EDIT - DELETE case GEOMOp::OpCheckGeom: // MENU TOOLS - CHECK GEOMETRY + case GEOMOp::OpMaterialsLibrary: // MENU TOOLS - MATERIALS LIBRARY case GEOMOp::OpDeflection: // POPUP MENU - DEFLECTION COEFFICIENT case GEOMOp::OpColor: // POPUP MENU - COLOR case GEOMOp::OpSetTexture: // POPUP MENU - SETTEXTURE @@ -425,6 +429,8 @@ void GeometryGUI::OnGUIEvent( int id ) case GEOMOp::OpPublishObject: // ROOT GEOM OBJECT - POPUP MENU - PUBLISH case GEOMOp::OpPointMarker: // POPUP MENU - POINT MARKER case GEOMOp::OpMaterialProperties: // POPUP MENU - MATERIAL PROPERTIES + case GEOMOp::OpPredefMaterial: // POPUP MENU - + case GEOMOp::OpPredefMaterCustom: // POPUP MENU - MATERIAL PROPERTIES - CUSTOM... case GEOMOp::OpEdgeWidth: // POPUP MENU - LINE WIDTH - EDGE WIDTH case GEOMOp::OpIsosWidth: // POPUP MENU - LINE WIDTH - ISOS WIDTH case GEOMOp::OpBringToFront: // POPUP MENU - BRING TO FRONT @@ -595,18 +601,10 @@ void GeometryGUI::OnGUIEvent( int id ) // call method of corresponding GUI library if ( library ) { - library->OnGUIEvent( id, desk ); - - // Update a list of materials for "Preferences" dialog - if ( id == GEOMOp::OpMaterialProperties ) { - LightApp_Preferences* pref = preferences(); - if ( pref ) { - Material_ResourceMgr aMatResMgr; - setPreferenceProperty( pref->rootItem()->findItem( tr( "PREF_MATERIAL" ), true )->id(), - "strings", - aMatResMgr.materials() ); - } - } + if( !theParam.isValid() ) + library->OnGUIEvent( id, desk ); + else + library->OnGUIEvent( id, desk, theParam); } else SUIT_MessageBox::critical( desk, tr( "GEOM_ERROR" ), tr( "GEOM_ERR_LIB_NOT_FOUND" ), tr( "GEOM_BUT_OK" ) ); @@ -846,6 +844,7 @@ void GeometryGUI::initialize( CAM_Application* app ) createGeomAction( GEOMOp::OpCheckGeom, "CHECK_GEOMETRY" ); #endif + createGeomAction( GEOMOp::OpMaterialsLibrary, "MATERIALS_LIBRARY" ); createGeomAction( GEOMOp::OpDMWireframe, "WIREFRAME" ); createGeomAction( GEOMOp::OpDMShading, "SHADING" ); createGeomAction( GEOMOp::OpDMShadingWithEdges, "SHADING_WITH_EDGES" ); @@ -887,7 +886,8 @@ void GeometryGUI::initialize( CAM_Application* app ) createGeomAction( GEOMOp::OpUnpublishObject, "POP_UNPUBLISH_OBJ" ); createGeomAction( GEOMOp::OpPublishObject, "POP_PUBLISH_OBJ" ); createGeomAction( GEOMOp::OpPointMarker, "POP_POINT_MARKER" ); - createGeomAction( GEOMOp::OpMaterialProperties, "POP_MATERIAL_PROPERTIES" ); + createGeomAction( GEOMOp::OpMaterialProperties, "POP_MATERIAL_PROPERTIES" ); + createGeomAction( GEOMOp::OpPredefMaterCustom, "POP_PREDEF_MATER_CUSTOM" ); createGeomAction( GEOMOp::OpPipeTShape, "PIPETSHAPE" ); @@ -1080,11 +1080,15 @@ void GeometryGUI::initialize( CAM_Application* app ) createMenu( GEOMOp::OpGetNonBlocks, measurId, -1 ); createMenu( GEOMOp::OpCheckSelfInters, measurId, -1 ); -#ifdef _DEBUG_ // PAL16821 int toolsId = createMenu( tr( "MEN_TOOLS" ), -1, -1, 50 ); +#if defined(_DEBUG_) || defined(_DEBUG) // PAL16821 createMenu( separator(), toolsId, -1 ); createMenu( GEOMOp::OpCheckGeom, toolsId, -1 ); #endif + + createMenu( separator(), toolsId, -1 ); + createMenu( GEOMOp::OpMaterialsLibrary, toolsId, -1 ); + createMenu( separator(), toolsId, -1 ); int viewId = createMenu( tr( "MEN_VIEW" ), -1, -1 ); createMenu( separator(), viewId, -1 ); @@ -1273,44 +1277,49 @@ void GeometryGUI::initialize( CAM_Application* app ) mgr->insert( separator(), -1, -1 ); // ----------- dispmodeId = mgr->insert( tr( "MEN_DISPLAY_MODE" ), -1, -1 ); // display mode menu mgr->insert( action( GEOMOp::OpWireframe ), dispmodeId, -1 ); // wireframe - mgr->setRule( action( GEOMOp::OpWireframe ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule ); + mgr->setRule( action( GEOMOp::OpWireframe ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule ); mgr->setRule( action( GEOMOp::OpWireframe ), clientOCCorVTK + " and displaymode='Wireframe'", QtxPopupMgr::ToggleRule ); mgr->insert( action( GEOMOp::OpShading ), dispmodeId, -1 ); // shading - mgr->setRule( action( GEOMOp::OpShading ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule ); + mgr->setRule( action( GEOMOp::OpShading ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule ); mgr->setRule( action( GEOMOp::OpShading ), clientOCCorVTK + " and displaymode='Shading'", QtxPopupMgr::ToggleRule ); mgr->insert( action( GEOMOp::OpShadingWithEdges ), dispmodeId, -1 ); // shading with edges - mgr->setRule( action( GEOMOp::OpShadingWithEdges ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule ); + mgr->setRule( action( GEOMOp::OpShadingWithEdges ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule ); mgr->setRule( action( GEOMOp::OpShadingWithEdges ), clientOCCorVTK + " and displaymode='ShadingWithEdges'", QtxPopupMgr::ToggleRule ); mgr->insert( action( GEOMOp::OpTexture ), dispmodeId, -1 ); // wireframe mgr->setRule( action( GEOMOp::OpTexture ), clientOCC_AndSomeVisible, QtxPopupMgr::VisibleRule ); mgr->setRule( action( GEOMOp::OpTexture), clientOCC + " and displaymode='Texture'", QtxPopupMgr::ToggleRule ); mgr->insert( separator(), dispmodeId, -1 ); mgr->insert( action( GEOMOp::OpVectors ), dispmodeId, -1 ); // vectors - mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule ); + mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule ); mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK + " and isVectorsMode", QtxPopupMgr::ToggleRule ); mgr->insert( separator(), -1, -1 ); // ----------- + mgr->insert( action( GEOMOp::OpColor ), -1, -1 ); // color mgr->setRule( action( GEOMOp::OpColor ), clientOCCorVTKorOB_AndSomeVisible + " and ($component={'GEOM'})" + "and isPhysicalMaterial=false", QtxPopupMgr::VisibleRule ); mgr->insert( action( GEOMOp::OpTransparency ), -1, -1 ); // transparency - mgr->setRule( action( GEOMOp::OpTransparency ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule ); + mgr->setRule( action( GEOMOp::OpTransparency ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule ); mgr->insert( action( GEOMOp::OpIsos ), -1, -1 ); // isos - mgr->setRule( action( GEOMOp::OpIsos ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible", QtxPopupMgr::VisibleRule ); + mgr->setRule( action( GEOMOp::OpIsos ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible" + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule ); mgr->insert( action( GEOMOp::OpDeflection ), -1, -1 ); // deflection - mgr->setRule( action( GEOMOp::OpDeflection ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible", QtxPopupMgr::VisibleRule ); + mgr->setRule( action( GEOMOp::OpDeflection ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible" + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule ); mgr->insert( action( GEOMOp::OpPointMarker ), -1, -1 ); // point marker //mgr->setRule( action( GEOMOp::OpPointMarker ), QString( "selcount>0 and $typeid in {%1}" ).arg(GEOM_POINT ), QtxPopupMgr::VisibleRule ); mgr->setRule( action( GEOMOp::OpPointMarker ), QString( "selcount>0 and ( $typeid in {%1} or compoundOfVertices=true ) " ).arg(GEOM::VERTEX).arg(GEOM::COMPOUND), QtxPopupMgr::VisibleRule ); - mgr->insert( action( GEOMOp::OpMaterialProperties ), -1, -1 ); // material properties - mgr->setRule( action( GEOMOp::OpMaterialProperties ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'}) and selcount>0 and isVisible", QtxPopupMgr::VisibleRule ); - mgr->insert( action( GEOMOp::OpSetTexture ), -1, -1 ); // texture + + // material properties + mgr->insert( action( GEOMOp::OpMaterialProperties ), -1, -1 ); + mgr->setRule( action( GEOMOp::OpMaterialProperties ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule ); + + // texture + mgr->insert( action( GEOMOp::OpSetTexture ), -1, -1 ); mgr->setRule( action( GEOMOp::OpSetTexture ), clientOCCorOB_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule ); int lineW = mgr->insert( tr( "MEN_LINE_WIDTH" ), -1, -1 ); // line width menu mgr->insert( action( GEOMOp::OpEdgeWidth ), lineW, -1 ); // edge width - mgr->setRule( action( GEOMOp::OpEdgeWidth ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule ); + mgr->setRule( action( GEOMOp::OpEdgeWidth ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule ); mgr->insert( action( GEOMOp::OpIsosWidth ), lineW, -1 ); // isos width - mgr->setRule( action( GEOMOp::OpIsosWidth ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule ); + mgr->setRule( action( GEOMOp::OpIsosWidth ), clientOCCorVTK_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule ); mgr->insert( separator(), -1, -1 ); // ----------- mgr->insert( action( GEOMOp::OpAutoColor ), -1, -1 ); // auto color @@ -1612,7 +1621,7 @@ void GeometryGUI::onViewManagerRemoved( SUIT_ViewManager* vm ) if ( GEOMGUI_OCCSelector* sr = itOCCSel.next() ) if ( sr->viewer() == viewer ) { - delete myOCCSelectors.takeAt( myOCCSelectors.indexOf( sr ) ); + /*delete*/ myOCCSelectors.takeAt( myOCCSelectors.indexOf( sr ) ); break; } } @@ -1623,7 +1632,7 @@ void GeometryGUI::onViewManagerRemoved( SUIT_ViewManager* vm ) if ( LightApp_VTKSelector* sr = itVTKSel.next() ) if ( sr->viewer() == viewer ) { - delete myVTKSelectors.takeAt( myVTKSelectors.indexOf( sr ) ); + /*delete*/ myVTKSelectors.takeAt( myVTKSelectors.indexOf( sr ) ); break; } } @@ -1689,6 +1698,58 @@ void GeometryGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& SalomeApp_Module::contextMenuPopup( client, menu, title ); SALOME_ListIO lst; getApp()->selectionMgr()->selectedObjects( lst ); + + //Add submenu for predefined materials + bool isPredefMat = SUIT_Session::session()->resourceMgr()->booleanValue( "Geometry", "predef_materials" ); + if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() > 0 ) { + QtxPopupMgr* mgr = popupMgr(); + //get parrent for submenu + QAction* act = mgr->action( mgr->actionId( action( GEOMOp::OpMaterialProperties ) ) ); + //Clear old menu + QMenu* oldMenu = act->menu() ; + if( oldMenu ) { + delete oldMenu; + } + if( isPredefMat ){ + QMenu* matMenu = new QMenu(); + QSignalMapper* signalMapper = new QSignalMapper( matMenu ); + + //Get current material model for the object + QVariant v; + LightApp_Application* anApp = dynamic_cast( getApp() ); + if ( anApp && anApp->activeViewManager() ) { + LightApp_Study* aStudy = dynamic_cast( anApp->activeStudy() ); + if( aStudy ) { + v = aStudy->getObjectProperty( anApp->activeViewManager()->getGlobalId(), lst.Last()->getEntry(), GEOM::propertyName( GEOM::Material ), QVariant() ); + } + } + QString curModel = ""; + if ( v.canConvert() ) curModel = v.toString(); + // get list of all predefined materials + QStringList materials = Material_ResourceMgr::resourceMgr()->materials(); + bool found = false; + foreach ( QString material, materials ) + { + QAction* menAct = matMenu->addAction( material ); + connect(menAct, SIGNAL( toggled( bool ) ), signalMapper, SLOT( map() ) ); + signalMapper->setMapping( menAct, material ); + menAct->setCheckable( true ); + // Set checked if this material is current + Material_Model aModel; + aModel.fromResources( material ); + if ( !found && aModel.toProperties() == curModel ) { + menAct->setChecked( true ); + found = true; + } + } + matMenu->insertAction( matMenu->addSeparator(), action( GEOMOp::OpPredefMaterCustom ) ); + matMenu->insertSeparator( action( GEOMOp::OpPredefMaterCustom ) ); + connect( signalMapper, SIGNAL( mapped( const QString & ) ), + this, SLOT( OnSetMaterial( const QString & ) ) ); + act->setMenu( matMenu ); + } + } + //Set name if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) { Handle(SALOME_InteractiveObject) io = lst.First(); SalomeApp_Study* appStudy = dynamic_cast( application()->activeStudy() ); @@ -1702,6 +1763,12 @@ void GeometryGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& } } +void GeometryGUI::OnSetMaterial(const QString& theName) +{ + OnGUIEvent( GEOMOp::OpPredefMaterial, QVariant( theName ) ); +} + + void GeometryGUI::createPreferences() { int tabId = addPreference( tr( "PREF_TAB_SETTINGS" ) ); @@ -1746,9 +1813,15 @@ void GeometryGUI::createPreferences() int defl = addPreference( tr( "PREF_DEFLECTION" ), genGroup, LightApp_Preferences::DblSpin, "Geometry", "deflection_coeff" ); + addPreference( tr( "PREF_PREDEF_MATERIALS" ), genGroup, + LightApp_Preferences::Bool, "Geometry", "predef_materials" ); + int material = addPreference( tr( "PREF_MATERIAL" ), genGroup, - LightApp_Preferences::Selector, - "Geometry", "material" ); + LightApp_Preferences::Selector, + "Geometry", "material" ); + + addPreference( tr( "PREF_EDITGROUP_COLOR" ), genGroup, + LightApp_Preferences::Color, "Geometry", "editgroup_color" ); const int nb = 4; int wd[nb]; @@ -1770,6 +1843,17 @@ void GeometryGUI::createPreferences() setPreferenceProperty( wd[i], "min", 1 ); setPreferenceProperty( wd[i], "max", 5 ); } + + int isoGroup = addPreference( tr( "PREF_ISOS" ), tabId ); + setPreferenceProperty( isoGroup, "columns", 2 ); + int isoU = addPreference( tr( "PREF_ISOS_U" ), isoGroup, + LightApp_Preferences::IntSpin, "Geometry", "iso_number_u" ); + setPreferenceProperty( isoU, "min", 0 ); + setPreferenceProperty( isoU, "max", 100000 ); + int isoV = addPreference( tr( "PREF_ISOS_V" ), isoGroup, + LightApp_Preferences::IntSpin, "Geometry", "iso_number_v" ); + setPreferenceProperty( isoV, "min", 0 ); + setPreferenceProperty( isoV, "max", 100000 ); // Quantities with individual precision settings int precGroup = addPreference( tr( "GEOM_PREF_GROUP_PRECISION" ), tabId ); @@ -1848,15 +1932,14 @@ void GeometryGUI::createPreferences() setPreferenceProperty( step, "precision", 3 ); // Set property for deflection value for spinboxes - setPreferenceProperty( defl, "min", DEFLECTION_MIN ); + setPreferenceProperty( defl, "min", GEOM::minDeflection() ); setPreferenceProperty( defl, "max", 1.0 ); setPreferenceProperty( defl, "step", 1.0e-04 ); setPreferenceProperty( defl, "precision", 6 ); // Set property for default material - Material_ResourceMgr aMatResMgr; - setPreferenceProperty( material, "strings", aMatResMgr.materials() ); - + setPreferenceProperty( material, "strings", Material_ResourceMgr::resourceMgr()->materials() ); + // Set property vertex marker type QList aMarkerTypeIndicesList; QList aMarkerTypeIconsList; @@ -1995,83 +2078,82 @@ void GeometryGUI::storeVisualParameters (int savePoint) if (!obj->FindAttribute(anAttr, "AttributeIOR")) continue; - std::string param,occParam = vType.toLatin1().data(); - occParam += NAME_SEPARATOR; - occParam += QString::number(aMgrId).toLatin1().data(); - occParam += NAME_SEPARATOR; + QString param, occParam = vType; + occParam += GEOM::sectionSeparator(); + occParam += QString::number(aMgrId); + occParam += GEOM::sectionSeparator(); - if (aProps.contains(VISIBILITY_PROP)) { - param = occParam + VISIBILITY_PROP; - ip->setParameter(entry, param, aProps.value(VISIBILITY_PROP).toInt() == 1 ? "On" : "Off"); + if (aProps.contains(GEOM::propertyName( GEOM::Visibility ))) { + param = occParam + GEOM::propertyName( GEOM::Visibility ); + ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Visibility )).toBool() ? "On" : "Off"); } - if (aProps.contains(DISPLAY_MODE_PROP)) { - param = occParam + DISPLAY_MODE_PROP; - ip->setParameter(entry, param, QString::number(aProps.value(DISPLAY_MODE_PROP).toInt()).toLatin1().data()); + if (aProps.contains(GEOM::propertyName( GEOM::DisplayMode ))) { + param = occParam + GEOM::propertyName( GEOM::DisplayMode ); + ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::DisplayMode )).toString().toStdString()); } - if (aProps.contains(COLOR_PROP)) { - QColor c = aProps.value(COLOR_PROP).value(); - QString colorStr = QString::number(c.red()/255.); - colorStr += DIGIT_SEPARATOR; colorStr += QString::number(c.green()/255.); - colorStr += DIGIT_SEPARATOR; colorStr += QString::number(c.blue()/255.); - param = occParam + COLOR_PROP; - ip->setParameter(entry, param, colorStr.toLatin1().data()); + if (aProps.contains(GEOM::propertyName( GEOM::Color ))) { + QColor c = aProps.value(GEOM::propertyName( GEOM::Color )).value(); + QStringList val; + val << QString::number(c.redF()); + val << QString::number(c.greenF()); + val << QString::number(c.blueF()); + param = occParam + GEOM::propertyName( GEOM::Color ); + ip->setParameter(entry, param.toStdString(), val.join( GEOM::subSectionSeparator()).toStdString()); } if (vType == SVTK_Viewer::Type()) { - if (aProps.contains(OPACITY_PROP)) { - param = occParam + OPACITY_PROP; - ip->setParameter(entry, param, QString::number(1. - aProps.value(TRANSPARENCY_PROP).toDouble()).toLatin1().data()); + if (aProps.contains(GEOM::propertyName( GEOM::Opacity ))) { + param = occParam + GEOM::propertyName( GEOM::Opacity ); + ip->setParameter(entry, param.toStdString(), QString::number(1. - aProps.value(GEOM::propertyName( GEOM::Transparency )).toDouble()).toStdString()); } } else if (vType == SOCC_Viewer::Type()) { - if (aProps.contains(TRANSPARENCY_PROP)) { - param = occParam + TRANSPARENCY_PROP; - ip->setParameter(entry, param, QString::number(aProps.value(TRANSPARENCY_PROP).toDouble()).toLatin1().data()); + if (aProps.contains(GEOM::propertyName( GEOM::Transparency ))) { + param = occParam + GEOM::propertyName( GEOM::Transparency ); + ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Transparency )).toString().toStdString()); } - if (aProps.contains(TOP_LEVEL_PROP)) { - param = occParam + TOP_LEVEL_PROP; - Standard_Boolean val = aProps.value(TOP_LEVEL_PROP).value(); - if (val == Standard_True) - ip->setParameter(entry, param, "1"); + if (aProps.contains(GEOM::propertyName( GEOM::TopLevel ))) { + param = occParam + GEOM::propertyName( GEOM::TopLevel ); + ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::TopLevel )).toString().toStdString()); } } - if (aProps.contains(ISOS_PROP)) { - param = occParam + ISOS_PROP; - ip->setParameter(entry, param, aProps.value(ISOS_PROP).toString().toLatin1().data()); + if (aProps.contains(GEOM::propertyName( GEOM::NbIsos ))) { + param = occParam + GEOM::propertyName( GEOM::NbIsos ); + ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::NbIsos )).toString().toStdString()); } - if (aProps.contains(VECTOR_MODE_PROP)) { - param = occParam + VECTOR_MODE_PROP; - ip->setParameter(entry, param, QString::number(aProps.value(VECTOR_MODE_PROP).toInt()).toLatin1().data()); + if (aProps.contains(GEOM::propertyName( GEOM::EdgesDirection ))) { + param = occParam + GEOM::propertyName( GEOM::EdgesDirection ); + ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::EdgesDirection )).toString().toStdString()); } - if (aProps.contains(DEFLECTION_COEFF_PROP)) { - param = occParam + DEFLECTION_COEFF_PROP; - ip->setParameter(entry, param, QString::number(aProps.value(DEFLECTION_COEFF_PROP).toDouble()).toLatin1().data()); + if (aProps.contains(GEOM::propertyName( GEOM::Deflection ))) { + param = occParam + GEOM::propertyName( GEOM::Deflection ); + ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Deflection )).toString().toStdString()); } //Marker type of the vertex - ONLY for the "Vertex" and "Compound of the Vertex" - if (aProps.contains(MARKER_TYPE_PROP)) { - param = occParam + MARKER_TYPE_PROP; - ip->setParameter(entry, param, aProps.value(MARKER_TYPE_PROP).toString().toLatin1().data()); + if (aProps.contains(GEOM::propertyName( GEOM::PointMarker ))) { + param = occParam + GEOM::propertyName( GEOM::PointMarker ); + ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::PointMarker )).toString().toStdString()); } - if (aProps.contains(MATERIAL_PROP)) { - param = occParam + MATERIAL_PROP; - ip->setParameter(entry, param, aProps.value(MATERIAL_PROP).toString().toLatin1().data()); + if (aProps.contains(GEOM::propertyName( GEOM::Material ))) { + param = occParam + GEOM::propertyName( GEOM::Material ); + ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::Material )).toString().toStdString()); } - if (aProps.contains(EDGE_WIDTH_PROP)) { - param = occParam + EDGE_WIDTH_PROP; - ip->setParameter(entry, param, aProps.value(EDGE_WIDTH_PROP).toString().toLatin1().data()); + if (aProps.contains(GEOM::propertyName( GEOM::LineWidth ))) { + param = occParam + GEOM::propertyName( GEOM::LineWidth ); + ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::LineWidth )).toString().toStdString()); } - if (aProps.contains(ISOS_WIDTH_PROP)) { - param = occParam + ISOS_WIDTH_PROP; - ip->setParameter(entry, param, aProps.value(ISOS_WIDTH_PROP).toString().toLatin1().data()); + if (aProps.contains(GEOM::propertyName( GEOM::IsosWidth ))) { + param = occParam + GEOM::propertyName( GEOM::IsosWidth ); + ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::IsosWidth )).toString().toStdString()); } } // object iterator } // for (views) @@ -2134,7 +2216,7 @@ void GeometryGUI::restoreVisualParameters (int savePoint) { // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName. // '_' is used as separator and should not be used in viewer type or parameter names. - QStringList lst = QString((*namesIt).c_str()).split(NAME_SEPARATOR, QString::SkipEmptyParts); + QStringList lst = QString((*namesIt).c_str()).split( GEOM::sectionSeparator(), QString::SkipEmptyParts); if (lst.size() != 3) continue; @@ -2152,36 +2234,36 @@ void GeometryGUI::restoreVisualParameters (int savePoint) } QString val((*valuesIt).c_str()); - if (paramNameStr == VISIBILITY_PROP) { - aListOfMap[viewIndex].insert(VISIBILITY_PROP, val == "On" ? 1 : 0); - } else if (paramNameStr == OPACITY_PROP) { - aListOfMap[viewIndex].insert(TRANSPARENCY_PROP, 1. - val.toDouble()); - } else if (paramNameStr == TRANSPARENCY_PROP) { - aListOfMap[viewIndex].insert( TRANSPARENCY_PROP, val.toDouble() ); - } else if (paramNameStr == TOP_LEVEL_PROP) { - aListOfMap[viewIndex].insert( TRANSPARENCY_PROP, val == "1" ? Standard_True : Standard_False ); - } else if (paramNameStr == DISPLAY_MODE_PROP) { - aListOfMap[viewIndex].insert( DISPLAY_MODE_PROP, val.toInt()); - } else if (paramNameStr == ISOS_PROP) { - aListOfMap[viewIndex].insert( ISOS_PROP, val); - } else if (paramNameStr == COLOR_PROP) { - QStringList rgb = val.split(DIGIT_SEPARATOR); + if (paramNameStr == GEOM::propertyName( GEOM::Visibility )) { + aListOfMap[viewIndex].insert(GEOM::propertyName( GEOM::Visibility ), val == "On"); + } else if (paramNameStr == GEOM::propertyName( GEOM::Opacity )) { + aListOfMap[viewIndex].insert(GEOM::propertyName( GEOM::Transparency ), 1. - val.toDouble()); + } else if (paramNameStr == GEOM::propertyName( GEOM::Transparency )) { + aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Transparency ), val.toDouble() ); + } else if (paramNameStr == GEOM::propertyName( GEOM::TopLevel )) { + aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::TopLevel ), val == "true" || val == "1"); + } else if (paramNameStr == GEOM::propertyName( GEOM::DisplayMode )) { + aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::DisplayMode ), val.toInt()); + } else if (paramNameStr == GEOM::propertyName( GEOM::NbIsos )) { + aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::NbIsos ), val); + } else if (paramNameStr == GEOM::propertyName( GEOM::Color )) { + QStringList rgb = val.split(GEOM::subSectionSeparator()); if (rgb.count() == 3) { - QColor c(int(rgb[0].toDouble()*255), int(rgb[1].toDouble()*255), int(rgb[2].toDouble()*255)); - aListOfMap[viewIndex].insert( COLOR_PROP, c); + QColor c = QColor::fromRgbF(rgb[0].toDouble(), rgb[1].toDouble(), rgb[2].toDouble()); + aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Color ), c); } - } else if (paramNameStr == VECTOR_MODE_PROP) { - aListOfMap[viewIndex].insert( VECTOR_MODE_PROP, val.toInt()); - } else if (paramNameStr == DEFLECTION_COEFF_PROP) { - aListOfMap[viewIndex].insert( DEFLECTION_COEFF_PROP, val.toDouble()); - } else if (paramNameStr == MARKER_TYPE_PROP) { - aListOfMap[viewIndex].insert( MARKER_TYPE_PROP, val); - } else if (paramNameStr == MATERIAL_PROP) { - aListOfMap[viewIndex].insert( MATERIAL_PROP, val); - } else if (paramNameStr == EDGE_WIDTH_PROP) { - aListOfMap[viewIndex].insert( EDGE_WIDTH_PROP, val); - } else if (paramNameStr == ISOS_WIDTH_PROP) { - aListOfMap[viewIndex].insert( ISOS_WIDTH_PROP, val); + } else if (paramNameStr == GEOM::propertyName( GEOM::EdgesDirection )) { + aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::EdgesDirection ), val == "true" || val == "1"); + } else if (paramNameStr == GEOM::propertyName( GEOM::Deflection )) { + aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Deflection ), val.toDouble()); + } else if (paramNameStr == GEOM::propertyName( GEOM::PointMarker )) { + aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::PointMarker ), val); + } else if (paramNameStr == GEOM::propertyName( GEOM::Material )) { + aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::Material ), val); + } else if (paramNameStr == GEOM::propertyName( GEOM::LineWidth )) { + aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::LineWidth ), val.toInt()); + } else if (paramNameStr == GEOM::propertyName( GEOM::IsosWidth )) { + aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::IsosWidth ), val.toInt()); } } // for names/parameters iterator @@ -2192,7 +2274,7 @@ void GeometryGUI::restoreVisualParameters (int savePoint) appStudy->setObjectPropMap(index, entry, aListOfMap[index]); //Get Visibility property of the current PropMap - if (aListOfMap[index].value(VISIBILITY_PROP) == 1) { + if (aListOfMap[index].value(GEOM::propertyName( GEOM::Visibility )) == 1) { SUIT_ViewManager* vman = lst.at(index); SUIT_ViewModel* vmodel = vman->getViewModel(); displayer()->Display(entry, true, dynamic_cast(vmodel)); @@ -2306,3 +2388,22 @@ bool GeometryGUI::renameObject( const QString& entry, const QString& name) } return result; } + +void GeometryGUI::updateMaterials() +{ + LightApp_Preferences* pref = preferences(); + if ( pref ) { + QStringList materials = Material_ResourceMgr::resourceMgr()->materials(); + QString currentMaterial = SUIT_Session::session()->resourceMgr()->stringValue( "Geometry", "material" ); + if ( !materials.contains( currentMaterial ) ) + // user material set as default in the preferences, might be removed + SUIT_Session::session()->resourceMgr()->setValue( "Geometry", "material", QString( "Plastic" ) ); + + QtxPreferenceItem* prefItem = pref->rootItem()->findItem( tr( "PREF_MATERIAL" ), true ); + if ( prefItem ) { + setPreferenceProperty( prefItem->id(), + "strings", materials ); + prefItem->retrieve(); + } + } +} diff --git a/src/GEOMGUI/GeometryGUI.h b/src/GEOMGUI/GeometryGUI.h index bde9446a7..9bf6e6326 100644 --- a/src/GEOMGUI/GeometryGUI.h +++ b/src/GEOMGUI/GeometryGUI.h @@ -111,7 +111,7 @@ public: void EmitSignalDefaultStepValueChanged( double newVal ); // Process action - void OnGUIEvent( int id ); + void OnGUIEvent( int id, const QVariant& theParam = QVariant( QVariant::Invalid ) ); // The Working Plane management void SetWorkingPlane( gp_Ax3 wp ) { myWorkingPlane = wp; } @@ -151,6 +151,8 @@ private slots: void OnGUIEvent(); void onWindowActivated( SUIT_ViewWindow* ); void onViewAboutToShow(); + void OnSetMaterial( const QString& ); + void updateMaterials(); signals : void SignalDeactivateActiveDialog(); diff --git a/src/GEOMGUI/GeometryGUI_Operations.h b/src/GEOMGUI/GeometryGUI_Operations.h index e17172e49..cea4c9048 100644 --- a/src/GEOMGUI/GeometryGUI_Operations.h +++ b/src/GEOMGUI/GeometryGUI_Operations.h @@ -29,6 +29,7 @@ namespace GEOMOp { OpExport = 1001, // MENU FILE - EXPORT OpDelete = 1020, // MENU EDIT - DELETE OpCheckGeom = 1030, // MENU TOOLS - CHECK GEOMETRY + OpMaterialsLibrary = 1040, // MENU TOOLS - MATERIALS LIBRARY OpSelectVertex = 1100, // POPUP MENU - SELECT ONLY - VERTEX OpSelectEdge = 1101, // POPUP MENU - SELECT ONLY - EDGE OpSelectWire = 1102, // POPUP MENU - SELECT ONLY - WIRE @@ -50,6 +51,8 @@ namespace GEOMOp { OpPointMarker = 1210, // POPUP MENU - POINT MARKER OpSetTexture = 1211, // POPUP MENU - SETTEXTURE OpMaterialProperties = 1212, // POPUP MENU - MATERIAL PROPERTIES + OpPredefMaterial = 1213, // POPUP MENU - MATERIAL PROPERTIES - + OpPredefMaterCustom = 1214, // POPUP MENU - MATERIAL PROPERTIES - CUSTOM... OpDiscloseChildren = 1250, // POPUP MENU - DISCLOSE CHILD ITEMS OpConcealChildren = 1251, // POPUP MENU - CONCEAL CHILD ITEMS OpUnpublishObject = 1253, // POPUP MENU - UNPUBLISH diff --git a/src/GEOMImpl/GEOMImpl_CircleDriver.cxx b/src/GEOMImpl/GEOMImpl_CircleDriver.cxx index b26507e88..e0c33a478 100644 --- a/src/GEOMImpl/GEOMImpl_CircleDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_CircleDriver.cxx @@ -18,17 +18,19 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include #include + #include #include + #include +#include + #include #include + #include #include #include @@ -48,29 +50,29 @@ //======================================================================= //function : GetID //purpose : -//======================================================================= +//======================================================================= const Standard_GUID& GEOMImpl_CircleDriver::GetID() { static Standard_GUID aCircleDriver("FF1BBB32-5D14-4df2-980B-3A668264EA16"); - return aCircleDriver; + return aCircleDriver; } //======================================================================= //function : GEOMImpl_CircleDriver -//purpose : +//purpose : //======================================================================= -GEOMImpl_CircleDriver::GEOMImpl_CircleDriver() +GEOMImpl_CircleDriver::GEOMImpl_CircleDriver() { } //======================================================================= //function : Execute //purpose : -//======================================================================= +//======================================================================= Standard_Integer GEOMImpl_CircleDriver::Execute(TFunction_Logbook& log) const { - if (Label().IsNull()) return 0; + if (Label().IsNull()) return 0; Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); GEOMImpl_ICircle aCI (aFunction); @@ -95,20 +97,7 @@ Standard_Integer GEOMImpl_CircleDriver::Execute(TFunction_Logbook& log) const Handle(GEOM_Function) aRefVector = aCI.GetVector(); if (!aRefVector.IsNull()) { TopoDS_Shape aShapeVec = aRefVector->GetValue(); - if (aShapeVec.ShapeType() != TopAbs_EDGE) { - Standard_ConstructionError::Raise - ("Circle creation aborted: invalid vector argument, must be a vector or an edge"); - } - TopoDS_Edge anE = TopoDS::Edge(aShapeVec); - TopoDS_Vertex V1, V2; - TopExp::Vertices(anE, V1, V2, Standard_True); - if (!V1.IsNull() && !V2.IsNull()) { - aV = gp_Vec(BRep_Tool::Pnt(V1), BRep_Tool::Pnt(V2)); - if (aV.Magnitude() < gp::Resolution()) { - Standard_ConstructionError::Raise - ("Circle creation aborted: vector of zero length is given"); - } - } + aV = GEOMUtils::GetVector(aShapeVec); } // Axes gp_Ax2 anAxes (aP, aV); @@ -163,7 +152,7 @@ Standard_Integer GEOMImpl_CircleDriver::Execute(TFunction_Logbook& log) const //Make Circle gp_Ax2 anAxes (aP1, aDir); gp_Circ aCirc (anAxes, aRadius); - aShape = BRepBuilderAPI_MakeEdge(aCirc).Edge(); + aShape = BRepBuilderAPI_MakeEdge(aCirc).Edge(); } } else if (aType == CIRCLE_THREE_PNT) { @@ -187,7 +176,7 @@ Standard_Integer GEOMImpl_CircleDriver::Execute(TFunction_Logbook& log) const 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 { } @@ -196,26 +185,26 @@ Standard_Integer GEOMImpl_CircleDriver::Execute(TFunction_Logbook& log) const aFunction->SetValue(aShape); - log.SetTouched(Label()); + log.SetTouched(Label()); - return 1; + 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); + 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", @@ -230,7 +219,7 @@ Standard_EXPORT Handle_Standard_Type& GEOMImpl_CircleDriver_Type_() //======================================================================= //function : DownCast //purpose : -//======================================================================= +//======================================================================= const Handle(GEOMImpl_CircleDriver) Handle(GEOMImpl_CircleDriver)::DownCast(const Handle(Standard_Transient)& AnObject) { Handle(GEOMImpl_CircleDriver) _anOtherObject; diff --git a/src/GEOMImpl/GEOMImpl_FaceDriver.cxx b/src/GEOMImpl/GEOMImpl_FaceDriver.cxx index 4aafb7114..708f8f450 100755 --- a/src/GEOMImpl/GEOMImpl_FaceDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_FaceDriver.cxx @@ -15,16 +15,15 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include #include + #include #include + #include -#include +#include #include #include @@ -89,7 +88,7 @@ Standard_Integer GEOMImpl_FaceDriver::Execute(TFunction_Logbook& log) const } else if (aRefShape.ShapeType() == TopAbs_FACE) { double aH = aFI.GetH() / 2.0; double aW = aFI.GetW() / 2.0; - gp_Ax3 anAx = GEOMImpl_IMeasureOperations::GetPosition(aRefShape); + gp_Ax3 anAx = GEOMUtils::GetPosition(aRefShape); gp_Pln aPln (anAx); aShape = BRepBuilderAPI_MakeFace(aPln, -aH, +aH, -aW, +aW).Shape(); } diff --git a/src/GEOMImpl/GEOMImpl_Fillet1dDriver.cxx b/src/GEOMImpl/GEOMImpl_Fillet1dDriver.cxx index f781f228e..38a0ba318 100644 --- a/src/GEOMImpl/GEOMImpl_Fillet1dDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_Fillet1dDriver.cxx @@ -23,10 +23,12 @@ #include #include #include -#include #include + #include +#include + #include #include #include @@ -352,7 +354,7 @@ bool GEOMImpl_Fillet1dDriver::MakeFillet(const TopoDS_Wire& aWire, aListOfNewEdge.Append(anEdgeToEdgeMap.Find(anEdge)); } - GEOMImpl_IShapesOperations::SortShapes(aListOfNewEdge); + GEOMUtils::SortShapes(aListOfNewEdge); BRepBuilderAPI_MakeWire aWireTool; aWireTool.Add(aListOfNewEdge); diff --git a/src/GEOMImpl/GEOMImpl_IBlocksOperations.cxx b/src/GEOMImpl/GEOMImpl_IBlocksOperations.cxx index efb69f42c..65b2ea018 100644 --- a/src/GEOMImpl/GEOMImpl_IBlocksOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IBlocksOperations.cxx @@ -34,7 +34,8 @@ #include #include #include -#include + +#include #include #include @@ -3492,13 +3493,13 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IBlocksOperations::Propagate } // while (listPrevEdges.Extent() > 0) // Sort shapes in current chain (Mantis issue 21053) - GEOMImpl_IShapesOperations::SortShapes(currentChain, Standard_False); + GEOMUtils::SortShapes(currentChain, Standard_False); aFirstInChains.Append(currentChain.First()); aMapChains.Bind(currentChain.First(), currentChain); } // Sort chains (Mantis issue 21053) - GEOMImpl_IShapesOperations::SortShapes(aFirstInChains, Standard_False); + GEOMUtils::SortShapes(aFirstInChains, Standard_False); // Store sorted chains in the document TopTools_ListIteratorOfListOfShape aChainsIt (aFirstInChains); diff --git a/src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx b/src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx index 22237b786..60983a177 100644 --- a/src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_ICurvesOperations.cxx @@ -736,19 +736,19 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineBezier GEOMImpl_ISpline aCI (aFunction); - int aLen = thePoints.size(); - aCI.SetLength(aLen); aCI.SetConstructorType(POINT_CONSTRUCTOR); - int ind = 1; + Handle(TColStd_HSequenceOfTransient) aPoints = new TColStd_HSequenceOfTransient; std::list::iterator it = thePoints.begin(); - for (; it != thePoints.end(); it++, ind++) { + for (; it != thePoints.end(); it++) { Handle(GEOM_Function) aRefPnt = (*it)->GetLastFunction(); - - if (aRefPnt.IsNull()) return NULL; - - aCI.SetPoint(ind, aRefPnt); + if (aRefPnt.IsNull()) { + SetErrorCode("NULL point for Besier curve"); + return NULL; + } + aPoints->Append(aRefPnt); } + aCI.SetPoints(aPoints); aCI.SetIsClosed(theIsClosed); @@ -798,7 +798,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineInterpolation //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 + //Add a new Spline function for interpolation type Handle(GEOM_Function) aFunction = aSpline->AddFunction(GEOMImpl_SplineDriver::GetID(), SPLINE_INTERPOLATION); if (aFunction.IsNull()) return NULL; @@ -808,19 +808,18 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineInterpolation GEOMImpl_ISpline aCI (aFunction); - int aLen = thePoints.size(); aCI.SetConstructorType(POINT_CONSTRUCTOR); - aCI.SetLength(aLen); - int ind = 1; + Handle(TColStd_HSequenceOfTransient) aPoints = new TColStd_HSequenceOfTransient; std::list::iterator it = thePoints.begin(); - for (; it != thePoints.end(); it++, ind++) { + for (; it != thePoints.end(); it++) { Handle(GEOM_Function) aRefPnt = (*it)->GetLastFunction(); - - if (aRefPnt.IsNull()) return NULL; - - aCI.SetPoint(ind, aRefPnt); + if (aRefPnt.IsNull()) { + return NULL; + } + aPoints->Append(aRefPnt); } + aCI.SetPoints(aPoints); aCI.SetIsClosed(theIsClosed); aCI.SetDoReordering(theDoReordering); @@ -856,6 +855,85 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineInterpolation return aSpline; } + +//============================================================================= +/*! + * MakeSplineInterpolWithTangents + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineInterpolWithTangents + (std::list thePoints, + Handle(GEOM_Object) theFirstVec, + Handle(GEOM_Object) theLastVec) +{ + SetErrorCode(KO); + + //Add a new Spline object + Handle(GEOM_Object) aSpline = GetEngine()->AddObject(GetDocID(), GEOM_SPLINE); + + //Add a new Spline function for interpolation type + Handle(GEOM_Function) aFunction = + aSpline->AddFunction(GEOMImpl_SplineDriver::GetID(), SPLINE_INTERPOL_TANGENTS); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_SplineDriver::GetID()) return NULL; + + GEOMImpl_ISpline aCI (aFunction); + + aCI.SetConstructorType(POINT_CONSTRUCTOR); + + Handle(TColStd_HSequenceOfTransient) aPoints = new TColStd_HSequenceOfTransient; + std::list::iterator it = thePoints.begin(); + for (; it != thePoints.end(); it++) { + Handle(GEOM_Function) aRefPnt = (*it)->GetLastFunction(); + if (aRefPnt.IsNull()) { + SetErrorCode("NULL point for Interpolation"); + return NULL; + } + aPoints->Append(aRefPnt); + } + aCI.SetPoints(aPoints); + + Handle(GEOM_Function) aVec1 = theFirstVec->GetLastFunction(); + Handle(GEOM_Function) aVec2 = theLastVec->GetLastFunction(); + + if (aVec1.IsNull() || aVec2.IsNull()) return NULL; + + aCI.SetFirstVector(aVec1); + aCI.SetLastVector(aVec2); + + //Compute the Spline value + try { +#if OCC_VERSION_LARGE > 0x06010000 + OCC_CATCH_SIGNALS; +#endif + 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 + GEOM::TPythonDump pd (aFunction); + pd << aSpline << " = geompy.MakeInterpolWithTangents(["; + + it = thePoints.begin(); + pd << (*it++); + while (it != thePoints.end()) { + pd << ", " << (*it++); + } + pd << "], " << theFirstVec << ", " << theLastVec << ")"; + + SetErrorCode(OK); + return aSpline; +} + //============================================================================= /*! * MakeCurveParametric @@ -864,7 +942,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSplineInterpolation Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCurveParametric (const char* thexExpr, const char* theyExpr, const char* thezExpr, double theParamMin, double theParamMax, double theParamStep, - CurveType theCurveType, + CurveType theCurveType, int theParamNbStep, bool theNewMethod) { TCollection_AsciiString aPyScript; @@ -958,7 +1036,7 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCurveParametric coords = PyObject_CallFunction(func,(char*)"(d, d, i)", theParamMin, theParamMax, theParamNbStep ); else coords = PyObject_CallFunction(func,(char*)"(d, d, d)", theParamMin, theParamMax, theParamStep ); - + PyObject* new_stderr = NULL; if (coords == NULL){ @@ -1038,7 +1116,6 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCurveParametric GEOMImpl_ISpline aCI (aFunction); - aCI.SetLength(lsize); aCI.SetConstructorType(COORD_CONSTRUCTOR); aCI.SetIsClosed(false); aCI.SetCoordinates(aCoordsArray); @@ -1058,7 +1135,6 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeCurveParametric GEOMImpl_ISpline aCI (aFunction); aCI.SetConstructorType(COORD_CONSTRUCTOR); - aCI.SetLength(lsize); aCI.SetIsClosed(false); aCI.SetDoReordering(false); aCI.SetCoordinates(aCoordsArray); diff --git a/src/GEOMImpl/GEOMImpl_ICurvesOperations.hxx b/src/GEOMImpl/GEOMImpl_ICurvesOperations.hxx index 829f9cc5d..f3e93170d 100644 --- a/src/GEOMImpl/GEOMImpl_ICurvesOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_ICurvesOperations.hxx @@ -32,11 +32,11 @@ class GEOM_Engine; class Handle(GEOM_Object); class GEOMImpl_ICurvesOperations : public GEOM_IOperations { - + public: enum CurveType { Polyline, Bezier, Interpolation }; - + Standard_EXPORT GEOMImpl_ICurvesOperations(GEOM_Engine* theEngine, int theDocID); Standard_EXPORT ~GEOMImpl_ICurvesOperations(); @@ -57,7 +57,7 @@ class GEOMImpl_ICurvesOperations : public GEOM_IOperations { Standard_EXPORT Handle(GEOM_Object) MakeArc (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2, Handle(GEOM_Object) thePnt3); - + Standard_EXPORT Handle(GEOM_Object) MakeArcCenter (Handle(GEOM_Object) thePnt1, Handle(GEOM_Object) thePnt2, Handle(GEOM_Object) thePnt3, @@ -77,9 +77,14 @@ class GEOMImpl_ICurvesOperations : public GEOM_IOperations { bool theIsClosed = false, bool theDoReordering = false); + Standard_EXPORT Handle(GEOM_Object) MakeSplineInterpolWithTangents + (std::list thePoints, + Handle(GEOM_Object) theFirstVec, + Handle(GEOM_Object) theLastVec); + Standard_EXPORT Handle(GEOM_Object) MakeCurveParametric - (const char* thexExpr, const char* theyExpr, const char* thezExpr, - double theParamMin, double theParamMax, double theParamStep, + (const char* thexExpr, const char* theyExpr, const char* thezExpr, + double theParamMin, double theParamMax, double theParamStep, CurveType theCurveType, int theParamNbStep=0, bool theNewMethod=false); Standard_EXPORT Handle(GEOM_Object) MakeSketcher (const char* theCommand, diff --git a/src/GEOMImpl/GEOMImpl_IInsertOperations.cxx b/src/GEOMImpl/GEOMImpl_IInsertOperations.cxx index afd889529..4fecfbca9 100644 --- a/src/GEOMImpl/GEOMImpl_IInsertOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IInsertOperations.cxx @@ -218,7 +218,7 @@ Handle(GEOM_Object) GEOMImpl_IInsertOperations::Import if (aFunction->GetDriverGUID() != GEOMImpl_ImportDriver::GetID()) return result; Handle(TCollection_HAsciiString) aHLibName; - if (!IsSupported(Standard_True, theFormatName/*.SubString(1,4)*/, aHLibName)) { + if (!IsSupported(Standard_True, theFormatName.SubString(1,4), aHLibName)) { return result; } TCollection_AsciiString aLibName = aHLibName->String(); @@ -302,7 +302,7 @@ TCollection_AsciiString GEOMImpl_IInsertOperations::ReadValue if (theFileName.IsEmpty() || theFormatName.IsEmpty() || theParameterName.IsEmpty()) return aValue; Handle(TCollection_HAsciiString) aHLibName; - if (!IsSupported(Standard_True, theFormatName/*.SubString(1,4)*/, aHLibName)) { + if (!IsSupported(Standard_True, theFormatName.SubString(1,4), aHLibName)) { return aValue; } TCollection_AsciiString aLibName = aHLibName->String(); diff --git a/src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx b/src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx index df3a87a49..b81e5c7ab 100644 --- a/src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx @@ -28,6 +28,8 @@ #include #include +#include + #include #include @@ -765,69 +767,6 @@ GEOMImpl_IMeasureOperations::ShapeKind GEOMImpl_IMeasureOperations::KindOfShape return aKind; } -//============================================================================= -/*! Get LCS, corresponding to the given shape. - * Origin of the LCS is situated at the shape's center of mass. - * Axes of the LCS are obtained from shape's location or, - * if the shape is a planar face, from position of its plane. - */ -//============================================================================= -gp_Ax3 GEOMImpl_IMeasureOperations::GetPosition (const TopoDS_Shape& theShape) -{ - gp_Ax3 aResult; - - if (theShape.IsNull()) - return aResult; - - // Axes - aResult.Transform(theShape.Location().Transformation()); - if (theShape.ShapeType() == TopAbs_FACE) { - Handle(Geom_Surface) aGS = BRep_Tool::Surface(TopoDS::Face(theShape)); - if (!aGS.IsNull() && aGS->IsKind(STANDARD_TYPE(Geom_Plane))) { - Handle(Geom_Plane) aGPlane = Handle(Geom_Plane)::DownCast(aGS); - gp_Pln aPln = aGPlane->Pln(); - aResult = aPln.Position(); - // In case of reverse orinetation of the face invert the plane normal - // (the face's normal does not mathc the plane's normal in this case) - if(theShape.Orientation() == TopAbs_REVERSED) - { - gp_Dir Vx = aResult.XDirection(); - gp_Dir N = aResult.Direction().Mirrored(Vx); - gp_Pnt P = aResult.Location(); - aResult = gp_Ax3(P, N, Vx); - } - } - } - - // Origin - gp_Pnt aPnt; - - TopAbs_ShapeEnum aShType = theShape.ShapeType(); - - if (aShType == TopAbs_VERTEX) { - aPnt = BRep_Tool::Pnt(TopoDS::Vertex(theShape)); - } - else { - if (aShType == TopAbs_COMPOUND) { - aShType = GEOMImpl_IShapesOperations::GetTypeOfSimplePart(theShape); - } - - GProp_GProps aSystem; - if (aShType == TopAbs_EDGE || aShType == TopAbs_WIRE) - BRepGProp::LinearProperties(theShape, aSystem); - else if (aShType == TopAbs_FACE || aShType == TopAbs_SHELL) - BRepGProp::SurfaceProperties(theShape, aSystem); - else - BRepGProp::VolumeProperties(theShape, aSystem); - - aPnt = aSystem.CentreOfMass(); - } - - aResult.SetLocation(aPnt); - - return aResult; -} - //============================================================================= /*! * GetPosition @@ -861,7 +800,7 @@ void GEOMImpl_IMeasureOperations::GetPosition OCC_CATCH_SIGNALS; #endif - gp_Ax3 anAx3 = GetPosition(aShape); + gp_Ax3 anAx3 = GEOMUtils::GetPosition(aShape); gp_Pnt anOri = anAx3.Location(); gp_Dir aDirZ = anAx3.Direction(); @@ -1227,6 +1166,59 @@ void GEOMImpl_IMeasureOperations::GetBoundingBox SetErrorCode(OK); } +//============================================================================= +/*! + * GetBoundingBox + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IMeasureOperations::GetBoundingBox + (Handle(GEOM_Object) theShape) +{ + SetErrorCode(KO); + + if (theShape.IsNull()) return NULL; + + //Add a new BoundingBox object + Handle(GEOM_Object) aBnd = GetEngine()->AddObject(GetDocID(), GEOM_BOX); + + //Add a new BoundingBox function + Handle(GEOM_Function) aFunction = + aBnd->AddFunction(GEOMImpl_MeasureDriver::GetID(), BND_BOX_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 BoundingBox value + try { +#if OCC_VERSION_LARGE > 0x06010000 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Measure driver failed to compute a bounding box"); + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + GEOM::TPythonDump(aFunction) << aBnd << " = geompy.MakeBoundingBox(" << theShape << ")"; + + SetErrorCode(OK); + return aBnd; +} + //============================================================================= /*! * GetTolerance @@ -1550,6 +1542,36 @@ TCollection_AsciiString GEOMImpl_IMeasureOperations::WhatIs (Handle(GEOM_Object) return Astr; } +//============================================================================= +/*! + * AreCoordsInside + */ +//============================================================================= +std::vector GEOMImpl_IMeasureOperations::AreCoordsInside(Handle(GEOM_Object) theShape, + const std::vector& coords, + double tolerance) +{ + std::vector res; + if (!theShape.IsNull()) { + Handle(GEOM_Function) aRefShape = theShape->GetLastFunction(); + if (!aRefShape.IsNull()) { + TopoDS_Shape aShape = aRefShape->GetValue(); + if (!aShape.IsNull()) { + BRepClass3d_SolidClassifier SC(aShape); + unsigned int nb_points = coords.size()/3; + for (int i = 0; i < nb_points; i++) { + double x = coords[3*i]; + double y = coords[3*i+1]; + double z = coords[3*i+2]; + gp_Pnt aPnt(x, y, z); + SC.Perform(aPnt, tolerance); + res.push_back( ( SC.State() == TopAbs_IN ) || ( SC.State() == TopAbs_ON ) ); + } + } + } + } + return res; +} //======================================================================= //function : CheckSingularCase @@ -1853,38 +1875,6 @@ static bool CheckSingularCase(const TopoDS_Shape& aSh1, } */ - -//============================================================================= -/*! - * AreCoordsInside - */ -//============================================================================= -std::vector GEOMImpl_IMeasureOperations::AreCoordsInside(Handle(GEOM_Object) theShape, - const std::vector& coords, - double tolerance) -{ - std::vector res; - if (!theShape.IsNull()) { - Handle(GEOM_Function) aRefShape = theShape->GetLastFunction(); - if (!aRefShape.IsNull()) { - TopoDS_Shape aShape = aRefShape->GetValue(); - if (!aShape.IsNull()) { - BRepClass3d_SolidClassifier SC(aShape); - unsigned int nb_points = coords.size()/3; - for (int i = 0; i < nb_points; i++) { - double x = coords[3*i]; - double y = coords[3*i+1]; - double z = coords[3*i+2]; - gp_Pnt aPnt(x, y, z); - SC.Perform(aPnt, tolerance); - res.push_back( ( SC.State() == TopAbs_IN ) || ( SC.State() == TopAbs_ON ) ); - } - } - } - } - return res; -} - //============================================================================= /*! * GetMinDistance @@ -1949,7 +1939,7 @@ Standard_Real GEOMImpl_IMeasureOperations::GetMinDistance // additional workaround for bugs 19899, 19908 and 19910 from Mantis gp_Pnt Ptmp1, Ptmp2; double dist = CheckSingularCase(aShape1, aShape2, Ptmp1, Ptmp2); - if(dist>-1.0) { + if (dist > -1.0) { Ptmp1.Coord(X1, Y1, Z1); Ptmp2.Coord(X2, Y2, Z2); SetErrorCode(OK); @@ -1986,6 +1976,84 @@ Standard_Real GEOMImpl_IMeasureOperations::GetMinDistance return MinDist; } +//======================================================================= +/*! + * Get coordinates of closest points of two shapes + */ +//======================================================================= +Standard_Integer GEOMImpl_IMeasureOperations::ClosestPoints (Handle(GEOM_Object) theShape1, + Handle(GEOM_Object) theShape2, + Handle(TColStd_HSequenceOfReal)& theDoubles) +{ + SetErrorCode(KO); + Standard_Integer nbSolutions = 0; + + if (theShape1.IsNull() || theShape2.IsNull()) return nbSolutions; + + Handle(GEOM_Function) aRefShape1 = theShape1->GetLastFunction(); + Handle(GEOM_Function) aRefShape2 = theShape2->GetLastFunction(); + if (aRefShape1.IsNull() || aRefShape2.IsNull()) return nbSolutions; + + TopoDS_Shape aShape1 = aRefShape1->GetValue(); + TopoDS_Shape aShape2 = aRefShape2->GetValue(); + if (aShape1.IsNull() || aShape2.IsNull()) { + SetErrorCode("One of Objects has NULL Shape"); + return nbSolutions; + } + + // Compute the extremities + try { +#if OCC_VERSION_LARGE > 0x06010000 + OCC_CATCH_SIGNALS; +#endif + + // skl 30.06.2008 + // additional workaround for bugs 19899, 19908 and 19910 from Mantis + gp_Pnt P1, P2; + double dist = CheckSingularCase(aShape1, aShape2, P1, P2); + if (dist > -1.0) { + nbSolutions = 1; + + theDoubles->Append(P1.X()); + theDoubles->Append(P1.Y()); + theDoubles->Append(P1.Z()); + theDoubles->Append(P2.X()); + theDoubles->Append(P2.Y()); + theDoubles->Append(P2.Z()); + + SetErrorCode(OK); + return nbSolutions; + } + + BRepExtrema_DistShapeShape dst (aShape1, aShape2); + if (dst.IsDone()) { + nbSolutions = dst.NbSolution(); + if (theDoubles.IsNull()) theDoubles = new TColStd_HSequenceOfReal; + + gp_Pnt P1, P2; + for (int i = 1; i <= nbSolutions; i++) { + P1 = dst.PointOnShape1(i); + P2 = dst.PointOnShape2(i); + + theDoubles->Append(P1.X()); + theDoubles->Append(P1.Y()); + theDoubles->Append(P1.Z()); + theDoubles->Append(P2.X()); + theDoubles->Append(P2.Y()); + theDoubles->Append(P2.Z()); + } + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return nbSolutions; + } + + SetErrorCode(OK); + return nbSolutions; +} + //======================================================================= /*! * Get coordinates of point diff --git a/src/GEOMImpl/GEOMImpl_IMeasureOperations.hxx b/src/GEOMImpl/GEOMImpl_IMeasureOperations.hxx index d84b8743c..1a9071838 100644 --- a/src/GEOMImpl/GEOMImpl_IMeasureOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_IMeasureOperations.hxx @@ -18,7 +18,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #ifndef _GEOMImpl_IMeasureOperations_HXX_ #define _GEOMImpl_IMeasureOperations_HXX_ @@ -118,6 +117,8 @@ class GEOMImpl_IMeasureOperations : public GEOM_IOperations { Standard_Real& Ymin, Standard_Real& Ymax, Standard_Real& Zmin, Standard_Real& Zmax); + Standard_EXPORT Handle(GEOM_Object) GetBoundingBox (Handle(GEOM_Object) theShape); + Standard_EXPORT void GetTolerance (Handle(GEOM_Object) theShape, Standard_Real& FaceMin, Standard_Real& FaceMax, Standard_Real& EdgeMin, Standard_Real& EdgeMax, @@ -143,6 +144,10 @@ class GEOMImpl_IMeasureOperations : public GEOM_IOperations { Standard_Real& X1, Standard_Real& Y1, Standard_Real& Z1, Standard_Real& X2, Standard_Real& Y2, Standard_Real& Z2); + Standard_EXPORT Standard_Integer ClosestPoints (Handle(GEOM_Object) theShape1, + Handle(GEOM_Object) theShape2, + Handle(TColStd_HSequenceOfReal)& theDoubles); + Standard_EXPORT void PointCoordinates (Handle(GEOM_Object) theShape, Standard_Real& theX, Standard_Real& theY, Standard_Real& theZ); @@ -168,9 +173,6 @@ class GEOMImpl_IMeasureOperations : public GEOM_IOperations { Standard_EXPORT Standard_Real MinSurfaceCurvatureByPoint (Handle(GEOM_Object) theSurf, Handle(GEOM_Object) thePoint); - public: - Standard_EXPORT static gp_Ax3 GetPosition (const TopoDS_Shape& theShape); - private: void StructuralDump (const BRepCheck_Analyzer& theAna, const TopoDS_Shape& theShape, diff --git a/src/GEOMImpl/GEOMImpl_IPipeDiffSect.hxx b/src/GEOMImpl/GEOMImpl_IPipeDiffSect.hxx index dbdb52601..393e65a47 100644 --- a/src/GEOMImpl/GEOMImpl_IPipeDiffSect.hxx +++ b/src/GEOMImpl/GEOMImpl_IPipeDiffSect.hxx @@ -18,15 +18,16 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// //NOTE: This is an intreface to a function for the Pipe creation. -// + #ifndef _GEOMImpl_IPIPEDIFFSECT_HXX_ #define _GEOMImpl_IPIPEDIFFSECT_HXX_ #include "GEOM_Function.hxx" +#include + #ifndef _GEOMImpl_IPIPE_HXX_ #include "GEOMImpl_IPipe.hxx" #endif diff --git a/src/GEOMImpl/GEOMImpl_IPipePath.hxx b/src/GEOMImpl/GEOMImpl_IPipePath.hxx index 028ab2f53..7b2ccd40a 100644 --- a/src/GEOMImpl/GEOMImpl_IPipePath.hxx +++ b/src/GEOMImpl/GEOMImpl_IPipePath.hxx @@ -23,6 +23,8 @@ #include "GEOM_Function.hxx" +#include + class GEOMImpl_IPipePath { public: diff --git a/src/GEOMImpl/GEOMImpl_IPipeShellSect.hxx b/src/GEOMImpl/GEOMImpl_IPipeShellSect.hxx index 0b3f35fd4..3061153f0 100644 --- a/src/GEOMImpl/GEOMImpl_IPipeShellSect.hxx +++ b/src/GEOMImpl/GEOMImpl_IPipeShellSect.hxx @@ -15,10 +15,9 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// //NOTE: This is an intreface to a function for the Pipe creation. -// + #ifndef _GEOMImpl_IPIPESHELLSECT_HXX_ #define _GEOMImpl_IPIPESHELLSECT_HXX_ @@ -28,6 +27,8 @@ #include "GEOMImpl_IPipeDiffSect.hxx" #endif +#include + #define PIPEDS_LIST_SUBBASES 6 diff --git a/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx b/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx index 682311302..fd1771a6a 100644 --- a/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx @@ -48,6 +48,8 @@ #include "GEOM_ISubShape.hxx" #include "GEOM_PythonDump.hxx" +#include "GEOMUtils.hxx" + #include "GEOMAlgo_ClsfBox.hxx" #include "GEOMAlgo_ClsfSolid.hxx" #include "GEOMAlgo_CoupleOfShapes.hxx" @@ -141,8 +143,6 @@ #include #include -#define STD_SORT_ALGO 1 - //============================================================================= /*! * constructor: @@ -1023,7 +1023,7 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetGlueShapes } // for stable order of returned entities - GEOMImpl_IShapesOperations::SortShapes(listOnePerSet, Standard_False); + GEOMUtils::SortShapes(listOnePerSet, Standard_False); TopTools_ListIteratorOfListOfShape aListIt (listOnePerSet); for (; aListIt.More(); aListIt.Next()) { @@ -1267,7 +1267,7 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::MakeExplode bool isOldSorting = false; if (theExplodeType == EXPLODE_OLD_INCLUDE_MAIN) isOldSorting = true; - SortShapes(listShape, isOldSorting); + GEOMUtils::SortShapes(listShape, isOldSorting); } TopTools_IndexedMapOfShape anIndices; @@ -1391,7 +1391,7 @@ Handle(TColStd_HSequenceOfInteger) GEOMImpl_IShapesOperations::SubShapeAllIDs bool isOldSorting = false; if (theExplodeType == EXPLODE_OLD_INCLUDE_MAIN) isOldSorting = true; - SortShapes(listShape, isOldSorting); + GEOMUtils::SortShapes(listShape, isOldSorting); } TopTools_IndexedMapOfShape anIndices; @@ -1558,14 +1558,62 @@ Standard_Integer GEOMImpl_IShapesOperations::GetSubShapeIndex (Handle(GEOM_Objec TopTools_IndexedMapOfShape anIndices; TopExp::MapShapes(aMainShape, anIndices); - if (anIndices.Contains(aSubShape)) { +// if (anIndices.Contains(aSubShape)) { +// SetErrorCode(OK); +// return anIndices.FindIndex(aSubShape); +// } + int id = anIndices.FindIndex(aSubShape); + if (id > 0) + { SetErrorCode(OK); - return anIndices.FindIndex(aSubShape); + return id; } - return -1; } + + +//============================================================================= +/*! + * GetSubShapeIndices + */ +//============================================================================= +Handle(TColStd_HSequenceOfInteger) GEOMImpl_IShapesOperations::GetSubShapesIndices (Handle(GEOM_Object) theMainShape, + std::list theSubShapes) +{ + MESSAGE("GEOMImpl_IShapesOperations::GetSubShapesIndices") + SetErrorCode(KO); + + Handle(TColStd_HSequenceOfInteger) aSeq = new TColStd_HSequenceOfInteger; + + TopoDS_Shape aMainShape = theMainShape->GetValue(); + if (aMainShape.IsNull()) + { + MESSAGE("NULL main shape") + return NULL; + } + + TopTools_IndexedMapOfShape anIndices; + TopExp::MapShapes(aMainShape, anIndices); + + std::list::iterator it; + for (it=theSubShapes.begin(); it != theSubShapes.end(); ++it) + { + TopoDS_Shape aSubShape = (*it)->GetValue(); + if (aSubShape.IsNull()) + { + MESSAGE("NULL subshape") + return NULL; + } + int id = anIndices.FindIndex(aSubShape); + aSeq->Append(id); + } + + SetErrorCode(OK); + return aSeq; +} + + //============================================================================= /*! * GetTopologyIndex @@ -2217,7 +2265,7 @@ Handle(TColStd_HSequenceOfInteger) TopoDS_Shape aShape = theShape->GetValue(); // Check presence of triangulation, build if need - if (!CheckTriangulation(aShape)) { + if (!GEOMUtils::CheckTriangulation(aShape)) { SetErrorCode("Cannot build triangulation on the shape"); return aSeqOfIDs; } @@ -2302,7 +2350,7 @@ Handle(TColStd_HSequenceOfInteger) Handle(GEOM_Function) aFunction = GEOM::GetCreatedLast(theShape,theBox)->GetLastFunction(); // Make a Python command - GEOM::TPythonDump(aFunction) + GEOM::TPythonDump(aFunction, /*append=*/true) << "listShapesOnBoxIDs = geompy.GetShapesOnBoxIDs(" << theBox << ", " << theShape << ", " @@ -2384,7 +2432,7 @@ Handle(TColStd_HSequenceOfInteger) TopTools_ListOfShape res; // Check presence of triangulation, build if need - if (!CheckTriangulation(aShape)) { + if (!GEOMUtils::CheckTriangulation(aShape)) { SetErrorCode("Cannot build triangulation on the shape"); return aSeqOfIDs; } @@ -2475,7 +2523,7 @@ Handle(TColStd_HSequenceOfInteger) GEOM::GetCreatedLast(theShape,theCheckShape)->GetLastFunction(); // Make a Python command - GEOM::TPythonDump(aFunction) + GEOM::TPythonDump(aFunction, /*append=*/true) << "listShapesOnBoxIDs = geompy.GetShapesOnShapeIDs(" << theCheckShape << ", " << theShape << ", " @@ -2604,7 +2652,7 @@ Handle(TColStd_HSequenceOfInteger) Handle(TColStd_HSequenceOfInteger) aSeqOfIDs; // Check presence of triangulation, build if need - if (!CheckTriangulation(theShape)) { + if (!GEOMUtils::CheckTriangulation(theShape)) { SetErrorCode("Cannot build triangulation on the shape"); return aSeqOfIDs; } @@ -3321,7 +3369,7 @@ Handle(TColStd_HSequenceOfInteger) GEOMImpl_IShapesOperations::GetShapesOnSphere // Make a Python command GEOM::TPythonDump(aFunction, /*append=*/true) - << "listShapesOnCylinder = geompy.GetShapesOnCylinderIDs" + << "listShapesOnCylinder = geompy.GetShapesOnSphereIDs" << "(" << theShape << ", " << aShapeType << ", " << theCenter << ", " << theRadius << ", " << theState << ")"; @@ -3385,7 +3433,7 @@ Handle(TColStd_HSequenceOfInteger) Handle(TColStd_HSequenceOfInteger) aSeqOfIDs; // Check presence of triangulation, build if need - if (!CheckTriangulation(aShape)) { + if (!GEOMUtils::CheckTriangulation(aShape)) { SetErrorCode("Cannot build triangulation on the shape"); return aSeqOfIDs; } @@ -3776,28 +3824,6 @@ namespace { } } -//================================================================================ -/*! - * \brief Return type of shape for explode. In case of compound it will be a type of sub-shape. - */ -//================================================================================ -TopAbs_ShapeEnum GEOMImpl_IShapesOperations::GetTypeOfSimplePart (const TopoDS_Shape& theShape) -{ - TopAbs_ShapeEnum aType = theShape.ShapeType(); - if (aType == TopAbs_VERTEX) return TopAbs_VERTEX; - else if (aType == TopAbs_EDGE || aType == TopAbs_WIRE) return TopAbs_EDGE; - else if (aType == TopAbs_FACE || aType == TopAbs_SHELL) return TopAbs_FACE; - else if (aType == TopAbs_SOLID || aType == TopAbs_COMPSOLID) return TopAbs_SOLID; - else if (aType == TopAbs_COMPOUND) { - // Only the iType of the first shape in the compound is taken into account - TopoDS_Iterator It (theShape, Standard_False, Standard_False); - if (It.More()) { - return GetTypeOfSimplePart(It.Value()); - } - } - return TopAbs_SHAPE; -} - //============================================================================= /*! * case GetInPlace: @@ -3839,7 +3865,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetInPlace (Handle(GEOM_Object) GProp_GProps aProps; // Find the iType of the aWhat shape - iType = GetTypeOfSimplePart(aWhat); + iType = GEOMUtils::GetTypeOfSimplePart(aWhat); if (iType == TopAbs_SHAPE) { SetErrorCode("Error: An attempt to extract a shape of not supported type."); return NULL; @@ -4041,7 +4067,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetInPlaceOld (Handle(GEOM_Objec return NULL; } */ - iType = GetTypeOfSimplePart(aWhat); + iType = GEOMUtils::GetTypeOfSimplePart(aWhat); if (iType == TopAbs_SHAPE) { SetErrorCode("Error: An attempt to extract a shape of not supported type."); return NULL; @@ -4266,321 +4292,6 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetInPlaceByHistory return aResult; } -//======================================================================= -//function : ShapeToDouble -//purpose : used by CompareShapes::operator() -//======================================================================= -std::pair ShapeToDouble (const TopoDS_Shape& S, bool isOldSorting) -{ - // Computing of CentreOfMass - gp_Pnt GPoint; - double Len; - - if (S.ShapeType() == TopAbs_VERTEX) { - GPoint = BRep_Tool::Pnt(TopoDS::Vertex(S)); - Len = (double)S.Orientation(); - } - else { - GProp_GProps GPr; - // BEGIN: fix for Mantis issue 0020842 - if (isOldSorting) { - BRepGProp::LinearProperties(S, GPr); - } - else { - if (S.ShapeType() == TopAbs_EDGE || S.ShapeType() == TopAbs_WIRE) { - BRepGProp::LinearProperties(S, GPr); - } - else if (S.ShapeType() == TopAbs_FACE || S.ShapeType() == TopAbs_SHELL) { - BRepGProp::SurfaceProperties(S, GPr); - } - else { - BRepGProp::VolumeProperties(S, GPr); - } - } - // END: fix for Mantis issue 0020842 - GPoint = GPr.CentreOfMass(); - Len = GPr.Mass(); - } - - double dMidXYZ = GPoint.X() * 999.0 + GPoint.Y() * 99.0 + GPoint.Z() * 0.9; - return std::make_pair(dMidXYZ, Len); -} - -//======================================================================= -//function : CompareShapes::operator() -//purpose : used by std::sort(), called from SortShapes() -//======================================================================= -bool GEOMImpl_IShapesOperations::CompareShapes::operator()(const TopoDS_Shape& theShape1, - const TopoDS_Shape& theShape2) -{ - if (!myMap.IsBound(theShape1)) { - myMap.Bind(theShape1, ShapeToDouble(theShape1, myIsOldSorting)); - } - - if (!myMap.IsBound(theShape2)) { - myMap.Bind(theShape2, ShapeToDouble(theShape2, myIsOldSorting)); - } - - std::pair val1 = myMap.Find(theShape1); - std::pair val2 = myMap.Find(theShape2); - - double tol = Precision::Confusion(); - bool exchange = Standard_False; - - double dMidXYZ = val1.first - val2.first; - if (dMidXYZ >= tol) { - exchange = Standard_True; - } - else if (Abs(dMidXYZ) < tol) { - double dLength = val1.second - val2.second; - if (dLength >= tol) { - exchange = Standard_True; - } - else if (Abs(dLength) < tol && theShape1.ShapeType() <= TopAbs_FACE) { - // PAL17233 - // equal values possible on shapes such as two halves of a sphere and - // a membrane inside the sphere - Bnd_Box box1,box2; - BRepBndLib::Add(theShape1, box1); - if (!box1.IsVoid()) { - BRepBndLib::Add(theShape2, box2); - Standard_Real dSquareExtent = box1.SquareExtent() - box2.SquareExtent(); - if (dSquareExtent >= tol) { - exchange = Standard_True; - } - else if (Abs(dSquareExtent) < tol) { - Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax, val1, val2; - box1.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax); - val1 = (aXmin+aXmax)*999.0 + (aYmin+aYmax)*99.0 + (aZmin+aZmax)*0.9; - box2.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax); - val2 = (aXmin+aXmax)*999.0 + (aYmin+aYmax)*99.0 + (aZmin+aZmax)*0.9; - if ((val1 - val2) >= tol) { - exchange = Standard_True; - } - } - } - } - } - - //return val1 < val2; - return !exchange; -} - -//======================================================================= -//function : SortShapes -//purpose : -//======================================================================= -void GEOMImpl_IShapesOperations::SortShapes(TopTools_ListOfShape& SL, - const Standard_Boolean isOldSorting) -{ -#ifdef STD_SORT_ALGO - std::vector aShapesVec; - aShapesVec.reserve(SL.Extent()); - - TopTools_ListIteratorOfListOfShape it (SL); - for (; it.More(); it.Next()) { - aShapesVec.push_back(it.Value()); - } - SL.Clear(); - - CompareShapes shComp (isOldSorting); - std::stable_sort(aShapesVec.begin(), aShapesVec.end(), shComp); - //std::sort(aShapesVec.begin(), aShapesVec.end(), shComp); - - std::vector::const_iterator anIter = aShapesVec.begin(); - for (; anIter != aShapesVec.end(); ++anIter) { - SL.Append(*anIter); - } -#else - // old implementation - 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 { - // BEGIN: fix for Mantis issue 0020842 - if (isOldSorting) { - BRepGProp::LinearProperties (S, GPr); - } - else { - if (S.ShapeType() == TopAbs_EDGE || S.ShapeType() == TopAbs_WIRE) { - BRepGProp::LinearProperties (S, GPr); - } - else if (S.ShapeType() == TopAbs_FACE || S.ShapeType() == TopAbs_SHELL) { - BRepGProp::SurfaceProperties(S, GPr); - } - else { - BRepGProp::VolumeProperties(S, GPr); - } - } - // END: fix for Mantis issue 0020842 - GPoint = GPr.CentreOfMass(); - Length.SetValue(Index, GPr.Mass()); - } - MidXYZ.SetValue(Index, GPoint.X()*999.0 + GPoint.Y()*99.0 + GPoint.Z()*0.9); - //cout << Index << " L: " << Length(Index) << "CG: " << MidXYZ(Index) << endl; - } - - // Sorting - Standard_Integer aTemp; - Standard_Boolean exchange, Sort = Standard_True; - Standard_Real tol = Precision::Confusion(); - while (Sort) - { - Sort = Standard_False; - for (Index=1; Index < MaxShapes; Index++) - { - exchange = Standard_False; - Standard_Real dMidXYZ = MidXYZ(OrderInd(Index)) - MidXYZ(OrderInd(Index+1)); - Standard_Real dLength = Length(OrderInd(Index)) - Length(OrderInd(Index+1)); - if ( dMidXYZ >= tol ) { -// cout << "MidXYZ: " << MidXYZ(OrderInd(Index))<< " > " <= tol ) { -// cout << "Length: " << Length(OrderInd(Index))<< " > " <= tol ) { -// cout << "SquareExtent: " << box1.SquareExtent()<<" > "< val2; - if ((val1 - val2) >= tol) { - exchange = Standard_True; - } - //cout << "box: " << val1<<" > "<GetLastFunction(); // Make a Python command - GEOM::TPythonDump(aFunction) + GEOM::TPythonDump(aFunction, /*append=*/true) << "listSameIDs = geompy.GetSameIDs(" << theShapeWhere << ", " << theShapeWhat << ")"; diff --git a/src/GEOMImpl/GEOMImpl_IShapesOperations.hxx b/src/GEOMImpl/GEOMImpl_IShapesOperations.hxx index 21885888a..745142c8c 100644 --- a/src/GEOMImpl/GEOMImpl_IShapesOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_IShapesOperations.hxx @@ -51,11 +51,6 @@ class GEOM_Engine; class Handle(GEOM_Object); class Handle(TColStd_HArray1OfInteger); -inline Standard_Boolean IsEqual (const TopoDS_Shape& S1, const TopoDS_Shape& S2) -{ - return S1.IsSame(S2); -} - class GEOMImpl_IShapesOperations : public GEOM_IOperations { public: @@ -142,6 +137,9 @@ class GEOMImpl_IShapesOperations : public GEOM_IOperations Standard_EXPORT Standard_Integer GetSubShapeIndex (Handle(GEOM_Object) theMainShape, Handle(GEOM_Object) theSubShape); + + Standard_EXPORT Handle(TColStd_HSequenceOfInteger) GetSubShapesIndices (Handle(GEOM_Object) theMainShape, + std::list theSubShapes); Standard_EXPORT Standard_Integer GetTopologyIndex (Handle(GEOM_Object) theMainShape, Handle(GEOM_Object) theSubShape); @@ -375,50 +373,6 @@ class GEOMImpl_IShapesOperations : public GEOM_IOperations const Standard_Integer theShapeType, GEOMAlgo_State theState); - public: - /*! - * \brief Sort shapes in the list by their coordinates. - * \param SL The list of shapes to sort. - */ - struct CompareShapes : public std::binary_function - { - CompareShapes (bool isOldSorting) - : myIsOldSorting(isOldSorting) {} - - bool operator()(const TopoDS_Shape& lhs, const TopoDS_Shape& rhs); - - typedef NCollection_DataMap > NCollection_DataMapOfShapeDouble; - NCollection_DataMapOfShapeDouble myMap; - bool myIsOldSorting; - }; - - Standard_EXPORT static void SortShapes (TopTools_ListOfShape& SL, - const Standard_Boolean isOldSorting = Standard_True); - - /*! - * \brief Convert TopoDS_COMPSOLID to TopoDS_COMPOUND. - * - * If the argument shape is not of type TopoDS_COMPSOLID, this method returns it as is. - * - * \param theCompsolid The compsolid to be converted. - * \retval TopoDS_Shape Returns the resulting compound. - */ - Standard_EXPORT static TopoDS_Shape CompsolidToCompound (const TopoDS_Shape& theCompsolid); - - /*! - * \brief Build a triangulation on \a theShape if it is absent. - * \param theShape The shape to check/build triangulation on. - * \retval bool Returns false if the shape has no faces, i.e. impossible to build triangulation. - */ - Standard_EXPORT static bool CheckTriangulation (const TopoDS_Shape& theShape); - - /*! - * \brief Return type of shape for explode. In case of compound it will be a type of its first sub shape. - * \param theShape The shape to get type of. - * \retval TopAbs_ShapeEnum Return type of shape for explode. - */ - Standard_EXPORT static TopAbs_ShapeEnum GetTypeOfSimplePart (const TopoDS_Shape& theShape); - private: Handle(GEOM_Object) MakeShape (std::list theShapes, const Standard_Integer theObjectType, diff --git a/src/GEOMImpl/GEOMImpl_ISpline.hxx b/src/GEOMImpl/GEOMImpl_ISpline.hxx index b20a7e6dc..e7f8b076a 100644 --- a/src/GEOMImpl/GEOMImpl_ISpline.hxx +++ b/src/GEOMImpl/GEOMImpl_ISpline.hxx @@ -18,53 +18,84 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// // NOTE: This is an interface to a function for the Spline creation. -#include "GEOM_Function.hxx" -#include +#include -#define SPL_ARG_LENG 1 -#define SPL_ARG_CLOS 2 -#define SPL_ARG_REOR 3 -#define SPL_ARG_LAST 2 - -#define SPL_CONSTRUCTOR 4 -#define SPL_ARG_ARRAY 5 +#include +#include class GEOMImpl_ISpline { public: + enum { + ARG_POINTS = 1, + ARG_CLOSED = 2, + ARG_REORDER = 3, + CONSTRUCTOR = 4, + ARG_ARRAY = 5, + ARG_VEC_1 = 6, + ARG_VEC_2 = 7 + }; + GEOMImpl_ISpline(Handle(GEOM_Function) theFunction): _func(theFunction) {} - void SetLength(int theLen) { _func->SetInteger(SPL_ARG_LENG, theLen); } + // Set - void SetIsClosed(bool theIsClosed) { _func->SetInteger(SPL_ARG_CLOS, (int)theIsClosed); } + void SetPoints (const Handle(TColStd_HSequenceOfTransient)& thePoints) + { _func->SetReferenceList(ARG_POINTS, thePoints); } - void SetDoReordering(bool theDoReordering) { _func->SetInteger(SPL_ARG_REOR, (int)theDoReordering); } + void SetIsClosed (bool theIsClosed) { _func->SetInteger(ARG_CLOSED, (int)theIsClosed); } + void SetDoReordering (bool theDoReordering) { _func->SetInteger(ARG_REORDER, (int)theDoReordering); } - void SetPoint(int theId, Handle(GEOM_Function) theP) { _func->SetReference(SPL_ARG_LAST + theId, theP); } + void SetConstructorType (int theConstructor) { _func->SetInteger(CONSTRUCTOR, theConstructor); } - int GetLength() { return _func->GetInteger(SPL_ARG_LENG); } + void SetCoordinates (const Handle(TColStd_HArray1OfReal)& theValue) + { _func->SetRealArray(ARG_ARRAY, theValue); } - bool GetIsClosed() { return (bool)_func->GetInteger(SPL_ARG_CLOS); } + void SetFirstVector (Handle(GEOM_Function) theVec) { _func->SetReference(ARG_VEC_1, theVec); } + void SetLastVector (Handle(GEOM_Function) theVec) { _func->SetReference(ARG_VEC_2, theVec); } - bool GetDoReordering() { return (bool)_func->GetInteger(SPL_ARG_REOR); } + // Get - Handle(GEOM_Function) GetPoint(int theId) { return _func->GetReference(SPL_ARG_LAST + theId); } + Handle(TColStd_HSequenceOfTransient) GetPoints() { return _func->GetReferenceList(ARG_POINTS); } + bool GetIsClosed() { return (bool)_func->GetInteger(ARG_CLOSED); } + bool GetDoReordering() { return (bool)_func->GetInteger(ARG_REORDER); } - void SetConstructorType(int theConstructor) {_func->SetInteger(SPL_CONSTRUCTOR,theConstructor); } + int GetConstructorType() { return _func->GetInteger(CONSTRUCTOR); } - int GetConstructorType() { return _func->GetInteger(SPL_CONSTRUCTOR); } + Handle(TColStd_HArray1OfReal) GetCoordinates() { return _func->GetRealArray(ARG_ARRAY); } + Handle(GEOM_Function) GetFirstVector () { return _func->GetReference(ARG_VEC_1); } + Handle(GEOM_Function) GetLastVector () { return _func->GetReference(ARG_VEC_2); } + + /* Old implementation (Salome 6.6.0 and earlier) +#define SPL_ARG_LENG 1 +#define SPL_ARG_CLOS 2 +#define SPL_ARG_REOR 3 +#define SPL_ARG_LAST 2 + +#define SPL_CONSTRUCTOR 4 +#define SPL_ARG_ARRAY 5 + + void SetLength(int theLen) { _func->SetInteger(SPL_ARG_LENG, theLen); } + void SetIsClosed(bool theIsClosed) { _func->SetInteger(SPL_ARG_CLOS, (int)theIsClosed); } + void SetDoReordering(bool theDoReordering) { _func->SetInteger(SPL_ARG_REOR, (int)theDoReordering); } + void SetConstructorType(int theConstructor) {_func->SetInteger(SPL_CONSTRUCTOR,theConstructor); } + void SetPoint(int theId, Handle(GEOM_Function) theP) { _func->SetReference(SPL_ARG_LAST + theId, theP); } void SetCoordinates(const Handle(TColStd_HArray1OfReal)& theValue) { _func->SetRealArray(SPL_ARG_ARRAY, theValue); } - + int GetLength() { return _func->GetInteger(SPL_ARG_LENG); } + bool GetIsClosed() { return (bool)_func->GetInteger(SPL_ARG_CLOS); } + bool GetDoReordering() { return (bool)_func->GetInteger(SPL_ARG_REOR); } + int GetConstructorType() { return _func->GetInteger(SPL_CONSTRUCTOR); } + Handle(GEOM_Function) GetPoint(int theId) { return _func->GetReference(SPL_ARG_LAST + theId); } Handle(TColStd_HArray1OfReal) GetCoordinates() { return _func->GetRealArray(SPL_ARG_ARRAY); } + */ private: diff --git a/src/GEOMImpl/GEOMImpl_ITransformOperations.cxx b/src/GEOMImpl/GEOMImpl_ITransformOperations.cxx index 07098c561..c296d9c58 100644 --- a/src/GEOMImpl/GEOMImpl_ITransformOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_ITransformOperations.cxx @@ -18,7 +18,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #include @@ -143,7 +142,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateTwoPoints } //Make a Python command - GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.TranslateTwoPoints(" + GEOM::TPythonDump(aFunction) << "geompy.TranslateTwoPoints(" << theObject << ", " << thePoint1 << ", " << thePoint2 << ")"; SetErrorCode(OK); @@ -362,7 +361,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateVector } //Make a Python command - GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.TranslateVector(" + GEOM::TPythonDump(aFunction) << "geompy.TranslateVector(" << theObject << ", " << theVector << ")"; SetErrorCode(OK); @@ -500,7 +499,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::Translate1D { SetErrorCode(KO); - if (theObject.IsNull() || theVector.IsNull()) return NULL; + 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 @@ -515,9 +514,10 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::Translate1D //Check if the function is set correctly if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL; - GEOMImpl_ITranslate aTI(aFunction); - aTI.SetVector(theVector->GetLastFunction()); + GEOMImpl_ITranslate aTI (aFunction); aTI.SetOriginal(aLastFunction); + if (!theVector.IsNull()) + aTI.SetVector(theVector->GetLastFunction()); aTI.SetStep1(theStep); aTI.SetNbIter1(theNbTimes); @@ -560,7 +560,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::Translate2D (Handle(GEOM_Obje { SetErrorCode(KO); - if (theObject.IsNull() || theVector.IsNull() || theVector2.IsNull()) return NULL; + 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 @@ -576,11 +576,13 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::Translate2D (Handle(GEOM_Obje if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL; GEOMImpl_ITranslate aTI (aFunction); - aTI.SetVector(theVector->GetLastFunction()); - aTI.SetVector2(theVector2->GetLastFunction()); aTI.SetOriginal(aLastFunction); + if (!theVector.IsNull()) + aTI.SetVector(theVector->GetLastFunction()); aTI.SetStep1(theStep1); aTI.SetNbIter1(theNbTimes1); + if (!theVector2.IsNull()) + aTI.SetVector2(theVector2->GetLastFunction()); aTI.SetStep2(theStep2); aTI.SetNbIter2(theNbTimes2); @@ -799,7 +801,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPlane } //Make a Python command - GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.MirrorPlane(" + GEOM::TPythonDump(aFunction) << "geompy.MirrorByPlane(" << theObject << ", " << thePlane << ")"; SetErrorCode(OK); @@ -906,7 +908,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPoint } //Make a Python command - GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.MirrorPoint(" + GEOM::TPythonDump(aFunction) << "geompy.MirrorByPoint(" << theObject << ", " << thePoint << ")"; SetErrorCode(OK); @@ -1013,7 +1015,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorAxis } //Make a Python command - GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.MirrorAxis(" + GEOM::TPythonDump(aFunction) << "geompy.MirrorByAxis(" << theObject << ", " << theAxis << ")"; SetErrorCode(OK); @@ -1118,7 +1120,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::OffsetShape } //Make a Python command - GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.OffsetShape(" + GEOM::TPythonDump(aFunction) << "geompy.Offset(" << theObject << ", " << theOffset << ")"; SetErrorCode(OK); @@ -1285,7 +1287,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShape } //Make a Python command - GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.ScaleShape(" + GEOM::TPythonDump(aFunction) << "geompy.Scale(" << theObject << ", " << thePoint << ", " << theFactor << ")"; SetErrorCode(OK); @@ -1426,7 +1428,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShapeAlongAxes (Handle(G return aCopy; } - GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.ScaleShapeAlongAxes(" + GEOM::TPythonDump(aFunction) << "geompy.ScaleAlongAxes(" << theObject << ", " << thePoint << ", " << theFactorX << ", " << theFactorY << ", " << theFactorZ << ")"; return theObject; @@ -1482,7 +1484,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionShape } //Make a Python command - GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.PositionShape(" + GEOM::TPythonDump(aFunction) << "geompy.Position(" << theObject << ", " << theStartLCS << ", " << theEndLCS << ")"; SetErrorCode(OK); @@ -1604,13 +1606,13 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionAlongPath //Make a Python command if (theCopy) { - GEOM::TPythonDump(aFunction) << aCopy << " = geompy.PositionAlongPath(" + GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakePositionAlongPath(" << theObject << ", " << thePath << ", " << theDistance << ", " << theCopy << ", " << theReverse << ")"; SetErrorCode(OK); return aCopy; } - GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.PositionAlongPath(" + GEOM::TPythonDump(aFunction) << "geompy.PositionAlongPath(" << theObject << ", " << thePath << ", " << theDistance << ", " << theCopy << ", " << theReverse << ")"; SetErrorCode(OK); @@ -1675,10 +1677,12 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate (Handle(GEOM_Object) t //============================================================================= /*! - * Rotate + * RotateCopy */ //============================================================================= -Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateCopy (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theAxis, double theAngle) +Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateCopy (Handle(GEOM_Object) theObject, + Handle(GEOM_Object) theAxis, + double theAngle) { SetErrorCode(KO); @@ -1728,7 +1732,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateCopy (Handle(GEOM_Objec //============================================================================= /*! - * Rotate1D + * Rotate1D (for MultiRotate1DNbTimes) */ //============================================================================= Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate1D (Handle(GEOM_Object) theObject, @@ -1737,7 +1741,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate1D (Handle(GEOM_Object) { SetErrorCode(KO); - if (theObject.IsNull() || theAxis.IsNull()) return NULL; + 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 rotated @@ -1754,7 +1758,8 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate1D (Handle(GEOM_Object) GEOMImpl_IRotate aRI(aFunction); aRI.SetOriginal(aLastFunction); - aRI.SetAxis(theAxis->GetLastFunction()); + if (!theAxis.IsNull()) + aRI.SetAxis(theAxis->GetLastFunction()); aRI.SetNbIter1(theNbTimes); //Compute the translation @@ -1774,7 +1779,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate1D (Handle(GEOM_Object) } //Make a Python command - GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MultiRotate1D(" + GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MultiRotate1DNbTimes(" << theObject << ", " << theAxis << ", " << theNbTimes << ")"; SetErrorCode(OK); @@ -1783,22 +1788,148 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate1D (Handle(GEOM_Object) //============================================================================= /*! - * Rotate2D + * Rotate1D (for MultiRotate1DByStep) + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate1D (Handle(GEOM_Object) theObject, + Handle(GEOM_Object) theAxis, + double theAngleStep, + Standard_Integer theNbSteps) +{ + 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 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_STEP); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL; + + //Convert angle into degrees + double anAngleStep = theAngleStep * 180. / M_PI; + + GEOMImpl_IRotate aRI (aFunction); + aRI.SetOriginal(aLastFunction); + if (!theAxis.IsNull()) + aRI.SetAxis(theAxis->GetLastFunction()); + aRI.SetAngle(anAngleStep); + aRI.SetNbIter1(theNbSteps); + + //Compute the translation + try { +#if OCC_VERSION_LARGE > 0x06010000 + OCC_CATCH_SIGNALS; +#endif + 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 + GEOM::TPythonDump(aFunction) + << aCopy << " = geompy.MultiRotate1DByStep(" << theObject << ", " + << theAxis << ", " << anAngleStep << "*math.pi/180.0, " << theNbSteps << ")"; + + SetErrorCode(OK); + return aCopy; +} + +//============================================================================= +/*! + * Rotate2D (for MultiRotate2DNbTimes) */ //============================================================================= Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate2D (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theAxis, - double theAngle, + Standard_Integer theNbObjects, + double theRadialStep, + Standard_Integer theNbSteps) +{ + 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 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; + + double anAngle = 360. / (double)theNbObjects; + + GEOMImpl_IRotate aRI (aFunction); + aRI.SetOriginal(aLastFunction); + if (!theAxis.IsNull()) + aRI.SetAxis(theAxis->GetLastFunction()); + aRI.SetAngle(anAngle); + aRI.SetNbIter1(theNbObjects); + aRI.SetStep(theRadialStep); + aRI.SetNbIter2(theNbSteps); + + //Compute the translation + try { +#if OCC_VERSION_LARGE > 0x06010000 + OCC_CATCH_SIGNALS; +#endif + 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 + GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MultiRotate2DNbTimes(" + << theObject << ", " << theAxis << ", " << theNbObjects + << ", " << theRadialStep << ", " << theNbSteps << ")"; + + SetErrorCode(OK); + return aCopy; +} + +//============================================================================= +/*! + * Rotate2D (for MultiRotate2DByStep) + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate2D (Handle(GEOM_Object) theObject, + Handle(GEOM_Object) theAxis, + double theAngleStep, Standard_Integer theNbTimes1, double theStep, Standard_Integer theNbTimes2) { SetErrorCode(KO); - if (theObject.IsNull() || theAxis.IsNull()) return NULL; + 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 rotated + 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()); @@ -1807,16 +1938,20 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate2D (Handle(GEOM_Object) aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_2D); if (aFunction.IsNull()) return NULL; - //Check if the function is set correctly + //Check if the function is set correctly if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL; - GEOMImpl_IRotate aRI(aFunction); - aRI.SetAxis(theAxis->GetLastFunction()); + //Convert angle into degrees + double anAngleStep = theAngleStep * 180. / M_PI; + + GEOMImpl_IRotate aRI (aFunction); aRI.SetOriginal(aLastFunction); + if (!theAxis.IsNull()) + aRI.SetAxis(theAxis->GetLastFunction()); + aRI.SetAngle(anAngleStep); aRI.SetNbIter1(theNbTimes1); - aRI.SetNbIter2(theNbTimes2); - aRI.SetAngle(theAngle); aRI.SetStep(theStep); + aRI.SetNbIter2(theNbTimes2); //Compute the translation try { @@ -1835,9 +1970,10 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate2D (Handle(GEOM_Object) } //Make a Python command - GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MultiRotate2D(" - << theObject << ", " << theAxis << ", " << theAngle << ", " - << theNbTimes1 << ", " << theStep << ", " << theNbTimes2 << ")"; + GEOM::TPythonDump(aFunction) + << aCopy << " = geompy.MultiRotate2DByStep(" << theObject << ", " + << theAxis << ", " << anAngleStep << "*math.pi/180.0, " + << theNbTimes1 << ", " << theStep << ", " << theNbTimes2 << ")"; SetErrorCode(OK); return aCopy; @@ -1858,7 +1994,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateThreePoints (Handle(GEO if (theObject.IsNull() || theCentPoint.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 rotated + 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) aCPF = theCentPoint->GetLastFunction(); @@ -1897,7 +2033,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateThreePoints (Handle(GEO } //Make a Python command - GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.RotateThreePoints(" << theObject + GEOM::TPythonDump(aFunction) << "geompy.RotateThreePoints(" << theObject << ", " << theCentPoint << ", "< #include #include #include + #include -#include + +#include #include #include @@ -109,7 +110,7 @@ Standard_Integer GEOMImpl_MarkerDriver::Execute(TFunction_Logbook& log) const } else if (aType == MARKER_SHAPE) { Handle(GEOM_Function) aRefShape = aPI.GetShape(); TopoDS_Shape aSh = aRefShape->GetValue(); - gp_Ax3 anAx3 = GEOMImpl_IMeasureOperations::GetPosition(aSh); + gp_Ax3 anAx3 = GEOMUtils::GetPosition(aSh); gp_Pln aPln (anAx3); double aTrimSize = 100.0; diff --git a/src/GEOMImpl/GEOMImpl_MeasureDriver.cxx b/src/GEOMImpl/GEOMImpl_MeasureDriver.cxx index 5e014b4eb..33ead5986 100644 --- a/src/GEOMImpl/GEOMImpl_MeasureDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_MeasureDriver.cxx @@ -18,20 +18,24 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #include #include #include -#include #include + #include +#include + #include +#include #include -#include +#include #include +#include +#include #include #include @@ -54,6 +58,7 @@ #include #include #include +#include //======================================================================= //function : GetID @@ -92,14 +97,47 @@ Standard_Integer GEOMImpl_MeasureDriver::Execute(TFunction_Logbook& log) const { Handle(GEOM_Function) aRefBase = aCI.GetBase(); TopoDS_Shape aShapeBase = aRefBase->GetValue(); - if (aShapeBase.IsNull()) { + if (aShapeBase.IsNull()) Standard_NullObject::Raise("Shape for centre of mass calculation is null"); - } - gp_Ax3 aPos = GEOMImpl_IMeasureOperations::GetPosition(aShapeBase); + gp_Ax3 aPos = GEOMUtils::GetPosition(aShapeBase); gp_Pnt aCenterMass = aPos.Location(); aShape = BRepBuilderAPI_MakeVertex(aCenterMass).Shape(); } + else if (aType == BND_BOX_MEASURE) + { + Handle(GEOM_Function) aRefBase = aCI.GetBase(); + TopoDS_Shape aShapeBase = aRefBase->GetValue(); + if (aShapeBase.IsNull()) + Standard_NullObject::Raise("Shape for bounding box calculation is null"); + + BRepBuilderAPI_Copy aCopyTool (aShapeBase); + if (!aCopyTool.IsDone()) + Standard_NullObject::Raise("Shape for bounding box calculation is bad"); + + aShapeBase = aCopyTool.Shape(); + + // remove triangulation to obtain more exact boundaries + BRepTools::Clean(aShapeBase); + + Bnd_Box B; + BRepBndLib::Add(aShapeBase, B); + + Standard_Real Xmin, Ymin, Zmin, Xmax, Ymax, Zmax; + B.Get(Xmin, Ymin, Zmin, Xmax, Ymax, Zmax); + + if (Xmax - Xmin < Precision::Confusion()) Xmax += Precision::Confusion(); + if (Ymax - Ymin < Precision::Confusion()) Ymax += Precision::Confusion(); + if (Zmax - Zmin < Precision::Confusion()) Zmax += Precision::Confusion(); + + gp_Pnt P1 (Xmin, Ymin, Zmin); + gp_Pnt P2 (Xmax, Ymax, Zmax); + + BRepPrimAPI_MakeBox MB (P1, P2); + MB.Build(); + if (!MB.IsDone()) StdFail_NotDone::Raise("Bounding box cannot be computed from the given shape"); + aShape = MB.Shape(); + } else if (aType == VERTEX_BY_INDEX) { Handle(GEOM_Function) aRefBase = aCI.GetBase(); @@ -189,7 +227,7 @@ Standard_Integer GEOMImpl_MeasureDriver::Execute(TFunction_Logbook& log) const } else { - gp_Ax3 aPos = GEOMImpl_IMeasureOperations::GetPosition(aFace); + gp_Ax3 aPos = GEOMUtils::GetPosition(aFace); p1 = aPos.Location(); } diff --git a/src/GEOMImpl/GEOMImpl_PipeDriver.cxx b/src/GEOMImpl/GEOMImpl_PipeDriver.cxx index 400c2a03c..9812da16a 100644 --- a/src/GEOMImpl/GEOMImpl_PipeDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_PipeDriver.cxx @@ -19,11 +19,8 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -#include - #include -#include #include #include #include @@ -31,8 +28,11 @@ #include #include #include + #include +#include + #include #include #include @@ -97,6 +97,13 @@ #include "utilities.h" +////////////////////////////////////////////////////////////////////////// +// Uncomment below macro to perform gluing in the end of MakePipe operation +// as fix of issue 0020207. +////////////////////////////////////////////////////////////////////////// +//#define GLUE_0020207 + + //======================================================================= //function : GetID //purpose : @@ -2477,6 +2484,8 @@ Standard_Integer GEOMImpl_PipeDriver::Execute (TFunction_Logbook& log) const } // Glue (for bug 0020207) + // No gluing is needed as the bug 0020207 is fixed in OCCT. +#ifdef GLUE_0020207 TopExp_Explorer anExpV (aShape, TopAbs_VERTEX); if (anExpV.More()) { Standard_Real aVertMaxTol = -RealLast(); @@ -2490,8 +2499,9 @@ Standard_Integer GEOMImpl_PipeDriver::Execute (TFunction_Logbook& log) const aShape = GEOMImpl_GlueDriver::GlueFaces(aShape, aVertMaxTol, Standard_True); //aShape = GEOMImpl_GlueDriver::GlueFaces(aShape, Precision::Confusion(), Standard_True); } +#endif - TopoDS_Shape aRes = GEOMImpl_IShapesOperations::CompsolidToCompound(aShape); + TopoDS_Shape aRes = GEOMUtils::CompsolidToCompound(aShape); aFunction->SetValue(aRes); log.SetTouched(Label()); diff --git a/src/GEOMImpl/GEOMImpl_PipeTShapeDriver.cxx b/src/GEOMImpl/GEOMImpl_PipeTShapeDriver.cxx index 025042282..f28ff1f27 100644 --- a/src/GEOMImpl/GEOMImpl_PipeTShapeDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_PipeTShapeDriver.cxx @@ -15,20 +15,20 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include #include + #include #include - #include + #include +#include + +#include -#include -#include "GEOMAlgo_FinderShapeOn1.hxx" -#include "GEOMAlgo_FinderShapeOn2.hxx" +#include +#include #include #include @@ -106,7 +106,7 @@ GEOMImpl_PipeTShapeDriver::GetShapesOnBoxIDs(const TopoDS_Shape& aBox, Handle(TColStd_HSequenceOfInteger) aSeqOfIDs; // Check presence of triangulation, build if need - if (!GEOMImpl_IShapesOperations::CheckTriangulation(aShape)) { + if (!GEOMUtils::CheckTriangulation(aShape)) { StdFail_NotDone::Raise("Cannot build triangulation on the shape"); return aSeqOfIDs; } @@ -179,7 +179,7 @@ Handle(TColStd_HSequenceOfInteger) Handle(TColStd_HSequenceOfInteger) aSeqOfIDs; // Check presence of triangulation, build if need - if (!GEOMImpl_IShapesOperations::CheckTriangulation(theShape)) { + if (!GEOMUtils::CheckTriangulation(theShape)) { StdFail_NotDone::Raise("Cannot build triangulation on the shape"); return aSeqOfIDs; } diff --git a/src/GEOMImpl/GEOMImpl_PlaneDriver.cxx b/src/GEOMImpl/GEOMImpl_PlaneDriver.cxx index e1968567b..8fc83e24e 100644 --- a/src/GEOMImpl/GEOMImpl_PlaneDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_PlaneDriver.cxx @@ -18,7 +18,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #include @@ -27,7 +26,7 @@ #include #include -#include +#include #include @@ -142,7 +141,7 @@ Standard_Integer GEOMImpl_PlaneDriver::Execute(TFunction_Logbook& log) const // Standard_TypeMismatch::Raise("Plane creation aborted: non-planar face given as argument"); //} //aShape = BRepBuilderAPI_MakeFace(aGS, -aSize, +aSize, -aSize, +aSize).Shape(); - gp_Ax3 anAx3 = GEOMImpl_IMeasureOperations::GetPosition(aRefShape); + gp_Ax3 anAx3 = GEOMUtils::GetPosition(aRefShape); gp_Pln aPln (anAx3); aShape = BRepBuilderAPI_MakeFace(aPln, -aSize, +aSize, -aSize, +aSize).Shape(); } @@ -223,7 +222,7 @@ Standard_Integer GEOMImpl_PlaneDriver::Execute(TFunction_Logbook& log) const TopoDS_Shape aRefShape = aRef->GetValue(); if (aRefShape.ShapeType() != TopAbs_FACE) return 0; - anAx3 = GEOMImpl_IMeasureOperations::GetPosition(aRefShape); + anAx3 = GEOMUtils::GetPosition(aRefShape); } if ( anOrientation == 2) diff --git a/src/GEOMImpl/GEOMImpl_PointDriver.cxx b/src/GEOMImpl/GEOMImpl_PointDriver.cxx index 9fa9cf9c0..832fdc15c 100644 --- a/src/GEOMImpl/GEOMImpl_PointDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_PointDriver.cxx @@ -43,6 +43,7 @@ #include #include #include +#include #include #include @@ -142,8 +143,27 @@ Standard_Integer GEOMImpl_PointDriver::Execute(TFunction_Logbook& log) const } 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); + if ( !aCurve.IsNull() ) { + aP = aFP + (aLP - aFP) * aPI.GetParameter(); + aPnt = aCurve->Value(aP); + } + else { + // null curve, e.g. degenerated edge + TopoDS_Iterator It(aRefShape, Standard_False, Standard_False); + TopoDS_Vertex aVertex; + if ( It.More() ) { + TopoDS_Shape aShape = It.Value(); + if ( !aShape.IsNull() ) + aVertex = TopoDS::Vertex( aShape ); + } + if ( !aVertex.IsNull() ) { + aPnt = BRep_Tool::Pnt( aVertex ); + } + else { + Standard_TypeMismatch::Raise + ("Point On Curve creation aborted : null curve"); + } + } } else if (aType == POINT_CURVE_COORD) { Handle(GEOM_Function) aRefFunc = aPI.GetCurve(); @@ -201,25 +221,45 @@ Standard_Integer GEOMImpl_PointDriver::Execute(TFunction_Logbook& log) const // Check orientation Standard_Real UFirst, ULast; Handle(Geom_Curve) EdgeCurve = BRep_Tool::Curve(aRefEdge, UFirst, ULast); - Handle(Geom_Curve) ReOrientedCurve = EdgeCurve; - - Standard_Real dU = ULast - UFirst; - Standard_Real par1 = UFirst + 0.1 * dU; - Standard_Real par2 = ULast - 0.1 * dU; - - gp_Pnt P1 = EdgeCurve->Value(par1); - gp_Pnt P2 = EdgeCurve->Value(par2); - if (aRefPnt.SquareDistance(P2) < aRefPnt.SquareDistance(P1)) { - ReOrientedCurve = EdgeCurve->Reversed(); - UFirst = EdgeCurve->ReversedParameter(ULast); + if ( !EdgeCurve.IsNull() ) { + Handle(Geom_Curve) ReOrientedCurve = EdgeCurve; + + Standard_Real dU = ULast - UFirst; + Standard_Real par1 = UFirst + 0.1 * dU; + Standard_Real par2 = ULast - 0.1 * dU; + + gp_Pnt P1 = EdgeCurve->Value(par1); + gp_Pnt P2 = EdgeCurve->Value(par2); + + if (aRefPnt.SquareDistance(P2) < aRefPnt.SquareDistance(P1)) { + ReOrientedCurve = EdgeCurve->Reversed(); + UFirst = EdgeCurve->ReversedParameter(ULast); + } + + // Get the point by length + GeomAdaptor_Curve AdapCurve = GeomAdaptor_Curve(ReOrientedCurve); + GCPnts_AbscissaPoint anAbsPnt (AdapCurve, aLength, UFirst); + Standard_Real aParam = anAbsPnt.Parameter(); + aPnt = AdapCurve.Value(aParam); + } + else { + // null curve, e.g. degenerated edge + TopoDS_Iterator It(aRefEdge, Standard_False, Standard_False); + TopoDS_Vertex aVertex; + if ( It.More() ) { + TopoDS_Shape aShape = It.Value(); + if ( !aShape.IsNull() ) + aVertex = TopoDS::Vertex( aShape ); + } + if ( !aVertex.IsNull() ) { + aPnt = BRep_Tool::Pnt( aVertex ); + } + else { + Standard_TypeMismatch::Raise + ("Point On Curve creation aborted : null curve"); + } } - - // Get the point by length - GeomAdaptor_Curve AdapCurve = GeomAdaptor_Curve(ReOrientedCurve); - GCPnts_AbscissaPoint anAbsPnt (AdapCurve, aLength, UFirst); - Standard_Real aParam = anAbsPnt.Parameter(); - aPnt = AdapCurve.Value(aParam); } else if (aType == POINT_SURFACE_PAR) { Handle(GEOM_Function) aRefFunc = aPI.GetSurface(); diff --git a/src/GEOMImpl/GEOMImpl_PositionDriver.cxx b/src/GEOMImpl/GEOMImpl_PositionDriver.cxx index be11e7dbb..73aed0fa2 100644 --- a/src/GEOMImpl/GEOMImpl_PositionDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_PositionDriver.cxx @@ -18,16 +18,15 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -//#include -// #include + #include #include + #include -#include +#include // OCCT Includes #include @@ -117,10 +116,10 @@ Standard_Integer GEOMImpl_PositionDriver::Execute(TFunction_Logbook& log) const gp_Ax3 aStartAx3, aDestAx3; // End LCS - aDestAx3 = GEOMImpl_IMeasureOperations::GetPosition(aShapeEndLCS); + aDestAx3 = GEOMUtils::GetPosition(aShapeEndLCS); // Start LCS - aStartAx3 = GEOMImpl_IMeasureOperations::GetPosition(aShapeStartLCS); + aStartAx3 = GEOMUtils::GetPosition(aShapeStartLCS); // Set transformation aTrsf.SetDisplacement(aStartAx3, aDestAx3); @@ -145,7 +144,7 @@ Standard_Integer GEOMImpl_PositionDriver::Execute(TFunction_Logbook& log) const gp_Ax3 aStartAx3, aDestAx3; // End LCS - aDestAx3 = GEOMImpl_IMeasureOperations::GetPosition(aShapeEndLCS); + aDestAx3 = GEOMUtils::GetPosition(aShapeEndLCS); // Set transformation aTrsf.SetDisplacement(aStartAx3, aDestAx3); diff --git a/src/GEOMImpl/GEOMImpl_PrismDriver.cxx b/src/GEOMImpl/GEOMImpl_PrismDriver.cxx index 87b18275d..ae25ae0b8 100644 --- a/src/GEOMImpl/GEOMImpl_PrismDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_PrismDriver.cxx @@ -18,17 +18,18 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #include #include -#include -#include #include #include #include + #include +#include + +#include #include #include @@ -249,7 +250,7 @@ Standard_Integer GEOMImpl_PrismDriver::Execute(TFunction_Logbook& log) const } else { - TopoDS_Shape aRes = GEOMImpl_IShapesOperations::CompsolidToCompound(aShape); + TopoDS_Shape aRes = GEOMUtils::CompsolidToCompound(aShape); aFunction->SetValue(aRes); } @@ -275,7 +276,7 @@ TopoDS_Shape GEOMImpl_PrismDriver::MakeScaledPrism (const TopoDS_Shape& theShape // 1. aCDG = geompy.MakeCDG(theBase) gp_Pnt aCDG = theCDG; if (!isCDG) { - gp_Ax3 aPos = GEOMImpl_IMeasureOperations::GetPosition(theShapeBase); + gp_Ax3 aPos = GEOMUtils::GetPosition(theShapeBase); aCDG = aPos.Location(); } TopoDS_Shape aShapeCDG_1 = BRepBuilderAPI_MakeVertex(aCDG).Shape(); diff --git a/src/GEOMImpl/GEOMImpl_RevolutionDriver.cxx b/src/GEOMImpl/GEOMImpl_RevolutionDriver.cxx index ea72dd7c3..44e68d973 100644 --- a/src/GEOMImpl/GEOMImpl_RevolutionDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_RevolutionDriver.cxx @@ -18,17 +18,18 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #include #include -#include #include #include + #include +#include + #include #include #include @@ -128,7 +129,7 @@ Standard_Integer GEOMImpl_RevolutionDriver::Execute(TFunction_Logbook& log) cons if (aShape.IsNull()) return 0; - TopoDS_Shape aRes = GEOMImpl_IShapesOperations::CompsolidToCompound(aShape); + TopoDS_Shape aRes = GEOMUtils::CompsolidToCompound(aShape); aFunction->SetValue(aRes); log.SetTouched(Label()); diff --git a/src/GEOMImpl/GEOMImpl_RotateDriver.cxx b/src/GEOMImpl/GEOMImpl_RotateDriver.cxx index 9f1e3035b..036538018 100644 --- a/src/GEOMImpl/GEOMImpl_RotateDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_RotateDriver.cxx @@ -18,36 +18,42 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #include #include #include #include + #include -#include -#include -#include -#include -#include + +#include + #include -#include -#include -#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 : @@ -92,13 +98,12 @@ Standard_Integer GEOMImpl_RotateDriver::Execute(TFunction_Logbook& log) const 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; + gp_Vec aV = GEOMUtils::GetVector(A); 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); + gp_Dir aDir (aV); + gp_Ax1 anAx1 (aP1, aDir); + Standard_Real anAngle = RI.GetAngle(); if (fabs(anAngle) < Precision::Angular()) anAngle += 2.*M_PI; // NPAL19665,19769 aTrsf.SetRotation(anAx1, anAngle); @@ -148,22 +153,24 @@ Standard_Integer GEOMImpl_RotateDriver::Execute(TFunction_Logbook& log) const TopLoc_Location aLocRes (aTrsfOrig); aShape = anOriginal.Located(aLocRes); } - else if (aType == ROTATE_1D) { + else if (aType == ROTATE_1D || aType == ROTATE_1D_STEP) { //Get direction + gp_Pnt aP1 = gp::Origin(); + gp_Dir D = gp::DZ(); 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); + if (!anAxis.IsNull()) { + TopoDS_Shape A = anAxis->GetValue(); + gp_Vec aV = GEOMUtils::GetVector(A); + TopoDS_Edge anEdge = TopoDS::Edge(A); + aP1 = BRep_Tool::Pnt(TopExp::FirstVertex(anEdge)); + D = gp_Dir(aV); + } + gp_Ax1 AX1 (aP1, D); Standard_Integer nbtimes = RI.GetNbIter1(); - Standard_Real angle = 360.0/nbtimes; + Standard_Real angle = 360. / nbtimes; + if (aType == ROTATE_1D_STEP) + angle = RI.GetAngle(); TopoDS_Compound aCompound; BRep_Builder B; @@ -177,7 +184,7 @@ Standard_Integer GEOMImpl_RotateDriver::Execute(TFunction_Logbook& log) const B.Add(aCompound, anOriginal); } else { - aTrsf.SetRotation(AX1, i*angle*M_PI/180.); + aTrsf.SetRotation(AX1, i * angle * M_PI / 180.); //TopLoc_Location aLocRes (aTrsf * aTrsfOrig); // gp_Trsf::Multiply() has a bug gp_Trsf aTrsfNew (aTrsfOrig); aTrsfNew.PreMultiply(aTrsf); @@ -194,16 +201,17 @@ Standard_Integer GEOMImpl_RotateDriver::Execute(TFunction_Logbook& log) const } else if (aType == ROTATE_2D) { //Get direction + gp_Pnt aP1 = gp::Origin(); + gp_Dir D = gp::DZ(); 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); + if (!anAxis.IsNull()) { + TopoDS_Shape A = anAxis->GetValue(); + gp_Vec aV = GEOMUtils::GetVector(A); + TopoDS_Edge anEdge = TopoDS::Edge(A); + aP1 = BRep_Tool::Pnt(TopExp::FirstVertex(anEdge)); + D = gp_Dir(aV); + } + gp_Ax1 AX1 (aP1, D); gp_Trsf aTrsf1; gp_Trsf aTrsf2; @@ -274,7 +282,7 @@ Standard_Integer GEOMImpl_RotateDriver::Execute(TFunction_Logbook& log) const B.Add(aCompound, anOriginal.Located(aLocRes)); } else { - aTrsf2.SetRotation(AX1, j*ang*M_PI/180.); + aTrsf2.SetRotation(AX1, j * ang * M_PI / 180.); //TopLoc_Location aLocRes (aTrsf2 * aTrsf1 * aTrsfOrig); // gp_Trsf::Multiply() has a bug gp_Trsf aTrsfNew (aTrsfOrig); aTrsfNew.PreMultiply(aTrsf1); diff --git a/src/GEOMImpl/GEOMImpl_SketcherDriver.cxx b/src/GEOMImpl/GEOMImpl_SketcherDriver.cxx index 70e627719..0ebe757d0 100644 --- a/src/GEOMImpl/GEOMImpl_SketcherDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_SketcherDriver.cxx @@ -18,7 +18,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #include @@ -27,7 +26,7 @@ #include #include -#include +#include #include @@ -117,7 +116,7 @@ Standard_Integer GEOMImpl_SketcherDriver::Execute(TFunction_Logbook& log) const // return 0; //Handle(Geom_Plane) aGPlane = Handle(Geom_Plane)::DownCast( aGS ); //aWPlane = aGPlane->Pln().Position(); - aWPlane = GEOMImpl_IMeasureOperations::GetPosition(aShape); + aWPlane = GEOMUtils::GetPosition(aShape); } gp_Trsf aTrans; aTrans.SetTransformation(aWPlane); diff --git a/src/GEOMImpl/GEOMImpl_SplineDriver.cxx b/src/GEOMImpl/GEOMImpl_SplineDriver.cxx index c87cdbc09..a94f0a279 100644 --- a/src/GEOMImpl/GEOMImpl_SplineDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_SplineDriver.cxx @@ -18,14 +18,14 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include #include + #include #include + #include +#include #include #include @@ -49,6 +49,10 @@ #include #include +#include + +#include + //======================================================================= //function : GetID //purpose : @@ -82,54 +86,73 @@ Standard_Integer GEOMImpl_SplineDriver::Execute(TFunction_Logbook& log) const TopoDS_Shape aShape; - if (aType == SPLINE_BEZIER || aType == SPLINE_INTERPOLATION) { + if (aType == SPLINE_BEZIER || + aType == SPLINE_INTERPOLATION || + aType == SPLINE_INTERPOL_TANGENTS) { bool useCoords = aCI.GetConstructorType() == COORD_CONSTRUCTOR; - TColgp_Array1OfPnt points(1, (useCoords ? aCI.GetLength() : 1) ); - if(useCoords) { - Handle(TColStd_HArray1OfReal) aCoordsArray = aCI.GetCoordinates(); + + Handle(TColStd_HArray1OfReal) aCoordsArray; // parametric case + Handle(TColStd_HSequenceOfTransient) aPoints; // points case + + int aLen = 0; + if (useCoords) { + aCoordsArray = aCI.GetCoordinates(); + aLen = aCoordsArray->Length() / 3; + } + else { + aPoints = aCI.GetPoints(); + aLen = aPoints->Length(); + } + + if (aLen < 2) return 0; + + TColgp_Array1OfPnt points (1, (useCoords ? aLen : 1)); + if (useCoords) { int anArrayLength = aCoordsArray->Length(); for (int i = 0, j = 1; i <= (anArrayLength-3); i += 3) { gp_Pnt aPnt = gp_Pnt(aCoordsArray->Value(i+1), aCoordsArray->Value(i+2), aCoordsArray->Value(i+3)); - points.SetValue(j,aPnt); + points.SetValue(j, aPnt); j++; - } + } } - - int ind, aLen = aCI.GetLength(); - if (aLen < 2) return 0; - Standard_Boolean isSeveral = Standard_False; - gp_Pnt aPrevP; int aRealLen = aLen; + if (aType == SPLINE_BEZIER && aCI.GetIsClosed()) { TopoDS_Vertex aV1; - if(useCoords) { + if (useCoords) { aV1 = BRepBuilderAPI_MakeVertex(points.Value(1)); - } else { - Handle(GEOM_Function) aFPoint = aCI.GetPoint(1); + } + else { + Handle(GEOM_Function) aFPoint = Handle(GEOM_Function)::DownCast(aPoints->Value(1)); TopoDS_Shape aFirstPnt = aFPoint->GetValue(); aV1 = TopoDS::Vertex(aFirstPnt); } TopoDS_Vertex aV2; - if(useCoords) { + if (useCoords) { aV2 = BRepBuilderAPI_MakeVertex(points.Value(aLen)); - } else { - Handle(GEOM_Function) aLPoint = aCI.GetPoint(aLen); + } + else { + Handle(GEOM_Function) aLPoint = Handle(GEOM_Function)::DownCast(aPoints->Value(aLen)); TopoDS_Shape aLastPnt = aLPoint->GetValue(); aV2 = TopoDS::Vertex(aLastPnt); } - + if (!aV1.IsNull() && !aV2.IsNull() && !aV1.IsSame(aV2)) { aRealLen++; } } - + + int ind; + Standard_Boolean isSeveral = Standard_False; + gp_Pnt aPrevP; + TColgp_Array1OfPnt CurvePoints (1, aRealLen); for (ind = 1; ind <= aLen; ind++) { gp_Pnt aP; - if( useCoords ) { + if (useCoords) { aP = points.Value(ind); if (!isSeveral && ind > 1) { if (aP.Distance(aPrevP) > Precision::Confusion()) { @@ -138,8 +161,9 @@ Standard_Integer GEOMImpl_SplineDriver::Execute(TFunction_Logbook& log) const } CurvePoints.SetValue(ind, aP); aPrevP = aP; - } else { - Handle(GEOM_Function) aRefPoint = aCI.GetPoint(ind); + } + else { + Handle(GEOM_Function) aRefPoint = Handle(GEOM_Function)::DownCast(aPoints->Value(ind)); TopoDS_Shape aShapePnt = aRefPoint->GetValue(); if (aShapePnt.ShapeType() == TopAbs_VERTEX) { aP = BRep_Tool::Pnt(TopoDS::Vertex(aShapePnt)); @@ -153,6 +177,7 @@ Standard_Integer GEOMImpl_SplineDriver::Execute(TFunction_Logbook& log) const } } } + if (aType == SPLINE_BEZIER) { if (!isSeveral) { Standard_ConstructionError::Raise("Points for Bezier Curve are too close"); @@ -160,13 +185,12 @@ Standard_Integer GEOMImpl_SplineDriver::Execute(TFunction_Logbook& log) const if (aRealLen > aLen) { // set last point equal to first for the closed curve CurvePoints.SetValue(aRealLen, CurvePoints.Value(1)); } - Handle(Geom_BezierCurve) GBC = new Geom_BezierCurve(CurvePoints); + Handle(Geom_BezierCurve) GBC = new Geom_BezierCurve (CurvePoints); aShape = BRepBuilderAPI_MakeEdge(GBC).Edge(); - } else { + } + else { //GeomAPI_PointsToBSpline GBC (CurvePoints); //aShape = BRepBuilderAPI_MakeEdge(GBC).Edge(); - - Handle(TColgp_HArray1OfPnt) aHCurvePoints = new TColgp_HArray1OfPnt(1, aLen); if (aCI.GetDoReordering()) { for (int curInd = 1; curInd < aLen - 1; curInd++) { @@ -194,18 +218,35 @@ Standard_Integer GEOMImpl_SplineDriver::Execute(TFunction_Logbook& log) const CurvePoints.SetValue(curInd + 1, nearPnt); } } - for (ind = 1; ind <= aLen; ind++) { - aHCurvePoints->SetValue(ind, CurvePoints.Value(ind)); - } } - else { - for (ind = 1; ind <= aLen; ind++) { - aHCurvePoints->SetValue(ind, CurvePoints.Value(ind)); - } + + Handle(TColgp_HArray1OfPnt) aHCurvePoints = new TColgp_HArray1OfPnt (1, aLen); + for (ind = 1; ind <= aLen; ind++) { + aHCurvePoints->SetValue(ind, CurvePoints.Value(ind)); } - - bool isClosed = aCI.GetIsClosed(); + + bool isClosed = Standard_False; + if (aType == SPLINE_INTERPOLATION) + isClosed = aCI.GetIsClosed(); + GeomAPI_Interpolate GBC (aHCurvePoints, isClosed, gp::Resolution()); + + if (aType == SPLINE_INTERPOL_TANGENTS) { + Handle(GEOM_Function) aVec1Ref = aCI.GetFirstVector(); + Handle(GEOM_Function) aVec2Ref = aCI.GetLastVector(); + + if (aVec1Ref.IsNull() || aVec2Ref.IsNull()) + Standard_NullObject::Raise("Null object is given for a vector"); + + TopoDS_Shape aVec1Sh = aVec1Ref->GetValue(); + TopoDS_Shape aVec2Sh = aVec2Ref->GetValue(); + + gp_Vec aV1 = GEOMUtils::GetVector(aVec1Sh); + gp_Vec aV2 = GEOMUtils::GetVector(aVec2Sh); + + GBC.Load(aV1, aV2, /*Scale*/Standard_True); + } + GBC.Perform(); if (GBC.IsDone()) aShape = BRepBuilderAPI_MakeEdge(GBC.Curve()).Edge(); @@ -215,13 +256,13 @@ Standard_Integer GEOMImpl_SplineDriver::Execute(TFunction_Logbook& log) const } else { } - + if (aShape.IsNull()) return 0; - + aFunction->SetValue(aShape); - + log.SetTouched(Label()); - + return 1; } diff --git a/src/GEOMImpl/GEOMImpl_TranslateDriver.cxx b/src/GEOMImpl/GEOMImpl_TranslateDriver.cxx index 575cbaea9..1f6de2170 100644 --- a/src/GEOMImpl/GEOMImpl_TranslateDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_TranslateDriver.cxx @@ -18,7 +18,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #include @@ -173,13 +172,14 @@ Standard_Integer GEOMImpl_TranslateDriver::Execute(TFunction_Logbook& log) const 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(); + gp_Vec Vec = gp::DX(); + if (!aVector.IsNull()) { + TopoDS_Shape aV = aVector->GetValue(); + if (aV.IsNull() || aV.ShapeType() != TopAbs_EDGE) return 0; + TopoDS_Edge anEdge = TopoDS::Edge(aV); + Vec = gp_Vec(BRep_Tool::Pnt(TopExp::FirstVertex(anEdge)), BRep_Tool::Pnt(TopExp::LastVertex(anEdge))); + Vec.Normalize(); + } TopLoc_Location aLocOrig = anOriginal.Location(); gp_Trsf aTrsfOrig = aLocOrig.Transformation(); @@ -202,32 +202,36 @@ Standard_Integer GEOMImpl_TranslateDriver::Execute(TFunction_Logbook& log) const } 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 aVec; + Standard_Real DX, DY, DZ, step1 = TI.GetStep1(), step2 = TI.GetStep2(); 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); + Handle(GEOM_Function) aVector2 = TI.GetVector2(); - gp_Vec Vec1(BRep_Tool::Pnt(TopExp::FirstVertex(anEdge)), BRep_Tool::Pnt(TopExp::LastVertex(anEdge))); - Vec1.Normalize(); + gp_Vec Vec1 = gp::DX(); + gp_Vec Vec2 = gp::DY(); - 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); + if (!aVector.IsNull()) { + TopoDS_Shape aV = aVector->GetValue(); + if (aV.IsNull() || aV.ShapeType() != TopAbs_EDGE) return 0; + TopoDS_Edge anEdge = TopoDS::Edge(aV); + Vec1 = gp_Vec(BRep_Tool::Pnt(TopExp::FirstVertex(anEdge)), BRep_Tool::Pnt(TopExp::LastVertex(anEdge))); + Vec1.Normalize(); + } - gp_Vec Vec2(BRep_Tool::Pnt(TopExp::FirstVertex(anEdge)), BRep_Tool::Pnt(TopExp::LastVertex(anEdge))); - Vec2.Normalize(); + if (!aVector2.IsNull()) { + TopoDS_Shape aV = aVector2->GetValue(); + if (aV.IsNull() || aV.ShapeType() != TopAbs_EDGE) return 0; + TopoDS_Edge anEdge = TopoDS::Edge(aV); + Vec2 = gp_Vec(BRep_Tool::Pnt(TopExp::FirstVertex(anEdge)), BRep_Tool::Pnt(TopExp::LastVertex(anEdge))); + Vec2.Normalize(); + } TopoDS_Compound aCompound; BRep_Builder B; - B.MakeCompound( aCompound ); + B.MakeCompound(aCompound); TopLoc_Location aLocOrig = anOriginal.Location(); gp_Trsf aTrsfOrig = aLocOrig.Transformation(); + gp_Vec aVec; for (int i = 0; i < nbtimes1; i++) { for (int j = 0; j < nbtimes2; j++) { diff --git a/src/GEOMImpl/GEOMImpl_Types.hxx b/src/GEOMImpl/GEOMImpl_Types.hxx index 4aeed6398..0419dd169 100755 --- a/src/GEOMImpl/GEOMImpl_Types.hxx +++ b/src/GEOMImpl/GEOMImpl_Types.hxx @@ -153,6 +153,7 @@ #define ROTATE_2D 4 #define ROTATE_THREE_POINTS 5 #define ROTATE_THREE_POINTS_COPY 6 +#define ROTATE_1D_STEP 7 #define MIRROR_PLANE 1 #define MIRROR_PLANE_COPY 2 @@ -234,8 +235,9 @@ #define POLYLINE_POINTS 1 -#define SPLINE_BEZIER 1 -#define SPLINE_INTERPOLATION 2 +#define SPLINE_BEZIER 1 +#define SPLINE_INTERPOLATION 2 +#define SPLINE_INTERPOL_TANGENTS 3 #define CIRCLE_THREE_PNT 1 #define CIRCLE_PNT_VEC_R 2 @@ -308,6 +310,7 @@ // Measures #define CDG_MEASURE 1 +#define BND_BOX_MEASURE 2 #define VECTOR_FACE_NORMALE 4 #define VERTEX_BY_INDEX 5 diff --git a/src/GEOMImpl/Makefile.am b/src/GEOMImpl/Makefile.am index 8ce12ca2e..f456551ce 100644 --- a/src/GEOMImpl/Makefile.am +++ b/src/GEOMImpl/Makefile.am @@ -238,14 +238,18 @@ libGEOMimpl_la_CPPFLAGS = \ -I$(srcdir)/../NMTDS \ -I$(srcdir)/../NMTTools \ -I$(srcdir)/../GEOM \ + -I$(srcdir)/../BlockFix \ -I$(srcdir)/../GEOMAlgo \ + -I$(srcdir)/../GEOMUtils \ -I$(srcdir)/../SKETCHER \ -I$(srcdir)/../ARCHIMEDE \ -I$(top_builddir)/idl libGEOMimpl_la_LDFLAGS = \ ../GEOM/libGEOMbasic.la \ + ../BlockFix/libBlockFix.la \ ../GEOMAlgo/libGEOMAlgo.la \ + ../GEOMUtils/libGEOMUtils.la \ ../ShHealOper/libShHealOper.la \ ../ARCHIMEDE/libGEOMArchimede.la \ ../SKETCHER/libGEOMSketcher.la \ diff --git a/src/GEOMToolsGUI/GEOMToolsGUI.cxx b/src/GEOMToolsGUI/GEOMToolsGUI.cxx index 01f2c182f..95b4507e8 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI.cxx +++ b/src/GEOMToolsGUI/GEOMToolsGUI.cxx @@ -325,7 +325,7 @@ bool GEOMToolsGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent) case GEOMOp::OpColor: // POPUP - COLOR OnColor(); break; - case GEOMOp::OpSetTexture: // POPUP - TEXTURE + case GEOMOp::OpSetTexture: // POPUP - TEXTURE OnTexture(); break; case GEOMOp::OpTransparency: // POPUP - TRANSPARENCY @@ -349,6 +349,12 @@ bool GEOMToolsGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent) case GEOMOp::OpMaterialProperties: // POPUP - MATERIAL PROPERTIES OnMaterialProperties(); break; + case GEOMOp::OpPredefMaterCustom: // POPUP - MATERIAL PROPERTIES - CUSTOM... + OnMaterialProperties(); + break; + case GEOMOp::OpMaterialsLibrary: // POPUP MENU - MATERIAL PROPERTIES + OnMaterialsLibrary(); + break; case GEOMOp::OpAutoColor: // POPUP - AUTO COLOR OnAutoColor(); break; @@ -387,6 +393,25 @@ bool GEOMToolsGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent) return true; } +//======================================================================= +// function : OnGUIEvent() +// purpose : +//======================================================================= +bool GEOMToolsGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent, const QVariant& theParam ) +{ + getGeometryGUI()->EmitSignalDeactivateDialog(); + + switch ( theCommandID ) { + case GEOMOp::OpPredefMaterial: // POPUP MENU - MATERIAL PROPERTIES - + OnSetMaterial( theParam ); + break; + default: + SUIT_Session::session()->activeApplication()->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); + break; + } + return true; +} + //=============================================================================== // function : OnEditDelete() // purpose : diff --git a/src/GEOMToolsGUI/GEOMToolsGUI.h b/src/GEOMToolsGUI/GEOMToolsGUI.h index 8b6c32c78..6c04a9be5 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI.h +++ b/src/GEOMToolsGUI/GEOMToolsGUI.h @@ -54,6 +54,8 @@ public: ~GEOMToolsGUI(); bool OnGUIEvent( int, SUIT_Desktop* ); + bool OnGUIEvent( int theCommandID, SUIT_Desktop*, const QVariant& ); + virtual void deactivate(); enum ActionType { SHOWDLG, INCR, DECR }; @@ -82,6 +84,8 @@ private: void OnPublishObject() ; void OnPointMarker(); void OnMaterialProperties(); + void OnMaterialsLibrary(); + void OnSetMaterial(const QVariant& ); void OnEdgeWidth(); void OnIsosWidth(); void OnBringToFront(); diff --git a/src/GEOMToolsGUI/GEOMToolsGUI_1.cxx b/src/GEOMToolsGUI/GEOMToolsGUI_1.cxx index 526a9b1e4..268c101c1 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI_1.cxx +++ b/src/GEOMToolsGUI/GEOMToolsGUI_1.cxx @@ -34,7 +34,9 @@ #include "GEOMToolsGUI_PublishDlg.h" #include "GEOMToolsGUI_MaterialPropertiesDlg.h" #include "GEOMToolsGUI_LineWidthDlg.h" -#include "Material_Model.h" +#include + +#include #include #include @@ -109,6 +111,7 @@ // VTK includes #include +class QtxDialog; // If the next macro is defined, autocolor feature works for all sub-shapes; // if it is undefined, autocolor feature works for groups only #define GENERAL_AUTOCOLOR @@ -298,8 +301,8 @@ void GEOMToolsGUI::SetColor( const QString& entry, const QColor& color, bool upd SUIT_ViewWindow* window = app->desktop()->activeWindow(); if ( !window ) return; - bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() ); - bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() ); + bool isOCC = window->getViewManager()->getType() == OCCViewer_Viewer::Type(); + bool isVTK = window->getViewManager()->getType() == SVTK_Viewer::Type(); // get view id int mgrId = window->getViewManager()->getGlobalId(); @@ -354,7 +357,7 @@ void GEOMToolsGUI::OnColor() bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() ); // get view id - int mgrId = window->getViewManager()->getGlobalId(); + int mgrId = window ? window->getViewManager()->getGlobalId() : -1; if ( isVTK ) { SVTK_ViewWindow* vtkVW = dynamic_cast( window ); @@ -363,7 +366,7 @@ void GEOMToolsGUI::OnColor() // get initial color (use first object from selection) SVTK_View* aView = vtkVW->getView(); QColor color = aView->GetColor( selected.First() ); - QVariant v = appStudy->getObjectProperty( mgrId, selected.First()->getEntry(), COLOR_PROP, color ); + QVariant v = appStudy->getObjectProperty( mgrId, selected.First()->getEntry(), GEOM::propertyName( GEOM::Color ), color ); // show Choose Color dialog box color = QColorDialog::getColor( v.value(), app->desktop() ); @@ -387,7 +390,7 @@ void GEOMToolsGUI::OnColor() QColor color = QColor((int)( aColor.Red() * 255.0 ), (int)( aColor.Green() * 255.0 ), (int)( aColor.Blue() * 255.0 )); - QVariant v = appStudy->getObjectProperty( mgrId, selected.First()->getEntry(), COLOR_PROP, color ); + QVariant v = appStudy->getObjectProperty( mgrId, selected.First()->getEntry(), GEOM::propertyName( GEOM::Color ), color ); // show Choose Color dialog box color = QColorDialog::getColor( v.value(), app->desktop() ); @@ -419,14 +422,14 @@ void GEOMToolsGUI::setVtkColor( SalomeApp_Study* study, // s { // get material property QString matProp; - matProp = study->getObjectProperty( mgrId, IO->getEntry(), MATERIAL_PROP, matProp ).toString(); + matProp = study->getObjectProperty( mgrId, IO->getEntry(), GEOM::propertyName( GEOM::Material ), matProp ).toString(); Material_Model material; material.fromProperties( matProp ); // change color only for shapes with not physical type of material if ( !material.isPhysical() ) { view->SetColor( IO, color ); - study->setObjectProperty( mgrId, IO->getEntry(), COLOR_PROP, color ); + study->setObjectProperty( mgrId, IO->getEntry(), GEOM::propertyName( GEOM::Color ), color ); } // store color to GEOM_Object @@ -459,7 +462,7 @@ void GEOMToolsGUI::setOccColor( SalomeApp_Study* study, // s // get material property QString matProp; - matProp = study->getObjectProperty( mgrId, IO->getEntry(), MATERIAL_PROP, matProp ).toString(); + matProp = study->getObjectProperty( mgrId, IO->getEntry(), GEOM::propertyName( GEOM::Material ), matProp ).toString(); Material_Model material; material.fromProperties( matProp ); @@ -504,7 +507,7 @@ void GEOMToolsGUI::setOccColor( SalomeApp_Study* study, // s io->Redisplay( Standard_True ); - study->setObjectProperty( mgrId, IO->getEntry(), COLOR_PROP, color ); + study->setObjectProperty( mgrId, IO->getEntry(), GEOM::propertyName( GEOM::Color ), color ); } // store color to GEOM_Object @@ -661,6 +664,7 @@ void GEOMToolsGUI::OnNbIsos( ActionType actionType ) OCCViewer_Viewer* vm = dynamic_cast( window->getViewManager()->getViewModel() ); Handle (AIS_InteractiveContext) ic = vm->getAISContext(); + int aMgrId = window->getViewManager()->getGlobalId(); ic->InitCurrent(); if ( ic->MoreCurrent() ) { @@ -702,12 +706,11 @@ void GEOMToolsGUI::OnNbIsos( ActionType actionType ) } for(; ic->MoreCurrent(); ic->NextCurrent()) { - int aMgrId = window->getViewManager()->getGlobalId(); CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current()); Handle(AIS_Drawer) CurDrawer = CurObject->Attributes(); - QVariant v = aStudy->getObjectProperty( aMgrId, CurObject->getIO()->getEntry(), EDGE_WIDTH_PROP , QVariant() ); + QVariant v = aStudy->getObjectProperty( aMgrId, CurObject->getIO()->getEntry(), GEOM::propertyName( GEOM::LineWidth ) , QVariant() ); int width = v.isValid() ? v.toInt() : 1; @@ -719,8 +722,8 @@ void GEOMToolsGUI::OnNbIsos( ActionType actionType ) ic->SetLocalAttributes(CurObject, CurDrawer); ic->Redisplay(CurObject); - QString anIsos("%1%2%3");anIsos = anIsos.arg(newNbUIso);anIsos = anIsos.arg(DIGIT_SEPARATOR);anIsos = anIsos.arg(newNbVIso); - aStudy->setObjectProperty(aMgrId ,CurObject->getIO()->getEntry(), ISOS_PROP, anIsos); + QString anIsos = QString("%1%2%3").arg(newNbUIso).arg(GEOM::subSectionSeparator()).arg(newNbVIso); + aStudy->setObjectProperty(aMgrId ,CurObject->getIO()->getEntry(), GEOM::propertyName( GEOM::NbIsos ), anIsos); } } GeometryGUI::Modified(); @@ -745,6 +748,8 @@ void GEOMToolsGUI::OnNbIsos( ActionType actionType ) if ( !vtkVW ) return; + int aMgrId = window->getViewManager()->getGlobalId(); + SALOME_View* view = GEOM_Displayer::GetActiveView(); vtkActorCollection* aCollection = vtkActorCollection::New(); @@ -814,9 +819,8 @@ void GEOMToolsGUI::OnNbIsos( ActionType actionType ) anActor->SetNbIsos(aIsos); anActor->StoreIsoNumbers(); - QString anIsos("%1%2%3");anIsos = anIsos.arg(newNbUIso);anIsos = anIsos.arg(DIGIT_SEPARATOR);anIsos = anIsos.arg(newNbVIso); - int aMgrId = window->getViewManager()->getGlobalId(); - aStudy->setObjectProperty(aMgrId ,anActor->getIO()->getEntry(), ISOS_PROP, anIsos); + QString anIsos = QString("%1%2%3").arg(newNbUIso).arg(GEOM::subSectionSeparator()).arg(newNbVIso); + aStudy->setObjectProperty(aMgrId ,anActor->getIO()->getEntry(), GEOM::propertyName( GEOM::NbIsos ), anIsos); } anAct = aCollection->GetNextActor(); } @@ -833,7 +837,7 @@ void GEOMToolsGUI::OnDeflection() bool isOCC = (window && window->getViewManager()->getType() == OCCViewer_Viewer::Type()); bool isVTK = (window && window->getViewManager()->getType() == SVTK_Viewer::Type()); - int mgrId = window->getViewManager()->getGlobalId(); + int mgrId = window ? window->getViewManager()->getGlobalId() : -1; if (isOCC) { // if is OCCViewer OCCViewer_Viewer* vm = dynamic_cast(window->getViewManager()->getViewModel()); @@ -863,7 +867,7 @@ void GEOMToolsGUI::OnDeflection() CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current()); ic->SetDeviationCoefficient(CurObject, aNewDC, Standard_True); ic->Redisplay(CurObject); - appStudy->setObjectProperty(mgrId,CurObject->getIO()->getEntry(), DEFLECTION_COEFF_PROP, aNewDC); + appStudy->setObjectProperty(mgrId,CurObject->getIO()->getEntry(), GEOM::propertyName( GEOM::Deflection ), aNewDC); } } } @@ -932,7 +936,7 @@ void GEOMToolsGUI::OnDeflection() if (GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct)) { // There are no casting to needed actor. anActor->SetDeflection(aDC); - appStudy->setObjectProperty(mgrId, anActor->getIO()->getEntry(), DEFLECTION_COEFF_PROP, aDC); + appStudy->setObjectProperty(mgrId, anActor->getIO()->getEntry(), GEOM::propertyName( GEOM::Deflection ), aDC); } anAct = aCollection->GetNextActor(); } @@ -1006,7 +1010,14 @@ void GEOMToolsGUI::OnPointMarker() void GEOMToolsGUI::OnMaterialProperties() { - GEOMToolsGUI_MaterialPropertiesDlg dlg( SUIT_Session::session()->activeApplication()->desktop() ); + GEOMToolsGUI_MaterialPropertiesDlg* dlg = new GEOMToolsGUI_MaterialPropertiesDlg( SUIT_Session::session()->activeApplication()->desktop(), true, false, QtxDialog::OK | QtxDialog::Close | QtxDialog::Apply | QtxDialog::Help ); + dlg->show(); +} + +void GEOMToolsGUI::OnMaterialsLibrary() +{ + GEOMToolsGUI_MaterialPropertiesDlg dlg( SUIT_Session::session()->activeApplication()->desktop(), false, true, QtxDialog::Standard ); + dlg.setWindowTitle( tr( "MATERIAL_LIBRARY_TLT" ) ); dlg.exec(); } @@ -1093,7 +1104,7 @@ void GEOMToolsGUI::OnEdgeWidth() bool isOCC = (window && window->getViewManager()->getType() == OCCViewer_Viewer::Type()); bool isVTK = (window && window->getViewManager()->getType() == SVTK_Viewer::Type()); - int mgrId = window->getViewManager()->getGlobalId(); + int mgrId = window ? window->getViewManager()->getGlobalId() : -1; if (isOCC) { // if is OCCViewer OCCViewer_Viewer* vm = dynamic_cast(window->getViewManager()->getViewModel()); @@ -1126,7 +1137,7 @@ void GEOMToolsGUI::OnEdgeWidth() ic->Redisplay(cur); } } - appStudy->setObjectProperty(mgrId, CurObject->getIO()->getEntry(), EDGE_WIDTH_PROP, aNewWidth); + appStudy->setObjectProperty(mgrId, CurObject->getIO()->getEntry(), GEOM::propertyName( GEOM::LineWidth ), aNewWidth); } } } @@ -1195,7 +1206,7 @@ void GEOMToolsGUI::OnEdgeWidth() if (GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct)) { // There are no casting to needed actor. anActor->SetWidth(aWidth); - appStudy->setObjectProperty(mgrId, anActor->getIO()->getEntry(), EDGE_WIDTH_PROP, aWidth); + appStudy->setObjectProperty(mgrId, anActor->getIO()->getEntry(), GEOM::propertyName( GEOM::LineWidth ), aWidth); } anAct = aCollection->GetNextActor(); } @@ -1218,6 +1229,7 @@ void GEOMToolsGUI::OnIsosWidth() { OCCViewer_Viewer* vm = dynamic_cast( window->getViewManager()->getViewModel() ); Handle (AIS_InteractiveContext) ic = vm->getAISContext(); + int aMgrId = window->getViewManager()->getGlobalId(); ic->InitCurrent(); if ( ic->MoreCurrent() ) { @@ -1246,7 +1258,6 @@ void GEOMToolsGUI::OnIsosWidth() { return; for(; ic->MoreCurrent(); ic->NextCurrent()) { - int aMgrId = window->getViewManager()->getGlobalId(); CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current()); Handle(AIS_Drawer) CurDrawer = CurObject->Attributes(); @@ -1256,7 +1267,7 @@ void GEOMToolsGUI::OnIsosWidth() { ic->Redisplay(CurObject); - aStudy->setObjectProperty(aMgrId ,CurObject->getIO()->getEntry(), ISOS_WIDTH_PROP, aWidth); + aStudy->setObjectProperty(aMgrId ,CurObject->getIO()->getEntry(), GEOM::propertyName( GEOM::IsosWidth ), aWidth); } GeometryGUI::Modified(); } @@ -1281,6 +1292,8 @@ void GEOMToolsGUI::OnIsosWidth() { if ( !vtkVW ) return; + int aMgrId = window->getViewManager()->getGlobalId(); + SALOME_View* view = GEOM_Displayer::GetActiveView(); vtkActorCollection* aCollection = vtkActorCollection::New(); @@ -1325,8 +1338,7 @@ void GEOMToolsGUI::OnIsosWidth() { if(GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct)) { // There are no casting to needed actor. anActor->SetIsosWidth(aWidth); - int aMgrId = window->getViewManager()->getGlobalId(); - aStudy->setObjectProperty(aMgrId ,anActor->getIO()->getEntry(), ISOS_WIDTH_PROP, aWidth); + aStudy->setObjectProperty(aMgrId ,anActor->getIO()->getEntry(), GEOM::propertyName( GEOM::IsosWidth ), aWidth); } anAct = aCollection->GetNextActor(); } @@ -1377,15 +1389,15 @@ void GEOMToolsGUI::OnBringToFront() { if ( isOCC ) { GEOMBase* gb = new GEOMBase(); Handle(GEOM_AISShape) aisShape; + int aMgrId = window->getViewManager()->getGlobalId(); Handle(AIS_InteractiveContext) ic = vm->getAISContext(); SALOME_ListIO anIOlst; for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) { aisShape = gb->ConvertIOinGEOMAISShape( It.Value(), true ); if ( !aisShape.IsNull() ) { + appStudy->setObjectProperty( aMgrId, aisShape->getIO()->getEntry(), GEOM::propertyName( GEOM::TopLevel ), checked ); aisShape->setTopLevel(checked); - int aMgrId = window->getViewManager()->getGlobalId(); - appStudy->setObjectProperty( aMgrId, aisShape->getIO()->getEntry(), TOP_LEVEL_PROP, checked ); anIOlst.Append(aisShape->getIO()); } } // for... @@ -1422,6 +1434,7 @@ void GEOMToolsGUI::OnClsBringToFront() { OCCViewer_Viewer* vm = dynamic_cast( window->getViewManager()->getViewModel() ); Handle (AIS_InteractiveContext) ic = vm->getAISContext(); + int aMgrId = window->getViewManager()->getGlobalId(); SALOME_ListIO anIOlst; AIS_ListOfInteractive aList; @@ -1433,10 +1446,8 @@ void GEOMToolsGUI::OnClsBringToFront() { if(CurObject.IsNull()) continue; + appStudy->setObjectProperty( aMgrId, QString(CurObject->getIO()->getEntry()), GEOM::propertyName( GEOM::TopLevel ), Standard_False ); CurObject->setTopLevel(Standard_False); - - int aMgrId = window->getViewManager()->getGlobalId(); - appStudy->setObjectProperty( aMgrId, QString(CurObject->getIO()->getEntry()), TOP_LEVEL_PROP, Standard_False ); anIOlst.Append(CurObject->getIO()); } disp->Redisplay(anIOlst); @@ -1444,3 +1455,40 @@ void GEOMToolsGUI::OnClsBringToFront() { } } +void GEOMToolsGUI::OnSetMaterial( const QVariant& theParam ) +{ + if ( !theParam.canConvert() ) return; + + QString theName = theParam.toString(); + + SalomeApp_Application* app = dynamic_cast( SUIT_Session::session()->activeApplication() ); + if ( !app ) return; + + SalomeApp_Study* study = dynamic_cast( app->activeStudy() ); + if ( !study ) return; + + LightApp_SelectionMgr* selMgr = app->selectionMgr(); + + SALOME_ListIO selected; + selMgr->selectedObjects( selected ); + + if ( selected.IsEmpty() ) return; + + GEOM_Displayer displayer( study ); + + SALOME_View* window = displayer.GetActiveView(); + if ( !window ) return; + + int mgrId = dynamic_cast( window )->getViewManager()->getGlobalId(); + + Material_Model aModel; + aModel.fromResources( theName ); + QString prop = aModel.toProperties(); + + for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) { + Handle(SALOME_InteractiveObject) io = It.Value(); + study->setObjectProperty( mgrId, io->getEntry(), GEOM::propertyName( GEOM::Material ), prop ); + if ( window->isVisible( io ) ) displayer.Redisplay( io, false ); + } + displayer.UpdateViewer(); +} diff --git a/src/GEOMToolsGUI/GEOMToolsGUI_DeflectionDlg.cxx b/src/GEOMToolsGUI/GEOMToolsGUI_DeflectionDlg.cxx index 428c91c47..48cfb2b0b 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI_DeflectionDlg.cxx +++ b/src/GEOMToolsGUI/GEOMToolsGUI_DeflectionDlg.cxx @@ -78,7 +78,7 @@ GEOMToolsGUI_DeflectionDlg::GEOMToolsGUI_DeflectionDlg (QWidget* parent) SpinBox->setAcceptNames( false ); SpinBox->setPrecision( aPrecision ); SpinBox->setDecimals( aPrecision ); - SpinBox->setRange( DEFLECTION_MIN, 1.0 ); + SpinBox->setRange( GEOM::minDeflection(), 1.0 ); SpinBox->setSingleStep( 1.0e-04 ); // Add a hint for the user saying how to tune precision QString userPropName = QObject::tr( QString( "GEOM_PREF_%1" ).arg( quantity ).toLatin1().constData() ); diff --git a/src/GEOMToolsGUI/GEOMToolsGUI_MarkerDlg.cxx b/src/GEOMToolsGUI/GEOMToolsGUI_MarkerDlg.cxx index 4ba147b78..7a1952ad6 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI_MarkerDlg.cxx +++ b/src/GEOMToolsGUI/GEOMToolsGUI_MarkerDlg.cxx @@ -228,13 +228,13 @@ void GEOMToolsGUI_MarkerDlg::accept() anObject->SetMarkerStd( getMarkerType(), getStandardMarkerScale() ); QString aMarker = "%1%2%3"; aMarker = aMarker.arg(getMarkerType()); - aMarker = aMarker.arg(DIGIT_SEPARATOR); + aMarker = aMarker.arg(GEOM::subSectionSeparator()); aMarker = aMarker.arg(getStandardMarkerScale()); - getStudy()->setObjectProperty(mgrId ,it.Value()->getEntry(),MARKER_TYPE_PROP, aMarker); + getStudy()->setObjectProperty(mgrId ,it.Value()->getEntry(),GEOM::propertyName( GEOM::PointMarker ), aMarker); } else if ( getCustomMarkerID() > 0 ) { anObject->SetMarkerTexture( getCustomMarkerID() ); - getStudy()->setObjectProperty(mgrId ,it.Value()->getEntry(),MARKER_TYPE_PROP, QString::number(getCustomMarkerID())); + getStudy()->setObjectProperty(mgrId ,it.Value()->getEntry(),GEOM::propertyName( GEOM::PointMarker ), QString::number(getCustomMarkerID())); } } } diff --git a/src/GEOMToolsGUI/GEOMToolsGUI_MaterialPropertiesDlg.cxx b/src/GEOMToolsGUI/GEOMToolsGUI_MaterialPropertiesDlg.cxx index ca92d6f08..61c7c763d 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI_MaterialPropertiesDlg.cxx +++ b/src/GEOMToolsGUI/GEOMToolsGUI_MaterialPropertiesDlg.cxx @@ -26,6 +26,7 @@ #include "GEOM_Constants.h" #include "GEOM_VTKPropertyMaterial.hxx" #include "GEOMBase.h" +#include "GEOM_Displayer.h" #include #include @@ -50,6 +51,7 @@ #include #include #include +#include #include #include #include @@ -89,13 +91,17 @@ void GEOMToolsGUI_MaterialList::contextMenuEvent( QContextMenuEvent* e ) /*! \brief Constructor \param parent parent widget + \param showSelWidget if \c true then objects can be selected by user + \param modal if \c true dialog box is modal + \param f specified control buttons for dialog box (QtxDialog::ButtonFlags) */ -GEOMToolsGUI_MaterialPropertiesDlg::GEOMToolsGUI_MaterialPropertiesDlg( QWidget* parent ) - : QtxDialog( parent, true, true, OK | Close | Apply | Help ) +GEOMToolsGUI_MaterialPropertiesDlg::GEOMToolsGUI_MaterialPropertiesDlg( QWidget* parent,bool showSelWidget, bool modal,const int f ) + : QtxDialog( parent, modal, true, f ) { + myShowSelWidget = showSelWidget; // Set title setWindowTitle( tr( "MATERIAL_PROPERTIES_TLT" ) ); - + // main layout QVBoxLayout* main = new QVBoxLayout( mainFrame() ); main->setMargin( 0 ); @@ -105,6 +111,11 @@ GEOMToolsGUI_MaterialPropertiesDlg::GEOMToolsGUI_MaterialPropertiesDlg( QWidget* QFrame* fr = new QFrame( mainFrame() ); fr->setFrameStyle( QFrame::Box | QFrame::Sunken ); main->addWidget( fr ); + // selection widget + myLineEditCurArg = new QLineEdit(fr); + myLineEditCurArg->setReadOnly(true); + myPushBtn = new QPushButton(fr); + QLabel* PushBtnLab = new QLabel( tr( "GEOM_OBJECTS" ), fr ); // materials list widget myMaterials = new GEOMToolsGUI_MaterialList( fr ); @@ -130,41 +141,64 @@ GEOMToolsGUI_MaterialPropertiesDlg::GEOMToolsGUI_MaterialPropertiesDlg( QWidget* // "physical" material type widgets myPhysical = new QCheckBox( tr( "PHYSICAL" ), propWidget ); + // Labels for front and back reflection components + QLabel* aFrontLabel = new QLabel( tr( "FRONT_FACE" ), propWidget ); + QLabel* aBackLabel = new QLabel( tr( "BACK_FACE" ), propWidget ); + // reflection components widgets for ( int i = Material_Model::Ambient; i <= Material_Model::Emissive; i++ ) { Reflection refl; + + refl.enabled = new QCheckBox( propWidget ); refl.label = new QLabel( tr( QString( "REFLECTION_%1" ).arg( i ).toLatin1().data() ), propWidget ); refl.color = new QtxColorButton( propWidget ); //refl.color->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - refl.coef = new QtxDoubleSpinBox( propWidget ); - refl.coef->setPrecision( 4 ); - refl.coef->setDecimals( 4 ); - refl.coef->setRange( 0., 1. ); - refl.coef->setSingleStep( 0.05 ); - refl.coef->setMinimumWidth( 80 ); - - refl.enabled = new QCheckBox( tr( "ENABLED" ), propWidget ); + refl.front_coef = new QtxDoubleSpinBox( propWidget ); + refl.front_coef->setPrecision( 4 ); + refl.front_coef->setDecimals( 4 ); + refl.front_coef->setRange( 0., 1. ); + refl.front_coef->setSingleStep( 0.05 ); + refl.front_coef->setMinimumWidth( 80 ); + + refl.back_coef = new QtxDoubleSpinBox( propWidget ); + refl.back_coef->setPrecision( 4 ); + refl.back_coef->setDecimals( 4 ); + refl.back_coef->setRange( 0., 1. ); + refl.back_coef->setSingleStep( 0.05 ); + refl.back_coef->setMinimumWidth( 80 ); myReflection << refl; } // shininess widgets QLabel* shininessLab = new QLabel( tr( "SHININESS" ), propWidget ); - myShininess = new QtxDoubleSpinBox( propWidget ); - myShininess->setPrecision( 4 ); - myShininess->setDecimals( 4 ); - myShininess->setRange( 0., 1. ); - myShininess->setSingleStep( 0.05 ); + myFrontShininess = new QtxDoubleSpinBox( propWidget ); + myFrontShininess->setPrecision( 4 ); + myFrontShininess->setDecimals( 4 ); + myFrontShininess->setRange( 0., 1. ); + myFrontShininess->setSingleStep( 0.05 ); + + myBackShininess = new QtxDoubleSpinBox( propWidget ); + myBackShininess->setPrecision( 4 ); + myBackShininess->setDecimals( 4 ); + myBackShininess->setRange( 0., 1. ); + myBackShininess->setSingleStep( 0.05 ); // separator widgets QFrame* line1 = new QFrame( propWidget ); line1->setFrameStyle( QFrame::HLine | QFrame::Sunken ); QFrame* line2 = new QFrame( propWidget ); line2->setFrameStyle( QFrame::HLine | QFrame::Sunken ); + QFrame* line3 = new QFrame( propWidget ); + line3->setFrameStyle( QFrame::VLine | QFrame::Sunken ); + QFrame* line4 = new QFrame( propWidget ); + line4->setFrameStyle( QFrame::VLine | QFrame::Sunken ); + QFrame* line5 = new QFrame( propWidget ); + line5->setFrameStyle( QFrame::HLine | QFrame::Sunken ); // add / remove material buttons myAddButton = new QPushButton( tr( "ADD_MATERIAL" ), propWidget ); @@ -178,21 +212,42 @@ GEOMToolsGUI_MaterialPropertiesDlg::GEOMToolsGUI_MaterialPropertiesDlg( QWidget* btnLayout->addWidget( myDelButton ); // layout all properties widgets together - propLayout->addWidget( myColorLab, 0, 0 ); - propLayout->addWidget( myColor, 0, 1 ); - propLayout->addWidget( line1, 1, 0, 1, 4 ); - propLayout->addWidget( myPhysical, 2, 0, 1, 2 ); + propLayout->addWidget( PushBtnLab,0,0); + propLayout->addWidget( myPushBtn,0,1); + propLayout->addWidget( myLineEditCurArg, 0, 2, 1, 5 ); + propLayout->addWidget( line1, 1, 0, 1, 7 ); + propLayout->addWidget( myColorLab, 2, 1 ); + propLayout->addWidget( myColor, 2, 2 ); + propLayout->addWidget( myPhysical, 2, 0 ); + propLayout->addWidget( line2, 3, 0, 1, 7 ); + propLayout->addWidget( aFrontLabel, 4, 4); + propLayout->addWidget( aBackLabel, 4, 6); + + propLayout->addWidget( line3, 4, 3, 6, 1 ); + propLayout->addWidget( line4, 4, 5, 6, 1 ); + + if( !myShowSelWidget ) { + myColorLab->hide(); + myColor->hide(); + line1->hide(); + myLineEditCurArg->hide(); + myPushBtn->hide(); + PushBtnLab->hide(); + } for ( int i = Material_Model::Ambient; i <= Material_Model::Emissive; i++ ) { - propLayout->addWidget( myReflection[i].label, i+3, 0 ); - propLayout->addWidget( myReflection[i].color, i+3, 1 ); - propLayout->addWidget( myReflection[i].coef, i+3, 2 ); - propLayout->addWidget( myReflection[i].enabled, i+3, 3 ); + propLayout->addWidget( myReflection[i].enabled, i+5, 0 ); + propLayout->addWidget( myReflection[i].label, i+5, 1 ); + propLayout->addWidget( myReflection[i].color, i+5, 2 ); + propLayout->addWidget( myReflection[i].front_coef, i+5, 4 ); + propLayout->addWidget( myReflection[i].back_coef, i+5, 6 ); } - propLayout->addWidget( shininessLab, 7, 0 ); - propLayout->addWidget( myShininess, 7, 2 ); - propLayout->addWidget( line2, 8, 0, 1, 4 ); - propLayout->setRowStretch( 9, 5 ); - propLayout->addLayout( btnLayout, 10, 0, 1, 4 ); + + propLayout->addWidget( shininessLab, 9, 0 ); + propLayout->addWidget( myFrontShininess, 9, 4 ); + propLayout->addWidget( myBackShininess, 9, 6 ); + propLayout->addWidget( line5, 10, 0, 1, 7 ); + propLayout->setRowStretch( 11, 5 ); + propLayout->addLayout( btnLayout, 12, 0, 1, 7 ); // initialize dialog box setButtonPosition( Right, Close ); @@ -227,6 +282,9 @@ GEOMToolsGUI_MaterialPropertiesDlg::GEOMToolsGUI_MaterialPropertiesDlg( QWidget* // install event filter to the materials list to process key press events myMaterials->installEventFilter( this ); + //Set image + myPushBtn->setIcon(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT"))); + // connect signals // note: all widgets, that change material properties, are connected to the common signal // changed(), instead of connecting directly to the slot - this allows easy temporary blocking @@ -234,10 +292,12 @@ GEOMToolsGUI_MaterialPropertiesDlg::GEOMToolsGUI_MaterialPropertiesDlg( QWidget* connect( myPhysical, SIGNAL( toggled( bool ) ), this, SIGNAL( changed() ) ); for ( int i = Material_Model::Ambient; i <= Material_Model::Emissive; i++ ) { connect( myReflection[i].color, SIGNAL( changed( QColor ) ), this, SIGNAL( changed() ) ); - connect( myReflection[i].coef, SIGNAL( valueChanged( double ) ), this, SIGNAL( changed() ) ); + connect( myReflection[i].front_coef, SIGNAL( valueChanged( double ) ), this, SIGNAL( changed() ) ); + connect( myReflection[i].back_coef, SIGNAL( valueChanged( double ) ), this, SIGNAL( changed() ) ); connect( myReflection[i].enabled, SIGNAL( toggled( bool ) ), this, SIGNAL( changed() ) ); } - connect( myShininess, SIGNAL( valueChanged( double ) ), this, SIGNAL( changed() ) ); + connect( myFrontShininess, SIGNAL( valueChanged( double ) ), this, SIGNAL( changed() ) ); + connect( myBackShininess, SIGNAL( valueChanged( double ) ), this, SIGNAL( changed() ) ); connect( myMaterials, SIGNAL( itemSelectionChanged() ), this, SLOT( onMaterialChanged() ) ); connect( myMaterials, SIGNAL( itemChanged( QListWidgetItem* ) ), @@ -249,6 +309,9 @@ GEOMToolsGUI_MaterialPropertiesDlg::GEOMToolsGUI_MaterialPropertiesDlg( QWidget* connect( this, SIGNAL( dlgApply() ), this, SLOT( onApply() ) ); connect( this, SIGNAL( dlgHelp() ), this, SLOT( onHelp() ) ); connect( this, SIGNAL( changed() ), this, SLOT( onChanged() ) ); + connect(myPushBtn, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), + SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); // initialize current material model according to the selection myColor->setColor( SUIT_Session::session()->resourceMgr()->colorValue( "Geometry", "shading_color", QColor( 255, 0, 0 ) ) ); @@ -266,17 +329,20 @@ GEOMToolsGUI_MaterialPropertiesDlg::GEOMToolsGUI_MaterialPropertiesDlg( QWidget* if ( window ) { int mgrId = window->getViewManager()->getGlobalId(); PropMap propMap = study->getObjectPropMap( mgrId, io->getEntry() ); - QString matProp = propMap.value(MATERIAL_PROP).toString(); + QString matProp = propMap.value(GEOM::propertyName( GEOM::Material )).toString(); if ( !matProp.isEmpty() ) myCurrentModel.fromProperties( matProp ); - QColor c = propMap.value(COLOR_PROP).value(); + QColor c = propMap.value(GEOM::propertyName( GEOM::Color )).value(); if ( c.isValid() ) myColor->setColor( c ); } } } } - + myLineEditCurArg->setText(""); + myPushBtn->click(); + SelectionIntoArgument(); + // finally activate current material properties myMaterials->setCurrentRow( 0 ); } @@ -324,12 +390,14 @@ void GEOMToolsGUI_MaterialPropertiesDlg::fromModel( const Material_Model& model for ( int i = Material_Model::Ambient; i <= Material_Model::Emissive; i++ ) { myReflection[i].color->setColor( model.color( (Material_Model::ReflectionType)i ) ); - myReflection[i].coef->setValue( model.reflection( (Material_Model::ReflectionType)i ) ); + myReflection[i].front_coef->setValue( model.reflection( (Material_Model::ReflectionType)i, true ) ); + myReflection[i].back_coef->setValue( model.reflection( (Material_Model::ReflectionType)i, false ) ); myReflection[i].enabled->setChecked( model.hasReflection( (Material_Model::ReflectionType)i ) ); } // shininess - myShininess->setValue( model.shininess() ); + myFrontShininess->setValue( model.shininess( true ) ); + myBackShininess->setValue( model.shininess( false ) ); // type (physical or no) myPhysical->setChecked( model.isPhysical() ); @@ -345,13 +413,15 @@ void GEOMToolsGUI_MaterialPropertiesDlg::toModel( Material_Model& model ) const model.setPhysical( myPhysical->isChecked() ); // shininess - model.setShininess( myShininess->value() ); + model.setShininess( myFrontShininess->value(), true ); + model.setShininess( myBackShininess->value(), false ); // reflection components for ( int i = Material_Model::Ambient; i <= Material_Model::Emissive; i++ ) { model.setColor ( (Material_Model::ReflectionType)i, myReflection[i].color->color() ); - model.setReflection( (Material_Model::ReflectionType)i, myReflection[i].coef->value() ); + model.setReflection( (Material_Model::ReflectionType)i, myReflection[i].front_coef->value(), true ); + model.setReflection( (Material_Model::ReflectionType)i, myReflection[i].back_coef->value(), false ); model.setReflection( (Material_Model::ReflectionType)i, myReflection[i].enabled->isChecked() ); } } @@ -391,7 +461,7 @@ void GEOMToolsGUI_MaterialPropertiesDlg::onApply() { // save user materials myResourceMgr.save(); - + if( !myShowSelWidget ) return; // store selected material properties in the current model toModel( myCurrentModel ); @@ -421,19 +491,20 @@ void GEOMToolsGUI_MaterialPropertiesDlg::onApply() SVTK_View* aView = vtkVW->getView(); // get VTK material properties from the current model - GEOM_VTKPropertyMaterial* vtkProp = myCurrentModel.getMaterialVTKProperty(); + GEOM_VTKPropertyMaterial* vtkPropF = myCurrentModel.getMaterialVTKProperty(); + GEOM_VTKPropertyMaterial* vtkPropB = myCurrentModel.getMaterialVTKProperty( false ); SUIT_OverrideCursor wc(); for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) { // set material property to the presentation - aView->SetMaterial( It.Value(), vtkProp ); + aView->SetMaterial( It.Value(), vtkPropF, vtkPropB ); // store chosen material in the property map - study->setObjectProperty( mgrId, It.Value()->getEntry(), MATERIAL_PROP, prop ); + study->setObjectProperty( mgrId, It.Value()->getEntry(), GEOM::propertyName( GEOM::Material ), prop ); // set correct color for the non-physical material if ( !myCurrentModel.isPhysical() ) { aView->SetColor( It.Value(), myColor->color() ); - study->setObjectProperty( mgrId, It.Value()->getEntry(), COLOR_PROP, myColor->color() ); + study->setObjectProperty( mgrId, It.Value()->getEntry(), GEOM::propertyName( GEOM::Color ), myColor->color() ); } } aView->Repaint(); @@ -448,25 +519,32 @@ void GEOMToolsGUI_MaterialPropertiesDlg::onApply() Handle(AIS_InteractiveContext) ic = vm->getAISContext(); // get OCC material aspect from the current model - Graphic3d_MaterialAspect occAspect = myCurrentModel.getMaterialOCCAspect(); + Graphic3d_MaterialAspect front_occAspect = myCurrentModel.getMaterialOCCAspect( true ); + Graphic3d_MaterialAspect back_occAspect = myCurrentModel.getMaterialOCCAspect( false ); SUIT_OverrideCursor wc(); for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) { Handle(GEOM_AISShape) aisShape = GEOMBase::ConvertIOinGEOMAISShape( It.Value(), true ); if ( !aisShape.IsNull() ) { - // set material property to the presentation - aisShape->SetMaterial( occAspect ); - // store chosen material in the property map - study->setObjectProperty( mgrId, It.Value()->getEntry(), MATERIAL_PROP, prop ); - // set correct color for the non-physical material - if ( !myCurrentModel.isPhysical() ) { - aisShape->SetShadingColor( SalomeApp_Tools::color( myColor->color() ) ); - study->setObjectProperty( mgrId, It.Value()->getEntry(), COLOR_PROP, myColor->color() ); - ic->RecomputePrsOnly( aisShape, Standard_False ); - } - //if ( aisShape->DisplayMode() != AIS_Shaded/*aisShape->DisplayMode() == GEOM_AISShape::ShadingWithEdges*/) - ic->Redisplay( aisShape, Standard_False ); + // Set front material for the selected shape + aisShape->SetCurrentFacingModel(Aspect_TOFM_FRONT_SIDE); + aisShape->SetMaterial(front_occAspect); + // Set back material for the selected shape + aisShape->SetCurrentFacingModel(Aspect_TOFM_BACK_SIDE); + aisShape->SetMaterial(back_occAspect); + // Return to the default facing mode + aisShape->SetCurrentFacingModel(Aspect_TOFM_BOTH_SIDE); + // store chosen material in the property map + study->setObjectProperty( mgrId, It.Value()->getEntry(), GEOM::propertyName( GEOM::Material ), prop ); + // set correct color for the non-physical material + if ( !myCurrentModel.isPhysical() ) { + aisShape->SetShadingColor( SalomeApp_Tools::color( myColor->color() ) ); + study->setObjectProperty( mgrId, It.Value()->getEntry(), GEOM::propertyName( GEOM::Color ), myColor->color() ); + ic->RecomputePrsOnly( aisShape, Standard_False ); + } + //if ( aisShape->DisplayMode() != AIS_Shaded/*aisShape->DisplayMode() == GEOM_AISShape::ShadingWithEdges*/) + ic->Redisplay( aisShape, Standard_False ); } } ic->UpdateCurrentViewer(); @@ -670,3 +748,37 @@ void GEOMToolsGUI_MaterialPropertiesDlg::updateState() myColor->setEnabled( !myPhysical->isChecked() ); myReflection[0].color->setEnabled( myPhysical->isChecked() ); } + + +void GEOMToolsGUI_MaterialPropertiesDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + + if (send == myPushBtn) { + // enable line edit + myLineEditCurArg->setEnabled(true); + myLineEditCurArg->setFocus(); + SelectionIntoArgument(); + // after setFocus(), because it will be setDown(false) when loses focus + send->setDown(true); + } +} + +/*! + \brief Called when selection as changed or other case +*/ +void GEOMToolsGUI_MaterialPropertiesDlg::SelectionIntoArgument() +{ + myLineEditCurArg->setText( "" ); + QString aString = ""; + + SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); + SalomeApp_Study* study = dynamic_cast( app->activeStudy() ); + LightApp_SelectionMgr* aSelMgr = app->selectionMgr(); + if ( study ) { + SALOME_ListIO aSelList; + aSelMgr->selectedObjects(aSelList); + int nbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aString, true); + } + myLineEditCurArg->setText( aString ); +} diff --git a/src/GEOMToolsGUI/GEOMToolsGUI_MaterialPropertiesDlg.h b/src/GEOMToolsGUI/GEOMToolsGUI_MaterialPropertiesDlg.h index 1e2a7c6f7..c9f20598e 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI_MaterialPropertiesDlg.h +++ b/src/GEOMToolsGUI/GEOMToolsGUI_MaterialPropertiesDlg.h @@ -45,7 +45,7 @@ class GEOMTOOLSGUI_EXPORT GEOMToolsGUI_MaterialPropertiesDlg : public QtxDialog enum { TypeRole = Qt::UserRole + 123, NameRole }; public: - GEOMToolsGUI_MaterialPropertiesDlg( QWidget* = 0 ); + GEOMToolsGUI_MaterialPropertiesDlg( QWidget* = 0 , bool = true, bool = false,const int = Standard ); ~GEOMToolsGUI_MaterialPropertiesDlg(); void accept(); @@ -72,26 +72,33 @@ private slots: void onAddMaterial(); void onApply(); void onHelp(); + void SetEditCurrentArgument(); + void SelectionIntoArgument(); private: typedef struct { + QCheckBox* enabled; QLabel* label; QtxColorButton* color; - QtxDoubleSpinBox* coef; - QCheckBox* enabled; + QtxDoubleSpinBox* front_coef; + QtxDoubleSpinBox* back_coef; } Reflection; GEOMToolsGUI_MaterialList* myMaterials; QCheckBox* myPhysical; QList myReflection; - QtxDoubleSpinBox* myShininess; + QtxDoubleSpinBox* myFrontShininess; + QtxDoubleSpinBox* myBackShininess; QLabel* myColorLab; QtxColorButton* myColor; QPushButton* myAddButton; QPushButton* myDelButton; Material_ResourceMgr myResourceMgr; Material_Model myCurrentModel; + bool myShowSelWidget; + QLineEdit* myLineEditCurArg; + QPushButton* myPushBtn; }; class GEOMToolsGUI_MaterialList : public QListWidget diff --git a/src/GEOMToolsGUI/GEOMToolsGUI_TransparencyDlg.cxx b/src/GEOMToolsGUI/GEOMToolsGUI_TransparencyDlg.cxx index 3bcbc16ea..55f7c92d2 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI_TransparencyDlg.cxx +++ b/src/GEOMToolsGUI/GEOMToolsGUI_TransparencyDlg.cxx @@ -286,7 +286,7 @@ void GEOMToolsGUI_TransparencyDlg::SetTransparency() SUIT_OverrideCursor(); for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) { aView->SetTransparency( It.Value(), newValue ); - aStudy->setObjectProperty( aMgrId , It.Value()->getEntry(), TRANSPARENCY_PROP , newValue ); + aStudy->setObjectProperty( aMgrId , It.Value()->getEntry(), GEOM::propertyName( GEOM::Transparency ) , newValue ); } GeometryGUI::Modified(); aView->Repaint(); @@ -317,7 +317,7 @@ void GEOMToolsGUI_TransparencyDlg::SetTransparency() if ( !aisShape.IsNull() ) { ic->SetTransparency( aisShape, newValue, false ); ic->Redisplay( aisShape, Standard_False, Standard_True ); - aStudy->setObjectProperty( aMgrId , It.Value()->getEntry(), TRANSPARENCY_PROP , newValue ); + aStudy->setObjectProperty( aMgrId , It.Value()->getEntry(), GEOM::propertyName( GEOM::Transparency ) , newValue ); } } // for... ic->UpdateCurrentViewer(); diff --git a/src/GEOMUtils/GEOMUtils.cxx b/src/GEOMUtils/GEOMUtils.cxx new file mode 100644 index 000000000..292ab5c44 --- /dev/null +++ b/src/GEOMUtils/GEOMUtils.cxx @@ -0,0 +1,499 @@ +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 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.com + +#include + +#include + +#include + +#include +#include +#include + +// OCCT Includes +#include + +#include +#include +#include +#include +#include + +#include + +#include +#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 STD_SORT_ALGO 1 + +//======================================================================= +//function : GetPosition +//purpose : +//======================================================================= +gp_Ax3 GEOMUtils::GetPosition (const TopoDS_Shape& theShape) +{ + gp_Ax3 aResult; + + if (theShape.IsNull()) + return aResult; + + // Axes + aResult.Transform(theShape.Location().Transformation()); + if (theShape.ShapeType() == TopAbs_FACE) { + Handle(Geom_Surface) aGS = BRep_Tool::Surface(TopoDS::Face(theShape)); + if (!aGS.IsNull() && aGS->IsKind(STANDARD_TYPE(Geom_Plane))) { + Handle(Geom_Plane) aGPlane = Handle(Geom_Plane)::DownCast(aGS); + gp_Pln aPln = aGPlane->Pln(); + aResult = aPln.Position(); + // In case of reverse orinetation of the face invert the plane normal + // (the face's normal does not mathc the plane's normal in this case) + if(theShape.Orientation() == TopAbs_REVERSED) + { + gp_Dir Vx = aResult.XDirection(); + gp_Dir N = aResult.Direction().Mirrored(Vx); + gp_Pnt P = aResult.Location(); + aResult = gp_Ax3(P, N, Vx); + } + } + } + + // Origin + gp_Pnt aPnt; + + TopAbs_ShapeEnum aShType = theShape.ShapeType(); + + if (aShType == TopAbs_VERTEX) { + aPnt = BRep_Tool::Pnt(TopoDS::Vertex(theShape)); + } + else { + if (aShType == TopAbs_COMPOUND) { + aShType = GetTypeOfSimplePart(theShape); + } + + GProp_GProps aSystem; + if (aShType == TopAbs_EDGE || aShType == TopAbs_WIRE) + BRepGProp::LinearProperties(theShape, aSystem); + else if (aShType == TopAbs_FACE || aShType == TopAbs_SHELL) + BRepGProp::SurfaceProperties(theShape, aSystem); + else + BRepGProp::VolumeProperties(theShape, aSystem); + + aPnt = aSystem.CentreOfMass(); + } + + aResult.SetLocation(aPnt); + + return aResult; +} + +//======================================================================= +//function : GetVector +//purpose : +//======================================================================= +gp_Vec GEOMUtils::GetVector (const TopoDS_Shape& theShape) +{ + if (theShape.IsNull()) + Standard_NullObject::Raise("Null shape is given for a vector"); + + if (theShape.ShapeType() != TopAbs_EDGE) + Standard_TypeMismatch::Raise("Invalid shape is given, must be a vector or an edge"); + + TopoDS_Edge anE = TopoDS::Edge(theShape); + + TopoDS_Vertex V1, V2; + TopExp::Vertices(anE, V1, V2, Standard_True); + + if (V1.IsNull() || V2.IsNull()) + Standard_NullObject::Raise("Invalid edge is given, it must have two points"); + + gp_Vec aV (BRep_Tool::Pnt(V1), BRep_Tool::Pnt(V2)); + if (aV.Magnitude() < gp::Resolution()) { + Standard_ConstructionError::Raise("Vector of zero length is given"); + } + + return aV; +} + +//======================================================================= +//function : ShapeToDouble +//purpose : used by CompareShapes::operator() +//======================================================================= +std::pair ShapeToDouble (const TopoDS_Shape& S, bool isOldSorting) +{ + // Computing of CentreOfMass + gp_Pnt GPoint; + double Len; + + if (S.ShapeType() == TopAbs_VERTEX) { + GPoint = BRep_Tool::Pnt(TopoDS::Vertex(S)); + Len = (double)S.Orientation(); + } + else { + GProp_GProps GPr; + // BEGIN: fix for Mantis issue 0020842 + if (isOldSorting) { + BRepGProp::LinearProperties(S, GPr); + } + else { + if (S.ShapeType() == TopAbs_EDGE || S.ShapeType() == TopAbs_WIRE) { + BRepGProp::LinearProperties(S, GPr); + } + else if (S.ShapeType() == TopAbs_FACE || S.ShapeType() == TopAbs_SHELL) { + BRepGProp::SurfaceProperties(S, GPr); + } + else { + BRepGProp::VolumeProperties(S, GPr); + } + } + // END: fix for Mantis issue 0020842 + GPoint = GPr.CentreOfMass(); + Len = GPr.Mass(); + } + + double dMidXYZ = GPoint.X() * 999.0 + GPoint.Y() * 99.0 + GPoint.Z() * 0.9; + return std::make_pair(dMidXYZ, Len); +} + +//======================================================================= +//function : CompareShapes::operator() +//purpose : used by std::sort(), called from SortShapes() +//======================================================================= +bool GEOMUtils::CompareShapes::operator() (const TopoDS_Shape& theShape1, + const TopoDS_Shape& theShape2) +{ + if (!myMap.IsBound(theShape1)) { + myMap.Bind(theShape1, ShapeToDouble(theShape1, myIsOldSorting)); + } + + if (!myMap.IsBound(theShape2)) { + myMap.Bind(theShape2, ShapeToDouble(theShape2, myIsOldSorting)); + } + + std::pair val1 = myMap.Find(theShape1); + std::pair val2 = myMap.Find(theShape2); + + double tol = Precision::Confusion(); + bool exchange = Standard_False; + + double dMidXYZ = val1.first - val2.first; + if (dMidXYZ >= tol) { + exchange = Standard_True; + } + else if (Abs(dMidXYZ) < tol) { + double dLength = val1.second - val2.second; + if (dLength >= tol) { + exchange = Standard_True; + } + else if (Abs(dLength) < tol && theShape1.ShapeType() <= TopAbs_FACE) { + // PAL17233 + // equal values possible on shapes such as two halves of a sphere and + // a membrane inside the sphere + Bnd_Box box1,box2; + BRepBndLib::Add(theShape1, box1); + if (!box1.IsVoid()) { + BRepBndLib::Add(theShape2, box2); + Standard_Real dSquareExtent = box1.SquareExtent() - box2.SquareExtent(); + if (dSquareExtent >= tol) { + exchange = Standard_True; + } + else if (Abs(dSquareExtent) < tol) { + Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax, val1, val2; + box1.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax); + val1 = (aXmin+aXmax)*999.0 + (aYmin+aYmax)*99.0 + (aZmin+aZmax)*0.9; + box2.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax); + val2 = (aXmin+aXmax)*999.0 + (aYmin+aYmax)*99.0 + (aZmin+aZmax)*0.9; + if ((val1 - val2) >= tol) { + exchange = Standard_True; + } + } + } + } + } + + //return val1 < val2; + return !exchange; +} + +//======================================================================= +//function : SortShapes +//purpose : +//======================================================================= +void GEOMUtils::SortShapes (TopTools_ListOfShape& SL, + const Standard_Boolean isOldSorting) +{ +#ifdef STD_SORT_ALGO + std::vector aShapesVec; + aShapesVec.reserve(SL.Extent()); + + TopTools_ListIteratorOfListOfShape it (SL); + for (; it.More(); it.Next()) { + aShapesVec.push_back(it.Value()); + } + SL.Clear(); + + CompareShapes shComp (isOldSorting); + std::stable_sort(aShapesVec.begin(), aShapesVec.end(), shComp); + //std::sort(aShapesVec.begin(), aShapesVec.end(), shComp); + + std::vector::const_iterator anIter = aShapesVec.begin(); + for (; anIter != aShapesVec.end(); ++anIter) { + SL.Append(*anIter); + } +#else + // old implementation + 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 { + // BEGIN: fix for Mantis issue 0020842 + if (isOldSorting) { + BRepGProp::LinearProperties (S, GPr); + } + else { + if (S.ShapeType() == TopAbs_EDGE || S.ShapeType() == TopAbs_WIRE) { + BRepGProp::LinearProperties (S, GPr); + } + else if (S.ShapeType() == TopAbs_FACE || S.ShapeType() == TopAbs_SHELL) { + BRepGProp::SurfaceProperties(S, GPr); + } + else { + BRepGProp::VolumeProperties(S, GPr); + } + } + // END: fix for Mantis issue 0020842 + GPoint = GPr.CentreOfMass(); + Length.SetValue(Index, GPr.Mass()); + } + MidXYZ.SetValue(Index, GPoint.X()*999.0 + GPoint.Y()*99.0 + GPoint.Z()*0.9); + //cout << Index << " L: " << Length(Index) << "CG: " << MidXYZ(Index) << endl; + } + + // Sorting + Standard_Integer aTemp; + Standard_Boolean exchange, Sort = Standard_True; + Standard_Real tol = Precision::Confusion(); + while (Sort) + { + Sort = Standard_False; + for (Index=1; Index < MaxShapes; Index++) + { + exchange = Standard_False; + Standard_Real dMidXYZ = MidXYZ(OrderInd(Index)) - MidXYZ(OrderInd(Index+1)); + Standard_Real dLength = Length(OrderInd(Index)) - Length(OrderInd(Index+1)); + if ( dMidXYZ >= tol ) { +// cout << "MidXYZ: " << MidXYZ(OrderInd(Index))<< " > " <= tol ) { +// cout << "Length: " << Length(OrderInd(Index))<< " > " <= tol ) { +// cout << "SquareExtent: " << box1.SquareExtent()<<" > "< val2; + if ((val1 - val2) >= tol) { + exchange = Standard_True; + } + //cout << "box: " << val1<<" > "< + +#include + +#include + +#include +#include + +#include + +#include + +inline Standard_Boolean IsEqual (const TopoDS_Shape& S1, const TopoDS_Shape& S2) +{ + return S1.IsSame(S2); +} + +class GEOMUtils { + + public: + /*! + * \brief Get Local Coordinate System, corresponding to the given shape. + * + * Origin of the LCS is situated at the shape's center of mass. + * Axes of the LCS are obtained from shape's location or, + * if the shape is a planar face, from position of its plane. + */ + Standard_EXPORT static gp_Ax3 GetPosition (const TopoDS_Shape& theShape); + + /*! + * \brief Get vector, defined by the given edge. + */ + Standard_EXPORT static gp_Vec GetVector (const TopoDS_Shape& theShape); + + /*! + * \brief Sort shapes in the list by their coordinates. + * \param SL The list of shapes to sort. + */ + struct CompareShapes : public std::binary_function + { + CompareShapes (bool isOldSorting) + : myIsOldSorting(isOldSorting) {} + + bool operator() (const TopoDS_Shape& lhs, const TopoDS_Shape& rhs); + + typedef NCollection_DataMap > GEOMUtils_DataMapOfShapeDouble; + GEOMUtils_DataMapOfShapeDouble myMap; + bool myIsOldSorting; + }; + + /*! + * \brief Sort shapes by their centers of mass, using formula X*999 + Y*99 + Z*0.9 + */ + Standard_EXPORT static void SortShapes (TopTools_ListOfShape& SL, + const Standard_Boolean isOldSorting = Standard_True); + + /*! + * \brief Convert TopoDS_COMPSOLID to TopoDS_COMPOUND. + * + * If the argument shape is not of type TopoDS_COMPSOLID, this method returns it as is. + * + * \param theCompsolid The compsolid to be converted. + * \retval TopoDS_Shape Returns the resulting compound. + */ + Standard_EXPORT static TopoDS_Shape CompsolidToCompound (const TopoDS_Shape& theCompsolid); + + /*! + * \brief Build a triangulation on \a theShape if it is absent. + * \param theShape The shape to check/build triangulation on. + * \retval bool Returns false if the shape has no faces, i.e. impossible to build triangulation. + */ + Standard_EXPORT static bool CheckTriangulation (const TopoDS_Shape& theShape); + + /*! + * \brief Return type of shape for explode. In case of compound it will be a type of its first sub shape. + * \param theShape The shape to get type of. + * \retval TopAbs_ShapeEnum Return type of shape for explode. + */ + Standard_EXPORT static TopAbs_ShapeEnum GetTypeOfSimplePart (const TopoDS_Shape& theShape); + +}; + +#endif diff --git a/src/GEOMUtils/Makefile.am b/src/GEOMUtils/Makefile.am new file mode 100644 index 000000000..844ac94f2 --- /dev/null +++ b/src/GEOMUtils/Makefile.am @@ -0,0 +1,57 @@ +# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, 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.salome-platform.org/ or email : webmaster.salome@opencascade.com + +# GEOMUtils : implementaion of some common methods for GEOMImpl package +# File : Makefile.am +# Author : Julia DOROVSKIKH + +include $(top_srcdir)/adm_local/unix/make_common_starter.am + +# Libraries targets +lib_LTLIBRARIES = libGEOMUtils.la + +# header files +salomeinclude_HEADERS = \ + GEOMUtils.hxx + +dist_libGEOMUtils_la_SOURCES = \ + GEOMUtils.cxx + +# additional information to compile and link file + +libGEOMUtils_la_CPPFLAGS = \ + $(CAS_CPPFLAGS) \ + $(KERNEL_CXXFLAGS) \ + $(BOOST_CPPFLAGS) \ + -I$(srcdir)/../ShHealOper \ + -I$(srcdir)/../NMTDS \ + -I$(srcdir)/../NMTTools \ + -I$(srcdir)/../BlockFix \ + -I$(srcdir)/../GEOMAlgo \ + -I$(srcdir)/../SKETCHER \ + -I$(srcdir)/../ARCHIMEDE + +libGEOMUtils_la_LDFLAGS = \ + ../BlockFix/libBlockFix.la \ + ../GEOMAlgo/libGEOMAlgo.la \ + ../ShHealOper/libShHealOper.la \ + ../ARCHIMEDE/libGEOMArchimede.la \ + ../SKETCHER/libGEOMSketcher.la \ + $(KERNEL_LDFLAGS) -lSALOMELocalTrace -lSALOMEBasics \ + $(CAS_LDPATH) -lTKCAF -lTKFillet -lTKOffset -lTKFeat \ + $(STDLIB) diff --git a/src/GEOM_I/GEOM_Gen_i.cc b/src/GEOM_I/GEOM_Gen_i.cc index 3dec74459..b034757f7 100644 --- a/src/GEOM_I/GEOM_Gen_i.cc +++ b/src/GEOM_I/GEOM_Gen_i.cc @@ -61,7 +61,7 @@ #include #include -#include "SALOMEDS_Tool.hxx" +#include //============================================================================ // function : GEOM_Gen_i() @@ -577,9 +577,6 @@ CORBA::Boolean GEOM_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent, // 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 (Study->Name()); - return true; } @@ -968,6 +965,9 @@ GEOM::ListOfGO* GEOM_Gen_i::RestoreSubShapes(SALOMEDS::Study_ptr theStudy, GEOM::GEOM_IGroupOperations_var aGroupOp = GetIGroupOperations(theStudy->StudyId()); GEOM::GEOM_ITransformOperations_var aTrsfOp = GetITransformOperations(theStudy->StudyId()); + PortableServer::Servant aServant = _poa->reference_to_servant(aTrsfOp.in()); + GEOM_ITransformOperations_i* aTrsfOpSv = dynamic_cast(aServant); + // Reconstruct arguments and tree of sub-shapes of the arguments CORBA::String_var anIOR; SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder(); @@ -998,7 +998,7 @@ GEOM::ListOfGO* GEOM_Gen_i::RestoreSubShapes(SALOMEDS::Study_ptr theStudy, case GEOM::FSM_MultiTransformed: { // Only for Multi-transformations - GEOM::GEOM_Object_var anArgOTrsf = aTrsfOp->TransformLikeOtherCopy(anArgO, theObject); + GEOM::GEOM_Object_var anArgOTrsf = aTrsfOpSv->TransformLikeOtherCopy(anArgO, theObject); if (!CORBA::is_nil(anArgOTrsf)) { CORBA::String_var anArgOTrsfEntry = anArgOTrsf->GetEntry(); Handle(GEOM_Object) anArgOTrsfImpl = _impl->GetObject(anArgOTrsf->GetStudyID(), anArgOTrsfEntry); @@ -1020,7 +1020,7 @@ GEOM::ListOfGO* GEOM_Gen_i::RestoreSubShapes(SALOMEDS::Study_ptr theStudy, { GEOMImpl_ITranslate aTI (anOFun); aMultiArgShape = GEOMImpl_ITransformOperations::TranslateShape1D(anArgOShape, &aTI); - //anArgOMulti = aTrsfOp->Translate1D(anArgO, , , ); + //anArgOMulti = aTrsfOpSv->Translate1D(anArgO, , , ); } break; case TRANSLATE_2D: @@ -1284,6 +1284,9 @@ GEOM::ListOfGO* GEOM_Gen_i::RestoreSubShapesOneLevel (SALOMEDS::Study_ptr th GEOM::GEOM_IGroupOperations_var aGroupOp = GetIGroupOperations(theStudy->StudyId()); GEOM::GEOM_ITransformOperations_var aTrsfOp = GetITransformOperations(theStudy->StudyId()); + PortableServer::Servant aServant = _poa->reference_to_servant(aTrsfOp.in()); + GEOM_ITransformOperations_i* aTrsfOpSv = dynamic_cast(aServant); + // Reconstruct published sub-shapes SALOMEDS::ChildIterator_var it = theStudy->NewChildIterator(theOldSO); @@ -1316,7 +1319,7 @@ GEOM::ListOfGO* GEOM_Gen_i::RestoreSubShapesOneLevel (SALOMEDS::Study_ptr th case GEOM::FSM_MultiTransformed: { // Only for Multi-transformations - GEOM::GEOM_Object_var anArgOTrsf = aTrsfOp->TransformLikeOtherCopy(anOldSubO, theNewO); + GEOM::GEOM_Object_var anArgOTrsf = aTrsfOpSv->TransformLikeOtherCopy(anOldSubO, theNewO); if (!CORBA::is_nil(anArgOTrsf)) { CORBA::String_var anArgOTrsfEntry = anArgOTrsf->GetEntry(); Handle(GEOM_Object) anArgOTrsfImpl = _impl->GetObject(anArgOTrsf->GetStudyID(), anArgOTrsfEntry); @@ -1559,6 +1562,9 @@ GEOM::ListOfGO* GEOM_Gen_i::RestoreGivenSubShapes(SALOMEDS::Study_ptr theStu GEOM::GEOM_IGroupOperations_var aGroupOp = GetIGroupOperations(theStudy->StudyId()); GEOM::GEOM_ITransformOperations_var aTrsfOp = GetITransformOperations(theStudy->StudyId()); + PortableServer::Servant aServant = _poa->reference_to_servant(aTrsfOp.in()); + GEOM_ITransformOperations_i* aTrsfOpSv = dynamic_cast(aServant); + // Reconstruct arguments and tree of sub-shapes of the arguments CORBA::String_var anIOR; SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder(); @@ -1589,7 +1595,7 @@ GEOM::ListOfGO* GEOM_Gen_i::RestoreGivenSubShapes(SALOMEDS::Study_ptr theStu case GEOM::FSM_MultiTransformed: { // Only for Multi-transformations - GEOM::GEOM_Object_var anArgOTrsf = aTrsfOp->TransformLikeOtherCopy(anArgO, theObject); + GEOM::GEOM_Object_var anArgOTrsf = aTrsfOpSv->TransformLikeOtherCopy(anArgO, theObject); if (!CORBA::is_nil(anArgOTrsf)) { CORBA::String_var anArgOTrsfEntry = anArgOTrsf->GetEntry(); Handle(GEOM_Object) anArgOTrsfImpl = _impl->GetObject(anArgOTrsf->GetStudyID(), anArgOTrsfEntry); @@ -1822,6 +1828,9 @@ GEOM::ListOfGO* GEOM_Gen_i::RestoreGivenSubShapesOneLevel (SALOMEDS::Study_ptr GEOM::GEOM_IGroupOperations_var aGroupOp = GetIGroupOperations(theStudy->StudyId()); GEOM::GEOM_ITransformOperations_var aTrsfOp = GetITransformOperations(theStudy->StudyId()); + PortableServer::Servant aServant = _poa->reference_to_servant(aTrsfOp.in()); + GEOM_ITransformOperations_i* aTrsfOpSv = dynamic_cast(aServant); + // Reconstruct published sub-shapes SALOMEDS::ChildIterator_var it = theStudy->NewChildIterator(theOldSO); @@ -1862,7 +1871,7 @@ GEOM::ListOfGO* GEOM_Gen_i::RestoreGivenSubShapesOneLevel (SALOMEDS::Study_ptr case GEOM::FSM_MultiTransformed: { // Only for Multi-transformations - GEOM::GEOM_Object_var anArgOTrsf = aTrsfOp->TransformLikeOtherCopy(anOldSubO, theNewO); + GEOM::GEOM_Object_var anArgOTrsf = aTrsfOpSv->TransformLikeOtherCopy(anOldSubO, theNewO); if (!CORBA::is_nil(anArgOTrsf)) { CORBA::String_var anArgOTrsfEntry = anArgOTrsf->GetEntry(); Handle(GEOM_Object) anArgOTrsfImpl = _impl->GetObject(anArgOTrsf->GetStudyID(), anArgOTrsfEntry); diff --git a/src/GEOM_I/GEOM_ICurvesOperations_i.cc b/src/GEOM_I/GEOM_ICurvesOperations_i.cc index 3f1a67800..88e381681 100644 --- a/src/GEOM_I/GEOM_ICurvesOperations_i.cc +++ b/src/GEOM_I/GEOM_ICurvesOperations_i.cc @@ -427,6 +427,46 @@ GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSplineInterpolation return GetObject(anObject); } +//============================================================================= +/*! + * MakeSplineInterpolWithTangents + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSplineInterpolWithTangents + (const GEOM::ListOfGO& thePoints, + GEOM::GEOM_Object_ptr theFirstVec, + GEOM::GEOM_Object_ptr theLastVec) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Get the reference points + int ind = 0; + int aLen = thePoints.length(); + std::list aPoints; + for (; ind < aLen; ind++) { + Handle(GEOM_Object) aPnt = GetObjectImpl(thePoints[ind]); + if (aPnt.IsNull()) return aGEOMObject._retn(); + aPoints.push_back(aPnt); + } + + //Get the reference vectors + Handle(GEOM_Object) aVec1 = GetObjectImpl(theFirstVec); + Handle(GEOM_Object) aVec2 = GetObjectImpl(theLastVec); + + if (aVec1.IsNull() || aVec2.IsNull()) return aGEOMObject._retn(); + + // Make Polyline + Handle(GEOM_Object) anObject = + GetOperations()->MakeSplineInterpolWithTangents(aPoints, aVec1, aVec2); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + //============================================================================= /*! * MakeCurveParametric diff --git a/src/GEOM_I/GEOM_ICurvesOperations_i.hh b/src/GEOM_I/GEOM_ICurvesOperations_i.hh index e50ab2111..07f4ce2a0 100644 --- a/src/GEOM_I/GEOM_ICurvesOperations_i.hh +++ b/src/GEOM_I/GEOM_ICurvesOperations_i.hh @@ -85,6 +85,10 @@ class GEOM_I_EXPORT GEOM_ICurvesOperations_i : CORBA::Boolean theIsClosed, CORBA::Boolean theDoReordering); + GEOM::GEOM_Object_ptr MakeSplineInterpolWithTangents (const GEOM::ListOfGO& thePoints, + GEOM::GEOM_Object_ptr theFirstVec, + GEOM::GEOM_Object_ptr theLastVec); + GEOM::GEOM_Object_ptr MakeCurveParametric (const char* thexExpr, const char* theyExpr, const char* thezExpr, double theParamMin, double theParamMax, double theParamStep, diff --git a/src/GEOM_I/GEOM_IMeasureOperations_i.cc b/src/GEOM_I/GEOM_IMeasureOperations_i.cc index ffbdcd5d4..b6132132c 100644 --- a/src/GEOM_I/GEOM_IMeasureOperations_i.cc +++ b/src/GEOM_I/GEOM_IMeasureOperations_i.cc @@ -18,7 +18,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #include @@ -273,6 +272,31 @@ void GEOM_IMeasureOperations_i::GetBoundingBox (GEOM::GEOM_Object_ptr theShape, GetOperations()->GetBoundingBox(aShape, Xmin, Xmax, Ymin, Ymax, Zmin, Zmax); } +//============================================================================= +/*! + * MakeBoundingBox + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IMeasureOperations_i::MakeBoundingBox + (GEOM::GEOM_Object_ptr theShape) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Get the reference shape + Handle(GEOM_Object) aShape = GetObjectImpl(theShape); + if (aShape.IsNull()) return aGEOMObject._retn(); + + // Make Box - bounding box of theShape + Handle(GEOM_Object) anObject = GetOperations()->GetBoundingBox(aShape); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + //============================================================================= /*! * GetTolerance @@ -494,6 +518,41 @@ CORBA::Double GEOM_IMeasureOperations_i::GetMinDistance return GetOperations()->GetMinDistance(aShape1, aShape2, X1, Y1, Z1, X2, Y2, Z2); } +//============================================================================= +/*! + * ClosestPoints + */ +//============================================================================= +CORBA::Long GEOM_IMeasureOperations_i::ClosestPoints + (GEOM::GEOM_Object_ptr theShape1, GEOM::GEOM_Object_ptr theShape2, + GEOM::ListOfDouble_out theCoords) +{ + //Set a not done flag + GetOperations()->SetNotDone(); + + // allocate the CORBA array + int nbSols = 0; + GEOM::ListOfDouble_var aDoublesArray = new GEOM::ListOfDouble(); + + //Get the reference shape + Handle(GEOM_Object) aShape1 = GetObjectImpl(theShape1); + Handle(GEOM_Object) aShape2 = GetObjectImpl(theShape2); + + if (!aShape1.IsNull() && !aShape2.IsNull()) { + Handle(TColStd_HSequenceOfReal) aDoubles = new TColStd_HSequenceOfReal; + // Get shape parameters + nbSols = GetOperations()->ClosestPoints(aShape1, aShape2, aDoubles); + int nbDbls = aDoubles->Length(); + aDoublesArray->length(nbDbls); + for (int id = 0; id < nbDbls; id++) { + aDoublesArray[id] = aDoubles->Value(id + 1); + } + } + + theCoords = aDoublesArray._retn(); + return nbSols; +} + //============================================================================= /*! * PointCoordinates diff --git a/src/GEOM_I/GEOM_IMeasureOperations_i.hh b/src/GEOM_I/GEOM_IMeasureOperations_i.hh index 4534dc45e..e8269bd22 100644 --- a/src/GEOM_I/GEOM_IMeasureOperations_i.hh +++ b/src/GEOM_I/GEOM_IMeasureOperations_i.hh @@ -18,7 +18,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #ifndef _GEOM_IMeasureOperations_i_HeaderFile #define _GEOM_IMeasureOperations_i_HeaderFile @@ -75,6 +74,8 @@ class GEOM_I_EXPORT GEOM_IMeasureOperations_i : CORBA::Double& Ymin, CORBA::Double& Ymax, CORBA::Double& Zmin, CORBA::Double& Zmax); + GEOM::GEOM_Object_ptr MakeBoundingBox (GEOM::GEOM_Object_ptr theShape); + void GetTolerance (GEOM::GEOM_Object_ptr theShape, CORBA::Double& FaceMin, CORBA::Double& FaceMax, CORBA::Double& EdgeMin, CORBA::Double& EdgeMax, @@ -102,6 +103,10 @@ class GEOM_I_EXPORT GEOM_IMeasureOperations_i : CORBA::Double& X1, CORBA::Double& Y1, CORBA::Double& Z1, CORBA::Double& X2, CORBA::Double& Y2, CORBA::Double& Z2); + CORBA::Long ClosestPoints (GEOM::GEOM_Object_ptr theShape1, + GEOM::GEOM_Object_ptr theShape2, + GEOM::ListOfDouble_out theCoords); + void PointCoordinates (GEOM::GEOM_Object_ptr theShape, CORBA::Double& X, CORBA::Double& Y, CORBA::Double& Z); diff --git a/src/GEOM_I/GEOM_IShapesOperations_i.cc b/src/GEOM_I/GEOM_IShapesOperations_i.cc index cee18553c..cd3aac8aa 100644 --- a/src/GEOM_I/GEOM_IShapesOperations_i.cc +++ b/src/GEOM_I/GEOM_IShapesOperations_i.cc @@ -831,6 +831,49 @@ CORBA::Long GEOM_IShapesOperations_i::GetSubShapeIndex return anID; } +//============================================================================= +/*! + * GetSubShapesIndices + */ +//============================================================================= +GEOM::ListOfLong* GEOM_IShapesOperations_i::GetSubShapesIndices + (GEOM::GEOM_Object_ptr theMainShape, const GEOM::ListOfGO& theSubShapes) +{ + GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong; + + //Get the reference main shape + Handle(GEOM_Object) aMainShapeRef = GetObjectImpl(theMainShape); + if (aMainShapeRef.IsNull()) return aSeq._retn(); + + //Get the subshapes + std::list aShapes; + int aLen = theSubShapes.length(); + for (int ind = 0; ind < aLen; ind++) { + Handle(GEOM_Object) aSh = GetObjectImpl(theSubShapes[ind]); + if (aSh.IsNull()) + { + MESSAGE("NULL shape") + return aSeq._retn(); + } + aShapes.push_back(aSh); + } + + //Get the IDs of inside + Handle(TColStd_HSequenceOfInteger) aHSeq = + GetOperations()->GetSubShapesIndices(aMainShapeRef, aShapes); + + if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn(); + + Standard_Integer aLength = aHSeq->Length(); + aSeq->length(aLength); + + for (Standard_Integer i = 1; i <= aLength; i++) + aSeq[i-1] = aHSeq->Value(i); + + return aSeq._retn(); +} + + //============================================================================= /*! * GetTopologyIndex diff --git a/src/GEOM_I/GEOM_IShapesOperations_i.hh b/src/GEOM_I/GEOM_IShapesOperations_i.hh index c01b6317e..41def03a9 100644 --- a/src/GEOM_I/GEOM_IShapesOperations_i.hh +++ b/src/GEOM_I/GEOM_IShapesOperations_i.hh @@ -128,6 +128,9 @@ class GEOM_I_EXPORT GEOM_IShapesOperations_i : CORBA::Long GetSubShapeIndex (GEOM::GEOM_Object_ptr theMainShape, GEOM::GEOM_Object_ptr theSubShape); + + GEOM::ListOfLong* GetSubShapesIndices (GEOM::GEOM_Object_ptr theMainShape, + const GEOM::ListOfGO& theSubShapes); CORBA::Long GetTopologyIndex (GEOM::GEOM_Object_ptr theMainShape, GEOM::GEOM_Object_ptr theSubShape); diff --git a/src/GEOM_I/GEOM_ITransformOperations_i.cc b/src/GEOM_I/GEOM_ITransformOperations_i.cc index 59bc4a293..05b132959 100644 --- a/src/GEOM_I/GEOM_ITransformOperations_i.cc +++ b/src/GEOM_I/GEOM_ITransformOperations_i.cc @@ -18,7 +18,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #include @@ -958,7 +957,7 @@ GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiTranslate1D //Get the vector of translation Handle(GEOM_Object) aVector = GetObjectImpl(theVector); - if (aVector.IsNull()) return aGEOMObject._retn(); + //if (aVector.IsNull()) return aGEOMObject._retn(); // DX by default //Perform the translation Handle(GEOM_Object) anObject = @@ -992,11 +991,11 @@ GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiTranslate2D (GEOM::GEOM_ //Get the vector1 of translation Handle(GEOM_Object) aVector1 = GetObjectImpl(theVector1); - if (aVector1.IsNull()) return aGEOMObject._retn(); + //if (aVector1.IsNull()) return aGEOMObject._retn(); // DX by default //Get the vector2 of translation Handle(GEOM_Object) aVector2 = GetObjectImpl(theVector2); - if (aVector2.IsNull()) return aGEOMObject._retn(); + //if (aVector2.IsNull()) return aGEOMObject._retn(); // DY by default //Perform the translation Handle(GEOM_Object) anObject = GetOperations()->Translate2D @@ -1026,7 +1025,7 @@ GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiRotate1D (GEOM::GEOM_Obj //Get the a directon of rotation Handle(GEOM_Object) aVector = GetObjectImpl(theVector); - if (aVector.IsNull()) return aGEOMObject._retn(); + //if (aVector.IsNull()) return aGEOMObject._retn(); // DZ by default //Perform the rotation Handle(GEOM_Object) anObject = GetOperations()->Rotate1D(aBasicObject, aVector, theNbTimes); @@ -1035,6 +1034,101 @@ GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiRotate1D (GEOM::GEOM_Obj return GetObject(anObject); } +//============================================================================= +/*! + * MultiRotate1DByStep + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiRotate1DByStep (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr theVector, + CORBA::Double theAngleStep, + CORBA::Long theNbSteps) +{ + //Set a not done flag + GetOperations()->SetNotDone(); + + GEOM::GEOM_Object_var aGEOMObject; + + //Get the object itself + Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject); + if (aBasicObject.IsNull()) return aGEOMObject._retn(); + + //Get the a directon of rotation + Handle(GEOM_Object) aVector = GetObjectImpl(theVector); + //if (aVector.IsNull()) return aGEOMObject._retn(); // DZ by default + + //Perform the rotation + Handle(GEOM_Object) anObject = GetOperations()->Rotate1D(aBasicObject, aVector, theAngleStep, theNbSteps); + if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MultiRotate2DNbTimes + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiRotate2DNbTimes (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr theVector, + CORBA::Long theNbObjects, + CORBA::Double theRadialStep, + CORBA::Long theNbSteps) +{ + //Set a not done flag + GetOperations()->SetNotDone(); + + GEOM::GEOM_Object_var aGEOMObject; + + //Get the object itself + Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject); + if (aBasicObject.IsNull()) return aGEOMObject._retn(); + + //Get the a directon of rotation + Handle(GEOM_Object) aVector = GetObjectImpl(theVector); + //if (aVector.IsNull()) return aGEOMObject._retn(); // DZ by default + + //Perform the rotation + Handle(GEOM_Object) anObject = GetOperations()->Rotate2D + (aBasicObject, aVector, theNbObjects, theRadialStep, theNbSteps); + if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MultiRotate2DByStep + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiRotate2DByStep (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr theVector, + CORBA::Double theAngle, + CORBA::Long theNbTimes1, + CORBA::Double theStep, + CORBA::Long theNbTimes2) +{ + //Set a not done flag + GetOperations()->SetNotDone(); + + GEOM::GEOM_Object_var aGEOMObject; + + //Get the object itself + Handle(GEOM_Object) aBasicObject = GetObjectImpl(theObject); + if (aBasicObject.IsNull()) return aGEOMObject._retn(); + + //Get the a directon of rotation + Handle(GEOM_Object) aVector = GetObjectImpl(theVector); + //if (aVector.IsNull()) return aGEOMObject._retn(); // DZ by default + + //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); +} + //============================================================================= /*! * MultiRotate2D @@ -1058,11 +1152,13 @@ GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiRotate2D (GEOM::GEOM_Obj //Get the a directon of rotation Handle(GEOM_Object) aVector = GetObjectImpl(theVector); - if (aVector.IsNull()) return aGEOMObject._retn(); + //if (aVector.IsNull()) return aGEOMObject._retn(); // DZ by default + + double anAngle = M_PI * theAngle / 180.; //Perform the rotation Handle(GEOM_Object) anObject = GetOperations()->Rotate2D - (aBasicObject, aVector, theAngle, theNbTimes1, theStep, theNbTimes2); + (aBasicObject, aVector, anAngle, 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 index f01f08c22..7f7964ce4 100644 --- a/src/GEOM_I/GEOM_ITransformOperations_i.hh +++ b/src/GEOM_I/GEOM_ITransformOperations_i.hh @@ -18,7 +18,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #ifndef _GEOM_ITransformOperations_i_HeaderFile #define _GEOM_ITransformOperations_i_HeaderFile @@ -39,17 +38,17 @@ class GEOM_I_EXPORT GEOM_ITransformOperations_i : { public: GEOM_ITransformOperations_i (PortableServer::POA_ptr thePOA, - GEOM::GEOM_Gen_ptr theEngine, - ::GEOMImpl_ITransformOperations* theImpl); + 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 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 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); @@ -59,15 +58,15 @@ class GEOM_I_EXPORT GEOM_ITransformOperations_i : 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 theVector); GEOM::GEOM_Object_ptr TranslateVectorCopy (GEOM::GEOM_Object_ptr theObject, - GEOM::GEOM_Object_ptr theVector); + GEOM::GEOM_Object_ptr theVector); GEOM::GEOM_Object_ptr TranslateVectorDistance (GEOM::GEOM_Object_ptr theObject, - GEOM::GEOM_Object_ptr theVector, - CORBA::Double theDistance, - CORBA::Boolean theCopy); + GEOM::GEOM_Object_ptr theVector, + CORBA::Double theDistance, + CORBA::Boolean theCopy); GEOM::GEOM_Object_ptr MultiTranslate1D (GEOM::GEOM_Object_ptr theObject, GEOM::GEOM_Object_ptr theVector, @@ -81,93 +80,111 @@ class GEOM_I_EXPORT GEOM_ITransformOperations_i : GEOM::GEOM_Object_ptr Rotate (GEOM::GEOM_Object_ptr theObject, GEOM::GEOM_Object_ptr theAxis, - CORBA::Double theAngle); + 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 theVector, + CORBA::Long theNbTimes); + + GEOM::GEOM_Object_ptr MultiRotate1DByStep (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr theAxis, + CORBA::Double theAngleStep, + CORBA::Long theNbSteps); + + GEOM::GEOM_Object_ptr MultiRotate2DNbTimes (GEOM::GEOM_Object_ptr theObject, + GEOM::GEOM_Object_ptr theAxis, + CORBA::Long theNbObjects, + CORBA::Double theRadialStep, + CORBA::Long theNbSteps); + + GEOM::GEOM_Object_ptr MultiRotate2DByStep (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 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 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 theAxis, + CORBA::Double theAngle); GEOM::GEOM_Object_ptr MirrorPlane (GEOM::GEOM_Object_ptr theObject, - GEOM::GEOM_Object_ptr thePlane); + GEOM::GEOM_Object_ptr thePlane); GEOM::GEOM_Object_ptr MirrorPlaneCopy (GEOM::GEOM_Object_ptr theObject, - GEOM::GEOM_Object_ptr thePlane); + GEOM::GEOM_Object_ptr thePlane); GEOM::GEOM_Object_ptr MirrorAxis (GEOM::GEOM_Object_ptr theObject, - GEOM::GEOM_Object_ptr theAxis); + GEOM::GEOM_Object_ptr theAxis); GEOM::GEOM_Object_ptr MirrorAxisCopy (GEOM::GEOM_Object_ptr theObject, - GEOM::GEOM_Object_ptr theAxis); + GEOM::GEOM_Object_ptr theAxis); GEOM::GEOM_Object_ptr MirrorPoint (GEOM::GEOM_Object_ptr theObject, - GEOM::GEOM_Object_ptr thePoint); + GEOM::GEOM_Object_ptr thePoint); GEOM::GEOM_Object_ptr MirrorPointCopy (GEOM::GEOM_Object_ptr theObject, - GEOM::GEOM_Object_ptr thePoint); + GEOM::GEOM_Object_ptr thePoint); GEOM::GEOM_Object_ptr OffsetShape (GEOM::GEOM_Object_ptr theObject, - CORBA::Double theOffset); + CORBA::Double theOffset); GEOM::GEOM_Object_ptr OffsetShapeCopy (GEOM::GEOM_Object_ptr theObject, - CORBA::Double theOffset); + CORBA::Double theOffset); GEOM::GEOM_Object_ptr ProjectShapeCopy (GEOM::GEOM_Object_ptr theSource, GEOM::GEOM_Object_ptr theTarget); GEOM::GEOM_Object_ptr ScaleShape (GEOM::GEOM_Object_ptr theObject, - GEOM::GEOM_Object_ptr thePoint, - CORBA::Double theFactor); + 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 thePoint, + CORBA::Double theFactor); GEOM::GEOM_Object_ptr ScaleShapeAlongAxes (GEOM::GEOM_Object_ptr theObject, - GEOM::GEOM_Object_ptr thePoint, - CORBA::Double theFactorX, - CORBA::Double theFactorY, - CORBA::Double theFactorZ); + GEOM::GEOM_Object_ptr thePoint, + CORBA::Double theFactorX, + CORBA::Double theFactorY, + CORBA::Double theFactorZ); GEOM::GEOM_Object_ptr ScaleShapeAlongAxesCopy (GEOM::GEOM_Object_ptr theObject, - GEOM::GEOM_Object_ptr thePoint, - CORBA::Double theFactorX, - CORBA::Double theFactorY, - CORBA::Double theFactorZ); + GEOM::GEOM_Object_ptr thePoint, + CORBA::Double theFactorX, + CORBA::Double theFactorY, + CORBA::Double theFactorZ); GEOM::GEOM_Object_ptr PositionShape (GEOM::GEOM_Object_ptr theObject, - GEOM::GEOM_Object_ptr theStartLCS, - GEOM::GEOM_Object_ptr theEndLCS); + 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); + GEOM::GEOM_Object_ptr theStartLCS, + GEOM::GEOM_Object_ptr theEndLCS); GEOM::GEOM_Object_ptr PositionAlongPath (GEOM::GEOM_Object_ptr theObject, - GEOM::GEOM_Object_ptr thePath, - CORBA::Double theDistance, - CORBA::Boolean theCopy, - CORBA::Boolean theReverse); + GEOM::GEOM_Object_ptr thePath, + CORBA::Double theDistance, + CORBA::Boolean theCopy, + CORBA::Boolean theReverse); GEOM::GEOM_Object_ptr RotateThreePoints (GEOM::GEOM_Object_ptr theObject, - GEOM::GEOM_Object_ptr theCentPoint, - GEOM::GEOM_Object_ptr thePoint1, - GEOM::GEOM_Object_ptr thePoint2); + GEOM::GEOM_Object_ptr theCentPoint, + GEOM::GEOM_Object_ptr thePoint1, + GEOM::GEOM_Object_ptr thePoint2); GEOM::GEOM_Object_ptr RotateThreePointsCopy (GEOM::GEOM_Object_ptr theObject, - GEOM::GEOM_Object_ptr theCentPoint, - GEOM::GEOM_Object_ptr thePoint1, - GEOM::GEOM_Object_ptr thePoint2); + GEOM::GEOM_Object_ptr theCentPoint, + GEOM::GEOM_Object_ptr thePoint1, + GEOM::GEOM_Object_ptr thePoint2); GEOM::GEOM_Object_ptr TransformLikeOtherCopy (GEOM::GEOM_Object_ptr theObject, GEOM::GEOM_Object_ptr theSample); diff --git a/src/GEOM_I/GEOM_Object_i.cc b/src/GEOM_I/GEOM_Object_i.cc index bc8afb0f9..649e2fa2e 100644 --- a/src/GEOM_I/GEOM_Object_i.cc +++ b/src/GEOM_I/GEOM_Object_i.cc @@ -206,7 +206,7 @@ char* GEOM_Object_i::GetName() char* aName = _impl->GetName(); if (aName) return aName; // this is already copy of pointer (see implementation of _impl) - return strdup(""); + return CORBA::string_dup(""); } //============================================================================= diff --git a/src/GEOM_I/GEOM_wrap.hxx b/src/GEOM_I/GEOM_wrap.hxx new file mode 100644 index 000000000..71fbbf773 --- /dev/null +++ b/src/GEOM_I/GEOM_wrap.hxx @@ -0,0 +1,59 @@ +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 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.com +// +// File : GEOM_wrap.hxx +// Created : Mon Dec 24 14:39:49 2012 +// Author : Edward AGAPOV (eap) + + +#ifndef __GEOM_wrap_HXX__ +#define __GEOM_wrap_HXX__ + +#include + +namespace GEOM +{ + // Declare a type GEOM::GEOM_Object_wrap to replace GEOM::GEOM_Object_var, + // to be used in the case if a new GEOM_Object is received, in which case + // obj->UnRegister() must be called to avoid a memory leak. + // The GEOM::GEOM_Object_wrap object calls UnRegister() at destruction. + // A simple rule: use GEOM::GEOM_Object_wrap if an object is returned by a + // GEOM operation (GEOM::GEOM_IBasicOperations etc). + // + typedef SALOME::GenericObj_wrap< GEOM_Object > GEOM_Object_wrap; + // + // wrappers of operations + typedef SALOME::GenericObj_wrap< GEOM_IBasicOperations > GEOM_IBasicOperations_wrap; + typedef SALOME::GenericObj_wrap< GEOM_ITransformOperations> GEOM_ITransformOperations_wrap; + typedef SALOME::GenericObj_wrap< GEOM_I3DPrimOperations > GEOM_I3DPrimOperations_wrap; + typedef SALOME::GenericObj_wrap< GEOM_IShapesOperations > GEOM_IShapesOperations_wrap; + typedef SALOME::GenericObj_wrap< GEOM_IBlocksOperations > GEOM_IBlocksOperations_wrap; + typedef SALOME::GenericObj_wrap< GEOM_IBooleanOperations > GEOM_IBooleanOperations_wrap; + typedef SALOME::GenericObj_wrap< GEOM_ICurvesOperations > GEOM_ICurvesOperations_wrap; + typedef SALOME::GenericObj_wrap< GEOM_ILocalOperations > GEOM_ILocalOperations_wrap; + typedef SALOME::GenericObj_wrap< GEOM_IHealingOperations > GEOM_IHealingOperations_wrap; + typedef SALOME::GenericObj_wrap< GEOM_IInsertOperations > GEOM_IInsertOperations_wrap; + typedef SALOME::GenericObj_wrap< GEOM_IMeasureOperations > GEOM_IMeasureOperations_wrap; + typedef SALOME::GenericObj_wrap< GEOM_IGroupOperations > GEOM_IGroupOperations_wrap; + typedef SALOME::GenericObj_wrap< GEOM_IAdvancedOperations > GEOM_IAdvancedOperations_wrap; +} + +#endif diff --git a/src/GEOM_I/Makefile.am b/src/GEOM_I/Makefile.am index b5cd51165..16383a10c 100644 --- a/src/GEOM_I/Makefile.am +++ b/src/GEOM_I/Makefile.am @@ -22,7 +22,6 @@ # Author : Patrick GOLDBRONN (CEA) # Modified by : Alexander BORODIN (OCN) - autotools usage # Module : GEOM -# $Header$ include $(top_srcdir)/adm_local/unix/make_common_starter.am @@ -47,7 +46,8 @@ salomeinclude_HEADERS = \ GEOM_IGroupOperations_i.hh \ GEOM_IAdvancedOperations_i.hh \ GEOM_Gen_i.hh \ - GEOM_GEOM_I.hxx + GEOM_GEOM_I.hxx \ + GEOM_wrap.hxx dist_libGEOMEngine_la_SOURCES = \ GEOM_Object_i.cc \ diff --git a/src/GEOM_I_Superv/Makefile.am b/src/GEOM_I_Superv/Makefile.am index e24863482..ef8ef7aff 100644 --- a/src/GEOM_I_Superv/Makefile.am +++ b/src/GEOM_I_Superv/Makefile.am @@ -22,7 +22,6 @@ # Author : Patrick GOLDBRONN (CEA) # Modified by : Alexander BORODIN (OCN) - autotools usage # Module : GEOM -# $Header$ # Libraries targets include $(top_srcdir)/adm_local/unix/make_common_starter.am diff --git a/src/GEOM_SWIG/GEOM_ObjectInfo.py b/src/GEOM_SWIG/GEOM_ObjectInfo.py index 8678a9de6..fb2ab3e15 100644 --- a/src/GEOM_SWIG/GEOM_ObjectInfo.py +++ b/src/GEOM_SWIG/GEOM_ObjectInfo.py @@ -22,7 +22,6 @@ # File : GEOM_ObjectInfo.py # Author : Michael ZORIN # Module : GEOM -# $Header: # import salome import geompy diff --git a/src/GEOM_SWIG/GEOM_Sketcher.py b/src/GEOM_SWIG/GEOM_Sketcher.py index e67172c27..ade5407af 100644 --- a/src/GEOM_SWIG/GEOM_Sketcher.py +++ b/src/GEOM_SWIG/GEOM_Sketcher.py @@ -25,7 +25,6 @@ # File : GEOM_Sketcher.py # Author : Damien COQUERET, Open CASCADE # Module : GEOM -# $Header$ # import geompy diff --git a/src/GEOM_SWIG/GEOM_TestAll.py b/src/GEOM_SWIG/GEOM_TestAll.py index 3b9381772..467463400 100644 --- a/src/GEOM_SWIG/GEOM_TestAll.py +++ b/src/GEOM_SWIG/GEOM_TestAll.py @@ -102,6 +102,8 @@ def TestAll (geompy, math): Polyline = geompy.MakePolyline([p0, pz, py, p200]) #(List of GEOM_Object)->GEOM_Object Bezier = geompy.MakeBezier([p0, pz, p200, px]) #(List of GEOM_Object)->GEOM_Object Interpol = geompy.MakeInterpol([px, py, p200, pxyz], True) #(List of GEOM_Object,Boolean)->GEOM_Object + InterpT1 = geompy.MakeInterpolWithTangents([px, py, pxyz], vx, vz) #(List of GO, GO, GO)->GEOM_Object + InterpT2 = geompy.MakeInterpolWithTangents([px, py, pxyz], vxy, vxyz) #(List of GO, GO, GO)->GEOM_Object 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 @@ -288,9 +290,10 @@ def TestAll (geompy, math): #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) + MultiRot1Dt = geompy.MultiRotate1DNbTimes(Chamfer, vx, nbtimes1) + MultiRot1Ds = geompy.MultiRotate1DByStep(Chamfer, vx, math.pi/4., nbtimes1) + MultiRot2Dt = geompy.MultiRotate2DNbTimes(Chamfer, vx, nbtimes1, step1, nbtimes2) + MultiRot2Ds = geompy.MultiRotate2DByStep(Chamfer, vx, angle1, nbtimes1, step1, nbtimes2) #Create Informations objects CDG = geompy.MakeCDG(Prism) #(GEOM_Object)->GEOM_Object @@ -343,6 +346,8 @@ def TestAll (geompy, math): id_Polyline = geompy.addToStudy(Polyline, "Polyline") id_Bezier = geompy.addToStudy(Bezier, "Bezier") id_Interpol = geompy.addToStudy(Interpol, "Interpol") + id_InterpT1 = geompy.addToStudy(InterpT1, "InterpT1") + id_InterpT2 = geompy.addToStudy(InterpT2, "InterpT2") id_Sketcher = geompy.addToStudy(Sketcher, "Sketcher") id_Sketcher3d_1 = geompy.addToStudy(Sketcher3d_1, "Sketcher 3D by interface") @@ -462,8 +467,10 @@ def TestAll (geompy, math): 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_MultiRot1Dt = geompy.addToStudy(MultiRot1Dt, "MultiRot1D NbTimes") + id_MultiRot1Ds = geompy.addToStudy(MultiRot1Ds, "MultiRot1D ByStep") + id_MultiRot2Dt = geompy.addToStudy(MultiRot2Dt, "MultiRot2D NbTimes") + id_MultiRot2Ds = geompy.addToStudy(MultiRot2Ds, "MultiRot2D ByStep") id_CDG = geompy.addToStudy(CDG, "CDG") id_Archimede = geompy.addToStudy(Archimede, "Archimede") diff --git a/src/GEOM_SWIG/GEOM_TestMeasures.py b/src/GEOM_SWIG/GEOM_TestMeasures.py index 1621f2bf4..cd9c07dd0 100644 --- a/src/GEOM_SWIG/GEOM_TestMeasures.py +++ b/src/GEOM_SWIG/GEOM_TestMeasures.py @@ -19,7 +19,6 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# def TestMeasureOperations (geompy, math): @@ -98,6 +97,8 @@ def TestMeasureOperations (geompy, math): print " Xmin = ", BB[0], ", Xmax = ", BB[1] print " Ymin = ", BB[2], ", Ymax = ", BB[3] print " Zmin = ", BB[4], ", Zmax = ", BB[5] + BB = geompy.MakeBoundingBox(box) + geompy.addToStudy(BB, "BoundingBox") ####### Inertia ####### @@ -163,6 +164,16 @@ def TestMeasureOperations (geompy, math): print "\nMinimal distance between Box and Cube = ", MinDistComps[0] print "Its components are (", MinDistComps[1], ", ", MinDistComps[2], ", ", MinDistComps[3], ")" + # Get all closest points + [nbSols, listCoords] = geompy.ClosestPoints(box, cube) + for i in range(nbSols): + v1 = geompy.MakeVertex(listCoords[i*6 + 0], listCoords[i*6 + 1], listCoords[i*6 + 2]) + v2 = geompy.MakeVertex(listCoords[i*6 + 3], listCoords[i*6 + 4], listCoords[i*6 + 5]) + + geompy.addToStudy(v1, 'MinDist_%d_on_Box'%(i+1)) + geompy.addToStudy(v2, 'MinDist_%d_on_Cube'%(i+1)) + pass + ####### Angle ####### OX = geompy.MakeVectorDXDYDZ(10, 0,0) diff --git a/src/GEOM_SWIG/GEOM_TestOthers.py b/src/GEOM_SWIG/GEOM_TestOthers.py index 4f85d8183..5ed4cbaab 100644 --- a/src/GEOM_SWIG/GEOM_TestOthers.py +++ b/src/GEOM_SWIG/GEOM_TestOthers.py @@ -23,7 +23,6 @@ # File : GEOM_TestOthers.py # Author : Julia DOROVSKIKH # Module : GEOM -# $Header$ # # ! Please, if you edit this example file, update also # ! GEOM_SRC/doc/salome/gui/GEOM/input/tui_test_others.doc @@ -187,11 +186,16 @@ def TestOtherOperations (geompy, math): 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) + MultiRot1Dt = geompy.MakeMultiRotation1DNbTimes(f12, vy, pz, 6) + MultiRot1Ds = geompy.MakeMultiRotation1DByStep(f12, vy, pz, math.pi/5., 6) - id_MultiRot1D = geompy.addToStudy(MultiRot1D, "MakeMultiRotation1D") - id_MultiRot2D = geompy.addToStudy(MultiRot2D, "MakeMultiRotation2D") + MultiRot2Dt = geompy.MakeMultiRotation2DNbTimes(f12, vy, pz, 5, 30, 3) + MultiRot2Ds = geompy.MakeMultiRotation2DByStep(f12, vy, pz, math.pi/4., 6, 30, 3) + + geompy.addToStudy(MultiRot1Dt, "MakeMultiRotation1DNbTimes") + geompy.addToStudy(MultiRot1Ds, "MakeMultiRotation1DByStep") + geompy.addToStudy(MultiRot2Dt, "MakeMultiRotation2DNbTimes") + geompy.addToStudy(MultiRot2Ds, "MakeMultiRotation2DByStep") # MakeFilletAll radius_fillet = 10. diff --git a/src/GEOM_SWIG/GEOM_blocks.py b/src/GEOM_SWIG/GEOM_blocks.py index 3acf5f5fa..6ad689eb0 100644 --- a/src/GEOM_SWIG/GEOM_blocks.py +++ b/src/GEOM_SWIG/GEOM_blocks.py @@ -25,7 +25,6 @@ # File : GEOM_blocks.py # Author : Julia DOROVSKIKH # Module : GEOM -# $Header$ # import salome import geompy diff --git a/src/GEOM_SWIG/GEOM_example.py b/src/GEOM_SWIG/GEOM_example.py index 4e7e6bd97..b4b66046e 100644 --- a/src/GEOM_SWIG/GEOM_example.py +++ b/src/GEOM_SWIG/GEOM_example.py @@ -25,7 +25,6 @@ # File : GEOM_example.py # Author : Paul RASCLE, EDF # Module : GEOM -# $Header$ # import salome import geompy diff --git a/src/GEOM_SWIG/GEOM_example2.py b/src/GEOM_SWIG/GEOM_example2.py index 9c18c56cf..accb3eb6d 100644 --- a/src/GEOM_SWIG/GEOM_example2.py +++ b/src/GEOM_SWIG/GEOM_example2.py @@ -25,7 +25,6 @@ # File : GEOM_example2.py # Author : Paul RASCLE, EDF # Module : GEOM -# $Header$ # import salome import geompy diff --git a/src/GEOM_SWIG/GEOM_example3.py b/src/GEOM_SWIG/GEOM_example3.py index 8e8c4b40b..2537a9fe5 100644 --- a/src/GEOM_SWIG/GEOM_example3.py +++ b/src/GEOM_SWIG/GEOM_example3.py @@ -25,7 +25,6 @@ # File : GEOM_example3.py # Author : Paul RASCLE, EDF # Module : GEOM -# $Header$ # import salome import geompy diff --git a/src/GEOM_SWIG/GEOM_example5.py b/src/GEOM_SWIG/GEOM_example5.py index 4caaeb7ac..767596185 100644 --- a/src/GEOM_SWIG/GEOM_example5.py +++ b/src/GEOM_SWIG/GEOM_example5.py @@ -25,7 +25,6 @@ # File : GEOM_example5.py # Author : Damien COQUERET, Open CASCADE # Module : GEOM -# $Header$ # import salome import geompy diff --git a/src/GEOM_SWIG/GEOM_example6.py b/src/GEOM_SWIG/GEOM_example6.py index 0041e1c4a..e168d341c 100755 --- a/src/GEOM_SWIG/GEOM_example6.py +++ b/src/GEOM_SWIG/GEOM_example6.py @@ -22,7 +22,6 @@ # File : GEOM_example6.py # Author : Dmitry MATVEITChEV # Module : GEOM -# $Header$ # import salome import geompy diff --git a/src/GEOM_SWIG/GEOM_moteur.py b/src/GEOM_SWIG/GEOM_moteur.py index b39172c3a..436030004 100644 --- a/src/GEOM_SWIG/GEOM_moteur.py +++ b/src/GEOM_SWIG/GEOM_moteur.py @@ -25,7 +25,6 @@ # File : GEOM_moteur.py # Author : Damien COQUERET, Open CASCADE # Module : GEOM -# $Header$ # import salome import geompy diff --git a/src/GEOM_SWIG/GEOM_usinggeom.py b/src/GEOM_SWIG/GEOM_usinggeom.py index 5093069d5..b62e7ce75 100644 --- a/src/GEOM_SWIG/GEOM_usinggeom.py +++ b/src/GEOM_SWIG/GEOM_usinggeom.py @@ -25,7 +25,6 @@ # File : GEOM_usinggeom.py # Author : Damien COQUERET, Open CASCADE # Module : GEOM -# $Header$ # import geompy import math diff --git a/src/GEOM_SWIG/batchmode_geompy.py b/src/GEOM_SWIG/batchmode_geompy.py index 9d45b34ac..0dfacfaaf 100644 --- a/src/GEOM_SWIG/batchmode_geompy.py +++ b/src/GEOM_SWIG/batchmode_geompy.py @@ -21,11 +21,10 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -# GEOM GEOM_SWIG : binding of C++ omplementaion with Python +# GEOM GEOM_SWIG : binding of C++ implementaion with Python # File : batchmode_geompy.py # Author : Paul RASCLE, EDF # Module : GEOM -# $Header$ -# From Salome version 3.2.0 geompy package suits for work in batch mode +# From Salome version 3.2.0 geompy package suits for work in batch mode # from geompy import * diff --git a/src/GEOM_SWIG/geompy.py b/src/GEOM_SWIG/geompy.py index f715dc8a4..5b7926670 100644 --- a/src/GEOM_SWIG/geompy.py +++ b/src/GEOM_SWIG/geompy.py @@ -25,7 +25,6 @@ # File : geompy.py # Author : Paul RASCLE, EDF # Module : GEOM -# $Header$ # import salome import geompyDC diff --git a/src/GEOM_SWIG/geompyDC.py b/src/GEOM_SWIG/geompyDC.py index 40a7dd53a..bf66f2e21 100644 --- a/src/GEOM_SWIG/geompyDC.py +++ b/src/GEOM_SWIG/geompyDC.py @@ -26,6 +26,112 @@ \brief Module geompy """ +## +## @defgroup l1_publish_data Publishing results in SALOME study +## @{ +## +## @details +## +## By default, all functions of geompy.py Python interface do not publish +## resulting geometrical objects. This can be done in the Python script +## by means of geompy.addToStudy() or geompy.addToStudyInFather() +## functions. +## +## However, it is possible to publish result data in the study +## automatically. For this, almost each function of geompy.py module has +## an additional @a theName parameter (@c None by default). +## As soon as non-empty string value is passed to this parameter, +## the result object is published in the study automatically. +## +## For example, +## +## @code +## box = geompy.MakeBoxDXDYDZ(100, 100, 100) # box is not published in the study yet +## geompy.addToStudy(box, "box") # explicit publishing +## @endcode +## +## can be replaced by one-line instruction +## +## @code +## box = geompy.MakeBoxDXDYDZ(100, 100, 100, theName="box") # box is published in the study with "box" name +## @endcode +## +## ... or simply +## +## @code +## box = geompy.MakeBoxDXDYDZ(100, 100, 100, "box") # box is published in the study with "box" name +## @endcode +## +## Note, that some functions produce more than one geometrical objects. For example, +## geompy.GetNonBlocks() function returns two objects: group of all non-hexa solids and group of +## all non-quad faces. For such functions it is possible to specify separate names for results. +## +## For example +## +## @code +## # create and publish cylinder +## cyl = geompy.MakeCylinderRH(100, 100, "cylinder") +## # get non blocks from cylinder +## g1, g2 = geompy.GetNonBlocks(cyl, "nonblock") +## @endcode +## +## Above example will publish both result compounds (first with non-hexa solids and +## second with non-quad faces) as two items, both named "nonblock". +## However, if second command is invoked as +## +## @code +## g1, g2 = geompy.GetNonBlocks(cyl, ("nonhexa", "nonquad")) +## @endcode +## +## ... the first compound will be published with "nonhexa" name, and second will be named "nonquad". +## +## Automatic publication of all results can be also enabled/disabled by means of the function +## geompy.addToStudyAuto(). The automatic publishing is managed by the numeric parameter passed +## to this function: +## - if @a maxNbSubShapes = 0, automatic publishing is disabled. +## - if @a maxNbSubShapes = -1 (default), automatic publishing is enabled and +## maximum number of sub-shapes allowed for publishing is unlimited; any negative +## value passed as parameter has the same effect. +## - if @a maxNbSubShapes is any positive value, automatic publishing is enabled and +## maximum number of sub-shapes allowed for publishing is set to specified value. +## +## When automatic publishing is enabled, you even do not need to pass @a theName parameter +## to the functions creating objects, instead default names will be used. However, you +## can always change the behavior, by passing explicit name to the @a theName parameter +## and it will be used instead default one. +## The publishing of the collections of objects will be done according to the above +## mentioned rules (maximum allowed number of sub-shapes). +## +## For example: +## +## @code +## geompy.addToStudyAuto() # enable automatic publication +## box = geompy.MakeBoxDXDYDZ(100, 100, 100) +## # the box is created and published in the study with default name +## geompy.addToStudyAuto(5) # set max allowed number of sub-shapes to 5 +## vertices = geompy.SubShapeAll(box, geompy.ShapeType['VERTEX']) +## # only 5 first vertices will be published, with default names +## print len(vertices) +## # note, that result value still containes all 8 vertices +## geompy.addToStudyAuto(-1) # disable automatic publication +## @endcode +## +## This feature can be used, for example, for debugging purposes. +## +## @note +## - Use automatic publication feature with caution. When it is enabled, any function of geompy.py module +## publishes the results in the study, that can lead to the huge size of the study data tree. +## For example, repeating call of geompy.SubShapeAll() command on the same main shape each time will +## publish all child objects, that will lead to a lot of duplicated items in the study. +## - Sub-shapes are automatically published as child items of the parent main shape in the study if main +## shape was also published before. Otherwise, sub-shapes are published as top-level objects. +## - Not that some functions of geompy.py module do not have @theName parameter (and, thus, do not support +## automatic publication). For example, some transformation operations like geompy.TranslateDXDYDZ(). +## Refer to the documentation to check if some function has such possibility. +## +## @} + + ## @defgroup l1_geompy_auxiliary Auxiliary data structures and methods ## @defgroup l1_geompy_purpose All package methods, grouped by their purpose @@ -63,6 +169,7 @@ ## @defgroup l3_basic_op Basic Operations ## @defgroup l3_boolean Boolean Operations ## @defgroup l3_transform Transformation Operations +## @defgroup l3_transform_d Transformation Operations deprecated methods ## @defgroup l3_local Local Operations (Fillet, Chamfer and other Features) ## @defgroup l3_blocks_op Blocks Operations ## @defgroup l3_healing Repairing Operations @@ -95,6 +202,18 @@ from gsketcher import Sketcher3D # @ingroup l1_geompy_auxiliary ShapeType = {"AUTO":-1, "COMPOUND":0, "COMPSOLID":1, "SOLID":2, "SHELL":3, "FACE":4, "WIRE":5, "EDGE":6, "VERTEX":7, "SHAPE":8} +# service function +def _toListOfNames(_names, _size=-1): + l = [] + import types + if type(_names) in [types.ListType, types.TupleType]: + for i in _names: l.append(i) + elif _names: + l.append(_names) + if l and len(l) < _size: + for i in range(len(l), _size): l.append("%s_%d"%(l[0],i)) + return l + ## Raise an Error, containing the Method_name, if Operation is Failed ## @ingroup l1_geompy_auxiliary def RaiseIfFailed (Method_name, Operation): @@ -376,6 +495,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): def __init__(self): GEOM._objref_GEOM_Gen.__init__(self) + self.myMaxNbSubShapesAllowed = 0 # auto-publishing is disabled by default self.myBuilder = None self.myStudyId = 0 self.father = None @@ -395,6 +515,82 @@ class geompyDC(GEOM._objref_GEOM_Gen): self.AdvOp = None pass + ## Process object publication in the study, as follows: + # - if @a theName is specified (not None), the object is published in the study + # with this name, not taking into account "auto-publishing" option; + # - if @a theName is NOT specified, the object is published in the study + # (using default name, which can be customized using @a theDefaultName parameter) + # only if auto-publishing is switched on. + # + # @param theObj object, a subject for publishing + # @param theName object name for study + # @param theDefaultName default name for the auto-publishing + # + # @sa addToStudyAuto() + def _autoPublish(self, theObj, theName, theDefaultName="noname"): + # --- + def _item_name(_names, _defname, _idx=-1): + if not _names: _names = _defname + if type(_names) in [types.ListType, types.TupleType]: + if _idx >= 0: + if _idx >= len(_names) or not _names[_idx]: + if type(_defname) not in [types.ListType, types.TupleType]: + _name = "%s_%d"%(_defname, _idx+1) + elif len(_defname) > 0 and _idx >= 0 and _idx < len(_defname): + _name = _defname[_idx] + else: + _name = "%noname_%d"%(dn, _idx+1) + pass + else: + _name = _names[_idx] + pass + else: + # must be wrong usage + _name = _names[0] + pass + else: + if _idx >= 0: + _name = "%s_%d"%(_names, _idx+1) + else: + _name = _names + pass + return _name + # --- + if not theObj: + return # null object + if not theName and not self.myMaxNbSubShapesAllowed: + return # nothing to do: auto-publishing is disabled + if not theName and not theDefaultName: + return # neither theName nor theDefaultName is given + import types + if type(theObj) in [types.ListType, types.TupleType]: + # list of objects is being published + idx = 0 + for obj in theObj: + if not obj: continue # bad object + ###if obj.GetStudyEntry(): continue # already published + name = _item_name(theName, theDefaultName, idx) + if obj.IsMainShape() or not obj.GetMainShape().GetStudyEntry(): + self.addToStudy(obj, name) # "%s_%d"%(aName, idx) + else: + self.addToStudyInFather(obj.GetMainShape(), obj, name) # "%s_%d"%(aName, idx) + pass + idx = idx+1 + if not theName and idx == self.myMaxNbSubShapesAllowed: break + pass + pass + else: + # single object is published + ###if theObj.GetStudyEntry(): return # already published + name = _item_name(theName, theDefaultName) + if theObj.IsMainShape(): + self.addToStudy(theObj, name) + else: + self.addToStudyInFather(theObj.GetMainShape(), theObj, name) + pass + pass + pass + ## @addtogroup l1_geompy_auxiliary ## @{ def init_geom(self,theStudy): @@ -427,6 +623,41 @@ class geompyDC(GEOM._objref_GEOM_Gen): self.AdvOp = self.GetIAdvancedOperations (self.myStudyId) pass + ## Enable / disable results auto-publishing + # + # The automatic publishing is managed in the following way: + # - if @a maxNbSubShapes = 0, automatic publishing is disabled. + # - if @a maxNbSubShapes = -1 (default), automatic publishing is enabled and + # maximum number of sub-shapes allowed for publishing is unlimited; any negative + # value passed as parameter has the same effect. + # - if @a maxNbSubShapes is any positive value, automatic publishing is enabled and + # maximum number of sub-shapes allowed for publishing is set to specified value. + # + # @param maxNbSubShapes maximum number of sub-shapes allowed for publishing. + # @ingroup l1_publish_data + def addToStudyAuto(self, maxNbSubShapes=-1): + """ + Enable / disable results auto-publishing + + The automatic publishing is managed in the following way: + - if @a maxNbSubShapes = 0, automatic publishing is disabled; + - if @a maxNbSubShapes = -1 (default), automatic publishing is enabled and + maximum number of sub-shapes allowed for publishing is unlimited; any negative + value passed as parameter has the same effect. + - if @a maxNbSubShapes is any positive value, automatic publishing is enabled and + maximum number of sub-shapes allowed for publishing is set to this value. + + Parameters: + maxNbSubShapes maximum number of sub-shapes allowed for publishing. + + Example of usage: + geompy.addToStudyAuto() # enable auto-publishing + geompy.MakeBoxDXDYDZ(100) # box is created and published with default name + geompy.addToStudyAuto(0) # disable auto-publishing + """ + self.myMaxNbSubShapesAllowed = max(-1, maxNbSubShapes) + pass + ## Dump component to the Python script # This method overrides IDL function to allow default values for the parameters. def DumpPython(self, theStudy, theIsPublished=True, theIsMultiFile=True): @@ -464,6 +695,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # these arguments description # \return study entry of the published shape in form of string # + # @ingroup l1_publish_data # @ref swig_all_addtostudy "Example" def addToStudy(self, aShape, aName, doRestoreSubShapes=False, theArgs=[], theFindMethod=GEOM.FSM_GetInPlace, theInheritFirstArg=False): @@ -503,6 +735,8 @@ class geompyDC(GEOM._objref_GEOM_Gen): # \param aName the name for the shape # # \return study entry of the published shape in form of string + # + # @ingroup l1_publish_data # @ref swig_all_addtostudyInFather "Example" def addToStudyInFather(self, aFather, aShape, aName): """ @@ -662,10 +896,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theX The X coordinate of the point. # @param theY The Y coordinate of the point. # @param theZ The Z coordinate of the point. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created point. # # @ref tui_creation_point "Example" - def MakeVertex(self, theX, theY, theZ): + def MakeVertex(self, theX, theY, theZ, theName=None): """ Create point by three coordinates. @@ -673,6 +911,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theX The X coordinate of the point. theY The Y coordinate of the point. theZ The Z coordinate of the point. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created point. @@ -682,6 +923,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.BasicOp.MakePointXYZ(theX, theY, theZ) RaiseIfFailed("MakePointXYZ", self.BasicOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "vertex") return anObj ## Create a point, distant from the referenced point @@ -690,10 +932,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @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. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created point. # # @ref tui_creation_point "Example" - def MakeVertexWithRef(self,theReference, theX, theY, theZ): + def MakeVertexWithRef(self, theReference, theX, theY, theZ, theName=None): """ Create a point, distant from the referenced point on the given distances along the coordinate axes. @@ -703,6 +949,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theX Displacement from the referenced point along OX axis. theY Displacement from the referenced point along OY axis. theZ Displacement from the referenced point along OZ axis. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created point. @@ -712,21 +961,29 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.BasicOp.MakePointWithReference(theReference, theX, theY, theZ) RaiseIfFailed("MakePointWithReference", self.BasicOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "vertex") 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. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created point. # # @ref tui_creation_point "Example" - def MakeVertexOnCurve(self,theRefCurve, theParameter): + def MakeVertexOnCurve(self, theRefCurve, theParameter, theName=None): """ Create a point, corresponding to the given parameter on the given curve. Parameters: theRefCurve The referenced curve. theParameter Value of parameter on the referenced curve. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created point. @@ -739,6 +996,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.BasicOp.MakePointOnCurve(theRefCurve, theParameter) RaiseIfFailed("MakePointOnCurve", self.BasicOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "vertex") return anObj ## Create a point by projection give coordinates on the given curve @@ -746,10 +1004,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theX X-coordinate in 3D space # @param theY Y-coordinate in 3D space # @param theZ Z-coordinate in 3D space + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created point. # # @ref tui_creation_point "Example" - def MakeVertexOnCurveByCoord(self,theRefCurve, theX, theY, theZ): + def MakeVertexOnCurveByCoord(self, theRefCurve, theX, theY, theZ, theName=None): """ Create a point by projection give coordinates on the given curve @@ -758,6 +1020,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theX X-coordinate in 3D space theY Y-coordinate in 3D space theZ Z-coordinate in 3D space + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created point. @@ -770,6 +1035,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.BasicOp.MakePointOnCurveByCoord(theRefCurve, theX, theY, theZ) RaiseIfFailed("MakeVertexOnCurveByCoord", self.BasicOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "vertex") return anObj ## Create a point, corresponding to the given length on the given curve. @@ -777,10 +1043,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theLength Length on the referenced curve. It can be negative. # @param theStartPoint Point allowing to choose the direction for the calculation # of the length. If None, start from the first point of theRefCurve. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created point. # # @ref tui_creation_point "Example" - def MakeVertexOnCurveByLength(self, theRefCurve, theLength, theStartPoint = None): + def MakeVertexOnCurveByLength(self, theRefCurve, theLength, theStartPoint = None, theName=None): """ Create a point, corresponding to the given length on the given curve. @@ -789,6 +1059,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theLength Length on the referenced curve. It can be negative. theStartPoint Point allowing to choose the direction for the calculation of the length. If None, start from the first point of theRefCurve. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created point. @@ -798,6 +1071,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.BasicOp.MakePointOnCurveByLength(theRefCurve, theLength, theStartPoint) RaiseIfFailed("MakePointOnCurveByLength", self.BasicOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "vertex") return anObj ## Create a point, corresponding to the given parameters on the @@ -805,10 +1079,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theRefSurf The referenced surface. # @param theUParameter Value of U-parameter on the referenced surface. # @param theVParameter Value of V-parameter on the referenced surface. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created point. # # @ref swig_MakeVertexOnSurface "Example" - def MakeVertexOnSurface(self, theRefSurf, theUParameter, theVParameter): + def MakeVertexOnSurface(self, theRefSurf, theUParameter, theVParameter, theName=None): """ Create a point, corresponding to the given parameters on the given surface. @@ -817,6 +1095,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theRefSurf The referenced surface. theUParameter Value of U-parameter on the referenced surface. theVParameter Value of V-parameter on the referenced surface. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created point. @@ -829,6 +1110,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.BasicOp.MakePointOnSurface(theRefSurf, theUParameter, theVParameter) RaiseIfFailed("MakePointOnSurface", self.BasicOp) anObj.SetParameters(Parameters); + self._autoPublish(anObj, theName, "vertex") return anObj ## Create a point by projection give coordinates on the given surface @@ -836,10 +1118,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theX X-coordinate in 3D space # @param theY Y-coordinate in 3D space # @param theZ Z-coordinate in 3D space + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created point. # # @ref swig_MakeVertexOnSurfaceByCoord "Example" - def MakeVertexOnSurfaceByCoord(self, theRefSurf, theX, theY, theZ): + def MakeVertexOnSurfaceByCoord(self, theRefSurf, theX, theY, theZ, theName=None): """ Create a point by projection give coordinates on the given surface @@ -848,6 +1134,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theX X-coordinate in 3D space theY Y-coordinate in 3D space theZ Z-coordinate in 3D space + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created point. @@ -860,6 +1149,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.BasicOp.MakePointOnSurfaceByCoord(theRefSurf, theX, theY, theZ) RaiseIfFailed("MakeVertexOnSurfaceByCoord", self.BasicOp) anObj.SetParameters(Parameters); + self._autoPublish(anObj, theName, "vertex") return anObj ## Create a point, which lays on the given face. @@ -868,10 +1158,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Such point can be used to uniquely identify the face inside any # shape in case, when the shape does not contain overlapped faces. # @param theFace The referenced face. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created point. # # @ref swig_MakeVertexInsideFace "Example" - def MakeVertexInsideFace (self, theFace): + def MakeVertexInsideFace (self, theFace, theName=None): """ Create a point, which lays on the given face. The point will lay in arbitrary place of the face. @@ -881,6 +1175,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): Parameters: theFace The referenced face. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created point. @@ -891,19 +1188,27 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestAll.py anObj = self.BasicOp.MakePointOnFace(theFace) RaiseIfFailed("MakeVertexInsideFace", self.BasicOp) + self._autoPublish(anObj, theName, "vertex") return anObj ## Create a point on intersection of two lines. # @param theRefLine1, theRefLine2 The referenced lines. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created point. # # @ref swig_MakeVertexOnLinesIntersection "Example" - def MakeVertexOnLinesIntersection(self, theRefLine1, theRefLine2): + def MakeVertexOnLinesIntersection(self, theRefLine1, theRefLine2, theName=None): """ Create a point on intersection of two lines. Parameters: theRefLine1, theRefLine2 The referenced lines. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created point. @@ -911,21 +1216,29 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestAll.py anObj = self.BasicOp.MakePointOnLinesIntersection(theRefLine1, theRefLine2) RaiseIfFailed("MakePointOnLinesIntersection", self.BasicOp) + self._autoPublish(anObj, theName, "vertex") return anObj ## Create a tangent, corresponding to the given parameter on the given curve. # @param theRefCurve The referenced curve. # @param theParameter Value of parameter on the referenced curve. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created tangent. # # @ref swig_MakeTangentOnCurve "Example" - def MakeTangentOnCurve(self, theRefCurve, theParameter): + def MakeTangentOnCurve(self, theRefCurve, theParameter, theName=None): """ Create a tangent, corresponding to the given parameter on the given curve. Parameters: theRefCurve The referenced curve. theParameter Value of parameter on the referenced curve. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created tangent. @@ -935,6 +1248,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): """ anObj = self.BasicOp.MakeTangentOnCurve(theRefCurve, theParameter) RaiseIfFailed("MakeTangentOnCurve", self.BasicOp) + self._autoPublish(anObj, theName, "tangent") return anObj ## Create a tangent plane, corresponding to the given parameter on the given face. @@ -942,10 +1256,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theParameterV vertical value of the center point (0.0 - 1.0). # @param theParameterU horisontal value of the center point (0.0 - 1.0). # @param theTrimSize the size of plane. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created tangent. # # @ref swig_MakeTangentPlaneOnFace "Example" - def MakeTangentPlaneOnFace(self, theFace, theParameterU, theParameterV, theTrimSize): + def MakeTangentPlaneOnFace(self, theFace, theParameterU, theParameterV, theTrimSize, theName=None): """ Create a tangent plane, corresponding to the given parameter on the given face. @@ -954,6 +1272,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theParameterV vertical value of the center point (0.0 - 1.0). theParameterU horisontal value of the center point (0.0 - 1.0). theTrimSize the size of plane. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created tangent. @@ -963,16 +1284,21 @@ class geompyDC(GEOM._objref_GEOM_Gen): """ anObj = self.BasicOp.MakeTangentPlaneOnFace(theFace, theParameterU, theParameterV, theTrimSize) RaiseIfFailed("MakeTangentPlaneOnFace", self.BasicOp) + self._autoPublish(anObj, theName, "tangent") return anObj ## Create a vector with the given components. # @param theDX X component of the vector. # @param theDY Y component of the vector. # @param theDZ Z component of the vector. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created vector. # # @ref tui_creation_vector "Example" - def MakeVectorDXDYDZ(self,theDX, theDY, theDZ): + def MakeVectorDXDYDZ(self, theDX, theDY, theDZ, theName=None): """ Create a vector with the given components. @@ -980,6 +1306,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theDX X component of the vector. theDY Y component of the vector. theDZ Z component of the vector. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created vector. @@ -989,21 +1318,29 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.BasicOp.MakeVectorDXDYDZ(theDX, theDY, theDZ) RaiseIfFailed("MakeVectorDXDYDZ", self.BasicOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "vector") return anObj ## Create a vector between two points. # @param thePnt1 Start point for the vector. # @param thePnt2 End point for the vector. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created vector. # # @ref tui_creation_vector "Example" - def MakeVector(self,thePnt1, thePnt2): + def MakeVector(self, thePnt1, thePnt2, theName=None): """ Create a vector between two points. Parameters: thePnt1 Start point for the vector. thePnt2 End point for the vector. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created vector. @@ -1011,16 +1348,21 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestAll.py anObj = self.BasicOp.MakeVectorTwoPnt(thePnt1, thePnt2) RaiseIfFailed("MakeVectorTwoPnt", self.BasicOp) + self._autoPublish(anObj, theName, "vector") return anObj ## Create a line, passing through the given point # and parrallel to the given direction # @param thePnt Point. The resulting line will pass through it. # @param theDir Direction. The resulting line will be parallel to it. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created line. # # @ref tui_creation_line "Example" - def MakeLine(self,thePnt, theDir): + def MakeLine(self, thePnt, theDir, theName=None): """ Create a line, passing through the given point and parrallel to the given direction @@ -1028,6 +1370,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): Parameters: thePnt Point. The resulting line will pass through it. theDir Direction. The resulting line will be parallel to it. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created line. @@ -1035,21 +1380,29 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestAll.py anObj = self.BasicOp.MakeLine(thePnt, theDir) RaiseIfFailed("MakeLine", self.BasicOp) + self._autoPublish(anObj, theName, "line") return anObj ## Create a line, passing through the given points # @param thePnt1 First of two points, defining the line. # @param thePnt2 Second of two points, defining the line. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created line. # # @ref tui_creation_line "Example" - def MakeLineTwoPnt(self,thePnt1, thePnt2): + def MakeLineTwoPnt(self, thePnt1, thePnt2, theName=None): """ Create a line, passing through the given points Parameters: thePnt1 First of two points, defining the line. thePnt2 Second of two points, defining the line. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created line. @@ -1057,21 +1410,29 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestAll.py anObj = self.BasicOp.MakeLineTwoPnt(thePnt1, thePnt2) RaiseIfFailed("MakeLineTwoPnt", self.BasicOp) + self._autoPublish(anObj, theName, "line") return anObj ## Create a line on two faces intersection. # @param theFace1 First of two faces, defining the line. # @param theFace2 Second of two faces, defining the line. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created line. # # @ref swig_MakeLineTwoFaces "Example" - def MakeLineTwoFaces(self, theFace1, theFace2): + def MakeLineTwoFaces(self, theFace1, theFace2, theName=None): """ Create a line on two faces intersection. Parameters: theFace1 First of two faces, defining the line. theFace2 Second of two faces, defining the line. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created line. @@ -1079,6 +1440,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestAll.py anObj = self.BasicOp.MakeLineTwoFaces(theFace1, theFace2) RaiseIfFailed("MakeLineTwoFaces", self.BasicOp) + self._autoPublish(anObj, theName, "line") return anObj ## Create a plane, passing through the given point @@ -1086,10 +1448,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @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. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created plane. # # @ref tui_creation_plane "Example" - def MakePlane(self,thePnt, theVec, theTrimSize): + def MakePlane(self, thePnt, theVec, theTrimSize, theName=None): """ Create a plane, passing through the given point and normal to the given vector. @@ -1098,6 +1464,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): thePnt Point, the plane has to pass through. theVec Vector, defining the plane normal direction. theTrimSize Half size of a side of quadrangle face, representing the plane. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created plane. @@ -1107,6 +1476,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.BasicOp.MakePlanePntVec(thePnt, theVec, theTrimSize) RaiseIfFailed("MakePlanePntVec", self.BasicOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "plane") return anObj ## Create a plane, passing through the three given points @@ -1114,10 +1484,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @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. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created plane. # # @ref tui_creation_plane "Example" - def MakePlaneThreePnt(self,thePnt1, thePnt2, thePnt3, theTrimSize): + def MakePlaneThreePnt(self, thePnt1, thePnt2, thePnt3, theTrimSize, theName=None): """ Create a plane, passing through the three given points @@ -1126,6 +1500,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): thePnt2 Second of three points, defining the plane. thePnt3 Fird of three points, defining the plane. theTrimSize Half size of a side of quadrangle face, representing the plane. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created plane. @@ -1135,21 +1512,29 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.BasicOp.MakePlaneThreePnt(thePnt1, thePnt2, thePnt3, theTrimSize) RaiseIfFailed("MakePlaneThreePnt", self.BasicOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "plane") return anObj ## Create a plane, similar to the existing one, but with another size of representing face. # @param theFace Referenced plane or LCS(Marker). # @param theTrimSize New half size of a side of quadrangle face, representing the plane. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created plane. # # @ref tui_creation_plane "Example" - def MakePlaneFace(self,theFace, theTrimSize): + def MakePlaneFace(self, theFace, theTrimSize, theName=None): """ Create a plane, similar to the existing one, but with another size of representing face. Parameters: theFace Referenced plane or LCS(Marker). theTrimSize New half size of a side of quadrangle face, representing the plane. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created plane. @@ -1159,6 +1544,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.BasicOp.MakePlaneFace(theFace, theTrimSize) RaiseIfFailed("MakePlaneFace", self.BasicOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "plane") return anObj ## Create a plane, passing through the 2 vectors @@ -1166,10 +1552,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theVec1 Vector, defining center point and plane direction. # @param theVec2 Vector, defining the plane normal direction. # @param theTrimSize Half size of a side of quadrangle face, representing the plane. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created plane. # # @ref tui_creation_plane "Example" - def MakePlane2Vec(self,theVec1, theVec2, theTrimSize): + def MakePlane2Vec(self, theVec1, theVec2, theTrimSize, theName=None): """ Create a plane, passing through the 2 vectors with center in a start point of the first vector. @@ -1178,6 +1568,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theVec1 Vector, defining center point and plane direction. theVec2 Vector, defining the plane normal direction. theTrimSize Half size of a side of quadrangle face, representing the plane. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created plane. @@ -1187,16 +1580,21 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.BasicOp.MakePlane2Vec(theVec1, theVec2, theTrimSize) RaiseIfFailed("MakePlane2Vec", self.BasicOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "plane") return anObj ## Create a plane, based on a Local coordinate system. # @param theLCS coordinate system, defining plane. # @param theTrimSize Half size of a side of quadrangle face, representing the plane. # @param theOrientation OXY, OYZ or OZX orientation - (1, 2 or 3) + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created plane. # # @ref tui_creation_plane "Example" - def MakePlaneLCS(self,theLCS, theTrimSize, theOrientation): + def MakePlaneLCS(self, theLCS, theTrimSize, theOrientation, theName=None): """ Create a plane, based on a Local coordinate system. @@ -1204,6 +1602,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theLCS coordinate system, defining plane. theTrimSize Half size of a side of quadrangle face, representing the plane. theOrientation OXY, OYZ or OZX orientation - (1, 2 or 3) + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created plane. @@ -1213,16 +1614,21 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.BasicOp.MakePlaneLCS(theLCS, theTrimSize, theOrientation) RaiseIfFailed("MakePlaneLCS", self.BasicOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "plane") 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 + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created coordinate system. # # @ref swig_MakeMarker "Example" - def MakeMarker(self, OX,OY,OZ, XDX,XDY,XDZ, YDX,YDY,YDZ): + def MakeMarker(self, OX,OY,OZ, XDX,XDY,XDZ, YDX,YDY,YDZ, theName=None): """ Create a local coordinate system. @@ -1230,6 +1636,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): OX,OY,OZ Three coordinates of coordinate system origin. XDX,XDY,XDZ Three components of OX direction YDX,YDY,YDZ Three components of OY direction + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created coordinate system. @@ -1239,35 +1648,48 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.BasicOp.MakeMarker(OX,OY,OZ, XDX,XDY,XDZ, YDX,YDY,YDZ) RaiseIfFailed("MakeMarker", self.BasicOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "lcs") return anObj ## Create a local coordinate system from shape. # @param theShape The initial shape to detect the coordinate system. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created coordinate system. # # @ref tui_creation_lcs "Example" - def MakeMarkerFromShape(self, theShape): + def MakeMarkerFromShape(self, theShape, theName=None): """ Create a local coordinate system from shape. Parameters: theShape The initial shape to detect the coordinate system. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created coordinate system. """ anObj = self.BasicOp.MakeMarkerFromShape(theShape) RaiseIfFailed("MakeMarkerFromShape", self.BasicOp) + self._autoPublish(anObj, theName, "lcs") return anObj ## Create a local coordinate system from point and two vectors. # @param theOrigin Point of coordinate system origin. # @param theXVec Vector of X direction # @param theYVec Vector of Y direction + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created coordinate system. # # @ref tui_creation_lcs "Example" - def MakeMarkerPntTwoVec(self, theOrigin, theXVec, theYVec): + def MakeMarkerPntTwoVec(self, theOrigin, theXVec, theYVec, theName=None): """ Create a local coordinate system from point and two vectors. @@ -1275,6 +1697,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theOrigin Point of coordinate system origin. theXVec Vector of X direction theYVec Vector of Y direction + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created coordinate system. @@ -1282,6 +1707,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): """ anObj = self.BasicOp.MakeMarkerPntTwoVec(theOrigin, theXVec, theYVec) RaiseIfFailed("MakeMarkerPntTwoVec", self.BasicOp) + self._autoPublish(anObj, theName, "lcs") return anObj # end of l3_basic_go @@ -1294,10 +1720,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param thePnt1 Start point of the arc. # @param thePnt2 Middle point of the arc. # @param thePnt3 End point of the arc. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created arc. # # @ref swig_MakeArc "Example" - def MakeArc(self,thePnt1, thePnt2, thePnt3): + def MakeArc(self, thePnt1, thePnt2, thePnt3, theName=None): """ Create an arc of circle, passing through three given points. @@ -1305,6 +1735,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): thePnt1 Start point of the arc. thePnt2 Middle point of the arc. thePnt3 End point of the arc. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created arc. @@ -1312,6 +1745,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestAll.py anObj = self.CurvesOp.MakeArc(thePnt1, thePnt2, thePnt3) RaiseIfFailed("MakeArc", self.CurvesOp) + self._autoPublish(anObj, theName, "arc") return anObj ## Create an arc of circle from a center and 2 points. @@ -1319,10 +1753,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param thePnt2 Start point of the arc. (Gives also the radius of the arc) # @param thePnt3 End point of the arc (Gives also a direction) # @param theSense Orientation of the arc + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created arc. # # @ref swig_MakeArc "Example" - def MakeArcCenter(self, thePnt1, thePnt2, thePnt3, theSense=False): + def MakeArcCenter(self, thePnt1, thePnt2, thePnt3, theSense=False, theName=None): """ Create an arc of circle from a center and 2 points. @@ -1331,6 +1769,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): thePnt2 Start point of the arc. (Gives also the radius of the arc) thePnt3 End point of the arc (Gives also a direction) theSense Orientation of the arc + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created arc. @@ -1338,16 +1779,21 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestAll.py anObj = self.CurvesOp.MakeArcCenter(thePnt1, thePnt2, thePnt3, theSense) RaiseIfFailed("MakeArcCenter", self.CurvesOp) + self._autoPublish(anObj, theName, "arc") return anObj ## Create an arc of ellipse, of center and two points. # @param theCenter Center of the arc. # @param thePnt1 defines major radius of the arc by distance from Pnt1 to Pnt2. # @param thePnt2 defines plane of ellipse and minor radius as distance from Pnt3 to line from Pnt1 to Pnt2. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created arc. # # @ref swig_MakeArc "Example" - def MakeArcOfEllipse(self,theCenter, thePnt1, thePnt2): + def MakeArcOfEllipse(self, theCenter, thePnt1, thePnt2, theName=None): """ Create an arc of ellipse, of center and two points. @@ -1355,6 +1801,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theCenter Center of the arc. thePnt1 defines major radius of the arc by distance from Pnt1 to Pnt2. thePnt2 defines plane of ellipse and minor radius as distance from Pnt3 to line from Pnt1 to Pnt2. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created arc. @@ -1362,16 +1811,21 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestAll.py anObj = self.CurvesOp.MakeArcOfEllipse(theCenter, thePnt1, thePnt2) RaiseIfFailed("MakeArcOfEllipse", self.CurvesOp) + self._autoPublish(anObj, theName, "arc") 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. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created circle. # # @ref tui_creation_circle "Example" - def MakeCircle(self, thePnt, theVec, theR): + def MakeCircle(self, thePnt, theVec, theR, theName=None): """ Create a circle with given center, normal vector and radius. @@ -1379,6 +1833,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): thePnt Circle center. theVec Vector, normal to the plane of the circle. theR Circle radius. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created circle. @@ -1388,14 +1845,19 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.CurvesOp.MakeCirclePntVecR(thePnt, theVec, theR) RaiseIfFailed("MakeCirclePntVecR", self.CurvesOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "circle") return anObj ## Create a circle with given radius. # Center of the circle will be in the origin of global # coordinate system and normal vector will be codirected with Z axis # @param theR Circle radius. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created circle. - def MakeCircleR(self, theR): + def MakeCircleR(self, theR, theName=None): """ Create a circle with given radius. Center of the circle will be in the origin of global @@ -1403,25 +1865,36 @@ class geompyDC(GEOM._objref_GEOM_Gen): Parameters: theR Circle radius. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created circle. """ anObj = self.CurvesOp.MakeCirclePntVecR(None, None, theR) RaiseIfFailed("MakeCirclePntVecR", self.CurvesOp) + self._autoPublish(anObj, theName, "circle") return anObj ## Create a circle, passing through three given points # @param thePnt1,thePnt2,thePnt3 Points, defining the circle. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created circle. # # @ref tui_creation_circle "Example" - def MakeCircleThreePnt(self,thePnt1, thePnt2, thePnt3): + def MakeCircleThreePnt(self, thePnt1, thePnt2, thePnt3, theName=None): """ Create a circle, passing through three given points Parameters: thePnt1,thePnt2,thePnt3 Points, defining the circle. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created circle. @@ -1429,16 +1902,21 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestAll.py anObj = self.CurvesOp.MakeCircleThreePnt(thePnt1, thePnt2, thePnt3) RaiseIfFailed("MakeCircleThreePnt", self.CurvesOp) + self._autoPublish(anObj, theName, "circle") return anObj ## Create a circle, with given point1 as center, # passing through the point2 as radius and laying in the plane, # defined by all three given points. # @param thePnt1,thePnt2,thePnt3 Points, defining the circle. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created circle. # # @ref swig_MakeCircle "Example" - def MakeCircleCenter2Pnt(self,thePnt1, thePnt2, thePnt3): + def MakeCircleCenter2Pnt(self, thePnt1, thePnt2, thePnt3, theName=None): """ Create a circle, with given point1 as center, passing through the point2 as radius and laying in the plane, @@ -1446,6 +1924,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): Parameters: thePnt1,thePnt2,thePnt3 Points, defining the circle. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created circle. @@ -1453,6 +1934,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_example6.py anObj = self.CurvesOp.MakeCircleCenter2Pnt(thePnt1, thePnt2, thePnt3) RaiseIfFailed("MakeCircleCenter2Pnt", self.CurvesOp) + self._autoPublish(anObj, theName, "circle") return anObj ## Create an ellipse with given center, normal vector and radiuses. @@ -1461,10 +1943,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theRMajor Major ellipse radius. # @param theRMinor Minor ellipse radius. # @param theVecMaj Vector, direction of the ellipse's main axis. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created ellipse. # # @ref tui_creation_ellipse "Example" - def MakeEllipse(self, thePnt, theVec, theRMajor, theRMinor, theVecMaj=None): + def MakeEllipse(self, thePnt, theVec, theRMajor, theRMinor, theVecMaj=None, theName=None): """ Create an ellipse with given center, normal vector and radiuses. @@ -1474,6 +1960,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theRMajor Major ellipse radius. theRMinor Minor ellipse radius. theVecMaj Vector, direction of the ellipse's main axis. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created ellipse. @@ -1487,6 +1976,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): pass RaiseIfFailed("MakeEllipse", self.CurvesOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "ellipse") return anObj ## Create an ellipse with given radiuses. @@ -1494,8 +1984,12 @@ class geompyDC(GEOM._objref_GEOM_Gen): # coordinate system and normal vector will be codirected with Z axis # @param theRMajor Major ellipse radius. # @param theRMinor Minor ellipse radius. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created ellipse. - def MakeEllipseRR(self, theRMajor, theRMinor): + def MakeEllipseRR(self, theRMajor, theRMinor, theName=None): """ Create an ellipse with given radiuses. Center of the ellipse will be in the origin of global @@ -1504,27 +1998,38 @@ class geompyDC(GEOM._objref_GEOM_Gen): Parameters: theRMajor Major ellipse radius. theRMinor Minor ellipse radius. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: - New GEOM.GEOM_Object, containing the created ellipse. + New GEOM.GEOM_Object, containing the created ellipse. """ anObj = self.CurvesOp.MakeEllipse(None, None, theRMajor, theRMinor) RaiseIfFailed("MakeEllipse", self.CurvesOp) + self._autoPublish(anObj, theName, "ellipse") return anObj ## Create a polyline on the set of points. # @param thePoints Sequence of points for the polyline. # @param theIsClosed If True, build a closed wire. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created polyline. # # @ref tui_creation_curve "Example" - def MakePolyline(self, thePoints, theIsClosed=False): + def MakePolyline(self, thePoints, theIsClosed=False, theName=None): """ Create a polyline on the set of points. Parameters: thePoints Sequence of points for the polyline. theIsClosed If True, build a closed wire. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created polyline. @@ -1532,21 +2037,29 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestAll.py anObj = self.CurvesOp.MakePolyline(thePoints, theIsClosed) RaiseIfFailed("MakePolyline", self.CurvesOp) + self._autoPublish(anObj, theName, "polyline") return anObj ## Create bezier curve on the set of points. # @param thePoints Sequence of points for the bezier curve. # @param theIsClosed If True, build a closed curve. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created bezier curve. # # @ref tui_creation_curve "Example" - def MakeBezier(self, thePoints, theIsClosed=False): + def MakeBezier(self, thePoints, theIsClosed=False, theName=None): """ Create bezier curve on the set of points. Parameters: thePoints Sequence of points for the bezier curve. theIsClosed If True, build a closed curve. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created bezier curve. @@ -1554,6 +2067,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestAll.py anObj = self.CurvesOp.MakeSplineBezier(thePoints, theIsClosed) RaiseIfFailed("MakeSplineBezier", self.CurvesOp) + self._autoPublish(anObj, theName, "bezier") return anObj ## Create B-Spline curve on the set of points. @@ -1561,10 +2075,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theIsClosed If True, build a closed curve. # @param theDoReordering If TRUE, the algo does not follow the order of # \a thePoints but searches for the closest vertex. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created B-Spline curve. # # @ref tui_creation_curve "Example" - def MakeInterpol(self, thePoints, theIsClosed=False, theDoReordering=False): + def MakeInterpol(self, thePoints, theIsClosed=False, theDoReordering=False, theName=None): """ Create B-Spline curve on the set of points. @@ -1573,15 +2091,50 @@ class geompyDC(GEOM._objref_GEOM_Gen): theIsClosed If True, build a closed curve. theDoReordering If True, the algo does not follow the order of thePoints but searches for the closest vertex. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created B-Spline curve. """ # Example: see GEOM_TestAll.py anObj = self.CurvesOp.MakeSplineInterpolation(thePoints, theIsClosed, theDoReordering) - RaiseIfFailed("MakeSplineInterpolation", self.CurvesOp) + RaiseIfFailed("MakeInterpol", self.CurvesOp) + self._autoPublish(anObj, theName, "bspline") return anObj + ## Create B-Spline curve on the set of points. + # @param thePoints Sequence of points for the B-Spline curve. + # @param theFirstVec Vector object, defining the curve direction at its first point. + # @param theLastVec Vector object, defining the curve direction at its last point. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # + # @return New GEOM.GEOM_Object, containing the created B-Spline curve. + # + # @ref tui_creation_curve "Example" + def MakeInterpolWithTangents(self, thePoints, theFirstVec, theLastVec, theName=None): + """ + Create B-Spline curve on the set of points. + + Parameters: + thePoints Sequence of points for the B-Spline curve. + theFirstVec Vector object, defining the curve direction at its first point. + theLastVec Vector object, defining the curve direction at its last point. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. + + Returns: + New GEOM.GEOM_Object, containing the created B-Spline curve. + """ + # Example: see GEOM_TestAll.py + anObj = self.CurvesOp.MakeSplineInterpolWithTangents(thePoints, theFirstVec, theLastVec) + RaiseIfFailed("MakeInterpolWithTangents", self.CurvesOp) + self._autoPublish(anObj, theName, "bspline") + return anObj ## Creates a curve using the parametric definition of the basic points. # @param thexExpr parametric equation of the coordinates X. @@ -1592,11 +2145,15 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theParamStep the number of steps if theNewMethod = True, else step value of the parameter. # @param theCurveType the type of the curve. # @param theNewMethod flag for switching to the new method if the flag is set to false a deprecated method is used which can lead to a bug. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created curve. # # @ref tui_creation_curve "Example" def MakeCurveParametric(self, thexExpr, theyExpr, thezExpr, - theParamMin, theParamMax, theParamStep, theCurveType, theNewMethod=False ): + theParamMin, theParamMax, theParamStep, theCurveType, theNewMethod=False, theName=None ): """ Creates a curve using the parametric definition of the basic points. @@ -1610,6 +2167,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theCurveType the type of the curve. theNewMethod flag for switching to the new method if the flag is set to false a deprecated method is used which can lead to a bug. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created curve. @@ -1621,9 +2181,8 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.CurvesOp.MakeCurveParametric(thexExpr,theyExpr,thezExpr,theParamMin,theParamMax,theParamStep,theCurveType) RaiseIfFailed("MakeSplineInterpolation", self.CurvesOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "curve") return anObj - - # end of l4_curves ## @} @@ -1679,10 +2238,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # coordinates of the working plane. # @param theWorkingPlane Nine double values, defining origin, # OZ and OX directions of the working plane. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created wire. # # @ref tui_sketcher_page "Example" - def MakeSketcher(self, theCommand, theWorkingPlane = [0,0,0, 0,0,1, 1,0,0]): + def MakeSketcher(self, theCommand, theWorkingPlane = [0,0,0, 0,0,1, 1,0,0], theName=None): """ Create a sketcher (wire or face), following the textual description, passed through theCommand argument. @@ -1726,6 +2289,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): coordinates of the working plane. theWorkingPlane Nine double values, defining origin, OZ and OX directions of the working plane. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created wire. @@ -1735,6 +2301,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.CurvesOp.MakeSketcher(theCommand, theWorkingPlane) RaiseIfFailed("MakeSketcher", self.CurvesOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "wire") return anObj ## Create a sketcher (wire or face), following the textual description, @@ -1743,10 +2310,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theCommand String, defining the sketcher in local # coordinates of the working plane. # @param theWorkingPlane Planar Face or LCS(Marker) of the working plane. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created wire. # # @ref tui_sketcher_page "Example" - def MakeSketcherOnPlane(self, theCommand, theWorkingPlane): + def MakeSketcherOnPlane(self, theCommand, theWorkingPlane, theName=None): """ Create a sketcher (wire or face), following the textual description, passed through theCommand argument. @@ -1756,6 +2327,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theCommand String, defining the sketcher in local coordinates of the working plane. theWorkingPlane Planar Face or LCS(Marker) of the working plane. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created wire. @@ -1764,16 +2338,21 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.CurvesOp.MakeSketcherOnPlane(theCommand, theWorkingPlane) RaiseIfFailed("MakeSketcherOnPlane", self.CurvesOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "wire") return anObj ## Create a sketcher wire, following the numerical description, # passed through theCoordinates argument. \n # @param theCoordinates double values, defining points to create a wire, # passing from it. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created wire. # # @ref tui_3dsketcher_page "Example" - def Make3DSketcher(self, theCoordinates): + def Make3DSketcher(self, theCoordinates, theName=None): """ Create a sketcher wire, following the numerical description, passed through theCoordinates argument. @@ -1781,6 +2360,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): Parameters: theCoordinates double values, defining points to create a wire, passing from it. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM_Object, containing the created wire. @@ -1789,6 +2371,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.CurvesOp.Make3DSketcher(theCoordinates) RaiseIfFailed("Make3DSketcher", self.CurvesOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "wire") return anObj ## Obtain a 3D sketcher interface @@ -1821,16 +2404,23 @@ class geompyDC(GEOM._objref_GEOM_Gen): # # @param x1,y1,z1 double values, defining first point it. # @param x2,y2,z2 double values, defining first point it. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. # # @return New GEOM.GEOM_Object, containing the created box. + # # @ref tui_creation_box "Example" - def MakeBox (self, x1,y1,z1, x2,y2,z2): + def MakeBox(self, x1, y1, z1, x2, y2, z2, theName=None): """ Create a box by coordinates of two opposite vertices. Parameters: x1,y1,z1 double values, defining first point. x2,y2,z2 double values, defining second point. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created box. @@ -1838,7 +2428,8 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestAll.py pnt1 = self.MakeVertex(x1,y1,z1) pnt2 = self.MakeVertex(x2,y2,z2) - return self.MakeBoxTwoPnt(pnt1,pnt2) + # note: auto-publishing is done in self.MakeBoxTwoPnt() + return self.MakeBoxTwoPnt(pnt1, pnt2, theName) ## Create a box with specified dimensions along the coordinate axes # and with edges, parallel to the coordinate axes. @@ -1846,10 +2437,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @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. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created box. # # @ref tui_creation_box "Example" - def MakeBoxDXDYDZ(self,theDX, theDY, theDZ): + def MakeBoxDXDYDZ(self, theDX, theDY, theDZ, theName=None): """ Create a box with specified dimensions along the coordinate axes and with edges, parallel to the coordinate axes. @@ -1859,6 +2454,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theDX Length of Box edges, parallel to OX axis. theDY Length of Box edges, parallel to OY axis. theDZ Length of Box edges, parallel to OZ axis. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created box. @@ -1868,16 +2466,21 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.PrimOp.MakeBoxDXDYDZ(theDX, theDY, theDZ) RaiseIfFailed("MakeBoxDXDYDZ", self.PrimOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "box") 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. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created box. # # @ref tui_creation_box "Example" - def MakeBoxTwoPnt(self,thePnt1, thePnt2): + def MakeBoxTwoPnt(self, thePnt1, thePnt2, theName=None): """ Create a box with two specified opposite vertices, and with edges, parallel to the coordinate axes @@ -1885,6 +2488,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): Parameters: thePnt1 First of two opposite vertices. thePnt2 Second of two opposite vertices. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created box. @@ -1892,16 +2498,21 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestAll.py anObj = self.PrimOp.MakeBoxTwoPnt(thePnt1, thePnt2) RaiseIfFailed("MakeBoxTwoPnt", self.PrimOp) + self._autoPublish(anObj, theName, "box") return anObj ## Create a face with specified dimensions with edges parallel to coordinate axes. # @param theH height of Face. # @param theW width of Face. # @param theOrientation face orientation: 1-OXY, 2-OYZ, 3-OZX + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created face. # # @ref tui_creation_face "Example" - def MakeFaceHW(self,theH, theW, theOrientation): + def MakeFaceHW(self, theH, theW, theOrientation, theName=None): """ Create a face with specified dimensions with edges parallel to coordinate axes. @@ -1909,6 +2520,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theH height of Face. theW width of Face. theOrientation face orientation: 1-OXY, 2-OYZ, 3-OZX + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created face. @@ -1918,6 +2532,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.PrimOp.MakeFaceHW(theH, theW, theOrientation) RaiseIfFailed("MakeFaceHW", self.PrimOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "rectangle") return anObj ## Create a face from another plane and two sizes, @@ -1926,10 +2541,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # the face object. # @param theH Height (vertical size). # @param theW Width (horisontal size). + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created face. # # @ref tui_creation_face "Example" - def MakeFaceObjHW(self, theObj, theH, theW): + def MakeFaceObjHW(self, theObj, theH, theW, theName=None): """ Create a face from another plane and two sizes, vertical size and horisontal size. @@ -1939,6 +2558,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): the face object. theH Height (vertical size). theW Width (horisontal size). + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM_Object, containing the created face. @@ -1948,16 +2570,21 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.PrimOp.MakeFaceObjHW(theObj, theH, theW) RaiseIfFailed("MakeFaceObjHW", self.PrimOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "rectangle") return anObj ## Create a disk with given center, normal vector and radius. # @param thePnt Disk center. # @param theVec Vector, normal to the plane of the disk. # @param theR Disk radius. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created disk. # # @ref tui_creation_disk "Example" - def MakeDiskPntVecR(self,thePnt, theVec, theR): + def MakeDiskPntVecR(self, thePnt, theVec, theR, theName=None): """ Create a disk with given center, normal vector and radius. @@ -1965,6 +2592,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): thePnt Disk center. theVec Vector, normal to the plane of the disk. theR Disk radius. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created disk. @@ -1974,19 +2604,27 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.PrimOp.MakeDiskPntVecR(thePnt, theVec, theR) RaiseIfFailed("MakeDiskPntVecR", self.PrimOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "disk") return anObj ## Create a disk, passing through three given points # @param thePnt1,thePnt2,thePnt3 Points, defining the disk. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created disk. # # @ref tui_creation_disk "Example" - def MakeDiskThreePnt(self,thePnt1, thePnt2, thePnt3): + def MakeDiskThreePnt(self, thePnt1, thePnt2, thePnt3, theName=None): """ Create a disk, passing through three given points Parameters: thePnt1,thePnt2,thePnt3 Points, defining the disk. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created disk. @@ -1994,21 +2632,29 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestAll.py anObj = self.PrimOp.MakeDiskThreePnt(thePnt1, thePnt2, thePnt3) RaiseIfFailed("MakeDiskThreePnt", self.PrimOp) + self._autoPublish(anObj, theName, "disk") return anObj ## Create a disk with specified dimensions along OX-OY coordinate axes. # @param theR Radius of Face. # @param theOrientation set the orientation belong axis OXY or OYZ or OZX + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created disk. # # @ref tui_creation_face "Example" - def MakeDiskR(self,theR, theOrientation): + def MakeDiskR(self, theR, theOrientation, theName=None): """ Create a disk with specified dimensions along OX-OY coordinate axes. Parameters: theR Radius of Face. theOrientation set the orientation belong axis OXY or OYZ or OZX + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created disk. @@ -2021,6 +2667,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.PrimOp.MakeDiskR(theR, theOrientation) RaiseIfFailed("MakeDiskR", self.PrimOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "disk") return anObj ## Create a cylinder with given base point, axis, radius and height. @@ -2028,10 +2675,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theAxis Cylinder axis. # @param theR Cylinder radius. # @param theH Cylinder height. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created cylinder. # # @ref tui_creation_cylinder "Example" - def MakeCylinder(self,thePnt, theAxis, theR, theH): + def MakeCylinder(self, thePnt, theAxis, theR, theH, theName=None): """ Create a cylinder with given base point, axis, radius and height. @@ -2040,6 +2691,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theAxis Cylinder axis. theR Cylinder radius. theH Cylinder height. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created cylinder. @@ -2049,6 +2703,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.PrimOp.MakeCylinderPntVecRH(thePnt, theAxis, theR, theH) RaiseIfFailed("MakeCylinderPntVecRH", self.PrimOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "cylinder") return anObj ## Create a cylinder with given radius and height at @@ -2056,10 +2711,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # will be collinear to the OZ axis of the coordinate system. # @param theR Cylinder radius. # @param theH Cylinder height. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created cylinder. # # @ref tui_creation_cylinder "Example" - def MakeCylinderRH(self,theR, theH): + def MakeCylinderRH(self, theR, theH, theName=None): """ Create a cylinder with given radius and height at the origin of coordinate system. Axis of the cylinder @@ -2068,6 +2727,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): Parameters: theR Cylinder radius. theH Cylinder height. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created cylinder. @@ -2077,21 +2739,29 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.PrimOp.MakeCylinderRH(theR, theH) RaiseIfFailed("MakeCylinderRH", self.PrimOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "cylinder") return anObj ## Create a sphere with given center and radius. # @param thePnt Sphere center. # @param theR Sphere radius. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created sphere. # # @ref tui_creation_sphere "Example" - def MakeSpherePntR(self, thePnt, theR): + def MakeSpherePntR(self, thePnt, theR, theName=None): """ Create a sphere with given center and radius. Parameters: thePnt Sphere center. theR Sphere radius. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created sphere. @@ -2101,41 +2771,57 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.PrimOp.MakeSpherePntR(thePnt, theR) RaiseIfFailed("MakeSpherePntR", self.PrimOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "sphere") return anObj ## Create a sphere with given center and radius. # @param x,y,z Coordinates of sphere center. # @param theR Sphere radius. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created sphere. # # @ref tui_creation_sphere "Example" - def MakeSphere(self, x, y, z, theR): + def MakeSphere(self, x, y, z, theR, theName=None): """ Create a sphere with given center and radius. Parameters: x,y,z Coordinates of sphere center. theR Sphere radius. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created sphere. """ # Example: see GEOM_TestAll.py point = self.MakeVertex(x, y, z) - anObj = self.MakeSpherePntR(point, theR) + # note: auto-publishing is done in self.MakeSpherePntR() + anObj = self.MakeSpherePntR(point, theR, theName) return anObj ## Create a sphere with given radius at the origin of coordinate system. # @param theR Sphere radius. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created sphere. # # @ref tui_creation_sphere "Example" - def MakeSphereR(self, theR): + def MakeSphereR(self, theR, theName=None): """ Create a sphere with given radius at the origin of coordinate system. Parameters: theR Sphere radius. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created sphere. @@ -2145,6 +2831,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.PrimOp.MakeSphereR(theR) RaiseIfFailed("MakeSphereR", self.PrimOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "sphere") return anObj ## Create a cone with given base point, axis, height and radiuses. @@ -2155,10 +2842,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # \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. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created cone. # # @ref tui_creation_cone "Example" - def MakeCone(self,thePnt, theAxis, theR1, theR2, theH): + def MakeCone(self, thePnt, theAxis, theR1, theR2, theH, theName=None): """ Create a cone with given base point, axis, height and radiuses. @@ -2168,6 +2859,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theR1 Radius of the first cone base. theR2 Radius of the second cone base. theH Cone height. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Note: If both radiuses are non-zero, the cone will be truncated. @@ -2181,6 +2875,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.PrimOp.MakeConePntVecR1R2H(thePnt, theAxis, theR1, theR2, theH) RaiseIfFailed("MakeConePntVecR1R2H", self.PrimOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "cone") return anObj ## Create a cone with given height and radiuses at @@ -2191,10 +2886,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # \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. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created cone. # # @ref tui_creation_cone "Example" - def MakeConeR1R2H(self,theR1, theR2, theH): + def MakeConeR1R2H(self, theR1, theR2, theH, theName=None): """ Create a cone with given height and radiuses at the origin of coordinate system. Axis of the cone will @@ -2204,6 +2903,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theR1 Radius of the first cone base. theR2 Radius of the second cone base. theH Cone height. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Note: If both radiuses are non-zero, the cone will be truncated. @@ -2217,6 +2919,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.PrimOp.MakeConeR1R2H(theR1, theR2, theH) RaiseIfFailed("MakeConeR1R2H", self.PrimOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "cone") return anObj ## Create a torus with given center, normal vector and radiuses. @@ -2224,10 +2927,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theVec Torus axis of symmetry. # @param theRMajor Torus major radius. # @param theRMinor Torus minor radius. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created torus. # # @ref tui_creation_torus "Example" - def MakeTorus(self, thePnt, theVec, theRMajor, theRMinor): + def MakeTorus(self, thePnt, theVec, theRMajor, theRMinor, theName=None): """ Create a torus with given center, normal vector and radiuses. @@ -2236,6 +2943,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theVec Torus axis of symmetry. theRMajor Torus major radius. theRMinor Torus minor radius. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created torus. @@ -2245,21 +2955,29 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.PrimOp.MakeTorusPntVecRR(thePnt, theVec, theRMajor, theRMinor) RaiseIfFailed("MakeTorusPntVecRR", self.PrimOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "torus") return anObj ## Create a torus with given radiuses at the origin of coordinate system. # @param theRMajor Torus major radius. # @param theRMinor Torus minor radius. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created torus. # # @ref tui_creation_torus "Example" - def MakeTorusRR(self, theRMajor, theRMinor): + def MakeTorusRR(self, theRMajor, theRMinor, theName=None): """ Create a torus with given radiuses at the origin of coordinate system. Parameters: theRMajor Torus major radius. theRMinor Torus minor radius. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created torus. @@ -2269,6 +2987,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.PrimOp.MakeTorusRR(theRMajor, theRMinor) RaiseIfFailed("MakeTorusRR", self.PrimOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "torus") return anObj # end of l3_3d_primitives @@ -2283,10 +3002,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param thePoint2 Second end of extrusion vector. # @param theScaleFactor Use it to make prism with scaled second base. # Nagative value means not scaled second base. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created prism. # # @ref tui_creation_prism "Example" - def MakePrism(self, theBase, thePoint1, thePoint2, theScaleFactor = -1.0): + def MakePrism(self, theBase, thePoint1, thePoint2, theScaleFactor = -1.0, theName=None): """ Create a shape by extrusion of the base shape along a vector, defined by two points. @@ -2296,6 +3019,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): thePoint2 Second end of extrusion vector. theScaleFactor Use it to make prism with scaled second base. Nagative value means not scaled second base. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created prism. @@ -2310,6 +3036,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.PrimOp.MakePrismTwoPnt(theBase, thePoint1, thePoint2) RaiseIfFailed("MakePrismTwoPnt", self.PrimOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "prism") return anObj ## Create a shape by extrusion of the base shape along a @@ -2317,10 +3044,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theBase Base shape to be extruded. # @param thePoint1 First end of extrusion vector. # @param thePoint2 Second end of extrusion vector. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created prism. # # @ref tui_creation_prism "Example" - def MakePrism2Ways(self, theBase, thePoint1, thePoint2): + def MakePrism2Ways(self, theBase, thePoint1, thePoint2, theName=None): """ Create a shape by extrusion of the base shape along a vector, defined by two points, in 2 Ways (forward/backward). @@ -2329,6 +3060,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theBase Base shape to be extruded. thePoint1 First end of extrusion vector. thePoint2 Second end of extrusion vector. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created prism. @@ -2336,6 +3070,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestAll.py anObj = self.PrimOp.MakePrismTwoPnt2Ways(theBase, thePoint1, thePoint2) RaiseIfFailed("MakePrismTwoPnt", self.PrimOp) + self._autoPublish(anObj, theName, "prism") return anObj ## Create a shape by extrusion of the base shape along the vector, @@ -2346,10 +3081,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theH Prism dimension along theVec. # @param theScaleFactor Use it to make prism with scaled second base. # Negative value means not scaled second base. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created prism. # # @ref tui_creation_prism "Example" - def MakePrismVecH(self, theBase, theVec, theH, theScaleFactor = -1.0): + def MakePrismVecH(self, theBase, theVec, theH, theScaleFactor = -1.0, theName=None): """ 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 @@ -2361,6 +3100,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theH Prism dimension along theVec. theScaleFactor Use it to make prism with scaled second base. Negative value means not scaled second base. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created prism. @@ -2376,6 +3118,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.PrimOp.MakePrismVecH(theBase, theVec, theH) RaiseIfFailed("MakePrismVecH", self.PrimOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "prism") return anObj ## Create a shape by extrusion of the base shape along the vector, @@ -2384,10 +3127,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theBase Base shape to be extruded. # @param theVec Direction of extrusion. # @param theH Prism dimension along theVec in forward direction. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created prism. # # @ref tui_creation_prism "Example" - def MakePrismVecH2Ways(self, theBase, theVec, theH): + def MakePrismVecH2Ways(self, theBase, theVec, theH, theName=None): """ 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 @@ -2397,6 +3144,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theBase Base shape to be extruded. theVec Direction of extrusion. theH Prism dimension along theVec in forward direction. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created prism. @@ -2406,6 +3156,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.PrimOp.MakePrismVecH2Ways(theBase, theVec, theH) RaiseIfFailed("MakePrismVecH2Ways", self.PrimOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "prism") return anObj ## Create a shape by extrusion of the base shape along the dx, dy, dz direction @@ -2413,10 +3164,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theDX, theDY, theDZ Directions of extrusion. # @param theScaleFactor Use it to make prism with scaled second base. # Nagative value means not scaled second base. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created prism. # # @ref tui_creation_prism "Example" - def MakePrismDXDYDZ(self, theBase, theDX, theDY, theDZ, theScaleFactor = -1.0): + def MakePrismDXDYDZ(self, theBase, theDX, theDY, theDZ, theScaleFactor = -1.0, theName=None): """ Create a shape by extrusion of the base shape along the dx, dy, dz direction @@ -2425,6 +3180,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theDX, theDY, theDZ Directions of extrusion. theScaleFactor Use it to make prism with scaled second base. Nagative value means not scaled second base. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created prism. @@ -2440,6 +3198,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.PrimOp.MakePrismDXDYDZ(theBase, theDX, theDY, theDZ) RaiseIfFailed("MakePrismDXDYDZ", self.PrimOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "prism") return anObj ## Create a shape by extrusion of the base shape along the dx, dy, dz direction @@ -2447,10 +3206,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # along the vector on the given distance in 2 Ways (forward/backward). # @param theBase Base shape to be extruded. # @param theDX, theDY, theDZ Directions of extrusion. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created prism. # # @ref tui_creation_prism "Example" - def MakePrismDXDYDZ2Ways(self, theBase, theDX, theDY, theDZ): + def MakePrismDXDYDZ2Ways(self, theBase, theDX, theDY, theDZ, theName=None): """ Create a shape by extrusion of the base shape along the dx, dy, dz direction i.e. all the space, transfixed by the base shape during its translation @@ -2459,6 +3222,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): Parameters: theBase Base shape to be extruded. theDX, theDY, theDZ Directions of extrusion. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created prism. @@ -2468,6 +3234,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.PrimOp.MakePrismDXDYDZ2Ways(theBase, theDX, theDY, theDZ) RaiseIfFailed("MakePrismDXDYDZ2Ways", self.PrimOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "prism") return anObj ## Create a shape by revolution of the base shape around the axis @@ -2476,10 +3243,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theBase Base shape to be rotated. # @param theAxis Rotation axis. # @param theAngle Rotation angle in radians. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created revolution. # # @ref tui_creation_revolution "Example" - def MakeRevolution(self, theBase, theAxis, theAngle): + def MakeRevolution(self, theBase, theAxis, theAngle, theName=None): """ 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 @@ -2489,6 +3260,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theBase Base shape to be rotated. theAxis Rotation axis. theAngle Rotation angle in radians. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created revolution. @@ -2498,6 +3272,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.PrimOp.MakeRevolutionAxisAngle(theBase, theAxis, theAngle) RaiseIfFailed("MakeRevolutionAxisAngle", self.PrimOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "revolution") return anObj ## Create a shape by revolution of the base shape around the axis @@ -2507,10 +3282,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theBase Base shape to be rotated. # @param theAxis Rotation axis. # @param theAngle Rotation angle in radians. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created revolution. # # @ref tui_creation_revolution "Example" - def MakeRevolution2Ways(self, theBase, theAxis, theAngle): + def MakeRevolution2Ways(self, theBase, theAxis, theAngle, theName=None): """ 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 @@ -2521,6 +3300,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theBase Base shape to be rotated. theAxis Rotation axis. theAngle Rotation angle in radians. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created revolution. @@ -2529,6 +3311,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.PrimOp.MakeRevolutionAxisAngle2Ways(theBase, theAxis, theAngle) RaiseIfFailed("MakeRevolutionAxisAngle2Ways", self.PrimOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "revolution") return anObj ## Create a filling from the given compound of contours. @@ -2544,11 +3327,15 @@ class geompyDC(GEOM._objref_GEOM_Gen): # the surface is created using given curves. The usage of # Approximation makes the algorithm work slower, but allows # building the surface for rather complex cases. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created filling surface. # # @ref tui_creation_filling "Example" def MakeFilling(self, theShape, theMinDeg=2, theMaxDeg=5, theTol2D=0.0001, - theTol3D=0.0001, theNbIter=0, theMethod=GEOM.FOM_Default, isApprox=0): + theTol3D=0.0001, theNbIter=0, theMethod=GEOM.FOM_Default, isApprox=0, theName=None): """ Create a filling from the given compound of contours. @@ -2565,6 +3352,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): the surface is created using given curves. The usage of Approximation makes the algorithm work slower, but allows building the surface for rather complex cases + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created filling surface. @@ -2579,6 +3369,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): theMethod, isApprox) RaiseIfFailed("MakeFilling", self.PrimOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "filling") return anObj @@ -2588,10 +3379,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theMinDeg a minimal degree of BSpline surface to create # @param theMaxDeg a maximal degree of BSpline surface to create # @param theTol3D a 3d tolerance to be reached + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created filling surface. # # @ref tui_creation_filling "Example" - def MakeFillingNew(self, theShape, theMinDeg=2, theMaxDeg=5, theTol3D=0.0001): + def MakeFillingNew(self, theShape, theMinDeg=2, theMaxDeg=5, theTol3D=0.0001, theName=None): """ Create a filling from the given compound of contours. This method corresponds to MakeFilling with isApprox=True @@ -2601,6 +3396,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theMinDeg a minimal degree of BSpline surface to create theMaxDeg a maximal degree of BSpline surface to create theTol3D a 3d tolerance to be reached + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created filling surface. @@ -2614,6 +3412,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): 0, theTol3D, 0, GEOM.FOM_Default, True) RaiseIfFailed("MakeFillingNew", self.PrimOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "filling") return anObj ## Create a shell or solid passing through set of sections.Sections should be wires,edges or vertices. @@ -2621,10 +3420,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theModeSolid - mode defining building solid or shell # @param thePreci - precision 3D used for smoothing # @param theRuled - mode defining type of the result surfaces (ruled or smoothed). + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created shell or solid. # # @ref swig_todo "Example" - def MakeThruSections(self,theSeqSections,theModeSolid,thePreci,theRuled): + def MakeThruSections(self, theSeqSections, theModeSolid, thePreci, theRuled, theName=None): """ Create a shell or solid passing through set of sections.Sections should be wires,edges or vertices. @@ -2633,6 +3436,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theModeSolid - mode defining building solid or shell thePreci - precision 3D used for smoothing theRuled - mode defining type of the result surfaces (ruled or smoothed). + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created shell or solid. @@ -2640,16 +3446,21 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestAll.py anObj = self.PrimOp.MakeThruSections(theSeqSections,theModeSolid,thePreci,theRuled) RaiseIfFailed("MakeThruSections", self.PrimOp) + self._autoPublish(anObj, theName, "filling") 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. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created pipe. # # @ref tui_creation_pipe "Example" - def MakePipe(self,theBase, thePath): + def MakePipe(self, theBase, thePath, theName=None): """ Create a shape by extrusion of the base shape along the path shape. The path shape can be a wire or an edge. @@ -2657,6 +3468,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): Parameters: theBase Base shape to be extruded. thePath Path shape to extrude the base shape along it. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created pipe. @@ -2664,6 +3478,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestAll.py anObj = self.PrimOp.MakePipe(theBase, thePath) RaiseIfFailed("MakePipe", self.PrimOp) + self._autoPublish(anObj, theName, "pipe") return anObj ## Create a shape by extrusion of the profile shape along @@ -2678,12 +3493,16 @@ class geompyDC(GEOM._objref_GEOM_Gen): # contact with the spine. # @param theWithCorrection - defining that the section is rotated to be # orthogonal to the spine tangent in the correspondent point + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created pipe. # # @ref tui_creation_pipe_with_diff_sec "Example" def MakePipeWithDifferentSections(self, theSeqBases, theLocations, thePath, - theWithContact, theWithCorrection): + theWithContact, theWithCorrection, theName=None): """ Create a shape by extrusion of the profile shape along the path shape. The path shape can be a wire or an edge. @@ -2699,6 +3518,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): contact with the spine(0/1) theWithCorrection - defining that the section is rotated to be orthogonal to the spine tangent in the correspondent point (0/1) + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created pipe. @@ -2707,6 +3529,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): theLocations, thePath, theWithContact, theWithCorrection) RaiseIfFailed("MakePipeWithDifferentSections", self.PrimOp) + self._autoPublish(anObj, theName, "pipe") return anObj ## Create a shape by extrusion of the profile shape along @@ -2730,12 +3553,16 @@ class geompyDC(GEOM._objref_GEOM_Gen): # contact with the spine. # @param theWithCorrection - defining that the section is rotated to be # orthogonal to the spine tangent in the correspondent point + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created solids. # # @ref tui_creation_pipe_with_shell_sec "Example" - def MakePipeWithShellSections(self,theSeqBases, theSeqSubBases, + def MakePipeWithShellSections(self, theSeqBases, theSeqSubBases, theLocations, thePath, - theWithContact, theWithCorrection): + theWithContact, theWithCorrection, theName=None): """ Create a shape by extrusion of the profile shape along the path shape. The path shape can be a wire or a edge. @@ -2760,6 +3587,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): contact with the spine (0/1) theWithCorrection - defining that the section is rotated to be orthogonal to the spine tangent in the correspondent point (0/1) + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created solids. @@ -2768,6 +3598,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): theLocations, thePath, theWithContact, theWithCorrection) RaiseIfFailed("MakePipeWithShellSections", self.PrimOp) + self._autoPublish(anObj, theName, "pipe") return anObj ## Create a shape by extrusion of the profile shape along @@ -2777,7 +3608,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # creating pipe between each pair of sections step by step. def MakePipeWithShellSectionsBySteps(self, theSeqBases, theSeqSubBases, theLocations, thePath, - theWithContact, theWithCorrection): + theWithContact, theWithCorrection, theName=None): """ Create a shape by extrusion of the profile shape along the path shape. This function is used only for debug pipe @@ -2812,27 +3643,36 @@ class geompyDC(GEOM._objref_GEOM_Gen): resc = self.MakeCompound(res) #resc = self.MakeSewing(res, 0.001) #print "resc: ",resc + self._autoPublish(resc, theName, "pipe") return resc ## Create solids between given sections # @param theSeqBases - list of sections (shell or face). # @param theLocations - list of corresponding vertexes + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created solids. # # @ref tui_creation_pipe_without_path "Example" - def MakePipeShellsWithoutPath(self, theSeqBases, theLocations): + def MakePipeShellsWithoutPath(self, theSeqBases, theLocations, theName=None): """ Create solids between given sections Parameters: theSeqBases - list of sections (shell or face). theLocations - list of corresponding vertexes + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created solids. """ anObj = self.PrimOp.MakePipeShellsWithoutPath(theSeqBases, theLocations) RaiseIfFailed("MakePipeShellsWithoutPath", self.PrimOp) + self._autoPublish(anObj, theName, "pipe") return anObj ## Create a shape by extrusion of the base shape along @@ -2843,10 +3683,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theVec Vector defines a constant binormal direction to keep the # same angle beetween the direction and the sections # along the sweep surface. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created pipe. # # @ref tui_creation_pipe "Example" - def MakePipeBiNormalAlongVector(self,theBase, thePath, theVec): + def MakePipeBiNormalAlongVector(self, theBase, thePath, theVec, theName=None): """ Create a shape by extrusion of the base shape along the path shape with constant bi-normal direction along the given vector. @@ -2858,6 +3702,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theVec Vector defines a constant binormal direction to keep the same angle beetween the direction and the sections along the sweep surface. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created pipe. @@ -2865,6 +3712,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestAll.py anObj = self.PrimOp.MakePipeBiNormalAlongVector(theBase, thePath, theVec) RaiseIfFailed("MakePipeBiNormalAlongVector", self.PrimOp) + self._autoPublish(anObj, theName, "pipe") return anObj ## Build a middle path of a pipe-like shape. @@ -2873,17 +3721,22 @@ class geompyDC(GEOM._objref_GEOM_Gen): # or a pipe-like solid. # @param theBase1, theBase2 Two bases of the supposed pipe. This # should be wires or faces of theShape. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @note It is not assumed that exact or approximate copy of theShape # can be obtained by applying existing Pipe operation on the # resulting "Path" wire taking theBase1 as the base - it is not # always possible; though in some particular cases it might work # it is not guaranteed. Thus, RestorePath function should not be # considered as an exact reverse operation of the Pipe. + # # @return New GEOM.GEOM_Object, containing an edge or wire that represent # source pipe's "path". # # @ref tui_creation_pipe_path "Example" - def RestorePath (self, theShape, theBase1, theBase2): + def RestorePath (self, theShape, theBase1, theBase2, theName=None): """ Build a middle path of a pipe-like shape. The path shape can be a wire or an edge. @@ -2893,6 +3746,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): or a pipe-like solid. theBase1, theBase2 Two bases of the supposed pipe. This should be wires or faces of theShape. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM_Object, containing an edge or wire that represent @@ -2900,6 +3756,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): """ anObj = self.PrimOp.RestorePath(theShape, theBase1, theBase2) RaiseIfFailed("RestorePath", self.PrimOp) + self._autoPublish(anObj, theName, "path") return anObj ## Build a middle path of a pipe-like shape. @@ -2908,17 +3765,22 @@ class geompyDC(GEOM._objref_GEOM_Gen): # or a pipe-like solid. # @param listEdges1, listEdges2 Two bases of the supposed pipe. This # should be lists of edges of theShape. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @note It is not assumed that exact or approximate copy of theShape # can be obtained by applying existing Pipe operation on the # resulting "Path" wire taking theBase1 as the base - it is not # always possible; though in some particular cases it might work # it is not guaranteed. Thus, RestorePath function should not be # considered as an exact reverse operation of the Pipe. + # # @return New GEOM.GEOM_Object, containing an edge or wire that represent # source pipe's "path". # # @ref tui_creation_pipe_path "Example" - def RestorePathEdges (self, theShape, listEdges1, listEdges2): + def RestorePathEdges (self, theShape, listEdges1, listEdges2, theName=None): """ Build a middle path of a pipe-like shape. The path shape can be a wire or an edge. @@ -2928,6 +3790,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): or a pipe-like solid. listEdges1, listEdges2 Two bases of the supposed pipe. This should be lists of edges of theShape. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM_Object, containing an edge or wire that represent @@ -2935,6 +3800,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): """ anObj = self.PrimOp.RestorePathEdges(theShape, listEdges1, listEdges2) RaiseIfFailed("RestorePath", self.PrimOp) + self._autoPublish(anObj, theName, "path") return anObj # end of l3_complex @@ -2946,16 +3812,23 @@ class geompyDC(GEOM._objref_GEOM_Gen): ## 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. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created edge. # # @ref tui_creation_edge "Example" - def MakeEdge(self,thePnt1, thePnt2): + def MakeEdge(self, thePnt1, thePnt2, theName=None): """ Create a linear edge with specified ends. Parameters: thePnt1 Point for the first end of edge. thePnt2 Point for the second end of edge. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created edge. @@ -2963,6 +3836,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestAll.py anObj = self.ShapesOp.MakeEdge(thePnt1, thePnt2) RaiseIfFailed("MakeEdge", self.ShapesOp) + self._autoPublish(anObj, theName, "edge") return anObj ## Create a new edge, corresponding to the given length on the given curve. @@ -2971,10 +3845,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theStartPoint Any point can be selected for it, the new edge will begin # at the end of \a theRefCurve, close to the selected point. # If None, start from the first point of \a theRefCurve. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created edge. # # @ref tui_creation_edge "Example" - def MakeEdgeOnCurveByLength(self, theRefCurve, theLength, theStartPoint = None): + def MakeEdgeOnCurveByLength(self, theRefCurve, theLength, theStartPoint = None, theName=None): """ Create a new edge, corresponding to the given length on the given curve. @@ -2984,6 +3862,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theStartPoint Any point can be selected for it, the new edge will begin at the end of theRefCurve, close to the selected point. If None, start from the first point of theRefCurve. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created edge. @@ -2993,16 +3874,21 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.ShapesOp.MakeEdgeOnCurveByLength(theRefCurve, theLength, theStartPoint) RaiseIfFailed("MakeEdgeOnCurveByLength", self.ShapesOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "edge") return anObj ## Create an edge from specified wire. # @param theWire source Wire # @param theLinearTolerance linear tolerance value (default = 1e-07) # @param theAngularTolerance angular tolerance value (default = 1e-12) + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created edge. # # @ref tui_creation_edge "Example" - def MakeEdgeWire(self, theWire, theLinearTolerance = 1e-07, theAngularTolerance = 1e-12): + def MakeEdgeWire(self, theWire, theLinearTolerance = 1e-07, theAngularTolerance = 1e-12, theName=None): """ Create an edge from specified wire. @@ -3010,6 +3896,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theWire source Wire theLinearTolerance linear tolerance value (default = 1e-07) theAngularTolerance angular tolerance value (default = 1e-12) + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created edge. @@ -3017,16 +3906,21 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestAll.py anObj = self.ShapesOp.MakeEdgeWire(theWire, theLinearTolerance, theAngularTolerance) RaiseIfFailed("MakeEdgeWire", self.ShapesOp) + self._autoPublish(anObj, theName, "edge") return anObj ## Create a wire from the set of edges and wires. # @param theEdgesAndWires List of edges and/or wires. # @param theTolerance Maximum distance between vertices, that will be merged. # Values less than 1e-07 are equivalent to 1e-07 (Precision::Confusion()) + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created wire. # # @ref tui_creation_wire "Example" - def MakeWire(self, theEdgesAndWires, theTolerance = 1e-07): + def MakeWire(self, theEdgesAndWires, theTolerance = 1e-07, theName=None): """ Create a wire from the set of edges and wires. @@ -3034,6 +3928,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theEdgesAndWires List of edges and/or wires. theTolerance Maximum distance between vertices, that will be merged. Values less than 1e-07 are equivalent to 1e-07 (Precision::Confusion()). + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created wire. @@ -3041,6 +3938,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestAll.py anObj = self.ShapesOp.MakeWire(theEdgesAndWires, theTolerance) RaiseIfFailed("MakeWire", self.ShapesOp) + self._autoPublish(anObj, theName, "wire") return anObj ## Create a face on the given wire. @@ -3050,10 +3948,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # than 1e-06, this face will be returned, otherwise the # algorithm tries to build any suitable face on the given # wire and prints a warning message. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created face. # # @ref tui_creation_face "Example" - def MakeFace(self, theWire, isPlanarWanted): + def MakeFace(self, theWire, isPlanarWanted, theName=None): """ Create a face on the given wire. @@ -3064,6 +3966,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): than 1e-06, this face will be returned, otherwise the algorithm tries to build any suitable face on the given wire and prints a warning message. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created face. @@ -3074,6 +3979,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): print "WARNING: Cannot build a planar face: required tolerance is too big. Non-planar face is built." else: RaiseIfFailed("MakeFace", self.ShapesOp) + self._autoPublish(anObj, theName, "face") return anObj ## Create a face on the given wires set. @@ -3083,10 +3989,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # than 1e-06, this face will be returned, otherwise the # algorithm tries to build any suitable face on the given # wire and prints a warning message. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created face. # # @ref tui_creation_face "Example" - def MakeFaceWires(self, theWires, isPlanarWanted): + def MakeFaceWires(self, theWires, isPlanarWanted, theName=None): """ Create a face on the given wires set. @@ -3097,6 +4007,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): than 1e-06, this face will be returned, otherwise the algorithm tries to build any suitable face on the given wire and prints a warning message. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created face. @@ -3107,31 +4020,40 @@ class geompyDC(GEOM._objref_GEOM_Gen): print "WARNING: Cannot build a planar face: required tolerance is too big. Non-planar face is built." else: RaiseIfFailed("MakeFaceWires", self.ShapesOp) + self._autoPublish(anObj, theName, "face") return anObj ## See MakeFaceWires() method for details. # # @ref tui_creation_face "Example 1" # \n @ref swig_MakeFaces "Example 2" - def MakeFaces(self, theWires, isPlanarWanted): + def MakeFaces(self, theWires, isPlanarWanted, theName=None): """ See geompy.MakeFaceWires() method for details. """ # Example: see GEOM_TestOthers.py - anObj = self.MakeFaceWires(theWires, isPlanarWanted) + # note: auto-publishing is done in self.MakeFaceWires() + anObj = self.MakeFaceWires(theWires, isPlanarWanted, theName) return anObj ## Create a shell from the set of faces and shells. # @param theFacesAndShells List of faces and/or shells. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created shell. # # @ref tui_creation_shell "Example" - def MakeShell(self,theFacesAndShells): + def MakeShell(self, theFacesAndShells, theName=None): """ Create a shell from the set of faces and shells. Parameters: theFacesAndShells List of faces and/or shells. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created shell. @@ -3139,19 +4061,27 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestAll.py anObj = self.ShapesOp.MakeShell(theFacesAndShells) RaiseIfFailed("MakeShell", self.ShapesOp) + self._autoPublish(anObj, theName, "shell") return anObj ## Create a solid, bounded by the given shells. # @param theShells Sequence of bounding shells. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created solid. # # @ref tui_creation_solid "Example" - def MakeSolid(self, theShells): + def MakeSolid(self, theShells, theName=None): """ Create a solid, bounded by the given shells. Parameters: theShells Sequence of bounding shells. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created solid. @@ -3165,19 +4095,27 @@ class geompyDC(GEOM._objref_GEOM_Gen): raise RuntimeError, "MakeSolidShells : Unable to create solid from unclosed shape" anObj = self.ShapesOp.MakeSolidShells(theShells) RaiseIfFailed("MakeSolidShells", self.ShapesOp) + self._autoPublish(anObj, theName, "solid") return anObj ## Create a compound of the given shapes. # @param theShapes List of shapes to put in compound. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created compound. # # @ref tui_creation_compound "Example" - def MakeCompound(self,theShapes): + def MakeCompound(self, theShapes, theName=None): """ Create a compound of the given shapes. Parameters: theShapes List of shapes to put in compound. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created compound. @@ -3185,6 +4123,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestAll.py anObj = self.ShapesOp.MakeCompound(theShapes) RaiseIfFailed("MakeCompound", self.ShapesOp) + self._autoPublish(anObj, theName, "compound") return anObj # end of l3_advanced @@ -3283,15 +4222,22 @@ class geompyDC(GEOM._objref_GEOM_Gen): ## Reverses an orientation the given shape. # @param theShape Shape to be reversed. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return The reversed copy of theShape. # # @ref swig_ChangeOrientation "Example" - def ChangeOrientation(self,theShape): + def ChangeOrientation(self, theShape, theName=None): """ Reverses an orientation the given shape. Parameters: theShape Shape to be reversed. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: The reversed copy of theShape. @@ -3299,17 +4245,19 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestAll.py anObj = self.ShapesOp.ChangeOrientation(theShape) RaiseIfFailed("ChangeOrientation", self.ShapesOp) + self._autoPublish(anObj, theName, "reversed") return anObj ## See ChangeOrientation() method for details. # # @ref swig_OrientationChange "Example" - def OrientationChange(self,theShape): + def OrientationChange(self, theShape, theName=None): """ See geompy.ChangeOrientation method for details. """ # Example: see GEOM_TestOthers.py - anObj = self.ChangeOrientation(theShape) + # note: auto-publishing is done in self.ChangeOrientation() + anObj = self.ChangeOrientation(theShape, theName) return anObj # end of l3_healing @@ -3344,10 +4292,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theShape1 Shape to find sub-shapes in. # @param theShape2 Shape to find shared sub-shapes with. # @param theShapeType Type of sub-shapes to be retrieved. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return List of sub-shapes of theShape1, shared with theShape2. # # @ref swig_GetSharedShapes "Example" - def GetSharedShapes(self,theShape1, theShape2, theShapeType): + def GetSharedShapes(self, theShape1, theShape2, theShapeType, theName=None): """ Get all sub-shapes of theShape1 of the given type, shared with theShape2. @@ -3355,6 +4307,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theShape1 Shape to find sub-shapes in. theShape2 Shape to find shared sub-shapes with. theShapeType Type of sub-shapes to be retrieved. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: List of sub-shapes of theShape1, shared with theShape2. @@ -3362,21 +4317,29 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestOthers.py aList = self.ShapesOp.GetSharedShapes(theShape1, theShape2, theShapeType) RaiseIfFailed("GetSharedShapes", self.ShapesOp) + self._autoPublish(aList, theName, "shared") return aList ## Get all sub-shapes, shared by all shapes in the list theShapes. # @param theShapes Shapes to find common sub-shapes of. # @param theShapeType Type of sub-shapes to be retrieved (see ShapeType()) + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return List of objects, that are sub-shapes of all given shapes. # # @ref swig_GetSharedShapes "Example" - def GetSharedShapesMulti(self, theShapes, theShapeType): + def GetSharedShapesMulti(self, theShapes, theShapeType, theName=None): """ Get all sub-shapes, shared by all shapes in the list theShapes. Parameters: theShapes Shapes to find common sub-shapes of. theShapeType Type of sub-shapes to be retrieved (see geompy.ShapeType) + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: List of GEOM.GEOM_Object, that are sub-shapes of all given shapes. @@ -3384,6 +4347,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestOthers.py aList = self.ShapesOp.GetSharedShapesMulti(theShapes, theShapeType) RaiseIfFailed("GetSharedShapesMulti", self.ShapesOp) + self._autoPublish(aList, theName, "shared") return aList ## Find in theShape all sub-shapes of type theShapeType, @@ -3394,10 +4358,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theAx1 Vector (or line, or linear edge), specifying normal # direction and location of the plane to find shapes on. # @param theState The state of the sub-shapes to find (see GEOM::shape_state) + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return List of all found sub-shapes. # # @ref swig_GetShapesOnPlane "Example" - def GetShapesOnPlane(self,theShape, theShapeType, theAx1, theState): + def GetShapesOnPlane(self, theShape, theShapeType, theAx1, theState, theName=None): """ Find in theShape all sub-shapes of type theShapeType, situated relatively the specified plane by the certain way, @@ -3409,6 +4377,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theAx1 Vector (or line, or linear edge), specifying normal direction and location of the plane to find shapes on. theState The state of the sub-shapes to find (see GEOM::shape_state) + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: List of all found sub-shapes. @@ -3416,6 +4387,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestOthers.py aList = self.ShapesOp.GetShapesOnPlane(theShape, theShapeType, theAx1, theState) RaiseIfFailed("GetShapesOnPlane", self.ShapesOp) + self._autoPublish(aList, theName, "shapeOnPlane") return aList ## Find in theShape all sub-shapes of type theShapeType, @@ -3426,10 +4398,11 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theAx1 Vector (or line, or linear edge), specifying normal # direction and location of the plane to find shapes on. # @param theState The state of the sub-shapes to find (see GEOM::shape_state) + # # @return List of all found sub-shapes indices. # # @ref swig_GetShapesOnPlaneIDs "Example" - def GetShapesOnPlaneIDs(self,theShape, theShapeType, theAx1, theState): + def GetShapesOnPlaneIDs(self, theShape, theShapeType, theAx1, theState): """ Find in theShape all sub-shapes of type theShapeType, situated relatively the specified plane by the certain way, @@ -3459,10 +4432,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # direction of the plane to find shapes on. # @param thePnt Point specifying location of the plane to find shapes on. # @param theState The state of the sub-shapes to find (see GEOM::shape_state) + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return List of all found sub-shapes. # # @ref swig_GetShapesOnPlaneWithLocation "Example" - def GetShapesOnPlaneWithLocation(self, theShape, theShapeType, theAx1, thePnt, theState): + def GetShapesOnPlaneWithLocation(self, theShape, theShapeType, theAx1, thePnt, theState, theName=None): """ Find in theShape all sub-shapes of type theShapeType, situated relatively the specified plane by the certain way, @@ -3475,6 +4452,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): direction and location of the plane to find shapes on. thePnt Point specifying location of the plane to find shapes on. theState The state of the sub-shapes to find (see GEOM::shape_state) + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: List of all found sub-shapes. @@ -3483,6 +4463,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): aList = self.ShapesOp.GetShapesOnPlaneWithLocation(theShape, theShapeType, theAx1, thePnt, theState) RaiseIfFailed("GetShapesOnPlaneWithLocation", self.ShapesOp) + self._autoPublish(aList, theName, "shapeOnPlane") return aList ## Find in theShape all sub-shapes of type theShapeType, @@ -3494,6 +4475,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # direction of the plane to find shapes on. # @param thePnt Point specifying location of the plane to find shapes on. # @param theState The state of the sub-shapes to find (see GEOM::shape_state) + # # @return List of all found sub-shapes indices. # # @ref swig_GetShapesOnPlaneWithLocationIDs "Example" @@ -3528,10 +4510,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # axis of the cylinder to find shapes on. # @param theRadius Radius of the cylinder to find shapes on. # @param theState The state of the sub-shapes to find (see GEOM::shape_state) + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return List of all found sub-shapes. # # @ref swig_GetShapesOnCylinder "Example" - def GetShapesOnCylinder(self, theShape, theShapeType, theAxis, theRadius, theState): + def GetShapesOnCylinder(self, theShape, theShapeType, theAxis, theRadius, theState, theName=None): """ Find in theShape all sub-shapes of type theShapeType, situated relatively the specified cylinder by the certain way, defined through theState parameter. @@ -3543,6 +4529,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): axis of the cylinder to find shapes on. theRadius Radius of the cylinder to find shapes on. theState The state of the sub-shapes to find (see GEOM::shape_state) + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: List of all found sub-shapes. @@ -3550,6 +4539,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestOthers.py aList = self.ShapesOp.GetShapesOnCylinder(theShape, theShapeType, theAxis, theRadius, theState) RaiseIfFailed("GetShapesOnCylinder", self.ShapesOp) + self._autoPublish(aList, theName, "shapeOnCylinder") return aList ## Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively @@ -3560,6 +4550,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # axis of the cylinder to find shapes on. # @param theRadius Radius of the cylinder to find shapes on. # @param theState The state of the sub-shapes to find (see GEOM::shape_state) + # # @return List of all found sub-shapes indices. # # @ref swig_GetShapesOnCylinderIDs "Example" @@ -3593,10 +4584,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param thePnt Point specifying location of the bottom of the cylinder. # @param theRadius Radius of the cylinder to find shapes on. # @param theState The state of the sub-shapes to find (see GEOM::shape_state) + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return List of all found sub-shapes. # # @ref swig_GetShapesOnCylinderWithLocation "Example" - def GetShapesOnCylinderWithLocation(self, theShape, theShapeType, theAxis, thePnt, theRadius, theState): + def GetShapesOnCylinderWithLocation(self, theShape, theShapeType, theAxis, thePnt, theRadius, theState, theName=None): """ Find in theShape all sub-shapes of type theShapeType, situated relatively the specified cylinder by the certain way, defined through theState parameter. @@ -3608,6 +4603,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): axis of the cylinder to find shapes on. theRadius Radius of the cylinder to find shapes on. theState The state of the sub-shapes to find (see GEOM::shape_state) + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: List of all found sub-shapes. @@ -3615,6 +4613,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestOthers.py aList = self.ShapesOp.GetShapesOnCylinderWithLocation(theShape, theShapeType, theAxis, thePnt, theRadius, theState) RaiseIfFailed("GetShapesOnCylinderWithLocation", self.ShapesOp) + self._autoPublish(aList, theName, "shapeOnCylinder") return aList ## Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively @@ -3626,6 +4625,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param thePnt Point specifying location of the bottom of the cylinder. # @param theRadius Radius of the cylinder to find shapes on. # @param theState The state of the sub-shapes to find (see GEOM::shape_state) + # # @return List of all found sub-shapes indices # # @ref swig_GetShapesOnCylinderWithLocationIDs "Example" @@ -3657,10 +4657,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theCenter Point, specifying center of the sphere to find shapes on. # @param theRadius Radius of the sphere to find shapes on. # @param theState The state of the sub-shapes to find (see GEOM::shape_state) + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return List of all found sub-shapes. # # @ref swig_GetShapesOnSphere "Example" - def GetShapesOnSphere(self,theShape, theShapeType, theCenter, theRadius, theState): + def GetShapesOnSphere(self, theShape, theShapeType, theCenter, theRadius, theState, theName=None): """ Find in theShape all sub-shapes of type theShapeType, situated relatively the specified sphere by the certain way, defined through theState parameter. @@ -3671,6 +4675,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theCenter Point, specifying center of the sphere to find shapes on. theRadius Radius of the sphere to find shapes on. theState The state of the sub-shapes to find (see GEOM::shape_state) + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: List of all found sub-shapes. @@ -3678,6 +4685,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestOthers.py aList = self.ShapesOp.GetShapesOnSphere(theShape, theShapeType, theCenter, theRadius, theState) RaiseIfFailed("GetShapesOnSphere", self.ShapesOp) + self._autoPublish(aList, theName, "shapeOnSphere") return aList ## Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively @@ -3687,10 +4695,11 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theCenter Point, specifying center of the sphere to find shapes on. # @param theRadius Radius of the sphere to find shapes on. # @param theState The state of the sub-shapes to find (see GEOM::shape_state) + # # @return List of all found sub-shapes indices. # # @ref swig_GetShapesOnSphereIDs "Example" - def GetShapesOnSphereIDs(self,theShape, theShapeType, theCenter, theRadius, theState): + def GetShapesOnSphereIDs(self, theShape, theShapeType, theCenter, theRadius, theState): """ Find in theShape all sub-shapes of type theShapeType, situated relatively the specified sphere by the certain way, defined through theState parameter. @@ -3719,12 +4728,16 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theBottomLeftPoint Point, specifying bottom left corner of a quadrangle # @param theBottomRigthPoint Point, specifying bottom right corner of a quadrangle # @param theState The state of the sub-shapes to find (see GEOM::shape_state) + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return List of all found sub-shapes. # # @ref swig_GetShapesOnQuadrangle "Example" def GetShapesOnQuadrangle(self, theShape, theShapeType, theTopLeftPoint, theTopRigthPoint, - theBottomLeftPoint, theBottomRigthPoint, theState): + theBottomLeftPoint, theBottomRigthPoint, theState, theName=None): """ Find in theShape all sub-shapes of type theShapeType, situated relatively the specified quadrangle by the certain way, defined through theState parameter. @@ -3737,6 +4750,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theBottomLeftPoint Point, specifying bottom left corner of a quadrangle theBottomRigthPoint Point, specifying bottom right corner of a quadrangle theState The state of the sub-shapes to find (see GEOM::shape_state) + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: List of all found sub-shapes. @@ -3746,6 +4762,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): theTopLeftPoint, theTopRigthPoint, theBottomLeftPoint, theBottomRigthPoint, theState) RaiseIfFailed("GetShapesOnQuadrangle", self.ShapesOp) + self._autoPublish(aList, theName, "shapeOnQuadrangle") return aList ## Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively @@ -3757,6 +4774,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theBottomLeftPoint Point, specifying bottom left corner of a quadrangle # @param theBottomRigthPoint Point, specifying bottom right corner of a quadrangle # @param theState The state of the sub-shapes to find (see GEOM::shape_state) + # # @return List of all found sub-shapes indices. # # @ref swig_GetShapesOnQuadrangleIDs "Example" @@ -3793,10 +4811,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theShape Shape to find sub-shapes of. # @param theShapeType Type of sub-shapes to be retrieved (see ShapeType()) # @param theState The state of the sub-shapes to find (see GEOM::shape_state) + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return List of all found sub-shapes. # # @ref swig_GetShapesOnBox "Example" - def GetShapesOnBox(self, theBox, theShape, theShapeType, theState): + def GetShapesOnBox(self, theBox, theShape, theShapeType, theState, theName=None): """ Find in theShape all sub-shapes of type theShapeType, situated relatively the specified theBox by the certain way, defined through theState parameter. @@ -3806,6 +4828,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theShape Shape to find sub-shapes of. theShapeType Type of sub-shapes to be retrieved (see geompy.ShapeType) theState The state of the sub-shapes to find (see GEOM::shape_state) + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: List of all found sub-shapes. @@ -3813,6 +4838,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestOthers.py aList = self.ShapesOp.GetShapesOnBox(theBox, theShape, theShapeType, theState) RaiseIfFailed("GetShapesOnBox", self.ShapesOp) + self._autoPublish(aList, theName, "shapeOnBox") return aList ## Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively @@ -3821,6 +4847,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theShape Shape to find sub-shapes of. # @param theShapeType Type of sub-shapes to be retrieved (see ShapeType()) # @param theState The state of the sub-shapes to find (see GEOM::shape_state) + # # @return List of all found sub-shapes indices. # # @ref swig_GetShapesOnBoxIDs "Example" @@ -3850,10 +4877,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theShape Shape to find sub-shapes of. # @param theShapeType Type of sub-shapes to be retrieved (see ShapeType()) # @param theState The state of the sub-shapes to find (see GEOM::shape_state) + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return List of all found sub-shapes. # # @ref swig_GetShapesOnShape "Example" - def GetShapesOnShape(self, theCheckShape, theShape, theShapeType, theState): + def GetShapesOnShape(self, theCheckShape, theShape, theShapeType, theState, theName=None): """ Find in theShape all sub-shapes of type theShapeType, situated relatively the specified theCheckShape by the @@ -3864,6 +4895,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theShape Shape to find sub-shapes of. theShapeType Type of sub-shapes to be retrieved (see geompy.ShapeType) theState The state of the sub-shapes to find (see GEOM::shape_state) + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: List of all found sub-shapes. @@ -3872,6 +4906,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): aList = self.ShapesOp.GetShapesOnShape(theCheckShape, theShape, theShapeType, theState) RaiseIfFailed("GetShapesOnShape", self.ShapesOp) + self._autoPublish(aList, theName, "shapeOnShape") return aList ## Find in \a theShape all sub-shapes of type \a theShapeType, @@ -3881,10 +4916,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theShape Shape to find sub-shapes of. # @param theShapeType Type of sub-shapes to be retrieved (see ShapeType()) # @param theState The state of the sub-shapes to find (see GEOM::shape_state) + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return All found sub-shapes as compound. # # @ref swig_GetShapesOnShapeAsCompound "Example" - def GetShapesOnShapeAsCompound(self, theCheckShape, theShape, theShapeType, theState): + def GetShapesOnShapeAsCompound(self, theCheckShape, theShape, theShapeType, theState, theName=None): """ Find in theShape all sub-shapes of type theShapeType, situated relatively the specified theCheckShape by the @@ -3895,6 +4934,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theShape Shape to find sub-shapes of. theShapeType Type of sub-shapes to be retrieved (see geompy.ShapeType) theState The state of the sub-shapes to find (see GEOM::shape_state) + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: All found sub-shapes as compound. @@ -3903,6 +4945,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.ShapesOp.GetShapesOnShapeAsCompound(theCheckShape, theShape, theShapeType, theState) RaiseIfFailed("GetShapesOnShapeAsCompound", self.ShapesOp) + self._autoPublish(anObj, theName, "shapeOnShape") return anObj ## Find in \a theShape all sub-shapes of type \a theShapeType, @@ -3912,6 +4955,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theShape Shape to find sub-shapes of. # @param theShapeType Type of sub-shapes to be retrieved (see ShapeType()) # @param theState The state of the sub-shapes to find (see GEOM::shape_state) + # # @return List of all found sub-shapes indices. # # @ref swig_GetShapesOnShapeIDs "Example" @@ -3942,6 +4986,10 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theShapeWhat Shape, specifying what to find. # @param isNewImplementation implementation of GetInPlace functionality # (default = False, old alghorithm based on shape properties) + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return Group of all found sub-shapes or a single found sub-shape. # # @note This function has a restriction on argument shapes. @@ -3951,7 +4999,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @image html get_in_place_lost_part.png # # @ref swig_GetInPlace "Example" - def GetInPlace(self, theShapeWhere, theShapeWhat, isNewImplementation = False): + def GetInPlace(self, theShapeWhere, theShapeWhat, isNewImplementation = False, theName=None): """ Get sub-shape(s) of theShapeWhere, which are coincident with theShapeWhat or could be a part of it. @@ -3961,6 +5009,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theShapeWhat Shape, specifying what to find. isNewImplementation Implementation of GetInPlace functionality (default = False, old alghorithm based on shape properties) + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: Group of all found sub-shapes or a single found sub-shape. @@ -3980,6 +5031,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.ShapesOp.GetInPlaceOld(theShapeWhere, theShapeWhat) pass RaiseIfFailed("GetInPlace", self.ShapesOp) + self._autoPublish(anObj, theName, "inplace") return anObj ## Get sub-shape(s) of \a theShapeWhere, which are @@ -3994,10 +5046,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theShapeWhere Shape to find sub-shapes of. # @param theShapeWhat Shape, specifying what to find (must be in the # building history of the ShapeWhere). + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return Group of all found sub-shapes or a single found sub-shape. # # @ref swig_GetInPlace "Example" - def GetInPlaceByHistory(self, theShapeWhere, theShapeWhat): + def GetInPlaceByHistory(self, theShapeWhere, theShapeWhat, theName=None): """ Implementation of this method is based on a saved history of an operation, produced theShapeWhere. The theShapeWhat must be among this operation's @@ -4009,6 +5065,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theShapeWhere Shape to find sub-shapes of. theShapeWhat Shape, specifying what to find (must be in the building history of the ShapeWhere). + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: Group of all found sub-shapes or a single found sub-shape. @@ -4016,16 +5075,21 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestOthers.py anObj = self.ShapesOp.GetInPlaceByHistory(theShapeWhere, theShapeWhat) RaiseIfFailed("GetInPlaceByHistory", self.ShapesOp) + self._autoPublish(anObj, theName, "inplace") return anObj ## Get sub-shape of theShapeWhere, which is # equal to \a theShapeWhat. # @param theShapeWhere Shape to find sub-shape of. # @param theShapeWhat Shape, specifying what to find. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object for found sub-shape. # # @ref swig_GetSame "Example" - def GetSame(self,theShapeWhere, theShapeWhat): + def GetSame(self, theShapeWhere, theShapeWhat, theName=None): """ Get sub-shape of theShapeWhere, which is equal to theShapeWhat. @@ -4033,12 +5097,16 @@ class geompyDC(GEOM._objref_GEOM_Gen): Parameters: theShapeWhere Shape to find sub-shape of. theShapeWhat Shape, specifying what to find. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object for found sub-shape. """ anObj = self.ShapesOp.GetSame(theShapeWhere, theShapeWhat) RaiseIfFailed("GetSame", self.ShapesOp) + self._autoPublish(anObj, theName, "sameShape") return anObj @@ -4049,7 +5117,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @return List of all found sub-shapes indices. # # @ref swig_GetSame "Example" - def GetSameIDs(self,theShapeWhere, theShapeWhat): + def GetSameIDs(self, theShapeWhere, theShapeWhat): """ Get sub-shape indices of theShapeWhere, which is equal to theShapeWhat. @@ -4076,23 +5144,31 @@ class geompyDC(GEOM._objref_GEOM_Gen): # of aShape, selected by their unique IDs inside aShape # @param aShape Shape to get sub-shape of. # @param ListOfID List of sub-shapes indices. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return Found sub-shape. # # @ref swig_all_decompose "Example" - def GetSubShape(self, aShape, ListOfID): + def GetSubShape(self, aShape, ListOfID, theName=None): """ Obtain a composite sub-shape of aShape, composed from sub-shapes of aShape, selected by their unique IDs inside aShape Parameters: - aShape Shape to get sub-shape of. - ListOfID List of sub-shapes indices. + aShape Shape to get sub-shape of. + ListOfID List of sub-shapes indices. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: Found sub-shape. """ # Example: see GEOM_TestAll.py anObj = self.AddSubShape(aShape,ListOfID) + self._autoPublish(anObj, theName, "subshape") return anObj ## Obtain unique ID of sub-shape aSubShape inside aShape @@ -4118,6 +5194,32 @@ class geompyDC(GEOM._objref_GEOM_Gen): anID = self.LocalOp.GetSubShapeIndex(aShape, aSubShape) RaiseIfFailed("GetSubShapeIndex", self.LocalOp) return anID + + ## Obtain unique IDs of sub-shapes aSubShapes inside aShape + # This function is provided for performance purpose. The complexity is O(n) with n + # the number of subobjects of aShape + # @param aShape Shape to get sub-shape of. + # @param aSubShapes Sub-shapes of aShape. + # @return list of IDs of found sub-shapes. + # + # @ref swig_all_decompose "Example" + def GetSubShapesIDs(self, aShape, aSubShapes): + """ + Obtain a list of IDs of sub-shapes aSubShapes inside aShape + This function is provided for performance purpose. The complexity is O(n) with n + the number of subobjects of aShape + + Parameters: + aShape Shape to get sub-shape of. + aSubShapes Sub-shapes of aShape. + + Returns: + List of IDs of found sub-shape. + """ + # Example: see GEOM_TestAll.py + anIDs = self.ShapesOp.GetSubShapesIndices(aShape, aSubShapes) + RaiseIfFailed("GetSubShapesIndices", self.ShapesOp) + return anIDs # end of l4_access ## @} @@ -4177,10 +5279,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # If the shape itself matches the type, it is also returned. # @param aShape Shape to be exploded. # @param aType Type of sub-shapes to be retrieved (see ShapeType()) + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return List of sub-shapes of type theShapeType, contained in theShape. # # @ref swig_all_decompose "Example" - def SubShapeAll(self, aShape, aType): + def SubShapeAll(self, aShape, aType, theName=None): """ Explode a shape on sub-shapes of a given type. If the shape itself matches the type, it is also returned. @@ -4188,6 +5294,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): Parameters: aShape Shape to be exploded. aType Type of sub-shapes to be retrieved (see geompy.ShapeType) + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: List of sub-shapes of type theShapeType, contained in theShape. @@ -4195,6 +5304,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestAll.py ListObj = self.ShapesOp.MakeAllSubShapes(aShape, EnumToLong( aType ), False) RaiseIfFailed("SubShapeAll", self.ShapesOp) + self._autoPublish(ListObj, theName, "subshape") return ListObj ## Explode a shape on sub-shapes of a given type. @@ -4224,10 +5334,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param aShape Shape to get sub-shape of. # @param ListOfInd List of sub-shapes indices. # @param aType Type of sub-shapes to be retrieved (see ShapeType()) + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return A compound of sub-shapes of aShape. # # @ref swig_all_decompose "Example" - def SubShape(self, aShape, aType, ListOfInd): + def SubShape(self, aShape, aType, ListOfInd, theName=None): """ Obtain a compound of sub-shapes of aShape, selected by they indices in list of all sub-shapes of type aType. @@ -4237,6 +5351,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): aShape Shape to get sub-shape of. ListOfID List of sub-shapes indices. aType Type of sub-shapes to be retrieved (see geompy.ShapeType) + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: A compound of sub-shapes of aShape. @@ -4246,7 +5363,8 @@ class geompyDC(GEOM._objref_GEOM_Gen): AllShapeIDsList = self.SubShapeAllIDs(aShape, EnumToLong( aType )) for ind in ListOfInd: ListOfIDs.append(AllShapeIDsList[ind - 1]) - anObj = self.GetSubShape(aShape, ListOfIDs) + # note: auto-publishing is done in self.GetSubShape() + anObj = self.GetSubShape(aShape, ListOfIDs, theName) return anObj ## Explode a shape on sub-shapes of a given type. @@ -4254,10 +5372,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # If the shape itself matches the type, it is also returned. # @param aShape Shape to be exploded. # @param aType Type of sub-shapes to be retrieved (see ShapeType()) + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return List of sub-shapes of type theShapeType, contained in theShape. # # @ref swig_SubShapeAllSorted "Example" - def SubShapeAllSortedCentres(self, aShape, aType): + def SubShapeAllSortedCentres(self, aShape, aType, theName=None): """ Explode a shape on sub-shapes of a given type. Sub-shapes will be sorted by coordinates of their gravity centers. @@ -4266,6 +5388,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): Parameters: aShape Shape to be exploded. aType Type of sub-shapes to be retrieved (see geompy.ShapeType) + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: List of sub-shapes of type theShapeType, contained in theShape. @@ -4273,6 +5398,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestAll.py ListObj = self.ShapesOp.MakeAllSubShapes(aShape, EnumToLong( aType ), True) RaiseIfFailed("SubShapeAllSortedCentres", self.ShapesOp) + self._autoPublish(ListObj, theName, "subshape") return ListObj ## Explode a shape on sub-shapes of a given type. @@ -4304,10 +5430,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param aShape Shape to get sub-shape of. # @param ListOfInd List of sub-shapes indices. # @param aType Type of sub-shapes to be retrieved (see ShapeType()) + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return A compound of sub-shapes of aShape. # # @ref swig_all_decompose "Example" - def SubShapeSortedCentres(self, aShape, aType, ListOfInd): + def SubShapeSortedCentres(self, aShape, aType, ListOfInd, theName=None): """ Obtain a compound of sub-shapes of aShape, selected by they indices in sorted list of all sub-shapes of type aType. @@ -4317,6 +5447,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): aShape Shape to get sub-shape of. ListOfID List of sub-shapes indices. aType Type of sub-shapes to be retrieved (see geompy.ShapeType) + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: A compound of sub-shapes of aShape. @@ -4326,17 +5459,22 @@ class geompyDC(GEOM._objref_GEOM_Gen): AllShapeIDsList = self.SubShapeAllSortedCentresIDs(aShape, EnumToLong( aType )) for ind in ListOfInd: ListOfIDs.append(AllShapeIDsList[ind - 1]) - anObj = self.GetSubShape(aShape, ListOfIDs) + # note: auto-publishing is done in self.GetSubShape() + anObj = self.GetSubShape(aShape, ListOfIDs, theName) return anObj ## Extract shapes (excluding the main shape) of given type. # @param aShape The shape. # @param aType The shape type (see ShapeType()) # @param isSorted Boolean flag to switch sorting on/off. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return List of sub-shapes of type aType, contained in aShape. # # @ref swig_FilletChamfer "Example" - def ExtractShapes(self, aShape, aType, isSorted = False): + def ExtractShapes(self, aShape, aType, isSorted = False, theName=None): """ Extract shapes (excluding the main shape) of given type. @@ -4344,6 +5482,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): aShape The shape. aType The shape type (see geompy.ShapeType) isSorted Boolean flag to switch sorting on/off. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: List of sub-shapes of type aType, contained in aShape. @@ -4351,21 +5492,28 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestAll.py ListObj = self.ShapesOp.ExtractSubShapes(aShape, EnumToLong( aType ), isSorted) RaiseIfFailed("ExtractSubShapes", self.ShapesOp) + self._autoPublish(ListObj, theName, "subshape") return ListObj ## Get a set of sub-shapes defined by their unique IDs inside aShape # @param aShape Main shape. # @param anIDs List of unique IDs of sub-shapes inside aShape. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. # @return List of GEOM.GEOM_Object, corresponding to found sub-shapes. # # @ref swig_all_decompose "Example" - def SubShapes(self, aShape, anIDs): + def SubShapes(self, aShape, anIDs, theName=None): """ Get a set of sub-shapes defined by their unique IDs inside theMainShape Parameters: aShape Main shape. anIDs List of unique IDs of sub-shapes inside theMainShape. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: List of GEOM.GEOM_Object, corresponding to found sub-shapes. @@ -4373,6 +5521,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestAll.py ListObj = self.ShapesOp.MakeSubShapes(aShape, anIDs) RaiseIfFailed("SubShapes", self.ShapesOp) + self._autoPublish(ListObj, theName, "subshape") return ListObj # end of l4_decompose @@ -4384,7 +5533,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): ## Deprecated method # It works like SubShapeAllSortedCentres(), but wrongly # defines centres of faces, shells and solids. - def SubShapeAllSorted(self, aShape, aType): + def SubShapeAllSorted(self, aShape, aType, theName=None): """ Deprecated method It works like geompy.SubShapeAllSortedCentres, but wrongly @@ -4392,6 +5541,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): """ ListObj = self.ShapesOp.MakeExplode(aShape, EnumToLong( aType ), True) RaiseIfFailed("MakeExplode", self.ShapesOp) + self._autoPublish(ListObj, theName, "subshape") return ListObj ## Deprecated method @@ -4410,7 +5560,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): ## Deprecated method # It works like SubShapeSortedCentres(), but has a bug # (wrongly defines centres of faces, shells and solids). - def SubShapeSorted(self, aShape, aType, ListOfInd): + def SubShapeSorted(self, aShape, aType, ListOfInd, theName=None): """ Deprecated method It works like geompy.SubShapeSortedCentres, but has a bug @@ -4420,7 +5570,8 @@ class geompyDC(GEOM._objref_GEOM_Gen): AllShapeIDsList = self.SubShapeAllSortedIDs(aShape, EnumToLong( aType )) for ind in ListOfInd: ListOfIDs.append(AllShapeIDsList[ind - 1]) - anObj = self.GetSubShape(aShape, ListOfIDs) + # note: auto-publishing is done in self.GetSubShape() + anObj = self.GetSubShape(aShape, ListOfIDs, theName) return anObj # end of l4_decompose_d @@ -4436,7 +5587,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): # ("FixShape.Tolerance3d", "SplitClosedFaces.NbSplitPoints", etc.). # @param theValues List of values of parameters, in the same order # as parameters are listed in theParameters list. - # + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. # # Operators and Parameters: \n # @@ -4508,7 +5661,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @return New GEOM.GEOM_Object, containing processed shape. # # \n @ref tui_shape_processing "Example" - def ProcessShape(self, theShape, theOperators, theParameters, theValues): + def ProcessShape(self, theShape, theOperators, theParameters, theValues, theName=None): """ Apply a sequence of Shape Healing operators to the given object. @@ -4519,7 +5672,11 @@ class geompyDC(GEOM._objref_GEOM_Gen): theOperators List of names of operators ("FixShape", "SplitClosedFaces", etc.). theParameters List of names of parameters ("FixShape.Tolerance3d", "SplitClosedFaces.NbSplitPoints", etc.). - Operators and Parameters: + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. + + Operators and Parameters: * FixShape - corrects invalid shapes. * FixShape.Tolerance3d - work tolerance for detection of the problems and correction of them. @@ -4598,16 +5755,21 @@ class geompyDC(GEOM._objref_GEOM_Gen): Parameters = ":" + Parameters pass anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "healed") return anObj ## Remove faces from the given object (shape). # @param theObject Shape to be processed. # @param theFaces Indices of faces to be removed, if EMPTY then the method # removes ALL faces of the given object. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing processed shape. # # @ref tui_suppress_faces "Example" - def SuppressFaces(self,theObject, theFaces): + def SuppressFaces(self, theObject, theFaces, theName=None): """ Remove faces from the given object (shape). @@ -4615,6 +5777,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theObject Shape to be processed. theFaces Indices of faces to be removed, if EMPTY then the method removes ALL faces of the given object. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing processed shape. @@ -4622,41 +5787,57 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestHealing.py anObj = self.HealOp.SuppressFaces(theObject, theFaces) RaiseIfFailed("SuppressFaces", self.HealOp) + self._autoPublish(anObj, theName, "suppressFaces") return anObj ## Sewing of some shapes into single shape. # @param ListShape Shapes to be processed. # @param theTolerance Required tolerance value. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing processed shape. # # @ref tui_sewing "Example" - def MakeSewing(self, ListShape, theTolerance): + def MakeSewing(self, ListShape, theTolerance, theName=None): """ Sewing of some shapes into single shape. Parameters: ListShape Shapes to be processed. theTolerance Required tolerance value. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing processed shape. """ # Example: see GEOM_TestHealing.py comp = self.MakeCompound(ListShape) - anObj = self.Sew(comp, theTolerance) + # note: auto-publishing is done in self.Sew() + anObj = self.Sew(comp, theTolerance, theName) return anObj ## Sewing of the given object. # @param theObject Shape to be processed. # @param theTolerance Required tolerance value. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing processed shape. - def Sew(self, theObject, theTolerance): + def Sew(self, theObject, theTolerance, theName=None): """ Sewing of the given object. Parameters: theObject Shape to be processed. theTolerance Required tolerance value. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing processed shape. @@ -4666,16 +5847,21 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.HealOp.Sew(theObject, theTolerance) RaiseIfFailed("Sew", self.HealOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "sewed") return anObj ## Remove internal wires and edges from the given object (face). # @param theObject Shape to be processed. # @param theWires Indices of wires to be removed, if EMPTY then the method # removes ALL internal wires of the given object. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing processed shape. # # @ref tui_suppress_internal_wires "Example" - def SuppressInternalWires(self,theObject, theWires): + def SuppressInternalWires(self, theObject, theWires, theName=None): """ Remove internal wires and edges from the given object (face). @@ -4683,6 +5869,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theObject Shape to be processed. theWires Indices of wires to be removed, if EMPTY then the method removes ALL internal wires of the given object. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing processed shape. @@ -4690,16 +5879,21 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestHealing.py anObj = self.HealOp.RemoveIntWires(theObject, theWires) RaiseIfFailed("RemoveIntWires", self.HealOp) + self._autoPublish(anObj, theName, "suppressWires") return anObj ## Remove internal closed contours (holes) from the given object. # @param theObject Shape to be processed. # @param theWires Indices of wires to be removed, if EMPTY then the method # removes ALL internal holes of the given object + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing processed shape. # # @ref tui_suppress_holes "Example" - def SuppressHoles(self,theObject, theWires): + def SuppressHoles(self, theObject, theWires, theName=None): """ Remove internal closed contours (holes) from the given object. @@ -4707,6 +5901,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theObject Shape to be processed. theWires Indices of wires to be removed, if EMPTY then the method removes ALL internal holes of the given object + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing processed shape. @@ -4714,6 +5911,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestHealing.py anObj = self.HealOp.FillHoles(theObject, theWires) RaiseIfFailed("FillHoles", self.HealOp) + self._autoPublish(anObj, theName, "suppressHoles") return anObj ## Close an open wire. @@ -4722,10 +5920,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # if [ ], then theObject itself is a wire. # @param isCommonVertex If True : closure by creation of a common vertex, # If False : closure by creation of an edge between ends. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing processed shape. # # @ref tui_close_contour "Example" - def CloseContour(self,theObject, theWires, isCommonVertex): + def CloseContour(self,theObject, theWires, isCommonVertex, theName=None): """ Close an open wire. @@ -4735,6 +5937,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): if [ ], then theObject itself is a wire. isCommonVertex If True : closure by creation of a common vertex, If False : closure by creation of an edge between ends. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing processed shape. @@ -4742,6 +5947,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestHealing.py anObj = self.HealOp.CloseContour(theObject, theWires, isCommonVertex) RaiseIfFailed("CloseContour", self.HealOp) + self._autoPublish(anObj, theName, "closeContour") return anObj ## Addition of a point to a given edge object. @@ -4752,10 +5958,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # depending on \a isByParameter. # @param isByParameter If TRUE : \a theValue is treated as a curve parameter [0..1], \n # if FALSE : \a theValue is treated as a length parameter [0..1] + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing processed shape. # # @ref tui_add_point_on_edge "Example" - def DivideEdge(self,theObject, theEdgeIndex, theValue, isByParameter): + def DivideEdge(self, theObject, theEdgeIndex, theValue, isByParameter, theName=None): """ Addition of a point to a given edge object. @@ -4767,6 +5977,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): depending on isByParameter. isByParameter If TRUE : theValue is treated as a curve parameter [0..1], if FALSE : theValue is treated as a length parameter [0..1] + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing processed shape. @@ -4776,16 +5989,21 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.HealOp.DivideEdge(theObject, theEdgeIndex, theValue, isByParameter) RaiseIfFailed("DivideEdge", self.HealOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "divideEdge") return anObj ## Suppress the vertices in the wire in case if adjacent edges are C1 continuous. # @param theWire Wire to minimize the number of C1 continuous edges in. # @param theVertices A list of vertices to suppress. If the list # is empty, all vertices in a wire will be assumed. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object with modified wire. # # @ref tui_fuse_collinear_edges "Example" - def FuseCollinearEdgesWithinWire(self, theWire, theVertices = []): + def FuseCollinearEdgesWithinWire(self, theWire, theVertices = [], theName=None): """ Suppress the vertices in the wire in case if adjacent edges are C1 continuous. @@ -4793,12 +6011,16 @@ class geompyDC(GEOM._objref_GEOM_Gen): theWire Wire to minimize the number of C1 continuous edges in. theVertices A list of vertices to suppress. If the list is empty, all vertices in a wire will be assumed. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object with modified wire. """ anObj = self.HealOp.FuseCollinearEdgesWithinWire(theWire, theVertices) RaiseIfFailed("FuseCollinearEdgesWithinWire", self.HealOp) + self._autoPublish(anObj, theName, "fuseEdges") return anObj ## Change orientation of the given object. Updates given shape. @@ -4822,60 +6044,83 @@ class geompyDC(GEOM._objref_GEOM_Gen): ## Change orientation of the given object. # @param theObject Shape to be processed. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing processed shape. # # @ref swig_todo "Example" - def ChangeOrientationShellCopy(self, theObject): + def ChangeOrientationShellCopy(self, theObject, theName=None): """ Change orientation of the given object. Parameters: theObject Shape to be processed. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing processed shape. """ anObj = self.HealOp.ChangeOrientationCopy(theObject) RaiseIfFailed("ChangeOrientationCopy", self.HealOp) + self._autoPublish(anObj, theName, "reversed") return anObj ## Try to limit tolerance of the given object by value \a theTolerance. # @param theObject Shape to be processed. # @param theTolerance Required tolerance value. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing processed shape. # # @ref tui_limit_tolerance "Example" - def LimitTolerance(self, theObject, theTolerance = 1e-07): + def LimitTolerance(self, theObject, theTolerance = 1e-07, theName=None): """ Try to limit tolerance of the given object by value theTolerance. Parameters: theObject Shape to be processed. theTolerance Required tolerance value. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing processed shape. """ anObj = self.HealOp.LimitTolerance(theObject, theTolerance) RaiseIfFailed("LimitTolerance", self.HealOp) + self._autoPublish(anObj, theName, "limitTolerance") return anObj ## Get a list of wires (wrapped in GEOM.GEOM_Object-s), # that constitute a free boundary of the given shape. # @param theObject Shape to get free boundary of. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return [\a status, \a theClosedWires, \a theOpenWires] # \n \a status: FALSE, if an error(s) occured during the method execution. # \n \a theClosedWires: Closed wires on the free boundary of the given shape. # \n \a theOpenWires: Open wires on the free boundary of the given shape. # # @ref tui_measurement_tools_page "Example" - def GetFreeBoundary(self, theObject): + def GetFreeBoundary(self, theObject, theName=None): """ Get a list of wires (wrapped in GEOM.GEOM_Object-s), that constitute a free boundary of the given shape. Parameters: theObject Shape to get free boundary of. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: [status, theClosedWires, theOpenWires] @@ -4886,6 +6131,8 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestHealing.py anObj = self.HealOp.GetFreeBoundary(theObject) RaiseIfFailed("GetFreeBoundary", self.HealOp) + self._autoPublish(anObj[1], theName, "closedWire") + self._autoPublish(anObj[2], theName, "openWire") return anObj ## Replace coincident faces in theShape by one face. @@ -4893,10 +6140,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theTolerance Maximum distance between faces, which can be considered as coincident. # @param doKeepNonSolids If FALSE, only solids will present in the result, # otherwise all initial shapes. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing a copy of theShape without coincident faces. # # @ref tui_glue_faces "Example" - def MakeGlueFaces(self, theShape, theTolerance, doKeepNonSolids=True): + def MakeGlueFaces(self, theShape, theTolerance, doKeepNonSolids=True, theName=None): """ Replace coincident faces in theShape by one face. @@ -4905,6 +6156,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theTolerance Maximum distance between faces, which can be considered as coincident. doKeepNonSolids If FALSE, only solids will present in the result, otherwise all initial shapes. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing a copy of theShape without coincident faces. @@ -4915,16 +6169,21 @@ class geompyDC(GEOM._objref_GEOM_Gen): if anObj is None: raise RuntimeError, "MakeGlueFaces : " + self.ShapesOp.GetErrorCode() anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "glueFaces") return anObj ## Find coincident faces in theShape for possible gluing. # @param theShape Initial shape. # @param theTolerance Maximum distance between faces, # which can be considered as coincident. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return GEOM.ListOfGO # # @ref tui_glue_faces "Example" - def GetGlueFaces(self, theShape, theTolerance): + def GetGlueFaces(self, theShape, theTolerance, theName=None): """ Find coincident faces in theShape for possible gluing. @@ -4932,12 +6191,16 @@ class geompyDC(GEOM._objref_GEOM_Gen): theShape Initial shape. theTolerance Maximum distance between faces, which can be considered as coincident. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: GEOM.ListOfGO """ anObj = self.ShapesOp.GetGlueFaces(theShape, theTolerance) RaiseIfFailed("GetGlueFaces", self.ShapesOp) + self._autoPublish(anObj, theName, "facesToGlue") return anObj ## Replace coincident faces in theShape by one face @@ -4951,12 +6214,16 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param doGlueAllEdges If TRUE, all coincident edges of theShape # will be glued, otherwise only the edges, # belonging to theFaces. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing a copy of theShape # without some faces. # # @ref tui_glue_faces "Example" def MakeGlueFacesByList(self, theShape, theTolerance, theFaces, - doKeepNonSolids=True, doGlueAllEdges=True): + doKeepNonSolids=True, doGlueAllEdges=True, theName=None): """ Replace coincident faces in theShape by one face in compliance with given list of faces @@ -4971,6 +6238,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): doGlueAllEdges If TRUE, all coincident edges of theShape will be glued, otherwise only the edges, belonging to theFaces. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing a copy of theShape @@ -4980,21 +6250,29 @@ class geompyDC(GEOM._objref_GEOM_Gen): doKeepNonSolids, doGlueAllEdges) if anObj is None: raise RuntimeError, "MakeGlueFacesByList : " + self.ShapesOp.GetErrorCode() + self._autoPublish(anObj, theName, "glueFaces") return anObj ## Replace coincident edges in theShape by one edge. # @param theShape Initial shape. # @param theTolerance Maximum distance between edges, which can be considered as coincident. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing a copy of theShape without coincident edges. # # @ref tui_glue_edges "Example" - def MakeGlueEdges(self, theShape, theTolerance): + def MakeGlueEdges(self, theShape, theTolerance, theName=None): """ Replace coincident edges in theShape by one edge. Parameters: theShape Initial shape. theTolerance Maximum distance between edges, which can be considered as coincident. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing a copy of theShape without coincident edges. @@ -5004,16 +6282,21 @@ class geompyDC(GEOM._objref_GEOM_Gen): if anObj is None: raise RuntimeError, "MakeGlueEdges : " + self.ShapesOp.GetErrorCode() anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "glueEdges") return anObj ## Find coincident edges in theShape for possible gluing. # @param theShape Initial shape. # @param theTolerance Maximum distance between edges, # which can be considered as coincident. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return GEOM.ListOfGO # # @ref tui_glue_edges "Example" - def GetGlueEdges(self, theShape, theTolerance): + def GetGlueEdges(self, theShape, theTolerance, theName=None): """ Find coincident edges in theShape for possible gluing. @@ -5021,12 +6304,16 @@ class geompyDC(GEOM._objref_GEOM_Gen): theShape Initial shape. theTolerance Maximum distance between edges, which can be considered as coincident. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: GEOM.ListOfGO """ anObj = self.ShapesOp.GetGlueEdges(theShape, theTolerance) RaiseIfFailed("GetGlueEdges", self.ShapesOp) + self._autoPublish(anObj, theName, "edgesToGlue") return anObj ## Replace coincident edges in theShape by one edge @@ -5035,11 +6322,15 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theTolerance Maximum distance between edges, # which can be considered as coincident. # @param theEdges List of edges for gluing. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing a copy of theShape # without some edges. # # @ref tui_glue_edges "Example" - def MakeGlueEdgesByList(self, theShape, theTolerance, theEdges): + def MakeGlueEdgesByList(self, theShape, theTolerance, theEdges, theName=None): """ Replace coincident edges in theShape by one edge in compliance with given list of edges. @@ -5049,6 +6340,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theTolerance Maximum distance between edges, which can be considered as coincident. theEdges List of edges for gluing. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing a copy of theShape @@ -5057,6 +6351,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.ShapesOp.MakeGlueEdgesByList(theShape, theTolerance, theEdges) if anObj is None: raise RuntimeError, "MakeGlueEdgesByList : " + self.ShapesOp.GetErrorCode() + self._autoPublish(anObj, theName, "glueEdges") return anObj # end of l3_healing @@ -5074,10 +6369,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theShape2 Second argument for boolean operation. # @param theOperation Indicates the operation to be done:\n # 1 - Common, 2 - Cut, 3 - Fuse, 4 - Section. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the result shape. # # @ref tui_fuse "Example" - def MakeBoolean(self,theShape1, theShape2, theOperation): + def MakeBoolean(self, theShape1, theShape2, theOperation, theName=None): """ Perform one of boolean operations on two given shapes. @@ -5086,6 +6385,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theShape2 Second argument for boolean operation. theOperation Indicates the operation to be done: 1 - Common, 2 - Cut, 3 - Fuse, 4 - Section. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the result shape. @@ -5093,94 +6395,128 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestAll.py anObj = self.BoolOp.MakeBoolean(theShape1, theShape2, theOperation) RaiseIfFailed("MakeBoolean", self.BoolOp) + def_names = { 1: "common", 2: "cut", 3: "fuse", 4: "section" } + self._autoPublish(anObj, theName, def_names[theOperation]) return anObj ## Perform Common boolean operation on two given shapes. # @param theShape1 First argument for boolean operation. # @param theShape2 Second argument for boolean operation. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the result shape. # # @ref tui_common "Example 1" # \n @ref swig_MakeCommon "Example 2" - def MakeCommon(self, theShape1, theShape2): + def MakeCommon(self, theShape1, theShape2, theName=None): """ Perform Common boolean operation on two given shapes. Parameters: theShape1 First argument for boolean operation. theShape2 Second argument for boolean operation. - + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. + Returns: New GEOM.GEOM_Object, containing the result shape. """ # Example: see GEOM_TestOthers.py - return self.MakeBoolean(theShape1, theShape2, 1) + # note: auto-publishing is done in self.MakeBoolean() + return self.MakeBoolean(theShape1, theShape2, 1, theName) ## Perform Cut boolean operation on two given shapes. # @param theShape1 First argument for boolean operation. # @param theShape2 Second argument for boolean operation. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the result shape. # # @ref tui_cut "Example 1" # \n @ref swig_MakeCommon "Example 2" - def MakeCut(self, theShape1, theShape2): + def MakeCut(self, theShape1, theShape2, theName=None): """ Perform Cut boolean operation on two given shapes. Parameters: theShape1 First argument for boolean operation. theShape2 Second argument for boolean operation. - + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. + Returns: New GEOM.GEOM_Object, containing the result shape. """ # Example: see GEOM_TestOthers.py - return self.MakeBoolean(theShape1, theShape2, 2) + # note: auto-publishing is done in self.MakeBoolean() + return self.MakeBoolean(theShape1, theShape2, 2, theName) ## Perform Fuse boolean operation on two given shapes. # @param theShape1 First argument for boolean operation. # @param theShape2 Second argument for boolean operation. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the result shape. # # @ref tui_fuse "Example 1" # \n @ref swig_MakeCommon "Example 2" - def MakeFuse(self, theShape1, theShape2): + def MakeFuse(self, theShape1, theShape2, theName=None): """ Perform Fuse boolean operation on two given shapes. Parameters: theShape1 First argument for boolean operation. theShape2 Second argument for boolean operation. - + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. + Returns: New GEOM.GEOM_Object, containing the result shape. """ # Example: see GEOM_TestOthers.py - return self.MakeBoolean(theShape1, theShape2, 3) + # note: auto-publishing is done in self.MakeBoolean() + return self.MakeBoolean(theShape1, theShape2, 3, theName) ## Perform Section boolean operation on two given shapes. # @param theShape1 First argument for boolean operation. # @param theShape2 Second argument for boolean operation. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the result shape. # # @ref tui_section "Example 1" # \n @ref swig_MakeCommon "Example 2" - def MakeSection(self, theShape1, theShape2): + def MakeSection(self, theShape1, theShape2, theName=None): """ Perform Section boolean operation on two given shapes. Parameters: theShape1 First argument for boolean operation. theShape2 Second argument for boolean operation. - + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. + Returns: New GEOM.GEOM_Object, containing the result shape. """ # Example: see GEOM_TestOthers.py - return self.MakeBoolean(theShape1, theShape2, 4) + # note: auto-publishing is done in self.MakeBoolean() + return self.MakeBoolean(theShape1, theShape2, 4, theName) # end of l3_boolean ## @} @@ -5198,6 +6534,10 @@ class geompyDC(GEOM._objref_GEOM_Gen): # target type (equal to Limit) are kept in the result, # else standalone shapes of lower dimension # are kept also (if they exist). + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @note Each compound from ListShapes and ListTools will be exploded # in order to avoid possible intersection between shapes from this compound. # @@ -5217,7 +6557,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @ref tui_partition "Example" def MakePartition(self, ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[], Limit=ShapeType["AUTO"], RemoveWebs=0, ListMaterials=[], - KeepNonlimitShapes=0): + KeepNonlimitShapes=0, theName=None): """ Perform partition operation. @@ -5231,6 +6571,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): target type (equal to Limit) are kept in the result, else standalone shapes of lower dimension are kept also (if they exist). + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Note: Each compound from ListShapes and ListTools will be exploded in order to avoid possible intersection between shapes from @@ -5263,6 +6606,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): Limit, RemoveWebs, ListMaterials, KeepNonlimitShapes); RaiseIfFailed("MakePartition", self.BoolOp) + self._autoPublish(anObj, theName, "partition") return anObj ## Perform partition operation. @@ -5281,7 +6625,8 @@ class geompyDC(GEOM._objref_GEOM_Gen): def MakePartitionNonSelfIntersectedShape(self, ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[], Limit=ShapeType["AUTO"], RemoveWebs=0, - ListMaterials=[], KeepNonlimitShapes=0): + ListMaterials=[], KeepNonlimitShapes=0, + theName=None): """ Perform partition operation. This method may be useful if it is needed to make a partition for @@ -5309,6 +6654,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): Limit, RemoveWebs, ListMaterials, KeepNonlimitShapes); RaiseIfFailed("MakePartitionNonSelfIntersectedShape", self.BoolOp) + self._autoPublish(anObj, theName, "partition") return anObj ## See method MakePartition() for more information. @@ -5317,30 +6663,38 @@ class geompyDC(GEOM._objref_GEOM_Gen): # \n @ref swig_Partition "Example 2" def Partition(self, ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[], Limit=ShapeType["AUTO"], RemoveWebs=0, ListMaterials=[], - KeepNonlimitShapes=0): + KeepNonlimitShapes=0, theName=None): """ See method geompy.MakePartition for more information. """ # Example: see GEOM_TestOthers.py + # note: auto-publishing is done in self.MakePartition() anObj = self.MakePartition(ListShapes, ListTools, ListKeepInside, ListRemoveInside, Limit, RemoveWebs, ListMaterials, - KeepNonlimitShapes); + KeepNonlimitShapes, theName); return anObj ## Perform partition of the Shape with the Plane # @param theShape Shape to be intersected. # @param thePlane Tool shape, to intersect theShape. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the result shape. # # @ref tui_partition "Example" - def MakeHalfPartition(self,theShape, thePlane): + def MakeHalfPartition(self, theShape, thePlane, theName=None): """ Perform partition of the Shape with the Plane Parameters: theShape Shape to be intersected. thePlane Tool shape, to intersect theShape. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the result shape. @@ -5348,6 +6702,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestAll.py anObj = self.BoolOp.MakeHalfPartition(theShape, thePlane) RaiseIfFailed("MakeHalfPartition", self.BoolOp) + self._autoPublish(anObj, theName, "partition") return anObj # end of l3_basic_op @@ -5356,16 +6711,49 @@ class geompyDC(GEOM._objref_GEOM_Gen): ## @addtogroup l3_transform ## @{ + ## 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. + # @param theCopy Flag used to translate object itself or create a copy. + # @return Translated @a theObject (GEOM.GEOM_Object) if @a theCopy flag is @c False (default) or + # new GEOM.GEOM_Object, containing the translated object if @a theCopy flag is @c True. + def TranslateTwoPoints(self, theObject, thePoint1, thePoint2, theCopy=False): + """ + Translate the given object along the vector, specified by its end points. + + Parameters: + theObject The object to be translated. + thePoint1 Start point of translation vector. + thePoint2 End point of translation vector. + theCopy Flag used to translate object itself or create a copy. + + Returns: + Translated theObject (GEOM.GEOM_Object) if theCopy flag is False (default) or + new GEOM.GEOM_Object, containing the translated object if theCopy flag is True. + """ + if theCopy: + anObj = self.TrsfOp.TranslateTwoPointsCopy(theObject, thePoint1, thePoint2) + else: + anObj = self.TrsfOp.TranslateTwoPoints(theObject, thePoint1, thePoint2) + RaiseIfFailed("TranslateTwoPoints", self.TrsfOp) + return anObj + ## 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. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the translated object. # # @ref tui_translation "Example 1" # \n @ref swig_MakeTranslationTwoPoints "Example 2" - def MakeTranslationTwoPoints(self,theObject, thePoint1, thePoint2): + def MakeTranslationTwoPoints(self, theObject, thePoint1, thePoint2, theName=None): """ Translate the given object along the vector, specified by its end points, creating its copy before the translation. @@ -5374,6 +6762,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theObject The object to be translated. thePoint1 Start point of translation vector. thePoint2 End point of translation vector. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the translated object. @@ -5381,28 +6772,36 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestAll.py anObj = self.TrsfOp.TranslateTwoPointsCopy(theObject, thePoint1, thePoint2) RaiseIfFailed("TranslateTwoPointsCopy", self.TrsfOp) + self._autoPublish(anObj, theName, "translated") return anObj ## 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 Translated GEOM.GEOM_Object. + # @param theCopy Flag used to translate object itself or create a copy. + # @return Translated @a theObject (GEOM.GEOM_Object) if @a theCopy flag is @c False (default) or + # new GEOM.GEOM_Object, containing the translated object if @a theCopy flag is @c True. # # @ref tui_translation "Example" - def TranslateDXDYDZ(self,theObject, theDX, theDY, theDZ): + def TranslateDXDYDZ(self, theObject, theDX, theDY, theDZ, theCopy=False): """ Translate the given object along the vector, specified by its components. Parameters: theObject The object to be translated. theDX,theDY,theDZ Components of translation vector. + theCopy Flag used to translate object itself or create a copy. Returns: - Translated GEOM.GEOM_Object. + Translated theObject (GEOM.GEOM_Object) if theCopy flag is False (default) or + new GEOM.GEOM_Object, containing the translated object if theCopy flag is True. """ # Example: see GEOM_TestAll.py theDX, theDY, theDZ, Parameters = ParseParameters(theDX, theDY, theDZ) - anObj = self.TrsfOp.TranslateDXDYDZ(theObject, theDX, theDY, theDZ) + if theCopy: + anObj = self.TrsfOp.TranslateDXDYDZCopy(theObject, theDX, theDY, theDZ) + else: + anObj = self.TrsfOp.TranslateDXDYDZ(theObject, theDX, theDY, theDZ) anObj.SetParameters(Parameters) RaiseIfFailed("TranslateDXDYDZ", self.TrsfOp) return anObj @@ -5411,10 +6810,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # by its components, creating its copy before the translation. # @param theObject The object to be translated. # @param theDX,theDY,theDZ Components of translation vector. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the translated object. # # @ref tui_translation "Example" - def MakeTranslation(self,theObject, theDX, theDY, theDZ): + def MakeTranslation(self,theObject, theDX, theDY, theDZ, theName=None): """ Translate the given object along the vector, specified by its components, creating its copy before the translation. @@ -5422,6 +6825,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): Parameters: theObject The object to be translated. theDX,theDY,theDZ Components of translation vector. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the translated object. @@ -5431,16 +6837,47 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.TrsfOp.TranslateDXDYDZCopy(theObject, theDX, theDY, theDZ) anObj.SetParameters(Parameters) RaiseIfFailed("TranslateDXDYDZ", self.TrsfOp) + self._autoPublish(anObj, theName, "translated") return anObj - ## Translate the given object along the given vector, - # creating its copy before the translation. + ## Translate the given object along the given vector. # @param theObject The object to be translated. # @param theVector The translation vector. - # @return New GEOM.GEOM_Object, containing the translated object. - # + # @param theCopy Flag used to translate object itself or create a copy. + # @return Translated @a theObject (GEOM.GEOM_Object) if @a theCopy flag is @c False (default) or + # new GEOM.GEOM_Object, containing the translated object if @a theCopy flag is @c True. + def TranslateVector(self, theObject, theVector, theCopy=False): + """ + Translate the given object along the given vector. + + Parameters: + theObject The object to be translated. + theVector The translation vector. + theCopy Flag used to translate object itself or create a copy. + + Returns: + Translated theObject (GEOM.GEOM_Object) if theCopy flag is False (default) or + new GEOM.GEOM_Object, containing the translated object if theCopy flag is True. + """ + if theCopy: + anObj = self.TrsfOp.TranslateVectorCopy(theObject, theVector) + else: + anObj = self.TrsfOp.TranslateVector(theObject, theVector) + RaiseIfFailed("TranslateVector", self.TrsfOp) + return anObj + + ## Translate the given object along the given vector, + # creating its copy before the translation. + # @param theObject The object to be translated. + # @param theVector The translation vector. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # + # @return New GEOM.GEOM_Object, containing the translated object. + # # @ref tui_translation "Example" - def MakeTranslationVector(self,theObject, theVector): + def MakeTranslationVector(self, theObject, theVector, theName=None): """ Translate the given object along the given vector, creating its copy before the translation. @@ -5448,6 +6885,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): Parameters: theObject The object to be translated. theVector The translation vector. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the translated object. @@ -5455,6 +6895,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestAll.py anObj = self.TrsfOp.TranslateVectorCopy(theObject, theVector) RaiseIfFailed("TranslateVectorCopy", self.TrsfOp) + self._autoPublish(anObj, theName, "translated") return anObj ## Translate the given object along the given vector on given distance. @@ -5462,10 +6903,11 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theVector The translation vector. # @param theDistance The translation distance. # @param theCopy Flag used to translate object itself or create a copy. - # @return New GEOM.GEOM_Object, containing the translated object. + # @return Translated @a theObject (GEOM.GEOM_Object) if @a theCopy flag is @c False (default) or + # new GEOM.GEOM_Object, containing the translated object if @a theCopy flag is @c True. # # @ref tui_translation "Example" - def TranslateVectorDistance(self, theObject, theVector, theDistance, theCopy): + def TranslateVectorDistance(self, theObject, theVector, theDistance, theCopy=False): """ Translate the given object along the given vector on given distance. @@ -5476,7 +6918,8 @@ class geompyDC(GEOM._objref_GEOM_Gen): theCopy Flag used to translate object itself or create a copy. Returns: - New GEOM.GEOM_Object, containing the translated object. + Translated theObject (GEOM.GEOM_Object) if theCopy flag is False (default) or + new GEOM.GEOM_Object, containing the translated object if theCopy flag is True. """ # Example: see GEOM_TestAll.py theDistance,Parameters = ParseParameters(theDistance) @@ -5490,10 +6933,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theObject The object to be translated. # @param theVector The translation vector. # @param theDistance The translation distance. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the translated object. # # @ref tui_translation "Example" - def MakeTranslationVectorDistance(self, theObject, theVector, theDistance): + def MakeTranslationVectorDistance(self, theObject, theVector, theDistance, theName=None): """ Translate the given object along the given vector on given distance, creating its copy before the translation. @@ -5502,6 +6949,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theObject The object to be translated. theVector The translation vector. theDistance The translation distance. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the translated object. @@ -5511,16 +6961,20 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.TrsfOp.TranslateVectorDistance(theObject, theVector, theDistance, 1) RaiseIfFailed("TranslateVectorDistance", self.TrsfOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "translated") return anObj ## 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 New GEOM.GEOM_Object, containing the rotated object. + # @param theCopy Flag used to rotate object itself or create a copy. + # + # @return Rotated @a theObject (GEOM.GEOM_Object) if @a theCopy flag is @c False (default) or + # new GEOM.GEOM_Object, containing the rotated object if @a theCopy flag is @c True. # # @ref tui_rotation "Example" - def Rotate(self,theObject, theAxis, theAngle): + def Rotate(self, theObject, theAxis, theAngle, theCopy=False): """ Rotate the given object around the given axis on the given angle. @@ -5528,9 +6982,11 @@ class geompyDC(GEOM._objref_GEOM_Gen): theObject The object to be rotated. theAxis Rotation axis. theAngle Rotation angle in radians. + theCopy Flag used to rotate object itself or create a copy. - Returns: - New GEOM.GEOM_Object, containing the rotated object. + Returns: + Rotated theObject (GEOM.GEOM_Object) if theCopy flag is False (default) or + new GEOM.GEOM_Object, containing the rotated object if theCopy flag is True. """ # Example: see GEOM_TestAll.py flag = False @@ -5539,8 +6995,11 @@ class geompyDC(GEOM._objref_GEOM_Gen): theAngle, Parameters = ParseParameters(theAngle) if flag: theAngle = theAngle*math.pi/180.0 - anObj = self.TrsfOp.Rotate(theObject, theAxis, theAngle) - RaiseIfFailed("RotateCopy", self.TrsfOp) + if theCopy: + anObj = self.TrsfOp.RotateCopy(theObject, theAxis, theAngle) + else: + anObj = self.TrsfOp.Rotate(theObject, theAxis, theAngle) + RaiseIfFailed("Rotate", self.TrsfOp) anObj.SetParameters(Parameters) return anObj @@ -5549,10 +7008,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theObject The object to be rotated. # @param theAxis Rotation axis. # @param theAngle Rotation angle in radians. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the rotated object. # # @ref tui_rotation "Example" - def MakeRotation(self,theObject, theAxis, theAngle): + def MakeRotation(self, theObject, theAxis, theAngle, theName=None): """ Rotate the given object around the given axis on the given angle, creating its copy before the rotatation. @@ -5561,6 +7024,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theObject The object to be rotated. theAxis Rotation axis. theAngle Rotation angle in radians. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the rotated object. @@ -5575,6 +7041,39 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.TrsfOp.RotateCopy(theObject, theAxis, theAngle) RaiseIfFailed("RotateCopy", self.TrsfOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "rotated") + return anObj + + ## Rotate given object around vector perpendicular to plane + # containing three points. + # @param theObject The object to be rotated. + # @param theCentPoint central point the axis is the vector perpendicular to the plane + # containing the three points. + # @param thePoint1,thePoint2 points in a perpendicular plane of the axis. + # @param theCopy Flag used to rotate object itself or create a copy. + # @return Rotated @a theObject (GEOM.GEOM_Object) if @a theCopy flag is @c False (default) or + # new GEOM.GEOM_Object, containing the rotated object if @a theCopy flag is @c True. + def RotateThreePoints(self, theObject, theCentPoint, thePoint1, thePoint2, theCopy=False): + """ + Rotate given object around vector perpendicular to plane + containing three points. + + Parameters: + theObject The object to be rotated. + theCentPoint central point the axis is the vector perpendicular to the plane + containing the three points. + thePoint1,thePoint2 points in a perpendicular plane of the axis. + theCopy Flag used to rotate object itself or create a copy. + + Returns: + Rotated theObject (GEOM.GEOM_Object) if theCopy flag is False (default) or + new GEOM.GEOM_Object, containing the rotated object if theCopy flag is True. + """ + if theCopy: + anObj = self.TrsfOp.RotateThreePointsCopy(theObject, theCentPoint, thePoint1, thePoint2) + else: + anObj = self.TrsfOp.RotateThreePoints(theObject, theCentPoint, thePoint1, thePoint2) + RaiseIfFailed("RotateThreePoints", self.TrsfOp) return anObj ## Rotate given object around vector perpendicular to plane @@ -5583,10 +7082,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theCentPoint central point the axis is the vector perpendicular to the plane # containing the three points. # @param thePoint1,thePoint2 in a perpendicular plane of the axis. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the rotated object. # # @ref tui_rotation "Example" - def MakeRotationThreePoints(self,theObject, theCentPoint, thePoint1, thePoint2): + def MakeRotationThreePoints(self, theObject, theCentPoint, thePoint1, thePoint2, theName=None): """ Rotate given object around vector perpendicular to plane containing three points, creating its copy before the rotatation. @@ -5596,6 +7099,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theCentPoint central point the axis is the vector perpendicular to the plane containing the three points. thePoint1,thePoint2 in a perpendicular plane of the axis. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the rotated object. @@ -5603,6 +7109,40 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestAll.py anObj = self.TrsfOp.RotateThreePointsCopy(theObject, theCentPoint, thePoint1, thePoint2) RaiseIfFailed("RotateThreePointsCopy", self.TrsfOp) + self._autoPublish(anObj, theName, "rotated") + return anObj + + ## Scale the given object by the specified factor. + # @param theObject The object to be scaled. + # @param thePoint Center point for scaling. + # Passing None for it means scaling relatively the origin of global CS. + # @param theFactor Scaling factor value. + # @param theCopy Flag used to scale object itself or create a copy. + # @return Scaled @a theObject (GEOM.GEOM_Object) if @a theCopy flag is @c False (default) or + # new GEOM.GEOM_Object, containing the scaled object if @a theCopy flag is @c True. + def Scale(self, theObject, thePoint, theFactor, theCopy=False): + """ + Scale the given object by the specified factor. + + Parameters: + theObject The object to be scaled. + thePoint Center point for scaling. + Passing None for it means scaling relatively the origin of global CS. + theFactor Scaling factor value. + theCopy Flag used to scale object itself or create a copy. + + Returns: + Scaled theObject (GEOM.GEOM_Object) if theCopy flag is False (default) or + new GEOM.GEOM_Object, containing the scaled object if theCopy flag is True. + """ + # Example: see GEOM_TestAll.py + theFactor, Parameters = ParseParameters(theFactor) + if theCopy: + anObj = self.TrsfOp.ScaleShapeCopy(theObject, thePoint, theFactor) + else: + anObj = self.TrsfOp.ScaleShape(theObject, thePoint, theFactor) + RaiseIfFailed("Scale", self.TrsfOp) + anObj.SetParameters(Parameters) return anObj ## Scale the given object by the factor, creating its copy before the scaling. @@ -5610,10 +7150,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param thePoint Center point for scaling. # Passing None for it means scaling relatively the origin of global CS. # @param theFactor Scaling factor value. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the scaled shape. # # @ref tui_scale "Example" - def MakeScaleTransform(self, theObject, thePoint, theFactor): + def MakeScaleTransform(self, theObject, thePoint, theFactor, theName=None): """ Scale the given object by the factor, creating its copy before the scaling. @@ -5622,6 +7166,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): thePoint Center point for scaling. Passing None for it means scaling relatively the origin of global CS. theFactor Scaling factor value. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the scaled shape. @@ -5631,6 +7178,42 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.TrsfOp.ScaleShapeCopy(theObject, thePoint, theFactor) RaiseIfFailed("ScaleShapeCopy", self.TrsfOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "scaled") + return anObj + + ## Scale the given object by different factors along coordinate axes. + # @param theObject The object to be scaled. + # @param thePoint Center point for scaling. + # Passing None for it means scaling relatively the origin of global CS. + # @param theFactorX,theFactorY,theFactorZ Scaling factors along each axis. + # @param theCopy Flag used to scale object itself or create a copy. + # @return Scaled @a theObject (GEOM.GEOM_Object) if @a theCopy flag is @c False (default) or + # new GEOM.GEOM_Object, containing the scaled object if @a theCopy flag is @c True. + def ScaleAlongAxes(self, theObject, thePoint, theFactorX, theFactorY, theFactorZ, theCopy=False): + """ + Scale the given object by different factors along coordinate axes. + + Parameters: + theObject The object to be scaled. + thePoint Center point for scaling. + Passing None for it means scaling relatively the origin of global CS. + theFactorX,theFactorY,theFactorZ Scaling factors along each axis. + theCopy Flag used to scale object itself or create a copy. + + Returns: + Scaled theObject (GEOM.GEOM_Object) if theCopy flag is False (default) or + new GEOM.GEOM_Object, containing the scaled object if theCopy flag is True. + """ + # Example: see GEOM_TestAll.py + theFactorX, theFactorY, theFactorZ, Parameters = ParseParameters(theFactorX, theFactorY, theFactorZ) + if theCopy: + anObj = self.TrsfOp.ScaleShapeAlongAxesCopy(theObject, thePoint, + theFactorX, theFactorY, theFactorZ) + else: + anObj = self.TrsfOp.ScaleShapeAlongAxes(theObject, thePoint, + theFactorX, theFactorY, theFactorZ) + RaiseIfFailed("ScaleAlongAxes", self.TrsfOp) + anObj.SetParameters(Parameters) return anObj ## Scale the given object by different factors along coordinate axes, @@ -5639,10 +7222,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param thePoint Center point for scaling. # Passing None for it means scaling relatively the origin of global CS. # @param theFactorX,theFactorY,theFactorZ Scaling factors along each axis. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the scaled shape. # # @ref swig_scale "Example" - def MakeScaleAlongAxes(self, theObject, thePoint, theFactorX, theFactorY, theFactorZ): + def MakeScaleAlongAxes(self, theObject, thePoint, theFactorX, theFactorY, theFactorZ, theName=None): """ Scale the given object by different factors along coordinate axes, creating its copy before the scaling. @@ -5652,6 +7239,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): thePoint Center point for scaling. Passing None for it means scaling relatively the origin of global CS. theFactorX,theFactorY,theFactorZ Scaling factors along each axis. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the scaled shape. @@ -5662,22 +7252,56 @@ class geompyDC(GEOM._objref_GEOM_Gen): theFactorX, theFactorY, theFactorZ) RaiseIfFailed("MakeScaleAlongAxes", self.TrsfOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "scaled") + return anObj + + ## Mirror an object relatively the given plane. + # @param theObject The object to be mirrored. + # @param thePlane Plane of symmetry. + # @param theCopy Flag used to mirror object itself or create a copy. + # @return Mirrored @a theObject (GEOM.GEOM_Object) if @a theCopy flag is @c False (default) or + # new GEOM.GEOM_Object, containing the mirrored object if @a theCopy flag is @c True. + def MirrorByPlane(self, theObject, thePlane, theCopy=False): + """ + Mirror an object relatively the given plane. + + Parameters: + theObject The object to be mirrored. + thePlane Plane of symmetry. + theCopy Flag used to mirror object itself or create a copy. + + Returns: + Mirrored theObject (GEOM.GEOM_Object) if theCopy flag is False (default) or + new GEOM.GEOM_Object, containing the mirrored object if theCopy flag is True. + """ + if theCopy: + anObj = self.TrsfOp.MirrorPlaneCopy(theObject, thePlane) + else: + anObj = self.TrsfOp.MirrorPlane(theObject, thePlane) + RaiseIfFailed("MirrorByPlane", self.TrsfOp) 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. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the mirrored shape. # # @ref tui_mirror "Example" - def MakeMirrorByPlane(self,theObject, thePlane): + def MakeMirrorByPlane(self, theObject, thePlane, theName=None): """ Create an object, symmetrical to the given one relatively the given plane. Parameters: theObject The object to be mirrored. thePlane Plane of symmetry. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the mirrored shape. @@ -5685,22 +7309,56 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestAll.py anObj = self.TrsfOp.MirrorPlaneCopy(theObject, thePlane) RaiseIfFailed("MirrorPlaneCopy", self.TrsfOp) + self._autoPublish(anObj, theName, "mirrored") + return anObj + + ## Mirror an object relatively the given axis. + # @param theObject The object to be mirrored. + # @param theAxis Axis of symmetry. + # @param theCopy Flag used to mirror object itself or create a copy. + # @return Mirrored @a theObject (GEOM.GEOM_Object) if @a theCopy flag is @c False (default) or + # new GEOM.GEOM_Object, containing the mirrored object if @a theCopy flag is @c True. + def MirrorByAxis(self, theObject, theAxis, theCopy=False): + """ + Mirror an object relatively the given axis. + + Parameters: + theObject The object to be mirrored. + theAxis Axis of symmetry. + theCopy Flag used to mirror object itself or create a copy. + + Returns: + Mirrored theObject (GEOM.GEOM_Object) if theCopy flag is False (default) or + new GEOM.GEOM_Object, containing the mirrored object if theCopy flag is True. + """ + if theCopy: + anObj = self.TrsfOp.MirrorAxisCopy(theObject, theAxis) + else: + anObj = self.TrsfOp.MirrorAxis(theObject, theAxis) + RaiseIfFailed("MirrorByAxis", self.TrsfOp) return anObj ## Create an object, symmetrical # to the given one relatively the given axis. # @param theObject The object to be mirrored. # @param theAxis Axis of symmetry. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the mirrored shape. # # @ref tui_mirror "Example" - def MakeMirrorByAxis(self,theObject, theAxis): + def MakeMirrorByAxis(self, theObject, theAxis, theName=None): """ Create an object, symmetrical to the given one relatively the given axis. Parameters: theObject The object to be mirrored. theAxis Axis of symmetry. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the mirrored shape. @@ -5708,16 +7366,48 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestAll.py anObj = self.TrsfOp.MirrorAxisCopy(theObject, theAxis) RaiseIfFailed("MirrorAxisCopy", self.TrsfOp) + self._autoPublish(anObj, theName, "mirrored") + return anObj + + ## Mirror an object relatively the given point. + # @param theObject The object to be mirrored. + # @param thePoint Point of symmetry. + # @param theCopy Flag used to mirror object itself or create a copy. + # @return Mirrored @a theObject (GEOM.GEOM_Object) if @a theCopy flag is @c False (default) or + # new GEOM.GEOM_Object, containing the mirrored object if @a theCopy flag is @c True. + def MirrorByPoint(self, theObject, thePoint, theCopy=False): + """ + Mirror an object relatively the given point. + + Parameters: + theObject The object to be mirrored. + thePoint Point of symmetry. + theCopy Flag used to mirror object itself or create a copy. + + Returns: + Mirrored theObject (GEOM.GEOM_Object) if theCopy flag is False (default) or + new GEOM.GEOM_Object, containing the mirrored object if theCopy flag is True. + """ + # Example: see GEOM_TestAll.py + if theCopy: + anObj = self.TrsfOp.MirrorPointCopy(theObject, thePoint) + else: + anObj = self.TrsfOp.MirrorPoint(theObject, thePoint) + RaiseIfFailed("MirrorByPoint", self.TrsfOp) return anObj ## Create an object, symmetrical # to the given one relatively the given point. # @param theObject The object to be mirrored. # @param thePoint Point of symmetry. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the mirrored shape. # # @ref tui_mirror "Example" - def MakeMirrorByPoint(self,theObject, thePoint): + def MakeMirrorByPoint(self, theObject, thePoint, theName=None): """ Create an object, symmetrical to the given one relatively the given point. @@ -5725,6 +7415,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): Parameters: theObject The object to be mirrored. thePoint Point of symmetry. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the mirrored shape. @@ -5732,6 +7425,44 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestAll.py anObj = self.TrsfOp.MirrorPointCopy(theObject, thePoint) RaiseIfFailed("MirrorPointCopy", self.TrsfOp) + self._autoPublish(anObj, theName, "mirrored") + return anObj + + ## Modify the location of the given object. + # @param theObject The object to be displaced. + # @param theStartLCS Coordinate system to perform displacement from it.\n + # If \a theStartLCS is NULL, displacement + # will be performed from global CS.\n + # If \a theObject itself is used as \a theStartLCS, + # its location will be changed to \a theEndLCS. + # @param theEndLCS Coordinate system to perform displacement to it. + # @param theCopy Flag used to displace object itself or create a copy. + # @return Displaced @a theObject (GEOM.GEOM_Object) if @a theCopy flag is @c False (default) or + # new GEOM.GEOM_Object, containing the displaced object if @a theCopy flag is @c True. + def Position(self, theObject, theStartLCS, theEndLCS, theCopy=False): + """ + Modify the Location of the given object by LCS, creating its copy before the setting. + + Parameters: + theObject The object to be displaced. + theStartLCS Coordinate system to perform displacement from it. + If theStartLCS is NULL, displacement + will be performed from global CS. + If theObject itself is used as theStartLCS, + its location will be changed to theEndLCS. + theEndLCS Coordinate system to perform displacement to it. + theCopy Flag used to displace object itself or create a copy. + + Returns: + Displaced theObject (GEOM.GEOM_Object) if theCopy flag is False (default) or + new GEOM.GEOM_Object, containing the displaced object if theCopy flag is True. + """ + # Example: see GEOM_TestAll.py + if theCopy: + anObj = self.TrsfOp.PositionShapeCopy(theObject, theStartLCS, theEndLCS) + else: + anObj = self.TrsfOp.PositionShape(theObject, theStartLCS, theEndLCS) + RaiseIfFailed("Displace", self.TrsfOp) return anObj ## Modify the Location of the given object by LCS, @@ -5743,10 +7474,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # If \a theObject itself is used as \a theStartLCS, # its location will be changed to \a theEndLCS. # @param theEndLCS Coordinate system to perform displacement to it. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the displaced shape. # # @ref tui_modify_location "Example" - def MakePosition(self,theObject, theStartLCS, theEndLCS): + def MakePosition(self, theObject, theStartLCS, theEndLCS, theName=None): """ Modify the Location of the given object by LCS, creating its copy before the setting. @@ -5758,6 +7493,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): If theObject itself is used as theStartLCS, its location will be changed to theEndLCS. theEndLCS Coordinate system to perform displacement to it. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the displaced shape. @@ -5772,20 +7510,22 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestAll.py anObj = self.TrsfOp.PositionShapeCopy(theObject, theStartLCS, theEndLCS) RaiseIfFailed("PositionShapeCopy", self.TrsfOp) + self._autoPublish(anObj, theName, "displaced") return anObj - ## Modify the Location of the given object by Path, + ## Modify the Location of the given object by Path. # @param theObject The object to be displaced. # @param thePath Wire or Edge along that the object will be translated. # @param theDistance progress of Path (0 = start location, 1 = end of path location). # @param theCopy is to create a copy objects if true. # @param theReverse 0 - for usual direction, 1 - to reverse path direction. - # @return New GEOM.GEOM_Object, containing the displaced shape. + # @return Displaced @a theObject (GEOM.GEOM_Object) if @a theCopy is @c False or + # new GEOM.GEOM_Object, containing the displaced shape if @a theCopy is @c True. # # @ref tui_modify_location "Example" def PositionAlongPath(self,theObject, thePath, theDistance, theCopy, theReverse): """ - Modify the Location of the given object by Path + Modify the Location of the given object by Path. Parameters: theObject The object to be displaced. @@ -5795,7 +7535,8 @@ class geompyDC(GEOM._objref_GEOM_Gen): theReverse 0 - for usual direction, 1 - to reverse path direction. Returns: - New GEOM.GEOM_Object, containing the displaced shape. + Displaced theObject (GEOM.GEOM_Object) if theCopy is False or + new GEOM.GEOM_Object, containing the displaced shape if theCopy is True. Example of usage: position = geompy.PositionAlongPath(cylinder, circle, 0.75, 1, 1) @@ -5805,19 +7546,86 @@ class geompyDC(GEOM._objref_GEOM_Gen): RaiseIfFailed("PositionAlongPath", self.TrsfOp) return anObj + ## Modify the Location of the given object by Path, creating its copy before the operation. + # @param theObject The object to be displaced. + # @param thePath Wire or Edge along that the object will be translated. + # @param theDistance progress of Path (0 = start location, 1 = end of path location). + # @param theReverse 0 - for usual direction, 1 - to reverse path direction. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # + # @return New GEOM.GEOM_Object, containing the displaced shape. + def MakePositionAlongPath(self, theObject, thePath, theDistance, theReverse, theName=None): + """ + Modify the Location of the given object by Path, creating its copy before the operation. + + Parameters: + theObject The object to be displaced. + thePath Wire or Edge along that the object will be translated. + theDistance progress of Path (0 = start location, 1 = end of path location). + theReverse 0 - for usual direction, 1 - to reverse path direction. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. + + Returns: + New GEOM.GEOM_Object, containing the displaced shape. + """ + # Example: see GEOM_TestAll.py + anObj = self.TrsfOp.PositionAlongPath(theObject, thePath, theDistance, 1, theReverse) + RaiseIfFailed("PositionAlongPath", self.TrsfOp) + self._autoPublish(anObj, theName, "displaced") + return anObj + + ## Offset given shape. + # @param theObject The base object for the offset. + # @param theOffset Offset value. + # @param theCopy Flag used to offset object itself or create a copy. + # @return Modified @a theObject (GEOM.GEOM_Object) if @a theCopy flag is @c False (default) or + # new GEOM.GEOM_Object, containing the result of offset operation if @a theCopy flag is @c True. + def Offset(self, theObject, theOffset, theCopy=False): + """ + Offset given shape. + + Parameters: + theObject The base object for the offset. + theOffset Offset value. + theCopy Flag used to offset object itself or create a copy. + + Returns: + Modified theObject (GEOM.GEOM_Object) if theCopy flag is False (default) or + new GEOM.GEOM_Object, containing the result of offset operation if theCopy flag is True. + """ + theOffset, Parameters = ParseParameters(theOffset) + if theCopy: + anObj = self.TrsfOp.OffsetShapeCopy(theObject, theOffset) + else: + anObj = self.TrsfOp.OffsetShape(theObject, theOffset) + RaiseIfFailed("Offset", self.TrsfOp) + anObj.SetParameters(Parameters) + return anObj + ## Create new object as offset of the given one. # @param theObject The base object for the offset. # @param theOffset Offset value. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the offset object. # # @ref tui_offset "Example" - def MakeOffset(self,theObject, theOffset): + def MakeOffset(self, theObject, theOffset, theName=None): """ Create new object as offset of the given one. Parameters: theObject The base object for the offset. theOffset Offset value. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the offset object. @@ -5832,21 +7640,29 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.TrsfOp.OffsetShapeCopy(theObject, theOffset) RaiseIfFailed("OffsetShapeCopy", self.TrsfOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "offset") return anObj ## Create new object as projection of the given one on a 2D surface. # @param theSource The source object for the projection. It can be a point, edge or wire. # @param theTarget The target object. It can be planar or cylindrical face. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the projection. # # @ref tui_projection "Example" - def MakeProjection(self, theSource, theTarget): + def MakeProjection(self, theSource, theTarget, theName=None): """ Create new object as projection of the given one on a 2D surface. Parameters: theSource The source object for the projection. It can be a point, edge or wire. theTarget The target object. It can be planar or cylindrical face. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the projection. @@ -5854,6 +7670,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestAll.py anObj = self.TrsfOp.ProjectShapeCopy(theSource, theTarget) RaiseIfFailed("ProjectShapeCopy", self.TrsfOp) + self._autoPublish(anObj, theName, "projection") return anObj # ----------------------------------------------------------------------------- @@ -5862,22 +7679,29 @@ class geompyDC(GEOM._objref_GEOM_Gen): ## 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 theVector Direction of the translation. DX if None. # @param theStep Distance to translate on. # @param theNbTimes Quantity of translations to be done. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing compound of all # the shapes, obtained after each translation. # # @ref tui_multi_translation "Example" - def MakeMultiTranslation1D(self,theObject, theVector, theStep, theNbTimes): + def MakeMultiTranslation1D(self, theObject, theVector, theStep, theNbTimes, theName=None): """ Translate the given object along the given vector a given number times Parameters: theObject The object to be translated. - theVector Direction of the translation. + theVector Direction of the translation. DX if None. theStep Distance to translate on. theNbTimes Quantity of translations to be done. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing compound of all @@ -5891,33 +7715,41 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.TrsfOp.MultiTranslate1D(theObject, theVector, theStep, theNbTimes) RaiseIfFailed("MultiTranslate1D", self.TrsfOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "multitranslation") 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 theVector1 Direction of the first translation. DX if None. # @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 theVector2 Direction of the second translation. DY if None. # @param theStep2 Step of the second translation. # @param theNbTimes2 Quantity of translations to be done along theVector2. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing compound of all # the shapes, obtained after each translation. # # @ref tui_multi_translation "Example" - def MakeMultiTranslation2D(self,theObject, theVector1, theStep1, theNbTimes1, - theVector2, theStep2, theNbTimes2): + def MakeMultiTranslation2D(self, theObject, theVector1, theStep1, theNbTimes1, + theVector2, theStep2, theNbTimes2, theName=None): """ Conseqently apply two specified translations to theObject specified number of times. Parameters: theObject The object to be translated. - theVector1 Direction of the first translation. + theVector1 Direction of the first translation. DX if None. theStep1 Step of the first translation. theNbTimes1 Quantity of translations to be done along theVector1. - theVector2 Direction of the second translation. + theVector2 Direction of the second translation. DY if None. theStep2 Step of the second translation. theNbTimes2 Quantity of translations to be done along theVector2. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing compound of all @@ -5932,39 +7764,142 @@ class geompyDC(GEOM._objref_GEOM_Gen): theVector2, theStep2, theNbTimes2) RaiseIfFailed("MultiTranslate2D", self.TrsfOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "multitranslation") 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 theAxis The rotation axis. DZ if None. # @param theNbTimes Quantity of rotations to be done. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing compound of all the # shapes, obtained after each rotation. # # @ref tui_multi_rotation "Example" - def MultiRotate1D(self,theObject, theAxis, theNbTimes): + def MultiRotate1DNbTimes (self, theObject, theAxis, theNbTimes, theName=None): """ Rotate the given object around the given axis a given number times. Rotation angle will be 2*PI/theNbTimes. Parameters: theObject The object to be rotated. - theAxis The rotation axis. + theAxis The rotation axis. DZ if None. theNbTimes Quantity of rotations to be done. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing compound of all the shapes, obtained after each rotation. Example of usage: - rot1d = geompy.MultiRotate1D(prism, vect, 4) + rot1d = geompy.MultiRotate1DNbTimes(prism, vect, 4) """ # Example: see GEOM_TestAll.py - theAxis, theNbTimes, Parameters = ParseParameters(theAxis, theNbTimes) + theNbTimes, Parameters = ParseParameters(theNbTimes) anObj = self.TrsfOp.MultiRotate1D(theObject, theAxis, theNbTimes) - RaiseIfFailed("MultiRotate1D", self.TrsfOp) + RaiseIfFailed("MultiRotate1DNbTimes", self.TrsfOp) + anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "multirotation") + return anObj + + ## Rotate the given object around the given axis + # a given number times on the given angle. + # @param theObject The object to be rotated. + # @param theAxis The rotation axis. DZ if None. + # @param theAngleStep Rotation angle in radians. + # @param theNbTimes Quantity of rotations to be done. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # + # @return New GEOM.GEOM_Object, containing compound of all the + # shapes, obtained after each rotation. + # + # @ref tui_multi_rotation "Example" + def MultiRotate1DByStep(self, theObject, theAxis, theAngleStep, theNbTimes, theName=None): + """ + Rotate the given object around the given axis + a given number times on the given angle. + + Parameters: + theObject The object to be rotated. + theAxis The rotation axis. DZ if None. + theAngleStep Rotation angle in radians. + theNbTimes Quantity of rotations to be done. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. + + Returns: + New GEOM.GEOM_Object, containing compound of all the + shapes, obtained after each rotation. + + Example of usage: + rot1d = geompy.MultiRotate1DByStep(prism, vect, math.pi/4, 4) + """ + # Example: see GEOM_TestAll.py + theAngleStep, theNbTimes, Parameters = ParseParameters(theAngleStep, theNbTimes) + anObj = self.TrsfOp.MultiRotate1DByStep(theObject, theAxis, theAngleStep, theNbTimes) + RaiseIfFailed("MultiRotate1DByStep", self.TrsfOp) + anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "multirotation") + return anObj + + ## Rotate the given object around the given axis a given + # number times and multi-translate each rotation result. + # Rotation angle will be 2*PI/theNbTimes1. + # 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. DZ if None. + # @param theNbTimes1 Quantity of rotations to be done. + # @param theRadialStep Translation distance. + # @param theNbTimes2 Quantity of translations to be done. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # + # @return New GEOM.GEOM_Object, containing compound of all the + # shapes, obtained after each transformation. + # + # @ref tui_multi_rotation "Example" + def MultiRotate2DNbTimes(self, theObject, theAxis, theNbTimes1, theRadialStep, theNbTimes2, theName=None): + """ + 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. + + Parameters: + theObject The object to be rotated. + theAxis Rotation axis. DZ if None. + theNbTimes1 Quantity of rotations to be done. + theRadialStep Translation distance. + theNbTimes2 Quantity of translations to be done. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. + + Returns: + New GEOM.GEOM_Object, containing compound of all the + shapes, obtained after each transformation. + + Example of usage: + rot2d = geompy.MultiRotate2D(prism, vect, 60, 4, 50, 5) + """ + # Example: see GEOM_TestAll.py + theNbTimes1, theRadialStep, theNbTimes2, Parameters = ParseParameters(theNbTimes1, theRadialStep, theNbTimes2) + anObj = self.TrsfOp.MultiRotate2DNbTimes(theObject, theAxis, theNbTimes1, theRadialStep, theNbTimes2) + RaiseIfFailed("MultiRotate2DNbTimes", self.TrsfOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "multirotation") return anObj ## Rotate the given object around the @@ -5973,16 +7908,20 @@ class geompyDC(GEOM._objref_GEOM_Gen): # 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 theAxis Rotation axis. DZ if None. + # @param theAngleStep Rotation angle in radians. # @param theNbTimes1 Quantity of rotations to be done. - # @param theStep Translation distance. + # @param theRadialStep Translation distance. # @param theNbTimes2 Quantity of translations to be done. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing compound of all the # shapes, obtained after each transformation. # # @ref tui_multi_rotation "Example" - def MultiRotate2D(self,theObject, theAxis, theAngle, theNbTimes1, theStep, theNbTimes2): + def MultiRotate2DByStep (self, theObject, theAxis, theAngleStep, theNbTimes1, theRadialStep, theNbTimes2, theName=None): """ Rotate the given object around the given axis on the given angle a given number @@ -5992,80 +7931,197 @@ class geompyDC(GEOM._objref_GEOM_Gen): Parameters: theObject The object to be rotated. - theAxis Rotation axis. - theAngle Rotation angle in graduces. + theAxis Rotation axis. DZ if None. + theAngleStep Rotation angle in radians. theNbTimes1 Quantity of rotations to be done. - theStep Translation distance. + theRadialStep Translation distance. theNbTimes2 Quantity of translations to be done. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing compound of all the shapes, obtained after each transformation. Example of usage: - rot2d = geompy.MultiRotate2D(prism, vect, 60, 4, 50, 5) + rot2d = geompy.MultiRotate2D(prism, vect, math.pi/3, 4, 50, 5) """ # Example: see GEOM_TestAll.py - theAngle, theNbTimes1, theStep, theNbTimes2, Parameters = ParseParameters(theAngle, theNbTimes1, theStep, theNbTimes2) - anObj = self.TrsfOp.MultiRotate2D(theObject, theAxis, theAngle, theNbTimes1, theStep, theNbTimes2) - RaiseIfFailed("MultiRotate2D", self.TrsfOp) + theAngleStep, theNbTimes1, theRadialStep, theNbTimes2, Parameters = ParseParameters(theAngleStep, theNbTimes1, theRadialStep, theNbTimes2) + anObj = self.TrsfOp.MultiRotate2DByStep(theObject, theAxis, theAngleStep, theNbTimes1, theRadialStep, theNbTimes2) + RaiseIfFailed("MultiRotate2DByStep", self.TrsfOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "multirotation") return anObj - ## The same, as MultiRotate1D(), but axis is given by direction and point + ## The same, as MultiRotate1DNbTimes(), but axis is given by direction and point + # + # @ref swig_MakeMultiRotation "Example" + def MakeMultiRotation1DNbTimes(self, aShape, aDir, aPoint, aNbTimes, theName=None): + """ + The same, as geompy.MultiRotate1DNbTimes, but axis is given by direction and point + + Example of usage: + pz = geompy.MakeVertex(0, 0, 100) + vy = geompy.MakeVectorDXDYDZ(0, 100, 0) + MultiRot1D = geompy.MakeMultiRotation1DNbTimes(prism, vy, pz, 6) + """ + # Example: see GEOM_TestOthers.py + aVec = self.MakeLine(aPoint,aDir) + # note: auto-publishing is done in self.MultiRotate1D() + anObj = self.MultiRotate1DNbTimes(aShape, aVec, aNbTimes, theName) + return anObj + + ## The same, as MultiRotate1DByStep(), but axis is given by direction and point # # @ref swig_MakeMultiRotation "Example" - def MakeMultiRotation1D(self,aShape,aDir,aPoint,aNbTimes): + def MakeMultiRotation1DByStep(self, aShape, aDir, aPoint, anAngle, aNbTimes, theName=None): """ The same, as geompy.MultiRotate1D, but axis is given by direction and point Example of usage: pz = geompy.MakeVertex(0, 0, 100) vy = geompy.MakeVectorDXDYDZ(0, 100, 0) - MultiRot1D = geompy.MakeMultiRotation1D(prism, vy, pz, 6) + MultiRot1D = geompy.MakeMultiRotation1DByStep(prism, vy, pz, math.pi/3, 6) """ # Example: see GEOM_TestOthers.py aVec = self.MakeLine(aPoint,aDir) - anObj = self.MultiRotate1D(aShape,aVec,aNbTimes) + # note: auto-publishing is done in self.MultiRotate1D() + anObj = self.MultiRotate1DByStep(aShape, aVec, anAngle, aNbTimes, theName) return anObj - ## The same, as MultiRotate2D(), but axis is given by direction and point + ## The same, as MultiRotate2DNbTimes(), but axis is given by direction and point # # @ref swig_MakeMultiRotation "Example" - def MakeMultiRotation2D(self,aShape,aDir,aPoint,anAngle,nbtimes1,aStep,nbtimes2): + def MakeMultiRotation2DNbTimes(self, aShape, aDir, aPoint, nbtimes1, aStep, nbtimes2, theName=None): """ - The same, as MultiRotate2D(), but axis is given by direction and point + The same, as MultiRotate2DNbTimes(), but axis is given by direction and point Example of usage: pz = geompy.MakeVertex(0, 0, 100) vy = geompy.MakeVectorDXDYDZ(0, 100, 0) - MultiRot2D = geompy.MakeMultiRotation2D(f12, vy, pz, 45, 6, 30, 3) + MultiRot2D = geompy.MakeMultiRotation2DNbTimes(f12, vy, pz, 6, 30, 3) """ # Example: see GEOM_TestOthers.py aVec = self.MakeLine(aPoint,aDir) - anObj = self.MultiRotate2D(aShape,aVec,anAngle,nbtimes1,aStep,nbtimes2) + # note: auto-publishing is done in self.MultiRotate2DNbTimes() + anObj = self.MultiRotate2DNbTimes(aShape, aVec, nbtimes1, aStep, nbtimes2, theName) + return anObj + + ## The same, as MultiRotate2DByStep(), but axis is given by direction and point + # + # @ref swig_MakeMultiRotation "Example" + def MakeMultiRotation2DByStep(self, aShape, aDir, aPoint, anAngle, nbtimes1, aStep, nbtimes2, theName=None): + """ + The same, as MultiRotate2DByStep(), but axis is given by direction and point + + Example of usage: + pz = geompy.MakeVertex(0, 0, 100) + vy = geompy.MakeVectorDXDYDZ(0, 100, 0) + MultiRot2D = geompy.MakeMultiRotation2DByStep(f12, vy, pz, math.pi/4, 6, 30, 3) + """ + # Example: see GEOM_TestOthers.py + aVec = self.MakeLine(aPoint,aDir) + # note: auto-publishing is done in self.MultiRotate2D() + anObj = self.MultiRotate2DByStep(aShape, aVec, anAngle, nbtimes1, aStep, nbtimes2, theName) return anObj # end of l3_transform ## @} + ## @addtogroup l3_transform_d + ## @{ + + ## Deprecated method. Use MultiRotate1DNbTimes instead. + def MultiRotate1D(self, theObject, theAxis, theNbTimes, theName=None): + """ + Deprecated method. Use MultiRotate1DNbTimes instead. + """ + print "The method MultiRotate1D is DEPRECATED. Use MultiRotate1DNbTimes instead." + return self.MultiRotate1DNbTimes(theObject, theAxis, theNbTimes, theName) + + ## The same, as MultiRotate2DByStep(), but theAngle is in degrees. + # This method is DEPRECATED. Use MultiRotate2DByStep() instead. + def MultiRotate2D(self, theObject, theAxis, theAngle, theNbTimes1, theStep, theNbTimes2, theName=None): + """ + The same, as MultiRotate2DByStep(), but theAngle is in degrees. + This method is DEPRECATED. Use MultiRotate2DByStep() instead. + + Example of usage: + rot2d = geompy.MultiRotate2D(prism, vect, 60, 4, 50, 5) + """ + print "The method MultiRotate2D is DEPRECATED. Use MultiRotate2DByStep instead." + theAngle, theNbTimes1, theStep, theNbTimes2, Parameters = ParseParameters(theAngle, theNbTimes1, theStep, theNbTimes2) + anObj = self.TrsfOp.MultiRotate2D(theObject, theAxis, theAngle, theNbTimes1, theStep, theNbTimes2) + RaiseIfFailed("MultiRotate2D", self.TrsfOp) + anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "multirotation") + return anObj + + ## The same, as MultiRotate1D(), but axis is given by direction and point + # This method is DEPRECATED. Use MakeMultiRotation1DNbTimes instead. + def MakeMultiRotation1D(self, aShape, aDir, aPoint, aNbTimes, theName=None): + """ + The same, as geompy.MultiRotate1D, but axis is given by direction and point. + This method is DEPRECATED. Use MakeMultiRotation1DNbTimes instead. + + Example of usage: + pz = geompy.MakeVertex(0, 0, 100) + vy = geompy.MakeVectorDXDYDZ(0, 100, 0) + MultiRot1D = geompy.MakeMultiRotation1D(prism, vy, pz, 6) + """ + print "The method MakeMultiRotation1D is DEPRECATED. Use MakeMultiRotation1DNbTimes instead." + aVec = self.MakeLine(aPoint,aDir) + # note: auto-publishing is done in self.MultiRotate1D() + anObj = self.MultiRotate1D(aShape, aVec, aNbTimes, theName) + return anObj + + ## The same, as MultiRotate2D(), but axis is given by direction and point + # This method is DEPRECATED. Use MakeMultiRotation2DByStep instead. + def MakeMultiRotation2D(self, aShape, aDir, aPoint, anAngle, nbtimes1, aStep, nbtimes2, theName=None): + """ + The same, as MultiRotate2D(), but axis is given by direction and point + This method is DEPRECATED. Use MakeMultiRotation2DByStep instead. + + Example of usage: + pz = geompy.MakeVertex(0, 0, 100) + vy = geompy.MakeVectorDXDYDZ(0, 100, 0) + MultiRot2D = geompy.MakeMultiRotation2D(f12, vy, pz, 45, 6, 30, 3) + """ + print "The method MakeMultiRotation2D is DEPRECATED. Use MakeMultiRotation2DByStep instead." + aVec = self.MakeLine(aPoint,aDir) + # note: auto-publishing is done in self.MultiRotate2D() + anObj = self.MultiRotate2D(aShape, aVec, anAngle, nbtimes1, aStep, nbtimes2, theName) + return anObj + + # end of l3_transform_d + ## @} + ## @addtogroup l3_local ## @{ ## Perform a fillet on all edges of the given shape. # @param theShape Shape, to perform fillet on. # @param theR Fillet radius. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the result shape. # # @ref tui_fillet "Example 1" # \n @ref swig_MakeFilletAll "Example 2" - def MakeFilletAll(self,theShape, theR): + def MakeFilletAll(self, theShape, theR, theName=None): """ Perform a fillet on all edges of the given shape. Parameters: theShape Shape, to perform fillet on. theR Fillet radius. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the result shape. @@ -6078,6 +8134,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.LocalOp.MakeFilletAll(theShape, theR) RaiseIfFailed("MakeFilletAll", self.LocalOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "fillet") return anObj ## Perform a fillet on the specified edges/faces of the given shape @@ -6085,11 +8142,16 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theR Fillet radius. # @param theShapeType Type of shapes in theListShapes (see ShapeType()) # @param theListShapes Global indices of edges/faces to perform fillet on. - # \note Global index of sub-shape can be obtained, using method GetSubShapeID(). + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # + # @note Global index of sub-shape can be obtained, using method GetSubShapeID(). + # # @return New GEOM.GEOM_Object, containing the result shape. # # @ref tui_fillet "Example" - def MakeFillet(self,theShape, theR, theShapeType, theListShapes): + def MakeFillet(self, theShape, theR, theShapeType, theListShapes, theName=None): """ Perform a fillet on the specified edges/faces of the given shape @@ -6098,6 +8160,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theR Fillet radius. theShapeType Type of shapes in theListShapes (see geompy.ShapeTypes) theListShapes Global indices of edges/faces to perform fillet on. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Note: Global index of sub-shape can be obtained, using method geompy.GetSubShapeID @@ -6125,10 +8190,11 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.LocalOp.MakeFilletFaces(theShape, theR, theListShapes) RaiseIfFailed("MakeFilletFaces", self.LocalOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "fillet") return anObj ## The same that MakeFillet() but with two Fillet Radius R1 and R2 - def MakeFilletR1R2(self, theShape, theR1, theR2, theShapeType, theListShapes): + def MakeFilletR1R2(self, theShape, theR1, theR2, theShapeType, theListShapes, theName=None): """ The same that geompy.MakeFillet but with two Fillet Radius R1 and R2 @@ -6151,6 +8217,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.LocalOp.MakeFilletFacesR1R2(theShape, theR1, theR2, theListShapes) RaiseIfFailed("MakeFilletFacesR1R2", self.LocalOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "fillet") return anObj ## Perform a fillet on the specified edges of the given shape @@ -6166,10 +8233,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # the fillet point, and such two (or more) edges can be united to allow # bigger radius. Set this flag to TRUE to allow collinear edges union, # thus ignoring the secant vertex (vertices). + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the result shape. # # @ref tui_fillet2d "Example" - def MakeFillet1D(self,theShape, theR, theListOfVertexes, doIgnoreSecantVertices = True): + def MakeFillet1D(self, theShape, theR, theListOfVertexes, doIgnoreSecantVertices = True, theName=None): """ Perform a fillet on the specified edges of the given shape @@ -6183,6 +8254,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): the fillet point, and such two (or more) edges can be united to allow bigger radius. Set this flag to TRUE to allow collinear edges union, thus ignoring the secant vertex (vertices). + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Note: Global index of sub-shape can be obtained, using method geompy.GetSubShapeID @@ -6202,17 +8276,23 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.LocalOp.MakeFillet1D(theShape, theR, theListOfVertexes, doIgnoreSecantVertices) RaiseIfFailed("MakeFillet1D", self.LocalOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "fillet") return anObj ## Perform a fillet at the specified vertices of the given face/shell. # @param theShape Face or Shell shape to perform fillet on. # @param theR Fillet radius. # @param theListOfVertexes Global indices of vertexes to perform fillet on. - # \note Global index of sub-shape can be obtained, using method GetSubShapeID(). + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # + # @note Global index of sub-shape can be obtained, using method GetSubShapeID(). + # # @return New GEOM.GEOM_Object, containing the result shape. # # @ref tui_fillet2d "Example" - def MakeFillet2D(self, theShape, theR, theListOfVertexes): + def MakeFillet2D(self, theShape, theR, theListOfVertexes, theName=None): """ Perform a fillet at the specified vertices of the given face/shell. @@ -6220,6 +8300,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theShape Face or Shell shape to perform fillet on. theR Fillet radius. theListOfVertexes Global indices of vertexes to perform fillet on. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Note: Global index of sub-shape can be obtained, using method geompy.GetSubShapeID @@ -6235,22 +8318,30 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.LocalOp.MakeFillet2D(theShape, theR, theListOfVertexes) RaiseIfFailed("MakeFillet2D", self.LocalOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "fillet") return anObj ## Perform a symmetric chamfer on all edges of the given shape. # @param theShape Shape, to perform chamfer on. # @param theD Chamfer size along each face. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the result shape. # # @ref tui_chamfer "Example 1" # \n @ref swig_MakeChamferAll "Example 2" - def MakeChamferAll(self,theShape, theD): + def MakeChamferAll(self, theShape, theD, theName=None): """ Perform a symmetric chamfer on all edges of the given shape. Parameters: theShape Shape, to perform chamfer on. theD Chamfer size along each face. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the result shape. @@ -6263,6 +8354,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.LocalOp.MakeChamferAll(theShape, theD) RaiseIfFailed("MakeChamferAll", self.LocalOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "chamfer") return anObj ## Perform a chamfer on edges, common to the specified faces, @@ -6271,11 +8363,16 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @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 GetSubShapeID(). + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # + # @note Global index of sub-shape can be obtained, using method GetSubShapeID(). + # # @return New GEOM.GEOM_Object, containing the result shape. # # @ref tui_chamfer "Example" - def MakeChamferEdge(self,theShape, theD1, theD2, theFace1, theFace2): + def MakeChamferEdge(self, theShape, theD1, theD2, theFace1, theFace2, theName=None): """ Perform a chamfer on edges, common to the specified faces, with distance D1 on the Face1 @@ -6285,6 +8382,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theD1 Chamfer size along theFace1. theD2 Chamfer size along theFace2. theFace1,theFace2 Global indices of two faces of theShape. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Note: Global index of sub-shape can be obtained, using method geompy.GetSubShapeID @@ -6303,6 +8403,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.LocalOp.MakeChamferEdge(theShape, theD1, theD2, theFace1, theFace2) RaiseIfFailed("MakeChamferEdge", self.LocalOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "chamfer") return anObj ## Perform a chamfer on edges @@ -6310,9 +8411,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theD Chamfer length # @param theAngle Angle of chamfer (angle in radians or a name of variable which defines angle in degrees) # @param theFace1,theFace2 Global indices of two faces of \a theShape. - # \note Global index of sub-shape can be obtained, using method GetSubShapeID(). + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # + # @note Global index of sub-shape can be obtained, using method GetSubShapeID(). + # # @return New GEOM.GEOM_Object, containing the result shape. - def MakeChamferEdgeAD(self, theShape, theD, theAngle, theFace1, theFace2): + def MakeChamferEdgeAD(self, theShape, theD, theAngle, theFace1, theFace2, theName=None): """ Perform a chamfer on edges @@ -6321,6 +8427,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theD1 Chamfer size along theFace1. theAngle Angle of chamfer (angle in radians or a name of variable which defines angle in degrees). theFace1,theFace2 Global indices of two faces of theShape. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Note: Global index of sub-shape can be obtained, using method geompy.GetSubShapeID @@ -6344,6 +8453,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.LocalOp.MakeChamferEdgeAD(theShape, theD, theAngle, theFace1, theFace2) RaiseIfFailed("MakeChamferEdgeAD", self.LocalOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "chamfer") return anObj ## Perform a chamfer on all edges of the specified faces, @@ -6354,11 +8464,16 @@ class geompyDC(GEOM._objref_GEOM_Gen): # 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 GetSubShapeID(). + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # + # @note Global index of sub-shape can be obtained, using method GetSubShapeID(). + # # @return New GEOM.GEOM_Object, containing the result shape. # # @ref tui_chamfer "Example" - def MakeChamferFaces(self,theShape, theD1, theD2, theFaces): + def MakeChamferFaces(self, theShape, theD1, theD2, theFaces, theName=None): """ Perform a chamfer on all edges of the specified faces, with distance D1 on the first specified face (if several for one edge) @@ -6370,7 +8485,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): will be get along face, which is nearer to theFaces beginning. theD2 Chamfer size along another of two faces, connected to the edge. theFaces Sequence of global indices of faces of theShape. - + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Note: Global index of sub-shape can be obtained, using method geompy.GetSubShapeID(). @@ -6382,13 +8499,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.LocalOp.MakeChamferFaces(theShape, theD1, theD2, theFaces) RaiseIfFailed("MakeChamferFaces", self.LocalOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "chamfer") return anObj ## The Same that MakeChamferFaces() but with params theD is chamfer lenght and # theAngle is Angle of chamfer (angle in radians or a name of variable which defines angle in degrees) # # @ref swig_FilletChamfer "Example" - def MakeChamferFacesAD(self, theShape, theD, theAngle, theFaces): + def MakeChamferFacesAD(self, theShape, theD, theAngle, theFaces, theName=None): """ The Same that geompy.MakeChamferFaces but with params theD is chamfer lenght and theAngle is Angle of chamfer (angle in radians or a name of variable which defines angle in degrees) @@ -6402,6 +8520,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.LocalOp.MakeChamferFacesAD(theShape, theD, theAngle, theFaces) RaiseIfFailed("MakeChamferFacesAD", self.LocalOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "chamfer") return anObj ## Perform a chamfer on edges, @@ -6409,10 +8528,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theShape Shape, to perform chamfer on. # @param theD1,theD2 Chamfer size # @param theEdges Sequence of edges of \a theShape. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the result shape. # # @ref swig_FilletChamfer "Example" - def MakeChamferEdges(self, theShape, theD1, theD2, theEdges): + def MakeChamferEdges(self, theShape, theD1, theD2, theEdges, theName=None): """ Perform a chamfer on edges, with distance D1 on the first specified face (if several for one edge) @@ -6421,6 +8544,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theShape Shape, to perform chamfer on. theD1,theD2 Chamfer size theEdges Sequence of edges of theShape. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the result shape. @@ -6429,11 +8555,12 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.LocalOp.MakeChamferEdges(theShape, theD1, theD2, theEdges) RaiseIfFailed("MakeChamferEdges", self.LocalOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "chamfer") return anObj ## The Same that MakeChamferEdges() but with params theD is chamfer lenght and # theAngle is Angle of chamfer (angle in radians or a name of variable which defines angle in degrees) - def MakeChamferEdgesAD(self, theShape, theD, theAngle, theEdges): + def MakeChamferEdgesAD(self, theShape, theD, theAngle, theEdges, theName=None): """ The Same that geompy.MakeChamferEdges but with params theD is chamfer lenght and theAngle is Angle of chamfer (angle in radians or a name of variable which defines angle in degrees) @@ -6447,21 +8574,23 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.LocalOp.MakeChamferEdgesAD(theShape, theD, theAngle, theEdges) RaiseIfFailed("MakeChamferEdgesAD", self.LocalOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "chamfer") return anObj - ## /sa MakeChamferEdge() and MakeChamferFaces() + ## @sa MakeChamferEdge(), MakeChamferFaces() # # @ref swig_MakeChamfer "Example" - def MakeChamfer(self,aShape,d1,d2,aShapeType,ListShape): + def MakeChamfer(self, aShape, d1, d2, aShapeType, ListShape, theName=None): """ See geompy.MakeChamferEdge() and geompy.MakeChamferFaces() functions for more information. """ # Example: see GEOM_TestOthers.py anObj = None + # note: auto-publishing is done in self.MakeChamferEdge() or self.MakeChamferFaces() if aShapeType == ShapeType["EDGE"]: - anObj = self.MakeChamferEdge(aShape,d1,d2,ListShape[0],ListShape[1]) + anObj = self.MakeChamferEdge(aShape,d1,d2,ListShape[0],ListShape[1],theName) else: - anObj = self.MakeChamferFaces(aShape,d1,d2,ListShape) + anObj = self.MakeChamferFaces(aShape,d1,d2,ListShape,theName) return anObj ## Remove material from a solid by extrusion of the base shape on the given distance. @@ -6470,10 +8599,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theBase Closed edge or wire defining the base shape to be extruded. # @param theH Prism dimension along the normal to theBase # @param theAngle Draft angle in degrees. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the initial shape with removed material # # @ref tui_creation_prism "Example" - def MakeExtrudedCut(self, theInit, theBase, theH, theAngle): + def MakeExtrudedCut(self, theInit, theBase, theH, theAngle, theName=None): """ Add material to a solid by extrusion of the base shape on the given distance. @@ -6482,6 +8615,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theBase Closed edge or wire defining the base shape to be extruded. theH Prism dimension along the normal to theBase theAngle Draft angle in degrees. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the initial shape with removed material. @@ -6491,6 +8627,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.PrimOp.MakeDraftPrism(theInit, theBase, theH, theAngle, False) RaiseIfFailed("MakeExtrudedBoss", self.PrimOp) #anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "extrudedCut") return anObj ## Add material to a solid by extrusion of the base shape on the given distance. @@ -6499,10 +8636,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theBase Closed edge or wire defining the base shape to be extruded. # @param theH Prism dimension along the normal to theBase # @param theAngle Draft angle in degrees. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the initial shape with added material # # @ref tui_creation_prism "Example" - def MakeExtrudedBoss(self, theInit, theBase, theH, theAngle): + def MakeExtrudedBoss(self, theInit, theBase, theH, theAngle, theName=None): """ Add material to a solid by extrusion of the base shape on the given distance. @@ -6511,6 +8652,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theBase Closed edge or wire defining the base shape to be extruded. theH Prism dimension along the normal to theBase theAngle Draft angle in degrees. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the initial shape with added material. @@ -6520,6 +8664,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.PrimOp.MakeDraftPrism(theInit, theBase, theH, theAngle, True) RaiseIfFailed("MakeExtrudedBoss", self.PrimOp) #anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "extrudedBoss") return anObj # end of l3_local @@ -6534,11 +8679,15 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theWeight Weight og the shape. # @param theWaterDensity Density of the water. # @param theMeshDeflection Deflection of the mesh, using to compute the section. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing a section of \a theShape # by a plane, corresponding to water level. # # @ref tui_archimede "Example" - def Archimede(self,theShape, theWeight, theWaterDensity, theMeshDeflection): + def Archimede(self, theShape, theWeight, theWaterDensity, theMeshDeflection, theName=None): """ Perform an Archimde operation on the given shape with given parameters. The object presenting the resulting face is returned. @@ -6548,6 +8697,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theWeight Weight og the shape. theWaterDensity Density of the water. theMeshDeflection Deflection of the mesh, using to compute the section. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing a section of theShape @@ -6559,6 +8711,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.LocalOp.MakeArchimede(theShape, theWeight, theWaterDensity, theMeshDeflection) RaiseIfFailed("MakeArchimede", self.LocalOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "archimede") return anObj # end of l3_basic_op @@ -6581,7 +8734,61 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestMeasures.py aTuple = self.MeasuOp.PointCoordinates(Point) RaiseIfFailed("PointCoordinates", self.MeasuOp) - return aTuple + return aTuple + + ## Get vector coordinates + # @return [x, y, z] + # + # @ref tui_measurement_tools_page "Example" + def VectorCoordinates(self,Vector): + """ + Get vector coordinates + + Returns: + [x, y, z] + """ + + p1=self.GetFirstVertex(Vector) + p2=self.GetLastVertex(Vector) + + X1=self.PointCoordinates(p1) + X2=self.PointCoordinates(p2) + + return (X2[0]-X1[0],X2[1]-X1[1],X2[2]-X1[2]) + + + ## Compute cross product + # @return vector w=u^v + # + # @ref tui_measurement_tools_page "Example" + def CrossProduct(self, Vector1, Vector2): + """ + Compute cross product + + Returns: vector w=u^v + """ + u=self.VectorCoordinates(Vector1) + v=self.VectorCoordinates(Vector2) + w=self.MakeVectorDXDYDZ(u[1]*v[2]-u[2]*v[1], u[2]*v[0]-u[0]*v[2], u[0]*v[1]-u[1]*v[0]) + + return w + + ## Compute cross product + # @return dot product p=u.v + # + # @ref tui_measurement_tools_page "Example" + def DotProduct(self, Vector1, Vector2): + """ + Compute cross product + + Returns: dot product p=u.v + """ + u=self.VectorCoordinates(Vector1) + v=self.VectorCoordinates(Vector2) + p=u[0]*v[0]+u[1]*v[1]+u[2]*v[2] + + return p + ## Get summarized length of all wires, # area of surface and volume of the given shape. @@ -6619,7 +8826,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Zmin,Zmax: Limits of shape along OZ axis. # # @ref tui_measurement_tools_page "Example" - def BoundingBox(self,theShape): + def BoundingBox (self, theShape): """ Get parameters of bounding box of the given shape @@ -6637,6 +8844,34 @@ class geompyDC(GEOM._objref_GEOM_Gen): RaiseIfFailed("GetBoundingBox", self.MeasuOp) return aTuple + ## Get bounding box of the given shape + # @param theShape Shape to obtain bounding box of. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # + # @return New GEOM.GEOM_Object, containing the created box. + # + # @ref tui_measurement_tools_page "Example" + def MakeBoundingBox (self, theShape, theName=None): + """ + Get bounding box of the given shape + + Parameters: + theShape Shape to obtain bounding box of. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. + + Returns: + New GEOM.GEOM_Object, containing the created box. + """ + # Example: see GEOM_TestMeasures.py + anObj = self.MeasuOp.MakeBoundingBox(theShape) + RaiseIfFailed("MakeBoundingBox", self.MeasuOp) + self._autoPublish(anObj, theName, "bndbox") + return anObj + ## 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] @@ -6702,7 +8937,8 @@ class geompyDC(GEOM._objref_GEOM_Gen): ## 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. + # @return Value of the minimal distance between the given shapes, in form of list + # [Distance, DX, DY, DZ]. # # @ref swig_all_measure "Example" def MinDistanceComponents(self, theShape1, theShape2): @@ -6713,7 +8949,8 @@ class geompyDC(GEOM._objref_GEOM_Gen): theShape1,theShape2 Shapes to find minimal distance between. Returns: - Value of the minimal distance between the given shapes. + Value of the minimal distance between the given shapes, in form of list + [Distance, DX, DY, DZ] """ # Example: see GEOM_TestMeasures.py aTuple = self.MeasuOp.GetMinDistance(theShape1, theShape2) @@ -6721,6 +8958,28 @@ class geompyDC(GEOM._objref_GEOM_Gen): aRes = [aTuple[0], aTuple[4] - aTuple[1], aTuple[5] - aTuple[2], aTuple[6] - aTuple[3]] return aRes + ## Get closest points of the given shapes. + # @param theShape1,theShape2 Shapes to find closest points of. + # @return The number of found solutions (-1 in case of infinite number of + # solutions) and a list of (X, Y, Z) coordinates for all couples of points. + # + # @ref tui_measurement_tools_page "Example" + def ClosestPoints (self, theShape1, theShape2): + """ + Get closest points of the given shapes. + + Parameters: + theShape1,theShape2 Shapes to find closest points of. + + Returns: + The number of found solutions (-1 in case of infinite number of + solutions) and a list of (X, Y, Z) coordinates for all couples of points. + """ + # Example: see GEOM_TestMeasures.py + aTuple = self.MeasuOp.ClosestPoints(theShape1, theShape2) + RaiseIfFailed("ClosestPoints", self.MeasuOp) + return aTuple + ## Get angle between the given shapes in degrees. # @param theShape1,theShape2 Lines or linear edges to find angle between. # @note If both arguments are vectors, the angle is computed in accordance @@ -7066,15 +9325,22 @@ class geompyDC(GEOM._objref_GEOM_Gen): ## Get a point, situated at the centre of mass of theShape. # @param theShape Shape to define centre of mass of. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created point. # # @ref tui_measurement_tools_page "Example" - def MakeCDG(self,theShape): + def MakeCDG(self, theShape, theName=None): """ Get a point, situated at the centre of mass of theShape. Parameters: theShape Shape to define centre of mass of. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created point. @@ -7082,21 +9348,29 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestMeasures.py anObj = self.MeasuOp.GetCentreOfMass(theShape) RaiseIfFailed("GetCentreOfMass", self.MeasuOp) + self._autoPublish(anObj, theName, "centerOfMass") return anObj ## Get a vertex sub-shape by index depended with orientation. # @param theShape Shape to find sub-shape. # @param theIndex Index to find vertex by this index (starting from zero) + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created vertex. # # @ref tui_measurement_tools_page "Example" - def GetVertexByIndex(self,theShape, theIndex): + def GetVertexByIndex(self, theShape, theIndex, theName=None): """ Get a vertex sub-shape by index depended with orientation. Parameters: theShape Shape to find sub-shape. theIndex Index to find vertex by this index (starting from zero) + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created vertex. @@ -7104,46 +9378,63 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestMeasures.py anObj = self.MeasuOp.GetVertexByIndex(theShape, theIndex) RaiseIfFailed("GetVertexByIndex", self.MeasuOp) + self._autoPublish(anObj, theName, "vertex") return anObj ## Get the first vertex of wire/edge depended orientation. # @param theShape Shape to find first vertex. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created vertex. # # @ref tui_measurement_tools_page "Example" - def GetFirstVertex(self,theShape): + def GetFirstVertex(self, theShape, theName=None): """ Get the first vertex of wire/edge depended orientation. Parameters: theShape Shape to find first vertex. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created vertex. """ # Example: see GEOM_TestMeasures.py - anObj = self.GetVertexByIndex(theShape, 0) + # note: auto-publishing is done in self.GetVertexByIndex() + anObj = self.GetVertexByIndex(theShape, 0, theName) RaiseIfFailed("GetFirstVertex", self.MeasuOp) return anObj ## Get the last vertex of wire/edge depended orientation. # @param theShape Shape to find last vertex. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created vertex. # # @ref tui_measurement_tools_page "Example" - def GetLastVertex(self,theShape): + def GetLastVertex(self, theShape, theName=None): """ Get the last vertex of wire/edge depended orientation. Parameters: theShape Shape to find last vertex. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created vertex. """ # Example: see GEOM_TestMeasures.py nb_vert = self.ShapesOp.NumberOfSubShapes(theShape, ShapeType["VERTEX"]) - anObj = self.GetVertexByIndex(theShape, (nb_vert-1)) + # note: auto-publishing is done in self.GetVertexByIndex() + anObj = self.GetVertexByIndex(theShape, (nb_vert-1), theName) RaiseIfFailed("GetLastVertex", self.MeasuOp) return anObj @@ -7151,10 +9442,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # the normale is calculated at the center of mass. # @param theFace Face to define normale of. # @param theOptionalPoint Point to compute the normale at. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created vector. # # @ref swig_todo "Example" - def GetNormal(self, theFace, theOptionalPoint = None): + def GetNormal(self, theFace, theOptionalPoint = None, theName=None): """ Get a normale to the given face. If the point is not given, the normale is calculated at the center of mass. @@ -7162,6 +9457,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): Parameters: theFace Face to define normale of. theOptionalPoint Point to compute the normale at. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created vector. @@ -7169,6 +9467,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestMeasures.py anObj = self.MeasuOp.GetNormal(theFace, theOptionalPoint) RaiseIfFailed("GetNormal", self.MeasuOp) + self._autoPublish(anObj, theName, "normal") return anObj ## Check a topology of the given shape. @@ -7324,10 +9623,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # If format 'IGES_SCALE' is used instead of 'IGES' or # format 'STEP_SCALE' is used instead of 'STEP', # length unit will be set to 'meter' and result model will be scaled. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the imported shape. # # @ref swig_Import_Export "Example" - def ImportFile(self, theFileName, theFormatName): + def ImportFile(self, theFileName, theFormatName, theName=None): """ Import a shape from the BREP or IGES or STEP file (depends on given format) with given name. @@ -7339,44 +9642,55 @@ class geompyDC(GEOM._objref_GEOM_Gen): If format 'IGES_SCALE' is used instead of 'IGES' or format 'STEP_SCALE' is used instead of 'STEP', length unit will be set to 'meter' and result model will be scaled. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the imported shape. """ # Example: see GEOM_TestOthers.py anObj = self.InsertOp.ImportFile(theFileName, theFormatName) - RaiseIfFailed("Import", self.InsertOp) + RaiseIfFailed("ImportFile", self.InsertOp) + self._autoPublish(anObj, theName, "imported") return anObj ## Deprecated analog of ImportFile() - def Import(self, theFileName, theFormatName): + def Import(self, theFileName, theFormatName, theName=None): """ - Deprecated analog of geompy.ImportFile + Deprecated analog of geompy.ImportFile, kept for backward compatibility only. """ print "WARNING: Function Import is deprecated, use ImportFile instead" - anObj = self.InsertOp.ImportFile(theFileName, theFormatName) - RaiseIfFailed("Import", self.InsertOp) - return anObj + # note: auto-publishing is done in self.ImportFile() + return self.ImportFile(theFileName, theFormatName, theName) ## Shortcut to ImportFile() for BREP format. # Import a shape from the BREP file with given name. # @param theFileName The file, containing the shape. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the imported shape. # # @ref swig_Import_Export "Example" - def ImportBREP(self, theFileName): + def ImportBREP(self, theFileName, theName=None): """ geompy.ImportFile(...) function for BREP format Import a shape from the BREP file with given name. Parameters: theFileName The file, containing the shape. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the imported shape. """ # Example: see GEOM_TestOthers.py - return self.ImportFile(theFileName, "BREP") + # note: auto-publishing is done in self.ImportFile() + return self.ImportFile(theFileName, "BREP", theName) ## Shortcut to ImportFile() for IGES format # Import a shape from the IGES file with given name. @@ -7384,10 +9698,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param ignoreUnits If True, file length units will be ignored (set to 'meter') # and result model will be scaled, if its units are not meters. # If False (default), file length units will be taken into account. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the imported shape. # # @ref swig_Import_Export "Example" - def ImportIGES(self, theFileName, ignoreUnits = False): + def ImportIGES(self, theFileName, ignoreUnits = False, theName=None): """ geompy.ImportFile(...) function for IGES format @@ -7396,14 +9714,18 @@ class geompyDC(GEOM._objref_GEOM_Gen): ignoreUnits If True, file length units will be ignored (set to 'meter') and result model will be scaled, if its units are not meters. If False (default), file length units will be taken into account. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the imported shape. """ # Example: see GEOM_TestOthers.py + # note: auto-publishing is done in self.ImportFile() if ignoreUnits: - return self.ImportFile(theFileName, "IGES_SCALE") - return self.ImportFile(theFileName, "IGES") + return self.ImportFile(theFileName, "IGES_SCALE", theName) + return self.ImportFile(theFileName, "IGES", theName) ## Return length unit from given IGES file # @param theFileName The file, containing the shape. @@ -7430,10 +9752,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param ignoreUnits If True, file length units will be ignored (set to 'meter') # and result model will be scaled, if its units are not meters. # If False (default), file length units will be taken into account. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the imported shape. # # @ref swig_Import_Export "Example" - def ImportSTEP(self, theFileName, ignoreUnits = False): + def ImportSTEP(self, theFileName, ignoreUnits = False, theName=None): """ geompy.ImportFile(...) function for STEP format @@ -7442,14 +9768,18 @@ class geompyDC(GEOM._objref_GEOM_Gen): ignoreUnits If True, file length units will be ignored (set to 'meter') and result model will be scaled, if its units are not meters. If False (default), file length units will be taken into account. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the imported shape. """ # Example: see GEOM_TestOthers.py + # note: auto-publishing is done in self.ImportFile() if ignoreUnits: - return self.ImportFile(theFileName, "STEP_SCALE") - return self.ImportFile(theFileName, "STEP") + return self.ImportFile(theFileName, "STEP_SCALE", theName) + return self.ImportFile(theFileName, "STEP", theName) ## Return length unit from given IGES or STEP file # @param theFileName The file, containing the shape. @@ -7474,10 +9804,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @note This method will not be dumped to the python script by DumpStudy functionality. # @note GEOM.GEOM_Object.GetShapeStream() method can be used to obtain the shape's BRep stream. # @param theStream The BRep binary stream. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM_Object, containing the shape, read from theStream. # # @ref swig_Import_Export "Example" - def RestoreShape (self, theStream): + def RestoreShape (self, theStream, theName=None): """ Read a shape from the binary stream, containing its bounding representation (BRep). @@ -7486,6 +9820,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): Parameters: theStream The BRep binary stream. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM_Object, containing the shape, read from theStream. @@ -7493,13 +9830,15 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestOthers.py anObj = self.InsertOp.RestoreShape(theStream) RaiseIfFailed("RestoreShape", self.InsertOp) + self._autoPublish(anObj, theName, "restored") return anObj ## 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. + # Available formats can be obtained with + # geompy.InsertOp.ExportTranslators()[0] method. # # @ref swig_Import_Export "Example" def Export(self, theObject, theFileName, theFormatName): @@ -7510,7 +9849,8 @@ class geompyDC(GEOM._objref_GEOM_Gen): theObject Shape to be stored in the file. theFileName Name of the file to store the given shape in. theFormatName Specify format for the shape storage. - Available formats can be obtained with geompy.InsertOp.ImportTranslators() method. + Available formats can be obtained with + geompy.InsertOp.ExportTranslators()[0] method. """ # Example: see GEOM_TestOthers.py self.InsertOp.Export(theObject, theFileName, theFormatName) @@ -7558,16 +9898,23 @@ class geompyDC(GEOM._objref_GEOM_Gen): ## 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. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created face. # # @ref tui_building_by_blocks_page "Example" - def MakeQuad(self,E1, E2, E3, E4): + def MakeQuad(self, E1, E2, E3, E4, theName=None): """ Create a quadrangle face from four edges. Order of Edges is not important. It is not necessary that edges share the same vertex. Parameters: E1,E2,E3,E4 Edges for the face bound. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created face. @@ -7578,21 +9925,29 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_Spanner.py anObj = self.BlocksOp.MakeQuad(E1, E2, E3, E4) RaiseIfFailed("MakeQuad", self.BlocksOp) + self._autoPublish(anObj, theName, "quad") 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. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created face. # # @ref tui_building_by_blocks_page "Example" - def MakeQuad2Edges(self,E1, E2): + def MakeQuad2Edges(self, E1, E2, theName=None): """ Create a quadrangle face on two edges. The missing edges will be built by creating the shortest ones. Parameters: E1,E2 Two opposite edges for the face. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created face. @@ -7612,22 +9967,30 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_Spanner.py anObj = self.BlocksOp.MakeQuad2Edges(E1, E2) RaiseIfFailed("MakeQuad2Edges", self.BlocksOp) + self._autoPublish(anObj, theName, "quad") 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. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created face. # # @ref tui_building_by_blocks_page "Example 1" # \n @ref swig_MakeQuad4Vertices "Example 2" - def MakeQuad4Vertices(self,V1, V2, V3, V4): + def MakeQuad4Vertices(self, V1, V2, V3, V4, theName=None): """ Create a quadrangle face with specified corners. The missing edges will be built by creating the shortest ones. Parameters: V1,V2,V3,V4 Corner vertices for the face. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created face. @@ -7644,22 +10007,30 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_Spanner.py anObj = self.BlocksOp.MakeQuad4Vertices(V1, V2, V3, V4) RaiseIfFailed("MakeQuad4Vertices", self.BlocksOp) + self._autoPublish(anObj, theName, "quad") 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. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created solid. # # @ref tui_building_by_blocks_page "Example 1" # \n @ref swig_MakeHexa "Example 2" - def MakeHexa(self,F1, F2, F3, F4, F5, F6): + def MakeHexa(self, F1, F2, F3, F4, F5, F6, theName=None): """ 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. Parameters: F1,F2,F3,F4,F5,F6 Faces for the hexahedral solid. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created solid. @@ -7670,22 +10041,30 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_Spanner.py anObj = self.BlocksOp.MakeHexa(F1, F2, F3, F4, F5, F6) RaiseIfFailed("MakeHexa", self.BlocksOp) + self._autoPublish(anObj, theName, "hexa") 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. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the created solid. # # @ref tui_building_by_blocks_page "Example 1" # \n @ref swig_MakeHexa2Faces "Example 2" - def MakeHexa2Faces(self,F1, F2): + def MakeHexa2Faces(self, F1, F2, theName=None): """ Create a hexahedral solid between two given faces. The missing faces will be built by creating the smallest ones. Parameters: F1,F2 Two opposite faces for the hexahedral solid. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the created solid. @@ -7696,6 +10075,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_Spanner.py anObj = self.BlocksOp.MakeHexa2Faces(F1, F2) RaiseIfFailed("MakeHexa2Faces", self.BlocksOp) + self._autoPublish(anObj, theName, "hexa") return anObj # end of l3_blocks @@ -7709,10 +10089,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theX,theY,theZ Coordinates of the sought vertex. # @param theEpsilon Maximum allowed distance between the resulting # vertex and point with the given coordinates. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the found vertex. # # @ref swig_GetPoint "Example" - def GetPoint(self, theShape, theX, theY, theZ, theEpsilon): + def GetPoint(self, theShape, theX, theY, theZ, theEpsilon, theName=None): """ Get a vertex, found in the given shape by its coordinates. @@ -7721,6 +10105,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theX,theY,theZ Coordinates of the sought vertex. theEpsilon Maximum allowed distance between the resulting vertex and point with the given coordinates. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the found vertex. @@ -7731,21 +10118,29 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestOthers.py anObj = self.BlocksOp.GetPoint(theShape, theX, theY, theZ, theEpsilon) RaiseIfFailed("GetPoint", self.BlocksOp) + self._autoPublish(anObj, theName, "vertex") return anObj ## Find a vertex of the given shape, which has minimal distance to the given point. # @param theShape Any shape. # @param thePoint Point, close to the desired vertex. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the found vertex. # # @ref swig_GetVertexNearPoint "Example" - def GetVertexNearPoint(self, theShape, thePoint): + def GetVertexNearPoint(self, theShape, thePoint, theName=None): """ Find a vertex of the given shape, which has minimal distance to the given point. Parameters: theShape Any shape. thePoint Point, close to the desired vertex. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the found vertex. @@ -7757,21 +10152,29 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestOthers.py anObj = self.BlocksOp.GetVertexNearPoint(theShape, thePoint) RaiseIfFailed("GetVertexNearPoint", self.BlocksOp) + self._autoPublish(anObj, theName, "vertex") return anObj ## 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. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the found edge. # # @ref swig_GetEdge "Example" - def GetEdge(self, theShape, thePoint1, thePoint2): + def GetEdge(self, theShape, thePoint1, thePoint2, theName=None): """ Get an edge, found in the given shape by two given vertices. Parameters: theShape Block or a compound of blocks. thePoint1,thePoint2 Points, close to the ends of the desired edge. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the found edge. @@ -7779,21 +10182,29 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_Spanner.py anObj = self.BlocksOp.GetEdge(theShape, thePoint1, thePoint2) RaiseIfFailed("GetEdge", self.BlocksOp) + self._autoPublish(anObj, theName, "edge") return anObj ## 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. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the found edge. # # @ref swig_GetEdgeNearPoint "Example" - def GetEdgeNearPoint(self, theShape, thePoint): + def GetEdgeNearPoint(self, theShape, thePoint, theName=None): """ Find an edge of the given shape, which has minimal distance to the given point. Parameters: theShape Block or a compound of blocks. thePoint Point, close to the desired edge. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the found edge. @@ -7801,21 +10212,29 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestOthers.py anObj = self.BlocksOp.GetEdgeNearPoint(theShape, thePoint) RaiseIfFailed("GetEdgeNearPoint", self.BlocksOp) + self._autoPublish(anObj, theName, "edge") return anObj ## Returns a face, found in the given shape by four given corner vertices. # @param theShape Block or a compound of blocks. # @param thePoint1,thePoint2,thePoint3,thePoint4 Points, close to the corners of the desired face. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the found face. # # @ref swig_todo "Example" - def GetFaceByPoints(self,theShape, thePoint1, thePoint2, thePoint3, thePoint4): + def GetFaceByPoints(self, theShape, thePoint1, thePoint2, thePoint3, thePoint4, theName=None): """ Returns a face, found in the given shape by four given corner vertices. Parameters: theShape Block or a compound of blocks. thePoint1,thePoint2,thePoint3,thePoint4 Points, close to the corners of the desired face. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the found face. @@ -7823,21 +10242,29 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_Spanner.py anObj = self.BlocksOp.GetFaceByPoints(theShape, thePoint1, thePoint2, thePoint3, thePoint4) RaiseIfFailed("GetFaceByPoints", self.BlocksOp) + self._autoPublish(anObj, theName, "face") return anObj ## Get a face of block, found in the given shape by two given edges. # @param theShape Block or a compound of blocks. # @param theEdge1,theEdge2 Edges, close to the edges of the desired face. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the found face. # # @ref swig_todo "Example" - def GetFaceByEdges(self,theShape, theEdge1, theEdge2): + def GetFaceByEdges(self, theShape, theEdge1, theEdge2, theName=None): """ Get a face of block, found in the given shape by two given edges. Parameters: theShape Block or a compound of blocks. theEdge1,theEdge2 Edges, close to the edges of the desired face. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the found face. @@ -7845,21 +10272,29 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_Spanner.py anObj = self.BlocksOp.GetFaceByEdges(theShape, theEdge1, theEdge2) RaiseIfFailed("GetFaceByEdges", self.BlocksOp) + self._autoPublish(anObj, theName, "face") return anObj ## Find a face, opposite to the given one in the given block. # @param theBlock Must be a hexahedral solid. # @param theFace Face of \a theBlock, opposite to the desired face. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the found face. # # @ref swig_GetOppositeFace "Example" - def GetOppositeFace(self,theBlock, theFace): + def GetOppositeFace(self, theBlock, theFace, theName=None): """ Find a face, opposite to the given one in the given block. Parameters: theBlock Must be a hexahedral solid. theFace Face of theBlock, opposite to the desired face. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the found face. @@ -7867,21 +10302,29 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_Spanner.py anObj = self.BlocksOp.GetOppositeFace(theBlock, theFace) RaiseIfFailed("GetOppositeFace", self.BlocksOp) + self._autoPublish(anObj, theName, "face") return anObj ## Find a face of the given shape, which has minimal distance to the given point. # @param theShape Block or a compound of blocks. # @param thePoint Point, close to the desired face. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the found face. # # @ref swig_GetFaceNearPoint "Example" - def GetFaceNearPoint(self, theShape, thePoint): + def GetFaceNearPoint(self, theShape, thePoint, theName=None): """ Find a face of the given shape, which has minimal distance to the given point. Parameters: theShape Block or a compound of blocks. thePoint Point, close to the desired face. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the found face. @@ -7889,21 +10332,29 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_Spanner.py anObj = self.BlocksOp.GetFaceNearPoint(theShape, thePoint) RaiseIfFailed("GetFaceNearPoint", self.BlocksOp) + self._autoPublish(anObj, theName, "face") return anObj ## Find a face of block, whose outside normale has minimal angle with the given vector. # @param theBlock Block or a compound of blocks. # @param theVector Vector, close to the normale of the desired face. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the found face. # # @ref swig_todo "Example" - def GetFaceByNormale(self, theBlock, theVector): + def GetFaceByNormale(self, theBlock, theVector, theName=None): """ Find a face of block, whose outside normale has minimal angle with the given vector. Parameters: theBlock Block or a compound of blocks. theVector Vector, close to the normale of the desired face. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the found face. @@ -7911,6 +10362,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_Spanner.py anObj = self.BlocksOp.GetFaceByNormale(theBlock, theVector) RaiseIfFailed("GetFaceByNormale", self.BlocksOp) + self._autoPublish(anObj, theName, "face") return anObj ## Find all sub-shapes of type \a theShapeType of the given shape, @@ -7921,10 +10373,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theTolerance The tolerance for distances comparison. All shapes # with distances to the given point in interval # [minimal_distance, minimal_distance + theTolerance] will be gathered. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM_Object, containing a group of all found shapes. # # @ref swig_GetShapesNearPoint "Example" - def GetShapesNearPoint(self, theShape, thePoint, theShapeType, theTolerance = 1e-07): + def GetShapesNearPoint(self, theShape, thePoint, theShapeType, theTolerance = 1e-07, theName=None): """ Find all sub-shapes of type theShapeType of the given shape, which have minimal distance to the given point. @@ -7936,6 +10392,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theTolerance The tolerance for distances comparison. All shapes with distances to the given point in interval [minimal_distance, minimal_distance + theTolerance] will be gathered. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM_Object, containing a group of all found shapes. @@ -7943,6 +10402,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestOthers.py anObj = self.BlocksOp.GetShapesNearPoint(theShape, thePoint, theShapeType, theTolerance) RaiseIfFailed("GetShapesNearPoint", self.BlocksOp) + self._autoPublish(anObj, theName, "group") return anObj # end of l3_blocks_op @@ -7991,6 +10451,10 @@ class geompyDC(GEOM._objref_GEOM_Gen): ## Retrieve all non blocks solids and faces from \a theShape. # @param theShape The shape to explore. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return A tuple of two GEOM_Objects. The first object is a group of all # non block solids (= not 6 faces, or with 6 faces, but with the # presence of non-quadrangular faces). The second object is a @@ -7998,12 +10462,15 @@ class geompyDC(GEOM._objref_GEOM_Gen): # # @ref tui_measurement_tools_page "Example 1" # \n @ref swig_GetNonBlocks "Example 2" - def GetNonBlocks (self, theShape): + def GetNonBlocks (self, theShape, theName=None): """ Retrieve all non blocks solids and faces from theShape. Parameters: theShape The shape to explore. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: A tuple of two GEOM_Objects. The first object is a group of all @@ -8017,6 +10484,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_Spanner.py aTuple = self.BlocksOp.GetNonBlocks(theShape) RaiseIfFailed("GetNonBlocks", self.BlocksOp) + self._autoPublish(aTuple, theName, ("groupNonHexas", "groupNonQuads")) return aTuple ## Remove all seam and degenerated edges from \a theShape. @@ -8025,10 +10493,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theShape The compound or single solid to remove irregular edges from. # @param doUnionFaces If True, then unite faces. If False (the default value), # do not unite faces. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return Improved shape. # # @ref swig_RemoveExtraEdges "Example" - def RemoveExtraEdges(self, theShape, doUnionFaces=False): + def RemoveExtraEdges(self, theShape, doUnionFaces=False, theName=None): """ Remove all seam and degenerated edges from theShape. Unite faces and edges, sharing one surface. It means that @@ -8038,6 +10510,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theShape The compound or single solid to remove irregular edges from. doUnionFaces If True, then unite faces. If False (the default value), do not unite faces. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: Improved shape. @@ -8047,16 +10522,21 @@ class geompyDC(GEOM._objref_GEOM_Gen): if doUnionFaces is True: nbFacesOptimum = 0 # 0 means unite faces anObj = self.BlocksOp.RemoveExtraEdges(theShape, nbFacesOptimum) RaiseIfFailed("RemoveExtraEdges", self.BlocksOp) + self._autoPublish(anObj, theName, "removeExtraEdges") return anObj ## Check, if the given shape is a blocks compound. # Fix all detected errors. # \note Single block can be also fixed by this method. # @param theShape The compound to check and improve. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return Improved compound. # # @ref swig_CheckAndImprove "Example" - def CheckAndImprove(self,theShape): + def CheckAndImprove(self, theShape, theName=None): """ Check, if the given shape is a blocks compound. Fix all detected errors. @@ -8066,6 +10546,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): Parameters: theShape The compound to check and improve. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: Improved compound. @@ -8073,6 +10556,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestOthers.py anObj = self.BlocksOp.CheckAndImprove(theShape) RaiseIfFailed("CheckAndImprove", self.BlocksOp) + self._autoPublish(anObj, theName, "improved") return anObj # end of l4_blocks_measure @@ -8085,12 +10569,17 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @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. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # + # @note If theMaxNbFaces = 0, the maximum number of faces is not restricted. + # # @return List of GEOM.GEOM_Object, containing the retrieved blocks. # # @ref tui_explode_on_blocks "Example 1" # \n @ref swig_MakeBlockExplode "Example 2" - def MakeBlockExplode(self,theCompound, theMinNbFaces, theMaxNbFaces): + def MakeBlockExplode(self, theCompound, theMinNbFaces, theMaxNbFaces, theName=None): """ Get all the blocks, contained in the given compound. @@ -8098,6 +10587,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theCompound The compound to explode. theMinNbFaces If solid has lower number of faces, it is not a block. theMaxNbFaces If solid has higher number of faces, it is not a block. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Note: If theMaxNbFaces = 0, the maximum number of faces is not restricted. @@ -8112,16 +10604,21 @@ class geompyDC(GEOM._objref_GEOM_Gen): for anObj in aList: anObj.SetParameters(Parameters) pass + self._autoPublish(aList, theName, "block") return aList ## Find block, containing the given point inside its volume or on boundary. # @param theCompound Compound, to find block in. # @param thePoint Point, close to the desired block. If the point lays on # boundary between some blocks, we return block with nearest center. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the found block. # # @ref swig_todo "Example" - def GetBlockNearPoint(self,theCompound, thePoint): + def GetBlockNearPoint(self, theCompound, thePoint, theName=None): """ Find block, containing the given point inside its volume or on boundary. @@ -8129,6 +10626,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theCompound Compound, to find block in. thePoint Point, close to the desired block. If the point lays on boundary between some blocks, we return block with nearest center. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the found block. @@ -8136,21 +10636,29 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_Spanner.py anObj = self.BlocksOp.GetBlockNearPoint(theCompound, thePoint) RaiseIfFailed("GetBlockNearPoint", self.BlocksOp) + self._autoPublish(anObj, theName, "block") return anObj ## Find block, containing all the elements, passed as the parts, or maximum quantity of them. # @param theCompound Compound, to find block in. # @param theParts List of faces and/or edges and/or vertices to be parts of the found block. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the found block. # # @ref swig_GetBlockByParts "Example" - def GetBlockByParts(self,theCompound, theParts): + def GetBlockByParts(self, theCompound, theParts, theName=None): """ Find block, containing all the elements, passed as the parts, or maximum quantity of them. Parameters: theCompound Compound, to find block in. theParts List of faces and/or edges and/or vertices to be parts of the found block. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM_Object, containing the found block. @@ -8158,21 +10666,29 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestOthers.py anObj = self.BlocksOp.GetBlockByParts(theCompound, theParts) RaiseIfFailed("GetBlockByParts", self.BlocksOp) + self._autoPublish(anObj, theName, "block") return anObj ## Return all blocks, containing all the elements, passed as the parts. # @param theCompound Compound, to find blocks in. # @param theParts List of faces and/or edges and/or vertices to be parts of the found blocks. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return List of GEOM.GEOM_Object, containing the found blocks. # # @ref swig_todo "Example" - def GetBlocksByParts(self,theCompound, theParts): + def GetBlocksByParts(self, theCompound, theParts, theName=None): """ Return all blocks, containing all the elements, passed as the parts. Parameters: theCompound Compound, to find blocks in. theParts List of faces and/or edges and/or vertices to be parts of the found blocks. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: List of GEOM.GEOM_Object, containing the found blocks. @@ -8180,6 +10696,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_Spanner.py aList = self.BlocksOp.GetBlocksByParts(theCompound, theParts) RaiseIfFailed("GetBlocksByParts", self.BlocksOp) + self._autoPublish(aList, theName, "block") return aList ## Multi-transformate block and glue the result. @@ -8188,11 +10705,16 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @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(). + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # + # @note Unique ID of sub-shape can be obtained, using method GetSubShapeID(). + # # @return New GEOM.GEOM_Object, containing the result shape. # # @ref tui_multi_transformation "Example" - def MakeMultiTransformation1D(self,Block, DirFace1, DirFace2, NbTimes): + def MakeMultiTransformation1D(self, Block, DirFace1, DirFace2, NbTimes, theName=None): """ Multi-transformate block and glue the result. Transformation is defined so, as to superpose direction faces. @@ -8202,6 +10724,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): DirFace1 ID of First direction face. DirFace2 ID of Second direction face. NbTimes Quantity of transformations to be done. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Note: Unique ID of sub-shape can be obtained, using method GetSubShapeID(). @@ -8214,6 +10739,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.BlocksOp.MakeMultiTransformation1D(Block, DirFace1, DirFace2, NbTimes) RaiseIfFailed("MakeMultiTransformation1D", self.BlocksOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "transformed") return anObj ## Multi-transformate block and glue the result. @@ -8221,11 +10747,15 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @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. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM.GEOM_Object, containing the result shape. # # @ref tui_multi_transformation "Example" - def MakeMultiTransformation2D(self,Block, DirFace1U, DirFace2U, NbTimesU, - DirFace1V, DirFace2V, NbTimesV): + def MakeMultiTransformation2D(self, Block, DirFace1U, DirFace2U, NbTimesU, + DirFace1V, DirFace2V, NbTimesV, theName=None): """ Multi-transformate block and glue the result. @@ -8234,6 +10764,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): DirFace1U,DirFace2U IDs of Direction faces for the first transformation. DirFace1V,DirFace2V IDs of Direction faces for the second transformation. NbTimesU,NbTimesV Quantity of transformations to be done. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: New GEOM.GEOM_Object, containing the result shape. @@ -8245,6 +10778,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): DirFace1V, DirFace2V, NbTimesV) RaiseIfFailed("MakeMultiTransformation2D", self.BlocksOp) anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "transformed") return anObj ## Build all possible propagation groups. @@ -8252,10 +10786,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # edge of this group directly or through other opposite edges. # Notion of Opposite Edge make sence only on quadrangle face. # @param theShape Shape to build propagation groups on. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return List of GEOM.GEOM_Object, each of them is a propagation group. # # @ref swig_Propagate "Example" - def Propagate(self,theShape): + def Propagate(self, theShape, theName=None): """ Build all possible propagation groups. Propagation group is a set of all edges, opposite to one (main) @@ -8264,6 +10802,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): Parameters: theShape Shape to build propagation groups on. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: List of GEOM.GEOM_Object, each of them is a propagation group. @@ -8271,6 +10812,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestOthers.py listChains = self.BlocksOp.Propagate(theShape) RaiseIfFailed("Propagate", self.BlocksOp) + self._autoPublish(listChains, theName, "propagate") return listChains # end of l3_blocks_op @@ -8282,11 +10824,15 @@ class geompyDC(GEOM._objref_GEOM_Gen): ## 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 (see GEOM::shape_type) - # @return a newly created GEOM group + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # + # @return a newly created GEOM group (GEOM.GEOM_Object) # # @ref tui_working_with_groups_page "Example 1" # \n @ref swig_CreateGroup "Example 2" - def CreateGroup(self,theMainShape, theShapeType): + def CreateGroup(self, theMainShape, theShapeType, theName=None): """ Creates a new group which will store sub-shapes of theMainShape @@ -8294,6 +10840,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theMainShape is a GEOM object on which the group is selected theShapeType defines a shape type of the group:"COMPOUND", "COMPSOLID", "SOLID", "SHELL", "FACE", "WIRE", "EDGE", "VERTEX", "SHAPE". + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: a newly created GEOM group @@ -8305,6 +10854,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestOthers.py anObj = self.GroupOp.CreateGroup(theMainShape, theShapeType) RaiseIfFailed("CreateGroup", self.GroupOp) + self._autoPublish(anObj, theName, "group") return anObj ## Adds a sub-object with ID theSubShapeId to the group @@ -8430,9 +10980,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # which are present in groups theGroup1 and theGroup2. # @param theGroup1, theGroup2 are the initial GEOM groups # to create the united group from. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return a newly created GEOM group. + # # @ref tui_union_groups_anchor "Example" - def UnionGroups (self, theGroup1, theGroup2): + def UnionGroups (self, theGroup1, theGroup2, theName=None): """ Union of two groups. New group is created. It will contain all entities @@ -8441,6 +10996,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): Parameters: theGroup1, theGroup2 are the initial GEOM groups to create the united group from. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: a newly created GEOM group. @@ -8448,15 +11006,21 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestOthers.py aGroup = self.GroupOp.UnionGroups(theGroup1, theGroup2) RaiseIfFailed("UnionGroups", self.GroupOp) + self._autoPublish(aGroup, theName, "group") return aGroup ## Intersection of two groups. # New group is created. It will contain only those entities # which are present in both groups theGroup1 and theGroup2. # @param theGroup1, theGroup2 are the initial GEOM groups to get common part of. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return a newly created GEOM group. + # # @ref tui_intersect_groups_anchor "Example" - def IntersectGroups (self, theGroup1, theGroup2): + def IntersectGroups (self, theGroup1, theGroup2, theName=None): """ Intersection of two groups. New group is created. It will contain only those entities @@ -8464,6 +11028,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): Parameters: theGroup1, theGroup2 are the initial GEOM groups to get common part of. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: a newly created GEOM group. @@ -8471,6 +11038,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestOthers.py aGroup = self.GroupOp.IntersectGroups(theGroup1, theGroup2) RaiseIfFailed("IntersectGroups", self.GroupOp) + self._autoPublish(aGroup, theName, "group") return aGroup ## Cut of two groups. @@ -8478,9 +11046,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # present in group theGroup1 but are not present in group theGroup2. # @param theGroup1 is a GEOM group to include elements of. # @param theGroup2 is a GEOM group to exclude elements of. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return a newly created GEOM group. + # # @ref tui_cut_groups_anchor "Example" - def CutGroups (self, theGroup1, theGroup2): + def CutGroups (self, theGroup1, theGroup2, theName=None): """ Cut of two groups. New group is created. It will contain entities which are @@ -8489,6 +11062,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): Parameters: theGroup1 is a GEOM group to include elements of. theGroup2 is a GEOM group to exclude elements of. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: a newly created GEOM group. @@ -8496,15 +11072,21 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestOthers.py aGroup = self.GroupOp.CutGroups(theGroup1, theGroup2) RaiseIfFailed("CutGroups", self.GroupOp) + self._autoPublish(aGroup, theName, "group") return aGroup ## Union of list of groups. # New group is created. It will contain all entities that are # present in groups listed in theGList. # @param theGList is a list of GEOM groups to create the united group from. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return a newly created GEOM group. + # # @ref tui_union_groups_anchor "Example" - def UnionListOfGroups (self, theGList): + def UnionListOfGroups (self, theGList, theName=None): """ Union of list of groups. New group is created. It will contain all entities that are @@ -8512,6 +11094,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): Parameters: theGList is a list of GEOM groups to create the united group from. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: a newly created GEOM group. @@ -8519,6 +11104,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestOthers.py aGroup = self.GroupOp.UnionListOfGroups(theGList) RaiseIfFailed("UnionListOfGroups", self.GroupOp) + self._autoPublish(aGroup, theName, "group") return aGroup ## Cut of lists of groups. @@ -8527,9 +11113,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # are not present in groups from theGList2. # @param theGList1 is a list of GEOM groups to include elements of. # @param theGList2 is a list of GEOM groups to exclude elements of. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return a newly created GEOM group. + # # @ref tui_intersect_groups_anchor "Example" - def IntersectListOfGroups (self, theGList): + def IntersectListOfGroups (self, theGList, theName=None): """ Cut of lists of groups. New group is created. It will contain only entities @@ -8539,6 +11130,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): Parameters: theGList1 is a list of GEOM groups to include elements of. theGList2 is a list of GEOM groups to exclude elements of. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: a newly created GEOM group. @@ -8546,6 +11140,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestOthers.py aGroup = self.GroupOp.IntersectListOfGroups(theGList) RaiseIfFailed("IntersectListOfGroups", self.GroupOp) + self._autoPublish(aGroup, theName, "group") return aGroup ## Cut of lists of groups. @@ -8554,9 +11149,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # are not present in groups from theGList2. # @param theGList1 is a list of GEOM groups to include elements of. # @param theGList2 is a list of GEOM groups to exclude elements of. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return a newly created GEOM group. + # # @ref tui_cut_groups_anchor "Example" - def CutListOfGroups (self, theGList1, theGList2): + def CutListOfGroups (self, theGList1, theGList2, theName=None): """ Cut of lists of groups. New group is created. It will contain only entities @@ -8566,6 +11166,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): Parameters: theGList1 is a list of GEOM groups to include elements of. theGList2 is a list of GEOM groups to exclude elements of. + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: a newly created GEOM group. @@ -8573,6 +11176,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestOthers.py aGroup = self.GroupOp.CutListOfGroups(theGList1, theGList2) RaiseIfFailed("CutListOfGroups", self.GroupOp) + self._autoPublish(aGroup, theName, "group") return aGroup ## Returns a list of sub-objects ID stored in the group @@ -8748,9 +11352,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param max_length maximum length of edges of theShape # @param include_max indicating if edges with length == max_length should be included in result, 1-yes, 0-no (default=1) # @param include_min indicating if edges with length == min_length should be included in result, 1-yes, 0-no (default=1) + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return a newly created GEOM group of edges + # # @@ref swig_todo "Example" - def GetEdgesByLength (self, theShape, min_length, max_length, include_min = 1, include_max = 1): + def GetEdgesByLength (self, theShape, min_length, max_length, include_min = 1, include_max = 1, theName=None): """ Create group of edges of theShape, whose length is in range [min_length, max_length]. If include_min/max == 0, edges with length == min/max_length will not be included in result. @@ -8761,6 +11370,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): max_length maximum length of edges of theShape include_max indicating if edges with length == max_length should be included in result, 1-yes, 0-no (default=1) include_min indicating if edges with length == min_length should be included in result, 1-yes, 0-no (default=1) + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: a newly created GEOM group of edges. @@ -8780,9 +11392,10 @@ class geompyDC(GEOM._objref_GEOM_Gen): if len(edges_in_range) <= 0: print "No edges found by given criteria" - return 0 + return None - group_edges = self.CreateGroup(theShape, ShapeType["EDGE"]) + # note: auto-publishing is done in self.CreateGroup() + group_edges = self.CreateGroup(theShape, ShapeType["EDGE"], theName) self.UnionList(group_edges, edges_in_range) return group_edges @@ -8856,10 +11469,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theP1 1st junction point of main pipe # @param theP2 2nd junction point of main pipe # @param theP3 Junction point of incident pipe + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return List of GEOM.GEOM_Object, containing the created shape and propagation groups. # # @ref tui_creation_pipetshape "Example" - def MakePipeTShape(self, theR1, theW1, theL1, theR2, theW2, theL2, theHexMesh=True, theP1=None, theP2=None, theP3=None): + def MakePipeTShape(self, theR1, theW1, theL1, theR2, theW2, theL2, theHexMesh=True, theP1=None, theP2=None, theP3=None, theName=None): """ Create a T-shape object with specified caracteristics for the main and the incident pipes (radius, width, half-length). @@ -8879,6 +11496,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theP1 1st junction point of main pipe theP2 2nd junction point of main pipe theP3 Junction point of incident pipe + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: List of GEOM_Object, containing the created shape and propagation groups. @@ -8896,6 +11516,8 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.AdvOp.MakePipeTShape(theR1, theW1, theL1, theR2, theW2, theL2, theHexMesh) RaiseIfFailed("MakePipeTShape", self.AdvOp) if Parameters: anObj[0].SetParameters(Parameters) + def_names = [ "pipeTShape" ] + [ "pipeTShape_grp_%d" % i for i in range(1, len(anObj)) ] + self._autoPublish(anObj, _toListOfNames(theName, len(anObj)), def_names) return anObj ## Create a T-shape object with chamfer and with specified caracteristics for the main @@ -8917,10 +11539,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theP1 1st junction point of main pipe # @param theP2 2nd junction point of main pipe # @param theP3 Junction point of incident pipe + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return List of GEOM.GEOM_Object, containing the created shape and propagation groups. # # @ref tui_creation_pipetshape "Example" - def MakePipeTShapeChamfer(self, theR1, theW1, theL1, theR2, theW2, theL2, theH, theW, theHexMesh=True, theP1=None, theP2=None, theP3=None): + def MakePipeTShapeChamfer(self, theR1, theW1, theL1, theR2, theW2, theL2, theH, theW, theHexMesh=True, theP1=None, theP2=None, theP3=None, theName=None): """ Create a T-shape object with chamfer and with specified caracteristics for the main and the incident pipes (radius, width, half-length). The chamfer is @@ -8943,6 +11569,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theP1 1st junction point of main pipe theP2 2nd junction point of main pipe theP3 Junction point of incident pipe + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: List of GEOM_Object, containing the created shape and propagation groups. @@ -8960,6 +11589,8 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.AdvOp.MakePipeTShapeChamfer(theR1, theW1, theL1, theR2, theW2, theL2, theH, theW, theHexMesh) RaiseIfFailed("MakePipeTShapeChamfer", self.AdvOp) if Parameters: anObj[0].SetParameters(Parameters) + def_names = [ "pipeTShape" ] + [ "pipeTShape_grp_%d" % i for i in range(1, len(anObj)) ] + self._autoPublish(anObj, _toListOfNames(theName, len(anObj)), def_names) return anObj ## Create a T-shape object with fillet and with specified caracteristics for the main @@ -8980,10 +11611,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theP1 1st junction point of main pipe # @param theP2 2nd junction point of main pipe # @param theP3 Junction point of incident pipe + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return List of GEOM.GEOM_Object, containing the created shape and propagation groups. # # @ref tui_creation_pipetshape "Example" - def MakePipeTShapeFillet(self, theR1, theW1, theL1, theR2, theW2, theL2, theRF, theHexMesh=True, theP1=None, theP2=None, theP3=None): + def MakePipeTShapeFillet(self, theR1, theW1, theL1, theR2, theW2, theL2, theRF, theHexMesh=True, theP1=None, theP2=None, theP3=None, theName=None): """ Create a T-shape object with fillet and with specified caracteristics for the main and the incident pipes (radius, width, half-length). The fillet is @@ -9005,6 +11640,9 @@ class geompyDC(GEOM._objref_GEOM_Gen): theP1 1st junction point of main pipe theP2 2nd junction point of main pipe theP3 Junction point of incident pipe + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: List of GEOM_Object, containing the created shape and propagation groups. @@ -9023,6 +11661,8 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.AdvOp.MakePipeTShapeFillet(theR1, theW1, theL1, theR2, theW2, theL2, theRF, theHexMesh) RaiseIfFailed("MakePipeTShapeFillet", self.AdvOp) if Parameters: anObj[0].SetParameters(Parameters) + def_names = [ "pipeTShape" ] + [ "pipeTShape_grp_%d" % i for i in range(1, len(anObj)) ] + self._autoPublish(anObj, _toListOfNames(theName, len(anObj)), def_names) return anObj ## This function allows creating a disk already divided into blocks. It @@ -9031,14 +11671,35 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theOrientation Orientation of the plane on which the disk will be built # 1 = XOY, 2 = OYZ, 3 = OZX # @param thePattern Division pattern. It can be GEOM.SQUARE or GEOM.HEXAGON + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM_Object, containing the created shape. # # @ref tui_creation_divideddisk "Example" - def MakeDividedDisk(self, theR, theOrientation, thePattern ): + def MakeDividedDisk(self, theR, theOrientation, thePattern, theName=None): + """ + Creates a disk, divided into blocks. It can be used to create divided pipes + for later meshing in hexaedra. + + Parameters: + theR Radius of the disk + theOrientation Orientation of the plane on which the disk will be built: + 1 = XOY, 2 = OYZ, 3 = OZX + thePattern Division pattern. It can be GEOM.SQUARE or GEOM.HEXAGON + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. + + Returns: + New GEOM_Object, containing the created shape. + """ theR, Parameters = ParseParameters(theR) anObj = self.AdvOp.MakeDividedDisk(theR, 67.0, theOrientation, thePattern) RaiseIfFailed("MakeDividedDisk", self.AdvOp) if Parameters: anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "dividedDisk") return anObj ## This function allows creating a disk already divided into blocks. It @@ -9047,28 +11708,68 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @param theVector Normal vector to the plane of the created disk # @param theRadius Radius of the disk # @param thePattern Division pattern. It can be GEOM.SQUARE or GEOM.HEXAGON + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM_Object, containing the created shape. # # @ref tui_creation_divideddisk "Example" - def MakeDividedDiskPntVecR(self, theCenter, theVector, theRadius, thePattern): + def MakeDividedDiskPntVecR(self, theCenter, theVector, theRadius, thePattern, theName=None): + """ + Creates a disk already divided into blocks. It can be used to create divided pipes + for later meshing in hexaedra. + + Parameters: + theCenter Center of the disk + theVector Normal vector to the plane of the created disk + theRadius Radius of the disk + thePattern Division pattern. It can be GEOM.SQUARE or GEOM.HEXAGON + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. + + Returns: + New GEOM_Object, containing the created shape. + """ theRadius, Parameters = ParseParameters(theRadius) anObj = self.AdvOp.MakeDividedDiskPntVecR(theCenter, theVector, theRadius, 67.0, thePattern) RaiseIfFailed("MakeDividedDiskPntVecR", self.AdvOp) if Parameters: anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "dividedDisk") return anObj ## Builds a cylinder prepared for hexa meshes # @param theR Radius of the cylinder # @param theH Height of the cylinder # @param thePattern Division pattern. It can be GEOM.SQUARE or GEOM.HEXAGON + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM_Object, containing the created shape. # # @ref tui_creation_dividedcylinder "Example" - def MakeDividedCylinder(self, theR, theH, thePattern): + def MakeDividedCylinder(self, theR, theH, thePattern, theName=None): + """ + Builds a cylinder prepared for hexa meshes + + Parameters: + theR Radius of the cylinder + theH Height of the cylinder + thePattern Division pattern. It can be GEOM.SQUARE or GEOM.HEXAGON + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. + + Returns: + New GEOM_Object, containing the created shape. + """ theR, theH, Parameters = ParseParameters(theR, theH) anObj = self.AdvOp.MakeDividedCylinder(theR, theH, thePattern) RaiseIfFailed("MakeDividedCylinder", self.AdvOp) if Parameters: anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "dividedCylinder") return anObj #@@ insert new functions before this line @@ do not remove this line @@# @@ -9079,24 +11780,33 @@ class geompyDC(GEOM._objref_GEOM_Gen): ## Create a copy of the given object # # @param theOriginal geometry object for copy - # @return unique object identifier + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # + # @return New GEOM_Object, containing the copied shape. + # # @ingroup l1_geompy_auxiliary # @ref swig_MakeCopy "Example" - def MakeCopy(self,theOriginal): + def MakeCopy(self, theOriginal, theName=None): """ Create a copy of the given object Paremeters: theOriginal geometry object for copy + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. Returns: - unique object identifier + New GEOM_Object, containing the copied shape. Example of usage: Copy = geompy.MakeCopy(Box) """ # Example: see GEOM_TestAll.py anObj = self.InsertOp.MakeCopy(theOriginal) RaiseIfFailed("MakeCopy", self.InsertOp) + self._autoPublish(anObj, theName, "copy") return anObj ## Add Path to load python scripts from diff --git a/src/GEOM_SWIG/gsketcher.py b/src/GEOM_SWIG/gsketcher.py index 11ef9bb6d..a3810ae06 100644 --- a/src/GEOM_SWIG/gsketcher.py +++ b/src/GEOM_SWIG/gsketcher.py @@ -253,11 +253,20 @@ class Sketcher3D: pass ## Obtain the sketcher result. + # @param theName Object name; when specified, this parameter is used + # for result publication in the study. Otherwise, if automatic + # publication is switched on, default value is used for result name. + # # @return New GEOM_Object, containing the created wire - def wire (self): + def wire (self, theName=None): """ Obtain the sketcher result. + Parameters: + theName Object name; when specified, this parameter is used + for result publication in the study. Otherwise, if automatic + publication is switched on, default value is used for result name. + Returns: New GEOM_Object, containing the created wire. @@ -272,4 +281,5 @@ class Sketcher3D: self.myCommand = "3DSketcher" RaiseIfFailed("Sketcher3D", self.geompyD.CurvesOp) wire.SetParameters(Parameters) + self.geompyD._autoPublish(wire, theName, "wire") return wire diff --git a/src/GEOM_SWIG_WITHIHM/Makefile.am b/src/GEOM_SWIG_WITHIHM/Makefile.am index 59166af81..710d23be6 100644 --- a/src/GEOM_SWIG_WITHIHM/Makefile.am +++ b/src/GEOM_SWIG_WITHIHM/Makefile.am @@ -66,12 +66,14 @@ _libGEOM_Swig_la_CPPFLAGS = \ -I$(srcdir)/../OBJECT \ -I$(srcdir)/../GEOMGUI \ -I$(srcdir)/../GEOMToolsGUI \ + -I$(srcdir)/../Material \ -I$(top_builddir)/idl _libGEOM_Swig_la_LDFLAGS = -module _libGEOM_Swig_la_LIBADD = \ ../GEOMGUI/libGEOM.la \ ../GEOMToolsGUI/libGEOMToolsGUI.la \ + ../Material/libMaterial.la \ $(PYTHON_LIBS) swig_wrap.cpp : $(SWIG_SOURCES) diff --git a/src/GEOM_SWIG_WITHIHM/libGEOM_Swig.cxx b/src/GEOM_SWIG_WITHIHM/libGEOM_Swig.cxx index 616fd5097..80623324f 100644 --- a/src/GEOM_SWIG_WITHIHM/libGEOM_Swig.cxx +++ b/src/GEOM_SWIG_WITHIHM/libGEOM_Swig.cxx @@ -19,705 +19,474 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // - -// GEOM GEOMGUI : GUI for Geometry component // File : libGEOM_Swig.cxx // Author : Nicolas REJNERI, Paul RASCLE -// + #include "libGEOM_Swig.h" #include "GeometryGUI.h" -#include "GEOMToolsGUI.h" - -#include "SUIT_Desktop.h" -#include "SUIT_Session.h" -#include "SalomeApp_Application.h" -#include "SalomeApp_Study.h" - -#include "OB_Browser.h" - -#include "OCCViewer_ViewWindow.h" -#include "OCCViewer_ViewManager.h" -#include "SOCC_ViewModel.h" -#include - -#include "SVTK_ViewModel.h" -#include "SVTK_ViewWindow.h" -#include "SVTK_View.h" -#include "SVTK_Renderer.h" -#include - -#include "GEOM_Actor.h" -#include "GEOM_Client.hxx" -#include "GEOM_AISShape.hxx" -#include "GEOM_InteractiveObject.hxx" #include "GEOM_Displayer.h" #include "GEOM_Constants.h" +#include "Material_Model.h" -#include "SALOME_Event.h" +#include +#include +#include +#include +#include +#include +#include +#include -// OCCT Includes -#include -#include -#include -#include -#include -#include -#include +#include // IDL Headers #include #include CORBA_SERVER_HEADER(GEOM_Gen) -#include - -static SHAPE_READER(ShapeReader); - -inline OCCViewer_Viewer* GetOCCViewer(SUIT_Application* theApp){ - SUIT_ViewWindow* window = theApp->desktop()->activeWindow(); - if(window && window->getViewManager()->getType() == OCCViewer_Viewer::Type()){ - OCCViewer_ViewWindow* vw = dynamic_cast( window ); - if ( vw ) { - OCCViewer_ViewManager* vm = dynamic_cast( vw->getViewManager() ); - if ( vm ) - return vm->getOCCViewer(); - } - } - - return 0; -} - -inline SVTK_ViewWindow* GetSVTKViewWindow(SUIT_Application* theApp){ - SUIT_ViewWindow* window = theApp->desktop()->activeWindow(); - if(window && window->getViewManager()->getType() == SVTK_Viewer::Type()) - return dynamic_cast( window ); - - return 0; -} - +/*! + \brief Constructor +*/ GEOM_Swig::GEOM_Swig() { - // MESSAGE("Constructeur"); + init(); } +/*! + \brief Destructor +*/ GEOM_Swig::~GEOM_Swig() { - // MESSAGE("Destructeur"); } -void GEOM_Swig::createAndDisplayGO (const char* Entry, bool isUpdated) +/*! + \brief Internal initialization +*/ +void GEOM_Swig::init() { class TEvent: public SALOME_Event { - std::string myEntry; - bool myUpdateViewer; public: - TEvent(const char* theEntry, bool toUpdateViewer): - myEntry(theEntry), - myUpdateViewer(toUpdateViewer) + TEvent() {} virtual void Execute() { + // check active study SUIT_Application* app = SUIT_Session::session()->activeApplication(); if (!app) return; + + SalomeApp_Study* study = dynamic_cast( app->activeStudy() ); + if ( !study ) return; - SalomeApp_Study* ActiveStudy = dynamic_cast(app->activeStudy()); - if (!ActiveStudy) return; - - _PTR(Study) aStudy(ActiveStudy->studyDS()); - _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder(); + _PTR(Study) studyDS( study->studyDS() ); + _PTR(StudyBuilder) builder = studyDS->NewBuilder(); - GEOM::GEOM_Gen_var Geom = GeometryGUI::GetGeomGen(); - if (CORBA::is_nil(Geom)) { - GeometryGUI::InitGeomGen(); - Geom = GeometryGUI::GetGeomGen(); - } - if (CORBA::is_nil(Geom)) + // get/init GEOM engine + GEOM::GEOM_Gen_var engine = GeometryGUI::GetGeomGen(); + if ( CORBA::is_nil( engine ) ) return; - std::string aFatherIOR; - _PTR(SComponent) father = aStudy->FindComponent("GEOM"); - if (!father) - return; - if (!father->ComponentIOR(aFatherIOR)) { - CORBA::String_var objStr = SalomeApp_Application::orb()->object_to_string(Geom); - aStudyBuilder->LoadWith(father, objStr.in()); - father->ComponentIOR(aFatherIOR); - } - - _PTR(SObject) obj = aStudy->FindObjectID(myEntry); - if (!obj) + // find GEOM component in the study + _PTR(SComponent) component = studyDS->FindComponent( "GEOM" ); + if ( !component ) return; - // Create new actor - _PTR(GenericAttribute) anAttr; - if (!obj->FindAttribute(anAttr, "AttributeIOR")) - return; - _PTR(AttributeIOR) anIOR(anAttr); - std::string anIORValue = anIOR->Value(); - - GEOM::GEOM_Object_var aShape = Geom->GetIORFromString(anIORValue.c_str()); - TopoDS_Shape Shape = ShapeReader.GetShape(Geom,aShape); - if (!Shape.IsNull()) { - if (obj->FindAttribute(anAttr, "AttributeName")) { - _PTR(AttributeName) aName (anAttr); - std::string aNameValue = aName->Value(); - // open transaction - /*SUIT_Operation* op = new SalomeApp_ImportOperation (app); - op->start(); - - _PTR(SObject) newObj1 = aStudyBuilder->NewObject(father); - aStudyBuilder->Addreference(newObj1, obj); - // commit transaction - op->commit();*/ - Handle(GEOM_InteractiveObject) anIO = - new GEOM_InteractiveObject (const_cast(anIORValue.c_str()), - const_cast(aFatherIOR.c_str()), - "GEOM", - const_cast( obj->GetID().c_str())); - - GEOM_Displayer(ActiveStudy).Display(anIO, myUpdateViewer); - /*if (SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(app)) { - SVTK_View* aView = aViewWindow->getView(); - int aMode = aView->GetDisplayMode(); - - vtkActorCollection* theActors = - GEOM_AssemblyBuilder::BuildActors(Shape,0,aMode,true); - theActors->InitTraversal(); - while (vtkActor* anActor = theActors->GetNextActor()) { - GEOM_Actor* GActor = GEOM_Actor::SafeDownCast(anActor); - GActor->setName(const_cast(aNameValue.c_str())); - GActor->setIO(anIO); - aView->Display(GActor); - } - aView->Repaint(); - } else if (OCCViewer_Viewer* occViewer = GetOCCViewer(app)) { - Handle(AIS_InteractiveContext) ic = occViewer->getAISContext(); - Handle(GEOM_AISShape) aSh = - new GEOM_AISShape (Shape,const_cast(aNameValue.c_str())); - aSh->setName(const_cast(aNameValue.c_str())); - aSh->setIO(anIO); - ic->Display(aSh); - ic->AddOrRemoveCurrentObject(aSh,true); - }*/ - // update object browser - SalomeApp_Application* app = NULL; //dynamic_cast(app); - if (app) { - CAM_Module* module = app->module("Geometry"); - SalomeApp_Module* appMod = dynamic_cast(module); - if (appMod) - appMod->updateObjBrowser(true); - } - } + // load GEOM data (if it is not done yet) + std::string ior; + if ( !component->ComponentIOR( ior ) ) { + CORBA::String_var engineIOR = SalomeApp_Application::orb()->object_to_string( engine ); + builder->LoadWith( component, engineIOR.in() ); } + + // update Object browser + if ( dynamic_cast( app ) ) + dynamic_cast( app )->updateObjectBrowser( true ); } }; - // MESSAGE("createAndDisplayGO"); - ProcessVoidEvent(new TEvent (Entry, isUpdated)); + ProcessVoidEvent( new TEvent() ); +} - class TEventUpdateBrowser: public SALOME_Event +/*! + \brief Display the presenation in the currently active view + \param theEntry geometry object's entry + \param theUpdateViewer \c true to update active view's contents +*/ +void GEOM_Swig::createAndDisplayGO( const char* theEntry, bool theUpdateViewer ) +{ + class TEvent: public SALOME_Event + { + std::string myEntry; + bool myUpdateViewer; + public: + TEvent( const char* _entry, bool _update ): + myEntry( _entry ), myUpdateViewer( _update ) + {} + virtual void Execute() { - public: - TEventUpdateBrowser() {} - virtual void Execute() { - SalomeApp_Application* app = - dynamic_cast(SUIT_Session::session()->activeApplication()); - if (app) { - CAM_Module* module = app->module("Geometry"); - SalomeApp_Module* appMod = dynamic_cast(module); - if (appMod) appMod->updateObjBrowser(true); - } - } - }; - - if (isUpdated) - ProcessVoidEvent(new TEventUpdateBrowser ()); + SUIT_Application* app = SUIT_Session::session()->activeApplication(); + if ( !app ) return; + SalomeApp_Study* study = dynamic_cast( app->activeStudy() ); + if ( !study ) return; + + Handle(SALOME_InteractiveObject) io = new SALOME_InteractiveObject( myEntry.c_str(), "GEOM", "" ); + + GEOM_Displayer( study ).Display( io, myUpdateViewer ); + } + }; + + ProcessVoidEvent( new TEvent( theEntry, theUpdateViewer ) ); } -void GEOM_Swig::createAndDisplayFitAllGO (const char* Entry) +/*! + \brief Same as createAndDisplayGO, but also fits the active view to the contents + \param theEntry geometry object's entry + \param theUpdateViewer \c true to update active view's contents +*/ +void GEOM_Swig::createAndDisplayFitAllGO( const char* theEntry ) { + // display object + createAndDisplayGO( theEntry ); + + // fit all the view class TEventFitAll: public SALOME_Event { - public: - TEventFitAll() {} - virtual void Execute() { - SUIT_Application* app = SUIT_Session::session()->activeApplication(); - if (!app) return; - - if (SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(app)) - { - SVTK_View* aView = aViewWindow->getView(); - aView->GetRenderer()->OnFitAll(); - } - else if (OCCViewer_Viewer* occViewer = GetOCCViewer(app)) - { - Handle(V3d_Viewer) aViewer3d = occViewer->getViewer3d(); - aViewer3d->InitActiveViews(); - - if (aViewer3d->MoreActiveViews()) - aViewer3d->ActiveView()->FitAll(); - } + public: + TEventFitAll() {} + virtual void Execute() + { + SUIT_Application* app = SUIT_Session::session()->activeApplication(); + if ( app ) { + SUIT_ViewWindow* window = app->desktop()->activeWindow(); + if ( dynamic_cast( window ) ) + dynamic_cast( window )->onFitAll(); + else if ( dynamic_cast( window ) ) + dynamic_cast( window )->onViewFitAll(); } + } + }; + + ProcessVoidEvent( new TEventFitAll() ); +} + +/*! + \brief Erase presentation in the currently active viewer + \param theEntry geometry object's entry + \param theUpdateViewer \c true to update active view's contents +*/ +void GEOM_Swig::eraseGO( const char* theEntry, bool theUpdateViewer ) +{ + class TEvent: public SALOME_Event + { + std::string myEntry; + bool myUpdateViewer; + public: + TEvent( const char* _entry, bool _update ): + myEntry( _entry ), myUpdateViewer( _update ) + {} + virtual void Execute() + { + SUIT_Application* app = SUIT_Session::session()->activeApplication(); + if ( !app ) return; + SalomeApp_Study* study = dynamic_cast( app->activeStudy() ); + if ( !study ) return; + + Handle(SALOME_InteractiveObject) io = new SALOME_InteractiveObject( myEntry.c_str(), "GEOM", "" ); + + GEOM_Displayer( study ).Erase( io, true, myUpdateViewer ); + } }; - createAndDisplayGO(Entry); - ProcessVoidEvent(new TEventFitAll()); + ProcessVoidEvent( new TEvent( theEntry, theUpdateViewer ) ); } +/*! + \brief Update active viewer contents +*/ void GEOM_Swig::UpdateViewer() { class TEventUpdateViewer: public SALOME_Event { - public: - TEventUpdateViewer() {} - virtual void Execute() { - SUIT_Application* app = SUIT_Session::session()->activeApplication(); - if (!app) return; - SalomeApp_Study* ActiveStudy = dynamic_cast(app->activeStudy()); - if (!ActiveStudy) return; - - GEOM_Displayer(ActiveStudy).UpdateViewer(); - } + public: + TEventUpdateViewer() + {} + virtual void Execute() + { + SUIT_Application* app = SUIT_Session::session()->activeApplication(); + if ( !app ) return; + + SalomeApp_Study* study = dynamic_cast( app->activeStudy() ); + if ( !study ) return; + + GEOM_Displayer( study ).UpdateViewer(); + } }; ProcessVoidEvent(new TEventUpdateViewer()); } -int GEOM_Swig::getIndexTopology(const char* SubIOR, const char* IOR) +/*! + \brief Get sub-shape index inside main shape + \param theSubIOR sub-shape geometry object's IOR + \param theMainIOR main shape geometry object's IOR + \return sub-shape index (-1 in case of error) +*/ +int GEOM_Swig::getIndexTopology( const char* theSubIOR, const char* theMainIOR ) { - GEOM::GEOM_Gen_var aGeomGen = GeometryGUI::GetGeomGen(); - if (CORBA::is_nil(aGeomGen)) - return -1; + int index = -1; - GEOM::GEOM_Object_var aMainShape = aGeomGen->GetIORFromString(IOR); - GEOM::GEOM_Object_var aSubShape = aGeomGen->GetIORFromString(SubIOR); - if (CORBA::is_nil(aMainShape) || CORBA::is_nil(aSubShape)) - return -1; + // get geom engine + GEOM::GEOM_Gen_var aGeomGen = GeometryGUI::GetGeomGen(); - GEOM::GEOM_IShapesOperations_var anIShapesOperations = - aGeomGen->GetIShapesOperations(aMainShape->GetStudyID()); - if (CORBA::is_nil(anIShapesOperations)) - return -1; + // get main shape's geom object by IOR + CORBA::Object_var anObject = SalomeApp_Application::orb()->string_to_object( theMainIOR ); + GEOM::GEOM_Object_var aMainShape = GEOM::GEOM_Object::_narrow( anObject.in() ); + // get sub-shape's geom object by IOR + anObject = SalomeApp_Application::orb()->string_to_object( theSubIOR ); + GEOM::GEOM_Object_var aSubShape = GEOM::GEOM_Object::_narrow( anObject.in() ); + + if ( !CORBA::is_nil( aGeomGen ) && !CORBA::is_nil( aMainShape ) && !CORBA::is_nil( aSubShape ) ) { + // get shapes operations interface + GEOM::GEOM_IShapesOperations_var anIShapesOperations = + aGeomGen->GetIShapesOperations( aMainShape->GetStudyID() ); + if ( !CORBA::is_nil( anIShapesOperations ) ) + index = anIShapesOperations->GetTopologyIndex( aMainShape, aSubShape ); + } - return anIShapesOperations->GetTopologyIndex(aMainShape, aSubShape); + return index; } -const char* GEOM_Swig::getShapeTypeString(const char* IOR) +/*! + \brief Get shape type name + \param theIOR geometry object's IOR + \return shape type name ("Shape of unknown type" in case of error) +*/ +const char* GEOM_Swig::getShapeTypeString( const char* theIOR ) { - TCollection_AsciiString aTypeName ("Shape of unknown type"); + QString aTypeName = "Shape of unknown type"; + // get geom engine GEOM::GEOM_Gen_var aGeomGen = GeometryGUI::GetGeomGen(); - if (!CORBA::is_nil(aGeomGen)) - { - GEOM::GEOM_Object_var aShape = aGeomGen->GetIORFromString(IOR); - if (!CORBA::is_nil(aShape)) - { - GEOM::GEOM_IShapesOperations_var anIShapesOperations = - aGeomGen->GetIShapesOperations(aShape->GetStudyID()); - if (!CORBA::is_nil(anIShapesOperations)) - { - aTypeName = anIShapesOperations->GetShapeTypeString(aShape); - } - } + + // get shape's geom object by IOR + CORBA::Object_var anObject = SalomeApp_Application::orb()->string_to_object( theIOR ); + GEOM::GEOM_Object_var aShape = GEOM::GEOM_Object::_narrow( anObject.in() ); + + if ( !CORBA::is_nil( aGeomGen ) && !CORBA::is_nil( aShape ) ) { + // get shapes operations interface + GEOM::GEOM_IShapesOperations_var anIShapesOperations = + aGeomGen->GetIShapesOperations( aShape->GetStudyID() ); + if ( !CORBA::is_nil( anIShapesOperations ) ) + aTypeName = anIShapesOperations->GetShapeTypeString( aShape ); } - return CORBA::string_dup(aTypeName.ToCString()); + return strdup( qPrintable( aTypeName ) ); } - -const char* GEOM_Swig::getShapeTypeIcon(const char* IOR) +/*! + \brief Get shape's icon ID (specified by its type) + \param theIOR geometry object's IOR + \return icon ID ("None" in case of error) +*/ +const char* GEOM_Swig::getShapeTypeIcon( const char* theIOR ) { - GEOM::GEOM_Gen_var Geom = GeometryGUI::GetGeomGen(); - if ( CORBA::is_nil( Geom ) ) - return "None"; + static const char* icons[] = { + "ICON_OBJBROWSER_COMPOUND", + "ICON_OBJBROWSER_COMPSOLID", + "ICON_OBJBROWSER_SOLID", + "ICON_OBJBROWSER_SHELL", + "ICON_OBJBROWSER_FACE", + "ICON_OBJBROWSER_WIRE", + "ICON_OBJBROWSER_EDGE", + "ICON_OBJBROWSER_VERTEX" + }; - GEOM::GEOM_Object_var aShape = Geom->GetIORFromString(IOR); - TopoDS_Shape shape = ShapeReader.GetShape(Geom, aShape); + const char* anIcon = "None"; - if( shape.IsNull() ) { - return "None" ; + try { + CORBA::Object_var anObject = SalomeApp_Application::orb()->string_to_object( theIOR ); + if ( !CORBA::is_nil( anObject ) ) { + GEOM::GEOM_Object_var aShape = GEOM::GEOM_Object::_narrow( anObject.in() ); + if ( !CORBA::is_nil( aShape ) ) { + GEOM::shape_type aType = aShape->GetShapeType(); + if ( aType >= GEOM::COMPOUND && aType < GEOM::SHAPE ) + anIcon = icons[ (int)aType ]; + } + } + } + catch ( CORBA::Exception& ) { } - switch (shape.ShapeType() ) - { - case TopAbs_COMPOUND: - { return "ICON_OBJBROWSER_COMPOUND" ;} - case TopAbs_COMPSOLID: - { return "ICON_OBJBROWSER_COMPSOLID" ;} - case TopAbs_SOLID: - { return "ICON_OBJBROWSER_SOLID" ;} - case TopAbs_SHELL: - { return "ICON_OBJBROWSER_SHELL" ;} - case TopAbs_FACE: - { return "ICON_OBJBROWSER_FACE" ;} - case TopAbs_WIRE: - { return "ICON_OBJBROWSER_WIRE" ;} - case TopAbs_EDGE: - { return "ICON_OBJBROWSER_EDGE" ;} - case TopAbs_VERTEX: - { return "ICON_OBJBROWSER_VERTEX" ;} - } + return anIcon; +} - return "None"; +class TSetPropertyEvent: public SALOME_Event +{ + QString myEntry; + QString myProperty; + QVariant myValue; + bool myUpdateViewer; + +public: + TSetPropertyEvent( const QString& _entry, + const QString& _property, + const QVariant& _value, + bool _update = true ); + virtual void Execute(); +}; + +TSetPropertyEvent::TSetPropertyEvent( const QString& _entry, + const QString& _property, + const QVariant& _value, + bool _update ): + myEntry( _entry ), + myProperty( _property ), + myValue( _value ), + myUpdateViewer( _update ) +{ } -void GEOM_Swig::setDisplayMode(const char* theEntry, int theMode, bool isUpdated) +void TSetPropertyEvent::Execute() { - class TEvent: public SALOME_Event { - std::string myEntry; - int myMode; - bool myUpdateViewer; - public: - TEvent(const char* theEntryArg, int theModeArg, bool theUpdated): - myEntry(theEntryArg), myMode(theModeArg), myUpdateViewer(theUpdated) - {} - virtual void Execute() { - SUIT_Application* anApp = SUIT_Session::session()->activeApplication(); - if (!anApp) return; - - Handle(SALOME_InteractiveObject) anIO = - new SALOME_InteractiveObject(myEntry.c_str(), "GEOM", ""); - - if (SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(anApp)) { - SVTK_View* aView = aViewWindow->getView(); - aView->SetDisplayMode(anIO, myMode); - if (myUpdateViewer) - aView->Repaint(); - } - else if (OCCViewer_Viewer* occViewer = GetOCCViewer(anApp)) { - SOCC_Viewer* soccViewer = dynamic_cast(occViewer); - if (soccViewer) - soccViewer->switchRepresentation(anIO, myMode, myUpdateViewer); - } - } - }; + SUIT_Application* app = SUIT_Session::session()->activeApplication(); + if ( !app ) return; + + SalomeApp_Study* study = dynamic_cast( app->activeStudy() ); + if ( !study ) return; + + GEOM_Displayer displayer( study ); + + SALOME_View* window = displayer.GetActiveView(); + if ( !window ) return; + + int mgrId = dynamic_cast( window )->getViewManager()->getGlobalId(); - ProcessVoidEvent(new TEvent (theEntry, theMode, isUpdated)); + study->setObjectProperty( mgrId, myEntry, myProperty, myValue ); + + Handle(SALOME_InteractiveObject) io = new SALOME_InteractiveObject( myEntry.toLatin1().data(), "GEOM" ); + if ( window->isVisible( io ) ) displayer.Redisplay( io, myUpdateViewer ); } -void GEOM_Swig::setVectorsMode(const char* theEntry, bool isOn, bool isUpdated) +/*! + \brief Set display mode to the presentation + \param theEntry geometry object's entry + \param theMode display mode: 0 - wireframe, 1 - shading, 2 - shading+edges, 3-textured + \param theUpdateViewer \c true to update active view's contents +*/ +void GEOM_Swig::setDisplayMode( const char* theEntry, int theMode, bool theUpdateViewer ) { - class TEvent: public SALOME_Event { - std::string myEntry; - bool myOn; - bool myUpdateViewer; - public: - TEvent(const char* theEntryArg, bool theOn, bool theUpdated): - myEntry(theEntryArg), myOn(theOn), myUpdateViewer(theUpdated) - {} - virtual void Execute() { - SUIT_Application* anApp = SUIT_Session::session()->activeApplication(); - if (!anApp) return; - - Handle(SALOME_InteractiveObject) anIO = - new SALOME_InteractiveObject(myEntry.c_str(), "GEOM", ""); - - if (SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(anApp)) { - SVTK_View* aView = aViewWindow->getView(); - SVTK_Viewer* stvkViewer = dynamic_cast(aViewWindow->getViewManager()->getViewModel()); - SVTK_Prs* vtkPrs = dynamic_cast( stvkViewer->CreatePrs( myEntry.c_str() ) ); - vtkActorCollection* anActors = vtkPrs->GetObjects(); - anActors->InitTraversal(); - while (vtkActor* anAct = anActors->GetNextActor()) { - GEOM_Actor* aGeomActor = GEOM_Actor::SafeDownCast(anAct); - aGeomActor->SetVectorMode(!aGeomActor->GetVectorMode()); - } - if (myUpdateViewer) - aView->Repaint(); - } - else if (OCCViewer_Viewer* occViewer = GetOCCViewer(anApp)) { - Handle(AIS_InteractiveContext) ic = occViewer->getAISContext(); - SOCC_Viewer* soccViewer = dynamic_cast(occViewer); - if (soccViewer) { - SOCC_Prs* occPrs = dynamic_cast( soccViewer->CreatePrs( myEntry.c_str() ) ); - if ( occPrs && !occPrs->IsNull() ) { - AIS_ListOfInteractive shapes; occPrs->GetObjects( shapes ); - AIS_ListIteratorOfListOfInteractive interIter( shapes ); - for ( ; interIter.More(); interIter.Next() ) { - Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast( interIter.Value() ); - aSh->SetDisplayVectors(myOn); - ic->RecomputePrsOnly(interIter.Value()); - } - } - } - } - } - }; + ProcessVoidEvent( new TSetPropertyEvent( theEntry, GEOM::propertyName( GEOM::DisplayMode ), + theMode, theUpdateViewer ) ); +} - ProcessVoidEvent(new TEvent (theEntry, isOn, isUpdated)); +/*! + \brief Show / hide edges direction vectors for the presentation + \param theEntry geometry object's entry + \param theOn \c true to show edges direction vectors or \c false otherwise + \param theUpdateViewer \c true to update active view's contents +*/ +void GEOM_Swig::setVectorsMode( const char* theEntry, bool theOn, bool theUpdateViewer ) +{ + ProcessVoidEvent( new TSetPropertyEvent( theEntry, GEOM::propertyName( GEOM::EdgesDirection ), + theOn, theUpdateViewer ) ); } -void GEOM_Swig::setColor(const char* theEntry, int red, int green, int blue, bool isUpdated) +/*! + \brief Change color of the presentation + \param theEntry geometry object's entry + \param theRed red component of the component (0-255) + \param theGreen green component of the component (0-255) + \param theBlue blue component of the component (0-255) + \param theUpdateViewer \c true to update active view's contents +*/ +void GEOM_Swig::setColor( const char* theEntry, int theRed, int theGreen, int theBlue, bool theUpdateViewer ) { - class TEvent: public SALOME_Event { - QString myEntry; - int myRed; - int myGreen; - int myBlue; - bool myUpdateViewer; - public: - TEvent(const char* theEntryArg, int theR, int theG, int theB, bool theUpdated): - myEntry(theEntryArg), myRed(theR), myGreen(theG), myBlue(theB), myUpdateViewer(theUpdated) - {} - virtual void Execute() { - SUIT_Application* anApp = SUIT_Session::session()->activeApplication(); - if (!anApp) return; - GEOMToolsGUI::SetColor( myEntry, QColor( myRed, myGreen, myBlue), myUpdateViewer ); - } - }; - ProcessVoidEvent(new TEvent(theEntry, red, green, blue, isUpdated)); + ProcessVoidEvent( new TSetPropertyEvent( theEntry, GEOM::propertyName( GEOM::Color ), + QColor( theRed, theGreen, theBlue ), theUpdateViewer ) ); } -void GEOM_Swig::setIsos(const char* Entry, int nbU, int nbV, bool isUpdated ) +/*! + \brief Set number of iso-lines to the presentation + \param theEntry geometry object's entry + \param theNbU number of iso-lines along U axis (interger value >= 0) + \param theNbV number of iso-lines along V axis (interger value >= 0) + \param theUpdateViewer \c true to update active view's contents +*/ +void GEOM_Swig::setIsos( const char* theEntry, int theNbU, int theNbV, bool theUpdateViewer ) { - class TEvent: public SALOME_Event { - std::string myEntry; - int myNbU, myNbV; - bool myUpdateViewer; - public: - TEvent(const char* theEntry, int theNbU, int theNbV, bool theUpdated): - myEntry(theEntry), myNbU(theNbU), myNbV(theNbV), myUpdateViewer(theUpdated) - {} - virtual void Execute() { - SUIT_Application* app = SUIT_Session::session()->activeApplication(); - if (!app) return; - SalomeApp_Study* study = dynamic_cast(app->activeStudy()); - if (!study) return; - - Handle(SALOME_InteractiveObject) anIO = - new SALOME_InteractiveObject(myEntry.c_str(), "GEOM", ""); - - if (SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(app)) { - SVTK_Viewer* aView = dynamic_cast(aViewWindow->getViewManager()->getViewModel()); - SVTK_Prs* vtkPrs = dynamic_cast( aView->CreatePrs( myEntry.c_str() ) ); - if ( vtkPrs ) { - vtkActorCollection* anActors = vtkPrs->GetObjects(); - anActors->InitTraversal(); - GEOM_Actor* anActor = GEOM_Actor::SafeDownCast( anActors->GetNextActor() ); - if ( anActor ) { - int aIsos[2]={myNbU,myNbV}; - anActor->SetNbIsos(aIsos); - anActor->StoreIsoNumbers(); - QString anIsos = QString("%1%2%3").arg(myNbU).arg(DIGIT_SEPARATOR).arg(myNbV); - int aMgrId = aView->getViewManager()->getGlobalId(); - study->setObjectProperty(aMgrId, myEntry.c_str(), ISOS_PROP, anIsos); - } - } - - if (myUpdateViewer) - aView->Repaint(); - } - else if (OCCViewer_Viewer* occViewer = GetOCCViewer(app)) { - Handle(AIS_InteractiveContext) ic = occViewer->getAISContext(); - SOCC_Viewer* soccViewer = dynamic_cast(occViewer); - if (soccViewer) { - int aMgrId = soccViewer->getViewManager()->getGlobalId(); - SOCC_Prs* occPrs = dynamic_cast( soccViewer->CreatePrs( myEntry.c_str() ) ); - if ( occPrs && !occPrs->IsNull() ) { - AIS_ListOfInteractive shapes; occPrs->GetObjects( shapes ); - AIS_ListIteratorOfListOfInteractive interIter( shapes ); - for ( ; interIter.More(); interIter.Next() ) { - Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast( interIter.Value() ); - if ( !aSh.IsNull() ) { - Handle(AIS_Drawer) drawer = aSh->Attributes(); - QVariant v = study->getObjectProperty( aMgrId, myEntry.c_str(), EDGE_WIDTH_PROP, QVariant() ); - int width = v.isValid() ? v.toInt() : 1; - drawer->SetUIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, width, myNbU) ); - drawer->SetVIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, width, myNbV) ); - aSh->storeIsoNumbers(); - ic->SetLocalAttributes(aSh, drawer); - ic->Redisplay(aSh); - QString anIsos = QString("%1%2%3").arg(myNbU).arg(DIGIT_SEPARATOR).arg(myNbV); - study->setObjectProperty(aMgrId, myEntry.c_str(), ISOS_PROP, anIsos); - } - } - } - } - } - } - }; + ProcessVoidEvent( new TSetPropertyEvent( theEntry, GEOM::propertyName( GEOM::NbIsos ), + QString( "%1%2%3" ).arg( theNbU ).arg( GEOM::subSectionSeparator() ).arg( theNbV ), + theUpdateViewer ) ); +} - ProcessVoidEvent(new TEvent (Entry, nbU, nbV, isUpdated)); +/*! + \brief Set transparency of the presentation + \param theEntry geometry object's entry + \param theTransparency transparency (floating point value between 0 and 1) + \param theUpdateViewer \c true to update active view's contents +*/ +void GEOM_Swig::setTransparency( const char* theEntry, float theTransparency, bool theUpdateViewer ) +{ + ProcessVoidEvent( new TSetPropertyEvent( theEntry, GEOM::propertyName( GEOM::Transparency ), + theTransparency, theUpdateViewer ) ); } -void GEOM_Swig::setTransparency(const char* theEntry, float transp, bool isUpdated) +/*! + \brief Set deflection coefficient of the presentation + \param theEntry geometry object's entry + \param theDeflection deflection coefficient (floating point value) + \param theUpdateViewer \c true to update active view's contents +*/ +void GEOM_Swig::setDeflection( const char* theEntry, float theDeflection, bool theUpdateViewer ) { - class TEvent: public SALOME_Event { - std::string myEntry; - float myParam; - bool myUpdateViewer; - public: - TEvent(const char* theEntryArg, float theParam, bool theUpdated): - myEntry(theEntryArg), myParam(theParam), myUpdateViewer(theUpdated) - {} - virtual void Execute() { - SUIT_Application* anApp = SUIT_Session::session()->activeApplication(); - if (!anApp) return; - - Handle(SALOME_InteractiveObject) anIO = - new SALOME_InteractiveObject(myEntry.c_str(), "GEOM", ""); - - if (SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(anApp)) { - SVTK_View* aView = aViewWindow->getView(); - aView->SetTransparency(anIO, myParam); - if (myUpdateViewer) - aView->Repaint(); - } else if (OCCViewer_Viewer* occViewer = GetOCCViewer(anApp)) { - SOCC_Viewer* soccViewer = dynamic_cast(occViewer); - if (soccViewer) - soccViewer->setTransparency(anIO, myParam, myUpdateViewer); - } - } - }; + ProcessVoidEvent( new TSetPropertyEvent( theEntry, GEOM::propertyName( GEOM::Deflection ), + theDeflection, theUpdateViewer ) ); +} - ProcessVoidEvent(new TEvent (theEntry, transp, isUpdated)); +/*! + \brief Set material to the presentation + \param theEntry geometry object's entry + \param theMaterial material name (string) + \param theUpdateViewer \c true to update active view's contents +*/ +void GEOM_Swig::setMaterial( const char* theEntry, const char* theMaterial, bool theUpdateViewer ) +{ + Material_Model material; + material.fromResources( theMaterial ); + ProcessVoidEvent( new TSetPropertyEvent( theEntry, GEOM::propertyName( GEOM::Material ), + material.toProperties(), theUpdateViewer ) ); } +/*! + \brief Set material property to the presentation + \param theEntry geometry object's entry + \param theMaterial material property string + \param theUpdateViewer \c true to update active view's contents +*/ +void GEOM_Swig::setMaterialProperty( const char* theEntry, const char* theMaterial, bool theUpdateViewer ) +{ + ProcessVoidEvent( new TSetPropertyEvent( theEntry, GEOM::propertyName( GEOM::Material ), + theMaterial, theUpdateViewer ) ); +} -class TInitGeomGenEvent: public SALOME_Event { +class TInitGeomGenEvent: public SALOME_Event +{ public: typedef bool TResult; TResult myResult; - TInitGeomGenEvent() : myResult(false) {} - virtual void Execute() { + TInitGeomGenEvent() : myResult(false) + {} + virtual void Execute() + { myResult = GeometryGUI::InitGeomGen(); } }; -bool GEOM_Swig::initGeomGen() -{ - return ProcessEvent(new TInitGeomGenEvent()); -} - - -void GEOM_Swig::eraseGO (const char* Entry, bool allWindows) -{ - class TEvent: public SALOME_Event - { - std::string myEntry; - bool myFromAllWindows; - public: - TEvent(const char* theEntry, bool fromAllWindows): - myEntry(theEntry), myFromAllWindows(fromAllWindows) - {} - virtual void Execute() - { - SUIT_Application* app = SUIT_Session::session()->activeApplication(); - if (!app) return; - SalomeApp_Study* ActiveStudy = dynamic_cast(app->activeStudy()); - if (!ActiveStudy) return; - - Handle (SALOME_InteractiveObject) aIO = new SALOME_InteractiveObject(myEntry.c_str(), "GEOM", ""); - - GEOM_Displayer(ActiveStudy).Erase(aIO, true); - /* if (myFromAllWindows) { - QPtrList aWindows = app->desktop()->windows(); - SUIT_ViewWindow* aWin = 0; - for (aWin = aWindows.first(); aWin; aWin = aWindows.next()) { - EraseObject(aWin, aIO); - } - } else { - SUIT_ViewWindow* aWin = app->desktop()->activeWindow(); - if (aWin) - EraseObject(aWin, aIO); - }*/ - } - - /* private: - void EraseObject(SUIT_ViewWindow* theWin, Handle (SALOME_InteractiveObject) theIO) - { - if (theWin->getViewManager()->getType() == OCCViewer_Viewer::Type()){ - OCCViewer_ViewWindow* vw = dynamic_cast( theWin ); - if ( vw ) { - OCCViewer_ViewManager* vm = dynamic_cast( vw->getViewManager() ); - if ( vm ) { - SOCC_Viewer* aViewer = dynamic_cast(vm->getOCCViewer()); - if (aViewer) { - SALOME_Prs* aPrs = aViewer->CreatePrs(myEntry.c_str()); - if (aPrs) { - SALOME_OCCPrs* aOccPrs = dynamic_cast(aPrs); - if (aOccPrs) { - aViewer->Erase(aOccPrs); - aViewer->Repaint(); - } - } - } - } - } - } else if (theWin->getViewManager()->getType() == SVTK_Viewer::Type()){ - SVTK_ViewWindow* aViewWindow = dynamic_cast( theWin ); - if (aViewWindow) { - aViewWindow->Erase(theIO); - } - } - }*/ - - }; - ProcessVoidEvent(new TEvent(Entry, allWindows)); -} - - - -void GEOM_Swig::setDeflection(const char* theEntry, float theDeflect) +/*! + \brief Initialize GEOM module's engine + \return \c true if initialization succeedes or \c false otherwise +*/ +bool GEOM_Swig::initGeomGen() { - class TEvent: public SALOME_Event { - std::string myEntry; - float myParam; - public: - TEvent(const char* theEntryArg, float theParam): - myEntry(theEntryArg), myParam(theParam) - {} - virtual void Execute() { - SUIT_Application* anApp = SUIT_Session::session()->activeApplication(); - if (!anApp) return; - - Handle(SALOME_InteractiveObject) anIO = - new SALOME_InteractiveObject(myEntry.c_str(), "GEOM", ""); - - if (SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(anApp)) { - vtkActorCollection* aActors = aViewWindow->getRenderer()->GetActors(); - aActors->InitTraversal(); - while (vtkActor* aAct = aActors->GetNextActor()) { - if (GEOM_Actor* aGeomActor = dynamic_cast(aAct)) { - if (aGeomActor->hasIO()) { - Handle(SALOME_InteractiveObject) aNextIO = aGeomActor->getIO(); - if (aNextIO->isSame(anIO)) { - aGeomActor->setDeflection(myParam); - aViewWindow->Repaint(); - return; - } - } - } - } - // aView->SetTransparency(anIO, myParam); - //aView->Repaint(); - } else if (OCCViewer_Viewer* occViewer = GetOCCViewer(anApp)) { - Handle(AIS_InteractiveContext) aContext = occViewer->getAISContext(); - AIS_ListOfInteractive aAISList; - aContext->DisplayedObjects(aAISList); - AIS_ListIteratorOfListOfInteractive it(aAISList); - for (; it.More(); it.Next()) { - Handle(SALOME_InteractiveObject) aObj = - Handle(SALOME_InteractiveObject)::DownCast(it.Value()->GetOwner()); - if ((!aObj.IsNull()) && aObj->hasEntry() && aObj->isSame(anIO)) { - Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(it.Value()); - if (!aShape.IsNull()) { - TopoDS_Shape aSh = aShape->Shape(); - if (!aSh.IsNull()) - BRepTools::Clean(aSh); - - aShape->SetOwnDeviationCoefficient( myParam ); - aShape->SetOwnHLRDeviationAngle( 1.57 ); - aContext->Redisplay(aShape); - return; - } - } - } - } - } - }; - - ProcessVoidEvent(new TEvent (theEntry, theDeflect)); + return ProcessEvent( new TInitGeomGenEvent() ); } - diff --git a/src/GEOM_SWIG_WITHIHM/libGEOM_Swig.h b/src/GEOM_SWIG_WITHIHM/libGEOM_Swig.h index 5f85b568b..8580c87c9 100644 --- a/src/GEOM_SWIG_WITHIHM/libGEOM_Swig.h +++ b/src/GEOM_SWIG_WITHIHM/libGEOM_Swig.h @@ -19,45 +19,43 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // - -// GEOM GEOMGUI : GUI for Geometry component // File : libGEOM_Swig.h // Author : Nicolas REJNERI, Paul RASCLE -// -#ifndef GEOMETRYGUI_SWIG_HXX -#define GEOMETRYGUI_SWIG_HXX +#ifndef LIBGEOM_SWIG_H +#define LIBGEOM_SWIG_H #include "GEOM_GEOMGUI.hxx" -// IDL Headers -#include -#include CORBA_SERVER_HEADER(GEOM_Gen) -#include CORBA_SERVER_HEADER(SALOMEDS) -#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) - class GEOMGUI_EXPORT GEOM_Swig { public: GEOM_Swig(); ~GEOM_Swig(); - void createAndDisplayGO(const char* Entry, bool isUpdated = true); - void eraseGO(const char* Entry, bool allWindows); - void createAndDisplayFitAllGO(const char* Entry); + void createAndDisplayGO( const char* theEntry, bool theUpdateViewer = true ); + void createAndDisplayFitAllGO( const char* theEntry ); + void eraseGO( const char* theEntry, bool theUpdateViewer = true ); + void UpdateViewer(); - void setDisplayMode(const char* Entry, int mode, bool isUpdated = true); - void setVectorsMode(const char* Entry, bool isSet, bool isUpdated = true); - void setColor(const char* Entry, int red, int green, int blue, bool isUpdated = true); - void setTransparency(const char* Entry, float transp, bool isUpdated = true); - void setIsos(const char* Entry, int nbU, int nbV, bool isUpdated =true); - void setDeflection(const char* Entry, float deflect); - int getIndexTopology(const char *SubEntry, const char *Entry); - const char* getShapeTypeString(const char *Entry); - const char* getShapeTypeIcon(const char *Ior); + void setDisplayMode( const char* theEntry, int theMode, bool theUpdateViewer = true ); + void setVectorsMode( const char* theEntry, bool theOn, bool theUpdateViewer = true ); + void setColor( const char* theEntry, int theRed, int theGreen, int theBlue, bool theUpdateViewer = true ); + void setTransparency( const char* theEntry, float theTransparency, bool theUpdateViewer = true ); + void setIsos( const char* theEntry, int theNbU, int theNbV, bool theUpdateViewer = true ); + void setDeflection( const char* theEntry, float theDeflection, bool theUpdateViewer = true ); + void setMaterial( const char* theEntry, const char* theMaterial, bool theUpdateViewer = true ); + void setMaterialProperty( const char* theEntry, const char* theMaterial, bool theUpdateViewer = true ); + + int getIndexTopology( const char* theSubIOR, const char* theMainIOR ); + const char* getShapeTypeString( const char* theIOR ); + const char* getShapeTypeIcon( const char* theIOR ); bool initGeomGen(); +private: + + void init(); }; -#endif // GEOMETRYGUI_SWIG_HXX +#endif // LIBGEOM_SWIG_H diff --git a/src/GEOM_SWIG_WITHIHM/libGEOM_Swig.i b/src/GEOM_SWIG_WITHIHM/libGEOM_Swig.i index 6bf220c2d..7504d783f 100644 --- a/src/GEOM_SWIG_WITHIHM/libGEOM_Swig.i +++ b/src/GEOM_SWIG_WITHIHM/libGEOM_Swig.i @@ -22,7 +22,6 @@ // Author : Nicolas REJNERI, Paul RASCLE // Project : SALOME // Module : GEOM -// $Header$ // %module libGEOM_Swig @@ -56,20 +55,24 @@ class GEOM_Swig GEOM_Swig(); ~GEOM_Swig(); - void createAndDisplayGO(const char* Entry, bool isUpdated =true); - void eraseGO(const char* Entry, bool allWindows); - void createAndDisplayFitAllGO(const char* Entry); + void createAndDisplayGO( const char* theEntry, bool theUpdateViewer = true ); + void createAndDisplayFitAllGO( const char* theEntry ); + void eraseGO( const char* theEntry, bool theUpdateViewer = true ); + void UpdateViewer(); - int getIndexTopology(const char *SubEntry, const char *Entry); - const char* getShapeTypeString(const char *Entry); - void setDisplayMode(const char* Entry, int mode, bool isUpdated =true); - void setVectorsMode(const char* Entry, bool isSet, bool isUpdated =true); - void setColor(const char* Entry, int red, int green, int blue, bool isUpdated =true); - void setTransparency(const char* Entry, float transp, bool isUpdated =true); - void setIsos(const char* Entry, int nbU, int nbV, bool isUpdated =true); - void setDeflection(const char* Entry, float deflect); - const char* getShapeTypeIcon(const char *Ior); + void setDisplayMode( const char* theEntry, int theMode, bool theUpdateViewer = true ); + void setVectorsMode( const char* theEntry, bool theOn, bool theUpdateViewer = true ); + void setColor( const char* theEntry, int theRed, int theGreen, int theBlue, bool theUpdateViewer = true ); + void setTransparency( const char* theEntry, float theTransparency, bool theUpdateViewer = true ); + void setIsos( const char* theEntry, int theNbU, int theNbV, bool theUpdateViewer = true ); + void setDeflection( const char* theEntry, float theDeflection, bool theUpdateViewer = true ); + void setMaterial( const char* theEntry, const char* theMaterial, bool theUpdateViewer = true ); + void setMaterialProperty( const char* theEntry, const char* theMaterial, bool theUpdateViewer = true ); + + int getIndexTopology( const char* theSubIOR, const char* theMainIOR ); + const char* getShapeTypeString( const char* theIOR ); + const char* getShapeTypeIcon( const char* theIOR ); bool initGeomGen(); }; diff --git a/src/GroupGUI/GroupGUI_GroupDlg.cxx b/src/GroupGUI/GroupGUI_GroupDlg.cxx index 5d51da8fb..8cd1ae6a7 100644 --- a/src/GroupGUI/GroupGUI_GroupDlg.cxx +++ b/src/GroupGUI/GroupGUI_GroupDlg.cxx @@ -33,6 +33,7 @@ #include #include +#include #include @@ -66,6 +67,9 @@ #include +#define GROUP_IDLST_COLOR Qt::blue // Specific color for the IDs of subShapes in the dialog box +#define GROUP_NEWIDLST_COLOR Qt::red // Specific color for the new IDs of subShapes in the dialog box + enum { ALL_SUBSHAPES = 0, GET_IN_PLACE, SUBSHAPES_OF_SHAPE2, SUBSHAPES_OF_INVISIBLE_SHAPE2 }; GroupGUI_GroupDlg::GroupGUI_GroupDlg (Mode mode, GeometryGUI* theGeometryGUI, QWidget* parent) @@ -186,11 +190,13 @@ GroupGUI_GroupDlg::GroupGUI_GroupDlg (Mode mode, GeometryGUI* theGeometryGUI, QW GroupGUI_GroupDlg::~GroupGUI_GroupDlg() { + GEOM_Displayer* aDisplayer = getDisplayer(); if (myIsHiddenMain) { - GEOM_Displayer* aDisplayer = getDisplayer(); aDisplayer->Display(myMainObj); myIsHiddenMain = false; } + aDisplayer->Display(myGroup); + myDmMode = -1; } //================================================================================= @@ -199,6 +205,7 @@ GroupGUI_GroupDlg::~GroupGUI_GroupDlg() //================================================================================= void GroupGUI_GroupDlg::Init() { + myDmMode = -1; LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); //unset shape type to avoid preparation of selection before exact user shape type selection @@ -236,9 +243,12 @@ void GroupGUI_GroupDlg::Init() setShapeType((TopAbs_ShapeEnum)anOper->GetType(myGroup)); GEOM::ListOfLong_var aCurrList = anOper->GetObjects(myGroup); - for (int i = 0, n = aCurrList->length(); i < n; i++) - myIdList->addItem(new QListWidgetItem(QString("%1").arg(aCurrList[i]))); - + for (int i = 0, n = aCurrList->length(); i < n; i++) { + QListWidgetItem* itm = new QListWidgetItem( QString( "%1" ).arg( aCurrList[ i ] ) ); + myGroupIdList.append( aCurrList[ i ] ); + itm->setTextColor( QColor( GROUP_IDLST_COLOR ) ); + myIdList->addItem( itm ); + } myEditCurrentArgument = 0; } connect(mySelBtn2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); @@ -306,14 +316,18 @@ void GroupGUI_GroupDlg::ClickOnOk() //================================================================================= bool GroupGUI_GroupDlg::ClickOnApply() { - if(!isApplyAndClose()) + if(!isApplyAndClose()) { setIsDisableBrowsing( true ); + setIsDisplayResult( false ); + } - if (!onAccept(myMode == CreateGroup, true,isApplyAndClose())) + if (!onAccept(myMode == CreateGroup, true, isApplyAndClose())) return false; - if(!isApplyAndClose()) + if(!isApplyAndClose()) { setIsDisableBrowsing( false ); + setIsDisplayResult( true ); + } if (myMode == CreateGroup) { @@ -322,8 +336,19 @@ bool GroupGUI_GroupDlg::ClickOnApply() ConstructorsClicked(getConstructorId()); } else + { + int n = myIdList->count(); + myGroupIdList.clear(); + if (n > 0) + { + for (int i = 0; i < n; i++) { + QListWidgetItem* anItem = myIdList->item( i ); + myGroupIdList.append( anItem->text().toInt() ); + anItem->setTextColor( GROUP_IDLST_COLOR ); + } + } activateSelection(); - + } return true; } @@ -576,7 +601,7 @@ void GroupGUI_GroupDlg::selectAllSubShapes() if (aSubShapes->length() > 0) { if (subSelectionWay() == ALL_SUBSHAPES) { - myIdList->clear(); // for sorted final list? +// myIdList->clear(); // for sorted final list? if (!aShOp->IsDone()) return; @@ -600,12 +625,13 @@ void GroupGUI_GroupDlg::selectAllSubShapes() QListWidgetItem* anItem = 0; QString text = QString("%1").arg(anIndex); - if (!myInPlaceObj->_is_nil()) { +// if (!myInPlaceObj->_is_nil()) { QList found = myIdList->findItems(text, Qt::MatchExactly); if (found.count()) anItem = found[0]; - } +// } if (!anItem) { anItem = new QListWidgetItem(text); + anItem->setTextColor( myGroupIdList.contains(anIndex) ? QColor( GROUP_IDLST_COLOR ) : QColor( GROUP_NEWIDLST_COLOR ) ); myIdList->addItem(anItem); } anItem->setSelected(true); @@ -754,6 +780,7 @@ void GroupGUI_GroupDlg::add() continue; QListWidgetItem* anItem = new QListWidgetItem(QString("%1").arg(aMapIndex(i))); + anItem->setTextColor( myGroupIdList.contains( aMapIndex( i ) ) ? QColor( GROUP_IDLST_COLOR ) : QColor( GROUP_NEWIDLST_COLOR ) ); myIdList->addItem(anItem); anItem->setSelected(true); } @@ -835,7 +862,7 @@ void GroupGUI_GroupDlg::setShapeType(const TopAbs_ShapeEnum theType) void GroupGUI_GroupDlg::activateSelection() { bool isApply = ((QPushButton*)sender() == buttonApply()); - if(!isApply) + if(!isApplyAndClose()) erasePreview(false); // local selection @@ -844,27 +871,42 @@ void GroupGUI_GroupDlg::activateSelection() myIsShapeType) // check if shape type is already choosen by user { GEOM_Displayer* aDisplayer = getDisplayer(); - - // Mantis issue 0021421: do not hide main shape, if explode on VERTEX - if (getShapeType() == TopAbs_VERTEX) { - if (myIsHiddenMain) - aDisplayer->Display(myMainObj); - } - else { - SALOME_View* view = GEOM_Displayer::GetActiveView(); + + //display mode for main shape + if ( myDmMode == -1 ) { + SALOME_View* view = GEOM_Displayer::GetActiveView(); if (view) { CORBA::String_var aMainEntry = myMainObj->GetStudyEntry(); Handle(SALOME_InteractiveObject) io = new SALOME_InteractiveObject (aMainEntry.in(), "GEOM", "TEMP_IO"); - if (view->isVisible(io)) { - aDisplayer->Erase(myMainObj, false, false); - myIsHiddenMain = true; + if ( view->isVisible( io ) ) { + Handle(GEOM_AISShape) aSh = GEOMBase::ConvertIOinGEOMAISShape( io, true ); + if(!aSh.IsNull()) { + myDmMode = aSh->isTopLevel() ? aSh->prevDisplayMode() : aSh->DisplayMode(); + } + // Hide main shape, if explode on VERTEX + if(getShapeType() != TopAbs_VERTEX) { + aDisplayer->Erase(myMainObj, false, false); + myIsHiddenMain = true; + } } + else + myDmMode = SUIT_Session::session()->resourceMgr()->integerValue( "Geometry", "display_mode" ); } } - if(!isApply) { - int prevDisplayMode = aDisplayer->SetDisplayMode(0); + aDisplayer->SetDisplayMode(myDmMode); + + // Mantis issue 0021421: do not hide main shape, if explode on VERTEX + if (getShapeType() == TopAbs_VERTEX) { + if (myIsHiddenMain) + aDisplayer->Display(myMainObj); + } + aDisplayer->Erase(myGroup, false, false); + + QColor aColor = SUIT_Session::session()->resourceMgr()->colorValue( "Geometry", "editgroup_color" ); + Quantity_NameOfColor aCol = SalomeApp_Tools::color( aColor ).Name(); + if(!isApplyAndClose()) { SUIT_ViewWindow* aViewWindow = 0; SUIT_Study* activeStudy = SUIT_Session::session()->activeApplication()->activeStudy(); if (activeStudy) @@ -895,8 +937,15 @@ void GroupGUI_GroupDlg::activateSelection() for (; anExp.More(); anExp.Next()) { TopoDS_Shape aSubShape = anExp.Current(); int index = aSubShapesMap.FindIndex(aSubShape); - QString anEntry = anEntryBase + QString("_%1").arg(index); - + QString anEntry = QString( "TEMP_" ) + anEntryBase + QString("_%1").arg(index); + Handle(SALOME_InteractiveObject) io = + new SALOME_InteractiveObject(anEntry.toAscii(), "GEOM", "TEMP_IO"); + if ( myGroupIdList.contains( index ) ) { + aDisplayer->SetColor( aCol ); + } + else { + aDisplayer->UnsetColor(); + } SALOME_Prs* aPrs = aDisplayer->buildSubshapePresentation(aSubShape, anEntry, aView); if (aPrs) { displayPreview(aPrs, true, false); // append, do not update @@ -914,7 +963,14 @@ void GroupGUI_GroupDlg::activateSelection() for (; aM2IPit.More(); aM2IPit.Next()) { int index = aM2IPit.Key(); TopoDS_Shape aSubShape = aSubShapesMap.FindKey(index); - QString anEntry = anEntryBase + QString("_%1").arg(index); + QString anEntry = QString( "TEMP_" ) + anEntryBase + QString("_%1").arg(index); + + if ( myGroupIdList.contains( index ) ) { + aDisplayer->SetColor( aCol ); + } + else { + aDisplayer->UnsetColor(); + } SALOME_Prs* aPrs = aDisplayer->buildSubshapePresentation(aSubShape, anEntry, aView); if (aPrs) { @@ -923,9 +979,9 @@ void GroupGUI_GroupDlg::activateSelection() } } else ; - + aDisplayer->UnsetDisplayMode(); + aDisplayer->UnsetColor(); aDisplayer->UpdateViewer(); - aDisplayer->SetDisplayMode(prevDisplayMode); } } diff --git a/src/GroupGUI/GroupGUI_GroupDlg.h b/src/GroupGUI/GroupGUI_GroupDlg.h index 438f52b10..84618bf4b 100644 --- a/src/GroupGUI/GroupGUI_GroupDlg.h +++ b/src/GroupGUI/GroupGUI_GroupDlg.h @@ -102,6 +102,8 @@ private: GEOM::GEOM_Object_var myInPlaceObj; int myInPlaceObjSelectState; TColStd_DataMapOfIntegerInteger myMain2InPlaceIndices; + QList myGroupIdList; + int myDmMode; QPushButton* mySelBtn; QLineEdit* myMainName; diff --git a/src/IGESExport/Makefile.am b/src/IGESExport/Makefile.am index 694aee5b0..9fed32fdb 100644 --- a/src/IGESExport/Makefile.am +++ b/src/IGESExport/Makefile.am @@ -21,7 +21,6 @@ # Author : Pavel TELKOV # Modified by : Alexander BORODIN (OCN) - autotools usage # Module : GEOM -# $Header$ # include $(top_srcdir)/adm_local/unix/make_common_starter.am diff --git a/src/IGESImport/Makefile.am b/src/IGESImport/Makefile.am index b6001bf34..ebecee851 100644 --- a/src/IGESImport/Makefile.am +++ b/src/IGESImport/Makefile.am @@ -20,7 +20,6 @@ # Author : Pavel TELKOV # Modified by : Alexander BORODIN (OCN) - autotools usage # Module : GEOM -# $Header$ include $(top_srcdir)/adm_local/unix/make_common_starter.am diff --git a/src/Makefile.am b/src/Makefile.am index 862b90287..e81e3bfd9 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -15,15 +15,14 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# # File : Makefile.am # Author : Alexander BORODIN, Open CASCADE S.A.S. (alexander.borodin@opencascade.com) # Package : src (source files directory) -SUBDIRS = ARCHIMEDE NMTDS NMTTools GEOMAlgo SKETCHER OCC2VTK GEOM \ - BREPExport BREPImport IGESExport IGESImport STEPExport \ - STEPImport STLExport VTKExport ShHealOper GEOMImpl GEOM_I \ +SUBDIRS = ARCHIMEDE NMTDS NMTTools BlockFix GEOMAlgo SKETCHER OCC2VTK GEOM \ + BREPExport BREPImport IGESExport IGESImport STEPExport STEPImport \ + STLExport VTKExport ShHealOper GEOMUtils GEOMImpl GEOM_I \ GEOMClient GEOM_I_Superv GEOM_SWIG GEOM_PY if WITH_OPENCV @@ -31,18 +30,18 @@ if WITH_OPENCV endif if GEOM_ENABLE_GUI - SUBDIRS += OBJECT DlgRef GEOMFiltersSelection Material GEOMGUI GEOMBase GEOMToolsGUI \ - DisplayGUI BasicGUI PrimitiveGUI GenerationGUI EntityGUI BuildGUI \ - BooleanGUI TransformationGUI OperationGUI RepairGUI MeasureGUI \ - GroupGUI BlocksGUI AdvancedGUI GEOM_SWIG_WITHIHM + SUBDIRS += OBJECT DlgRef GEOMFiltersSelection Material GEOMGUI GEOMBase \ + GEOMToolsGUI DisplayGUI BasicGUI PrimitiveGUI GenerationGUI \ + EntityGUI BuildGUI BooleanGUI TransformationGUI OperationGUI \ + RepairGUI MeasureGUI GroupGUI BlocksGUI AdvancedGUI GEOM_SWIG_WITHIHM endif -DIST_SUBDIRS = ARCHIMEDE NMTDS NMTTools GEOMAlgo \ - SKETCHER OCC2VTK GEOM BREPExport \ - BREPImport IGESExport IGESImport STEPExport STEPImport STLExport \ - VTKExport ShHealOper GEOMImpl GEOM_I GEOMClient GEOM_I_Superv \ - GEOM_SWIG OBJECT DlgRef GEOMFiltersSelection Material GEOMGUI GEOMBase \ +DIST_SUBDIRS = ARCHIMEDE NMTDS NMTTools BlockFix GEOMAlgo SKETCHER \ + OCC2VTK GEOM BREPExport BREPImport IGESExport IGESImport \ + STEPExport STEPImport STLExport VTKExport ShHealOper GEOMUtils \ + GEOMImpl GEOM_I GEOMClient GEOM_I_Superv GEOM_SWIG OBJECT \ + DlgRef GEOMFiltersSelection Material GEOMGUI GEOMBase \ GEOMToolsGUI DisplayGUI BasicGUI PrimitiveGUI GenerationGUI \ EntityGUI BuildGUI BooleanGUI TransformationGUI OperationGUI \ - RepairGUI MeasureGUI GroupGUI BlocksGUI AdvancedGUI \ + RepairGUI MeasureGUI GroupGUI BlocksGUI AdvancedGUI \ GEOM_SWIG_WITHIHM GEOM_PY ShapeRecognition diff --git a/src/Material/Makefile.am b/src/Material/Makefile.am index c0c43367f..e87bf9360 100644 --- a/src/Material/Makefile.am +++ b/src/Material/Makefile.am @@ -36,6 +36,12 @@ dist_libMaterial_la_SOURCES = \ Material_Model.cxx \ Material_ResourceMgr.cxx +MOC_FILES = \ + Material_ResourceMgr_moc.cxx + +nodist_libMaterial_la_SOURCES = \ + $(MOC_FILES) + # additional information to compile and link file libMaterial_la_CPPFLAGS = \ $(QT_INCLUDES) \ diff --git a/src/Material/Material_Model.cxx b/src/Material/Material_Model.cxx index 9744571c5..949d7d2b0 100644 --- a/src/Material/Material_Model.cxx +++ b/src/Material/Material_Model.cxx @@ -25,6 +25,8 @@ #include "GEOM_VTKPropertyMaterial.hxx" #include "Material_ResourceMgr.h" +#include + /*! \brief Constructor @@ -78,21 +80,36 @@ void Material_Model::fromProperties( const QString& props ) else if ( key == "emissivecolor" && Qtx::stringToColor( data, colorValue ) ) { setColor( Emissive, colorValue ); } - else if ( key == "ambientcoefficient" && dblOk ) { + else if ( key == "frontambientcoefficient" && dblOk ) { setReflection( Ambient, dblValue ); } - else if ( key == "diffusecoefficient" && dblOk ) { + else if ( key == "backambientcoefficient" && dblOk ) { + setReflection( Ambient, dblValue, false ); + } + else if ( key == "frontdiffusecoefficient" && dblOk ) { setReflection( Diffuse, dblValue ); } - else if ( key == "specularcoefficient" && dblOk ) { + else if ( key == "backdiffusecoefficient" && dblOk ) { + setReflection( Diffuse, dblValue, false ); + } + else if ( key == "frontspecularcoefficient" && dblOk ) { setReflection( Specular, dblValue ); } - else if ( key == "emissivecoefficient" && dblOk ) { + else if ( key == "backspecularcoefficient" && dblOk ) { + setReflection( Specular, dblValue, false ); + } + else if ( key == "frontemissivecoefficient" && dblOk ) { setReflection( Emissive, dblValue ); } - else if ( key == "shininess" && dblOk ) { + else if ( key == "backemissivecoefficient" && dblOk ) { + setReflection( Emissive, dblValue, false ); + } + else if ( key == "frontshininess" && dblOk ) { setShininess( dblValue ); } + else if ( key == "backshininess" && dblOk ) { + setShininess( dblValue, false ); + } else if ( key == "transparency" && dblOk ) { setTransparency( dblValue ); } @@ -128,7 +145,7 @@ QString Material_Model::toProperties() props << fmt.arg( "Physical" ).arg( isPhysical() ); // shininess - props << fmt.arg( "Shininess" ).arg( shininess() ); + props << fmt.arg( "FrontShininess" ).arg( QString::number ( shininess( true ), 'g', 4 ) ) << fmt.arg( "BackShininess" ).arg( QString::number ( shininess( false ), 'g', 4 ) ); //transparency props << fmt.arg( "Transparency" ).arg( transparency() ); @@ -137,25 +154,25 @@ QString Material_Model::toProperties() props << fmt.arg( "Ambient" ).arg( hasReflection( Ambient ) ); if ( color( Ambient ).isValid() ) props << fmt.arg( "AmbientColor" ).arg( Qtx::colorToString( color( Ambient ) ) ); - props << fmt.arg( "AmbientCoefficient" ).arg( reflection( Ambient ) ); + props << fmt.arg( "FrontAmbientCoefficient" ).arg( QString::number ( reflection( Ambient, true ), 'g', 4 ) ) << fmt.arg( "BackAmbientCoefficient" ).arg( QString::number ( reflection( Ambient, false ), 'g', 4 ) ); // diffuse reflection props << fmt.arg( "Diffuse" ).arg( hasReflection( Diffuse ) ); if ( color( Diffuse ).isValid() ) props << fmt.arg( "DiffuseColor" ).arg( Qtx::colorToString( color( Diffuse ) ) ); - props << fmt.arg( "DiffuseCoefficient" ).arg( reflection( Diffuse ) ); + props << fmt.arg( "FrontDiffuseCoefficient" ).arg( QString::number ( reflection( Diffuse, true ), 'g', 4 ) ) << fmt.arg( "BackDiffuseCoefficient" ).arg( QString::number ( reflection( Diffuse, false ), 'g', 4 ) ); // specular reflection props << fmt.arg( "Specular" ).arg( hasReflection( Specular ) ); if ( color( Specular ).isValid() ) props << fmt.arg( "SpecularColor" ).arg( Qtx::colorToString( color( Specular ) ) ); - props << fmt.arg( "SpecularCoefficient" ).arg( reflection( Specular ) ); + props << fmt.arg( "FrontSpecularCoefficient" ).arg( QString::number ( reflection( Specular, true ), 'g', 4 ) ) << fmt.arg( "BackSpecularCoefficient" ).arg( QString::number ( reflection( Specular, false ), 'g', 4 ) ); // emissive reflection props << fmt.arg( "Emissive" ).arg( hasReflection( Emissive ) ); if ( color( Emissive ).isValid() ) props << fmt.arg( "EmissiveColor" ).arg( Qtx::colorToString( color( Emissive ) ) ); - props << fmt.arg( "EmissiveCoefficient" ).arg( reflection( Emissive ) ); + props << fmt.arg( "FrontEmissiveCoefficient" ).arg( QString::number ( reflection( Emissive, true ), 'g', 4 ) ) << fmt.arg( "BackEmissiveCoefficient" ).arg( QString::number ( reflection( Emissive, false ), 'g', 4 ) ); return props.join( ":" ); } @@ -169,7 +186,7 @@ QString Material_Model::toProperties() \param resMgr resource manager (if not specified, new resources manager is created) \sa toResources() */ -void Material_Model::fromResources( const QString& material, QtxResourceMgr* resMgr ) +void Material_Model::fromResources( const QString& material, Material_ResourceMgr* resMgr ) { static QString common = "[common]"; @@ -179,23 +196,33 @@ void Material_Model::fromResources( const QString& material, QtxResourceMgr* res // material name is not specified: use default values if ( material.isEmpty() ) return; - bool ownResourcesMgr = resMgr == 0; - - if ( ownResourcesMgr ) - resMgr = new Material_ResourceMgr(); + if ( !resMgr ) + resMgr = Material_ResourceMgr::resourceMgr(); + + // lock resources manager + QMutexLocker lock( &resMgr->myMutex ); // read common section if ( material != common && resMgr->hasSection( common ) ) - fromResources( common, resMgr ); + read( common, resMgr ); + + // read material section + read( material, resMgr ); +} +void Material_Model::read( const QString& material, Material_ResourceMgr* resMgr ) +{ // physical if ( resMgr->hasValue( material, "physical" ) ) { setPhysical( resMgr->booleanValue( material, "physical" ) ); } // shininess - if ( resMgr->hasValue( material, "shininess" ) ) { - setShininess( resMgr->doubleValue( material, "shininess" ) ); + if ( resMgr->hasValue( material, "front_shininess" ) ) { + setShininess( resMgr->doubleValue( material, "front_shininess" ) ); + } + if ( resMgr->hasValue( material, "back_shininess" ) ) { + setShininess( resMgr->doubleValue( material, "back_shininess" ), false ); } // transparency @@ -207,8 +234,11 @@ void Material_Model::fromResources( const QString& material, QtxResourceMgr* res if ( resMgr->hasValue( material, "ambient-color" ) ) { setColor( Ambient, resMgr->colorValue( material, "ambient-color" ) ); } - if ( resMgr->hasValue( material, "ambient-coefficient" ) ) { - setReflection( Ambient, resMgr->doubleValue( material, "ambient-coefficient" ) ); + if ( resMgr->hasValue( material, "front_ambient-coefficient" ) ) { + setReflection( Ambient, resMgr->doubleValue( material, "front_ambient-coefficient" ) ); + } + if ( resMgr->hasValue( material, "back_ambient-coefficient" ) ) { + setReflection( Ambient, resMgr->doubleValue( material, "back_ambient-coefficient" ), false ); } if ( resMgr->hasValue( material, "ambient" ) ) { setReflection( Ambient, resMgr->booleanValue( material, "ambient" ) ); @@ -218,8 +248,11 @@ void Material_Model::fromResources( const QString& material, QtxResourceMgr* res if ( resMgr->hasValue( material, "diffuse-color" ) ) { setColor( Diffuse, resMgr->colorValue( material, "diffuse-color" ) ); } - if ( resMgr->hasValue( material, "diffuse-coefficient" ) ) { - setReflection( Diffuse, resMgr->doubleValue( material, "diffuse-coefficient" ) ); + if ( resMgr->hasValue( material, "front_diffuse-coefficient" ) ) { + setReflection( Diffuse, resMgr->doubleValue( material, "front_diffuse-coefficient" ) ); + } + if ( resMgr->hasValue( material, "back_diffuse-coefficient" ) ) { + setReflection( Diffuse, resMgr->doubleValue( material, "back_diffuse-coefficient" ), false ); } if ( resMgr->hasValue( material, "diffuse" ) ) { setReflection( Diffuse, resMgr->booleanValue( material, "diffuse" ) ); @@ -229,8 +262,11 @@ void Material_Model::fromResources( const QString& material, QtxResourceMgr* res if ( resMgr->hasValue( material, "specular-color" ) ) { setColor( Specular, resMgr->colorValue( material, "specular-color" ) ); } - if ( resMgr->hasValue( material, "specular-coefficient" ) ) { - setReflection( Specular, resMgr->doubleValue( material, "specular-coefficient" ) ); + if ( resMgr->hasValue( material, "front_specular-coefficient" ) ) { + setReflection( Specular, resMgr->doubleValue( material, "front_specular-coefficient" ) ); + } + if ( resMgr->hasValue( material, "back_specular-coefficient" ) ) { + setReflection( Specular, resMgr->doubleValue( material, "back_specular-coefficient" ), false ); } if ( resMgr->hasValue( material, "specular" ) ) { setReflection( Specular, resMgr->booleanValue( material, "specular" ) ); @@ -240,15 +276,15 @@ void Material_Model::fromResources( const QString& material, QtxResourceMgr* res if ( resMgr->hasValue( material, "emissive-color" ) ) { setColor( Emissive, resMgr->colorValue( material, "emissive-color" ) ); } - if ( resMgr->hasValue( material, "emissive-coefficient" ) ) { - setReflection( Emissive, resMgr->doubleValue( material, "emissive-coefficient" ) ); + if ( resMgr->hasValue( material, "front_emissive-coefficient" ) ) { + setReflection( Emissive, resMgr->doubleValue( material, "front_emissive-coefficient" ) ); + } + if ( resMgr->hasValue( material, "back_emissive-coefficient" ) ) { + setReflection( Emissive, resMgr->doubleValue( material, "back_emissive-coefficient" ), false ); } if ( resMgr->hasValue( material, "emissive" ) ) { setReflection( Emissive, resMgr->booleanValue( material, "emissive" ) ); } - - if ( ownResourcesMgr ) - delete resMgr; } /*! @@ -257,9 +293,12 @@ void Material_Model::fromResources( const QString& material, QtxResourceMgr* res \param resMgr resource manager \sa fromResources() */ -void Material_Model::toResources( const QString& material, QtxResourceMgr* resMgr ) +void Material_Model::toResources( const QString& material, Material_ResourceMgr* resMgr ) { if ( resMgr && !material.isEmpty() ) { + // lock resources manager + QMutexLocker lock( &resMgr->myMutex ); + // remove resources section (to clean-up all previous properties) resMgr->remove( material ); @@ -267,7 +306,8 @@ void Material_Model::toResources( const QString& material, QtxResourceMgr* resMg resMgr->setValue( material, "physical", isPhysical() ); // shininess - resMgr->setValue( material, "shininess", shininess() ); + resMgr->setValue( material, "front_shininess", shininess( true) ); + resMgr->setValue( material, "back_shininess", shininess( false ) ); // transparency resMgr->setValue( material, "transparency", transparency() ); @@ -275,46 +315,33 @@ void Material_Model::toResources( const QString& material, QtxResourceMgr* resMg // ambient reflection if ( color( Ambient ).isValid() ) resMgr->setValue( material, "ambient-color", color( Ambient ) ); - resMgr->setValue( material, "ambient-coefficient", reflection( Ambient ) ); + resMgr->setValue( material, "front_ambient-coefficient", reflection( Ambient ) ); + resMgr->setValue( material, "back_ambient-coefficient", reflection( Ambient, false ) ); resMgr->setValue( material, "ambient", hasReflection( Ambient ) ); // diffuse reflection if ( color( Diffuse ).isValid() ) resMgr->setValue( material, "diffuse-color", color( Diffuse ) ); - resMgr->setValue( material, "diffuse-coefficient", reflection( Diffuse ) ); + resMgr->setValue( material, "front_diffuse-coefficient", reflection( Diffuse ) ); + resMgr->setValue( material, "back_diffuse-coefficient", reflection( Diffuse, false ) ); resMgr->setValue( material, "diffuse", hasReflection( Diffuse ) ); // Specular reflection if ( color( Specular ).isValid() ) resMgr->setValue( material, "specular-color", color( Specular ) ); - resMgr->setValue( material, "specular-coefficient", reflection( Specular ) ); + resMgr->setValue( material, "front_specular-coefficient", reflection( Specular ) ); + resMgr->setValue( material, "back_specular-coefficient", reflection( Specular, false ) ); resMgr->setValue( material, "specular", hasReflection( Specular ) ); // Emissive reflection if ( color( Emissive ).isValid() ) resMgr->setValue( material, "emissive-color", color( Emissive ) ); - resMgr->setValue( material, "emissive-coefficient", reflection( Emissive ) ); + resMgr->setValue( material, "front_emissive-coefficient", reflection( Emissive ) ); + resMgr->setValue( material, "back_emissive-coefficient", reflection( Emissive, false ) ); resMgr->setValue( material, "emissive", hasReflection( Emissive ) ); } } -/*! - \brief Initialize material model from the preferences - - The material name is retrieved from the "material" parameter of the "Geometry" section - of the specified resources manager. - - \param resMgr resources manager - \sa fromResources(), toResources() -*/ -// void Material_Model::fromPreferences( QtxResourceMgr* resMgr ) -// { -// if ( resMgr ) { -// // default material is Plastic -// fromResources( resMgr->stringValue( "Geometry", "material", "Plastic" ) ); -// } -// } - /*! \brief Get material type \return \c true if material is physical or \c false otherwise @@ -390,14 +417,18 @@ void Material_Model::setColor( ReflectionType type, const QColor& value ) /*! \brief Get coefficient value for the given reflection type \param type reflection type + \param theIsFront boolean flag for choosing side \return coefficient value for the specified reflection type - \sa setReflection(ReflectionType, double) + \sa setReflection(ReflectionType, double, bool = true) */ -double Material_Model::reflection( ReflectionType type ) const +double Material_Model::reflection( ReflectionType type, bool theIsFront ) const { double value = 0.0; if ( type >= 0 && type < 4 ) - value = myReflection[ type ].coef; + if ( theIsFront ) + value = myReflection[ type ].front_coef; + else + value = myReflection[ type ].back_coef; return value; } @@ -405,32 +436,44 @@ double Material_Model::reflection( ReflectionType type ) const \brief Set coefficient value for the given reflection type \param type reflection type \param value coefficient to be used by the given reflection type - \sa reflection() + \param theIsFront boolean flag for choosing side + \sa reflection( bool = true) */ -void Material_Model::setReflection( ReflectionType type, double value ) +void Material_Model::setReflection( ReflectionType type, double value, bool theIsFront ) { if ( type >= 0 && type < 4 ) - myReflection[ type ].coef = value; + if ( theIsFront ) + myReflection[ type ].front_coef = value; + else + myReflection[ type ].back_coef = value; } /*! \brief Get shininess value + \param theIsFront boolean flag for choosing side \return shininess value of the material - \sa setShininess() + \sa setShininess( double, bool = true ) */ -double Material_Model::shininess() const +double Material_Model::shininess( bool theIsFront ) const { - return myShininess; + if ( theIsFront ) + return myFrontShininess; + else + return myBackShininess; } /*! \brief Set shininess value \param value new shininess value - \sa shininess() + \param theIsFront boolean flag for choosing side + \sa shininess( bool = true ) */ -void Material_Model::setShininess( double value ) +void Material_Model::setShininess( double value, bool theIsFront ) { - myShininess = value; + if ( theIsFront ) + myFrontShininess = value; + else + myBackShininess = value; } /*! @@ -464,39 +507,45 @@ void Material_Model::init() setPhysical( false ); // shininess setShininess( 0.039 ); + setShininess( 0.039, false ); // transparency setTransparency( 0.0 ); // ambient reflection (enabled by default) Qtx::stringToColor( "#333333", c ); setColor( Ambient, c ); - setReflection( Ambient, 0.3 ); + setReflection( Ambient, 0.3, true ); + setReflection( Ambient, 0.3, false ); setReflection( Ambient, true ); // diffuse reflection (enabled by default) Qtx::stringToColor( "#000000", c ); setColor( Diffuse, c ); setReflection( Diffuse, 0.65 ); + setReflection( Diffuse, 0.65, false ); setReflection( Diffuse, true ); // specular reflection (enabled by default) Qtx::stringToColor( "#ffffff", c ); setColor( Specular, c ); - setReflection( Specular, 0.0 ); + setReflection( Specular, 0.0 ); + setReflection( Specular, 0.0, false ); setReflection( Specular, true ); // emissive reflection (disabled by default) Qtx::stringToColor( "#000000", c ); setColor( Emissive, c ); - setReflection( Emissive, 0.0 ); + setReflection( Emissive, 0.0 ); + setReflection( Emissive, 0.0, false ); setReflection( Emissive, false ); } /*! \brief Construct OCCT material aspect from material model + \param theIsFront boolean flag for choosing side \return material aspect object with corresponding properties */ -Graphic3d_MaterialAspect Material_Model::getMaterialOCCAspect() +Graphic3d_MaterialAspect Material_Model::getMaterialOCCAspect( bool theIsFront ) { // Get material aspect from the current model Graphic3d_MaterialAspect aspect; @@ -508,7 +557,7 @@ Graphic3d_MaterialAspect Material_Model::getMaterialOCCAspect() c = color( Ambient ); aspect.SetAmbientColor( Quantity_Color( c.redF(), c.greenF(), c.blueF(), Quantity_TOC_RGB ) ); } - aspect.SetAmbient( reflection( Ambient )); + aspect.SetAmbient( reflection( Ambient, theIsFront )); if ( hasReflection( Ambient ) ) aspect.SetReflectionModeOn( Graphic3d_TOR_AMBIENT ); else @@ -519,7 +568,7 @@ Graphic3d_MaterialAspect Material_Model::getMaterialOCCAspect() c = color( Diffuse ); aspect.SetDiffuseColor( Quantity_Color( c.redF(), c.greenF(), c.blueF(), Quantity_TOC_RGB ) ); } - aspect.SetDiffuse( reflection( Diffuse )); + aspect.SetDiffuse( reflection( Diffuse, theIsFront )); if ( hasReflection( Diffuse ) ) aspect.SetReflectionModeOn( Graphic3d_TOR_DIFFUSE ); else @@ -530,7 +579,7 @@ Graphic3d_MaterialAspect Material_Model::getMaterialOCCAspect() c = color( Specular ); aspect.SetSpecularColor( Quantity_Color( c.redF(), c.greenF(), c.blueF(), Quantity_TOC_RGB ) ); } - aspect.SetSpecular( reflection( Specular )); + aspect.SetSpecular( reflection( Specular, theIsFront )); if ( hasReflection( Specular ) ) aspect.SetReflectionModeOn( Graphic3d_TOR_SPECULAR ); else @@ -541,14 +590,14 @@ Graphic3d_MaterialAspect Material_Model::getMaterialOCCAspect() c = color( Emissive ); aspect.SetEmissiveColor( Quantity_Color( c.redF(), c.greenF(), c.blueF(), Quantity_TOC_RGB ) ); } - aspect.SetEmissive( reflection( Emissive )); + aspect.SetEmissive( reflection( Emissive, theIsFront )); if ( hasReflection( Emissive ) ) aspect.SetReflectionModeOn( Graphic3d_TOR_EMISSION ); else aspect.SetReflectionModeOff( Graphic3d_TOR_EMISSION ); // shininess - aspect.SetShininess( shininess() ); + aspect.SetShininess( shininess( theIsFront ) ); // transparency aspect.SetTransparency( transparency() ); @@ -561,9 +610,10 @@ Graphic3d_MaterialAspect Material_Model::getMaterialOCCAspect() /*! \brief Construct VTK property from material model + \param theIsFront boolean flag for choosing side \return VTK property with correspondent material properties */ -GEOM_VTKPropertyMaterial* Material_Model::getMaterialVTKProperty() +GEOM_VTKPropertyMaterial* Material_Model::getMaterialVTKProperty( bool theIsFront ) { // NOTE: In VTK it's impossible to switch on/off specific reflection type // NOTE: In VTK emissive reflection type is not supported @@ -579,25 +629,25 @@ GEOM_VTKPropertyMaterial* Material_Model::getMaterialVTKProperty() if ( color( Ambient ).isValid() && hasReflection( Ambient ) ) { c = color( Ambient ); prop->SetAmbientColor( c.redF(), c.greenF(), c.blueF() ); - prop->SetAmbient( reflection( Ambient ) ); + prop->SetAmbient( reflection( Ambient, theIsFront ) ); } // diffuse reflection if ( color( Diffuse ).isValid() && hasReflection( Diffuse ) ) { c = color( Diffuse ); prop->SetDiffuseColor( c.redF(), c.greenF(), c.blueF() ); - prop->SetDiffuse( reflection( Diffuse ) ); + prop->SetDiffuse( reflection( Diffuse, theIsFront ) ); } // specular reflection if ( color( Specular ).isValid() && hasReflection( Specular ) ) { c = color( Specular ); prop->SetSpecularColor( c.redF(), c.greenF(), c.blueF() ); - prop->SetSpecular( reflection( Specular ) ); + prop->SetSpecular( reflection( Specular, theIsFront ) ); } // shininess - prop->SetSpecularPower( shininess()*100.0 ); + prop->SetSpecularPower( shininess( theIsFront )*100.0 ); // transparency prop->SetOpacity( 1 - transparency() ); diff --git a/src/Material/Material_Model.h b/src/Material/Material_Model.h index 3f3c8ff24..d27ad1236 100644 --- a/src/Material/Material_Model.h +++ b/src/Material/Material_Model.h @@ -32,7 +32,7 @@ #include -class QtxResourceMgr; +class Material_ResourceMgr; class GEOM_VTKPropertyMaterial; class MATERIAL_SALOME_EXPORT Material_Model @@ -51,8 +51,8 @@ public: void fromProperties( const QString& ); QString toProperties(); - void fromResources( const QString& = QString(), QtxResourceMgr* = 0 ); - void toResources( const QString&, QtxResourceMgr* ); + void fromResources( const QString& = QString(), Material_ResourceMgr* = 0 ); + void toResources( const QString&, Material_ResourceMgr* ); bool isPhysical() const; void setPhysical( bool ); @@ -63,32 +63,35 @@ public: QColor color( ReflectionType ) const; void setColor( ReflectionType, const QColor& ); - double reflection( ReflectionType ) const; - void setReflection( ReflectionType, double ); + double reflection( ReflectionType, bool = true ) const; + void setReflection( ReflectionType, double, bool = true ); - double shininess() const; - void setShininess( double ); + double shininess( bool = true) const; + void setShininess( double, bool = true ); double transparency() const; void setTransparency( double ); - Graphic3d_MaterialAspect getMaterialOCCAspect(); - GEOM_VTKPropertyMaterial* getMaterialVTKProperty(); + Graphic3d_MaterialAspect getMaterialOCCAspect( bool = true ); + GEOM_VTKPropertyMaterial* getMaterialVTKProperty( bool = true ); private: void init(); + void read( const QString&, Material_ResourceMgr* ); private: typedef struct { QColor color; - double coef; + double front_coef; + double back_coef; bool enabled; } ReflectionData; typedef QVector ReflectionList; bool myIsPhysical; - double myShininess; + double myFrontShininess; + double myBackShininess; double myTransparency; ReflectionList myReflection; }; diff --git a/src/Material/Material_ResourceMgr.cxx b/src/Material/Material_ResourceMgr.cxx index 97853f532..eef31d76d 100644 --- a/src/Material/Material_ResourceMgr.cxx +++ b/src/Material/Material_ResourceMgr.cxx @@ -22,6 +22,31 @@ #include "Material_ResourceMgr.h" +#include +#include + +/*! + \class Material_ResourceMgr::Updater + \brief Updates the contents of the resource manager as soon as + user materials database file is changed + \internal +*/ +class Material_ResourceMgr::Updater : public QThread +{ +public: + Material_ResourceMgr* myResourceMgr; + Updater( Material_ResourceMgr* resMgr ) : myResourceMgr( resMgr ) + { + start(); + } + void run() + { + QMutexLocker lock( &myResourceMgr->myMutex ); + myResourceMgr->clear(); + myResourceMgr->load(); + } +}; + /*! \class Material_ResourceMgr \brief Material properties resources manager. @@ -41,7 +66,8 @@ \brief Constructor */ Material_ResourceMgr::Material_ResourceMgr() - : QtxResourceMgr( "SalomeMaterial", "%1Config" ) + : QtxResourceMgr( "SalomeMaterial", "%1Config" ), + myWatcher( 0 ) { if ( dirList().isEmpty() && ::getenv( "GEOM_ROOT_DIR" ) ) setDirList( QStringList() << Qtx::addSlash( ::getenv( "GEOM_ROOT_DIR" ) ) + "share/salome/resources/geom" ); @@ -53,6 +79,24 @@ Material_ResourceMgr::Material_ResourceMgr() */ Material_ResourceMgr::~Material_ResourceMgr() { + watchUserFile( false ); +} + +/*! + \brief Get shared instance of resources manager + + This instance of resource manager is global for the application; + it watches for changes in the user materials database file to + maintain the fresh version of the materials data. +*/ +Material_ResourceMgr* Material_ResourceMgr::resourceMgr() +{ + static Material_ResourceMgr* resMgr = 0; + if ( !resMgr ) { + resMgr = new Material_ResourceMgr(); + resMgr->watchUserFile( true ); + } + return resMgr; } /*! @@ -63,6 +107,8 @@ Material_ResourceMgr::~Material_ResourceMgr() */ QStringList Material_ResourceMgr::materials( MaterialType theType, bool theSort ) { + QMutexLocker lock( &myMutex ); + // store original working mode WorkingMode m = workingMode(); @@ -114,3 +160,34 @@ QStringList Material_ResourceMgr::materials( MaterialType theType, bool theSort return result; } + +/*! + \brief Start/stop this resource manager watching the user materials database file. + \internal +*/ +void Material_ResourceMgr::watchUserFile( bool on ) +{ + if ( on ) { + if ( !myWatcher ) { + myWatcher = new QFileSystemWatcher( this ); + myWatcher->addPath( userFileName( appName() ) ); + connect( myWatcher, SIGNAL( fileChanged( QString ) ), this, SLOT( update() ) ); + } + } + else { + if ( myWatcher ) { + delete myWatcher; + myWatcher = 0; + } + } +} + +/*! + \brief Update user database slot + \internal +*/ +void Material_ResourceMgr::update() +{ + Updater( this ).wait(); + emit changed(); +} diff --git a/src/Material/Material_ResourceMgr.h b/src/Material/Material_ResourceMgr.h index a98a531d7..de71b1028 100644 --- a/src/Material/Material_ResourceMgr.h +++ b/src/Material/Material_ResourceMgr.h @@ -25,10 +25,18 @@ #include "Material.h" +#include +#include #include -class MATERIAL_SALOME_EXPORT Material_ResourceMgr : public QtxResourceMgr +class QFileSystemWatcher; + +class MATERIAL_SALOME_EXPORT Material_ResourceMgr : public QObject, public QtxResourceMgr { + Q_OBJECT; + + class Updater; + public: //! Material type typedef enum { @@ -40,8 +48,24 @@ public: Material_ResourceMgr(); ~Material_ResourceMgr(); + static Material_ResourceMgr* resourceMgr(); + QStringList materials( MaterialType = All, bool = true ); - + +signals: + void changed(); + +private: + void watchUserFile( bool ); + +private slots: + void update(); + +private: + QFileSystemWatcher* myWatcher; + QMutex myMutex; + + friend class Material_Model; }; #endif // MATERIAL_RESOURCEMGR_H diff --git a/src/Material/resources/SalomeMaterial.xml b/src/Material/resources/SalomeMaterial.xml index d1e26882c..6cdcb94a5 100644 --- a/src/Material/resources/SalomeMaterial.xml +++ b/src/Material/resources/SalomeMaterial.xml @@ -23,196 +23,279 @@ -->

    - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + +
    - - - - + + + + + + + +
    - - - - + + + + + + + +
    - - - - + + + + + + + +
    - - - - - - - + + + + + + + + + + + +
    - - - - - + + + + + + + + +
    - - - - - - - - + + + + + + + + + + + +
    - - - - - - - - + + + + + + + + + + + +
    - - - - - - - - + + + + + + + + + + + +
    - - - - - - - - + + + + + + + + + + + +
    - - - - - - - - + + + + + + + + + + + +
    - - - - - - - + + + + + + + + + + +
    - - - - - - - - + + + + + + + + + + + +
    - - - - - - + + + + + + + + + +
    - - - - - - - - + + + + + + + + + + + +
    - - - - - - - - + + + + + + + + + + + +
    - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + +
    - - - - - - - - + + + + + + + + + + + +
    - - - - - - - - + + + + + + + + + + + +
    - - - - - - - - + + + + + + + + + + + +
    diff --git a/src/MeasureGUI/Makefile.am b/src/MeasureGUI/Makefile.am index 55cfcf7a5..c739ca76b 100644 --- a/src/MeasureGUI/Makefile.am +++ b/src/MeasureGUI/Makefile.am @@ -15,7 +15,6 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# # GEOM MEASUREGUI : # File : Makefile.am @@ -95,7 +94,6 @@ UIC_FILES = \ ui_MeasureGUI_1Sel3LineEdit_QTD.h \ ui_MeasureGUI_1Sel6LineEdit_QTD.h \ ui_MeasureGUI_2Sel1LineEdit_QTD.h \ - ui_MeasureGUI_2Sel4LineEdit_QTD.h \ ui_MeasureGUI_SkeletonBox_QTD.h BUILT_SOURCES = $(UIC_FILES) diff --git a/src/MeasureGUI/MeasureGUI_2Sel4LineEdit_QTD.ui b/src/MeasureGUI/MeasureGUI_2Sel4LineEdit_QTD.ui deleted file mode 100644 index d63fb5ab9..000000000 --- a/src/MeasureGUI/MeasureGUI_2Sel4LineEdit_QTD.ui +++ /dev/null @@ -1,189 +0,0 @@ - - MeasureGUI_2Sel4LineEdit_QTD - - - - 0 - 0 - 198 - 197 - - - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - - - - - - - 0 - 0 - - - - TL1 - - - false - - - - - - - - 0 - 0 - - - - - - - - - 100 - 0 - - - - - - - - - 0 - 0 - - - - TL2 - - - false - - - - - - - - 0 - 0 - - - - - - - - - 100 - 0 - - - - - - - - - 0 - 0 - - - - TL3 - - - false - - - - - - - - - - - 0 - 0 - - - - TL4 - - - false - - - - - - - - - - - 0 - 0 - - - - TL5 - - - false - - - - - - - - - - - 0 - 0 - - - - TL6 - - - false - - - - - - - - - - - - - - diff --git a/src/MeasureGUI/MeasureGUI_BndBoxDlg.cxx b/src/MeasureGUI/MeasureGUI_BndBoxDlg.cxx index d3eb0603a..790c0a41c 100644 --- a/src/MeasureGUI/MeasureGUI_BndBoxDlg.cxx +++ b/src/MeasureGUI/MeasureGUI_BndBoxDlg.cxx @@ -35,6 +35,10 @@ #include #include +#include +#include +#include +#include //================================================================================= // class : MeasureGUI_BndBoxDlg() @@ -44,21 +48,23 @@ // true to construct a modal dialog. //================================================================================= MeasureGUI_BndBoxDlg::MeasureGUI_BndBoxDlg (GeometryGUI* GUI, QWidget* parent) - : MeasureGUI_Skeleton(GUI, parent) + : GEOMBase_Skeleton(GUI, parent) { - QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( - "GEOM", tr( "ICON_DLG_BOUNDING_BOX" ) ) ); - QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( - "GEOM", tr( "ICON_SELECT" ) ) ); + QPixmap image0 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_BOUNDING_BOX"))); + QPixmap image1 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT"))); - setWindowTitle( tr( "GEOM_BNDBOX_TITLE" ) ); + setWindowTitle(tr("GEOM_BNDBOX_TITLE")); /***************************************************************/ - mainFrame()->GroupConstructors->setTitle( tr( "GEOM_BNDBOX" ) ); - mainFrame()->RadioButton1->setIcon( image0 ); + mainFrame()->GroupConstructors->setTitle(tr("GEOM_BNDBOX")); + mainFrame()->RadioButton1->setIcon(image0); + mainFrame()->RadioButton2->setAttribute( Qt::WA_DeleteOnClose ); + mainFrame()->RadioButton2->close(); + mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose ); + mainFrame()->RadioButton3->close(); - myGrp = new MeasureGUI_1Sel6LineEdit( centralWidget() ); + myGrp = new MeasureGUI_1Sel6LineEdit (centralWidget()); myGrp->GroupBox1->setTitle( tr( "GEOM_BNDBOX_OBJDIM" ) ); myGrp->TextLabel1->setText( tr( "GEOM_OBJECT" ) ); myGrp->TextLabel2->setText( tr( "GEOM_MIN" ) ); @@ -87,7 +93,7 @@ MeasureGUI_BndBoxDlg::MeasureGUI_BndBoxDlg (GeometryGUI* GUI, QWidget* parent) /***************************************************************/ - myHelpFileName = "using_measurement_tools_page.html#bounding_box_anchor"; + myHelpFileName = "bounding_box_page.html"; /* Initialisation */ Init(); @@ -107,9 +113,66 @@ MeasureGUI_BndBoxDlg::~MeasureGUI_BndBoxDlg() //================================================================================= void MeasureGUI_BndBoxDlg::Init() { - mySelBtn = myGrp->PushButton1; - mySelEdit = myGrp->LineEdit1; - MeasureGUI_Skeleton::Init(); + myEditCurrentArgument = myGrp->LineEdit1; + + connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply())); + connect(myGrp->PushButton1, SIGNAL(clicked()), this, SLOT(SelectionIntoArgument())); + + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); + + initName(tr("GEOM_BNDBOX")); + globalSelection(); + SelectionIntoArgument(); +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void MeasureGUI_BndBoxDlg::ClickOnOk() +{ + if (ClickOnApply()) + ClickOnCancel(); +} + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +bool MeasureGUI_BndBoxDlg::ClickOnApply() +{ + if (!onAccept()) + return false; + + initName(); + return true; +} + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void MeasureGUI_BndBoxDlg::ActivateThisDialog() +{ + GEOMBase_Skeleton::ActivateThisDialog(); + + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); + + globalSelection(); + redisplayPreview(); +} + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void MeasureGUI_BndBoxDlg::enterEvent(QEvent*) +{ + if (!mainFrame()->GroupConstructors->isEnabled()) + ActivateThisDialog(); } //================================================================================= @@ -121,7 +184,7 @@ void MeasureGUI_BndBoxDlg::processObject() double aXMin, aXMax, aYMin, aYMax, aZMin, aZMax; if (!getParameters(aXMin, aXMax, aYMin, aYMax, aZMin, aZMax)) { - mySelEdit->setText(""); + myEditCurrentArgument->setText(""); myGrp->LineEdit11->setText(""); myGrp->LineEdit12->setText(""); myGrp->LineEdit21->setText(""); @@ -177,3 +240,97 @@ SALOME_Prs* MeasureGUI_BndBoxDlg::buildPrs() return !aShape.IsNull() ? getDisplayer()->BuildPrs(aShape) : 0; } + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void MeasureGUI_BndBoxDlg::SelectionIntoArgument() +{ + myEditCurrentArgument->setText(""); + myObj = GEOM::GEOM_Object::_nil(); + + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); + SALOME_ListIO aSelList; + aSelMgr->selectedObjects(aSelList); + + if (aSelList.Extent() != 1) { + processObject(); + erasePreview(); + return; + } + + GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First()); + + if (aSelectedObject->_is_nil()) { + processObject(); + erasePreview(); + return; + } + + myObj = aSelectedObject; + myEditCurrentArgument->setText(GEOMBase::GetName(myObj)); + processObject(); + redisplayPreview(); +} + +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr MeasureGUI_BndBoxDlg::createOperation() +{ + return getGeomEngine()->GetIMeasureOperations(getStudyId()); +} + +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool MeasureGUI_BndBoxDlg::isValid (QString&) +{ + return !myObj->_is_nil(); +} + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool MeasureGUI_BndBoxDlg::execute (ObjectList& objects) +{ + GEOM::GEOM_IMeasureOperations_var anOper = GEOM::GEOM_IMeasureOperations::_narrow(getOperation()); + GEOM::GEOM_Object_var anObj = anOper->MakeBoundingBox(myObj); + + if (!anObj->_is_nil()) + objects.push_back(anObj._retn()); + + return true; +} + +//================================================================================= +// function : redisplayPreview() +// purpose : +//================================================================================= +void MeasureGUI_BndBoxDlg::redisplayPreview() +{ + QString aMess; + if (!isValid(aMess)) { + erasePreview(true); + return; + } + + erasePreview(false); + + try { + SUIT_OverrideCursor(); + + getDisplayer()->SetColor(Quantity_NOC_VIOLET); + getDisplayer()->SetToActivate(false); + + if (SALOME_Prs* aPrs = buildPrs()) + displayPreview(aPrs); + } + catch (const SALOME::SALOME_Exception& e) { + SalomeApp_Tools::QtCatchCorbaException(e); + } +} diff --git a/src/MeasureGUI/MeasureGUI_BndBoxDlg.h b/src/MeasureGUI/MeasureGUI_BndBoxDlg.h index 8fd3af034..e2c5367f8 100644 --- a/src/MeasureGUI/MeasureGUI_BndBoxDlg.h +++ b/src/MeasureGUI/MeasureGUI_BndBoxDlg.h @@ -18,16 +18,15 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// // GEOM GEOMGUI : GUI for Geometry component // File : MeasureGUI_BndBoxDlg.h // Author : Nicolas REJNERI, Open CASCADE S.A.S. -// + #ifndef MEASUREGUI_BNDBOXDLG_H #define MEASUREGUI_BNDBOXDLG_H -#include "MeasureGUI_Skeleton.h" +#include "GEOMBase_Skeleton.h" class MeasureGUI_1Sel6LineEdit; @@ -35,27 +34,38 @@ class MeasureGUI_1Sel6LineEdit; // class : DialogBox_PROPERTIES // purpose : //================================================================================= -class MeasureGUI_BndBoxDlg : public MeasureGUI_Skeleton +class MeasureGUI_BndBoxDlg : public GEOMBase_Skeleton { Q_OBJECT public: - MeasureGUI_BndBoxDlg( GeometryGUI*, QWidget* ); + MeasureGUI_BndBoxDlg (GeometryGUI*, QWidget*); ~MeasureGUI_BndBoxDlg(); protected: - // redefined from GEOMBase_Helper and MeasureGUI_Skeleton - virtual void processObject(); - virtual SALOME_Prs* buildPrs(); + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid (QString&); + virtual bool execute (ObjectList&); + + void redisplayPreview(); + virtual void processObject(); + virtual SALOME_Prs* buildPrs(); private: - void Init(); - bool getParameters( double&, double&, - double&, double&, - double&, double& ); + void Init(); + void enterEvent (QEvent*); + bool getParameters (double&, double&, double&, double&, double&, double&); private: - MeasureGUI_1Sel6LineEdit* myGrp; + GEOM::GEOM_Object_var myObj; + MeasureGUI_1Sel6LineEdit* myGrp; + +private slots: + void ClickOnOk(); + bool ClickOnApply(); + void SelectionIntoArgument(); + void ActivateThisDialog(); }; #endif // MEASUREGUI_BNDBOXDLG_H diff --git a/src/MeasureGUI/MeasureGUI_DistanceDlg.cxx b/src/MeasureGUI/MeasureGUI_DistanceDlg.cxx index ffd630a9a..a49f2789d 100644 --- a/src/MeasureGUI/MeasureGUI_DistanceDlg.cxx +++ b/src/MeasureGUI/MeasureGUI_DistanceDlg.cxx @@ -18,12 +18,11 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// // GEOM GEOMGUI : GUI for Geometry component // File : MeasureGUI_DistanceDlg.cxx // Author : Nicolas REJNERI, Open CASCADE S.A.S. -// + #include "MeasureGUI_DistanceDlg.h" #include "MeasureGUI_Widgets.h" @@ -36,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -61,7 +61,7 @@ // true to construct a modal dialog. //================================================================================= MeasureGUI_DistanceDlg::MeasureGUI_DistanceDlg (GeometryGUI* GUI, QWidget* parent) - : MeasureGUI_Skeleton(GUI, parent) + : GEOMBase_Skeleton(GUI, parent) { SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_MINDIST"))); @@ -72,30 +72,39 @@ MeasureGUI_DistanceDlg::MeasureGUI_DistanceDlg (GeometryGUI* GUI, QWidget* paren /***************************************************************/ mainFrame()->GroupConstructors->setTitle(tr("GEOM_DISTANCE")); mainFrame()->RadioButton1->setIcon(image0); + mainFrame()->RadioButton2->setAttribute(Qt::WA_DeleteOnClose); + mainFrame()->RadioButton2->close(); + mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose); + mainFrame()->RadioButton3->close(); - myGrp = new MeasureGUI_2Sel4LineEdit(centralWidget()); + mainFrame()->GroupBoxName->hide(); + + myGrp = new MeasureGUI_DistanceGroup (centralWidget()); myGrp->GroupBox1->setTitle(tr("GEOM_MINDIST_OBJ")); + + // Arguments myGrp->TextLabel1->setText(tr("GEOM_OBJECT_I").arg("1")); myGrp->TextLabel2->setText(tr("GEOM_OBJECT_I").arg("2")); + myGrp->PushButton1->setIcon(image1); + myGrp->PushButton2->setIcon(image1); + myGrp->LineEdit1->setReadOnly(true); + myGrp->LineEdit2->setReadOnly(true); + + // Solutions combobox + myGrp->TextLabel7->setText(tr("GEOM_SOLUTION")); + + // Distance, dx, dy and dz myGrp->TextLabel3->setText(tr("GEOM_LENGTH")); myGrp->TextLabel4->setText(tr("GEOM_DX")); myGrp->TextLabel5->setText(tr("GEOM_DY")); myGrp->TextLabel6->setText(tr("GEOM_DZ")); myGrp->LineEdit3->setReadOnly(true); - myGrp->PushButton1->setIcon(image1); - myGrp->PushButton2->setIcon(image1); - myGrp->LineEdit1->setReadOnly(true); - myGrp->LineEdit2->setReadOnly(true); myGrp->LineEdit4->setReadOnly(true); myGrp->LineEdit5->setReadOnly(true); myGrp->LineEdit6->setReadOnly(true); - - QVBoxLayout* layout = new QVBoxLayout(centralWidget()); - layout->setMargin(0); layout->setSpacing(6); - layout->addWidget(myGrp); /***************************************************************/ - myHelpFileName = "using_measurement_tools_page.html#min_distance_anchor"; + myHelpFileName = "min_distance_page.html"; // Initialisation Init(); @@ -115,120 +124,139 @@ MeasureGUI_DistanceDlg::~MeasureGUI_DistanceDlg() //================================================================================= void MeasureGUI_DistanceDlg::Init() { - // init variables - myGrp->LineEdit1->setText(""); - myGrp->LineEdit2->setText(""); - myObj = myObj2 = GEOM::GEOM_Object::_nil(); - - mySelBtn = myGrp->PushButton1; - mySelEdit = myGrp->LineEdit1; - myEditCurrentArgument = myGrp->LineEdit1; + myDbls = new GEOM::ListOfDouble(); // signals and slots connections - connect(myGrp->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply())); + + connect(myGrp->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(myGrp->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - MeasureGUI_Skeleton::Init(); + connect(myGrp->ComboBox1, SIGNAL(currentIndexChanged(int)), this, SLOT(SolutionSelected(int))); + + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); + + globalSelection(); + SelectionIntoArgument(); } //================================================================================= -// function : SelectionIntoArgument() -// purpose : Called when selection has changed +// function : ClickOnOk() +// purpose : //================================================================================= -void MeasureGUI_DistanceDlg::SelectionIntoArgument() +void MeasureGUI_DistanceDlg::ClickOnOk() { - LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); - SALOME_ListIO aSelList; - aSelMgr->selectedObjects(aSelList); + if (ClickOnApply()) + ClickOnCancel(); +} - GEOM::GEOM_Object_var aSelectedObject = GEOM::GEOM_Object::_nil(); +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +bool MeasureGUI_DistanceDlg::ClickOnApply() +{ + if (!onAccept()) + return false; - if (aSelList.Extent() > 0) { - aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() ); - } + initName(); + return true; +} + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void MeasureGUI_DistanceDlg::ActivateThisDialog() +{ + GEOMBase_Skeleton::ActivateThisDialog(); - // clear selection - disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); - myGeomGUI->getApp()->selectionMgr()->clearSelected(); connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - if (myEditCurrentArgument == myGrp->LineEdit1) { - myObj = aSelectedObject; - if (!myObj->_is_nil() && myObj2->_is_nil()) - myGrp->PushButton2->click(); - } - else { - myObj2 = aSelectedObject; - if (!myObj2->_is_nil() && myObj->_is_nil()) - myGrp->PushButton1->click(); - } - - processObject(); + globalSelection(); + redisplayPreview(); } //================================================================================= -// function : processObject() -// purpose : Fill dialogs fields in accordance with myObj and myObj2 +// function : enterEvent() +// purpose : //================================================================================= -void MeasureGUI_DistanceDlg::processObject() +void MeasureGUI_DistanceDlg::enterEvent(QEvent*) { - 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)) { - SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); - int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 ); - - myGrp->LineEdit3->setText(DlgRef::PrintDoubleValue(aDist, aPrecision)); - - gp_XYZ aVec = aPnt2.XYZ() - aPnt1.XYZ(); - myGrp->LineEdit4->setText(DlgRef::PrintDoubleValue(aVec.X(), aPrecision)); - myGrp->LineEdit5->setText(DlgRef::PrintDoubleValue(aVec.Y(), aPrecision)); - myGrp->LineEdit6->setText(DlgRef::PrintDoubleValue(aVec.Z(), aPrecision)); + if (!mainFrame()->GroupConstructors->isEnabled()) + ActivateThisDialog(); +} - redisplayPreview(); - } - else { +//================================================================================= +// function : SolutionSelected() +// purpose : Called when ComboBox selection has changed +//================================================================================= +void MeasureGUI_DistanceDlg::SolutionSelected (int i) +{ + if (i < 0 || myDbls->length() < (i+1)*6) { myGrp->LineEdit3->setText(""); myGrp->LineEdit4->setText(""); myGrp->LineEdit5->setText(""); myGrp->LineEdit6->setText(""); erasePreview(); + return; } + + SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); + int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 ); + + gp_Pnt p1 (myDbls[i*6 + 0], myDbls[i*6 + 1], myDbls[i*6 + 2]); + gp_Pnt p2 (myDbls[i*6 + 3], myDbls[i*6 + 4], myDbls[i*6 + 5]); + + double aDist = p1.Distance(p2); + myGrp->LineEdit3->setText(DlgRef::PrintDoubleValue(aDist, aPrecision)); + + gp_XYZ aVec = p2.XYZ() - p1.XYZ(); + myGrp->LineEdit4->setText(DlgRef::PrintDoubleValue(aVec.X(), aPrecision)); + myGrp->LineEdit5->setText(DlgRef::PrintDoubleValue(aVec.Y(), aPrecision)); + myGrp->LineEdit6->setText(DlgRef::PrintDoubleValue(aVec.Z(), aPrecision)); + + redisplayPreview(); } //================================================================================= -// function : getParameters() -// purpose : Get distance between objects +// function : SelectionIntoArgument() +// purpose : Called when selection has changed //================================================================================= -bool MeasureGUI_DistanceDlg::getParameters (double& theDistance, - gp_Pnt& thePnt1, - gp_Pnt& thePnt2) +void MeasureGUI_DistanceDlg::SelectionIntoArgument() { - QString msg; - if (isValid(msg)) { - GEOM::GEOM_IMeasureOperations_var anOper = GEOM::GEOM_IMeasureOperations::_narrow( getOperation() ); + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); + SALOME_ListIO aSelList; + aSelMgr->selectedObjects(aSelList); - try { - double x1, y1, z1, x2, y2, z2; - theDistance = anOper->GetMinDistance(myObj, myObj2, x1, y1, z1, x2, y2, z2); + GEOM::GEOM_Object_var aSelectedObject = GEOM::GEOM_Object::_nil(); - thePnt1.SetCoord(x1, y1, z1); - thePnt2.SetCoord(x2, y2, z2); - } - catch(const SALOME::SALOME_Exception& e) { - SalomeApp_Tools::QtCatchCorbaException(e); - return false; - } + if (aSelList.Extent() > 0) { + aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First()); + } - return anOper->IsDone(); + // clear selection + disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); + myGeomGUI->getApp()->selectionMgr()->clearSelected(); + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); + + if (myEditCurrentArgument == myGrp->LineEdit1) { + myObj1 = aSelectedObject; + if (!myObj1->_is_nil() && myObj2->_is_nil()) + myGrp->PushButton2->click(); + } + else { + myObj2 = aSelectedObject; + if (!myObj2->_is_nil() && myObj1->_is_nil()) + myGrp->PushButton1->click(); } - return false; + processObject(); } //================================================================================= @@ -263,22 +291,41 @@ void MeasureGUI_DistanceDlg::SetEditCurrentArgument() } //================================================================================= -// function : LineEditReturnPressed() -// purpose : +// function : processObject() +// purpose : Fill dialogs fields in accordance with myObj1 and myObj2 //================================================================================= -void MeasureGUI_DistanceDlg::LineEditReturnPressed() +void MeasureGUI_DistanceDlg::processObject() { - QLineEdit* send = (QLineEdit*)sender(); + myGrp->LineEdit1->setText(!myObj1->_is_nil() ? GEOMBase::GetName(myObj1) : ""); + myGrp->LineEdit2->setText(!myObj2->_is_nil() ? GEOMBase::GetName(myObj2) : ""); + + myGrp->ComboBox1->clear(); + myDbls->length(0); + erasePreview(); - if (send == myGrp->LineEdit1 || send == myGrp->LineEdit2) { - myEditCurrentArgument = send; + int nbSols = 0; + + QString msg; + if (!isValid(msg)) return; - LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); - SALOME_ListIO aSelList; - aSelMgr->selectedObjects(aSelList); + GEOM::GEOM_IMeasureOperations_var anOper = GEOM::GEOM_IMeasureOperations::_narrow(getOperation()); + try { + nbSols = anOper->ClosestPoints(myObj1, myObj2, myDbls); + } + catch (const SALOME::SALOME_Exception& e) { + SalomeApp_Tools::QtCatchCorbaException(e); + return; + } - if (GEOMBase::SelectionByNameInDialogs(this, myGrp->LineEdit1->text(), aSelList)) - myGrp->LineEdit1->setText(myGrp->LineEdit1->text()); + if (!anOper->IsDone()) + myGrp->ComboBox1->addItem(tr(anOper->GetErrorCode())); + else if (nbSols <= 0) + myGrp->ComboBox1->addItem(tr("GEOM_MINDIST_NO_SOL")); + else { + for (int i = 0; i < nbSols; i++) { + myGrp->ComboBox1->addItem(tr("GEOM_SOLUTION_I").arg(i + 1)); + } + myGrp->ComboBox1->setCurrentIndex(0); } } @@ -288,47 +335,52 @@ void MeasureGUI_DistanceDlg::LineEditReturnPressed() //================================================================================= SALOME_Prs* MeasureGUI_DistanceDlg::buildPrs() { - double aDist = 0.; - gp_Pnt aPnt1(0, 0, 0), aPnt2(0, 0, 0); - SUIT_ViewWindow* vw = SUIT_Session::session()->activeApplication()->desktop()->activeWindow(); - if (myObj->_is_nil() || myObj2->_is_nil() || - !getParameters(aDist, aPnt1, aPnt2) || - vw->getViewManager()->getType() != OCCViewer_Viewer::Type()) + int currSol = myGrp->ComboBox1->currentIndex(); + + if (myObj1->_is_nil() || myObj2->_is_nil() || + currSol == -1 || (currSol+1)*6 > myDbls->length() || + vw->getViewManager()->getType() != OCCViewer_Viewer::Type()) return 0; + gp_Pnt aPnt1 (myDbls[currSol*6 + 0], myDbls[currSol*6 + 1], myDbls[currSol*6 + 2]); + gp_Pnt aPnt2 (myDbls[currSol*6 + 3], myDbls[currSol*6 + 4], myDbls[currSol*6 + 5]); + + double aDist = aPnt1.Distance(aPnt2); + try { if (aDist <= 1.e-9) { - BRepBuilderAPI_MakeVertex aMaker(aPnt1); + BRepBuilderAPI_MakeVertex aMaker (aPnt1); return getDisplayer()->BuildPrs(aMaker.Vertex()); } else { - BRepBuilderAPI_MakeEdge MakeEdge(aPnt1, aPnt2); + BRepBuilderAPI_MakeEdge MakeEdge (aPnt1, aPnt2); TopoDS_Vertex aVert1 = BRepBuilderAPI_MakeVertex(aPnt1); TopoDS_Vertex aVert2 = BRepBuilderAPI_MakeVertex(aPnt2); QString aLabel; aLabel.sprintf("%.1f", aDist); - gp_Pnt aPnt3((aPnt1.X() + aPnt2.X()) / 2, + gp_Pnt aPnt3 ((aPnt1.X() + aPnt2.X()) / 2, (aPnt1.Y() + aPnt2.Y()) / 2, (aPnt1.Z() + aPnt2.Z()) / 2); - gp_Vec va(aPnt3, aPnt1); - gp_Vec vb(aPnt3, aPnt2); + gp_Vec va (aPnt3, aPnt1); + gp_Vec vb (aPnt3, aPnt2); 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()); + gce_MakePln gce_MP (aPnt1, aPnt2, aPnt3); + Handle(Geom_Plane) P = new Geom_Plane (gce_MP.Value()); - Handle(AIS_LengthDimension) anIO = new AIS_LengthDimension( - aVert1, aVert2, P, aDist, TCollection_ExtendedString((Standard_CString)aLabel.toLatin1().constData())); + Handle(AIS_LengthDimension) anIO = new AIS_LengthDimension + (aVert1, aVert2, P, aDist, + TCollection_ExtendedString((Standard_CString)aLabel.toLatin1().constData())); anIO->SetArrowSize(aDist/20); SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); @@ -345,16 +397,172 @@ SALOME_Prs* MeasureGUI_DistanceDlg::buildPrs() return aPrs; } } - catch(Standard_Failure) { + catch (Standard_Failure) { return 0; } } +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr MeasureGUI_DistanceDlg::createOperation() +{ + return getGeomEngine()->GetIMeasureOperations(getStudyId()); +} + //================================================================================= // function : isValid() // purpose : //================================================================================= bool MeasureGUI_DistanceDlg::isValid (QString& msg) { - return MeasureGUI_Skeleton::isValid(msg) && !myObj2->_is_nil(); + return !myObj1->_is_nil() && !myObj2->_is_nil(); +} + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool MeasureGUI_DistanceDlg::execute (ObjectList& objects) +{ + GEOM::GEOM_IMeasureOperations_var anOper = GEOM::GEOM_IMeasureOperations::_narrow(getOperation()); + GEOM::GEOM_IBasicOperations_var aBasicOper = getGeomEngine()->GetIBasicOperations(getStudyId()); + + GEOM::ListOfDouble_var aDbls; + int nbSols = anOper->ClosestPoints(myObj1, myObj2, aDbls); + + if (anOper->IsDone()) { + for (int i = 0; i < nbSols; i++) { + GEOM::GEOM_Object_var anObj1 = aBasicOper->MakePointXYZ(aDbls[i*6 + 0], aDbls[i*6 + 1], aDbls[i*6 + 2]); + GEOM::GEOM_Object_var anObj2 = aBasicOper->MakePointXYZ(aDbls[i*6 + 3], aDbls[i*6 + 4], aDbls[i*6 + 5]); + + if (!anObj1->_is_nil() && !anObj2->_is_nil()) { + objects.push_back(anObj1._retn()); + objects.push_back(anObj2._retn()); + } + } + } + + return true; +} + +//================================================================================= +// function : redisplayPreview() +// purpose : +//================================================================================= +void MeasureGUI_DistanceDlg::redisplayPreview() +{ + QString aMess; + if (!isValid(aMess)) { + erasePreview(true); + return; + } + + erasePreview(false); + + try { + SUIT_OverrideCursor(); + + getDisplayer()->SetColor(Quantity_NOC_VIOLET); + getDisplayer()->SetToActivate(false); + + if (SALOME_Prs* aPrs = buildPrs()) + displayPreview(aPrs); + } + catch (const SALOME::SALOME_Exception& e) { + SalomeApp_Tools::QtCatchCorbaException(e); + } +} + +//================================================================ +// Function : getNewObjectName +// Purpose : Redefine this method to return proper name for a new object +//================================================================ +QString MeasureGUI_DistanceDlg::getNewObjectName (int currObj) const +{ + QString aName = tr("GEOM_MINDIST_NAME") + QString("_%1_").arg((currObj+1)/2); + aName += GEOMBase::GetName(currObj%2 ? myObj1 : myObj2); + + return aName; +} + +//================================================================================= +// function : MeasureGUI_DistanceGroup +// purpose : +//================================================================================= +MeasureGUI_DistanceGroup::MeasureGUI_DistanceGroup (QWidget *parent) +{ + gridLayout = new QGridLayout (parent); + gridLayout->setSpacing(6); + gridLayout->setContentsMargins(11, 11, 11, 11); + gridLayout->setHorizontalSpacing(0); + gridLayout->setVerticalSpacing(0); + gridLayout->setContentsMargins(0, 0, 0, 0); + + GroupBox1 = new QGroupBox (parent); + + gridLayout1 = new QGridLayout (GroupBox1); + gridLayout1->setSpacing(6); + gridLayout1->setContentsMargins(11, 11, 11, 11); + gridLayout1->setHorizontalSpacing(6); + gridLayout1->setVerticalSpacing(6); + gridLayout1->setContentsMargins(9, 9, 9, 9); + + // 2Sel + TextLabel1 = new QLabel(GroupBox1); + TextLabel2 = new QLabel(GroupBox1); + + PushButton1 = new QPushButton (GroupBox1); + PushButton2 = new QPushButton (GroupBox1); + + LineEdit1 = new QLineEdit(GroupBox1); + LineEdit2 = new QLineEdit(GroupBox1); + + gridLayout1->addWidget(TextLabel1, 0, 0, 1, 1); + gridLayout1->addWidget(TextLabel2, 1, 0, 1, 1); + gridLayout1->addWidget(PushButton1, 0, 1, 1, 1); + gridLayout1->addWidget(PushButton2, 1, 1, 1, 1); + gridLayout1->addWidget(LineEdit1, 0, 2, 1, 1); + gridLayout1->addWidget(LineEdit2, 1, 2, 1, 1); + + // 1Combo + TextLabel7 = new QLabel (GroupBox1); + + ComboBox1 = new QComboBox (GroupBox1); + + gridLayout1->addWidget(TextLabel7, 2, 0, 1, 1); + gridLayout1->addWidget(ComboBox1, 2, 1, 1, 2); + + // 4Text + TextLabel3 = new QLabel (GroupBox1); + TextLabel4 = new QLabel (GroupBox1); + TextLabel5 = new QLabel (GroupBox1); + TextLabel6 = new QLabel (GroupBox1); + + LineEdit3 = new QLineEdit(GroupBox1); + LineEdit4 = new QLineEdit(GroupBox1); + LineEdit5 = new QLineEdit(GroupBox1); + LineEdit6 = new QLineEdit(GroupBox1); + + gridLayout1->addWidget(TextLabel3, 3, 0, 1, 1); + gridLayout1->addWidget(TextLabel4, 4, 0, 1, 1); + gridLayout1->addWidget(TextLabel5, 5, 0, 1, 1); + gridLayout1->addWidget(TextLabel6, 6, 0, 1, 1); + + gridLayout1->addWidget(LineEdit3, 3, 1, 1, 2); + gridLayout1->addWidget(LineEdit4, 4, 1, 1, 2); + gridLayout1->addWidget(LineEdit5, 5, 1, 1, 2); + gridLayout1->addWidget(LineEdit6, 6, 1, 1, 2); + + gridLayout->addWidget(GroupBox1, 0, 0, 1, 1); +} + +//================================================================================= +// function : ~MeasureGUI_DistanceGroup() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +MeasureGUI_DistanceGroup::~MeasureGUI_DistanceGroup() +{ + // no need to delete child widgets, Qt does it all for us } diff --git a/src/MeasureGUI/MeasureGUI_DistanceDlg.h b/src/MeasureGUI/MeasureGUI_DistanceDlg.h index 2c4e9c56d..9f4c7992c 100644 --- a/src/MeasureGUI/MeasureGUI_DistanceDlg.h +++ b/src/MeasureGUI/MeasureGUI_DistanceDlg.h @@ -18,54 +18,110 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// // GEOM GEOMGUI : GUI for Geometry component // File : MeasureGUI_DistanceDlg.h // Author : Nicolas REJNERI, Open CASCADE S.A.S. -// + #ifndef MEASUREGUI_DISTANCEDLG_H #define MEASUREGUI_DISTANCEDLG_H -#include "MeasureGUI_Skeleton.h" +#include + +// IDL Headers +#include +#include CORBA_SERVER_HEADER(GEOM_Gen) + +#include +#include +#include +#include +#include +#include -class MeasureGUI_2Sel4LineEdit; class gp_Pnt; //================================================================================= -// class : MeasureGUI_DistanceDlg +// class : MeasureGUI_DistanceGroup // purpose : //================================================================================= +class MeasureGUI_DistanceGroup : public QWidget +{ + Q_OBJECT + + public: + MeasureGUI_DistanceGroup (QWidget *parent); + ~MeasureGUI_DistanceGroup(); + + public: + QGridLayout *gridLayout; + QGroupBox *GroupBox1; + QGridLayout *gridLayout1; + + // 2Sel + QLabel *TextLabel1; + QLabel *TextLabel2; + QPushButton *PushButton1; + QPushButton *PushButton2; + QLineEdit *LineEdit1; + QLineEdit *LineEdit2; + + // 1Combo + QLabel *TextLabel7; + QComboBox *ComboBox1; -class MeasureGUI_DistanceDlg : public MeasureGUI_Skeleton -{ + // 4Text + QLabel *TextLabel3; + QLabel *TextLabel4; + QLabel *TextLabel5; + QLabel *TextLabel6; + QLineEdit *LineEdit3; + QLineEdit *LineEdit4; + QLineEdit *LineEdit5; + QLineEdit *LineEdit6; +}; + +//================================================================================= +// class : MeasureGUI_DistanceDlg +// purpose : +//================================================================================= +class MeasureGUI_DistanceDlg : public GEOMBase_Skeleton +{ Q_OBJECT - + public: - MeasureGUI_DistanceDlg( GeometryGUI*, QWidget* ); + MeasureGUI_DistanceDlg (GeometryGUI*, QWidget*); ~MeasureGUI_DistanceDlg(); protected: - // redefined from GEOMBase_Helper and MeasureGUI_Skeleton + // redefined from GEOMBase_Helper and GEOMBase_Skeleton + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid (QString&); + virtual bool execute (ObjectList&); + virtual QString getNewObjectName (int CurrObj = -1) const; + + void redisplayPreview(); virtual void processObject(); virtual SALOME_Prs* buildPrs(); - virtual void SelectionIntoArgument(); - virtual void LineEditReturnPressed(); - virtual void SetEditCurrentArgument(); - virtual bool isValid( QString& ); private: void Init(); - bool getParameters( double&, - gp_Pnt&, - gp_Pnt& ); + void enterEvent (QEvent*); + private: - QLineEdit* myEditCurrentArgument; - QLineEdit* mySelEdit2; - QPushButton* mySelBtn2; - - MeasureGUI_2Sel4LineEdit* myGrp; + GEOM::GEOM_Object_var myObj1; GEOM::GEOM_Object_var myObj2; + + MeasureGUI_DistanceGroup* myGrp; + GEOM::ListOfDouble_var myDbls; + +private slots: + void ClickOnOk(); + bool ClickOnApply(); + void ActivateThisDialog(); + void SelectionIntoArgument(); + void SetEditCurrentArgument(); + void SolutionSelected (int i); }; #endif // MEASUREGUI_DISTANCEDLG_H diff --git a/src/MeasureGUI/MeasureGUI_Widgets.cxx b/src/MeasureGUI/MeasureGUI_Widgets.cxx index 5cb2936fd..d9b93cf1e 100644 --- a/src/MeasureGUI/MeasureGUI_Widgets.cxx +++ b/src/MeasureGUI/MeasureGUI_Widgets.cxx @@ -15,11 +15,10 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// // File : MeasureGUI_Widgets.cxx // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) -// + #include "MeasureGUI_Widgets.h" ////////////////////////////////////////// @@ -121,20 +120,6 @@ MeasureGUI_2Sel1LineEdit::~MeasureGUI_2Sel1LineEdit() { } -////////////////////////////////////////// -// MeasureGUI_2Sel4LineEdit -////////////////////////////////////////// - -MeasureGUI_2Sel4LineEdit::MeasureGUI_2Sel4LineEdit( QWidget* parent, Qt::WindowFlags f ) -: QWidget( parent, f ) -{ - setupUi( this ); -} - -MeasureGUI_2Sel4LineEdit::~MeasureGUI_2Sel4LineEdit() -{ -} - ////////////////////////////////////////// // MeasureGUI_SkeletonBox ////////////////////////////////////////// diff --git a/src/MeasureGUI/MeasureGUI_Widgets.h b/src/MeasureGUI/MeasureGUI_Widgets.h index 17067d067..651b65298 100644 --- a/src/MeasureGUI/MeasureGUI_Widgets.h +++ b/src/MeasureGUI/MeasureGUI_Widgets.h @@ -15,11 +15,10 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// // File : MeasureGUI_Widgets.h // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) -// + #ifndef MEASUREGUI_WIDGETS_H #define MEASUREGUI_WIDGETS_H @@ -135,22 +134,6 @@ public: ~MeasureGUI_2Sel1LineEdit(); }; -////////////////////////////////////////// -// MeasureGUI_2Sel4LineEdit -////////////////////////////////////////// - -#include "ui_MeasureGUI_2Sel4LineEdit_QTD.h" - -class MeasureGUI_2Sel4LineEdit : public QWidget, - public Ui::MeasureGUI_2Sel4LineEdit_QTD -{ - Q_OBJECT - -public: - MeasureGUI_2Sel4LineEdit( QWidget* = 0, Qt::WindowFlags = 0 ); - ~MeasureGUI_2Sel4LineEdit(); -}; - ////////////////////////////////////////// // MeasureGUI_SkeletonBox ////////////////////////////////////////// diff --git a/src/OBJECT/GEOM_AISShape.cxx b/src/OBJECT/GEOM_AISShape.cxx index 4b5b686e4..63e8d187b 100644 --- a/src/OBJECT/GEOM_AISShape.cxx +++ b/src/OBJECT/GEOM_AISShape.cxx @@ -166,7 +166,6 @@ GEOM_AISShape::GEOM_AISShape(const TopoDS_Shape& shape, myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial(aMatAspect); myDrawer->ShadingAspect()->Aspect()->SetBackMaterial(aMatAspect); } - myCurrentMaterial = myDrawer->ShadingAspect()->Aspect()->FrontMaterial(); } void GEOM_AISShape::setIO(const Handle(SALOME_InteractiveObject)& io){ @@ -206,7 +205,7 @@ void GEOM_AISShape::Compute(const Handle(PrsMgr_PresentationManager3d)& aPresent Handle(AIS_InteractiveContext) anIC = GetContext(); // StdSelect_DisplayMode d = (StdSelect_DisplayMode) aMode; - bool isTopLev = (isTopLevel() && topLevelDisplayMode() != TopShowAdditionalWActor); + bool isTopLev = isTopLevel() && switchTopLevel(); switch (aMode) { case 0://StdSelect_DM_Wireframe: { @@ -316,24 +315,6 @@ void GEOM_AISShape::Compute(const Handle(PrsMgr_PresentationManager3d)& aPresent // aPrs->ReCompute(); // for hidden line recomputation if necessary... } -void GEOM_AISShape::SetTransparency(const Standard_Real aValue) -{ - if(aValue<0.0 || aValue>1.0) return; - - if(aValue<=0.05) - { - UnsetTransparency(); - return; - } - - Graphic3d_MaterialAspect FMat = myDrawer->ShadingAspect()->Aspect()->FrontMaterial(); - FMat.SetTransparency(aValue); - myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial(FMat); - myDrawer->ShadingAspect()->Aspect()->SetBackMaterial(FMat); - myCurrentMaterial = FMat; - myTransparency = aValue; -} - void GEOM_AISShape::SetShadingColor(const Quantity_Color &aCol) { myShadingColor = aCol; @@ -387,16 +368,13 @@ void GEOM_AISShape::shadingMode(const Handle(PrsMgr_PresentationManager3d)& aPre myDrawer->ShadingAspect()->Aspect()->SetDistinguishOn(); Graphic3d_MaterialAspect aMatAspect(Graphic3d_NOM_PLASTIC); - aMatAspect.SetTransparency(myTransparency); - myCurrentMaterial = myDrawer->ShadingAspect()->Aspect()->FrontMaterial(); - myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial( isTopLevel() ? aMatAspect : myCurrentMaterial ); - myDrawer->ShadingAspect()->Aspect()->SetBackMaterial( isTopLevel() ? aMatAspect : myCurrentMaterial ); - - //Handle(Graphic3d_AspectFillArea3d) a4bis = myDrawer->ShadingAspect()->Aspect(); - // P->SetPrimitivesAspect(a4bis); - // G->SetGroupPrimitivesAspect(a4bis); - //a4bis->SetInteriorColor(myShadingColor); - if( isTopLevel() && topLevelDisplayMode() != TopShowAdditionalWActor ) + aMatAspect.SetTransparency(Transparency()); + Graphic3d_MaterialAspect currentFrontMaterial = myDrawer->ShadingAspect()->Aspect()->FrontMaterial(); + Graphic3d_MaterialAspect currentBackMaterial = myDrawer->ShadingAspect()->Aspect()->BackMaterial(); + myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial( isTopLevel() ? aMatAspect : currentFrontMaterial ); + myDrawer->ShadingAspect()->Aspect()->SetBackMaterial ( isTopLevel() ? aMatAspect : currentBackMaterial ); + + if( isTopLevel() && switchTopLevel() ) myDrawer->ShadingAspect()->SetColor( topLevelColor() ); else { if(myDrawer->ShadingAspect()->Aspect()->FrontMaterial().MaterialType( Graphic3d_MATERIAL_ASPECT )) diff --git a/src/OBJECT/GEOM_AISShape.hxx b/src/OBJECT/GEOM_AISShape.hxx index eec1ef7bf..5bd38ac77 100644 --- a/src/OBJECT/GEOM_AISShape.hxx +++ b/src/OBJECT/GEOM_AISShape.hxx @@ -116,7 +116,6 @@ public: void highlightSubShapes(const TColStd_IndexedMapOfInteger& aIndexMap, const Standard_Boolean aHighlight ); ~GEOM_AISShape(); - void SetTransparency(const Standard_Real aValue); void SetShadingColor(const Quantity_Color &aCol); void SetEdgesInShadingColor(const Quantity_Color &aCol); void SetDisplayVectors(bool isShow); @@ -172,7 +171,6 @@ private: TCollection_AsciiString myName; bool myDisplayVectors; Standard_Boolean myTopLevel; - Graphic3d_MaterialAspect myCurrentMaterial; Standard_Integer myPrevDisplayMode; static TopLevelDispMode myTopLevelDm; diff --git a/src/OBJECT/GEOM_AISVector.cxx b/src/OBJECT/GEOM_AISVector.cxx index 051b875cc..542837d39 100644 --- a/src/OBJECT/GEOM_AISVector.cxx +++ b/src/OBJECT/GEOM_AISVector.cxx @@ -23,7 +23,6 @@ // GEOM OBJECT : interactive object for Geometry entities visualization // File : GEOM_AISVector.cxx // Author : Julia DOROVSKIKH -// $Header$ // #include diff --git a/src/OBJECT/GEOM_Actor.cxx b/src/OBJECT/GEOM_Actor.cxx index a68e25b0e..1552ee794 100644 --- a/src/OBJECT/GEOM_Actor.cxx +++ b/src/OBJECT/GEOM_Actor.cxx @@ -24,7 +24,6 @@ // File : GEOM_Actor.cxx // Author : Christophe ATTANASIO // Module : GEOM -// $Header$ // /*! \class GEOM_Actor GEOM_Actor.h @@ -113,7 +112,8 @@ GEOM_Actor::GEOM_Actor(): myHighlightProp(vtkProperty::New()), myPreHighlightProp(vtkProperty::New()), - myShadingFaceProp(vtkProperty::New()) + myShadingFaceProp(vtkProperty::New()), + myShadingBackFaceProp(vtkProperty::New()) { #ifdef MYDEBUG MESSAGE (this<< " GEOM_Actor::GEOM_Actor"); @@ -150,19 +150,22 @@ GEOM_Actor::GEOM_Actor(): myIsolatedEdgeActor->SetInput(myIsolatedEdgeSource->GetOutput(),false); aProperty = myIsolatedEdgeActor->GetProperty(); aProperty->SetRepresentation(VTK_WIREFRAME); - aProperty->SetColor(1, 0, 0); + myIsolatedEdgeColor[0] = 1; myIsolatedEdgeColor[1] = 0; myIsolatedEdgeColor[2] = 0; + aProperty->SetColor(myIsolatedEdgeColor[0], myIsolatedEdgeColor[1], myIsolatedEdgeColor[2]); myAppendFilter->AddInput(myOneFaceEdgeSource->GetOutput()); myOneFaceEdgeActor->SetInput(myOneFaceEdgeSource->GetOutput(),false); aProperty = myOneFaceEdgeActor->GetProperty(); aProperty->SetRepresentation(VTK_WIREFRAME); - aProperty->SetColor(0, 1, 0); + myOneFaceEdgeColor[0] = 0; myOneFaceEdgeColor[1] = 1; myOneFaceEdgeColor[2] = 0; + aProperty->SetColor(myOneFaceEdgeColor[0], myOneFaceEdgeColor[1], myOneFaceEdgeColor[2]); myAppendFilter->AddInput(mySharedEdgeSource->GetOutput()); mySharedEdgeActor->SetInput(mySharedEdgeSource->GetOutput(),false); aProperty = mySharedEdgeActor->GetProperty(); aProperty->SetRepresentation(VTK_WIREFRAME); - aProperty->SetColor(1, 1, 0); + mySharedEdgeColor[0] = 1; mySharedEdgeColor[1] = 1; mySharedEdgeColor[2] = 0; + aProperty->SetColor(mySharedEdgeColor[0], mySharedEdgeColor[1], mySharedEdgeColor[2]); myAppendFilter->AddInput(myWireframeFaceSource->GetOutput()); myWireframeFaceActor->SetInput(myWireframeFaceSource->GetOutput(),false); @@ -183,8 +186,6 @@ GEOM_Actor::GEOM_Actor(): myShadingFaceActor->SetProperty(myShadingFaceProp.GetPointer()); - StoreBoundaryColors(); - myNbIsos[0] = -1; myNbIsos[1] = -1; @@ -202,6 +203,7 @@ GEOM_Actor::~GEOM_Actor() myHighlightProp->Delete(); myPreHighlightProp->Delete(); myShadingFaceProp->Delete(); + myShadingBackFaceProp->Delete(); } GEOM_Actor* @@ -295,40 +297,42 @@ setDisplayMode(int theMode) MESSAGE ( "GEOM_Actor::setDisplayMode = "<GetProperty()->SetColor(myEdgesInShadingColor[0], - myEdgesInShadingColor[1], - myEdgesInShadingColor[2]); - myOneFaceEdgeActor->GetProperty()->SetColor(myEdgesInShadingColor[0], - myEdgesInShadingColor[1], - myEdgesInShadingColor[2]); - mySharedEdgeActor->GetProperty()->SetColor(myEdgesInShadingColor[0], + if ( theMode == (int)eShadingWithEdges ) { + // Coloring edges + myIsolatedEdgeActor->GetProperty()->SetColor(myEdgesInShadingColor[0], myEdgesInShadingColor[1], myEdgesInShadingColor[2]); - //SetModified(); - } else { - myIsolatedEdgeActor->GetProperty()->SetColor(myEdgesInWireframeColor[0], - myEdgesInWireframeColor[1], - myEdgesInWireframeColor[2]); - } + myOneFaceEdgeActor->GetProperty()->SetColor(myEdgesInShadingColor[0], + myEdgesInShadingColor[1], + myEdgesInShadingColor[2]); + mySharedEdgeActor->GetProperty()->SetColor(myEdgesInShadingColor[0], + myEdgesInShadingColor[1], + myEdgesInShadingColor[2]); + } + else { + // Restore number of iso-lines + RestoreIsoNumbers(); + + // Coloring edges + myIsolatedEdgeActor->GetProperty()->SetColor(myIsolatedEdgeColor[0], + myIsolatedEdgeColor[1], + myIsolatedEdgeColor[2]); + mySharedEdgeActor->GetProperty()->SetColor(myIsolatedEdgeColor[0], + myIsolatedEdgeColor[1], + myIsolatedEdgeColor[2]); + myOneFaceEdgeActor->GetProperty()->SetColor(myOneFaceEdgeColor[0], + myOneFaceEdgeColor[1], + myOneFaceEdgeColor[2]); } VTKViewer_Actor::setDisplayMode(theMode); @@ -501,6 +505,26 @@ vtkProperty* GEOM_Actor::GetWireframeProperty() return myWireframeFaceActor->GetProperty(); } +vtkProperty* GEOM_Actor::GetIsolatedEdgeProperty() +{ + return myIsolatedEdgeActor->GetProperty(); +} + +vtkProperty* GEOM_Actor::GetVertexProperty() +{ + return myVertexActor->GetProperty(); +} + +vtkProperty* GEOM_Actor::GetSharedEdgeProperty() +{ + return mySharedEdgeActor->GetProperty(); +} + +vtkProperty* GEOM_Actor::GetFaceEdgeProperty() +{ + return myOneFaceEdgeActor->GetProperty(); +} + void GEOM_Actor::SetShadingProperty(vtkProperty* Prop) { #ifdef MYDEBUG @@ -547,6 +571,7 @@ void GEOM_Actor::Render(vtkRenderer *ren, vtkMapper *theMapper) myPreHighlightProp->SetRepresentationToSurface(); myHighlightProp->SetRepresentationToSurface(); myShadingFaceProp->SetRepresentationToSurface(); + myShadingBackFaceProp->SetRepresentationToSurface(); break; } @@ -554,14 +579,17 @@ void GEOM_Actor::Render(vtkRenderer *ren, vtkMapper *theMapper) if(myIsPreselected){ this->myHighlightActor->SetProperty(myPreHighlightProp.GetPointer()); myShadingFaceActor->SetProperty(myPreHighlightProp.GetPointer()); + myShadingFaceActor->SetBackfaceProperty(myPreHighlightProp.GetPointer()); } else { this->myHighlightActor->SetProperty(myShadingFaceProp.GetPointer()); myShadingFaceActor->SetProperty(myShadingFaceProp.GetPointer()); + myShadingFaceActor->SetBackfaceProperty(myShadingBackFaceProp.GetPointer()); } } else{ this->myHighlightActor->SetProperty(myHighlightProp.GetPointer()); myShadingFaceActor->SetProperty(myHighlightProp.GetPointer()); + myShadingFaceActor->SetBackfaceProperty(myHighlightProp.GetPointer()); } this->Property->Render(this, ren); @@ -672,6 +700,7 @@ void GEOM_Actor::SetOpacity(vtkFloatingPointType opa) { // enk:tested OK myShadingFaceProp->SetOpacity(opa); + myShadingBackFaceProp->SetOpacity(opa); myHighlightProp->SetOpacity(opa); myPreHighlightProp->SetOpacity(opa); myVertexActor->GetProperty()->SetOpacity(opa); @@ -685,21 +714,22 @@ vtkFloatingPointType GEOM_Actor::GetOpacity() void GEOM_Actor::SetColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b) { - // enk:tested OK - myShadingFaceProp->SetColor(r,g,b); // shading color (Shading) - myVertexActor->GetProperty()->SetColor(r,g,b); // vertex actor (Shading/Wireframe) - if ( myDisplayMode != (int)eShadingWithEdges ) { - myIsolatedEdgeActor->GetProperty()->SetColor(r,g,b); // standalone edge color (Wireframe) - myOneFaceEdgeActor->GetProperty()->SetColor(r,g,b); // standalone face edge color (Wireframe) - mySharedEdgeActor->GetProperty()->SetColor(r,g,b); // share edge color (Wireframe) - } - - StoreBoundaryColors(); + // set the same color to all sub-actors: + // - points + // - standalone edges + // - shared edges + // - free edges + // - shading color (front and back faces) + SetPointColor(r, g, b); + SetIsolatedEdgeColor(r, g, b); + SetSharedEdgeColor(r, g, b); + SetFreeEdgeColor(r, g, b); + myShadingFaceProp->SetColor(r,g,b); // shading color + myShadingBackFaceProp->SetColor(r,g,b); // back face shading color } void GEOM_Actor::GetColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b) { - // enk:tested OK vtkFloatingPointType aRGB[3]; myShadingFaceProp->GetColor(aRGB); r = aRGB[0]; @@ -707,25 +737,97 @@ void GEOM_Actor::GetColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFlo b = aRGB[2]; } +/*! + \brief Set color of points + Points actor is shown in Wireframe mode only, see SetVisibility() +*/ +void GEOM_Actor::SetPointColor(vtkFloatingPointType r, vtkFloatingPointType g, vtkFloatingPointType b) +{ + myVertexActor->GetProperty()->SetColor(r, g, b); +} + +/*! + \brief Set color of standalone edges, wires, vectors + This actor is shown in all display mode, see SetVisibility() + TODO: check - this color seems to be used not only for standalone edges +*/ +void GEOM_Actor::SetIsolatedEdgeColor(vtkFloatingPointType r, vtkFloatingPointType g, vtkFloatingPointType b) +{ + myIsolatedEdgeColor[0] = r; myIsolatedEdgeColor[1] = g; myIsolatedEdgeColor[2] = b; + if ( myDisplayMode != (int)eShadingWithEdges ) + myIsolatedEdgeActor->GetProperty()->SetColor(r, g, b); +} + +/*! + \brief Set color of shared edges + This actor is shown only in wireframe and shading+edges display modes, see SetVisibility() + TODO: check - this seems to be not working currently +*/ +void GEOM_Actor::SetSharedEdgeColor(vtkFloatingPointType r, vtkFloatingPointType g, vtkFloatingPointType b) +{ + mySharedEdgeColor[0] = r; mySharedEdgeColor[1] = g; mySharedEdgeColor[2] = b; + if ( myDisplayMode != (int)eShadingWithEdges ) + mySharedEdgeActor->GetProperty()->SetColor(r, g, b); +} + +/*! + \brief Set color of edges for standalone faces + This actor is shown only in wireframe and shading+edges display modes, see SetVisibility() + TODO: this color should be used not only for faces +*/ +void GEOM_Actor::SetFreeEdgeColor(vtkFloatingPointType r, vtkFloatingPointType g, vtkFloatingPointType b) +{ + myOneFaceEdgeColor[0] = r; myOneFaceEdgeColor[1] = g; myOneFaceEdgeColor[2] = b; + if ( myDisplayMode != (int)eShadingWithEdges ) + myOneFaceEdgeActor->GetProperty()->SetColor(r, g, b); +} + +/*! + \brief Set color of iso-lines + This actor is shown only in wireframe display mode, see SetVisibility() +*/ +void GEOM_Actor::SetIsosColor(vtkFloatingPointType r, vtkFloatingPointType g, vtkFloatingPointType b) +{ + myWireframeFaceActor->GetProperty()->SetColor(r, g, b); +} + void GEOM_Actor::SetMaterial(std::vector theProps) { // we set material properties as back and front material + int aSize = theProps.size(); + + if ( aSize < 1 || aSize > 2) + return; + + // theProps[0] -- front material properties + // theProps[1] -- back material properties (if exist) + double aCoefnt; // Set reflection coefficients aCoefnt = theProps[0]->GetAmbient(); myShadingFaceProp->SetAmbient(aCoefnt); myVertexActor->GetProperty()->SetAmbient(aCoefnt); + if ( aSize == 2 ) + aCoefnt = theProps[1]->GetAmbient(); + myShadingBackFaceProp->SetAmbient(aCoefnt); // Set diffuse coefficients aCoefnt = theProps[0]->GetDiffuse(); myShadingFaceProp->SetDiffuse(aCoefnt); myVertexActor->GetProperty()->SetDiffuse(aCoefnt); + if ( aSize == 2 ) + aCoefnt = theProps[1]->GetDiffuse(); + myShadingBackFaceProp->SetDiffuse(aCoefnt); // Set specular coefficients aCoefnt = theProps[0]->GetSpecular(); myShadingFaceProp->SetSpecular(aCoefnt); myVertexActor->GetProperty()->SetSpecular(aCoefnt); + if ( aSize == 2 ) + aCoefnt = theProps[1]->GetSpecular(); + myShadingBackFaceProp->SetSpecular(aCoefnt); + double* aColor; @@ -733,28 +835,48 @@ void GEOM_Actor::SetMaterial(std::vector theProps) aColor = theProps[0]->GetAmbientColor(); myShadingFaceProp->SetAmbientColor(aColor[0], aColor[1], aColor[2]); myVertexActor->GetProperty()->SetAmbientColor(aColor[0], aColor[1], aColor[2]); + if ( aSize == 2 ) + aColor = theProps[1]->GetAmbientColor(); + myShadingBackFaceProp->SetAmbientColor(aColor[0], aColor[1], aColor[2]); // Set diffuse colors aColor = theProps[0]->GetDiffuseColor(); myShadingFaceProp->SetDiffuseColor(aColor[0], aColor[1], aColor[2]); myVertexActor->GetProperty()->SetDiffuseColor(aColor[0], aColor[1], aColor[2]); + if ( aSize == 2 ) + aColor = theProps[1]->GetDiffuseColor(); + myShadingBackFaceProp->SetDiffuseColor(aColor[0], aColor[1], aColor[2]); // Set specular colors aColor = theProps[0]->GetSpecularColor(); myShadingFaceProp->SetSpecularColor(aColor[0], aColor[1], aColor[2]); myVertexActor->GetProperty()->SetSpecularColor(aColor[0], aColor[1], aColor[2]); + if ( aSize == 2 ) + aColor = theProps[1]->GetSpecularColor(); + myShadingBackFaceProp->SetSpecularColor(aColor[0], aColor[1], aColor[2]); // Set shininess aCoefnt = theProps[0]->GetSpecularPower(); myShadingFaceProp->SetSpecularPower(aCoefnt); myVertexActor->GetProperty()->SetSpecularPower(aCoefnt); + if ( aSize == 2 ) + aCoefnt = theProps[1]->GetSpecularPower(); + myShadingBackFaceProp->SetSpecularPower(aCoefnt); + + // Set back face material property + myShadingFaceActor->SetBackfaceProperty(myShadingBackFaceProp.GetPointer()); } -vtkProperty* GEOM_Actor::GetMaterial() +vtkProperty* GEOM_Actor::GetFrontMaterial() { return myShadingFaceProp; } +vtkProperty* GEOM_Actor::GetBackMaterial() +{ + return myShadingBackFaceProp; +} + bool GEOM_Actor::IsInfinitive() { return ((bool)myShape.Infinite() || isOnlyVertex); @@ -995,22 +1117,3 @@ void GEOM_Actor::ResetIsoNumbers() int aNb[2] = {0, 0}; myWireframeFaceSource->SetNbIso(aNb); } - -void GEOM_Actor::StoreBoundaryColors() -{ - myShadingFaceProp->GetColor(myEdgesInWireframeColor); - -} - -void GEOM_Actor::RestoreBoundaryColors() -{ - myIsolatedEdgeActor->GetProperty()->SetColor(myEdgesInWireframeColor[0], - myEdgesInWireframeColor[1], - myEdgesInWireframeColor[2]); - myOneFaceEdgeActor->GetProperty()->SetColor(myEdgesInWireframeColor[0], - myEdgesInWireframeColor[1], - myEdgesInWireframeColor[2]); - mySharedEdgeActor->GetProperty()->SetColor(myEdgesInWireframeColor[0], - myEdgesInWireframeColor[1], - myEdgesInWireframeColor[2]); -} diff --git a/src/OBJECT/GEOM_Actor.h b/src/OBJECT/GEOM_Actor.h index 28df32d67..d773b6cf6 100644 --- a/src/OBJECT/GEOM_Actor.h +++ b/src/OBJECT/GEOM_Actor.h @@ -24,7 +24,6 @@ // File : GEOM_Actor.h // Author : Christophe ATTANASIO // Module : GEOM -// $Header$ // #ifndef GEOM_ACTOR_H #define GEOM_ACTOR_H @@ -88,6 +87,10 @@ public: vtkProperty* GetWireframeProperty(); vtkProperty* GetShadingProperty(); + vtkProperty* GetIsolatedEdgeProperty(); + vtkProperty* GetVertexProperty(); + vtkProperty* GetSharedEdgeProperty(); + vtkProperty* GetFaceEdgeProperty(); void setDeflection(double adef); virtual void setDisplayMode(int thenewmode); @@ -121,14 +124,27 @@ public: void SetOpacity(vtkFloatingPointType opa); vtkFloatingPointType GetOpacity(); - // Color - void SetColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b); - void GetColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b); + // Color (same to all sub-actors/display modes) + void SetColor(vtkFloatingPointType r, vtkFloatingPointType g, vtkFloatingPointType b); + void GetColor(vtkFloatingPointType& r, vtkFloatingPointType& g, vtkFloatingPointType& b); + // Color of points + void SetPointColor(vtkFloatingPointType r, vtkFloatingPointType g, vtkFloatingPointType b); + // Color of standalone edges, wires, vectors + void SetIsolatedEdgeColor(vtkFloatingPointType r, vtkFloatingPointType g, vtkFloatingPointType b); + // Color of shared edges + void SetSharedEdgeColor(vtkFloatingPointType r, vtkFloatingPointType g, vtkFloatingPointType b); + // Color of free edges + void SetFreeEdgeColor(vtkFloatingPointType r, vtkFloatingPointType g, vtkFloatingPointType b); + // Color of edges in shading+edges display mode + void SetEdgesInShadingColor(vtkFloatingPointType r, vtkFloatingPointType g, vtkFloatingPointType b); + // Color of iso-lines + void SetIsosColor(vtkFloatingPointType r, vtkFloatingPointType g, vtkFloatingPointType b); + // Material void SetMaterial(std::vector theProps); - vtkProperty* GetMaterial(); - + vtkProperty* GetFrontMaterial(); + vtkProperty* GetBackMaterial(); virtual bool IsInfinitive(); // overloaded functions @@ -186,9 +202,6 @@ public: bool GetVectorMode(); - //! Edges in shading color management - void SetEdgesInShadingColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b); - void StoreIsoNumbers(); @@ -203,9 +216,6 @@ protected: void GetMatrix(vtkCamera* theCam, vtkMatrix4x4 *result); - void StoreBoundaryColors(); - void RestoreBoundaryColors(); - GEOM_Actor(); ~GEOM_Actor(); @@ -243,6 +253,7 @@ private: vtkSmartPointer myHighlightProp; vtkSmartPointer myPreHighlightProp; vtkSmartPointer myShadingFaceProp; + vtkSmartPointer myShadingBackFaceProp; PAppendFilter myAppendFilter; PPolyGeomPainterDataMapper myPolyDataMapper; @@ -254,6 +265,9 @@ private: vtkFloatingPointType myEdgesInWireframeColor[3]; vtkFloatingPointType myEdgesInShadingColor[3]; + vtkFloatingPointType myIsolatedEdgeColor[3]; + vtkFloatingPointType mySharedEdgeColor[3]; + vtkFloatingPointType myOneFaceEdgeColor[3]; }; #endif //GEOM_ACTOR_H diff --git a/src/OBJECT/GEOM_Constants.cxx b/src/OBJECT/GEOM_Constants.cxx new file mode 100644 index 000000000..aa1b7ec04 --- /dev/null +++ b/src/OBJECT/GEOM_Constants.cxx @@ -0,0 +1,102 @@ +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 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.com +// + +// File : GEOM_Constants.cxx +// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) + +#include "GEOM_Constants.h" + +namespace GEOM +{ + + /*! + \brief Get minimal allowed value for deflection coefficient + */ + double minDeflection() + { + return 1e-06; // DEFLECTION_MIN + } + + /*! + \brief Get character used to separate parameter names + */ + QString sectionSeparator() + { + return "_"; // NAME_SEPARATOR + } + + /*! + \brief Get character used to separate numeric parameter values (color = r:g:b) + */ + QString subSectionSeparator() + { + return ":"; // DIGIT_SEPARATOR + } + + QString propertyName( Property type ) + { + static const char* names[] = { + // visibility + "Visibility", // VISIBILITY_PROP + // transparency + "Transparency", // TRANSPARENCY_PROP + // display mode + "DisplayMode", // DISPLAY_MODE_PROP + // number of the iso lines (along u and v directions) + "Isos", // ISOS_PROP + // main / shading color + "Color", // COLOR_PROP + // "show edges direction" flag + "VectorMode", // VECTOR_MODE_PROP + // deflection coefficient + "DeflectionCoeff", // DEFLECTION_COEFF_PROP + // point marker data + "MarkerType", // MARKER_TYPE_PROP + // material + "Material", // MATERIAL_PROP + // general line width + "EdgeWidth", // EDGE_WIDTH_PROP + // isos width + "IsosWidth", // ISOS_WIDTH_PROP + // top-level flag + "TopLevelFlag", // TOP_LEVEL_PROP + // opacity + "Opacity", // OPACITY_PROP + // shading color + "ShadingColor", // - + // wireframe color + "WireframeColor", // - + // standalone edges color + "LineColor", // - + // free boundaries color + "FreeBndColor", // - + // points color + "PointColor", // - + // isos color + "IsosColor", // - + // outlines color + "OutlineColor", // - + }; + return ( type >= GEOM::Visibility && type <= GEOM::LastProperty ) ? names[type] : QString(); + } + +} // namespace GEOM diff --git a/src/OBJECT/GEOM_Constants.h b/src/OBJECT/GEOM_Constants.h index b890379e3..50474475a 100644 --- a/src/OBJECT/GEOM_Constants.h +++ b/src/OBJECT/GEOM_Constants.h @@ -21,31 +21,49 @@ // // File : GEOM_Constants.h -// Author : Margarita KARPUNINA -// Module : GEOM -// +// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) + #ifndef GEOM_CONSTANTS_H #define GEOM_CONSTANTS_H -// minimum allowed value for deflection coefficient -#define DEFLECTION_MIN 1e-06 - -//Define separators -#define NAME_SEPARATOR '_' // character used to separate parameter names -#define DIGIT_SEPARATOR ':' // character used to separate numeric parameter values (color = r:g:b) - -#define VISIBILITY_PROP "Visibility" //Object visibility property -#define OPACITY_PROP "Opacity" //Object opacity property -#define TRANSPARENCY_PROP "Transparency" //Object transparency property -#define DISPLAY_MODE_PROP "DisplayMode" //Object display mode property -#define ISOS_PROP "Isos" //Number of the Isos property of the object -#define COLOR_PROP "Color" //Color of the object -#define VECTOR_MODE_PROP "VectorMode" //Vector mode property -#define DEFLECTION_COEFF_PROP "DeflectionCoeff" //Deflection coeff property -#define MARKER_TYPE_PROP "MarkerType" //Marker type property -#define MATERIAL_PROP "Material" //Object material property -#define EDGE_WIDTH_PROP "EdgeWidth" //Width of the edge -#define ISOS_WIDTH_PROP "IsosWidth" //Width of the iso-lines -#define TOP_LEVEL_PROP "TopLevelFlag" //Top level flag +#include + +#include "GEOM_OBJECT_defs.hxx" + +namespace GEOM +{ + enum Property { + Visibility, + Transparency, + DisplayMode, + NbIsos, + Color, + EdgesDirection, + Deflection, + PointMarker, + Material, + LineWidth, + IsosWidth, + TopLevel, + LastStudyProperty = TopLevel, + Opacity, + ShadingColor, + WireframeColor, + LineColor, + FreeBndColor, + PointColor, + IsosColor, + OutlineColor, + LastProperty = OutlineColor, + }; + + GEOM_OBJECT_EXPORT double minDeflection(); + + GEOM_OBJECT_EXPORT QString sectionSeparator(); + GEOM_OBJECT_EXPORT QString subSectionSeparator(); + + GEOM_OBJECT_EXPORT QString propertyName( Property ); +} + #endif //GEOM_CONSTANTS_H diff --git a/src/OBJECT/GEOM_DeviceActor.cxx b/src/OBJECT/GEOM_DeviceActor.cxx index 266814569..9a25e86e5 100755 --- a/src/OBJECT/GEOM_DeviceActor.cxx +++ b/src/OBJECT/GEOM_DeviceActor.cxx @@ -73,6 +73,20 @@ GetProperty() return myActor->GetProperty(); } +void +GEOM_DeviceActor:: +SetBackfaceProperty(vtkProperty* theProperty) +{ + myActor->SetBackfaceProperty(theProperty); +} + +vtkProperty* +GEOM_DeviceActor:: +GetBackfaceProperty() +{ + return myActor->GetBackfaceProperty(); +} + void GEOM_DeviceActor:: SetVisibility(int theVisibility) diff --git a/src/OBJECT/GEOM_DeviceActor.h b/src/OBJECT/GEOM_DeviceActor.h index 8b36ab7ae..67edada94 100755 --- a/src/OBJECT/GEOM_DeviceActor.h +++ b/src/OBJECT/GEOM_DeviceActor.h @@ -52,7 +52,10 @@ public: void SetProperty(vtkProperty* theProperty); vtkProperty* GetProperty(); - + + void SetBackfaceProperty(vtkProperty* theProperty); + vtkProperty* GetBackfaceProperty(); + void SetVisibility(int theVisibility); int GetVisibility(); diff --git a/src/OBJECT/GEOM_InteractiveObject.cxx b/src/OBJECT/GEOM_InteractiveObject.cxx index d108c1735..caa18d7b7 100644 --- a/src/OBJECT/GEOM_InteractiveObject.cxx +++ b/src/OBJECT/GEOM_InteractiveObject.cxx @@ -24,7 +24,6 @@ // File : GEOM_InteractiveObject.cxx // Author : Christophe ATTANASIO // Module : GEOM -// $Header$ // /*! \class GEOM_InteractiveObject GEOM_InteractiveObject.hxx diff --git a/src/OBJECT/GEOM_OCCReader.h b/src/OBJECT/GEOM_OCCReader.h index 3be818b36..c69b67d35 100644 --- a/src/OBJECT/GEOM_OCCReader.h +++ b/src/OBJECT/GEOM_OCCReader.h @@ -24,7 +24,6 @@ // File : GEOM_OCCReader.h // Author : Christophe ATTANASIO // Module : GEOM -// $Header$ // /*! \class GEOM_OCCReader GEOM_OCCReader.h diff --git a/src/OBJECT/GEOM_TopWireframeShape.cxx b/src/OBJECT/GEOM_TopWireframeShape.cxx index f22b3197f..4729ecfda 100755 --- a/src/OBJECT/GEOM_TopWireframeShape.cxx +++ b/src/OBJECT/GEOM_TopWireframeShape.cxx @@ -56,6 +56,10 @@ GEOM_TopWireframeShape::GEOM_TopWireframeShape(const TopoDS_Shape& shape) SetColor(GEOM_AISShape::topLevelColor()); } +GEOM_TopWireframeShape::~GEOM_TopWireframeShape() +{ +} + Handle(SALOME_InteractiveObject) GEOM_TopWireframeShape::getIO(){ Handle(SALOME_InteractiveObject) IO; if ( !GetOwner().IsNull() ) diff --git a/src/OBJECT/GEOM_TopWireframeShape.ixx b/src/OBJECT/GEOM_TopWireframeShape.ixx index 1fd891967..a4f1408d6 100755 --- a/src/OBJECT/GEOM_TopWireframeShape.ixx +++ b/src/OBJECT/GEOM_TopWireframeShape.ixx @@ -30,8 +30,6 @@ #include #endif -GEOM_TopWireframeShape::~GEOM_TopWireframeShape() {} - Standard_EXPORT Handle_Standard_Type& GEOM_TopWireframeShape_Type_() { diff --git a/src/OBJECT/GEOM_VTKTrihedron.cxx b/src/OBJECT/GEOM_VTKTrihedron.cxx index a57f359d1..5c5259745 100644 --- a/src/OBJECT/GEOM_VTKTrihedron.cxx +++ b/src/OBJECT/GEOM_VTKTrihedron.cxx @@ -24,7 +24,6 @@ // File : GEOM_VTKTrihedron.cxx // Author : Sergey LITONIN // Module : SALOME -// $Header: // #include "GEOM_VTKTrihedron.hxx" @@ -117,11 +116,15 @@ void GEOM_VTKTrihedronAxis::SetSize( vtkFloatingPointType theSize ) 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 ) ); + + // Set Arrow Position + myMatrix->SetElement( i - 1 , 3, aPosition[ i - 1 ] ); + } myArrowActor->SetUserMatrix( myMatrix ); - myArrowActor->SetPosition( aPosition ); #ifdef IPAL21440 if( vtkCoordinate* aCoord = myLabelActor->GetPositionCoordinate()->GetReferenceCoordinate() ) @@ -429,3 +432,4 @@ void GEOM_VTKTrihedron::SetAxesColors( vtkFloatingPointType theColor[3], bool th myAxis[ 1 ]->SetColor( theIsDiffuse ? 0.0 : theColor[0], theColor[1], theIsDiffuse ? 0.0 : theColor[2] ); myAxis[ 2 ]->SetColor( theIsDiffuse ? 0.0 : theColor[0], theIsDiffuse ? 0.0 : theColor[1], theColor[2] ); } + diff --git a/src/OBJECT/GEOM_VTKTrihedron.hxx b/src/OBJECT/GEOM_VTKTrihedron.hxx index 99a3ab60c..897312ae0 100644 --- a/src/OBJECT/GEOM_VTKTrihedron.hxx +++ b/src/OBJECT/GEOM_VTKTrihedron.hxx @@ -24,7 +24,6 @@ // File : GEOM_VTKTrihedron.h // Author : Sergey LITONIN // Module : SALOME -// $Header: // #ifndef GEOM_VTKTrihedron_H #define GEOM_VTKTrihedron_H diff --git a/src/OBJECT/Makefile.am b/src/OBJECT/Makefile.am index ae48a97f8..b59d98914 100644 --- a/src/OBJECT/Makefile.am +++ b/src/OBJECT/Makefile.am @@ -65,7 +65,8 @@ dist_libGEOMObject_la_SOURCES = \ GEOM_VTKPropertyMaterial.cxx \ GEOM_AISVector.cxx \ GEOM_PainterPolyDataMapper.cxx \ - GEOM_DeviceActor.cxx + GEOM_DeviceActor.cxx \ + GEOM_Constants.cxx libGEOMObject_la_CPPFLAGS = \ diff --git a/src/RepairGUI/RepairGUI_FreeBoundDlg.cxx b/src/RepairGUI/RepairGUI_FreeBoundDlg.cxx index 3ef492fcc..6f76359f6 100644 --- a/src/RepairGUI/RepairGUI_FreeBoundDlg.cxx +++ b/src/RepairGUI/RepairGUI_FreeBoundDlg.cxx @@ -18,15 +18,16 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// // GEOM GEOMGUI : GUI for Geometry component // File : RepairGUI_FreeBoundDlg.cxx // Author : Sergey LITONIN, Open CASCADE S.A.S. (sergey.litonin@opencascade.com) -// + #include "RepairGUI_FreeBoundDlg.h" #include +#include + #include #include #include @@ -51,7 +52,7 @@ #include #define SPACING 6 -#define MARGIN 9 +#define MARGIN 0 /*! Class : RepairGUI_FreeBoundDlg @@ -62,59 +63,55 @@ // function : RepairGUI_FreeBoundDlg // purpose : Constructor //================================================================================= -RepairGUI_FreeBoundDlg::RepairGUI_FreeBoundDlg( GeometryGUI* theGUI, QWidget* theParent ) - : QDialog( theParent, 0 ), - GEOMBase_Helper( dynamic_cast( theParent ) ), - myGeomGUI( theGUI ) +RepairGUI_FreeBoundDlg::RepairGUI_FreeBoundDlg (GeometryGUI* theGUI, QWidget* theParent) + : GEOMBase_Skeleton(theGUI, theParent) { - setAttribute( Qt::WA_DeleteOnClose ); - - setWindowTitle( tr( "CAPTION" ) ); - - QPixmap iconSelect( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) ); - - QGroupBox* aMainGrp = new QGroupBox( tr( "FREE_BOUND" ), this ); - - QLabel* lab = new QLabel( tr( "GEOM_OBJECT" ), aMainGrp ); - QPushButton* btn = new QPushButton( aMainGrp ); - btn->setIcon( iconSelect ); - myEdit = new QLineEdit( aMainGrp ); - myEdit->setReadOnly( true ); - myEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - - myClosedLbl = new QLabel( tr( "NUMBER_CLOSED" ), aMainGrp ); - myOpenLbl = new QLabel( tr( "NUMBER_OPEN" ), aMainGrp ); - myClosedLbl->setMinimumWidth( 150 ); - myOpenLbl->setMinimumWidth( 150 ); - - QGridLayout* aMainGrpLayout = new QGridLayout( aMainGrp ); - aMainGrpLayout->setMargin( MARGIN ); aMainGrpLayout->setSpacing( SPACING ); - aMainGrpLayout->addWidget( lab, 0, 0 ); - aMainGrpLayout->addWidget( btn, 0, 1 ); - aMainGrpLayout->addWidget( myEdit, 0, 2 ); - aMainGrpLayout->addWidget( myClosedLbl, 1, 0, 1, 3 ); - aMainGrpLayout->addWidget( myOpenLbl, 2, 0, 1, 3 ); - - QFrame* aFrame = new QFrame( this ); - aFrame->setFrameStyle( QFrame::Box | QFrame::Sunken ); - QPushButton* aCloseBtn = new QPushButton( tr( "GEOM_BUT_CLOSE" ), aFrame ); - QPushButton* aHelpBtn = new QPushButton( tr( "GEOM_BUT_HELP" ), aFrame ); - QHBoxLayout* aBtnLay = new QHBoxLayout( aFrame ); - aBtnLay->setMargin( MARGIN ); aBtnLay->setSpacing( SPACING ); - aBtnLay->addWidget( aCloseBtn ); - aBtnLay->addSpacing( SPACING ); aBtnLay->addStretch(); - aBtnLay->addWidget( aHelpBtn ); - - QVBoxLayout* aLay = new QVBoxLayout( this ); - aLay->setSpacing( SPACING ); - aLay->setMargin( MARGIN ); - aLay->addWidget( aMainGrp ); - aLay->addWidget( aFrame ); - - myHelpFileName = "using_measurement_tools_page.html#boundaries_anchor"; - - connect( aCloseBtn, SIGNAL( clicked() ), SLOT( onClose() ) ); - connect( aHelpBtn, SIGNAL( clicked() ), SLOT( onHelp() ) ); + QPixmap image0 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_FREE_BOUNDS"))); + QPixmap image1 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT"))); + + setWindowTitle(tr("CAPTION")); + + /***************************************************************/ + + mainFrame()->GroupConstructors->setTitle(tr("FREE_BOUND")); + mainFrame()->RadioButton1->setIcon(image0); + mainFrame()->RadioButton2->setAttribute(Qt::WA_DeleteOnClose); + mainFrame()->RadioButton2->close(); + mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose); + mainFrame()->RadioButton3->close(); + + mainFrame()->GroupBoxName->hide(); + + QGroupBox* aMainGrp = new QGroupBox (tr("FREE_BOUND"), this); + + QLabel* lab = new QLabel (tr("GEOM_OBJECT"), aMainGrp); + QPushButton* btn = new QPushButton (aMainGrp); + btn->setIcon(image1); + myEdit = new QLineEdit (aMainGrp); + myEdit->setReadOnly(true); + myEdit->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); + + myClosedLbl = new QLabel (tr("NUMBER_CLOSED"), aMainGrp); + myOpenLbl = new QLabel (tr("NUMBER_OPEN"), aMainGrp); + myClosedLbl->setMinimumWidth(150); + myOpenLbl->setMinimumWidth(150); + + QGridLayout* aMainGrpLayout = new QGridLayout (aMainGrp); + aMainGrpLayout->addWidget(lab, 0, 0); + aMainGrpLayout->addWidget(btn, 0, 1); + aMainGrpLayout->addWidget(myEdit, 0, 2); + aMainGrpLayout->addWidget(myClosedLbl, 1, 0, 1, 3); + aMainGrpLayout->addWidget(myOpenLbl, 2, 0, 1, 3); + + QVBoxLayout* aLay = new QVBoxLayout (centralWidget()); + aLay->setSpacing(SPACING); + aLay->setMargin(MARGIN); + aLay->addWidget(aMainGrp); + + resize(minimumSizeHint()); + /***************************************************************/ + + myHelpFileName = "boundaries_page.html"; Init(); } @@ -128,126 +125,99 @@ RepairGUI_FreeBoundDlg::~RepairGUI_FreeBoundDlg() } //================================================================================= -// function : onClose -// purpose : SLOT. Called when "close" button pressed. Close dialog +// function : Init +// purpose : Initialize dialog fields //================================================================================= -void RepairGUI_FreeBoundDlg::onClose() +void RepairGUI_FreeBoundDlg::Init() { - globalSelection(); - disconnect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(), 0, this, 0 ); - myGeomGUI->SetActiveDialogBox( 0 ); - reject(); - erasePreview(); + myNbClosed = myNbOpen = 0; + myObj = GEOM::GEOM_Object::_nil(); + + myEditCurrentArgument = myEdit; + + connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply())); + + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); + + activateSelection(); + SelectionIntoArgument(); } //================================================================================= -// function : onHelp() +// function : ClickOnOk() // purpose : //================================================================================= -void RepairGUI_FreeBoundDlg::onHelp() +void RepairGUI_FreeBoundDlg::ClickOnOk() { - LightApp_Application* app = (LightApp_Application*)( SUIT_Session::session()->activeApplication() ); - if ( app ) - app->onHelpContextModule( myGeomGUI ? app->moduleName( myGeomGUI->moduleName() ) : QString(""), myHelpFileName ); - else { - QString platform; -#ifdef WIN32 - platform = "winapplication"; -#else - platform = "application"; -#endif - SUIT_MessageBox::warning( this, - tr( "WRN_WARNING" ), - tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE"). - arg( app->resourceMgr()->stringValue( "ExternalBrowser", - platform ) ).arg( myHelpFileName ) ); - } + if (ClickOnApply()) + ClickOnCancel(); } //================================================================================= -// function : onDeactivate -// purpose : Deactivate this dialog +// function : ClickOnApply() +// purpose : //================================================================================= -void RepairGUI_FreeBoundDlg::onDeactivate() +bool RepairGUI_FreeBoundDlg::ClickOnApply() { - setEnabled( false ); - globalSelection(); - disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 ); - myGeomGUI->SetActiveDialogBox( 0 ); + if (!onAccept()) + return false; + return true; } //================================================================================= -// function : onActivate -// purpose : Activate this dialog +// function : ActivateThisDialog() +// purpose : //================================================================================= -void RepairGUI_FreeBoundDlg::onActivate() +void RepairGUI_FreeBoundDlg::ActivateThisDialog() { - myGeomGUI->EmitSignalDeactivateDialog(); - setEnabled( true ); - myGeomGUI->SetActiveDialogBox( this ); - connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(), - SIGNAL( currentSelectionChanged() ), SLOT( onSelectionDone() ) ); + GEOMBase_Skeleton::ActivateThisDialog(); + + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); + activateSelection(); - onSelectionDone(); + displayPreview(true); } //================================================================================= -// function : onSelectionDone -// purpose : SLOT. Called when selection changed. +// function : enterEvent() +// purpose : //================================================================================= -void RepairGUI_FreeBoundDlg::onSelectionDone() +void RepairGUI_FreeBoundDlg::enterEvent(QEvent*) { - LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); - SALOME_ListIO aSelList; - aSelMgr->selectedObjects(aSelList); - - if ( aSelList.Extent() != 1 ) - return; - - GEOM::GEOM_Object_var anObj = - GEOMBase::ConvertIOinGEOMObject( aSelList.First() ); - - if ( !GEOMBase::IsShape( anObj ) ) - return; - else { - myObj = anObj; - displayPreview( true, false, true, true, 3 ); - } + if (!mainFrame()->GroupConstructors->isEnabled()) + ActivateThisDialog(); } //================================================================================= -// function : Init -// purpose : Initialize dialog fields +// function : SelectionIntoArgument +// purpose : SLOT. Called when selection changed. //================================================================================= -void RepairGUI_FreeBoundDlg::Init() +void RepairGUI_FreeBoundDlg::SelectionIntoArgument() { - myNbClosed = myNbOpen = 0; + myEditCurrentArgument->setText(""); + myClosedLbl->setText(tr("NUMBER_CLOSED")); + myOpenLbl->setText(tr("NUMBER_OPEN")); myObj = GEOM::GEOM_Object::_nil(); + erasePreview(); - connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), SLOT ( onDeactivate() ) ); - connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(), - SIGNAL( currentSelectionChanged() ), SLOT( onSelectionDone() ) ); + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); + SALOME_ListIO aSelList; + aSelMgr->selectedObjects(aSelList); - activateSelection(); - onSelectionDone(); -} + if (aSelList.Extent() != 1) + return; -//================================================================================= -// function : enterEvent -// purpose : Activate dialog -//================================================================================= -void RepairGUI_FreeBoundDlg::enterEvent( QEvent* ) -{ - onActivate(); -} + GEOM::GEOM_Object_var anObj = GEOMBase::ConvertIOinGEOMObject(aSelList.First()); -//================================================================================= -// function : closeEvent -// purpose : Close dialog -//================================================================================= -void RepairGUI_FreeBoundDlg::closeEvent( QCloseEvent* ) -{ - onClose(); + if (!GEOMBase::IsShape(anObj)) + return; + + myObj = anObj; + myEditCurrentArgument->setText(GEOMBase::GetName(myObj)); + displayPreview(true, false, true, true, 3); } //================================================================================= @@ -257,11 +227,11 @@ void RepairGUI_FreeBoundDlg::closeEvent( QCloseEvent* ) 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 ); + aMap.Add(GEOM_FACE); + aMap.Add(GEOM_SHELL); + aMap.Add(GEOM_SOLID); + aMap.Add(GEOM_COMPOUND); + globalSelection(aMap); } //================================================================================= @@ -270,14 +240,14 @@ void RepairGUI_FreeBoundDlg::activateSelection() //================================================================================= GEOM::GEOM_IOperations_ptr RepairGUI_FreeBoundDlg::createOperation() { - return getGeomEngine()->GetIHealingOperations( getStudyId() ); + return getGeomEngine()->GetIHealingOperations(getStudyId()); } //================================================================================= // function : isValid // purpose : //================================================================================= -bool RepairGUI_FreeBoundDlg::isValid( QString& ) +bool RepairGUI_FreeBoundDlg::isValid (QString&) { return !myObj->_is_nil(); } @@ -286,52 +256,50 @@ bool RepairGUI_FreeBoundDlg::isValid( QString& ) // function : execute // purpose : Get free boundaries //================================================================================= -bool RepairGUI_FreeBoundDlg::execute( ObjectList& objects ) +bool RepairGUI_FreeBoundDlg::execute (ObjectList& objects) { - if ( !IsPreview() || myObj->_is_nil() ) - return false; - GEOM::ListOfGO_var aClosed, anOpen; - GEOM::GEOM_IHealingOperations_var anOper = GEOM::GEOM_IHealingOperations::_narrow( getOperation() ); - bool result = anOper->GetFreeBoundary( myObj, aClosed, anOpen ); + GEOM::GEOM_IHealingOperations_var anOper = GEOM::GEOM_IHealingOperations::_narrow(getOperation()); + bool result = anOper->GetFreeBoundary(myObj, aClosed, anOpen); - if ( result ) { + 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" ) ); + for (i = 0; i < myNbClosed; i++) + objects.push_back(aClosed[i]._retn()); + for (i = 0; i < myNbOpen; i++) + objects.push_back(anOpen[i]._retn()); + + QString aLabelText = tr("NUMBER_CLOSED") + QString("%1").arg(myNbClosed); + myClosedLbl->setText(aLabelText); + aLabelText = tr("NUMBER_OPEN") + QString("%1").arg(myNbOpen); + myOpenLbl->setText(aLabelText); } + myCurrObj = 1; return result; } -//================================================================================= -// function : keyPressEvent() -// purpose : -//================================================================================= -void RepairGUI_FreeBoundDlg::keyPressEvent( QKeyEvent* e ) +//================================================================ +// Function : getNewObjectName +// Purpose : Redefine this method to return proper name for a new object +//================================================================ +QString RepairGUI_FreeBoundDlg::getNewObjectName (int currObj) const { - QDialog::keyPressEvent( e ); - if ( e->isAccepted() ) - return; + QString aName = tr("NAME_CLOSED").arg(currObj); + if (currObj > myNbClosed) + aName = tr("NAME_OPEN").arg(currObj); + return aName; +} - if ( e->key() == Qt::Key_F1 ) { - e->accept(); - onHelp(); - } +//================================================================ +// Function : getFather +// Purpose : Get father object for object to be added in study +// (called with addInStudy method) +//================================================================ +GEOM::GEOM_Object_ptr RepairGUI_FreeBoundDlg::getFather (GEOM::GEOM_Object_ptr) +{ + return myObj; } diff --git a/src/RepairGUI/RepairGUI_FreeBoundDlg.h b/src/RepairGUI/RepairGUI_FreeBoundDlg.h index af65e1602..f9ac7bc7c 100644 --- a/src/RepairGUI/RepairGUI_FreeBoundDlg.h +++ b/src/RepairGUI/RepairGUI_FreeBoundDlg.h @@ -18,17 +18,16 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// // GEOM GEOMGUI : GUI for Geometry component // File : RepairGUI_FreeBoundDlg.h // Author : Sergey LITONIN, Open CASCADE S.A.S. (sergey.litonin@opencascade.com) -// + #ifndef REPAIRGUI_FREEBOUNDDLG_H #define REPAIRGUI_FREEBOUNDDLG_H #include -#include +#include class QLineEdit; class QLabel; @@ -38,42 +37,42 @@ class GeometryGUI; // class : RepairGUI_FreeBoundDlg // purpose : Dialog for displaying free boundaries of selected face, shell or solid //================================================================================= -class RepairGUI_FreeBoundDlg : public QDialog, - public GEOMBase_Helper +class RepairGUI_FreeBoundDlg : public GEOMBase_Skeleton { Q_OBJECT public: - RepairGUI_FreeBoundDlg( GeometryGUI*, QWidget* ); + RepairGUI_FreeBoundDlg (GeometryGUI*, QWidget*); ~RepairGUI_FreeBoundDlg(); -private slots: - void onClose(); - void onHelp(); - void onDeactivate(); - void onActivate(); - void onSelectionDone(); +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid (QString&); + virtual bool execute (ObjectList&); + virtual GEOM::GEOM_Object_ptr getFather (GEOM::GEOM_Object_ptr); + virtual QString getNewObjectName (int CurrObj = -1) const; private: void Init(); - void enterEvent( QEvent* ); - void closeEvent( QCloseEvent* ); - void keyPressEvent( QKeyEvent* ); + void enterEvent (QEvent*); void activateSelection(); - - virtual GEOM::GEOM_IOperations_ptr createOperation(); - virtual bool execute( ObjectList& ); - virtual bool isValid( QString& ); private: QLineEdit* myEdit; QLabel* myClosedLbl; QLabel* myOpenLbl; + GEOM::GEOM_Object_var myObj; - GeometryGUI* myGeomGUI; int myNbClosed; int myNbOpen; - QString myHelpFileName; + int myCurrObj; + +private slots: + void ClickOnOk(); + bool ClickOnApply(); + void SelectionIntoArgument(); + void ActivateThisDialog(); }; #endif // REPAIRGUI_FREEBOUNDDLG_H diff --git a/src/SKETCHER/Makefile.am b/src/SKETCHER/Makefile.am index 503d0b9b5..1836cfde3 100644 --- a/src/SKETCHER/Makefile.am +++ b/src/SKETCHER/Makefile.am @@ -22,7 +22,6 @@ # Author : Patrick GOLDBRONN (CEA) # Modified by : Alexander BORODIN (OCN) - autotools usage # Module : GEOM -# $Header$ # include $(top_srcdir)/adm_local/unix/make_common_starter.am diff --git a/src/SKETCHER/Sketcher_Profile.hxx b/src/SKETCHER/Sketcher_Profile.hxx index f323a058e..ed3bb0037 100644 --- a/src/SKETCHER/Sketcher_Profile.hxx +++ b/src/SKETCHER/Sketcher_Profile.hxx @@ -24,7 +24,6 @@ // File : Sketcher_Profile.h // Author : Damien COQUERET // Module : GEOM -// $Header: // #include #include diff --git a/src/STEPExport/Makefile.am b/src/STEPExport/Makefile.am index 96bf0e2b5..39ef12d5b 100644 --- a/src/STEPExport/Makefile.am +++ b/src/STEPExport/Makefile.am @@ -21,7 +21,6 @@ # Author : Pavel TELKOV # Modified by : Alexander BORODIN (OCN) - autotools usage # Module : GEOM -# $Header$ # include $(top_srcdir)/adm_local/unix/make_common_starter.am diff --git a/src/STEPExport/STEPExport.cxx b/src/STEPExport/STEPExport.cxx index abe5c310a..e911cd01e 100644 --- a/src/STEPExport/STEPExport.cxx +++ b/src/STEPExport/STEPExport.cxx @@ -61,8 +61,9 @@ extern "C" { - STEPEXPORT_EXPORT - int Export(const TopoDS_Shape& theShape, const TCollection_AsciiString& theFileName) + STEPEXPORT_EXPORT int Export (const TopoDS_Shape& theShape, + const TCollection_AsciiString& theFileName, + const TCollection_AsciiString& /*theFormatName*/) { MESSAGE("Export STEP into file " << theFileName.ToCString()); diff --git a/src/STLExport/Makefile.am b/src/STLExport/Makefile.am index d482d48fe..0f94bda86 100644 --- a/src/STLExport/Makefile.am +++ b/src/STLExport/Makefile.am @@ -17,8 +17,6 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -# $Header$ -# include $(top_srcdir)/adm_local/unix/make_common_starter.am # header files diff --git a/src/ShHealOper/Makefile.am b/src/ShHealOper/Makefile.am index d2f1cd4ae..b7c55a1e2 100644 --- a/src/ShHealOper/Makefile.am +++ b/src/ShHealOper/Makefile.am @@ -22,7 +22,6 @@ # Author : Alexander SLADKOV # Modified by : Alexander BORODIN (OCN) - autotools usage # Module : GEOM -# $Header: # include $(top_srcdir)/adm_local/unix/make_common_starter.am diff --git a/src/TransformationGUI/TransformationGUI_MultiRotationDlg.cxx b/src/TransformationGUI/TransformationGUI_MultiRotationDlg.cxx index f450a2f8c..5f22ed33a 100644 --- a/src/TransformationGUI/TransformationGUI_MultiRotationDlg.cxx +++ b/src/TransformationGUI/TransformationGUI_MultiRotationDlg.cxx @@ -69,34 +69,25 @@ TransformationGUI_MultiRotationDlg::TransformationGUI_MultiRotationDlg mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose); mainFrame()->RadioButton3->close(); - GroupPoints = new DlgRef_2Sel1SpinInt(centralWidget()); - GroupPoints->GroupBox1->setTitle(tr("GEOM_MULTIROTATION_SIMPLE")); - GroupPoints->TextLabel1->setText(tr("GEOM_MAIN_OBJECT")); - GroupPoints->TextLabel2->setText(tr("GEOM_VECTOR")); - GroupPoints->TextLabel3->setText(tr("GEOM_NB_TIMES")); - GroupPoints->PushButton1->setIcon(image2); - GroupPoints->PushButton2->setIcon(image2); - GroupPoints->LineEdit1->setReadOnly(true); - GroupPoints->LineEdit2->setReadOnly(true); - - GroupDimensions = new DlgRef_2Sel4Spin1Check(centralWidget()); - GroupDimensions->GroupBox1->setTitle(tr("GEOM_MULTIROTATION_DOUBLE")); - GroupDimensions->TextLabel1->setText(tr("GEOM_MAIN_OBJECT")); - GroupDimensions->TextLabel2->setText(tr("GEOM_VECTOR")); - GroupDimensions->TextLabel3->setText(tr("GEOM_ANGLE")); - GroupDimensions->TextLabel4->setText(tr("GEOM_NB_TIMES")); - GroupDimensions->TextLabel5->setText(tr("GEOM_STEP")); - GroupDimensions->TextLabel6->setText(tr("GEOM_NB_TIMES")); - GroupDimensions->CheckButton1->setText(tr("GEOM_REVERSE")); - GroupDimensions->PushButton1->setIcon(image2); - GroupDimensions->PushButton2->setIcon(image2); - GroupDimensions->LineEdit1->setReadOnly(true); - GroupDimensions->LineEdit2->setReadOnly(true); - - QVBoxLayout* layout = new QVBoxLayout(centralWidget()); - layout->setMargin(0); layout->setSpacing(6); - layout->addWidget(GroupPoints); - layout->addWidget(GroupDimensions); + bool isAngleStep = false; + + GroupArgs = new TransformationGUI_2Sel4Spin1Check (centralWidget()); + GroupArgs->GroupBox1->setTitle(tr("GEOM_MULTIROTATION_DOUBLE")); + GroupArgs->TextLabel1->setText(tr("GEOM_MAIN_OBJECT")); + GroupArgs->TextLabel2->setText(tr("GEOM_VECTOR")); + //GroupArgs->TextLabel3->setText(tr("GEOM_ANGLE_STEP")); + GroupArgs->CheckAngleStep->setText(tr("GEOM_ANGLE_STEP")); + GroupArgs->CheckAngleStep->setChecked(isAngleStep); + GroupArgs->TextLabel4->setText(tr("GEOM_NB_TIMES")); + GroupArgs->TextLabel5->setText(tr("GEOM_STEP_R")); + GroupArgs->TextLabel6->setText(tr("GEOM_NB_TIMES")); + GroupArgs->CheckButton1->setText(tr("GEOM_REVERSE")); + GroupArgs->PushButton1->setIcon(image2); + GroupArgs->PushButton2->setIcon(image2); + GroupArgs->LineEdit1->setReadOnly(true); + GroupArgs->LineEdit2->setReadOnly(true); + GroupArgs->SpinBox_DX1->setEnabled(isAngleStep); + GroupArgs->CheckButton1->setEnabled(isAngleStep); /***************************************************************/ setHelpFileName("multi_rotation_operation_page.html"); @@ -119,38 +110,23 @@ TransformationGUI_MultiRotationDlg::~TransformationGUI_MultiRotationDlg() //================================================================================= void TransformationGUI_MultiRotationDlg::Init() { + // init variables + myAng = 45.0; + myStep = 50.0; + myNbTimes1 = myNbTimes2 = 3; + // Get setting of step value from file configuration SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); double step = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100); int SpecificStep1 = 5; int SpecificStep2 = 1; - // init variables - myAng = 45.0; - myStep = 50.0; - myNbTimes1 = myNbTimes2 = 2; // min, max, step and decimals for spin boxes & initial values - initSpinBox(GroupPoints->SpinBox_DX, 1, 999, SpecificStep2); - GroupPoints->SpinBox_DX->setValue(myNbTimes1); - - initSpinBox(GroupDimensions->SpinBox_DX1, COORD_MIN, COORD_MAX, SpecificStep1, "angle_precision" ); - initSpinBox(GroupDimensions->SpinBox_DY1, 1, 999, SpecificStep2); - initSpinBox(GroupDimensions->SpinBox_DX2, COORD_MIN, COORD_MAX, step,"length_precision" ); - initSpinBox(GroupDimensions->SpinBox_DY2, 1, 999, SpecificStep2); - GroupDimensions->SpinBox_DX1->setValue(myAng); - GroupDimensions->SpinBox_DY1->setValue(myNbTimes1); - GroupDimensions->SpinBox_DX2->setValue(myStep); - GroupDimensions->SpinBox_DY2->setValue(myNbTimes2); - - GroupPoints->LineEdit1->setText(""); - GroupPoints->LineEdit2->setText(""); - - GroupDimensions->LineEdit1->setText(""); - GroupDimensions->LineEdit2->setText(""); - - myBase.nullify(); - myVector.nullify(); + initSpinBox(GroupArgs->SpinBox_DX1, COORD_MIN, COORD_MAX, SpecificStep1, "angle_precision"); + initSpinBox(GroupArgs->SpinBox_DY1, 1, 999, SpecificStep2); + initSpinBox(GroupArgs->SpinBox_DX2, COORD_MIN, COORD_MAX, step, "length_precision"); + initSpinBox(GroupArgs->SpinBox_DY2, 1, 999, SpecificStep2); mainFrame()->GroupBoxPublish->show(); @@ -158,25 +134,23 @@ void TransformationGUI_MultiRotationDlg::Init() connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk())); connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply())); - connect(this, SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int))); + connect(this, SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int))); - connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect(GroupDimensions->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect(GroupDimensions->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupArgs->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupArgs->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(int)), this, SLOT(ValueChangedInSpinBox(int))); - connect(GroupDimensions->SpinBox_DX1, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(GroupDimensions->SpinBox_DY1, SIGNAL(valueChanged(int)), this, SLOT(ValueChangedInSpinBox(int))); - connect(GroupDimensions->SpinBox_DX2, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); - connect(GroupDimensions->SpinBox_DY2, SIGNAL(valueChanged(int)), this, SLOT(ValueChangedInSpinBox(int))); + connect(GroupArgs->SpinBox_DX1, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupArgs->SpinBox_DY1, SIGNAL(valueChanged(int)), this, SLOT(ValueChangedInSpinBox(int))); + connect(GroupArgs->SpinBox_DX2, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + connect(GroupArgs->SpinBox_DY2, SIGNAL(valueChanged(int)), this, SLOT(ValueChangedInSpinBox(int))); - connect(GroupDimensions->SpinBox_DX1,SIGNAL(textChanged( const QString& )), - this, SLOT(TextValueChangedInSpinBox( const QString& ))); + connect(GroupArgs->SpinBox_DX1, SIGNAL(textChanged(const QString&)), + this, SLOT(TextValueChangedInSpinBox(const QString&))); connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double))); - connect(GroupDimensions->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(ReverseAngle())); + connect(GroupArgs->CheckAngleStep, SIGNAL(toggled(bool)), this, SLOT(CheckAngleStep(bool))); + connect(GroupArgs->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(ReverseAngle())); initName(tr("GEOM_MULTIROTATION")); @@ -189,13 +163,7 @@ void TransformationGUI_MultiRotationDlg::Init() //================================================================================= void TransformationGUI_MultiRotationDlg::SetDoubleSpinBoxStep (double step) { - GroupDimensions->SpinBox_DX2->setSingleStep(step); - - // san: Commented so as not to override specific step settings - //GroupPoints->SpinBox_DX->setSingleStep((int)step); - //GroupDimensions->SpinBox_DX1->setSingleStep(step); - //GroupDimensions->SpinBox_DY1->setSingleStep((int)step); - //GroupDimensions->SpinBox_DY2->setSingleStep((int)step); + GroupArgs->SpinBox_DX2->setSingleStep(step); } //================================================================================= @@ -206,42 +174,42 @@ void TransformationGUI_MultiRotationDlg::ConstructorsClicked (int constructorId) { disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); - switch (constructorId) { - case 0: // Rotate simple - { - GroupDimensions->hide(); - GroupPoints->show(); + myBase.nullify(); + myVector.nullify(); - GroupPoints->LineEdit1->setText(""); - GroupPoints->LineEdit2->setText(""); - myBase.nullify(); - myVector.nullify(); + GroupArgs->LineEdit1->setText(""); + GroupArgs->LineEdit2->setText(""); - GroupPoints->SpinBox_DX->setValue(myNbTimes1); + GroupArgs->SpinBox_DX1->setValue(myAng); + GroupArgs->SpinBox_DY1->setValue(myNbTimes1); + GroupArgs->SpinBox_DX2->setValue(myStep); + GroupArgs->SpinBox_DY2->setValue(myNbTimes2); - GroupPoints->PushButton1->click(); + switch (constructorId) { + case 0: // Rotate simple + { + GroupArgs->GroupBox1->setTitle(tr("GEOM_MULTIROTATION_SIMPLE")); + GroupArgs->TextLabel5->hide(); + GroupArgs->TextLabel6->hide(); + GroupArgs->SpinBox_DX2->hide(); + GroupArgs->SpinBox_DY2->hide(); + GroupArgs->CheckButton1->hide(); } break; case 1: // Rotate double { - GroupPoints->hide(); - GroupDimensions->show(); - - GroupDimensions->LineEdit1->setText(""); - GroupDimensions->LineEdit2->setText(""); - myBase.nullify(); - myVector.nullify(); - - GroupDimensions->SpinBox_DX1->setValue(myAng); - GroupDimensions->SpinBox_DY1->setValue(myNbTimes1); - GroupDimensions->SpinBox_DX2->setValue(myStep); - GroupDimensions->SpinBox_DY2->setValue(myNbTimes2); - - GroupDimensions->PushButton1->click(); + GroupArgs->GroupBox1->setTitle(tr("GEOM_MULTIROTATION_DOUBLE")); + GroupArgs->TextLabel5->show(); + GroupArgs->TextLabel6->show(); + GroupArgs->SpinBox_DX2->show(); + GroupArgs->SpinBox_DY2->show(); + GroupArgs->CheckButton1->show(); } break; } + GroupArgs->PushButton1->click(); + qApp->processEvents(); updateGeometry(); resize(minimumSizeHint()); @@ -289,33 +257,39 @@ void TransformationGUI_MultiRotationDlg::SelectionIntoArgument() { erasePreview(); - TopAbs_ShapeEnum aNeedType = ( myEditCurrentArgument == GroupPoints->LineEdit2 || - myEditCurrentArgument == GroupDimensions->LineEdit2 ) ? + TopAbs_ShapeEnum aNeedType = ( myEditCurrentArgument == GroupArgs->LineEdit2 ) ? TopAbs_EDGE : TopAbs_SHAPE; GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType ); TopoDS_Shape aShape; if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) { QString aName = GEOMBase::GetName( aSelectedObject.get() ); myEditCurrentArgument->setText( aName ); - if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) { - myBase = aSelectedObject; - if ( !myVector ) - GroupPoints->PushButton2->click(); - } - else if ( myEditCurrentArgument == GroupPoints->LineEdit2) { - myVector = aSelectedObject; - if ( !myBase ) - GroupPoints->PushButton1->click(); - } - else if ( myEditCurrentArgument == GroupDimensions->LineEdit1 ) { + if ( myEditCurrentArgument == GroupArgs->LineEdit1 ) { myBase = aSelectedObject; + + // recompute myAng and myStep (Mantis issue 0021718) + GEOM::GEOM_IMeasureOperations_var anOper = getGeomEngine()->GetIMeasureOperations(getStudyId()); + double Xmin, Xmax, Ymin, Ymax, Zmin, Zmax; + anOper->GetBoundingBox(myBase.get(), Xmin, Xmax, Ymin, Ymax, Zmin, Zmax); + if (anOper->IsDone()) { + // angular step + double diag = sqrt((Xmax-Xmin)*(Xmax-Xmin) + (Ymax-Ymin)*(Ymax-Ymin)); + double d = sqrt((0.5*(Xmax+Xmin))*(0.5*(Xmax+Xmin)) + (0.5*(Ymax+Ymin))*(0.5*(Ymax+Ymin))); + myAng = floor(2.0 * atan(diag/d) * 180.0 / M_PI); + GroupArgs->SpinBox_DX1->setValue(myAng); + + // radial step + myStep = Max(floor(1.5*(Xmax-Xmin)), floor(1.5*(Ymax-Ymin))); + GroupArgs->SpinBox_DX2->setValue(myStep); + } + if ( !myVector ) - GroupDimensions->PushButton2->click(); + GroupArgs->PushButton2->click(); } - else if ( myEditCurrentArgument == GroupDimensions->LineEdit2 ) { + else if ( myEditCurrentArgument == GroupArgs->LineEdit2 ) { myVector = aSelectedObject; if ( !myBase ) - GroupDimensions->PushButton1->click(); + GroupArgs->PushButton1->click(); } // clear selection @@ -325,11 +299,9 @@ void TransformationGUI_MultiRotationDlg::SelectionIntoArgument() this, SLOT(SelectionIntoArgument())); } else { - if ( myEditCurrentArgument == GroupPoints->LineEdit1 || - myEditCurrentArgument == GroupDimensions->LineEdit1 ) + if ( myEditCurrentArgument == GroupArgs->LineEdit1 ) myBase.nullify(); - else if ( myEditCurrentArgument == GroupPoints->LineEdit2 || - myEditCurrentArgument == GroupDimensions->LineEdit2 ) + else if ( myEditCurrentArgument == GroupArgs->LineEdit2 ) myVector.nullify(); myEditCurrentArgument->setText(""); } @@ -348,33 +320,19 @@ void TransformationGUI_MultiRotationDlg::SetEditCurrentArgument() disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); globalSelection(GEOM_ALLSHAPES); - if (send == GroupPoints->PushButton1) { - myEditCurrentArgument = GroupPoints->LineEdit1; - - GroupPoints->PushButton2->setDown(false); - GroupPoints->LineEdit2->setEnabled(false); - } - else if (send == GroupPoints->PushButton2) { - myEditCurrentArgument = GroupPoints->LineEdit2; - - localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE); - - GroupPoints->PushButton1->setDown(false); - GroupPoints->LineEdit1->setEnabled(false); - } - else if (send == GroupDimensions->PushButton1) { - myEditCurrentArgument = GroupDimensions->LineEdit1; + if (send == GroupArgs->PushButton1) { + myEditCurrentArgument = GroupArgs->LineEdit1; - GroupDimensions->PushButton2->setDown(false); - GroupDimensions->LineEdit2->setEnabled(false); + GroupArgs->PushButton2->setDown(false); + GroupArgs->LineEdit2->setEnabled(false); } - else if (send == GroupDimensions->PushButton2) { - myEditCurrentArgument = GroupDimensions->LineEdit2; + else if (send == GroupArgs->PushButton2) { + myEditCurrentArgument = GroupArgs->LineEdit2; localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE); - GroupDimensions->PushButton1->setDown(false); - GroupDimensions->LineEdit1->setEnabled(false); + GroupArgs->PushButton1->setDown(false); + GroupArgs->LineEdit1->setEnabled(false); } connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); @@ -416,12 +374,13 @@ void TransformationGUI_MultiRotationDlg::enterEvent (QEvent*) // function : TextValueChangedInSpinBox() // purpose : //================================================================================= -void TransformationGUI_MultiRotationDlg::TextValueChangedInSpinBox(const QString& s){ +void TransformationGUI_MultiRotationDlg::TextValueChangedInSpinBox (const QString& s) +{ bool isDigit; s.toDouble(&isDigit); - if(!isDigit) - GroupDimensions->CheckButton1->setChecked(false); - GroupDimensions->CheckButton1->setEnabled(isDigit); + if (!isDigit) + GroupArgs->CheckButton1->setChecked(false); + GroupArgs->CheckButton1->setEnabled(isDigit); } //================================================================================= @@ -432,9 +391,9 @@ void TransformationGUI_MultiRotationDlg::ValueChangedInSpinBox (double newValue) { QObject* send = (QObject*)sender(); - if (send == GroupDimensions->SpinBox_DX1) + if (send == GroupArgs->SpinBox_DX1) myAng = newValue; - else if (send == GroupDimensions->SpinBox_DX2) + else if (send == GroupArgs->SpinBox_DX2) myStep = newValue; processPreview(); @@ -448,9 +407,9 @@ void TransformationGUI_MultiRotationDlg::ValueChangedInSpinBox (int newValue) { QObject* send = (QObject*)sender(); - if (send == GroupPoints->SpinBox_DX || send == GroupDimensions->SpinBox_DY1) + if (send == GroupArgs->SpinBox_DY1) myNbTimes1 = newValue; - else if (send == GroupDimensions->SpinBox_DY2) + else if (send == GroupArgs->SpinBox_DY2) myNbTimes2 = newValue; processPreview(); @@ -458,7 +417,7 @@ void TransformationGUI_MultiRotationDlg::ValueChangedInSpinBox (int newValue) //================================================================================= // function : ReverseAngle() -// purpose : 'state' not used here +// purpose : //================================================================================= void TransformationGUI_MultiRotationDlg::ReverseAngle() { @@ -467,11 +426,22 @@ void TransformationGUI_MultiRotationDlg::ReverseAngle() int aConstructorId = getConstructorId(); if (aConstructorId == 1) - GroupDimensions->SpinBox_DX1->setValue(myAng); + GroupArgs->SpinBox_DX1->setValue(myAng); processPreview(); } +//================================================================================= +// function : CheckAngleStep() +// purpose : +//================================================================================= +void TransformationGUI_MultiRotationDlg::CheckAngleStep (bool isOn) +{ + GroupArgs->SpinBox_DX1->setEnabled(isOn); + GroupArgs->CheckButton1->setEnabled(isOn); + processPreview(); +} + //================================================================================= // function : createOperation // purpose : @@ -488,16 +458,20 @@ GEOM::GEOM_IOperations_ptr TransformationGUI_MultiRotationDlg::createOperation() bool TransformationGUI_MultiRotationDlg::isValid (QString& msg) { bool ok = false; - switch(getConstructorId()){ + switch (getConstructorId()) { case 0: - ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) && myBase && myVector; + ok = (GroupArgs->SpinBox_DX1->isValid( msg, !IsPreview() ) && + GroupArgs->SpinBox_DY1->isValid( msg, !IsPreview() ) && + //myBase && myVector); // myVector = DZ by default + myBase); break; case 1: - ok = GroupDimensions->SpinBox_DX1->isValid( msg, !IsPreview() ) && - GroupDimensions->SpinBox_DY1->isValid( msg, !IsPreview() ) && - GroupDimensions->SpinBox_DX2->isValid( msg, !IsPreview() ) && - GroupDimensions->SpinBox_DY2->isValid( msg, !IsPreview() ) && - myBase && myVector; + ok = (GroupArgs->SpinBox_DX1->isValid( msg, !IsPreview() ) && + GroupArgs->SpinBox_DY1->isValid( msg, !IsPreview() ) && + GroupArgs->SpinBox_DX2->isValid( msg, !IsPreview() ) && + GroupArgs->SpinBox_DY2->isValid( msg, !IsPreview() ) && + //myBase && myVector); // myVector = DZ by default + myBase); break; default: break; @@ -520,29 +494,38 @@ bool TransformationGUI_MultiRotationDlg::execute (ObjectList& objects) switch (getConstructorId()) { case 0: - if ( myBase && myVector ) { + if (GroupArgs->CheckAngleStep->isChecked()) + anObj = anOper->MultiRotate1DByStep(myBase.get(), myVector.get(), myAng * M_PI / 180., myNbTimes1); + else anObj = anOper->MultiRotate1D(myBase.get(), myVector.get(), myNbTimes1); - if(!IsPreview()) - aParameters<SpinBox_DX->text(); - res = true; + + if (!IsPreview()) { + if (GroupArgs->CheckAngleStep->isChecked()) + aParameters << GroupArgs->SpinBox_DX1->text(); + aParameters << GroupArgs->SpinBox_DY1->text(); } + res = true; break; case 1: - if ( myBase && myVector ) { - anObj = anOper->MultiRotate2D(myBase.get(), myVector.get(), myAng, myNbTimes1, myStep, myNbTimes2); - if(!IsPreview()) { - aParameters<SpinBox_DX1->text(); - aParameters<SpinBox_DY1->text(); - aParameters<SpinBox_DX2->text(); - aParameters<SpinBox_DY2->text(); - } - res = true; + if (GroupArgs->CheckAngleStep->isChecked()) + anObj = anOper->MultiRotate2DByStep(myBase.get(), myVector.get(), myAng * M_PI / 180., myNbTimes1, + myStep, myNbTimes2); + else + anObj = anOper->MultiRotate2DNbTimes(myBase.get(), myVector.get(), myNbTimes1, myStep, myNbTimes2); + + if (!IsPreview()) { + if (GroupArgs->CheckAngleStep->isChecked()) + aParameters << GroupArgs->SpinBox_DX1->text(); + aParameters << GroupArgs->SpinBox_DY1->text(); + aParameters << GroupArgs->SpinBox_DX2->text(); + aParameters << GroupArgs->SpinBox_DY2->text(); } + res = true; break; } if (!anObj->_is_nil()) { - if(!IsPreview()) + if (!IsPreview()) anObj->SetParameters(aParameters.join(":").toLatin1().constData()); objects.push_back(anObj._retn()); } @@ -586,3 +569,82 @@ void TransformationGUI_MultiRotationDlg::restoreSubShapes (SALOMEDS::Study_ptr mainFrame()->CheckBoxAddPrefix->isChecked()); } } + +//================================================================================= +// function : TransformationGUI_2Sel4Spin1Check +// purpose : +//================================================================================= +TransformationGUI_2Sel4Spin1Check::TransformationGUI_2Sel4Spin1Check (QWidget *parent) +{ + gridLayout = new QGridLayout (parent); + gridLayout->setSpacing(6); + gridLayout->setContentsMargins(11, 11, 11, 11); + gridLayout->setHorizontalSpacing(0); + gridLayout->setVerticalSpacing(0); + gridLayout->setContentsMargins(0, 0, 0, 0); + + GroupBox1 = new QGroupBox (parent); + + gridLayout1 = new QGridLayout (GroupBox1); + gridLayout1->setSpacing(6); + gridLayout1->setContentsMargins(11, 11, 11, 11); + gridLayout1->setHorizontalSpacing(6); + gridLayout1->setVerticalSpacing(6); + gridLayout1->setContentsMargins(9, 9, 9, 9); + + // 2Sel + TextLabel1 = new QLabel(GroupBox1); + TextLabel2 = new QLabel(GroupBox1); + + PushButton1 = new QPushButton (GroupBox1); + PushButton2 = new QPushButton (GroupBox1); + + LineEdit2 = new QLineEdit(GroupBox1); + LineEdit1 = new QLineEdit(GroupBox1); + + gridLayout1->addWidget(TextLabel1, 0, 0, 1, 1); + gridLayout1->addWidget(TextLabel2, 1, 0, 1, 1); + gridLayout1->addWidget(PushButton1, 0, 1, 1, 1); + gridLayout1->addWidget(PushButton2, 1, 1, 1, 1); + gridLayout1->addWidget(LineEdit1, 0, 2, 1, 1); + gridLayout1->addWidget(LineEdit2, 1, 2, 1, 1); + + // 4Spin (double-int-double-int) + //TextLabel3 = new QLabel (GroupBox1); + CheckAngleStep = new QCheckBox (GroupBox1); + TextLabel4 = new QLabel (GroupBox1); + TextLabel5 = new QLabel (GroupBox1); + TextLabel6 = new QLabel (GroupBox1); + + SpinBox_DX1 = new SalomeApp_DoubleSpinBox (GroupBox1); + SpinBox_DY1 = new SalomeApp_IntSpinBox (GroupBox1); + SpinBox_DX2 = new SalomeApp_DoubleSpinBox (GroupBox1); + SpinBox_DY2 = new SalomeApp_IntSpinBox (GroupBox1); + + //gridLayout1->addWidget(TextLabel3, 2, 0, 1, 1); + gridLayout1->addWidget(CheckAngleStep, 2, 0, 1, 1); + gridLayout1->addWidget(TextLabel4, 3, 0, 1, 1); + gridLayout1->addWidget(TextLabel5, 5, 0, 1, 1); + gridLayout1->addWidget(TextLabel6, 6, 0, 1, 1); + + gridLayout1->addWidget(SpinBox_DX1, 2, 1, 1, 2); + gridLayout1->addWidget(SpinBox_DY1, 3, 1, 1, 2); + gridLayout1->addWidget(SpinBox_DX2, 5, 1, 1, 2); + gridLayout1->addWidget(SpinBox_DY2, 6, 1, 1, 2); + + // 1Check + CheckButton1 = new QCheckBox (GroupBox1); + + gridLayout1->addWidget(CheckButton1, 4, 0, 1, 3); + + gridLayout->addWidget(GroupBox1, 0, 0, 1, 1); +} + +//================================================================================= +// function : ~TransformationGUI_2Sel4Spin1Check() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +TransformationGUI_2Sel4Spin1Check::~TransformationGUI_2Sel4Spin1Check() +{ + // no need to delete child widgets, Qt does it all for us +} diff --git a/src/TransformationGUI/TransformationGUI_MultiRotationDlg.h b/src/TransformationGUI/TransformationGUI_MultiRotationDlg.h index fac7bd502..ed4268145 100644 --- a/src/TransformationGUI/TransformationGUI_MultiRotationDlg.h +++ b/src/TransformationGUI/TransformationGUI_MultiRotationDlg.h @@ -18,34 +18,78 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// // GEOM GEOMGUI : GUI for Geometry component // File : TransformationGUI_MultiRotationDlg.h // Author : Damien COQUERET, Open CASCADE S.A.S. -// + #ifndef TRANSFORMATIONGUI_MULTIROTATIONDLG_H #define TRANSFORMATIONGUI_MULTIROTATIONDLG_H #include "GEOMBase_Skeleton.h" #include "GEOM_GenericObjPtr.h" -class DlgRef_2Sel4Spin1Check; -class DlgRef_2Sel1SpinInt; +#include + +#include +#include +#include +#include +#include +#include + +//================================================================================= +// class : TransformationGUI_2Sel4Spin1Check +// purpose : +//================================================================================= +class TransformationGUI_2Sel4Spin1Check : public QWidget +{ + Q_OBJECT + + public: + TransformationGUI_2Sel4Spin1Check (QWidget *parent); + ~TransformationGUI_2Sel4Spin1Check(); + + public: + QGridLayout *gridLayout; + QGroupBox *GroupBox1; + QGridLayout *gridLayout1; + + // 2Sel + QLabel *TextLabel1; + QLabel *TextLabel2; + QPushButton *PushButton1; + QPushButton *PushButton2; + QLineEdit *LineEdit1; + QLineEdit *LineEdit2; + + // 4Spin (double-int-double-int) + QCheckBox *CheckAngleStep; + QLabel *TextLabel4; + QLabel *TextLabel5; + QLabel *TextLabel6; + SalomeApp_DoubleSpinBox *SpinBox_DX1; + SalomeApp_IntSpinBox *SpinBox_DY1; + SalomeApp_DoubleSpinBox *SpinBox_DX2; + SalomeApp_IntSpinBox *SpinBox_DY2; + + // 1Check + QCheckBox *CheckButton1; +}; //================================================================================= // class : TransformationGUI_MultiRotationDlg // purpose : //================================================================================= class TransformationGUI_MultiRotationDlg : public GEOMBase_Skeleton -{ +{ Q_OBJECT public: - TransformationGUI_MultiRotationDlg( GeometryGUI*, QWidget* = 0, - bool = false, Qt::WindowFlags = 0 ); + TransformationGUI_MultiRotationDlg (GeometryGUI*, QWidget* = 0, + bool = false, Qt::WindowFlags = 0); ~TransformationGUI_MultiRotationDlg(); - + protected: // redefined from GEOMBase_Helper virtual GEOM::GEOM_IOperations_ptr createOperation(); @@ -57,7 +101,7 @@ protected: private: void Init(); void enterEvent( QEvent* ); - + private: GEOM::GeomObjPtr myBase, myVector; int myNbTimes1; @@ -67,9 +111,8 @@ private: // to initialize the first selection field with a selected object on the dialog creation bool myInitial; - - DlgRef_2Sel1SpinInt* GroupPoints; - DlgRef_2Sel4Spin1Check* GroupDimensions; + + TransformationGUI_2Sel4Spin1Check* GroupArgs; private slots: void ClickOnOk(); @@ -77,6 +120,7 @@ private slots: void ActivateThisDialog(); void SelectionIntoArgument(); void SetEditCurrentArgument(); + void CheckAngleStep (bool); void ReverseAngle(); void ValueChangedInSpinBox( double ); void ValueChangedInSpinBox( int ); diff --git a/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.cxx b/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.cxx index 352f88c2e..60eb1f981 100644 --- a/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.cxx +++ b/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.cxx @@ -82,10 +82,10 @@ TransformationGUI_MultiTranslationDlg::TransformationGUI_MultiTranslationDlg GroupPoints = new DlgRef_2Sel2Spin1Check(centralWidget()); GroupPoints->GroupBox1->setTitle(tr("GEOM_MULTITRANSLATION_SIMPLE")); GroupPoints->TextLabel1->setText(tr("GEOM_MAIN_OBJECT")); - GroupPoints->TextLabel2->setText(tr("GEOM_VECTOR_U")); - GroupPoints->TextLabel3->setText(tr("GEOM_STEP_U")); - GroupPoints->TextLabel4->setText(tr("GEOM_NB_TIMES_U")); - GroupPoints->CheckButton1->setText(tr("GEOM_REVERSE_U")); + GroupPoints->TextLabel2->setText(tr("GEOM_VECTOR")); + GroupPoints->TextLabel3->setText(tr("GEOM_STEP")); + GroupPoints->TextLabel4->setText(tr("GEOM_NB_TIMES")); + GroupPoints->CheckButton1->setText(tr("GEOM_REVERSE_DIRECTION")); GroupPoints->PushButton1->setIcon(image2); GroupPoints->PushButton2->setIcon(image2); GroupPoints->LineEdit1->setReadOnly(true); @@ -142,7 +142,7 @@ void TransformationGUI_MultiTranslationDlg::Init() int SpecificStep = 1; // init variables myStepU = myStepV = 50.0; - myNbTimesU = myNbTimesV = 2; + myNbTimesU = myNbTimesV = 3; // min, max, step and decimals for spin boxes & initial values initSpinBox(GroupPoints->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" ); @@ -328,9 +328,20 @@ void TransformationGUI_MultiTranslationDlg::SelectionIntoArgument() if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) { QString aName = GEOMBase::GetName( aSelectedObject.get() ); myEditCurrentArgument->setText( aName ); + if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) { myBase = aSelectedObject; - if ( !myVectorU ) + + // recompute myStepU (Mantis issue 0021718) + GEOM::GEOM_IMeasureOperations_var anOper = getGeomEngine()->GetIMeasureOperations(getStudyId()); + double Xmin, Xmax, Ymin, Ymax, Zmin, Zmax; + anOper->GetBoundingBox(myBase.get(), Xmin, Xmax, Ymin, Ymax, Zmin, Zmax); + if (anOper->IsDone()) { + myStepU = floor(1.5 * (Xmax - Xmin)); + GroupPoints->SpinBox_DX->setValue(myStepU); + } + + if (!myVectorU) GroupPoints->PushButton2->click(); } else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) { @@ -340,6 +351,18 @@ void TransformationGUI_MultiTranslationDlg::SelectionIntoArgument() } else if ( myEditCurrentArgument == GroupDimensions->LineEdit1 ) { myBase = aSelectedObject; + + // recompute myStepU and myStepV (Mantis issue 0021718) + GEOM::GEOM_IMeasureOperations_var anOper = getGeomEngine()->GetIMeasureOperations(getStudyId()); + double Xmin, Xmax, Ymin, Ymax, Zmin, Zmax; + anOper->GetBoundingBox(myBase.get(), Xmin, Xmax, Ymin, Ymax, Zmin, Zmax); + if (anOper->IsDone()) { + myStepU = floor(1.5 * (Xmax - Xmin)); + myStepV = floor(1.5 * (Ymax - Ymin)); + GroupDimensions->SpinBox_DX1->setValue(myStepU); + GroupDimensions->SpinBox_DX2->setValue(myStepV); + } + if ( !myVectorU ) GroupDimensions->PushButton2->click(); else if ( !myVectorV ) @@ -597,18 +620,20 @@ GEOM::GEOM_IOperations_ptr TransformationGUI_MultiTranslationDlg::createOperatio bool TransformationGUI_MultiTranslationDlg::isValid (QString& msg) { bool ok = false; - switch ( getConstructorId() ) { + switch (getConstructorId()) { case 0: ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) && GroupPoints->SpinBox_DY->isValid( msg, !IsPreview() ) && - myBase && myVectorU; + myBase; + //myBase && myVectorU; // Mantis issue 0021718 break; case 1: ok = GroupDimensions->SpinBox_DX1->isValid( msg, !IsPreview() ) && GroupDimensions->SpinBox_DY1->isValid( msg, !IsPreview() ) && GroupDimensions->SpinBox_DX2->isValid( msg, !IsPreview() ) && GroupDimensions->SpinBox_DY2->isValid( msg, !IsPreview() ) && - myBase && myVectorU && myVectorV; + myBase; + //myBase && myVectorU && myVectorV; // Mantis issue 0021718 break; default: break; @@ -625,43 +650,38 @@ bool TransformationGUI_MultiTranslationDlg::execute (ObjectList& objects) bool res = false; GEOM::GEOM_Object_var anObj; - QStringList aParameters; GEOM::GEOM_ITransformOperations_var anOper = GEOM::GEOM_ITransformOperations::_narrow(getOperation()); switch (getConstructorId()) { case 0: - if ( myBase && myVectorU ) { - createPathPreview ( myVectorU.get() ); - anObj = anOper->MultiTranslate1D(myBase.get(), myVectorU.get(), myStepU, myNbTimesU); - if(!IsPreview()) { - aParameters<SpinBox_DX->text(); - aParameters<SpinBox_DY->text(); - } - res = true; + createPathPreview(myVectorU.get()); + anObj = anOper->MultiTranslate1D(myBase.get(), myVectorU.get(), myStepU, myNbTimesU); + if (!IsPreview()) { + aParameters << GroupPoints->SpinBox_DX->text(); + aParameters << GroupPoints->SpinBox_DY->text(); } + res = true; break; case 1: - if ( myBase && myVectorU && myVectorV ) { - createPathPreview ( myVectorU.get() ); - createPathPreview ( myVectorV.get() ); - anObj = anOper->MultiTranslate2D(myBase.get(), - myVectorU.get(), myStepU, myNbTimesU, - myVectorV.get(), myStepV, myNbTimesV); - if(!IsPreview()) { - aParameters<SpinBox_DX1->text(); - aParameters<SpinBox_DY1->text(); - aParameters<SpinBox_DX2->text(); - aParameters<SpinBox_DY2->text(); - } - res = true; + createPathPreview(myVectorU.get()); + createPathPreview(myVectorV.get()); + anObj = anOper->MultiTranslate2D(myBase.get(), + myVectorU.get(), myStepU, myNbTimesU, + myVectorV.get(), myStepV, myNbTimesV); + if (!IsPreview()) { + aParameters << GroupDimensions->SpinBox_DX1->text(); + aParameters << GroupDimensions->SpinBox_DY1->text(); + aParameters << GroupDimensions->SpinBox_DX2->text(); + aParameters << GroupDimensions->SpinBox_DY2->text(); } + res = true; break; } if (!anObj->_is_nil()) { - if(!IsPreview()) + if (!IsPreview()) anObj->SetParameters(aParameters.join(":").toLatin1().constData()); objects.push_back(anObj._retn()); } @@ -716,6 +736,7 @@ void TransformationGUI_MultiTranslationDlg::restoreSubShapes (SALOMEDS::Study_pt void TransformationGUI_MultiTranslationDlg::createPathPreview ( GEOM::GEOM_Object_ptr thePath ) { if ( IsPreview() ) { + if (thePath->_is_nil()) return; TopoDS_Shape aShape; GEOMBase::GetShape( thePath, aShape, TopAbs_SHAPE ); TopoDS_Edge anEdge = TopoDS::Edge( aShape ); diff --git a/src/VTKExport/Makefile.am b/src/VTKExport/Makefile.am index a3485f69e..976cfbab2 100644 --- a/src/VTKExport/Makefile.am +++ b/src/VTKExport/Makefile.am @@ -17,8 +17,6 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -# $Header$ -# include $(top_srcdir)/adm_local/unix/make_common_starter.am # header files