#---------------------------------------------------------------------------
#Input related options
#---------------------------------------------------------------------------
-INPUT = . @top_srcdir@/idl
-FILE_PATTERNS = geompy.py GEOM_Gen.idl
+INPUT = geompy.py @top_srcdir@/src/GEOM_SWIG/gsketcher.py @top_srcdir@/idl/GEOM_Gen.idl
+FILE_PATTERNS =
IMAGE_PATH = @srcdir@/images
EXAMPLE_PATH = @top_srcdir@/src/GEOM_SWIG
RECURSIVE = NO
\page create_3dsketcher_page 3D Sketcher
-3D Sketcher allows creating a closed or unclosed 3D wire from a list of points.
+3D Sketcher allows creating a closed or unclosed 3D wire, made of
+consequent straight segments.
To create a 3D Sketch, select in the main menu <em>New Entity -> Basic -> 3D Sketch</em>.
\image html 3dsketch2.png
-In this dialog it is possible to define the coordinates of the points.
+The first sketcher point can be defined by \b Absolute coordinates X, Y and Z.
+When the first point is defined, it is possible to add straight segments.
+Each segment will start at the end point of previous segment or at the
+sketcher first point, if there are no validated segments.
-The position of each point can be defined by \b Absolute coordinates X, Y, Z or
-by \b Relative coordinates DX, DY, DZ with respect to the previous Applied point.
-The type of coordinates can be selected by the <b>Coordinates Type</b>
+Segment can be defined by:
+ - \b Absolute coordinates X, Y and Z of its second end,
+ - \b Relative coordinates DX, DY and DZ of its second end with
+ respect to the previous applied point,
+ - \b Direction and \b Length of the segment. Direction is set by two
+ \b Angles in selected coordinate system.
+
+The way of segment construction can be selected by the <b>Coordinates Type</b>
radio buttons.
-To add the point in the list of points and to proceed with the
-definition of the next point, click <b>Apply</b> button. \b Undo and
-\b Redo buttons, respectively, remove or restore the last point in the list.
+To validate the segment and to proceed with the definition of the next
+segment, click <b>Apply</b> button. \b Undo and \b Redo buttons,
+respectively, remove or restore the last segment in the wire.
\n <b>"Sketch Validation"</b> button applies the wire, built by the
user, "as is".
\n <b>"Sketch Closure"</b> closes the Sketch by a straight line from
the start to the end point and applies it.
-To make a closed wire using the TUI command, the first and the last point should
-have the same coordinates.
-
-The Result of the operation will be a \b GEOM_Object.
-
-<b>TUI Command:</b> <em>geompy.Make3DSketcher( [ PointsList ] )</em>
-This algorithm creates a wire from the list of real values, which define XYZ
-coordinates of points.
-
<b>Example:</b>
\image html 3dsketch1.png
+<b>TUI Command:</b> <em>geompy.Make3DSketcher( [ PointsList ] )</em>
+This algorithm creates a wire from the list of real values, which
+define absolute XYZ coordinates of points. The Result of the operation
+will be a \b GEOM_Object.
+
+\note To make a closed wire using this TUI command, the first and the
+last point should have the same coordinates.
+
+\n Another way to create the 3D Sketcher in TUI is using Sketcher3D
+interface.
+<b>TUI Command:</b> <em>sk = geompy.Sketcher3D()</em>
+Returns an instance of Sketcher3D interface <i>sk</i>.
+Use the below examples and see the \ref gsketcher.Sketcher3D "Sketcher3D"
+interface documentation for more information.
+
Our <b>TUI Scripts</b> provide you with useful examples of the use of
\ref tui_3dsketcher_page "3D Sketcher".
*/
\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
box and press "Apply" or "Apply & Close" button.
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 R - Radius of the cylinder
- \b H - Height of the cylinder
+- \b Pattern - Division pattern
\image html dividedcylinder_dlg.png
\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
-(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:
\n For both operations :
Specify the parameters of the DividedDisk object creation in the opened dialog
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
-<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 Radius - Radius of the disk
- \b Orientation - Plane on wich the disk will be built
+- \b Pattern - Division pattern
\image html divided_disk_dlg.png
\n Second way : by giving its center, normal and radius.
<b>TUI Command:</b> <em>geompy.MakeDividedDiskPntVecR(Center, Vector,
-Radius)</em>
+Radius, Pattern)</em>
<b>Arguments:</b>
- \b Center - Center of the disk
- \b Vector - Normal to the plane of the disk
- \b Radius - Radius of the disk
+- \b Pattern - Division pattern
\image html divided_disk_PntVecR_dlg.png
\image html point5.png
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
to project point on the given face.
--- /dev/null
+/*!
+
+\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".
+
+*/
import salome
gg = salome.ImportComponentGUI("GEOM")
-# create a 3D sketcher (wire) of the given points coordinates
+# Create a 3D sketcher (wire) on the given points coordinates
sketcher1 = geompy.Make3DSketcher([ 0,0,0, 50,50,50, 0,50,0, 50,0,50, 10,20,100, 0,0,0 ])
# add object in the study
-id_sketcher1 = geompy.addToStudy(sketcher1,"Sketcher1")
+id_sketcher1 = geompy.addToStudy(sketcher1, "Sketcher1")
# display the sketcher
gg.createAndDisplayGO(id_sketcher1)
+
+# Create a 3D sketcher (wire) with Sketcher3D interface
+
+# get the interface instance
+sk = geompy.Sketcher3D()
+
+# add three points with absolute coordinates
+# the first point will be the start point of sketcher
+# two segments will be added by this command
+sk.addPointsAbsolute(1,2,3, 7,0,0, 10,-3.5,-11)
+
+# add one segment, defined by two angles in "OXY" coordinate system and length
+sk.addPointAnglesLength("OXY", 45, 0, 100)
+
+# add three points with relative coordinates
+# three segments will be added by this command
+sk.addPointsRelative(20,0,0, 20,0,100, -40,0,-50)
+
+# set to close the sketcher
+sk.close()
+
+# obtain the sketcher result
+sketcher2 = sk.wire()
+
+# add object in the study
+id_sketcher2 = geompy.addToStudy(sketcher2, "Sketcher2")
+
+# display the sketcher
+gg.createAndDisplayGO(id_sketcher2)
\endcode
-*/
\ No newline at end of file
+*/
arc_face = geompy.MakeFaceWires([Arc, Add_line], 1)
p_on_face1 = geompy.MakeVertexOnSurface(arc_face, 0.5, 0.5)
p_on_face2 = geompy.MakeVertexOnSurfaceByCoord(arc_face, 35, 35, 35)
+p_on_face3 = geompy.MakeVertexInsideFace(arc_face)
# add objects in the study
id_p_inter = geompy.addToStudy(p_inter, "Vertex on Lines Intersection")
id_p_on_face1 = geompy.addToStudy(p_on_face1, "Vertex on face by parameter")
id_p_on_face2 = geompy.addToStudy(p_on_face2, "Vertex on face by point projection")
+id_p_on_face3 = geompy.addToStudy(p_on_face3, "Vertex inside face")
# display vertices
gg.createAndDisplayGO(id_p0)
--- /dev/null
+/*!
+
+\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
+
+*/
<li>\subpage tui_free_faces_page</li>
<li>\subpage tui_check_shape_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>
</ul>
\anchor swig_MakeVertexOnSurfaceByCoord
\until p_on_face2
+\anchor swig_MakeVertexInsideFace
+\until p_on_face3
+
\until S = geompy.MakeRotation
\anchor swig_MakeLineTwoFaces
\anchor swig_UnionIDs
\until print " ", ObjectID
+\anchor swig_bop_on_groups
+\until Box, Group_CL_2_4
+
\anchor swig_GetType
\until Type of elements
\anchor swig_GetOppositeFace
\until id_face41
+\until id_glueALL
+
+\anchor swig_GetNonBlocks
+\until Spanner is a
+
\anchor spanner_continue
\until return Spanner
\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
import geompy
salome.sg.updateObjBrowser(1)
\endcode
+\anchor tui_edit_groups_anchor
+
<br><h2>Adding an object to the group</h2>
\code
salome.sg.updateObjBrowser(1)
\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
+
*/
<li>\subpage free_faces_page "Check Free Faces"</li>
<li>\subpage check_shape_page "Check Shape"</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>
</ul>
\ref tui_measurement_tools_page "Measurement Tools" with <b>TUI
commands</b>.
-*/
\ No newline at end of file
+*/
<li><b>Select Only</b> provides a filter for exclusive selection of objects of a certain type.</li>
</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:
\image html ob_popup_menu.png <br>
<ul>
<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
child objects. When some child objects are hidden, the name of the
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
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.
\page work_with_groups_page Working with groups
Creation and editing groups of sub-shapes of a geometrical object makes
-handling sub-shapes much easier. This functionality is available in OCC
-viewer only.
+handling sub-shapes much easier. Also some Boolean operations on
+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
+This functionality is available in OCC viewer only.
+
To create a group of sub-shapes of a geometrical object in the main
menu select <b>New entity > Group > Create</b>
\n The following menu will appear:
created, ShapeType is a type of shapes in the created group.
\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>
\image html image193.png "Groups on a cylinder"
-
-<br><h2>Edit a group</h2>
+<br>
+\anchor edit_groups_anchor
+<h2>Edit a group</h2>
\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 >
Group > Edit</b>. This menu is designed in the same way as the
<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 <b>TUI Command:</b>
\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
-\ref tui_working_with_groups_page "Working with Groups".
+\ref tui_cut_groups_anchor "Cut of Groups" operation.
*/
// # 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();
in double theYParameter,
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.
string PrintBCErrors (in GEOM_Object theCompound,
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 Create a sketcher (wire or face), following the textual description,
- * 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
- * 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...]]"
*
* coordinates of the working plane.
* \param theWorkingPlane Nine double values, defining origin,
* OZ and OX directions of the working plane.
- * \return New GEOM_Object, containing the created wire.
+ * \return New GEOM_Object, containing the created wire or face.
*/
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.
+ * \brief Create a sketcher (wire or face), following the textual description,
+ * passed through \a theCommand argument.
*
- * Format of the description string have to be the following:
+ * For format of the description string see the previous method.\n
*
- * "Make3DSketcher[x1, y1, z1, x2, y2, z2, ..., xN, yN, zN]"
+ * \param theCommand String, defining the sketcher in local
+ * coordinates of the working plane.
+ * \param theWorkingPlane Planar Face or LCS(Marker) of the working plane.
+ * \return New GEOM_Object, containing the created wire or face.
*/
+ GEOM_Object MakeSketcherOnPlane (in string theCommand, in GEOM_Object theWorkingPlane);
- GEOM_Object Make3DSketcher (in ListOfDouble theCoordinates);
-
- /*!
- * \brief Create a sketcher (wire or face), following the textual description,
- * passed through \a theCommand argument.
+ /*!
+ * \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)
*
- * For format of the description string see the previous method.\n
* \param theCommand String, defining the sketcher in local
* coordinates of the working plane.
- * \param theWorkingPlane Planar Face or LCS(Marker) of the working plane.
* \return New GEOM_Object, containing the created wire.
*/
- GEOM_Object MakeSketcherOnPlane (in string theCommand, in GEOM_Object theWorkingPlane);
+ 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_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.
* \param theFormats Output. List of formats, available for import.
void ExportTranslators (out string_array theFormats,
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
* \param theTextureFile texture file name
*/
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
* \param theGroup is a GEOM group which type is returned.
group_edit.png \
glue.png \
check_blocks_compound.png \
+get_non_blocks.png \
check_self_intersections.png \
free_faces.png \
propagate.png \
<parameter name="SettingsGeomStep" value="10" />
<parameter name="display_mode" value="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="free_bound_color" value="0, 255, 0" />
<parameter name="line_color" value="255, 0, 0" />
#include <SalomeApp_Application.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()
// purpose : Constructs a BooleanGUI_Dialog which is a child of 'parent', with the
layout->addWidget(myGroup);
/***************************************************************/
+#ifdef NO_PREVIEW
+ mainFrame()->CheckBoxPreview->setChecked( false );
+ mainFrame()->CheckBoxPreview->hide();
+#endif
// Initialisation
Init();
}
if (myEditCurrentArgument == myGroup->LineEdit1) myObject1.nullify();
else if (myEditCurrentArgument == myGroup->LineEdit2) myObject2.nullify();
}
+ processPreview();
}
//=================================================================================
// 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 : DisplayGUI.cxx
// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
-//
+
#include "DisplayGUI.h"
#include <GeometryGUI.h>
#include "GeometryGUI_Operations.h"
getGeometryGUI()->EmitSignalDeactivateDialog();
DisplayOnly();
break;
+ case GEOMOp::OpShowOnlyChildren: // POPUP MENU - SHOW ONLY CHILDREN
+ getGeometryGUI()->EmitSignalDeactivateDialog();
+ DisplayOnlyChildren();
+ break;
case GEOMOp::OpHideAll: // MENU VIEW - HIDE ALL
EraseAll();
break;
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()
// purpose : Display selected GEOM objects
// 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 : DisplayGUI.h
// Author : Damien COQUERET, Open CASCADE S.A.S.
-//
+
#ifndef DISPLAYGUI_H
#define DISPLAYGUI_H
void Display();
// Display selected GEOM objects and erase other
void DisplayOnly();
+ // Display only children of selected GEOM objects and erase other
+ void DisplayOnlyChildren();
// Erase selected GEOM objects
void Erase();
// 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 : EntityGUI_3DSketcherDlg.cxx
// Author : DMV, OCN
-//
+
#include <cmath>
#include <string>
#include <boost/lexical_cast.hpp>
#include <GEOMBase.h>
#include <GeometryGUI.h>
-#include <Precision.hxx>
+#include <Precision.hxx>
#include <DlgRef.h>
#include <SUIT_Session.h>
#include <SalomeApp_Tools.h>
//OCCT includes
-//#include <BRep_Tool.hxx>
-//#include <TopExp.hxx>
-//#include <TopExp_Explorer.hxx>
-//#include <TopoDS_Vertex.hxx>
#include <TopoDS.hxx>
#include <TColStd_IndexedMapOfInteger.hxx>
-//#include <BRepBuilderAPI_Transform.hxx>
-//#include <BRepBuilderAPI_MakeWire.hxx>
#include <BRepBuilderAPI_MakeVertex.hxx>
#include <BRepBuilderAPI_MakePolygon.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
TYPE_TWO_ANGLES
};
+enum
+{
+ OXY,
+ OYZ,
+ OXZ
+};
+
class Locker
{
public:
- Locker( bool& l ) : myLock( l ) { myLock = true; }
- ~Locker() { myLock = false; }
+ Locker(bool& l) : myLock(l) { myLock = true; }
+ ~Locker() { myLock = false; }
private:
bool& myLock;
};
// The dialog will by default be modeless, unless you set 'modal' to
// TRUE to construct a modal dialog.
//=================================================================================
-EntityGUI_3DSketcherDlg::EntityGUI_3DSketcherDlg( GeometryGUI* theGeometryGUI, QWidget* parent,
+EntityGUI_3DSketcherDlg::EntityGUI_3DSketcherDlg (GeometryGUI* theGeometryGUI, QWidget* parent,
bool modal, Qt::WindowFlags fl,
- const double lineWidth )
- : GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl ),
- myMode( -1 ),
- myOK( false ),
- myLineWidth( lineWidth ),
- myGeometryGUI( theGeometryGUI ),
+ const double lineWidth)
+ : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl),
+ myMode(-1),
+ myOK(false),
+ myLineWidth(lineWidth),
+ myGeometryGUI(theGeometryGUI),
myLengthIORedoList()
+// myLastAngleNormal()
{
- QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
- QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_UNDO" ) ) );
- QPixmap image2( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_REDO" ) ) );
- QPixmap image3( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICO_3DSKETCH" ) ) );
+ QPixmap image0(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT")));
+ QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_UNDO")));
+ QPixmap image2(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_REDO")));
+ QPixmap image3(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICO_3DSKETCH")));
- setWindowTitle( tr( "GEOM_3DSKETCHER_TITLE" ) );
+ setWindowTitle(tr("GEOM_3DSKETCHER_TITLE"));
/***************************************************************/
- mainFrame()->GroupConstructors->setTitle( tr( "GEOM_3DSKETCHER" ) );
- mainFrame()->RadioButton1->setIcon( image3 );;
+ mainFrame()->GroupConstructors->setTitle(tr("GEOM_3DSKETCHER"));
+ mainFrame()->RadioButton1->setIcon(image3);;
mainFrame()->RadioButton2->close();
mainFrame()->RadioButton3->close();
GroupType->RadioButton2->setText(tr("GEOM_SKETCHER_REL"));
GroupType->RadioButton3->setText(tr("Angles")); //TODO translation
// GroupType->RadioButton3->close();
- myTypeGroup = new QButtonGroup( this );
- myTypeGroup->addButton( GroupType->RadioButton1, 0 );
- myTypeGroup->addButton( GroupType->RadioButton2, 1 );
- myTypeGroup->addButton( GroupType->RadioButton3, 2 );
-
- Group3Spin = new EntityGUI_3Spin( centralWidget() );
- Group3Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
- Group3Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
- Group3Spin->buttonUndo->setIcon( image1 );
- Group3Spin->buttonRedo->setIcon( image2 );
- Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X2" ) );
- Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y2" ) );
- Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_Z2" ) );
-
- GroupAngles = new EntityGUI_Angles( centralWidget() );
- GroupAngles->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
- GroupAngles->buttonUndo->setIcon( image1 );
- GroupAngles->buttonRedo->setIcon( image2 );
- GroupAngles->checkBox->setText( tr( "Angle 2" ) ); //TODO translation
-
- GroupControls = new EntityGUI_Controls( centralWidget() );
+ myTypeGroup = new QButtonGroup(this);
+ myTypeGroup->addButton(GroupType->RadioButton1, 0);
+ myTypeGroup->addButton(GroupType->RadioButton2, 1);
+ myTypeGroup->addButton(GroupType->RadioButton3, 2);
+
+ Group3Spin = new EntityGUI_3Spin(centralWidget());
+ Group3Spin->GroupBox1->setTitle(tr("GEOM_SKETCHER_VALUES"));
+ Group3Spin->buttonApply->setText(tr("GEOM_SKETCHER_APPLY"));
+ Group3Spin->buttonUndo->setIcon(image1);
+ Group3Spin->buttonRedo->setIcon(image2);
+ Group3Spin->TextLabel1->setText(tr("GEOM_SKETCHER_X2"));
+ Group3Spin->TextLabel2->setText(tr("GEOM_SKETCHER_Y2"));
+ Group3Spin->TextLabel3->setText(tr("GEOM_SKETCHER_Z2"));
+
+ GroupAngles = new EntityGUI_Angles(centralWidget());
+ GroupAngles->buttonApply->setText(tr("GEOM_SKETCHER_APPLY"));
+ GroupAngles->buttonUndo->setIcon(image1);
+ GroupAngles->buttonRedo->setIcon(image2);
+ GroupAngles->checkBox->setText(tr("Angle 2")); //TODO translation
+
+ GroupControls = new EntityGUI_Controls(centralWidget());
GroupControls->GroupBox1->setTitle(tr("GEOM_CONTROLS"));
- GroupControls->CheckBox1->setText( tr( "Show length dimensions" ) ); //TODO translation
- GroupControls->CheckBox2->setText( tr( "Show angle dimensions" ) ); //TODO translation
-
- buttonOk()->setText( tr( "GEOM_BUT_END_SKETCH" ) );
- buttonApply()->setText( tr( "GEOM_BUT_CLOSE_SKETCH" ) );
-
- QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
- layout->setMargin( 0 ); layout->setSpacing( 6 );
- layout->addWidget( GroupType );
- layout->addWidget( Group3Spin );
- layout->addWidget( GroupAngles );
- layout->addWidget( GroupControls );
-
- setHelpFileName( "create_3dsketcher_page.html" );
+ GroupControls->CheckBox1->setText(tr("Show length 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"));
+ buttonApply()->setText(tr("GEOM_BUT_CLOSE_SKETCH"));
+
+ QVBoxLayout* layout = new QVBoxLayout(centralWidget());
+ layout->setMargin(0); layout->setSpacing(6);
+ layout->addWidget(GroupType);
+ layout->addWidget(Group3Spin);
+ layout->addWidget(GroupAngles);
+ layout->addWidget(GroupControls);
+
+ setHelpFileName("create_3dsketcher_page.html");
resize(100,100);
Init();
-}
-
-
+}
//=================================================================================
// function : ~EntityGUI_3DSketcherDlg()
//=================================================================================
EntityGUI_3DSketcherDlg::~EntityGUI_3DSketcherDlg()
{
- myGeomGUI->SetActiveDialogBox( 0 );
+ myGeomGUI->SetActiveDialogBox(0);
}
//=================================================================================
void EntityGUI_3DSketcherDlg::Init()
{
myOK = false;
- myOrientation = 1;
+ myOrientation = OXY;
myPrsType = NONE;
-
+
SUIT_ViewWindow* vw = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
myAnglePrs = dynamic_cast<SOCC_Prs*>(((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->CreatePrs(0));
myLengthPrs = dynamic_cast<SOCC_Prs*>(((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->CreatePrs(0));
-
+
//TEST
- localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
+ localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
// globalSelection(GEOM_PREVIEW);
+// setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
/* 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);
/* min, max, step and decimals for spin boxes */
- initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
- initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
- initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
-
- initSpinBox( GroupAngles->SpinBox_DA , -180.0, 180.0, step, "angular_precision" );
- initSpinBox( GroupAngles->SpinBox_DA2, -90.0, 90.0, step, "angular_precision" );
- initSpinBox( GroupAngles->SpinBox_DL , COORD_MIN, COORD_MAX, step, "length_precision" );
+ initSpinBox(Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision");
+ initSpinBox(Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision");
+ initSpinBox(Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision");
+
+ initSpinBox(GroupAngles->SpinBox_DA , -180.0, 180.0, step, "angular_precision");
+ initSpinBox(GroupAngles->SpinBox_DA2, -90.0, 90.0, step, "angular_precision");
+ initSpinBox(GroupAngles->SpinBox_DL , COORD_MIN, COORD_MAX, step, "length_precision");
Group3Spin->SpinBox_DX->setValue(0.0);
Group3Spin->SpinBox_DY->setValue(0.0);
Group3Spin->SpinBox_DZ->setValue(0.0);
-
+
GroupAngles->SpinBox_DA->setValue(0.0);
GroupAngles->SpinBox_DA2->setValue(0.0);
GroupAngles->SpinBox_DL->setValue(0.0);
-
+
GroupAngles->radioButton_1->setChecked(true);
GroupAngles->checkBox->setChecked(false);
- GroupAngles->SpinBox_DA2->setEnabled(false);
+ GroupAngles->SpinBox_DA2->setEnabled(false);
+
+ GroupControls->CheckBox1->setChecked(true);
+ GroupControls->CheckBox2->setChecked(true);
+ GroupControls->CheckBox3->setChecked(true);
- GroupControls->CheckBox1->setChecked( true );
- GroupControls->CheckBox2->setChecked( true );
isLengthVisible = true;
isAngleVisible = true;
-
+
GroupAngles->hide();
/* signals and slots connections */
- connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
- connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
+ connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
+ connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
- connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
+ connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
- connect( Group3Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnAddPoint() ) );
- connect( Group3Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
- connect( Group3Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) ) ;
-
- connect( GroupAngles->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnAddPoint() ) );
- connect( GroupAngles->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
- connect( GroupAngles->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) ) ;
+ connect(Group3Spin->buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnAddPoint()));
+ connect(Group3Spin->buttonUndo, SIGNAL(clicked()), this, SLOT(ClickOnUndo()));
+ connect(Group3Spin->buttonRedo, SIGNAL(clicked()), this, SLOT(ClickOnRedo())) ;
- connect( myTypeGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( TypeClicked( int ) ) );
+ connect(GroupAngles->buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnAddPoint()));
+ connect(GroupAngles->buttonUndo, SIGNAL(clicked()), this, SLOT(ClickOnUndo()));
+ connect(GroupAngles->buttonRedo, SIGNAL(clicked()), this, SLOT(ClickOnRedo())) ;
- connect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
- connect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
- connect( Group3Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
-
- connect( GroupAngles->SpinBox_DA, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
- connect( GroupAngles->SpinBox_DA2, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
- connect( GroupAngles->SpinBox_DL, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
-
- connect( GroupAngles->radioButton_1, SIGNAL( clicked ( bool ) ), this, SLOT( ButtonClicked(bool) ) ) ;
- connect( GroupAngles->radioButton_2, SIGNAL( clicked ( bool ) ), this, SLOT( ButtonClicked(bool) ) ) ;
- connect( GroupAngles->radioButton_3, SIGNAL( clicked ( bool ) ), this, SLOT( ButtonClicked(bool) ) ) ;
-
- connect( GroupAngles->checkBox, 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(myTypeGroup, SIGNAL(buttonClicked(int)), this, SLOT(TypeClicked(int)));
+
+ connect(Group3Spin->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
+ connect(Group3Spin->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
+ connect(Group3Spin->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
+
+ connect(GroupAngles->SpinBox_DA, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
+ connect(GroupAngles->SpinBox_DA2, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
+ connect(GroupAngles->SpinBox_DL, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
+
+ connect(GroupAngles->radioButton_1, SIGNAL(clicked (bool)), this, SLOT(ButtonClicked(bool))) ;
+ connect(GroupAngles->radioButton_2, SIGNAL(clicked (bool)), this, SLOT(ButtonClicked(bool))) ;
+ connect(GroupAngles->radioButton_3, SIGNAL(clicked (bool)), this, SLOT(ButtonClicked(bool))) ;
+
+ connect(GroupAngles->checkBox, 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->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)));
- connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) );
- connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) );
+ connect(myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
+ connect(myGeomGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
- initName( tr( "GEOM_3DSKETCHER" ) );
+ initName(tr("GEOM_3DSKETCHER"));
+
+ GroupControls->CheckBox3->click();
UpdateButtonsState();
- GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
+ GEOMBase_Helper::displayPreview(true, false, true, true, myLineWidth);
}
//=================================================================================
// function : TypeClicked()
// purpose : Radio button management
//=================================================================================
-void EntityGUI_3DSketcherDlg::TypeClicked( int mode )
+void EntityGUI_3DSketcherDlg::TypeClicked (int mode)
{
- if ( mode == myMode ) return;
+ if (mode == myMode) return;
GroupAngles->hide();
Group3Spin->show();
-
+
bool blocked = Group3Spin->SpinBox_DX->signalsBlocked();
Group3Spin->SpinBox_DX->blockSignals(true);
Group3Spin->SpinBox_DY->blockSignals(true);
Group3Spin->SpinBox_DZ->blockSignals(true);
+
// Get setting of step value from file configuration
XYZ xyz = getLastPoint();
bool okx, oky, okz;
- Group3Spin->SpinBox_DX->text().toDouble( &okx );
- Group3Spin->SpinBox_DY->text().toDouble( &oky );
- Group3Spin->SpinBox_DZ->text().toDouble( &okz );
- if ( mode == 0 ) { // XY
- Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X2" ) );
- Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y2" ) );
- Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_Z2" ) );
+ Group3Spin->SpinBox_DX->text().toDouble(&okx);
+ Group3Spin->SpinBox_DY->text().toDouble(&oky);
+ Group3Spin->SpinBox_DZ->text().toDouble(&okz);
+
+ if (mode == 0) { // XYZ
+ Group3Spin->TextLabel1->setText(tr("GEOM_SKETCHER_X2"));
+ Group3Spin->TextLabel2->setText(tr("GEOM_SKETCHER_Y2"));
+ Group3Spin->TextLabel3->setText(tr("GEOM_SKETCHER_Z2"));
if (myMode == 1)
{
- if ( okx ) Group3Spin->SpinBox_DX->setValue( xyz.x + Group3Spin->SpinBox_DX->value() );
- if ( oky ) Group3Spin->SpinBox_DY->setValue( xyz.y + Group3Spin->SpinBox_DY->value() );
- if ( okz ) Group3Spin->SpinBox_DZ->setValue( xyz.z + Group3Spin->SpinBox_DZ->value() );
+ if (okx) Group3Spin->SpinBox_DX->setValue(xyz.x + Group3Spin->SpinBox_DX->value());
+ if (oky) Group3Spin->SpinBox_DY->setValue(xyz.y + Group3Spin->SpinBox_DY->value());
+ if (okz) Group3Spin->SpinBox_DZ->setValue(xyz.z + Group3Spin->SpinBox_DZ->value());
}
Group3Spin->buttonApply->setFocus();
}
- else if ( mode == 1) { // DXDY
- Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_DX2" ) );
- Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_DY2" ) );
- Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_DZ2" ) );
+ else if (mode == 1) { // DXDYDZ
+ Group3Spin->TextLabel1->setText(tr("GEOM_SKETCHER_DX2"));
+ Group3Spin->TextLabel2->setText(tr("GEOM_SKETCHER_DY2"));
+ Group3Spin->TextLabel3->setText(tr("GEOM_SKETCHER_DZ2"));
if (myMode == 0)
{
- if ( okx ) Group3Spin->SpinBox_DX->setValue( Group3Spin->SpinBox_DX->value() - xyz.x );
- if ( oky ) Group3Spin->SpinBox_DY->setValue( Group3Spin->SpinBox_DY->value() - xyz.y );
- if ( okz ) Group3Spin->SpinBox_DZ->setValue( Group3Spin->SpinBox_DZ->value() - xyz.z );
+ if (okx) Group3Spin->SpinBox_DX->setValue(Group3Spin->SpinBox_DX->value() - xyz.x);
+ if (oky) Group3Spin->SpinBox_DY->setValue(Group3Spin->SpinBox_DY->value() - xyz.y);
+ if (okz) Group3Spin->SpinBox_DZ->setValue(Group3Spin->SpinBox_DZ->value() - xyz.z);
}
Group3Spin->buttonApply->setFocus();
}
- else if (mode == 2){ // Angles
+ else if (mode == 2) { // Angles and Length
Group3Spin->hide();
GroupAngles->show();
GroupAngles->buttonApply->setFocus();
}
-
+
Group3Spin->SpinBox_DX->blockSignals(blocked);
Group3Spin->SpinBox_DY->blockSignals(blocked);
Group3Spin->SpinBox_DZ->blockSignals(blocked);
myMode = mode;
-
+
updateGeometry();
resize(minimumSizeHint());
-
- GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
+
+ GEOMBase_Helper::displayPreview(true, false, true, true, myLineWidth);
}
//=================================================================================
// purpose : called when the point coordinates is Applyed
//=================================================================================
void EntityGUI_3DSketcherDlg::ClickOnAddPoint()
-{
+{
QString msg;
- if ( !isValid( msg ) ) {
- showError( msg );
+ if (!isValid(msg)) {
+ showError(msg);
return;
}
-
+
// Display and store angle dimensions interactive objects in Prs
- if( GroupType->RadioButton3->isChecked() )
+ if (GroupType->RadioButton3->isChecked()) // ANGLES
{
double anAngle2 = 0.0;
if (GroupAngles->checkBox->isChecked())
anAngle2 = GroupAngles->SpinBox_DA2->value();
-
- // Store length dimensions
- displayLength(GroupAngles->SpinBox_DL->value(), /*store =*/true);
+
// Store angle dimensions
- displayAngle(GroupAngles->SpinBox_DA->value(), anAngle2,
- GroupAngles->SpinBox_DL->value(), myOrientation, /*store =*/true);
+ displayAngle(GroupAngles->SpinBox_DA->value(), anAngle2,
+ 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
- if (GroupType->RadioButton1->isChecked() ||
+ if (GroupType->RadioButton1->isChecked() || // ABSOLUTE or RELATIVE coordinates
GroupType->RadioButton2->isChecked())
{
displayLength(-1, /*store=*/true);
}
-
- myPointsList.append( getCurrentPoint() );
- myPrsTypeList.push_back( myPrsType );
-
+
+ myPointsList.append(getCurrentPoint());
+ myPrsTypeList.push_back(myPrsType);
+
// Clean redo lists
myRedoList.clear();
myPrsTypeRedoList.clear();
myLengthIORedoList.Clear();
myAngleIORedoList.Clear();
-
- if ( myMode == 1 ) {
- Group3Spin->SpinBox_DX->setValue( 0.0 );
- Group3Spin->SpinBox_DY->setValue( 0.0 );
- Group3Spin->SpinBox_DZ->setValue( 0.0 );
+
+ if (myMode == 1)
+ {
+ Group3Spin->SpinBox_DX->setValue(0.0);
+ Group3Spin->SpinBox_DY->setValue(0.0);
+ Group3Spin->SpinBox_DZ->setValue(0.0);
}
- else if ( myMode == 2 )
+ else if (myMode == 2)
{
- GroupAngles->SpinBox_DA->setValue( 0.0 );
- GroupAngles->SpinBox_DL->setValue( 0.0 );
- GroupAngles->SpinBox_DA2->setValue( 0.0 );
+ GroupAngles->SpinBox_DA->setValue(0.0);
+ GroupAngles->SpinBox_DL->setValue(0.0);
+ GroupAngles->SpinBox_DA2->setValue(0.0);
}
- UpdateButtonsState();
- GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
+ UpdatePointCoordinates();
+
+ UpdateButtonsState();
+ GEOMBase_Helper::displayPreview(true, false, true, true, myLineWidth);
}
//=================================================================================
// function : UpdateButtonsState()
-// purpose :
+// purpose :
//=================================================================================
void EntityGUI_3DSketcherDlg::UpdateButtonsState()
{
- if ( myPointsList.count() == 0 ) GroupType->RadioButton1->click();
- GroupType->RadioButton2->setEnabled( myPointsList.count() > 0 );
- GroupType->RadioButton3->setEnabled( myPointsList.count() > 0 );
- Group3Spin->buttonUndo->setEnabled( myPointsList.count() > 0 );
- Group3Spin->buttonRedo->setEnabled( myRedoList.count() > 0 );
- GroupAngles->buttonUndo->setEnabled( myPointsList.count() > 0 );
- GroupAngles->buttonRedo->setEnabled( myRedoList.count() > 0 );
+ if (myPointsList.count() == 0) GroupType->RadioButton1->click();
+ GroupType->RadioButton2->setEnabled(myPointsList.count() > 0);
+ GroupType->RadioButton3->setEnabled(myPointsList.count() > 0);
+ Group3Spin->buttonUndo->setEnabled(myPointsList.count() > 0);
+ Group3Spin->buttonRedo->setEnabled(myRedoList.count() > 0);
+ GroupAngles->buttonUndo->setEnabled(myPointsList.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));
+ }
+
}
//=================================================================================
void EntityGUI_3DSketcherDlg::ClickOnUndo()
{
if (myPointsList.count() > 0) {
- myRedoList.append( myPointsList.takeLast() );
+ myRedoList.append(myPointsList.takeLast());
UpdateButtonsState();
- GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
-
+ GEOMBase_Helper::displayPreview(true, false, true, true, myLineWidth);
+
// Erase dimensions presentations
SUIT_ViewWindow* vw = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
- ((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Erase(myLengthPrs, true);
+ ((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Erase(myLengthPrs, true);
((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Erase(myAnglePrs, true);
-
+
if (myPrsTypeList.back() != NONE)
{
// Remove last prepended IO
- removeLastIOFromPrs( TYPE_LENGTH );
- }
- if ( myPrsTypeList.back() == TYPE_ANGLE ||
- myPrsTypeList.back() == TYPE_TWO_ANGLES )
+ removeLastIOFromPrs(TYPE_LENGTH);
+ }
+ if (myPrsTypeList.back() == TYPE_ANGLE ||
+ myPrsTypeList.back() == TYPE_TWO_ANGLES)
{
// Remove first Angle IO from presentation
- removeLastIOFromPrs( TYPE_ANGLE );
- if ( myPrsTypeList.back() == TYPE_TWO_ANGLES )
+ removeLastIOFromPrs(TYPE_ANGLE);
+ if (myPrsTypeList.back() == TYPE_TWO_ANGLES)
{
// Remove second Angle IO
- removeLastIOFromPrs( TYPE_ANGLE );
+ removeLastIOFromPrs(TYPE_ANGLE);
}
}
-
+
// Erase last action type and store it in redo list
myPrsTypeRedoList.push_back(myPrsTypeList.back());
myPrsTypeList.pop_back();
-
+
// Display modified presentation
if (isLengthVisible)
((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Display(myLengthPrs);
if (isAngleVisible)
((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Display(myAnglePrs);
+ // Update of point coordinates in the control groupbox
+ UpdatePointCoordinates();
+
updateViewer();
}
}
//=================================================================================
void EntityGUI_3DSketcherDlg::ClickOnRedo()
{
- if ( myRedoList.count() > 0) {
- myPointsList.append( myRedoList.takeLast() );
+ if (myRedoList.count() > 0) {
+ myPointsList.append(myRedoList.takeLast());
UpdateButtonsState();
- GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
-
+ GEOMBase_Helper::displayPreview(true, false, true, true, myLineWidth);
+
// Erase dimensions presentations
SUIT_ViewWindow* vw = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Erase(myLengthPrs, true);
((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Erase(myAnglePrs, true);
-
- if ( myPrsTypeRedoList.back() != NONE )
- restoreLastIOToPrs( TYPE_LENGTH );
-
- if ( myPrsTypeRedoList.back() == TYPE_ANGLE ||
- myPrsTypeRedoList.back() == TYPE_TWO_ANGLES )
+
+ if (myPrsTypeRedoList.back() != NONE)
+ restoreLastIOToPrs(TYPE_LENGTH);
+
+ if (myPrsTypeRedoList.back() == TYPE_ANGLE ||
+ myPrsTypeRedoList.back() == TYPE_TWO_ANGLES)
{
// Add a first IO from the Redo list
- restoreLastIOToPrs( TYPE_ANGLE );
- if ( myPrsTypeRedoList.back() == TYPE_TWO_ANGLES )
+ restoreLastIOToPrs(TYPE_ANGLE);
+ if (myPrsTypeRedoList.back() == TYPE_TWO_ANGLES)
{
// Add a second IO from the Redo list
- restoreLastIOToPrs( TYPE_ANGLE );
+ restoreLastIOToPrs(TYPE_ANGLE);
}
}
-
+
// Record last prs type
myPrsTypeList.push_back(myPrsTypeRedoList.back());
myPrsTypeRedoList.pop_back();
-
+
// Display modified presentation
if (isLengthVisible)
((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Display(myLengthPrs);
if (isAngleVisible)
((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Display(myAnglePrs);
+ // Update of point coordinates in the control groupbox
+ UpdatePointCoordinates();
+
updateViewer();
}
}
// function : removeLastIO()
// purpose :
//=================================================================================
-void EntityGUI_3DSketcherDlg::removeLastIOFromPrs(int type)
+void EntityGUI_3DSketcherDlg::removeLastIOFromPrs (int type)
{
AIS_ListOfInteractive anIOList;
-
+
if (type == TYPE_LENGTH)
{
myLengthPrs->GetObjects(anIOList);
myLengthIORedoList.Prepend(anIOList.First()); // Store last prepended Length IO in redo list
myLengthPrs->RemoveFirst(); // Remove it from myLengthPrs
- }
+ }
if (type == TYPE_ANGLE)
{
myAnglePrs->GetObjects(anIOList);
myAngleIORedoList.Prepend(anIOList.First()); // Store last prepended Angle IO in redo list
myAnglePrs->RemoveFirst(); // Remove it from myAnglePrs
- }
+ }
}
//=================================================================================
// function : restoreLastIO()
// purpose :
//=================================================================================
-void EntityGUI_3DSketcherDlg::restoreLastIOToPrs(int type)
+void EntityGUI_3DSketcherDlg::restoreLastIOToPrs (int type)
{
if (type == TYPE_LENGTH)
{
myLengthPrs->PrependObject(myLengthIORedoList.First()); // Restore last removed IO
myLengthIORedoList.RemoveFirst(); // Remove it from redo list
- }
+ }
if (type == TYPE_ANGLE)
{
myAnglePrs->PrependObject(myAngleIORedoList.First()); // Restore last removed IO
myAngleIORedoList.RemoveFirst(); // Remove it from redo list
- }
+ }
}
//=================================================================================
aSelMgr->selectedObjects(aSelList);
int nbSel = aSelList.Extent();
- if ( nbSel == 1 ) {
- GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
- if ( !CORBA::is_nil(aSelectedObject) ) {
+ if (nbSel == 1) {
+ GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First());
+ if (!CORBA::is_nil(aSelectedObject)) {
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;
aSelMgr->GetIndexes(aSelList.First(), aMap);
- if (aMap.Extent() == 1)
- {
- int anIndex = aMap(1);
- GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId());
- aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
- }
+ if (aMap.Extent() == 1) {
+ int anIndex = aMap(1);
+ GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId());
+ aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
+ }
}
bool isOk = true;
- if ( aShape.ShapeType() != TopAbs_VERTEX )
+ if (aShape.ShapeType() != TopAbs_VERTEX)
isOk = GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX);
if (isOk) {
gp_Pnt aPnt;
- if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
+ if (GEOMBase::VertexToPoint(aShape, aPnt)) {
// set coordinates to the Spin Boxes
double aX, aY, aZ;
aX = aPnt.X();
Group3Spin->SpinBox_DX->blockSignals(true);
Group3Spin->SpinBox_DY->blockSignals(true);
Group3Spin->SpinBox_DZ->blockSignals(true);
- if ( GroupType->RadioButton1->isChecked() ) {
- Group3Spin->SpinBox_DX->setValue( aX );
- Group3Spin->SpinBox_DY->setValue( aY );
- Group3Spin->SpinBox_DZ->setValue( aZ );
- } else if ( GroupType->RadioButton2->isChecked() ) {
+ if (GroupType->RadioButton1->isChecked()) {
+ Group3Spin->SpinBox_DX->setValue(aX);
+ Group3Spin->SpinBox_DY->setValue(aY);
+ Group3Spin->SpinBox_DZ->setValue(aZ);
+ }
+ else if (GroupType->RadioButton2->isChecked()) {
XYZ xyz = getLastPoint();
- Group3Spin->SpinBox_DX->setValue( aX - xyz.x );
- Group3Spin->SpinBox_DY->setValue( aY - xyz.y );
- Group3Spin->SpinBox_DZ->setValue( aZ - xyz.z );
+ Group3Spin->SpinBox_DX->setValue(aX - xyz.x);
+ Group3Spin->SpinBox_DY->setValue(aY - xyz.y);
+ Group3Spin->SpinBox_DZ->setValue(aZ - xyz.z);
}
Group3Spin->SpinBox_DX->blockSignals(blocked);
Group3Spin->SpinBox_DY->blockSignals(blocked);
}
}
}
- GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
+ GEOMBase_Helper::displayPreview(true, false, true, true, myLineWidth);
}
//=================================================================================
//=================================================================================
void EntityGUI_3DSketcherDlg::DeactivateActiveDialog()
{
- setEnabled( false );
+ setEnabled(false);
globalSelection();
- disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 );
- myGeomGUI->SetActiveDialogBox( 0 );
+ disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
+ myGeomGUI->SetActiveDialogBox(0);
}
-
//=================================================================================
// function : ActivateThisDialog()
// purpose :
void EntityGUI_3DSketcherDlg::ActivateThisDialog()
{
myGeomGUI->EmitSignalDeactivateDialog();
- setEnabled( true );
- myGeomGUI->SetActiveDialogBox( this );
+ setEnabled(true);
+ myGeomGUI->SetActiveDialogBox(this);
- connect( myGeomGUI->getApp()->selectionMgr(),
- SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
+ connect(myGeomGUI->getApp()->selectionMgr(),
+ SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
- localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
- GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
+ localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
+ GEOMBase_Helper::displayPreview(true, false, true, true, myLineWidth);
}
-
//=================================================================================
// function : ValueChangedInSpinBox()
// purpose :
//=================================================================================
-void EntityGUI_3DSketcherDlg::ValueChangedInSpinBox( double newValue )
+void EntityGUI_3DSketcherDlg::ValueChangedInSpinBox (double newValue)
{
- GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
+ GEOMBase_Helper::displayPreview(true, false, true, true, myLineWidth);
}
-
//=================================================================================
// function : BoxChecked()
// purpose : ChecBoxes management
//=================================================================================
-void EntityGUI_3DSketcherDlg::BoxChecked( bool checked )
+void EntityGUI_3DSketcherDlg::BoxChecked (bool checked)
{
QCheckBox* send = (QCheckBox*) sender();
SUIT_ViewWindow* vw = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
-
+
if (send == GroupAngles->checkBox)
- GroupAngles->SpinBox_DA2->setEnabled(checked);
-
+ GroupAngles->SpinBox_DA2->setEnabled(checked);
+
else if (send == GroupControls->CheckBox1)
{
((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Erase(myLengthPrs, true);
- if(checked){
+ if (checked){
((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Display(myLengthPrs);
isLengthVisible=true;
}
}
else if (send == GroupControls->CheckBox2)
{
- ((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Erase(myAnglePrs, true);
- if(checked)
+ ((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Erase(myAnglePrs, true);
+ if (checked)
{
((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Display(myAnglePrs);
isAngleVisible=true;
else
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());
+ }
- GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
+ updateGeometry();
+ resize(minimumSizeHint());
+
+ GEOMBase_Helper::displayPreview(true, false, true, true, myLineWidth);
}
//=================================================================================
// function : ButtonClicked()
// purpose :
//=================================================================================
-void EntityGUI_3DSketcherDlg::ButtonClicked( bool checked )
+void EntityGUI_3DSketcherDlg::ButtonClicked (bool checked)
{
if (GroupAngles->radioButton_1->isChecked())
- myOrientation = 1;
+ myOrientation = OXY;
else if (GroupAngles->radioButton_2->isChecked())
- myOrientation = 2;
+ myOrientation = OYZ;
else
- myOrientation = 3;
-
- GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
+ myOrientation = OXZ;
+
+ GEOMBase_Helper::displayPreview(true, false, true, true, myLineWidth);
}
//=================================================================================
// function : enterEvent()
// purpose :
//=================================================================================
-void EntityGUI_3DSketcherDlg::enterEvent( QEvent* )
+void EntityGUI_3DSketcherDlg::enterEvent (QEvent*)
{
- if ( !mainFrame()->GroupConstructors->isEnabled() )
+ if (!mainFrame()->GroupConstructors->isEnabled())
ActivateThisDialog();
}
//=================================================================================
GEOM::GEOM_IOperations_ptr EntityGUI_3DSketcherDlg::createOperation()
{
- return getGeomEngine()->GetICurvesOperations( getStudyId() );
+ return getGeomEngine()->GetICurvesOperations(getStudyId());
}
//=================================================================================
// function : isValid
// purpose :
//=================================================================================
-bool EntityGUI_3DSketcherDlg::isValid( QString& msg )
+bool EntityGUI_3DSketcherDlg::isValid (QString& msg)
{
bool ok = true;
- ok = Group3Spin->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
- ok = Group3Spin->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
- ok = Group3Spin->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok;
+ ok = Group3Spin->SpinBox_DX->isValid(msg, !IsPreview()) && ok;
+ ok = Group3Spin->SpinBox_DY->isValid(msg, !IsPreview()) && ok;
+ ok = Group3Spin->SpinBox_DZ->isValid(msg, !IsPreview()) && ok;
return ok;
}
// function : execute
// purpose :
//=================================================================================
-bool EntityGUI_3DSketcherDlg::execute( ObjectList& objects )
+bool EntityGUI_3DSketcherDlg::execute (ObjectList& objects)
{
- GEOM::ListOfDouble_var aCoordsArray = new GEOM::ListOfDouble;
- if (!myOK || myPointsList.size() == 0)
- aCoordsArray->length((myPointsList.size()+1)*3);
- else
- aCoordsArray->length(myPointsList.size()*3);
-
+ //GEOM::ListOfDouble_var aCoordsArray = new GEOM::ListOfDouble;
+ //if (!myOK || myPointsList.size() == 0)
+ // aCoordsArray->length((myPointsList.size()+1)*3);
+ //else
+ // aCoordsArray->length(myPointsList.size()*3);
+
+ QStringList aCommands;
+ aCommands << "3DSketcher";
QStringList aParameters;
- int i = 0;
+ //int i = 0;
QList<XYZ>::const_iterator it;
- for(it = myPointsList.begin(); it != myPointsList.end(); ++it ) {
- aCoordsArray[i++] = (*it).x;
- aCoordsArray[i++] = (*it).y;
- aCoordsArray[i++] = (*it).z;
- aParameters << (*it).xt;
- aParameters << (*it).yt;
- aParameters << (*it).zt;
+ for (it = myPointsList.begin(); it != myPointsList.end(); ++it) {
+ //aCoordsArray[i++] = (*it).x;
+ //aCoordsArray[i++] = (*it).y;
+ //aCoordsArray[i++] = (*it).z;
+ aCommands << (*it).command;
+ aParameters << (*it).params;
}
if (!myOK || myPointsList.size() == 0) {
XYZ xyz = getCurrentPoint();
- aCoordsArray[i++] = xyz.x;
- aCoordsArray[i++] = xyz.y;
- aCoordsArray[i++] = xyz.z;
- aParameters << xyz.xt;
- aParameters << xyz.yt;
- aParameters << xyz.zt;
- }
+ //aCoordsArray[i++] = xyz.x;
+ //aCoordsArray[i++] = xyz.y;
+ //aCoordsArray[i++] = xyz.z;
+ aCommands << xyz.command;
+ aParameters << xyz.params;
+ }
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 ( !IsPreview() ) anObj->SetParameters(aParameters.join(":").toLatin1().constData());
- objects.push_back( anObj._retn() );
+ if (!anObj->_is_nil()) {
+ if (!IsPreview()) anObj->SetParameters(aParameters.join(":").toLatin1().constData());
+ objects.push_back(anObj._retn());
}
return true;
// function : SetDoubleSpinBoxStep()
// purpose : Double spin box management
//=================================================================================
-void EntityGUI_3DSketcherDlg::SetDoubleSpinBoxStep( double step )
+void EntityGUI_3DSketcherDlg::SetDoubleSpinBoxStep (double step)
{
Group3Spin->SpinBox_DX->setSingleStep(step);
Group3Spin->SpinBox_DY->setSingleStep(step);
//=================================================================================
void EntityGUI_3DSketcherDlg::ClickOnOk()
{
- Locker lock( myOK );
+ Locker lock(myOK);
- if ( !onAccept() )
+ if (!onAccept())
return;
ClickOnCancel();
bool EntityGUI_3DSketcherDlg::ClickOnApply()
{
QString msg;
- if ( !isValid( msg ) ) {
- showError( msg );
+ if (!isValid(msg)) {
+ showError(msg);
return false;
}
if (myPointsList.count() > 0)
myPointsList.append(myPointsList[0]);
- Locker lock( myOK );
+ Locker lock(myOK);
- if ( !onAccept() )
+ if (!onAccept())
return false;
-
+
ClickOnCancel();
return true;
}
//=================================================================================
// function : getCurrentPoint()
-// purpose : returns current points
+// purpose : returns current point
//=================================================================================
EntityGUI_3DSketcherDlg::XYZ EntityGUI_3DSketcherDlg::getCurrentPoint() const
{
- XYZ xyz;
- // Temporary way of doing this. To be changed with ordered improvement of the sketcher
- if ( myMode == 2 )
- {
- double anAngle = GroupAngles->SpinBox_DA->value() * M_PI/180.0;
- double anAngle2 = 0.0;
+ XYZ xyz;
+
+ SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+ int aPrecision = resMgr->integerValue("Geometry", "length_precision", 7);
+
+ 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();
-
- if (GroupAngles->checkBox->isChecked())
- anAngle2 = GroupAngles->SpinBox_DA2->value() * M_PI/180.0;
-
+
+ double anAngle2 = 0.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);
-
- xyz = getLastPoint();
- if (GroupAngles->radioButton_1->isChecked())
+
+ XYZ xyzP = getLastPoint();
+ if (GroupAngles->radioButton_1->isChecked()) // OXY
{
- xyz.x += aProjectedLength * cos(anAngle);
- xyz.y += aProjectedLength * sin(anAngle);
- xyz.z += aLength * sin(anAngle2);
+ xyz.x = xyzP.x + aProjectedLength * cos(anAngle);
+ xyz.y = xyzP.y + aProjectedLength * sin(anAngle);
+ 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.z += aProjectedLength * sin(anAngle);
- xyz.x += aLength * sin(anAngle2);
+ xyz.y = xyzP.y + aProjectedLength * cos(anAngle);
+ xyz.z = xyzP.z + aProjectedLength * sin(anAngle);
+ xyz.x = xyzP.x + aLength * sin(anAngle2);
}
- else
+ else // OXZ
{
- xyz.z += aProjectedLength * sin(anAngle);
- xyz.x += aProjectedLength * cos(anAngle);
- xyz.y += aLength * sin(anAngle2);
+ xyz.z = xyzP.z + aProjectedLength * sin(anAngle);
+ xyz.x = xyzP.x + aProjectedLength * cos(anAngle);
+ xyz.y = xyzP.y + aLength * sin(anAngle2);
}
}
- else
- {
- if ( myMode == 0 ) {
+ else {
+ if (myMode == 0) { // XYZ
xyz.x = Group3Spin->SpinBox_DX->value();
xyz.y = Group3Spin->SpinBox_DY->value();
xyz.z = Group3Spin->SpinBox_DZ->value();
- }
- else{
+ xyz.command = "TT ";
+ }
+ else { // DXDYDZ
xyz = getLastPoint();
xyz.x += Group3Spin->SpinBox_DX->value();
xyz.y += Group3Spin->SpinBox_DY->value();
xyz.z += Group3Spin->SpinBox_DZ->value();
+ xyz.command = "T ";
}
- xyz.xt = Group3Spin->SpinBox_DX->text();
- xyz.yt = Group3Spin->SpinBox_DY->text();
- xyz.zt = Group3Spin->SpinBox_DZ->text();
+
+ double aX = Group3Spin->SpinBox_DX->value();
+ 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;
}
// Purpose : Method for displaying preview of resulting shape
// Redefined from GEOMBase_Helper.
//================================================================
-void EntityGUI_3DSketcherDlg::displayPreview( GEOM::GEOM_Object_ptr object,
+void EntityGUI_3DSketcherDlg::displayPreview (GEOM::GEOM_Object_ptr object,
const bool append,
const bool activate,
const bool update,
const double lineWidth,
const int displayMode,
- const int color )
-{
- SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
-
+ const int color)
+{
+ SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+
QColor aColor = resMgr->colorValue("Geometry","line_color",QColor(255,0,0));
- Quantity_NameOfColor line_color = SalomeApp_Tools::color( aColor ).Name();
-
+ Quantity_NameOfColor line_color = SalomeApp_Tools::color(aColor).Name();
+
// set width of displayed shape
int lw = lineWidth;
- if(lw == -1) {
+ if (lw == -1) {
lw = resMgr->integerValue("Geometry", "preview_edge_width", -1);
}
- getDisplayer()->SetWidth( lw );
+ getDisplayer()->SetWidth(lw);
// Disable activation of selection
- getDisplayer()->SetToActivate( activate );
+ getDisplayer()->SetToActivate(activate);
// Make a reference to GEOM_Object
- CORBA::String_var objStr = myGeometryGUI->getApp()->orb()->object_to_string( object );
- getDisplayer()->SetName( objStr.in() );
+ CORBA::String_var objStr = myGeometryGUI->getApp()->orb()->object_to_string(object);
+ getDisplayer()->SetName(objStr.in());
// Create wire from applied object
TopoDS_Shape anApplyedWire, aLastSegment;
- if ( !createShapes( object, anApplyedWire, aLastSegment ) )
+ if (!createShapes(object, anApplyedWire, aLastSegment))
return;
// Set color for preview shape
- getDisplayer()->SetColor( line_color );
-
+ getDisplayer()->SetColor(line_color);
+
// Build prs
- SALOME_Prs* aPrs = getDisplayer()->BuildPrs( anApplyedWire );
- if ( aPrs != 0 && !aPrs->IsNull() )
- GEOMBase_Helper::displayPreview( aPrs, append, update );
+ SALOME_Prs* aPrs = getDisplayer()->BuildPrs(anApplyedWire);
+ if (aPrs != 0 && !aPrs->IsNull())
+ GEOMBase_Helper::displayPreview(aPrs, append, update);
+
+ getDisplayer()->SetColor(Quantity_NOC_VIOLET);
+ aPrs = getDisplayer()->BuildPrs(aLastSegment);
+
+ if (aPrs != 0 && !aPrs->IsNull())
+ GEOMBase_Helper::displayPreview(aPrs, append, update);
+
+ getDisplayer()->SetColor(line_color);
- getDisplayer()->SetColor( Quantity_NOC_VIOLET );
- aPrs = getDisplayer()->BuildPrs( aLastSegment );
-
- if ( aPrs != 0 && !aPrs->IsNull() )
- GEOMBase_Helper::displayPreview( aPrs, append, update );
-
- getDisplayer()->SetColor( line_color );
-
// Display local trihedron if the mode is relatives coordinates or angles
if (myMode == 1 || myMode == 2)
displayTrihedron(2);
-
+
// Display preview of suitable dimension presentations
- if(myMode == 2) // ANGLES
+ if (myMode == 2) // ANGLES
{
double anAngle2 = 0.0;
if (GroupAngles->checkBox->isChecked())
anAngle2 = GroupAngles->SpinBox_DA2->value();
-
+
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
- displayLength();
-
+ if (myMode == 0 || myMode == 1) // COORDINATES
+ displayLength();
+
getDisplayer()->UnsetName();
// Enable activation of displayed objects
- getDisplayer()->SetToActivate( true );
+ getDisplayer()->SetToActivate(true);
}
//================================================================
// Function : displayTrihedron()
// Purpose : Method for displaying trihedron
//================================================================
-void EntityGUI_3DSketcherDlg::displayTrihedron(int selMode)
+void EntityGUI_3DSketcherDlg::displayTrihedron (int selMode)
{
// Add trihedron to preview
SUIT_ViewWindow* vw = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
-
+
gp_Pnt P(getLastPoint().x,getLastPoint().y,getLastPoint().z);
Handle(Geom_Axis2Placement) anAxis = new Geom_Axis2Placement(P,gp::DZ(),gp::DX());
Handle(AIS_Trihedron) anIO = new AIS_Trihedron(anAxis);
anIO->SetSelectionMode(selMode);
-
- SOCC_Prs* aSPrs = dynamic_cast<SOCC_Prs*>(((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->CreatePrs(0));
-
- if (aSPrs)
- {
+
+ SOCC_Prs* aSPrs = dynamic_cast<SOCC_Prs*>
+ (((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->CreatePrs(0));
+
+ if (aSPrs) {
aSPrs->PrependObject(anIO);
- GEOMBase_Helper::displayPreview( aSPrs, true, true );
+ GEOMBase_Helper::displayPreview(aSPrs, true, true);
}
}
// Function : displayAngle()
// 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() ||
- theLength < Precision::Confusion() )
+ if (Abs(theAngle2 - 90.0) < Precision::Angular() ||
+ theLength < Precision::Confusion())
return;
- SUIT_ViewWindow* vw = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
-
+ SUIT_ViewWindow* vw = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
+
XYZ Last = getLastPoint();
XYZ Current = getCurrentPoint();
-
+
gp_Pnt Last_Pnt(Last.x,Last.y,Last.z);
gp_Pnt Current_Pnt(Current.x,Current.y,Current.z);
gp_Pnt P1, P2;
-
+
bool twoAngles = GroupAngles->checkBox->isChecked();
-
+
switch(theOrientation)
{
- case 1: //OXY
- {
+ case OXY:
+ {
P1 = gp_Pnt(Last.x + theLength,Last.y,Last.z); // X direction
P2 = gp_Pnt(Last.x + theLength * cos(theAngle1 * M_PI / 180.),
Last.y + theLength * sin(theAngle1 * M_PI / 180.),
- Last.z);
+ Last.z);
break;
}
- case 2: //OYZ
+ case OYZ:
{
P1 = gp_Pnt(Last.x, Last.y + theLength,Last.z); // Y direction
- P2 = gp_Pnt(Last.x,
+ P2 = gp_Pnt(Last.x,
Last.y + theLength * cos(theAngle1 * M_PI / 180.),
- Last.z + theLength * sin(theAngle1 * M_PI / 180.));
+ Last.z + theLength * sin(theAngle1 * M_PI / 180.));
break;
}
- case 3: //OXZ
+ case OXZ:
{
- P1 = gp_Pnt( Last.x + theLength,Last.y,Last.z); // X direction
- P2 = gp_Pnt( Last.x + theLength * cos(theAngle1 * M_PI / 180.) ,
- Last.y,
- Last.z + theLength * sin(theAngle1 * M_PI / 180.));
+ P1 = gp_Pnt(Last.x + theLength,Last.y,Last.z); // X direction
+ P2 = gp_Pnt(Last.x + theLength * cos(theAngle1 * M_PI / 180.) ,
+ Last.y,
+ Last.z + theLength * sin(theAngle1 * M_PI / 180.));
break;
}
}
-
+
TopoDS_Vertex V1 = BRepBuilderAPI_MakeVertex(P1);
TopoDS_Vertex V2 = BRepBuilderAPI_MakeVertex(P2);
TopoDS_Vertex LastV = BRepBuilderAPI_MakeVertex(Last_Pnt);
TopoDS_Edge anEdge1 = BRepBuilderAPI_MakeEdge(LastV, V1);
TopoDS_Edge anEdge2 = BRepBuilderAPI_MakeEdge(LastV, V2);
TopoDS_Edge anEdge3 = BRepBuilderAPI_MakeEdge(LastV, CurV);
-
- gce_MakePln gce_MP(Last_Pnt, P1, P2);
- Handle(Geom_Plane) aPlane = new Geom_Plane(gce_MP.Value());
-
- // Covert angles to string
+
+ gce_MakePln gce_MP (Last_Pnt, P1, P2);
+ Handle(Geom_Plane) aPlane = new Geom_Plane(gce_MP.Value());
+
+ // Convert angles to string
std::string Angle1_str = doubleToString(theAngle1);
std::string Angle2_str = doubleToString(theAngle2);
-
+
// Create interactive object
- Handle(AIS_AngleDimension) anAngleIO = new AIS_AngleDimension(anEdge1, anEdge2, aPlane, theAngle1 * M_PI / 180.,
- TCollection_ExtendedString(Angle1_str.c_str()));
- anAngleIO->SetArrowSize( (theAngle1 * M_PI / 180) * (theLength/20) );
-
+ Handle(AIS_AngleDimension) anAngleIO = new AIS_AngleDimension
+ (anEdge1, anEdge2, aPlane, theAngle1 * M_PI / 180.,
+ TCollection_ExtendedString(Angle1_str.c_str()));
+ anAngleIO->SetArrowSize((theAngle1 * M_PI / 180) * (theLength/20));
+
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
int w = resMgr->integerValue("Geometry", "measures_line_width", 1);
-
+
Handle(Prs3d_AngleAspect) asp = new Prs3d_AngleAspect();
asp->LineAspect()->SetWidth(w);
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)
{
// Erase dimensions presentations
((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Erase(myAnglePrs, true);
-
myAnglePrs->PrependObject(anAngleIO);
- myPrsType = TYPE_ANGLE; // Overwrite type with ANGLE
-
+
// Display modified presentation
if (isAngleVisible)
((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Display(myAnglePrs);
}
- else if(aSPrs)
+ else if (aSPrs)
{
aSPrs->AddObject(anAngleIO);
}
+ myPrsType = TYPE_ANGLE; // Overwrite type with ANGLE
if (twoAngles)
{
gce_MakePln gce_MP2(Last_Pnt, P2, Current_Pnt);
Handle(Geom_Plane) aPlane2 = new Geom_Plane(gce_MP2.Value());
-
- Handle(AIS_AngleDimension) anAngle2IO = new AIS_AngleDimension(anEdge2, anEdge3, aPlane2, theAngle2 * M_PI / 180.,
- TCollection_ExtendedString(Angle2_str.c_str()));
- anAngle2IO->SetArrowSize( (theAngle2 * M_PI / 180) * (theLength/20) );
-
+
+ Handle(AIS_AngleDimension) anAngle2IO =
+ new AIS_AngleDimension(anEdge2, anEdge3, aPlane2, theAngle2 * M_PI / 180.,
+ TCollection_ExtendedString(Angle2_str.c_str()));
+ anAngle2IO->SetArrowSize((theAngle2 * M_PI / 180) * (theLength/20));
+
anAngle2IO->Attributes()->SetAngleAspect(asp);
-
+
if (store)
{
// Erase dimensions presentations
((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Erase(myAnglePrs, true);
-
myAnglePrs->PrependObject(anAngle2IO);
- myPrsType = TYPE_TWO_ANGLES; // Overwrite type with TWO_ANGLES
-
+
// Display modified presentation
if (isAngleVisible)
((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Display(myAnglePrs);
}
else if (aSPrs)
{
- aSPrs->AddObject(anAngle2IO);
+ aSPrs->AddObject(anAngle2IO);
}
+
+ myPrsType = TYPE_TWO_ANGLES; // Overwrite type with TWO_ANGLES
}
-
- if(!store && isAngleVisible)
- {
- GEOMBase_Helper::displayPreview( aSPrs, true, true );
+
+ if (!store && isAngleVisible)
+ {
+ GEOMBase_Helper::displayPreview(aSPrs, true, true);
}
}
// Function : displayLength()
// 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();
-
+
XYZ Last = getLastPoint();
XYZ Current = getCurrentPoint();
XYZ Penultimate = getPenultimatePoint();
- double aLength = 0.0;
+ bool withAngle = (type == TYPE_ANGLE || type == TYPE_TWO_ANGLES);
+ bool twoAngles = (type == TYPE_TWO_ANGLES);
- if( theLength < 0) // Calculate length if not given
+ double aLength = 0.0;
+
+ if (theLength < 0) // Calculate length if not given
{
aLength = sqrt((Last.x - Current.x)*(Last.x - Current.x) +
- (Last.y - Current.y)*(Last.y - Current.y) +
+ (Last.y - Current.y)*(Last.y - Current.y) +
(Last.z - Current.z)*(Last.z - Current.z));
}
else
aLength = theLength;
-
+
if (aLength<Precision::Confusion())
return;
-
+
gp_Pnt P1 = gp_Pnt(Last.x,Last.y,Last.z);
gp_Pnt P2 = gp_Pnt(Current.x,Current.y,Current.z);
gp_Pnt P3 = gp_Pnt(Penultimate.x,Penultimate.y,Penultimate.z);
-
+
gp_Vec Vec1(P1,P2);
gp_Vec Vec2(P1,P3);
-
+ gp_Vec Vec3 = Vec1;
+
TopoDS_Vertex aVert1 = BRepBuilderAPI_MakeVertex(P1);
TopoDS_Vertex aVert2 = BRepBuilderAPI_MakeVertex(P2);
-
+
// Convert length to string
std::string aLength_str = doubleToString(aLength);
- // Plane for the presentation
- if ( Abs(Vec1.CrossMagnitude(Vec2)) < Precision::Confusion() ) // Check colinearity
+ // Define the suitable plane for right relative positioning of dimension presentations
+
+ gp_Dir aNormal; // Normal defining the plane of the presentation
+ if (withAngle) // If one angle
{
- Vec2 = gp_Vec(gp::DX());
- if ( Abs(Vec1.CrossMagnitude(Vec2)) < Precision::Confusion())
+ switch(myOrientation)
{
- Vec2 = gp_Vec(gp::DY());
+ 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;
+ }
}
- }
-
- // Normal to the representation plane
- gp_Dir Normal(Vec2.Crossed(Vec1));
-
-// // 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();
-// }
-// }
+ 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());
+ if (Abs(Vec1.CrossMagnitude(Vec2)) < Precision::Confusion())
+ {
+ 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
- gce_MakePln gce_MP(P1, Normal);
+ // Plane construction
+ gce_MakePln gce_MP(P1, aNormal);
Handle(Geom_Plane) aPlane = new Geom_Plane(gce_MP.Value());
-
- Handle(AIS_LengthDimension) anIO = new AIS_LengthDimension(aVert1,
- aVert2,
- aPlane,
- aLength,
- TCollection_ExtendedString(aLength_str.c_str()));
+
+ Handle(AIS_LengthDimension) anIO =
+ new AIS_LengthDimension(aVert1,
+ aVert2,
+ aPlane,
+ aLength,
+ TCollection_ExtendedString(aLength_str.c_str()));
anIO->SetArrowSize(aLength/20);
-
+
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
int w = resMgr->integerValue("Geometry", "measures_line_width", 1);
Handle(Prs3d_LengthAspect) asp = new Prs3d_LengthAspect();
asp->LineAspect()->SetWidth(w);
anIO->Attributes()->SetLengthAspect(asp);
-
+
if (store)
{
// Erase length dimensions presentation
((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Erase(myLengthPrs, true);
-
myLengthPrs->PrependObject(anIO);
- myPrsType = TYPE_LENGTH;
-
+
// Display modified presentation
if (isLengthVisible)
((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Display(myLengthPrs);
}
- 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)
{
aSPrs->PrependObject(anIO);
- GEOMBase_Helper::displayPreview( aSPrs, true, true );
+ GEOMBase_Helper::displayPreview(aSPrs, true, true);
}
}
+
+ myPrsType = TYPE_LENGTH;
}
//================================================================
// Function : createShapes
// Purpose : Create applyed wire, and last segment from entry object
//================================================================
-bool EntityGUI_3DSketcherDlg::createShapes( GEOM::GEOM_Object_ptr /*theObject*/,
+bool EntityGUI_3DSketcherDlg::createShapes (GEOM::GEOM_Object_ptr /*theObject*/,
TopoDS_Shape& theApplyedWire,
- TopoDS_Shape& theLastSegment )
+ TopoDS_Shape& theLastSegment)
{
QList<gp_Pnt> points;
- foreach( XYZ xyz, myPointsList) {
+ foreach (XYZ xyz, myPointsList) {
gp_Pnt p(xyz.x, xyz.y, xyz.z);
- if ( points.isEmpty() || points.last().Distance(p) > gp::Resolution())
+ if (points.isEmpty() || points.last().Distance(p) > gp::Resolution())
points << p;
- }
-
- if ( points.count() == 1 ) {
+ }
+
+ if (points.count() == 1) {
// only one point is created
BRepBuilderAPI_MakeVertex mkVertex (points.last());
theApplyedWire = mkVertex.Shape();
}
- else if ( points.count() > 1 ) {
+ else if (points.count() > 1) {
// wire is created
BRepBuilderAPI_MakePolygon mkWire;
- foreach( gp_Pnt p, points )
+ foreach(gp_Pnt p, points)
mkWire.Add(p);
theApplyedWire = mkWire.Shape();
}
XYZ curxyz = getCurrentPoint();
gp_Pnt curpnt(curxyz.x, curxyz.y, curxyz.z);
-
- if ( points.isEmpty() || points.last().Distance(curpnt) <= gp::Resolution() ) {
+
+ if (points.isEmpty() || points.last().Distance(curpnt) <= gp::Resolution()) {
BRepBuilderAPI_MakeVertex mkVertex (curpnt);
theLastSegment = mkVertex.Shape();
}
/* VSR: old algorithm does not work properly, see bug 0020899
TopoDS_Shape aShape;
- if ( !GEOMBase::GetShape( theObject, aShape ) )
+ if (!GEOMBase::GetShape(theObject, aShape))
return false;
- if( aShape.ShapeType() != TopAbs_WIRE && aShape.ShapeType() != TopAbs_VERTEX )
+ if (aShape.ShapeType() != TopAbs_WIRE && aShape.ShapeType() != TopAbs_VERTEX)
return false;
theApplyedWire = aShape;
- if ( myOK )
+ if (myOK)
return true;
BRepBuilderAPI_MakeWire aBuilder;
- TopExp_Explorer edgeExp( aShape, TopAbs_EDGE );
- while ( 1 ) {
+ TopExp_Explorer edgeExp(aShape, TopAbs_EDGE);
+ while (1) {
TopoDS_Shape anEdge = edgeExp.Current();
edgeExp.Next();
- if ( edgeExp.More() ) // i.e. non-last edge
- aBuilder.Add( TopoDS::Edge( anEdge ) );
+ if (edgeExp.More()) // i.e. non-last edge
+ aBuilder.Add(TopoDS::Edge(anEdge));
else {
theLastSegment = anEdge;
break;
}
}
- if ( aBuilder.IsDone() ) {
+ if (aBuilder.IsDone()) {
theApplyedWire = aBuilder.Shape();
}
- else if ( !theLastSegment.IsNull() ) {
- TopExp_Explorer vertexExp( theLastSegment, TopAbs_VERTEX );
+ else if (!theLastSegment.IsNull()) {
+ TopExp_Explorer vertexExp(theLastSegment, TopAbs_VERTEX);
theApplyedWire = vertexExp.Current();
}
*/
// Function : doubleToString
// Purpose : converts double to string
//================================================================
-std::string EntityGUI_3DSketcherDlg::doubleToString(double num)
+std::string EntityGUI_3DSketcherDlg::doubleToString (double num)
{
// truncate num
int digNum = 5;
char format = 'g'; // truncated to a number of significant digits
-
- return QString::number( num, format, digNum).toStdString();
+
+ return QString::number(num, format, digNum).toStdString();
}
// 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 : EntityGUI_3DSketcherDlg.h
// Author : DMV, OCN
-//
+
#ifndef ENTITYGUI_3DSKETCHERDLG_H
#define ENTITYGUI_3DSKETCHERDLG_H
struct XYZ
{
- XYZ() { x = y = z = 0.0; xt = yt = zt = "0.0"; }
- double x, y, z;
- QString xt, yt, zt;
+ XYZ() { x = y = z = 0.0; command = params = ""; }
+ double x, y, z; // for preview only
+ QString command;
+ QString params;
};
typedef QList<XYZ> XYZList;
public:
- EntityGUI_3DSketcherDlg( GeometryGUI*, QWidget* = 0, bool = false, Qt::WindowFlags = 0, const double = 2. );
+ EntityGUI_3DSketcherDlg (GeometryGUI*, QWidget* = 0, bool = false, Qt::WindowFlags = 0, const double = 2.);
~EntityGUI_3DSketcherDlg();
protected:
void displayTrihedron( int );
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,
TopoDS_Shape&,
bool ClickOnApply();
// bool isSameAsPrevious();
void UpdateButtonsState();
+ void UpdatePointCoordinates();
void ClickOnUndo();
void ClickOnRedo();
<rect>
<x>0</x>
<y>0</y>
- <width>327</width>
- <height>50</height>
+ <width>278</width>
+ <height>181</height>
</rect>
</property>
<property name="windowTitle">
</property>
<item row="0" column="0">
<widget class="QGroupBox" name="GroupBox1">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="title">
<string/>
</property>
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0">
- <widget class="QCheckBox" name="CheckBox2">
- <property name="text">
- <string/>
- </property>
- </widget>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <widget class="QCheckBox" name="CheckBox2">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QCheckBox" name="CheckBox1">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QCheckBox" name="CheckBox3">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
</item>
- <item row="1" column="0">
- <widget class="QCheckBox" name="CheckBox1">
- <property name="text">
- <string/>
- </property>
- </widget>
+ <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>
</widget>
GroupD2->show();
Group3Spin->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
}
resize( minimumSizeHint() );
void EntityGUI_SketcherDlg::Dir2Clicked( int constructorId )
{
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
double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_VX2" ) );
Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_VY2" ) );
- myDX = 0.0;
Group3Spin->SpinBox_DX->setValue( myDX );
- myDY = 0.0;
Group3Spin->SpinBox_DY->setValue( myDY );
Group3Spin->show();
Group3Spin->buttonApply->setFocus();
Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_ANGLE2" ));
Group3Spin->SpinBox_DX->setValue( myAngle );
- myRadius = 100.0;
Group3Spin->SpinBox_DY->setValue( myRadius );
- myLength = 30.0;
Group3Spin->SpinBox_DZ->setValue( myLength );
Group3Spin->show();
Group3Spin->buttonApply->setFocus();
initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 5., "angle_precision" );
Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
- myRadius = 100.0;
+// myRadius = 100.0;
Group2Spin->SpinBox_DX->setValue( myRadius );
- myLength = 30.0;
+// myLength = 30.0;
Group2Spin->SpinBox_DY->setValue( myLength );
Group2Spin->show();
Group2Spin->buttonApply->setFocus();
initSpinBox( Group2Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 5., "angle_precision" );
Group2Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_RADIUS2" ) );
Group2Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_ANGLE2" ) );
- myRadius = 100.0;
+// myRadius = 100.0;
Group2Spin->SpinBox_DX->setValue( myRadius );
- myLength = 30.0;
+// myLength = 30.0;
Group2Spin->SpinBox_DY->setValue( myLength );
Group2Spin->show();
Group2Spin->buttonApply->setFocus();
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_DS, COORD_MIN, COORD_MAX, 5., "length_precision" );
- myDX = 0.0;
Group4Spin->SpinBox_DX->setValue( myDX );
- myDY = 0.0;
Group4Spin->SpinBox_DY->setValue( myDY );
- myRadius = 100.0;
+// myRadius = 100.0;
Group4Spin->SpinBox_DZ->setValue( myRadius );
- myLength = 30.0;
+// myLength = 30.0;
Group4Spin->SpinBox_DS->setValue( myLength );
Group4Spin->show();
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() );
GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
}
// add function description before dump
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
if (aFuncScript.Location( aCurScript,
aFuncScript.Length() - aCurScript.Length(),
aFuncScript.Length()))
- continue;
+ continue; // aCurScript is already at the end of aFuncScript
aFuncScript += aCurScript;
}
if (isDumpCollected ) {
//=============================================================================
/*!
- * ProcessFunction: Dump fucntion description into script
+ * ProcessFunction: Dump function description into script
*/
//=============================================================================
bool ProcessFunction(Handle(GEOM_Function)& theFunction,
//Check if its internal function which doesn't requires dumping
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
if (theIsPublished)
{
//Replace parameter by notebook variables
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 ) {
int i = 1;
bool isBefore = true;
aPc.SetXYZ(aXYZc);
aInfo.SetLocation(aPc);
//
- gp_Vec aVec(aPc, aP2);
- gp_Dir aDir(aVec);
- aInfo.SetDirection(aDir);
+ if ( aLength >= gp::Resolution() ) {
+ gp_Vec aVec(aPc, aP2);
+ gp_Dir aDir(aVec);
+ aInfo.SetDirection(aDir);
+ }
}
//modified by NIZNHY-PKV Tue Jul 03 10:19:06 2012t
// Line
// 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 : GEOMGUI_Selection.cxx
// Author : Alexander SOLOVYOV, Open CASCADE S.A.S. (alexander.solovyov@opencascade.com)
-//
+
#include "GEOMGUI_Selection.h"
#include "GeometryGUI.h"
v = isVectorsMode( idx );
else if ( p == "topLevel" )
v = topLevel( idx );
- else if ( p == "hasHiddenChildren" )
- v = hasHiddenChildren( idx );
- else if ( p == "hasShownChildren" )
- v = hasShownChildren( idx );
+ else if ( p == "hasChildren" )
+ v = hasChildren( idx );
+ else if ( p == "hasConcealedChildren" )
+ v = hasConcealedChildren( idx );
+ else if ( p == "hasDisclosedChildren" )
+ v = hasDisclosedChildren( idx );
else if ( p == "compoundOfVertices" )
v = compoundOfVertices( idx );
else if ( p == "imported" )
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;
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( study() );
return OK;
}
-bool GEOMGUI_Selection::hasShownChildren( const int index ) const
+bool GEOMGUI_Selection::hasDisclosedChildren( const int index ) const
{
bool OK = false;
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( study() );
// 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 : GEOMGUI_Selection.h
// Author : Alexander SOLOVYOV, Open CASCADE S.A.S. (alexander.solovyov@opencascade.com)
-//
+
#ifndef GEOMGUI_SELECTION_H
#define GEOMGUI_SELECTION_H
QString displayMode( const int ) const;
QString selectionMode() const;
bool isVectorsMode( const int ) const;
- bool hasHiddenChildren( const int ) const;
- bool hasShownChildren( const int ) const;
+ bool hasChildren( const int ) const;
+ bool hasConcealedChildren( const int ) const;
+ bool hasDisclosedChildren( const int ) const;
bool compoundOfVertices( const int ) const;
bool topLevel( const int ) const;
bool isPhysicalMaterial( const int ) const;
#include <Graphic3d_HArray1OfBytes.hxx>
#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
// Purpose : Get active study, returns 0 if no open study frame
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 )
{
int aHue = -1;
hasColor = false;
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()) {
SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
if ( study ) {
+ _PTR(Study) aStudy = study->studyDS();
aSColor = theGeomObject->GetColor();
hasColor = aSColor.R >= 0 && aSColor.G >= 0 && aSColor.B >= 0;
- if( !hasColor && theGeomObject->GetType() == GEOM_GROUP ) { // auto color for group
- GEOM::GEOM_Gen_var theGeomGen = GeometryGUI::GetGeomGen();
- GEOM::GEOM_IGroupOperations_var anOperations = theGeomGen->GetIGroupOperations( study->id() );
- GEOM::GEOM_Object_var aMainObject = anOperations->GetMainShape( theGeomObject );
- if ( !aMainObject->_is_nil() && aMainObject->GetAutoColor() )
- {
- QList<SALOMEDS::Color> aReservedColors;
-
- SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( app );
- CORBA::String_var IOR = app->orb()->object_to_string( aMainObject );
- if ( strcmp(IOR.in(), "") != 0 )
- {
- _PTR(Study) aStudy = study->studyDS();
- _PTR(SObject) aMainSObject( aStudy->FindObjectIOR( std::string(IOR) ) );
- _PTR(ChildIterator) it( aStudy->NewChildIterator( aMainSObject ) );
- for( ; it->More(); it->Next() )
- {
- _PTR(SObject) aChildSObject( it->Value() );
- GEOM::GEOM_Object_var aChildObject =
- GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aChildSObject));
- if( CORBA::is_nil( aChildObject ) )
- continue;
-
- if( aChildObject->GetType() != GEOM_GROUP )
- continue;
-
- SALOMEDS::Color aReservedColor = aChildObject->GetColor();
- aReservedColors.append( aReservedColor );
- }
- }
-
- aSColor = getUniqueColor( aReservedColors );
- hasColor = true;
- }
+ if ( !hasColor ) {
+#ifdef GENERAL_AUTOCOLOR // auto-color for all sub-shapes
+ bool general_autocolor = true;
+#else // auto-color for groups only
+ 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;
+ CORBA::String_var IOR = app->orb()->object_to_string( aMainObject );
+ _PTR(SObject) aMainSObject( aStudy->FindObjectIOR( IOR.in() ) );
+ if ( aMainSObject ) {
+ _PTR(ChildIterator) it( aStudy->NewChildIterator( aMainSObject ) );
+ for ( ; it->More(); it->Next() ) {
+ _PTR(SObject) aChildSObject( it->Value() );
+ GEOM::GEOM_Object_var aChildObject =
+ GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aChildSObject));
+ if ( CORBA::is_nil( aChildObject ) )
+ continue;
+
+ SALOMEDS::Color aReservedColor = aChildObject->GetColor();
+ if ( aReservedColor.R >= 0 && aReservedColor.G >= 0 && aReservedColor.B >= 0 )
+ aReservedColors.append( aReservedColor );
+ }
+ }
+ aSColor = getUniqueColor( aReservedColors );
+ hasColor = true;
+#endif // SIMPLE_AUTOCOLOR
+ }
+ }
}
}
}
SalomeApp_Study* getStudy() const;
static SALOMEDS::Color getUniqueColor( const QList<SALOMEDS::Color>& );
+ static SALOMEDS::Color getPredefinedUniqueColor();
static PropMap getDefaultPropertyMap(const QString& viewer_type);
<source>ICON_DLG_CHECK_COMPOUND_OF_BLOCKS</source>
<translation>check_blocks_compound.png</translation>
</message>
+ <message>
+ <source>ICON_DLG_GETNONBLOCKS</source>
+ <translation>get_non_blocks.png</translation>
+ </message>
<message>
<source>ICON_DLG_CHECK_SELF_INTERSECTIONS</source>
<translation>check_self_intersections.png</translation>
<source>ICO_CHECK_COMPOUND</source>
<translation>check_blocks_compound.png</translation>
</message>
+ <message>
+ <source>ICO_GET_NON_BLOCKS</source>
+ <translation>get_non_blocks.png</translation>
+ </message>
<message>
<source>ICO_CHECK_SELF_INTERSECTIONS</source>
<translation>check_self_intersections.png</translation>
<source>ICO_COMMON</source>
<translation>common.png</translation>
</message>
+ <message>
+ <source>ICO_GROUP_INTERSECT</source>
+ <translation>common.png</translation>
+ </message>
<message>
<source>ICO_COMPOUND</source>
<translation>build_compound.png</translation>
<source>ICO_CUT</source>
<translation>cut.png</translation>
</message>
+ <message>
+ <source>ICO_GROUP_CUT</source>
+ <translation>cut.png</translation>
+ </message>
<message>
<source>ICO_CYLINDER</source>
<translation>cylinder.png</translation>
<source>ICO_FUSE</source>
<translation>fuse.png</translation>
</message>
+ <message>
+ <source>ICO_GROUP_UNION</source>
+ <translation>fuse.png</translation>
+ </message>
<message>
<source>ICO_GLUE_FACES</source>
<translation>glue.png</translation>
<source>BRep_API: command not done</source>
<translation>Error: can't build object</translation>
</message>
+ <message>
+ <source>PAL_NOT_DONE_ERROR</source>
+ <translation>Operation aborted</translation>
+ </message>
<message>
<source>CHANGE_ORIENTATION_NEW_OBJ_NAME</source>
<translation>Invert</translation>
<source>GEOM_CHECK_BLOCKS_COMPOUND_SUBSHAPES</source>
<translation>Incriminated Sub-shapes</translation>
</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>
<source>GEOM_CHECK_INFOS</source>
<translation>Object And Its Topological Information</translation>
<source>GEOM_COORDINATES_TYPE</source>
<translation>Coordinates Type</translation>
</message>
+ <message>
+ <source>GEOM_CONTROLS</source>
+ <translation>Dimensions</translation>
+ </message>
<message>
<source>GEOM_SOLID</source>
<translation>Solid</translation>
<source>MEN_CHECK_COMPOUND</source>
<translation>Check Compound of Blocks</translation>
</message>
+ <message>
+ <source>MEN_GET_NON_BLOCKS</source>
+ <translation>Get Non Blocks</translation>
+ </message>
<message>
<source>MEN_CHECK_SELF_INTERSECTIONS</source>
<translation>Detect Self-intersections</translation>
<source>MEN_DISPLAY_ONLY</source>
<translation>Show Only</translation>
</message>
+ <message>
+ <source>MEN_SHOW_ONLY_CHILDREN</source>
+ <translation>Show Only Children</translation>
+ </message>
<message>
<source>MEN_BRING_TO_FRONT</source>
<translation>Bring To Front</translation>
<source>MEN_GROUP_EDIT</source>
<translation>Edit</translation>
</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>
<source>MEN_RELOAD_IMPORTED</source>
<translation>Reload From Disk</translation>
<translation>Create Group</translation>
</message>
<message>
- <source>MEN_POP_SHOW_CHILDREN</source>
- <translation>Show Children</translation>
+ <source>MEN_POP_DISCLOSE_CHILDREN</source>
+ <translation>Disclose child items</translation>
</message>
<message>
- <source>MEN_POP_HIDE_CHILDREN</source>
- <translation>Hide Children</translation>
+ <source>MEN_POP_CONCEAL_CHILDREN</source>
+ <translation>Conceal child items</translation>
</message>
<message>
<source>MEN_POP_UNPUBLISH_OBJ</source>
<source>STB_CHECK_COMPOUND</source>
<translation>Check compound of blocks</translation>
</message>
+ <message>
+ <source>STB_GET_NON_BLOCKS</source>
+ <translation>Get non blocks</translation>
+ </message>
<message>
<source>STB_CHECK_SELF_INTERSECTIONS</source>
<translation>Detect Self-intersections</translation>
<source>STB_DISPLAY_ONLY</source>
<translation>Show only</translation>
</message>
+ <message>
+ <source>STB_SHOW_ONLY_CHILDREN</source>
+ <translation>Show Only Children</translation>
+ </message>
<message>
<source>STB_EDGE</source>
<translation>Build an edge</translation>
<source>STB_GROUP_EDIT</source>
<translation>Edit a group</translation>
</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>
<source>STB_RELOAD_IMPORTED</source>
<translation>Reload imported shape from its original place on disk</translation>
<source>STB_POP_CREATE_GROUP</source>
<translation>Create Group</translation>
</message>
- <message>
- <source>STB_POP_SHOW_CHILDREN</source>
- <translation>Show child objects</translation>
- </message>
<message>
<source>STB_POP_UNPUBLISH_OBJ</source>
<translation>Unpublish object</translation>
<translation>Publish object</translation>
</message>
<message>
- <source>STB_POP_HIDE_CHILDREN</source>
- <translation>Hide child objects</translation>
+ <source>STB_POP_DISCLOSE_CHILDREN</source>
+ <translation>Disclose child items</translation>
+ </message>
+ <message>
+ <source>STB_POP_CONCEAL_CHILDREN</source>
+ <translation>Conceal child items</translation>
</message>
<message>
<source>STB_POP_ISOS</source>
<source>TOP_CHECK_COMPOUND</source>
<translation>Check compound of blocks</translation>
</message>
+ <message>
+ <source>TOP_GET_NON_BLOCKS</source>
+ <translation>Get non blocks</translation>
+ </message>
<message>
<source>TOP_CHECK_SELF_INTERSECTIONS</source>
<translation>Detect Self-intersections</translation>
<source>TOP_DISPLAY_ONLY</source>
<translation>Show only</translation>
</message>
+ <message>
+ <source>TOP_SHOW_ONLY_CHILDREN</source>
+ <translation>Show Only Children</translation>
+ </message>
<message>
<source>TOP_EDGE</source>
<translation>Build edge</translation>
<source>TOP_GROUP_EDIT</source>
<translation>Edit a group</translation>
</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>
<source>TOP_HEX_SOLID</source>
<translation>Hexahedral Solid</translation>
<source>TOP_POP_CREATE_GROUP</source>
<translation>Create Group</translation>
</message>
- <message>
- <source>TOP_POP_SHOW_CHILDREN</source>
- <translation>Show Children</translation>
- </message>
<message>
<source>TOP_POP_UNPUBLISH_OBJ</source>
<translation>Unpublish object</translation>
<translation>Publish object</translation>
</message>
<message>
- <source>TOP_POP_HIDE_CHILDREN</source>
- <translation>Hide Children</translation>
+ <source>TOP_POP_DISCLOSE_CHILDREN</source>
+ <translation>Disclose child items</translation>
+ </message>
+ <message>
+ <source>TOP_POP_CONCEAL_CHILDREN</source>
+ <translation>Conceal child items</translation>
</message>
<message>
<source>TOP_POP_ISOS</source>
<translation>Please, select a group to edit</translation>
</message>
</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>
<name>GroupGUI_GroupDlg</name>
<message>
NotViewerDependentCommands << GEOMOp::OpDelete
<< GEOMOp::OpShow
<< GEOMOp::OpShowOnly
- << GEOMOp::OpShowChildren
- << GEOMOp::OpHideChildren
+ << GEOMOp::OpShowOnlyChildren
+ << GEOMOp::OpDiscloseChildren
+ << GEOMOp::OpConcealChildren
<< GEOMOp::OpUnpublishObject
<< GEOMOp::OpPublishObject
<< GEOMOp::OpPointMarker;
case GEOMOp::OpDecrNbIsos: // SHORTCUT - DECREASE NB ISOS
case GEOMOp::OpAutoColor: // POPUP MENU - AUTO COLOR
case GEOMOp::OpNoAutoColor: // POPUP MENU - DISABLE AUTO COLOR
- case GEOMOp::OpShowChildren: // POPUP MENU - SHOW CHILDREN
- case GEOMOp::OpHideChildren: // POPUP MENU - HIDE CHILDREN
+ case GEOMOp::OpDiscloseChildren: // POPUP MENU - DISCLOSE CHILD ITEMS
+ case GEOMOp::OpConcealChildren: // POPUP MENU - CONCEAL CHILD ITEMS
case GEOMOp::OpUnpublishObject: // POPUP MENU - UNPUBLISH
case GEOMOp::OpPublishObject: // ROOT GEOM OBJECT - POPUP MENU - PUBLISH
case GEOMOp::OpPointMarker: // POPUP MENU - POINT MARKER
case GEOMOp::OpDMShadingWithEdges: // MENU VIEW - SHADING
case GEOMOp::OpShowAll: // MENU VIEW - SHOW ALL
case GEOMOp::OpShowOnly: // MENU VIEW - DISPLAY ONLY
+ case GEOMOp::OpShowOnlyChildren: // MENU VIEW - SHOW ONLY CHILDREN
case GEOMOp::OpHideAll: // MENU VIEW - ERASE ALL
case GEOMOp::OpHide: // MENU VIEW - ERASE
case GEOMOp::OpShow: // MENU VIEW - DISPLAY
case GEOMOp::OpWhatIs: // MENU MEASURE - WHATIS
case GEOMOp::OpCheckShape: // MENU MEASURE - CHECK
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::OpCheckSelfInters: // MENU MEASURE - CHECK SELF INTERSECTIONS
libName = "MeasureGUI";
case GEOMOp::OpGroupCreate: // MENU GROUP - CREATE
case GEOMOp::OpGroupCreatePopup: // POPUP MENU - CREATE GROUP
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";
break;
case GEOMOp::OpHexaSolid: // MENU BLOCKS - HEXAHEDRAL SOLID
createGeomAction( GEOMOp::OpGroupCreate, "GROUP_CREATE" );
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::OpWhatIs, "WHAT_IS" );
createGeomAction( GEOMOp::OpCheckShape, "CHECK" );
createGeomAction( GEOMOp::OpCheckCompound, "CHECK_COMPOUND" );
+ createGeomAction( GEOMOp::OpGetNonBlocks, "GET_NON_BLOCKS" );
createGeomAction( GEOMOp::OpCheckSelfInters, "CHECK_SELF_INTERSECTIONS" );
#ifdef _DEBUG_ // PAL16821
createGeomAction( GEOMOp::OpSelectCompound, "COMPOUND_SEL_ONLY", "", 0, true );
createGeomAction( GEOMOp::OpSelectAll, "ALL_SEL_ONLY", "", 0, true );
createGeomAction( GEOMOp::OpShowOnly, "DISPLAY_ONLY" );
+ createGeomAction( GEOMOp::OpShowOnlyChildren, "SHOW_ONLY_CHILDREN" );
createGeomAction( GEOMOp::OpBringToFront, "BRING_TO_FRONT", "", 0, true );
createGeomAction( GEOMOp::OpClsBringToFront, "CLS_BRING_TO_FRONT" );
createGeomAction( GEOMOp::OpHide, "ERASE" );
createGeomAction( GEOMOp::OpAutoColor, "POP_AUTO_COLOR" );
createGeomAction( GEOMOp::OpNoAutoColor, "POP_DISABLE_AUTO_COLOR" );
createGeomAction( GEOMOp::OpGroupCreatePopup, "POP_CREATE_GROUP" );
- createGeomAction( GEOMOp::OpShowChildren, "POP_SHOW_CHILDREN" );
- createGeomAction( GEOMOp::OpHideChildren, "POP_HIDE_CHILDREN" );
+ createGeomAction( GEOMOp::OpDiscloseChildren, "POP_DISCLOSE_CHILDREN" );
+ createGeomAction( GEOMOp::OpConcealChildren, "POP_CONCEAL_CHILDREN" );
createGeomAction( GEOMOp::OpUnpublishObject, "POP_UNPUBLISH_OBJ" );
createGeomAction( GEOMOp::OpPublishObject, "POP_PUBLISH_OBJ" );
createGeomAction( GEOMOp::OpPointMarker, "POP_POINT_MARKER" );
createMenu( separator(), newEntId, -1 );
int groupId = createMenu( tr( "MEN_GROUP" ), newEntId, -1 );
- createMenu( GEOMOp::OpGroupCreate, groupId, -1 );
- createMenu( GEOMOp::OpGroupEdit, groupId, -1 );
+ createMenu( GEOMOp::OpGroupCreate, 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( GEOMOp::OpWhatIs, measurId, -1 );
createMenu( GEOMOp::OpCheckShape, measurId, -1 );
createMenu( GEOMOp::OpCheckCompound, measurId, -1 );
+ createMenu( GEOMOp::OpGetNonBlocks, measurId, -1 );
createMenu( GEOMOp::OpCheckSelfInters, measurId, -1 );
#ifdef _DEBUG_ // PAL16821
createTool( GEOMOp::OpWhatIs, measureTbId );
createTool( GEOMOp::OpCheckShape, measureTbId );
createTool( GEOMOp::OpCheckCompound, measureTbId );
+ createTool( GEOMOp::OpGetNonBlocks, measureTbId );
createTool( GEOMOp::OpCheckSelfInters, measureTbId );
-
+
int picturesTbId = createTool( tr( "TOOL_PICTURES" ) );
createTool( GEOMOp::OpPictureImport, picturesTbId );
#ifdef WITH_OPENCV
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->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->setRule( action( GEOMOp::OpShowChildren ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasHiddenChildren=true"), QtxPopupMgr::VisibleRule );
+ mgr->insert( action( GEOMOp::OpDiscloseChildren ), -1, -1 ); // disclose child items
+ 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->setRule( action( GEOMOp::OpHideChildren ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasShownChildren=true"), QtxPopupMgr::VisibleRule );
+ mgr->insert( action( GEOMOp::OpConcealChildren ), -1, -1 ); // conceal shild items
+ 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->setRule( action( GEOMOp::OpGroupEdit ), QString("client='ObjectBrowser' and type='Group' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
mgr->insert( separator(), -1, -1 ); // -----------
mgr->setRule(action(GEOMOp::OpSelectAll), selectOnly + " and selectionmode='ALL'", QtxPopupMgr::ToggleRule);
mgr->insert( action(GEOMOp::OpShowOnly ), -1, -1 ); // display only
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( action( GEOMOp::OpUnpublishObject ), -1, -1 ); // Unpublish object
void GeometryGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& title )
{
SalomeApp_Module::contextMenuPopup( client, menu, title );
-
- /*
SALOME_ListIO lst;
- getApp()->selectionMgr()->selectedObjects(lst);
- if (lst.Extent() < 1)
- return;
-
- SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
- _PTR(Study) study = appStudy->studyDS();
-
- bool isImported = true;
- SALOME_ListIteratorOfListIO anIt (lst);
- for (; anIt.More() && isImported; anIt.Next()) {
- Handle(SALOME_InteractiveObject) io = anIt.Value();
- _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;
+ getApp()->selectionMgr()->selectedObjects( lst );
+ if ( ( client == "OCCViewer" || client == "VTKViewer" ) && lst.Extent() == 1 ) {
+ Handle(SALOME_InteractiveObject) io = lst.First();
+ SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() );
+ _PTR(Study) study = appStudy->studyDS();
+ _PTR(SObject) obj = study->FindObjectID( io->getEntry() );
+ if ( obj ) {
+ QString aName = QString( obj->GetName().c_str() );
+ aName.remove( QRegExp("\\s+$") );
+ title = aName;
}
}
-
- if (isImported) {
- menu->addAction(action(GEOMOp::OpReimport)); // Reload imported shape
- }
- */
}
void GeometryGUI::createPreferences()
namespace GEOMOp {
enum {
- // ToolsGUI ------------------//--------------------------------
+ // ToolsGUI --------------------//--------------------------------
OpImport = 1000, // MENU FILE - IMPORT
OpExport = 1001, // MENU FILE - EXPORT
OpDelete = 1020, // MENU EDIT - DELETE
OpPointMarker = 1210, // POPUP MENU - POINT MARKER
OpSetTexture = 1211, // POPUP MENU - SETTEXTURE
OpMaterialProperties = 1212, // POPUP MENU - MATERIAL PROPERTIES
- OpShowChildren = 1250, // POPUP MENU - SHOW CHILDREN
- OpHideChildren = 1251, // POPUP MENU - HIDE CHILDREN
+ OpDiscloseChildren = 1250, // POPUP MENU - DISCLOSE CHILD ITEMS
+ OpConcealChildren = 1251, // POPUP MENU - CONCEAL CHILD ITEMS
OpUnpublishObject = 1253, // POPUP MENU - UNPUBLISH
OpPublishObject = 1254, // GEOM ROOT OBJECT - POPUP MENU - PUBLISH
OpEdgeWidth = 1260, // POPUP MENU - LINE WIDTH - EDGE WIDTH
OpIsosWidth = 1261, // POPUP MENU - LINE WIDTH - ISOS WIDTH
-
- // DisplayGUI ----------------//--------------------------------
+ // DisplayGUI ------------------//--------------------------------
OpSwitchVectors = 2001, // MENU VIEW - DISPLAY MODE - SHOW/HIDE EDGE DIRECTION
OpShowAll = 2002, // MENU VIEW - SHOW ALL
OpHideAll = 2003, // MENU VIEW - HIDE ALL
OpShow = 2100, // POPUP MENU - SHOW
OpShowOnly = 2101, // POPUP MENU - SHOW ONLY
OpHide = 2102, // POPUP MENU - HIDE
+ OpShowOnlyChildren = 2103, // POPUP MENU - SHOW ONLY CHILDREN
OpWireframe = 2200, // POPUP MENU - DISPLAY MODE - WIREFRAME
OpShading = 2201, // POPUP MENU - DISPLAY MODE - SHADING
OpShadingWithEdges = 2202, // POPUP MENU - DISPLAY MODE - SHADING WITH EDGES
OpTexture = 2204, // POPUP MENU - DISPLAY MODE - TEXTURE
OpBringToFront = 2205, // POPUP MENU - BRING TO FRONT
OpClsBringToFront = 2206,
- // BasicGUI ------------------//--------------------------------
+ // BasicGUI --------------------//--------------------------------
OpPoint = 3000, // MENU NEW ENTITY - BASIC - POINT
OpLine = 3001, // MENU NEW ENTITY - BASIC - LINE
OpCircle = 3002, // MENU NEW ENTITY - BASIC - CIRCLE
OpCurve = 3007, // MENU NEW ENTITY - BASIC - CURVE
OpLCS = 3008, // MENU NEW ENTITY - BASIC - LOCAL COORDINATE SYSTEM
OpOriginAndVectors = 3009, // MENU NEW ENTITY - BASIC - ORIGIN AND BASE VECTORS
- // PrimitiveGUI --------------//--------------------------------
+ // PrimitiveGUI ----------------//--------------------------------
OpBox = 3100, // MENU NEW ENTITY - PRIMITIVES - BOX
OpCylinder = 3101, // MENU NEW ENTITY - PRIMITIVES - CYLINDER
OpSphere = 3102, // MENU NEW ENTITY - PRIMITIVES - SPHERE
OpCone = 3104, // MENU NEW ENTITY - PRIMITIVES - CONE
OpRectangle = 3105, // MENU NEW ENTITY - PRIMITIVES - FACE
OpDisk = 3106, // MENU NEW ENTITY - PRIMITIVES - DISK
- // GenerationGUI -------------//--------------------------------
+ // GenerationGUI ---------------//--------------------------------
OpPrism = 3200, // MENU NEW ENTITY - GENERATION - EXTRUSION
OpRevolution = 3201, // MENU NEW ENTITY - GENERATION - REVOLUTION
OpFilling = 3202, // MENU NEW ENTITY - GENERATION - FILLING
OpPipe = 3203, // MENU NEW ENTITY - GENERATION - EXTRUSION ALONG PATH
- // EntityGUI -----------------//--------------------------------
+ // EntityGUI -------------------//--------------------------------
Op2dSketcher = 3300, // MENU NEW ENTITY - SKETCHER
Op3dSketcher = 3301, // MENU NEW ENTITY - 3D SKETCHER
OpExplode = 3302, // MENU NEW ENTITY - EXPLODE
OpFeatureDetect = 3303, // MENU NEW ENTITY - FEATURE DETECTION
#endif
OpPictureImport = 3304, // MENU NEW ENTITY - IMPORT PICTURE IN VIEWER
-
- // BuildGUI ------------------//--------------------------------
+ // BuildGUI --------------------//--------------------------------
OpEdge = 3400, // MENU NEW ENTITY - BUILD - EDGE
OpWire = 3401, // MENU NEW ENTITY - BUILD - WIRE
OpFace = 3402, // MENU NEW ENTITY - BUILD - FACE
OpShell = 3403, // MENU NEW ENTITY - BUILD - SHELL
OpSolid = 3404, // MENU NEW ENTITY - BUILD - SOLID
OpCompound = 3405, // MENU NEW ENTITY - BUILD - COMPOUND
- // BooleanGUI ----------------//--------------------------------
+ // BooleanGUI ------------------//--------------------------------
OpFuse = 3500, // MENU OPERATIONS - BOOLEAN - FUSE
OpCommon = 3501, // MENU OPERATIONS - BOOLEAN - COMMON
OpCut = 3502, // MENU OPERATIONS - BOOLEAN - CUT
OpSection = 3503, // MENU OPERATIONS - BOOLEAN - SECTION
- // TransformationGUI ---------//--------------------------------
+ // TransformationGUI -----------//--------------------------------
OpTranslate = 3600, // MENU OPERATIONS - TRANSFORMATION - TRANSLATION
OpRotate = 3601, // MENU OPERATIONS - TRANSFORMATION - ROTATION
OpChangeLoc = 3602, // MENU OPERATIONS - TRANSFORMATION - LOCATION
OpMultiRotate = 3607, // MENU OPERATIONS - TRANSFORMATION - MULTI-ROTATION
OpReimport = 3608, // POPUP MENU - RELOAD IMPORTED
OpProjection = 3609, // MENU OPERATIONS - TRANSFORMATION - PROJECTION
- // OperationGUI
+ // OperationGUI ----------------//--------------------------------
OpPartition = 3700, // MENU OPERATION - PARTITION
OpArchimede = 3701, // MENU OPERATION - ARCHIMEDE
OpFillet3d = 3702, // MENU OPERATION - FILLET
OpSharedShapes = 3708, // MENU OPERATION - GET SHARED SHAPES
OpExtrudedBoss = 3709, // MENU OPERATION - ETRUDED BOSS
OpExtrudedCut = 3710, // MENU OPERATION - ETRUDED CUT
- // RepairGUI -----------------//--------------------------------
+ // RepairGUI -------------------//--------------------------------
OpSewing = 4000, // MENU REPAIR - SEWING
OpSuppressFaces = 4001, // MENU REPAIR - SUPPRESS FACES
OpSuppressHoles = 4002, // MENU REPAIR - SUPPRESS HOLES
OpLimitTolerance = 4012, // MENU REPAIR - LIMIT TOLERANCE
OpGlueEdges = 4013, // MENU REPAIR - GLUE EDGES
OpFuseEdges = 4014, // MENU REPAIR - FUSE COLLINEAR EDGES
- // MeasureGUI ----------------//--------------------------------
+ // MeasureGUI ------------------//--------------------------------
OpProperties = 5000, // MENU MEASURES - PROPERTIES
OpCenterMass = 5001, // MENU MEASURES - CENTRE OF MASS
OpInertia = 5002, // MENU MEASURES - INERTIA
OpCheckCompound = 5010, // MENU MEASURES - CHECK COMPOUND OF BLOCKS
OpPointCoordinates = 5011, // MENU MEASURES - POINT COORDINATES
OpCheckSelfInters = 5012, // MENU MEASURES - CHECK SELF INTERSECTIONS
- // GroupGUI ------------------//--------------------------------
+ OpGetNonBlocks = 5013, // MENU MEASURES - GET NON BLOCKS
+ // GroupGUI --------------------//--------------------------------
OpGroupCreate = 6000, // MENU GROUP - CREATE
OpGroupEdit = 6001, // MENU GROUP - EDIT
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
OpMultiTransform = 6101, // MENU BLOCKS - MULTI-TRANSFORMATION
OpQuadFace = 6102, // MENU BLOCKS - QUADRANGLE FACE
OpPropagate = 6103, // MENU BLOCKS - PROPAGATE
OpExplodeBlock = 6104, // MENU BLOCKS - EXPLODE ON BLOCKS
- // AdvancedGUI ---------------//--------------------------------
+ // AdvancedGUI -----------------//--------------------------------
OpAdvancedNoOp = 10000, // NO OPERATION (advanced operations base)
OpPipeTShape = 10001, // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE
-// OpPipeTShapeGroups = 10002, // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE GROUPS
- OpDividedDisk = 10003, // MENU NEW ENTITY - ADVANCED - DIVIDEDDISK
- OpDividedCylinder = 10004, // MENU NEW ENTITY - ADVANCED - DIVIDEDCYLINDER
+ //OpPipeTShapeGroups = 10002, // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE GROUPS
+ OpDividedDisk = 10003, // MENU NEW ENTITY - ADVANCED - DIVIDEDDISK
+ OpDividedCylinder = 10004, // MENU NEW ENTITY - ADVANCED - DIVIDEDCYLINDER
//@@ insert new functions before this line @@ do not remove this line @@//
};
}
+++ /dev/null
-// 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.cxx
-// Author : Nicolas REJNERI, Paul RASCLE
-//
-#include "GeometryGUI_Swig.hxx"
-
-#include "GeometryGUI.h"
-
-#include "SUIT_Desktop.h"
-#include "SUIT_Session.h"
-#include "SalomeApp_Application.h"
-#include "SalomeApp_Study.h"
-
-#include "OB_Browser.h"
-
-#include "OCCViewer_ViewWindow.h"
-#include "OCCViewer_ViewManager.h"
-#include "SOCC_ViewModel.h"
-#include <SOCC_Prs.h>
-
-#include "SVTK_ViewModel.h"
-#include "SVTK_ViewWindow.h"
-#include "SVTK_View.h"
-#include "SVTK_Renderer.h"
-#include <SVTK_Prs.h>
-
-#include "GEOM_Actor.h"
-#include "GEOM_Client.hxx"
-#include "GEOM_AISShape.hxx"
-#include "GEOM_InteractiveObject.hxx"
-#include "GEOM_Displayer.h"
-
-#include "SALOME_Event.h"
-
-// OCCT Includes
-#include <TopAbs.hxx>
-#include <TopoDS_Shape.hxx>
-#include <AIS_ListOfInteractive.hxx>
-#include <AIS_ListIteratorOfListOfInteractive.hxx>
-#include <AIS_Drawer.hxx>
-#include <BRepTools.hxx>
-
-// IDL Headers
-#include <SALOMEconfig.h>
-#include CORBA_SERVER_HEADER(GEOM_Gen)
-
-#include <vtkRenderer.h>
-
-static SHAPE_READER(ShapeReader);
-
-inline OCCViewer_Viewer* GetOCCViewer(SUIT_Application* theApp){
- SUIT_ViewWindow* window = theApp->desktop()->activeWindow();
- if(window && window->getViewManager()->getType() == OCCViewer_Viewer::Type()){
- OCCViewer_ViewWindow* vw = dynamic_cast<OCCViewer_ViewWindow*>( window );
- if ( vw ) {
- OCCViewer_ViewManager* vm = dynamic_cast<OCCViewer_ViewManager*>( vw->getViewManager() );
- if ( vm )
- return vm->getOCCViewer();
- }
- }
-
- return 0;
-}
-
-inline SVTK_ViewWindow* GetSVTKViewWindow(SUIT_Application* theApp){
- SUIT_ViewWindow* window = theApp->desktop()->activeWindow();
- if(window && window->getViewManager()->getType() == SVTK_Viewer::Type())
- return dynamic_cast<SVTK_ViewWindow*>( window );
-
- return 0;
-}
-
-GEOM_Swig::GEOM_Swig()
-{
- // MESSAGE("Constructeur");
-}
-
-GEOM_Swig::~GEOM_Swig()
-{
- // MESSAGE("Destructeur");
-}
-
-void GEOM_Swig::createAndDisplayGO (const char* Entry, bool isUpdated)
-{
- class TEvent: public SALOME_Event
- {
- std::string myEntry;
- bool myUpdateViewer;
- public:
- TEvent(const char* theEntry, bool toUpdateViewer):
- myEntry(theEntry),
- myUpdateViewer(toUpdateViewer)
- {}
- virtual void Execute()
- {
- SUIT_Application* app = SUIT_Session::session()->activeApplication();
- if (!app) return;
-
- SalomeApp_Study* ActiveStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
- if (!ActiveStudy) return;
-
- _PTR(Study) aStudy(ActiveStudy->studyDS());
- _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
-
- GEOM::GEOM_Gen_var Geom = GeometryGUI::GetGeomGen();
- if (CORBA::is_nil(Geom)) {
- GeometryGUI::InitGeomGen();
- Geom = GeometryGUI::GetGeomGen();
- }
- if (CORBA::is_nil(Geom))
- return;
-
- std::string aFatherIOR;
- _PTR(SComponent) father = aStudy->FindComponent("GEOM");
- if (!father)
- return;
- if (!father->ComponentIOR(aFatherIOR)) {
- CORBA::String_var objStr = SalomeApp_Application::orb()->object_to_string(Geom);
- aStudyBuilder->LoadWith(father, objStr.in());
- father->ComponentIOR(aFatherIOR);
- }
-
- _PTR(SObject) obj = aStudy->FindObjectID(myEntry);
- if (!obj)
- return;
-
- // Create new actor
- _PTR(GenericAttribute) anAttr;
- if (!obj->FindAttribute(anAttr, "AttributeIOR"))
- return;
- _PTR(AttributeIOR) anIOR(anAttr);
- std::string anIORValue = anIOR->Value();
-
- GEOM::GEOM_Object_var aShape = Geom->GetIORFromString(anIORValue.c_str());
- TopoDS_Shape Shape = ShapeReader.GetShape(Geom,aShape);
- if (!Shape.IsNull()) {
- if (obj->FindAttribute(anAttr, "AttributeName")) {
- _PTR(AttributeName) aName (anAttr);
- std::string aNameValue = aName->Value();
- // open transaction
- /*SUIT_Operation* op = new SalomeApp_ImportOperation (app);
- op->start();
-
- _PTR(SObject) newObj1 = aStudyBuilder->NewObject(father);
- aStudyBuilder->Addreference(newObj1, obj);
- // commit transaction
- op->commit();*/
- Handle(GEOM_InteractiveObject) anIO =
- new GEOM_InteractiveObject (const_cast<char*>(anIORValue.c_str()),
- const_cast<char*>(aFatherIOR.c_str()),
- "GEOM",
- const_cast<char*>( obj->GetID().c_str()));
-
- GEOM_Displayer(ActiveStudy).Display(anIO, myUpdateViewer);
- /*if (SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(app)) {
- SVTK_View* aView = aViewWindow->getView();
- int aMode = aView->GetDisplayMode();
-
- vtkActorCollection* theActors =
- GEOM_AssemblyBuilder::BuildActors(Shape,0,aMode,true);
- theActors->InitTraversal();
- while (vtkActor* anActor = theActors->GetNextActor()) {
- GEOM_Actor* GActor = GEOM_Actor::SafeDownCast(anActor);
- GActor->setName(const_cast<char*>(aNameValue.c_str()));
- GActor->setIO(anIO);
- aView->Display(GActor);
- }
- aView->Repaint();
- } else if (OCCViewer_Viewer* occViewer = GetOCCViewer(app)) {
- Handle(AIS_InteractiveContext) ic = occViewer->getAISContext();
- Handle(GEOM_AISShape) aSh =
- new GEOM_AISShape (Shape,const_cast<char*>(aNameValue.c_str()));
- aSh->setName(const_cast<char*>(aNameValue.c_str()));
- aSh->setIO(anIO);
- ic->Display(aSh);
- ic->AddOrRemoveCurrentObject(aSh,true);
- }*/
- // update object browser
- SalomeApp_Application* app = NULL; //dynamic_cast<SalomeApp_Application*>(app);
- if (app) {
- CAM_Module* module = app->module("Geometry");
- SalomeApp_Module* appMod = dynamic_cast<SalomeApp_Module*>(module);
- if (appMod)
- appMod->updateObjBrowser(true);
- }
- }
- }
- }
- };
-
- // MESSAGE("createAndDisplayGO");
- ProcessVoidEvent(new TEvent (Entry, isUpdated));
-
- class TEventUpdateBrowser: public SALOME_Event
- {
- public:
- TEventUpdateBrowser() {}
- virtual void Execute() {
- SalomeApp_Application* app =
- dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
- if (app) {
- CAM_Module* module = app->module("Geometry");
- SalomeApp_Module* appMod = dynamic_cast<SalomeApp_Module*>(module);
- if (appMod) appMod->updateObjBrowser(true);
- }
- }
- };
-
- if (isUpdated)
- ProcessVoidEvent(new TEventUpdateBrowser ());
-}
-
-void GEOM_Swig::createAndDisplayFitAllGO (const char* Entry)
-{
- class TEventFitAll: public SALOME_Event
- {
- public:
- TEventFitAll() {}
- virtual void Execute() {
- SUIT_Application* app = SUIT_Session::session()->activeApplication();
- if (!app) return;
-
- if (SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(app))
- {
- SVTK_View* aView = aViewWindow->getView();
- aView->GetRenderer()->OnFitAll();
- }
- else if (OCCViewer_Viewer* occViewer = GetOCCViewer(app))
- {
- Handle(V3d_Viewer) aViewer3d = occViewer->getViewer3d();
- aViewer3d->InitActiveViews();
-
- if (aViewer3d->MoreActiveViews())
- aViewer3d->ActiveView()->FitAll();
- }
- }
- };
-
- createAndDisplayGO(Entry);
- ProcessVoidEvent(new TEventFitAll());
-}
-
-void GEOM_Swig::UpdateViewer()
-{
- class TEventUpdateViewer: public SALOME_Event
- {
- public:
- TEventUpdateViewer() {}
- virtual void Execute() {
- SUIT_Application* app = SUIT_Session::session()->activeApplication();
- if (!app) return;
- SalomeApp_Study* ActiveStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
- if (!ActiveStudy) return;
-
- GEOM_Displayer(ActiveStudy).UpdateViewer();
- }
- };
-
- ProcessVoidEvent(new TEventUpdateViewer());
-}
-
-int GEOM_Swig::getIndexTopology(const char* SubIOR, const char* IOR)
-{
- GEOM::GEOM_Gen_var aGeomGen = GeometryGUI::GetGeomGen();
- if (CORBA::is_nil(aGeomGen))
- return -1;
-
- GEOM::GEOM_Object_var aMainShape = aGeomGen->GetIORFromString(IOR);
- GEOM::GEOM_Object_var aSubShape = aGeomGen->GetIORFromString(SubIOR);
- if (CORBA::is_nil(aMainShape) || CORBA::is_nil(aSubShape))
- return -1;
-
- GEOM::GEOM_IShapesOperations_var anIShapesOperations =
- aGeomGen->GetIShapesOperations(aMainShape->GetStudyID());
- if (CORBA::is_nil(anIShapesOperations))
- return -1;
-
- return anIShapesOperations->GetTopologyIndex(aMainShape, aSubShape);
-}
-
-const char* GEOM_Swig::getShapeTypeString(const char* IOR)
-{
- TCollection_AsciiString aTypeName ("Shape of unknown type");
-
- GEOM::GEOM_Gen_var aGeomGen = GeometryGUI::GetGeomGen();
- if (!CORBA::is_nil(aGeomGen))
- {
- GEOM::GEOM_Object_var aShape = aGeomGen->GetIORFromString(IOR);
- if (!CORBA::is_nil(aShape))
- {
- GEOM::GEOM_IShapesOperations_var anIShapesOperations =
- aGeomGen->GetIShapesOperations(aShape->GetStudyID());
- if (!CORBA::is_nil(anIShapesOperations))
- {
- aTypeName = anIShapesOperations->GetShapeTypeString(aShape);
- }
- }
- }
-
- return CORBA::string_dup(aTypeName.ToCString());
-}
-
-
-const char* GEOM_Swig::getShapeTypeIcon(const char* IOR)
-{
- GEOM::GEOM_Gen_var Geom = GeometryGUI::GetGeomGen();
- if ( CORBA::is_nil( Geom ) )
- return "None";
-
- GEOM::GEOM_Object_var aShape = Geom->GetIORFromString(IOR);
- TopoDS_Shape shape = ShapeReader.GetShape(Geom, aShape);
-
- if( shape.IsNull() ) {
- return "None" ;
- }
-
- switch (shape.ShapeType() )
- {
- case TopAbs_COMPOUND:
- { return "ICON_OBJBROWSER_COMPOUND" ;}
- case TopAbs_COMPSOLID:
- { return "ICON_OBJBROWSER_COMPSOLID" ;}
- case TopAbs_SOLID:
- { return "ICON_OBJBROWSER_SOLID" ;}
- case TopAbs_SHELL:
- { return "ICON_OBJBROWSER_SHELL" ;}
- case TopAbs_FACE:
- { return "ICON_OBJBROWSER_FACE" ;}
- case TopAbs_WIRE:
- { return "ICON_OBJBROWSER_WIRE" ;}
- case TopAbs_EDGE:
- { return "ICON_OBJBROWSER_EDGE" ;}
- case TopAbs_VERTEX:
- { return "ICON_OBJBROWSER_VERTEX" ;}
- }
-
- return "None";
-}
-
-void GEOM_Swig::setDisplayMode(const char* theEntry, int theMode, bool isUpdated)
-{
- class TEvent: public SALOME_Event {
- std::string myEntry;
- int myMode;
- bool myUpdateViewer;
- public:
- TEvent(const char* theEntryArg, int theModeArg, bool theUpdated):
- myEntry(theEntryArg), myMode(theModeArg), myUpdateViewer(theUpdated)
- {}
- virtual void Execute() {
- SUIT_Application* anApp = SUIT_Session::session()->activeApplication();
- if (!anApp) return;
-
- Handle(SALOME_InteractiveObject) anIO =
- new SALOME_InteractiveObject(myEntry.c_str(), "GEOM", "");
-
- if (SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(anApp)) {
- SVTK_View* aView = aViewWindow->getView();
- aView->SetDisplayMode(anIO, myMode);
- if (myUpdateViewer)
- aView->Repaint();
- }
- else if (OCCViewer_Viewer* occViewer = GetOCCViewer(anApp)) {
- SOCC_Viewer* soccViewer = dynamic_cast<SOCC_Viewer*>(occViewer);
- if (soccViewer)
- soccViewer->switchRepresentation(anIO, myMode, myUpdateViewer);
- }
- }
- };
-
- ProcessVoidEvent(new TEvent (theEntry, theMode, isUpdated));
-}
-
-void GEOM_Swig::setVectorsMode(const char* theEntry, bool isOn, bool isUpdated)
-{
- class TEvent: public SALOME_Event {
- std::string myEntry;
- bool myOn;
- bool myUpdateViewer;
- public:
- TEvent(const char* theEntryArg, bool theOn, bool theUpdated):
- myEntry(theEntryArg), myOn(theOn), myUpdateViewer(theUpdated)
- {}
- virtual void Execute() {
- SUIT_Application* anApp = SUIT_Session::session()->activeApplication();
- if (!anApp) return;
-
- Handle(SALOME_InteractiveObject) anIO =
- new SALOME_InteractiveObject(myEntry.c_str(), "GEOM", "");
-
- if (SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(anApp)) {
- SVTK_View* aView = aViewWindow->getView();
- SVTK_Viewer* stvkViewer = dynamic_cast<SVTK_Viewer*>(aViewWindow->getViewManager()->getViewModel());
- SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>( stvkViewer->CreatePrs( myEntry.c_str() ) );
- vtkActorCollection* anActors = vtkPrs->GetObjects();
- anActors->InitTraversal();
- while (vtkActor* anAct = anActors->GetNextActor()) {
- GEOM_Actor* aGeomActor = GEOM_Actor::SafeDownCast(anAct);
- aGeomActor->SetVectorMode(!aGeomActor->GetVectorMode());
- }
- if (myUpdateViewer)
- aView->Repaint();
- }
- else if (OCCViewer_Viewer* occViewer = GetOCCViewer(anApp)) {
- Handle(AIS_InteractiveContext) ic = occViewer->getAISContext();
- SOCC_Viewer* soccViewer = dynamic_cast<SOCC_Viewer*>(occViewer);
- if (soccViewer) {
- SOCC_Prs* occPrs = dynamic_cast<SOCC_Prs*>( soccViewer->CreatePrs( myEntry.c_str() ) );
- if ( occPrs && !occPrs->IsNull() ) {
- AIS_ListOfInteractive shapes; occPrs->GetObjects( shapes );
- AIS_ListIteratorOfListOfInteractive interIter( shapes );
- for ( ; interIter.More(); interIter.Next() ) {
- Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast( interIter.Value() );
- aSh->SetDisplayVectors(myOn);
- ic->RecomputePrsOnly(interIter.Value());
- }
- }
- }
- }
- }
- };
-
- ProcessVoidEvent(new TEvent (theEntry, isOn, isUpdated));
-}
-
-void GEOM_Swig::setColor(const char* theEntry, int red, int green, int blue, bool isUpdated)
-{
- class TEvent: public SALOME_Event {
- std::string myEntry;
- int myRed;
- int myGreen;
- int myBlue;
- bool myUpdateViewer;
- public:
- TEvent(const char* theEntryArg, int theR, int theG, int theB, bool theUpdated):
- myEntry(theEntryArg), myRed(theR), myGreen(theG), myBlue(theB), myUpdateViewer(theUpdated)
- {}
- virtual void Execute() {
- SUIT_Application* anApp = SUIT_Session::session()->activeApplication();
- if (!anApp) return;
-
- Handle(SALOME_InteractiveObject) anIO =
- new SALOME_InteractiveObject(myEntry.c_str(), "GEOM", "");
-
- if (SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(anApp)){
- SVTK_View* aView = aViewWindow->getView();
- QColor aColor (myRed, myGreen, myBlue);
- aView->SetColor(anIO, aColor);
- if (myUpdateViewer)
- aView->Repaint();
- } else if (OCCViewer_Viewer* occViewer = GetOCCViewer(anApp)) {
- Handle(AIS_InteractiveContext) ic = occViewer->getAISContext();
- SOCC_Viewer* soccViewer = dynamic_cast<SOCC_Viewer*>(occViewer);
- if (soccViewer)
- {
- SALOME_Prs* prs= soccViewer->CreatePrs( myEntry.c_str() );
- const SOCC_Prs* anOCCPrs = dynamic_cast<const SOCC_Prs*>( prs );
- if ( !anOCCPrs || anOCCPrs->IsNull() )
- return;
-
- // get objects to be displayed
- AIS_ListOfInteractive anAISObjects;
- anOCCPrs->GetObjects( anAISObjects );
- AIS_ListIteratorOfListOfInteractive ite( anAISObjects );
- Quantity_Color CSFColor = Quantity_Color(myRed/255., myGreen/255., myBlue/255., Quantity_TOC_RGB);
- for ( ; ite.More(); ite.Next() )
- {
- if(!ic->IsDisplayed(ite.Value()))continue; //only displayed ais
- ite.Value()->SetColor(CSFColor);
- if (ite.Value()->IsKind(STANDARD_TYPE(GEOM_AISShape))) Handle(GEOM_AISShape)::DownCast(ite.Value())->SetShadingColor(CSFColor);
- ite.Value()->Redisplay(Standard_True); // as in OnColor
- }
- if (myUpdateViewer) occViewer->update();
- }
- }
- }
- };
- ProcessVoidEvent(new TEvent(theEntry, red, green, blue, isUpdated));
-}
-
-void GEOM_Swig::setTransparency(const char* theEntry, float transp, bool isUpdated)
-{
- class TEvent: public SALOME_Event {
- std::string myEntry;
- float myParam;
- bool myUpdateViewer;
- public:
- TEvent(const char* theEntryArg, float theParam, bool theUpdated):
- myEntry(theEntryArg), myParam(theParam), myUpdateViewer(theUpdated)
- {}
- virtual void Execute() {
- SUIT_Application* anApp = SUIT_Session::session()->activeApplication();
- if (!anApp) return;
-
- Handle(SALOME_InteractiveObject) anIO =
- new SALOME_InteractiveObject(myEntry.c_str(), "GEOM", "");
-
- if (SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(anApp)) {
- SVTK_View* aView = aViewWindow->getView();
- aView->SetTransparency(anIO, myParam);
- if (myUpdateViewer)
- aView->Repaint();
- } else if (OCCViewer_Viewer* occViewer = GetOCCViewer(anApp)) {
- SOCC_Viewer* soccViewer = dynamic_cast<SOCC_Viewer*>(occViewer);
- if (soccViewer)
- soccViewer->setTransparency(anIO, myParam, myUpdateViewer);
- }
- }
- };
-
- ProcessVoidEvent(new TEvent (theEntry, transp, isUpdated));
-}
-
-
-class TInitGeomGenEvent: public SALOME_Event {
-public:
- typedef bool TResult;
- TResult myResult;
- TInitGeomGenEvent() : myResult(false) {}
- virtual void Execute() {
- myResult = GeometryGUI::InitGeomGen();
- }
-};
-bool GEOM_Swig::initGeomGen()
-{
- return ProcessEvent(new TInitGeomGenEvent());
-}
-
-
-
-void GEOM_Swig::eraseGO (const char* Entry, bool allWindows)
-{
- class TEvent: public SALOME_Event
- {
- std::string myEntry;
- bool myFromAllWindows;
- public:
- TEvent(const char* theEntry, bool fromAllWindows):
- myEntry(theEntry), myFromAllWindows(fromAllWindows)
- {}
- virtual void Execute()
- {
- SUIT_Application* app = SUIT_Session::session()->activeApplication();
- if (!app) return;
- SalomeApp_Study* ActiveStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
- if (!ActiveStudy) return;
-
- Handle (SALOME_InteractiveObject) aIO = new SALOME_InteractiveObject(myEntry.c_str(), "GEOM", "");
-
- GEOM_Displayer(ActiveStudy).Erase(aIO, true);
- /* if (myFromAllWindows) {
- QPtrList<SUIT_ViewWindow> aWindows = app->desktop()->windows();
- SUIT_ViewWindow* aWin = 0;
- for (aWin = aWindows.first(); aWin; aWin = aWindows.next()) {
- EraseObject(aWin, aIO);
- }
- } else {
- SUIT_ViewWindow* aWin = app->desktop()->activeWindow();
- if (aWin)
- EraseObject(aWin, aIO);
- }*/
- }
-
- /* private:
- void EraseObject(SUIT_ViewWindow* theWin, Handle (SALOME_InteractiveObject) theIO)
- {
- if (theWin->getViewManager()->getType() == OCCViewer_Viewer::Type()){
- OCCViewer_ViewWindow* vw = dynamic_cast<OCCViewer_ViewWindow*>( theWin );
- if ( vw ) {
- OCCViewer_ViewManager* vm = dynamic_cast<OCCViewer_ViewManager*>( vw->getViewManager() );
- if ( vm ) {
- SOCC_Viewer* aViewer = dynamic_cast<SOCC_Viewer*>(vm->getOCCViewer());
- if (aViewer) {
- SALOME_Prs* aPrs = aViewer->CreatePrs(myEntry.c_str());
- if (aPrs) {
- SALOME_OCCPrs* aOccPrs = dynamic_cast<SALOME_OCCPrs*>(aPrs);
- if (aOccPrs) {
- aViewer->Erase(aOccPrs);
- aViewer->Repaint();
- }
- }
- }
- }
- }
- } else if (theWin->getViewManager()->getType() == SVTK_Viewer::Type()){
- SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( theWin );
- if (aViewWindow) {
- aViewWindow->Erase(theIO);
- }
- }
- }*/
-
- };
- ProcessVoidEvent(new TEvent(Entry, allWindows));
-}
-
-
-
-void GEOM_Swig::setDeflection(const char* theEntry, float theDeflect)
-{
- class TEvent: public SALOME_Event {
- std::string myEntry;
- float myParam;
- public:
- TEvent(const char* theEntryArg, float theParam):
- myEntry(theEntryArg), myParam(theParam)
- {}
- virtual void Execute() {
- SUIT_Application* anApp = SUIT_Session::session()->activeApplication();
- if (!anApp) return;
-
- Handle(SALOME_InteractiveObject) anIO =
- new SALOME_InteractiveObject(myEntry.c_str(), "GEOM", "");
-
- if (SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(anApp)) {
- vtkActorCollection* aActors = aViewWindow->getRenderer()->GetActors();
- aActors->InitTraversal();
- while (vtkActor* aAct = aActors->GetNextActor()) {
- if (GEOM_Actor* aGeomActor = dynamic_cast<GEOM_Actor*>(aAct)) {
- if (aGeomActor->hasIO()) {
- Handle(SALOME_InteractiveObject) aNextIO = aGeomActor->getIO();
- if (aNextIO->isSame(anIO)) {
- aGeomActor->setDeflection(myParam);
- aViewWindow->Repaint();
- return;
- }
- }
- }
- }
- // aView->SetTransparency(anIO, myParam);
- //aView->Repaint();
- } else if (OCCViewer_Viewer* occViewer = GetOCCViewer(anApp)) {
- Handle(AIS_InteractiveContext) aContext = occViewer->getAISContext();
- AIS_ListOfInteractive aAISList;
- aContext->DisplayedObjects(aAISList);
- AIS_ListIteratorOfListOfInteractive it(aAISList);
- for (; it.More(); it.Next()) {
- Handle(SALOME_InteractiveObject) aObj =
- Handle(SALOME_InteractiveObject)::DownCast(it.Value()->GetOwner());
- if ((!aObj.IsNull()) && aObj->hasEntry() && aObj->isSame(anIO)) {
- Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(it.Value());
- if (!aShape.IsNull()) {
- TopoDS_Shape aSh = aShape->Shape();
- if (!aSh.IsNull())
- BRepTools::Clean(aSh);
-
- aShape->SetOwnDeviationCoefficient( myParam );
- aShape->SetOwnHLRDeviationAngle( 1.57 );
- aContext->Redisplay(aShape);
- return;
- }
- }
- }
- }
- }
- };
-
- ProcessVoidEvent(new TEvent (theEntry, theDeflect));
-}
-
+++ /dev/null
-// 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.hxx
-// Author : Nicolas REJNERI, Paul RASCLE
-//
-#ifndef GEOMETRYGUI_SWIG_HXX
-#define GEOMETRYGUI_SWIG_HXX
-
-#include "GEOM_GEOMGUI.hxx"
-
-// IDL Headers
-#include <SALOMEconfig.h>
-#include CORBA_SERVER_HEADER(GEOM_Gen)
-#include CORBA_SERVER_HEADER(SALOMEDS)
-#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
-
-class GEOMGUI_EXPORT GEOM_Swig
-{
-public:
- GEOM_Swig();
- ~GEOM_Swig();
-
- void createAndDisplayGO(const char* Entry, bool isUpdated = true);
- void eraseGO(const char* Entry, bool allWindows);
- void createAndDisplayFitAllGO(const char* Entry);
- void UpdateViewer();
- void setDisplayMode(const char* Entry, int mode, bool isUpdated = true);
- void setVectorsMode(const char* Entry, bool isSet, bool isUpdated = true);
- void setColor(const char* Entry, int red, int green, int blue, bool isUpdated = true);
- void setTransparency(const char* Entry, float transp, bool isUpdated = true);
- void setDeflection(const char* Entry, float deflect);
-
- int getIndexTopology(const char *SubEntry, const char *Entry);
- const char* getShapeTypeString(const char *Entry);
- const char* getShapeTypeIcon(const char *Ior);
-
- bool initGeomGen();
-};
-
-#endif // GEOMETRYGUI_SWIG_HXX
+++ /dev/null
-// 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();
-};
GEOM_Displayer.h \
GEOMGUI_OCCSelector.h \
GEOMGUI_Selection.h \
- GeometryGUI_Swig.hxx \
- GeometryGUI_Swig.i \
GEOM_GEOMGUI.hxx
dist_libGEOM_la_SOURCES = \
GEOMGUI.cxx \
GEOM_Displayer.cxx \
GEOMGUI_OCCSelector.cxx \
- GEOMGUI_Selection.cxx \
- GeometryGUI_Swig.cxx
+ GEOMGUI_Selection.cxx
MOC_FILES = \
GeometryGUI_moc.cxx
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
#include <Standard_Stream.hxx>
#include <GEOMImpl_IMeasureOperations.hxx>
+#include <Basics_Utils.hxx>
+
// OCCT Includes
#include <BRepBuilderAPI_MakePolygon.hxx>
#include <BRepBuilderAPI_MakeVertex.hxx>
+#include <BRepBuilderAPI_MakeEdge.hxx>
+#include <BRepBuilderAPI_MakeWire.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Wire.hxx>
{
if (Label().IsNull()) return 0;
Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
-
+
GEOMImpl_I3DSketcher aCI (aFunction);
TopoDS_Shape aShape;
- Handle(TColStd_HArray1OfReal) aCoordsArray = aCI.GetCoordinates();
- int anArrayLength = aCoordsArray->Length();
+ if (aFunction->GetType() == SKETCHER3D_COORDS) {
+ Handle(TColStd_HArray1OfReal) aCoordsArray = aCI.GetCoordinates();
+ int anArrayLength = aCoordsArray->Length();
- std::list<gp_Pnt> points;
-
- for (int i = 0; i <= (anArrayLength-3); i += 3) {
- gp_Pnt aPnt = gp_Pnt(aCoordsArray->Value(i+1), aCoordsArray->Value(i+2), aCoordsArray->Value(i+3));
- if (points.empty() || aPnt.Distance(points.back()) > gp::Resolution())
- points.push_back(aPnt);
- }
+ std::list<gp_Pnt> points;
+
+ for (int i = 0; i <= (anArrayLength-3); i += 3) {
+ gp_Pnt aPnt = gp_Pnt(aCoordsArray->Value(i+1), aCoordsArray->Value(i+2), aCoordsArray->Value(i+3));
+ if (points.empty() || aPnt.Distance(points.back()) > gp::Resolution())
+ points.push_back(aPnt);
+ }
+
+ if ( points.size() == 1) { // Only Start Point
+ BRepBuilderAPI_MakeVertex mkVertex (points.back());
+ aShape = mkVertex.Shape();
+ }
+ else if ( points.size() > 1) { // Make Wire
+ BRepBuilderAPI_MakePolygon aMakePoly;
+ std::list<gp_Pnt>::iterator it;
+ for (it = points.begin(); it != points.end(); ++it) {
+ aMakePoly.Add(*it);
+ }
- if ( points.size() == 1) { // Only Start Point
- BRepBuilderAPI_MakeVertex mkVertex (points.back());
- aShape = mkVertex.Shape();
+ if (points.size() > 2 &&
+ points.back().X() == points.front().X() &&
+ points.back().Y() == points.front().Y() &&
+ points.back().Z() == points.front().Z())
+ aMakePoly.Close();
+
+ if (aMakePoly.IsDone())
+ aShape = aMakePoly.Wire();
+ }
}
- else if ( points.size() > 1) { // Make Wire
- BRepBuilderAPI_MakePolygon aMakePoly;
- std::list<gp_Pnt>::iterator it;
- for (it = points.begin(); it != points.end(); ++it) {
- aMakePoly.Add(*it);
+ 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);
+ }
}
- if (points.size() > 2 &&
- points.back().X() == points.front().X() &&
- points.back().Y() == points.front().Y() &&
- points.back().Z() == points.front().Z())
- aMakePoly.Close();
-
- if (aMakePoly.IsDone())
- aShape = aMakePoly.Wire();
+ 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;
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
- 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) {
MESSAGE("Some non-blocks have been removed");
//Make a Python command
GEOM::TPythonDump pd (aFunction);
- pd << aFilling << " = geompy.MakeFilling("
- << theShape << ", " << theMinDeg << ", " << theMaxDeg << ", "
- << theTol2D << ", " << theTol3D << ", " << theNbIter << ", ";
- if( theMethod==1 ) pd << "GEOM.FOM_UseOri";
- else if( theMethod==2 ) pd << "GEOM.FOM_AutoCorrect";
- else pd << "GEOM.FOM_Default";
- if(isApprox)
- pd << ", " << isApprox ;
+ pd << aFilling << " = geompy.MakeFilling(" << theShape ;
+ if ( theMinDeg != 2 ) pd << ", theMinDeg=" << theMinDeg ;
+ if ( theMaxDeg != 5 ) pd << ", theMaxDeg=" << theMaxDeg ;
+ if ( fabs(theTol2D-0.0001) > Precision::Confusion() )
+ pd << ", theTol2D=" << theTol2D ;
+ if ( fabs(theTol3D-0.0001) > Precision::Confusion() )
+ pd << ", theTol3D=" << theTol3D ;
+ 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 << ")";
SetErrorCode(OK);
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
//NOTE: This is an interface to a function for the Sketcher creation.
-//
+
#include "GEOM_Function.hxx"
#include <TColStd_HArray1OfReal.hxx>
-#define SKETCH_ARG_COORDS 1
-
class GEOMImpl_I3DSketcher
{
- public:
+public:
- GEOMImpl_I3DSketcher(Handle(GEOM_Function) theFunction): _func(theFunction) {}
+ GEOMImpl_I3DSketcher (Handle(GEOM_Function) theFunction): _func(theFunction) {}
- void SetCoordinates(const Handle(TColStd_HArray1OfReal)& theValue)
- { _func->SetRealArray(SKETCH_ARG_COORDS, theValue); }
+ void SetCoordinates (const Handle(TColStd_HArray1OfReal)& theValue)
+ { _func->SetRealArray(SKETCH_ARG_COORDS, theValue); }
Handle(TColStd_HArray1OfReal) GetCoordinates() { return _func->GetRealArray(SKETCH_ARG_COORDS); }
- private:
+ void SetCommand (const TCollection_AsciiString& theCommand)
+ { _func->SetString(SKETCH_ARG_COMMAND, theCommand); }
+
+ TCollection_AsciiString GetCommand() { return _func->GetString(SKETCH_ARG_COMMAND); }
+
+private:
+
+ enum {
+ SKETCH_ARG_COORDS = 1,
+ SKETCH_ARG_COMMAND = 2
+ };
Handle(GEOM_Function) _func;
};
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
#include <Standard_Stream.hxx>
case PointOn_CurveByCoord: fType = POINT_CURVE_COORD; break;
case PointOn_SurfaceByParam: fType = POINT_SURFACE_PAR; break;
case PointOn_SurfaceByCoord: fType = POINT_SURFACE_COORD; break;
+ case PointOn_Face: fType = POINT_FACE_ANY; break;
default: break;
}
Handle(GEOM_Function) aFunction = aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), fType);
aPI.SetX(theParam1);
aPI.SetY(theParam2);
aPI.SetZ(theParam3);
+ break;
+ case PointOn_Face:
+ aPI.SetSurface(aRefFunction);
+ break;
default: break;
}
<< theGeomObj << ", " << theParam1 << ", " << theRefPoint << ")";
break;
case PointOn_CurveByCoord:
- GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurveByCoord("
- << theGeomObj << ", " << theParam1
- << ", " << theParam2 << ", " << theParam3 << ")";
+ GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurveByCoord("
+ << theGeomObj << ", " << theParam1
+ << ", " << theParam2 << ", " << theParam3 << ")";
break;
case PointOn_SurfaceByParam:
- GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnSurface("
- << theGeomObj << ", " << theParam1
- << ", " << theParam2 << ")";
+ GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnSurface("
+ << theGeomObj << ", " << theParam1
+ << ", " << theParam2 << ")";
break;
case PointOn_SurfaceByCoord:
- GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnSurfaceByCoord("
- << theGeomObj << ", " << theParam1
- << ", " << theParam2 << ", " << theParam3 << ")";
+ GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnSurfaceByCoord("
+ << theGeomObj << ", " << theParam1
+ << ", " << theParam2 << ", " << theParam3 << ")";
+ break;
+ case PointOn_Face:
+ GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexInsideFace("
+ << theGeomObj << ")";
+ break;
default: break;
}
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);
+}
//=============================================================================
/*!
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
#ifndef _GEOMImpl_IBasicOperations_HXX_
#define _GEOMImpl_IBasicOperations_HXX_
double theYParam,
double theZParam);
+ Standard_EXPORT Handle(GEOM_Object) MakePointOnFace (Handle(GEOM_Object) theFace);
+
// Vector
Standard_EXPORT Handle(GEOM_Object) MakeVectorDXDYDZ (double theDX, double theDY, double theDZ);
PointOn_CurveByCoord,
PointOn_CurveByLength,
PointOn_SurfaceByParam,
- PointOn_SurfaceByCoord
+ PointOn_SurfaceByCoord,
+ PointOn_Face
};
Handle(GEOM_Object) makePointOnGeom (Handle(GEOM_Object) theGeomObj,
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
#ifdef WNT
#pragma warning( disable:4786 )
void GEOMImpl_IBlocksOperations::AddBlocksFrom (const TopoDS_Shape& theShape,
TopTools_ListOfShape& BLO,
TopTools_ListOfShape& NOT,
- TopTools_ListOfShape& EXT)
+ TopTools_ListOfShape& EXT,
+ TopTools_ListOfShape& NOQ)
{
TopAbs_ShapeEnum aType = theShape.ShapeType();
switch (aType) {
{
TopoDS_Iterator It (theShape);
for (; It.More(); It.Next()) {
- AddBlocksFrom(It.Value(), BLO, NOT, EXT);
+ AddBlocksFrom(It.Value(), BLO, NOT, EXT, NOQ);
}
}
break;
for (; expF.More(); expF.Next()) {
if (mapFaces.Add(expF.Current())) {
nbFaces++;
- if (nbFaces > 6) break;
+ //0021483//if (nbFaces > 6) break;
// get wire
TopoDS_Shape aF = expF.Current();
if (!wires.More()) {
// no wire in the face
hasNonQuadr = Standard_True;
- break;
+ NOQ.Append(aF);//0021483
+ //0021483//break;
+ continue;
}
TopoDS_Shape aWire = wires.Current();
wires.Next();
if (wires.More()) {
// multiple wires in the face
hasNonQuadr = Standard_True;
- break;
+ NOQ.Append(aF);//0021483
+ //0021483//break;
+ continue;
}
// Check number of edges in the face
}
if (nbEdges != 4) {
hasNonQuadr = Standard_True;
+ NOQ.Append(aF);//0021483
}
}
}
}
}
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:
NOT.Append(theShape);
}
TopTools_ListOfShape NOT; // Not blocks
TopTools_ListOfShape EXT; // Hexahedral solids, having degenerated and/or seam edges
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
if (NOT.Extent() > 0) {
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
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
#ifndef _GEOMImpl_IBlocksOperations_HXX_
#define _GEOMImpl_IBlocksOperations_HXX_
};
Standard_EXPORT Standard_Boolean CheckCompoundOfBlocksOld (Handle(GEOM_Object) theCompound,
- std::list<BCError>& theErrors);
+ std::list<BCError>& theErrors);
Standard_EXPORT Standard_Boolean CheckCompoundOfBlocks (Handle(GEOM_Object) theCompound,
- std::list<BCError>& theErrors);
+ std::list<BCError>& theErrors);
- Standard_EXPORT TCollection_AsciiString PrintBCErrors (Handle(GEOM_Object) theCompound,
+ Standard_EXPORT TCollection_AsciiString PrintBCErrors (Handle(GEOM_Object) theCompound,
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,
const Standard_Integer theOptimumNbFaces = 6);
Standard_EXPORT static void AddBlocksFrom (const TopoDS_Shape& theShape,
TopTools_ListOfShape& BLO,
TopTools_ListOfShape& NOT,
- TopTools_ListOfShape& EXT);
+ TopTools_ListOfShape& EXT,
+ TopTools_ListOfShape& NOQ);
// Extract blocks from blocks compounds
Standard_EXPORT Handle(TColStd_HSequenceOfTransient) ExplodeCompoundOfBlocks
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
#ifdef WNT
// E.A. : On windows with python 2.6, there is a conflict
//=============================================================================
/*!
- * Make3DSketcher
+ * MakeSketcherOnPlane
*/
//=============================================================================
-Handle(GEOM_Object) GEOMImpl_ICurvesOperations::Make3DSketcher (std::list<double> theCoordinates)
+Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcherOnPlane
+ (const char* theCommand,
+ Handle(GEOM_Object) theWorkingPlane)
{
SetErrorCode(KO);
+ if (!theCommand || strcmp(theCommand, "") == 0) return NULL;
+
//Add a new Sketcher object
- Handle(GEOM_Object) a3DSketcher = GetEngine()->AddObject(GetDocID(), GEOM_3DSKETCHER);
+ Handle(GEOM_Object) aSketcher = GetEngine()->AddObject(GetDocID(), GEOM_SKETCHER);
//Add a new Sketcher function
Handle(GEOM_Function) aFunction =
- a3DSketcher->AddFunction(GEOMImpl_3DSketcherDriver::GetID(), GEOM_3DSKETCHER);
+ aSketcher->AddFunction(GEOMImpl_SketcherDriver::GetID(), SKETCHER_PLANE);
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++;
+ if (aFunction->GetDriverGUID() != GEOMImpl_SketcherDriver::GetID()) return NULL;
- Handle(TColStd_HArray1OfReal) aCoordsArray = new TColStd_HArray1OfReal (1, nbOfCoords);
+ GEOMImpl_ISketcher aCI (aFunction);
- it = theCoordinates.begin();
- int ind = 1;
- for (; it != theCoordinates.end(); it++, ind++)
- aCoordsArray->SetValue(ind, *it);
+ TCollection_AsciiString aCommand((char*) theCommand);
+ aCI.SetCommand(aCommand);
- aCI.SetCoordinates(aCoordsArray);
+ Handle(GEOM_Function) aRefPlane = theWorkingPlane->GetLastFunction();
+ if (aRefPlane.IsNull()) return NULL;
+ aCI.SetWorkingPlane( aRefPlane );
//Compute the Sketcher value
try {
OCC_CATCH_SIGNALS;
#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
- SetErrorCode("3D Sketcher driver failed");
+ SetErrorCode("Sketcher driver failed");
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 << "])";
+ GEOM::TPythonDump (aFunction) << aSketcher << " = geompy.MakeSketcherOnPlane(\""
+ << aCommand.ToCString() << "\", " << theWorkingPlane << " )";
SetErrorCode(OK);
- return a3DSketcher;
+ return aSketcher;
}
//=============================================================================
/*!
- * MakeSketcherOnPlane
+ * Make3DSketcherCommand
*/
//=============================================================================
-Handle(GEOM_Object) GEOMImpl_ICurvesOperations::MakeSketcherOnPlane
- (const char* theCommand,
- Handle(GEOM_Object) theWorkingPlane)
+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_SKETCHER);
+ Handle(GEOM_Object) aSketcher = GetEngine()->AddObject(GetDocID(), GEOM_3DSKETCHER);
//Add a new Sketcher function
Handle(GEOM_Function) aFunction =
- aSketcher->AddFunction(GEOMImpl_SketcherDriver::GetID(), SKETCHER_PLANE);
+ aSketcher->AddFunction(GEOMImpl_3DSketcherDriver::GetID(), SKETCHER3D_COMMAND);
if (aFunction.IsNull()) return NULL;
//Check if the function is set correctly
- if (aFunction->GetDriverGUID() != GEOMImpl_SketcherDriver::GetID()) return NULL;
+ if (aFunction->GetDriverGUID() != GEOMImpl_3DSketcherDriver::GetID()) return NULL;
- GEOMImpl_ISketcher aCI (aFunction);
+ GEOMImpl_I3DSketcher aCI (aFunction);
- TCollection_AsciiString aCommand((char*) theCommand);
+ TCollection_AsciiString aCommand ((char*) theCommand);
aCI.SetCommand(aCommand);
- Handle(GEOM_Function) aRefPlane = theWorkingPlane->GetLastFunction();
- if (aRefPlane.IsNull()) return NULL;
- aCI.SetWorkingPlane( aRefPlane );
+ //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 {
OCC_CATCH_SIGNALS;
#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
- SetErrorCode("Sketcher driver failed");
+ SetErrorCode("3D Sketcher driver failed");
return NULL;
}
}
}
//Make a Python command
- GEOM::TPythonDump (aFunction) << aSketcher << " = geompy.MakeSketcherOnPlane(\""
- << aCommand.ToCString() << "\", " << theWorkingPlane << " )";
+ GEOM::TPythonDump pd (aFunction);
+ pd << a3DSketcher << " = geompy.Make3DSketcher([";
+
+ it = theCoordinates.begin();
+ pd << (*it++);
+ while (it != theCoordinates.end()) {
+ pd << ", " << (*it++);
+ }
+ pd << "])";
SetErrorCode(OK);
- return aSketcher;
+ return a3DSketcher;
}
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
#ifndef _GEOMImpl_ICurvesOperations_HXX_
#define _GEOMImpl_ICurvesOperations_HXX_
bool theIsClosed = false,
bool theDoReordering = false);
- Standard_EXPORT Handle(GEOM_Object) MakeCurveParametric(const char* thexExpr, const char* theyExpr, const char* thezExpr,
- double theParamMin, double theParamMax, double theParamStep,
- CurveType theCurveType,
- int theParamNbStep=0, bool theNewMethod=false);
+ Standard_EXPORT Handle(GEOM_Object) MakeCurveParametric
+ (const char* thexExpr, const char* theyExpr, const char* thezExpr,
+ double theParamMin, double theParamMax, double theParamStep,
+ CurveType theCurveType, int theParamNbStep=0, bool theNewMethod=false);
Standard_EXPORT Handle(GEOM_Object) MakeSketcher (const char* theCommand,
std::list<double> theWorkingPlane);
- Standard_EXPORT Handle(GEOM_Object) Make3DSketcher (std::list<double> theCoordinates);
Standard_EXPORT Handle(GEOM_Object) MakeSketcherOnPlane (const char* theCommand,
Handle(GEOM_Object) theWorkingPlane);
+ Standard_EXPORT Handle(GEOM_Object) Make3DSketcherCommand (const char* theCommand);
+ Standard_EXPORT Handle(GEOM_Object) Make3DSketcher (std::list<double> theCoordinates);
};
#endif
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
#include <Standard_Stream.hxx>
if ( aLength - aRemLength > 0 ) {
aNewSeq = new TColStd_HArray1OfInteger(1, aLength - aRemLength);
for (j = 1; j <= aLength; j++) {
- if (!mapIDsToRemove.Contains(aSeq->Value(j))) {
- aNewSeq->SetValue(k, aSeq->Value(j));
- k++;
- }
+ if (!mapIDsToRemove.Contains(aSeq->Value(j))) {
+ aNewSeq->SetValue(k, aSeq->Value(j));
+ k++;
+ }
}
}
else {
if ( aLength - aRemLength > 0 ) {
aNewSeq = new TColStd_HArray1OfInteger(1, aLength - aRemLength);
for (j = 1; j <= aLength; j++) {
- if (!mapIDsToRemove.Contains(aSeq->Value(j))) {
- aNewSeq->SetValue(k, aSeq->Value(j));
- k++;
- }
+ if (!mapIDsToRemove.Contains(aSeq->Value(j))) {
+ aNewSeq->SetValue(k, aSeq->Value(j));
+ k++;
+ }
}
}
else {
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
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
#ifndef _GEOMImpl_IGroupOperations_HXX_
#define _GEOMImpl_IGroupOperations_HXX_
#include "GEOM_Engine.hxx"
#include "GEOM_Object.hxx"
#include <TDocStd_Document.hxx>
-#include <TColStd_HArray1OfInteger.hxx>
+#include <TColStd_HArray1OfInteger.hxx>
#include <TColStd_HSequenceOfInteger.hxx>
#include <TopAbs.hxx>
Standard_EXPORT void DifferenceIDs (Handle(GEOM_Object) theGroup,
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 Handle(GEOM_Object) GetMainShape(Handle(GEOM_Object) theGroup);
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
#include <Standard_Stream.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Vertex.hxx>
+#include <BRep_Builder.hxx>
#include <BRep_Tool.hxx>
+#include <BRepTools.hxx>
#include <gp_Pnt.hxx>
#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
//=============================================================================
/*!
- * constructor:
+ * constructor
*/
//=============================================================================
-
GEOMImpl_IInsertOperations::GEOMImpl_IInsertOperations(GEOM_Engine* theEngine, int theDocID)
: GEOM_IOperations(theEngine, theDocID)
{
* destructor
*/
//=============================================================================
-
GEOMImpl_IInsertOperations::~GEOMImpl_IInsertOperations()
{
MESSAGE("GEOMImpl_IInsertOperations::~GEOMImpl_IInsertOperations");
}
-
-
//=============================================================================
/*!
* MakeCopy
*/
//=============================================================================
-Handle(GEOM_Object) GEOMImpl_IInsertOperations::MakeCopy(Handle(GEOM_Object) theOriginal)
+Handle(GEOM_Object) GEOMImpl_IInsertOperations::MakeCopy (Handle(GEOM_Object) theOriginal)
{
SetErrorCode(KO);
aCI.SetFileName(theFileName);
aCI.SetFormatName(theFormatName);
aCI.SetPluginName(aLibName);
- //cout<<"IIO: theFormatName = "<<theFormatName.ToCString()<<endl;
//Perform the Import
try {
SetErrorCode(OK);
- if( theFormatName == "IGES_UNIT" ) {
+ // OLD CODE: begin
+ if (theFormatName == "IGES_UNIT") {
TopoDS_Shape S = aFunction->GetValue();
TopoDS_Vertex V = TopoDS::Vertex(S);
gp_Pnt P = BRep_Tool::Pnt(V);
//cout<<"IIO: aUnitName = "<<aUnitName.ToCString()<<endl;
SetErrorCode(aUnitName);
}
+ // OLD CODE: end
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
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)
{
SetErrorCode(KO);
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
#ifndef _GEOMImpl_IInsertOperations_HXX_
#define _GEOMImpl_IInsertOperations_HXX_
Standard_EXPORT Handle(GEOM_Object) Import (const TCollection_AsciiString& theFileName,
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,
const TCollection_AsciiString& theFileName,
const TCollection_AsciiString& theFormatType);
const TCollection_AsciiString& theFormat,
Handle(TCollection_HAsciiString)& theLibName);
+ Standard_EXPORT Handle(GEOM_Object) RestoreShape (std::istringstream& theStream);
+
Standard_EXPORT int LoadTexture(const TCollection_AsciiString& theTextureFile);
Standard_EXPORT int AddTexture(int theWidth, int theHeight,
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
#include <Standard_Stream.hxx>
#include <NMTDS_Tools.hxx>
#include <NMTDS_InterfPool.hxx>
#include <NMTDS_PInterfPool.hxx>
-//#include <NMTDS_PassKeyBoolean.hxx>
#include <NMTDS_PairBoolean.hxx>
#include <NMTDS_ShapesDataStructure.hxx>
-//#include <NMTDS_ListIteratorOfListOfPassKeyBoolean.hxx>
#include <NMTDS_ListIteratorOfListOfPairBoolean.hxx>
#include <Basics_OCCTVersion.hxx>
#include <TFunction_Logbook.hxx>
#include <TDF_Tool.hxx>
+#include <BRep_Builder.hxx>
+#include <BRep_TFace.hxx>
#include <BRep_Tool.hxx>
#include <BRepAdaptor_Surface.hxx>
+#include <BRepBuilderAPI_Copy.hxx>
#include <BRepBndLib.hxx>
#include <BRepCheck.hxx>
#include <BRepCheck_ListIteratorOfListOfStatus.hxx>
#include <BRepCheck_Result.hxx>
#include <BRepCheck_Shell.hxx>
+#include <BRepClass3d_SolidClassifier.hxx>
#include <BRepExtrema_DistShapeShape.hxx>
#include <BRepGProp.hxx>
#include <BRepTools.hxx>
#include <Bnd_Box.hxx>
-#include <GProp_GProps.hxx>
-#include <GProp_PrincipalProps.hxx>
-
#include <TopAbs.hxx>
#include <TopExp.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Vertex.hxx>
+#include <TopoDS_Compound.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopExp_Explorer.hxx>
#include <TopTools_MapOfShape.hxx>
#include <TopTools_ListOfShape.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 <Geom_Surface.hxx>
+
+#include <Geom_BezierSurface.hxx>
+#include <Geom_BSplineSurface.hxx>
+#include <Geom_Circle.hxx>
+#include <Geom_ConicalSurface.hxx>
+#include <Geom_CylindricalSurface.hxx>
+#include <Geom_Line.hxx>
+#include <Geom_OffsetSurface.hxx>
#include <Geom_Plane.hxx>
+#include <Geom_RectangularTrimmedSurface.hxx>
#include <Geom_SphericalSurface.hxx>
-#include <Geom_CylindricalSurface.hxx>
-#include <Geom_ToroidalSurface.hxx>
-#include <Geom_ConicalSurface.hxx>
+#include <Geom_Surface.hxx>
#include <Geom_SurfaceOfLinearExtrusion.hxx>
#include <Geom_SurfaceOfRevolution.hxx>
-#include <Geom_BezierSurface.hxx>
-#include <Geom_BSplineSurface.hxx>
-#include <Geom_RectangularTrimmedSurface.hxx>
-#include <Geom_OffsetSurface.hxx>
-#include <Geom_Line.hxx>
-
-#include <gp_Pln.hxx>
-#include <gp_Lin.hxx>
+#include <Geom_ToroidalSurface.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_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
+#include <GProp_GProps.hxx>
+#include <GProp_PrincipalProps.hxx>
-#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>
+#include <gp_Pln.hxx>
+#include <gp_Lin.hxx>
+#include <Standard_Failure.hxx>
+#include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
//=============================================================================
/*!
if(theShape.Orientation() == TopAbs_REVERSED)
{
gp_Dir Vx = aResult.XDirection();
- gp_Dir N = aResult.Direction().Mirrored(Vx);
+ gp_Dir N = aResult.Direction().Mirrored(Vx);
gp_Pnt P = aResult.Location();
aResult = gp_Ax3(P, N, Vx);
- }
+ }
}
}
#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
#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);
B.Get(Xmin, Ymin, Zmin, Xmax, Ymax, Zmax);
}
const NMTDS_ShapesDataStructure& aDS = *(aCSI.DS());
Standard_Integer aNbS = aDS.NumberOfShapesOfTheObject();
- // 3. Get the pairs of interfered shapes
+ // 3. Get the pairs of interfered shapes
NMTDS_PInterfPool pIP = aCSI.IP();
//const NMTDS_ListOfPassKeyBoolean& aLPKB = pIP->Get();
const NMTDS_ListOfPairBoolean& aLPKB = pIP->Get();
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
#include <Standard_Stream.hxx>
#include <GEOMImpl_Types.hxx>
#include <GEOM_Function.hxx>
-#include "utilities.h"
-
#include <TopoDS_Shape.hxx>
+#include <TCollection_HAsciiString.hxx>
+
+#include "utilities.h"
+
#include <Standard_Failure.hxx>
#include <StdFail_NotDone.hxx>
TCollection_AsciiString&,
const TDF_Label&);
+typedef Handle(TCollection_HAsciiString) (*pGetValue)(const TCollection_AsciiString&,
+ const TCollection_AsciiString&,
+ TCollection_AsciiString&);
+
//=======================================================================
//function : GetID
//purpose :
return aImportDriver;
}
-
//=======================================================================
//function : GEOMImpl_ImportDriver
//purpose :
// load plugin library
LibHandle anImportLib = LoadLib( aLibName.ToCString() ); //This is workaround of BUG OCC13051
+
+ // Get Import method
funcPoint fp = 0;
if ( anImportLib )
fp = (funcPoint)GetProc( anImportLib, "Import" );
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_
// 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 : GEOMImpl_ImportDriver.ixx
// Module : GEOMImpl
-//
+
#ifndef _GEOMImpl_ImportDriver_HeaderFile
#define _GEOMImpl_ImportDriver_HeaderFile
#include <Standard_CString.hxx>
#endif
+#include <TCollection_AsciiString.hxx>
+
class TColStd_SequenceOfExtendedString;
Standard_EXPORT static const Standard_GUID& GetID();
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
//
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;
if (aShapeBase.ShapeType() == TopAbs_VERTEX) {
aProf = aShapeBase;
aProf = aShapeBase;
}
else if (aShapeBase.ShapeType() == TopAbs_FACE) {
- TopExp_Explorer wexp(aShapeBase,TopAbs_WIRE);
+ TopExp_Explorer wexp (aShapeBase,TopAbs_WIRE);
aProf = wexp.Current();
}
else {
Standard_TypeMismatch::Raise
("MakePipe aborted : invalid type of base");
}
- BRepOffsetAPI_MakePipeShell PipeBuilder(aWirePath);
+ BRepOffsetAPI_MakePipeShell PipeBuilder (aWirePath);
PipeBuilder.Add(aProf);
if (aShapeVec.IsNull()) {
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
#include <Standard_Stream.hxx>
#include <GEOMImpl_IPoint.hxx>
#include <GEOMImpl_Types.hxx>
#include <GEOM_Function.hxx>
+#include <GEOMAlgo_Tools3D.hxx>
#include <ShapeAnalysis.hxx>
aPnt = gp_Pnt(aPI.GetX(), aPI.GetY(), aPI.GetZ());
}
else if (aType == POINT_XYZ_REF) {
- Handle(GEOM_Function) aRefPoint = aPI.GetRef();
- TopoDS_Shape aRefShape = aRefPoint->GetValue();
+ Handle(GEOM_Function) aRefFunc = aPI.GetRef();
+ TopoDS_Shape aRefShape = aRefFunc->GetValue();
if (aRefShape.ShapeType() != TopAbs_VERTEX) {
Standard_TypeMismatch::Raise
("Point creation aborted : referenced shape is not a vertex");
aPnt = gp_Pnt(P.X() + aPI.GetX(), P.Y() + aPI.GetY(), P.Z() + aPI.GetZ());
}
else if (aType == POINT_CURVE_PAR) {
- Handle(GEOM_Function) aRefCurve = aPI.GetCurve();
- TopoDS_Shape aRefShape = aRefCurve->GetValue();
+ Handle(GEOM_Function) aRefFunc = aPI.GetCurve();
+ TopoDS_Shape aRefShape = aRefFunc->GetValue();
if (aRefShape.ShapeType() != TopAbs_EDGE) {
Standard_TypeMismatch::Raise
("Point On Curve creation aborted : curve shape is not an edge");
aPnt = aCurve->Value(aP);
}
else if (aType == POINT_CURVE_COORD) {
- Handle(GEOM_Function) aRefCurve = aPI.GetCurve();
- TopoDS_Shape aRefShape = aRefCurve->GetValue();
+ Handle(GEOM_Function) aRefFunc = aPI.GetCurve();
+ TopoDS_Shape aRefShape = aRefFunc->GetValue();
if (aRefShape.ShapeType() != TopAbs_EDGE) {
Standard_TypeMismatch::Raise
("Point On Curve creation aborted : curve shape is not an edge");
}
else if (aType == POINT_CURVE_LENGTH) {
// RefCurve
- Handle(GEOM_Function) aRefCurve = aPI.GetCurve();
- if (aRefCurve.IsNull()) {
+ Handle(GEOM_Function) aRefFunc = aPI.GetCurve();
+ if (aRefFunc.IsNull()) {
Standard_NullObject::Raise
("Point On Curve creation aborted : curve object is null");
}
- TopoDS_Shape aRefShape1 = aRefCurve->GetValue();
+ TopoDS_Shape aRefShape1 = aRefFunc->GetValue();
if (aRefShape1.ShapeType() != TopAbs_EDGE) {
Standard_TypeMismatch::Raise
("Point On Curve creation aborted : curve shape is not an edge");
aPnt = AdapCurve.Value(aParam);
}
else if (aType == POINT_SURFACE_PAR) {
- Handle(GEOM_Function) aRefCurve = aPI.GetSurface();
- TopoDS_Shape aRefShape = aRefCurve->GetValue();
+ 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");
aPnt = aSurf->Value(U,V);
}
else if (aType == POINT_SURFACE_COORD) {
- Handle(GEOM_Function) aRefCurve = aPI.GetSurface();
- TopoDS_Shape aRefShape = aRefCurve->GetValue();
+ 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");
("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) {
Handle(GEOM_Function) aRef1 = aPI.GetLine1();
Handle(GEOM_Function) aRef2 = aPI.GetLine2();
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
#include <GEOMImpl_ShapeDriver.hxx>
unsigned int ind, nbshapes = aShapes->Length();
// add faces
- BRepBuilderAPI_Sewing aSewing(Precision::Confusion()*10.0);
+ BRepBuilderAPI_Sewing aSewing (Precision::Confusion()*10.0);
for (ind = 1; ind <= nbshapes; ind++) {
Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(aShapes->Value(ind));
TopoDS_Shape aShape_i = aRefShape->GetValue();
aSewing.Perform();
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)
TopoDS_Shell ss;
B.MakeShell(ss);
ish++;
}
- if (ish != 1)
- aShape = aSewing.SewedShape();
+ 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();
+ }
+ }
}
}
// 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_Object types
#define POINT_SURFACE_PAR 5
#define POINT_CURVE_COORD 6
#define POINT_SURFACE_COORD 7
-#define POINT_CURVE_LENGTH 8
+#define POINT_CURVE_LENGTH 8
+#define POINT_FACE_ANY 9
// Vector
#define VECTOR_TWO_PNT 1
#define GLUE_EDGES_BY_LIST 4
#define SKETCHER_NINE_DOUBLS 1
-#define SKETCHER_PLANE 2
+#define SKETCHER_PLANE 2
+
+#define SKETCHER3D_COORDS 1
+#define SKETCHER3D_COMMAND 2
// Measures
#define CDG_MEASURE 1
case GEOMOp::OpNoAutoColor: // POPUP - DISABLE AUTO COLOR
OnDisableAutoColor();
break;
- case GEOMOp::OpShowChildren: // POPUP - SHOW CHILDREN
- case GEOMOp::OpHideChildren: // POPUP - HIDE CHILDREN
- OnShowHideChildren( theCommandID == GEOMOp::OpShowChildren );
+ case GEOMOp::OpDiscloseChildren: // POPUP - SHOW CHILDREN
+ case GEOMOp::OpConcealChildren: // POPUP - HIDE CHILDREN
+ OnDiscloseConcealChildren( theCommandID == GEOMOp::OpDiscloseChildren );
break;
case GEOMOp::OpPointMarker: // POPUP - POINT MARKER
OnPointMarker();
CORBA::String_var fileN = fileName.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
if ( aCurrentType == "IGES" ) {
GEOM::GEOM_Object_var anObj = aInsOp->ImportFile( fileN, "IGES_UNIT" );
} // if ( needConvert )
} // if ( aCurrentType == "IGES" )
else if ( aCurrentType == "ACIS" ) {
+ */
+
+ if ( aCurrentType == "ACIS" ) {
if ( acisAnswer != SUIT_MessageBox::YesToAll && acisAnswer != SUIT_MessageBox::NoToAll ) {
SUIT_MessageBox::StandardButtons btns = SUIT_MessageBox::Yes | SUIT_MessageBox::No;
if ( i < fileNames.count()-1 ) btns = btns | SUIT_MessageBox::YesToAll | SUIT_MessageBox::NoToAll;
} // if ( acisAnswer != YesToAll && acisAnswer != NoToAll )
} // else if ( aCurrentType == "ACIS" )
+ // IMPORT
GEOM::GEOM_Object_var anObj = aInsOp->ImportFile( fileN, fileT );
if ( !anObj->_is_nil() && aInsOp->IsDone() ) {
#include "GEOM_ToolsGUI.hxx"
#include <GEOMGUI.h>
-
#include <SALOMEDSClient.hxx>
class GEOM_Displayer;
class SALOME_View;
class SALOME_ListIO;
+class SalomeApp_Study;
+class SVTK_View;
+class QColor;
+class Handle_SALOME_InteractiveObject;
+class Handle_AIS_InteractiveContext;
#include <QList>
enum ActionType { SHOWDLG, INCR, DECR };
+ static void SetColor( const QString&, const QColor&, bool );
+
private:
// Import and export topology methods
bool Import();
void OnNbIsos( ActionType actionType = SHOWDLG );
void OnDeflection();
void OnSelectOnly(int mode);
- void OnShowHideChildren( bool );
+ void OnDiscloseConcealChildren( bool );
void OnUnpublishObject();
void OnPublishObject() ;
void OnPointMarker();
_PTR(Study),
QList<SALOME_View*>,
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
// VTK includes
#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()
{
SalomeApp_Application* app =
if( CORBA::is_nil( aChildObject ) )
continue;
+#ifndef GENERAL_AUTOCOLOR // auto-color for groups only
if( aChildObject->GetType() != GEOM_GROUP )
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 );
- aChildObject->SetColor( 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 ) );
return;
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()
{
- SALOME_ListIO selected;
+ // 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 ( app && appStudy ) {
- LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
- if ( aSelMgr ) {
- aSelMgr->selectedObjects( selected );
- if ( !selected.IsEmpty() ) {
- SUIT_ViewWindow* window = app->desktop()->activeWindow();
- bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
- bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
- int mgrId = window->getViewManager()->getGlobalId();
- if ( isVTK ) {
- SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
- if ( !vtkVW )
- return;
- SVTK_View* aView = vtkVW->getView();
- QColor initcolor = aView->GetColor( selected.First() );
- QColor c = QColorDialog::getColor( initcolor, app->desktop() );
- if ( c.isValid() ) {
- SUIT_OverrideCursor();
- for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
- QString matProp;
- 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
- _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 ) {
- Handle(AIS_InteractiveObject) io = GEOMBase::GetAIS( selected.First() );
- if ( !io.IsNull() ) {
- Quantity_Color aColor;
- io->Color( aColor );
- QColor ic = QColor((int )( aColor.Red() * 255.0 ),
- (int)( aColor.Green() * 255.0 ),
- (int)( aColor.Blue() * 255.0 ));
-
- QVariant v = appStudy->getObjectProperty(mgrId,selected.First()->getEntry(), COLOR_PROP, ic);
-
- QColor initcolor = v.value<QColor>();
- QColor c = QColorDialog::getColor( initcolor, app->desktop() );
- if ( c.isValid() ) {
- 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() );
- Handle (AIS_InteractiveContext) ic = vm->getAISContext();
- for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
- QString matProp;
- matProp = appStudy->getObjectProperty(mgrId,It.Value()->getEntry(), MATERIAL_PROP, matProp).toString();
- Material_Model material;
- 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
-
- if ( io->IsKind( STANDARD_TYPE(AIS_Shape) ) ) {
- TopoDS_Shape theShape = Handle(AIS_Shape)::DownCast( io )->Shape();
- bool onlyVertex = (theShape.ShapeType() == TopAbs_VERTEX || GEOM_Displayer::isCompoundOfVertices( theShape ));
- if (onlyVertex) {
- // Set color for a point
-
- Handle(AIS_Drawer) aCurDrawer = io->Attributes();
- Handle(Prs3d_PointAspect) aCurPointAspect = aCurDrawer->PointAspect();
- Quantity_Color aCurColor;
- Standard_Real aCurScale;
- Aspect_TypeOfMarker aCurTypeOfMarker;
- aCurPointAspect->Aspect()->Values( aCurColor, aCurTypeOfMarker, aCurScale );
- if ( aCurTypeOfMarker != Aspect_TOM_USERDEFINED ) {
- aCurDrawer->SetPointAspect(new Prs3d_PointAspect(aCurTypeOfMarker, aColor, aCurScale));
- }
- else {
- Standard_Integer aWidth, aHeight;
- aCurPointAspect->GetTextureSize( aWidth, aHeight );
+ if ( !appStudy ) return;
-#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
- Handle(TColStd_HArray1OfByte) aTexture = aCurPointAspect->GetTexture();
-#else
- Handle(Graphic3d_HArray1OfBytes) aTexture = aCurPointAspect->GetTexture();
-#endif
+ // get selection manager
+ LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
+ if ( !aSelMgr ) return;
- aCurDrawer->SetPointAspect(new Prs3d_PointAspect(aColor, 1, aWidth, aHeight, aTexture));
- }
- ic->SetLocalAttributes(io, aCurDrawer, Standard_False);
- }
- }
-
- io->SetColor( aColor );
- if ( io->IsKind( STANDARD_TYPE(GEOM_AISShape) ) ) {
- Handle(GEOM_AISShape) aGAISShape = Handle(GEOM_AISShape)::DownCast( io );
- aGAISShape->SetShadingColor( aColor );
- aGAISShape->storeBoundaryColors();
- }
-
- appStudy->setObjectProperty(mgrId,It.Value()->getEntry(), COLOR_PROP, c);
-
- io->Redisplay( Standard_True );
-
- // store color to GEOM_Object
- _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 );
- }
- } // for
- ic->UpdateCurrentViewer();
- GeometryGUI::Modified();
- } // if c.isValid()
- } // first IO is not null
- } // if ( isOCC )
- } // if ( selection not empty )
+ // get selection
+ SALOME_ListIO selected;
+ aSelMgr->selectedObjects( selected );
+ if ( selected.IsEmpty() ) return;
+
+ // get active view
+ SUIT_ViewWindow* window = app->desktop()->activeWindow();
+ 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();
+
+ if ( isVTK ) {
+ SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
+ if ( !vtkVW ) return;
+
+ // get initial color (use first object from selection)
+ SVTK_View* aView = vtkVW->getView();
+ QColor color = aView->GetColor( selected.First() );
+ QVariant v = appStudy->getObjectProperty( mgrId, selected.First()->getEntry(), COLOR_PROP, color );
+
+ // 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();
+ for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
+ GEOMToolsGUI::setVtkColor( appStudy, mgrId, aView, It.Value(), color );
+ }
+ aView->Repaint();
+ }
+ else if ( isOCC ) {
+ // find AIS interactive object (for first item in selection)
+ Handle(AIS_InteractiveObject) io = GEOMBase::GetAIS( selected.First() );
+ if ( io.IsNull() ) return;
+
+ // get initial color (use first object from selection)
+ Quantity_Color aColor;
+ io->Color( aColor );
+ QColor color = QColor((int)( aColor.Red() * 255.0 ),
+ (int)( aColor.Green() * 255.0 ),
+ (int)( aColor.Blue() * 255.0 ));
+ QVariant v = appStudy->getObjectProperty( mgrId, selected.First()->getEntry(), COLOR_PROP, color );
+
+ // 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();
+ OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*> ( window->getViewManager()->getViewModel() );
+ Handle (AIS_InteractiveContext) ic = vm->getAISContext();
+ 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;
+ matProp = study->getObjectProperty( mgrId, IO->getEntry(), MATERIAL_PROP, matProp ).toString();
+ Material_Model material;
+ material.fromProperties( matProp );
+
+ // change color only for shapes with not physical type of material
+ if ( !material.isPhysical() ) {
+ view->SetColor( IO, color );
+ study->setObjectProperty( mgrId, IO->getEntry(), COLOR_PROP, color );
+ }
+
+ // 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) ) ) {
+ TopoDS_Shape theShape = Handle(AIS_Shape)::DownCast( io )->Shape();
+ bool onlyVertex = (theShape.ShapeType() == TopAbs_VERTEX || GEOM_Displayer::isCompoundOfVertices( theShape ));
+ if ( onlyVertex ) {
+ // set color for a point
+ Handle(AIS_Drawer) aCurDrawer = io->Attributes();
+ Handle(Prs3d_PointAspect) aCurPointAspect = aCurDrawer->PointAspect();
+ Quantity_Color aCurColor;
+ Standard_Real aCurScale;
+ Aspect_TypeOfMarker aCurTypeOfMarker;
+ aCurPointAspect->Aspect()->Values( aCurColor, aCurTypeOfMarker, aCurScale );
+ if ( aCurTypeOfMarker != Aspect_TOM_USERDEFINED ) {
+ aCurDrawer->SetPointAspect( new Prs3d_PointAspect( aCurTypeOfMarker, aColor, aCurScale ) );
+ }
+ else {
+ Standard_Integer aWidth, aHeight;
+ aCurPointAspect->GetTextureSize( aWidth, aHeight );
+#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
+ Handle(TColStd_HArray1OfByte) aTexture = aCurPointAspect->GetTexture();
+#else
+ Handle(Graphic3d_HArray1OfBytes) aTexture = aCurPointAspect->GetTexture();
+#endif
+ aCurDrawer->SetPointAspect( new Prs3d_PointAspect( aColor, 1, aWidth, aHeight, aTexture ) );
+ }
+ ic->SetLocalAttributes( io, aCurDrawer, Standard_False );
+ }
+ }
+
+ io->SetColor( aColor );
+ if ( io->IsKind( STANDARD_TYPE(GEOM_AISShape) ) ) {
+ Handle(GEOM_AISShape) aGAISShape = Handle(GEOM_AISShape)::DownCast( io );
+ aGAISShape->SetShadingColor( aColor );
+ aGAISShape->storeBoundaryColors();
+ }
+
+ io->Redisplay( Standard_True );
+
+ 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() ) );
+ GEOM::GEOM_Object_var anObject =
+ GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aSObject));
+ 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::OnTexture()
{
SALOME_ListIO selected;
}
}
-void GEOMToolsGUI::OnShowHideChildren( bool show )
+void GEOMToolsGUI::OnDiscloseConcealChildren( bool show )
{
SALOME_ListIO selected;
SalomeApp_Application* app =
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
#include <Standard_Stream.hxx>
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);
+}
//=============================================================================
/*!
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
#ifndef _GEOM_IBasicOperations_i_HeaderFile
#define _GEOM_IBasicOperations_i_HeaderFile
CORBA::Double theYParameter,
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 theLine2);
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
#include <Standard_Stream.hxx>
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
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
#ifndef _GEOM_IBlocksOperations_i_HeaderFile
#define _GEOM_IBlocksOperations_i_HeaderFile
char* PrintBCErrors (GEOM::GEOM_Object_ptr theCompound,
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,
CORBA::Long theOptimumNbFaces);
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
#include <Standard_Stream.hxx>
* MakeCurveParametric
*/
//=============================================================================
-GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCurveParametric(const char* thexExpr, const char* theyExpr, const char* thezExpr,
- double theParamMin, double theParamMax, double theParamStep,
- GEOM::curve_type theCurveType) {
+GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCurveParametric
+ (const char* thexExpr, const char* theyExpr, const char* thezExpr,
+ double theParamMin, double theParamMax, double theParamStep,
+ GEOM::curve_type theCurveType)
+{
GEOM::GEOM_Object_var aGEOMObject;
//Set a not done flag
GetOperations()->SetNotDone();
-
+
GEOMImpl_ICurvesOperations::CurveType aType;
switch(theCurveType) {
case GEOM::Polyline:
break;
default:
break;
- }
-
+ }
// Make Polyline
Handle(GEOM_Object) anObject =
- GetOperations()->MakeCurveParametric(thexExpr, theyExpr, thezExpr,
- theParamMin, theParamMax,
- theParamStep, aType);
-
+ GetOperations()->MakeCurveParametric(thexExpr, theyExpr, thezExpr,
+ theParamMin, theParamMax,
+ theParamStep, aType);
+
if (!GetOperations()->IsDone() || anObject.IsNull())
- return aGEOMObject._retn();
-
+ return aGEOMObject._retn();
+
return GetObject(anObject);
}
* MakeCurveParametricNew
*/
//=============================================================================
-GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCurveParametricNew(const char* thexExpr, const char* theyExpr, const char* thezExpr,
- double theParamMin, double theParamMax, CORBA::Long theParamNbStep,
- GEOM::curve_type theCurveType) {
+GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCurveParametricNew
+ (const char* thexExpr, const char* theyExpr, const char* thezExpr,
+ double theParamMin, double theParamMax, CORBA::Long theParamNbStep,
+ GEOM::curve_type theCurveType)
+{
GEOM::GEOM_Object_var aGEOMObject;
//Set a not done flag
GetOperations()->SetNotDone();
-
+
GEOMImpl_ICurvesOperations::CurveType aType;
switch(theCurveType) {
case GEOM::Polyline:
break;
default:
break;
- }
-
+ }
// Make Polyline
Handle(GEOM_Object) anObject =
- GetOperations()->MakeCurveParametric(thexExpr, theyExpr, thezExpr,
- theParamMin, theParamMax,
+ GetOperations()->MakeCurveParametric(thexExpr, theyExpr, thezExpr,
+ theParamMin, theParamMax,
0.0, aType, theParamNbStep, true);
-
+
if (!GetOperations()->IsDone() || anObject.IsNull())
- return aGEOMObject._retn();
-
+ return aGEOMObject._retn();
+
return GetObject(anObject);
}
//=============================================================================
/*!
- * Make3DSketcher
+ * MakeSketcherOnPlane
*/
//=============================================================================
-GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::Make3DSketcher
- (const GEOM::ListOfDouble& theCoordinates)
+GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSketcherOnPlane
+ (const char* theCommand, GEOM::GEOM_Object_ptr theWorkingPlane)
{
//Set a not done flag
GetOperations()->SetNotDone();
- int ind = 0;
- int aLen = theCoordinates.length();
- std::list<double> aCoords;
- for (; ind < aLen; ind++)
- aCoords.push_back(theCoordinates[ind]);
+ Handle(GEOM_Object) aWorkingPlane = GetObjectImpl(theWorkingPlane);
// Make Sketcher
Handle(GEOM_Object) anObject =
- GetOperations()->Make3DSketcher(aCoords);
+ GetOperations()->MakeSketcherOnPlane(theCommand, aWorkingPlane);
if (!GetOperations()->IsDone() || anObject.IsNull())
return GEOM::GEOM_Object::_nil();
//=============================================================================
/*!
- * MakeSketcherOnPlane
+ * Make3DSketcherCommand
*/
//=============================================================================
-GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSketcherOnPlane
- (const char* theCommand, GEOM::GEOM_Object_ptr theWorkingPlane)
+GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::Make3DSketcherCommand (const char* theCommand)
{
//Set a not done flag
GetOperations()->SetNotDone();
- Handle(GEOM_Object) aWorkingPlane = GetObjectImpl(theWorkingPlane);
+ // Make 3D Sketcher
+ Handle(GEOM_Object) anObject = GetOperations()->Make3DSketcherCommand(theCommand);
+ if (!GetOperations()->IsDone() || anObject.IsNull())
+ return GEOM::GEOM_Object::_nil();
+
+ return GetObject(anObject);
+}
+
+//=============================================================================
+/*!
+ * Make3DSketcher
+ */
+//=============================================================================
+GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::Make3DSketcher
+ (const GEOM::ListOfDouble& theCoordinates)
+{
+ //Set a not done flag
+ GetOperations()->SetNotDone();
+
+ int ind = 0;
+ int aLen = theCoordinates.length();
+ std::list<double> aCoords;
+ for (; ind < aLen; ind++)
+ aCoords.push_back(theCoordinates[ind]);
// Make Sketcher
Handle(GEOM_Object) anObject =
- GetOperations()->MakeSketcherOnPlane(theCommand, aWorkingPlane);
+ GetOperations()->Make3DSketcher(aCoords);
if (!GetOperations()->IsDone() || anObject.IsNull())
return GEOM::GEOM_Object::_nil();
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
#ifndef _GEOM_ICurvesOperations_i_HeaderFile
#define _GEOM_ICurvesOperations_i_HeaderFile
#include "GEOMImpl_ICurvesOperations.hxx"
-class GEOM_I_EXPORT GEOM_ICurvesOperations_i :
+class GEOM_I_EXPORT GEOM_ICurvesOperations_i :
public virtual POA_GEOM::GEOM_ICurvesOperations,
public virtual GEOM_IOperations_i
{
public:
GEOM_ICurvesOperations_i (PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr theEngine,
- ::GEOMImpl_ICurvesOperations* theImpl);
+ ::GEOMImpl_ICurvesOperations* theImpl);
~GEOM_ICurvesOperations_i();
GEOM::GEOM_Object_ptr MakeCirclePntVecR (GEOM::GEOM_Object_ptr theCenter,
- GEOM::GEOM_Object_ptr theVector,
- double theR);
+ GEOM::GEOM_Object_ptr theVector,
+ double theR);
GEOM::GEOM_Object_ptr MakeCircleThreePnt (GEOM::GEOM_Object_ptr thePnt1,
- GEOM::GEOM_Object_ptr thePnt2,
- GEOM::GEOM_Object_ptr thePnt3);
+ GEOM::GEOM_Object_ptr thePnt2,
+ GEOM::GEOM_Object_ptr thePnt3);
GEOM::GEOM_Object_ptr MakeCircleCenter2Pnt (GEOM::GEOM_Object_ptr thePnt1,
- GEOM::GEOM_Object_ptr thePnt2,
- GEOM::GEOM_Object_ptr thePnt3);
+ GEOM::GEOM_Object_ptr thePnt2,
+ GEOM::GEOM_Object_ptr thePnt3);
GEOM::GEOM_Object_ptr MakeEllipse (GEOM::GEOM_Object_ptr theCenter,
- GEOM::GEOM_Object_ptr theVector,
- double theRMajor, double theRMinor);
+ GEOM::GEOM_Object_ptr theVector,
+ double theRMajor, double theRMinor);
GEOM::GEOM_Object_ptr MakeEllipseVec (GEOM::GEOM_Object_ptr theCenter,
- GEOM::GEOM_Object_ptr theVector,
- double theRMajor, double theRMinor,
- GEOM::GEOM_Object_ptr theVectorMajor);
+ GEOM::GEOM_Object_ptr theVector,
+ double theRMajor, double theRMinor,
+ GEOM::GEOM_Object_ptr theVectorMajor);
GEOM::GEOM_Object_ptr MakeArc (GEOM::GEOM_Object_ptr thePnt1,
- GEOM::GEOM_Object_ptr thePnt2,
- GEOM::GEOM_Object_ptr thePnt3);
-
+ GEOM::GEOM_Object_ptr thePnt2,
+ GEOM::GEOM_Object_ptr thePnt3);
+
GEOM::GEOM_Object_ptr MakeArcCenter (GEOM::GEOM_Object_ptr thePnt1,
GEOM::GEOM_Object_ptr thePnt2,
GEOM::GEOM_Object_ptr thePnt3,
bool theSense);
GEOM::GEOM_Object_ptr MakeArcOfEllipse (GEOM::GEOM_Object_ptr thePnt1,
- GEOM::GEOM_Object_ptr thePnt2,
- GEOM::GEOM_Object_ptr thePnt3);
-
+ GEOM::GEOM_Object_ptr thePnt2,
+ GEOM::GEOM_Object_ptr thePnt3);
+
GEOM::GEOM_Object_ptr MakePolyline (const GEOM::ListOfGO& thePoints,
CORBA::Boolean theIsClosed);
CORBA::Boolean theIsClosed,
CORBA::Boolean theDoReordering);
- GEOM::GEOM_Object_ptr MakeCurveParametric(const char* thexExpr, const char* theyExpr, const char* thezExpr,
- double theParamMin, double theParamMax, double theParamStep,
- GEOM::curve_type theCurveType);
-
- GEOM::GEOM_Object_ptr MakeCurveParametricNew(const char* thexExpr, const char* theyExpr, const char* thezExpr,
- double theParamMin, double theParamMax, CORBA::Long theParamNbStep,
- GEOM::curve_type theCurveType);
+ GEOM::GEOM_Object_ptr MakeCurveParametric
+ (const char* thexExpr, const char* theyExpr, const char* thezExpr,
+ double theParamMin, double theParamMax, double theParamStep,
+ GEOM::curve_type theCurveType);
+
+ GEOM::GEOM_Object_ptr MakeCurveParametricNew
+ (const char* thexExpr, const char* theyExpr, const char* thezExpr,
+ double theParamMin, double theParamMax, CORBA::Long theParamNbStep,
+ GEOM::curve_type theCurveType);
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 Make3DSketcherCommand (const char* theCommand);
+
+ GEOM::GEOM_Object_ptr Make3DSketcher (const GEOM::ListOfDouble& theCoordinates);
+
::GEOMImpl_ICurvesOperations* GetOperations()
{ return (::GEOMImpl_ICurvesOperations*)GetImpl(); }
};
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
#include <Standard_Stream.hxx>
//Perform the operation
GetOperations()->UnionIDs(aGroupRef, aSubShapes);
- return;
}
//=============================================================================
//Perform the operation
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);
}
//=============================================================================
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
#ifndef _GEOM_IGroupOperations_i_HeaderFile
#define _GEOM_IGroupOperations_i_HeaderFile
#include "GEOMImpl_IGroupOperations.hxx"
-class GEOM_I_EXPORT GEOM_IGroupOperations_i :
+class GEOM_I_EXPORT GEOM_IGroupOperations_i :
public virtual POA_GEOM::GEOM_IGroupOperations,
public virtual GEOM_IOperations_i
{
public:
GEOM_IGroupOperations_i (PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr theEngine,
- ::GEOMImpl_IGroupOperations* theImpl);
+ ::GEOMImpl_IGroupOperations* theImpl);
~GEOM_IGroupOperations_i();
- GEOM::GEOM_Object_ptr CreateGroup (GEOM::GEOM_Object_ptr theMainShape, CORBA::Long theShapeType);
-
+ GEOM::GEOM_Object_ptr CreateGroup (GEOM::GEOM_Object_ptr theMainShape, CORBA::Long theShapeType);
+
void AddObject (GEOM::GEOM_Object_ptr theGroup, CORBA::Long theSubShapeId);
void RemoveObject (GEOM::GEOM_Object_ptr theGroup, CORBA::Long theSubShapeId);
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);
-
+
GEOM::GEOM_Object_ptr GetMainShape (GEOM::GEOM_Object_ptr theGroup);
GEOM::ListOfLong* GetObjects (GEOM::GEOM_Object_ptr theGroup);
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
#ifdef WNT
#pragma warning( disable:4786 )
//=============================================================================
/*!
- * constructor:
+ * constructor
*/
//=============================================================================
GEOM_IInsertOperations_i::GEOM_IInsertOperations_i (PortableServer::POA_ptr thePOA,
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
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)
{
GetOperations()->SetNotDone();
return GetOperations()->LoadTexture( theTextureFile );
}
+//=============================================================================
+/*!
+ * AddTexture
+ */
+//=============================================================================
CORBA::Long GEOM_IInsertOperations_i::AddTexture(CORBA::Long theWidth, CORBA::Long theHeight,
const SALOMEDS::TMPFile& theTexture)
{
return GetOperations()->AddTexture( theWidth, theHeight, aTexture );
}
+//=============================================================================
+/*!
+ * GetTexture
+ */
+//=============================================================================
SALOMEDS::TMPFile* GEOM_IInsertOperations_i::GetTexture(CORBA::Long theID,
CORBA::Long& theWidth,
CORBA::Long& theHeight)
return aTexture._retn();
}
+//=============================================================================
+/*!
+ * GetAllTextures
+ */
+//=============================================================================
GEOM::ListOfLong* GEOM_IInsertOperations_i::GetAllTextures()
{
std::list<int> localIDs = GetOperations()->GetAllTextures();
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
#ifndef _GEOM_IInsertOperations_i_HeaderFile
#define _GEOM_IInsertOperations_i_HeaderFile
GEOM::GEOM_Object_ptr ImportFile (const char* theFileName,
const char* theFormatName);
+ char* ReadValue (const char* theFileName,
+ const char* theFormatName,
+ const char* theParameterName);
+
void ImportTranslators (GEOM::string_array_out theFormats,
GEOM::string_array_out thePatterns);
void ExportTranslators (GEOM::string_array_out theFormats,
GEOM::string_array_out thePatterns);
+ GEOM::GEOM_Object_ptr RestoreShape (const SALOMEDS::TMPFile& theStream);
+
CORBA::Long LoadTexture(const char* theTextureFile);
CORBA::Long AddTexture(CORBA::Long theWidth, CORBA::Long theHeight,
const SALOMEDS::TMPFile& theTexture);
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
-
# GEOM GEOM_SWIG : binding of C++ implementaion with Python
# File : GEOM_Spanner.py
# Author : Julia DOROVSKIKH
# Module : GEOM
-# $Header$
+#
# ! Please, if you edit this example file, update also
# ! GEOM_SRC/doc/salome/gui/GEOM/input/tui_test_spanner.doc
# ! as some sequences of symbols from this example are used during
# ! documentation generation to identify certain places of this file
-############# MakeSpanner #############
#
+############# MakeSpanner #############
def MakeSpanner (geompy, math, isBlocksTest = 0, isMeshTest = 0, smesh = None):
### Variables ###
isCompOfBlocks6 = BlocksOp.CheckCompoundOfBlocks(Spanner)
if isCompOfBlocks6 == 0:
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:
print "Spanner is a compound of hexahedral solids"
# 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 GEOM_SWIG : binding of C++ omplementaion with Python
# File : GEOM_usinggeom.py
Interpol = geompy.MakeInterpol([px, py, p200, pxyz], True) #(List of GEOM_Object,Boolean)->GEOM_Object
Sketcher = geompy.MakeSketcher("Sketcher:F -100 -100:TT 250 -100:R 0:C 100 150:R 0:L 300:WW",
[100,0,0, 1,1,1, -1,1,0]) #(String, List of Doubles)->GEOM_Object
- Sketcher3d = geompy.Make3DSketcher([0,0,0, 50,50,50, 0,50,50, 10,0,0])
-
+
+ #Create 3D wires with 3D Sketcher
+ sk = geompy.Sketcher3D()
+ sk.addPointsAbsolute(0,0,0, 70,0,0)
+ sk.addPointsRelative(0, 0, 130)
+ sk.addPointAnglesLength("OXY", 50, 0, 100)
+ sk.addPointAnglesLength("OXZ", 30, 80, 130)
+ sk.close()
+ Sketcher3d_1 = sk.wire()
+
+ Sketcher3d_2 = geompy.Make3DSketcher([0,0,0, 50,50,50, 0,50,50, 10,0,0])
+
#Create local coordinate system from shape
cs4 = geompy.MakeMarkerFromShape(Plane)
#Test point on surface creation
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_face3 = geompy.MakeVertexInsideFace(Face) #(GEOM_Object)->GEOM_Object
# Test plane from existing face creation
Plane2 = geompy.MakePlaneFace(Face, trimsize) #(GEOM_Object, Double)->GEOM_Object
id_Bezier = geompy.addToStudy(Bezier, "Bezier")
id_Interpol = geompy.addToStudy(Interpol, "Interpol")
id_Sketcher = geompy.addToStudy(Sketcher, "Sketcher")
- id_Sketcher3d = geompy.addToStudy(Sketcher3d, "Sketcher 3D")
+
+ id_Sketcher3d_1 = geompy.addToStudy(Sketcher3d_1, "Sketcher 3D by interface")
+ id_Sketcher3d_2 = geompy.addToStudy(Sketcher3d_2, "Sketcher 3D by list")
id_p_on_arc = geompy.addToStudy(p_on_arc, "Vertex on Arc (0.25)")
id_p_on_arc2 = geompy.addToStudy(p_on_arc2, "Vertex on Arc at(100, -10, 10)" )
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_face3 = geompy.addToStudy(p_on_face3, "Vertex inside Face")
id_Prism1 = geompy.addToStudy(Prism1, "Prism by Two Pnt")
id_Shell1 = geompy.addToStudy(Shell1, "Shell from Prism1 faces")
os.remove(fileExportImportIGES)
os.remove(fileExportImportSTEP)
+ # Test RestoreShape from binary BRep stream
+ aStream = shape.GetShapeStream()
+ aNewShape = geompy.RestoreShape(aStream)
+ geompy.addToStudy(aNewShape, "aNewShape")
+
print "OK"
# OrientationChange
Box = geompy.MakeBoxDXDYDZ(200, 200, 200)
+ geompy.addToStudy(Box, "Box")
Orientation = geompy.OrientationChange(Box)
id_Orientation = geompy.addToStudy(Orientation, "OrientationChange")
IsValid = geompy.CheckCompoundOfBlocks(Compound1)
if IsValid == 0:
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:
print "The Blocks Compound is VALID"
for ObjectID in GetObjectIDs:
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
# -----------------------------------------------------------------------------
dist_salomescript_DATA = \
geompy.py \
geompyDC.py \
+ gsketcher.py \
batchmode_geompy.py \
GEOM_Spanner.py \
GEOM_blocks.py \
import geompyDC
from salome import *
-geom = lcc.FindOrLoadComponent("FactoryServer", "GEOM")
-geom.init_geom(salome.myStudy)
-
-# Export the methods of geompyDC
-for k in dir(geom):
- if k[0] == '_':continue
- globals()[k]=getattr(geom,k)
-del k
-from geompyDC import ShapeType, GEOM, kind, info, PackData, ReadTexture, EnumToLong
+# 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" )
+ # initialize GEOM with current study
+ geom.init_geom( salome.myStudy )
+ # export the methods of geompyDC
+ for k in dir( geom ):
+ if k[0] == '_': continue
+ globals()[k] = getattr( geom, k )
+ pass
+ del k
+ from geompyDC import ShapeType, GEOM, kind, info, PackData, ReadTexture, EnumToLong
+ pass
+except:
+ geom = None
+ pass
## @}
-import salome
-salome.salome_init()
-from salome import *
+# initialize SALOME session in try/except block
+# to avoid problems in some cases, e.g. when generating documentation
+try:
+ import salome
+ salome.salome_init()
+ from salome import *
+except:
+ pass
from salome_notebook import *
import math
import os
+from gsketcher import Sketcher3D
+
## Enumeration ShapeType as a dictionary. \n
## Topological types of shapes (like Open Cascade types). See GEOM::shape_type for details.
# @ingroup l1_geompy_auxiliary
# Example: see GEOM_TestAll.py
try:
aSObject = self.AddInStudy(self.myStudy, aShape, aName, None)
+ if aSObject and aName: aSObject.SetAttrString("AttributeName", aName)
if doRestoreSubShapes:
self.RestoreSubShapesSO(self.myStudy, aSObject, theArgs,
theFindMethod, theInheritFirstArg, True )
# Example: see GEOM_TestAll.py
try:
aSObject = self.AddInStudy(self.myStudy, aShape, aName, aFather)
+ if aSObject and aName: aSObject.SetAttrString("AttributeName", aName)
except:
print "addToStudyInFather() failed"
return ""
New GEOM.GEOM_Object, containing the created point.
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)
# Example: see GEOM_TestAll.py
New GEOM.GEOM_Object, containing the created point.
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)
# Example: see GEOM_TestAll.py
anObj.SetParameters(Parameters);
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.
# @param theRefLine1, theRefLine2 The referenced lines.
# @return New GEOM.GEOM_Object, containing the created point.
New GEOM.GEOM_Object, containing the created tangent.
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)
RaiseIfFailed("MakeTangentOnCurve", self.BasicOp)
# - "C radius length" : Create arc by direction, radius and length(in degree)
# - "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
# - "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
# - "EE x y xc yc flag1 flag2": Create arc by point at X & Y with given cEnter coordinates
- "C radius length" : Create arc by direction, radius and length(in degree)
- "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
- "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
- "EE x y xc yc flag1 flag2": Create arc by point at X & Y with given cEnter coordinates
Returns:
New GEOM.GEOM_Object, containing the created wire.
"""
+ theCommand,Parameters = ParseSketcherCommand(theCommand)
anObj = self.CurvesOp.MakeSketcherOnPlane(theCommand, theWorkingPlane)
RaiseIfFailed("MakeSketcherOnPlane", self.CurvesOp)
+ anObj.SetParameters(Parameters)
return anObj
## Create a sketcher wire, following the numerical description,
# passing from it.
# @return New GEOM.GEOM_Object, containing the created wire.
#
- # @ref tui_sketcher_page "Example"
+ # @ref tui_3dsketcher_page "Example"
def Make3DSketcher(self, theCoordinates):
"""
Create a sketcher wire, following the numerical description,
anObj.SetParameters(Parameters)
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
## @}
#
# @return New GEOM.GEOM_Object, containing the created box.
# @ref tui_creation_box "Example"
- def MakeBox(self,x1,y1,z1,x2,y2,z2):
+ def MakeBox (self, x1,y1,z1, x2,y2,z2):
"""
Create a box by coordinates of two opposite vertices.
New GEOM.GEOM_Object, containing the created disk.
Example of usage:
- Disk3 = geompy.MakeDiskR(100., 1) #(1 Doubles, 1 Int)->GEOM_Object
+ Disk3 = geompy.MakeDiskR(100., 1)
"""
# Example: see GEOM_TestAll.py
theR,Parameters = ParseParameters(theR)
theR2 Radius of the second cone base.
theH Cone height.
- Note:
+ Note:
If both radiuses are non-zero, the cone will be truncated.
If the radiuses are equal, a cylinder will be created instead.
- Returns:
+ Returns:
New GEOM.GEOM_Object, containing the created cone.
"""
# Example: see GEOM_TestAll.py
If both radiuses are non-zero, the cone will be truncated.
If the radiuses are equal, a cylinder will be created instead.
- Returns:
+ Returns:
New GEOM.GEOM_Object, containing the created cone.
"""
# Example: see GEOM_TestAll.py
List of sub-shapes of type theShapeType, contained in theShape.
"""
# Example: see GEOM_TestAll.py
- ListObj = self.ShapesOp.MakeAllSubShapes(aShape, aType, False)
+ ListObj = self.ShapesOp.MakeAllSubShapes(aShape, EnumToLong( aType ), False)
RaiseIfFailed("SubShapeAll", self.ShapesOp)
return ListObj
Returns:
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)
return ListObj
"""
# Example: see GEOM_TestAll.py
ListOfIDs = []
- AllShapeIDsList = self.SubShapeAllIDs(aShape, aType)
+ AllShapeIDsList = self.SubShapeAllIDs(aShape, EnumToLong( aType ))
for ind in ListOfInd:
ListOfIDs.append(AllShapeIDsList[ind - 1])
anObj = self.GetSubShape(aShape, ListOfIDs)
List of sub-shapes of type theShapeType, contained in theShape.
"""
# Example: see GEOM_TestAll.py
- ListObj = self.ShapesOp.MakeAllSubShapes(aShape, aType, True)
+ ListObj = self.ShapesOp.MakeAllSubShapes(aShape, EnumToLong( aType ), True)
RaiseIfFailed("SubShapeAllSortedCentres", self.ShapesOp)
return ListObj
Returns:
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)
return ListIDs
"""
# Example: see GEOM_TestAll.py
ListOfIDs = []
- AllShapeIDsList = self.SubShapeAllSortedCentresIDs(aShape, aType)
+ AllShapeIDsList = self.SubShapeAllSortedCentresIDs(aShape, EnumToLong( aType ))
for ind in ListOfInd:
ListOfIDs.append(AllShapeIDsList[ind - 1])
anObj = self.GetSubShape(aShape, ListOfIDs)
List of sub-shapes of type aType, contained in aShape.
"""
# Example: see GEOM_TestAll.py
- ListObj = self.ShapesOp.ExtractSubShapes(aShape, aType, isSorted)
+ ListObj = self.ShapesOp.ExtractSubShapes(aShape, EnumToLong( aType ), isSorted)
RaiseIfFailed("ExtractSubShapes", self.ShapesOp)
return ListObj
It works like geompy.SubShapeAllSortedCentres, but wrongly
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)
return ListObj
It works like geompy.SubShapeAllSortedCentresIDs, but wrongly
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)
return ListIDs
(wrongly defines centres of faces, shells and solids).
"""
ListOfIDs = []
- AllShapeIDsList = self.SubShapeAllSortedIDs(aShape, aType)
+ AllShapeIDsList = self.SubShapeAllSortedIDs(aShape, EnumToLong( aType ))
for ind in ListOfInd:
ListOfIDs.append(AllShapeIDsList[ind - 1])
anObj = self.GetSubShape(aShape, ListOfIDs)
# Example: see GEOM_TestOthers.py
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.
# @param theObject Shape to be stored in the file.
# @param theFileName Name of the file to store the given shape in.
print Descr
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.
# Unite faces and edges, sharing one surface. It means that
# this faces must have references to one C++ surface object (handle).
RaiseIfFailed("DifferenceIDs", self.GroupOp)
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
# @param theGroup is a GEOM group for which a list of IDs is requested
#
--- /dev/null
+# -*- 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
# 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
# ===============================================================
# Step 2: build the dynamic library from cpp built source files and
# 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 |
#
-# The file libGEOM_Swig.py will be installed to the
-# <prefix>/bin/salome directory.
-# The library _libGEOM_Swig.so will be installed to the
+# The files libGEOM_Swig.py and _libGEOM_Swig.so will be installed to the
# <prefix>/lib/python<version>/site-package/salome directory.
#
SWIG_FLAGS = @SWIG_FLAGS@ -I$(srcdir) -I$(srcdir)/../GEOMGUI
SWIG_SOURCES = libGEOM_Swig.i
+salomeinclude_HEADERS = $(SWIG_SOURCES) libGEOM_Swig.h
+
salomepython_PYTHON = libGEOM_Swig.py
salomepyexec_LTLIBRARIES = _libGEOM_Swig.la
-libGEOM_Swig.py: swig_wrap.cpp
-BUILT_SOURCES = swig_wrap.cpp
-_libGEOM_Swig_la_SOURCES = $(SWIG_SOURCES)
-nodist__libGEOM_Swig_la_SOURCES = $(BUILT_SOURCES)
-
-salomeinclude_HEADERS = $(SWIG_SOURCES)
+_libGEOM_Swig_la_SOURCES = $(SWIG_SOURCES) libGEOM_Swig.h libGEOM_Swig.cxx
+nodist__libGEOM_Swig_la_SOURCES = swig_wrap.cpp
_libGEOM_Swig_la_CPPFLAGS = \
$(QT_INCLUDES) \
$(GUI_CXXFLAGS) \
$(CORBA_CXXFLAGS) \
$(CORBA_INCLUDES) \
+ $(BOOST_CPPFLAGS) \
+ -I$(srcdir)/../GEOMClient \
+ -I$(srcdir)/../OBJECT \
-I$(srcdir)/../GEOMGUI \
+ -I$(srcdir)/../GEOMToolsGUI \
-I$(top_builddir)/idl
_libGEOM_Swig_la_LDFLAGS = -module
_libGEOM_Swig_la_LIBADD = \
../GEOMGUI/libGEOM.la \
+ ../GEOMToolsGUI/libGEOMToolsGUI.la \
$(PYTHON_LIBS)
swig_wrap.cpp : $(SWIG_SOURCES)
$(SWIG) $(SWIG_FLAGS) -o $@ $<
+libGEOM_Swig.py: swig_wrap.cpp
+
CLEANFILES = swig_wrap.cpp libGEOM_Swig.py
--- /dev/null
+// 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 : libGEOM_Swig.cxx
+// Author : Nicolas REJNERI, Paul RASCLE
+//
+#include "libGEOM_Swig.h"
+
+#include "GeometryGUI.h"
+#include "GEOMToolsGUI.h"
+
+#include "SUIT_Desktop.h"
+#include "SUIT_Session.h"
+#include "SalomeApp_Application.h"
+#include "SalomeApp_Study.h"
+
+#include "OB_Browser.h"
+
+#include "OCCViewer_ViewWindow.h"
+#include "OCCViewer_ViewManager.h"
+#include "SOCC_ViewModel.h"
+#include <SOCC_Prs.h>
+
+#include "SVTK_ViewModel.h"
+#include "SVTK_ViewWindow.h"
+#include "SVTK_View.h"
+#include "SVTK_Renderer.h"
+#include <SVTK_Prs.h>
+
+#include "GEOM_Actor.h"
+#include "GEOM_Client.hxx"
+#include "GEOM_AISShape.hxx"
+#include "GEOM_InteractiveObject.hxx"
+#include "GEOM_Displayer.h"
+#include "GEOM_Constants.h"
+
+#include "SALOME_Event.h"
+
+// OCCT Includes
+#include <TopAbs.hxx>
+#include <TopoDS_Shape.hxx>
+#include <AIS_ListOfInteractive.hxx>
+#include <AIS_ListIteratorOfListOfInteractive.hxx>
+#include <AIS_Drawer.hxx>
+#include <Prs3d_IsoAspect.hxx>
+#include <BRepTools.hxx>
+
+// IDL Headers
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(GEOM_Gen)
+
+#include <vtkRenderer.h>
+
+static SHAPE_READER(ShapeReader);
+
+inline OCCViewer_Viewer* GetOCCViewer(SUIT_Application* theApp){
+ SUIT_ViewWindow* window = theApp->desktop()->activeWindow();
+ if(window && window->getViewManager()->getType() == OCCViewer_Viewer::Type()){
+ OCCViewer_ViewWindow* vw = dynamic_cast<OCCViewer_ViewWindow*>( window );
+ if ( vw ) {
+ OCCViewer_ViewManager* vm = dynamic_cast<OCCViewer_ViewManager*>( vw->getViewManager() );
+ if ( vm )
+ return vm->getOCCViewer();
+ }
+ }
+
+ return 0;
+}
+
+inline SVTK_ViewWindow* GetSVTKViewWindow(SUIT_Application* theApp){
+ SUIT_ViewWindow* window = theApp->desktop()->activeWindow();
+ if(window && window->getViewManager()->getType() == SVTK_Viewer::Type())
+ return dynamic_cast<SVTK_ViewWindow*>( window );
+
+ return 0;
+}
+
+GEOM_Swig::GEOM_Swig()
+{
+ // MESSAGE("Constructeur");
+}
+
+GEOM_Swig::~GEOM_Swig()
+{
+ // MESSAGE("Destructeur");
+}
+
+void GEOM_Swig::createAndDisplayGO (const char* Entry, bool isUpdated)
+{
+ class TEvent: public SALOME_Event
+ {
+ std::string myEntry;
+ bool myUpdateViewer;
+ public:
+ TEvent(const char* theEntry, bool toUpdateViewer):
+ myEntry(theEntry),
+ myUpdateViewer(toUpdateViewer)
+ {}
+ virtual void Execute()
+ {
+ SUIT_Application* app = SUIT_Session::session()->activeApplication();
+ if (!app) return;
+
+ SalomeApp_Study* ActiveStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
+ if (!ActiveStudy) return;
+
+ _PTR(Study) aStudy(ActiveStudy->studyDS());
+ _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
+
+ GEOM::GEOM_Gen_var Geom = GeometryGUI::GetGeomGen();
+ if (CORBA::is_nil(Geom)) {
+ GeometryGUI::InitGeomGen();
+ Geom = GeometryGUI::GetGeomGen();
+ }
+ if (CORBA::is_nil(Geom))
+ return;
+
+ std::string aFatherIOR;
+ _PTR(SComponent) father = aStudy->FindComponent("GEOM");
+ if (!father)
+ return;
+ if (!father->ComponentIOR(aFatherIOR)) {
+ CORBA::String_var objStr = SalomeApp_Application::orb()->object_to_string(Geom);
+ aStudyBuilder->LoadWith(father, objStr.in());
+ father->ComponentIOR(aFatherIOR);
+ }
+
+ _PTR(SObject) obj = aStudy->FindObjectID(myEntry);
+ if (!obj)
+ return;
+
+ // Create new actor
+ _PTR(GenericAttribute) anAttr;
+ if (!obj->FindAttribute(anAttr, "AttributeIOR"))
+ return;
+ _PTR(AttributeIOR) anIOR(anAttr);
+ std::string anIORValue = anIOR->Value();
+
+ GEOM::GEOM_Object_var aShape = Geom->GetIORFromString(anIORValue.c_str());
+ TopoDS_Shape Shape = ShapeReader.GetShape(Geom,aShape);
+ if (!Shape.IsNull()) {
+ if (obj->FindAttribute(anAttr, "AttributeName")) {
+ _PTR(AttributeName) aName (anAttr);
+ std::string aNameValue = aName->Value();
+ // open transaction
+ /*SUIT_Operation* op = new SalomeApp_ImportOperation (app);
+ op->start();
+
+ _PTR(SObject) newObj1 = aStudyBuilder->NewObject(father);
+ aStudyBuilder->Addreference(newObj1, obj);
+ // commit transaction
+ op->commit();*/
+ Handle(GEOM_InteractiveObject) anIO =
+ new GEOM_InteractiveObject (const_cast<char*>(anIORValue.c_str()),
+ const_cast<char*>(aFatherIOR.c_str()),
+ "GEOM",
+ const_cast<char*>( obj->GetID().c_str()));
+
+ GEOM_Displayer(ActiveStudy).Display(anIO, myUpdateViewer);
+ /*if (SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(app)) {
+ SVTK_View* aView = aViewWindow->getView();
+ int aMode = aView->GetDisplayMode();
+
+ vtkActorCollection* theActors =
+ GEOM_AssemblyBuilder::BuildActors(Shape,0,aMode,true);
+ theActors->InitTraversal();
+ while (vtkActor* anActor = theActors->GetNextActor()) {
+ GEOM_Actor* GActor = GEOM_Actor::SafeDownCast(anActor);
+ GActor->setName(const_cast<char*>(aNameValue.c_str()));
+ GActor->setIO(anIO);
+ aView->Display(GActor);
+ }
+ aView->Repaint();
+ } else if (OCCViewer_Viewer* occViewer = GetOCCViewer(app)) {
+ Handle(AIS_InteractiveContext) ic = occViewer->getAISContext();
+ Handle(GEOM_AISShape) aSh =
+ new GEOM_AISShape (Shape,const_cast<char*>(aNameValue.c_str()));
+ aSh->setName(const_cast<char*>(aNameValue.c_str()));
+ aSh->setIO(anIO);
+ ic->Display(aSh);
+ ic->AddOrRemoveCurrentObject(aSh,true);
+ }*/
+ // update object browser
+ SalomeApp_Application* app = NULL; //dynamic_cast<SalomeApp_Application*>(app);
+ if (app) {
+ CAM_Module* module = app->module("Geometry");
+ SalomeApp_Module* appMod = dynamic_cast<SalomeApp_Module*>(module);
+ if (appMod)
+ appMod->updateObjBrowser(true);
+ }
+ }
+ }
+ }
+ };
+
+ // MESSAGE("createAndDisplayGO");
+ ProcessVoidEvent(new TEvent (Entry, isUpdated));
+
+ class TEventUpdateBrowser: public SALOME_Event
+ {
+ public:
+ TEventUpdateBrowser() {}
+ virtual void Execute() {
+ SalomeApp_Application* app =
+ dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
+ if (app) {
+ CAM_Module* module = app->module("Geometry");
+ SalomeApp_Module* appMod = dynamic_cast<SalomeApp_Module*>(module);
+ if (appMod) appMod->updateObjBrowser(true);
+ }
+ }
+ };
+
+ if (isUpdated)
+ ProcessVoidEvent(new TEventUpdateBrowser ());
+}
+
+void GEOM_Swig::createAndDisplayFitAllGO (const char* Entry)
+{
+ class TEventFitAll: public SALOME_Event
+ {
+ public:
+ TEventFitAll() {}
+ virtual void Execute() {
+ SUIT_Application* app = SUIT_Session::session()->activeApplication();
+ if (!app) return;
+
+ if (SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(app))
+ {
+ SVTK_View* aView = aViewWindow->getView();
+ aView->GetRenderer()->OnFitAll();
+ }
+ else if (OCCViewer_Viewer* occViewer = GetOCCViewer(app))
+ {
+ Handle(V3d_Viewer) aViewer3d = occViewer->getViewer3d();
+ aViewer3d->InitActiveViews();
+
+ if (aViewer3d->MoreActiveViews())
+ aViewer3d->ActiveView()->FitAll();
+ }
+ }
+ };
+
+ createAndDisplayGO(Entry);
+ ProcessVoidEvent(new TEventFitAll());
+}
+
+void GEOM_Swig::UpdateViewer()
+{
+ class TEventUpdateViewer: public SALOME_Event
+ {
+ public:
+ TEventUpdateViewer() {}
+ virtual void Execute() {
+ SUIT_Application* app = SUIT_Session::session()->activeApplication();
+ if (!app) return;
+ SalomeApp_Study* ActiveStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
+ if (!ActiveStudy) return;
+
+ GEOM_Displayer(ActiveStudy).UpdateViewer();
+ }
+ };
+
+ ProcessVoidEvent(new TEventUpdateViewer());
+}
+
+int GEOM_Swig::getIndexTopology(const char* SubIOR, const char* IOR)
+{
+ GEOM::GEOM_Gen_var aGeomGen = GeometryGUI::GetGeomGen();
+ if (CORBA::is_nil(aGeomGen))
+ return -1;
+
+ GEOM::GEOM_Object_var aMainShape = aGeomGen->GetIORFromString(IOR);
+ GEOM::GEOM_Object_var aSubShape = aGeomGen->GetIORFromString(SubIOR);
+ if (CORBA::is_nil(aMainShape) || CORBA::is_nil(aSubShape))
+ return -1;
+
+ GEOM::GEOM_IShapesOperations_var anIShapesOperations =
+ aGeomGen->GetIShapesOperations(aMainShape->GetStudyID());
+ if (CORBA::is_nil(anIShapesOperations))
+ return -1;
+
+ return anIShapesOperations->GetTopologyIndex(aMainShape, aSubShape);
+}
+
+const char* GEOM_Swig::getShapeTypeString(const char* IOR)
+{
+ TCollection_AsciiString aTypeName ("Shape of unknown type");
+
+ GEOM::GEOM_Gen_var aGeomGen = GeometryGUI::GetGeomGen();
+ if (!CORBA::is_nil(aGeomGen))
+ {
+ GEOM::GEOM_Object_var aShape = aGeomGen->GetIORFromString(IOR);
+ if (!CORBA::is_nil(aShape))
+ {
+ GEOM::GEOM_IShapesOperations_var anIShapesOperations =
+ aGeomGen->GetIShapesOperations(aShape->GetStudyID());
+ if (!CORBA::is_nil(anIShapesOperations))
+ {
+ aTypeName = anIShapesOperations->GetShapeTypeString(aShape);
+ }
+ }
+ }
+
+ return CORBA::string_dup(aTypeName.ToCString());
+}
+
+
+const char* GEOM_Swig::getShapeTypeIcon(const char* IOR)
+{
+ GEOM::GEOM_Gen_var Geom = GeometryGUI::GetGeomGen();
+ if ( CORBA::is_nil( Geom ) )
+ return "None";
+
+ GEOM::GEOM_Object_var aShape = Geom->GetIORFromString(IOR);
+ TopoDS_Shape shape = ShapeReader.GetShape(Geom, aShape);
+
+ if( shape.IsNull() ) {
+ return "None" ;
+ }
+
+ switch (shape.ShapeType() )
+ {
+ case TopAbs_COMPOUND:
+ { return "ICON_OBJBROWSER_COMPOUND" ;}
+ case TopAbs_COMPSOLID:
+ { return "ICON_OBJBROWSER_COMPSOLID" ;}
+ case TopAbs_SOLID:
+ { return "ICON_OBJBROWSER_SOLID" ;}
+ case TopAbs_SHELL:
+ { return "ICON_OBJBROWSER_SHELL" ;}
+ case TopAbs_FACE:
+ { return "ICON_OBJBROWSER_FACE" ;}
+ case TopAbs_WIRE:
+ { return "ICON_OBJBROWSER_WIRE" ;}
+ case TopAbs_EDGE:
+ { return "ICON_OBJBROWSER_EDGE" ;}
+ case TopAbs_VERTEX:
+ { return "ICON_OBJBROWSER_VERTEX" ;}
+ }
+
+ return "None";
+}
+
+void GEOM_Swig::setDisplayMode(const char* theEntry, int theMode, bool isUpdated)
+{
+ class TEvent: public SALOME_Event {
+ std::string myEntry;
+ int myMode;
+ bool myUpdateViewer;
+ public:
+ TEvent(const char* theEntryArg, int theModeArg, bool theUpdated):
+ myEntry(theEntryArg), myMode(theModeArg), myUpdateViewer(theUpdated)
+ {}
+ virtual void Execute() {
+ SUIT_Application* anApp = SUIT_Session::session()->activeApplication();
+ if (!anApp) return;
+
+ Handle(SALOME_InteractiveObject) anIO =
+ new SALOME_InteractiveObject(myEntry.c_str(), "GEOM", "");
+
+ if (SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(anApp)) {
+ SVTK_View* aView = aViewWindow->getView();
+ aView->SetDisplayMode(anIO, myMode);
+ if (myUpdateViewer)
+ aView->Repaint();
+ }
+ else if (OCCViewer_Viewer* occViewer = GetOCCViewer(anApp)) {
+ SOCC_Viewer* soccViewer = dynamic_cast<SOCC_Viewer*>(occViewer);
+ if (soccViewer)
+ soccViewer->switchRepresentation(anIO, myMode, myUpdateViewer);
+ }
+ }
+ };
+
+ ProcessVoidEvent(new TEvent (theEntry, theMode, isUpdated));
+}
+
+void GEOM_Swig::setVectorsMode(const char* theEntry, bool isOn, bool isUpdated)
+{
+ class TEvent: public SALOME_Event {
+ std::string myEntry;
+ bool myOn;
+ bool myUpdateViewer;
+ public:
+ TEvent(const char* theEntryArg, bool theOn, bool theUpdated):
+ myEntry(theEntryArg), myOn(theOn), myUpdateViewer(theUpdated)
+ {}
+ virtual void Execute() {
+ SUIT_Application* anApp = SUIT_Session::session()->activeApplication();
+ if (!anApp) return;
+
+ Handle(SALOME_InteractiveObject) anIO =
+ new SALOME_InteractiveObject(myEntry.c_str(), "GEOM", "");
+
+ if (SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(anApp)) {
+ SVTK_View* aView = aViewWindow->getView();
+ SVTK_Viewer* stvkViewer = dynamic_cast<SVTK_Viewer*>(aViewWindow->getViewManager()->getViewModel());
+ SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>( stvkViewer->CreatePrs( myEntry.c_str() ) );
+ vtkActorCollection* anActors = vtkPrs->GetObjects();
+ anActors->InitTraversal();
+ while (vtkActor* anAct = anActors->GetNextActor()) {
+ GEOM_Actor* aGeomActor = GEOM_Actor::SafeDownCast(anAct);
+ aGeomActor->SetVectorMode(!aGeomActor->GetVectorMode());
+ }
+ if (myUpdateViewer)
+ aView->Repaint();
+ }
+ else if (OCCViewer_Viewer* occViewer = GetOCCViewer(anApp)) {
+ Handle(AIS_InteractiveContext) ic = occViewer->getAISContext();
+ SOCC_Viewer* soccViewer = dynamic_cast<SOCC_Viewer*>(occViewer);
+ if (soccViewer) {
+ SOCC_Prs* occPrs = dynamic_cast<SOCC_Prs*>( soccViewer->CreatePrs( myEntry.c_str() ) );
+ if ( occPrs && !occPrs->IsNull() ) {
+ AIS_ListOfInteractive shapes; occPrs->GetObjects( shapes );
+ AIS_ListIteratorOfListOfInteractive interIter( shapes );
+ for ( ; interIter.More(); interIter.Next() ) {
+ Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast( interIter.Value() );
+ aSh->SetDisplayVectors(myOn);
+ ic->RecomputePrsOnly(interIter.Value());
+ }
+ }
+ }
+ }
+ }
+ };
+
+ ProcessVoidEvent(new TEvent (theEntry, isOn, isUpdated));
+}
+
+void GEOM_Swig::setColor(const char* theEntry, int red, int green, int blue, bool isUpdated)
+{
+ class TEvent: public SALOME_Event {
+ QString myEntry;
+ int myRed;
+ int myGreen;
+ int myBlue;
+ bool myUpdateViewer;
+ public:
+ TEvent(const char* theEntryArg, int theR, int theG, int theB, bool theUpdated):
+ myEntry(theEntryArg), myRed(theR), myGreen(theG), myBlue(theB), myUpdateViewer(theUpdated)
+ {}
+ virtual void Execute() {
+ SUIT_Application* anApp = SUIT_Session::session()->activeApplication();
+ if (!anApp) return;
+ GEOMToolsGUI::SetColor( myEntry, QColor( myRed, myGreen, myBlue), myUpdateViewer );
+ }
+ };
+ ProcessVoidEvent(new TEvent(theEntry, red, green, blue, isUpdated));
+}
+
+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 =
+ new SALOME_InteractiveObject(myEntry.c_str(), "GEOM", "");
+
+ if (SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(app)) {
+ SVTK_Viewer* aView = dynamic_cast<SVTK_Viewer*>(aViewWindow->getViewManager()->getViewModel());
+ SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>( aView->CreatePrs( myEntry.c_str() ) );
+ if ( vtkPrs ) {
+ vtkActorCollection* anActors = vtkPrs->GetObjects();
+ anActors->InitTraversal();
+ GEOM_Actor* anActor = GEOM_Actor::SafeDownCast( anActors->GetNextActor() );
+ if ( anActor ) {
+ int aIsos[2]={myNbU,myNbV};
+ anActor->SetNbIsos(aIsos);
+ anActor->StoreIsoNumbers();
+ QString anIsos = QString("%1%2%3").arg(myNbU).arg(DIGIT_SEPARATOR).arg(myNbV);
+ int aMgrId = aView->getViewManager()->getGlobalId();
+ study->setObjectProperty(aMgrId, myEntry.c_str(), ISOS_PROP, anIsos);
+ }
+ }
+
+ if (myUpdateViewer)
+ aView->Repaint();
+ }
+ else if (OCCViewer_Viewer* occViewer = GetOCCViewer(app)) {
+ Handle(AIS_InteractiveContext) ic = occViewer->getAISContext();
+ SOCC_Viewer* soccViewer = dynamic_cast<SOCC_Viewer*>(occViewer);
+ if (soccViewer) {
+ int aMgrId = soccViewer->getViewManager()->getGlobalId();
+ SOCC_Prs* occPrs = dynamic_cast<SOCC_Prs*>( soccViewer->CreatePrs( myEntry.c_str() ) );
+ if ( occPrs && !occPrs->IsNull() ) {
+ AIS_ListOfInteractive shapes; occPrs->GetObjects( shapes );
+ AIS_ListIteratorOfListOfInteractive interIter( shapes );
+ for ( ; interIter.More(); interIter.Next() ) {
+ Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast( interIter.Value() );
+ if ( !aSh.IsNull() ) {
+ Handle(AIS_Drawer) drawer = aSh->Attributes();
+ QVariant v = study->getObjectProperty( aMgrId, myEntry.c_str(), EDGE_WIDTH_PROP, QVariant() );
+ int width = v.isValid() ? v.toInt() : 1;
+ drawer->SetUIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, width, myNbU) );
+ drawer->SetVIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, width, myNbV) );
+ aSh->storeIsoNumbers();
+ ic->SetLocalAttributes(aSh, drawer);
+ ic->Redisplay(aSh);
+ QString anIsos = QString("%1%2%3").arg(myNbU).arg(DIGIT_SEPARATOR).arg(myNbV);
+ study->setObjectProperty(aMgrId, myEntry.c_str(), ISOS_PROP, anIsos);
+ }
+ }
+ }
+ }
+ }
+ }
+ };
+
+ ProcessVoidEvent(new TEvent (Entry, nbU, nbV, isUpdated));
+}
+
+void GEOM_Swig::setTransparency(const char* theEntry, float transp, bool isUpdated)
+{
+ class TEvent: public SALOME_Event {
+ std::string myEntry;
+ float myParam;
+ bool myUpdateViewer;
+ public:
+ TEvent(const char* theEntryArg, float theParam, bool theUpdated):
+ myEntry(theEntryArg), myParam(theParam), myUpdateViewer(theUpdated)
+ {}
+ virtual void Execute() {
+ SUIT_Application* anApp = SUIT_Session::session()->activeApplication();
+ if (!anApp) return;
+
+ Handle(SALOME_InteractiveObject) anIO =
+ new SALOME_InteractiveObject(myEntry.c_str(), "GEOM", "");
+
+ if (SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(anApp)) {
+ SVTK_View* aView = aViewWindow->getView();
+ aView->SetTransparency(anIO, myParam);
+ if (myUpdateViewer)
+ aView->Repaint();
+ } else if (OCCViewer_Viewer* occViewer = GetOCCViewer(anApp)) {
+ SOCC_Viewer* soccViewer = dynamic_cast<SOCC_Viewer*>(occViewer);
+ if (soccViewer)
+ soccViewer->setTransparency(anIO, myParam, myUpdateViewer);
+ }
+ }
+ };
+
+ ProcessVoidEvent(new TEvent (theEntry, transp, isUpdated));
+}
+
+
+class TInitGeomGenEvent: public SALOME_Event {
+public:
+ typedef bool TResult;
+ TResult myResult;
+ TInitGeomGenEvent() : myResult(false) {}
+ virtual void Execute() {
+ myResult = GeometryGUI::InitGeomGen();
+ }
+};
+bool GEOM_Swig::initGeomGen()
+{
+ return ProcessEvent(new TInitGeomGenEvent());
+}
+
+
+
+void GEOM_Swig::eraseGO (const char* Entry, bool allWindows)
+{
+ class TEvent: public SALOME_Event
+ {
+ std::string myEntry;
+ bool myFromAllWindows;
+ public:
+ TEvent(const char* theEntry, bool fromAllWindows):
+ myEntry(theEntry), myFromAllWindows(fromAllWindows)
+ {}
+ virtual void Execute()
+ {
+ SUIT_Application* app = SUIT_Session::session()->activeApplication();
+ if (!app) return;
+ SalomeApp_Study* ActiveStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
+ if (!ActiveStudy) return;
+
+ Handle (SALOME_InteractiveObject) aIO = new SALOME_InteractiveObject(myEntry.c_str(), "GEOM", "");
+
+ GEOM_Displayer(ActiveStudy).Erase(aIO, true);
+ /* if (myFromAllWindows) {
+ QPtrList<SUIT_ViewWindow> aWindows = app->desktop()->windows();
+ SUIT_ViewWindow* aWin = 0;
+ for (aWin = aWindows.first(); aWin; aWin = aWindows.next()) {
+ EraseObject(aWin, aIO);
+ }
+ } else {
+ SUIT_ViewWindow* aWin = app->desktop()->activeWindow();
+ if (aWin)
+ EraseObject(aWin, aIO);
+ }*/
+ }
+
+ /* private:
+ void EraseObject(SUIT_ViewWindow* theWin, Handle (SALOME_InteractiveObject) theIO)
+ {
+ if (theWin->getViewManager()->getType() == OCCViewer_Viewer::Type()){
+ OCCViewer_ViewWindow* vw = dynamic_cast<OCCViewer_ViewWindow*>( theWin );
+ if ( vw ) {
+ OCCViewer_ViewManager* vm = dynamic_cast<OCCViewer_ViewManager*>( vw->getViewManager() );
+ if ( vm ) {
+ SOCC_Viewer* aViewer = dynamic_cast<SOCC_Viewer*>(vm->getOCCViewer());
+ if (aViewer) {
+ SALOME_Prs* aPrs = aViewer->CreatePrs(myEntry.c_str());
+ if (aPrs) {
+ SALOME_OCCPrs* aOccPrs = dynamic_cast<SALOME_OCCPrs*>(aPrs);
+ if (aOccPrs) {
+ aViewer->Erase(aOccPrs);
+ aViewer->Repaint();
+ }
+ }
+ }
+ }
+ }
+ } else if (theWin->getViewManager()->getType() == SVTK_Viewer::Type()){
+ SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( theWin );
+ if (aViewWindow) {
+ aViewWindow->Erase(theIO);
+ }
+ }
+ }*/
+
+ };
+ ProcessVoidEvent(new TEvent(Entry, allWindows));
+}
+
+
+
+void GEOM_Swig::setDeflection(const char* theEntry, float theDeflect)
+{
+ class TEvent: public SALOME_Event {
+ std::string myEntry;
+ float myParam;
+ public:
+ TEvent(const char* theEntryArg, float theParam):
+ myEntry(theEntryArg), myParam(theParam)
+ {}
+ virtual void Execute() {
+ SUIT_Application* anApp = SUIT_Session::session()->activeApplication();
+ if (!anApp) return;
+
+ Handle(SALOME_InteractiveObject) anIO =
+ new SALOME_InteractiveObject(myEntry.c_str(), "GEOM", "");
+
+ if (SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(anApp)) {
+ vtkActorCollection* aActors = aViewWindow->getRenderer()->GetActors();
+ aActors->InitTraversal();
+ while (vtkActor* aAct = aActors->GetNextActor()) {
+ if (GEOM_Actor* aGeomActor = dynamic_cast<GEOM_Actor*>(aAct)) {
+ if (aGeomActor->hasIO()) {
+ Handle(SALOME_InteractiveObject) aNextIO = aGeomActor->getIO();
+ if (aNextIO->isSame(anIO)) {
+ aGeomActor->setDeflection(myParam);
+ aViewWindow->Repaint();
+ return;
+ }
+ }
+ }
+ }
+ // aView->SetTransparency(anIO, myParam);
+ //aView->Repaint();
+ } else if (OCCViewer_Viewer* occViewer = GetOCCViewer(anApp)) {
+ Handle(AIS_InteractiveContext) aContext = occViewer->getAISContext();
+ AIS_ListOfInteractive aAISList;
+ aContext->DisplayedObjects(aAISList);
+ AIS_ListIteratorOfListOfInteractive it(aAISList);
+ for (; it.More(); it.Next()) {
+ Handle(SALOME_InteractiveObject) aObj =
+ Handle(SALOME_InteractiveObject)::DownCast(it.Value()->GetOwner());
+ if ((!aObj.IsNull()) && aObj->hasEntry() && aObj->isSame(anIO)) {
+ Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(it.Value());
+ if (!aShape.IsNull()) {
+ TopoDS_Shape aSh = aShape->Shape();
+ if (!aSh.IsNull())
+ BRepTools::Clean(aSh);
+
+ aShape->SetOwnDeviationCoefficient( myParam );
+ aShape->SetOwnHLRDeviationAngle( 1.57 );
+ aContext->Redisplay(aShape);
+ return;
+ }
+ }
+ }
+ }
+ }
+ };
+
+ ProcessVoidEvent(new TEvent (theEntry, theDeflect));
+}
+
--- /dev/null
+// 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 : libGEOM_Swig.h
+// Author : Nicolas REJNERI, Paul RASCLE
+//
+
+#ifndef GEOMETRYGUI_SWIG_HXX
+#define GEOMETRYGUI_SWIG_HXX
+
+#include "GEOM_GEOMGUI.hxx"
+
+// IDL Headers
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(GEOM_Gen)
+#include CORBA_SERVER_HEADER(SALOMEDS)
+#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+
+class GEOMGUI_EXPORT GEOM_Swig
+{
+public:
+ GEOM_Swig();
+ ~GEOM_Swig();
+
+ void createAndDisplayGO(const char* Entry, bool isUpdated = true);
+ void eraseGO(const char* Entry, bool allWindows);
+ void createAndDisplayFitAllGO(const char* Entry);
+ void UpdateViewer();
+ void setDisplayMode(const char* Entry, int mode, bool isUpdated = true);
+ void setVectorsMode(const char* Entry, bool isSet, bool isUpdated = true);
+ void setColor(const char* Entry, int red, int green, int blue, bool isUpdated = true);
+ void setTransparency(const char* Entry, float transp, bool isUpdated = true);
+ void setIsos(const char* Entry, int nbU, int nbV, bool isUpdated =true);
+ void setDeflection(const char* Entry, float deflect);
+
+ int getIndexTopology(const char *SubEntry, const char *Entry);
+ const char* getShapeTypeString(const char *Entry);
+ const char* getShapeTypeIcon(const char *Ior);
+
+ bool initGeomGen();
+};
+
+#endif // GEOMETRYGUI_SWIG_HXX
//
%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();
+};
// 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 : GroupGUI.cxx
// Author : Sergey ANIKIN, Open CASCADE S.A.S. (sergey.anikin@opencascade.com)
-//
+
#include "GroupGUI.h"
#include "GroupGUI_GroupDlg.h"
+#include "GroupGUI_BooleanDlg.h"
#include <GeometryGUI.h>
#include "GeometryGUI_Operations.h"
// function : GroupGUI()
// purpose : Constructor
//=======================================================================
-GroupGUI::GroupGUI( GeometryGUI* parent )
- : GEOMGUI( parent )
+GroupGUI::GroupGUI (GeometryGUI* parent)
+ : GEOMGUI(parent)
{
}
// function : OnGUIEvent()
// purpose :
//=======================================================================
-bool GroupGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent )
+bool GroupGUI::OnGUIEvent (int theCommandID, SUIT_Desktop* parent)
{
SalomeApp_Application* app = getGeometryGUI()->getApp();
- if ( !app ) return false;
+ if (!app) return false;
getGeometryGUI()->EmitSignalDeactivateDialog();
QDialog* aDlg = 0;
- SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
- if ( !appStudy ) return false;
+ SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
+ if (!appStudy) return false;
_PTR(Study) aStudy = appStudy->studyDS();
- if ( aStudy->GetProperties()->IsLocked() ) {
- SUIT_MessageBox::warning( parent,
- tr( "WRN_WARNING" ),
- tr( "WRN_STUDY_LOCKED" ) );
+ if (aStudy->GetProperties()->IsLocked()) {
+ SUIT_MessageBox::warning(parent, tr("WRN_WARNING"), tr("WRN_STUDY_LOCKED"));
return false;
}
- switch ( theCommandID ) {
+ switch (theCommandID) {
case GEOMOp::OpGroupCreate:
case GEOMOp::OpGroupCreatePopup: // CREATE GROUP
- aDlg = new GroupGUI_GroupDlg( GroupGUI_GroupDlg::CreateGroup, getGeometryGUI(), parent );
+ aDlg = new GroupGUI_GroupDlg (GroupGUI_GroupDlg::CreateGroup, getGeometryGUI(), parent);
break;
- case GEOMOp::OpGroupEdit: // EDIT GROUP
+ case GEOMOp::OpGroupEdit: // EDIT GROUP
{
SALOME_ListIO aList;
aList.Clear();
LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
- if ( aSelMgr )
- aSelMgr->selectedObjects( aList );
+ if (aSelMgr)
+ aSelMgr->selectedObjects(aList);
- if ( aList.Extent() == 1 ) {
+ if (aList.Extent() == 1) {
GEOM::GEOM_Object_var anObj =
- GEOMBase::ConvertIOinGEOMObject( aList.First() );
+ GEOMBase::ConvertIOinGEOMObject(aList.First());
- if ( !CORBA::is_nil( anObj ) && anObj->GetType() == GEOM_GROUP ) {
- aDlg = new GroupGUI_GroupDlg( GroupGUI_GroupDlg::EditGroup, getGeometryGUI(), parent );
+ if (!CORBA::is_nil(anObj) && anObj->GetType() == GEOM_GROUP) {
+ aDlg = new GroupGUI_GroupDlg (GroupGUI_GroupDlg::EditGroup, getGeometryGUI(), parent);
break;
}
}
- SUIT_MessageBox::warning( parent, tr( "WRN_WARNING" ), tr( "NO_GROUP" ) );
- break;
+ SUIT_MessageBox::warning(parent, tr("WRN_WARNING"), tr("NO_GROUP"));
}
+ break;
+ case GEOMOp::OpGroupUnion: // UNION GROUPS
+ aDlg = new GroupGUI_BooleanDlg (GroupGUI_BooleanDlg::UNION, getGeometryGUI(), parent);
+ break;
+ case GEOMOp::OpGroupIntersect: // INTERSECT GROUPS
+ aDlg = new GroupGUI_BooleanDlg (GroupGUI_BooleanDlg::INTERSECT, getGeometryGUI(), parent);
+ break;
+ case GEOMOp::OpGroupCut: // CUT GROUPS
+ aDlg = new GroupGUI_BooleanDlg (GroupGUI_BooleanDlg::CUT, getGeometryGUI(), parent);
+ break;
default:
- app->putInfo( tr( "GEOM_PRP_COMMAND" ).arg( theCommandID ) );
+ app->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID));
break;
}
- if ( aDlg ) {
+ if (aDlg) {
aDlg->updateGeometry();
- aDlg->resize( aDlg->minimumSizeHint() );
+ aDlg->resize(aDlg->minimumSizeHint());
aDlg->show();
}
--- /dev/null
+// 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 : GroupGUI_BooleanDlg.cxx
+// Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
+
+#include "GroupGUI_BooleanDlg.h"
+
+#include <DlgRef.h>
+#include <GeometryGUI.h>
+#include <GEOMBase.h>
+
+#include <SUIT_Session.h>
+#include <SUIT_ResourceMgr.h>
+#include <SalomeApp_Application.h>
+#include <LightApp_SelectionMgr.h>
+
+#include <GEOMImpl_Types.hxx>
+
+//=================================================================================
+// class : GroupGUI_BooleanDlg()
+// purpose : Constructs a GroupGUI_BooleanDlg which is a child of 'parent', with the
+// name 'name' and widget flags set to 'f'.
+// The dialog will by default be modeless, unless you set 'modal' to
+// TRUE to construct a modal dialog.
+//=================================================================================
+GroupGUI_BooleanDlg::GroupGUI_BooleanDlg (const int theOperation, GeometryGUI* theGeometryGUI,
+ QWidget* parent, bool modal, Qt::WindowFlags fl)
+ : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl),
+ myOperation(theOperation)
+{
+ QPixmap image0;
+ QString aTitle, aCaption;
+ switch (myOperation) {
+ case UNION:
+ image0 = QPixmap(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_FUSE")));
+ aTitle = tr("GEOM_UNION");
+ aCaption = tr("GEOM_UNION_TITLE");
+ setHelpFileName("work_with_groups_page.html#union_groups_anchor");
+ break;
+ case INTERSECT:
+ image0 = QPixmap(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_COMMON")));
+ aTitle = tr("GEOM_INTERSECT");
+ aCaption = tr("GEOM_INTERSECT_TITLE");
+ setHelpFileName("work_with_groups_page.html#intersect_groups_anchor");
+ break;
+ case CUT:
+ image0 = QPixmap(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_CUT")));
+ aTitle = tr("GEOM_CUT");
+ aCaption = tr("GEOM_CUT_TITLE");
+ setHelpFileName("work_with_groups_page.html#cut_groups_anchor");
+ break;
+ }
+ QPixmap image1 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT")));
+
+ setWindowTitle(aCaption);
+
+ /***************************************************************/
+ mainFrame()->GroupConstructors->setTitle(aTitle);
+ mainFrame()->RadioButton1->setIcon(image0);
+ mainFrame()->RadioButton2->setAttribute(Qt::WA_DeleteOnClose);
+ mainFrame()->RadioButton2->close();
+ mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
+ mainFrame()->RadioButton3->close();
+
+ myGroup = new DlgRef_2Sel (centralWidget());
+
+ myGroup->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
+ if (myOperation == CUT) {
+ myGroup->TextLabel1->setText(tr("GEOM_MAIN_GROUPS"));
+ myGroup->TextLabel2->setText(tr("GEOM_TOOL_GROUPS"));
+ }
+ else {
+ myGroup->TextLabel1->setText(tr("GEOM_GROUPS").arg(1));
+ myGroup->TextLabel2->hide();
+ myGroup->PushButton2->hide();
+ myGroup->LineEdit2->hide();
+ }
+
+ myGroup->PushButton1->setIcon(image1);
+ myGroup->PushButton2->setIcon(image1);
+ myGroup->LineEdit1->setReadOnly(true);
+ myGroup->LineEdit2->setReadOnly(true);
+
+ QVBoxLayout* layout = new QVBoxLayout (centralWidget());
+ layout->setMargin(0); layout->setSpacing(6);
+ layout->addWidget(myGroup);
+ /***************************************************************/
+
+ // Initialisation
+ Init();
+}
+
+//=================================================================================
+// function : ~GroupGUI_BooleanDlg()
+// purpose : Destroys the object and frees any allocated resources
+//=================================================================================
+GroupGUI_BooleanDlg::~GroupGUI_BooleanDlg()
+{
+}
+
+//=================================================================================
+// function : Init()
+// purpose :
+//=================================================================================
+void GroupGUI_BooleanDlg::Init()
+{
+ // init variables
+ myEditCurrentArgument = myGroup->LineEdit1;
+
+ myGroup->LineEdit1->setText("");
+ myGroup->LineEdit2->setText("");
+ myListShapes.length( 0 );
+ myListTools.length( 0 );
+
+ // signals and slots connections
+ connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
+ connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
+
+ connect(myGroup->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
+ connect(myGroup->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
+
+ connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
+ SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
+
+ initName(mainFrame()->GroupConstructors->title());
+
+ setTabOrder(mainFrame()->GroupConstructors, mainFrame()->GroupBoxName);
+ setTabOrder(mainFrame()->GroupBoxName, mainFrame()->GroupMedium);
+ setTabOrder(mainFrame()->GroupMedium, mainFrame()->GroupButtons);
+
+ mainFrame()->RadioButton1->setFocus();
+
+ globalSelection(GEOM_GROUP);
+
+ myGroup->PushButton1->click();
+ SelectionIntoArgument();
+ resize(100,100);
+}
+
+//=================================================================================
+// function : ClickOnOk()
+// purpose :
+//=================================================================================
+void GroupGUI_BooleanDlg::ClickOnOk()
+{
+ setIsApplyAndClose(true);
+ if (ClickOnApply())
+ ClickOnCancel();
+}
+
+//=================================================================================
+// function : ClickOnApply()
+// purpose :
+//=================================================================================
+bool GroupGUI_BooleanDlg::ClickOnApply()
+{
+ if (!onAccept())
+ return false;
+
+ initName();
+ // activate selection and connect selection manager
+ myGroup->PushButton1->click();
+ return true;
+}
+
+//=================================================================================
+// function : SelectionIntoArgument()
+// purpose : Called when selection is changed or on dialog initialization or activation
+//=================================================================================
+void GroupGUI_BooleanDlg::SelectionIntoArgument()
+{
+ myEditCurrentArgument->setText("");
+
+ LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
+ SALOME_ListIO aSelList;
+ aSelMgr->selectedObjects(aSelList);
+
+ QString aString = "";
+ GEOMBase::GetNameOfSelectedIObjects(aSelList, aString, true);
+
+ if (myEditCurrentArgument == myGroup->LineEdit1) {
+ GEOMBase::ConvertListOfIOInListOfGO(aSelList, myListShapes, true);
+ }
+ else if ( myEditCurrentArgument == myGroup->LineEdit2 ) {
+ GEOMBase::ConvertListOfIOInListOfGO(aSelList, myListTools, true);
+ }
+
+ myEditCurrentArgument->setText(aString);
+}
+
+//=================================================================================
+// function : SetEditCurrentArgument()
+// purpose :
+//=================================================================================
+void GroupGUI_BooleanDlg::SetEditCurrentArgument()
+{
+ QPushButton* send = (QPushButton*)sender();
+
+ if (send == myGroup->PushButton1) {
+ myEditCurrentArgument = myGroup->LineEdit1;
+
+ myGroup->PushButton2->setDown(false);
+ myGroup->LineEdit2->setEnabled(false);
+ }
+ else if (send == myGroup->PushButton2) {
+ myEditCurrentArgument = myGroup->LineEdit2;
+
+ myGroup->PushButton1->setDown(false);
+ myGroup->LineEdit1->setEnabled(false);
+ }
+
+ // enable line edit
+ myEditCurrentArgument->setEnabled(true);
+ myEditCurrentArgument->setFocus();
+ // after setFocus(), because it will be setDown(false) when loses focus
+ send->setDown(true);
+}
+
+//=================================================================================
+// function : ActivateThisDialog()
+// purpose :
+//=================================================================================
+void GroupGUI_BooleanDlg::ActivateThisDialog()
+{
+ GEOMBase_Skeleton::ActivateThisDialog();
+
+ connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
+ this, SLOT(SelectionIntoArgument()));
+}
+
+//=================================================================================
+// function : enterEvent()
+// purpose : when mouse enter onto the QWidget
+//=================================================================================
+void GroupGUI_BooleanDlg::enterEvent (QEvent*)
+{
+ if (!mainFrame()->GroupConstructors->isEnabled())
+ ActivateThisDialog();
+}
+
+//=================================================================================
+// function : createOperation
+// purpose :
+//=================================================================================
+GEOM::GEOM_IOperations_ptr GroupGUI_BooleanDlg::createOperation()
+{
+ return getGeomEngine()->GetIGroupOperations(getStudyId());
+}
+
+//=================================================================================
+// function : isValid
+// purpose :
+//=================================================================================
+bool GroupGUI_BooleanDlg::isValid (QString&)
+{
+ return (myListShapes.length() > 0);
+}
+
+//=================================================================================
+// function : execute
+// purpose :
+//=================================================================================
+bool GroupGUI_BooleanDlg::execute (ObjectList& objects)
+{
+ GEOM::GEOM_Object_var anObj;
+
+ GEOM::GEOM_IGroupOperations_var anOper = GEOM::GEOM_IGroupOperations::_narrow(getOperation());
+ switch (myOperation) {
+ case UNION:
+ anObj = anOper->UnionListOfGroups(myListShapes);
+ break;
+ case INTERSECT:
+ anObj = anOper->IntersectListOfGroups(myListShapes);
+ break;
+ case CUT:
+ anObj = anOper->CutListOfGroups(myListShapes, myListTools);
+ break;
+ default:
+ ;
+ }
+ if (!anObj->_is_nil())
+ objects.push_back(anObj._retn());
+
+ return true;
+}
+
+//================================================================
+// Function : getFather
+// Purpose : Get father object for object to be added in study
+// (called with addInStudy method)
+//================================================================
+GEOM::GEOM_Object_ptr GroupGUI_BooleanDlg::getFather(GEOM::GEOM_Object_ptr theObj)
+{
+ GEOM::GEOM_Object_var aFatherObj;
+ if (theObj->GetType() == GEOM_GROUP) {
+ GEOM::GEOM_IGroupOperations_var anOper = GEOM::GEOM_IGroupOperations::_narrow(getOperation());
+ aFatherObj = anOper->GetMainShape(theObj);
+ }
+ return aFatherObj._retn();
+}
--- /dev/null
+// 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 : GroupGUI_BooleanDlg.h
+// Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
+
+#ifndef GROUPGUI_BOOLEANDLG_H
+#define GROUPGUI_BOOLEANDLG_H
+
+#include "GEOMBase_Skeleton.h"
+#include "GEOM_GenericObjPtr.h"
+
+class DlgRef_2Sel;
+
+//=================================================================================
+// class : GroupGUI_BooleanDlg
+// purpose :
+//=================================================================================
+class GroupGUI_BooleanDlg : public GEOMBase_Skeleton
+{
+ Q_OBJECT
+
+public:
+ enum Operation { UNION = 1, INTERSECT = 2, CUT = 3 };
+
+ GroupGUI_BooleanDlg (const int, GeometryGUI*, QWidget* = 0,
+ bool = false, Qt::WindowFlags = 0);
+ ~GroupGUI_BooleanDlg();
+
+protected:
+ // redefined from GEOMBase_Helper
+ virtual GEOM::GEOM_IOperations_ptr createOperation();
+ virtual bool isValid (QString&);
+ virtual bool execute (ObjectList&);
+ virtual GEOM::GEOM_Object_ptr getFather (GEOM::GEOM_Object_ptr);
+
+private:
+ void Init();
+ void enterEvent (QEvent*);
+
+private slots:
+ void ClickOnOk();
+ bool ClickOnApply();
+ void SetEditCurrentArgument();
+ void SelectionIntoArgument();
+ void ActivateThisDialog();
+
+private:
+ int myOperation;
+
+ GEOM::ListOfGO myListShapes;
+ GEOM::ListOfGO myListTools;
+
+ DlgRef_2Sel* myGroup;
+};
+
+#endif // GROUPGUI_BOOLEANDLG_H
# 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 GROUPGUI :
# File : Makefile.am
# Author : Alexander BORODIN, Open CASCADE S.A.S. (alexander.borodin@opencascade.com)
# Package : GroupGUI
-#
+
include $(top_srcdir)/adm_local/unix/make_common_starter.am
# Libraries targets
# header files
salomeinclude_HEADERS = \
GroupGUI.h \
+ GroupGUI_BooleanDlg.h \
GroupGUI_GroupDlg.h
dist_libGroupGUI_la_SOURCES = \
GroupGUI.h \
+ GroupGUI_BooleanDlg.h \
GroupGUI_GroupDlg.h \
GroupGUI.cxx \
+ GroupGUI_BooleanDlg.cxx \
GroupGUI_GroupDlg.cxx
-MOC_FILES = \
- GroupGUI_moc.cxx \
+MOC_FILES = \
+ GroupGUI_moc.cxx \
+ GroupGUI_BooleanDlg_moc.cxx \
GroupGUI_GroupDlg_moc.cxx
nodist_libGroupGUI_la_SOURCES = \
#include <BRep_Builder.hxx>
#include <gp_Pnt.hxx>
+#include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
+
#ifdef WNT
#if defined IGESIMPORT_EXPORTS || defined IGESImport_EXPORTS
#if defined WIN32
extern "C"
{
+ IGESIMPORT_EXPORT
+ Handle(TCollection_HAsciiString) GetValue (const TCollection_AsciiString& theFileName,
+ const TCollection_AsciiString& theParameterName,
+ TCollection_AsciiString& theError)
+ {
+ Handle(TCollection_HAsciiString) aValue;
+
+ if (theParameterName != "LEN_UNITS") {
+ theError = theParameterName + " parameter reading is not supported by IGES plugin";
+ return aValue;
+ }
+
+ // Set "C" numeric locale to save numbers correctly
+ Kernel_Utils::Localizer loc;
+
+ IGESControl_Reader aReader;
+
+ Interface_Static::SetCVal("xstep.cascade.unit","M");
+
+ try {
+ OCC_CATCH_SIGNALS;
+
+ IFSelect_ReturnStatus status = aReader.ReadFile(theFileName.ToCString());
+ if (status == IFSelect_RetDone) {
+ Handle(IGESData_IGESModel) aModel =
+ Handle(IGESData_IGESModel)::DownCast(aReader.Model());
+ if (!aModel.IsNull()) {
+ aValue = aModel->GlobalSection().UnitName();
+
+ if (!aValue.IsNull()) {
+ Handle(TCollection_HAsciiString) aPrefix = new TCollection_HAsciiString ("UNIT_");
+ aValue->Prepend(aPrefix);
+ }
+ }
+ }
+ else {
+ theError = theFileName + " reading failed";
+ }
+ }
+ catch (Standard_Failure) {
+ Handle(Standard_Failure) aFail = Standard_Failure::Caught();
+ theError = aFail->GetMessageString();
+ }
+
+ return aValue;
+ }
+
IGESIMPORT_EXPORT
TopoDS_Shape Import (const TCollection_AsciiString& theFileName,
const TCollection_AsciiString& theFormatName,
TCollection_AsciiString& theError,
const TDF_Label& theShapeLabel)
{
+ TopoDS_Shape aResShape;
+
// Set "C" numeric locale to save numbers correctly
Kernel_Utils::Localizer loc;
IGESControl_Reader aReader;
- TopoDS_Shape aResShape;
+
Interface_Static::SetCVal("xstep.cascade.unit","M");
+
try {
+ OCC_CATCH_SIGNALS;
+
IFSelect_ReturnStatus status = aReader.ReadFile(theFileName.ToCString());
if (status == IFSelect_RetDone) {
+ // BEGIN: old code
if (theFormatName == "IGES_UNIT") {
Handle(IGESData_IGESModel) aModel =
Handle(IGESData_IGESModel)::DownCast(aReader.Model());
- gp_Pnt P(1.0,0.0,0.0);
+ gp_Pnt P (1.0, 0.0, 0.0);
if (!aModel.IsNull()) {
Handle(TCollection_HAsciiString) aUnitName =
aModel->GlobalSection().UnitName();
- //cout<<"aUnitName = "<<aUnitName->ToCString()<<endl;
- //cout<<"aUnitFlag = "<<aModel->GlobalSection().UnitFlag()<<endl;
- if (aUnitName->String()=="MM") {
- P = gp_Pnt(0.001,0.0,0.0);
- }
- else if (aUnitName->String()=="CM") {
- P = gp_Pnt(0.01,0.0,0.0);
+ if (!aUnitName.IsNull()) {
+ if (aUnitName->String()=="MM") {
+ P = gp_Pnt(0.001,0.0,0.0);
+ }
+ else if (aUnitName->String()=="CM") {
+ P = gp_Pnt(0.01,0.0,0.0);
+ }
}
}
BRep_Builder B;
aResShape = V;
return aResShape;
}
+ // END: old code
+
if (theFormatName == "IGES_SCALE") {
//cout<<"need re-scale a model"<<endl;
// set UnitFlag to 'meter'
MeasureGUI_WhatisDlg.h \
MeasureGUI_CheckShapeDlg.h \
MeasureGUI_CheckCompoundOfBlocksDlg.h \
+ MeasureGUI_GetNonBlocksDlg.h \
MeasureGUI_CheckSelfIntersectionsDlg.h \
MeasureGUI_PointDlg.h
MeasureGUI_WhatisDlg.cxx \
MeasureGUI_CheckShapeDlg.cxx \
MeasureGUI_CheckCompoundOfBlocksDlg.cxx \
+ MeasureGUI_GetNonBlocksDlg.cxx \
MeasureGUI_CheckSelfIntersectionsDlg.cxx \
MeasureGUI_PointDlg.cxx
MeasureGUI_WhatisDlg_moc.cxx \
MeasureGUI_CheckShapeDlg_moc.cxx \
MeasureGUI_CheckCompoundOfBlocksDlg_moc.cxx \
+ MeasureGUI_GetNonBlocksDlg_moc.cxx \
MeasureGUI_CheckSelfIntersectionsDlg_moc.cxx \
MeasureGUI_PointDlg_moc.cxx
libMeasureGUI_la_LDFLAGS = \
$(CAS_LDFLAGS) -lTKGeomBase \
../GEOMBase/libGEOMBase.la ../DlgRef/libDlgRef.la
-
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
// GEOM GEOMGUI : GUI for Geometry component
// File : MeasureGUI.cxx
#include "MeasureGUI_WhatisDlg.h" // Method WHATIS
#include "MeasureGUI_CheckShapeDlg.h" // Method CHECKSHAPE
#include "MeasureGUI_CheckCompoundOfBlocksDlg.h" // Method CHECKCOMPOUND
+#include "MeasureGUI_GetNonBlocksDlg.h" // Method GET NON BLOCKS
#include "MeasureGUI_CheckSelfIntersectionsDlg.h" // Method CHECK SELF INTERSCTIONS
#include "MeasureGUI_PointDlg.h" // Method POINTCOORDINATES
case GEOMOp::OpCheckCompound:
dlg = new MeasureGUI_CheckCompoundOfBlocksDlg( getGeometryGUI(), parent );
break; // CHECKCOMPOUND
+ case GEOMOp::OpGetNonBlocks:
+ dlg = new MeasureGUI_GetNonBlocksDlg(getGeometryGUI(), parent);
+ break; // GET NON BLOCKS
case GEOMOp::OpCheckSelfInters:
dlg = new MeasureGUI_CheckSelfIntersectionsDlg( getGeometryGUI(), parent );
break; // CHECK SELF INTERSCTIONS
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
// GEOM GEOMGUI : GUI for Geometry component
// File : MeasureGUI_BndBoxDlg.cxx
// Author : Nicolas REJNERI, Open CASCADE S.A.S.
-//
+
#include "MeasureGUI_BndBoxDlg.h"
#include "MeasureGUI_Widgets.h"
#include <GEOMBase.h>
#include <DlgRef.h>
-#include <GEOM_Function.hxx>
-#include <GEOM_Object.hxx>
-
#include <BRepPrimAPI_MakeBox.hxx>
-#include <BRepAdaptor_Surface.hxx>
-#include <BRep_Tool.hxx>
-#include <BRep_TFace.hxx>
-#include <TopoDS.hxx>
-#include <TopoDS_Face.hxx>
-#include <TopExp_Explorer.hxx>
#include <SUIT_Session.h>
#include <SUIT_ResourceMgr.h>
-#include <SalomeApp_Tools.h>
-
-// #include <qlineedit.h>
-// #include <qlabel.h>
-// #include <qlayout.h>
-// #include <qpushbutton.h>
-// #include <qradiobutton.h>
-// #include <qbuttongroup.h>
//=================================================================================
// class : MeasureGUI_BndBoxDlg()
-// purpose : Constructs a MeasureGUI_BndBoxDlg which is a child of 'parent', with the
+// purpose : Constructs a MeasureGUI_BndBoxDlg which is a child of 'parent', with the
// name 'name' and widget flags set to 'f'.
// The dialog will by default be modeless, unless you set 'modal' to
// true to construct a modal dialog.
//=================================================================================
-MeasureGUI_BndBoxDlg::MeasureGUI_BndBoxDlg( GeometryGUI* GUI, QWidget* parent )
- : MeasureGUI_Skeleton( GUI, parent )
+MeasureGUI_BndBoxDlg::MeasureGUI_BndBoxDlg (GeometryGUI* GUI, QWidget* parent)
+ : MeasureGUI_Skeleton(GUI, parent)
{
QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap(
"GEOM", tr( "ICON_DLG_BOUNDING_BOX" ) ) );
setWindowTitle( tr( "GEOM_BNDBOX_TITLE" ) );
/***************************************************************/
-
+
mainFrame()->GroupConstructors->setTitle( tr( "GEOM_BNDBOX" ) );
mainFrame()->RadioButton1->setIcon( image0 );
QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
layout->setMargin( 0 ); layout->setSpacing( 6 );
layout->addWidget( myGrp );
-
+
/***************************************************************/
myHelpFileName = "using_measurement_tools_page.html#bounding_box_anchor";
Init();
}
-
//=================================================================================
// function : ~MeasureGUI_BndBoxDlg()
// purpose : Destroys the object and frees any allocated resources
{
}
-
//=================================================================================
// function : Init()
// purpose :
{
double aXMin, aXMax, aYMin, aYMax, aZMin, aZMax;
- if ( !getParameters( aXMin, aXMax, aYMin, aYMax, aZMin, aZMax ) ) {
- mySelEdit->setText( "" );
- myGrp->LineEdit11->setText( "" );
- myGrp->LineEdit12->setText( "" );
- myGrp->LineEdit21->setText( "" );
- myGrp->LineEdit22->setText( "" );
- myGrp->LineEdit31->setText( "" );
- myGrp->LineEdit32->setText( "" );
+ if (!getParameters(aXMin, aXMax, aYMin, aYMax, aZMin, aZMax)) {
+ mySelEdit->setText("");
+ myGrp->LineEdit11->setText("");
+ myGrp->LineEdit12->setText("");
+ myGrp->LineEdit21->setText("");
+ myGrp->LineEdit22->setText("");
+ myGrp->LineEdit31->setText("");
+ myGrp->LineEdit32->setText("");
}
else {
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
// function : getParameters
// purpose :
//=================================================================================
-bool MeasureGUI_BndBoxDlg::getParameters( double& theXmin, double& theXmax,
+bool MeasureGUI_BndBoxDlg::getParameters (double& theXmin, double& theXmax,
double& theYmin, double& theYmax,
- double& theZmin, double& theZmax )
+ double& theZmin, double& theZmax)
{
- if ( myObj->_is_nil() )
+ if (myObj->_is_nil())
return false;
- else {
- GEOM::GEOM_IMeasureOperations_var anOper = GEOM::GEOM_IMeasureOperations::_narrow( getOperation() );
- try {
- Handle(Poly_Triangulation) Trtn = 0;
-
- GEOM::GEOM_Gen_var aGeomGen = GeometryGUI::GetGeomGen();
- if ( CORBA::is_nil(aGeomGen) )
- return false;
-
- QString IOR = GEOMBase::GetIORFromObject( myObj );
- GEOM::GEOM_Object_var anObject = aGeomGen->GetIORFromString( IOR.toLatin1().constData() );
- if ( CORBA::is_nil(anObject) )
- return false;
-
- TopoDS_Shape aShape;
- GEOMBase::GetShape(anObject, aShape, TopAbs_SHAPE);
- if ( aShape.IsNull() )
- return false;
-
- TopLoc_Location l;
- Handle(Poly_Triangulation) T;
- TopExp_Explorer ex;
- for (ex.Init(aShape,TopAbs_FACE); ex.More(); ex.Next()) {
- const TopoDS_Face& F = TopoDS::Face(ex.Current());
- BRepAdaptor_Surface surf(F);
- if (surf.GetType() == GeomAbs_Sphere) {
- T = BRep_Tool::Triangulation(F, l);
- if (!T.IsNull()) {
- Handle(Poly_Triangulation) NullTrtn = 0;
- (*((Handle(BRep_TFace)*)&F.TShape()))->Triangulation(NullTrtn);
- Trtn = T;
- break;
- }
- }
- else
- break;
- }
-
- anOper->GetBoundingBox( myObj, theXmin, theXmax, theYmin, theYmax, theZmin, theZmax );
-
- if (!Trtn.IsNull()) {
- TopLoc_Location l;
- Handle(Poly_Triangulation) T;
- TopExp_Explorer ex;
- for (ex.Init(aShape,TopAbs_FACE); ex.More(); ex.Next()) {
- const TopoDS_Face& F = TopoDS::Face(ex.Current());
- (*((Handle(BRep_TFace)*)&F.TShape()))->Triangulation(Trtn);
- break;
- }
- }
-
- }
- catch( const SALOME::SALOME_Exception& e ) {
- SalomeApp_Tools::QtCatchCorbaException( e );
- return false;
- }
-
- return anOper->IsDone();
- }
+
+ GEOM::GEOM_IMeasureOperations_var anOper = GEOM::GEOM_IMeasureOperations::_narrow(getOperation());
+ anOper->GetBoundingBox(myObj, theXmin, theXmax, theYmin, theYmax, theZmin, theZmax);
+
+ return anOper->IsDone();
}
//=================================================================================
{
double aXMin, aYMin, aZMin, aXMax, aYMax, aZMax;
- if ( myObj->_is_nil() || !getParameters( aXMin, aXMax, aYMin, aYMax, aZMin, aZMax ) )
+ if (!getParameters(aXMin, aXMax, aYMin, aYMax, aZMin, aZMax))
return 0;
- TopoDS_Shape aShape = BRepPrimAPI_MakeBox( gp_Pnt( aXMin, aYMin, aZMin ),
- gp_Pnt( aXMax, aYMax, aZMax ) ).Shape();
-
- return !aShape.IsNull() ? getDisplayer()->BuildPrs( aShape ) : 0;
+ TopoDS_Shape aShape = BRepPrimAPI_MakeBox(gp_Pnt(aXMin, aYMin, aZMin),
+ gp_Pnt(aXMax, aYMax, aZMax)).Shape();
+ return !aShape.IsNull() ? getDisplayer()->BuildPrs(aShape) : 0;
}
/***************************************************************/
- myHelpFileName = "using_measurement_tools_page.html#center_mass_anchor";
+ myHelpFileName = "center_mass_page.html";
/* Initialisation */
Init();
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
// GEOM GEOMGUI : GUI for Geometry component
// File : MeasureGUI_CheckSelfIntersectionsDlg.cxx
-// Author : Vladimir KLYACHIN, Open CASCADE S.A.S. (vladimir.klyachin@opencascade.com)
#include "MeasureGUI_CheckSelfIntersectionsDlg.h"
#include "MeasureGUI_Widgets.h"
SalomeApp_Tools::QtCatchCorbaException(e);
isFailed = true;
}
- if (isFailed) {
+
+ if (!anOper->IsDone()) {
+ aMsg += tr(anOper->GetErrorCode());
+ myGrp->TextView1->setText(aMsg);
+ return;
+ }
+ else if (isFailed) {
aMsg += tr("GEOM_CHECK_SELF_INTERSECTIONS_FAILED");
myGrp->TextView1->setText(aMsg);
return;
--- /dev/null
+// 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 : MeasureGUI_GetNonBlocksDlg.cxx
+
+#include "MeasureGUI_GetNonBlocksDlg.h"
+
+#include <DlgRef.h>
+#include <GEOMBase.h>
+
+#include <GeometryGUI.h>
+
+#include <SUIT_Session.h>
+#include <SUIT_ResourceMgr.h>
+#include <SalomeApp_Application.h>
+#include <LightApp_SelectionMgr.h>
+#include <SalomeApp_Tools.h>
+
+//=================================================================================
+// class : MeasureGUI_GetNonBlocksDlg()
+// purpose : Constructs a MeasureGUI_GetNonBlocksDlg which is a child of 'parent',
+// with the name 'name' and widget flags set to 'f'.
+// The dialog will by default be modeless, unless you set 'modal' to
+// true to construct a modal dialog.
+//=================================================================================
+MeasureGUI_GetNonBlocksDlg::MeasureGUI_GetNonBlocksDlg (GeometryGUI* theGeometryGUI, QWidget* parent)
+ : GEOMBase_Skeleton(theGeometryGUI, parent, false)
+{
+ QPixmap image0 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_GETNONBLOCKS")));
+ QPixmap image1 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT")));
+
+ setWindowTitle(tr("GEOM_GETNONBLOCKS_TITLE"));
+
+ /***************************************************************/
+ mainFrame()->GroupConstructors->setTitle(tr("GEOM_GETNONBLOCKS"));
+ mainFrame()->RadioButton1->setIcon(image0);
+ mainFrame()->RadioButton2->setAttribute(Qt::WA_DeleteOnClose);
+ mainFrame()->RadioButton2->close();
+ mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
+ mainFrame()->RadioButton3->close();
+
+ myGrp = new DlgRef_1Sel (centralWidget());
+ myGrp->GroupBox1->setTitle(tr("GEOM_GETNONBLOCKS"));
+ myGrp->TextLabel1->setText(tr("GEOM_OBJECT"));
+ myGrp->PushButton1->setIcon(image1);
+ myGrp->LineEdit1->setReadOnly(true);
+
+ QVBoxLayout* layout = new QVBoxLayout(centralWidget());
+ layout->setMargin(0); layout->setSpacing(6);
+ layout->addWidget(myGrp);
+
+ /***************************************************************/
+
+ myHelpFileName = "get_non_blocks_page.html";
+
+ /* Initialisation */
+ Init();
+}
+
+//=================================================================================
+// function : ~MeasureGUI_GetNonBlocksDlg()
+// purpose : Destroys the object and frees any allocated resources
+//=================================================================================
+MeasureGUI_GetNonBlocksDlg::~MeasureGUI_GetNonBlocksDlg()
+{
+}
+
+//=================================================================================
+// function : Init()
+// purpose :
+//=================================================================================
+void MeasureGUI_GetNonBlocksDlg::Init()
+{
+ showOnlyPreviewControl();
+
+ /* init variables */
+ myEditCurrentArgument = myGrp->LineEdit1;
+
+ /* signals and slots connections */
+ connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
+ connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
+
+ connect(myGrp->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
+ connect(myGrp->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
+
+ connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
+ SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
+
+ //initName(tr("GEOM_NONBLOCKS"));
+ mainFrame()->ResultName->setText(tr("GEOM_NONBLOCKS"));
+ globalSelection();
+ SelectionIntoArgument();
+}
+
+//=================================================================================
+// function : ClickOnOk()
+// purpose :
+//=================================================================================
+void MeasureGUI_GetNonBlocksDlg::ClickOnOk()
+{
+ if (ClickOnApply())
+ ClickOnCancel();
+}
+
+//=================================================================================
+// function : ClickOnApply()
+// purpose :
+//=================================================================================
+bool MeasureGUI_GetNonBlocksDlg::ClickOnApply()
+{
+ if (!onAccept())
+ return false;
+
+ //initName();
+ return true;
+}
+
+//=================================================================================
+// function : SelectionIntoArgument()
+// purpose : Called when selection as changed or other case
+//=================================================================================
+void MeasureGUI_GetNonBlocksDlg::SelectionIntoArgument()
+{
+ erasePreview();
+ myObj = GEOM::GEOM_Object::_nil();
+
+ LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
+ SALOME_ListIO aSelList;
+ aSelMgr->selectedObjects(aSelList);
+
+ if (aSelList.Extent() != 1) {
+ processObject();
+ return;
+ }
+
+ GEOM::GEOM_Object_var aSelectedObject =
+ GEOMBase::ConvertIOinGEOMObject(aSelList.First());
+
+ if (aSelectedObject->_is_nil()) {
+ processObject();
+ return;
+ }
+
+ myObj = aSelectedObject;
+ processObject();
+}
+
+//=================================================================================
+// function : SetEditCurrentArgument()
+// purpose :
+//=================================================================================
+void MeasureGUI_GetNonBlocksDlg::SetEditCurrentArgument()
+{
+ myGrp->LineEdit1->setFocus();
+ myEditCurrentArgument = myGrp->LineEdit1;
+ SelectionIntoArgument();
+}
+
+//=================================================================================
+// function : LineEditReturnPressed()
+// purpose :
+//=================================================================================
+void MeasureGUI_GetNonBlocksDlg::LineEditReturnPressed()
+{
+ QLineEdit* send = (QLineEdit*)sender();
+ if (send == myGrp->LineEdit1) {
+ myEditCurrentArgument = myGrp->LineEdit1;
+ GEOMBase_Skeleton::LineEditReturnPressed();
+ }
+}
+
+//=================================================================================
+// function : ActivateThisDialog()
+// purpose :
+//=================================================================================
+void MeasureGUI_GetNonBlocksDlg::ActivateThisDialog()
+{
+ GEOMBase_Skeleton::ActivateThisDialog();
+
+ connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
+ SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
+
+ globalSelection();
+ processPreview();
+}
+
+//=================================================================================
+// function : processObject()
+// purpose : Fill dialog fields in accordance with myObj
+//=================================================================================
+void MeasureGUI_GetNonBlocksDlg::processObject()
+{
+ if (myObj->_is_nil()) {
+ erasePreview();
+ }
+ else {
+ myGrp->LineEdit1->setText(GEOMBase::GetName(myObj));
+
+ processPreview();
+ }
+}
+
+//=================================================================================
+// function : enterEvent()
+// purpose :
+//=================================================================================
+void MeasureGUI_GetNonBlocksDlg::enterEvent (QEvent*)
+{
+ if (!mainFrame()->GroupConstructors->isEnabled())
+ ActivateThisDialog();
+}
+
+//=================================================================================
+// function : createOperation
+// purpose :
+//=================================================================================
+GEOM::GEOM_IOperations_ptr MeasureGUI_GetNonBlocksDlg::createOperation()
+{
+ return getGeomEngine()->GetIBlocksOperations(getStudyId());
+}
+
+//=================================================================================
+// function : isValid
+// purpose :
+//=================================================================================
+bool MeasureGUI_GetNonBlocksDlg::isValid (QString&)
+{
+ return !myObj->_is_nil();
+}
+
+//=================================================================================
+// function : execute
+// purpose :
+//=================================================================================
+bool MeasureGUI_GetNonBlocksDlg::execute (ObjectList& objects)
+{
+ GEOM::GEOM_IBlocksOperations_var anOper = GEOM::GEOM_IBlocksOperations::_narrow(getOperation());
+ GEOM::GEOM_Object_var aNonQuads;
+ GEOM::GEOM_Object_var anObj = anOper->GetNonBlocks(myObj, aNonQuads);
+ //mainFrame()->ResultName->setText(tr("GEOM_NONBLOCKS"));
+
+ if (!anObj->_is_nil())
+ objects.push_back(anObj._retn());
+ if (!aNonQuads->_is_nil())
+ objects.push_back(aNonQuads._retn());
+
+ return true;
+}
+
+//================================================================
+// Function : getFather
+// Purpose : Get father object for object to be added in study
+// ( called with addInStudy method )
+//================================================================
+GEOM::GEOM_Object_ptr MeasureGUI_GetNonBlocksDlg::getFather (GEOM::GEOM_Object_ptr)
+{
+ return myObj;
+}
--- /dev/null
+// 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 : MeasureGUI_GetNonBlocksDlg.h
+
+#ifndef MEASUREGUI_GETNONBLOCKSDLG_H
+#define MEASUREGUI_GETNONBLOCKSDLG_H
+
+#include <GEOMBase_Skeleton.h>
+
+class DlgRef_1Sel;
+
+//=================================================================================
+// class : MeasureGUI_GetNonBlocksDlg
+// purpose :
+//=================================================================================
+class MeasureGUI_GetNonBlocksDlg : public GEOMBase_Skeleton
+{
+ Q_OBJECT
+
+public:
+ MeasureGUI_GetNonBlocksDlg (GeometryGUI*, QWidget*);
+ ~MeasureGUI_GetNonBlocksDlg();
+
+protected:
+ // redefined from GEOMBase_Helper
+ virtual GEOM::GEOM_IOperations_ptr createOperation();
+ virtual bool isValid (QString&);
+ virtual bool execute (ObjectList&);
+ virtual GEOM::GEOM_Object_ptr getFather (GEOM::GEOM_Object_ptr);
+
+private slots:
+ void ClickOnOk();
+ bool ClickOnApply();
+ void ActivateThisDialog();
+ void LineEditReturnPressed();
+ void SelectionIntoArgument();
+ void SetEditCurrentArgument();
+
+private:
+ void Init();
+ void enterEvent (QEvent*);
+ void processObject();
+
+private:
+ GEOM::GEOM_Object_var myObj;
+ DlgRef_1Sel* myGrp;
+};
+
+#endif // MEASUREGUI_GETNONBLOCKSDLG_H
Standard_Boolean GEOM_AISShape::toActivate() {
return Standard_True;
-}
\ No newline at end of file
+}
void GEOM_TopWireframeShape::setIO(const Handle(SALOME_InteractiveObject)& io){
SetOwner( io );
-}
\ No newline at end of file
+}
// other inline functions and methods (like "C++: function call" methods)
//
-#endif
\ No newline at end of file
+#endif
#include <TopoDS_Iterator.hxx>
#include <TopoDS_Shape.hxx>
+// VSR 22/08/2012: issue 0021787: remove "Preview" button from BOP and Partition operations
+// Comment next line to enable preview in Partition dialog box
+#define NO_PREVIEW
+
//=================================================================================
// class : OperationGUI_PartitionDlg()
// purpose : Constructs a OperationGUI_PartitionDlg which is a child of 'parent', with the
setHelpFileName( "partition_page.html" );
+#ifdef NO_PREVIEW
+ mainFrame()->CheckBoxPreview->setChecked( false );
+ mainFrame()->CheckBoxPreview->hide();
+#endif
Init();
}
// 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: STEPImport.cxx
// Created: Wed May 19 14:41:10 2004
#include <Basics_Utils.hxx>
#include <Basics_OCCTVersion.hxx>
-#include <BRep_Builder.hxx>
+#include <TDF_ChildIDIterator.hxx>
+#include <TDF_Label.hxx>
+#include <TDataStd_Name.hxx>
+#include <TNaming_Builder.hxx>
+#include <TNaming_NamedShape.hxx>
+
#include <IFSelect_ReturnStatus.hxx>
#include <Interface_InterfaceModel.hxx>
#include <Interface_Static.hxx>
#include <StepBasic_ProductDefinitionFormation.hxx>
#include <StepGeom_GeometricRepresentationItem.hxx>
#include <StepShape_TopologicalRepresentationItem.hxx>
-#include <TCollection_AsciiString.hxx>
-#include <TDF_ChildIDIterator.hxx>
-#include <TDF_Label.hxx>
-#include <TDataStd_Name.hxx>
-#include <TNaming_Builder.hxx>
-#include <TNaming_NamedShape.hxx>
+#include <TransferBRep.hxx>
+#include <Transfer_Binder.hxx>
+#include <Transfer_TransientProcess.hxx>
+#include <XSControl_TransferReader.hxx>
+#include <XSControl_WorkSession.hxx>
+
+#include <BRep_Builder.hxx>
+
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopoDS_Compound.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopoDS_Shape.hxx>
-#include <TransferBRep.hxx>
-#include <Transfer_Binder.hxx>
-#include <Transfer_TransientProcess.hxx>
-#include <XSControl_TransferReader.hxx>
-#include <XSControl_WorkSession.hxx>
+
+#include <TCollection_AsciiString.hxx>
+#include <TColStd_SequenceOfAsciiString.hxx>
#include <Standard_Failure.hxx>
#include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
extern "C"
{
+ STEPIMPORT_EXPORT
+ Handle(TCollection_HAsciiString) GetValue (const TCollection_AsciiString& theFileName,
+ const TCollection_AsciiString& theParameterName,
+ TCollection_AsciiString& theError)
+ {
+ Handle(TCollection_HAsciiString) aValue;
+
+ if (theParameterName != "LEN_UNITS") {
+ theError = theParameterName + " parameter reading is not supported by STEP plugin";
+ return aValue;
+ }
+
+ // Set "C" numeric locale to save numbers correctly
+ Kernel_Utils::Localizer loc;
+
+ STEPControl_Reader aReader;
+
+ Interface_Static::SetCVal("xstep.cascade.unit","M");
+ Interface_Static::SetIVal("read.step.ideas", 1);
+ Interface_Static::SetIVal("read.step.nonmanifold", 1);
+
+ try {
+#if OCC_VERSION_LARGE > 0x06010000
+ OCC_CATCH_SIGNALS;
+#endif
+ IFSelect_ReturnStatus status = aReader.ReadFile(theFileName.ToCString());
+ if (status == IFSelect_RetDone) {
+ TColStd_SequenceOfAsciiString anUnitLengthNames;
+ TColStd_SequenceOfAsciiString anUnitAngleNames;
+ TColStd_SequenceOfAsciiString anUnitSolidAngleNames;
+ aReader.FileUnits(anUnitLengthNames, anUnitAngleNames, anUnitSolidAngleNames);
+ if (anUnitLengthNames.Length() > 0) {
+ TCollection_AsciiString aLenUnits = anUnitLengthNames.First();
+ if (aLenUnits == "millimetre")
+ aValue = new TCollection_HAsciiString ("UNIT_MM");
+ else if (aLenUnits == "centimetre")
+ aValue = new TCollection_HAsciiString ("UNIT_CM");
+ else if (aLenUnits == "metre")
+ aValue = new TCollection_HAsciiString ("UNIT_M");
+ else if (aLenUnits == "INCH")
+ aValue = new TCollection_HAsciiString ("UNIT_INCH");
+ // TODO
+ //else if (aLenUnits == "")
+ // aValue = new TCollection_HAsciiString ("");
+
+ // tmp begin
+ //std::cout << "$$$ --- " << anUnitLengthNames.First();
+ //for (int ii = 2; ii <= anUnitLengthNames.Length(); ii++)
+ // std::cout << ", " << anUnitLengthNames.Value(ii);
+ //std::cout << std::endl;
+ // tmp end
+ }
+ }
+ else {
+ theError = theFileName + " reading failed";
+ }
+ }
+ catch (Standard_Failure) {
+ Handle(Standard_Failure) aFail = Standard_Failure::Caught();
+ theError = aFail->GetMessageString();
+ }
+
+ return aValue;
+ }
+
STEPIMPORT_EXPORT
TopoDS_Shape Import (const TCollection_AsciiString& theFileName,
- const TCollection_AsciiString& /*theFormatName*/,
+ const TCollection_AsciiString& theFormatName,
TCollection_AsciiString& theError,
const TDF_Label& theShapeLabel)
{
- MESSAGE("Import STEP model from file " << theFileName.ToCString());
+ TopoDS_Shape aResShape;
+
// Set "C" numeric locale to save numbers correctly
Kernel_Utils::Localizer loc;
- TopoDS_Shape aResShape;
- //VRV: OCC 4.0 migration
+
STEPControl_Reader aReader;
+
//VSR: 16/09/09: Convert to METERS
Interface_Static::SetCVal("xstep.cascade.unit","M");
Interface_Static::SetIVal("read.step.ideas", 1);
Interface_Static::SetIVal("read.step.nonmanifold", 1);
- //VRV: OCC 4.0 migration
- TopoDS_Compound compound;
+
BRep_Builder B;
+ TopoDS_Compound compound;
B.MakeCompound(compound);
+
try {
-#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
-#endif
+
IFSelect_ReturnStatus status = aReader.ReadFile(theFileName.ToCString());
if (status == IFSelect_RetDone) {
+
+ // Regard or not the model units
+ if (theFormatName == "STEP_SCALE") {
+ // set UnitFlag to units from file
+ TColStd_SequenceOfAsciiString anUnitLengthNames;
+ TColStd_SequenceOfAsciiString anUnitAngleNames;
+ TColStd_SequenceOfAsciiString anUnitSolidAngleNames;
+ aReader.FileUnits(anUnitLengthNames, anUnitAngleNames, anUnitSolidAngleNames);
+ if (anUnitLengthNames.Length() > 0) {
+ TCollection_AsciiString aLenUnits = anUnitLengthNames.First();
+ if (aLenUnits == "millimetre")
+ Interface_Static::SetCVal("xstep.cascade.unit", "MM");
+ else if (aLenUnits == "centimetre")
+ Interface_Static::SetCVal("xstep.cascade.unit", "CM");
+ else if (aLenUnits == "metre")
+ Interface_Static::SetCVal("xstep.cascade.unit", "M");
+ else if (aLenUnits == "INCH")
+ Interface_Static::SetCVal("xstep.cascade.unit", "INCH");
+ else {
+ theError = "The file contains not supported units.";
+ return aResShape;
+ }
+ // TODO
+ //else if (aLenUnits == "")
+ // Interface_Static::SetCVal("xstep.cascade.unit", "");
+ }
+ }
+ else {
+ //cout<<"need re-scale a model"<<endl;
+ // set UnitFlag to 'meter'
+ Interface_Static::SetCVal("xstep.cascade.unit","M");
+ }
+
Standard_Boolean failsonly = Standard_False;
aReader.PrintCheckLoad(failsonly, IFSelect_ItemsByEntity);
+
/* Root transfers */
Standard_Integer nbr = aReader.NbRootsForTransfer();
aReader.PrintCheckTransfer(failsonly, IFSelect_ItemsByEntity);