From: jfa Date: Wed, 12 Sep 2012 10:41:33 +0000 (+0000) Subject: Mantis issue 0021392: EDF 1631 GEOM: Dump study of sketcher 3D with relatives coordin... X-Git-Tag: V6_6_0a1~24 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3cdf240cf13ef41475158e8dd8c6d7e479b8cc2a;p=modules%2Fgeom.git Mantis issue 0021392: EDF 1631 GEOM: Dump study of sketcher 3D with relatives coordinates. --- diff --git a/doc/salome/gui/GEOM/doxyfile_py.in b/doc/salome/gui/GEOM/doxyfile_py.in index c35ee2024..bd50daa50 100755 --- a/doc/salome/gui/GEOM/doxyfile_py.in +++ b/doc/salome/gui/GEOM/doxyfile_py.in @@ -99,8 +99,8 @@ EXAMPLE_RECURSIVE = NO #--------------------------------------------------------------------------- #Input related options #--------------------------------------------------------------------------- -INPUT = . @top_srcdir@/idl -FILE_PATTERNS = geompy.py GEOM_Gen.idl +INPUT = geompy.py @top_srcdir@/src/GEOM_SWIG/gsketcher.py @top_srcdir@/idl/GEOM_Gen.idl +FILE_PATTERNS = IMAGE_PATH = @srcdir@/images EXAMPLE_PATH = @top_srcdir@/src/GEOM_SWIG RECURSIVE = NO diff --git a/doc/salome/gui/GEOM/images/3dsketch2.png b/doc/salome/gui/GEOM/images/3dsketch2.png index 51f171d9f..1925ecfd8 100755 Binary files a/doc/salome/gui/GEOM/images/3dsketch2.png and b/doc/salome/gui/GEOM/images/3dsketch2.png differ diff --git a/doc/salome/gui/GEOM/input/creating_3dsketcher.doc b/doc/salome/gui/GEOM/input/creating_3dsketcher.doc index fcc0ba56d..651ebc461 100755 --- a/doc/salome/gui/GEOM/input/creating_3dsketcher.doc +++ b/doc/salome/gui/GEOM/input/creating_3dsketcher.doc @@ -2,41 +2,56 @@ \page create_3dsketcher_page 3D Sketcher -3D Sketcher allows creating a closed or unclosed 3D wire from a list of points. +3D Sketcher allows creating a closed or unclosed 3D wire, made of +consequent straight segments. To create a 3D Sketch, select in the main menu New Entity -> Basic -> 3D Sketch. \image html 3dsketch2.png -In this dialog it is possible to define the coordinates of the points. +The first sketcher point can be defined by \b Absolute coordinates X, Y and Z. +When the first point is defined, it is possible to add straight segments. +Each segment will start at the end point of previous segment or at the +sketcher first point, if there are no validated segments. -The position of each point can be defined by \b Absolute coordinates X, Y, Z or -by \b Relative coordinates DX, DY, DZ with respect to the previous Applied point. -The type of coordinates can be selected by the Coordinates Type +Segment can be defined by: + - \b Absolute coordinates X, Y and Z of its second end, + - \b Relative coordinates DX, DY and DZ of its second end with + respect to the previous applied point, + - \b Direction and \b Length of the segment. Direction is set by two + \b Angles in selected coordinate system. + +The way of segment construction can be selected by the Coordinates Type radio buttons. -To add the point in the list of points and to proceed with the -definition of the next point, click Apply button. \b Undo and -\b Redo buttons, respectively, remove or restore the last point in the list. +To validate the segment and to proceed with the definition of the next +segment, click Apply button. \b Undo and \b Redo buttons, +respectively, remove or restore the last segment in the wire. \n "Sketch Validation" button applies the wire, built by the user, "as is". \n "Sketch Closure" closes the Sketch by a straight line from the start to the end point and applies it. -To make a closed wire using the TUI command, the first and the last point should -have the same coordinates. - -The Result of the operation will be a \b GEOM_Object. - -TUI Command: geompy.Make3DSketcher( [ PointsList ] ) -This algorithm creates a wire from the list of real values, which define XYZ -coordinates of points. - Example: \image html 3dsketch1.png +TUI Command: geompy.Make3DSketcher( [ PointsList ] ) +This algorithm creates a wire from the list of real values, which +define absolute XYZ coordinates of points. The Result of the operation +will be a \b GEOM_Object. + +\note To make a closed wire using this TUI command, the first and the +last point should have the same coordinates. + +\n Another way to create the 3D Sketcher in TUI is using Sketcher3D +interface. +TUI Command: sk = geompy.Sketcher3D() +Returns an instance of Sketcher3D interface sk. +Use the below examples and see the \ref gsketcher.Sketcher3D "Sketcher3D" +interface documentation for more information. + Our TUI Scripts provide you with useful examples of the use of \ref tui_3dsketcher_page "3D Sketcher". */ diff --git a/doc/salome/gui/GEOM/input/tui_3dsketcher.doc b/doc/salome/gui/GEOM/input/tui_3dsketcher.doc index c9760fbcf..4916dfce2 100755 --- a/doc/salome/gui/GEOM/input/tui_3dsketcher.doc +++ b/doc/salome/gui/GEOM/input/tui_3dsketcher.doc @@ -7,14 +7,43 @@ import geompy import salome gg = salome.ImportComponentGUI("GEOM") -# create a 3D sketcher (wire) of the given points coordinates +# 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") +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 -*/ \ No newline at end of file +*/ diff --git a/src/GEOMGUI/GEOM_msg_en.ts b/src/GEOMGUI/GEOM_msg_en.ts index 4f503aae2..e677b0980 100644 --- a/src/GEOMGUI/GEOM_msg_en.ts +++ b/src/GEOMGUI/GEOM_msg_en.ts @@ -1842,6 +1842,10 @@ Please, select face, shell or solid and try again GEOM_COORDINATES_TYPE Coordinates Type + + GEOM_CONTROLS + Dimensions + GEOM_SOLID Solid diff --git a/src/GEOM_SWIG/GEOM_TestAll.py b/src/GEOM_SWIG/GEOM_TestAll.py index 3e7c14dc2..550cd7843 100644 --- a/src/GEOM_SWIG/GEOM_TestAll.py +++ b/src/GEOM_SWIG/GEOM_TestAll.py @@ -105,8 +105,18 @@ def TestAll (geompy, math): Interpol = geompy.MakeInterpol([px, py, p200, pxyz], True) #(List of GEOM_Object,Boolean)->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 - Sketcher3d = geompy.Make3DSketcher([0,0,0, 50,50,50, 0,50,50, 10,0,0]) - + + #Create 3D wires with 3D Sketcher + sk = geompy.Sketcher3D() + sk.addPointsAbsolute(0,0,0, 70,0,0) + sk.addPointsRelative(0, 0, 130) + sk.addPointAnglesLength("OXY", 50, 0, 100) + sk.addPointAnglesLength("OXZ", 30, 80, 130) + sk.close() + Sketcher3d_1 = sk.wire() + + Sketcher3d_2 = geompy.Make3DSketcher([0,0,0, 50,50,50, 0,50,50, 10,0,0]) + #Create local coordinate system from shape cs4 = geompy.MakeMarkerFromShape(Plane) @@ -330,7 +340,9 @@ def TestAll (geompy, math): id_Bezier = geompy.addToStudy(Bezier, "Bezier") id_Interpol = geompy.addToStudy(Interpol, "Interpol") id_Sketcher = geompy.addToStudy(Sketcher, "Sketcher") - id_Sketcher3d = geompy.addToStudy(Sketcher3d, "Sketcher 3D") + + id_Sketcher3d_1 = geompy.addToStudy(Sketcher3d_1, "Sketcher 3D by interface") + id_Sketcher3d_2 = geompy.addToStudy(Sketcher3d_2, "Sketcher 3D by list") id_p_on_arc = geompy.addToStudy(p_on_arc, "Vertex on Arc (0.25)") id_p_on_arc2 = geompy.addToStudy(p_on_arc2, "Vertex on Arc at(100, -10, 10)" ) diff --git a/src/GEOM_SWIG/Makefile.am b/src/GEOM_SWIG/Makefile.am index 3fe82e1a4..c9742d239 100644 --- a/src/GEOM_SWIG/Makefile.am +++ b/src/GEOM_SWIG/Makefile.am @@ -35,6 +35,7 @@ include $(top_srcdir)/adm_local/unix/make_common_starter.am dist_salomescript_DATA = \ geompy.py \ geompyDC.py \ + gsketcher.py \ batchmode_geompy.py \ GEOM_Spanner.py \ GEOM_blocks.py \ diff --git a/src/GEOM_SWIG/geompyDC.py b/src/GEOM_SWIG/geompyDC.py index b28726d44..c650b7c1e 100644 --- a/src/GEOM_SWIG/geompyDC.py +++ b/src/GEOM_SWIG/geompyDC.py @@ -88,6 +88,8 @@ import GEOM import math import os +from gsketcher import Sketcher3D + ## Enumeration ShapeType as a dictionary. \n ## Topological types of shapes (like Open Cascade types). See GEOM::shape_type for details. # @ingroup l1_geompy_auxiliary @@ -1739,7 +1741,7 @@ class geompyDC(GEOM._objref_GEOM_Gen): # passing from it. # @return New GEOM.GEOM_Object, containing the created wire. # - # @ref tui_sketcher_page "Example" + # @ref tui_3dsketcher_page "Example" def Make3DSketcher(self, theCoordinates): """ Create a sketcher wire, following the numerical description, @@ -1759,16 +1761,21 @@ class geompyDC(GEOM._objref_GEOM_Gen): return anObj ## Obtain a 3D sketcher interface + # @return An instance of @ref gsketcher.Sketcher3D "Sketcher3D" interface + # + # @ref tui_3dsketcher_page "Example" def Sketcher3D (self): """ + Obtain a 3D sketcher interface. + Example of usage: - sk = geompy.Sketcher3D() - sk.addPointsAbsolute(0, 0, 0) - sk.addPointsAbsolute(70, 0, 0) - sk.addPointsRelative(0, 0, 130) - sk.addPointAnglesLength("OXY", 50, 0, 100) - sk.addPointAnglesLength("OXZ", 30, 80, 130) - a3D_Sketcher_1 = sk.makeWire() + sk = geompy.Sketcher3D() + sk.addPointsAbsolute(0,0,0, 70,0,0) + sk.addPointsRelative(0, 0, 130) + sk.addPointAnglesLength("OXY", 50, 0, 100) + sk.addPointAnglesLength("OXZ", 30, 80, 130) + sk.close() + a3D_Sketcher_1 = sk.wire() """ sk = Sketcher3D (self) return sk @@ -8851,62 +8858,6 @@ class geompyDC(GEOM._objref_GEOM_Gen): RaiseIfFailed("AddTexture", self.InsertOp) return ID -## 3D Sketcher functionality -## Use geompy.Sketcher3D() to obtain an instance of this class -def printVar (var): - if isinstance(var, str): - return "\'%s\'"%var - else: - return "%.7f"%var - -class Sketcher3D: - def __init__(self, geompyD): - self.geompyD = geompyD - self.myCommand = "3DSketcher" - pass - - def addPointsAbsolute (self, *listCoords): - ii = 1 - for cc in listCoords: - if ii == 1: - self.myCommand = self.myCommand + ":TT" - self.myCommand = self.myCommand + " %s"%printVar(cc) - if ii == 3: - ii = 1 - else: - ii = ii + 1 - pass - - def addPointsRelative (self, *listCoords): - ii = 1 - for cc in listCoords: - if ii == 1: - self.myCommand = self.myCommand + ":T" - self.myCommand = self.myCommand + " %s"%printVar(cc) - if ii == 3: - ii = 1 - else: - ii = ii + 1 - pass - - ## axes can be: "OXY", "OYZ" or "OXZ" - def addPointAnglesLength (self, axes, angle1, angle2, length): - self.myCommand = self.myCommand + ":%s %s %s %s" % (axes, printVar(angle1), printVar(angle2), printVar(length)) - pass - - def close (self): - self.myCommand = self.myCommand + ":WW" - pass - - ## Obtain the sketcher result - def wire (self): - Command,Parameters = ParseSketcherCommand(self.myCommand) - wire = self.geompyD.CurvesOp.Make3DSketcherCommand(Command) - self.myCommand = "3DSketcher" - RaiseIfFailed("Sketcher3D", self.geompyD.CurvesOp) - wire.SetParameters(Parameters) - return wire - import omniORB #Register the new proxy for GEOM_Gen omniORB.registerObjref(GEOM._objref_GEOM_Gen._NP_RepositoryId, geompyDC) diff --git a/src/GEOM_SWIG/gsketcher.py b/src/GEOM_SWIG/gsketcher.py new file mode 100644 index 000000000..11cb0771c --- /dev/null +++ b/src/GEOM_SWIG/gsketcher.py @@ -0,0 +1,182 @@ +# -*- coding: iso-8859-1 -*- +# 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 : gsketcher.py +# Author : Julia DOROVSKIKH, Open CASCADE S.A.S. +# Module : GEOM_SWIG + +""" + \namespace geompy + \brief 3D Sketcher interface +""" + +# This method is used by 3D Sketcher functionality +def printVar (var): + if isinstance(var, str): + return "\'%s\'"%var + else: + return "%.7f"%var + +## An interface to build a 3D Sketcher step-by-step. +# Use geompy.Sketcher3D() method to obtain an instance of this class. +# +# @ref tui_3dsketcher_page "Example" +class Sketcher3D: + """ + 3D sketcher interface. + + Example of usage: + sk = geompy.Sketcher3D() + sk.addPointsAbsolute(0,0,0, 70,0,0) + sk.addPointsRelative(0, 0, 130) + sk.addPointAnglesLength("OXY", 50, 0, 100) + sk.addPointAnglesLength("OXZ", 30, 80, 130) + sk.close() + a3D_Sketcher_1 = sk.wire() + """ + + def __init__(self, geompyD): + self.geompyD = geompyD + self.myCommand = "3DSketcher" + pass + + ## Add one or more points, sequentially connected with straight segments. + # Coordinates are considered as absolute. + # If the first point of sketcher is not yet defined, the first point + # from the listCoords will become the first sketcher point. + # @param X1, Y1, Z1, X2, Y2, Z2, ... Coordinates of points + def addPointsAbsolute (self, *listCoords): + """ + Add one or more points, sequentially connected with straight segments. + Coordinates are considered as absolute. + If the first point of sketcher is not yet defined, the first point + from the listCoords will become the first sketcher point. + + Parameters: + X1, Y1, Z1, X2, Y2, Z2, ... Coordinates of points + + Example of usage: + sk = geompy.Sketcher3D() + sk.addPointsAbsolute(0,0,0, 70,0,0) + a3D_Sketcher_1 = sk.wire() + """ + ii = 1 + for cc in listCoords: + if ii == 1: + self.myCommand = self.myCommand + ":TT" + self.myCommand = self.myCommand + " %s"%printVar(cc) + if ii == 3: + ii = 1 + else: + ii = ii + 1 + pass + + ## Add one or more points, sequentially connected with straight segments. + # Coordinates are considered relative to the previous point. + # If the first point of sketcher is not yet defined, the + # origin (0, 0, 0) will become the first sketcher point. + # @param X1, Y1, Z1, X2, Y2, Z2, ... Coordinates of points + def addPointsRelative (self, *listCoords): + """ + Add one or more points, sequentially connected with straight segments. + Coordinates are considered relative to the previous point. + If the first point of sketcher is not yet defined, the + origin (0, 0, 0) will become the first sketcher point. + + Parameters: + X1, Y1, Z1, X2, Y2, Z2, ... Relative coordinates of points + + Example of usage: + sk = geompy.Sketcher3D() + sk.addPointsRelative(0,0,130, 70,0,-130) + a3D_Sketcher_1 = sk.wire() + """ + ii = 1 + for cc in listCoords: + if ii == 1: + self.myCommand = self.myCommand + ":T" + self.myCommand = self.myCommand + " %s"%printVar(cc) + if ii == 3: + ii = 1 + else: + ii = ii + 1 + pass + + ## Add one straight segment, defined by two angles and length. + # If the first point of sketcher is not yet defined, the + # origin (0, 0, 0) will become the first sketcher point. + # @param axes can be: "OXY", "OYZ" or "OXZ" + # @param angle1 angle in a plane, defined by the \a axes + # @param angle2 angle from the plane, defined by the \a axes + # @param length length of the segment + def addPointAnglesLength (self, axes, angle1, angle2, length): + """ + Add one straight segment, defined by two angles and length. + If the first point of sketcher is not yet defined, the + origin (0, 0, 0) will become the first sketcher point. + + Parameters: + axes can be: "OXY", "OYZ" or "OXZ" + angle1 angle in a plane, defined by the \a axes + angle2 angle from the plane, defined by the \a axes + length length of the segment + + Example of usage: + sk = geompy.Sketcher3D() + sk.addPointAnglesLength("OXY", 50, 0, 100) + a3D_Sketcher_1 = sk.wire() + """ + self.myCommand = self.myCommand + ":%s %s %s %s" % (axes, printVar(angle1), printVar(angle2), printVar(length)) + pass + + ## Set to close the wire + def close (self): + """ + Set to close the wire + + Example of usage: + sk = geompy.Sketcher3D() + sk.addPointsRelative(0,0,130, 70,0,-130) + sk.close() + a3D_Sketcher_1 = sk.wire() + """ + self.myCommand = self.myCommand + ":WW" + pass + + ## Obtain the sketcher result. + # @return New GEOM_Object, containing the created wire + def wire (self): + """ + Obtain the sketcher result. + + Returns: + New GEOM_Object, containing the created wire. + + Example of usage: + sk = geompy.Sketcher3D() + sk.addPointsRelative(0,0,130, 70,0,-130) + a3D_Sketcher_1 = sk.wire() + """ + from geompyDC import ParseSketcherCommand, RaiseIfFailed + Command,Parameters = ParseSketcherCommand(self.myCommand) + wire = self.geompyD.CurvesOp.Make3DSketcherCommand(Command) + self.myCommand = "3DSketcher" + RaiseIfFailed("Sketcher3D", self.geompyD.CurvesOp) + wire.SetParameters(Parameters) + return wire