Merge from V6_main (04/10/2012)

This commit is contained in:
vsr 2012-10-08 11:16:36 +00:00
parent f115d16e43
commit 8180539548
117 changed files with 5877 additions and 1544 deletions

View File

@ -99,8 +99,8 @@ EXAMPLE_RECURSIVE = NO
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
#Input related options #Input related options
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
INPUT = . @top_srcdir@/idl INPUT = geompy.py @top_srcdir@/src/GEOM_SWIG/gsketcher.py @top_srcdir@/idl/GEOM_Gen.idl
FILE_PATTERNS = geompy.py GEOM_Gen.idl FILE_PATTERNS =
IMAGE_PATH = @srcdir@/images IMAGE_PATH = @srcdir@/images
EXAMPLE_PATH = @top_srcdir@/src/GEOM_SWIG EXAMPLE_PATH = @top_srcdir@/src/GEOM_SWIG
RECURSIVE = NO RECURSIVE = NO

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 26 KiB

View File

@ -2,41 +2,56 @@
\page create_3dsketcher_page 3D Sketcher \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>. To create a 3D Sketch, select in the main menu <em>New Entity -> Basic -> 3D Sketch</em>.
\image html 3dsketch2.png \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 Segment can be defined by:
by \b Relative coordinates DX, DY, DZ with respect to the previous Applied point. - \b Absolute coordinates X, Y and Z of its second end,
The type of coordinates can be selected by the <b>Coordinates Type</b> - \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. radio buttons.
To add the point in the list of points and to proceed with the To validate the segment and to proceed with the definition of the next
definition of the next point, click <b>Apply</b> button. \b Undo and segment, click <b>Apply</b> button. \b Undo and \b Redo buttons,
\b Redo buttons, respectively, remove or restore the last point in the list. respectively, remove or restore the last segment in the wire.
\n <b>"Sketch Validation"</b> button applies the wire, built by the \n <b>"Sketch Validation"</b> button applies the wire, built by the
user, "as is". user, "as is".
\n <b>"Sketch Closure"</b> closes the Sketch by a straight line from \n <b>"Sketch Closure"</b> closes the Sketch by a straight line from
the start to the end point and applies it. 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> <b>Example:</b>
\image html 3dsketch1.png \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 Our <b>TUI Scripts</b> provide you with useful examples of the use of
\ref tui_3dsketcher_page "3D Sketcher". \ref tui_3dsketcher_page "3D Sketcher".
*/ */

View File

@ -2,7 +2,12 @@
\page create_dividedcylinder_page DividedCylinder \page create_dividedcylinder_page DividedCylinder
The <b>Divided cylinder</b> object is a cylinder divided into \b blocks for easy hexaedral meshing</b>. The <b>Divided cylinder</b> object is a cylinder divided into \b blocks for easy hexaedral meshing.Two division patterns are available :
<ul>
<li> A square pattern which is frequently used </li>
<li> An hexagonal pattern which ensures a better mesh quality and especially less acute or obtuse angles </li>
</ul>
\image html dividedcylinder.png \image html dividedcylinder.png
@ -13,11 +18,12 @@ Specify the parameters of the DividedCylinder object creation in the opened dial
box and press "Apply" or "Apply & Close" button. box and press "Apply" or "Apply & Close" button.
Result of each operation will be a GEOM_Object. Result of each operation will be a GEOM_Object.
<b>TUI Command:</b> <em>geompy.MakeDividedCylinder(R, H)</em> <b>TUI Command:</b> <em>geompy.MakeDividedCylinder(R, H, Pattern)</em>
<b>Arguments:</b> <b>Arguments:</b>
- \b R - Radius of the cylinder - \b R - Radius of the cylinder
- \b H - Height of the cylinder - \b H - Height of the cylinder
- \b Pattern - Division pattern
\image html dividedcylinder_dlg.png \image html dividedcylinder_dlg.png

View File

@ -2,10 +2,17 @@
\page create_divideddisk_page DividedDisk \page create_divideddisk_page DividedDisk
The <b>Divided disk</b> object is a disk divided into \b blocks. It means that it's a shape <b>prepared for hexaedral meshing</b>. The <b>Divided disk</b> object is a disk divided into \b blocks. It means that it's a shape <b>prepared for hexaedral meshing</b>. Two division patterns are available :
<ul>
<li> A square pattern which is frequently used </li>
<li> An hexagonal pattern which ensures a better mesh quality and especially less acute or obtuse angles </li>
</ul>
\n Moreover this shape can be used as a basis in an \ref create_extrusion_alongpath_page "Extrusion along a path" operation in order to obtain any <b>tube shape</b> prepared for hexaedral meshing \n Moreover this shape can be used as a basis in an \ref create_extrusion_alongpath_page "Extrusion along a path" operation in order to obtain any <b>tube shape</b> prepared for hexaedral meshing
(see example below). (see example below). (Another alternative is to create a 2D mesh on the divided disk and create a 3D mesh by extrusion in the SMESH module.)
Example: Example:
@ -18,27 +25,29 @@ Advanced - > DividedDisk </b>
\n For both operations : \n For both operations :
Specify the parameters of the DividedDisk object creation in the opened dialog Specify the parameters of the DividedDisk object creation in the opened dialog
box and press "Apply" or "Apply & Close" button. box and press "Apply" or "Apply & Close" button.
Result of each operation will be a GEOM_Object. The result of each operation will be a GEOM_Object.
\n First way : by radius and orientation (plane "OXY", "OYZ" or "OZX"). The resulting disk is located at the origin of coordinates \n First way : by radius and orientation (plane "OXY", "OYZ" or "OZX"). The resulting disk is located at the origin of coordinates
<b>TUI Command:</b> <em>geompy.MakeDividedDisk(Radius, Orientation)</em> <b>TUI Command:</b> <em>geompy.MakeDividedDisk(Radius, Orientation, Pattern)</em>
<b>Arguments:</b> <b>Arguments:</b>
- \b Radius - Radius of the disk - \b Radius - Radius of the disk
- \b Orientation - Plane on wich the disk will be built - \b Orientation - Plane on wich the disk will be built
- \b Pattern - Division pattern
\image html divided_disk_dlg.png \image html divided_disk_dlg.png
\n Second way : by giving its center, normal and radius. \n Second way : by giving its center, normal and radius.
<b>TUI Command:</b> <em>geompy.MakeDividedDiskPntVecR(Center, Vector, <b>TUI Command:</b> <em>geompy.MakeDividedDiskPntVecR(Center, Vector,
Radius)</em> Radius, Pattern)</em>
<b>Arguments:</b> <b>Arguments:</b>
- \b Center - Center of the disk - \b Center - Center of the disk
- \b Vector - Normal to the plane of the disk - \b Vector - Normal to the plane of the disk
- \b Radius - Radius of the disk - \b Radius - Radius of the disk
- \b Pattern - Division pattern
\image html divided_disk_PntVecR_dlg.png \image html divided_disk_PntVecR_dlg.png

View File

@ -73,7 +73,7 @@ position of the point on the given face.
\image html point5.png \image html point5.png
Alternatively, it is possible to define 3D coordinates of the point projected on the given face. Alternatively, it is possible to define 3D coordinates of the point projected on the given face.
\n <b>TUI Command:</b> <em>geompy.MakeVertexOnSurface(myFace,X,Y,Z).</em> \n <b>TUI Command:</b> <em>geompy.MakeVertexOnSurfaceByCoord(myFace,X,Y,Z).</em>
\n <b>Arguments:</b> Name + 1 face + 3 coordinate values \n <b>Arguments:</b> Name + 1 face + 3 coordinate values
to project point on the given face. to project point on the given face.

View File

@ -0,0 +1,23 @@
/*!
\page get_non_blocks_page Get Non Blocks
\image html measures2.png
Retrieve all non blocks solids and faces from the given shape.
Collect them in two groups: solids and faces separately.
\n <b>Result:</b> Two or less groups are published in the Object
Browser under the processed object. Reports error if
no bad sub-shapes (solids and faces) have been found.
\n <b>TUI Command:</b>
<em>geompy.GetNonBlocks(Compound).</em> Returns 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 group of all non
quadrangular faces.
See also a \ref tui_get_non_blocks_page "TUI example".
*/

View File

@ -7,7 +7,7 @@ import geompy
import salome import salome
gg = salome.ImportComponentGUI("GEOM") 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 ]) 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 # add object in the study
@ -15,6 +15,35 @@ id_sketcher1 = geompy.addToStudy(sketcher1,"Sketcher1")
# display the sketcher # display the sketcher
gg.createAndDisplayGO(id_sketcher1) 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 \endcode
*/ */

View File

@ -37,6 +37,7 @@ Add_line = geompy.MakeLineTwoPnt(px, py)
arc_face = geompy.MakeFaceWires([Arc, Add_line], 1) arc_face = geompy.MakeFaceWires([Arc, Add_line], 1)
p_on_face1 = geompy.MakeVertexOnSurface(arc_face, 0.5, 0.5) p_on_face1 = geompy.MakeVertexOnSurface(arc_face, 0.5, 0.5)
p_on_face2 = geompy.MakeVertexOnSurfaceByCoord(arc_face, 35, 35, 35) p_on_face2 = geompy.MakeVertexOnSurfaceByCoord(arc_face, 35, 35, 35)
p_on_face3 = geompy.MakeVertexInsideFace(arc_face)
# add objects in the study # add objects in the study
@ -54,6 +55,7 @@ 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_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_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_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 # display vertices
gg.createAndDisplayGO(id_p0) gg.createAndDisplayGO(id_p0)

View File

@ -0,0 +1,32 @@
/*!
\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([box1, box2])
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
*/

View File

@ -17,6 +17,7 @@
<li>\subpage tui_free_faces_page</li> <li>\subpage tui_free_faces_page</li>
<li>\subpage tui_check_shape_page</li> <li>\subpage tui_check_shape_page</li>
<li>\subpage tui_check_compound_of_blocks_page</li> <li>\subpage tui_check_compound_of_blocks_page</li>
<li>\subpage tui_get_non_blocks_page</li>
<li>\subpage tui_check_self_intersections_page</li> <li>\subpage tui_check_self_intersections_page</li>
</ul> </ul>

View File

@ -40,6 +40,9 @@
\anchor swig_MakeVertexOnSurfaceByCoord \anchor swig_MakeVertexOnSurfaceByCoord
\until p_on_face2 \until p_on_face2
\anchor swig_MakeVertexInsideFace
\until p_on_face3
\until S = geompy.MakeRotation \until S = geompy.MakeRotation
\anchor swig_MakeLineTwoFaces \anchor swig_MakeLineTwoFaces

View File

@ -79,6 +79,9 @@
\anchor swig_UnionIDs \anchor swig_UnionIDs
\until print " ", ObjectID \until print " ", ObjectID
\anchor swig_bop_on_groups
\until Box, Group_CL_2_4
\anchor swig_GetType \anchor swig_GetType
\until Type of elements \until Type of elements

View File

@ -35,6 +35,11 @@
\anchor swig_GetOppositeFace \anchor swig_GetOppositeFace
\until id_face41 \until id_face41
\until id_glueALL
\anchor swig_GetNonBlocks
\until Spanner is a
\anchor spanner_continue \anchor spanner_continue
\until return Spanner \until return Spanner

View File

@ -2,7 +2,9 @@
\page tui_working_with_groups_page Working with Groups \page tui_working_with_groups_page Working with Groups
<br><h2>Creation of a group</h2> <br>
\anchor tui_create_groups_anchor
<h2>Creation of a group</h2>
\code \code
import geompy import geompy
@ -42,6 +44,8 @@ gg.createAndDisplayGO(id_group1)
salome.sg.updateObjBrowser(1) salome.sg.updateObjBrowser(1)
\endcode \endcode
\anchor tui_edit_groups_anchor
<br><h2>Adding an object to the group</h2> <br><h2>Adding an object to the group</h2>
\code \code
@ -107,4 +111,108 @@ gg.createAndDisplayGO(id_group1)
salome.sg.updateObjBrowser(1) salome.sg.updateObjBrowser(1)
\endcode \endcode
<br>
\anchor tui_union_groups_anchor
<h2>Union Groups</h2>
\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
<br>
\anchor tui_intersect_groups_anchor
<h2>Intersect Groups</h2>
\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
<br>
\anchor tui_cut_groups_anchor
<h2>Cut Groups</h2>
\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
*/ */

View File

@ -25,6 +25,7 @@ concerning created or imported geometrical objects :
<li>\subpage free_faces_page "Check Free Faces"</li> <li>\subpage free_faces_page "Check Free Faces"</li>
<li>\subpage check_shape_page "Check Shape"</li> <li>\subpage check_shape_page "Check Shape"</li>
<li>\subpage check_compound_of_blocks_page "Check compound of blocks"</li> <li>\subpage check_compound_of_blocks_page "Check compound of blocks"</li>
<li>\subpage get_non_blocks_page "Get non blocks"</li>
<li>\subpage check_self_intersections_page "Detect Self-intersections"</li> <li>\subpage check_self_intersections_page "Detect Self-intersections"</li>
</ul> </ul>

View File

@ -74,18 +74,23 @@ on the viewer background:
<li><b>Select Only</b> provides a filter for exclusive selection of objects of a certain type.</li> <li><b>Select Only</b> provides a filter for exclusive selection of objects of a certain type.</li>
</ul> </ul>
The the following commands appear in the Object Browser context menu The following commands appear in the Object Browser context menu
under certain conditions: under certain conditions:
\image html ob_popup_menu.png <br> \image html ob_popup_menu.png <br>
<ul> <ul>
<li>\ref work_with_groups_page "Create Group" - allows creating groups of geometrical objects.</li> <li>\ref work_with_groups_page "Create Group" - allows creating groups of geometrical objects.</li>
<li><b>Hide Children</b> / <b>Show Children</b> - hides / shows child
<li><b>Conceal child items</b> / <b>Disclose child items</b> - hides / shows child
sub-objects in the Object Browser, if the selected geometric object has sub-objects in the Object Browser, if the selected geometric object has
child objects. When some child objects are hidden, the name of the child objects. When some child objects are hidden, the name of the
parent object is hilghlighted with bold font.</li> parent object is hilghlighted with bold font.</li>
<li><b>Show Only Children</b> - erase in current viewer all objects
and then display only children of the selected object(s).
</li>
<li><b>Unpublish</b> - unpublish the selected geometric object from the Object Browser <li><b>Unpublish</b> - unpublish the selected geometric object from the Object Browser
and erase it from all viewers. To publish unpublished geometric objects select in the and erase it from all viewers. To publish unpublished geometric objects select in the
context menu of the <b>Geometry</b> root object <b>Publish...</b> item. context menu of the <b>Geometry</b> root object <b>Publish...</b> item.

View File

@ -3,13 +3,25 @@
\page work_with_groups_page Working with groups \page work_with_groups_page Working with groups
Creation and editing groups of sub-shapes of a geometrical object makes Creation and editing groups of sub-shapes of a geometrical object makes
handling sub-shapes much easier. This functionality is available in OCC handling sub-shapes much easier. Also some Boolean operations on
viewer only. groups are available.
<br><h2>Create a group</h2> <ul>
<li>\ref create_groups_anchor "Create a Group"</li>
<li>\ref edit_groups_anchor "Edit a Group"</li>
<li>\ref union_groups_anchor "Union Groups"</li>
<li>\ref intersect_groups_anchor "Intersect Groups"</li>
<li>\ref cut_groups_anchor "Cut Groups"</li>
</ul>
<br>
\anchor create_groups_anchor
<h2>Create a group</h2>
\image html image56.png \image html image56.png
This functionality is available in OCC viewer only.
To create a group of sub-shapes of a geometrical object in the main To create a group of sub-shapes of a geometrical object in the main
menu select <b>New entity > Group > Create</b> menu select <b>New entity > Group > Create</b>
\n The following menu will appear: \n The following menu will appear:
@ -72,19 +84,29 @@ ShapeType),</em> where MainShape is a shape for which the group is
created, ShapeType is a type of shapes in the created group. created, ShapeType is a type of shapes in the created group.
\n <b>Arguments:</b> 1 Shape + Type of sub-shape. \n <b>Arguments:</b> 1 Shape + Type of sub-shape.
Our <b>TUI Scripts</b> provide you with useful examples of
\ref tui_create_groups_anchor "Create a Group" operation.
<b>Example:</b> <b>Example:</b>
\image html image193.png "Groups on a cylinder" \image html image193.png "Groups on a cylinder"
<br>
<br><h2>Edit a group</h2> \anchor edit_groups_anchor
<h2>Edit a group</h2>
\image html image57.png \image html image57.png
This functionality is available in OCC viewer only.
To \b Edit an existing group in the main menu select <b>New entity > To \b Edit an existing group in the main menu select <b>New entity >
Group > Edit</b>. This menu is designed in the same way as the Group > Edit</b>. This menu is designed in the same way as the
<b>Create a group</b> menu. <b>Create a group</b> menu.
\n <b>Dialog Box:</b>
\image html editgroup.png
\n The \b Result of the operation will be a \b GEOM_Object. \n The \b Result of the operation will be a \b GEOM_Object.
\n <b>TUI Command:</b> \n <b>TUI Command:</b>
@ -101,11 +123,80 @@ the sub-shape to be removed from the group.</li>
\n <b>Arguments:</b> 1 Shape + its sub-shapes. \n <b>Arguments:</b> 1 Shape + its sub-shapes.
\n <b>Dialog Box:</b> Our <b>TUI Scripts</b> provide you with useful examples of
\ref tui_edit_groups_anchor "Edit a Group" operation.
\image html editgroup.png <br>
\anchor union_groups_anchor
<h2>Union of groups</h2>
This operation allows to create a new group in such a way that all
sub-shapes that are present in the initial groups will be added to
the new one.
<em>To union groups:</em>
<ol>
<li>In the <b>New Entity</b> menu select the \b Group - <b>Union Groups</b> item.
The following dialog box will appear:
\image html groups_union_dlg.png
In this dialog box you should specify the name of the resulting group
and set of groups which will be united.
</li>
<li>Click the \b Apply or <b>Apply and Close</b> button to confirm creation of the group.</li>
</ol>
<b>See Also</b> a sample TUI Script of a
\ref tui_union_groups_anchor "Union of Groups" operation.
<br>
\anchor intersect_groups_anchor
<h2>Intersection of groups</h2>
This operation allows to create a new group in such a way that only
sub-shapes that are present in all initial groups together are added to the
new one.
<em>To intersect groups:</em>
<ol>
<li>In the <b>New Entity</b> menu select the \b Group - <b>Intersect Groups</b> item.
The following dialog box will appear:
\image html groups_intersect_dlg.png
In this dialog box you should specify the name of the resulting group
and set of groups which will be intersected.
</li>
<li>Click the \b Apply or <b>Apply and Close</b> button to confirm creation of the group.</li>
</ol>
<b>See Also</b> a sample TUI Script of an
\ref tui_intersect_groups_anchor "Intersection of Groups" operation.
<br>
\anchor cut_groups_anchor
<h2>Cut of groups</h2>
This operation allows to create a new group in such a way that all
sub-shapes that are present in the main groups but are absent in the
tool groups are added to the new one.
<em>To cut groups:</em>
<ol>
<li>In the <b>New Entity</b> menu select the \b Group - <b>Cut Groups</b> item.
The following dialog box will appear:
\image html groups_cut_dlg.png
In this dialog box you should specify the name of the resulting group
and groups which will be cut.
</li>
<li>Click the \b Apply or <b>Apply and Close</b> button to confirm creation of the
group.</li>
</ol>
Our <b>TUI Scripts</b> provide you with useful examples of Our <b>TUI Scripts</b> provide you with useful examples of
\ref tui_working_with_groups_page "Working with Groups". \ref tui_cut_groups_anchor "Cut of Groups" operation.
*/ */

View File

@ -360,7 +360,8 @@ module GEOM
// # Internal methods (For sub-shape identification) // # Internal methods (For sub-shape identification)
// ###################################################################### // ######################################################################
/*! /*!
* \brief Get geometric shape of the object as a byte stream * \brief Get geometric shape of the object as a byte stream in BRep format
* \note GEOM_IInsertOperations::RestoreShape() method can be used to restore shape from a BRep stream.
*/ */
SALOMEDS::TMPFile GetShapeStream(); SALOMEDS::TMPFile GetShapeStream();
@ -540,6 +541,16 @@ module GEOM
in double theYParameter, in double theYParameter,
in double theZParameter); in double theZParameter);
/*!
* \brief Create a point, which lays on the given face.
* The point will lay in arbitrary place of the face.
* The only condition on it is a non-zero distance to the face boundary.
* 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.
* \return New GEOM_Object, containing the created point.
*/
GEOM_Object MakePointOnFace (in GEOM_Object theFace);
/*! /*!
* \brief Create a point, on two lines intersection. * \brief Create a point, on two lines intersection.
@ -2403,6 +2414,17 @@ module GEOM
string PrintBCErrors (in GEOM_Object theCompound, string PrintBCErrors (in GEOM_Object theCompound,
in BCErrors theErrors); in BCErrors theErrors);
/*!
* \brief Retrieve all non blocks solids and faces from a shape.
*
* \param theShape The shape to explore.
* \param theNonQuads Output parameter. Group of all non quadrangular faces.
*
* \return Group of all non block solids (= not 6 faces, or with 6
* faces, but with the presence of non-quadrangular faces).
*/
GEOM_Object GetNonBlocks (in GEOM_Object theShape, out GEOM_Object theNonQuads);
/*! /*!
* \brief Remove all seam and degenerated edges from \a theShape. * \brief Remove all seam and degenerated edges from \a theShape.
* *
@ -2777,7 +2799,7 @@ module GEOM
* passed through \a theCommand argument. * passed through \a theCommand argument.
* *
* Edges of the resulting wire or face will be arcs of circles and/or linear segments. \n * Edges of the resulting wire or face will be arcs of circles and/or linear segments. \n
* Format of the description string have to be the following: * Format of the description string has to be the following:
* *
* "Sketcher[:F x1 y1]:CMD[:CMD[:CMD...]]" * "Sketcher[:F x1 y1]:CMD[:CMD[:CMD...]]"
* *
@ -2805,32 +2827,60 @@ module GEOM
* coordinates of the working plane. * coordinates of the working plane.
* \param theWorkingPlane Nine double values, defining origin, * \param theWorkingPlane Nine double values, defining origin,
* OZ and OX directions of the working plane. * OZ and OX directions of the working plane.
* \return New GEOM_Object, containing the created wire. * \return New GEOM_Object, containing the created wire or face.
*/ */
GEOM_Object MakeSketcher (in string theCommand, in ListOfDouble theWorkingPlane); GEOM_Object MakeSketcher (in string theCommand, in ListOfDouble theWorkingPlane);
/*!
* \brief Create a 3D sketcher, following the numerical description,
* passed through points created by \a theCoordinates argument.
*
* Format of the description string have to be the following:
*
* "Make3DSketcher[x1, y1, z1, x2, y2, z2, ..., xN, yN, zN]"
*/
GEOM_Object Make3DSketcher (in ListOfDouble theCoordinates);
/*! /*!
* \brief Create a sketcher (wire or face), following the textual description, * \brief Create a sketcher (wire or face), following the textual description,
* passed through \a theCommand argument. * passed through \a theCommand argument.
* *
* For format of the description string see the previous method.\n * For format of the description string see the previous method.\n
*
* \param theCommand String, defining the sketcher in local * \param theCommand String, defining the sketcher in local
* coordinates of the working plane. * coordinates of the working plane.
* \param theWorkingPlane Planar Face or LCS(Marker) of the working plane. * \param theWorkingPlane Planar Face or LCS(Marker) of the working plane.
* \return New GEOM_Object, containing the created wire. * \return New GEOM_Object, containing the created wire or face.
*/ */
GEOM_Object MakeSketcherOnPlane (in string theCommand, in GEOM_Object theWorkingPlane); GEOM_Object MakeSketcherOnPlane (in string theCommand, in GEOM_Object theWorkingPlane);
/*!
* \brief Create a 3D sketcher, following the textual description,
* passed through \a theCommand argument.
*
* Format of the description string has to be the following:
*
* "3DSketcher:CMD[:CMD[:CMD...]]"
*
* Where CMD is one of
* - "TT x y z" : Create segment by point at X & Y or set the first point
* - "T dx dy dz" : Create segment by point with DX & DY
* .
* \n
* - "OXY angleX angle2 length" : Create segment by two angles and length
* - "OYZ angleY angle2 length" : Create segment by two angles and length
* - "OXZ angleX angle2 length" : Create segment by two angles and length
* .
* \n
* - "WW" : Close Wire (to finish)
*
* \param theCommand String, defining the sketcher in local
* coordinates of the working plane.
* \return New GEOM_Object, containing the created wire.
*/
GEOM_Object Make3DSketcherCommand (in string theCommand);
/*!
* \brief Create a 3D sketcher, made of a straight segments, joining points
* with coordinates passed through \a theCoordinates argument.
*
* Order of coordinates has to be the following:
* x1, y1, z1, x2, y2, z2, ..., xN, yN, zN
*
* \param theCoordinates List of double values.
* \return New GEOM_Object, containing the created wire.
*/
GEOM_Object Make3DSketcher (in ListOfDouble theCoordinates);
}; };
// # GEOM_ILocalOperations: // # GEOM_ILocalOperations:
@ -3200,6 +3250,17 @@ module GEOM
*/ */
GEOM_Object ImportFile (in string theFileName, in string theFormatName); GEOM_Object ImportFile (in string theFileName, in string theFormatName);
/*!
* \brief Read a value of parameter from a file, containing a shape.
* \param theFileName The file, containing the shape.
* \param theFormatName Specify format for the file reading.
* Available formats can be obtained with <VAR>ImportTranslators()</VAR> method.
* \param theParameterName Specify the parameter. For example, pass "LEN_UNITS"
* to obtain length units, in which the file is written.
* \return Value of requested parameter in form of text string.
*/
string ReadValue (in string theFileName, in string theFormatName, in string theParameterName);
/*! /*!
* \brief Get the supported import formats and corresponding patterns for File dialog. * \brief Get the supported import formats and corresponding patterns for File dialog.
* \param theFormats Output. List of formats, available for import. * \param theFormats Output. List of formats, available for import.
@ -3218,6 +3279,14 @@ module GEOM
void ExportTranslators (out string_array theFormats, void ExportTranslators (out string_array theFormats,
out string_array thePatterns); out string_array thePatterns);
/*!
* \brief Read a shape from the binary stream, containing its bounding representation (BRep).
* \note GEOM_Object::GetShapeStream() method can be used to obtain the shape's BRep stream.
* \param theStream The BRep binary stream.
* \return New GEOM_Object, containing the shape, read from theStream.
*/
GEOM_Object RestoreShape (in SALOMEDS::TMPFile theStream);
/*! /*!
* \brief Load texture from file * \brief Load texture from file
* \param theTextureFile texture file name * \param theTextureFile texture file name
@ -3635,6 +3704,65 @@ module GEOM
*/ */
void DifferenceIDs (in GEOM_Object theGroup, in ListOfLong theSubShapes); void DifferenceIDs (in GEOM_Object theGroup, in ListOfLong theSubShapes);
/*!
* \brief Union of two groups.
* New group is created. It will contain all entities
* which are present in groups theGroup1 and theGroup2.
* \param theGroup1, theGroup2 are the initial GEOM groups
* to create the united group from.
* \return a newly created GEOM group.
*/
GEOM_Object UnionGroups (in GEOM_Object theGroup1, in GEOM_Object theGroup2);
/*!
* \brief 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.
* \return a newly created GEOM group.
*/
GEOM_Object IntersectGroups (in GEOM_Object theGroup1, in GEOM_Object theGroup2);
/*!
* \brief Cut of two groups.
* New group is created. It will contain entities which are
* 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.
* \return a newly created GEOM group.
*/
GEOM_Object CutGroups (in GEOM_Object theGroup1, in GEOM_Object theGroup2);
/*!
* \brief 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.
* \return a newly created GEOM group.
*/
GEOM_Object UnionListOfGroups (in ListOfGO theGList);
/*!
* \brief Intersection of list of groups.
* New group is created. It will contain only entities
* which are simultaneously present in the groups listed in theGList.
* \param theGList is a list of GEOM groups to get common part of.
* \return a newly created GEOM group.
*/
GEOM_Object IntersectListOfGroups (in ListOfGO theGList);
/*!
* \brief Cut of lists of groups.
* New group is created. It will contain only entities
* which are present in groups listed in theGList1 but
* 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.
* \return a newly created GEOM group.
*/
GEOM_Object CutListOfGroups (in ListOfGO theGList1,
in ListOfGO theGList2);
/*! /*!
* \brief Returns a type of sub-objects stored in the group * \brief Returns a type of sub-objects stored in the group
* \param theGroup is a GEOM group which type is returned. * \param theGroup is a GEOM group which type is returned.

View File

@ -232,6 +232,7 @@ group_new.png \
group_edit.png \ group_edit.png \
glue.png \ glue.png \
check_blocks_compound.png \ check_blocks_compound.png \
get_non_blocks.png \
check_self_intersections.png \ check_self_intersections.png \
free_faces.png \ free_faces.png \
propagate.png \ propagate.png \

View File

@ -43,7 +43,7 @@
<parameter name="SettingsGeomStep" value="10" /> <parameter name="SettingsGeomStep" value="10" />
<parameter name="display_mode" value="0" /> <parameter name="display_mode" value="0" />
<parameter name="shading_color" value="255, 255, 0" /> <parameter name="shading_color" value="255, 255, 0" />
<parameter name="edges_in_shading_color" value="255, 255, 255" /> <parameter name="edges_in_shading_color" value="180, 180, 180" />
<parameter name="wireframe_color" value="255, 255, 0" /> <parameter name="wireframe_color" value="255, 255, 0" />
<parameter name="free_bound_color" value="0, 255, 0" /> <parameter name="free_bound_color" value="0, 255, 0" />
<parameter name="line_color" value="255, 0, 0" /> <parameter name="line_color" value="255, 0, 0" />

Binary file not shown.

After

Width:  |  Height:  |  Size: 1004 B

View File

@ -36,6 +36,10 @@
#include <SalomeApp_Application.h> #include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h> #include <LightApp_SelectionMgr.h>
// VSR 22/08/2012: issue 0021787: remove "Preview" button from BOP and Partition operations
// Comment next line to enable preview in BOP dialog box
#define NO_PREVIEW
//================================================================================= //=================================================================================
// class : BooleanGUI_Dialog() // class : BooleanGUI_Dialog()
// purpose : Constructs a BooleanGUI_Dialog which is a child of 'parent', with the // purpose : Constructs a BooleanGUI_Dialog which is a child of 'parent', with the
@ -110,6 +114,10 @@ BooleanGUI_Dialog::BooleanGUI_Dialog (const int theOperation, GeometryGUI* theGe
layout->addWidget(myGroup); layout->addWidget(myGroup);
/***************************************************************/ /***************************************************************/
#ifdef NO_PREVIEW
mainFrame()->CheckBoxPreview->setChecked( false );
mainFrame()->CheckBoxPreview->hide();
#endif
// Initialisation // Initialisation
Init(); Init();
} }
@ -224,6 +232,7 @@ void BooleanGUI_Dialog::SelectionIntoArgument()
if (myEditCurrentArgument == myGroup->LineEdit1) myObject1.nullify(); if (myEditCurrentArgument == myGroup->LineEdit1) myObject1.nullify();
else if (myEditCurrentArgument == myGroup->LineEdit2) myObject2.nullify(); else if (myEditCurrentArgument == myGroup->LineEdit2) myObject2.nullify();
} }
processPreview();
} }
//================================================================================= //=================================================================================

View File

@ -18,12 +18,11 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// GEOM GEOMGUI : GUI for Geometry component // GEOM GEOMGUI : GUI for Geometry component
// File : DisplayGUI.cxx // File : DisplayGUI.cxx
// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
//
#include "DisplayGUI.h" #include "DisplayGUI.h"
#include <GeometryGUI.h> #include <GeometryGUI.h>
#include "GeometryGUI_Operations.h" #include "GeometryGUI_Operations.h"
@ -110,6 +109,10 @@ bool DisplayGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent)
getGeometryGUI()->EmitSignalDeactivateDialog(); getGeometryGUI()->EmitSignalDeactivateDialog();
DisplayOnly(); DisplayOnly();
break; break;
case GEOMOp::OpShowOnlyChildren: // POPUP MENU - SHOW ONLY CHILDREN
getGeometryGUI()->EmitSignalDeactivateDialog();
DisplayOnlyChildren();
break;
case GEOMOp::OpHideAll: // MENU VIEW - HIDE ALL case GEOMOp::OpHideAll: // MENU VIEW - HIDE ALL
EraseAll(); EraseAll();
break; break;
@ -217,6 +220,62 @@ void DisplayGUI::DisplayOnly()
Display(); Display();
} }
//=====================================================================================
// function : DisplayGUI::DisplayOnlyChildren()
// purpose : Display only children of selected GEOM objects and erase other
//=====================================================================================
void DisplayGUI::DisplayOnlyChildren()
{
EraseAll();
SALOME_ListIO listIO;
SalomeApp_Application* app = getGeometryGUI()->getApp();
if (!app) return;
SalomeApp_Study* anActiveStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
if (!anActiveStudy) return;
LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
if (!aSelMgr) return;
// get selection
SALOME_ListIO aList;
//aSelMgr->selectedObjects(aList);
aSelMgr->selectedObjects(aList, "ObjectBrowser", false);
SALOME_ListIteratorOfListIO It (aList);
SUIT_OverrideCursor();
for (; It.More(); It.Next()) {
Handle(SALOME_InteractiveObject) anIObject = It.Value();
if (anIObject->hasEntry()) {
_PTR(SObject) SO (anActiveStudy->studyDS()->FindObjectID(anIObject->getEntry()));
if (SO) {
_PTR(SComponent) SC (SO->GetFatherComponent());
if (QString(SO->GetID().c_str()) == QString(SO->GetFatherComponent()->GetID().c_str())) {
// if component is selected, pass it
}
else {
_PTR(ChildIterator) anIter (anActiveStudy->studyDS()->NewChildIterator(SO));
anIter->InitEx(true);
while (anIter->More()) {
_PTR(SObject) valSO (anIter->Value());
_PTR(SObject) refSO;
if (!valSO->ReferencedObject(refSO)) {
listIO.Append(new SALOME_InteractiveObject(valSO->GetID().c_str(),
SC->ComponentDataType().c_str(),
valSO->GetName().c_str()));
}
anIter->Next();
}
}
}
}
}
GEOM_Displayer(anActiveStudy).Display(listIO, true);
}
//===================================================================================== //=====================================================================================
// function : DisplayGUI::Display() // function : DisplayGUI::Display()
// purpose : Display selected GEOM objects // purpose : Display selected GEOM objects

View File

@ -18,12 +18,11 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// GEOM GEOMGUI : GUI for Geometry component // GEOM GEOMGUI : GUI for Geometry component
// File : DisplayGUI.h // File : DisplayGUI.h
// Author : Damien COQUERET, Open CASCADE S.A.S. // Author : Damien COQUERET, Open CASCADE S.A.S.
//
#ifndef DISPLAYGUI_H #ifndef DISPLAYGUI_H
#define DISPLAYGUI_H #define DISPLAYGUI_H
@ -53,6 +52,8 @@ public:
void Display(); void Display();
// Display selected GEOM objects and erase other // Display selected GEOM objects and erase other
void DisplayOnly(); void DisplayOnly();
// Display only children of selected GEOM objects and erase other
void DisplayOnlyChildren();
// Erase selected GEOM objects // Erase selected GEOM objects
void Erase(); void Erase();

View File

@ -15,12 +15,11 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// GEOM GEOMGUI : GUI for Geometry component // GEOM GEOMGUI : GUI for Geometry component
// File : EntityGUI_3DSketcherDlg.cxx // File : EntityGUI_3DSketcherDlg.cxx
// Author : DMV, OCN // Author : DMV, OCN
//
#include <cmath> #include <cmath>
#include <string> #include <string>
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
@ -49,14 +48,8 @@
#include <SalomeApp_Tools.h> #include <SalomeApp_Tools.h>
//OCCT includes //OCCT includes
//#include <BRep_Tool.hxx>
//#include <TopExp.hxx>
//#include <TopExp_Explorer.hxx>
//#include <TopoDS_Vertex.hxx>
#include <TopoDS.hxx> #include <TopoDS.hxx>
#include <TColStd_IndexedMapOfInteger.hxx> #include <TColStd_IndexedMapOfInteger.hxx>
//#include <BRepBuilderAPI_Transform.hxx>
//#include <BRepBuilderAPI_MakeWire.hxx>
#include <BRepBuilderAPI_MakeVertex.hxx> #include <BRepBuilderAPI_MakeVertex.hxx>
#include <BRepBuilderAPI_MakePolygon.hxx> #include <BRepBuilderAPI_MakePolygon.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx> #include <BRepBuilderAPI_MakeEdge.hxx>
@ -86,6 +79,13 @@ enum
TYPE_TWO_ANGLES TYPE_TWO_ANGLES
}; };
enum
{
OXY,
OYZ,
OXZ
};
class Locker class Locker
{ {
public: public:
@ -111,6 +111,7 @@ EntityGUI_3DSketcherDlg::EntityGUI_3DSketcherDlg( GeometryGUI* theGeometryGUI, Q
myLineWidth(lineWidth), myLineWidth(lineWidth),
myGeometryGUI(theGeometryGUI), myGeometryGUI(theGeometryGUI),
myLengthIORedoList() myLengthIORedoList()
// myLastAngleNormal()
{ {
QPixmap image0(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT"))); QPixmap image0(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT")));
QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_UNDO"))); QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_UNDO")));
@ -156,6 +157,19 @@ EntityGUI_3DSketcherDlg::EntityGUI_3DSketcherDlg( GeometryGUI* theGeometryGUI, Q
GroupControls->GroupBox1->setTitle(tr("GEOM_CONTROLS")); GroupControls->GroupBox1->setTitle(tr("GEOM_CONTROLS"));
GroupControls->CheckBox1->setText(tr("Show length dimensions")); //TODO translation GroupControls->CheckBox1->setText(tr("Show length dimensions")); //TODO translation
GroupControls->CheckBox2->setText(tr("Show angle dimensions")); //TODO translation GroupControls->CheckBox2->setText(tr("Show angle dimensions")); //TODO translation
GroupControls->CheckBox3->setText(tr("Show start/end point coordinates")); //TODO translation
GroupControls->lineEdit_1->setReadOnly(true);
GroupControls->lineEdit_2->setReadOnly(true);
GroupControls->lineEdit_3->setReadOnly(true);
GroupControls->lineEdit_4->setReadOnly(true);
GroupControls->lineEdit_5->setReadOnly(true);
GroupControls->lineEdit_6->setReadOnly(true);
GroupControls->label_1->setText(tr("X:"));
GroupControls->label_2->setText(tr("Y:"));
GroupControls->label_3->setText(tr("Z:"));
GroupControls->label_4->setText(tr("X:"));
GroupControls->label_5->setText(tr("Y:"));
GroupControls->label_6->setText(tr("Z:"));
buttonOk()->setText(tr("GEOM_BUT_END_SKETCH")); buttonOk()->setText(tr("GEOM_BUT_END_SKETCH"));
buttonApply()->setText(tr("GEOM_BUT_CLOSE_SKETCH")); buttonApply()->setText(tr("GEOM_BUT_CLOSE_SKETCH"));
@ -173,8 +187,6 @@ EntityGUI_3DSketcherDlg::EntityGUI_3DSketcherDlg( GeometryGUI* theGeometryGUI, Q
Init(); Init();
} }
//================================================================================= //=================================================================================
// function : ~EntityGUI_3DSketcherDlg() // function : ~EntityGUI_3DSketcherDlg()
// purpose : Destroys the object and frees any allocated resources // purpose : Destroys the object and frees any allocated resources
@ -191,7 +203,7 @@ EntityGUI_3DSketcherDlg::~EntityGUI_3DSketcherDlg()
void EntityGUI_3DSketcherDlg::Init() void EntityGUI_3DSketcherDlg::Init()
{ {
myOK = false; myOK = false;
myOrientation = 1; myOrientation = OXY;
myPrsType = NONE; myPrsType = NONE;
SUIT_ViewWindow* vw = SUIT_Session::session()->activeApplication()->desktop()->activeWindow(); SUIT_ViewWindow* vw = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
@ -201,6 +213,7 @@ void EntityGUI_3DSketcherDlg::Init()
//TEST //TEST
localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX); localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
// globalSelection(GEOM_PREVIEW); // globalSelection(GEOM_PREVIEW);
// setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
/* Get setting of step value from file configuration */ /* Get setting of step value from file configuration */
double step = SUIT_Session::session()->resourceMgr()->doubleValue("Geometry", "SettingsGeomStep", 100.0); double step = SUIT_Session::session()->resourceMgr()->doubleValue("Geometry", "SettingsGeomStep", 100.0);
@ -228,6 +241,8 @@ void EntityGUI_3DSketcherDlg::Init()
GroupControls->CheckBox1->setChecked(true); GroupControls->CheckBox1->setChecked(true);
GroupControls->CheckBox2->setChecked(true); GroupControls->CheckBox2->setChecked(true);
GroupControls->CheckBox3->setChecked(true);
isLengthVisible = true; isLengthVisible = true;
isAngleVisible = true; isAngleVisible = true;
@ -264,6 +279,7 @@ void EntityGUI_3DSketcherDlg::Init()
connect(GroupAngles->checkBox, SIGNAL(clicked (bool)), this, SLOT(BoxChecked (bool))) ; connect(GroupAngles->checkBox, SIGNAL(clicked (bool)), this, SLOT(BoxChecked (bool))) ;
connect(GroupControls->CheckBox1, SIGNAL(clicked (bool)), this, SLOT(BoxChecked (bool))) ; connect(GroupControls->CheckBox1, SIGNAL(clicked (bool)), this, SLOT(BoxChecked (bool))) ;
connect(GroupControls->CheckBox2, SIGNAL(clicked (bool)), this, SLOT(BoxChecked (bool))) ; connect(GroupControls->CheckBox2, SIGNAL(clicked (bool)), this, SLOT(BoxChecked (bool))) ;
connect(GroupControls->CheckBox3, SIGNAL(clicked (bool)), this, SLOT(BoxChecked (bool))) ;
connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double))); connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double)));
@ -272,6 +288,8 @@ void EntityGUI_3DSketcherDlg::Init()
initName(tr("GEOM_3DSKETCHER")); initName(tr("GEOM_3DSKETCHER"));
GroupControls->CheckBox3->click();
UpdateButtonsState(); UpdateButtonsState();
GEOMBase_Helper::displayPreview(true, false, true, true, myLineWidth); GEOMBase_Helper::displayPreview(true, false, true, true, myLineWidth);
} }
@ -291,13 +309,15 @@ void EntityGUI_3DSketcherDlg::TypeClicked( int mode )
Group3Spin->SpinBox_DX->blockSignals(true); Group3Spin->SpinBox_DX->blockSignals(true);
Group3Spin->SpinBox_DY->blockSignals(true); Group3Spin->SpinBox_DY->blockSignals(true);
Group3Spin->SpinBox_DZ->blockSignals(true); Group3Spin->SpinBox_DZ->blockSignals(true);
// Get setting of step value from file configuration // Get setting of step value from file configuration
XYZ xyz = getLastPoint(); XYZ xyz = getLastPoint();
bool okx, oky, okz; bool okx, oky, okz;
Group3Spin->SpinBox_DX->text().toDouble(&okx); Group3Spin->SpinBox_DX->text().toDouble(&okx);
Group3Spin->SpinBox_DY->text().toDouble(&oky); Group3Spin->SpinBox_DY->text().toDouble(&oky);
Group3Spin->SpinBox_DZ->text().toDouble(&okz); Group3Spin->SpinBox_DZ->text().toDouble(&okz);
if ( mode == 0 ) { // XY
if (mode == 0) { // XYZ
Group3Spin->TextLabel1->setText(tr("GEOM_SKETCHER_X2")); Group3Spin->TextLabel1->setText(tr("GEOM_SKETCHER_X2"));
Group3Spin->TextLabel2->setText(tr("GEOM_SKETCHER_Y2")); Group3Spin->TextLabel2->setText(tr("GEOM_SKETCHER_Y2"));
Group3Spin->TextLabel3->setText(tr("GEOM_SKETCHER_Z2")); Group3Spin->TextLabel3->setText(tr("GEOM_SKETCHER_Z2"));
@ -309,7 +329,7 @@ void EntityGUI_3DSketcherDlg::TypeClicked( int mode )
} }
Group3Spin->buttonApply->setFocus(); Group3Spin->buttonApply->setFocus();
} }
else if ( mode == 1) { // DXDY else if (mode == 1) { // DXDYDZ
Group3Spin->TextLabel1->setText(tr("GEOM_SKETCHER_DX2")); Group3Spin->TextLabel1->setText(tr("GEOM_SKETCHER_DX2"));
Group3Spin->TextLabel2->setText(tr("GEOM_SKETCHER_DY2")); Group3Spin->TextLabel2->setText(tr("GEOM_SKETCHER_DY2"));
Group3Spin->TextLabel3->setText(tr("GEOM_SKETCHER_DZ2")); Group3Spin->TextLabel3->setText(tr("GEOM_SKETCHER_DZ2"));
@ -321,7 +341,7 @@ void EntityGUI_3DSketcherDlg::TypeClicked( int mode )
} }
Group3Spin->buttonApply->setFocus(); Group3Spin->buttonApply->setFocus();
} }
else if (mode == 2){ // Angles else if (mode == 2) { // Angles and Length
Group3Spin->hide(); Group3Spin->hide();
GroupAngles->show(); GroupAngles->show();
GroupAngles->buttonApply->setFocus(); GroupAngles->buttonApply->setFocus();
@ -352,21 +372,21 @@ void EntityGUI_3DSketcherDlg::ClickOnAddPoint()
} }
// Display and store angle dimensions interactive objects in Prs // Display and store angle dimensions interactive objects in Prs
if( GroupType->RadioButton3->isChecked() ) if (GroupType->RadioButton3->isChecked()) // ANGLES
{ {
double anAngle2 = 0.0; double anAngle2 = 0.0;
if (GroupAngles->checkBox->isChecked()) if (GroupAngles->checkBox->isChecked())
anAngle2 = GroupAngles->SpinBox_DA2->value(); anAngle2 = GroupAngles->SpinBox_DA2->value();
// Store length dimensions
displayLength(GroupAngles->SpinBox_DL->value(), /*store =*/true);
// Store angle dimensions // Store angle dimensions
displayAngle(GroupAngles->SpinBox_DA->value(), anAngle2, displayAngle(GroupAngles->SpinBox_DA->value(), anAngle2,
GroupAngles->SpinBox_DL->value(), myOrientation, /*store =*/true); GroupAngles->SpinBox_DL->value(), myOrientation, /*store =*/true);
// Store length dimensions
displayLength(GroupAngles->SpinBox_DL->value(), /*store =*/true, /*type=*/myPrsType);
} }
// Display and store store length dimension interactive object in Prs // Display and store store length dimension interactive object in Prs
if (GroupType->RadioButton1->isChecked() || if (GroupType->RadioButton1->isChecked() || // ABSOLUTE or RELATIVE coordinates
GroupType->RadioButton2->isChecked()) GroupType->RadioButton2->isChecked())
{ {
displayLength(-1, /*store=*/true); displayLength(-1, /*store=*/true);
@ -381,7 +401,8 @@ void EntityGUI_3DSketcherDlg::ClickOnAddPoint()
myLengthIORedoList.Clear(); myLengthIORedoList.Clear();
myAngleIORedoList.Clear(); myAngleIORedoList.Clear();
if ( myMode == 1 ) { if (myMode == 1)
{
Group3Spin->SpinBox_DX->setValue(0.0); Group3Spin->SpinBox_DX->setValue(0.0);
Group3Spin->SpinBox_DY->setValue(0.0); Group3Spin->SpinBox_DY->setValue(0.0);
Group3Spin->SpinBox_DZ->setValue(0.0); Group3Spin->SpinBox_DZ->setValue(0.0);
@ -392,9 +413,11 @@ void EntityGUI_3DSketcherDlg::ClickOnAddPoint()
GroupAngles->SpinBox_DL->setValue(0.0); GroupAngles->SpinBox_DL->setValue(0.0);
GroupAngles->SpinBox_DA2->setValue(0.0); GroupAngles->SpinBox_DA2->setValue(0.0);
} }
UpdatePointCoordinates();
UpdateButtonsState(); UpdateButtonsState();
GEOMBase_Helper::displayPreview(true, false, true, true, myLineWidth); GEOMBase_Helper::displayPreview(true, false, true, true, myLineWidth);
} }
//================================================================================= //=================================================================================
@ -412,6 +435,44 @@ void EntityGUI_3DSketcherDlg::UpdateButtonsState()
GroupAngles->buttonRedo->setEnabled(myRedoList.count() > 0); GroupAngles->buttonRedo->setEnabled(myRedoList.count() > 0);
} }
//=================================================================================
// function : UpdatePointCoordinates()
// purpose :Update point coordinates in the control groupbox
//=================================================================================
void EntityGUI_3DSketcherDlg::UpdatePointCoordinates()
{
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
int aPrecision = resMgr->integerValue("Geometry", "length_precision", 6);
if (myPointsList.count() == 0)
{
GroupControls->lineEdit_1->setText("");
GroupControls->lineEdit_2->setText("");
GroupControls->lineEdit_3->setText("");
GroupControls->lineEdit_4->setText("");
GroupControls->lineEdit_5->setText("");
GroupControls->lineEdit_6->setText("");
}
else if (myPointsList.count() == 1)
{
GroupControls->lineEdit_1->setText(DlgRef::PrintDoubleValue(getLastPoint().x, aPrecision));
GroupControls->lineEdit_2->setText(DlgRef::PrintDoubleValue(getLastPoint().y, aPrecision));
GroupControls->lineEdit_3->setText(DlgRef::PrintDoubleValue(getLastPoint().z, aPrecision));
GroupControls->lineEdit_4->setText("");
GroupControls->lineEdit_5->setText("");
GroupControls->lineEdit_6->setText("");
}
else
{
GroupControls->lineEdit_4->setText(DlgRef::PrintDoubleValue(getLastPoint().x, aPrecision));
GroupControls->lineEdit_5->setText(DlgRef::PrintDoubleValue(getLastPoint().y, aPrecision));
GroupControls->lineEdit_6->setText(DlgRef::PrintDoubleValue(getLastPoint().z, aPrecision));
}
}
//================================================================================= //=================================================================================
// function : ClickOnUndo() // function : ClickOnUndo()
// purpose : // purpose :
@ -455,6 +516,9 @@ void EntityGUI_3DSketcherDlg::ClickOnUndo()
if (isAngleVisible) if (isAngleVisible)
((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Display(myAnglePrs); ((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Display(myAnglePrs);
// Update of point coordinates in the control groupbox
UpdatePointCoordinates();
updateViewer(); updateViewer();
} }
} }
@ -500,6 +564,9 @@ void EntityGUI_3DSketcherDlg::ClickOnRedo()
if (isAngleVisible) if (isAngleVisible)
((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Display(myAnglePrs); ((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Display(myAnglePrs);
// Update of point coordinates in the control groupbox
UpdatePointCoordinates();
updateViewer(); updateViewer();
} }
} }
@ -559,11 +626,11 @@ void EntityGUI_3DSketcherDlg::SelectionIntoArgument()
GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First()); GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First());
if (!CORBA::is_nil(aSelectedObject)) { if (!CORBA::is_nil(aSelectedObject)) {
TopoDS_Shape aShape; TopoDS_Shape aShape;
if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE)) { // Explore the shape if its a local selection if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE)) {
// Explore the shape if its a local selection
TColStd_IndexedMapOfInteger aMap; TColStd_IndexedMapOfInteger aMap;
aSelMgr->GetIndexes(aSelList.First(), aMap); aSelMgr->GetIndexes(aSelList.First(), aMap);
if (aMap.Extent() == 1) if (aMap.Extent() == 1) {
{
int anIndex = aMap(1); int anIndex = aMap(1);
GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId()); GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId());
aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex); aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
@ -588,7 +655,8 @@ void EntityGUI_3DSketcherDlg::SelectionIntoArgument()
Group3Spin->SpinBox_DX->setValue(aX); Group3Spin->SpinBox_DX->setValue(aX);
Group3Spin->SpinBox_DY->setValue(aY); Group3Spin->SpinBox_DY->setValue(aY);
Group3Spin->SpinBox_DZ->setValue(aZ); Group3Spin->SpinBox_DZ->setValue(aZ);
} else if ( GroupType->RadioButton2->isChecked() ) { }
else if (GroupType->RadioButton2->isChecked()) {
XYZ xyz = getLastPoint(); XYZ xyz = getLastPoint();
Group3Spin->SpinBox_DX->setValue(aX - xyz.x); Group3Spin->SpinBox_DX->setValue(aX - xyz.x);
Group3Spin->SpinBox_DY->setValue(aY - xyz.y); Group3Spin->SpinBox_DY->setValue(aY - xyz.y);
@ -616,7 +684,6 @@ void EntityGUI_3DSketcherDlg::DeactivateActiveDialog()
myGeomGUI->SetActiveDialogBox(0); myGeomGUI->SetActiveDialogBox(0);
} }
//================================================================================= //=================================================================================
// function : ActivateThisDialog() // function : ActivateThisDialog()
// purpose : // purpose :
@ -634,7 +701,6 @@ void EntityGUI_3DSketcherDlg::ActivateThisDialog()
GEOMBase_Helper::displayPreview(true, false, true, true, myLineWidth); GEOMBase_Helper::displayPreview(true, false, true, true, myLineWidth);
} }
//================================================================================= //=================================================================================
// function : ValueChangedInSpinBox() // function : ValueChangedInSpinBox()
// purpose : // purpose :
@ -644,7 +710,6 @@ void EntityGUI_3DSketcherDlg::ValueChangedInSpinBox( double newValue )
GEOMBase_Helper::displayPreview(true, false, true, true, myLineWidth); GEOMBase_Helper::displayPreview(true, false, true, true, myLineWidth);
} }
//================================================================================= //=================================================================================
// function : BoxChecked() // function : BoxChecked()
// purpose : ChecBoxes management // purpose : ChecBoxes management
@ -678,6 +743,30 @@ void EntityGUI_3DSketcherDlg::BoxChecked( bool checked )
else else
isAngleVisible=false; isAngleVisible=false;
} }
else if (send == GroupControls->CheckBox3)
{
GroupControls->lineEdit_1->setVisible(checked);
GroupControls->lineEdit_2->setVisible(checked);
GroupControls->lineEdit_3->setVisible(checked);
GroupControls->lineEdit_4->setVisible(checked);
GroupControls->lineEdit_5->setVisible(checked);
GroupControls->lineEdit_6->setVisible(checked);
GroupControls->label_1->setVisible(checked);
GroupControls->label_2->setVisible(checked);
GroupControls->label_3->setVisible(checked);
GroupControls->label_4->setVisible(checked);
GroupControls->label_5->setVisible(checked);
GroupControls->label_6->setVisible(checked);
GroupControls->label_7->setVisible(checked);
GroupControls->label_8->setVisible(checked);
GroupControls->updateGeometry();
GroupControls->resize(minimumSizeHint());
}
updateGeometry();
resize(minimumSizeHint());
GEOMBase_Helper::displayPreview(true, false, true, true, myLineWidth); GEOMBase_Helper::displayPreview(true, false, true, true, myLineWidth);
} }
@ -689,11 +778,11 @@ void EntityGUI_3DSketcherDlg::BoxChecked( bool checked )
void EntityGUI_3DSketcherDlg::ButtonClicked (bool checked) void EntityGUI_3DSketcherDlg::ButtonClicked (bool checked)
{ {
if (GroupAngles->radioButton_1->isChecked()) if (GroupAngles->radioButton_1->isChecked())
myOrientation = 1; myOrientation = OXY;
else if (GroupAngles->radioButton_2->isChecked()) else if (GroupAngles->radioButton_2->isChecked())
myOrientation = 2; myOrientation = OYZ;
else else
myOrientation = 3; myOrientation = OXZ;
GEOMBase_Helper::displayPreview(true, false, true, true, myLineWidth); GEOMBase_Helper::displayPreview(true, false, true, true, myLineWidth);
} }
@ -736,37 +825,38 @@ bool EntityGUI_3DSketcherDlg::isValid( QString& msg )
//================================================================================= //=================================================================================
bool EntityGUI_3DSketcherDlg::execute (ObjectList& objects) bool EntityGUI_3DSketcherDlg::execute (ObjectList& objects)
{ {
GEOM::ListOfDouble_var aCoordsArray = new GEOM::ListOfDouble; //GEOM::ListOfDouble_var aCoordsArray = new GEOM::ListOfDouble;
if (!myOK || myPointsList.size() == 0) //if (!myOK || myPointsList.size() == 0)
aCoordsArray->length((myPointsList.size()+1)*3); // aCoordsArray->length((myPointsList.size()+1)*3);
else //else
aCoordsArray->length(myPointsList.size()*3); // aCoordsArray->length(myPointsList.size()*3);
QStringList aCommands;
aCommands << "3DSketcher";
QStringList aParameters; QStringList aParameters;
int i = 0; //int i = 0;
QList<XYZ>::const_iterator it; QList<XYZ>::const_iterator it;
for (it = myPointsList.begin(); it != myPointsList.end(); ++it) { for (it = myPointsList.begin(); it != myPointsList.end(); ++it) {
aCoordsArray[i++] = (*it).x; //aCoordsArray[i++] = (*it).x;
aCoordsArray[i++] = (*it).y; //aCoordsArray[i++] = (*it).y;
aCoordsArray[i++] = (*it).z; //aCoordsArray[i++] = (*it).z;
aParameters << (*it).xt; aCommands << (*it).command;
aParameters << (*it).yt; aParameters << (*it).params;
aParameters << (*it).zt;
} }
if (!myOK || myPointsList.size() == 0) { if (!myOK || myPointsList.size() == 0) {
XYZ xyz = getCurrentPoint(); XYZ xyz = getCurrentPoint();
aCoordsArray[i++] = xyz.x; //aCoordsArray[i++] = xyz.x;
aCoordsArray[i++] = xyz.y; //aCoordsArray[i++] = xyz.y;
aCoordsArray[i++] = xyz.z; //aCoordsArray[i++] = xyz.z;
aParameters << xyz.xt; aCommands << xyz.command;
aParameters << xyz.yt; aParameters << xyz.params;
aParameters << xyz.zt;
} }
GEOM::GEOM_ICurvesOperations_var anOper = GEOM::GEOM_ICurvesOperations::_narrow(getOperation()); GEOM::GEOM_ICurvesOperations_var anOper = GEOM::GEOM_ICurvesOperations::_narrow(getOperation());
GEOM::GEOM_Object_var anObj = anOper->Make3DSketcher( aCoordsArray ); //GEOM::GEOM_Object_var anObj = anOper->Make3DSketcher(aCoordsArray);
GEOM::GEOM_Object_var anObj = anOper->Make3DSketcherCommand(aCommands.join(":").toLatin1().constData());
if (!anObj->_is_nil()) { if (!anObj->_is_nil()) {
if (!IsPreview()) anObj->SetParameters(aParameters.join(":").toLatin1().constData()); if (!IsPreview()) anObj->SetParameters(aParameters.join(":").toLatin1().constData());
@ -849,59 +939,94 @@ EntityGUI_3DSketcherDlg::XYZ EntityGUI_3DSketcherDlg::getPenultimatePoint() cons
//================================================================================= //=================================================================================
// function : getCurrentPoint() // function : getCurrentPoint()
// purpose : returns current points // purpose : returns current point
//================================================================================= //=================================================================================
EntityGUI_3DSketcherDlg::XYZ EntityGUI_3DSketcherDlg::getCurrentPoint() const EntityGUI_3DSketcherDlg::XYZ EntityGUI_3DSketcherDlg::getCurrentPoint() const
{ {
XYZ xyz; XYZ xyz;
// Temporary way of doing this. To be changed with ordered improvement of the sketcher
if ( myMode == 2 ) SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
{ int aPrecision = resMgr->integerValue("Geometry", "length_precision", 7);
double anAngle = GroupAngles->SpinBox_DA->value() * M_PI/180.0;
double anAngle2 = 0.0; if (myMode == 2) {
if (GroupAngles->radioButton_1->isChecked())
xyz.command = "OXY ";
else if (GroupAngles->radioButton_2->isChecked())
xyz.command = "OYZ ";
else
xyz.command = "OXZ ";
double anAngle = GroupAngles->SpinBox_DA->value();
double aLength = GroupAngles->SpinBox_DL->value(); double aLength = GroupAngles->SpinBox_DL->value();
if (GroupAngles->checkBox->isChecked()) double anAngle2 = 0.0;
anAngle2 = GroupAngles->SpinBox_DA2->value() * M_PI/180.0; QString da2 = "0";
if (GroupAngles->checkBox->isChecked()) {
anAngle2 = GroupAngles->SpinBox_DA2->value();
da2 = GroupAngles->SpinBox_DA2->text();
}
xyz.command +=
QString::number(anAngle, 'g', aPrecision) + " " +
QString::number(anAngle2, 'g', aPrecision) + " " +
QString::number(aLength, 'g', aPrecision);
xyz.params =
GroupAngles->SpinBox_DA->text() + ":" +
da2 + ":" +
GroupAngles->SpinBox_DL->text();
// Calculate point coordinates for preview
anAngle = anAngle * M_PI/180.0;
anAngle2 = anAngle2 * M_PI/180.0;
double aProjectedLength = aLength * cos(anAngle2); double aProjectedLength = aLength * cos(anAngle2);
xyz = getLastPoint(); XYZ xyzP = getLastPoint();
if (GroupAngles->radioButton_1->isChecked()) if (GroupAngles->radioButton_1->isChecked()) // OXY
{ {
xyz.x += aProjectedLength * cos(anAngle); xyz.x = xyzP.x + aProjectedLength * cos(anAngle);
xyz.y += aProjectedLength * sin(anAngle); xyz.y = xyzP.y + aProjectedLength * sin(anAngle);
xyz.z += aLength * sin(anAngle2); xyz.z = xyzP.z + aLength * sin(anAngle2);
} }
else if (GroupAngles->radioButton_2->isChecked()) else if (GroupAngles->radioButton_2->isChecked()) // OYZ
{ {
xyz.y += aProjectedLength * cos(anAngle); xyz.y = xyzP.y + aProjectedLength * cos(anAngle);
xyz.z += aProjectedLength * sin(anAngle); xyz.z = xyzP.z + aProjectedLength * sin(anAngle);
xyz.x += aLength * sin(anAngle2); xyz.x = xyzP.x + aLength * sin(anAngle2);
} }
else else // OXZ
{ {
xyz.z += aProjectedLength * sin(anAngle); xyz.z = xyzP.z + aProjectedLength * sin(anAngle);
xyz.x += aProjectedLength * cos(anAngle); xyz.x = xyzP.x + aProjectedLength * cos(anAngle);
xyz.y += aLength * sin(anAngle2); xyz.y = xyzP.y + aLength * sin(anAngle2);
} }
} }
else else {
{ if (myMode == 0) { // XYZ
if ( myMode == 0 ) {
xyz.x = Group3Spin->SpinBox_DX->value(); xyz.x = Group3Spin->SpinBox_DX->value();
xyz.y = Group3Spin->SpinBox_DY->value(); xyz.y = Group3Spin->SpinBox_DY->value();
xyz.z = Group3Spin->SpinBox_DZ->value(); xyz.z = Group3Spin->SpinBox_DZ->value();
xyz.command = "TT ";
} }
else{ else { // DXDYDZ
xyz = getLastPoint(); xyz = getLastPoint();
xyz.x += Group3Spin->SpinBox_DX->value(); xyz.x += Group3Spin->SpinBox_DX->value();
xyz.y += Group3Spin->SpinBox_DY->value(); xyz.y += Group3Spin->SpinBox_DY->value();
xyz.z += Group3Spin->SpinBox_DZ->value(); xyz.z += Group3Spin->SpinBox_DZ->value();
xyz.command = "T ";
} }
xyz.xt = Group3Spin->SpinBox_DX->text();
xyz.yt = Group3Spin->SpinBox_DY->text(); double aX = Group3Spin->SpinBox_DX->value();
xyz.zt = Group3Spin->SpinBox_DZ->text(); double aY = Group3Spin->SpinBox_DY->value();
double aZ = Group3Spin->SpinBox_DZ->value();
xyz.command +=
QString::number(aX, 'g', aPrecision) + " " +
QString::number(aY, 'g', aPrecision) + " " +
QString::number(aZ, 'g', aPrecision);
xyz.params =
Group3Spin->SpinBox_DX->text() + ":" +
Group3Spin->SpinBox_DY->text() + ":" +
Group3Spin->SpinBox_DZ->text();
} }
return xyz; return xyz;
} }
@ -971,7 +1096,7 @@ void EntityGUI_3DSketcherDlg::displayPreview( GEOM::GEOM_Object_ptr object,
anAngle2 = GroupAngles->SpinBox_DA2->value(); anAngle2 = GroupAngles->SpinBox_DA2->value();
displayAngle(GroupAngles->SpinBox_DA->value(), anAngle2, GroupAngles->SpinBox_DL->value(), myOrientation); displayAngle(GroupAngles->SpinBox_DA->value(), anAngle2, GroupAngles->SpinBox_DL->value(), myOrientation);
displayLength(GroupAngles->SpinBox_DL->value()); displayLength(GroupAngles->SpinBox_DL->value(), /*store=*/false, /*type=*/myPrsType);
} }
if (myMode == 0 || myMode == 1) // COORDINATES if (myMode == 0 || myMode == 1) // COORDINATES
displayLength(); displayLength();
@ -996,10 +1121,10 @@ void EntityGUI_3DSketcherDlg::displayTrihedron(int selMode)
Handle(AIS_Trihedron) anIO = new AIS_Trihedron(anAxis); Handle(AIS_Trihedron) anIO = new AIS_Trihedron(anAxis);
anIO->SetSelectionMode(selMode); anIO->SetSelectionMode(selMode);
SOCC_Prs* aSPrs = dynamic_cast<SOCC_Prs*>(((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->CreatePrs(0)); SOCC_Prs* aSPrs = dynamic_cast<SOCC_Prs*>
(((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->CreatePrs(0));
if (aSPrs) if (aSPrs) {
{
aSPrs->PrependObject(anIO); aSPrs->PrependObject(anIO);
GEOMBase_Helper::displayPreview(aSPrs, true, true); GEOMBase_Helper::displayPreview(aSPrs, true, true);
} }
@ -1009,7 +1134,8 @@ void EntityGUI_3DSketcherDlg::displayTrihedron(int selMode)
// Function : displayAngle() // Function : displayAngle()
// Purpose : Method for displaying angle dimensions // Purpose : Method for displaying angle dimensions
//================================================================ //================================================================
void EntityGUI_3DSketcherDlg::displayAngle(double theAngle1, double theAngle2, double theLength, int theOrientation, bool store) void EntityGUI_3DSketcherDlg::displayAngle (double theAngle1, double theAngle2,
double theLength, int theOrientation, bool store)
{ {
if (Abs(theAngle2 - 90.0) < Precision::Angular() || if (Abs(theAngle2 - 90.0) < Precision::Angular() ||
theLength < Precision::Confusion()) theLength < Precision::Confusion())
@ -1028,7 +1154,7 @@ void EntityGUI_3DSketcherDlg::displayAngle(double theAngle1, double theAngle2, d
switch(theOrientation) switch(theOrientation)
{ {
case 1: //OXY case OXY:
{ {
P1 = gp_Pnt(Last.x + theLength,Last.y,Last.z); // X direction P1 = gp_Pnt(Last.x + theLength,Last.y,Last.z); // X direction
P2 = gp_Pnt(Last.x + theLength * cos(theAngle1 * M_PI / 180.), P2 = gp_Pnt(Last.x + theLength * cos(theAngle1 * M_PI / 180.),
@ -1036,7 +1162,7 @@ void EntityGUI_3DSketcherDlg::displayAngle(double theAngle1, double theAngle2, d
Last.z); Last.z);
break; break;
} }
case 2: //OYZ case OYZ:
{ {
P1 = gp_Pnt(Last.x, Last.y + theLength,Last.z); // Y direction P1 = gp_Pnt(Last.x, Last.y + theLength,Last.z); // Y direction
P2 = gp_Pnt(Last.x, P2 = gp_Pnt(Last.x,
@ -1044,7 +1170,7 @@ void EntityGUI_3DSketcherDlg::displayAngle(double theAngle1, double theAngle2, d
Last.z + theLength * sin(theAngle1 * M_PI / 180.)); Last.z + theLength * sin(theAngle1 * M_PI / 180.));
break; break;
} }
case 3: //OXZ case OXZ:
{ {
P1 = gp_Pnt(Last.x + theLength,Last.y,Last.z); // X direction P1 = gp_Pnt(Last.x + theLength,Last.y,Last.z); // X direction
P2 = gp_Pnt(Last.x + theLength * cos(theAngle1 * M_PI / 180.) , P2 = gp_Pnt(Last.x + theLength * cos(theAngle1 * M_PI / 180.) ,
@ -1065,12 +1191,13 @@ void EntityGUI_3DSketcherDlg::displayAngle(double theAngle1, double theAngle2, d
gce_MakePln gce_MP (Last_Pnt, P1, P2); gce_MakePln gce_MP (Last_Pnt, P1, P2);
Handle(Geom_Plane) aPlane = new Geom_Plane(gce_MP.Value()); Handle(Geom_Plane) aPlane = new Geom_Plane(gce_MP.Value());
// Covert angles to string // Convert angles to string
std::string Angle1_str = doubleToString(theAngle1); std::string Angle1_str = doubleToString(theAngle1);
std::string Angle2_str = doubleToString(theAngle2); std::string Angle2_str = doubleToString(theAngle2);
// Create interactive object // Create interactive object
Handle(AIS_AngleDimension) anAngleIO = new AIS_AngleDimension(anEdge1, anEdge2, aPlane, theAngle1 * M_PI / 180., Handle(AIS_AngleDimension) anAngleIO = new AIS_AngleDimension
(anEdge1, anEdge2, aPlane, theAngle1 * M_PI / 180.,
TCollection_ExtendedString(Angle1_str.c_str())); TCollection_ExtendedString(Angle1_str.c_str()));
anAngleIO->SetArrowSize((theAngle1 * M_PI / 180) * (theLength/20)); anAngleIO->SetArrowSize((theAngle1 * M_PI / 180) * (theLength/20));
@ -1081,15 +1208,14 @@ void EntityGUI_3DSketcherDlg::displayAngle(double theAngle1, double theAngle2, d
asp->LineAspect()->SetWidth(w); asp->LineAspect()->SetWidth(w);
anAngleIO->Attributes()->SetAngleAspect(asp); anAngleIO->Attributes()->SetAngleAspect(asp);
SOCC_Prs* aSPrs = dynamic_cast<SOCC_Prs*>(((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->CreatePrs(0)); SOCC_Prs* aSPrs = dynamic_cast<SOCC_Prs*>
(((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->CreatePrs(0));
if (store) if (store)
{ {
// Erase dimensions presentations // Erase dimensions presentations
((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Erase(myAnglePrs, true); ((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Erase(myAnglePrs, true);
myAnglePrs->PrependObject(anAngleIO); myAnglePrs->PrependObject(anAngleIO);
myPrsType = TYPE_ANGLE; // Overwrite type with ANGLE
// Display modified presentation // Display modified presentation
if (isAngleVisible) if (isAngleVisible)
@ -1099,13 +1225,15 @@ void EntityGUI_3DSketcherDlg::displayAngle(double theAngle1, double theAngle2, d
{ {
aSPrs->AddObject(anAngleIO); aSPrs->AddObject(anAngleIO);
} }
myPrsType = TYPE_ANGLE; // Overwrite type with ANGLE
if (twoAngles) if (twoAngles)
{ {
gce_MakePln gce_MP2(Last_Pnt, P2, Current_Pnt); gce_MakePln gce_MP2(Last_Pnt, P2, Current_Pnt);
Handle(Geom_Plane) aPlane2 = new Geom_Plane(gce_MP2.Value()); Handle(Geom_Plane) aPlane2 = new Geom_Plane(gce_MP2.Value());
Handle(AIS_AngleDimension) anAngle2IO = new AIS_AngleDimension(anEdge2, anEdge3, aPlane2, theAngle2 * M_PI / 180., Handle(AIS_AngleDimension) anAngle2IO =
new AIS_AngleDimension(anEdge2, anEdge3, aPlane2, theAngle2 * M_PI / 180.,
TCollection_ExtendedString(Angle2_str.c_str())); TCollection_ExtendedString(Angle2_str.c_str()));
anAngle2IO->SetArrowSize((theAngle2 * M_PI / 180) * (theLength/20)); anAngle2IO->SetArrowSize((theAngle2 * M_PI / 180) * (theLength/20));
@ -1115,9 +1243,7 @@ void EntityGUI_3DSketcherDlg::displayAngle(double theAngle1, double theAngle2, d
{ {
// Erase dimensions presentations // Erase dimensions presentations
((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Erase(myAnglePrs, true); ((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Erase(myAnglePrs, true);
myAnglePrs->PrependObject(anAngle2IO); myAnglePrs->PrependObject(anAngle2IO);
myPrsType = TYPE_TWO_ANGLES; // Overwrite type with TWO_ANGLES
// Display modified presentation // Display modified presentation
if (isAngleVisible) if (isAngleVisible)
@ -1127,6 +1253,8 @@ void EntityGUI_3DSketcherDlg::displayAngle(double theAngle1, double theAngle2, d
{ {
aSPrs->AddObject(anAngle2IO); aSPrs->AddObject(anAngle2IO);
} }
myPrsType = TYPE_TWO_ANGLES; // Overwrite type with TWO_ANGLES
} }
if (!store && isAngleVisible) if (!store && isAngleVisible)
@ -1139,7 +1267,7 @@ void EntityGUI_3DSketcherDlg::displayAngle(double theAngle1, double theAngle2, d
// Function : displayLength() // Function : displayLength()
// Purpose : Method for displaying length dimensions // Purpose : Method for displaying length dimensions
//================================================================ //================================================================
void EntityGUI_3DSketcherDlg::displayLength(double theLength, bool store) void EntityGUI_3DSketcherDlg::displayLength (double theLength, bool store, int type)
{ {
SUIT_ViewWindow* vw = SUIT_Session::session()->activeApplication()->desktop()->activeWindow(); SUIT_ViewWindow* vw = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
@ -1147,6 +1275,9 @@ void EntityGUI_3DSketcherDlg::displayLength(double theLength, bool store)
XYZ Current = getCurrentPoint(); XYZ Current = getCurrentPoint();
XYZ Penultimate = getPenultimatePoint(); XYZ Penultimate = getPenultimatePoint();
bool withAngle = (type == TYPE_ANGLE || type == TYPE_TWO_ANGLES);
bool twoAngles = (type == TYPE_TWO_ANGLES);
double aLength = 0.0; double aLength = 0.0;
if (theLength < 0) // Calculate length if not given if (theLength < 0) // Calculate length if not given
@ -1167,6 +1298,7 @@ void EntityGUI_3DSketcherDlg::displayLength(double theLength, bool store)
gp_Vec Vec1(P1,P2); gp_Vec Vec1(P1,P2);
gp_Vec Vec2(P1,P3); gp_Vec Vec2(P1,P3);
gp_Vec Vec3 = Vec1;
TopoDS_Vertex aVert1 = BRepBuilderAPI_MakeVertex(P1); TopoDS_Vertex aVert1 = BRepBuilderAPI_MakeVertex(P1);
TopoDS_Vertex aVert2 = BRepBuilderAPI_MakeVertex(P2); TopoDS_Vertex aVert2 = BRepBuilderAPI_MakeVertex(P2);
@ -1174,8 +1306,55 @@ void EntityGUI_3DSketcherDlg::displayLength(double theLength, bool store)
// Convert length to string // Convert length to string
std::string aLength_str = doubleToString(aLength); std::string aLength_str = doubleToString(aLength);
// Plane for the presentation // Define the suitable plane for right relative positioning of dimension presentations
if ( Abs(Vec1.CrossMagnitude(Vec2)) < Precision::Confusion() ) // Check colinearity
gp_Dir aNormal; // Normal defining the plane of the presentation
if (withAngle) // If one angle
{
switch(myOrientation)
{
case OXY:
{
aNormal = gp::DZ().Crossed(gp_Dir(Vec1));//--> the plane is orthogonal to the angle presentation
// plane and contains the current edge
if (twoAngles) // If two angles
{
gp_XYZ Vec1_XY(Vec1.X(),Vec1.Y(),0.0);// --> define Vec3 as the projection of the current
Vec3 = gp_Vec(Vec1_XY); // edge on the plane chosen for the first angle
}
break;
}
case OYZ:
{
aNormal = gp::DX().Crossed(gp_Dir(Vec1));
if (twoAngles)
{
gp_XYZ Vec1_YZ(0.0,Vec1.Y(),Vec1.Z());
Vec3 = gp_Vec(Vec1_YZ);
}
break;
}
case OXZ:
{
aNormal = gp::DY().Crossed(gp_Dir(Vec1));
if (twoAngles)
{
gp_XYZ Vec1_XZ(Vec1.X(),0.0,Vec1.Z());
Vec3 = gp_Vec(Vec1_XZ);
}
break;
}
}
if(twoAngles // If two angles
&& Abs(Vec1.CrossMagnitude(Vec3)) > Precision::Confusion())
{
aNormal = gp_Dir(Vec1.Crossed(Vec3));// --> set the normal as the cross product of
} // the current edge with its projection
} // it ensures that the dimension changes
else
{
// Check colinearity
if (Abs(Vec1.CrossMagnitude(Vec2)) < Precision::Confusion())
{ {
Vec2 = gp_Vec(gp::DX()); Vec2 = gp_Vec(gp::DX());
if (Abs(Vec1.CrossMagnitude(Vec2)) < Precision::Confusion()) if (Abs(Vec1.CrossMagnitude(Vec2)) < Precision::Confusion())
@ -1183,41 +1362,15 @@ void EntityGUI_3DSketcherDlg::displayLength(double theLength, bool store)
Vec2 = gp_Vec(gp::DY()); Vec2 = gp_Vec(gp::DY());
} }
} }
aNormal = gp_Dir(Vec1.Crossed(Vec2)); // If no angles --> the plane is the one formed by
} // the last edge and the current one
// Normal to the representation plane // Plane construction
gp_Dir Normal(Vec2.Crossed(Vec1)); gce_MakePln gce_MP(P1, aNormal);
// // Check orientation of plane in order to avoid it to change during an Angle preview
// MESSAGE("repere0 abs = "<< Abs(Normal.Dot(gp::DZ()) ))
// if ( Abs(Normal.Dot(gp::DZ())) > Precision::Confusion() )
// {
// MESSAGE("repere1")
// if ( Normal.Dot(gp::DZ()) < 0.0 ){
// MESSAGE("REVERSE on OZ basis")
// Normal.Reverse();
// }
// }
// else if ( Abs(Normal.Dot(gp::DX())) > Precision::Confusion() )
// {
// MESSAGE("repere2")
// if ( Normal.Dot(gp::DX()) < 0.0 ){
// MESSAGE("REVERSE on OX basis")
// Normal.Reverse();
// }
// }
// else if ( Abs(Normal.Dot(gp::DY())) > Precision::Confusion() )
// {
// MESSAGE("repere3")
// if ( Normal.Dot(gp::DY()) < 0.0 ){
// MESSAGE("REVERSE on OY basis")
// Normal.Reverse();
// }
// }
gce_MakePln gce_MP(P1, Normal);
Handle(Geom_Plane) aPlane = new Geom_Plane(gce_MP.Value()); Handle(Geom_Plane) aPlane = new Geom_Plane(gce_MP.Value());
Handle(AIS_LengthDimension) anIO = new AIS_LengthDimension(aVert1, Handle(AIS_LengthDimension) anIO =
new AIS_LengthDimension(aVert1,
aVert2, aVert2,
aPlane, aPlane,
aLength, aLength,
@ -1234,9 +1387,7 @@ void EntityGUI_3DSketcherDlg::displayLength(double theLength, bool store)
{ {
// Erase length dimensions presentation // Erase length dimensions presentation
((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Erase(myLengthPrs, true); ((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Erase(myLengthPrs, true);
myLengthPrs->PrependObject(anIO); myLengthPrs->PrependObject(anIO);
myPrsType = TYPE_LENGTH;
// Display modified presentation // Display modified presentation
if (isLengthVisible) if (isLengthVisible)
@ -1244,13 +1395,16 @@ void EntityGUI_3DSketcherDlg::displayLength(double theLength, bool store)
} }
else if (isLengthVisible) else if (isLengthVisible)
{ {
SOCC_Prs* aSPrs = dynamic_cast<SOCC_Prs*>(((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->CreatePrs(0)); SOCC_Prs* aSPrs = dynamic_cast<SOCC_Prs*>
(((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->CreatePrs(0));
if (aSPrs) if (aSPrs)
{ {
aSPrs->PrependObject(anIO); aSPrs->PrependObject(anIO);
GEOMBase_Helper::displayPreview(aSPrs, true, true); GEOMBase_Helper::displayPreview(aSPrs, true, true);
} }
} }
myPrsType = TYPE_LENGTH;
} }
//================================================================ //================================================================

View File

@ -15,12 +15,11 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// GEOM GEOMGUI : GUI for Geometry component // GEOM GEOMGUI : GUI for Geometry component
// File : EntityGUI_3DSketcherDlg.h // File : EntityGUI_3DSketcherDlg.h
// Author : DMV, OCN // Author : DMV, OCN
//
#ifndef ENTITYGUI_3DSKETCHERDLG_H #ifndef ENTITYGUI_3DSKETCHERDLG_H
#define ENTITYGUI_3DSKETCHERDLG_H #define ENTITYGUI_3DSKETCHERDLG_H
@ -53,9 +52,10 @@ class EntityGUI_3DSketcherDlg : public GEOMBase_Skeleton
struct XYZ struct XYZ
{ {
XYZ() { x = y = z = 0.0; xt = yt = zt = "0.0"; } XYZ() { x = y = z = 0.0; command = params = ""; }
double x, y, z; double x, y, z; // for preview only
QString xt, yt, zt; QString command;
QString params;
}; };
typedef QList<XYZ> XYZList; typedef QList<XYZ> XYZList;
@ -85,7 +85,7 @@ private:
void displayTrihedron( int ); void displayTrihedron( int );
void displayAngle( double, double, double, int, bool store = false ); void displayAngle( double, double, double, int, bool store = false );
void displayLength( double theLength = -1.0, bool store = false ); void displayLength( double theLength = -1.0, bool store = false, int type = 1);
bool createShapes( GEOM::GEOM_Object_ptr, bool createShapes( GEOM::GEOM_Object_ptr,
TopoDS_Shape&, TopoDS_Shape&,
@ -132,6 +132,7 @@ private slots:
bool ClickOnApply(); bool ClickOnApply();
// bool isSameAsPrevious(); // bool isSameAsPrevious();
void UpdateButtonsState(); void UpdateButtonsState();
void UpdatePointCoordinates();
void ClickOnUndo(); void ClickOnUndo();
void ClickOnRedo(); void ClickOnRedo();

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>327</width> <width>278</width>
<height>50</height> <height>181</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -19,9 +19,17 @@
</property> </property>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QGroupBox" name="GroupBox1"> <widget class="QGroupBox" name="GroupBox1">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title"> <property name="title">
<string/> <string/>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="0"> <item row="0" column="0">
<widget class="QCheckBox" name="CheckBox2"> <widget class="QCheckBox" name="CheckBox2">
@ -30,13 +38,100 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="0" column="1">
<widget class="QCheckBox" name="CheckBox1"> <widget class="QCheckBox" name="CheckBox1">
<property name="text"> <property name="text">
<string/> <string/>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0">
<widget class="QCheckBox" name="CheckBox3">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Start:</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_1">
<property name="text">
<string>X</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="lineEdit_1"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Y</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="lineEdit_2"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Z</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="lineEdit_3"/>
</item>
<item row="0" column="3">
<widget class="QLabel" name="label_7">
<property name="text">
<string>End:</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="label_4">
<property name="text">
<string>X</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QLineEdit" name="lineEdit_4"/>
</item>
<item row="2" column="2">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Y</string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QLineEdit" name="lineEdit_5"/>
</item>
<item row="3" column="2">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Z</string>
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="QLineEdit" name="lineEdit_6"/>
</item>
</layout>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>

View File

@ -674,6 +674,13 @@ void EntityGUI_SketcherDlg::DestClicked( int constructorId )
GroupD2->show(); GroupD2->show();
Group3Spin->checkBox->hide(); Group3Spin->checkBox->hide();
Group4Spin->checkBox->hide(); Group4Spin->checkBox->hide();
if (myConstructorId == 1) {
myRadius = 100.0;
myLength = 30.0;
myAngle = 0.0;
myDX = 0.0;
myDY = 0.0;
}
Dir1Clicked( 2 ); // Angle Dir1Clicked( 2 ); // Angle
} }
resize( minimumSizeHint() ); resize( minimumSizeHint() );
@ -899,7 +906,17 @@ void EntityGUI_SketcherDlg::Dir1Clicked( int constructorId )
void EntityGUI_SketcherDlg::Dir2Clicked( int constructorId ) void EntityGUI_SketcherDlg::Dir2Clicked( int constructorId )
{ {
InitClick(); InitClick();
myAngle = 0.0; Group3Spin->SpinBox_DX->blockSignals(true); // Block signals in order not to modify
Group3Spin->SpinBox_DY->blockSignals(true); // defaut values
Group3Spin->SpinBox_DZ->blockSignals(true);
Group2Spin->SpinBox_DX->blockSignals(true);
Group2Spin->SpinBox_DY->blockSignals(true);
Group4Spin->SpinBox_DX->blockSignals(true);
Group4Spin->SpinBox_DY->blockSignals(true);
Group4Spin->SpinBox_DZ->blockSignals(true);
Group4Spin->SpinBox_DS->blockSignals(true);
// Get setting of step value from file configuration // Get setting of step value from file configuration
double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 ); double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
@ -980,9 +997,7 @@ void EntityGUI_SketcherDlg::Dir2Clicked( int constructorId )
initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" ); initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_VX2" ) ); Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_VX2" ) );
Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_VY2" ) ); Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_VY2" ) );
myDX = 0.0;
Group3Spin->SpinBox_DX->setValue( myDX ); Group3Spin->SpinBox_DX->setValue( myDX );
myDY = 0.0;
Group3Spin->SpinBox_DY->setValue( myDY ); Group3Spin->SpinBox_DY->setValue( myDY );
Group3Spin->show(); Group3Spin->show();
Group3Spin->buttonApply->setFocus(); Group3Spin->buttonApply->setFocus();
@ -1015,9 +1030,7 @@ void EntityGUI_SketcherDlg::Dir2Clicked( int constructorId )
Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_RADIUS2" ) ); Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_ANGLE2" )); Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_ANGLE2" ));
Group3Spin->SpinBox_DX->setValue( myAngle ); Group3Spin->SpinBox_DX->setValue( myAngle );
myRadius = 100.0;
Group3Spin->SpinBox_DY->setValue( myRadius ); Group3Spin->SpinBox_DY->setValue( myRadius );
myLength = 30.0;
Group3Spin->SpinBox_DZ->setValue( myLength ); Group3Spin->SpinBox_DZ->setValue( myLength );
Group3Spin->show(); Group3Spin->show();
Group3Spin->buttonApply->setFocus(); Group3Spin->buttonApply->setFocus();
@ -1030,9 +1043,9 @@ void EntityGUI_SketcherDlg::Dir2Clicked( int constructorId )
initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 5., "angle_precision" ); initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 5., "angle_precision" );
Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_RADIUS2" ) ); Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_ANGLE2" ) ); Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
myRadius = 100.0; // myRadius = 100.0;
Group2Spin->SpinBox_DX->setValue( myRadius ); Group2Spin->SpinBox_DX->setValue( myRadius );
myLength = 30.0; // myLength = 30.0;
Group2Spin->SpinBox_DY->setValue( myLength ); Group2Spin->SpinBox_DY->setValue( myLength );
Group2Spin->show(); Group2Spin->show();
Group2Spin->buttonApply->setFocus(); Group2Spin->buttonApply->setFocus();
@ -1045,9 +1058,9 @@ void EntityGUI_SketcherDlg::Dir2Clicked( int constructorId )
initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 5., "angle_precision" ); initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 5., "angle_precision" );
Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_RADIUS2" ) ); Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_ANGLE2" ) ); Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
myRadius = 100.0; // myRadius = 100.0;
Group2Spin->SpinBox_DX->setValue( myRadius ); Group2Spin->SpinBox_DX->setValue( myRadius );
myLength = 30.0; // myLength = 30.0;
Group2Spin->SpinBox_DY->setValue( myLength ); Group2Spin->SpinBox_DY->setValue( myLength );
Group2Spin->show(); Group2Spin->show();
Group2Spin->buttonApply->setFocus(); Group2Spin->buttonApply->setFocus();
@ -1064,19 +1077,29 @@ void EntityGUI_SketcherDlg::Dir2Clicked( int constructorId )
initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, "length_precision" ); initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, "length_precision" ); initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, 5., "length_precision" ); initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, 5., "length_precision" );
myDX = 0.0;
Group4Spin->SpinBox_DX->setValue( myDX ); Group4Spin->SpinBox_DX->setValue( myDX );
myDY = 0.0;
Group4Spin->SpinBox_DY->setValue( myDY ); Group4Spin->SpinBox_DY->setValue( myDY );
myRadius = 100.0; // myRadius = 100.0;
Group4Spin->SpinBox_DZ->setValue( myRadius ); Group4Spin->SpinBox_DZ->setValue( myRadius );
myLength = 30.0; // myLength = 30.0;
Group4Spin->SpinBox_DS->setValue( myLength ); Group4Spin->SpinBox_DS->setValue( myLength );
Group4Spin->show(); Group4Spin->show();
Group4Spin->buttonApply->setFocus(); Group4Spin->buttonApply->setFocus();
} }
} }
} }
Group3Spin->SpinBox_DX->blockSignals(false); // Restore signals
Group3Spin->SpinBox_DY->blockSignals(false);
Group3Spin->SpinBox_DZ->blockSignals(false);
Group2Spin->SpinBox_DX->blockSignals(false);
Group2Spin->SpinBox_DY->blockSignals(false);
Group4Spin->SpinBox_DX->blockSignals(false);
Group4Spin->SpinBox_DY->blockSignals(false);
Group4Spin->SpinBox_DZ->blockSignals(false);
Group4Spin->SpinBox_DS->blockSignals(false);
resize( minimumSizeHint() ); resize( minimumSizeHint() );
GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth ); GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
} }

View File

@ -674,12 +674,13 @@ TCollection_AsciiString GEOM_Engine::DumpPython(int theDocID,
// add function description before dump // add function description before dump
if (!aCurScript.IsEmpty()) if (!aCurScript.IsEmpty())
{ {
if ( aFunction->GetDriverGUID() == GEOM_Object::GetSubShapeID() ) if ( aFunction->GetDriverGUID() == GEOM_Object::GetSubShapeID() &&
aFuncScript.Length() > aCurScript.Length() )
// avoid repeated SubShape...() command at the end // avoid repeated SubShape...() command at the end
if (aFuncScript.Location( aCurScript, if (aFuncScript.Location( aCurScript,
aFuncScript.Length() - aCurScript.Length(), aFuncScript.Length() - aCurScript.Length(),
aFuncScript.Length())) aFuncScript.Length()))
continue; continue; // aCurScript is already at the end of aFuncScript
aFuncScript += aCurScript; aFuncScript += aCurScript;
} }
if (isDumpCollected ) { if (isDumpCollected ) {
@ -960,7 +961,7 @@ std::list<int> GEOM_Engine::getAllTextures(int theDocID)
//============================================================================= //=============================================================================
/*! /*!
* ProcessFunction: Dump fucntion description into script * ProcessFunction: Dump function description into script
*/ */
//============================================================================= //=============================================================================
bool ProcessFunction(Handle(GEOM_Function)& theFunction, bool ProcessFunction(Handle(GEOM_Function)& theFunction,
@ -1022,6 +1023,16 @@ bool ProcessFunction(Handle(GEOM_Function)& theFunction,
//Check if its internal function which doesn't requires dumping //Check if its internal function which doesn't requires dumping
if(aDescr == "None") return false; if(aDescr == "None") return false;
//Check the very specific case of RestoreShape function,
//which is not dumped, but the result can be published by the user.
//We do not publish such objects to decrease danger of dumped script failure.
if(aDescr.Value(1) == '#') {
TCollection_AsciiString anObjEntry;
TDF_Tool::Entry(theFunction->GetOwnerEntry(), anObjEntry);
theIgnoreObjs.insert(anObjEntry);
return false;
}
// 0020001 PTv, check for critical functions, which require dump of objects // 0020001 PTv, check for critical functions, which require dump of objects
if (theIsPublished) if (theIsPublished)
{ {
@ -1035,6 +1046,95 @@ bool ProcessFunction(Handle(GEOM_Function)& theFunction,
//Replace parameter by notebook variables //Replace parameter by notebook variables
ReplaceVariables(aDescr,theVariables); ReplaceVariables(aDescr,theVariables);
//Process sketcher functions, replacing string command by calls to Sketcher interface
if (aDescr.Search( "Make3DSketcher" ) != -1) {
TCollection_AsciiString aNewDescr;
int i = 1;
TCollection_AsciiString aSubStr = aDescr.Token("\n\t", i);
for (; !aSubStr.IsEmpty(); aSubStr = aDescr.Token("\n\t", i)) {
if (aSubStr.Search( "Make3DSketcherCommand" ) != -1) {
TCollection_AsciiString aResult = aSubStr.Token(" ", 1);
// "3DSketcher:CMD[:CMD[:CMD...]]"
TCollection_AsciiString aCommand = aSubStr.Token("\"", 2);
// Split the command string to separate CMDs
int icmd = 2;
TColStd_SequenceOfAsciiString aSequence;
if (aCommand.Length()) {
TCollection_AsciiString aToken = aCommand.Token(":", icmd);
while (aToken.Length() > 0) {
aSequence.Append(aToken);
aToken = aCommand.Token(":", ++icmd);
}
}
if (aSequence.Length() > 0) {
if (i > 1)
aNewDescr += "\n\t";
aNewDescr += "sk = geompy.Sketcher3D()";
int nbCMDs = aSequence.Length();
for (icmd = 1; icmd <= nbCMDs; icmd++) {
aNewDescr += "\n\t";
TCollection_AsciiString aCMD = aSequence.Value(icmd);
// Split the CMD into string values
TColStd_SequenceOfAsciiString aStrVals;
int ival = 1;
TCollection_AsciiString aToken = aCMD.Token(" ", ival);
while (aToken.Length() > 0) {
aStrVals.Append(aToken);
aToken = aCMD.Token(" ", ++ival);
}
TCollection_AsciiString aCMDpref = aStrVals.Value(1);
if (aCMDpref == "TT") {
aNewDescr += "sk.addPointsAbsolute(";
aNewDescr += aStrVals.Value(2) + ", " + aStrVals.Value(3) + ", " + aStrVals.Value(4) + ")";
}
else if (aCMDpref == "T") {
aNewDescr += "sk.addPointsRelative(";
aNewDescr += aStrVals.Value(2) + ", " + aStrVals.Value(3) + ", " + aStrVals.Value(4) + ")";
}
else if (aCMDpref == "WW") {
aNewDescr += "sk.close()";
}
else {
aNewDescr += "sk.addPointAnglesLength(\"";
aNewDescr += aCMDpref + "\", " +
aStrVals.Value(2) + ", " + aStrVals.Value(3) + ", " + aStrVals.Value(4) + ")";
}
}
aNewDescr += "\n\t";
aNewDescr += aResult + " = sk.wire()";
}
} // Make3DSketcherCommand
else if (aSubStr.Search( "Make3DSketcher" ) != -1) {
TCollection_AsciiString aResult = aSubStr.Token(" ", 1);
TCollection_AsciiString aCommand = aSubStr.Token("[", 2);
aCommand = aCommand.Token("]", 1);
if (i > 1)
aNewDescr += "\n\t";
aNewDescr += "sk = geompy.Sketcher3D()";
aNewDescr += "\n\t";
aNewDescr += "sk.addPointsAbsolute(";
aNewDescr += aCommand + ")";
aNewDescr += "\n\t";
aNewDescr += aResult + " = sk.wire()";
}
else {
if (i > 1)
aNewDescr += "\n\t";
aNewDescr += aSubStr;
}
i++;
}
aDescr = aNewDescr;
}
if ( theIsDumpCollected ) { if ( theIsDumpCollected ) {
int i = 1; int i = 1;
bool isBefore = true; bool isBefore = true;

View File

@ -570,10 +570,12 @@ void GEOMAlgo_ShapeInfoFiller::FillEdge(const TopoDS_Shape& aS)
aPc.SetXYZ(aXYZc); aPc.SetXYZ(aXYZc);
aInfo.SetLocation(aPc); aInfo.SetLocation(aPc);
// //
if ( aLength >= gp::Resolution() ) {
gp_Vec aVec(aPc, aP2); gp_Vec aVec(aPc, aP2);
gp_Dir aDir(aVec); gp_Dir aDir(aVec);
aInfo.SetDirection(aDir); aInfo.SetDirection(aDir);
} }
}
//modified by NIZNHY-PKV Tue Jul 03 10:19:06 2012t //modified by NIZNHY-PKV Tue Jul 03 10:19:06 2012t
// Line // Line
else if (aCT==GeomAbs_Line) { else if (aCT==GeomAbs_Line) {

View File

@ -18,11 +18,10 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// File : GEOMGUI_Selection.cxx // File : GEOMGUI_Selection.cxx
// Author : Alexander SOLOVYOV, Open CASCADE S.A.S. (alexander.solovyov@opencascade.com) // Author : Alexander SOLOVYOV, Open CASCADE S.A.S. (alexander.solovyov@opencascade.com)
//
#include "GEOMGUI_Selection.h" #include "GEOMGUI_Selection.h"
#include "GeometryGUI.h" #include "GeometryGUI.h"
@ -159,10 +158,12 @@ QVariant GEOMGUI_Selection::parameter( const int idx, const QString& p ) const
v = isVectorsMode( idx ); v = isVectorsMode( idx );
else if ( p == "topLevel" ) else if ( p == "topLevel" )
v = topLevel( idx ); v = topLevel( idx );
else if ( p == "hasHiddenChildren" ) else if ( p == "hasChildren" )
v = hasHiddenChildren( idx ); v = hasChildren( idx );
else if ( p == "hasShownChildren" ) else if ( p == "hasConcealedChildren" )
v = hasShownChildren( idx ); v = hasConcealedChildren( idx );
else if ( p == "hasDisclosedChildren" )
v = hasDisclosedChildren( idx );
else if ( p == "compoundOfVertices" ) else if ( p == "compoundOfVertices" )
v = compoundOfVertices( idx ); v = compoundOfVertices( idx );
else if ( p == "imported" ) else if ( p == "imported" )
@ -446,7 +447,23 @@ bool GEOMGUI_Selection::isCompoundOfVertices( GEOM::GEOM_Object_ptr obj )
return ret; return ret;
} }
bool GEOMGUI_Selection::hasHiddenChildren( const int index ) const bool GEOMGUI_Selection::hasChildren( const int index ) const
{
bool ok = false;
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( study() );
if ( appStudy ) {
QString anEntry = entry( index );
_PTR(Study) study = appStudy->studyDS();
if ( study && !anEntry.isEmpty() ) {
_PTR(SObject) aSO( study->FindObjectID( anEntry.toStdString() ) );
ok = hasChildren( aSO );
}
}
return ok;
}
bool GEOMGUI_Selection::hasConcealedChildren( const int index ) const
{ {
bool OK = false; bool OK = false;
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( study() ); SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( study() );
@ -462,7 +479,7 @@ bool GEOMGUI_Selection::hasHiddenChildren( const int index ) const
return OK; return OK;
} }
bool GEOMGUI_Selection::hasShownChildren( const int index ) const bool GEOMGUI_Selection::hasDisclosedChildren( const int index ) const
{ {
bool OK = false; bool OK = false;
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( study() ); SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( study() );

View File

@ -18,11 +18,10 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// File : GEOMGUI_Selection.h // File : GEOMGUI_Selection.h
// Author : Alexander SOLOVYOV, Open CASCADE S.A.S. (alexander.solovyov@opencascade.com) // Author : Alexander SOLOVYOV, Open CASCADE S.A.S. (alexander.solovyov@opencascade.com)
//
#ifndef GEOMGUI_SELECTION_H #ifndef GEOMGUI_SELECTION_H
#define GEOMGUI_SELECTION_H #define GEOMGUI_SELECTION_H
@ -66,8 +65,9 @@ private:
QString displayMode( const int ) const; QString displayMode( const int ) const;
QString selectionMode() const; QString selectionMode() const;
bool isVectorsMode( const int ) const; bool isVectorsMode( const int ) const;
bool hasHiddenChildren( const int ) const; bool hasChildren( const int ) const;
bool hasShownChildren( const int ) const; bool hasConcealedChildren( const int ) const;
bool hasDisclosedChildren( const int ) const;
bool compoundOfVertices( const int ) const; bool compoundOfVertices( const int ) const;
bool topLevel( const int ) const; bool topLevel( const int ) const;
bool isPhysicalMaterial( const int ) const; bool isPhysicalMaterial( const int ) const;

View File

@ -114,6 +114,13 @@
#include <Graphic3d_HArray1OfBytes.hxx> #include <Graphic3d_HArray1OfBytes.hxx>
#endif #endif
// 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
// Below macro, when uncommented, switches on simplified (more performant) algorithm
// of auto-color picking up
//#define SIMPLE_AUTOCOLOR
//================================================================ //================================================================
// Function : getActiveStudy // Function : getActiveStudy
// Purpose : Get active study, returns 0 if no open study frame // Purpose : Get active study, returns 0 if no open study frame
@ -1823,6 +1830,40 @@ int GEOM_Displayer::UnsetDisplayMode()
return aPrevMode; return aPrevMode;
} }
SALOMEDS::Color GEOM_Displayer::getPredefinedUniqueColor()
{
static QList<QColor> colors;
if ( colors.isEmpty() ) {
const int rfactor = 4; // red color component split factor, must be > 0
const int gfactor = 4; // green color component split factor, must be > 0
const int bfactor = 3; // blue color component split factor, must be > 0
// -
// total number of pre-defined colors is defined as
// nbcolors = rfactor * gfactor * bfactor
// NB: all three factors should not have same values
// otherwise all colors will be greyish
for ( int g = 0; g < gfactor; g++ ) {
for ( int r = 0; r < rfactor; r++ ) {
for ( int b = 0; b < bfactor; b++ )
colors.append( QColor( qRgb( r * 255 / (rfactor-1), g * 255 / (gfactor-1), b * 255 / (bfactor-1) ) ) );
}
}
}
static int currentColor = 0;
SALOMEDS::Color color;
color.R = (double)colors[currentColor].red() / 255.0;
color.G = (double)colors[currentColor].green() / 255.0;
color.B = (double)colors[currentColor].blue() / 255.0;
currentColor = (currentColor+1) % colors.count();
return color;
}
SALOMEDS::Color GEOM_Displayer::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors ) SALOMEDS::Color GEOM_Displayer::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
{ {
int aHue = -1; int aHue = -1;
@ -2003,47 +2044,49 @@ SALOMEDS::Color GEOM_Displayer::getColor(GEOM::GEOM_Object_var theGeomObject, bo
hasColor = false; hasColor = false;
SUIT_Session* session = SUIT_Session::session(); SUIT_Session* session = SUIT_Session::session();
SUIT_Application* app = session->activeApplication(); SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
if ( app && !theGeomObject->_is_nil()) { if ( app && !theGeomObject->_is_nil()) {
SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ); SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
if ( study ) { if ( study ) {
_PTR(Study) aStudy = study->studyDS();
aSColor = theGeomObject->GetColor(); aSColor = theGeomObject->GetColor();
hasColor = aSColor.R >= 0 && aSColor.G >= 0 && aSColor.B >= 0; hasColor = aSColor.R >= 0 && aSColor.G >= 0 && aSColor.B >= 0;
if( !hasColor && theGeomObject->GetType() == GEOM_GROUP ) { // auto color for group if ( !hasColor ) {
GEOM::GEOM_Gen_var theGeomGen = GeometryGUI::GetGeomGen(); #ifdef GENERAL_AUTOCOLOR // auto-color for all sub-shapes
GEOM::GEOM_IGroupOperations_var anOperations = theGeomGen->GetIGroupOperations( study->id() ); bool general_autocolor = true;
GEOM::GEOM_Object_var aMainObject = anOperations->GetMainShape( theGeomObject ); #else // auto-color for groups only
if ( !aMainObject->_is_nil() && aMainObject->GetAutoColor() ) bool general_autocolor = false;
{ #endif // GENERAL_AUTOCOLOR
if ( general_autocolor || theGeomObject->GetType() == GEOM_GROUP ) {
GEOM::GEOM_Object_var aMainObject = theGeomObject->GetMainShape();
if ( !CORBA::is_nil( aMainObject ) && aMainObject->GetAutoColor() ) {
#ifdef SIMPLE_AUTOCOLOR // simplified algorithm for auto-colors
aSColor = getPredefinedUniqueColor();
hasColor = true;
#else // old algorithm for auto-colors
QList<SALOMEDS::Color> aReservedColors; QList<SALOMEDS::Color> aReservedColors;
SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( app );
CORBA::String_var IOR = app->orb()->object_to_string( aMainObject ); CORBA::String_var IOR = app->orb()->object_to_string( aMainObject );
if ( strcmp(IOR.in(), "") != 0 ) _PTR(SObject) aMainSObject( aStudy->FindObjectIOR( IOR.in() ) );
{ if ( aMainSObject ) {
_PTR(Study) aStudy = study->studyDS();
_PTR(SObject) aMainSObject( aStudy->FindObjectIOR( std::string(IOR) ) );
_PTR(ChildIterator) it( aStudy->NewChildIterator( aMainSObject ) ); _PTR(ChildIterator) it( aStudy->NewChildIterator( aMainSObject ) );
for( ; it->More(); it->Next() ) for ( ; it->More(); it->Next() ) {
{
_PTR(SObject) aChildSObject( it->Value() ); _PTR(SObject) aChildSObject( it->Value() );
GEOM::GEOM_Object_var aChildObject = GEOM::GEOM_Object_var aChildObject =
GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aChildSObject)); GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aChildSObject));
if ( CORBA::is_nil( aChildObject ) ) if ( CORBA::is_nil( aChildObject ) )
continue; continue;
if( aChildObject->GetType() != GEOM_GROUP )
continue;
SALOMEDS::Color aReservedColor = aChildObject->GetColor(); SALOMEDS::Color aReservedColor = aChildObject->GetColor();
if ( aReservedColor.R >= 0 && aReservedColor.G >= 0 && aReservedColor.B >= 0 )
aReservedColors.append( aReservedColor ); aReservedColors.append( aReservedColor );
} }
} }
aSColor = getUniqueColor( aReservedColors ); aSColor = getUniqueColor( aReservedColors );
hasColor = true; hasColor = true;
#endif // SIMPLE_AUTOCOLOR
}
} }
} }
} }

View File

@ -169,6 +169,7 @@ public:
SalomeApp_Study* getStudy() const; SalomeApp_Study* getStudy() const;
static SALOMEDS::Color getUniqueColor( const QList<SALOMEDS::Color>& ); static SALOMEDS::Color getUniqueColor( const QList<SALOMEDS::Color>& );
static SALOMEDS::Color getPredefinedUniqueColor();
static PropMap getDefaultPropertyMap(const QString& viewer_type); static PropMap getDefaultPropertyMap(const QString& viewer_type);

View File

@ -167,6 +167,10 @@
<source>ICON_DLG_CHECK_COMPOUND_OF_BLOCKS</source> <source>ICON_DLG_CHECK_COMPOUND_OF_BLOCKS</source>
<translation>check_blocks_compound.png</translation> <translation>check_blocks_compound.png</translation>
</message> </message>
<message>
<source>ICON_DLG_GETNONBLOCKS</source>
<translation>get_non_blocks.png</translation>
</message>
<message> <message>
<source>ICON_DLG_CHECK_SELF_INTERSECTIONS</source> <source>ICON_DLG_CHECK_SELF_INTERSECTIONS</source>
<translation>check_self_intersections.png</translation> <translation>check_self_intersections.png</translation>
@ -739,6 +743,10 @@
<source>ICO_CHECK_COMPOUND</source> <source>ICO_CHECK_COMPOUND</source>
<translation>check_blocks_compound.png</translation> <translation>check_blocks_compound.png</translation>
</message> </message>
<message>
<source>ICO_GET_NON_BLOCKS</source>
<translation>get_non_blocks.png</translation>
</message>
<message> <message>
<source>ICO_CHECK_SELF_INTERSECTIONS</source> <source>ICO_CHECK_SELF_INTERSECTIONS</source>
<translation>check_self_intersections.png</translation> <translation>check_self_intersections.png</translation>
@ -763,6 +771,10 @@
<source>ICO_COMMON</source> <source>ICO_COMMON</source>
<translation>common.png</translation> <translation>common.png</translation>
</message> </message>
<message>
<source>ICO_GROUP_INTERSECT</source>
<translation>common.png</translation>
</message>
<message> <message>
<source>ICO_COMPOUND</source> <source>ICO_COMPOUND</source>
<translation>build_compound.png</translation> <translation>build_compound.png</translation>
@ -783,6 +795,10 @@
<source>ICO_CUT</source> <source>ICO_CUT</source>
<translation>cut.png</translation> <translation>cut.png</translation>
</message> </message>
<message>
<source>ICO_GROUP_CUT</source>
<translation>cut.png</translation>
</message>
<message> <message>
<source>ICO_CYLINDER</source> <source>ICO_CYLINDER</source>
<translation>cylinder.png</translation> <translation>cylinder.png</translation>
@ -887,6 +903,10 @@
<source>ICO_FUSE</source> <source>ICO_FUSE</source>
<translation>fuse.png</translation> <translation>fuse.png</translation>
</message> </message>
<message>
<source>ICO_GROUP_UNION</source>
<translation>fuse.png</translation>
</message>
<message> <message>
<source>ICO_GLUE_FACES</source> <source>ICO_GLUE_FACES</source>
<translation>glue.png</translation> <translation>glue.png</translation>

View File

@ -7,6 +7,10 @@
<source>BRep_API: command not done</source> <source>BRep_API: command not done</source>
<translation>Error: can&apos;t build object</translation> <translation>Error: can&apos;t build object</translation>
</message> </message>
<message>
<source>PAL_NOT_DONE_ERROR</source>
<translation>Operation aborted</translation>
</message>
<message> <message>
<source>CHANGE_ORIENTATION_NEW_OBJ_NAME</source> <source>CHANGE_ORIENTATION_NEW_OBJ_NAME</source>
<translation>Invert</translation> <translation>Invert</translation>
@ -357,6 +361,18 @@ Please, select face, shell or solid and try again</translation>
<source>GEOM_CHECK_BLOCKS_COMPOUND_SUBSHAPES</source> <source>GEOM_CHECK_BLOCKS_COMPOUND_SUBSHAPES</source>
<translation>Incriminated Sub-shapes</translation> <translation>Incriminated Sub-shapes</translation>
</message> </message>
<message>
<source>GEOM_GETNONBLOCKS_TITLE</source>
<translation>Get non-hexahedral solids and non-quadrangular faces</translation>
</message>
<message>
<source>GEOM_GETNONBLOCKS</source>
<translation>Get non blocks</translation>
</message>
<message>
<source>GEOM_NONBLOCKS</source>
<translation>NonBlocksGroup</translation>
</message>
<message> <message>
<source>GEOM_CHECK_INFOS</source> <source>GEOM_CHECK_INFOS</source>
<translation>Object And Its Topological Information</translation> <translation>Object And Its Topological Information</translation>
@ -1830,6 +1846,10 @@ Please, select face, shell or solid and try again</translation>
<source>GEOM_COORDINATES_TYPE</source> <source>GEOM_COORDINATES_TYPE</source>
<translation>Coordinates Type</translation> <translation>Coordinates Type</translation>
</message> </message>
<message>
<source>GEOM_CONTROLS</source>
<translation>Dimensions</translation>
</message>
<message> <message>
<source>GEOM_SOLID</source> <source>GEOM_SOLID</source>
<translation>Solid</translation> <translation>Solid</translation>
@ -2310,6 +2330,10 @@ Please, select face, shell or solid and try again</translation>
<source>MEN_CHECK_COMPOUND</source> <source>MEN_CHECK_COMPOUND</source>
<translation>Check Compound of Blocks</translation> <translation>Check Compound of Blocks</translation>
</message> </message>
<message>
<source>MEN_GET_NON_BLOCKS</source>
<translation>Get Non Blocks</translation>
</message>
<message> <message>
<source>MEN_CHECK_SELF_INTERSECTIONS</source> <source>MEN_CHECK_SELF_INTERSECTIONS</source>
<translation>Detect Self-intersections</translation> <translation>Detect Self-intersections</translation>
@ -2422,6 +2446,10 @@ Please, select face, shell or solid and try again</translation>
<source>MEN_DISPLAY_ONLY</source> <source>MEN_DISPLAY_ONLY</source>
<translation>Show Only</translation> <translation>Show Only</translation>
</message> </message>
<message>
<source>MEN_SHOW_ONLY_CHILDREN</source>
<translation>Show Only Children</translation>
</message>
<message> <message>
<source>MEN_BRING_TO_FRONT</source> <source>MEN_BRING_TO_FRONT</source>
<translation>Bring To Front</translation> <translation>Bring To Front</translation>
@ -2550,6 +2578,18 @@ Please, select face, shell or solid and try again</translation>
<source>MEN_GROUP_EDIT</source> <source>MEN_GROUP_EDIT</source>
<translation>Edit</translation> <translation>Edit</translation>
</message> </message>
<message>
<source>MEN_GROUP_UNION</source>
<translation>Union Groups</translation>
</message>
<message>
<source>MEN_GROUP_INTERSECT</source>
<translation>Intersect Groups</translation>
</message>
<message>
<source>MEN_GROUP_CUT</source>
<translation>Cut Groups</translation>
</message>
<message> <message>
<source>MEN_RELOAD_IMPORTED</source> <source>MEN_RELOAD_IMPORTED</source>
<translation>Reload From Disk</translation> <translation>Reload From Disk</translation>
@ -2667,12 +2707,12 @@ Please, select face, shell or solid and try again</translation>
<translation>Create Group</translation> <translation>Create Group</translation>
</message> </message>
<message> <message>
<source>MEN_POP_SHOW_CHILDREN</source> <source>MEN_POP_DISCLOSE_CHILDREN</source>
<translation>Show Children</translation> <translation>Disclose child items</translation>
</message> </message>
<message> <message>
<source>MEN_POP_HIDE_CHILDREN</source> <source>MEN_POP_CONCEAL_CHILDREN</source>
<translation>Hide Children</translation> <translation>Conceal child items</translation>
</message> </message>
<message> <message>
<source>MEN_POP_UNPUBLISH_OBJ</source> <source>MEN_POP_UNPUBLISH_OBJ</source>
@ -3154,6 +3194,10 @@ Please, select face, shell or solid and try again</translation>
<source>STB_CHECK_COMPOUND</source> <source>STB_CHECK_COMPOUND</source>
<translation>Check compound of blocks</translation> <translation>Check compound of blocks</translation>
</message> </message>
<message>
<source>STB_GET_NON_BLOCKS</source>
<translation>Get non blocks</translation>
</message>
<message> <message>
<source>STB_CHECK_SELF_INTERSECTIONS</source> <source>STB_CHECK_SELF_INTERSECTIONS</source>
<translation>Detect Self-intersections</translation> <translation>Detect Self-intersections</translation>
@ -3234,6 +3278,10 @@ Please, select face, shell or solid and try again</translation>
<source>STB_DISPLAY_ONLY</source> <source>STB_DISPLAY_ONLY</source>
<translation>Show only</translation> <translation>Show only</translation>
</message> </message>
<message>
<source>STB_SHOW_ONLY_CHILDREN</source>
<translation>Show Only Children</translation>
</message>
<message> <message>
<source>STB_EDGE</source> <source>STB_EDGE</source>
<translation>Build an edge</translation> <translation>Build an edge</translation>
@ -3322,6 +3370,18 @@ Please, select face, shell or solid and try again</translation>
<source>STB_GROUP_EDIT</source> <source>STB_GROUP_EDIT</source>
<translation>Edit a group</translation> <translation>Edit a group</translation>
</message> </message>
<message>
<source>STB_GROUP_UNION</source>
<translation>Union Groups</translation>
</message>
<message>
<source>STB_GROUP_INTERSECT</source>
<translation>Intersect Groups</translation>
</message>
<message>
<source>STB_GROUP_CUT</source>
<translation>Cut Groups</translation>
</message>
<message> <message>
<source>STB_RELOAD_IMPORTED</source> <source>STB_RELOAD_IMPORTED</source>
<translation>Reload imported shape from its original place on disk</translation> <translation>Reload imported shape from its original place on disk</translation>
@ -3426,10 +3486,6 @@ Please, select face, shell or solid and try again</translation>
<source>STB_POP_CREATE_GROUP</source> <source>STB_POP_CREATE_GROUP</source>
<translation>Create Group</translation> <translation>Create Group</translation>
</message> </message>
<message>
<source>STB_POP_SHOW_CHILDREN</source>
<translation>Show child objects</translation>
</message>
<message> <message>
<source>STB_POP_UNPUBLISH_OBJ</source> <source>STB_POP_UNPUBLISH_OBJ</source>
<translation>Unpublish object</translation> <translation>Unpublish object</translation>
@ -3439,8 +3495,12 @@ Please, select face, shell or solid and try again</translation>
<translation>Publish object</translation> <translation>Publish object</translation>
</message> </message>
<message> <message>
<source>STB_POP_HIDE_CHILDREN</source> <source>STB_POP_DISCLOSE_CHILDREN</source>
<translation>Hide child objects</translation> <translation>Disclose child items</translation>
</message>
<message>
<source>STB_POP_CONCEAL_CHILDREN</source>
<translation>Conceal child items</translation>
</message> </message>
<message> <message>
<source>STB_POP_ISOS</source> <source>STB_POP_ISOS</source>
@ -3762,6 +3822,10 @@ Please, select face, shell or solid and try again</translation>
<source>TOP_CHECK_COMPOUND</source> <source>TOP_CHECK_COMPOUND</source>
<translation>Check compound of blocks</translation> <translation>Check compound of blocks</translation>
</message> </message>
<message>
<source>TOP_GET_NON_BLOCKS</source>
<translation>Get non blocks</translation>
</message>
<message> <message>
<source>TOP_CHECK_SELF_INTERSECTIONS</source> <source>TOP_CHECK_SELF_INTERSECTIONS</source>
<translation>Detect Self-intersections</translation> <translation>Detect Self-intersections</translation>
@ -3838,6 +3902,10 @@ Please, select face, shell or solid and try again</translation>
<source>TOP_DISPLAY_ONLY</source> <source>TOP_DISPLAY_ONLY</source>
<translation>Show only</translation> <translation>Show only</translation>
</message> </message>
<message>
<source>TOP_SHOW_ONLY_CHILDREN</source>
<translation>Show Only Children</translation>
</message>
<message> <message>
<source>TOP_EDGE</source> <source>TOP_EDGE</source>
<translation>Build edge</translation> <translation>Build edge</translation>
@ -3918,6 +3986,18 @@ Please, select face, shell or solid and try again</translation>
<source>TOP_GROUP_EDIT</source> <source>TOP_GROUP_EDIT</source>
<translation>Edit a group</translation> <translation>Edit a group</translation>
</message> </message>
<message>
<source>TOP_GROUP_UNION</source>
<translation>Union Groups</translation>
</message>
<message>
<source>TOP_GROUP_INTERSECT</source>
<translation>Intersect Groups</translation>
</message>
<message>
<source>TOP_GROUP_CUT</source>
<translation>Cut Groups</translation>
</message>
<message> <message>
<source>TOP_HEX_SOLID</source> <source>TOP_HEX_SOLID</source>
<translation>Hexahedral Solid</translation> <translation>Hexahedral Solid</translation>
@ -4026,10 +4106,6 @@ Please, select face, shell or solid and try again</translation>
<source>TOP_POP_CREATE_GROUP</source> <source>TOP_POP_CREATE_GROUP</source>
<translation>Create Group</translation> <translation>Create Group</translation>
</message> </message>
<message>
<source>TOP_POP_SHOW_CHILDREN</source>
<translation>Show Children</translation>
</message>
<message> <message>
<source>TOP_POP_UNPUBLISH_OBJ</source> <source>TOP_POP_UNPUBLISH_OBJ</source>
<translation>Unpublish object</translation> <translation>Unpublish object</translation>
@ -4039,8 +4115,12 @@ Please, select face, shell or solid and try again</translation>
<translation>Publish object</translation> <translation>Publish object</translation>
</message> </message>
<message> <message>
<source>TOP_POP_HIDE_CHILDREN</source> <source>TOP_POP_DISCLOSE_CHILDREN</source>
<translation>Hide Children</translation> <translation>Disclose child items</translation>
</message>
<message>
<source>TOP_POP_CONCEAL_CHILDREN</source>
<translation>Conceal child items</translation>
</message> </message>
<message> <message>
<source>TOP_POP_ISOS</source> <source>TOP_POP_ISOS</source>
@ -5037,6 +5117,45 @@ Number of sketch points too small</translation>
<translation>Please, select a group to edit</translation> <translation>Please, select a group to edit</translation>
</message> </message>
</context> </context>
<context>
<name>GroupGUI_BooleanDlg</name>
<message>
<source>GEOM_UNION</source>
<translation>Union</translation>
</message>
<message>
<source>GEOM_UNION_TITLE</source>
<translation>Union Groups</translation>
</message>
<message>
<source>GEOM_INTERSECT</source>
<translation>Intersect</translation>
</message>
<message>
<source>GEOM_INTERSECT_TITLE</source>
<translation>Intersect Groups</translation>
</message>
<message>
<source>GEOM_CUT</source>
<translation>Cut</translation>
</message>
<message>
<source>GEOM_CUT_TITLE</source>
<translation>Cut Groups</translation>
</message>
<message>
<source>GEOM_GROUPS</source>
<translation>Groups</translation>
</message>
<message>
<source>GEOM_MAIN_GROUPS</source>
<translation>Main Groups</translation>
</message>
<message>
<source>GEOM_TOOL_GROUPS</source>
<translation>Tool Groups</translation>
</message>
</context>
<context> <context>
<name>GroupGUI_GroupDlg</name> <name>GroupGUI_GroupDlg</name>
<message> <message>

View File

@ -376,8 +376,9 @@ void GeometryGUI::OnGUIEvent( int id )
NotViewerDependentCommands << GEOMOp::OpDelete NotViewerDependentCommands << GEOMOp::OpDelete
<< GEOMOp::OpShow << GEOMOp::OpShow
<< GEOMOp::OpShowOnly << GEOMOp::OpShowOnly
<< GEOMOp::OpShowChildren << GEOMOp::OpShowOnlyChildren
<< GEOMOp::OpHideChildren << GEOMOp::OpDiscloseChildren
<< GEOMOp::OpConcealChildren
<< GEOMOp::OpUnpublishObject << GEOMOp::OpUnpublishObject
<< GEOMOp::OpPublishObject << GEOMOp::OpPublishObject
<< GEOMOp::OpPointMarker; << GEOMOp::OpPointMarker;
@ -419,8 +420,8 @@ void GeometryGUI::OnGUIEvent( int id )
case GEOMOp::OpDecrNbIsos: // SHORTCUT - DECREASE NB ISOS case GEOMOp::OpDecrNbIsos: // SHORTCUT - DECREASE NB ISOS
case GEOMOp::OpAutoColor: // POPUP MENU - AUTO COLOR case GEOMOp::OpAutoColor: // POPUP MENU - AUTO COLOR
case GEOMOp::OpNoAutoColor: // POPUP MENU - DISABLE AUTO COLOR case GEOMOp::OpNoAutoColor: // POPUP MENU - DISABLE AUTO COLOR
case GEOMOp::OpShowChildren: // POPUP MENU - SHOW CHILDREN case GEOMOp::OpDiscloseChildren: // POPUP MENU - DISCLOSE CHILD ITEMS
case GEOMOp::OpHideChildren: // POPUP MENU - HIDE CHILDREN case GEOMOp::OpConcealChildren: // POPUP MENU - CONCEAL CHILD ITEMS
case GEOMOp::OpUnpublishObject: // POPUP MENU - UNPUBLISH case GEOMOp::OpUnpublishObject: // POPUP MENU - UNPUBLISH
case GEOMOp::OpPublishObject: // ROOT GEOM OBJECT - POPUP MENU - PUBLISH case GEOMOp::OpPublishObject: // ROOT GEOM OBJECT - POPUP MENU - PUBLISH
case GEOMOp::OpPointMarker: // POPUP MENU - POINT MARKER case GEOMOp::OpPointMarker: // POPUP MENU - POINT MARKER
@ -436,6 +437,7 @@ void GeometryGUI::OnGUIEvent( int id )
case GEOMOp::OpDMShadingWithEdges: // MENU VIEW - SHADING case GEOMOp::OpDMShadingWithEdges: // MENU VIEW - SHADING
case GEOMOp::OpShowAll: // MENU VIEW - SHOW ALL case GEOMOp::OpShowAll: // MENU VIEW - SHOW ALL
case GEOMOp::OpShowOnly: // MENU VIEW - DISPLAY ONLY case GEOMOp::OpShowOnly: // MENU VIEW - DISPLAY ONLY
case GEOMOp::OpShowOnlyChildren: // MENU VIEW - SHOW ONLY CHILDREN
case GEOMOp::OpHideAll: // MENU VIEW - ERASE ALL case GEOMOp::OpHideAll: // MENU VIEW - ERASE ALL
case GEOMOp::OpHide: // MENU VIEW - ERASE case GEOMOp::OpHide: // MENU VIEW - ERASE
case GEOMOp::OpShow: // MENU VIEW - DISPLAY case GEOMOp::OpShow: // MENU VIEW - DISPLAY
@ -549,6 +551,7 @@ void GeometryGUI::OnGUIEvent( int id )
case GEOMOp::OpWhatIs: // MENU MEASURE - WHATIS case GEOMOp::OpWhatIs: // MENU MEASURE - WHATIS
case GEOMOp::OpCheckShape: // MENU MEASURE - CHECK case GEOMOp::OpCheckShape: // MENU MEASURE - CHECK
case GEOMOp::OpCheckCompound: // MENU MEASURE - CHECK COMPOUND OF BLOCKS case GEOMOp::OpCheckCompound: // MENU MEASURE - CHECK COMPOUND OF BLOCKS
case GEOMOp::OpGetNonBlocks: // MENU MEASURE - Get NON BLOCKS
case GEOMOp::OpPointCoordinates: // MENU MEASURE - POINT COORDINATES case GEOMOp::OpPointCoordinates: // MENU MEASURE - POINT COORDINATES
case GEOMOp::OpCheckSelfInters: // MENU MEASURE - CHECK SELF INTERSECTIONS case GEOMOp::OpCheckSelfInters: // MENU MEASURE - CHECK SELF INTERSECTIONS
libName = "MeasureGUI"; libName = "MeasureGUI";
@ -556,6 +559,9 @@ void GeometryGUI::OnGUIEvent( int id )
case GEOMOp::OpGroupCreate: // MENU GROUP - CREATE case GEOMOp::OpGroupCreate: // MENU GROUP - CREATE
case GEOMOp::OpGroupCreatePopup: // POPUP MENU - CREATE GROUP case GEOMOp::OpGroupCreatePopup: // POPUP MENU - CREATE GROUP
case GEOMOp::OpGroupEdit: // MENU GROUP - EDIT case GEOMOp::OpGroupEdit: // MENU GROUP - EDIT
case GEOMOp::OpGroupUnion: // MENU GROUP - UNION
case GEOMOp::OpGroupIntersect: // MENU GROUP - INTERSECT
case GEOMOp::OpGroupCut: // MENU GROUP - CUT
libName = "GroupGUI"; libName = "GroupGUI";
break; break;
case GEOMOp::OpHexaSolid: // MENU BLOCKS - HEXAHEDRAL SOLID case GEOMOp::OpHexaSolid: // MENU BLOCKS - HEXAHEDRAL SOLID
@ -748,6 +754,9 @@ void GeometryGUI::initialize( CAM_Application* app )
createGeomAction( GEOMOp::OpGroupCreate, "GROUP_CREATE" ); createGeomAction( GEOMOp::OpGroupCreate, "GROUP_CREATE" );
createGeomAction( GEOMOp::OpGroupEdit, "GROUP_EDIT" ); createGeomAction( GEOMOp::OpGroupEdit, "GROUP_EDIT" );
createGeomAction( GEOMOp::OpGroupUnion, "GROUP_UNION" );
createGeomAction( GEOMOp::OpGroupIntersect, "GROUP_INTERSECT" );
createGeomAction( GEOMOp::OpGroupCut, "GROUP_CUT" );
createGeomAction( GEOMOp::OpReimport, "RELOAD_IMPORTED" ); createGeomAction( GEOMOp::OpReimport, "RELOAD_IMPORTED" );
@ -829,6 +838,7 @@ void GeometryGUI::initialize( CAM_Application* app )
createGeomAction( GEOMOp::OpWhatIs, "WHAT_IS" ); createGeomAction( GEOMOp::OpWhatIs, "WHAT_IS" );
createGeomAction( GEOMOp::OpCheckShape, "CHECK" ); createGeomAction( GEOMOp::OpCheckShape, "CHECK" );
createGeomAction( GEOMOp::OpCheckCompound, "CHECK_COMPOUND" ); createGeomAction( GEOMOp::OpCheckCompound, "CHECK_COMPOUND" );
createGeomAction( GEOMOp::OpGetNonBlocks, "GET_NON_BLOCKS" );
createGeomAction( GEOMOp::OpCheckSelfInters, "CHECK_SELF_INTERSECTIONS" ); createGeomAction( GEOMOp::OpCheckSelfInters, "CHECK_SELF_INTERSECTIONS" );
#ifdef _DEBUG_ // PAL16821 #ifdef _DEBUG_ // PAL16821
@ -851,6 +861,7 @@ void GeometryGUI::initialize( CAM_Application* app )
createGeomAction( GEOMOp::OpSelectCompound, "COMPOUND_SEL_ONLY", "", 0, true ); createGeomAction( GEOMOp::OpSelectCompound, "COMPOUND_SEL_ONLY", "", 0, true );
createGeomAction( GEOMOp::OpSelectAll, "ALL_SEL_ONLY", "", 0, true ); createGeomAction( GEOMOp::OpSelectAll, "ALL_SEL_ONLY", "", 0, true );
createGeomAction( GEOMOp::OpShowOnly, "DISPLAY_ONLY" ); createGeomAction( GEOMOp::OpShowOnly, "DISPLAY_ONLY" );
createGeomAction( GEOMOp::OpShowOnlyChildren, "SHOW_ONLY_CHILDREN" );
createGeomAction( GEOMOp::OpBringToFront, "BRING_TO_FRONT", "", 0, true ); createGeomAction( GEOMOp::OpBringToFront, "BRING_TO_FRONT", "", 0, true );
createGeomAction( GEOMOp::OpClsBringToFront, "CLS_BRING_TO_FRONT" ); createGeomAction( GEOMOp::OpClsBringToFront, "CLS_BRING_TO_FRONT" );
createGeomAction( GEOMOp::OpHide, "ERASE" ); createGeomAction( GEOMOp::OpHide, "ERASE" );
@ -870,8 +881,8 @@ void GeometryGUI::initialize( CAM_Application* app )
createGeomAction( GEOMOp::OpAutoColor, "POP_AUTO_COLOR" ); createGeomAction( GEOMOp::OpAutoColor, "POP_AUTO_COLOR" );
createGeomAction( GEOMOp::OpNoAutoColor, "POP_DISABLE_AUTO_COLOR" ); createGeomAction( GEOMOp::OpNoAutoColor, "POP_DISABLE_AUTO_COLOR" );
createGeomAction( GEOMOp::OpGroupCreatePopup, "POP_CREATE_GROUP" ); createGeomAction( GEOMOp::OpGroupCreatePopup, "POP_CREATE_GROUP" );
createGeomAction( GEOMOp::OpShowChildren, "POP_SHOW_CHILDREN" ); createGeomAction( GEOMOp::OpDiscloseChildren, "POP_DISCLOSE_CHILDREN" );
createGeomAction( GEOMOp::OpHideChildren, "POP_HIDE_CHILDREN" ); createGeomAction( GEOMOp::OpConcealChildren, "POP_CONCEAL_CHILDREN" );
createGeomAction( GEOMOp::OpUnpublishObject, "POP_UNPUBLISH_OBJ" ); createGeomAction( GEOMOp::OpUnpublishObject, "POP_UNPUBLISH_OBJ" );
createGeomAction( GEOMOp::OpPublishObject, "POP_PUBLISH_OBJ" ); createGeomAction( GEOMOp::OpPublishObject, "POP_PUBLISH_OBJ" );
createGeomAction( GEOMOp::OpPointMarker, "POP_POINT_MARKER" ); createGeomAction( GEOMOp::OpPointMarker, "POP_POINT_MARKER" );
@ -949,6 +960,9 @@ void GeometryGUI::initialize( CAM_Application* app )
int groupId = createMenu( tr( "MEN_GROUP" ), newEntId, -1 ); int groupId = createMenu( tr( "MEN_GROUP" ), newEntId, -1 );
createMenu( GEOMOp::OpGroupCreate, groupId, -1 ); createMenu( GEOMOp::OpGroupCreate, groupId, -1 );
createMenu( GEOMOp::OpGroupEdit, groupId, -1 ); createMenu( GEOMOp::OpGroupEdit, groupId, -1 );
createMenu( GEOMOp::OpGroupUnion, groupId, -1 );
createMenu( GEOMOp::OpGroupIntersect, groupId, -1 );
createMenu( GEOMOp::OpGroupCut, groupId, -1 );
createMenu( separator(), newEntId, -1 ); createMenu( separator(), newEntId, -1 );
@ -1059,6 +1073,7 @@ void GeometryGUI::initialize( CAM_Application* app )
createMenu( GEOMOp::OpWhatIs, measurId, -1 ); createMenu( GEOMOp::OpWhatIs, measurId, -1 );
createMenu( GEOMOp::OpCheckShape, measurId, -1 ); createMenu( GEOMOp::OpCheckShape, measurId, -1 );
createMenu( GEOMOp::OpCheckCompound, measurId, -1 ); createMenu( GEOMOp::OpCheckCompound, measurId, -1 );
createMenu( GEOMOp::OpGetNonBlocks, measurId, -1 );
createMenu( GEOMOp::OpCheckSelfInters, measurId, -1 ); createMenu( GEOMOp::OpCheckSelfInters, measurId, -1 );
#ifdef _DEBUG_ // PAL16821 #ifdef _DEBUG_ // PAL16821
@ -1196,6 +1211,7 @@ void GeometryGUI::initialize( CAM_Application* app )
createTool( GEOMOp::OpWhatIs, measureTbId ); createTool( GEOMOp::OpWhatIs, measureTbId );
createTool( GEOMOp::OpCheckShape, measureTbId ); createTool( GEOMOp::OpCheckShape, measureTbId );
createTool( GEOMOp::OpCheckCompound, measureTbId ); createTool( GEOMOp::OpCheckCompound, measureTbId );
createTool( GEOMOp::OpGetNonBlocks, measureTbId );
createTool( GEOMOp::OpCheckSelfInters, measureTbId ); createTool( GEOMOp::OpCheckSelfInters, measureTbId );
int picturesTbId = createTool( tr( "TOOL_PICTURES" ) ); int picturesTbId = createTool( tr( "TOOL_PICTURES" ) );
@ -1229,11 +1245,11 @@ void GeometryGUI::initialize( CAM_Application* app )
mgr->setRule( action( GEOMOp::OpDelete ), QString("$type in {'Shape' 'Group'} and selcount>0"), QtxPopupMgr::VisibleRule ); mgr->setRule( action( GEOMOp::OpDelete ), QString("$type in {'Shape' 'Group'} and selcount>0"), QtxPopupMgr::VisibleRule );
mgr->insert( action( GEOMOp::OpGroupCreatePopup ), -1, -1 ); // create group mgr->insert( action( GEOMOp::OpGroupCreatePopup ), -1, -1 ); // create group
mgr->setRule( action( GEOMOp::OpGroupCreatePopup ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule ); mgr->setRule( action( GEOMOp::OpGroupCreatePopup ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
mgr->insert( action( GEOMOp::OpShowChildren ), -1, -1 ); // show children mgr->insert( action( GEOMOp::OpDiscloseChildren ), -1, -1 ); // disclose child items
mgr->setRule( action( GEOMOp::OpShowChildren ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasHiddenChildren=true"), QtxPopupMgr::VisibleRule ); mgr->setRule( action( GEOMOp::OpDiscloseChildren ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasConcealedChildren=true"), QtxPopupMgr::VisibleRule );
mgr->insert( action( GEOMOp::OpHideChildren ), -1, -1 ); // hide children mgr->insert( action( GEOMOp::OpConcealChildren ), -1, -1 ); // conceal shild items
mgr->setRule( action( GEOMOp::OpHideChildren ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasShownChildren=true"), QtxPopupMgr::VisibleRule ); mgr->setRule( action( GEOMOp::OpConcealChildren ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasDisclosedChildren=true"), QtxPopupMgr::VisibleRule );
mgr->insert( action( GEOMOp::OpGroupEdit ), -1, -1 ); // edit group mgr->insert( action( GEOMOp::OpGroupEdit ), -1, -1 ); // edit group
mgr->setRule( action( GEOMOp::OpGroupEdit ), QString("client='ObjectBrowser' and type='Group' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule ); mgr->setRule( action( GEOMOp::OpGroupEdit ), QString("client='ObjectBrowser' and type='Group' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
mgr->insert( separator(), -1, -1 ); // ----------- mgr->insert( separator(), -1, -1 ); // -----------
@ -1340,6 +1356,8 @@ void GeometryGUI::initialize( CAM_Application* app )
mgr->setRule(action(GEOMOp::OpSelectAll), selectOnly + " and selectionmode='ALL'", QtxPopupMgr::ToggleRule); mgr->setRule(action(GEOMOp::OpSelectAll), selectOnly + " and selectionmode='ALL'", QtxPopupMgr::ToggleRule);
mgr->insert( action(GEOMOp::OpShowOnly ), -1, -1 ); // display only mgr->insert( action(GEOMOp::OpShowOnly ), -1, -1 ); // display only
mgr->setRule(action(GEOMOp::OpShowOnly ), rule.arg( types ).arg( "true" ), QtxPopupMgr::VisibleRule ); mgr->setRule(action(GEOMOp::OpShowOnly ), rule.arg( types ).arg( "true" ), QtxPopupMgr::VisibleRule );
mgr->insert( action(GEOMOp::OpShowOnlyChildren ), -1, -1 ); // display only children
mgr->setRule(action(GEOMOp::OpShowOnlyChildren ), (canDisplay + "and ($type in {%1}) and client='ObjectBrowser' and hasChildren=true").arg( types ), QtxPopupMgr::VisibleRule );
mgr->insert( separator(), -1, -1 ); // ----------- mgr->insert( separator(), -1, -1 ); // -----------
mgr->insert( action( GEOMOp::OpUnpublishObject ), -1, -1 ); // Unpublish object mgr->insert( action( GEOMOp::OpUnpublishObject ), -1, -1 ); // Unpublish object
@ -1663,41 +1681,19 @@ LightApp_Selection* GeometryGUI::createSelection() const
void GeometryGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title ) void GeometryGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
{ {
SalomeApp_Module::contextMenuPopup( client, menu, title ); SalomeApp_Module::contextMenuPopup( client, menu, title );
/*
SALOME_ListIO lst; SALOME_ListIO lst;
getApp()->selectionMgr()->selectedObjects( lst ); getApp()->selectionMgr()->selectedObjects( lst );
if (lst.Extent() < 1) if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
return; Handle(SALOME_InteractiveObject) io = lst.First();
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() ); SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
_PTR(Study) study = appStudy->studyDS(); _PTR(Study) study = appStudy->studyDS();
_PTR(SObject) obj = study->FindObjectID( io->getEntry() );
bool isImported = true; if ( obj ) {
SALOME_ListIteratorOfListIO anIt (lst); QString aName = QString( obj->GetName().c_str() );
for (; anIt.More() && isImported; anIt.Next()) { aName.remove( QRegExp("\\s+$") );
Handle(SALOME_InteractiveObject) io = anIt.Value(); title = aName;
_PTR(SObject) aSObj = study->FindObjectID(io->getEntry());
if (aSObj) {
if (lst.Extent() == 1) {
// Set context menu title
if (client == "OCCViewer" || client == "VTKViewer")
title = QString(aSObj->GetName().c_str());
}
CORBA::Object_var anObj = GeometryGUI::ClientSObjectToObject(aSObj);
GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow(anObj);
if (CORBA::is_nil(aGeomObj) || aGeomObj->GetType() != GEOM_IMPORT)
isImported = false;
} else {
isImported = false;
} }
} }
if (isImported) {
menu->addAction(action(GEOMOp::OpReimport)); // Reload imported shape
}
*/
} }
void GeometryGUI::createPreferences() void GeometryGUI::createPreferences()

View File

@ -24,7 +24,7 @@
namespace GEOMOp { namespace GEOMOp {
enum { enum {
// ToolsGUI ------------------//-------------------------------- // ToolsGUI --------------------//--------------------------------
OpImport = 1000, // MENU FILE - IMPORT OpImport = 1000, // MENU FILE - IMPORT
OpExport = 1001, // MENU FILE - EXPORT OpExport = 1001, // MENU FILE - EXPORT
OpDelete = 1020, // MENU EDIT - DELETE OpDelete = 1020, // MENU EDIT - DELETE
@ -50,14 +50,13 @@ namespace GEOMOp {
OpPointMarker = 1210, // POPUP MENU - POINT MARKER OpPointMarker = 1210, // POPUP MENU - POINT MARKER
OpSetTexture = 1211, // POPUP MENU - SETTEXTURE OpSetTexture = 1211, // POPUP MENU - SETTEXTURE
OpMaterialProperties = 1212, // POPUP MENU - MATERIAL PROPERTIES OpMaterialProperties = 1212, // POPUP MENU - MATERIAL PROPERTIES
OpShowChildren = 1250, // POPUP MENU - SHOW CHILDREN OpDiscloseChildren = 1250, // POPUP MENU - DISCLOSE CHILD ITEMS
OpHideChildren = 1251, // POPUP MENU - HIDE CHILDREN OpConcealChildren = 1251, // POPUP MENU - CONCEAL CHILD ITEMS
OpUnpublishObject = 1253, // POPUP MENU - UNPUBLISH OpUnpublishObject = 1253, // POPUP MENU - UNPUBLISH
OpPublishObject = 1254, // GEOM ROOT OBJECT - POPUP MENU - PUBLISH OpPublishObject = 1254, // GEOM ROOT OBJECT - POPUP MENU - PUBLISH
OpEdgeWidth = 1260, // POPUP MENU - LINE WIDTH - EDGE WIDTH OpEdgeWidth = 1260, // POPUP MENU - LINE WIDTH - EDGE WIDTH
OpIsosWidth = 1261, // POPUP MENU - LINE WIDTH - ISOS WIDTH OpIsosWidth = 1261, // POPUP MENU - LINE WIDTH - ISOS WIDTH
// DisplayGUI ------------------//--------------------------------
// DisplayGUI ----------------//--------------------------------
OpSwitchVectors = 2001, // MENU VIEW - DISPLAY MODE - SHOW/HIDE EDGE DIRECTION OpSwitchVectors = 2001, // MENU VIEW - DISPLAY MODE - SHOW/HIDE EDGE DIRECTION
OpShowAll = 2002, // MENU VIEW - SHOW ALL OpShowAll = 2002, // MENU VIEW - SHOW ALL
OpHideAll = 2003, // MENU VIEW - HIDE ALL OpHideAll = 2003, // MENU VIEW - HIDE ALL
@ -67,6 +66,7 @@ namespace GEOMOp {
OpShow = 2100, // POPUP MENU - SHOW OpShow = 2100, // POPUP MENU - SHOW
OpShowOnly = 2101, // POPUP MENU - SHOW ONLY OpShowOnly = 2101, // POPUP MENU - SHOW ONLY
OpHide = 2102, // POPUP MENU - HIDE OpHide = 2102, // POPUP MENU - HIDE
OpShowOnlyChildren = 2103, // POPUP MENU - SHOW ONLY CHILDREN
OpWireframe = 2200, // POPUP MENU - DISPLAY MODE - WIREFRAME OpWireframe = 2200, // POPUP MENU - DISPLAY MODE - WIREFRAME
OpShading = 2201, // POPUP MENU - DISPLAY MODE - SHADING OpShading = 2201, // POPUP MENU - DISPLAY MODE - SHADING
OpShadingWithEdges = 2202, // POPUP MENU - DISPLAY MODE - SHADING WITH EDGES OpShadingWithEdges = 2202, // POPUP MENU - DISPLAY MODE - SHADING WITH EDGES
@ -74,7 +74,7 @@ namespace GEOMOp {
OpTexture = 2204, // POPUP MENU - DISPLAY MODE - TEXTURE OpTexture = 2204, // POPUP MENU - DISPLAY MODE - TEXTURE
OpBringToFront = 2205, // POPUP MENU - BRING TO FRONT OpBringToFront = 2205, // POPUP MENU - BRING TO FRONT
OpClsBringToFront = 2206, OpClsBringToFront = 2206,
// BasicGUI ------------------//-------------------------------- // BasicGUI --------------------//--------------------------------
OpPoint = 3000, // MENU NEW ENTITY - BASIC - POINT OpPoint = 3000, // MENU NEW ENTITY - BASIC - POINT
OpLine = 3001, // MENU NEW ENTITY - BASIC - LINE OpLine = 3001, // MENU NEW ENTITY - BASIC - LINE
OpCircle = 3002, // MENU NEW ENTITY - BASIC - CIRCLE OpCircle = 3002, // MENU NEW ENTITY - BASIC - CIRCLE
@ -85,7 +85,7 @@ namespace GEOMOp {
OpCurve = 3007, // MENU NEW ENTITY - BASIC - CURVE OpCurve = 3007, // MENU NEW ENTITY - BASIC - CURVE
OpLCS = 3008, // MENU NEW ENTITY - BASIC - LOCAL COORDINATE SYSTEM OpLCS = 3008, // MENU NEW ENTITY - BASIC - LOCAL COORDINATE SYSTEM
OpOriginAndVectors = 3009, // MENU NEW ENTITY - BASIC - ORIGIN AND BASE VECTORS OpOriginAndVectors = 3009, // MENU NEW ENTITY - BASIC - ORIGIN AND BASE VECTORS
// PrimitiveGUI --------------//-------------------------------- // PrimitiveGUI ----------------//--------------------------------
OpBox = 3100, // MENU NEW ENTITY - PRIMITIVES - BOX OpBox = 3100, // MENU NEW ENTITY - PRIMITIVES - BOX
OpCylinder = 3101, // MENU NEW ENTITY - PRIMITIVES - CYLINDER OpCylinder = 3101, // MENU NEW ENTITY - PRIMITIVES - CYLINDER
OpSphere = 3102, // MENU NEW ENTITY - PRIMITIVES - SPHERE OpSphere = 3102, // MENU NEW ENTITY - PRIMITIVES - SPHERE
@ -93,12 +93,12 @@ namespace GEOMOp {
OpCone = 3104, // MENU NEW ENTITY - PRIMITIVES - CONE OpCone = 3104, // MENU NEW ENTITY - PRIMITIVES - CONE
OpRectangle = 3105, // MENU NEW ENTITY - PRIMITIVES - FACE OpRectangle = 3105, // MENU NEW ENTITY - PRIMITIVES - FACE
OpDisk = 3106, // MENU NEW ENTITY - PRIMITIVES - DISK OpDisk = 3106, // MENU NEW ENTITY - PRIMITIVES - DISK
// GenerationGUI -------------//-------------------------------- // GenerationGUI ---------------//--------------------------------
OpPrism = 3200, // MENU NEW ENTITY - GENERATION - EXTRUSION OpPrism = 3200, // MENU NEW ENTITY - GENERATION - EXTRUSION
OpRevolution = 3201, // MENU NEW ENTITY - GENERATION - REVOLUTION OpRevolution = 3201, // MENU NEW ENTITY - GENERATION - REVOLUTION
OpFilling = 3202, // MENU NEW ENTITY - GENERATION - FILLING OpFilling = 3202, // MENU NEW ENTITY - GENERATION - FILLING
OpPipe = 3203, // MENU NEW ENTITY - GENERATION - EXTRUSION ALONG PATH OpPipe = 3203, // MENU NEW ENTITY - GENERATION - EXTRUSION ALONG PATH
// EntityGUI -----------------//-------------------------------- // EntityGUI -------------------//--------------------------------
Op2dSketcher = 3300, // MENU NEW ENTITY - SKETCHER Op2dSketcher = 3300, // MENU NEW ENTITY - SKETCHER
Op3dSketcher = 3301, // MENU NEW ENTITY - 3D SKETCHER Op3dSketcher = 3301, // MENU NEW ENTITY - 3D SKETCHER
OpExplode = 3302, // MENU NEW ENTITY - EXPLODE OpExplode = 3302, // MENU NEW ENTITY - EXPLODE
@ -106,20 +106,19 @@ namespace GEOMOp {
OpFeatureDetect = 3303, // MENU NEW ENTITY - FEATURE DETECTION OpFeatureDetect = 3303, // MENU NEW ENTITY - FEATURE DETECTION
#endif #endif
OpPictureImport = 3304, // MENU NEW ENTITY - IMPORT PICTURE IN VIEWER OpPictureImport = 3304, // MENU NEW ENTITY - IMPORT PICTURE IN VIEWER
// BuildGUI --------------------//--------------------------------
// BuildGUI ------------------//--------------------------------
OpEdge = 3400, // MENU NEW ENTITY - BUILD - EDGE OpEdge = 3400, // MENU NEW ENTITY - BUILD - EDGE
OpWire = 3401, // MENU NEW ENTITY - BUILD - WIRE OpWire = 3401, // MENU NEW ENTITY - BUILD - WIRE
OpFace = 3402, // MENU NEW ENTITY - BUILD - FACE OpFace = 3402, // MENU NEW ENTITY - BUILD - FACE
OpShell = 3403, // MENU NEW ENTITY - BUILD - SHELL OpShell = 3403, // MENU NEW ENTITY - BUILD - SHELL
OpSolid = 3404, // MENU NEW ENTITY - BUILD - SOLID OpSolid = 3404, // MENU NEW ENTITY - BUILD - SOLID
OpCompound = 3405, // MENU NEW ENTITY - BUILD - COMPOUND OpCompound = 3405, // MENU NEW ENTITY - BUILD - COMPOUND
// BooleanGUI ----------------//-------------------------------- // BooleanGUI ------------------//--------------------------------
OpFuse = 3500, // MENU OPERATIONS - BOOLEAN - FUSE OpFuse = 3500, // MENU OPERATIONS - BOOLEAN - FUSE
OpCommon = 3501, // MENU OPERATIONS - BOOLEAN - COMMON OpCommon = 3501, // MENU OPERATIONS - BOOLEAN - COMMON
OpCut = 3502, // MENU OPERATIONS - BOOLEAN - CUT OpCut = 3502, // MENU OPERATIONS - BOOLEAN - CUT
OpSection = 3503, // MENU OPERATIONS - BOOLEAN - SECTION OpSection = 3503, // MENU OPERATIONS - BOOLEAN - SECTION
// TransformationGUI ---------//-------------------------------- // TransformationGUI -----------//--------------------------------
OpTranslate = 3600, // MENU OPERATIONS - TRANSFORMATION - TRANSLATION OpTranslate = 3600, // MENU OPERATIONS - TRANSFORMATION - TRANSLATION
OpRotate = 3601, // MENU OPERATIONS - TRANSFORMATION - ROTATION OpRotate = 3601, // MENU OPERATIONS - TRANSFORMATION - ROTATION
OpChangeLoc = 3602, // MENU OPERATIONS - TRANSFORMATION - LOCATION OpChangeLoc = 3602, // MENU OPERATIONS - TRANSFORMATION - LOCATION
@ -130,7 +129,7 @@ namespace GEOMOp {
OpMultiRotate = 3607, // MENU OPERATIONS - TRANSFORMATION - MULTI-ROTATION OpMultiRotate = 3607, // MENU OPERATIONS - TRANSFORMATION - MULTI-ROTATION
OpReimport = 3608, // POPUP MENU - RELOAD IMPORTED OpReimport = 3608, // POPUP MENU - RELOAD IMPORTED
OpProjection = 3609, // MENU OPERATIONS - TRANSFORMATION - PROJECTION OpProjection = 3609, // MENU OPERATIONS - TRANSFORMATION - PROJECTION
// OperationGUI // OperationGUI ----------------//--------------------------------
OpPartition = 3700, // MENU OPERATION - PARTITION OpPartition = 3700, // MENU OPERATION - PARTITION
OpArchimede = 3701, // MENU OPERATION - ARCHIMEDE OpArchimede = 3701, // MENU OPERATION - ARCHIMEDE
OpFillet3d = 3702, // MENU OPERATION - FILLET OpFillet3d = 3702, // MENU OPERATION - FILLET
@ -142,7 +141,7 @@ namespace GEOMOp {
OpSharedShapes = 3708, // MENU OPERATION - GET SHARED SHAPES OpSharedShapes = 3708, // MENU OPERATION - GET SHARED SHAPES
OpExtrudedBoss = 3709, // MENU OPERATION - ETRUDED BOSS OpExtrudedBoss = 3709, // MENU OPERATION - ETRUDED BOSS
OpExtrudedCut = 3710, // MENU OPERATION - ETRUDED CUT OpExtrudedCut = 3710, // MENU OPERATION - ETRUDED CUT
// RepairGUI -----------------//-------------------------------- // RepairGUI -------------------//--------------------------------
OpSewing = 4000, // MENU REPAIR - SEWING OpSewing = 4000, // MENU REPAIR - SEWING
OpSuppressFaces = 4001, // MENU REPAIR - SUPPRESS FACES OpSuppressFaces = 4001, // MENU REPAIR - SUPPRESS FACES
OpSuppressHoles = 4002, // MENU REPAIR - SUPPRESS HOLES OpSuppressHoles = 4002, // MENU REPAIR - SUPPRESS HOLES
@ -158,7 +157,7 @@ namespace GEOMOp {
OpLimitTolerance = 4012, // MENU REPAIR - LIMIT TOLERANCE OpLimitTolerance = 4012, // MENU REPAIR - LIMIT TOLERANCE
OpGlueEdges = 4013, // MENU REPAIR - GLUE EDGES OpGlueEdges = 4013, // MENU REPAIR - GLUE EDGES
OpFuseEdges = 4014, // MENU REPAIR - FUSE COLLINEAR EDGES OpFuseEdges = 4014, // MENU REPAIR - FUSE COLLINEAR EDGES
// MeasureGUI ----------------//-------------------------------- // MeasureGUI ------------------//--------------------------------
OpProperties = 5000, // MENU MEASURES - PROPERTIES OpProperties = 5000, // MENU MEASURES - PROPERTIES
OpCenterMass = 5001, // MENU MEASURES - CENTRE OF MASS OpCenterMass = 5001, // MENU MEASURES - CENTRE OF MASS
OpInertia = 5002, // MENU MEASURES - INERTIA OpInertia = 5002, // MENU MEASURES - INERTIA
@ -172,17 +171,21 @@ namespace GEOMOp {
OpCheckCompound = 5010, // MENU MEASURES - CHECK COMPOUND OF BLOCKS OpCheckCompound = 5010, // MENU MEASURES - CHECK COMPOUND OF BLOCKS
OpPointCoordinates = 5011, // MENU MEASURES - POINT COORDINATES OpPointCoordinates = 5011, // MENU MEASURES - POINT COORDINATES
OpCheckSelfInters = 5012, // MENU MEASURES - CHECK SELF INTERSECTIONS OpCheckSelfInters = 5012, // MENU MEASURES - CHECK SELF INTERSECTIONS
// GroupGUI ------------------//-------------------------------- OpGetNonBlocks = 5013, // MENU MEASURES - GET NON BLOCKS
// GroupGUI --------------------//--------------------------------
OpGroupCreate = 6000, // MENU GROUP - CREATE OpGroupCreate = 6000, // MENU GROUP - CREATE
OpGroupEdit = 6001, // MENU GROUP - EDIT OpGroupEdit = 6001, // MENU GROUP - EDIT
OpGroupCreatePopup = 6002, // POPUP MENU - CREATE GROUP OpGroupCreatePopup = 6002, // POPUP MENU - CREATE GROUP
// BlocksGUI -----------------//-------------------------------- OpGroupUnion = 6003, // POPUP MENU - UNION GROUPS
OpGroupIntersect = 6004, // POPUP MENU - INTERSECT GROUPS
OpGroupCut = 6005, // POPUP MENU - CUT GROUPS
// BlocksGUI -------------------//--------------------------------
OpHexaSolid = 6100, // MENU BLOCKS - HEXAHEDRAL SOLID OpHexaSolid = 6100, // MENU BLOCKS - HEXAHEDRAL SOLID
OpMultiTransform = 6101, // MENU BLOCKS - MULTI-TRANSFORMATION OpMultiTransform = 6101, // MENU BLOCKS - MULTI-TRANSFORMATION
OpQuadFace = 6102, // MENU BLOCKS - QUADRANGLE FACE OpQuadFace = 6102, // MENU BLOCKS - QUADRANGLE FACE
OpPropagate = 6103, // MENU BLOCKS - PROPAGATE OpPropagate = 6103, // MENU BLOCKS - PROPAGATE
OpExplodeBlock = 6104, // MENU BLOCKS - EXPLODE ON BLOCKS OpExplodeBlock = 6104, // MENU BLOCKS - EXPLODE ON BLOCKS
// AdvancedGUI ---------------//-------------------------------- // AdvancedGUI -----------------//--------------------------------
OpAdvancedNoOp = 10000, // NO OPERATION (advanced operations base) OpAdvancedNoOp = 10000, // NO OPERATION (advanced operations base)
OpPipeTShape = 10001, // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE OpPipeTShape = 10001, // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE
//OpPipeTShapeGroups = 10002, // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE GROUPS //OpPipeTShapeGroups = 10002, // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE GROUPS

View File

@ -1,72 +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
//
// GEOM GEOMGUI : GUI for Geometry component
// File : GeometryGUI_Swig.i
// Author : Nicolas REJNERI, Paul RASCLE
//
%{
#include "GeometryGUI_Swig.hxx"
%}
/*
managing C++ exception in the Python API
*/
%exception
{
class PyAllowThreadsGuard {
public:
// Py_BEGIN_ALLOW_THREADS
PyAllowThreadsGuard() { _save = PyEval_SaveThread(); }
// Py_END_ALLOW_THREADS
~PyAllowThreadsGuard() { PyEval_RestoreThread(_save); }
private:
PyThreadState *_save;
};
PyAllowThreadsGuard guard;
$action
}
class 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 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 setDeflection(const char* Entry, float deflect);
const char* getShapeTypeIcon(const char *Ior);
bool initGeomGen();
};

View File

@ -35,8 +35,6 @@ salomeinclude_HEADERS = \
GEOM_Displayer.h \ GEOM_Displayer.h \
GEOMGUI_OCCSelector.h \ GEOMGUI_OCCSelector.h \
GEOMGUI_Selection.h \ GEOMGUI_Selection.h \
GeometryGUI_Swig.hxx \
GeometryGUI_Swig.i \
GEOM_GEOMGUI.hxx GEOM_GEOMGUI.hxx
dist_libGEOM_la_SOURCES = \ dist_libGEOM_la_SOURCES = \
@ -44,8 +42,7 @@ dist_libGEOM_la_SOURCES = \
GEOMGUI.cxx \ GEOMGUI.cxx \
GEOM_Displayer.cxx \ GEOM_Displayer.cxx \
GEOMGUI_OCCSelector.cxx \ GEOMGUI_OCCSelector.cxx \
GEOMGUI_Selection.cxx \ GEOMGUI_Selection.cxx
GeometryGUI_Swig.cxx
MOC_FILES = \ MOC_FILES = \
GeometryGUI_moc.cxx GeometryGUI_moc.cxx

View File

@ -15,7 +15,6 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include <Standard_Stream.hxx> #include <Standard_Stream.hxx>
@ -26,9 +25,13 @@
#include <GEOMImpl_IMeasureOperations.hxx> #include <GEOMImpl_IMeasureOperations.hxx>
#include <Basics_Utils.hxx>
// OCCT Includes // OCCT Includes
#include <BRepBuilderAPI_MakePolygon.hxx> #include <BRepBuilderAPI_MakePolygon.hxx>
#include <BRepBuilderAPI_MakeVertex.hxx> #include <BRepBuilderAPI_MakeVertex.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <BRepBuilderAPI_MakeWire.hxx>
#include <TopoDS.hxx> #include <TopoDS.hxx>
#include <TopoDS_Shape.hxx> #include <TopoDS_Shape.hxx>
#include <TopoDS_Wire.hxx> #include <TopoDS_Wire.hxx>
@ -68,6 +71,7 @@ Standard_Integer GEOMImpl_3DSketcherDriver::Execute(TFunction_Logbook& log) cons
TopoDS_Shape aShape; TopoDS_Shape aShape;
if (aFunction->GetType() == SKETCHER3D_COORDS) {
Handle(TColStd_HArray1OfReal) aCoordsArray = aCI.GetCoordinates(); Handle(TColStd_HArray1OfReal) aCoordsArray = aCI.GetCoordinates();
int anArrayLength = aCoordsArray->Length(); int anArrayLength = aCoordsArray->Length();
@ -99,6 +103,198 @@ Standard_Integer GEOMImpl_3DSketcherDriver::Execute(TFunction_Logbook& log) cons
if (aMakePoly.IsDone()) if (aMakePoly.IsDone())
aShape = aMakePoly.Wire(); aShape = aMakePoly.Wire();
} }
}
else if (aFunction->GetType() == SKETCHER3D_COMMAND) {
Kernel_Utils::Localizer loc;
TCollection_AsciiString aCommand = aCI.GetCommand();
// "3DSketcher:CMD[:CMD[:CMD...]]"
// Split the command string to separate CMDs
int icmd = 2;
TColStd_SequenceOfAsciiString aSequence;
if (aCommand.Length()) {
TCollection_AsciiString aToken = aCommand.Token(":", icmd);
while (aToken.Length() > 0) {
aSequence.Append(aToken);
aToken = aCommand.Token(":", ++icmd);
}
}
int nbEdges = 0;
bool isFirstPointSet = false;
gp_XYZ p = gp::Origin().XYZ();
BRepBuilderAPI_MakeVertex MV0 (p);
TopoDS_Vertex V = TopoDS::Vertex(MV0.Shape());
gp_XYZ p0 = p;
TopoDS_Vertex V0 = V;
bool doClose = false;
BRepBuilderAPI_MakeWire MW;
int nbCMDs = aSequence.Length();
for (icmd = 1; icmd <= nbCMDs; icmd++) {
TCollection_AsciiString aCMD = aSequence.Value(icmd);
// Split the CMD into string values
TColStd_SequenceOfAsciiString aStrVals;
int ival = 1;
TCollection_AsciiString aToken = aCMD.Token(" ", ival);
while (aToken.Length() > 0) {
aStrVals.Append(aToken);
aToken = aCMD.Token(" ", ++ival);
}
// "TT x y z" : Create segment by point at X & Y or set the first point
// "T dx dy dz" : Create segment by point with DX & DY
//
// "OXY angleX angle2 length" : Create segment by two angles and length
// "OYZ angleY angle2 length" : Create segment by two angles and length
// "OXZ angleX angle2 length" : Create segment by two angles and length
//
// "WW" : Close Wire (to finish)
switch (aStrVals.Value(1).Value(1))
{
case 'T':
{
if (aStrVals.Length() != 4)
Standard_ConstructionError::Raise("3D Sketcher error: Bad format of command.");
gp_XYZ vp;
vp.SetX(aStrVals.Value(2).RealValue());
vp.SetY(aStrVals.Value(3).RealValue());
vp.SetZ(aStrVals.Value(4).RealValue());
if (aStrVals.Value(1) == "TT") { // absolute coordinates
if (!isFirstPointSet) {
p = vp;
BRepBuilderAPI_MakeVertex MV (p);
V = TopoDS::Vertex(MV.Shape());
p0 = p;
V0 = V;
isFirstPointSet = true;
}
else {
if ((vp - p).SquareModulus() > Precision::Confusion()) {
BRepBuilderAPI_MakeVertex MV (vp);
TopoDS_Vertex VV = TopoDS::Vertex(MV.Shape());
BRepBuilderAPI_MakeEdge ME (V, VV);
MW.Add(ME);
nbEdges++;
p = vp;
V = VV;
}
}
}
else if (aStrVals.Value(1) == "T") { // relative coordinates
if (vp.SquareModulus() > Precision::Confusion()) {
vp = p + vp;
BRepBuilderAPI_MakeVertex MV (vp);
TopoDS_Vertex VV = TopoDS::Vertex(MV.Shape());
BRepBuilderAPI_MakeEdge ME (V, VV);
MW.Add(ME);
nbEdges++;
p = vp;
V = VV;
}
}
else
Standard_ConstructionError::Raise("3D Sketcher error: Bad format of command.");
}
break;
case 'O':
{
if (aStrVals.Length() != 4)
Standard_ConstructionError::Raise("3D Sketcher error: Bad format of command.");
double anAngle = aStrVals.Value(2).RealValue() * M_PI/180.0;
double anAngle2 = aStrVals.Value(3).RealValue() * M_PI/180.0;
double aLength = aStrVals.Value(4).RealValue();
double aProjectedLength = aLength * cos(anAngle2);
gp_XYZ vp;
vp.SetX(aStrVals.Value(2).RealValue());
vp.SetY(aStrVals.Value(3).RealValue());
vp.SetZ(aStrVals.Value(4).RealValue());
if (aStrVals.Value(1) == "OXY") {
vp.SetX(p.X() + aProjectedLength * cos(anAngle));
vp.SetY(p.Y() + aProjectedLength * sin(anAngle));
vp.SetZ(p.Z() + aLength * sin(anAngle2));
}
else if (aStrVals.Value(1) == "OYZ") {
vp.SetX(p.X() + aLength * sin(anAngle2));
vp.SetY(p.Y() + aProjectedLength * cos(anAngle));
vp.SetZ(p.Z() + aProjectedLength * sin(anAngle));
}
else if (aStrVals.Value(1) == "OXZ") {
vp.SetX(p.X() + aProjectedLength * cos(anAngle));
vp.SetY(p.Y() + aLength * sin(anAngle2));
vp.SetZ(p.Z() + aProjectedLength * sin(anAngle));
}
else
Standard_ConstructionError::Raise("3D Sketcher error: Bad format of command.");
if ((vp - p).SquareModulus() > Precision::Confusion()) {
BRepBuilderAPI_MakeVertex MV (vp);
TopoDS_Vertex VV = TopoDS::Vertex(MV.Shape());
BRepBuilderAPI_MakeEdge ME (V, VV);
MW.Add(ME);
nbEdges++;
p = vp;
V = VV;
}
}
break;
case 'W':
{
if (aStrVals.Length() != 1)
Standard_ConstructionError::Raise("3D Sketcher error: Bad format of command.");
if (aStrVals.Value(1) == "WW")
doClose = true;
else
Standard_ConstructionError::Raise("3D Sketcher error: Bad format of command.");
}
break;
default:
{
Standard_ConstructionError::Raise("3D Sketcher error: Bad format of command.");
}
}
}
if (doClose &&
nbEdges > 1 && // as 3D sketcher has only straight edges
(p - p0).SquareModulus() > Precision::Confusion()) {
BRepBuilderAPI_MakeEdge ME (V, V0);
MW.Add(ME);
nbEdges++;
}
if (nbEdges > 0) {
if (!MW.IsDone())
Standard_ConstructionError::Raise("3D Sketcher error: Wire construction failed.");
aShape = MW;
}
else {
if (isFirstPointSet) {
aShape = V0;
}
}
}
else {
}
if (aShape.IsNull()) return 0; if (aShape.IsNull()) return 0;

View File

@ -600,7 +600,8 @@ Standard_Integer GEOMImpl_BlockDriver::Execute(TFunction_Logbook& log) const
TopTools_ListOfShape BLO; // All blocks from the given compound TopTools_ListOfShape BLO; // All blocks from the given compound
TopTools_ListOfShape NOT; // Not blocks TopTools_ListOfShape NOT; // Not blocks
TopTools_ListOfShape EXT; // Hexahedral solids, having degenerated and/or seam edges TopTools_ListOfShape EXT; // Hexahedral solids, having degenerated and/or seam edges
GEOMImpl_IBlocksOperations::AddBlocksFrom(aFixedExtra, BLO, NOT, EXT); TopTools_ListOfShape NOQ; // All non-quadrangular faces
GEOMImpl_IBlocksOperations::AddBlocksFrom(aFixedExtra, BLO, NOT, EXT, NOQ);
if (NOT.Extent() > 0) { if (NOT.Extent() > 0) {
MESSAGE("Some non-blocks have been removed"); MESSAGE("Some non-blocks have been removed");

View File

@ -1611,14 +1611,17 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFilling
//Make a Python command //Make a Python command
GEOM::TPythonDump pd (aFunction); GEOM::TPythonDump pd (aFunction);
pd << aFilling << " = geompy.MakeFilling(" pd << aFilling << " = geompy.MakeFilling(" << theShape ;
<< theShape << ", " << theMinDeg << ", " << theMaxDeg << ", " if ( theMinDeg != 2 ) pd << ", theMinDeg=" << theMinDeg ;
<< theTol2D << ", " << theTol3D << ", " << theNbIter << ", "; if ( theMaxDeg != 5 ) pd << ", theMaxDeg=" << theMaxDeg ;
if( theMethod==1 ) pd << "GEOM.FOM_UseOri"; if ( fabs(theTol2D-0.0001) > Precision::Confusion() )
else if( theMethod==2 ) pd << "GEOM.FOM_AutoCorrect"; pd << ", theTol2D=" << theTol2D ;
else pd << "GEOM.FOM_Default"; if ( fabs(theTol3D-0.0001) > Precision::Confusion() )
if(isApprox) pd << ", theTol3D=" << theTol3D ;
pd << ", " << isApprox ; if ( theNbIter != 0 ) pd << ", theNbIter=" << theNbIter ;
if ( theMethod==1 ) pd << ", theMethod=GEOM.FOM_UseOri";
else if( theMethod==2 ) pd << ", theMethod=GEOM.FOM_AutoCorrect";
if(isApprox) pd << ", isApprox=" << isApprox ;
pd << ")"; pd << ")";
SetErrorCode(OK); SetErrorCode(OK);

View File

@ -15,16 +15,13 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
//NOTE: This is an interface to a function for the Sketcher creation. //NOTE: This is an interface to a function for the Sketcher creation.
//
#include "GEOM_Function.hxx" #include "GEOM_Function.hxx"
#include <TColStd_HArray1OfReal.hxx> #include <TColStd_HArray1OfReal.hxx>
#define SKETCH_ARG_COORDS 1
class GEOMImpl_I3DSketcher class GEOMImpl_I3DSketcher
{ {
public: public:
@ -36,7 +33,17 @@ class GEOMImpl_I3DSketcher
Handle(TColStd_HArray1OfReal) GetCoordinates() { return _func->GetRealArray(SKETCH_ARG_COORDS); } Handle(TColStd_HArray1OfReal) GetCoordinates() { return _func->GetRealArray(SKETCH_ARG_COORDS); }
void SetCommand (const TCollection_AsciiString& theCommand)
{ _func->SetString(SKETCH_ARG_COMMAND, theCommand); }
TCollection_AsciiString GetCommand() { return _func->GetString(SKETCH_ARG_COMMAND); }
private: private:
enum {
SKETCH_ARG_COORDS = 1,
SKETCH_ARG_COMMAND = 2
};
Handle(GEOM_Function) _func; Handle(GEOM_Function) _func;
}; };

View File

@ -18,7 +18,6 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include <Standard_Stream.hxx> #include <Standard_Stream.hxx>
@ -212,6 +211,7 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::makePointOnGeom
case PointOn_CurveByCoord: fType = POINT_CURVE_COORD; break; case PointOn_CurveByCoord: fType = POINT_CURVE_COORD; break;
case PointOn_SurfaceByParam: fType = POINT_SURFACE_PAR; break; case PointOn_SurfaceByParam: fType = POINT_SURFACE_PAR; break;
case PointOn_SurfaceByCoord: fType = POINT_SURFACE_COORD; break; case PointOn_SurfaceByCoord: fType = POINT_SURFACE_COORD; break;
case PointOn_Face: fType = POINT_FACE_ANY; break;
default: break; default: break;
} }
Handle(GEOM_Function) aFunction = aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), fType); Handle(GEOM_Function) aFunction = aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), fType);
@ -254,6 +254,10 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::makePointOnGeom
aPI.SetX(theParam1); aPI.SetX(theParam1);
aPI.SetY(theParam2); aPI.SetY(theParam2);
aPI.SetZ(theParam3); aPI.SetZ(theParam3);
break;
case PointOn_Face:
aPI.SetSurface(aRefFunction);
break;
default: break; default: break;
} }
@ -298,6 +302,11 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::makePointOnGeom
GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnSurfaceByCoord(" GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnSurfaceByCoord("
<< theGeomObj << ", " << theParam1 << theGeomObj << ", " << theParam1
<< ", " << theParam2 << ", " << theParam3 << ")"; << ", " << theParam2 << ", " << theParam3 << ")";
break;
case PointOn_Face:
GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexInsideFace("
<< theGeomObj << ")";
break;
default: break; default: break;
} }
@ -370,6 +379,15 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnSurfaceByCoord
return makePointOnGeom(theSurface, theXParam, theYParam, theZParam, PointOn_SurfaceByCoord); return makePointOnGeom(theSurface, theXParam, theYParam, theZParam, PointOn_SurfaceByCoord);
} }
//=============================================================================
/*!
* MakePointOnFace
*/
//=============================================================================
Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnFace (Handle(GEOM_Object) theFace)
{
return makePointOnGeom(theFace, 0., 0., 0., PointOn_Face);
}
//============================================================================= //=============================================================================
/*! /*!

View File

@ -18,7 +18,6 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#ifndef _GEOMImpl_IBasicOperations_HXX_ #ifndef _GEOMImpl_IBasicOperations_HXX_
#define _GEOMImpl_IBasicOperations_HXX_ #define _GEOMImpl_IBasicOperations_HXX_
@ -64,6 +63,8 @@ class GEOMImpl_IBasicOperations : public GEOM_IOperations {
double theYParam, double theYParam,
double theZParam); double theZParam);
Standard_EXPORT Handle(GEOM_Object) MakePointOnFace (Handle(GEOM_Object) theFace);
// Vector // Vector
Standard_EXPORT Handle(GEOM_Object) MakeVectorDXDYDZ (double theDX, double theDY, double theDZ); Standard_EXPORT Handle(GEOM_Object) MakeVectorDXDYDZ (double theDX, double theDY, double theDZ);
@ -128,7 +129,8 @@ class GEOMImpl_IBasicOperations : public GEOM_IOperations {
PointOn_CurveByCoord, PointOn_CurveByCoord,
PointOn_CurveByLength, PointOn_CurveByLength,
PointOn_SurfaceByParam, PointOn_SurfaceByParam,
PointOn_SurfaceByCoord PointOn_SurfaceByCoord,
PointOn_Face
}; };
Handle(GEOM_Object) makePointOnGeom (Handle(GEOM_Object) theGeomObj, Handle(GEOM_Object) makePointOnGeom (Handle(GEOM_Object) theGeomObj,

View File

@ -18,7 +18,6 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#ifdef WNT #ifdef WNT
#pragma warning( disable:4786 ) #pragma warning( disable:4786 )
@ -1735,7 +1734,8 @@ Standard_Boolean GEOMImpl_IBlocksOperations::IsCompoundOfBlocks
void GEOMImpl_IBlocksOperations::AddBlocksFrom (const TopoDS_Shape& theShape, void GEOMImpl_IBlocksOperations::AddBlocksFrom (const TopoDS_Shape& theShape,
TopTools_ListOfShape& BLO, TopTools_ListOfShape& BLO,
TopTools_ListOfShape& NOT, TopTools_ListOfShape& NOT,
TopTools_ListOfShape& EXT) TopTools_ListOfShape& EXT,
TopTools_ListOfShape& NOQ)
{ {
TopAbs_ShapeEnum aType = theShape.ShapeType(); TopAbs_ShapeEnum aType = theShape.ShapeType();
switch (aType) { switch (aType) {
@ -1744,7 +1744,7 @@ void GEOMImpl_IBlocksOperations::AddBlocksFrom (const TopoDS_Shape& theShape,
{ {
TopoDS_Iterator It (theShape); TopoDS_Iterator It (theShape);
for (; It.More(); It.Next()) { for (; It.More(); It.Next()) {
AddBlocksFrom(It.Value(), BLO, NOT, EXT); AddBlocksFrom(It.Value(), BLO, NOT, EXT, NOQ);
} }
} }
break; break;
@ -1766,7 +1766,7 @@ void GEOMImpl_IBlocksOperations::AddBlocksFrom (const TopoDS_Shape& theShape,
for (; expF.More(); expF.Next()) { for (; expF.More(); expF.Next()) {
if (mapFaces.Add(expF.Current())) { if (mapFaces.Add(expF.Current())) {
nbFaces++; nbFaces++;
if (nbFaces > 6) break; //0021483//if (nbFaces > 6) break;
// get wire // get wire
TopoDS_Shape aF = expF.Current(); TopoDS_Shape aF = expF.Current();
@ -1774,14 +1774,18 @@ void GEOMImpl_IBlocksOperations::AddBlocksFrom (const TopoDS_Shape& theShape,
if (!wires.More()) { if (!wires.More()) {
// no wire in the face // no wire in the face
hasNonQuadr = Standard_True; hasNonQuadr = Standard_True;
break; NOQ.Append(aF);//0021483
//0021483//break;
continue;
} }
TopoDS_Shape aWire = wires.Current(); TopoDS_Shape aWire = wires.Current();
wires.Next(); wires.Next();
if (wires.More()) { if (wires.More()) {
// multiple wires in the face // multiple wires in the face
hasNonQuadr = Standard_True; hasNonQuadr = Standard_True;
break; NOQ.Append(aF);//0021483
//0021483//break;
continue;
} }
// Check number of edges in the face // Check number of edges in the face
@ -1796,6 +1800,7 @@ void GEOMImpl_IBlocksOperations::AddBlocksFrom (const TopoDS_Shape& theShape,
} }
if (nbEdges != 4) { if (nbEdges != 4) {
hasNonQuadr = Standard_True; hasNonQuadr = Standard_True;
NOQ.Append(aF);//0021483
} }
} }
} }
@ -1808,6 +1813,47 @@ void GEOMImpl_IBlocksOperations::AddBlocksFrom (const TopoDS_Shape& theShape,
} }
} }
break; break;
case TopAbs_SHELL: //0021483
case TopAbs_FACE: //0021483
{
// Count edges in each face
TopTools_MapOfShape mapFaces;
TopExp_Explorer expF (theShape, TopAbs_FACE);
for (; expF.More(); expF.Next()) {
if (mapFaces.Add(expF.Current())) {
// get wire
TopoDS_Shape aF = expF.Current();
TopExp_Explorer wires (aF, TopAbs_WIRE);
if (!wires.More()) {
// no wire in the face
NOQ.Append(aF);//0021483
continue;
}
TopoDS_Shape aWire = wires.Current();
wires.Next();
if (wires.More()) {
// multiple wires in the face
NOQ.Append(aF);//0021483
continue;
}
// Check number of edges in the face
Standard_Integer nbEdges = 0;
TopTools_MapOfShape mapEdges;
TopExp_Explorer expW (aWire, TopAbs_EDGE);
for (; expW.More(); expW.Next()) {
if (mapEdges.Add(expW.Current())) {
nbEdges++;
if (nbEdges > 4) break;
}
}
if (nbEdges != 4) {
NOQ.Append(aF);//0021483
}
}
}
}
break;
default: default:
NOT.Append(theShape); NOT.Append(theShape);
} }
@ -2353,7 +2399,8 @@ Standard_Boolean GEOMImpl_IBlocksOperations::CheckCompoundOfBlocks
TopTools_ListOfShape NOT; // Not blocks TopTools_ListOfShape NOT; // Not blocks
TopTools_ListOfShape EXT; // Hexahedral solids, having degenerated and/or seam edges TopTools_ListOfShape EXT; // Hexahedral solids, having degenerated and/or seam edges
TopTools_ListOfShape BLO; // All blocks from the given compound TopTools_ListOfShape BLO; // All blocks from the given compound
AddBlocksFrom(aBlockOrComp, BLO, NOT, EXT); TopTools_ListOfShape NOQ; // All non-quadrangular faces
AddBlocksFrom(aBlockOrComp, BLO, NOT, EXT, NOQ);
// Report non-blocks // Report non-blocks
if (NOT.Extent() > 0) { if (NOT.Extent() > 0) {
@ -2513,6 +2560,100 @@ Standard_Boolean GEOMImpl_IBlocksOperations::CheckCompoundOfBlocks
return isCompOfBlocks; return isCompOfBlocks;
} }
//=============================================================================
/*!
* GetNonBlocks
*/
//=============================================================================
Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetNonBlocks
(Handle(GEOM_Object) theShape,
Handle(GEOM_Object)& theNonQuads)
{
SetErrorCode(KO);
if (theShape.IsNull()) return NULL;
TopoDS_Shape aShape = theShape->GetValue();
// Separate blocks from non-blocks
TopTools_ListOfShape BLO; // All blocks from the given compound
TopTools_ListOfShape NOT; // Not blocks
TopTools_ListOfShape EXT; // Hexahedral solids, having degenerated and/or seam edges
TopTools_ListOfShape NOQ; // All non-quadrangular faces
AddBlocksFrom(aShape, BLO, NOT, EXT, NOQ);
if (NOT.IsEmpty() && EXT.IsEmpty() && NOQ.IsEmpty()) {
SetErrorCode("NOT_FOUND_ANY");
return NULL;
}
// Map sub-shapes and their indices
TopTools_IndexedMapOfShape anIndices;
TopExp::MapShapes(aShape, anIndices);
// Non-blocks
Handle(GEOM_Object) aNonBlocks;
if (NOT.Extent() > 0 || EXT.Extent() > 0) {
Handle(TColStd_HArray1OfInteger) anArray =
new TColStd_HArray1OfInteger (1, NOT.Extent() + EXT.Extent());
Standard_Integer ii = 1;
TopTools_ListIteratorOfListOfShape it1 (NOT);
for (; it1.More(); it1.Next(), ii++) {
anArray->SetValue(ii, anIndices.FindIndex(it1.Value()));
}
TopTools_ListIteratorOfListOfShape it2 (EXT);
for (; it2.More(); it2.Next(), ii++) {
anArray->SetValue(ii, anIndices.FindIndex(it2.Value()));
}
aNonBlocks = GetEngine()->AddSubShape(theShape, anArray);
if (aNonBlocks.IsNull()) {
SetErrorCode("Error in algorithm: result found, but cannot be returned.");
return NULL;
}
aNonBlocks->SetType(GEOM_GROUP);
TDF_Label aFreeLabel = aNonBlocks->GetFreeLabel();
TDataStd_Integer::Set(aFreeLabel, (Standard_Integer)TopAbs_SOLID);
}
// Non-quadrangles
if (NOQ.Extent() > 0) {
Handle(TColStd_HArray1OfInteger) anArray =
new TColStd_HArray1OfInteger (1, NOQ.Extent());
Standard_Integer ii = 1;
TopTools_ListIteratorOfListOfShape it1 (NOQ);
for (; it1.More(); it1.Next(), ii++) {
anArray->SetValue(ii, anIndices.FindIndex(it1.Value()));
}
theNonQuads = GetEngine()->AddSubShape(theShape, anArray);
if (theNonQuads.IsNull()) {
SetErrorCode("Error in algorithm: result found, but cannot be returned.");
return NULL;
}
theNonQuads->SetType(GEOM_GROUP);
TDF_Label aFreeLabel = theNonQuads->GetFreeLabel();
TDataStd_Integer::Set(aFreeLabel, (Standard_Integer)TopAbs_FACE);
}
//Make a Python command
Handle(GEOM_Function) aMainShape = theShape->GetLastFunction();
GEOM::TPythonDump pd (aMainShape, /*append=*/true);
pd << "(";
if (aNonBlocks.IsNull())
pd << "no_bad_solids";
else
pd << aNonBlocks;
pd << ", ";
if (theNonQuads.IsNull())
pd << "no_bad_faces";
else
pd << theNonQuads;
pd << ") = geompy.GetNonBlocks(" << theShape << ")";
SetErrorCode(OK);
return aNonBlocks;
}
//============================================================================= //=============================================================================
/*! /*!
* RemoveExtraEdges * RemoveExtraEdges

View File

@ -18,7 +18,6 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#ifndef _GEOMImpl_IBlocksOperations_HXX_ #ifndef _GEOMImpl_IBlocksOperations_HXX_
#define _GEOMImpl_IBlocksOperations_HXX_ #define _GEOMImpl_IBlocksOperations_HXX_
@ -134,6 +133,9 @@ class GEOMImpl_IBlocksOperations : public GEOM_IOperations {
Standard_EXPORT TCollection_AsciiString PrintBCErrors (Handle(GEOM_Object) theCompound, Standard_EXPORT TCollection_AsciiString PrintBCErrors (Handle(GEOM_Object) theCompound,
const std::list<BCError>& theErrors); const std::list<BCError>& theErrors);
Standard_EXPORT Handle(GEOM_Object) GetNonBlocks (Handle(GEOM_Object) theShape,
Handle(GEOM_Object)& theNonQuads);
Standard_EXPORT Handle(GEOM_Object) RemoveExtraEdges (Handle(GEOM_Object) theShape, Standard_EXPORT Handle(GEOM_Object) RemoveExtraEdges (Handle(GEOM_Object) theShape,
const Standard_Integer theOptimumNbFaces = 6); const Standard_Integer theOptimumNbFaces = 6);
@ -142,7 +144,8 @@ class GEOMImpl_IBlocksOperations : public GEOM_IOperations {
Standard_EXPORT static void AddBlocksFrom (const TopoDS_Shape& theShape, Standard_EXPORT static void AddBlocksFrom (const TopoDS_Shape& theShape,
TopTools_ListOfShape& BLO, TopTools_ListOfShape& BLO,
TopTools_ListOfShape& NOT, TopTools_ListOfShape& NOT,
TopTools_ListOfShape& EXT); TopTools_ListOfShape& EXT,
TopTools_ListOfShape& NOQ);
// Extract blocks from blocks compounds // Extract blocks from blocks compounds
Standard_EXPORT Handle(TColStd_HSequenceOfTransient) ExplodeCompoundOfBlocks Standard_EXPORT Handle(TColStd_HSequenceOfTransient) ExplodeCompoundOfBlocks

View File

@ -18,7 +18,6 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#ifdef WNT #ifdef WNT
// E.A. : On windows with python 2.6, there is a conflict // E.A. : On windows with python 2.6, there is a conflict
@ -1166,73 +1165,6 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcher (const char* theCom
return aSketcher; return aSketcher;
} }
//=============================================================================
/*!
* Make3DSketcher
*/
//=============================================================================
Handle(GEOM_Object) GEOMImpl_ICurvesOperations::Make3DSketcher (std::list<double> theCoordinates)
{
SetErrorCode(KO);
//Add a new Sketcher object
Handle(GEOM_Object) a3DSketcher = GetEngine()->AddObject(GetDocID(), GEOM_3DSKETCHER);
//Add a new Sketcher function
Handle(GEOM_Function) aFunction =
a3DSketcher->AddFunction(GEOMImpl_3DSketcherDriver::GetID(), GEOM_3DSKETCHER);
if (aFunction.IsNull()) return NULL;
//Check if the function is set correctly
if (aFunction->GetDriverGUID() != GEOMImpl_3DSketcherDriver::GetID()) return NULL;
GEOMImpl_I3DSketcher aCI (aFunction);
int nbOfCoords = 0;
std::list<double>::iterator it = theCoordinates.begin();
for (; it != theCoordinates.end(); it++)
nbOfCoords++;
Handle(TColStd_HArray1OfReal) aCoordsArray = new TColStd_HArray1OfReal (1, nbOfCoords);
it = theCoordinates.begin();
int ind = 1;
for (; it != theCoordinates.end(); it++, ind++)
aCoordsArray->SetValue(ind, *it);
aCI.SetCoordinates(aCoordsArray);
//Compute the Sketcher value
try {
#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("3D Sketcher 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 << a3DSketcher << " = geompy.Make3DSketcher([";
it = theCoordinates.begin();
pd << (*it++);
while (it != theCoordinates.end()) {
pd << ", " << (*it++);
}
pd << "])";
SetErrorCode(OK);
return a3DSketcher;
}
//============================================================================= //=============================================================================
/*! /*!
* MakeSketcherOnPlane * MakeSketcherOnPlane
@ -1289,3 +1221,121 @@ Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcherOnPlane
SetErrorCode(OK); SetErrorCode(OK);
return aSketcher; return aSketcher;
} }
//=============================================================================
/*!
* Make3DSketcherCommand
*/
//=============================================================================
Handle(GEOM_Object) GEOMImpl_ICurvesOperations::Make3DSketcherCommand (const char* theCommand)
{
SetErrorCode(KO);
if (!theCommand || strcmp(theCommand, "") == 0) return NULL;
//Add a new Sketcher object
Handle(GEOM_Object) aSketcher = GetEngine()->AddObject(GetDocID(), GEOM_3DSKETCHER);
//Add a new Sketcher function
Handle(GEOM_Function) aFunction =
aSketcher->AddFunction(GEOMImpl_3DSketcherDriver::GetID(), SKETCHER3D_COMMAND);
if (aFunction.IsNull()) return NULL;
//Check if the function is set correctly
if (aFunction->GetDriverGUID() != GEOMImpl_3DSketcherDriver::GetID()) return NULL;
GEOMImpl_I3DSketcher aCI (aFunction);
TCollection_AsciiString aCommand ((char*) theCommand);
aCI.SetCommand(aCommand);
//Compute the 3D Sketcher value
try {
#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("3D Sketcher 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 << aSketcher << " = geompy.Make3DSketcherCommand(\"" << aCommand.ToCString() << "\")";
SetErrorCode(OK);
return aSketcher;
}
//=============================================================================
/*!
* Make3DSketcher
*/
//=============================================================================
Handle(GEOM_Object) GEOMImpl_ICurvesOperations::Make3DSketcher (std::list<double> theCoordinates)
{
SetErrorCode(KO);
//Add a new Sketcher object
Handle(GEOM_Object) a3DSketcher = GetEngine()->AddObject(GetDocID(), GEOM_3DSKETCHER);
//Add a new Sketcher function
Handle(GEOM_Function) aFunction =
a3DSketcher->AddFunction(GEOMImpl_3DSketcherDriver::GetID(), SKETCHER3D_COORDS);
if (aFunction.IsNull()) return NULL;
//Check if the function is set correctly
if (aFunction->GetDriverGUID() != GEOMImpl_3DSketcherDriver::GetID()) return NULL;
GEOMImpl_I3DSketcher aCI (aFunction);
int nbOfCoords = 0;
std::list<double>::iterator it = theCoordinates.begin();
for (; it != theCoordinates.end(); it++)
nbOfCoords++;
Handle(TColStd_HArray1OfReal) aCoordsArray = new TColStd_HArray1OfReal (1, nbOfCoords);
it = theCoordinates.begin();
int ind = 1;
for (; it != theCoordinates.end(); it++, ind++)
aCoordsArray->SetValue(ind, *it);
aCI.SetCoordinates(aCoordsArray);
//Compute the Sketcher value
try {
#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("3D Sketcher 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 << a3DSketcher << " = geompy.Make3DSketcher([";
it = theCoordinates.begin();
pd << (*it++);
while (it != theCoordinates.end()) {
pd << ", " << (*it++);
}
pd << "])";
SetErrorCode(OK);
return a3DSketcher;
}

View File

@ -18,7 +18,6 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#ifndef _GEOMImpl_ICurvesOperations_HXX_ #ifndef _GEOMImpl_ICurvesOperations_HXX_
#define _GEOMImpl_ICurvesOperations_HXX_ #define _GEOMImpl_ICurvesOperations_HXX_
@ -78,16 +77,17 @@ class GEOMImpl_ICurvesOperations : public GEOM_IOperations {
bool theIsClosed = false, bool theIsClosed = false,
bool theDoReordering = false); bool theDoReordering = false);
Standard_EXPORT Handle(GEOM_Object) MakeCurveParametric(const char* thexExpr, const char* theyExpr, const char* thezExpr, Standard_EXPORT Handle(GEOM_Object) MakeCurveParametric
(const char* thexExpr, const char* theyExpr, const char* thezExpr,
double theParamMin, double theParamMax, double theParamStep, double theParamMin, double theParamMax, double theParamStep,
CurveType theCurveType, CurveType theCurveType, int theParamNbStep=0, bool theNewMethod=false);
int theParamNbStep=0, bool theNewMethod=false);
Standard_EXPORT Handle(GEOM_Object) MakeSketcher (const char* theCommand, Standard_EXPORT Handle(GEOM_Object) MakeSketcher (const char* theCommand,
std::list<double> theWorkingPlane); std::list<double> theWorkingPlane);
Standard_EXPORT Handle(GEOM_Object) Make3DSketcher (std::list<double> theCoordinates);
Standard_EXPORT Handle(GEOM_Object) MakeSketcherOnPlane (const char* theCommand, Standard_EXPORT Handle(GEOM_Object) MakeSketcherOnPlane (const char* theCommand,
Handle(GEOM_Object) theWorkingPlane); Handle(GEOM_Object) theWorkingPlane);
Standard_EXPORT Handle(GEOM_Object) Make3DSketcherCommand (const char* theCommand);
Standard_EXPORT Handle(GEOM_Object) Make3DSketcher (std::list<double> theCoordinates);
}; };
#endif #endif

View File

@ -18,7 +18,6 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include <Standard_Stream.hxx> #include <Standard_Stream.hxx>
@ -750,6 +749,743 @@ void GEOMImpl_IGroupOperations::DifferenceIDs (Handle(GEOM_Object) theGroup,
SetErrorCode(OK); SetErrorCode(OK);
} }
//=============================================================================
/*!
* UnionGroups
*/
//=============================================================================
Handle(GEOM_Object) GEOMImpl_IGroupOperations::UnionGroups (Handle(GEOM_Object) theGroup1,
Handle(GEOM_Object) theGroup2)
{
SetErrorCode(KO);
if (theGroup1.IsNull() || theGroup2.IsNull()) return NULL;
// Get group type
TopAbs_ShapeEnum aType1 = GetType(theGroup1);
TopAbs_ShapeEnum aType2 = GetType(theGroup2);
TopAbs_ShapeEnum aType = aType1;
if (aType1 != aType2) {
if (aType1 != TopAbs_SHAPE && aType1 != TopAbs_COMPOUND) {
if (aType2 == TopAbs_SHAPE || aType2 == TopAbs_COMPOUND)
aType = aType2;
else {
SetErrorCode("Error: UnionGroups cannot be performed on groups of different type");
return NULL;
}
}
}
// Get Main Shape
Handle(GEOM_Function) aFunction1 = theGroup1->GetLastFunction();
Handle(GEOM_Function) aFunction2 = theGroup2->GetLastFunction();
if (aFunction1.IsNull() || aFunction2.IsNull()) return NULL;
GEOM_ISubShape aSSI1 (aFunction1);
GEOM_ISubShape aSSI2 (aFunction2);
Handle(GEOM_Function) aMainShapeFunc1 = aSSI1.GetMainShape();
Handle(GEOM_Function) aMainShapeFunc2 = aSSI2.GetMainShape();
if (aMainShapeFunc1.IsNull() || aMainShapeFunc2.IsNull()) return NULL;
TDF_Label aLabel1 = aMainShapeFunc1->GetOwnerEntry();
TDF_Label aLabel2 = aMainShapeFunc2->GetOwnerEntry();
if (aLabel1.IsRoot() || aLabel2.IsRoot()) {
SetErrorCode("Error: UnionGroups can be performed only on groups");
return NULL;
}
if (aLabel1 != aLabel2) {
SetErrorCode("Error: UnionGroups cannot be performed on groups, built on different main shapes");
return NULL;
}
Handle(GEOM_Object) aMainObj = GEOM_Object::GetObject(aLabel1);
if (aMainObj.IsNull()) return NULL;
// New contents of the group
TColStd_ListOfInteger aNewIDs;
TColStd_MapOfInteger mapIDs;
Handle(TColStd_HArray1OfInteger) aSeq1 = aSSI1.GetIndices();
Handle(TColStd_HArray1OfInteger) aSeq2 = aSSI2.GetIndices();
if (aSeq1.IsNull() || aSeq2.IsNull()) return NULL;
Standard_Integer j, val_j;
Standard_Integer aLength1 = aSeq1->Length();
Standard_Integer aLength2 = aSeq2->Length();
for (j = 1; j <= aLength1; j++) {
val_j = aSeq1->Value(j);
if (val_j > 0 && mapIDs.Add(val_j)) {
aNewIDs.Append(val_j);
}
}
for (j = 1; j <= aLength2; j++) {
val_j = aSeq2->Value(j);
if (val_j > 0 && mapIDs.Add(val_j)) {
aNewIDs.Append(val_j);
}
}
if (aNewIDs.Extent() < 1) {
SetErrorCode("Error: UnionGroups cannot be performed on two empty groups");
return NULL;
}
// Put new indices from the list into an array
Standard_Integer k = 1;
TColStd_ListIteratorOfListOfInteger aNewIDsIter (aNewIDs);
Handle(TColStd_HArray1OfInteger) aNewArr = new TColStd_HArray1OfInteger (1, aNewIDs.Extent());
for (; aNewIDsIter.More(); aNewIDsIter.Next(), k++) {
aNewArr->SetValue(k, aNewIDsIter.Value());
}
// Create the Group
Handle(GEOM_Object) aGroup = GetEngine()->AddSubShape(aMainObj, aNewArr);
aGroup->SetType(GEOM_GROUP);
TDF_Label aFreeLabel = aGroup->GetFreeLabel();
TDataStd_Integer::Set(aFreeLabel, (Standard_Integer)aType);
// Make a Python command
Handle(GEOM_Function) aFunction = aGroup->GetFunction(1);
GEOM::TPythonDump(aFunction) << aGroup << " = geompy.UnionGroups("
<< theGroup1 << ", " << theGroup2 << ")";
SetErrorCode(OK);
return aGroup;
}
//=============================================================================
/*!
* IntersectGroups
*/
//=============================================================================
Handle(GEOM_Object) GEOMImpl_IGroupOperations::IntersectGroups (Handle(GEOM_Object) theGroup1,
Handle(GEOM_Object) theGroup2)
{
SetErrorCode(KO);
if (theGroup1.IsNull() || theGroup2.IsNull()) return NULL;
// Get group type
TopAbs_ShapeEnum aType1 = GetType(theGroup1);
TopAbs_ShapeEnum aType2 = GetType(theGroup2);
TopAbs_ShapeEnum aType = aType1;
if (aType1 != aType2) {
if (aType1 != TopAbs_SHAPE && aType1 != TopAbs_COMPOUND) {
if (aType2 == TopAbs_SHAPE || aType2 == TopAbs_COMPOUND)
aType = aType2;
else {
SetErrorCode("Error: IntersectGroups cannot be performed on groups of different type");
return NULL;
}
}
}
// Get Main Shape
Handle(GEOM_Function) aFunction1 = theGroup1->GetLastFunction();
Handle(GEOM_Function) aFunction2 = theGroup2->GetLastFunction();
if (aFunction1.IsNull() || aFunction2.IsNull()) return NULL;
GEOM_ISubShape aSSI1 (aFunction1);
GEOM_ISubShape aSSI2 (aFunction2);
Handle(GEOM_Function) aMainShapeFunc1 = aSSI1.GetMainShape();
Handle(GEOM_Function) aMainShapeFunc2 = aSSI2.GetMainShape();
if (aMainShapeFunc1.IsNull() || aMainShapeFunc2.IsNull()) return NULL;
TDF_Label aLabel1 = aMainShapeFunc1->GetOwnerEntry();
TDF_Label aLabel2 = aMainShapeFunc2->GetOwnerEntry();
if (aLabel1.IsRoot() || aLabel2.IsRoot()) {
SetErrorCode("Error: UnionGroups can be performed only on groups");
return NULL;
}
if (aLabel1 != aLabel2) {
SetErrorCode("Error: IntersectGroups cannot be performed on groups, built on different main shapes");
return NULL;
}
Handle(GEOM_Object) aMainObj = GEOM_Object::GetObject(aLabel1);
if (aMainObj.IsNull()) return NULL;
// New contents of the group
TColStd_ListOfInteger aNewIDs;
TColStd_MapOfInteger mapIDs;
Handle(TColStd_HArray1OfInteger) aSeq1 = aSSI1.GetIndices();
Handle(TColStd_HArray1OfInteger) aSeq2 = aSSI2.GetIndices();
if (aSeq1.IsNull() || aSeq2.IsNull()) return NULL;
Standard_Integer j, val_j;
Standard_Integer aLength1 = aSeq1->Length();
Standard_Integer aLength2 = aSeq2->Length();
for (j = 1; j <= aLength1; j++) {
mapIDs.Add(aSeq1->Value(j));
}
for (j = 1; j <= aLength2; j++) {
val_j = aSeq2->Value(j);
if (val_j > 0 && !mapIDs.Add(val_j)) {
// add index, if it is in mapIDs (filled from Group_1)
aNewIDs.Append(val_j);
}
}
Handle(TColStd_HArray1OfInteger) aNewArr;
if (aNewIDs.Extent() < 1) {
aNewArr = new TColStd_HArray1OfInteger (1, 1);
aNewArr->SetValue(1, -1);
}
else {
// Put new indices from the list into an array
Standard_Integer k = 1;
TColStd_ListIteratorOfListOfInteger aNewIDsIter (aNewIDs);
aNewArr = new TColStd_HArray1OfInteger (1, aNewIDs.Extent());
for (; aNewIDsIter.More(); aNewIDsIter.Next(), k++) {
aNewArr->SetValue(k, aNewIDsIter.Value());
}
}
// Create the Group
Handle(GEOM_Object) aGroup = GetEngine()->AddSubShape(aMainObj, aNewArr);
aGroup->SetType(GEOM_GROUP);
TDF_Label aFreeLabel = aGroup->GetFreeLabel();
TDataStd_Integer::Set(aFreeLabel, (Standard_Integer)aType);
// Make a Python command
Handle(GEOM_Function) aFunction = aGroup->GetFunction(1);
GEOM::TPythonDump(aFunction) << aGroup << " = geompy.IntersectGroups("
<< theGroup1 << ", " << theGroup2 << ")";
SetErrorCode(OK);
return aGroup;
}
//=============================================================================
/*!
* CutGroups
*/
//=============================================================================
Handle(GEOM_Object) GEOMImpl_IGroupOperations::CutGroups (Handle(GEOM_Object) theGroup1,
Handle(GEOM_Object) theGroup2)
{
SetErrorCode(KO);
if (theGroup1.IsNull() || theGroup2.IsNull()) return NULL;
// Get group type
TopAbs_ShapeEnum aType1 = GetType(theGroup1);
TopAbs_ShapeEnum aType2 = GetType(theGroup2);
TopAbs_ShapeEnum aType = aType1;
if (aType1 != aType2) {
if (aType1 != TopAbs_SHAPE && aType1 != TopAbs_COMPOUND) {
if (aType2 == TopAbs_SHAPE || aType2 == TopAbs_COMPOUND)
aType = aType2;
else {
SetErrorCode("Error: CutGroups cannot be performed on groups of different type");
return NULL;
}
}
}
// Get Main Shape
Handle(GEOM_Function) aFunction1 = theGroup1->GetLastFunction();
Handle(GEOM_Function) aFunction2 = theGroup2->GetLastFunction();
if (aFunction1.IsNull() || aFunction2.IsNull()) return NULL;
GEOM_ISubShape aSSI1 (aFunction1);
GEOM_ISubShape aSSI2 (aFunction2);
Handle(GEOM_Function) aMainShapeFunc1 = aSSI1.GetMainShape();
Handle(GEOM_Function) aMainShapeFunc2 = aSSI2.GetMainShape();
if (aMainShapeFunc1.IsNull() || aMainShapeFunc2.IsNull()) return NULL;
TDF_Label aLabel1 = aMainShapeFunc1->GetOwnerEntry();
TDF_Label aLabel2 = aMainShapeFunc2->GetOwnerEntry();
if (aLabel1.IsRoot() || aLabel2.IsRoot()) {
SetErrorCode("Error: UnionGroups can be performed only on groups");
return NULL;
}
if (aLabel1 != aLabel2) {
SetErrorCode("Error: CutGroups cannot be performed on groups, built on different main shapes");
return NULL;
}
Handle(GEOM_Object) aMainObj = GEOM_Object::GetObject(aLabel1);
if (aMainObj.IsNull()) return NULL;
// New contents of the group
TColStd_ListOfInteger aNewIDs;
TColStd_MapOfInteger mapIDs;
Handle(TColStd_HArray1OfInteger) aSeq1 = aSSI1.GetIndices();
Handle(TColStd_HArray1OfInteger) aSeq2 = aSSI2.GetIndices();
if (aSeq1.IsNull() || aSeq2.IsNull()) return NULL;
Standard_Integer j, val_j;
Standard_Integer aLength1 = aSeq1->Length();
Standard_Integer aLength2 = aSeq2->Length();
for (j = 1; j <= aLength2; j++) {
mapIDs.Add(aSeq2->Value(j));
}
for (j = 1; j <= aLength1; j++) {
val_j = aSeq1->Value(j);
if (val_j > 0 && mapIDs.Add(val_j)) {
// add index, if it is not in mapIDs (filled from Group_2)
aNewIDs.Append(val_j);
}
}
Handle(TColStd_HArray1OfInteger) aNewArr;
if (aNewIDs.Extent() < 1) {
aNewArr = new TColStd_HArray1OfInteger (1, 1);
aNewArr->SetValue(1, -1);
}
else {
// Put new indices from the list into an array
Standard_Integer k = 1;
TColStd_ListIteratorOfListOfInteger aNewIDsIter (aNewIDs);
aNewArr = new TColStd_HArray1OfInteger (1, aNewIDs.Extent());
for (; aNewIDsIter.More(); aNewIDsIter.Next(), k++) {
aNewArr->SetValue(k, aNewIDsIter.Value());
}
}
// Create the Group
Handle(GEOM_Object) aGroup = GetEngine()->AddSubShape(aMainObj, aNewArr);
aGroup->SetType(GEOM_GROUP);
TDF_Label aFreeLabel = aGroup->GetFreeLabel();
TDataStd_Integer::Set(aFreeLabel, (Standard_Integer)aType);
// Make a Python command
Handle(GEOM_Function) aFunction = aGroup->GetFunction(1);
GEOM::TPythonDump(aFunction) << aGroup << " = geompy.CutGroups("
<< theGroup1 << ", " << theGroup2 << ")";
SetErrorCode(OK);
return aGroup;
}
//=============================================================================
/*!
* UnionListOfGroups
*/
//=============================================================================
Handle(GEOM_Object) GEOMImpl_IGroupOperations::UnionListOfGroups
(const Handle(TColStd_HSequenceOfTransient)& theGList)
{
SetErrorCode(KO);
if (theGList.IsNull()) return NULL;
Standard_Integer i, aLen = theGList->Length();
if (aLen < 1) {
SetErrorCode("UnionListOfGroups error: the list of groups is empty");
return NULL;
}
TopAbs_ShapeEnum aType, aType_i;
TDF_Label aLabel, aLabel_i;
TColStd_ListOfInteger aNewIDs;
TColStd_MapOfInteger mapIDs;
// Iterate on the initial groups
for (i = 1; i <= aLen; i++) {
Handle(GEOM_Object) aGr_i = Handle(GEOM_Object)::DownCast(theGList->Value(i));
// Get group type
aType_i = GetType(aGr_i);
if (i == 1)
aType = aType_i;
else {
if (aType_i != aType) {
if (aType != TopAbs_SHAPE && aType != TopAbs_COMPOUND) {
if (aType_i == TopAbs_SHAPE || aType_i == TopAbs_COMPOUND)
aType = aType_i;
else {
SetErrorCode("Error: UnionListOfGroups cannot be performed on groups of different type");
return NULL;
}
}
}
}
// Get Main Shape
Handle(GEOM_Function) aFunction_i = aGr_i->GetLastFunction();
if (aFunction_i.IsNull()) return NULL;
GEOM_ISubShape aSSI (aFunction_i);
Handle(GEOM_Function) aMainShapeFunc = aSSI.GetMainShape();
if (aMainShapeFunc.IsNull()) return NULL;
aLabel_i = aMainShapeFunc->GetOwnerEntry();
if (aLabel_i.IsRoot()) {
SetErrorCode("Error: UnionGroups can be performed only on groups");
return NULL;
}
if (i == 1)
aLabel = aLabel_i;
else {
if (aLabel_i != aLabel) {
SetErrorCode("Error: UnionListOfGroups cannot be performed on groups, built on different main shapes");
return NULL;
}
}
// New contents of the group
Handle(TColStd_HArray1OfInteger) aSeq = aSSI.GetIndices();
if (aSeq.IsNull()) return NULL;
Standard_Integer j, val_j, aLength = aSeq->Length();
for (j = 1; j <= aLength; j++) {
val_j = aSeq->Value(j);
if (val_j > 0 && mapIDs.Add(val_j)) {
aNewIDs.Append(val_j);
}
}
}
// Check the resulting list of indices
if (aNewIDs.Extent() < 1) {
SetErrorCode("Error: UnionListOfGroups cannot be performed on all empty groups");
return NULL;
}
Handle(GEOM_Object) aMainObj = GEOM_Object::GetObject(aLabel);
if (aMainObj.IsNull()) return NULL;
// Put new indices from the list into an array
Standard_Integer k = 1;
TColStd_ListIteratorOfListOfInteger aNewIDsIter (aNewIDs);
Handle(TColStd_HArray1OfInteger) aNewArr = new TColStd_HArray1OfInteger (1, aNewIDs.Extent());
for (; aNewIDsIter.More(); aNewIDsIter.Next(), k++) {
aNewArr->SetValue(k, aNewIDsIter.Value());
}
// Create the Group
Handle(GEOM_Object) aGroup = GetEngine()->AddSubShape(aMainObj, aNewArr);
aGroup->SetType(GEOM_GROUP);
TDF_Label aFreeLabel = aGroup->GetFreeLabel();
TDataStd_Integer::Set(aFreeLabel, (Standard_Integer)aType);
//Make a Python command
Handle(GEOM_Function) aFunction = aGroup->GetFunction(1);
GEOM::TPythonDump pd (aFunction);
pd << aGroup << " = geompy.UnionListOfGroups([";
for (i = 1; i <= aLen; i++) {
Handle(GEOM_Object) aGr_i = Handle(GEOM_Object)::DownCast(theGList->Value(i));
pd << aGr_i << ((i < aLen) ? ", " : "])");
}
SetErrorCode(OK);
return aGroup;
}
//=============================================================================
/*!
* IntersectListOfGroups
*/
//=============================================================================
Handle(GEOM_Object) GEOMImpl_IGroupOperations::IntersectListOfGroups
(const Handle(TColStd_HSequenceOfTransient)& theGList)
{
SetErrorCode(KO);
if (theGList.IsNull()) return NULL;
Standard_Integer i, aLen = theGList->Length();
if (aLen < 1) {
SetErrorCode("IntersectListOfGroups error: the list of groups is empty");
return NULL;
}
TopAbs_ShapeEnum aType, aType_i;
TDF_Label aLabel, aLabel_i;
TColStd_ListOfInteger aNewIDs;
TColStd_MapOfInteger mapIDs;
// Iterate on the initial groups
for (i = 1; i <= aLen; i++) {
Handle(GEOM_Object) aGr_i = Handle(GEOM_Object)::DownCast(theGList->Value(i));
// Get group type
aType_i = GetType(aGr_i);
if (i == 1)
aType = aType_i;
else {
if (aType_i != aType) {
if (aType != TopAbs_SHAPE && aType != TopAbs_COMPOUND) {
if (aType_i == TopAbs_SHAPE || aType_i == TopAbs_COMPOUND)
aType = aType_i;
else {
SetErrorCode("Error: IntersectListOfGroups cannot be performed on groups of different type");
return NULL;
}
}
}
}
// Get Main Shape
Handle(GEOM_Function) aFunction_i = aGr_i->GetLastFunction();
if (aFunction_i.IsNull()) return NULL;
GEOM_ISubShape aSSI (aFunction_i);
Handle(GEOM_Function) aMainShapeFunc = aSSI.GetMainShape();
if (aMainShapeFunc.IsNull()) return NULL;
aLabel_i = aMainShapeFunc->GetOwnerEntry();
if (aLabel_i.IsRoot()) {
SetErrorCode("Error: UnionGroups can be performed only on groups");
return NULL;
}
if (i == 1)
aLabel = aLabel_i;
else {
if (aLabel_i != aLabel) {
SetErrorCode("Error: IntersectListOfGroups cannot be performed on groups, built on different main shapes");
return NULL;
}
}
// New contents of the group
Handle(TColStd_HArray1OfInteger) aSeq = aSSI.GetIndices();
if (aSeq.IsNull()) return NULL;
Standard_Integer j, val_j, aLength = aSeq->Length();
for (j = 1; j <= aLength; j++) {
val_j = aSeq->Value(j);
if (val_j > 0) {
if (i == 1) {
// get all elements of the first group
if (mapIDs.Add(val_j))
aNewIDs.Append(val_j);
}
else {
// get only elements, present in all previously processed groups
if (!mapIDs.Add(val_j))
aNewIDs.Append(val_j);
}
}
}
// refill the map with only validated elements
if (i > 1) {
mapIDs.Clear();
TColStd_ListIteratorOfListOfInteger aNewIDsIter (aNewIDs);
for (; aNewIDsIter.More(); aNewIDsIter.Next()) {
mapIDs.Add(aNewIDsIter.Value());
}
}
// clear the resulting list before starting the next sycle
if (i < aLen) {
aNewIDs.Clear();
}
}
Handle(GEOM_Object) aMainObj = GEOM_Object::GetObject(aLabel);
if (aMainObj.IsNull()) return NULL;
Handle(TColStd_HArray1OfInteger) aNewArr;
if (aNewIDs.Extent() < 1) {
aNewArr = new TColStd_HArray1OfInteger (1, 1);
aNewArr->SetValue(1, -1);
}
else {
// Put new indices from the list into an array
Standard_Integer k = 1;
TColStd_ListIteratorOfListOfInteger aNewIDsIter (aNewIDs);
aNewArr = new TColStd_HArray1OfInteger (1, aNewIDs.Extent());
for (; aNewIDsIter.More(); aNewIDsIter.Next(), k++) {
aNewArr->SetValue(k, aNewIDsIter.Value());
}
}
// Create the Group
Handle(GEOM_Object) aGroup = GetEngine()->AddSubShape(aMainObj, aNewArr);
aGroup->SetType(GEOM_GROUP);
TDF_Label aFreeLabel = aGroup->GetFreeLabel();
TDataStd_Integer::Set(aFreeLabel, (Standard_Integer)aType);
//Make a Python command
Handle(GEOM_Function) aFunction = aGroup->GetFunction(1);
GEOM::TPythonDump pd (aFunction);
pd << aGroup << " = geompy.IntersectListOfGroups([";
for (i = 1; i <= aLen; i++) {
Handle(GEOM_Object) aGr_i = Handle(GEOM_Object)::DownCast(theGList->Value(i));
pd << aGr_i << ((i < aLen) ? ", " : "])");
}
SetErrorCode(OK);
return aGroup;
}
//=============================================================================
/*!
* CutListOfGroups
*/
//=============================================================================
Handle(GEOM_Object) GEOMImpl_IGroupOperations::CutListOfGroups
(const Handle(TColStd_HSequenceOfTransient)& theGList1,
const Handle(TColStd_HSequenceOfTransient)& theGList2)
{
SetErrorCode(KO);
if (theGList1.IsNull() || theGList2.IsNull()) return NULL;
Standard_Integer i;
Standard_Integer aLen1 = theGList1->Length();
Standard_Integer aLen2 = theGList2->Length();
if (aLen1 < 1) {
SetErrorCode("CutListOfGroups error: the first list of groups is empty");
return NULL;
}
TopAbs_ShapeEnum aType, aType_i;
TDF_Label aLabel, aLabel_i;
TColStd_ListOfInteger aNewIDs;
TColStd_MapOfInteger mapIDs;
// 1. Collect indices to be excluded (from theGList2) into the mapIDs
for (i = 1; i <= aLen2; i++) {
Handle(GEOM_Object) aGr_i = Handle(GEOM_Object)::DownCast(theGList2->Value(i));
// Get group type
aType_i = GetType(aGr_i);
if (i == 1)
aType = aType_i;
else {
if (aType_i != aType) {
if (aType != TopAbs_SHAPE && aType != TopAbs_COMPOUND) {
if (aType_i == TopAbs_SHAPE || aType_i == TopAbs_COMPOUND)
aType = aType_i;
else {
SetErrorCode("Error: CutListOfGroups cannot be performed on groups of different type");
return NULL;
}
}
}
}
// Get Main Shape
Handle(GEOM_Function) aFunction_i = aGr_i->GetLastFunction();
if (aFunction_i.IsNull()) return NULL;
GEOM_ISubShape aSSI (aFunction_i);
Handle(GEOM_Function) aMainShapeFunc = aSSI.GetMainShape();
if (aMainShapeFunc.IsNull()) return NULL;
aLabel_i = aMainShapeFunc->GetOwnerEntry();
if (aLabel_i.IsRoot()) {
SetErrorCode("Error: UnionGroups can be performed only on groups");
return NULL;
}
if (i == 1)
aLabel = aLabel_i;
else {
if (aLabel_i != aLabel) {
SetErrorCode("Error: CutListOfGroups cannot be performed on groups, built on different main shapes");
return NULL;
}
}
// Indiced to exclude
Handle(TColStd_HArray1OfInteger) aSeq = aSSI.GetIndices();
if (aSeq.IsNull()) return NULL;
Standard_Integer j, aLength = aSeq->Length();
for (j = 1; j <= aLength; j++) {
mapIDs.Add(aSeq->Value(j));
}
}
// 2. Collect indices from theGList1, avoiding indices from theGList2 (mapIDs)
for (i = 1; i <= aLen1; i++) {
Handle(GEOM_Object) aGr_i = Handle(GEOM_Object)::DownCast(theGList1->Value(i));
// Get group type
aType_i = GetType(aGr_i);
if (i == 1 && aLen2 < 1)
aType = aType_i;
else {
if (aType_i != aType) {
if (aType != TopAbs_SHAPE && aType != TopAbs_COMPOUND) {
if (aType_i == TopAbs_SHAPE || aType_i == TopAbs_COMPOUND)
aType = aType_i;
else {
SetErrorCode("Error: CutListOfGroups cannot be performed on groups of different type");
return NULL;
}
}
}
}
// Get Main Shape
Handle(GEOM_Function) aFunction_i = aGr_i->GetLastFunction();
if (aFunction_i.IsNull()) return NULL;
GEOM_ISubShape aSSI (aFunction_i);
Handle(GEOM_Function) aMainShapeFunc = aSSI.GetMainShape();
if (aMainShapeFunc.IsNull()) return NULL;
aLabel_i = aMainShapeFunc->GetOwnerEntry();
if (aLabel_i.IsRoot()) {
SetErrorCode("Error: UnionGroups can be performed only on groups");
return NULL;
}
if (i == 1 && aLen2 < 1)
aLabel = aLabel_i;
else {
if (aLabel_i != aLabel) {
SetErrorCode("Error: CutListOfGroups cannot be performed on groups, built on different main shapes");
return NULL;
}
}
// New contents of the group
Handle(TColStd_HArray1OfInteger) aSeq = aSSI.GetIndices();
if (aSeq.IsNull()) return NULL;
Standard_Integer j, val_j, aLength = aSeq->Length();
for (j = 1; j <= aLength; j++) {
val_j = aSeq->Value(j);
if (val_j > 0 && mapIDs.Add(val_j)) {
// get only elements, not present in mapIDs (theGList2)
aNewIDs.Append(val_j);
}
}
}
Handle(GEOM_Object) aMainObj = GEOM_Object::GetObject(aLabel);
if (aMainObj.IsNull()) return NULL;
Handle(TColStd_HArray1OfInteger) aNewArr;
if (aNewIDs.Extent() < 1) {
aNewArr = new TColStd_HArray1OfInteger (1, 1);
aNewArr->SetValue(1, -1);
}
else {
// Put new indices from the list into an array
Standard_Integer k = 1;
TColStd_ListIteratorOfListOfInteger aNewIDsIter (aNewIDs);
aNewArr = new TColStd_HArray1OfInteger (1, aNewIDs.Extent());
for (; aNewIDsIter.More(); aNewIDsIter.Next(), k++) {
aNewArr->SetValue(k, aNewIDsIter.Value());
}
}
// Create the Group
Handle(GEOM_Object) aGroup = GetEngine()->AddSubShape(aMainObj, aNewArr);
aGroup->SetType(GEOM_GROUP);
TDF_Label aFreeLabel = aGroup->GetFreeLabel();
TDataStd_Integer::Set(aFreeLabel, (Standard_Integer)aType);
//Make a Python command
Handle(GEOM_Function) aFunction = aGroup->GetFunction(1);
GEOM::TPythonDump pd (aFunction);
pd << aGroup << " = geompy.CutListOfGroups([";
for (i = 1; i <= aLen1; i++) {
Handle(GEOM_Object) aGr_i = Handle(GEOM_Object)::DownCast(theGList1->Value(i));
pd << aGr_i << ((i < aLen1) ? ", " : "], [");
}
for (i = 1; i <= aLen2; i++) {
Handle(GEOM_Object) aGr_i = Handle(GEOM_Object)::DownCast(theGList2->Value(i));
pd << aGr_i << ((i < aLen2) ? ", " : "])");
}
SetErrorCode(OK);
return aGroup;
}
//============================================================================= //=============================================================================
/*! /*!
* GetType * GetType

View File

@ -18,7 +18,6 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#ifndef _GEOMImpl_IGroupOperations_HXX_ #ifndef _GEOMImpl_IGroupOperations_HXX_
#define _GEOMImpl_IGroupOperations_HXX_ #define _GEOMImpl_IGroupOperations_HXX_
@ -55,6 +54,20 @@ class GEOMImpl_IGroupOperations : public GEOM_IOperations {
Standard_EXPORT void DifferenceIDs (Handle(GEOM_Object) theGroup, Standard_EXPORT void DifferenceIDs (Handle(GEOM_Object) theGroup,
const Handle(TColStd_HSequenceOfInteger)& theSubShapes); const Handle(TColStd_HSequenceOfInteger)& theSubShapes);
Standard_EXPORT Handle(GEOM_Object) UnionGroups (Handle(GEOM_Object) theGroup1,
Handle(GEOM_Object) theGroup2);
Standard_EXPORT Handle(GEOM_Object) IntersectGroups (Handle(GEOM_Object) theGroup1,
Handle(GEOM_Object) theGroup2);
Standard_EXPORT Handle(GEOM_Object) CutGroups (Handle(GEOM_Object) theGroup1,
Handle(GEOM_Object) theGroup2);
Standard_EXPORT Handle(GEOM_Object) UnionListOfGroups
(const Handle(TColStd_HSequenceOfTransient)& theGList);
Standard_EXPORT Handle(GEOM_Object) IntersectListOfGroups
(const Handle(TColStd_HSequenceOfTransient)& theGList);
Standard_EXPORT Handle(GEOM_Object) CutListOfGroups (const Handle(TColStd_HSequenceOfTransient)& theGList1,
const Handle(TColStd_HSequenceOfTransient)& theGList2);
Standard_EXPORT TopAbs_ShapeEnum GetType(Handle(GEOM_Object) theGroup); Standard_EXPORT TopAbs_ShapeEnum GetType(Handle(GEOM_Object) theGroup);
Standard_EXPORT Handle(GEOM_Object) GetMainShape(Handle(GEOM_Object) theGroup); Standard_EXPORT Handle(GEOM_Object) GetMainShape(Handle(GEOM_Object) theGroup);

View File

@ -18,7 +18,6 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include <Standard_Stream.hxx> #include <Standard_Stream.hxx>
@ -47,7 +46,9 @@
#include <TopoDS.hxx> #include <TopoDS.hxx>
#include <TopoDS_Vertex.hxx> #include <TopoDS_Vertex.hxx>
#include <BRep_Builder.hxx>
#include <BRep_Tool.hxx> #include <BRep_Tool.hxx>
#include <BRepTools.hxx>
#include <gp_Pnt.hxx> #include <gp_Pnt.hxx>
#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
@ -61,10 +62,9 @@
//============================================================================= //=============================================================================
/*! /*!
* constructor: * constructor
*/ */
//============================================================================= //=============================================================================
GEOMImpl_IInsertOperations::GEOMImpl_IInsertOperations(GEOM_Engine* theEngine, int theDocID) GEOMImpl_IInsertOperations::GEOMImpl_IInsertOperations(GEOM_Engine* theEngine, int theDocID)
: GEOM_IOperations(theEngine, theDocID) : GEOM_IOperations(theEngine, theDocID)
{ {
@ -76,14 +76,11 @@ GEOMImpl_IInsertOperations::GEOMImpl_IInsertOperations(GEOM_Engine* theEngine, i
* destructor * destructor
*/ */
//============================================================================= //=============================================================================
GEOMImpl_IInsertOperations::~GEOMImpl_IInsertOperations() GEOMImpl_IInsertOperations::~GEOMImpl_IInsertOperations()
{ {
MESSAGE("GEOMImpl_IInsertOperations::~GEOMImpl_IInsertOperations"); MESSAGE("GEOMImpl_IInsertOperations::~GEOMImpl_IInsertOperations");
} }
//============================================================================= //=============================================================================
/*! /*!
* MakeCopy * MakeCopy
@ -231,7 +228,6 @@ Handle(GEOM_Object) GEOMImpl_IInsertOperations::Import
aCI.SetFileName(theFileName); aCI.SetFileName(theFileName);
aCI.SetFormatName(theFormatName); aCI.SetFormatName(theFormatName);
aCI.SetPluginName(aLibName); aCI.SetPluginName(aLibName);
//cout<<"IIO: theFormatName = "<<theFormatName.ToCString()<<endl;
//Perform the Import //Perform the Import
try { try {
@ -257,6 +253,7 @@ Handle(GEOM_Object) GEOMImpl_IInsertOperations::Import
SetErrorCode(OK); SetErrorCode(OK);
// OLD CODE: begin
if (theFormatName == "IGES_UNIT") { if (theFormatName == "IGES_UNIT") {
TopoDS_Shape S = aFunction->GetValue(); TopoDS_Shape S = aFunction->GetValue();
TopoDS_Vertex V = TopoDS::Vertex(S); TopoDS_Vertex V = TopoDS::Vertex(S);
@ -270,10 +267,42 @@ Handle(GEOM_Object) GEOMImpl_IInsertOperations::Import
//cout<<"IIO: aUnitName = "<<aUnitName.ToCString()<<endl; //cout<<"IIO: aUnitName = "<<aUnitName.ToCString()<<endl;
SetErrorCode(aUnitName); SetErrorCode(aUnitName);
} }
// OLD CODE: end
return result; return result;
} }
//=============================================================================
/*!
* ReadValue
*/
//=============================================================================
TCollection_AsciiString GEOMImpl_IInsertOperations::ReadValue
(const TCollection_AsciiString& theFileName,
const TCollection_AsciiString& theFormatName,
const TCollection_AsciiString& theParameterName)
{
SetErrorCode(KO);
TCollection_AsciiString aValue, anError;
if (theFileName.IsEmpty() || theFormatName.IsEmpty() || theParameterName.IsEmpty()) return aValue;
Handle(TCollection_HAsciiString) aHLibName;
if (!IsSupported(Standard_True, theFormatName.SubString(1,4), aHLibName)) {
return aValue;
}
TCollection_AsciiString aLibName = aHLibName->String();
aValue = GEOMImpl_ImportDriver::ReadValue(theFileName, aLibName, theParameterName, anError);
if (anError.IsEmpty())
SetErrorCode(OK);
else
SetErrorCode(anError.ToCString());
return aValue;
}
//============================================================================= //=============================================================================
/*! /*!
* ImportTranslators * ImportTranslators
@ -554,6 +583,48 @@ Standard_Boolean GEOMImpl_IInsertOperations::InitResMgr()
myResMgrUser->Find("Import") || myResMgrUser->Find("Export")); myResMgrUser->Find("Import") || myResMgrUser->Find("Export"));
} }
//=============================================================================
/*!
* RestoreShape
*/
//=============================================================================
Handle(GEOM_Object) GEOMImpl_IInsertOperations::RestoreShape (std::istringstream& theStream)
{
SetErrorCode(KO);
//Add a new result object
Handle(GEOM_Object) result = GetEngine()->AddObject(GetDocID(), GEOM_COPY);
//Add a Copy function
Handle(GEOM_Function) aFunction = result->AddFunction(GEOMImpl_CopyDriver::GetID(), COPY_WITHOUT_REF);
if (aFunction.IsNull()) return NULL;
//Check if the function is set correctly
if (aFunction->GetDriverGUID() != GEOMImpl_CopyDriver::GetID()) return NULL;
//Read a shape from the stream
TopoDS_Shape aShape;
BRep_Builder B;
BRepTools::Read(aShape, theStream, B);
if (aShape.IsNull()) {
SetErrorCode("RestoreShape error: BREP reading failed");
}
//Set function value
aFunction->SetValue(aShape);
//Special dump to avoid restored shapes publication.
//See correcponding code in GEOM_Engine.cxx (method ProcessFunction)
//GEOM::TPythonDump(aFunction) << "#";
GEOM::TPythonDump(aFunction) << result
<< " = geompy.RestoreShape(\"\") # the shape string has not been dump for performance reason";
SetErrorCode(OK);
return result;
}
int GEOMImpl_IInsertOperations::LoadTexture(const TCollection_AsciiString& theTextureFile) int GEOMImpl_IInsertOperations::LoadTexture(const TCollection_AsciiString& theTextureFile)
{ {
SetErrorCode(KO); SetErrorCode(KO);

View File

@ -18,7 +18,6 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#ifndef _GEOMImpl_IInsertOperations_HXX_ #ifndef _GEOMImpl_IInsertOperations_HXX_
#define _GEOMImpl_IInsertOperations_HXX_ #define _GEOMImpl_IInsertOperations_HXX_
@ -55,6 +54,10 @@ class GEOMImpl_IInsertOperations : public GEOM_IOperations {
Standard_EXPORT Handle(GEOM_Object) Import (const TCollection_AsciiString& theFileName, Standard_EXPORT Handle(GEOM_Object) Import (const TCollection_AsciiString& theFileName,
const TCollection_AsciiString& theFormatType); const TCollection_AsciiString& theFormatType);
Standard_EXPORT TCollection_AsciiString ReadValue (const TCollection_AsciiString& theFileName,
const TCollection_AsciiString& theFormatType,
const TCollection_AsciiString& theParameterName);
Standard_EXPORT void Export (const Handle(GEOM_Object) theOriginal, Standard_EXPORT void Export (const Handle(GEOM_Object) theOriginal,
const TCollection_AsciiString& theFileName, const TCollection_AsciiString& theFileName,
const TCollection_AsciiString& theFormatType); const TCollection_AsciiString& theFormatType);
@ -69,6 +72,8 @@ class GEOMImpl_IInsertOperations : public GEOM_IOperations {
const TCollection_AsciiString& theFormat, const TCollection_AsciiString& theFormat,
Handle(TCollection_HAsciiString)& theLibName); Handle(TCollection_HAsciiString)& theLibName);
Standard_EXPORT Handle(GEOM_Object) RestoreShape (std::istringstream& theStream);
Standard_EXPORT int LoadTexture(const TCollection_AsciiString& theTextureFile); Standard_EXPORT int LoadTexture(const TCollection_AsciiString& theTextureFile);
Standard_EXPORT int AddTexture(int theWidth, int theHeight, Standard_EXPORT int AddTexture(int theWidth, int theHeight,

View File

@ -18,7 +18,6 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include <Standard_Stream.hxx> #include <Standard_Stream.hxx>
@ -40,10 +39,8 @@
#include <NMTDS_Tools.hxx> #include <NMTDS_Tools.hxx>
#include <NMTDS_InterfPool.hxx> #include <NMTDS_InterfPool.hxx>
#include <NMTDS_PInterfPool.hxx> #include <NMTDS_PInterfPool.hxx>
//#include <NMTDS_PassKeyBoolean.hxx>
#include <NMTDS_PairBoolean.hxx> #include <NMTDS_PairBoolean.hxx>
#include <NMTDS_ShapesDataStructure.hxx> #include <NMTDS_ShapesDataStructure.hxx>
//#include <NMTDS_ListIteratorOfListOfPassKeyBoolean.hxx>
#include <NMTDS_ListIteratorOfListOfPairBoolean.hxx> #include <NMTDS_ListIteratorOfListOfPairBoolean.hxx>
#include <Basics_OCCTVersion.hxx> #include <Basics_OCCTVersion.hxx>
@ -58,22 +55,23 @@
#include <TFunction_Logbook.hxx> #include <TFunction_Logbook.hxx>
#include <TDF_Tool.hxx> #include <TDF_Tool.hxx>
#include <BRep_Builder.hxx>
#include <BRep_TFace.hxx>
#include <BRep_Tool.hxx> #include <BRep_Tool.hxx>
#include <BRepAdaptor_Surface.hxx> #include <BRepAdaptor_Surface.hxx>
#include <BRepBuilderAPI_Copy.hxx>
#include <BRepBndLib.hxx> #include <BRepBndLib.hxx>
#include <BRepCheck.hxx> #include <BRepCheck.hxx>
#include <BRepCheck_ListIteratorOfListOfStatus.hxx> #include <BRepCheck_ListIteratorOfListOfStatus.hxx>
#include <BRepCheck_Result.hxx> #include <BRepCheck_Result.hxx>
#include <BRepCheck_Shell.hxx> #include <BRepCheck_Shell.hxx>
#include <BRepClass3d_SolidClassifier.hxx>
#include <BRepExtrema_DistShapeShape.hxx> #include <BRepExtrema_DistShapeShape.hxx>
#include <BRepGProp.hxx> #include <BRepGProp.hxx>
#include <BRepTools.hxx> #include <BRepTools.hxx>
#include <Bnd_Box.hxx> #include <Bnd_Box.hxx>
#include <GProp_GProps.hxx>
#include <GProp_PrincipalProps.hxx>
#include <TopAbs.hxx> #include <TopAbs.hxx>
#include <TopExp.hxx> #include <TopExp.hxx>
#include <TopoDS.hxx> #include <TopoDS.hxx>
@ -81,49 +79,49 @@
#include <TopoDS_Face.hxx> #include <TopoDS_Face.hxx>
#include <TopoDS_Shape.hxx> #include <TopoDS_Shape.hxx>
#include <TopoDS_Vertex.hxx> #include <TopoDS_Vertex.hxx>
#include <TopoDS_Compound.hxx>
#include <TopoDS_Iterator.hxx> #include <TopoDS_Iterator.hxx>
#include <TopExp_Explorer.hxx> #include <TopExp_Explorer.hxx>
#include <TopTools_MapOfShape.hxx> #include <TopTools_MapOfShape.hxx>
#include <TopTools_ListOfShape.hxx> #include <TopTools_ListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx> #include <TopTools_ListIteratorOfListOfShape.hxx>
#include <ShapeAnalysis.hxx>
#include <ShapeAnalysis_Surface.hxx>
#include <ShapeFix_Shape.hxx>
#include <GeomAPI_IntSS.hxx>
#include <GeomAPI_ProjectPointOnCurve.hxx>
#include <GeomAbs_SurfaceType.hxx> #include <GeomAbs_SurfaceType.hxx>
#include <Geom_Surface.hxx>
#include <Geom_Plane.hxx>
#include <Geom_SphericalSurface.hxx>
#include <Geom_CylindricalSurface.hxx>
#include <Geom_ToroidalSurface.hxx>
#include <Geom_ConicalSurface.hxx>
#include <Geom_SurfaceOfLinearExtrusion.hxx>
#include <Geom_SurfaceOfRevolution.hxx>
#include <Geom_BezierSurface.hxx> #include <Geom_BezierSurface.hxx>
#include <Geom_BSplineSurface.hxx> #include <Geom_BSplineSurface.hxx>
#include <Geom_RectangularTrimmedSurface.hxx> #include <Geom_Circle.hxx>
#include <Geom_OffsetSurface.hxx> #include <Geom_ConicalSurface.hxx>
#include <Geom_CylindricalSurface.hxx>
#include <Geom_Line.hxx> #include <Geom_Line.hxx>
#include <Geom_OffsetSurface.hxx>
#include <Geom_Plane.hxx>
#include <Geom_RectangularTrimmedSurface.hxx>
#include <Geom_SphericalSurface.hxx>
#include <Geom_Surface.hxx>
#include <Geom_SurfaceOfLinearExtrusion.hxx>
#include <Geom_SurfaceOfRevolution.hxx>
#include <Geom_ToroidalSurface.hxx>
#include <GeomLProp_CLProps.hxx>
#include <GeomLProp_SLProps.hxx>
#include <GProp_GProps.hxx>
#include <GProp_PrincipalProps.hxx>
#include <gp_Pln.hxx> #include <gp_Pln.hxx>
#include <gp_Lin.hxx> #include <gp_Lin.hxx>
#include <GeomAPI_ProjectPointOnCurve.hxx>
#include <GeomLProp_CLProps.hxx>
#include <GeomLProp_SLProps.hxx>
#include <ShapeAnalysis.hxx>
#include <ShapeAnalysis_Surface.hxx>
#include <Standard_Failure.hxx> #include <Standard_Failure.hxx>
#include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
#include <BRepClass3d_SolidClassifier.hxx>
#include <BRep_Builder.hxx>
#include <GeomAPI_IntSS.hxx>
#include <Geom_Circle.hxx>
#include <Geom_SphericalSurface.hxx>
#include <Geom_ToroidalSurface.hxx>
#include <ShapeFix_Shape.hxx>
#include <TopoDS_Compound.hxx>
//============================================================================= //=============================================================================
/*! /*!
* Constructor * Constructor
@ -1206,6 +1204,17 @@ void GEOMImpl_IMeasureOperations::GetBoundingBox
#if OCC_VERSION_LARGE > 0x06010000 #if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS; OCC_CATCH_SIGNALS;
#endif #endif
BRepBuilderAPI_Copy aCopyTool (aShape);
if (!aCopyTool.IsDone()) {
SetErrorCode("GetBoundingBox Error: Bad shape detected");
return;
}
aShape = aCopyTool.Shape();
// remove triangulation to obtain more exact boundaries
BRepTools::Clean(aShape);
BRepBndLib::Add(aShape, B); BRepBndLib::Add(aShape, B);
B.Get(Xmin, Ymin, Zmin, Xmax, Ymax, Zmax); B.Get(Xmin, Ymin, Zmin, Xmax, Ymax, Zmax);
} }

View File

@ -18,7 +18,6 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include <Standard_Stream.hxx> #include <Standard_Stream.hxx>
@ -27,10 +26,12 @@
#include <GEOMImpl_Types.hxx> #include <GEOMImpl_Types.hxx>
#include <GEOM_Function.hxx> #include <GEOM_Function.hxx>
#include "utilities.h"
#include <TopoDS_Shape.hxx> #include <TopoDS_Shape.hxx>
#include <TCollection_HAsciiString.hxx>
#include "utilities.h"
#include <Standard_Failure.hxx> #include <Standard_Failure.hxx>
#include <StdFail_NotDone.hxx> #include <StdFail_NotDone.hxx>
@ -57,6 +58,10 @@ typedef TopoDS_Shape (*funcPoint)(const TCollection_AsciiString&,
TCollection_AsciiString&, TCollection_AsciiString&,
const TDF_Label&); const TDF_Label&);
typedef Handle(TCollection_HAsciiString) (*pGetValue)(const TCollection_AsciiString&,
const TCollection_AsciiString&,
TCollection_AsciiString&);
//======================================================================= //=======================================================================
//function : GetID //function : GetID
//purpose : //purpose :
@ -67,7 +72,6 @@ const Standard_GUID& GEOMImpl_ImportDriver::GetID()
return aImportDriver; return aImportDriver;
} }
//======================================================================= //=======================================================================
//function : GEOMImpl_ImportDriver //function : GEOMImpl_ImportDriver
//purpose : //purpose :
@ -97,6 +101,8 @@ Standard_Integer GEOMImpl_ImportDriver::Execute(TFunction_Logbook& log) const
// load plugin library // load plugin library
LibHandle anImportLib = LoadLib( aLibName.ToCString() ); //This is workaround of BUG OCC13051 LibHandle anImportLib = LoadLib( aLibName.ToCString() ); //This is workaround of BUG OCC13051
// Get Import method
funcPoint fp = 0; funcPoint fp = 0;
if ( anImportLib ) if ( anImportLib )
fp = (funcPoint)GetProc( anImportLib, "Import" ); fp = (funcPoint)GetProc( anImportLib, "Import" );
@ -129,6 +135,53 @@ Standard_Integer GEOMImpl_ImportDriver::Execute(TFunction_Logbook& log) const
return 1; return 1;
} }
//=======================================================================
//function : ReadValue
//purpose :
//=======================================================================
TCollection_AsciiString GEOMImpl_ImportDriver::ReadValue(const TCollection_AsciiString& theFileName,
const TCollection_AsciiString& theLibName,
const TCollection_AsciiString& theParameterName,
TCollection_AsciiString& theError)
{
TCollection_AsciiString aValue;
if (theFileName.IsEmpty() || theLibName.IsEmpty() || theParameterName.IsEmpty())
return aValue;
// load plugin library
LibHandle anImportLib = LoadLib(theLibName.ToCString()); //This is workaround of BUG OCC13051
if (!anImportLib) {
theError = theLibName + " library was not installed";
return aValue;
}
// Get GetValue method
pGetValue pGV = (pGetValue)GetProc(anImportLib, "GetValue");
if (!pGV) {
theError = theLibName + " library doesn't support GetValue method";
return aValue;
}
Handle(TCollection_HAsciiString) aHValue = pGV(theFileName, theParameterName, theError);
if (aHValue.IsNull()) {
if (theError.IsEmpty())
theError = theFileName + " doesn't contain requested parameter";
return aValue;
}
aValue = aHValue->String();
// unload plugin library
// commented by enk:
// the bug was occured: using ACIS Import/Export plugin
//UnLoadLib( anImportLib ); //This is workaround of BUG OCC13051
return aValue;
}
//======================================================================= //=======================================================================
//function : GEOMImpl_ImportDriver_Type_ //function : GEOMImpl_ImportDriver_Type_

View File

@ -18,11 +18,10 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// File : GEOMImpl_ImportDriver.ixx // File : GEOMImpl_ImportDriver.ixx
// Module : GEOMImpl // Module : GEOMImpl
//
#ifndef _GEOMImpl_ImportDriver_HeaderFile #ifndef _GEOMImpl_ImportDriver_HeaderFile
#define _GEOMImpl_ImportDriver_HeaderFile #define _GEOMImpl_ImportDriver_HeaderFile
@ -119,6 +118,8 @@ class Handle(GEOMImpl_ImportDriver) : public Handle(TFunction_Driver) {
#include <Standard_CString.hxx> #include <Standard_CString.hxx>
#endif #endif
#include <TCollection_AsciiString.hxx>
class TColStd_SequenceOfExtendedString; class TColStd_SequenceOfExtendedString;
@ -148,6 +149,11 @@ Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const { r
Standard_EXPORT static const Standard_GUID& GetID(); Standard_EXPORT static const Standard_GUID& GetID();
Standard_EXPORT ~GEOMImpl_ImportDriver() {}; Standard_EXPORT ~GEOMImpl_ImportDriver() {};
// Static method
Standard_EXPORT static TCollection_AsciiString ReadValue (const TCollection_AsciiString& theFileName,
const TCollection_AsciiString& theLibName,
const TCollection_AsciiString& theParameterName,
TCollection_AsciiString& theError);
// Type management // Type management
// //

View File

@ -2222,6 +2222,11 @@ static TopoDS_Shape CreatePipeBiNormalAlongVector(const TopoDS_Wire& aWirePath,
Standard_NullObject::Raise("MakePipe aborted : null base argument"); Standard_NullObject::Raise("MakePipe aborted : null base argument");
} }
// Make copy to prevent modifying of base object: 0021525
BRepBuilderAPI_Copy Copy (aShapeBase);
if (Copy.IsDone())
aShapeBase = Copy.Shape();
TopoDS_Shape aProf; TopoDS_Shape aProf;
if (aShapeBase.ShapeType() == TopAbs_VERTEX) { if (aShapeBase.ShapeType() == TopAbs_VERTEX) {
aProf = aShapeBase; aProf = aShapeBase;

View File

@ -18,7 +18,6 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include <Standard_Stream.hxx> #include <Standard_Stream.hxx>
@ -26,6 +25,7 @@
#include <GEOMImpl_IPoint.hxx> #include <GEOMImpl_IPoint.hxx>
#include <GEOMImpl_Types.hxx> #include <GEOMImpl_Types.hxx>
#include <GEOM_Function.hxx> #include <GEOM_Function.hxx>
#include <GEOMAlgo_Tools3D.hxx>
#include <ShapeAnalysis.hxx> #include <ShapeAnalysis.hxx>
@ -124,8 +124,8 @@ Standard_Integer GEOMImpl_PointDriver::Execute(TFunction_Logbook& log) const
aPnt = gp_Pnt(aPI.GetX(), aPI.GetY(), aPI.GetZ()); aPnt = gp_Pnt(aPI.GetX(), aPI.GetY(), aPI.GetZ());
} }
else if (aType == POINT_XYZ_REF) { else if (aType == POINT_XYZ_REF) {
Handle(GEOM_Function) aRefPoint = aPI.GetRef(); Handle(GEOM_Function) aRefFunc = aPI.GetRef();
TopoDS_Shape aRefShape = aRefPoint->GetValue(); TopoDS_Shape aRefShape = aRefFunc->GetValue();
if (aRefShape.ShapeType() != TopAbs_VERTEX) { if (aRefShape.ShapeType() != TopAbs_VERTEX) {
Standard_TypeMismatch::Raise Standard_TypeMismatch::Raise
("Point creation aborted : referenced shape is not a vertex"); ("Point creation aborted : referenced shape is not a vertex");
@ -134,8 +134,8 @@ Standard_Integer GEOMImpl_PointDriver::Execute(TFunction_Logbook& log) const
aPnt = gp_Pnt(P.X() + aPI.GetX(), P.Y() + aPI.GetY(), P.Z() + aPI.GetZ()); aPnt = gp_Pnt(P.X() + aPI.GetX(), P.Y() + aPI.GetY(), P.Z() + aPI.GetZ());
} }
else if (aType == POINT_CURVE_PAR) { else if (aType == POINT_CURVE_PAR) {
Handle(GEOM_Function) aRefCurve = aPI.GetCurve(); Handle(GEOM_Function) aRefFunc = aPI.GetCurve();
TopoDS_Shape aRefShape = aRefCurve->GetValue(); TopoDS_Shape aRefShape = aRefFunc->GetValue();
if (aRefShape.ShapeType() != TopAbs_EDGE) { if (aRefShape.ShapeType() != TopAbs_EDGE) {
Standard_TypeMismatch::Raise Standard_TypeMismatch::Raise
("Point On Curve creation aborted : curve shape is not an edge"); ("Point On Curve creation aborted : curve shape is not an edge");
@ -146,8 +146,8 @@ Standard_Integer GEOMImpl_PointDriver::Execute(TFunction_Logbook& log) const
aPnt = aCurve->Value(aP); aPnt = aCurve->Value(aP);
} }
else if (aType == POINT_CURVE_COORD) { else if (aType == POINT_CURVE_COORD) {
Handle(GEOM_Function) aRefCurve = aPI.GetCurve(); Handle(GEOM_Function) aRefFunc = aPI.GetCurve();
TopoDS_Shape aRefShape = aRefCurve->GetValue(); TopoDS_Shape aRefShape = aRefFunc->GetValue();
if (aRefShape.ShapeType() != TopAbs_EDGE) { if (aRefShape.ShapeType() != TopAbs_EDGE) {
Standard_TypeMismatch::Raise Standard_TypeMismatch::Raise
("Point On Curve creation aborted : curve shape is not an edge"); ("Point On Curve creation aborted : curve shape is not an edge");
@ -160,12 +160,12 @@ Standard_Integer GEOMImpl_PointDriver::Execute(TFunction_Logbook& log) const
} }
else if (aType == POINT_CURVE_LENGTH) { else if (aType == POINT_CURVE_LENGTH) {
// RefCurve // RefCurve
Handle(GEOM_Function) aRefCurve = aPI.GetCurve(); Handle(GEOM_Function) aRefFunc = aPI.GetCurve();
if (aRefCurve.IsNull()) { if (aRefFunc.IsNull()) {
Standard_NullObject::Raise Standard_NullObject::Raise
("Point On Curve creation aborted : curve object is null"); ("Point On Curve creation aborted : curve object is null");
} }
TopoDS_Shape aRefShape1 = aRefCurve->GetValue(); TopoDS_Shape aRefShape1 = aRefFunc->GetValue();
if (aRefShape1.ShapeType() != TopAbs_EDGE) { if (aRefShape1.ShapeType() != TopAbs_EDGE) {
Standard_TypeMismatch::Raise Standard_TypeMismatch::Raise
("Point On Curve creation aborted : curve shape is not an edge"); ("Point On Curve creation aborted : curve shape is not an edge");
@ -222,8 +222,8 @@ Standard_Integer GEOMImpl_PointDriver::Execute(TFunction_Logbook& log) const
aPnt = AdapCurve.Value(aParam); aPnt = AdapCurve.Value(aParam);
} }
else if (aType == POINT_SURFACE_PAR) { else if (aType == POINT_SURFACE_PAR) {
Handle(GEOM_Function) aRefCurve = aPI.GetSurface(); Handle(GEOM_Function) aRefFunc = aPI.GetSurface();
TopoDS_Shape aRefShape = aRefCurve->GetValue(); TopoDS_Shape aRefShape = aRefFunc->GetValue();
if (aRefShape.ShapeType() != TopAbs_FACE) { if (aRefShape.ShapeType() != TopAbs_FACE) {
Standard_TypeMismatch::Raise Standard_TypeMismatch::Raise
("Point On Surface creation aborted : surface shape is not a face"); ("Point On Surface creation aborted : surface shape is not a face");
@ -238,8 +238,8 @@ Standard_Integer GEOMImpl_PointDriver::Execute(TFunction_Logbook& log) const
aPnt = aSurf->Value(U,V); aPnt = aSurf->Value(U,V);
} }
else if (aType == POINT_SURFACE_COORD) { else if (aType == POINT_SURFACE_COORD) {
Handle(GEOM_Function) aRefCurve = aPI.GetSurface(); Handle(GEOM_Function) aRefFunc = aPI.GetSurface();
TopoDS_Shape aRefShape = aRefCurve->GetValue(); TopoDS_Shape aRefShape = aRefFunc->GetValue();
if (aRefShape.ShapeType() != TopAbs_FACE) { if (aRefShape.ShapeType() != TopAbs_FACE) {
Standard_TypeMismatch::Raise Standard_TypeMismatch::Raise
("Point On Surface creation aborted : surface shape is not a face"); ("Point On Surface creation aborted : surface shape is not a face");
@ -250,6 +250,17 @@ Standard_Integer GEOMImpl_PointDriver::Execute(TFunction_Logbook& log) const
("Point On Surface creation aborted : cannot project point"); ("Point On Surface creation aborted : cannot project point");
} }
} }
else if (aType == POINT_FACE_ANY) {
Handle(GEOM_Function) aRefFunc = aPI.GetSurface();
TopoDS_Shape aRefShape = aRefFunc->GetValue();
if (aRefShape.ShapeType() != TopAbs_FACE) {
Standard_TypeMismatch::Raise
("Point On Surface creation aborted : surface shape is not a face");
}
TopoDS_Face F = TopoDS::Face(aRefShape);
gp_Pnt2d aP2d;
GEOMAlgo_Tools3D::PntInFace(F, aPnt, aP2d);
}
else if (aType == POINT_LINES_INTERSECTION) { else if (aType == POINT_LINES_INTERSECTION) {
Handle(GEOM_Function) aRef1 = aPI.GetLine1(); Handle(GEOM_Function) aRef1 = aPI.GetLine1();
Handle(GEOM_Function) aRef2 = aPI.GetLine2(); Handle(GEOM_Function) aRef2 = aPI.GetLine2();

View File

@ -18,7 +18,6 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include <GEOMImpl_ShapeDriver.hxx> #include <GEOMImpl_ShapeDriver.hxx>
@ -362,6 +361,7 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const
aSewing.Perform(); aSewing.Perform();
TopoDS_Shape sh = aSewing.SewedShape(); TopoDS_Shape sh = aSewing.SewedShape();
if (sh.ShapeType()==TopAbs_FACE && nbshapes==1) { if (sh.ShapeType()==TopAbs_FACE && nbshapes==1) {
// case for creation of shell from one face - PAL12722 (skl 26.06.2006) // case for creation of shell from one face - PAL12722 (skl 26.06.2006)
TopoDS_Shell ss; TopoDS_Shell ss;
@ -378,9 +378,26 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const
ish++; ish++;
} }
if (ish != 1) if (ish != 1) {
// try the case of one face (Mantis issue 0021809)
TopExp_Explorer expF (sh, TopAbs_FACE);
Standard_Integer ifa = 0;
for (; expF.More(); expF.Next()) {
aShape = expF.Current();
ifa++;
}
if (ifa == 1) {
TopoDS_Shell ss;
B.MakeShell(ss);
B.Add(ss,aShape);
aShape = ss;
}
else {
aShape = aSewing.SewedShape(); aShape = aSewing.SewedShape();
} }
}
}
} }
else if (aType == SOLID_SHELL) { else if (aType == SOLID_SHELL) {

View File

@ -18,7 +18,6 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// GEOM_Object types // GEOM_Object types
@ -117,6 +116,7 @@
#define POINT_CURVE_COORD 6 #define POINT_CURVE_COORD 6
#define POINT_SURFACE_COORD 7 #define POINT_SURFACE_COORD 7
#define POINT_CURVE_LENGTH 8 #define POINT_CURVE_LENGTH 8
#define POINT_FACE_ANY 9
// Vector // Vector
#define VECTOR_TWO_PNT 1 #define VECTOR_TWO_PNT 1
@ -297,6 +297,9 @@
#define SKETCHER_NINE_DOUBLS 1 #define SKETCHER_NINE_DOUBLS 1
#define SKETCHER_PLANE 2 #define SKETCHER_PLANE 2
#define SKETCHER3D_COORDS 1
#define SKETCHER3D_COMMAND 2
// Measures // Measures
#define CDG_MEASURE 1 #define CDG_MEASURE 1
#define VECTOR_FACE_NORMALE 4 #define VECTOR_FACE_NORMALE 4

View File

@ -355,9 +355,9 @@ bool GEOMToolsGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent)
case GEOMOp::OpNoAutoColor: // POPUP - DISABLE AUTO COLOR case GEOMOp::OpNoAutoColor: // POPUP - DISABLE AUTO COLOR
OnDisableAutoColor(); OnDisableAutoColor();
break; break;
case GEOMOp::OpShowChildren: // POPUP - SHOW CHILDREN case GEOMOp::OpDiscloseChildren: // POPUP - SHOW CHILDREN
case GEOMOp::OpHideChildren: // POPUP - HIDE CHILDREN case GEOMOp::OpConcealChildren: // POPUP - HIDE CHILDREN
OnShowHideChildren( theCommandID == GEOMOp::OpShowChildren ); OnDiscloseConcealChildren( theCommandID == GEOMOp::OpDiscloseChildren );
break; break;
case GEOMOp::OpPointMarker: // POPUP - POINT MARKER case GEOMOp::OpPointMarker: // POPUP - POINT MARKER
OnPointMarker(); OnPointMarker();
@ -647,6 +647,42 @@ bool GEOMToolsGUI::Import()
CORBA::String_var fileN = fileName.toLatin1().constData(); CORBA::String_var fileN = fileName.toLatin1().constData();
CORBA::String_var fileT = aCurrentType.toLatin1().constData(); CORBA::String_var fileT = aCurrentType.toLatin1().constData();
// jfa 21.08.2012 for mantis issue 21511 (STEP file units)
CORBA::String_var aUnits = aInsOp->ReadValue(fileN, fileT, "LEN_UNITS");
TCollection_AsciiString aUnitsStr (aUnits.in());
bool needConvert = true;
if (aUnitsStr.IsEmpty() || aUnitsStr == "UNIT_M")
needConvert = false;
if (needConvert) {
if (igesAnswer == SUIT_MessageBox::NoToAll) {
// converting for all files is already approved
fileT = (aCurrentType + "_SCALE").toLatin1().constData();
}
else if (igesAnswer != SUIT_MessageBox::YesToAll) {
SUIT_MessageBox::StandardButtons btns = SUIT_MessageBox::Yes | SUIT_MessageBox::No;
if (i < fileNames.count() - 1) btns = btns | SUIT_MessageBox::YesToAll | SUIT_MessageBox::NoToAll;
igesAnswer = SUIT_MessageBox::question(app->desktop(),
"Question",//tr("WRN_WARNING"),
tr("GEOM_SCALE_DIMENSIONS"),
btns | SUIT_MessageBox::Cancel,
SUIT_MessageBox::No);
switch (igesAnswer) {
case SUIT_MessageBox::Cancel:
return false; // cancel (break) import operation
case SUIT_MessageBox::Yes:
case SUIT_MessageBox::YesToAll:
break; // scaling is confirmed
case SUIT_MessageBox::No:
case SUIT_MessageBox::NoAll:
fileT = (aCurrentType + "_SCALE").toLatin1().constData();
default:
break; // scaling is rejected
} // switch ( igesAnswer )
} // if ( igeAnswer != NoToAll )
} // if ( needConvert )
/*
// skl 29.05.2009 // skl 29.05.2009
if ( aCurrentType == "IGES" ) { if ( aCurrentType == "IGES" ) {
GEOM::GEOM_Object_var anObj = aInsOp->ImportFile( fileN, "IGES_UNIT" ); GEOM::GEOM_Object_var anObj = aInsOp->ImportFile( fileN, "IGES_UNIT" );
@ -684,6 +720,9 @@ bool GEOMToolsGUI::Import()
} // if ( needConvert ) } // if ( needConvert )
} // if ( aCurrentType == "IGES" ) } // if ( aCurrentType == "IGES" )
else if ( aCurrentType == "ACIS" ) { else if ( aCurrentType == "ACIS" ) {
*/
if ( aCurrentType == "ACIS" ) {
if ( acisAnswer != SUIT_MessageBox::YesToAll && acisAnswer != SUIT_MessageBox::NoToAll ) { if ( acisAnswer != SUIT_MessageBox::YesToAll && acisAnswer != SUIT_MessageBox::NoToAll ) {
SUIT_MessageBox::StandardButtons btns = SUIT_MessageBox::Yes | SUIT_MessageBox::No; SUIT_MessageBox::StandardButtons btns = SUIT_MessageBox::Yes | SUIT_MessageBox::No;
if ( i < fileNames.count()-1 ) btns = btns | SUIT_MessageBox::YesToAll | SUIT_MessageBox::NoToAll; if ( i < fileNames.count()-1 ) btns = btns | SUIT_MessageBox::YesToAll | SUIT_MessageBox::NoToAll;
@ -697,6 +736,7 @@ bool GEOMToolsGUI::Import()
} // if ( acisAnswer != YesToAll && acisAnswer != NoToAll ) } // if ( acisAnswer != YesToAll && acisAnswer != NoToAll )
} // else if ( aCurrentType == "ACIS" ) } // else if ( aCurrentType == "ACIS" )
// IMPORT
GEOM::GEOM_Object_var anObj = aInsOp->ImportFile( fileN, fileT ); GEOM::GEOM_Object_var anObj = aInsOp->ImportFile( fileN, fileT );
if ( !anObj->_is_nil() && aInsOp->IsDone() ) { if ( !anObj->_is_nil() && aInsOp->IsDone() ) {

View File

@ -30,12 +30,16 @@
#include "GEOM_ToolsGUI.hxx" #include "GEOM_ToolsGUI.hxx"
#include <GEOMGUI.h> #include <GEOMGUI.h>
#include <SALOMEDSClient.hxx> #include <SALOMEDSClient.hxx>
class GEOM_Displayer; class GEOM_Displayer;
class SALOME_View; class SALOME_View;
class SALOME_ListIO; class SALOME_ListIO;
class SalomeApp_Study;
class SVTK_View;
class QColor;
class Handle_SALOME_InteractiveObject;
class Handle_AIS_InteractiveContext;
#include <QList> #include <QList>
@ -54,6 +58,8 @@ public:
enum ActionType { SHOWDLG, INCR, DECR }; enum ActionType { SHOWDLG, INCR, DECR };
static void SetColor( const QString&, const QColor&, bool );
private: private:
// Import and export topology methods // Import and export topology methods
bool Import(); bool Import();
@ -71,7 +77,7 @@ private:
void OnNbIsos( ActionType actionType = SHOWDLG ); void OnNbIsos( ActionType actionType = SHOWDLG );
void OnDeflection(); void OnDeflection();
void OnSelectOnly(int mode); void OnSelectOnly(int mode);
void OnShowHideChildren( bool ); void OnDiscloseConcealChildren( bool );
void OnUnpublishObject(); void OnUnpublishObject();
void OnPublishObject() ; void OnPublishObject() ;
void OnPointMarker(); void OnPointMarker();
@ -89,6 +95,18 @@ private:
_PTR(Study), _PTR(Study),
QList<SALOME_View*>, QList<SALOME_View*>,
GEOM_Displayer* ); GEOM_Displayer* );
static void setVtkColor( SalomeApp_Study* study,
int mgrId,
SVTK_View* view,
const Handle_SALOME_InteractiveObject& IO,
const QColor& color );
static void setOccColor( SalomeApp_Study* study,
int mgrId,
const Handle_AIS_InteractiveContext& ic,
const Handle_SALOME_InteractiveObject& IO,
const QColor& color );
}; };
#endif // GEOMTOOLSGUI_H #endif // GEOMTOOLSGUI_H

View File

@ -109,6 +109,13 @@
// VTK includes // VTK includes
#include <vtkRenderer.h> #include <vtkRenderer.h>
// 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
// Below macro, when uncommented, switches on simplified (more performant) algorithm
// of auto-color picking up
//#define SIMPLE_AUTOCOLOR
void GEOMToolsGUI::OnCheckGeometry() void GEOMToolsGUI::OnCheckGeometry()
{ {
SalomeApp_Application* app = SalomeApp_Application* app =
@ -163,12 +170,18 @@ void GEOMToolsGUI::OnAutoColor()
if( CORBA::is_nil( aChildObject ) ) if( CORBA::is_nil( aChildObject ) )
continue; continue;
#ifndef GENERAL_AUTOCOLOR // auto-color for groups only
if( aChildObject->GetType() != GEOM_GROUP ) if( aChildObject->GetType() != GEOM_GROUP )
continue; continue;
#endif // GENERAL_AUTOCOLOR
#ifdef SIMPLE_AUTOCOLOR // simplified algorithm for auto-colors
SALOMEDS::Color aColor = GEOM_Displayer::getPredefinedUniqueColor();
#else // old algorithm for auto-colors
SALOMEDS::Color aColor = GEOM_Displayer::getUniqueColor( aReservedColors ); SALOMEDS::Color aColor = GEOM_Displayer::getUniqueColor( aReservedColors );
aChildObject->SetColor( aColor );
aReservedColors.append( aColor ); aReservedColors.append( aColor );
#endif // SIMPLE_AUTOCOLOR
aChildObject->SetColor( aColor );
QColor c( (int)( aColor.R * 255.0 ), (int)( aColor.G * 255.0 ), (int)( aColor.B * 255.0 ) ); QColor c( (int)( aColor.R * 255.0 ), (int)( aColor.G * 255.0 ), (int)( aColor.B * 255.0 ) );
@ -267,88 +280,198 @@ void GEOMToolsGUI::OnDisableAutoColor()
return; return;
aMainObject->SetAutoColor( false ); aMainObject->SetAutoColor( false );
}
void GEOMToolsGUI::SetColor( const QString& entry, const QColor& color, bool updateViewer )
{
if ( entry.isEmpty() || !color.isValid() ) return;
// get active application
SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
if ( !app ) return;
// get current study
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
if ( !appStudy ) return;
// get active view
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() );
// get view id
int mgrId = window->getViewManager()->getGlobalId();
Handle(SALOME_InteractiveObject) IO =
new SALOME_InteractiveObject( entry.toLatin1().data(), "GEOM", "");
if ( isVTK ) {
SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
if ( !vtkVW ) return;
SVTK_View* aView = vtkVW->getView();
GEOMToolsGUI::setVtkColor( appStudy, mgrId, aView, IO, color );
if ( updateViewer ) aView->Repaint();
}
else if ( isOCC ) {
OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*> ( window->getViewManager()->getViewModel() );
Handle (AIS_InteractiveContext) ic = vm->getAISContext();
GEOMToolsGUI::setOccColor( appStudy, mgrId, ic, IO, color );
if ( updateViewer ) ic->UpdateCurrentViewer();
}
// mark study as modified
GeometryGUI::Modified();
// update actions
app->updateActions(); //SRN: To update a Save button in the toolbar
} }
void GEOMToolsGUI::OnColor() void GEOMToolsGUI::OnColor()
{ {
SALOME_ListIO selected; // get active application
SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
if ( !app ) return;
// get current study
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ); SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
if ( app && appStudy ) { if ( !appStudy ) return;
// get selection manager
LightApp_SelectionMgr* aSelMgr = app->selectionMgr(); LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
if ( aSelMgr ) { if ( !aSelMgr ) return;
// get selection
SALOME_ListIO selected;
aSelMgr->selectedObjects( selected ); aSelMgr->selectedObjects( selected );
if ( !selected.IsEmpty() ) { if ( selected.IsEmpty() ) return;
// get active view
SUIT_ViewWindow* window = app->desktop()->activeWindow(); SUIT_ViewWindow* window = app->desktop()->activeWindow();
bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() ); bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() ); bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
// get view id
int mgrId = window->getViewManager()->getGlobalId(); int mgrId = window->getViewManager()->getGlobalId();
if ( isVTK ) { if ( isVTK ) {
SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window ); SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
if ( !vtkVW ) if ( !vtkVW ) return;
return;
// get initial color (use first object from selection)
SVTK_View* aView = vtkVW->getView(); SVTK_View* aView = vtkVW->getView();
QColor initcolor = aView->GetColor( selected.First() ); QColor color = aView->GetColor( selected.First() );
QColor c = QColorDialog::getColor( initcolor, app->desktop() ); QVariant v = appStudy->getObjectProperty( mgrId, selected.First()->getEntry(), COLOR_PROP, color );
if ( c.isValid() ) {
// show Choose Color dialog box
color = QColorDialog::getColor( v.value<QColor>(), app->desktop() );
if ( !color.isValid() ) return;
// iterate through list of objects and assign new color
SUIT_OverrideCursor(); SUIT_OverrideCursor();
for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) { for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
QString matProp; GEOMToolsGUI::setVtkColor( appStudy, mgrId, aView, It.Value(), color );
matProp = appStudy->getObjectProperty(mgrId,It.Value()->getEntry(), MATERIAL_PROP, matProp).toString();
Material_Model material;
material.fromProperties( matProp );
if ( !material.isPhysical() ) {
aView->SetColor( It.Value(), c );
appStudy->setObjectProperty(mgrId,It.Value()->getEntry(),COLOR_PROP, c);
} }
// store color to GEOM_Object aView->Repaint();
_PTR(Study) aStudy = appStudy->studyDS();
_PTR(SObject) aSObject( aStudy->FindObjectID( It.Value()->getEntry() ) );
GEOM::GEOM_Object_var anObject =
GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aSObject));
SALOMEDS::Color aSColor;
aSColor.R = (double)c.red() / 255.0;
aSColor.G = (double)c.green() / 255.0;
aSColor.B = (double)c.blue() / 255.0;
anObject->SetColor( aSColor );
anObject->SetAutoColor( false );
} }
GeometryGUI::Modified();
}
} // if ( isVTK )
else if ( isOCC ) { else if ( isOCC ) {
// find AIS interactive object (for first item in selection)
Handle(AIS_InteractiveObject) io = GEOMBase::GetAIS( selected.First() ); Handle(AIS_InteractiveObject) io = GEOMBase::GetAIS( selected.First() );
if ( !io.IsNull() ) { if ( io.IsNull() ) return;
// get initial color (use first object from selection)
Quantity_Color aColor; Quantity_Color aColor;
io->Color( aColor ); io->Color( aColor );
QColor ic = QColor((int )( aColor.Red() * 255.0 ), QColor color = QColor((int)( aColor.Red() * 255.0 ),
(int)( aColor.Green() * 255.0 ), (int)( aColor.Green() * 255.0 ),
(int)( aColor.Blue() * 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(), COLOR_PROP, ic); // show Choose Color dialog box
color = QColorDialog::getColor( v.value<QColor>(), app->desktop() );
if ( !color.isValid() ) return;
QColor initcolor = v.value<QColor>(); // iterate through list of objects and assign new color
QColor c = QColorDialog::getColor( initcolor, app->desktop() );
if ( c.isValid() ) {
SUIT_OverrideCursor(); SUIT_OverrideCursor();
aColor = Quantity_Color( c.red() / 255., c.green() / 255., c.blue() / 255., Quantity_TOC_RGB );
OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*> ( window->getViewManager()->getViewModel() ); OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*> ( window->getViewManager()->getViewModel() );
Handle (AIS_InteractiveContext) ic = vm->getAISContext(); Handle (AIS_InteractiveContext) ic = vm->getAISContext();
for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) { for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
GEOMToolsGUI::setOccColor( appStudy, mgrId, ic, It.Value(), color );
}
ic->UpdateCurrentViewer();
}
// mark study as modified
GeometryGUI::Modified();
// update actions
app->updateActions(); //SRN: To update a Save button in the toolbar
}
void GEOMToolsGUI::setVtkColor( SalomeApp_Study* study, // study
int mgrId, // view window id
SVTK_View* view, // VTK view
const Handle(SALOME_InteractiveObject)& IO, // interactive object
const QColor& color ) // color
{
// get material property
QString matProp; QString matProp;
matProp = appStudy->getObjectProperty(mgrId,It.Value()->getEntry(), MATERIAL_PROP, matProp).toString(); matProp = study->getObjectProperty( mgrId, IO->getEntry(), MATERIAL_PROP, matProp ).toString();
Material_Model material; Material_Model material;
material.fromProperties( matProp ); material.fromProperties( matProp );
io = GEOMBase::GetAIS( It.Value(), true );
if ( !io.IsNull() && !material.isPhysical() ) { // change color only for shapes with not physical type of material
// 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 );
}
// store color to GEOM_Object
_PTR(Study) aStudy = study->studyDS();
_PTR(SObject) aSObject( aStudy->FindObjectID( IO->getEntry() ) );
if ( !aSObject ) return;
GEOM::GEOM_Object_var anObject =
GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aSObject));
if ( CORBA::is_nil( anObject ) ) return;
SALOMEDS::Color aSColor;
aSColor.R = (double)color.red() / 255.0;
aSColor.G = (double)color.green() / 255.0;
aSColor.B = (double)color.blue() / 255.0;
anObject->SetColor( aSColor );
anObject->SetAutoColor( false );
}
void GEOMToolsGUI::setOccColor( SalomeApp_Study* study, // study
int mgrId, // view window id
const Handle(AIS_InteractiveContext)& ic, // OCC interactive context
const Handle(SALOME_InteractiveObject)& IO, // interactive object
const QColor& color ) // color
{
// get AIS object
Handle(AIS_InteractiveObject) io = GEOMBase::GetAIS( IO, true );
if ( io.IsNull() ) return;
// get material property
QString matProp;
matProp = study->getObjectProperty( mgrId, IO->getEntry(), MATERIAL_PROP, matProp ).toString();
Material_Model material;
material.fromProperties( matProp );
Quantity_Color aColor = Quantity_Color( color.red() / 255., color.green() / 255., color.blue() / 255., Quantity_TOC_RGB );
// change color only for shapes with not physical type of material
if ( !material.isPhysical() ) {
if ( io->IsKind( STANDARD_TYPE(AIS_Shape) ) ) { if ( io->IsKind( STANDARD_TYPE(AIS_Shape) ) ) {
TopoDS_Shape theShape = Handle(AIS_Shape)::DownCast( io )->Shape(); TopoDS_Shape theShape = Handle(AIS_Shape)::DownCast( io )->Shape();
bool onlyVertex = (theShape.ShapeType() == TopAbs_VERTEX || GEOM_Displayer::isCompoundOfVertices( theShape )); bool onlyVertex = (theShape.ShapeType() == TopAbs_VERTEX || GEOM_Displayer::isCompoundOfVertices( theShape ));
if ( onlyVertex ) { if ( onlyVertex ) {
// Set color for a point // set color for a point
Handle(AIS_Drawer) aCurDrawer = io->Attributes(); Handle(AIS_Drawer) aCurDrawer = io->Attributes();
Handle(Prs3d_PointAspect) aCurPointAspect = aCurDrawer->PointAspect(); Handle(Prs3d_PointAspect) aCurPointAspect = aCurDrawer->PointAspect();
Quantity_Color aCurColor; Quantity_Color aCurColor;
@ -361,13 +484,11 @@ void GEOMToolsGUI::OnColor()
else { else {
Standard_Integer aWidth, aHeight; Standard_Integer aWidth, aHeight;
aCurPointAspect->GetTextureSize( aWidth, aHeight ); aCurPointAspect->GetTextureSize( aWidth, aHeight );
#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
Handle(TColStd_HArray1OfByte) aTexture = aCurPointAspect->GetTexture(); Handle(TColStd_HArray1OfByte) aTexture = aCurPointAspect->GetTexture();
#else #else
Handle(Graphic3d_HArray1OfBytes) aTexture = aCurPointAspect->GetTexture(); Handle(Graphic3d_HArray1OfBytes) aTexture = aCurPointAspect->GetTexture();
#endif #endif
aCurDrawer->SetPointAspect( new Prs3d_PointAspect( aColor, 1, aWidth, aHeight, aTexture ) ); aCurDrawer->SetPointAspect( new Prs3d_PointAspect( aColor, 1, aWidth, aHeight, aTexture ) );
} }
ic->SetLocalAttributes( io, aCurDrawer, Standard_False ); ic->SetLocalAttributes( io, aCurDrawer, Standard_False );
@ -381,36 +502,23 @@ void GEOMToolsGUI::OnColor()
aGAISShape->storeBoundaryColors(); aGAISShape->storeBoundaryColors();
} }
appStudy->setObjectProperty(mgrId,It.Value()->getEntry(), COLOR_PROP, c);
io->Redisplay( Standard_True ); io->Redisplay( Standard_True );
study->setObjectProperty( mgrId, IO->getEntry(), COLOR_PROP, color );
}
// store color to GEOM_Object // store color to GEOM_Object
_PTR(Study) aStudy = appStudy->studyDS(); _PTR(Study) aStudy = study->studyDS();
_PTR(SObject) aSObject( aStudy->FindObjectID( It.Value()->getEntry() ) ); _PTR(SObject) aSObject( aStudy->FindObjectID( IO->getEntry() ) );
GEOM::GEOM_Object_var anObject = GEOM::GEOM_Object_var anObject =
GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aSObject)); GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aSObject));
SALOMEDS::Color aSColor; SALOMEDS::Color aSColor;
aSColor.R = (double)c.red() / 255.0; aSColor.R = (double)color.red() / 255.0;
aSColor.G = (double)c.green() / 255.0; aSColor.G = (double)color.green() / 255.0;
aSColor.B = (double)c.blue() / 255.0; aSColor.B = (double)color.blue() / 255.0;
anObject->SetColor( aSColor ); anObject->SetColor( aSColor );
anObject->SetAutoColor( false ); anObject->SetAutoColor( false );
} }
} // for
ic->UpdateCurrentViewer();
GeometryGUI::Modified();
} // if c.isValid()
} // first IO is not null
} // if ( isOCC )
} // if ( selection not empty )
}
}
app->updateActions(); //SRN: To update a Save button in the toolbar
}
void GEOMToolsGUI::OnTexture() void GEOMToolsGUI::OnTexture()
{ {
@ -844,7 +952,7 @@ void GEOMToolsGUI::OnSelectOnly(int mode)
} }
} }
void GEOMToolsGUI::OnShowHideChildren( bool show ) void GEOMToolsGUI::OnDiscloseConcealChildren( bool show )
{ {
SALOME_ListIO selected; SALOME_ListIO selected;
SalomeApp_Application* app = SalomeApp_Application* app =

View File

@ -18,7 +18,6 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include <Standard_Stream.hxx> #include <Standard_Stream.hxx>
@ -277,6 +276,29 @@ GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnSurfaceByCoord
return GetObject(anObject); return GetObject(anObject);
} }
//=============================================================================
/*!
* MakePointOnFace
*/
//=============================================================================
GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnFace (GEOM::GEOM_Object_ptr theFace)
{
GEOM::GEOM_Object_var aGEOMObject;
//Set a not done flag
GetOperations()->SetNotDone();
//Get the reference face
Handle(GEOM_Object) aReference = GetObjectImpl(theFace);
if (aReference.IsNull()) return aGEOMObject._retn();
//Create the point
Handle(GEOM_Object) anObject = GetOperations()->MakePointOnFace(aReference);
if (!GetOperations()->IsDone() || anObject.IsNull())
return aGEOMObject._retn();
return GetObject(anObject);
}
//============================================================================= //=============================================================================
/*! /*!

View File

@ -18,7 +18,6 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#ifndef _GEOM_IBasicOperations_i_HeaderFile #ifndef _GEOM_IBasicOperations_i_HeaderFile
#define _GEOM_IBasicOperations_i_HeaderFile #define _GEOM_IBasicOperations_i_HeaderFile
@ -73,6 +72,8 @@ class GEOM_I_EXPORT GEOM_IBasicOperations_i :
CORBA::Double theYParameter, CORBA::Double theYParameter,
CORBA::Double theZParameter); CORBA::Double theZParameter);
GEOM::GEOM_Object_ptr MakePointOnFace (GEOM::GEOM_Object_ptr theFace);
GEOM::GEOM_Object_ptr MakePointOnLinesIntersection (GEOM::GEOM_Object_ptr theLine1, GEOM::GEOM_Object_ptr MakePointOnLinesIntersection (GEOM::GEOM_Object_ptr theLine1,
GEOM::GEOM_Object_ptr theLine2); GEOM::GEOM_Object_ptr theLine2);

View File

@ -18,7 +18,6 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include <Standard_Stream.hxx> #include <Standard_Stream.hxx>
@ -742,6 +741,39 @@ char* GEOM_IBlocksOperations_i::PrintBCErrors
return CORBA::string_dup(aDescr.ToCString()); return CORBA::string_dup(aDescr.ToCString());
} }
//=============================================================================
/*!
* GetNonBlocks
*/
//=============================================================================
GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetNonBlocks
(GEOM::GEOM_Object_ptr theShape,
GEOM::GEOM_Object_out theNonQuads)
{
GEOM::GEOM_Object_var aGEOMObject;
GEOM::GEOM_Object_var aNonQuads;
theNonQuads = aNonQuads._retn();
//Set a not done flag
GetOperations()->SetNotDone();
//Get the reference Objects
Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
if (aShape.IsNull()) return aGEOMObject._retn();
//Get the result
Handle(GEOM_Object) aFaces;
Handle(GEOM_Object) anObject = GetOperations()->GetNonBlocks(aShape, aFaces);
if (!GetOperations()->IsDone() || anObject.IsNull())
return aGEOMObject._retn();
if (!aFaces.IsNull())
theNonQuads = GetObject(aFaces);
return GetObject(anObject);
}
//============================================================================= //=============================================================================
/*! /*!
* RemoveExtraEdges * RemoveExtraEdges

View File

@ -18,7 +18,6 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#ifndef _GEOM_IBlocksOperations_i_HeaderFile #ifndef _GEOM_IBlocksOperations_i_HeaderFile
#define _GEOM_IBlocksOperations_i_HeaderFile #define _GEOM_IBlocksOperations_i_HeaderFile
@ -121,6 +120,9 @@ class GEOM_I_EXPORT GEOM_IBlocksOperations_i :
char* PrintBCErrors (GEOM::GEOM_Object_ptr theCompound, char* PrintBCErrors (GEOM::GEOM_Object_ptr theCompound,
const GEOM::GEOM_IBlocksOperations::BCErrors& theErrors); const GEOM::GEOM_IBlocksOperations::BCErrors& theErrors);
GEOM::GEOM_Object_ptr GetNonBlocks (GEOM::GEOM_Object_ptr theShape,
GEOM::GEOM_Object_out theNonQuads);
GEOM::GEOM_Object_ptr RemoveExtraEdges (GEOM::GEOM_Object_ptr theShape, GEOM::GEOM_Object_ptr RemoveExtraEdges (GEOM::GEOM_Object_ptr theShape,
CORBA::Long theOptimumNbFaces); CORBA::Long theOptimumNbFaces);

View File

@ -18,7 +18,6 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include <Standard_Stream.hxx> #include <Standard_Stream.hxx>
@ -433,9 +432,11 @@ GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSplineInterpolation
* MakeCurveParametric * MakeCurveParametric
*/ */
//============================================================================= //=============================================================================
GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCurveParametric(const char* thexExpr, const char* theyExpr, const char* thezExpr, GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCurveParametric
(const char* thexExpr, const char* theyExpr, const char* thezExpr,
double theParamMin, double theParamMax, double theParamStep, double theParamMin, double theParamMax, double theParamStep,
GEOM::curve_type theCurveType) { GEOM::curve_type theCurveType)
{
GEOM::GEOM_Object_var aGEOMObject; GEOM::GEOM_Object_var aGEOMObject;
//Set a not done flag //Set a not done flag
GetOperations()->SetNotDone(); GetOperations()->SetNotDone();
@ -455,7 +456,6 @@ GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCurveParametric(const char*
break; break;
} }
// Make Polyline // Make Polyline
Handle(GEOM_Object) anObject = Handle(GEOM_Object) anObject =
GetOperations()->MakeCurveParametric(thexExpr, theyExpr, thezExpr, GetOperations()->MakeCurveParametric(thexExpr, theyExpr, thezExpr,
@ -473,9 +473,11 @@ GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCurveParametric(const char*
* MakeCurveParametricNew * MakeCurveParametricNew
*/ */
//============================================================================= //=============================================================================
GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCurveParametricNew(const char* thexExpr, const char* theyExpr, const char* thezExpr, GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCurveParametricNew
(const char* thexExpr, const char* theyExpr, const char* thezExpr,
double theParamMin, double theParamMax, CORBA::Long theParamNbStep, double theParamMin, double theParamMax, CORBA::Long theParamNbStep,
GEOM::curve_type theCurveType) { GEOM::curve_type theCurveType)
{
GEOM::GEOM_Object_var aGEOMObject; GEOM::GEOM_Object_var aGEOMObject;
//Set a not done flag //Set a not done flag
GetOperations()->SetNotDone(); GetOperations()->SetNotDone();
@ -495,7 +497,6 @@ GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCurveParametricNew(const cha
break; break;
} }
// Make Polyline // Make Polyline
Handle(GEOM_Object) anObject = Handle(GEOM_Object) anObject =
GetOperations()->MakeCurveParametric(thexExpr, theyExpr, thezExpr, GetOperations()->MakeCurveParametric(thexExpr, theyExpr, thezExpr,
@ -534,6 +535,46 @@ GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSketcher
return GetObject(anObject); return GetObject(anObject);
} }
//=============================================================================
/*!
* MakeSketcherOnPlane
*/
//=============================================================================
GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSketcherOnPlane
(const char* theCommand, GEOM::GEOM_Object_ptr theWorkingPlane)
{
//Set a not done flag
GetOperations()->SetNotDone();
Handle(GEOM_Object) aWorkingPlane = GetObjectImpl(theWorkingPlane);
// Make Sketcher
Handle(GEOM_Object) anObject =
GetOperations()->MakeSketcherOnPlane(theCommand, aWorkingPlane);
if (!GetOperations()->IsDone() || anObject.IsNull())
return GEOM::GEOM_Object::_nil();
return GetObject(anObject);
}
//=============================================================================
/*!
* Make3DSketcherCommand
*/
//=============================================================================
GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::Make3DSketcherCommand (const char* theCommand)
{
//Set a not done flag
GetOperations()->SetNotDone();
// Make 3D Sketcher
Handle(GEOM_Object) anObject = GetOperations()->Make3DSketcherCommand(theCommand);
if (!GetOperations()->IsDone() || anObject.IsNull())
return GEOM::GEOM_Object::_nil();
return GetObject(anObject);
}
//============================================================================= //=============================================================================
/*! /*!
* Make3DSketcher * Make3DSketcher
@ -559,25 +600,3 @@ GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::Make3DSketcher
return GetObject(anObject); return GetObject(anObject);
} }
//=============================================================================
/*!
* MakeSketcherOnPlane
*/
//=============================================================================
GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSketcherOnPlane
(const char* theCommand, GEOM::GEOM_Object_ptr theWorkingPlane)
{
//Set a not done flag
GetOperations()->SetNotDone();
Handle(GEOM_Object) aWorkingPlane = GetObjectImpl(theWorkingPlane);
// Make Sketcher
Handle(GEOM_Object) anObject =
GetOperations()->MakeSketcherOnPlane(theCommand, aWorkingPlane);
if (!GetOperations()->IsDone() || anObject.IsNull())
return GEOM::GEOM_Object::_nil();
return GetObject(anObject);
}

View File

@ -18,7 +18,6 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#ifndef _GEOM_ICurvesOperations_i_HeaderFile #ifndef _GEOM_ICurvesOperations_i_HeaderFile
#define _GEOM_ICurvesOperations_i_HeaderFile #define _GEOM_ICurvesOperations_i_HeaderFile
@ -86,20 +85,24 @@ class GEOM_I_EXPORT GEOM_ICurvesOperations_i :
CORBA::Boolean theIsClosed, CORBA::Boolean theIsClosed,
CORBA::Boolean theDoReordering); CORBA::Boolean theDoReordering);
GEOM::GEOM_Object_ptr MakeCurveParametric(const char* thexExpr, const char* theyExpr, const char* thezExpr, GEOM::GEOM_Object_ptr MakeCurveParametric
(const char* thexExpr, const char* theyExpr, const char* thezExpr,
double theParamMin, double theParamMax, double theParamStep, double theParamMin, double theParamMax, double theParamStep,
GEOM::curve_type theCurveType); GEOM::curve_type theCurveType);
GEOM::GEOM_Object_ptr MakeCurveParametricNew(const char* thexExpr, const char* theyExpr, const char* thezExpr, GEOM::GEOM_Object_ptr MakeCurveParametricNew
(const char* thexExpr, const char* theyExpr, const char* thezExpr,
double theParamMin, double theParamMax, CORBA::Long theParamNbStep, double theParamMin, double theParamMax, CORBA::Long theParamNbStep,
GEOM::curve_type theCurveType); GEOM::curve_type theCurveType);
GEOM::GEOM_Object_ptr MakeSketcher (const char* theCommand, const GEOM::ListOfDouble& theWorkingPlane); GEOM::GEOM_Object_ptr MakeSketcher (const char* theCommand, const GEOM::ListOfDouble& theWorkingPlane);
GEOM::GEOM_Object_ptr Make3DSketcher (const GEOM::ListOfDouble& theCoordinates);
GEOM::GEOM_Object_ptr MakeSketcherOnPlane (const char* theCommand, GEOM::GEOM_Object_ptr theWorkingPlane); GEOM::GEOM_Object_ptr MakeSketcherOnPlane (const char* theCommand, GEOM::GEOM_Object_ptr theWorkingPlane);
GEOM::GEOM_Object_ptr Make3DSketcherCommand (const char* theCommand);
GEOM::GEOM_Object_ptr Make3DSketcher (const GEOM::ListOfDouble& theCoordinates);
::GEOMImpl_ICurvesOperations* GetOperations() ::GEOMImpl_ICurvesOperations* GetOperations()
{ return (::GEOMImpl_ICurvesOperations*)GetImpl(); } { return (::GEOMImpl_ICurvesOperations*)GetImpl(); }
}; };

View File

@ -18,7 +18,6 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include <Standard_Stream.hxx> #include <Standard_Stream.hxx>
@ -202,7 +201,6 @@ void GEOM_IGroupOperations_i::UnionIDs (GEOM::GEOM_Object_ptr theGroup,
//Perform the operation //Perform the operation
GetOperations()->UnionIDs(aGroupRef, aSubShapes); GetOperations()->UnionIDs(aGroupRef, aSubShapes);
return;
} }
//============================================================================= //=============================================================================
@ -230,7 +228,176 @@ void GEOM_IGroupOperations_i::DifferenceIDs (GEOM::GEOM_Object_ptr theGroup,
//Perform the operation //Perform the operation
GetOperations()->DifferenceIDs(aGroupRef, aSubShapes); GetOperations()->DifferenceIDs(aGroupRef, aSubShapes);
return; }
//=============================================================================
/*!
* UnionGroups
*/
//=============================================================================
GEOM::GEOM_Object_ptr GEOM_IGroupOperations_i::UnionGroups (GEOM::GEOM_Object_ptr theGroup1,
GEOM::GEOM_Object_ptr theGroup2)
{
GEOM::GEOM_Object_var aGEOMObject;
//Set a not done flag
GetOperations()->SetNotDone();
//Get the reference groups
Handle(GEOM_Object) aGroupRef1 = GetObjectImpl(theGroup1);
Handle(GEOM_Object) aGroupRef2 = GetObjectImpl(theGroup2);
if (aGroupRef1.IsNull() || aGroupRef2.IsNull()) return aGEOMObject._retn();
//Perform the operation
Handle(GEOM_Object) anObject = GetOperations()->UnionGroups(aGroupRef1, aGroupRef2);
if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
return GetObject(anObject);
}
//=============================================================================
/*!
* IntersectGroups
*/
//=============================================================================
GEOM::GEOM_Object_ptr GEOM_IGroupOperations_i::IntersectGroups (GEOM::GEOM_Object_ptr theGroup1,
GEOM::GEOM_Object_ptr theGroup2)
{
GEOM::GEOM_Object_var aGEOMObject;
//Set a not done flag
GetOperations()->SetNotDone();
//Get the reference groups
Handle(GEOM_Object) aGroupRef1 = GetObjectImpl(theGroup1);
Handle(GEOM_Object) aGroupRef2 = GetObjectImpl(theGroup2);
if (aGroupRef1.IsNull() || aGroupRef2.IsNull()) return aGEOMObject._retn();
//Perform the operation
Handle(GEOM_Object) anObject = GetOperations()->IntersectGroups(aGroupRef1, aGroupRef2);
if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
return GetObject(anObject);
}
//=============================================================================
/*!
* CutGroups
*/
//=============================================================================
GEOM::GEOM_Object_ptr GEOM_IGroupOperations_i::CutGroups (GEOM::GEOM_Object_ptr theGroup1,
GEOM::GEOM_Object_ptr theGroup2)
{
GEOM::GEOM_Object_var aGEOMObject;
//Set a not done flag
GetOperations()->SetNotDone();
//Get the reference groups
Handle(GEOM_Object) aGroupRef1 = GetObjectImpl(theGroup1);
Handle(GEOM_Object) aGroupRef2 = GetObjectImpl(theGroup2);
if (aGroupRef1.IsNull() || aGroupRef2.IsNull()) return aGEOMObject._retn();
//Perform the operation
Handle(GEOM_Object) anObject = GetOperations()->CutGroups(aGroupRef1, aGroupRef2);
if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
return GetObject(anObject);
}
//=============================================================================
/*!
* UnionListOfGroups
*/
//=============================================================================
GEOM::GEOM_Object_ptr GEOM_IGroupOperations_i::UnionListOfGroups (const GEOM::ListOfGO& theGList)
{
GEOM::GEOM_Object_var aGEOMObject;
//Set a not done flag
GetOperations()->SetNotDone();
//Get the reference groups
Handle(TColStd_HSequenceOfTransient) aGroups = new TColStd_HSequenceOfTransient;
int ind, aLen = theGList.length();
for (ind = 0; ind < aLen; ind++) {
Handle(GEOM_Object) aGr = GetObjectImpl(theGList[ind]);
if (aGr.IsNull()) return aGEOMObject._retn();
aGroups->Append(aGr);
}
//Perform the operation
Handle(GEOM_Object) anObject = GetOperations()->UnionListOfGroups(aGroups);
if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
return GetObject(anObject);
}
//=============================================================================
/*!
* IntersectListOfGroups
*/
//=============================================================================
GEOM::GEOM_Object_ptr GEOM_IGroupOperations_i::IntersectListOfGroups (const GEOM::ListOfGO& theGList)
{
GEOM::GEOM_Object_var aGEOMObject;
//Set a not done flag
GetOperations()->SetNotDone();
//Get the reference groups
Handle(TColStd_HSequenceOfTransient) aGroups = new TColStd_HSequenceOfTransient;
int ind, aLen = theGList.length();
for (ind = 0; ind < aLen; ind++) {
Handle(GEOM_Object) aGr = GetObjectImpl(theGList[ind]);
if (aGr.IsNull()) return aGEOMObject._retn();
aGroups->Append(aGr);
}
//Perform the operation
Handle(GEOM_Object) anObject = GetOperations()->IntersectListOfGroups(aGroups);
if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
return GetObject(anObject);
}
//=============================================================================
/*!
* CutListOfGroups
*/
//=============================================================================
GEOM::GEOM_Object_ptr GEOM_IGroupOperations_i::CutListOfGroups (const GEOM::ListOfGO& theGList1,
const GEOM::ListOfGO& theGList2)
{
GEOM::GEOM_Object_var aGEOMObject;
//Set a not done flag
GetOperations()->SetNotDone();
//Get the reference groups
Handle(TColStd_HSequenceOfTransient) aGroups1 = new TColStd_HSequenceOfTransient;
Handle(TColStd_HSequenceOfTransient) aGroups2 = new TColStd_HSequenceOfTransient;
int ind, aLen = theGList1.length();
for (ind = 0; ind < aLen; ind++) {
Handle(GEOM_Object) aGr = GetObjectImpl(theGList1[ind]);
if (aGr.IsNull()) return aGEOMObject._retn();
aGroups1->Append(aGr);
}
aLen = theGList2.length();
for (ind = 0; ind < aLen; ind++) {
Handle(GEOM_Object) aGr = GetObjectImpl(theGList2[ind]);
if (aGr.IsNull()) return aGEOMObject._retn();
aGroups2->Append(aGr);
}
//Perform the operation
Handle(GEOM_Object) anObject = GetOperations()->CutListOfGroups(aGroups1, aGroups2);
if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
return GetObject(anObject);
} }
//============================================================================= //=============================================================================

View File

@ -18,7 +18,6 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#ifndef _GEOM_IGroupOperations_i_HeaderFile #ifndef _GEOM_IGroupOperations_i_HeaderFile
#define _GEOM_IGroupOperations_i_HeaderFile #define _GEOM_IGroupOperations_i_HeaderFile
@ -56,6 +55,14 @@ class GEOM_I_EXPORT GEOM_IGroupOperations_i :
void DifferenceIDs (GEOM::GEOM_Object_ptr theGroup, const GEOM::ListOfLong& theSubShapes); void DifferenceIDs (GEOM::GEOM_Object_ptr theGroup, const GEOM::ListOfLong& theSubShapes);
GEOM::GEOM_Object_ptr UnionGroups (GEOM::GEOM_Object_ptr theGroup1, GEOM::GEOM_Object_ptr theGroup2);
GEOM::GEOM_Object_ptr IntersectGroups (GEOM::GEOM_Object_ptr theGroup1, GEOM::GEOM_Object_ptr theGroup2);
GEOM::GEOM_Object_ptr CutGroups (GEOM::GEOM_Object_ptr theGroup1, GEOM::GEOM_Object_ptr theGroup2);
GEOM::GEOM_Object_ptr UnionListOfGroups (const GEOM::ListOfGO& theGList);
GEOM::GEOM_Object_ptr IntersectListOfGroups (const GEOM::ListOfGO& theGList);
GEOM::GEOM_Object_ptr CutListOfGroups (const GEOM::ListOfGO& theGList1, const GEOM::ListOfGO& theGList2);
CORBA::Long GetType (GEOM::GEOM_Object_ptr theGroup); CORBA::Long GetType (GEOM::GEOM_Object_ptr theGroup);
GEOM::GEOM_Object_ptr GetMainShape (GEOM::GEOM_Object_ptr theGroup); GEOM::GEOM_Object_ptr GetMainShape (GEOM::GEOM_Object_ptr theGroup);

View File

@ -18,7 +18,6 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#ifdef WNT #ifdef WNT
#pragma warning( disable:4786 ) #pragma warning( disable:4786 )
@ -47,7 +46,7 @@
//============================================================================= //=============================================================================
/*! /*!
* constructor: * constructor
*/ */
//============================================================================= //=============================================================================
GEOM_IInsertOperations_i::GEOM_IInsertOperations_i (PortableServer::POA_ptr thePOA, GEOM_IInsertOperations_i::GEOM_IInsertOperations_i (PortableServer::POA_ptr thePOA,
@ -155,6 +154,32 @@ GEOM::GEOM_Object_ptr GEOM_IInsertOperations_i::ImportFile
return GetObject(anObject); return GetObject(anObject);
} }
//=============================================================================
/*!
* ReadValue
*/
//=============================================================================
char* GEOM_IInsertOperations_i::ReadValue(const char* theFileName,
const char* theFormatName,
const char* theParameterName)
{
//Set a not done flag
GetOperations()->SetNotDone();
char* aFileName = strdup(theFileName);
char* aFormatName = strdup(theFormatName);
char* aParameterName = strdup(theParameterName);
TCollection_AsciiString aUnits = GetOperations()->ReadValue
(aFileName, aFormatName, aParameterName);
free(aFileName);
free(aFormatName);
free(aParameterName);
return CORBA::string_dup(aUnits.ToCString());
}
//============================================================================= //=============================================================================
/*! /*!
* ImportTranslators * ImportTranslators
@ -225,12 +250,47 @@ void GEOM_IInsertOperations_i::ExportTranslators
thePatterns = aPatternsArray._retn(); thePatterns = aPatternsArray._retn();
} }
//=============================================================================
/*!
* RestoreShape
*/
//=============================================================================
GEOM::GEOM_Object_ptr GEOM_IInsertOperations_i::RestoreShape (const SALOMEDS::TMPFile& theStream)
{
GEOM::GEOM_Object_var aGEOMObject;
//Set a not done flag
GetOperations()->SetNotDone();
if (theStream.length() < 1)
return aGEOMObject._retn();
char* buf = (char*)theStream.NP_data();
std::istringstream aStream (buf);
Handle(GEOM_Object) anObject = GetOperations()->RestoreShape(aStream);
if (!GetOperations()->IsDone() || anObject.IsNull())
return aGEOMObject._retn();
return GetObject(anObject);
}
//=============================================================================
/*!
* LoadTexture
*/
//=============================================================================
CORBA::Long GEOM_IInsertOperations_i::LoadTexture(const char* theTextureFile) CORBA::Long GEOM_IInsertOperations_i::LoadTexture(const char* theTextureFile)
{ {
GetOperations()->SetNotDone(); GetOperations()->SetNotDone();
return GetOperations()->LoadTexture( theTextureFile ); return GetOperations()->LoadTexture( theTextureFile );
} }
//=============================================================================
/*!
* AddTexture
*/
//=============================================================================
CORBA::Long GEOM_IInsertOperations_i::AddTexture(CORBA::Long theWidth, CORBA::Long theHeight, CORBA::Long GEOM_IInsertOperations_i::AddTexture(CORBA::Long theWidth, CORBA::Long theHeight,
const SALOMEDS::TMPFile& theTexture) const SALOMEDS::TMPFile& theTexture)
{ {
@ -255,6 +315,11 @@ CORBA::Long GEOM_IInsertOperations_i::AddTexture(CORBA::Long theWidth, CORBA::Lo
return GetOperations()->AddTexture( theWidth, theHeight, aTexture ); return GetOperations()->AddTexture( theWidth, theHeight, aTexture );
} }
//=============================================================================
/*!
* GetTexture
*/
//=============================================================================
SALOMEDS::TMPFile* GEOM_IInsertOperations_i::GetTexture(CORBA::Long theID, SALOMEDS::TMPFile* GEOM_IInsertOperations_i::GetTexture(CORBA::Long theID,
CORBA::Long& theWidth, CORBA::Long& theWidth,
CORBA::Long& theHeight) CORBA::Long& theHeight)
@ -278,6 +343,11 @@ SALOMEDS::TMPFile* GEOM_IInsertOperations_i::GetTexture(CORBA::Long theID,
return aTexture._retn(); return aTexture._retn();
} }
//=============================================================================
/*!
* GetAllTextures
*/
//=============================================================================
GEOM::ListOfLong* GEOM_IInsertOperations_i::GetAllTextures() GEOM::ListOfLong* GEOM_IInsertOperations_i::GetAllTextures()
{ {
std::list<int> localIDs = GetOperations()->GetAllTextures(); std::list<int> localIDs = GetOperations()->GetAllTextures();

View File

@ -18,7 +18,6 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#ifndef _GEOM_IInsertOperations_i_HeaderFile #ifndef _GEOM_IInsertOperations_i_HeaderFile
#define _GEOM_IInsertOperations_i_HeaderFile #define _GEOM_IInsertOperations_i_HeaderFile
@ -52,12 +51,18 @@ class GEOM_I_EXPORT GEOM_IInsertOperations_i :
GEOM::GEOM_Object_ptr ImportFile (const char* theFileName, GEOM::GEOM_Object_ptr ImportFile (const char* theFileName,
const char* theFormatName); const char* theFormatName);
char* ReadValue (const char* theFileName,
const char* theFormatName,
const char* theParameterName);
void ImportTranslators (GEOM::string_array_out theFormats, void ImportTranslators (GEOM::string_array_out theFormats,
GEOM::string_array_out thePatterns); GEOM::string_array_out thePatterns);
void ExportTranslators (GEOM::string_array_out theFormats, void ExportTranslators (GEOM::string_array_out theFormats,
GEOM::string_array_out thePatterns); GEOM::string_array_out thePatterns);
GEOM::GEOM_Object_ptr RestoreShape (const SALOMEDS::TMPFile& theStream);
CORBA::Long LoadTexture(const char* theTextureFile); CORBA::Long LoadTexture(const char* theTextureFile);
CORBA::Long AddTexture(CORBA::Long theWidth, CORBA::Long theHeight, CORBA::Long AddTexture(CORBA::Long theWidth, CORBA::Long theHeight,
const SALOMEDS::TMPFile& theTexture); const SALOMEDS::TMPFile& theTexture);

View File

@ -20,18 +20,17 @@
# #
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
# #
# GEOM GEOM_SWIG : binding of C++ implementaion with Python # GEOM GEOM_SWIG : binding of C++ implementaion with Python
# File : GEOM_Spanner.py # File : GEOM_Spanner.py
# Author : Julia DOROVSKIKH # Author : Julia DOROVSKIKH
# Module : GEOM # Module : GEOM
# $Header$ #
# ! Please, if you edit this example file, update also # ! Please, if you edit this example file, update also
# ! GEOM_SRC/doc/salome/gui/GEOM/input/tui_test_spanner.doc # ! GEOM_SRC/doc/salome/gui/GEOM/input/tui_test_spanner.doc
# ! as some sequences of symbols from this example are used during # ! as some sequences of symbols from this example are used during
# ! documentation generation to identify certain places of this file # ! documentation generation to identify certain places of this file
############# MakeSpanner #############
# #
############# MakeSpanner #############
def MakeSpanner (geompy, math, isBlocksTest = 0, isMeshTest = 0, smesh = None): def MakeSpanner (geompy, math, isBlocksTest = 0, isMeshTest = 0, smesh = None):
### Variables ### ### Variables ###
@ -304,6 +303,11 @@ def MakeSpanner (geompy, math, isBlocksTest = 0, isMeshTest = 0, smesh = None):
isCompOfBlocks6 = BlocksOp.CheckCompoundOfBlocks(Spanner) isCompOfBlocks6 = BlocksOp.CheckCompoundOfBlocks(Spanner)
if isCompOfBlocks6 == 0: if isCompOfBlocks6 == 0:
print "Spanner is not a compound of hexahedral solids" print "Spanner is not a compound of hexahedral solids"
(NonBlocks, NonQuads) = geompy.GetNonBlocks(Spanner)
if NonBlocks is not None:
geompy.addToStudyInFather(Spanner, NonBlocks, "Group of non-hexahedral solids")
if NonQuads is not None:
geompy.addToStudyInFather(Spanner, NonQuads, "Group of non-quadrangular faces")
else: else:
print "Spanner is a compound of hexahedral solids" print "Spanner is a compound of hexahedral solids"

View File

@ -19,7 +19,6 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# #
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # 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++ omplementaion with Python
# File : GEOM_usinggeom.py # File : GEOM_usinggeom.py
@ -105,7 +104,17 @@ def TestAll (geompy, math):
Interpol = geompy.MakeInterpol([px, py, p200, pxyz], True) #(List of GEOM_Object,Boolean)->GEOM_Object 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", 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 [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 #Create local coordinate system from shape
cs4 = geompy.MakeMarkerFromShape(Plane) cs4 = geompy.MakeMarkerFromShape(Plane)
@ -183,6 +192,7 @@ def TestAll (geompy, math):
#Test point on surface creation #Test point on surface creation
p_on_face = geompy.MakeVertexOnSurface(Face, 0.1, 0.8) #(GEOM_Object, Double, Double)->GEOM_Object p_on_face = geompy.MakeVertexOnSurface(Face, 0.1, 0.8) #(GEOM_Object, Double, Double)->GEOM_Object
p_on_face2 = geompy.MakeVertexOnSurfaceByCoord(Face, 0., 0., 0.) #(GEOM_Object, Double, Double, Double)->GEOM_Object p_on_face2 = geompy.MakeVertexOnSurfaceByCoord(Face, 0., 0., 0.) #(GEOM_Object, Double, Double, Double)->GEOM_Object
p_on_face3 = geompy.MakeVertexInsideFace(Face) #(GEOM_Object)->GEOM_Object
# Test plane from existing face creation # Test plane from existing face creation
Plane2 = geompy.MakePlaneFace(Face, trimsize) #(GEOM_Object, Double)->GEOM_Object Plane2 = geompy.MakePlaneFace(Face, trimsize) #(GEOM_Object, Double)->GEOM_Object
@ -330,7 +340,9 @@ def TestAll (geompy, math):
id_Bezier = geompy.addToStudy(Bezier, "Bezier") id_Bezier = geompy.addToStudy(Bezier, "Bezier")
id_Interpol = geompy.addToStudy(Interpol, "Interpol") id_Interpol = geompy.addToStudy(Interpol, "Interpol")
id_Sketcher = geompy.addToStudy(Sketcher, "Sketcher") 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_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)" ) id_p_on_arc2 = geompy.addToStudy(p_on_arc2, "Vertex on Arc at(100, -10, 10)" )
@ -374,6 +386,7 @@ def TestAll (geompy, math):
id_p_on_face = geompy.addToStudy(p_on_face, "Vertex on Face (0.1, 0.8)") id_p_on_face = geompy.addToStudy(p_on_face, "Vertex on Face (0.1, 0.8)")
id_p_on_face2 = geompy.addToStudy(p_on_face2, "Vertex on Face at(0., 0., 0.)") id_p_on_face2 = geompy.addToStudy(p_on_face2, "Vertex on Face at(0., 0., 0.)")
id_p_on_face3 = geompy.addToStudy(p_on_face3, "Vertex inside Face")
id_Prism1 = geompy.addToStudy(Prism1, "Prism by Two Pnt") id_Prism1 = geompy.addToStudy(Prism1, "Prism by Two Pnt")
id_Shell1 = geompy.addToStudy(Shell1, "Shell from Prism1 faces") id_Shell1 = geompy.addToStudy(Shell1, "Shell from Prism1 faces")

View File

@ -95,6 +95,11 @@ def TestExportImport (geompy, shape):
os.remove(fileExportImportIGES) os.remove(fileExportImportIGES)
os.remove(fileExportImportSTEP) os.remove(fileExportImportSTEP)
# Test RestoreShape from binary BRep stream
aStream = shape.GetShapeStream()
aNewShape = geompy.RestoreShape(aStream)
geompy.addToStudy(aNewShape, "aNewShape")
print "OK" print "OK"
@ -144,6 +149,7 @@ def TestOtherOperations (geompy, math):
# OrientationChange # OrientationChange
Box = geompy.MakeBoxDXDYDZ(200, 200, 200) Box = geompy.MakeBoxDXDYDZ(200, 200, 200)
geompy.addToStudy(Box, "Box")
Orientation = geompy.OrientationChange(Box) Orientation = geompy.OrientationChange(Box)
id_Orientation = geompy.addToStudy(Orientation, "OrientationChange") id_Orientation = geompy.addToStudy(Orientation, "OrientationChange")
@ -243,6 +249,11 @@ def TestOtherOperations (geompy, math):
IsValid = geompy.CheckCompoundOfBlocks(Compound1) IsValid = geompy.CheckCompoundOfBlocks(Compound1)
if IsValid == 0: if IsValid == 0:
print "The Blocks Compound is NOT VALID" print "The Blocks Compound is NOT VALID"
(NonBlocks, NonQuads) = geompy.GetNonBlocks(Compound1)
if NonBlocks is not None:
geompy.addToStudyInFather(Compound1, NonBlocks, "Group of non-hexahedral solids")
if NonQuads is not None:
geompy.addToStudyInFather(Compound1, NonQuads, "Group of non-quadrangular faces")
else: else:
print "The Blocks Compound is VALID" print "The Blocks Compound is VALID"
@ -311,6 +322,42 @@ def TestOtherOperations (geompy, math):
for ObjectID in GetObjectIDs: for ObjectID in GetObjectIDs:
print " ", ObjectID print " ", ObjectID
# Boolean Operations on Groups (Union, Intersection, Cut)
Group_1 = geompy.CreateGroup(Box, geompy.ShapeType["FACE"])
geompy.UnionIDs(Group_1, [13, 23])
Group_2 = geompy.CreateGroup(Box, geompy.ShapeType["FACE"])
geompy.UnionIDs(Group_2, [3, 27])
Group_3 = geompy.CreateGroup(Box, geompy.ShapeType["FACE"])
geompy.UnionIDs(Group_3, [33, 23])
Group_4 = geompy.CreateGroup(Box, geompy.ShapeType["FACE"])
geompy.UnionIDs(Group_4, [31, 27])
geompy.addToStudyInFather(Box, Group_1, 'Group_1')
geompy.addToStudyInFather(Box, Group_2, 'Group_2')
geompy.addToStudyInFather(Box, Group_3, 'Group_3')
geompy.addToStudyInFather(Box, Group_4, 'Group_4')
# union groups
Group_U_1_2 = geompy.UnionGroups(Group_1, Group_2)
Group_UL_3_4 = geompy.UnionListOfGroups([Group_3, Group_4])
geompy.addToStudyInFather(Box, Group_U_1_2, 'Group_U_1_2')
geompy.addToStudyInFather(Box, Group_UL_3_4, 'Group_UL_3_4')
# intersect groups
Group_I_1_3 = geompy.IntersectGroups(Group_1, Group_3)
Group_IL_1_3 = geompy.IntersectListOfGroups([Group_1, Group_3])
geompy.addToStudyInFather(Box, Group_I_1_3, 'Group_I_1_3')
geompy.addToStudyInFather(Box, Group_IL_1_3, 'Group_IL_1_3')
# cut groups
Group_C_2_4 = geompy.CutGroups(Group_2, Group_4)
Group_CL_2_4 = geompy.CutListOfGroups([Group_2], [Group_4])
geompy.addToStudyInFather(Box, Group_C_2_4, 'Group_C_2_4')
geompy.addToStudyInFather(Box, Group_CL_2_4, 'Group_CL_2_4')
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
# enumeration ShapeTypeString as a dictionary # enumeration ShapeTypeString as a dictionary
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------

View File

@ -35,6 +35,7 @@ include $(top_srcdir)/adm_local/unix/make_common_starter.am
dist_salomescript_DATA = \ dist_salomescript_DATA = \
geompy.py \ geompy.py \
geompyDC.py \ geompyDC.py \
gsketcher.py \
batchmode_geompy.py \ batchmode_geompy.py \
GEOM_Spanner.py \ GEOM_Spanner.py \
GEOM_blocks.py \ GEOM_blocks.py \

View File

@ -31,13 +31,22 @@ import salome
import geompyDC import geompyDC
from salome import * from salome import *
# retrieve GEOM engine in try/except block
# to avoid problems in some cases, e.g. when generating documentation
try:
# get GEOM engine
geom = lcc.FindOrLoadComponent( "FactoryServer", "GEOM" ) geom = lcc.FindOrLoadComponent( "FactoryServer", "GEOM" )
# initialize GEOM with current study
geom.init_geom( salome.myStudy ) geom.init_geom( salome.myStudy )
# Export the methods of geompyDC # export the methods of geompyDC
for k in dir( geom ): for k in dir( geom ):
if k[0] == '_': continue if k[0] == '_': continue
globals()[k] = getattr( geom, k ) globals()[k] = getattr( geom, k )
pass
del k del k
from geompyDC import ShapeType, GEOM, kind, info, PackData, ReadTexture, EnumToLong from geompyDC import ShapeType, GEOM, kind, info, PackData, ReadTexture, EnumToLong
pass
except:
geom = None
pass

View File

@ -73,9 +73,14 @@
## @} ## @}
# initialize SALOME session in try/except block
# to avoid problems in some cases, e.g. when generating documentation
try:
import salome import salome
salome.salome_init() salome.salome_init()
from salome import * from salome import *
except:
pass
from salome_notebook import * from salome_notebook import *
@ -83,6 +88,8 @@ import GEOM
import math import math
import os import os
from gsketcher import Sketcher3D
## Enumeration ShapeType as a dictionary. \n ## Enumeration ShapeType as a dictionary. \n
## Topological types of shapes (like Open Cascade types). See GEOM::shape_type for details. ## Topological types of shapes (like Open Cascade types). See GEOM::shape_type for details.
# @ingroup l1_geompy_auxiliary # @ingroup l1_geompy_auxiliary
@ -481,6 +488,7 @@ class geompyDC(GEOM._objref_GEOM_Gen):
# Example: see GEOM_TestAll.py # Example: see GEOM_TestAll.py
try: try:
aSObject = self.AddInStudy(self.myStudy, aShape, aName, None) aSObject = self.AddInStudy(self.myStudy, aShape, aName, None)
if aSObject and aName: aSObject.SetAttrString("AttributeName", aName)
if doRestoreSubShapes: if doRestoreSubShapes:
self.RestoreSubShapesSO(self.myStudy, aSObject, theArgs, self.RestoreSubShapesSO(self.myStudy, aSObject, theArgs,
theFindMethod, theInheritFirstArg, True ) theFindMethod, theInheritFirstArg, True )
@ -511,6 +519,7 @@ class geompyDC(GEOM._objref_GEOM_Gen):
# Example: see GEOM_TestAll.py # Example: see GEOM_TestAll.py
try: try:
aSObject = self.AddInStudy(self.myStudy, aShape, aName, aFather) aSObject = self.AddInStudy(self.myStudy, aShape, aName, aFather)
if aSObject and aName: aSObject.SetAttrString("AttributeName", aName)
except: except:
print "addToStudyInFather() failed" print "addToStudyInFather() failed"
return "" return ""
@ -813,7 +822,7 @@ class geompyDC(GEOM._objref_GEOM_Gen):
New GEOM.GEOM_Object, containing the created point. New GEOM.GEOM_Object, containing the created point.
Example of usage: Example of usage:
p_on_face = geompy.MakeVertexOnSurface(Face, 0.1, 0.8) #(GEOM_Object, Double, Double)->GEOM_Object p_on_face = geompy.MakeVertexOnSurface(Face, 0.1, 0.8)
""" """
theUParameter, theVParameter, Parameters = ParseParameters(theUParameter, theVParameter) theUParameter, theVParameter, Parameters = ParseParameters(theUParameter, theVParameter)
# Example: see GEOM_TestAll.py # Example: see GEOM_TestAll.py
@ -844,7 +853,7 @@ class geompyDC(GEOM._objref_GEOM_Gen):
New GEOM.GEOM_Object, containing the created point. New GEOM.GEOM_Object, containing the created point.
Example of usage: Example of usage:
p_on_face2 = geompy.MakeVertexOnSurfaceByCoord(Face, 0., 0., 0.) #(GEOM_Object, Double, Double, Double)->GEOM_Object p_on_face2 = geompy.MakeVertexOnSurfaceByCoord(Face, 0., 0., 0.)
""" """
theX, theY, theZ, Parameters = ParseParameters(theX, theY, theZ) theX, theY, theZ, Parameters = ParseParameters(theX, theY, theZ)
# Example: see GEOM_TestAll.py # Example: see GEOM_TestAll.py
@ -853,6 +862,37 @@ class geompyDC(GEOM._objref_GEOM_Gen):
anObj.SetParameters(Parameters); anObj.SetParameters(Parameters);
return anObj return anObj
## Create a point, which lays on the given face.
# The point will lay in arbitrary place of the face.
# The only condition on it is a non-zero distance to the face boundary.
# 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.
# @return New GEOM.GEOM_Object, containing the created point.
#
# @ref swig_MakeVertexInsideFace "Example"
def MakeVertexInsideFace (self, theFace):
"""
Create a point, which lays on the given face.
The point will lay in arbitrary place of the face.
The only condition on it is a non-zero distance to the face boundary.
Such point can be used to uniquely identify the face inside any
shape in case, when the shape does not contain overlapped faces.
Parameters:
theFace The referenced face.
Returns:
New GEOM.GEOM_Object, containing the created point.
Example of usage:
p_on_face = geompy.MakeVertexInsideFace(Face)
"""
# Example: see GEOM_TestAll.py
anObj = self.BasicOp.MakePointOnFace(theFace)
RaiseIfFailed("MakeVertexInsideFace", self.BasicOp)
return anObj
## Create a point on intersection of two lines. ## Create a point on intersection of two lines.
# @param theRefLine1, theRefLine2 The referenced lines. # @param theRefLine1, theRefLine2 The referenced lines.
# @return New GEOM.GEOM_Object, containing the created point. # @return New GEOM.GEOM_Object, containing the created point.
@ -891,7 +931,7 @@ class geompyDC(GEOM._objref_GEOM_Gen):
New GEOM.GEOM_Object, containing the created tangent. New GEOM.GEOM_Object, containing the created tangent.
Example of usage: Example of usage:
tan_on_arc = geompy.MakeTangentOnCurve(Arc, 0.7) #(GEOM_Object, Double)->GEOM_Object tan_on_arc = geompy.MakeTangentOnCurve(Arc, 0.7)
""" """
anObj = self.BasicOp.MakeTangentOnCurve(theRefCurve, theParameter) anObj = self.BasicOp.MakeTangentOnCurve(theRefCurve, theParameter)
RaiseIfFailed("MakeTangentOnCurve", self.BasicOp) RaiseIfFailed("MakeTangentOnCurve", self.BasicOp)
@ -1615,7 +1655,6 @@ class geompyDC(GEOM._objref_GEOM_Gen):
# - "C radius length" : Create arc by direction, radius and length(in degree) # - "C radius length" : Create arc by direction, radius and length(in degree)
# - "AA x y": Create arc by point at X & Y # - "AA x y": Create arc by point at X & Y
# - "A dx dy" : Create arc by point with DX & DY # - "A dx dy" : Create arc by point with DX & DY
# - "A dx dy" : Create arc by point with DX & DY
# - "UU x y radius flag1": Create arc by point at X & Y with given radiUs # - "UU x y radius flag1": Create arc by point at X & Y with given radiUs
# - "U dx dy radius flag1" : Create arc by point with DX & DY with given radiUs # - "U dx dy radius flag1" : Create arc by point with DX & DY with given radiUs
# - "EE x y xc yc flag1 flag2": Create arc by point at X & Y with given cEnter coordinates # - "EE x y xc yc flag1 flag2": Create arc by point at X & Y with given cEnter coordinates
@ -1665,7 +1704,6 @@ class geompyDC(GEOM._objref_GEOM_Gen):
- "C radius length" : Create arc by direction, radius and length(in degree) - "C radius length" : Create arc by direction, radius and length(in degree)
- "AA x y": Create arc by point at X & Y - "AA x y": Create arc by point at X & Y
- "A dx dy" : Create arc by point with DX & DY - "A dx dy" : Create arc by point with DX & DY
- "A dx dy" : Create arc by point with DX & DY
- "UU x y radius flag1": Create arc by point at X & Y with given radiUs - "UU x y radius flag1": Create arc by point at X & Y with given radiUs
- "U dx dy radius flag1" : Create arc by point with DX & DY with given radiUs - "U dx dy radius flag1" : Create arc by point with DX & DY with given radiUs
- "EE x y xc yc flag1 flag2": Create arc by point at X & Y with given cEnter coordinates - "EE x y xc yc flag1 flag2": Create arc by point at X & Y with given cEnter coordinates
@ -1722,8 +1760,10 @@ class geompyDC(GEOM._objref_GEOM_Gen):
Returns: Returns:
New GEOM.GEOM_Object, containing the created wire. New GEOM.GEOM_Object, containing the created wire.
""" """
theCommand,Parameters = ParseSketcherCommand(theCommand)
anObj = self.CurvesOp.MakeSketcherOnPlane(theCommand, theWorkingPlane) anObj = self.CurvesOp.MakeSketcherOnPlane(theCommand, theWorkingPlane)
RaiseIfFailed("MakeSketcherOnPlane", self.CurvesOp) RaiseIfFailed("MakeSketcherOnPlane", self.CurvesOp)
anObj.SetParameters(Parameters)
return anObj return anObj
## Create a sketcher wire, following the numerical description, ## Create a sketcher wire, following the numerical description,
@ -1732,7 +1772,7 @@ class geompyDC(GEOM._objref_GEOM_Gen):
# passing from it. # passing from it.
# @return New GEOM.GEOM_Object, containing the created wire. # @return New GEOM.GEOM_Object, containing the created wire.
# #
# @ref tui_sketcher_page "Example" # @ref tui_3dsketcher_page "Example"
def Make3DSketcher(self, theCoordinates): def Make3DSketcher(self, theCoordinates):
""" """
Create a sketcher wire, following the numerical description, Create a sketcher wire, following the numerical description,
@ -1751,6 +1791,26 @@ class geompyDC(GEOM._objref_GEOM_Gen):
anObj.SetParameters(Parameters) anObj.SetParameters(Parameters)
return anObj 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, 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
# end of l3_sketcher # end of l3_sketcher
## @} ## @}
@ -1954,7 +2014,7 @@ class geompyDC(GEOM._objref_GEOM_Gen):
New GEOM.GEOM_Object, containing the created disk. New GEOM.GEOM_Object, containing the created disk.
Example of usage: Example of usage:
Disk3 = geompy.MakeDiskR(100., 1) #(1 Doubles, 1 Int)->GEOM_Object Disk3 = geompy.MakeDiskR(100., 1)
""" """
# Example: see GEOM_TestAll.py # Example: see GEOM_TestAll.py
theR,Parameters = ParseParameters(theR) theR,Parameters = ParseParameters(theR)
@ -4063,7 +4123,7 @@ class geompyDC(GEOM._objref_GEOM_Gen):
List of sub-shapes of type theShapeType, contained in theShape. List of sub-shapes of type theShapeType, contained in theShape.
""" """
# Example: see GEOM_TestAll.py # Example: see GEOM_TestAll.py
ListObj = self.ShapesOp.MakeAllSubShapes(aShape, aType, False) ListObj = self.ShapesOp.MakeAllSubShapes(aShape, EnumToLong( aType ), False)
RaiseIfFailed("SubShapeAll", self.ShapesOp) RaiseIfFailed("SubShapeAll", self.ShapesOp)
return ListObj return ListObj
@ -4084,7 +4144,7 @@ class geompyDC(GEOM._objref_GEOM_Gen):
Returns: Returns:
List of IDs of sub-shapes. List of IDs of sub-shapes.
""" """
ListObj = self.ShapesOp.GetAllSubShapesIDs(aShape, aType, False) ListObj = self.ShapesOp.GetAllSubShapesIDs(aShape, EnumToLong( aType ), False)
RaiseIfFailed("SubShapeAllIDs", self.ShapesOp) RaiseIfFailed("SubShapeAllIDs", self.ShapesOp)
return ListObj return ListObj
@ -4113,7 +4173,7 @@ class geompyDC(GEOM._objref_GEOM_Gen):
""" """
# Example: see GEOM_TestAll.py # Example: see GEOM_TestAll.py
ListOfIDs = [] ListOfIDs = []
AllShapeIDsList = self.SubShapeAllIDs(aShape, aType) AllShapeIDsList = self.SubShapeAllIDs(aShape, EnumToLong( aType ))
for ind in ListOfInd: for ind in ListOfInd:
ListOfIDs.append(AllShapeIDsList[ind - 1]) ListOfIDs.append(AllShapeIDsList[ind - 1])
anObj = self.GetSubShape(aShape, ListOfIDs) anObj = self.GetSubShape(aShape, ListOfIDs)
@ -4141,7 +4201,7 @@ class geompyDC(GEOM._objref_GEOM_Gen):
List of sub-shapes of type theShapeType, contained in theShape. List of sub-shapes of type theShapeType, contained in theShape.
""" """
# Example: see GEOM_TestAll.py # Example: see GEOM_TestAll.py
ListObj = self.ShapesOp.MakeAllSubShapes(aShape, aType, True) ListObj = self.ShapesOp.MakeAllSubShapes(aShape, EnumToLong( aType ), True)
RaiseIfFailed("SubShapeAllSortedCentres", self.ShapesOp) RaiseIfFailed("SubShapeAllSortedCentres", self.ShapesOp)
return ListObj return ListObj
@ -4164,7 +4224,7 @@ class geompyDC(GEOM._objref_GEOM_Gen):
Returns: Returns:
List of IDs of sub-shapes. List of IDs of sub-shapes.
""" """
ListIDs = self.ShapesOp.GetAllSubShapesIDs(aShape, aType, True) ListIDs = self.ShapesOp.GetAllSubShapesIDs(aShape, EnumToLong( aType ), True)
RaiseIfFailed("SubShapeAllIDs", self.ShapesOp) RaiseIfFailed("SubShapeAllIDs", self.ShapesOp)
return ListIDs return ListIDs
@ -4193,7 +4253,7 @@ class geompyDC(GEOM._objref_GEOM_Gen):
""" """
# Example: see GEOM_TestAll.py # Example: see GEOM_TestAll.py
ListOfIDs = [] ListOfIDs = []
AllShapeIDsList = self.SubShapeAllSortedCentresIDs(aShape, aType) AllShapeIDsList = self.SubShapeAllSortedCentresIDs(aShape, EnumToLong( aType ))
for ind in ListOfInd: for ind in ListOfInd:
ListOfIDs.append(AllShapeIDsList[ind - 1]) ListOfIDs.append(AllShapeIDsList[ind - 1])
anObj = self.GetSubShape(aShape, ListOfIDs) anObj = self.GetSubShape(aShape, ListOfIDs)
@ -4219,7 +4279,7 @@ class geompyDC(GEOM._objref_GEOM_Gen):
List of sub-shapes of type aType, contained in aShape. List of sub-shapes of type aType, contained in aShape.
""" """
# Example: see GEOM_TestAll.py # Example: see GEOM_TestAll.py
ListObj = self.ShapesOp.ExtractSubShapes(aShape, aType, isSorted) ListObj = self.ShapesOp.ExtractSubShapes(aShape, EnumToLong( aType ), isSorted)
RaiseIfFailed("ExtractSubShapes", self.ShapesOp) RaiseIfFailed("ExtractSubShapes", self.ShapesOp)
return ListObj return ListObj
@ -4260,7 +4320,7 @@ class geompyDC(GEOM._objref_GEOM_Gen):
It works like geompy.SubShapeAllSortedCentres, but wrongly It works like geompy.SubShapeAllSortedCentres, but wrongly
defines centres of faces, shells and solids. defines centres of faces, shells and solids.
""" """
ListObj = self.ShapesOp.MakeExplode(aShape, aType, True) ListObj = self.ShapesOp.MakeExplode(aShape, EnumToLong( aType ), True)
RaiseIfFailed("MakeExplode", self.ShapesOp) RaiseIfFailed("MakeExplode", self.ShapesOp)
return ListObj return ListObj
@ -4273,7 +4333,7 @@ class geompyDC(GEOM._objref_GEOM_Gen):
It works like geompy.SubShapeAllSortedCentresIDs, but wrongly It works like geompy.SubShapeAllSortedCentresIDs, but wrongly
defines centres of faces, shells and solids. defines centres of faces, shells and solids.
""" """
ListIDs = self.ShapesOp.SubShapeAllIDs(aShape, aType, True) ListIDs = self.ShapesOp.SubShapeAllIDs(aShape, EnumToLong( aType ), True)
RaiseIfFailed("SubShapeAllIDs", self.ShapesOp) RaiseIfFailed("SubShapeAllIDs", self.ShapesOp)
return ListIDs return ListIDs
@ -4287,7 +4347,7 @@ class geompyDC(GEOM._objref_GEOM_Gen):
(wrongly defines centres of faces, shells and solids). (wrongly defines centres of faces, shells and solids).
""" """
ListOfIDs = [] ListOfIDs = []
AllShapeIDsList = self.SubShapeAllSortedIDs(aShape, aType) AllShapeIDsList = self.SubShapeAllSortedIDs(aShape, EnumToLong( aType ))
for ind in ListOfInd: for ind in ListOfInd:
ListOfIDs.append(AllShapeIDsList[ind - 1]) ListOfIDs.append(AllShapeIDsList[ind - 1])
anObj = self.GetSubShape(aShape, ListOfIDs) anObj = self.GetSubShape(aShape, ListOfIDs)
@ -7280,6 +7340,31 @@ class geompyDC(GEOM._objref_GEOM_Gen):
# Example: see GEOM_TestOthers.py # Example: see GEOM_TestOthers.py
return self.ImportFile(theFileName, "STEP") return self.ImportFile(theFileName, "STEP")
## Read a shape from the binary stream, containing its bounding representation (BRep).
# @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.
# @return New GEOM_Object, containing the shape, read from theStream.
#
# @ref swig_Import_Export "Example"
def RestoreShape (self, theStream):
"""
Read a shape from the binary stream, containing its bounding representation (BRep).
Note:
shape.GetShapeStream() method can be used to obtain the shape's BRep stream.
Parameters:
theStream The BRep binary stream.
Returns:
New GEOM_Object, containing the shape, read from theStream.
"""
# Example: see GEOM_TestOthers.py
anObj = self.InsertOp.RestoreShape(theStream)
RaiseIfFailed("RestoreShape", self.InsertOp)
return anObj
## Export the given shape into a file with given name. ## Export the given shape into a file with given name.
# @param theObject Shape to be stored in the file. # @param theObject Shape to be stored in the file.
# @param theFileName Name of the file to store the given shape in. # @param theFileName Name of the file to store the given shape in.
@ -7774,6 +7859,36 @@ class geompyDC(GEOM._objref_GEOM_Gen):
print Descr print Descr
return IsValid return IsValid
## Retrieve all non blocks solids and faces from \a theShape.
# @param theShape The shape to explore.
# @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
# group of all non quadrangular faces.
#
# @ref tui_measurement_tools_page "Example 1"
# \n @ref swig_GetNonBlocks "Example 2"
def GetNonBlocks (self, theShape):
"""
Retrieve all non blocks solids and faces from theShape.
Parameters:
theShape The shape to explore.
Returns:
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
group of all non quadrangular faces.
Usage:
(res_sols, res_faces) = geompy.GetNonBlocks(myShape1)
"""
# Example: see GEOM_Spanner.py
aTuple = self.BlocksOp.GetNonBlocks(theShape)
RaiseIfFailed("GetNonBlocks", self.BlocksOp)
return aTuple
## Remove all seam and degenerated edges from \a theShape. ## Remove all seam and degenerated edges from \a theShape.
# Unite faces and edges, sharing one surface. It means that # Unite faces and edges, sharing one surface. It means that
# this faces must have references to one C++ surface object (handle). # this faces must have references to one C++ surface object (handle).
@ -8180,6 +8295,156 @@ class geompyDC(GEOM._objref_GEOM_Gen):
RaiseIfFailed("DifferenceIDs", self.GroupOp) RaiseIfFailed("DifferenceIDs", self.GroupOp)
pass pass
## Union of two groups.
# New group is created. It will contain all entities
# which are present in groups theGroup1 and theGroup2.
# @param theGroup1, theGroup2 are the initial GEOM groups
# to create the united group from.
# @return a newly created GEOM group.
# @ref tui_union_groups_anchor "Example"
def UnionGroups (self, theGroup1, theGroup2):
"""
Union of two groups.
New group is created. It will contain all entities
which are present in groups theGroup1 and theGroup2.
Parameters:
theGroup1, theGroup2 are the initial GEOM groups
to create the united group from.
Returns:
a newly created GEOM group.
"""
# Example: see GEOM_TestOthers.py
aGroup = self.GroupOp.UnionGroups(theGroup1, theGroup2)
RaiseIfFailed("UnionGroups", self.GroupOp)
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.
# @return a newly created GEOM group.
# @ref tui_intersect_groups_anchor "Example"
def IntersectGroups (self, theGroup1, theGroup2):
"""
Intersection of two groups.
New group is created. It will contain only those entities
which are present in both groups theGroup1 and theGroup2.
Parameters:
theGroup1, theGroup2 are the initial GEOM groups to get common part of.
Returns:
a newly created GEOM group.
"""
# Example: see GEOM_TestOthers.py
aGroup = self.GroupOp.IntersectGroups(theGroup1, theGroup2)
RaiseIfFailed("IntersectGroups", self.GroupOp)
return aGroup
## Cut of two groups.
# New group is created. It will contain entities which are
# 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.
# @return a newly created GEOM group.
# @ref tui_cut_groups_anchor "Example"
def CutGroups (self, theGroup1, theGroup2):
"""
Cut of two groups.
New group is created. It will contain entities which are
present in group theGroup1 but are not present in group theGroup2.
Parameters:
theGroup1 is a GEOM group to include elements of.
theGroup2 is a GEOM group to exclude elements of.
Returns:
a newly created GEOM group.
"""
# Example: see GEOM_TestOthers.py
aGroup = self.GroupOp.CutGroups(theGroup1, theGroup2)
RaiseIfFailed("CutGroups", self.GroupOp)
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.
# @return a newly created GEOM group.
# @ref tui_union_groups_anchor "Example"
def UnionListOfGroups (self, theGList):
"""
Union of list of groups.
New group is created. It will contain all entities that are
present in groups listed in theGList.
Parameters:
theGList is a list of GEOM groups to create the united group from.
Returns:
a newly created GEOM group.
"""
# Example: see GEOM_TestOthers.py
aGroup = self.GroupOp.UnionListOfGroups(theGList)
RaiseIfFailed("UnionListOfGroups", self.GroupOp)
return aGroup
## Cut of lists of groups.
# New group is created. It will contain only entities
# which are present in groups listed in theGList1 but
# 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.
# @return a newly created GEOM group.
# @ref tui_intersect_groups_anchor "Example"
def IntersectListOfGroups (self, theGList):
"""
Cut of lists of groups.
New group is created. It will contain only entities
which are present in groups listed in theGList1 but
are not present in groups from theGList2.
Parameters:
theGList1 is a list of GEOM groups to include elements of.
theGList2 is a list of GEOM groups to exclude elements of.
Returns:
a newly created GEOM group.
"""
# Example: see GEOM_TestOthers.py
aGroup = self.GroupOp.IntersectListOfGroups(theGList)
RaiseIfFailed("IntersectListOfGroups", self.GroupOp)
return aGroup
## Cut of lists of groups.
# New group is created. It will contain only entities
# which are present in groups listed in theGList1 but
# 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.
# @return a newly created GEOM group.
# @ref tui_cut_groups_anchor "Example"
def CutListOfGroups (self, theGList1, theGList2):
"""
Cut of lists of groups.
New group is created. It will contain only entities
which are present in groups listed in theGList1 but
are not present in groups from theGList2.
Parameters:
theGList1 is a list of GEOM groups to include elements of.
theGList2 is a list of GEOM groups to exclude elements of.
Returns:
a newly created GEOM group.
"""
# Example: see GEOM_TestOthers.py
aGroup = self.GroupOp.CutListOfGroups(theGList1, theGList2)
RaiseIfFailed("CutListOfGroups", self.GroupOp)
return aGroup
## Returns a list of sub-objects ID stored in the group ## Returns a list of sub-objects ID stored in the group
# @param theGroup is a GEOM group for which a list of IDs is requested # @param theGroup is a GEOM group for which a list of IDs is requested
# #

182
src/GEOM_SWIG/gsketcher.py Normal file
View 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

View File

@ -17,14 +17,6 @@
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
# #
# GEOM GEOM_SWIG : binding of C++ omplementaion with Python
# File : Makefile.in
# Author : Nicolas REJNERI, Paul RASCLE
# Modified by : Alexander BORODIN (OCN) - autotools usage
# Module : GEOM
# $Header$
# Libraries targets
#
include $(top_srcdir)/adm_local/unix/make_common_starter.am include $(top_srcdir)/adm_local/unix/make_common_starter.am
# =============================================================== # ===============================================================
@ -40,28 +32,24 @@ include $(top_srcdir)/adm_local/unix/make_common_starter.am
# Step 2: build the dynamic library from cpp built source files and # Step 2: build the dynamic library from cpp built source files and
# dependant libraries. # dependant libraries.
# #
# swig_wrap.cpp -- gcc --> swig_wrap.o |-- link --> _libSALOME_Swig.la # swig_wrap.cpp -- gcc --> swig_wrap.o |-- link --> _libGEOM_Swig.la
# + | # + |
# dependant libs | # dependant libs |
# #
# The file libGEOM_Swig.py will be installed to the # The files libGEOM_Swig.py and _libGEOM_Swig.so will be installed to the
# <prefix>/bin/salome directory.
# The library _libGEOM_Swig.so will be installed to the
# <prefix>/lib/python<version>/site-package/salome directory. # <prefix>/lib/python<version>/site-package/salome directory.
# #
SWIG_FLAGS = @SWIG_FLAGS@ -I$(srcdir) -I$(srcdir)/../GEOMGUI SWIG_FLAGS = @SWIG_FLAGS@ -I$(srcdir) -I$(srcdir)/../GEOMGUI
SWIG_SOURCES = libGEOM_Swig.i SWIG_SOURCES = libGEOM_Swig.i
salomeinclude_HEADERS = $(SWIG_SOURCES) libGEOM_Swig.h
salomepython_PYTHON = libGEOM_Swig.py salomepython_PYTHON = libGEOM_Swig.py
salomepyexec_LTLIBRARIES = _libGEOM_Swig.la salomepyexec_LTLIBRARIES = _libGEOM_Swig.la
libGEOM_Swig.py: swig_wrap.cpp _libGEOM_Swig_la_SOURCES = $(SWIG_SOURCES) libGEOM_Swig.h libGEOM_Swig.cxx
BUILT_SOURCES = swig_wrap.cpp nodist__libGEOM_Swig_la_SOURCES = swig_wrap.cpp
_libGEOM_Swig_la_SOURCES = $(SWIG_SOURCES)
nodist__libGEOM_Swig_la_SOURCES = $(BUILT_SOURCES)
salomeinclude_HEADERS = $(SWIG_SOURCES)
_libGEOM_Swig_la_CPPFLAGS = \ _libGEOM_Swig_la_CPPFLAGS = \
$(QT_INCLUDES) \ $(QT_INCLUDES) \
@ -73,16 +61,23 @@ _libGEOM_Swig_la_CPPFLAGS = \
$(GUI_CXXFLAGS) \ $(GUI_CXXFLAGS) \
$(CORBA_CXXFLAGS) \ $(CORBA_CXXFLAGS) \
$(CORBA_INCLUDES) \ $(CORBA_INCLUDES) \
$(BOOST_CPPFLAGS) \
-I$(srcdir)/../GEOMClient \
-I$(srcdir)/../OBJECT \
-I$(srcdir)/../GEOMGUI \ -I$(srcdir)/../GEOMGUI \
-I$(srcdir)/../GEOMToolsGUI \
-I$(top_builddir)/idl -I$(top_builddir)/idl
_libGEOM_Swig_la_LDFLAGS = -module _libGEOM_Swig_la_LDFLAGS = -module
_libGEOM_Swig_la_LIBADD = \ _libGEOM_Swig_la_LIBADD = \
../GEOMGUI/libGEOM.la \ ../GEOMGUI/libGEOM.la \
../GEOMToolsGUI/libGEOMToolsGUI.la \
$(PYTHON_LIBS) $(PYTHON_LIBS)
swig_wrap.cpp : $(SWIG_SOURCES) swig_wrap.cpp : $(SWIG_SOURCES)
$(SWIG) $(SWIG_FLAGS) -o $@ $< $(SWIG) $(SWIG_FLAGS) -o $@ $<
libGEOM_Swig.py: swig_wrap.cpp
CLEANFILES = swig_wrap.cpp libGEOM_Swig.py CLEANFILES = swig_wrap.cpp libGEOM_Swig.py

View File

@ -21,12 +21,13 @@
// //
// GEOM GEOMGUI : GUI for Geometry component // GEOM GEOMGUI : GUI for Geometry component
// File : GeometryGUI_Swig.cxx // File : libGEOM_Swig.cxx
// Author : Nicolas REJNERI, Paul RASCLE // Author : Nicolas REJNERI, Paul RASCLE
// //
#include "GeometryGUI_Swig.hxx" #include "libGEOM_Swig.h"
#include "GeometryGUI.h" #include "GeometryGUI.h"
#include "GEOMToolsGUI.h"
#include "SUIT_Desktop.h" #include "SUIT_Desktop.h"
#include "SUIT_Session.h" #include "SUIT_Session.h"
@ -51,6 +52,7 @@
#include "GEOM_AISShape.hxx" #include "GEOM_AISShape.hxx"
#include "GEOM_InteractiveObject.hxx" #include "GEOM_InteractiveObject.hxx"
#include "GEOM_Displayer.h" #include "GEOM_Displayer.h"
#include "GEOM_Constants.h"
#include "SALOME_Event.h" #include "SALOME_Event.h"
@ -60,6 +62,7 @@
#include <AIS_ListOfInteractive.hxx> #include <AIS_ListOfInteractive.hxx>
#include <AIS_ListIteratorOfListOfInteractive.hxx> #include <AIS_ListIteratorOfListOfInteractive.hxx>
#include <AIS_Drawer.hxx> #include <AIS_Drawer.hxx>
#include <Prs3d_IsoAspect.hxx>
#include <BRepTools.hxx> #include <BRepTools.hxx>
// IDL Headers // IDL Headers
@ -448,7 +451,7 @@ void GEOM_Swig::setVectorsMode(const char* theEntry, bool isOn, bool isUpdated)
void GEOM_Swig::setColor(const char* theEntry, int red, int green, int blue, bool isUpdated) void GEOM_Swig::setColor(const char* theEntry, int red, int green, int blue, bool isUpdated)
{ {
class TEvent: public SALOME_Event { class TEvent: public SALOME_Event {
std::string myEntry; QString myEntry;
int myRed; int myRed;
int myGreen; int myGreen;
int myBlue; int myBlue;
@ -460,44 +463,82 @@ void GEOM_Swig::setColor(const char* theEntry, int red, int green, int blue, boo
virtual void Execute() { virtual void Execute() {
SUIT_Application* anApp = SUIT_Session::session()->activeApplication(); SUIT_Application* anApp = SUIT_Session::session()->activeApplication();
if (!anApp) return; if (!anApp) return;
GEOMToolsGUI::SetColor( myEntry, QColor( myRed, myGreen, myBlue), myUpdateViewer );
}
};
ProcessVoidEvent(new TEvent(theEntry, red, green, blue, isUpdated));
}
void GEOM_Swig::setIsos(const char* Entry, int nbU, int nbV, bool isUpdated )
{
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<SalomeApp_Study*>(app->activeStudy());
if (!study) return;
Handle(SALOME_InteractiveObject) anIO = Handle(SALOME_InteractiveObject) anIO =
new SALOME_InteractiveObject(myEntry.c_str(), "GEOM", ""); new SALOME_InteractiveObject(myEntry.c_str(), "GEOM", "");
if (SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(anApp)){ if (SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(app)) {
SVTK_View* aView = aViewWindow->getView(); SVTK_Viewer* aView = dynamic_cast<SVTK_Viewer*>(aViewWindow->getViewManager()->getViewModel());
QColor aColor (myRed, myGreen, myBlue); SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>( aView->CreatePrs( myEntry.c_str() ) );
aView->SetColor(anIO, aColor); 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) if (myUpdateViewer)
aView->Repaint(); aView->Repaint();
} else if (OCCViewer_Viewer* occViewer = GetOCCViewer(anApp)) { }
else if (OCCViewer_Viewer* occViewer = GetOCCViewer(app)) {
Handle(AIS_InteractiveContext) ic = occViewer->getAISContext(); Handle(AIS_InteractiveContext) ic = occViewer->getAISContext();
SOCC_Viewer* soccViewer = dynamic_cast<SOCC_Viewer*>(occViewer); SOCC_Viewer* soccViewer = dynamic_cast<SOCC_Viewer*>(occViewer);
if (soccViewer) if (soccViewer) {
{ int aMgrId = soccViewer->getViewManager()->getGlobalId();
SALOME_Prs* prs= soccViewer->CreatePrs( myEntry.c_str() ); SOCC_Prs* occPrs = dynamic_cast<SOCC_Prs*>( soccViewer->CreatePrs( myEntry.c_str() ) );
const SOCC_Prs* anOCCPrs = dynamic_cast<const SOCC_Prs*>( prs ); if ( occPrs && !occPrs->IsNull() ) {
if ( !anOCCPrs || anOCCPrs->IsNull() ) AIS_ListOfInteractive shapes; occPrs->GetObjects( shapes );
return; AIS_ListIteratorOfListOfInteractive interIter( shapes );
for ( ; interIter.More(); interIter.Next() ) {
// get objects to be displayed Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast( interIter.Value() );
AIS_ListOfInteractive anAISObjects; if ( !aSh.IsNull() ) {
anOCCPrs->GetObjects( anAISObjects ); Handle(AIS_Drawer) drawer = aSh->Attributes();
AIS_ListIteratorOfListOfInteractive ite( anAISObjects ); QVariant v = study->getObjectProperty( aMgrId, myEntry.c_str(), EDGE_WIDTH_PROP, QVariant() );
Quantity_Color CSFColor = Quantity_Color(myRed/255., myGreen/255., myBlue/255., Quantity_TOC_RGB); int width = v.isValid() ? v.toInt() : 1;
for ( ; ite.More(); ite.Next() ) 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) );
if(!ic->IsDisplayed(ite.Value()))continue; //only displayed ais aSh->storeIsoNumbers();
ite.Value()->SetColor(CSFColor); ic->SetLocalAttributes(aSh, drawer);
if (ite.Value()->IsKind(STANDARD_TYPE(GEOM_AISShape))) Handle(GEOM_AISShape)::DownCast(ite.Value())->SetShadingColor(CSFColor); ic->Redisplay(aSh);
ite.Value()->Redisplay(Standard_True); // as in OnColor QString anIsos = QString("%1%2%3").arg(myNbU).arg(DIGIT_SEPARATOR).arg(myNbV);
study->setObjectProperty(aMgrId, myEntry.c_str(), ISOS_PROP, anIsos);
}
}
} }
if (myUpdateViewer) occViewer->update();
} }
} }
} }
}; };
ProcessVoidEvent(new TEvent(theEntry, red, green, blue, isUpdated));
ProcessVoidEvent(new TEvent (Entry, nbU, nbV, isUpdated));
} }
void GEOM_Swig::setTransparency(const char* theEntry, float transp, bool isUpdated) void GEOM_Swig::setTransparency(const char* theEntry, float transp, bool isUpdated)

View File

@ -21,9 +21,10 @@
// //
// GEOM GEOMGUI : GUI for Geometry component // GEOM GEOMGUI : GUI for Geometry component
// File : GeometryGUI_Swig.hxx // File : libGEOM_Swig.h
// Author : Nicolas REJNERI, Paul RASCLE // Author : Nicolas REJNERI, Paul RASCLE
// //
#ifndef GEOMETRYGUI_SWIG_HXX #ifndef GEOMETRYGUI_SWIG_HXX
#define GEOMETRYGUI_SWIG_HXX #define GEOMETRYGUI_SWIG_HXX
@ -49,6 +50,7 @@ public:
void setVectorsMode(const char* Entry, bool isSet, 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 setColor(const char* Entry, int red, int green, int blue, bool isUpdated = true);
void setTransparency(const char* Entry, float transp, 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); void setDeflection(const char* Entry, float deflect);
int getIndexTopology(const char *SubEntry, const char *Entry); int getIndexTopology(const char *SubEntry, const char *Entry);

View File

@ -26,5 +26,51 @@
// //
%module libGEOM_Swig %module libGEOM_Swig
%include "GeometryGUI_Swig.i" %{
#include "libGEOM_Swig.h"
%}
/*
managing C++ exception in the Python API
*/
%exception
{
class PyAllowThreadsGuard {
public:
// Py_BEGIN_ALLOW_THREADS
PyAllowThreadsGuard() { _save = PyEval_SaveThread(); }
// Py_END_ALLOW_THREADS
~PyAllowThreadsGuard() { PyEval_RestoreThread(_save); }
private:
PyThreadState *_save;
};
PyAllowThreadsGuard guard;
$action
}
class 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 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);
bool initGeomGen();
};

Some files were not shown because too many files have changed in this diff Show More