mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-01-26 21:40:33 +05:00
Mantis issue 0021392: EDF 1631 GEOM: Dump study of sketcher 3D with relatives coordinates.
This commit is contained in:
parent
1ca71ca225
commit
3cdf240cf1
@ -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
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 30 KiB |
@ -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 <em>New Entity -> Basic -> 3D Sketch</em>.
|
||||
|
||||
\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 <b>Coordinates Type</b>
|
||||
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 <b>Coordinates Type</b>
|
||||
radio buttons.
|
||||
|
||||
To add the point in the list of points and to proceed with the
|
||||
definition of the next point, click <b>Apply</b> 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 <b>Apply</b> button. \b Undo and \b Redo buttons,
|
||||
respectively, remove or restore the last segment in the wire.
|
||||
|
||||
\n <b>"Sketch Validation"</b> button applies the wire, built by the
|
||||
user, "as is".
|
||||
\n <b>"Sketch Closure"</b> 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.
|
||||
|
||||
<b>TUI Command:</b> <em>geompy.Make3DSketcher( [ PointsList ] )</em>
|
||||
This algorithm creates a wire from the list of real values, which define XYZ
|
||||
coordinates of points.
|
||||
|
||||
<b>Example:</b>
|
||||
|
||||
\image html 3dsketch1.png
|
||||
|
||||
<b>TUI Command:</b> <em>geompy.Make3DSketcher( [ PointsList ] )</em>
|
||||
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.
|
||||
<b>TUI Command:</b> <em>sk = geompy.Sketcher3D()</em>
|
||||
Returns an instance of Sketcher3D interface <i>sk</i>.
|
||||
Use the below examples and see the \ref gsketcher.Sketcher3D "Sketcher3D"
|
||||
interface documentation for more information.
|
||||
|
||||
Our <b>TUI Scripts</b> provide you with useful examples of the use of
|
||||
\ref tui_3dsketcher_page "3D Sketcher".
|
||||
*/
|
||||
|
@ -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
|
||||
|
||||
*/
|
||||
*/
|
||||
|
@ -1842,6 +1842,10 @@ Please, select face, shell or solid and try again</translation>
|
||||
<source>GEOM_COORDINATES_TYPE</source>
|
||||
<translation>Coordinates Type</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>GEOM_CONTROLS</source>
|
||||
<translation>Dimensions</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>GEOM_SOLID</source>
|
||||
<translation>Solid</translation>
|
||||
|
@ -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)" )
|
||||
|
@ -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 \
|
||||
|
@ -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)
|
||||
|
182
src/GEOM_SWIG/gsketcher.py
Normal file
182
src/GEOM_SWIG/gsketcher.py
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user