<ul>
<li>\ref arithmetic_1d_anchor "Arithmetic 1D"</li>
<li>\ref average_length_anchor "Average Length"</li>
+<li>\ref max_length_anchor "Max Size"</li>
<li>\ref deflection_1d_anchor "Deflection 1D"</li>
<li>\ref number_of_segments_anchor "Number of segments"</li>
<li>\ref start_and_end_length_anchor "Start and end length"</li>
\ref tui_average_length "Defining Average Length" hypothesis
operation.
+<br>\anchor max_length_anchor
+<h2>Max Size</h2>
+<b>Max Size</b> hypothesis allows splitting geometrical edges into
+segments not longer than the given length. Definition of this hypothesis
+consists of setting the maximal allowed \b length of segments.
+<b>Use preestimated length</b> check box lets you specify \b length
+automatically calculated basing on size of your geometrical object,
+namely as diagonal of bounding box divided by ten. The divider can be
+changed via "Segmentation of diagonal of boundary box of geometry"
+preference parameter.
+<b>Use preestimated length</b> check box is enabled only if the
+geometrical object has been selected before hypothesis definition.
+
+\image html a-maxsize1d.png
+
<br>
\anchor number_of_segments_anchor
<h2>Number of segments hypothesis</h2>
<ul>
<li>\ref arithmetic_1d_anchor "Arithmetic 1D"</li>
<li>\ref average_length_anchor "Average Length"</li>
+<li>\ref max_length_anchor "Max Size"</li>
<li>\ref deflection_1d_anchor "Deflection 1D"</li>
<li>\ref number_of_segments_anchor "Number of segments"</li>
<li>\ref start_and_end_length_anchor "Start and end length"</li>
help of a scalar bar, which is displayed near the presentation of your
mesh.
-There are 1D, 2D and 3D quality controls.
+There are 0D, 1D, 2D and 3D quality controls.
+
+0D mesh quality controls:
+<ul>
+<li>\ref free_nodes_page "Free nodes"</li>
+</ul>
1D mesh quality controls:
<ul>
<ul>
<li>\subpage aspect_ratio_3d_page "Aspect ratio 3D"</li>
<li>\subpage volume_page "Volume"</li>
+<li>\subpage free_faces_page "Free faces"</li>
</ul>
-*/
\ No newline at end of file
+*/
\ref tui_create_group_on_geometry "Create a Group on Geometry"
operation.
+<br><h2>Creation of groups using existing groups and sub-meshes.</h2>
+
+Application provides possibility to create new <b>standalone</b> groups using existing standalone groups, groups on geometry and sub-meshes. This functionality is implemented using "Select from" group box of "Create group" dialog box described above.
+
+This functionality is described on the example of creating new group from existing standalone groups and groups on geometry.
+
+Imagine there are group G1. It can be standalone group or group on geometry.
+
+To create group G2 containing all entities of group G1 and a faces graphically selected in 3D view following steps can be performed:
+<ul>
+<li>User opens "Create group" dialog box.</li>
+<li>The user specifies "Face" type of entities and "G2" name of group.</li>
+<li>The user checks "Group" check-box of "Select From" group box.</li>
+<li>The user selects G1 group in object browser or 3D view.</li>
+<li>The user presses "Add" push button of "Content" group box. "Id Elements" list-box is filled with identifiers of faces belonging to group G1.</li>
+<li>The user selects other faces in 3D view.</li>
+<li>The user presses "Apply" button. System creates group G2.</li>
+</ul>
+
+Please note that group G2 does not have a references to source group G1. It contains list of faces identifiers only. So if G1 group will be changed group G2 will remain unmodified.
+
+<br>
+\anchor gui_create_dim_group
+<h2>Creating groups of entities from existing groups of superior dimensions</h2>
+
+Application provides possibility for creating groups of entities from existing groups of superior dimensions. For example, it is possible to create group of nodes using list of existing groups of faces.
+
+To create groups of entities from existing groups of superior dimensions, in the \b Mesh menu select <b>Group of underlying entities</b>.<br>
+
+The following dialog box will appear:
+
+\image html dimgroup_dlg.png
+
+In this dialog box you should specify the name of the resulting group, types of entities and set of source groups.
+
+For example, we have two source Volume groups illustrated on the figure below
+
+\image html dimgroup_src.png
+<center>Source groups</center>
+
+In this case we obtain following results for Faces, Edges and Nodes.
+
+\image html dimgroup_2d.png
+<center>Faces</center>
+
+\image html dimgroup_1d.png
+<center>Edges</center>
+
+\image html dimgroup_0d.png
+<center>Nodes</center>
+
+<b>See Also</b> a sample TUI Script of a
+\ref tui_create_dim_group "Creating groups of entities from existing groups of superior dimensions"
+operation.
*/
\ No newline at end of file
group.</li>
</ol>
+\n <em>To convert an existing group on geometry into standalone group
+of elements and modify:</em>
+<ol>
+<li>Select your group on geometry in the Object Browser and in the \b Mesh menu click
+the <b>Edit Group as Standalone</b> item.</li>
+
+\image html image74.gif
+<center><em>"Edit Group as Standalone" button</em></center>
+
+The group on geometry will be converted into standalone group and can
+be modified as group of elements
+<li>Click the \b Apply or <b>Apply and Close</b> button to confirm modification of the
+group.</li>
+
<br><b>See Also</b> a sample TUI Script of an
\ref tui_edit_group "Edit Group" operation.
-*/
\ No newline at end of file
+*/
<li>specify the IDs of the elements which will be extruded by
selecting them in the 3D viewer or select the whole mesh or
submesh,</li>
+<li>specify the distance at which the elements will be extruded,</li>
<li>specify the vector along which the elements will be extruded,</li>
<li>number of steps.</li>
</ul>
--- /dev/null
+/*!
+
+\page free_faces_page Free faces
+
+\n This mesh quality control highlights faces which are connected
+less than to two mesh volume elements. Free faces are shown with a color differs from
+the color of shared faces.
+
+\image html free_faces.png
+<center>In this picture some volume mesh element are removed as
+a result some faces become connected only to one
+volume. i.e. become free.
+
+<br><b>See Also</b> a sample TUI Script of a
+\ref tui_free_faces "Free Faces quality control" operation.
+
+*/
--- /dev/null
+/*!
+
+\page free_nodes_page Free nodes
+
+\n This mesh quality control highlights nodes which are not connected
+to any mesh element. Free nodes are shown with a color differs from
+the color of nodes.
+
+\image html free_nodes.png
+<center>In this picture some nodes don't connected to a mesh element as
+a result of deleting elements and adding several isolated nodes.
+
+<br><b>See Also</b> a sample TUI Script of a
+\ref tui_free_nodes "Free Nodes quality control" operation.
+
+*/
\image html image7.jpg "Example of MESH module usage for engineering tasks"
-*/
\ No newline at end of file
+*/
--- /dev/null
+/*!
+
+\page preview_meshes_page Preview and Compute meshes
+
+Before whole mesh computation it is allowed to see the mesh preview.
+When mesh object is already created and all hypotheses assigned,
+select your mesh in the <b>Object Browser</b>. From the
+\b Mesh menu select \b Preview or click "Preview" button of the
+toolbar or activate "Preview" item from pop-up menu.
+
+\image html mesh_precompute.png
+<center><em>"Preview" button</em></center>
+
+The Mesh Preview dialog box appears. In this dialog box you can select
+preview mode <b>1D mesh</b> or <b>2D mesh</b> depending on assigned
+hypotheses to mesh.
+
+The 1D mesh preview shows as nodes computed on geometry edges
+
+\image html preview_mesh_1D.png
+
+The 2D mesh preview shows edge mesh elements, computed on geometry faces
+
+\image html preview_mesh_2D.png
+
+Pressing <b>Compute</b> button leads to whole mesh computation
+process.
+During exit from Preview dialog box, the question about storage temporary
+created mesh elements appers:
+
+\image html preview_tmp_data.png
+
+Note, that computed temporary mesh elements can be reused during next
+mesh computation process.
+
+*/
\image html editing_groups2.png
<br>
-\anchor tui_union_of_two_groups
-<h2>Union of two groups</h2>
+\anchor tui_union_of_groups
+<h2>Union of groups</h2>
\code
import SMESH_mechanic
print "Criterion: Area > 20, Nb = ", len( anIds )
# create a group by adding elements with area > 20
-aGroup1 = mesh.CreateEmptyGroup(SMESH.FACE, "Area > 20")
+aGroup1 = mesh.CreateEmptyGroup(smesh.FACE, "Area > 20")
aGroup1.Add(anIds)
# Criterion : AREA = 20
aGroup2.Add(anIds)
# create union group : area >= 20
-aGroup3 = mesh.UnionGroups(aGroup1, aGroup2, "Area >= 20")
+aGroup3 = mesh.UnionListOfGroups([aGroup1, aGroup2], "Area >= 20")
print "Criterion: Area >= 20, Nb = ", len(aGroup3.GetListOfID())
+# Please note that also there is UnionGroups() method which works with two groups only
# Criterion : AREA < 20
aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_LessThan, 20.)
aGroup4.Add(anIds)
# create union group : area >= 20 and area < 20
-aGroup5 = mesh.UnionGroups(aGroup3, aGroup4, "Any Area")
+aGroup5 = mesh.UnionListOfGroups([aGroup3, aGroup4], "Any Area")
print "Criterion: Any Area, Nb = ", len(aGroup5.GetListOfID())
salome.sg.updateObjBrowser(1)
\image html union_groups3.png
<br>
-\anchor tui_intersection_of_two_groups
-<h2>Intersection of two groups</h2>
+\anchor tui_intersection_of_groups
+<h2>Intersection of groups</h2>
\code
import SMESH_mechanic
print "Criterion: Area > 20, Nb = ", len(anIds)
# create a group by adding elements with area > 20
-aGroup1 = mesh.CreateEmptyGroup(SMESH.FACE, "Area > 20")
+aGroup1 = mesh.CreateEmptyGroup(smesh.FACE, "Area > 20")
aGroup1.Add(anIds)
# Criterion : AREA < 60
print "Criterion: Area < 60, Nb = ", len(anIds)
# create a group by adding elements with area < 60
-aGroup2 = mesh.CreateEmptyGroup(SMESH.FACE, "Area < 60")
+aGroup2 = mesh.CreateEmptyGroup(smesh.FACE, "Area < 60")
aGroup2.Add(anIds)
# create an intersection of groups : 20 < area < 60
-aGroup3 = mesh.IntersectGroups(aGroup1, aGroup2, "20 < Area < 60")
+aGroup3 = mesh.IntersectListOfGroups([aGroup1, aGroup2], "20 < Area < 60")
print "Criterion: 20 < Area < 60, Nb = ", len(aGroup3.GetListOfID())
+# Please note that also there is IntersectGroups() method which works with two groups only
salome.sg.updateObjBrowser(1)
\endcode
\image html intersect_groups3.png
<br>
-\anchor tui_cut_of_two_groups
-<h2>Cut of two groups</h2>
+\anchor tui_cut_of_groups
+<h2>Cut of groups</h2>
\code
import SMESH_mechanic
# create a cut of groups : area >= 60
aGroupRes = mesh.CutGroups(aGroupMain, aGroupTool, "Area >= 60")
print "Criterion: Area >= 60, Nb = ", len(aGroupRes.GetListOfID())
+# Please note that also there is CutListOfGroups() method which works with lists of groups of any lengths
salome.sg.updateObjBrowser(1)
\endcode
\image html cut_groups3.png
+<br>
+\anchor tui_create_dim_group
+<h2>Creating groups of entities from existing groups of superior dimensions</h2>
+
+\code
+import SMESH_mechanic
+
+smesh = SMESH_mechanic.smesh
+mesh = SMESH_mechanic.mesh
+salome = SMESH_mechanic.salome
+
+# Criterion : AREA > 100
+aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 100.)
+
+anIds = mesh.GetIdsFromFilter(aFilter)
+
+print "Criterion: Area > 100, Nb = ", len(anIds)
+
+# create a group by adding elements with area > 100
+aSrcGroup1 = mesh.MakeGroupByIds("Area > 100", smesh.FACE, anIds)
+
+# Criterion : AREA < 30
+aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_LessThan, 30.)
+
+anIds = mesh.GetIdsFromFilter(aFilter)
+
+print "Criterion: Area < 30, Nb = ", len(anIds)
+
+# create a group by adding elements with area < 30
+aSrcGroup2 = mesh.MakeGroupByIds("Area < 30", smesh.FACE, anIds)
+
+# Create group of edges using source groups of faces
+aGrp = mesh.CreateDimGroup( [aSrcGroup1, aSrcGroup2], smesh.EDGE, "Edges" )
+
+# Create group of nodes using source groups of faces
+aGrp = mesh.CreateDimGroup( [aSrcGroup1, aSrcGroup2], smesh.NODE, "Nodes" )
+
+salome.sg.updateObjBrowser(1)
+\endcode
+
+\image html dimgroup_tui1.png
+<center>Source groups of faces<\center>
+
+\image html dimgroup_tui2.png
+<center>Result groups of edges and nodes<\center>
+
+
+
+
+
*/
\ No newline at end of file
salome.sg.updateObjBrowser(1)
\endcode
+<br>
+\anchor tui_free_nodes
+<h2>Free Nodes</h2>
+
+\code
+import salome
+import geompy
+
+import smesh
+
+# create box
+box = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
+idbox = geompy.addToStudy(box, "box")
+
+# create a mesh
+mesh = smesh.Mesh(box, "Mesh_free_nodes")
+algo = mesh.Segment()
+algo.NumberOfSegments(10)
+algo = mesh.Triangle(smesh.MEFISTO)
+algo.MaxElementArea(150.)
+mesh.Compute()
+
+# Remove some elements to obtain free nodes
+# Criterion : AREA < 80.
+area_margin = 80.
+
+aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_LessThan, area_margin)
+
+anIds = mesh.GetIdsFromFilter(aFilter)
+
+mesh.RemoveElements(anIds)
+
+# criterion : free nodes
+aFilter = smesh.GetFilter(smesh.NODE, smesh.FT_FreeNodes)
+anNodeIds = mesh.GetIdsFromFilter(aFilter)
+
+# create a group
+aGroup = mesh.CreateEmptyGroup(smesh.NODE, "Free_nodes")
+aGroup.Add(anNodeIds)
+
+# print the result
+print "Criterion: Free nodes Nb = ", len(anNodeIds)
+j = 1
+for i in range(len(anNodeIds)):
+ if j > 20: j = 1; print ""
+ print anNodeIds[i],
+ j = j + 1
+ pass
+print ""
+
+salome.sg.updateObjBrowser(1)
+\endcode
+
+
+<br>
+\anchor tui_free_faces
+<h2>Free Faces</h2>
+
+\code
+import salome
+import geompy
+
+####### GEOM part ########
+
+Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200)
+Box_1_vertex_6 = geompy.GetSubShape(Box_1, [6])
+Box_1 = geompy.GetMainShape(Box_1_vertex_6)
+Box_1_vertex_16 = geompy.GetSubShape(Box_1, [16])
+Box_1 = geompy.GetMainShape(Box_1_vertex_16)
+Box_1_vertex_11 = geompy.GetSubShape(Box_1, [11])
+Box_1 = geompy.GetMainShape(Box_1_vertex_11)
+Plane_1 = geompy.MakePlaneThreePnt(Box_1_vertex_6, Box_1_vertex_16, Box_1_vertex_11, 2000)
+Partition_1 = geompy.MakePartition([Box_1], [Plane_1], [], [], geompy.ShapeType["SOLID"], 0, [], 0)
+
+Box_1_vertex_19 = geompy.GetSubShape(Box_1, [19])
+Box_1_vertex_21 = geompy.GetSubShape(Box_1, [21])
+Plane_2 = geompy.MakePlaneThreePnt(Box_1_vertex_16, Box_1_vertex_19, Box_1_vertex_21, 2000)
+
+geompy.addToStudy( Box_1, "Box_1" )
+geompy.addToStudyInFather( Box_1, Box_1_vertex_6, "Box_1:vertex_6" )
+geompy.addToStudyInFather( Box_1, Box_1_vertex_16, "Box_1:vertex_16" )
+geompy.addToStudyInFather( Box_1, Box_1_vertex_11, "Box_1:vertex_11" )
+geompy.addToStudy( Plane_1, "Plane_1" )
+geompy.addToStudy( Partition_1, "Partition_1" )
+geompy.addToStudyInFather( Box_1, Box_1_vertex_19, "Box_1:vertex_19" )
+geompy.addToStudyInFather( Box_1, Box_1_vertex_21, "Box_1:vertex_21" )
+geompy.addToStudy( Plane_2, "Plane_2" )
+
+###### SMESH part ######
+import smesh
+
+import StdMeshers
+import NETGENPlugin
+
+Mesh_1 = smesh.Mesh(Partition_1)
+Regular_1D = Mesh_1.Segment()
+Max_Size_1 = Regular_1D.MaxSize(34.641)
+MEFISTO_2D = Mesh_1.Triangle()
+Tetrahedron_Netgen = Mesh_1.Tetrahedron(algo=smesh.NETGEN)
+isDone = Mesh_1.Compute()
+
+# create a group of free faces
+aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_FreeFaces )
+aFaceIds = Mesh_1.GetIdsFromFilter(aFilter)
+
+aGroup = Mesh_1.CreateEmptyGroup(smesh.FACE, "Free_faces")
+aGroup.Add(aFaceIds)
+
+# print the result
+print "Criterion: Free nodes Nb = ", len(anNodeIds)
+j = 1
+for i in range(len(aFaceIds)):
+ if j > 20: j = 1; print ""
+ print anNodeIds[i],
+ j = j + 1
+ pass
+print ""
+
+#filter faces from plane 2
+aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_BelongToPlane, Plane_2)
+aFaceIds = Mesh_1.GetIdsFromFilter(aFilter)
+aGroup.Remove(aFaceIds)
+
+# create a group of shared faces (located on partition boundary inside box)
+aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_BelongToPlane, Plane_1)
+aFaceIds = Mesh_1.GetIdsFromFilter(aFilter)
+
+aGroup = Mesh_1.CreateEmptyGroup(smesh.FACE, "Shared_faces")
+aGroup.Add(aFaceIds)
+
+salome.sg.updateObjBrowser(1)
+\endcode
+
+
<br>
\anchor tui_length_2d
<h2>Length 2D</h2>
salome.sg.updateObjBrowser(1)
\endcode
-*/
\ No newline at end of file
+*/
<br>
\anchor union_anchor
-<h2>Union of two groups</h2>
+<h2>Union of groups</h2>
This operation allows to create a new group in such a way that all
mesh elements that are present in the initial groups will be added to
the new one.
-<em>To union two groups:</em>
+<em>To union groups:</em>
<ol>
<li>In the \b Mesh menu select the <b>Union Groups</b> item. The following
dialog box will appear:
\image html uniongroups.png
In this dialog box you should specify the name of the resulting group
-and two groups which will be united.
+and set of groups which will be united.
For example, we have two groups Group1 and Group2.
\n The result of their \b Union will be Group12:
</ol>
<b>See Also</b> a sample TUI Script of a
-\ref tui_union_of_two_groups "Union of two Groups" operation.
+\ref tui_union_of_groups "Union of Groups" operation.
<br>
\anchor intersection_anchor
-<h2>Intersection of two groups</h2>
+<h2>Intersection of groups</h2>
This operation allows to create a new group in such a way that all
-mesh elements that are present in both initial groups are added to the
+mesh elements that are present in all initial groups together are added to the
new one.
-<em>To intersect two groups:</em>
+<em>To intersect groups:</em>
<ol>
<li>In the \b Mesh menu select the <b>Intersect Groups</b> item. The
following dialog box will appear:
\image html intersectgroups.png
In this dialog box you should specify the name of the resulting group
-and two groups which will be intersected.
+and set of groups which will be intersected.
For example, we have two groups Group1 and Group2.
\n The result of their \b Intersection will be Group12a:
</ol>
<b>See Also</b> a sample TUI Script of an
-\ref tui_intersection_of_two_groups "Intersection of two Groups" operation.
+\ref tui_intersection_of_groups "Intersection of Groups" operation.
<br>
\anchor cut_anchor
-<h2>Cut of two groups</h2>
+<h2>Cut of groups</h2>
This operation allows to create a new group in such a way that all
-mesh elements that are present in the main group but are absent in the
-tool group are added to the new one.
+mesh elements that are present in the main groups but are absent in the
+tool groups are added to the new one.
-<em>To cut two groups:</em>
+<em>To cut groups:</em>
<ol>
<li>In the \b Mesh menu select the <b>Cut Groups</b> item. The
following dialog box will appear:
\image html cutgroups.png
In this dialog box you should specify the name of the resulting group
-and two groups which will be cut.
+and groups which will be cut.
For example, we have two groups Group1 and Group2.
\n The result of their \b Cut will be Group12b:
</ol>
<b>See Also</b> a sample TUI Script of a
-\ref tui_cut_of_two_groups "Cut of two Groups" operation.
+\ref tui_cut_of_groups "Cut of Groups" operation.
*/
\ No newline at end of file
libSalomeIDLSMESH_la_LIBADD = \
@CORBA_LIBS@ \
$(MED_LDFLAGS) -lSalomeIDLMED \
- $(GEOM_LDFLAGS) -lSalomeIDLGEOM
+ $(GEOM_LDFLAGS) -lSalomeIDLGEOM \
+ $(KERNEL_LDFLAGS) -lSalomeIDLKernel
# These variables defines the building process of CORBA files
OMNIORB_IDL = @OMNIORB_IDL@
double GetPrecision();
};
+ /*!
+ * StdMeshers_MaxLength: interface of "Max length" hypothesis
+ */
+ interface StdMeshers_MaxLength : SMESH::SMESH_Hypothesis
+ {
+ /*!
+ * Sets <length> parameter value
+ */
+ void SetLength(in double length)
+ raises (SALOME::SALOME_Exception);
+ /*!
+ * Returns <length> parameter value
+ */
+ double GetLength();
+ /*!
+ * Returns true if preestemated length is defined
+ */
+ boolean HavePreestimatedLength();
+ /*!
+ * Returns preestemated length
+ */
+ double GetPreestimatedLength();
+ /*!
+ * Sets preestemated length
+ */
+ void SetPreestimatedLength(in double length);
+ /*!
+ * Sets boolean parameter enabling/desabling usage of length computed
+ * basing on size of bounding box of shape to mesh
+ */
+ void SetUsePreestimatedLength(in boolean toUse);
+ /*!
+ * Returns value of boolean parameter enabling/desabling usage of length computed
+ * basing on size of bounding box of shape to mesh
+ */
+ boolean GetUsePreestimatedLength();
+ };
+
/*!
* StdMeshers_AutomaticLength: interface of "Automatic length" hypothesis
*/
FT_Volume3D,
FT_FreeBorders,
FT_FreeEdges,
+ FT_FreeNodes,
+ FT_FreeFaces,
FT_MultiConnection,
FT_MultiConnection2D,
FT_Length,
FT_LyingOnGeom,
FT_RangeOfIds,
FT_BadOrientedVolume,
+ FT_LinearOrQuadratic,
+ FT_GroupColor,
+ FT_ElemGeomType,
FT_LessThan,
FT_MoreThan,
FT_EqualTo,
typedef sequence<Value> Values;
Values GetValues();
};
-
+
/*!
* Predicates are intended for verification of criteria,
* must return bool value by mesh id
* Verify whether 2D mesh element has free edges( i.e. edges connected to one face only )
*/
interface FreeEdges: Predicate
-
{
struct Border
{
Borders GetBorders();
};
+ /*!
+ * Logical functor (predicate) "Free nodes".
+ * Verify whether mesh has free nodes( i.e. nodes are not connected to any element )
+ */
+ interface FreeNodes: Predicate{};
+
+ /*!
+ * Logical functor (predicate) "Free faces".
+ * Verify whether 2D mesh element is free ( i.e. connected to one volume only )
+ */
+ interface FreeFaces: Predicate{};
/*!
* Abstract logical functor (predicate) "RangeOfIds".
interface LogicalAND: LogicalBinary{};
interface LogicalOR : LogicalBinary{};
+ /*!
+ * Logical functor (predicate) "Is element Linear or Quadratic".
+ * Verify whether a mesh element is linear
+ */
+ interface LinearOrQuadratic: Predicate {
+ void SetElementType( in ElementType theType );
+ };
+
+ /*!
+ * Functor "Group Color"
+ * Returns color of group to which mesh element belongs to
+ */
+ interface GroupColor : Predicate{
+ void SetElementType( in ElementType theType );
+ void SetColorStr( in string theColor );
+ string GetColorStr();
+ };
+
+ /*!
+ * Functor "Element geometry type"
+ * Returns is element has indicated geometry type
+ */
+ interface ElemGeomType : Predicate{
+ void SetElementType ( in ElementType theType );
+ void SetGeometryType( in GeometryType theType );
+ };
+
/*!
* Filter
*/
* ThresholdStr - Threshold value defined as string. Used for:
* 1. Diaposon of identifiers. Example: "1,2,3,5-10,12,27-29"
* 2. BelongToGeom predicate for storing name of shape
+ * 3. GroupColor predicate for storing group color "0.2;0;0.5"
* ThresholdID - One more threshold value defined as string. Used for:
* 1. BelongToGeom predicate for storing id of shape
* Tolerance - Tolerance is used for comparators (EqualTo comparision) and for
FreeBorders CreateFreeBorders();
FreeEdges CreateFreeEdges();
+ FreeNodes CreateFreeNodes();
+ FreeFaces CreateFreeFaces();
RangeOfIds CreateRangeOfIds();
BadOrientedVolume CreateBadOrientedVolume();
+ LinearOrQuadratic CreateLinearOrQuadratic();
+
+ GroupColor CreateGroupColor();
+ ElemGeomType CreateElemGeomType();
/*!
* Create comparators ( predicates )
//
// File : SMESH_Gen.idl
// Author : Paul RASCLE, EDF
-// $Header$
-//
+
#ifndef _SMESH_GEN_IDL_
#define _SMESH_GEN_IDL_
raises ( SALOME::SALOME_Exception );
/*!
- * Return a hypothesis holding parameter values corresponding to the mesh
- * existing on the given geometry.
+ * Return a hypothesis holding parameter values corresponding either to the mesh
+ * existing on the given geometry or to size of the geometry.
* The returned hypothesis may be the one existing in a study and used
* to compute the mesh, or a temporary one created just to pass parameter
- * values
+ * values.
*/
SMESH_Hypothesis GetHypothesisParameterValues( in string theHypName,
in string theLibName,
in SMESH_Mesh theMesh,
- in GEOM::GEOM_Object theGeom)
+ in GEOM::GEOM_Object theGeom,
+ in boolean byMesh)
+ raises ( SALOME::SALOME_Exception );
+
+ /*!
+ * Sets number of segments per diagonal of boundary box of geometry by which
+ * default segment length of appropriate 1D hypotheses is defined
+ */
+ void SetBoundaryBoxSegmentation( in long theNbSegments );
+
+ /*!
+ * Set the object name
+ */
+ void SetName( in string theObjectIOR,
+ in string theObjectName )
raises ( SALOME::SALOME_Exception );
/*!
raises ( SALOME::SALOME_Exception );
/*!
- * Create a empty mesh object
+ * Create an empty mesh object
*/
SMESH_Mesh CreateEmptyMesh()
raises ( SALOME::SALOME_Exception );
in GEOM::GEOM_Object theSubObject )
raises ( SALOME::SALOME_Exception );
+ /*!
+ * Calculate Mesh as preview till indicated dimension
+ * First, verify list of hypothesis associated with the subShape.
+ * Return mesh preview structure
+ */
+ MeshPreviewStruct Precompute( in SMESH_Mesh theMesh,
+ in GEOM::GEOM_Object theSubObject,
+ in Dimension theDimension,
+ inout long_array theShapesId )
+ raises ( SALOME::SALOME_Exception );
+
/*!
* Return errors of hypotheses definintion
* algo_error_array is empty if everything is OK
//
// File : SMESH_Mesh.idl
// Author : Paul RASCLE, EDF
-// $Header$
//
+
#ifndef _SMESH_MESH_IDL_
#define _SMESH_MESH_IDL_
FACE,
VOLUME
};
+
+ /*!
+ * Enumeration for element geometry type, like in SMDS
+ */
+ enum GeometryType
+ {
+ Geom_POINT,
+ Geom_EDGE,
+ Geom_TRIANGLE,
+ Geom_QUADRANGLE,
+ Geom_POLYGON,
+ Geom_TETRA,
+ Geom_PYRAMID,
+ Geom_HEXA,
+ Geom_PENTA,
+ Geom_POLYHEDRA
+ };
/*!
* ElementOrder points out entities of what order are requested
void Clear()
raises (SALOME::SALOME_Exception);
+ /*!
+ * Remove all nodes and elements of submesh
+ */
+ void ClearSubMesh(in long ShapeID)
+ raises (SALOME::SALOME_Exception);
+
/*!
* Get the subMesh object associated to a subShape. The subMesh object
* gives access to nodes and elements IDs.
in SMESH_GroupBase aGroup2,
in string name )
raises (SALOME::SALOME_Exception);
+
+ /*!
+ * Union of list of groups
+ * New group is created. All mesh elements that are
+ * present in initial groups are added to the new one
+ */
+ SMESH_Group UnionListOfGroups (in ListOfGroups aListOfGroups,
+ in string name )
+ raises (SALOME::SALOME_Exception);
/*!
* Intersection of two groups
in SMESH_GroupBase aGroup2,
in string name )
raises (SALOME::SALOME_Exception);
+
+ /*!
+ * Intersection of list of groups
+ * New group is created. All mesh elements that are
+ * present in all initial groups simultaneously are added to the new one.
+ */
+ SMESH_Group IntersectListOfGroups (in ListOfGroups aListOfGroups,
+ in string name)
+ raises (SALOME::SALOME_Exception);
/*!
* Cut of two groups
* main group but do not present in tool group are added to the new one
*/
SMESH_Group CutGroups (in SMESH_GroupBase aMainGroup,
- in SMESH_GroupBase aToolGroup,
- in string name )
+ in SMESH_GroupBase aToolGroup,
+ in string name )
+ raises (SALOME::SALOME_Exception);
+
+ /*!
+ * Cut of lists of groups
+ * New group is created. All mesh elements that are present in
+ * main groups but do not present in tool groups are added to the new one
+ */
+ SMESH_Group CutListOfGroups (in ListOfGroups aMainGroups,
+ in ListOfGroups aToolGroups,
+ in string name)
+ raises (SALOME::SALOME_Exception);
+
+ /*!
+ * Create groups of entities from existing groups of superior dimensions
+ * New group is created. System
+ * 1) extracts all nodes from each group,
+ * 2) combines all elements of specified dimension laying on these nodes.
+ */
+ SMESH_Group CreateDimGroup( in ListOfGroups aListOfGroups,
+ in ElementType anElemType,
+ in string name )
+ raises (SALOME::SALOME_Exception);
+
+ /*!
+ * Convert group on geometry into standalone group
+ */
+ SMESH_Group ConvertToStandalone( in SMESH_GroupOnGeom theGeomGroup )
raises (SALOME::SALOME_Exception);
/*!
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// File : SMESH_MeshEditor.idl
-// $Header$
//
+
#ifndef _SMESH_MESHEDITOR_IDL_
#define _SMESH_MESHEDITOR_IDL_
* not creared - returns empty list
*/
long_array GetLastCreatedElems();
+
+ /*!
+ * \brief Creates a hole in a mesh by doubling the nodes of some particular elements
+ * \param theNodes - identifiers of nodes to be doubled
+ * \param theModifiedElems - identifiers of elements to be updated by the new (doubled)
+ * nodes. If list of element identifiers is empty then nodes are doubled but
+ * they not assigned to elements
+ * \return TRUE if operation has been completed successfully, FALSE otherwise
+ * \sa DoubleNode(), DoubleNodeGroup(), DoubleNodeGroups()
+ */
+ boolean DoubleNodes( in long_array theNodes, in long_array theModifiedElems );
+
+ /*!
+ * \brief Creates a hole in a mesh by doubling the nodes of some particular elements
+ * This method provided for convenience works as DoubleNodes() described above.
+ * \param theNodeId - identifier of node to be doubled.
+ * \param theModifiedElems - identifiers of elements to be updated.
+ * \return TRUE if operation has been completed successfully, FALSE otherwise
+ * \sa DoubleNodes(), DoubleNodeGroup(), DoubleNodeGroups()
+ */
+ boolean DoubleNode( in long theNodeId, in long_array theModifiedElems );
+
+ /*!
+ * \brief Creates a hole in a mesh by doubling the nodes of some particular elements
+ * This method provided for convenience works as DoubleNodes() described above.
+ * \param theNodes - group of nodes to be doubled.
+ * \param theModifiedElems - group of elements to be updated.
+ * \return TRUE if operation has been completed successfully, FALSE otherwise
+ * \sa DoubleNode(), DoubleNodes(), DoubleNodeGroups()
+ */
+ boolean DoubleNodeGroup( in SMESH_GroupBase theNodes,
+ in SMESH_GroupBase theModifiedElems );
+
+ /*!
+ \brief Creates a hole in a mesh by doubling the nodes of some particular elements
+ This method provided for convenience works as DoubleNodes() described above.
+ \param theNodes - list of groups of nodes to be doubled
+ \param theModifiedElems - list of groups of elements to be updated.
+ \return TRUE if operation has been completed successfully, FALSE otherwise
+ \sa DoubleNode(), DoubleNodeGroup(), DoubleNodes()
+ */
+ boolean DoubleNodeGroups( in ListOfGroups theNodes,
+ in ListOfGroups theModifiedElems );
};
};
# Author : Patrick GOLDBRONN (CEA)
# Date : 28/06/2001
# Modified by : Alexander BORODIN (OCN) - autotools usage
-# $Header$
#
include $(top_srcdir)/adm_local/unix/make_common_starter.am
mesh_length_2d.png \
mesh_free_edges.png \
mesh_free_edges_2d.png \
+ mesh_free_nodes.png \
mesh_multi_edges.png \
mesh_multi_edges_2d.png \
mesh_line_n.png \
mesh_tree_hypo_projection_2d.png \
mesh_build_compound.png \
mesh_node_to_point.png \
- mesh_tree_mesh_partial.png
+ mesh_tree_mesh_partial.png \
+ mesh_extractGroup.png \
+ mesh_precompute.png \
+ mesh_free_faces.png
# VSR: little trick to avoid putting if SMESHCatalog.xml to the distribution archive
nodist_salomeres_SCRIPTS = SMESHCatalog.xml
<parameter name="selection_width" value="5"/>
<parameter name="highlight_width" value="5"/>
<parameter name="controls_precision" value="0"/>
- <parameter name="scalar_bar_horizontal_height" value="0.05"/>
- <parameter name="scalar_bar_horizontal_width" value="0.5" />
- <parameter name="scalar_bar_horizontal_x" value="0.01"/>
+ <parameter name="scalar_bar_horizontal_height" value="0.08"/>
+ <parameter name="scalar_bar_horizontal_width" value="0.8" />
+ <parameter name="scalar_bar_horizontal_x" value="0.1"/>
<parameter name="scalar_bar_horizontal_y" value="0.01"/>
<parameter name="scalar_bar_label_color" value="255, 255, 255"/>
<parameter name="scalar_bar_label_font" value="Arial,12" />
<parameter name="scalar_bar_orientation" value="0" />
<parameter name="scalar_bar_title_color" value="255, 255, 255"/>
<parameter name="scalar_bar_title_font" value="Arial,12" />
- <parameter name="scalar_bar_vertical_height" value="0.5" />
- <parameter name="scalar_bar_vertical_width" value="0.05" />
+ <parameter name="scalar_bar_vertical_height" value="0.8" />
+ <parameter name="scalar_bar_vertical_width" value="0.08" />
<parameter name="scalar_bar_vertical_x" value="0.01" />
- <parameter name="scalar_bar_vertical_y" value="0.01" />
+ <parameter name="scalar_bar_vertical_y" value="0.1" />
<parameter name="DisplayMode" value="true" />
<parameter name="auto_update" value="true" />
<parameter name="display_mode" value="1" />
<parameter name="auto_groups" value="false"/>
<parameter name="show_result_notification" value="2"/>
+ <parameter name="segmentation" value="10"/>
</section>
<section name="resources">
<!-- Module resources -->
icon-id="mesh_hypo_length.png"
dim="1"/>
+ <hypothesis type="MaxLength"
+ label-id="Max Size"
+ icon-id="mesh_hypo_length.png"
+ dim="1"/>
+
<hypothesis type="Arithmetic1D"
label-id="Arithmetic 1D"
icon-id="mesh_hypo_length.png"
<algorithm type="Regular_1D"
label-id="Wire discretisation"
icon-id="mesh_algo_regular.png"
- hypos="LocalLength,Arithmetic1D,StartEndLength,NumberOfSegments,Deflection1D,AutomaticLength"
+ hypos="LocalLength,MaxLength,Arithmetic1D,StartEndLength,NumberOfSegments,Deflection1D,AutomaticLength"
opt-hypos="Propagation,QuadraticMesh"
input="VERTEX"
output="EDGE"
<algorithm type="CompositeSegment_1D"
label-id="Composite side discretisation"
icon-id="mesh_algo_regular.png"
- hypos="LocalLength,Arithmetic1D,StartEndLength,NumberOfSegments,Deflection1D,AutomaticLength"
+ hypos="LocalLength,MaxLength,Arithmetic1D,StartEndLength,NumberOfSegments,Deflection1D,AutomaticLength"
opt-hypos="Propagation,QuadraticMesh"
input="VERTEX"
output="EDGE"
<hypotheses-set-group>
<hypotheses-set name="Automatic Tetrahedralization"
- hypos="AutomaticLength"
+ hypos="MaxLength"
algos="Regular_1D, MEFISTO_2D, NETGEN_3D"/>
<hypotheses-set name="Automatic Hexahedralization"
- hypos="AutomaticLength"
+ hypos="NumberOfSegments"
algos="Regular_1D, Quadrangle_2D, Hexa_3D"/>
</hypotheses-set-group>
$(CAS_CPPFLAGS) \
$(BOOST_CPPFLAGS) \
$(KERNEL_CXXFLAGS) \
- -I$(srcdir)/../SMDS
+ -I$(srcdir)/../SMDS \
+ -I$(srcdir)/../SMESHDS
libSMESHControls_la_LDFLAGS = \
../SMDS/libSMDS.la \
- $(KERNEL_LDFLAGS) -lOpUtil\
+ ../SMESHDS/libSMESHDS.la \
$(CAS_LDPATH) -lTKernel -lTKBRep -lTKG3d
SMESHControls_CPPFLAGS = \
SMESHControls_LDADD = \
../SMDS/libSMDS.la \
+ ../SMESHDS/libSMESHDS.la \
libSMESHControls.la \
$(KERNEL_LDFLAGS) -lOpUtil -lSALOMELocalTrace -lSALOMEBasics \
$(GEOM_LDFLAGS) -lGEOMAlgo \
#include "SMDS_QuadraticFaceOfNodes.hxx"
#include "SMDS_QuadraticEdge.hxx"
+#include "SMESHDS_Mesh.hxx"
+#include "SMESHDS_GroupBase.hxx"
+
/*
AUXILIARY METHODS
*/
//std::cout<<"theBorders.size() = "<<theBorders.size()<<endl;
}
+
+/*
+ Class : FreeNodes
+ Description : Predicate for free nodes
+*/
+
+FreeNodes::FreeNodes()
+{
+ myMesh = 0;
+}
+
+void FreeNodes::SetMesh( const SMDS_Mesh* theMesh )
+{
+ myMesh = theMesh;
+}
+
+bool FreeNodes::IsSatisfy( long theNodeId )
+{
+ const SMDS_MeshNode* aNode = myMesh->FindNode( theNodeId );
+ if (!aNode)
+ return false;
+
+ return (aNode->NbInverseElements() < 1);
+}
+
+SMDSAbs_ElementType FreeNodes::GetType() const
+{
+ return SMDSAbs_Node;
+}
+
+
+/*
+ Class : FreeFaces
+ Description : Predicate for free faces
+*/
+
+FreeFaces::FreeFaces()
+{
+ myMesh = 0;
+}
+
+void FreeFaces::SetMesh( const SMDS_Mesh* theMesh )
+{
+ myMesh = theMesh;
+}
+
+bool FreeFaces::IsSatisfy( long theId )
+{
+ if (!myMesh) return false;
+ // check that faces nodes refers to less than two common volumes
+ const SMDS_MeshElement* aFace = myMesh->FindElement( theId );
+ if ( !aFace || aFace->GetType() != SMDSAbs_Face )
+ return false;
+
+ int nbNode = aFace->NbNodes();
+
+ // collect volumes check that number of volumss with count equal nbNode not less than 2
+ typedef map< SMDS_MeshElement*, int > TMapOfVolume; // map of volume counters
+ typedef map< SMDS_MeshElement*, int >::iterator TItrMapOfVolume; // iterator
+ TMapOfVolume mapOfVol;
+
+ SMDS_ElemIteratorPtr nodeItr = aFace->nodesIterator();
+ while ( nodeItr->more() ) {
+ const SMDS_MeshNode* aNode = static_cast<const SMDS_MeshNode*>(nodeItr->next());
+ if ( !aNode ) continue;
+ SMDS_ElemIteratorPtr volItr = aNode->GetInverseElementIterator(SMDSAbs_Volume);
+ while ( volItr->more() ) {
+ SMDS_MeshElement* aVol = (SMDS_MeshElement*)volItr->next();
+ TItrMapOfVolume itr = mapOfVol.insert(make_pair(aVol, 0)).first;
+ (*itr).second++;
+ }
+ }
+ int nbVol = 0;
+ TItrMapOfVolume volItr = mapOfVol.begin();
+ TItrMapOfVolume volEnd = mapOfVol.end();
+ for ( ; volItr != volEnd; ++volItr )
+ if ( (*volItr).second >= nbNode )
+ nbVol++;
+ // face is not free if number of volumes constructed on thier nodes more than one
+ return (nbVol < 2);
+}
+
+SMDSAbs_ElementType FreeFaces::GetType() const
+{
+ return SMDSAbs_Face;
+}
+
+/*
+ Class : LinearOrQuadratic
+ Description : Predicate to verify whether a mesh element is linear
+*/
+
+LinearOrQuadratic::LinearOrQuadratic()
+{
+ myMesh = 0;
+}
+
+void LinearOrQuadratic::SetMesh( const SMDS_Mesh* theMesh )
+{
+ myMesh = theMesh;
+}
+
+bool LinearOrQuadratic::IsSatisfy( long theId )
+{
+ if (!myMesh) return false;
+ const SMDS_MeshElement* anElem = myMesh->FindElement( theId );
+ if ( !anElem || (myType != SMDSAbs_All && anElem->GetType() != myType) )
+ return false;
+ return (!anElem->IsQuadratic());
+}
+
+void LinearOrQuadratic::SetType( SMDSAbs_ElementType theType )
+{
+ myType = theType;
+}
+
+SMDSAbs_ElementType LinearOrQuadratic::GetType() const
+{
+ return myType;
+}
+
+/*
+ Class : GroupColor
+ Description : Functor for check color of group to whic mesh element belongs to
+*/
+
+GroupColor::GroupColor()
+{
+}
+
+bool GroupColor::IsSatisfy( long theId )
+{
+ return (myIDs.find( theId ) != myIDs.end());
+}
+
+void GroupColor::SetType( SMDSAbs_ElementType theType )
+{
+ myType = theType;
+}
+
+SMDSAbs_ElementType GroupColor::GetType() const
+{
+ return myType;
+}
+
+static bool isEqual( const Quantity_Color& theColor1,
+ const Quantity_Color& theColor2 )
+{
+ // tolerance to compare colors
+ const double tol = 5*1e-3;
+ return ( fabs( theColor1.Red() - theColor2.Red() ) < tol &&
+ fabs( theColor1.Green() - theColor2.Green() ) < tol &&
+ fabs( theColor1.Blue() - theColor2.Blue() ) < tol );
+}
+
+
+void GroupColor::SetMesh( const SMDS_Mesh* theMesh )
+{
+ myIDs.clear();
+
+ const SMESHDS_Mesh* aMesh = dynamic_cast<const SMESHDS_Mesh*>(theMesh);
+ if ( !aMesh )
+ return;
+
+ int nbGrp = aMesh->GetNbGroups();
+ if ( !nbGrp )
+ return;
+
+ // iterates on groups and find necessary elements ids
+ const std::set<SMESHDS_GroupBase*>& aGroups = aMesh->GetGroups();
+ set<SMESHDS_GroupBase*>::const_iterator GrIt = aGroups.begin();
+ for (; GrIt != aGroups.end(); GrIt++) {
+ SMESHDS_GroupBase* aGrp = (*GrIt);
+ if ( !aGrp )
+ continue;
+ // check type and color of group
+ if ( !isEqual( myColor, aGrp->GetColor() ) )
+ continue;
+ if ( myType != SMDSAbs_All && myType != (SMDSAbs_ElementType)aGrp->GetType() )
+ continue;
+
+ // add elements IDS into control
+ int aSize = aGrp->Extent();
+ for (int i = 0; i < aSize; i++)
+ myIDs.insert( aGrp->GetID(i+1) );
+ }
+}
+
+void GroupColor::SetColorStr( const TCollection_AsciiString& theStr )
+{
+ TCollection_AsciiString aStr = theStr;
+ aStr.RemoveAll( ' ' );
+ aStr.RemoveAll( '\t' );
+ for ( int aPos = aStr.Search( ";;" ); aPos != -1; aPos = aStr.Search( ";;" ) )
+ aStr.Remove( aPos, 2 );
+ Standard_Real clr[3];
+ clr[0] = clr[1] = clr[2] = 0.;
+ for ( int i = 0; i < 3; i++ ) {
+ TCollection_AsciiString tmpStr = aStr.Token( ";", i+1 );
+ if ( !tmpStr.IsEmpty() && tmpStr.IsRealValue() )
+ clr[i] = tmpStr.RealValue();
+ }
+ myColor = Quantity_Color( clr[0], clr[1], clr[2], Quantity_TOC_RGB );
+}
+
+//=======================================================================
+// name : GetRangeStr
+// Purpose : Get range as a string.
+// Example: "1,2,3,50-60,63,67,70-"
+//=======================================================================
+void GroupColor::GetColorStr( TCollection_AsciiString& theResStr ) const
+{
+ theResStr.Clear();
+ theResStr += TCollection_AsciiString( myColor.Red() );
+ theResStr += TCollection_AsciiString( ";" ) + TCollection_AsciiString( myColor.Green() );
+ theResStr += TCollection_AsciiString( ";" ) + TCollection_AsciiString( myColor.Blue() );
+}
+
+/*
+ Class : ElemGeomType
+ Description : Predicate to check element geometry type
+*/
+
+ElemGeomType::ElemGeomType()
+{
+ myMesh = 0;
+ myType = SMDSAbs_All;
+ myGeomType = SMDSGeom_TRIANGLE;
+}
+
+void ElemGeomType::SetMesh( const SMDS_Mesh* theMesh )
+{
+ myMesh = theMesh;
+}
+
+bool ElemGeomType::IsSatisfy( long theId )
+{
+ if (!myMesh) return false;
+ const SMDS_MeshElement* anElem = myMesh->FindElement( theId );
+ const SMDSAbs_ElementType anElemType = anElem->GetType();
+ if ( !anElem || (myType != SMDSAbs_All && anElemType != myType) )
+ return false;
+ const int aNbNode = anElem->NbNodes();
+ bool isOk = false;
+ switch( anElemType )
+ {
+ case SMDSAbs_Node:
+ isOk = (myGeomType == SMDSGeom_POINT);
+ break;
+
+ case SMDSAbs_Edge:
+ isOk = (myGeomType == SMDSGeom_EDGE);
+ break;
+
+ case SMDSAbs_Face:
+ if ( myGeomType == SMDSGeom_TRIANGLE )
+ isOk = (!anElem->IsPoly() && aNbNode == 3);
+ else if ( myGeomType == SMDSGeom_QUADRANGLE )
+ isOk = (!anElem->IsPoly() && aNbNode == 4);
+ else if ( myGeomType == SMDSGeom_POLYGON )
+ isOk = anElem->IsPoly();
+ break;
+
+ case SMDSAbs_Volume:
+ if ( myGeomType == SMDSGeom_TETRA )
+ isOk = (!anElem->IsPoly() && aNbNode == 4);
+ else if ( myGeomType == SMDSGeom_PYRAMID )
+ isOk = (!anElem->IsPoly() && aNbNode == 5);
+ else if ( myGeomType == SMDSGeom_PENTA )
+ isOk = (!anElem->IsPoly() && aNbNode == 6);
+ else if ( myGeomType == SMDSGeom_HEXA )
+ isOk = (!anElem->IsPoly() && aNbNode == 8);
+ else if ( myGeomType == SMDSGeom_POLYHEDRA )
+ isOk = anElem->IsPoly();
+ break;
+ default: break;
+ }
+ return isOk;
+}
+
+void ElemGeomType::SetType( SMDSAbs_ElementType theType )
+{
+ myType = theType;
+}
+
+SMDSAbs_ElementType ElemGeomType::GetType() const
+{
+ return myType;
+}
+
+void ElemGeomType::SetGeomType( SMDSAbs_GeometryType theType )
+{
+ myGeomType = theType;
+}
+
+SMDSAbs_GeometryType ElemGeomType::GetGeomType() const
+{
+ return myGeomType;
+}
+
/*
Class : RangeOfIds
Description : Predicate for Range of Ids.
#include <TopoDS_Face.hxx>
#include <TopTools_MapOfShape.hxx>
#include <BRepClass3d_SolidClassifier.hxx>
+#include <Quantity_Color.hxx>
#include "SMDSAbs_ElementType.hxx"
#include "SMDS_MeshNode.hxx"
const SMDS_Mesh* myMesh;
};
typedef boost::shared_ptr<FreeEdges> FreeEdgesPtr;
+
+
+ /*
+ Class : FreeNodes
+ Description : Predicate for free nodes
+ */
+ class SMESHCONTROLS_EXPORT FreeNodes: public virtual Predicate{
+ public:
+ FreeNodes();
+ virtual void SetMesh( const SMDS_Mesh* theMesh );
+ virtual bool IsSatisfy( long theNodeId );
+ virtual SMDSAbs_ElementType GetType() const;
+ protected:
+ const SMDS_Mesh* myMesh;
+ };
+
/*
Class : RangeOfIds
typedef boost::shared_ptr<ElementsOnShape> ElementsOnShapePtr;
+ /*
+ Class : FreeFaces
+ Description : Predicate for free faces
+ */
+ class SMESHCONTROLS_EXPORT FreeFaces: public virtual Predicate{
+ public:
+ FreeFaces();
+ virtual void SetMesh( const SMDS_Mesh* theMesh );
+ virtual bool IsSatisfy( long theElementId );
+ virtual SMDSAbs_ElementType GetType() const;
+
+ private:
+ const SMDS_Mesh* myMesh;
+ };
+
+ /*
+ Class : LinearOrQuadratic
+ Description : Predicate for free faces
+ */
+ class SMESHCONTROLS_EXPORT LinearOrQuadratic: public virtual Predicate{
+ public:
+ LinearOrQuadratic();
+ virtual void SetMesh( const SMDS_Mesh* theMesh );
+ virtual bool IsSatisfy( long theElementId );
+ void SetType( SMDSAbs_ElementType theType );
+ virtual SMDSAbs_ElementType GetType() const;
+
+ private:
+ const SMDS_Mesh* myMesh;
+ SMDSAbs_ElementType myType;
+ };
+ typedef boost::shared_ptr<LinearOrQuadratic> LinearOrQuadraticPtr;
+
+ /*
+ Class : GroupColor
+ Description : Functor for check color of group to whic mesh element belongs to
+ */
+ class SMESHCONTROLS_EXPORT GroupColor: public virtual Predicate{
+ public:
+ GroupColor();
+ virtual void SetMesh( const SMDS_Mesh* theMesh );
+ virtual bool IsSatisfy( long theElementId );
+ void SetType( SMDSAbs_ElementType theType );
+ virtual SMDSAbs_ElementType GetType() const;
+ void SetColorStr( const TCollection_AsciiString& );
+ void GetColorStr( TCollection_AsciiString& ) const;
+
+ private:
+ typedef std::set< long > TIDs;
+
+ Quantity_Color myColor;
+ SMDSAbs_ElementType myType;
+ TIDs myIDs;
+ };
+ typedef boost::shared_ptr<GroupColor> GroupColorPtr;
+
+ /*
+ Class : ElemGeomType
+ Description : Predicate to check element geometry type
+ */
+ class SMESHCONTROLS_EXPORT ElemGeomType: public virtual Predicate{
+ public:
+ ElemGeomType();
+ virtual void SetMesh( const SMDS_Mesh* theMesh );
+ virtual bool IsSatisfy( long theElementId );
+ void SetType( SMDSAbs_ElementType theType );
+ virtual SMDSAbs_ElementType GetType() const;
+ void SetGeomType( SMDSAbs_GeometryType theType );
+ virtual SMDSAbs_GeometryType GetGeomType() const;
+
+ private:
+ const SMDS_Mesh* myMesh;
+ SMDSAbs_ElementType myType;
+ SMDSAbs_GeometryType myGeomType;
+ };
+ typedef boost::shared_ptr<ElemGeomType> ElemGeomTypePtr;
+
/*
FILTER
*/
// File : SMESH_Actor.cxx
// Author : Nicolas REJNERI
// Module : SMESH
-// $Header$
-//
+
+
#include "SMESH_ActorDef.h"
#include "SMESH_ActorUtils.h"
#include "SMESH_DeviceActor.h"
aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
+ my2DExtProp = vtkProperty::New();
+ my2DExtProp->DeepCopy(mySurfaceProp);
+ SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
+ anRGB[0] = 1 - anRGB[0];
+ anRGB[1] = 1 - anRGB[1];
+ anRGB[2] = 1 - anRGB[2];
+ my2DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
+
+ my2DExtActor = SMESH_DeviceActor::New();
+ my2DExtActor->SetUserMatrix(aMatrix);
+ my2DExtActor->PickableOff();
+ my2DExtActor->SetProperty(my2DExtProp);
+ my2DExtActor->SetBackfaceProperty(my2DExtProp);
+ my2DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
+ aFilter = my2DExtActor->GetExtractUnstructuredGrid();
+ aFilter->RegisterCellsWithType(VTK_TRIANGLE);
+ aFilter->RegisterCellsWithType(VTK_POLYGON);
+ aFilter->RegisterCellsWithType(VTK_QUAD);
+ aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
+ aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
+
my3DActor = SMESH_DeviceActor::New();
my3DActor->SetUserMatrix(aMatrix);
my3DActor->PickableOff();
my1DProp->DeepCopy(myEdgeProp);
my1DProp->SetLineWidth(aLineWidth + aLineWidthInc);
my1DProp->SetPointSize(aPointSize);
-
+
my1DExtProp = vtkProperty::New();
my1DExtProp->DeepCopy(myEdgeProp);
anRGB[0] = 1 - anRGB[0];
myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
aFilter = myNodeActor->GetExtractUnstructuredGrid();
aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
-
+
+ myNodeExtProp = vtkProperty::New();
+ myNodeExtProp->DeepCopy(myNodeProp);
+ anRGB[0] = 1 - anRGB[0];
+ anRGB[1] = 1 - anRGB[1];
+ anRGB[2] = 1 - anRGB[2];
+ myNodeExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
+ myNodeExtProp->SetPointSize(aPointSize);
+
+ myNodeExtActor = SMESH_DeviceActor::New();
+ myNodeExtActor->SetUserMatrix(aMatrix);
+ myNodeExtActor->SetStoreClippingMapping(true);
+ myNodeExtActor->PickableOff();
+ myNodeExtActor->SetHighlited(true);
+ myNodeExtActor->SetVisibility(false);
+ myNodeExtActor->SetProperty(myNodeExtProp);
+ myNodeExtActor->SetRepresentation(SMESH_DeviceActor::ePoint);
+ aFilter = myNodeExtActor->GetExtractUnstructuredGrid();
+ aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
+ aFilter->RegisterCellsWithType(VTK_VERTEX);
//Definition of Pickable and Highlitable engines
//----------------------------------------------
myPreselectProp->Delete();
myNodeProp->Delete();
-
+ myNodeExtProp->Delete();
+
my1DProp->Delete();
my1DActor->Delete();
my1DExtActor->Delete();
my2DActor->Delete();
+ my2DExtProp->Delete();
+ my2DExtActor->Delete();
my3DActor->Delete();
myNodeActor->Delete();
myBaseActor->Delete();
+ myNodeExtActor->Delete();
+
myHighlitableActor->Delete();
//Deleting of pints numbering pipeline
aFunctor.reset(new SMESH::Controls::FreeEdges());
myControlActor = my2DActor;
break;
+ case eFreeNodes:
+ aFunctor.reset(new SMESH::Controls::FreeNodes());
+ myControlActor = myNodeActor;
+ break;
+ case eFreeFaces:
+ aFunctor.reset(new SMESH::Controls::FreeFaces());
+ myControlActor = my2DActor;
+ break;
case eMultiConnection:
aFunctor.reset(new SMESH::Controls::MultiConnection());
myControlActor = my1DActor;
if(aNbCells){
myControlMode = theMode;
switch(myControlMode){
+ case eFreeNodes:
+ myNodeExtActor->SetExtControlMode(aFunctor);
+ break;
case eFreeEdges:
case eFreeBorders:
my1DExtActor->SetExtControlMode(aFunctor);
break;
+ case eFreeFaces:
+ my2DExtActor->SetExtControlMode(aFunctor);
+ break;
case eLength2D:
case eMultiConnection2D:
my1DExtActor->SetExtControlMode(aFunctor,myScalarBarActor,myLookupTable);
switch(myControlMode){
case eLength2D:
case eFreeEdges:
+ case eFreeFaces:
case eMultiConnection2D:
//SetEntityMode(eEdges);
SetEntityMode(eFaces);
theRenderer->AddActor(myNodeActor);
theRenderer->AddActor(myBaseActor);
+
+ theRenderer->AddActor(myNodeExtActor);
my3DActor->AddToRender(theRenderer);
my2DActor->AddToRender(theRenderer);
+ my2DExtActor->AddToRender(theRenderer);
theRenderer->AddActor(my1DActor);
theRenderer->AddActor(my1DExtActor);
theRenderer->AddActor(myHighlitableActor);
-
+
theRenderer->AddActor2D(myScalarBarActor);
myPtsSelectVisiblePoints->SetRenderer(theRenderer);
theRenderer->RemoveActor(myNodeActor);
theRenderer->RemoveActor(myBaseActor);
+ theRenderer->RemoveActor(myNodeExtActor);
+
theRenderer->RemoveActor(myHighlitableActor);
theRenderer->RemoveActor(my1DActor);
theRenderer->RemoveActor(my1DExtActor);
my2DActor->RemoveFromRender(theRenderer);
+ my2DExtActor->RemoveFromRender(theRenderer);
my3DActor->RemoveFromRender(theRenderer);
theRenderer->RemoveActor(myScalarBarActor);
myNodeActor->Init(myVisualObj,myImplicitBoolean);
myBaseActor->Init(myVisualObj,myImplicitBoolean);
-
+
myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
+
+ myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
my1DActor->Init(myVisualObj,myImplicitBoolean);
my1DExtActor->Init(myVisualObj,myImplicitBoolean);
my2DActor->Init(myVisualObj,myImplicitBoolean);
+ my2DExtActor->Init(myVisualObj,myImplicitBoolean);
my3DActor->Init(myVisualObj,myImplicitBoolean);
my1DActor->GetMapper()->SetLookupTable(myLookupTable);
my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
my2DActor->GetMapper()->SetLookupTable(myLookupTable);
+ my2DExtActor->GetMapper()->SetLookupTable(myLookupTable);
my3DActor->GetMapper()->SetLookupTable(myLookupTable);
vtkFloatingPointType aFactor, aUnits;
my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
+ my2DExtActor->SetPolygonOffsetParameters(aFactor,aUnits*0.5);
SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
if( !mgr )
myNodeActor->SetTransform(theTransform);
myBaseActor->SetTransform(theTransform);
-
+
myHighlitableActor->SetTransform(theTransform);
+ myNodeExtActor->SetTransform(theTransform);
+
my1DActor->SetTransform(theTransform);
my1DExtActor->SetTransform(theTransform);
my2DActor->SetTransform(theTransform);
+ my2DExtActor->SetTransform(theTransform);
my3DActor->SetTransform(theTransform);
Modified();
my1DExtActor->SetShrinkFactor(theValue);
my2DActor->SetShrinkFactor(theValue);
+ my2DExtActor->SetShrinkFactor(theValue);
my3DActor->SetShrinkFactor(theValue);
Modified();
my1DExtActor->SetShrink();
my2DActor->SetShrink();
+ my2DExtActor->SetShrink();
my3DActor->SetShrink();
myIsShrunk = true;
my1DExtActor->UnShrink();
my2DActor->UnShrink();
+ my2DExtActor->UnShrink();
my3DActor->UnShrink();
myIsShrunk = false;
myNodeActor->VisibilityOff();
myBaseActor->VisibilityOff();
+ myNodeExtActor->VisibilityOff();
+
my1DActor->VisibilityOff();
my1DExtActor->VisibilityOff();
my2DActor->VisibilityOff();
+ my2DExtActor->VisibilityOff();
my3DActor->VisibilityOff();
myScalarBarActor->VisibilityOff();
if(GetVisibility()){
if(theIsUpdateRepersentation)
SetRepresentation(GetRepresentation());
-
+
if(myControlMode != eNone){
switch(myControlMode){
+ case eFreeNodes:
+ myNodeExtActor->VisibilityOn();
+ break;
case eFreeEdges:
case eFreeBorders:
my1DExtActor->VisibilityOn();
break;
+ case eFreeFaces:
+ my2DExtActor->VisibilityOn();
+ break;
case eLength2D:
case eMultiConnection2D:
my1DExtActor->VisibilityOn();
myPickableActor = myBaseActor;
myNodeActor->SetVisibility(false);
+ myNodeExtActor->SetVisibility(false);
vtkProperty *aProp = NULL, *aBackProp = NULL;
SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
switch(myRepresentation){
my2DActor->SetProperty(aProp);
my2DActor->SetBackfaceProperty(aBackProp);
my2DActor->SetRepresentation(aReperesent);
+
+ my2DExtActor->SetRepresentation(aReperesent);
my3DActor->SetProperty(aProp);
my3DActor->SetBackfaceProperty(aBackProp);
my3DActor->SetRepresentation(aReperesent);
my1DExtActor->SetVisibility(false);
+ my2DExtActor->SetVisibility(false);
switch(myControlMode){
case eLength:
void SMESH_ActorDef::GetSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
::GetColor(mySurfaceProp,r,g,b);
+ my2DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
}
void SMESH_ActorDef::SetBackSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
void SMESH_ActorDef::SetNodeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
myNodeProp->SetColor(r,g,b);
+ myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
Modified();
}
void SMESH_ActorDef::SetNodeSize(vtkFloatingPointType theVal){
myNodeProp->SetPointSize(theVal);
+ myNodeExtProp->SetPointSize(theVal);
myHighlightProp->SetPointSize(theVal);
myPreselectProp->SetPointSize(theVal);
myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
+
+ myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
+ my2DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
}
else
aScalarBarTitleProp->ItalicOff();
- if ( f.underline() )
+ if ( f.overline() )
aScalarBarTitleProp->ShadowOn();
else
aScalarBarTitleProp->ShadowOff();
else
aScalarBarLabelProp->ItalicOff();
- if( f.underline() )
+ if( f.overline() )
aScalarBarLabelProp->ShadowOn();
else
aScalarBarLabelProp->ShadowOff();
// File : SMESH_Actor.h
// Author : Nicolas REJNERI
// Module : SMESH
-// $Header$
-//
+
#ifndef SMESH_ACTOR_H
#define SMESH_ACTOR_H
virtual void SetFacesOriented(bool theIsFacesOriented) = 0;
virtual bool GetFacesOriented() = 0;
- enum eControl{eNone, eLength, eLength2D, eFreeBorders, eFreeEdges, eMultiConnection,
- eArea, eTaper, eAspectRatio, eMinimumAngle, eWarping, eSkew,
- eAspectRatio3D, eMultiConnection2D, eVolume3D};
+ enum eControl{eNone, eLength, eLength2D, eFreeBorders, eFreeEdges, eFreeNodes,
+ eFreeFaces, eMultiConnection, eArea, eTaper, eAspectRatio,
+ eMinimumAngle, eWarping, eSkew, eAspectRatio3D, eMultiConnection2D, eVolume3D};
virtual void SetControlMode(eControl theMode) = 0;
virtual eControl GetControlMode() = 0;
// File : SMESH_ActorDef.h
// Author : Nicolas REJNERI
// Module : SMESH
-// $Header$
//
+
#ifndef SMESH_ACTORDEF_H
#define SMESH_ACTORDEF_H
SMESH_DeviceActor* myHighlitableActor;
eControl myControlMode;
+ vtkProperty* my2DExtProp;
SMESH_DeviceActor* my2DActor;
+ SMESH_DeviceActor* my2DExtActor;
SMESH_DeviceActor* my3DActor;
SMESH_DeviceActor* myControlActor;
+ vtkProperty* myNodeExtProp;
+ SMESH_DeviceActor* myNodeExtActor;
+
vtkProperty* my1DProp;
SMESH_DeviceActor* my1DActor;
vtkProperty* my1DExtProp;
// File : SMESH_DeviceActor.cxx
// Author :
// Module : SMESH
-// $Header$
//
+
#include "SMESH_DeviceActor.h"
#include "SMESH_ExtractGeometry.h"
#include "SMESH_ControlsDef.hxx"
myVisualObj->UpdateFunctor(theFunctor);
using namespace SMESH::Controls;
- if(FreeBorders* aFreeBorders = dynamic_cast<FreeBorders*>(theFunctor.get())){
+ if ( dynamic_cast<FreeBorders*>(theFunctor.get()) ||
+ dynamic_cast<FreeFaces*>(theFunctor.get()) ) {
+ Predicate* aFreePredicate = dynamic_cast<Predicate*>(theFunctor.get());
myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
vtkIdType aNbCells = aGrid->GetNumberOfCells();
for( vtkIdType i = 0; i < aNbCells; i++ ){
vtkIdType anObjId = myVisualObj->GetElemObjId(i);
- if(aFreeBorders->IsSatisfy(anObjId))
+ if(aFreePredicate->IsSatisfy(anObjId))
myExtractUnstructuredGrid->RegisterCell(i);
}
if(!myExtractUnstructuredGrid->IsCellsRegistered())
SetUnstructuredGrid(aDataSet);
aDataSet->Delete();
+ }else if(FreeNodes* aFreeNodes = dynamic_cast<FreeNodes*>(theFunctor.get())){
+ myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
+ vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
+ vtkIdType aNbCells = aGrid->GetNumberOfCells();
+ for( vtkIdType i = 0; i < aNbCells; i++ ){
+ vtkIdType anObjId = myVisualObj->GetNodeObjId(i);
+ if(aFreeNodes->IsSatisfy(anObjId))
+ myExtractUnstructuredGrid->RegisterCell(i);
+ }
+ if(!myExtractUnstructuredGrid->IsCellsRegistered())
+ myExtractUnstructuredGrid->RegisterCell(-1);
+ SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
}
}
SMDSAbs_NbElementTypes
};
+/*! enumeration for element geometry type */
+enum SMDSAbs_GeometryType
+{
+ // 0D element
+ SMDSGeom_POINT,
+ // 1D element
+ SMDSGeom_EDGE,
+ // 2D element
+ SMDSGeom_TRIANGLE,
+ SMDSGeom_QUADRANGLE,
+ SMDSGeom_POLYGON,
+ // 3D element
+ SMDSGeom_TETRA,
+ SMDSGeom_PYRAMID,
+ SMDSGeom_PENTA,
+ SMDSGeom_HEXA,
+ SMDSGeom_POLYHEDRA,
+};
+
+
enum SMDSAbs_ElementOrder {
ORDER_ANY, /*! entities of any order */
ORDER_LINEAR, /*! entities of 1st order */
// File : SMESH_Algo.cxx
// Author : Paul RASCLE, EDF
// Module : SMESH
-// $Header$
//
+
#include "SMESH_Algo.hxx"
#include "SMESH_Comment.hxx"
#include "SMESH_Gen.hxx"
//================================================================================
/*!
- * \brief Initialize my parameter values by the mesh built on the geometry
- * \param theMesh - the built mesh
- * \param theShape - the geometry of interest
- * \retval bool - true if parameter values have been successfully defined
- *
- * Just return false as the algorithm does not hold parameters values
+ * \brief Just return false as the algorithm does not hold parameters values
*/
//================================================================================
{
return false;
}
-
+bool SMESH_Algo::SetParametersByElementSize(double, const SMESH_Mesh*)
+{
+ return false;
+}
//================================================================================
/*!
* \brief Fill vector of node parameters on geometrical edge, including vertex nodes
return theParams.size() > 1;
}
+//================================================================================
+/*!
+ * \brief Fill vector of node parameters on geometrical edge, including vertex nodes
+ * \param theMesh - The mesh containing nodes
+ * \param theEdge - The geometrical edge of interest
+ * \param theParams - The resulting vector of sorted node parameters
+ * \retval bool - false if not all parameters are OK
+ */
+//================================================================================
+
+bool SMESH_Algo::GetSortedNodesOnEdge(const SMESHDS_Mesh* theMesh,
+ const TopoDS_Edge& theEdge,
+ const bool ignoreMediumNodes,
+ map< double, const SMDS_MeshNode* > & theNodes)
+{
+ theNodes.clear();
+
+ if ( !theMesh || theEdge.IsNull() )
+ return false;
+
+ SMESHDS_SubMesh * eSubMesh = theMesh->MeshElements( theEdge );
+ if ( !eSubMesh || !eSubMesh->GetElements()->more() )
+ return false; // edge is not meshed
+
+ int nbNodes = 0;
+ set < double > paramSet;
+ if ( eSubMesh )
+ {
+ // loop on nodes of an edge: sort them by param on edge
+ SMDS_NodeIteratorPtr nIt = eSubMesh->GetNodes();
+ while ( nIt->more() )
+ {
+ const SMDS_MeshNode* node = nIt->next();
+ if ( ignoreMediumNodes ) {
+ SMDS_ElemIteratorPtr elemIt = node->GetInverseElementIterator();
+ if ( elemIt->more() && elemIt->next()->IsMediumNode( node ))
+ continue;
+ }
+ const SMDS_PositionPtr& pos = node->GetPosition();
+ if ( pos->GetTypeOfPosition() != SMDS_TOP_EDGE )
+ return false;
+ const SMDS_EdgePosition* epos =
+ static_cast<const SMDS_EdgePosition*>(node->GetPosition().get());
+ theNodes.insert( make_pair( epos->GetUParameter(), node ));
+ ++nbNodes;
+ }
+ }
+ // add vertex nodes
+ TopoDS_Vertex v1, v2;
+ TopExp::Vertices(theEdge, v1, v2);
+ const SMDS_MeshNode* n1 = VertexNode( v1, (SMESHDS_Mesh*) theMesh );
+ const SMDS_MeshNode* n2 = VertexNode( v2, (SMESHDS_Mesh*) theMesh );
+ Standard_Real f, l;
+ BRep_Tool::Range(theEdge, f, l);
+ if ( v1.Orientation() != TopAbs_FORWARD )
+ std::swap( f, l );
+ if ( n1 && ++nbNodes )
+ theNodes.insert( make_pair( f, n1 ));
+ if ( n2 && ++nbNodes )
+ theNodes.insert( make_pair( l, n2 ));
+
+ return theNodes.size() == nbNodes;
+}
+
//================================================================================
/*!
* \brief Make filter recognize only compatible hypotheses
// File : SMESH_Algo.hxx
// Author : Paul RASCLE, EDF
// Module : SMESH
-// $Header$
//
+
#ifndef _SMESH_ALGO_HXX_
#define _SMESH_ALGO_HXX_
#include <string>
#include <vector>
#include <list>
+#include <map>
class SMESH_Gen;
class SMESH_Mesh;
bool InitCompatibleHypoFilter( SMESH_HypoFilter & theFilter,
const bool ignoreAuxiliary) const;
/*!
- * \brief Initialize my parameter values by the mesh built on the geometry
- *
- * Just return false as the algorithm does not hold parameters values
+ * \brief Just return false as the algorithm does not hold parameters values
*/
- virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh,
- const TopoDS_Shape& theShape);
+ virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
+ virtual bool SetParametersByElementSize(double elemLenght, const SMESH_Mesh* theMesh=0);
/*!
* \brief return compute error
*/
static bool GetNodeParamOnEdge(const SMESHDS_Mesh* theMesh,
const TopoDS_Edge& theEdge,
std::vector< double > & theParams);
+ /*!
+ * \brief Fill map of node parameter on geometrical edge to node it-self
+ * \param theMesh - The mesh containing nodes
+ * \param theEdge - The geometrical edge of interest
+ * \param theNodes - The resulting map
+ * \param ignoreMediumNodes - to store medium nodes of quadratic elements or not
+ * \retval bool - false if not all parameters are OK
+ */
+ static bool GetSortedNodesOnEdge(const SMESHDS_Mesh* theMesh,
+ const TopoDS_Edge& theEdge,
+ const bool ignoreMediumNodes,
+ std::map< double, const SMDS_MeshNode* > & theNodes);
/*!
* \brief Find out elements orientation on a geometrical face
* \param theFace - The face correctly oriented in the shape being meshed
// File : SMESH_Gen.cxx
// Author : Paul RASCLE, EDF
// Module : SMESH
-// $Header$
-//
+
#include "SMESH_Gen.hxx"
#include "SMESH_subMesh.hxx"
#include "SMESH_HypoFilter.hxx"
MESSAGE("SMESH_Gen::SMESH_Gen");
_localId = 0;
_hypId = 0;
+ _segmentation = 10;
}
//=============================================================================
*/
//=============================================================================
-bool SMESH_Gen::Compute(SMESH_Mesh & aMesh,
- const TopoDS_Shape & aShape,
- const bool anUpward)
+bool SMESH_Gen::Compute(SMESH_Mesh & aMesh,
+ const TopoDS_Shape & aShape,
+ const bool anUpward,
+ const ::MeshDimension aDim,
+ TSetOfInt* aShapesId)
{
MESSAGE("SMESH_Gen::Compute");
SMESH_subMesh* smToCompute = smIt->next();
// do not mesh vertices of a pseudo shape
- if ( !aMesh.HasShapeToMesh() &&
- smToCompute->GetSubShape().ShapeType() == TopAbs_VERTEX )
+ const TopAbs_ShapeEnum aShType = smToCompute->GetSubShape().ShapeType();
+ if ( !aMesh.HasShapeToMesh() && aShType == TopAbs_VERTEX )
continue;
+ // check for preview dimension limitations
+ if ( aShapesId && GetShapeDim( aShType ) > (int)aDim )
+ {
+ // clear compute state to not show previous compute errors
+ // if preview invoked less dimension less than previous
+ smToCompute->ComputeStateEngine( SMESH_subMesh::CHECK_COMPUTE_STATE );
+ continue;
+ }
+
if (smToCompute->GetComputeState() == SMESH_subMesh::READY_TO_COMPUTE)
smToCompute->ComputeStateEngine( SMESH_subMesh::COMPUTE );
// we check all the submeshes here and detect if any of them failed to compute
if (smToCompute->GetComputeState() == SMESH_subMesh::FAILED_TO_COMPUTE)
ret = false;
+ else if ( aShapesId )
+ aShapesId->insert( smToCompute->GetId() );
}
return ret;
}
continue;
const TopoDS_Shape& aSubShape = smToCompute->GetSubShape();
- if ( GetShapeDim( aSubShape ) < 1 ) break;
+ const int aShapeDim = GetShapeDim( aSubShape );
+ if ( aShapeDim < 1 ) break;
+
+ // check for preview dimension limitations
+ if ( aShapesId && aShapeDim > (int)aDim )
+ continue;
SMESH_Algo* algo = GetAlgo( aMesh, aSubShape );
if ( algo && !algo->NeedDescretBoundary() )
if ( algo->SupportSubmeshes() )
smWithAlgoSupportingSubmeshes.push_back( smToCompute );
else
+ {
smToCompute->ComputeStateEngine( SMESH_subMesh::COMPUTE );
+ if ( aShapesId )
+ aShapesId->insert( smToCompute->GetId() );
+ }
}
}
// ------------------------------------------------------------
SMESH_subMesh* smToCompute = smIt->next();
const TopoDS_Shape& aSubShape = smToCompute->GetSubShape();
- if ( aSubShape.ShapeType() == TopAbs_VERTEX ) continue;
-
+ const int aShapeDim = GetShapeDim( aSubShape );
+ //if ( aSubShape.ShapeType() == TopAbs_VERTEX ) continue;
+ if ( aShapeDim < 1 ) continue;
+
+ // check for preview dimension limitations
+ if ( aShapesId && GetShapeDim( aSubShape.ShapeType() ) > (int)aDim )
+ continue;
+
SMESH_HypoFilter filter( SMESH_HypoFilter::IsAlgo() );
filter
.And( SMESH_HypoFilter::IsApplicableTo( aSubShape ))
if ( SMESH_Algo* subAlgo = (SMESH_Algo*) aMesh.GetHypothesis( aSubShape, filter, true )) {
SMESH_Hypothesis::Hypothesis_Status status;
if ( subAlgo->CheckHypothesis( aMesh, aSubShape, status ))
- // mesh a lower smToCompute
- Compute( aMesh, aSubShape );
+ // mesh a lower smToCompute starting from vertices
+ Compute( aMesh, aSubShape, /*anUpward=*/true, aDim, aShapesId );
}
}
}
// ----------------------------------------------------------
for ( subIt = smWithAlgoSupportingSubmeshes.rbegin(); subIt != subEnd; ++subIt )
if ( sm->GetComputeState() == SMESH_subMesh::READY_TO_COMPUTE)
+ {
+ const TopAbs_ShapeEnum aShType = sm->GetSubShape().ShapeType();
+ // check for preview dimension limitations
+ if ( aShapesId && GetShapeDim( aShType ) > (int)aDim )
+ continue;
+
sm->ComputeStateEngine( SMESH_subMesh::COMPUTE );
+ if ( aShapesId )
+ aShapesId->insert( sm->GetId() );
+ }
// -----------------------------------------------
// mesh the rest subshapes starting from vertices
// -----------------------------------------------
- ret = Compute( aMesh, aShape, /*anUpward=*/true );
+ ret = Compute( aMesh, aShape, /*anUpward=*/true, aDim, aShapesId );
}
MESSAGE( "VSR - SMESH_Gen::Compute() finished, OK = " << ret);
return myStudyContext;
}
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
+// //=============================================================================
+// /*!
+// *
+// */
+// //=============================================================================
-void SMESH_Gen::Save(int studyId, const char *aUrlOfFile)
-{
-}
+// void SMESH_Gen::Save(int studyId, const char *aUrlOfFile)
+// {
+// }
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
+// //=============================================================================
+// /*!
+// *
+// */
+// //=============================================================================
-void SMESH_Gen::Load(int studyId, const char *aUrlOfFile)
-{
-}
+// void SMESH_Gen::Load(int studyId, const char *aUrlOfFile)
+// {
+// }
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
+// //=============================================================================
+// /*!
+// *
+// */
+// //=============================================================================
-void SMESH_Gen::Close(int studyId)
-{
-}
+// void SMESH_Gen::Close(int studyId)
+// {
+// }
//=============================================================================
/*!
if ( dim.empty() )
{
dim.resize( TopAbs_SHAPE, -1 );
- dim[ TopAbs_COMPOUND ] = 3;
- dim[ TopAbs_COMPSOLID ] = 3;
- dim[ TopAbs_SOLID ] = 3;
- dim[ TopAbs_SHELL ] = 3;
- dim[ TopAbs_FACE ] = 2;
- dim[ TopAbs_WIRE ] = 1;
- dim[ TopAbs_EDGE ] = 1;
- dim[ TopAbs_VERTEX ] = 0;
+ dim[ TopAbs_COMPOUND ] = MeshDim_3D;
+ dim[ TopAbs_COMPSOLID ] = MeshDim_3D;
+ dim[ TopAbs_SOLID ] = MeshDim_3D;
+ dim[ TopAbs_SHELL ] = MeshDim_3D;
+ dim[ TopAbs_FACE ] = MeshDim_2D;
+ dim[ TopAbs_WIRE ] = MeshDim_1D;
+ dim[ TopAbs_EDGE ] = MeshDim_1D;
+ dim[ TopAbs_VERTEX ] = MeshDim_0D;
}
return dim[ aShapeType ];
}
// File : SMESH_Gen.hxx
// Author : Paul RASCLE, EDF
// Module : SMESH
-// $Header$
//
+
#ifndef _SMESH_GEN_HXX_
#define _SMESH_GEN_HXX_
#include <TopoDS_Shape.hxx>
#include <map>
+#include <list>
class SMESHDS_Document;
SMESHDS_Document * myDocument;
} StudyContextStruct;
+typedef std::set<int> TSetOfInt;
+
class SMESH_EXPORT SMESH_Gen
{
public:
/*!
* \brief Computes aMesh on aShape
* \param anUpward - compute from vertices up to more complex shape (internal usage)
+ * \param aDim - upper level dimension of the mesh computation
+ * \param aShapesId - list of shapes with computed mesh entities (elements or nodes)
* \retval bool - true if none submesh failed to compute
*/
- bool Compute(::SMESH_Mesh & aMesh,
- const TopoDS_Shape & aShape,
- const bool anUpward=false);
+ bool Compute(::SMESH_Mesh & aMesh,
+ const TopoDS_Shape & aShape,
+ const bool anUpward=false,
+ const ::MeshDimension aDim=::MeshDim_3D,
+ TSetOfInt* aShapesId=0);
bool CheckAlgoState(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape);
// notify on bad state of attached algos, return false
// if Compute() would fail because of some algo bad state
+ /*!
+ * \brief Sets number of segments per diagonal of boundary box of geometry by which
+ * default segment length of appropriate 1D hypotheses is defined
+ */
+ void SetBoundaryBoxSegmentation( int theNbSegments ) { _segmentation = theNbSegments; }
+ int GetBoundaryBoxSegmentation() const { return _segmentation; }
struct TAlgoStateError
{
// inherited methods from SALOMEDS::Driver
- void Save(int studyId, const char *aUrlOfFile);
- void Load(int studyId, const char *aUrlOfFile);
- void Close(int studyId);
- const char *ComponentDataType();
+// void Save(int studyId, const char *aUrlOfFile);
+// void Load(int studyId, const char *aUrlOfFile);
+// void Close(int studyId);
+// const char *ComponentDataType();
- const char *IORToLocalPersistentID(const char *IORString, bool & IsAFile);
- const char *LocalPersistentIDToIOR(const char *aLocalPersistentID);
+// const char *IORToLocalPersistentID(const char *IORString, bool & IsAFile);
+// const char *LocalPersistentIDToIOR(const char *aLocalPersistentID);
int GetANewId();
// hypotheses managing
int _hypId;
+
+ // number of segments per diagonal of boundary box of geometry by which
+ // default segment length of appropriate 1D hypotheses is defined
+ int _segmentation;
};
#endif
// File : SMESH_Hypothesis.hxx
// Author : Paul RASCLE, EDF
// Module : SMESH
-// $Header$
//
+
#ifndef _SMESH_HYPOTHESIS_HXX_
#define _SMESH_HYPOTHESIS_HXX_
class TopoDS_Shape;
class SMESH_Mesh;
+enum MeshDimension // dimension of mesh
+{
+ MeshDim_0D = 0,
+ MeshDim_1D,
+ MeshDim_2D,
+ MeshDim_3D
+};
+
class SMESH_EXPORT SMESH_Hypothesis: public SMESHDS_Hypothesis
{
public:
/*!
* \brief Initialize my parameter values by the mesh built on the geometry
- * \param theMesh - the built mesh
- * \param theShape - the geometry of interest
- * \retval bool - true if parameter values have been successfully defined
+ * \param theMesh - the built mesh
+ * \param theShape - the geometry of interest
+ * \retval bool - true if parameter values have been successfully defined
*/
virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape)=0;
+ /*!
+ * \brief Initialize my parameter values by linear size of mesh element.
+ * \retval bool - true if parameter values have been successfully defined
+ */
+ virtual bool SetParametersByElementSize(double elemLenght, const SMESH_Mesh* theMesh=0)=0;
+
/*!
* \brief Return true if me is an auxiliary hypothesis
* \retval bool - auxiliary or not
// File : SMESH_Mesh.cxx
// Author : Paul RASCLE, EDF
// Module : SMESH
-// $Header$
//
#include "SMESH_Mesh.hxx"
#include "SMESH_subMesh.hxx"
#include "DriverSTL_R_SMDS_Mesh.h"
#undef _Precision_HeaderFile
+#include <BRepBndLib.hxx>
#include <BRepPrimAPI_MakeBox.hxx>
+#include <Bnd_Box.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
_myMeshDS = theDocument->GetMesh(_idDoc);
_isShapeToMesh = false;
_isAutoColor = false;
+ _shapeDiagonal = 0.0;
_myMeshDS->ShapeToMesh( PseudoShape() );
}
// clear SMESHDS
TopoDS_Shape aNullShape;
_myMeshDS->ShapeToMesh( aNullShape );
+
+ _shapeDiagonal = 0.0;
}
// set a new geometry
return aSolid;
}
+//=======================================================================
+/*!
+ * \brief Return diagonal size of bounding box of a shape
+ */
+//=======================================================================
+
+double SMESH_Mesh::GetShapeDiagonalSize(const TopoDS_Shape & aShape)
+{
+ Bnd_Box Box;
+ BRepBndLib::Add(aShape, Box);
+ return sqrt( Box.SquareExtent() );
+}
+
+//=======================================================================
+/*!
+ * \brief Return diagonal size of bounding box of shape to mesh
+ */
+//=======================================================================
+
+double SMESH_Mesh::GetShapeDiagonalSize() const
+{
+ if ( _shapeDiagonal == 0. && _isShapeToMesh )
+ const_cast<SMESH_Mesh*>(this)->_shapeDiagonal = GetShapeDiagonalSize( GetShapeToMesh() );
+
+ return _shapeDiagonal;
+}
+
//=======================================================================
/*!
* \brief Remove all nodes and elements
// }
}
+//=======================================================================
+/*!
+ * \brief Remove all nodes and elements of indicated shape
+ */
+//=======================================================================
+
+void SMESH_Mesh::ClearSubMesh(const int theShapeId)
+{
+ // clear sub-meshes; get ready to re-compute as a side-effect
+ if ( SMESH_subMesh *sm = GetSubMeshContaining( theShapeId ) )
+ {
+ SMESH_subMeshIteratorPtr smIt = sm->getDependsOnIterator(/*includeSelf=*/true,
+ /*complexShapeFirst=*/false);
+ while ( smIt->more() )
+ {
+ sm = smIt->next();
+ TopAbs_ShapeEnum shapeType = sm->GetSubShape().ShapeType();
+ if ( shapeType == TopAbs_VERTEX || shapeType < TopAbs_SOLID )
+ // all other shapes depends on vertices so they are already cleaned
+ sm->ComputeStateEngine( SMESH_subMesh::CLEAN );
+ // to recompute even if failed
+ sm->ComputeStateEngine( SMESH_subMesh::CHECK_COMPUTE_STATE );
+ }
+ }
+}
+
//=======================================================================
//function : UNVToMesh
//purpose :
{
return _myMeshDS->GetElementType( id, iselem );
}
+
+//=============================================================================
+/*!
+ * \brief Convert group on geometry into standalone group
+ */
+//=============================================================================
+
+SMESH_Group* SMESH_Mesh::ConvertToStandalone ( int theGroupID )
+{
+ SMESH_Group* aGroup = 0;
+ std::map < int, SMESH_Group * >::iterator itg = _mapGroup.find( theGroupID );
+ if ( itg == _mapGroup.end() )
+ return aGroup;
+
+ SMESH_Group* anOldGrp = (*itg).second;
+ SMESHDS_GroupBase* anOldGrpDS = anOldGrp->GetGroupDS();
+ if ( !anOldGrp || !anOldGrpDS )
+ return aGroup;
+
+ // create new standalone group
+ aGroup = new SMESH_Group (theGroupID, this, anOldGrpDS->GetType(), anOldGrp->GetName() );
+ _mapGroup[theGroupID] = aGroup;
+
+ SMESHDS_Group* aNewGrpDS = dynamic_cast<SMESHDS_Group*>( aGroup->GetGroupDS() );
+ GetMeshDS()->RemoveGroup( anOldGrpDS );
+ GetMeshDS()->AddGroup( aNewGrpDS );
+
+ // add elements (or nodes) into new created group
+ SMDS_ElemIteratorPtr anItr = anOldGrpDS->GetElements();
+ while ( anItr->more() )
+ aNewGrpDS->Add( (anItr->next())->GetID() );
+
+ // remove old group
+ delete anOldGrp;
+
+ return aGroup;
+}
+
// File : SMESH_Mesh.hxx
// Author : Paul RASCLE, EDF
// Module : SMESH
-// $Header$
//
#ifndef _SMESH_MESH_HXX_
#define _SMESH_MESH_HXX_
* \brief Return true if there is a geometry to be meshed, not PseudoShape()
*/
bool HasShapeToMesh() const { return _isShapeToMesh; }
+ /*!
+ * \brief Return diagonal size of bounding box of shape to mesh.
+ */
+ double GetShapeDiagonalSize() const;
+ /*!
+ * \brief Return diagonal size of bounding box of a shape.
+ */
+ static double GetShapeDiagonalSize(const TopoDS_Shape & aShape);
/*!
* \brief Return a solid which is returned by GetShapeToMesh() if
* a real geometry to be meshed was not set
*/
void Clear();
+ /*!
+ * \brief Remove all nodes and elements of indicated shape
+ */
+ void ClearSubMesh(const int theShapeId);
+
int UNVToMesh(const char* theFileName);
/*!
* consult DriverMED_R_SMESHDS_Mesh::ReadStatus for returned value
void RemoveGroup (const int theGroupID);
+ SMESH_Group* ConvertToStandalone ( int theGroupID );
SMDSAbs_ElementType GetElementType( const int id, const bool iselem );
SMESH_Gen * _gen;
bool _isAutoColor;
+
+ double _shapeDiagonal; //!< diagonal size of bounding box of shape to mesh
TopTools_IndexedDataMapOfShapeListOfShape _mapAncestors;
TNodeXYZ( const SMDS_MeshNode* n ):gp_XYZ( n->X(), n->Y(), n->Z() ) {}
};
-typedef pair< const SMDS_MeshNode*, const SMDS_MeshNode* > NLink;
-
-//=======================================================================
-/*!
- * \brief A sorted pair of nodes
- */
-//=======================================================================
-
-struct TLink: public NLink
-{
- TLink(const SMDS_MeshNode* n1, const SMDS_MeshNode* n2 ):NLink( n1, n2 )
- { if ( n1->GetID() < n2->GetID() ) std::swap( first, second ); }
- TLink(const NLink& link ):NLink( link )
- { if ( first->GetID() < second->GetID() ) std::swap( first, second ); }
-};
-
//=======================================================================
//function : SMESH_MeshEditor
//purpose :
// 1. map of elements with their linkIDs
// 2. map of linkIDs with their elements
- map< TLink, list< const SMDS_MeshElement* > > mapLi_listEl;
- map< TLink, list< const SMDS_MeshElement* > >::iterator itLE;
- map< const SMDS_MeshElement*, set< TLink > > mapEl_setLi;
- map< const SMDS_MeshElement*, set< TLink > >::iterator itEL;
+ map< SMESH_TLink, list< const SMDS_MeshElement* > > mapLi_listEl;
+ map< SMESH_TLink, list< const SMDS_MeshElement* > >::iterator itLE;
+ map< const SMDS_MeshElement*, set< SMESH_TLink > > mapEl_setLi;
+ map< const SMDS_MeshElement*, set< SMESH_TLink > >::iterator itEL;
TIDSortedElemSet::iterator itElem;
for ( itElem = theElems.begin(); itElem != theElems.end(); itElem++ ) {
// fill maps
for ( i = 0; i < 3; i++ ) {
- TLink link( aNodes[i], aNodes[i+1] );
+ SMESH_TLink link( aNodes[i], aNodes[i+1] );
// check if elements sharing a link can be fused
itLE = mapLi_listEl.find( link );
if ( itLE != mapLi_listEl.end() ) {
int nbElems = (*itLE).second.size();
if ( nbElems < 2 ) {
const SMDS_MeshElement* elem = (*itLE).second.front();
- TLink link = (*itLE).first;
+ SMESH_TLink link = (*itLE).first;
mapEl_setLi[ elem ].erase( link );
if ( mapEl_setLi[ elem ].empty() )
mapEl_setLi.erase( elem );
// search elements to fuse starting from startElem or links of elements
// fused earlyer - startLinks
- list< TLink > startLinks;
+ list< SMESH_TLink > startLinks;
while ( startElem || !startLinks.empty() ) {
while ( !startElem && !startLinks.empty() ) {
// Get an element to start, by a link
- TLink linkId = startLinks.front();
+ SMESH_TLink linkId = startLinks.front();
startLinks.pop_front();
itLE = mapLi_listEl.find( linkId );
if ( itLE != mapLi_listEl.end() ) {
if ( startElem ) {
// Get candidates to be fused
const SMDS_MeshElement *tr1 = startElem, *tr2 = 0, *tr3 = 0;
- const TLink *link12, *link13;
+ const SMESH_TLink *link12, *link13;
startElem = 0;
ASSERT( mapEl_setLi.find( tr1 ) != mapEl_setLi.end() );
- set< TLink >& setLi = mapEl_setLi[ tr1 ];
+ set< SMESH_TLink >& setLi = mapEl_setLi[ tr1 ];
ASSERT( !setLi.empty() );
- set< TLink >::iterator itLi;
+ set< SMESH_TLink >::iterator itLi;
for ( itLi = setLi.begin(); itLi != setLi.end(); itLi++ )
{
- const TLink & link = (*itLi);
+ const SMESH_TLink & link = (*itLi);
itLE = mapLi_listEl.find( link );
if ( itLE == mapLi_listEl.end() )
continue;
}
// add other links of elem to list of links to re-start from
- set< TLink >& links = mapEl_setLi[ elem ];
- set< TLink >::iterator it;
+ set< SMESH_TLink >& links = mapEl_setLi[ elem ];
+ set< SMESH_TLink >::iterator it;
for ( it = links.begin(); it != links.end(); it++ ) {
- const TLink& link2 = (*it);
+ const SMESH_TLink& link2 = (*it);
if ( link2 != link )
startLinks.push_back( link2 );
}
// fix nodes on mesh boundary
if ( checkBoundaryNodes ) {
- typedef pair<const SMDS_MeshNode*, const SMDS_MeshNode*> TLink;
- map< TLink, int > linkNbMap; // how many times a link encounters in elemsOnFace
- map< TLink, int >::iterator link_nb;
+ map< NLink, int > linkNbMap; // how many times a link encounters in elemsOnFace
+ map< NLink, int >::iterator link_nb;
// put all elements links to linkNbMap
list< const SMDS_MeshElement* >::iterator elemIt = elemsOnFace.begin();
for ( ; elemIt != elemsOnFace.end(); ++elemIt ) {
const SMDS_MeshNode* curNode, *prevNode = elem->GetNode( nbn );
for ( int iN = 0; iN < nbn; ++iN ) {
curNode = elem->GetNode( iN );
- TLink link;
+ NLink link;
if ( curNode < prevNode ) link = make_pair( curNode , prevNode );
else link = make_pair( prevNode , curNode );
prevNode = curNode;
if ( theSecondNode1 != theSecondNode2 )
nReplaceMap.insert( make_pair( theSecondNode1, theSecondNode2 ));
- set< TLink > linkSet; // set of nodes where order of nodes is ignored
- linkSet.insert( TLink( theFirstNode1, theSecondNode1 ));
+ set< SMESH_TLink > linkSet; // set of nodes where order of nodes is ignored
+ linkSet.insert( SMESH_TLink( theFirstNode1, theSecondNode1 ));
list< NLink > linkList[2];
linkList[0].push_back( NLink( theFirstNode1, theSecondNode1 ));
for ( int i = 0; i < nbN; i++ )
{
const SMDS_MeshNode* n2 = f0->GetNode( i );
- pair< set< TLink >::iterator, bool > iter_isnew =
- linkSet.insert( TLink( n1, n2 ));
+ pair< set< SMESH_TLink >::iterator, bool > iter_isnew =
+ linkSet.insert( SMESH_TLink( n1, n2 ));
if ( !iter_isnew.second ) { // already in a set: no need to process
linkSet.erase( iter_isnew.first );
}
return SEW_OK;
}
+
+/*!
+ \brief Creates a hole in a mesh by doubling the nodes of some particular elements
+ \param theNodes - identifiers of nodes to be doubled
+ \param theModifiedElems - identifiers of elements to be updated by the new (doubled)
+ nodes. If list of element identifiers is empty then nodes are doubled but
+ they not assigned to elements
+ \return TRUE if operation has been completed successfully, FALSE otherwise
+*/
+bool SMESH_MeshEditor::DoubleNodes( const std::list< int >& theListOfNodes,
+ const std::list< int >& theListOfModifiedElems )
+{
+ myLastCreatedElems.Clear();
+ myLastCreatedNodes.Clear();
+
+ if ( theListOfNodes.size() == 0 )
+ return false;
+
+ SMESHDS_Mesh* aMeshDS = GetMeshDS();
+ if ( !aMeshDS )
+ return false;
+
+ // iterate through nodes and duplicate them
+
+ std::map< const SMDS_MeshNode*, const SMDS_MeshNode* > anOldNodeToNewNode;
+
+ std::list< int >::const_iterator aNodeIter;
+ for ( aNodeIter = theListOfNodes.begin(); aNodeIter != theListOfNodes.end(); ++aNodeIter )
+ {
+ int aCurr = *aNodeIter;
+ SMDS_MeshNode* aNode = (SMDS_MeshNode*)aMeshDS->FindNode( aCurr );
+ if ( !aNode )
+ continue;
+
+ // duplicate node
+
+ const SMDS_MeshNode* aNewNode = aMeshDS->AddNode( aNode->X(), aNode->Y(), aNode->Z() );
+ if ( aNewNode )
+ {
+ anOldNodeToNewNode[ aNode ] = aNewNode;
+ myLastCreatedNodes.Append( aNewNode );
+ }
+ }
+
+ // Create map of new nodes for modified elements
+
+ std::map< SMDS_MeshElement*, vector<const SMDS_MeshNode*> > anElemToNodes;
+
+ std::list< int >::const_iterator anElemIter;
+ for ( anElemIter = theListOfModifiedElems.begin();
+ anElemIter != theListOfModifiedElems.end(); ++anElemIter )
+ {
+ int aCurr = *anElemIter;
+ SMDS_MeshElement* anElem = (SMDS_MeshElement*)aMeshDS->FindElement( aCurr );
+ if ( !anElem )
+ continue;
+
+ vector<const SMDS_MeshNode*> aNodeArr( anElem->NbNodes() );
+
+ SMDS_ElemIteratorPtr anIter = anElem->nodesIterator();
+ int ind = 0;
+ while ( anIter->more() )
+ {
+ SMDS_MeshNode* aCurrNode = (SMDS_MeshNode*)anIter->next();
+ if ( aCurr && anOldNodeToNewNode.find( aCurrNode ) != anOldNodeToNewNode.end() )
+ {
+ const SMDS_MeshNode* aNewNode = anOldNodeToNewNode[ aCurrNode ];
+ aNodeArr[ ind++ ] = aNewNode;
+ }
+ else
+ aNodeArr[ ind++ ] = aCurrNode;
+ }
+ anElemToNodes[ anElem ] = aNodeArr;
+ }
+
+ // Change nodes of elements
+
+ std::map< SMDS_MeshElement*, vector<const SMDS_MeshNode*> >::iterator
+ anElemToNodesIter = anElemToNodes.begin();
+ for ( ; anElemToNodesIter != anElemToNodes.end(); ++anElemToNodesIter )
+ {
+ const SMDS_MeshElement* anElem = anElemToNodesIter->first;
+ vector<const SMDS_MeshNode*> aNodeArr = anElemToNodesIter->second;
+ if ( anElem )
+ aMeshDS->ChangeElementNodes( anElem, &aNodeArr[ 0 ], anElem->NbNodes() );
+ }
+
+ return true;
+}
std::list<const SMDS_MeshElement*> > TElemOfElemListMap;
typedef std::map<const SMDS_MeshNode*, const SMDS_MeshNode*> TNodeNodeMap;
+
+typedef pair< const SMDS_MeshNode*, const SMDS_MeshNode* > NLink;
+
+//=======================================================================
+/*!
+ * \brief A sorted pair of nodes
+ */
+//=======================================================================
+
+struct SMESH_TLink: public NLink
+{
+ SMESH_TLink(const SMDS_MeshNode* n1, const SMDS_MeshNode* n2 ):NLink( n1, n2 )
+ { if ( n1->GetID() < n2->GetID() ) std::swap( first, second ); }
+ SMESH_TLink(const NLink& link ):NLink( link )
+ { if ( first->GetID() < second->GetID() ) std::swap( first, second ); }
+};
+
+
class SMDS_MeshFace;
class SMDS_MeshNode;
class gp_Ax1;
const SMESH_SequenceOfElemPtr& GetLastCreatedNodes() const { return myLastCreatedNodes; }
const SMESH_SequenceOfElemPtr& GetLastCreatedElems() const { return myLastCreatedElems; }
+
+ bool DoubleNodes( const std::list< int >& theListOfNodes,
+ const std::list< int >& theListOfModifiedElems );
private:
aTitle = QObject::tr( "MULTI_BORDERS" );
aControl = SMESH_Actor::eMultiConnection;
break;
+ case 6005:
+ aTitle = QObject::tr( "FREE_NODES" );
+ aControl = SMESH_Actor::eFreeNodes;
+ break;
case 6019:
aTitle = QObject::tr( "MULTI2D_BORDERS" );
aControl = SMESH_Actor::eMultiConnection2D;
aTitle = QObject::tr( "SMESH_VOLUME" );
aControl = SMESH_Actor::eVolume3D;
break;
+ case 6021:
+ aTitle = QObject::tr( "FREE_FACES" );
+ aControl = SMESH_Actor::eFreeFaces;
+ break;
}
anActor->SetControlMode(aControl);
anActor->GetScalarBarActor()->SetTitle(aTitle.toLatin1().data());
{
CORBA::Boolean anIsEmbeddedMode;
myComponentSMESH = SMESH_Client::GetSMESHGen(getApp()->orb(),anIsEmbeddedMode);
+
+ // 0019923: EDF 765 SMESH : default values of hypothesis
+ SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
+ int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation" );
+ myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
}
myActiveDialogBox = 0;
}
case 701: // COMPUTE MESH
+ case 711: // PRECOMPUTE MESH
{
if (checkLock(aStudy)) break;
-
- startOperation( 701 );
+ startOperation( theCommandID );
}
break;
- case 702: // Create mesh
- startOperation( 702 );
- break;
- case 703: // Create sub-mesh
- startOperation( 703 );
- break;
+ case 702: // Create mesh
+ case 703: // Create sub-mesh
case 704: // Edit mesh/sub-mesh
- startOperation( 704 );
+ startOperation( theCommandID );
break;
case 710: // Build compound mesh
{
break;
}
+ case 815: // Edit GEOM GROUP as standalone
+ {
+ if ( !vtkwnd )
+ {
+ SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
+ tr( "NOT_A_VTK_VIEWER" ) );
+ break;
+ }
+
+ if(checkLock(aStudy)) break;
+ EmitSignalDeactivateDialog();
+
+ LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
+ SALOME_ListIO selected;
+ if( aSel )
+ aSel->selectedObjects( selected );
+
+ SALOME_ListIteratorOfListIO It (selected);
+ for ( ; It.More(); It.Next() )
+ {
+ SMESH::SMESH_GroupOnGeom_var aGroup =
+ SMESH::IObjectToInterface<SMESH::SMESH_GroupOnGeom>(It.Value());
+ if (!aGroup->_is_nil()) {
+ SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg( this, aGroup, true );
+ aDlg->show();
+ }
+ }
+ break;
+ }
+
case 810: // Union Groups
case 811: // Intersect groups
case 812: // Cut groups
EmitSignalDeactivateDialog();
- int aMode;
- if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
- else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
- else aMode = SMESHGUI_GroupOpDlg::CUT;
+ SMESHGUI_GroupOpDlg* aDlg = 0;
+ if ( theCommandID == 810 )
+ aDlg = new SMESHGUI_UnionGroupsDlg( this );
+ else if ( theCommandID == 811 )
+ aDlg = new SMESHGUI_IntersectGroupsDlg( this );
+ else
+ aDlg = new SMESHGUI_CutGroupsDlg( this );
+
+ aDlg->show();
+
+ break;
+ }
+
+ case 814: // Create groups of entities from existing groups of superior dimensions
+ {
+ if ( checkLock( aStudy ) )
+ break;
+
+ EmitSignalDeactivateDialog();
+ SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
+ aDlg->show();
- ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show();
break;
}
if( aSel )
aSel->selectedObjects( selected );
- bool isAny = false; // iss there any appropriate object selected
+ bool isAny = false; // is there any appropriate object selected
SALOME_ListIteratorOfListIO It( selected );
for ( ; It.More(); It.Next() )
newName = LightApp_NameDlg::getName(desktop(), newName);
if ( !newName.isEmpty() )
{
- //old source: aStudy->renameIObject( IObject, newName );
- aName->SetValue( newName.toLatin1().constData() );
-
- // if current object is group update group's name
- SMESH::SMESH_GroupBase_var aGroup =
- SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
- if (!aGroup->_is_nil() )
- aGroup->SetName( newName.toLatin1().constData() );
+ SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), newName.toLatin1().data());
updateObjBrowser();
}
case 6002:
case 6003:
case 6004:
+ case 6005:
case 6009:
+ case 6021:
if ( vtkwnd ) {
LightApp_SelectionMgr* mgr = selectionMgr();
createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" );
createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" );
createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" );
+ createSMESHAction( 711, "PRECOMPUTE", "ICON_PRECOMPUTE" );
createSMESHAction( 806, "CREATE_GEO_GROUP","ICON_CREATE_GEO_GROUP" );
createSMESHAction( 801, "CREATE_GROUP", "ICON_CREATE_GROUP" );
createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" );
createSMESHAction( 803, "EDIT_GROUP", "ICON_EDIT_GROUP" );
+ createSMESHAction( 815, "EDIT_GEOMGROUP_AS_GROUP", "ICON_EDIT_GROUP" );
createSMESHAction( 804, "ADD" );
createSMESHAction( 805, "REMOVE" );
createSMESHAction( 810, "UN_GROUP", "ICON_UNION" );
createSMESHAction( 811, "INT_GROUP", "ICON_INTERSECT" );
createSMESHAction( 812, "CUT_GROUP", "ICON_CUT" );
+ createSMESHAction( 814, "UNDERLYING_ELEMS","ICON_UNDERLYING_ELEMS" );
createSMESHAction( 813, "DEL_GROUP", "ICON_DEL_GROUP" );
createSMESHAction( 900, "ADV_INFO", "ICON_ADV_INFO" );
createSMESHAction( 902, "STD_INFO", "ICON_STD_INFO" );
createSMESHAction( 903, "WHAT_IS", "ICON_WHAT_IS" );
createSMESHAction( 6001, "LENGTH", "ICON_LENGTH", 0, true );
createSMESHAction( 6002, "FREE_EDGE", "ICON_FREE_EDGE", 0, true );
+ createSMESHAction( 6021, "FREE_FACES", "ICON_FREE_FACES", 0, true );
createSMESHAction( 6003, "FREE_BORDER", "ICON_FREE_EDGE_2D", 0, true );
createSMESHAction( 6004, "CONNECTION", "ICON_CONNECTION", 0, true );
+ createSMESHAction( 6005, "FREE_NODE", "ICON_FREE_NODE", 0, true );
createSMESHAction( 6011, "AREA", "ICON_AREA", 0, true );
createSMESHAction( 6012, "TAPER", "ICON_TAPER", 0, true );
createSMESHAction( 6013, "ASPECT", "ICON_ASPECT", 0, true );
createMenu( 710, meshId, -1 );
createMenu( separator(), meshId, -1 );
createMenu( 701, meshId, -1 );
+ createMenu( 711, meshId, -1 );
createMenu( separator(), meshId, -1 );
createMenu( 801, meshId, -1 );
createMenu( 806, meshId, -1 );
createMenu( 802, meshId, -1 );
createMenu( 803, meshId, -1 );
+ createMenu( 815, meshId, -1 );
createMenu( separator(), meshId, -1 );
createMenu( 810, meshId, -1 );
createMenu( 811, meshId, -1 );
createMenu( 812, meshId, -1 );
createMenu( separator(), meshId, -1 );
+ createMenu( 814, meshId, -1 );
+ createMenu( separator(), meshId, -1 );
createMenu( 813, meshId, -1 );
createMenu( separator(), meshId, -1 );
createMenu( 900, meshId, -1 );
createMenu( 6001, ctrlId, -1 );
createMenu( 6004, ctrlId, -1 );
createMenu( separator(), ctrlId, -1 );
+ createMenu( 6005, ctrlId, -1 );
createMenu( 6002, ctrlId, -1 );
createMenu( 6018, ctrlId, -1 );
createMenu( 6019, ctrlId, -1 );
createMenu( separator(), ctrlId, -1 );
createMenu( 6017, ctrlId, -1 );
createMenu( 6009, ctrlId, -1 );
+ createMenu( 6021, ctrlId, -1 );
createMenu( separator(), ctrlId, -1 );
createMenu( 400, addId, -1 );
createTool( 710, meshTb );
createTool( separator(), meshTb );
createTool( 701, meshTb );
+ createTool( 711, meshTb );
createTool( separator(), meshTb );
createTool( 801, meshTb );
createTool( 806, meshTb );
createTool( 802, meshTb );
createTool( 803, meshTb );
+ //createTool( 815, meshTb );
createTool( separator(), meshTb );
createTool( 900, meshTb );
createTool( 902, meshTb );
createTool( 6003, ctrlTb );
createTool( 6004, ctrlTb );
createTool( separator(), ctrlTb );
+ createTool( 6005, ctrlTb );
createTool( 6002, ctrlTb );
createTool( 6018, ctrlTb );
createTool( 6019, ctrlTb );
createTool( separator(), ctrlTb );
createTool( 6017, ctrlTb );
createTool( 6009, ctrlTb );
+ createTool( 6021, ctrlTb );
createTool( separator(), ctrlTb );
createTool( 400, addRemTb );
createPopupItem( 150, OB, mesh, "&& selcount=1 && isImported" ); // FILE INFORMATION
createPopupItem( 703, OB, mesh, "&& isComputable"); // CREATE_SUBMESH
- createPopupItem( 703, OB, subMesh, "&& isComputable" ); // CREATE_SUBMESH
+ //createPopupItem( 703, OB, subMesh, "&& isComputable" ); // CREATE_SUBMESH
createPopupItem( 704, OB, mesh, "&& isComputable"); // EDIT_MESHSUBMESH
createPopupItem( 704, OB, subMesh, "&& isComputable" ); // EDIT_MESHSUBMESH
createPopupItem( 803, OB, group ); // EDIT_GROUP
+ createPopupItem( 815, OB, group, "&& groupType = 'GroupOnGeom'" ); // EDIT_GROUP
+
popupMgr()->insert( separator(), -1, 0 );
createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE
+ createPopupItem( 711, OB, mesh, "&& isComputable" ); // PRECOMPUTE
createPopupItem( 214, OB, mesh_group ); // UPDATE
createPopupItem( 900, OB, mesh_group ); // ADV_INFO
createPopupItem( 902, OB, mesh ); // STD_INFO
createPopupItem( 803, View, group ); // EDIT_GROUP
createPopupItem( 804, View, elems ); // ADD
createPopupItem( 805, View, elems ); // REMOVE
+
popupMgr()->insert( separator(), -1, 0 );
createPopupItem( 214, View, mesh_group ); // UPDATE
createPopupItem( 900, View, mesh_group ); // ADV_INFO
// Controls
//-------------------------------------------------
QString
+ aMeshInVtkHasNodes = aMeshInVTK + "&&" + hasNodes,
aMeshInVtkHasEdges = aMeshInVTK + "&&" + hasEdges,
aMeshInVtkHasFaces = aMeshInVTK + "&&" + hasFaces,
aMeshInVtkHasVolumes = aMeshInVTK + "&&" + hasVolumes;
popupMgr()->insert( separator(), anId, -1 );
+ popupMgr()->insert( action( 6005 ), anId, -1 ); // FREE_NODE
+ popupMgr()->setRule( action( 6005 ), aMeshInVtkHasNodes, QtxPopupMgr::VisibleRule );
+ popupMgr()->setRule( action( 6005 ), "controlMode = 'eFreeNodes'", QtxPopupMgr::ToggleRule );
+
popupMgr()->insert( action( 6002 ), anId, -1 ); // FREE_EDGE
- popupMgr()->setRule( action( 6002 ), aMeshInVtkHasFaces, QtxPopupMgr::VisibleRule );
+ popupMgr()->setRule( action( 6002 ), aMeshInVtkHasEdges, QtxPopupMgr::VisibleRule );
popupMgr()->setRule( action( 6002 ), "controlMode = 'eFreeEdges'", QtxPopupMgr::ToggleRule );
popupMgr()->insert( action( 6018 ), anId, -1 ); // LENGTH_2D
popupMgr()->setRule( action( 6009 ), aMeshInVtkHasVolumes, QtxPopupMgr::VisibleRule );
popupMgr()->setRule( action( 6009 ), "controlMode = 'eVolume3D'", QtxPopupMgr::ToggleRule );
+ popupMgr()->insert( action( 6021 ), anId, -1 ); // FREE_FACE
+ popupMgr()->setRule( action( 6021 ), aMeshInVtkHasFaces /*aMeshInVtkHasVolumes*/,
+ QtxPopupMgr::VisibleRule );
+ popupMgr()->setRule( action( 6021 ), "controlMode = 'eFreeFaces'", QtxPopupMgr::ToggleRule );
+
popupMgr()->insert( separator(), anId, -1 );
popupMgr()->insert( action( 201 ), anId, -1 ); // SCALAR_BAR_PROP
void SMESHGUI::createPreferences()
{
+ // General tab ------------------------------------------------------------------------
int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
int updateGroup = addPreference( tr( "PREF_GROUP_UPDATE" ), genTab );
setPreferenceProperty( notifyMode, "strings", modes );
setPreferenceProperty( notifyMode, "indexes", indices );
+ int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
+ setPreferenceProperty( segGroup, "columns", 2 );
+ int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
+ "SMESH", "segmentation" );
+ setPreferenceProperty( segLen, "min", 1 );
+ setPreferenceProperty( segLen, "max", 10000000 );
+
+ // Mesh tab ------------------------------------------------------------------------
int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
setPreferenceProperty( nodeGroup, "columns", 2 );
addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
+ // Selection tab ------------------------------------------------------------------------
int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
+ // Scalar Bar tab ------------------------------------------------------------------------
int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
setPreferenceProperty( fontGr, "columns", 2 );
- int tfont = addPreference( tr( "SMESH_TITLE" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_title_font" );
+ addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
- int lfont = addPreference( tr( "SMESH_LABELS" ), fontGr, LightApp_Preferences::Font, "SMESH", "scalar_bar_label_font" );
- addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
-
- QStringList fam;
- fam.append( tr( "SMESH_FONT_ARIAL" ) );
- fam.append( tr( "SMESH_FONT_COURIER" ) );
- fam.append( tr( "SMESH_FONT_TIMES" ) );
- int wflag = ( QtxFontEdit::Family | QtxFontEdit::Scripting );
- setPreferenceProperty( tfont, "families", fam );
- setPreferenceProperty( tfont, "system", false );
- setPreferenceProperty( tfont, "widget_flags", wflag );
- setPreferenceProperty( lfont, "families", fam );
- setPreferenceProperty( lfont, "system", false );
- setPreferenceProperty( lfont, "widget_flags", wflag );
+ addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
+ addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
setPreferenceProperty( colorsLabelsGr, "columns", 2 );
void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
{
- if( sect=="SMESH" ){
+ if( sect=="SMESH" ) {
float sbX1,sbY1,sbW,sbH;
float aTol = 1.00000009999999;
std::string aWarning;
if(sbX1+sbW > aTol){
aWarning = "Origin and Size Vertical: X+Width > 1\n";
sbX1=0.01;
- sbW=0.05;
+ sbW=0.08;
aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
}
sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
if(sbX1+sbW > aTol){
aWarning = "Origin and Size Horizontal: X+Width > 1\n";
- sbX1=0.01;
- sbW=0.05;
+ sbX1=0.1;
+ sbW=0.08;
aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
}
if(sbY1+sbH > aTol){
aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
sbY1=0.01;
- sbH=0.05;
+ sbH=0.08;
aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
}
}
+ else if ( name == "segmentation" ) {
+ int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation" );
+ myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
+ }
if(aWarning.size() != 0){
aWarning += "The default values are applied instead.";
case 704: // Edit mesh/sub-mesh
op = new SMESHGUI_MeshOp( false );
break;
+ case 711: // Precompute mesh
+ op = new SMESHGUI_PrecomputeOp();
+ break;
case 806: // Create group on geom
op = new SMESHGUI_GroupOnShapeOp();
break;
}
}
}
+
+/*!
+ \brief Adds preferences for dfont of VTK viewer
+ \param label label
+ \param pIf group identifier
+ \param param parameter
+ \return identifier of preferences
+*/
+int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param )
+{
+ int tfont = addPreference( label, pId, LightApp_Preferences::Font, "VISU", param );
+
+ setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
+
+ QStringList fam;
+ fam.append( tr( "SMESH_FONT_ARIAL" ) );
+ fam.append( tr( "SMESH_FONT_COURIER" ) );
+ fam.append( tr( "SMESH_FONT_TIMES" ) );
+
+ setPreferenceProperty( tfont, "fonts", fam );
+
+ int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
+ setPreferenceProperty( tfont, "features", f );
+
+ return tfont;
+}
+
+
+
+
+
+
private:
void OnEditDelete();
+ int addVtkFontPref( const QString& label,
+ const int pId,
+ const QString& param );
private :
static SMESH::SMESH_Gen_var myComponentSMESH;
#include <SUIT_OverrideCursor.h>
#include <SUIT_MessageBox.h>
#include <SUIT_Desktop.h>
+#include <QtxComboBox.h>
// SALOME KERNEL includes
+#include <SALOMEDS_SObject.hxx>
#include <SALOMEDSClient_SObject.hxx>
// OCCT includes
// VTK includes
#include <vtkProperty.h>
-// IDL includes
-#include <SALOMEconfig.h>
-#include CORBA_SERVER_HEADER(SMESH_Gen)
-
// STL includes
#include <vector>
#include <set>
*/
//=======================================================================
-SMESHGUI_ComputeDlg::SMESHGUI_ComputeDlg(): SMESHGUI_Dialog( 0, false, true, Close/* | Help*/ )
+SMESHGUI_ComputeDlg::SMESHGUI_ComputeDlg( QWidget* parent )
+ : SMESHGUI_Dialog( parent, false, true, Close/* | Help*/ )
{
QVBoxLayout* aDlgLay = new QVBoxLayout (mainFrame());
aDlgLay->setMargin( 0 );
aDlgLay->setStretchFactor(aMainFrame, 1);
}
+// =========================================================================================
+/*!
+ * \brief Destructor
+ */
+//=======================================================================
+
+SMESHGUI_ComputeDlg::~SMESHGUI_ComputeDlg()
+{
+}
+
//=======================================================================
// function : createMainFrame()
// purpose : Create frame containing dialog's fields
*/
//================================================================================
-SMESHGUI_ComputeOp::SMESHGUI_ComputeOp()
+SMESHGUI_BaseComputeOp::SMESHGUI_BaseComputeOp()
+ : SMESHGUI_Operation(),
+ myCompDlg( 0 )
{
- myDlg = new SMESHGUI_ComputeDlg;
myTShapeDisplayer = new SMESH::TShapeDisplayer();
myBadMeshDisplayer = 0;
//myHelpFileName = "/files/about_meshes.htm"; // V3
myHelpFileName = "about_meshes_page.html"; // V4
-
- // connect signals and slots
- connect(myDlg->myShowBtn, SIGNAL (clicked()), SLOT(onPreviewShape()));
- connect(myDlg->myPublishBtn, SIGNAL (clicked()), SLOT(onPublishShape()));
- connect(myDlg->myBadMeshBtn, SIGNAL (clicked()), SLOT(onShowBadMesh()));
- connect(table(), SIGNAL(itemSelectionChanged()), SLOT(currentCellChanged()));
- connect(table(), SIGNAL(currentCellChanged(int,int,int,int)), SLOT(currentCellChanged()));
}
-//=======================================================================
-// function : startOperation()
-// purpose : Init dialog fields, connect signals and slots, show dialog
-//=======================================================================
+//================================================================================
+/*!
+ * \brief Start operation
+ * \purpose Init dialog fields, connect signals and slots, show dialog
+ */
+//================================================================================
-void SMESHGUI_ComputeOp::startOperation()
+void SMESHGUI_BaseComputeOp::startOperation()
{
- SMESHGUI_Operation::startOperation();
-
- // check selection
+ // create compute dialog if not created before
+ computeDlg();
myMesh = SMESH::SMESH_Mesh::_nil();
myMainShape = GEOM::GEOM_Object::_nil();
+ // check selection
LightApp_SelectionMgr *Sel = selectionMgr();
SALOME_ListIO selected; Sel->selectedObjects( selected );
return;
}
- Handle(SALOME_InteractiveObject) IObject = selected.First();
- myMesh = SMESH::GetMeshByIO(IObject);
+ myIObject = selected.First();
+ myMesh = SMESH::GetMeshByIO(myIObject);
if (myMesh->_is_nil()) {
SUIT_MessageBox::warning(desktop(),
tr("SMESH_WRN_WARNING"),
tr("SMESH_WRN_NO_AVAILABLE_DATA"));
onCancel();
- return;
+
}
+ myMainShape = myMesh->GetShapeToMesh();
+ SMESHGUI_Operation::startOperation();
+}
+
+//================================================================================
+/*!
+ * \brief computeMesh()
+*/
+//================================================================================
+
+void SMESHGUI_BaseComputeOp::computeMesh()
+{
// COMPUTE MESH
SMESH::MemoryReserve aMemoryReserve;
bool computeFailed = true, memoryLack = false;
_PTR(SObject) aMeshSObj = SMESH::FindSObject(myMesh);
- myMainShape = myMesh->GetShapeToMesh();
bool hasShape = myMesh->HasShapeToMesh();
bool shapeOK = myMainShape->_is_nil() ? !hasShape : hasShape;
if ( shapeOK && aMeshSObj )
{
- myDlg->myMeshName->setText( aMeshSObj->GetName().c_str() );
+ myCompDlg->myMeshName->setText( aMeshSObj->GetName().c_str() );
SMESH::SMESH_Gen_var gen = getSMESHGUI()->GetSMESHGen();
SMESH::algo_error_array_var errors = gen->GetAlgoState(myMesh,myMainShape);
if ( errors->length() > 0 ) {
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
OCC_CATCH_SIGNALS;
#endif
- SMESH::Update(IObject, true);
+ SMESH::Update(myIObject, true);
}
catch (...) {
#ifdef _DEBUG_
}
}
}
- Sel->setSelectedObjects( selected );
+ LightApp_SelectionMgr *Sel = selectionMgr();
+ if ( Sel )
+ {
+ SALOME_ListIO selected;
+ selected.Append( myIObject );
+ Sel->setSelectedObjects( selected );
+ }
}
}
if ( memoryLack )
aMemoryReserve.release();
- myDlg->setWindowTitle(tr( computeFailed ? "SMESH_WRN_COMPUTE_FAILED" : "SMESH_COMPUTE_SUCCEED"));
- myDlg->myMemoryLackGroup->hide();
+ myCompDlg->setWindowTitle(tr( computeFailed ? "SMESH_WRN_COMPUTE_FAILED" : "SMESH_COMPUTE_SUCCEED"));
// SHOW ERRORS
-
+
bool noCompError = ( !aCompErrors.operator->() || aCompErrors->length() == 0 );
bool noHypoError = ( aHypErrors.isEmpty() );
- if ( memoryLack )
+ SUIT_ResourceMgr* resMgr = SMESH::GetResourceMgr( SMESHGUI::GetSMESHGUI() );
+ int aNotifyMode = resMgr->integerValue( "SMESH", "show_result_notification" );
+
+ bool isShowResultDlg = true;
+ switch( aNotifyMode ) {
+ case 0: // show the mesh computation result dialog NEVER
+ isShowResultDlg = false;
+ commit();
+ break;
+ case 1: // show the mesh computation result dialog if there are some errors
+ if ( memoryLack || !noCompError || !noHypoError )
+ isShowResultDlg = true;
+ else
+ {
+ isShowResultDlg = false;
+ commit();
+ }
+ break;
+ default: // show the result dialog after each mesh computation
+ isShowResultDlg = true;
+ }
+
+ // SHOW RESULTS
+ if ( isShowResultDlg )
+ showComputeResult( memoryLack, noCompError,aCompErrors, noHypoError, aHypErrors );
+}
+
+void SMESHGUI_BaseComputeOp::showComputeResult( const bool theMemoryLack,
+ const bool theNoCompError,
+ SMESH::compute_error_array_var& theCompErrors,
+ const bool theNoHypoError,
+ const QString& theHypErrors )
+{
+ bool hasShape = myMesh->HasShapeToMesh();
+ SMESHGUI_ComputeDlg* aCompDlg = computeDlg();
+ aCompDlg->myMemoryLackGroup->hide();
+
+ if ( theMemoryLack )
{
- myDlg->myMemoryLackGroup->show();
- myDlg->myFullInfo->hide();
- myDlg->myBriefInfo->hide();
- myDlg->myHypErrorGroup->hide();
- myDlg->myCompErrorGroup->hide();
+ aCompDlg->myMemoryLackGroup->show();
+ aCompDlg->myFullInfo->hide();
+ aCompDlg->myBriefInfo->hide();
+ aCompDlg->myHypErrorGroup->hide();
+ aCompDlg->myCompErrorGroup->hide();
}
- else if ( noCompError && noHypoError )
+ else if ( theNoCompError && theNoHypoError )
{
- myDlg->myFullInfo->SetInfoByMesh( myMesh );
- myDlg->myFullInfo->show();
- myDlg->myBriefInfo->hide();
- myDlg->myHypErrorGroup->hide();
- myDlg->myCompErrorGroup->hide();
+ aCompDlg->myFullInfo->SetInfoByMesh( myMesh );
+ aCompDlg->myFullInfo->show();
+ aCompDlg->myBriefInfo->hide();
+ aCompDlg->myHypErrorGroup->hide();
+ aCompDlg->myCompErrorGroup->hide();
}
else
{
- QTableWidget* tbl = myDlg->myTable;
- myDlg->myBriefInfo->SetInfoByMesh( myMesh );
- myDlg->myBriefInfo->show();
- myDlg->myFullInfo->hide();
+ QTableWidget* tbl = aCompDlg->myTable;
+ aCompDlg->myBriefInfo->SetInfoByMesh( myMesh );
+ aCompDlg->myBriefInfo->show();
+ aCompDlg->myFullInfo->hide();
- if ( noHypoError ) {
- myDlg->myHypErrorGroup->hide();
+ if ( theNoHypoError ) {
+ aCompDlg->myHypErrorGroup->hide();
}
else {
- myDlg->myHypErrorGroup->show();
- myDlg->myHypErrorLabel->setText( aHypErrors );
+ aCompDlg->myHypErrorGroup->show();
+ aCompDlg->myHypErrorLabel->setText( theHypErrors );
}
- if ( noCompError ) {
- myDlg->myCompErrorGroup->hide();
+ if ( theNoCompError ) {
+ aCompDlg->myCompErrorGroup->hide();
}
else {
- myDlg->myCompErrorGroup->show();
+ aCompDlg->myCompErrorGroup->show();
if ( !hasShape ) {
- myDlg->myPublishBtn->hide();
- myDlg->myShowBtn->hide();
+ aCompDlg->myPublishBtn->hide();
+ aCompDlg->myShowBtn->hide();
}
else {
- myDlg->myPublishBtn->show();
- myDlg->myShowBtn->show();
+ aCompDlg->myPublishBtn->show();
+ aCompDlg->myShowBtn->show();
}
// fill table of errors
- tbl->setRowCount( aCompErrors->length() );
+ tbl->setRowCount( theCompErrors->length() );
if ( !hasShape ) tbl->hideColumn( COL_SHAPE );
else tbl->showColumn( COL_SHAPE );
tbl->setColumnWidth( COL_ERROR, 200 );
bool hasBadMesh = false;
- for ( int row = 0; row < aCompErrors->length(); ++row )
+ for ( int row = 0; row < theCompErrors->length(); ++row )
{
- SMESH::ComputeError & err = aCompErrors[ row ];
+ SMESH::ComputeError & err = theCompErrors[ row ];
QString text = err.algoName.in();
if ( !tbl->item( row, COL_ALGO ) ) tbl->setItem( row, COL_ALGO, new QTableWidgetItem( text ) );
tbl->resizeColumnToContents( COL_SHAPE );
if ( hasBadMesh )
- myDlg->myBadMeshBtn->show();
+ aCompDlg->myBadMeshBtn->show();
else
- myDlg->myBadMeshBtn->hide();
+ aCompDlg->myBadMeshBtn->hide();
tbl->setCurrentCell(0,0);
currentCellChanged(); // to update buttons
}
}
- SUIT_ResourceMgr* resMgr = SMESH::GetResourceMgr( SMESHGUI::GetSMESHGUI() );
- int aNotifyMode = resMgr->integerValue( "SMESH", "show_result_notification" );
-
- switch( aNotifyMode ) {
- case 0: // show the mesh computation result dialog NEVER
- commit();
- break;
- case 1: // show the mesh computation result dialog if there are some errors
- if ( memoryLack || !noCompError || !noHypoError )
- myDlg->show();
- else
- commit();
- break;
- default: // show the result dialog after each mesh computation
- myDlg->show();
- }
-
+ // show dialog and wait, becase Compute can be invoked from Preview operation
+ aCompDlg->exec();
}
//================================================================================
*/
//================================================================================
-void SMESHGUI_ComputeOp::stopOperation()
+void SMESHGUI_BaseComputeOp::stopOperation()
{
SMESHGUI_Operation::stopOperation();
- myTShapeDisplayer->SetVisibility( false );
+ if ( myTShapeDisplayer )
+ myTShapeDisplayer->SetVisibility( false );
if ( myBadMeshDisplayer ) {
myBadMeshDisplayer->SetVisibility( false );
// delete it in order not to have problems at its destruction when the viewer
delete myBadMeshDisplayer;
myBadMeshDisplayer = 0;
}
+ myIObject.Nullify();
}
//================================================================================
*/
//================================================================================
-void SMESHGUI_ComputeOp::onPublishShape()
+void SMESHGUI_BaseComputeOp::onPublishShape()
{
GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
SALOMEDS::Study_var study = SMESHGUI::GetSMESHGen()->GetCurrentStudy();
*/
//================================================================================
-void SMESHGUI_ComputeOp::onShowBadMesh()
+void SMESHGUI_BaseComputeOp::onShowBadMesh()
{
myTShapeDisplayer->SetVisibility( false );
QList<int> rows;
*/
//================================================================================
-void SMESHGUI_ComputeOp::currentCellChanged()
+void SMESHGUI_BaseComputeOp::currentCellChanged()
{
myTShapeDisplayer->SetVisibility( false );
if ( myBadMeshDisplayer )
if ( !table()->item(row, COL_BAD_MESH)->text().isEmpty() )
hasBadMesh = true;
}
- myDlg->myPublishBtn->setEnabled( publishEnable );
- myDlg->myShowBtn ->setEnabled( showEnable );
- myDlg->myBadMeshBtn->setEnabled( hasBadMesh && ( nbSelected == 1 ));
+ myCompDlg->myPublishBtn->setEnabled( publishEnable );
+ myCompDlg->myShowBtn ->setEnabled( showEnable );
+ myCompDlg->myBadMeshBtn->setEnabled( hasBadMesh && ( nbSelected == 1 ));
}
//================================================================================
*/
//================================================================================
-void SMESHGUI_ComputeOp::onPreviewShape()
+void SMESHGUI_BaseComputeOp::onPreviewShape()
{
if ( myTShapeDisplayer )
{
*/
//================================================================================
-SMESHGUI_ComputeOp::~SMESHGUI_ComputeOp()
+SMESHGUI_BaseComputeOp::~SMESHGUI_BaseComputeOp()
{
+ delete myCompDlg;
+ myCompDlg = 0;
delete myTShapeDisplayer;
if ( myBadMeshDisplayer )
delete myBadMeshDisplayer;
}
+//================================================================================
+/*!
+ * \brief Gets dialog of compute operation
+ * \retval SMESHGUI_ComputeDlg* - pointer to dialog of this operation
+ */
+//================================================================================
+
+SMESHGUI_ComputeDlg* SMESHGUI_BaseComputeOp::computeDlg() const
+{
+ if ( !myCompDlg )
+ {
+ SMESHGUI_BaseComputeOp* me = (SMESHGUI_BaseComputeOp*)this;
+ me->myCompDlg = new SMESHGUI_ComputeDlg( desktop() );
+ // connect signals and slots
+ connect(myCompDlg->myShowBtn, SIGNAL (clicked()), SLOT(onPreviewShape()));
+ connect(myCompDlg->myPublishBtn, SIGNAL (clicked()), SLOT(onPublishShape()));
+ connect(myCompDlg->myBadMeshBtn, SIGNAL (clicked()), SLOT(onShowBadMesh()));
+
+ QTableWidget* aTable = me->table();
+ connect(aTable, SIGNAL(itemSelectionChanged()), SLOT(currentCellChanged()));
+ connect(aTable, SIGNAL(currentCellChanged(int,int,int,int)), SLOT(currentCellChanged()));
+ }
+ return myCompDlg;
+}
+
+//================================================================================
+/*!
+ * \brief Return a table
+ */
+//================================================================================
+
+QTableWidget* SMESHGUI_BaseComputeOp::table()
+{
+ return myCompDlg->myTable;
+}
+
+
+//================================================================================
+/*!
+ * \brief Constructor
+*/
+//================================================================================
+
+SMESHGUI_ComputeOp::SMESHGUI_ComputeOp()
+ : SMESHGUI_BaseComputeOp()
+{
+}
+
+
+//================================================================================
+/*!
+ * \brief Desctructor
+*/
+//================================================================================
+
+SMESHGUI_ComputeOp::~SMESHGUI_ComputeOp()
+{
+}
+
+//================================================================================
+/*!
+ * \brief perform it's intention action: compute mesh
+ */
+//================================================================================
+
+void SMESHGUI_ComputeOp::startOperation()
+{
+ SMESHGUI_BaseComputeOp::startOperation();
+ computeMesh();
+}
+
+//================================================================================
+/*!
+ * \brief perform it's intention action: compute mesh
+ */
+//================================================================================
+
+bool SMESHGUI_ComputeOp::onApply()
+{
+ return true;
+}
+
//================================================================================
/*!
* \brief Gets dialog of this operation
LightApp_Dialog* SMESHGUI_ComputeOp::dlg() const
{
- return myDlg;
+ return computeDlg();
}
//================================================================================
/*!
- * \brief perform it's intention action: compute mesh
+ * \brief Constructor
+*/
+//================================================================================
+
+SMESHGUI_PrecomputeOp::SMESHGUI_PrecomputeOp()
+ : SMESHGUI_BaseComputeOp(),
+ myDlg( 0 ),
+ myActiveDlg( 0 ),
+ myPreviewDisplayer( 0 )
+{
+ myHelpFileName = "preview_meshes_page.html"; // V4
+}
+
+//================================================================================
+/*!
+ * \brief Destructor
*/
//================================================================================
-bool SMESHGUI_ComputeOp::onApply()
+SMESHGUI_PrecomputeOp::~SMESHGUI_PrecomputeOp()
+{
+ delete myDlg;
+ myDlg = 0;
+ myActiveDlg = 0;
+ if ( myPreviewDisplayer )
+ delete myPreviewDisplayer;
+ myPreviewDisplayer = 0;
+}
+
+//================================================================================
+/*!
+ * \brief Gets current dialog of this operation
+ * \retval LightApp_Dialog* - pointer to dialog of this operation
+ */
+//================================================================================
+
+LightApp_Dialog* SMESHGUI_PrecomputeOp::dlg() const
+{
+ return myActiveDlg;
+}
+
+//================================================================================
+/*!
+ * \brief perform it's intention action: prepare data
+ */
+//================================================================================
+
+void SMESHGUI_PrecomputeOp::startOperation()
+{
+ if ( !myDlg )
+ {
+ myDlg = new SMESHGUI_PrecomputeDlg( desktop() );
+
+ // connect signals
+ connect( myDlg, SIGNAL( preview() ), this, SLOT( onPreview() ) );
+ }
+ myActiveDlg = myDlg;
+
+ // connect signal to compute dialog. which will be shown after Compute mesh operation
+ SMESHGUI_ComputeDlg* cmpDlg = computeDlg();
+ if ( cmpDlg )
+ {
+ // disconnect signals
+ disconnect( cmpDlg, SIGNAL( dlgOk() ), this, SLOT( onOk() ) );
+ disconnect( cmpDlg, SIGNAL( dlgApply() ), this, SLOT( onApply() ) );
+ disconnect( cmpDlg, SIGNAL( dlgCancel() ), this, SLOT( onCancel() ) );
+ disconnect( cmpDlg, SIGNAL( dlgClose() ), this, SLOT( onCancel() ) );
+ disconnect( cmpDlg, SIGNAL( dlgHelp() ), this, SLOT( onHelp() ) );
+
+ // connect signals
+ if( cmpDlg->testButtonFlags( QtxDialog::OK ) )
+ connect( cmpDlg, SIGNAL( dlgOk() ), this, SLOT( onOk() ) );
+ if( cmpDlg->testButtonFlags( QtxDialog::Apply ) )
+ connect( cmpDlg, SIGNAL( dlgApply() ), this, SLOT( onApply() ) );
+ if( cmpDlg->testButtonFlags( QtxDialog::Help ) )
+ connect( cmpDlg, SIGNAL( dlgHelp() ), this, SLOT( onHelp() ) );
+ if( cmpDlg->testButtonFlags( QtxDialog::Cancel ) )
+ connect( cmpDlg, SIGNAL( dlgCancel() ), this, SLOT( onCancel() ) );
+ if( cmpDlg->testButtonFlags( QtxDialog::Close ) )
+ connect( cmpDlg, SIGNAL( dlgClose() ), this, SLOT( onCancel() ) );
+ }
+
+ SMESHGUI_BaseComputeOp::startOperation();
+
+ myDlg->show();
+}
+
+//================================================================================
+/*!
+ * \brief Stops operation
+ */
+//================================================================================
+
+void SMESHGUI_PrecomputeOp::stopOperation()
+{
+ if ( myPreviewDisplayer )
+ {
+ myPreviewDisplayer->SetVisibility( false );
+ delete myPreviewDisplayer;
+ myPreviewDisplayer = 0;
+ }
+ myMapShapeId.clear();
+ SMESHGUI_BaseComputeOp::stopOperation();
+}
+
+//================================================================================
+/*!
+ * \brief perform it's intention action: reinitialise dialog
+ */
+//================================================================================
+
+void SMESHGUI_PrecomputeOp::resumeOperation()
{
+ if ( myActiveDlg == myDlg )
+ initDialog();
+ SMESHGUI_BaseComputeOp::resumeOperation();
+}
+
+void SMESHGUI_PrecomputeOp::initDialog()
+{
+ QList<int> modes;
+ QMap<int, int> modeMap;
+ _PTR(SObject) aHypRoot;
+ _PTR(GenericAttribute) anAttr;
+ int aPart = SMESH::Tag_RefOnAppliedAlgorithms;
+
+ _PTR(SObject) pMesh = studyDS()->FindObjectID( myIObject->getEntry() );
+ if ( pMesh && pMesh->FindSubObject( aPart, aHypRoot ) )
+ {
+ _PTR(ChildIterator) anIter =
+ SMESH::GetActiveStudyDocument()->NewChildIterator( aHypRoot );
+ for ( ; anIter->More(); anIter->Next() )
+ {
+ _PTR(SObject) anObj = anIter->Value();
+ _PTR(SObject) aRefObj;
+ if ( anObj->ReferencedObject( aRefObj ) )
+ anObj = aRefObj;
+ else
+ continue;
+
+ if ( anObj->FindAttribute( anAttr, "AttributeName" ) )
+ {
+ CORBA::Object_var aVar = _CAST(SObject,anObj)->GetObject();
+ if ( CORBA::is_nil( aVar ) )
+ continue;
+
+ SMESH::SMESH_Algo_var algo = SMESH::SMESH_3D_Algo::_narrow( aVar );
+ if ( !algo->_is_nil() )
+ {
+ modeMap[ SMESH::DIM_1D ] = 0;
+ modeMap[ SMESH::DIM_2D ] = 0;
+ }
+ else
+ {
+ algo = SMESH::SMESH_2D_Algo::_narrow( aVar );
+ if ( !algo->_is_nil() )
+ modeMap[ SMESH::DIM_2D ] = 0;
+ }
+ }
+ }
+ }
+ if ( modeMap.contains( SMESH::DIM_1D ) )
+ modes.append( SMESH::DIM_1D );
+ if ( modeMap.contains( SMESH::DIM_2D ) )
+ modes.append( SMESH::DIM_2D );
+
+ myDlg->setPreviewModes( modes );
+}
+
+//================================================================================
+/*!
+ * \brief perform it's intention action:
+ */
+//================================================================================
+
+bool SMESHGUI_PrecomputeOp::onApply()
+{
+ QObject* obj = sender();
+ if ( obj != myDlg && myActiveDlg == myDlg )
+ return true; // just return from error messages
+ if ( myActiveDlg == myDlg )
+ {
+ myDlg->hide();
+ myMapShapeId.clear();
+ myActiveDlg = computeDlg();
+ computeMesh();
+ }
+
return true;
}
//================================================================================
/*!
- * \brief Return a table
+ * \brief perform it's intention action: compute mesh
*/
//================================================================================
-QTableWidget* SMESHGUI_ComputeOp::table()
+void SMESHGUI_PrecomputeOp::onCancel()
+{
+ QObject* curDlg = sender();
+ if ( curDlg == computeDlg() )
+ {
+ if ( myActiveDlg == myDlg ) // return from error messages
+ myDlg->show();
+
+ return;
+ }
+
+ if ( myActiveDlg == myDlg && !myMesh->_is_nil() && myMapShapeId.count() )
+ {
+ // ask to remove already computed mesh elements
+ if ( SUIT_MessageBox::question( desktop(), tr( "SMESH_WARNING" ),
+ tr( "CLEAR_SUBMESH_QUESTION" ),
+ tr( "SMESH_BUT_DELETE" ), tr( "SMESH_BUT_NO" ), 0, 1 ) == 0 )
+ {
+ // remove all submeshes for collected shapes
+ QMap<int,int>::const_iterator it = myMapShapeId.constBegin();
+ for ( ; it != myMapShapeId.constEnd(); ++it )
+ myMesh->ClearSubMesh( *it );
+ }
+ }
+ myMapShapeId.clear();
+ SMESHGUI_BaseComputeOp::onCancel();
+}
+
+//================================================================================
+/*!
+ * \brief perform it's intention action: preview mesh
+ */
+//================================================================================
+
+void SMESHGUI_PrecomputeOp::onPreview()
+{
+ if ( !myDlg || myMesh->_is_nil() || myMainShape->_is_nil() )
+ return;
+
+ _PTR(SObject) aMeshSObj = SMESH::FindSObject(myMesh);
+ if ( !aMeshSObj )
+ return;
+ // Compute preview of mesh,
+ // i.e. compute mesh till indicated dimension
+ int dim = myDlg->getPreviewMode();
+
+ SMESH::MemoryReserve aMemoryReserve;
+
+ SMESH::compute_error_array_var aCompErrors;
+ QString aHypErrors;
+
+ bool computeFailed = true, memoryLack = false;
+
+ SMESHGUI_ComputeDlg* aCompDlg = computeDlg();
+ aCompDlg->myMeshName->setText( aMeshSObj->GetName().c_str() );
+
+ SMESHGUI* gui = getSMESHGUI();
+ SMESH::SMESH_Gen_var gen = gui->GetSMESHGen();
+ SMESH::algo_error_array_var errors = gen->GetAlgoState(myMesh,myMainShape);
+ if ( errors->length() > 0 ) {
+ aHypErrors = SMESH::GetMessageOnAlgoStateErrors( errors.in() );
+ }
+
+ SUIT_OverrideCursor aWaitCursor;
+
+ SVTK_ViewWindow* view = SMESH::GetViewWindow( gui );
+ if ( myPreviewDisplayer ) delete myPreviewDisplayer;
+ myPreviewDisplayer = new SMESHGUI_MeshEditPreview( view );
+
+ SMESH::long_array_var aShapesId = new SMESH::long_array();
+ try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
+
+ SMESH::MeshPreviewStruct_var previewData =
+ gen->Precompute(myMesh, myMainShape, (SMESH::Dimension)dim, aShapesId);
+ SMESH::MeshPreviewStruct* previewRes = previewData._retn();
+ if ( previewRes && previewRes->nodesXYZ.length() > 0 )
+ {
+ computeFailed = false;
+ myPreviewDisplayer->SetData( previewRes );
+ // append shape indeces with computed mesh entities
+ for ( int i = 0, n = aShapesId->length(); i < n; i++ )
+ myMapShapeId[ aShapesId[ i ] ] = 0;
+ }
+ else
+ myPreviewDisplayer->SetVisibility(false);
+ }
+ catch(const SALOME::SALOME_Exception & S_ex){
+ memoryLack = true;
+ myPreviewDisplayer->SetVisibility(false);
+ }
+
+ try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
+ aCompErrors = gen->GetComputeErrors( myMesh, myMainShape );
+ // check if there are memory problems
+ for ( int i = 0; (i < aCompErrors->length()) && !memoryLack; ++i )
+ memoryLack = ( aCompErrors[ i ].code == SMESH::COMPERR_MEMORY_PB );
+ }
+ catch(const SALOME::SALOME_Exception & S_ex){
+ memoryLack = true;
+ }
+
+ if ( memoryLack )
+ aMemoryReserve.release();
+
+ bool noCompError = ( !aCompErrors.operator->() || aCompErrors->length() == 0 );
+ bool noHypoError = ( aHypErrors.isEmpty() );
+
+ SUIT_ResourceMgr* resMgr = SMESH::GetResourceMgr( gui );
+ int aNotifyMode = resMgr->integerValue( "SMESH", "show_result_notification" );
+
+ bool isShowError = true;
+ switch( aNotifyMode ) {
+ case 0: // show the mesh computation result dialog NEVER
+ isShowError = false;
+ break;
+ case 1: // show the mesh computation result dialog if there are some errors
+ default: // show the result dialog after each mesh computation
+ if ( !computeFailed && !memoryLack && noCompError && noHypoError )
+ isShowError = false;
+ break;
+ }
+
+ aWaitCursor.suspend();
+ // SHOW ERRORS
+ if ( isShowError )
+ {
+ myDlg->hide();
+ aCompDlg->setWindowTitle(tr( computeFailed ? "SMESH_WRN_COMPUTE_FAILED" : "SMESH_COMPUTE_SUCCEED"));
+ showComputeResult( memoryLack, noCompError, aCompErrors, noHypoError, aHypErrors );
+ }
+}
+
+
+//================================================================================
+/*!
+ * \brief Constructor
+*/
+//================================================================================
+
+SMESHGUI_PrecomputeDlg::SMESHGUI_PrecomputeDlg( QWidget* parent )
+ : SMESHGUI_Dialog( parent, false, false, OK | Cancel | Help )
+{
+ setWindowTitle( tr( "CAPTION" ) );
+
+ setButtonText( OK, tr( "COMPUTE" ) );
+ QFrame* main = mainFrame();
+
+ QVBoxLayout* layout = new QVBoxLayout( main );
+
+ QFrame* frame = new QFrame( main );
+ layout->setMargin(0); layout->setSpacing(0);
+ layout->addWidget( frame );
+
+ QHBoxLayout* frameLay = new QHBoxLayout( frame );
+ frameLay->setMargin(0); frameLay->setSpacing(SPACING);
+
+ myPreviewMode = new QtxComboBox( frame );
+ frameLay->addWidget( myPreviewMode );
+
+ myPreviewBtn = new QPushButton( tr( "PREVIEW" ), frame );
+ frameLay->addWidget( myPreviewBtn );
+
+ connect( myPreviewBtn, SIGNAL( clicked( bool ) ), this, SIGNAL( preview() ) );
+}
+
+//================================================================================
+/*!
+ * \brief Destructor
+*/
+//================================================================================
+
+SMESHGUI_PrecomputeDlg::~SMESHGUI_PrecomputeDlg()
+{
+}
+
+//================================================================================
+/*!
+ * \brief Sets available preview modes
+*/
+//================================================================================
+
+void SMESHGUI_PrecomputeDlg::setPreviewModes( const QList<int>& theModes )
+{
+ myPreviewMode->clear();
+ QList<int>::const_iterator it = theModes.constBegin();
+ for ( int i = 0; it != theModes.constEnd(); ++it, i++ )
+ {
+ QString mode = QString( "PREVIEW_%1" ).arg( *it );
+ myPreviewMode->addItem( tr( mode.toLatin1().data() ) );
+ myPreviewMode->setId( i, *it );
+ }
+ myPreviewBtn->setEnabled( !theModes.isEmpty() );
+}
+
+//================================================================================
+/*!
+ * \brief Returns current preview mesh mode
+*/
+//================================================================================
+
+int SMESHGUI_PrecomputeDlg::getPreviewMode() const
{
- return myDlg->myTable;
+ return myPreviewMode->currentId();
}
#include "SMESHGUI_Dialog.h"
#include "SMESHGUI_Operation.h"
+// SALOME GUI includes
+#include <SALOME_InteractiveObject.hxx>
+
// Qt includes
+#include <QMap>
+#include <QPointer>
#include <QGroupBox>
// IDL includes
#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SMESH_Gen)
#include CORBA_SERVER_HEADER(SMESH_Mesh)
class QFrame;
class QPushButton;
class QTableWidget;
class QLabel;
+class QtxComboBox;
class SMESHGUI_ComputeDlg;
+class SMESHGUI_PrecomputeDlg;
class SMESHGUI_MeshEditPreview;
+class SMESH::compute_error_array;
+
namespace SMESH
{
class TShapeDisplayer;
}
+/*!
+ * \brief Base operation to compute a mesh and show computation errors
+ */
+class SMESHGUI_EXPORT SMESHGUI_BaseComputeOp: public SMESHGUI_Operation
+{
+ Q_OBJECT
+
+public:
+ SMESHGUI_BaseComputeOp();
+ virtual ~SMESHGUI_BaseComputeOp();
+
+protected:
+ virtual void startOperation();
+ virtual void stopOperation();
+
+ SMESHGUI_ComputeDlg* computeDlg() const;
+ void computeMesh();
+ void showComputeResult( const bool,
+ const bool,
+ SMESH::compute_error_array_var&,
+ const bool,
+ const QString& );
+
+protected slots:
+ void onPreviewShape();
+ void onPublishShape();
+ void onShowBadMesh();
+ void currentCellChanged();
+
+private:
+ QTableWidget* table();
+
+private:
+ QPointer<SMESHGUI_ComputeDlg> myCompDlg;
+
+protected:
+ SMESH::SMESH_Mesh_var myMesh;
+ GEOM::GEOM_Object_var myMainShape;
+ SMESH::TShapeDisplayer* myTShapeDisplayer;
+ SMESHGUI_MeshEditPreview* myBadMeshDisplayer;
+ Handle(SALOME_InteractiveObject) myIObject;
+};
+
/*!
* \brief Operation to compute a mesh and show computation errors
*/
-class SMESHGUI_EXPORT SMESHGUI_ComputeOp: public SMESHGUI_Operation
+class SMESHGUI_EXPORT SMESHGUI_ComputeOp: public SMESHGUI_BaseComputeOp
{
Q_OBJECT
virtual LightApp_Dialog* dlg() const;
+protected:
+ virtual void startOperation();
+
+protected slots:
+ virtual bool onApply();
+};
+
+/*!
+ * \brief Operation to preview and compute a mesh and show computation errors
+ */
+class SMESHGUI_EXPORT SMESHGUI_PrecomputeOp: public SMESHGUI_BaseComputeOp
+{
+ Q_OBJECT
+
+public:
+ SMESHGUI_PrecomputeOp();
+ virtual ~SMESHGUI_PrecomputeOp();
+
+ virtual LightApp_Dialog* dlg() const;
+
protected:
virtual void startOperation();
virtual void stopOperation();
+ virtual void resumeOperation();
+
+ virtual void initDialog();
protected slots:
virtual bool onApply();
+ virtual void onCancel();
private slots:
- void onPreviewShape();
- void onPublishShape();
- void onShowBadMesh();
- void currentCellChanged();
+ void onPreview();
private:
- QTableWidget* table();
-
- SMESHGUI_ComputeDlg* myDlg;
-
- SMESH::SMESH_Mesh_var myMesh;
- GEOM::GEOM_Object_var myMainShape;
- SMESH::TShapeDisplayer* myTShapeDisplayer;
- SMESHGUI_MeshEditPreview* myBadMeshDisplayer;
+ QMap< int, int > myMapShapeId;
+ QPointer<LightApp_Dialog> myActiveDlg;
+ QPointer<SMESHGUI_PrecomputeDlg> myDlg;
+ SMESHGUI_MeshEditPreview* myPreviewDisplayer;
};
/*!
Q_OBJECT
public:
- SMESHGUI_ComputeDlg();
+ SMESHGUI_ComputeDlg( QWidget* );
+ virtual ~SMESHGUI_ComputeDlg();
-private:
+protected:
QFrame* createMainFrame( QWidget* );
QLabel* myMeshName;
SMESHGUI_MeshInfosBox* myBriefInfo;
SMESHGUI_MeshInfosBox* myFullInfo;
- friend class SMESHGUI_ComputeOp;
+ friend class SMESHGUI_BaseComputeOp;
+ friend class SMESHGUI_PrecomputeOp;
+};
+
+/*!
+ * \brief Dialog to preview and compute a mesh and show computation errors
+ */
+
+class SMESHGUI_EXPORT SMESHGUI_PrecomputeDlg : public SMESHGUI_Dialog
+{
+ Q_OBJECT
+
+public:
+ SMESHGUI_PrecomputeDlg( QWidget* );
+ virtual ~SMESHGUI_PrecomputeDlg();
+
+ void setPreviewModes( const QList<int>& );
+ int getPreviewMode() const;
+
+signals:
+ void preview();
+
+private:
+ QPushButton* myPreviewBtn;
+ QtxComboBox* myPreviewMode;
};
+
#endif // SMESHGUI_COMPUTEDLG_H
#include "SMESHGUI_MeshUtils.h"
#include "SMESHGUI_SpinBox.h"
#include "SMESHGUI_IdValidator.h"
+#include "SMESHGUI_FilterDlg.h"
#include <SMESH_Actor.h>
#include <SMESH_TypeFilter.hxx>
SMESHGUI_ExtrusionAlongPathDlg::SMESHGUI_ExtrusionAlongPathDlg( SMESHGUI* theModule )
: QDialog( SMESH::GetDesktop( theModule ) ),
mySMESHGUI( theModule ),
- mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
+ mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
+ myFilterDlg( 0 )
{
SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI );
QPixmap edgeImage ( mgr->loadPixmap("SMESH", tr("ICON_DLG_EDGE")));
ElementsLineEdit = new QLineEdit(GroupArguments);
ElementsLineEdit->setValidator(myIdValidator);
+ QPushButton* filterBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), GroupArguments );
+ connect(filterBtn, SIGNAL(clicked()), this, SLOT(setFilters()));
// Controls for the whole mesh selection
MeshCheck = new QCheckBox(tr("SMESH_SELECT_WHOLE_MESH"), GroupArguments);
GroupArgumentsLayout->addWidget(ElementsLab, 0, 0);
GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1);
GroupArgumentsLayout->addWidget(ElementsLineEdit, 0, 2);
- GroupArgumentsLayout->addWidget(MeshCheck, 1, 0, 1, 3);
- GroupArgumentsLayout->addWidget(PathGrp, 2, 0, 1, 3);
- GroupArgumentsLayout->addWidget(BasePointGrp, 3, 0, 1, 3);
- GroupArgumentsLayout->addWidget(AnglesGrp, 4, 0, 1, 3);
- GroupArgumentsLayout->addWidget(MakeGroupsCheck, 5, 0, 1, 3);
+ GroupArgumentsLayout->addWidget(filterBtn, 0, 3);
+ GroupArgumentsLayout->addWidget(MeshCheck, 1, 0, 1, 4);
+ GroupArgumentsLayout->addWidget(PathGrp, 2, 0, 1, 4);
+ GroupArgumentsLayout->addWidget(BasePointGrp, 3, 0, 1, 4);
+ GroupArgumentsLayout->addWidget(AnglesGrp, 4, 0, 1, 4);
+ GroupArgumentsLayout->addWidget(MakeGroupsCheck, 5, 0, 1, 4);
/***************************************************************/
// common buttons group box
SMESHGUI_ExtrusionAlongPathDlg::~SMESHGUI_ExtrusionAlongPathDlg()
{
// no need to delete child widgets, Qt does it all for us
+ if ( myFilterDlg != 0 ) {
+ myFilterDlg->setParent( 0 );
+ delete myFilterDlg;
+ }
}
//=================================================================================
disconnect(mySelectionMgr, 0, this, 0);
mySelectionMgr->clearFilters();
//mySelectionMgr->clearSelected();
- SMESH::SetPickable(); // ???
- SMESH::SetPointRepresentation(false);
+ if (SMESH::GetCurrentVtkView()) {
+ SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters
+ SMESH::SetPointRepresentation(false);
+ SMESH::SetPickable();
+ }
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
aViewWindow->SetSelectionMode(ActorSelection);
mySMESHGUI->ResetState();
ClickOnHelp();
}
}
+
+//=================================================================================
+// function : setFilters()
+// purpose : SLOT. Called when "Filter" button pressed.
+//=================================================================================
+void SMESHGUI_ExtrusionAlongPathDlg::setFilters()
+{
+ if ( !myFilterDlg )
+ {
+ QList<int> types;
+ types.append( SMESH::EDGE );
+ types.append( SMESH::FACE );
+ myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, types );
+ }
+ myFilterDlg->Init( Elements1dRB->isChecked() ? SMESH::EDGE : SMESH::FACE );
+
+ myFilterDlg->SetSelection();
+ myFilterDlg->SetMesh( myMesh );
+ myFilterDlg->SetSourceWg( ElementsLineEdit );
+
+ myFilterDlg->show();
+}
class SMESH_Actor;
class SMESHGUI_IdValidator;
class SMESHGUI_SpinBox;
+class SMESHGUI_FilterDlg;
class SVTK_Selector;
class LightApp_SelectionMgr;
class SUIT_SelectionFilter;
QString myHelpFileName;
+ SMESHGUI_FilterDlg* myFilterDlg;
+
protected slots:
void reject();
void onSelectMesh();
void OnAngleAdded();
void OnAngleRemoved();
+ void setFilters();
};
#endif // SMESHGUI_EXTRUSIONALONGPATHDLG_H
#include "SMESHGUI_MeshUtils.h"
#include "SMESHGUI_SpinBox.h"
#include "SMESHGUI_IdValidator.h"
+#include "SMESHGUI_FilterDlg.h"
#include <SMESH_Actor.h>
#include <SMESH_TypeFilter.hxx>
// OCCT includes
#include <TColStd_MapOfInteger.hxx>
#include <TColStd_IndexedMapOfInteger.hxx>
+#include <gp_XYZ.hxx>
// Qt includes
#include <QApplication>
SMESHGUI_ExtrusionDlg::SMESHGUI_ExtrusionDlg (SMESHGUI* theModule)
: QDialog( SMESH::GetDesktop( theModule ) ),
mySMESHGUI( theModule ),
- mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
+ mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
+ myFilterDlg( 0 )
{
QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_EDGE")));
QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_TRIANGLE")));
LineEditElements = new QLineEdit(GroupArguments);
LineEditElements->setValidator(myIdValidator);
+ QPushButton* filterBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), GroupArguments );
+ connect(filterBtn, SIGNAL(clicked()), this, SLOT(setFilters()));
// Control for the whole mesh selection
CheckBoxMesh = new QCheckBox(tr("SMESH_SELECT_WHOLE_MESH"), GroupArguments);
- // Controls for vector selection
+ //Control for the Distance selection
+ TextLabelDistance = new QLabel(tr("SMESH_DISTANCE"), GroupArguments);
+
TextLabelVector = new QLabel(tr("SMESH_VECTOR"), GroupArguments);
-
- TextLabelDx = new QLabel(tr("SMESH_DX"), GroupArguments);
+ TextLabelDx = new QLabel(tr("SMESH_X"), GroupArguments);
SpinBox_Dx = new SMESHGUI_SpinBox(GroupArguments);
-
- TextLabelDy = new QLabel(tr("SMESH_DY"), GroupArguments);
+
+ TextLabelDy = new QLabel(tr("SMESH_Y"), GroupArguments);
SpinBox_Dy = new SMESHGUI_SpinBox(GroupArguments);
- TextLabelDz = new QLabel(tr("SMESH_DZ"), GroupArguments);
+ TextLabelDz = new QLabel(tr("SMESH_Z"), GroupArguments);
SpinBox_Dz = new SMESHGUI_SpinBox(GroupArguments);
+ // Controls for vector selection
+
+ SelectVectorButton = new QPushButton(GroupArguments);
+ SelectVectorButton->setIcon(image2);
+
+ TextLabelVx = new QLabel(tr("SMESH_DX"), GroupArguments);
+ SpinBox_Vx = new SMESHGUI_SpinBox(GroupArguments);
+
+ TextLabelVy = new QLabel(tr("SMESH_DY"), GroupArguments);
+ SpinBox_Vy = new SMESHGUI_SpinBox(GroupArguments);
+
+ TextLabelVz = new QLabel(tr("SMESH_DZ"), GroupArguments);
+ SpinBox_Vz = new SMESHGUI_SpinBox(GroupArguments);
+
// Controls for nb. steps defining
TextLabelNbSteps = new QLabel(tr("SMESH_NUMBEROFSTEPS"), GroupArguments);
SpinBox_NbSteps = new QSpinBox(GroupArguments);
GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0);
GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1);
- GroupArgumentsLayout->addWidget(LineEditElements, 0, 2, 1, 6);
+ GroupArgumentsLayout->addWidget(LineEditElements, 0, 2, 1, 5);
+ GroupArgumentsLayout->addWidget(filterBtn, 0, 7);
GroupArgumentsLayout->addWidget(CheckBoxMesh, 1, 0, 1, 8);
- GroupArgumentsLayout->addWidget(TextLabelVector, 2, 0);
+ GroupArgumentsLayout->addWidget(TextLabelDistance, 2, 0);
GroupArgumentsLayout->addWidget(TextLabelDx, 2, 2);
GroupArgumentsLayout->addWidget(SpinBox_Dx, 2, 3);
GroupArgumentsLayout->addWidget(TextLabelDy, 2, 4);
GroupArgumentsLayout->addWidget(SpinBox_Dy, 2, 5);
GroupArgumentsLayout->addWidget(TextLabelDz, 2, 6);
GroupArgumentsLayout->addWidget(SpinBox_Dz, 2, 7);
- GroupArgumentsLayout->addWidget(TextLabelNbSteps, 3, 0);
- GroupArgumentsLayout->addWidget(SpinBox_NbSteps, 3, 2, 1, 6);
- GroupArgumentsLayout->addWidget(MakeGroupsCheck, 4, 0, 1, 8);
+ GroupArgumentsLayout->addWidget(TextLabelVector, 3, 0);
+ GroupArgumentsLayout->addWidget(SelectVectorButton, 3, 1);
+ GroupArgumentsLayout->addWidget(TextLabelVx, 3, 2);
+ GroupArgumentsLayout->addWidget(SpinBox_Vx, 3, 3);
+ GroupArgumentsLayout->addWidget(TextLabelVy, 3, 4);
+ GroupArgumentsLayout->addWidget(SpinBox_Vy, 3, 5);
+ GroupArgumentsLayout->addWidget(TextLabelVz, 3, 6);
+ GroupArgumentsLayout->addWidget(SpinBox_Vz, 3, 7);
+ GroupArgumentsLayout->addWidget(TextLabelNbSteps, 4, 0);
+ GroupArgumentsLayout->addWidget(SpinBox_NbSteps, 4, 2, 1, 6);
+ GroupArgumentsLayout->addWidget(MakeGroupsCheck, 5, 0, 1, 8);
/***************************************************************/
SMESHGUI_ExtrusionDlgLayout->addWidget(ConstructorsBox);
SMESHGUI_ExtrusionDlgLayout->addWidget(GroupButtons);
/* Initialisations */
+ SpinBox_Vx->RangeStepAndValidator(-1, 1, 0.01, 3);
+ SpinBox_Vy->RangeStepAndValidator(-1, 1, 0.01, 3);
+ SpinBox_Vz->RangeStepAndValidator(-1, 1, 0.01, 3);
+
SpinBox_Dx->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
SpinBox_Dy->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
SpinBox_Dz->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, 3);
-
+
SpinBox_NbSteps->setRange(1, 999999);
RadioButton1->setChecked(true);
connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
// to update state of the Ok & Apply buttons
+ connect(SpinBox_Vx, SIGNAL(valueChanged(double)), SLOT(CheckIsEnable()));
+ connect(SpinBox_Vy, SIGNAL(valueChanged(double)), SLOT(CheckIsEnable()));
+ connect(SpinBox_Vz, SIGNAL(valueChanged(double)), SLOT(CheckIsEnable()));
connect(SpinBox_Dx, SIGNAL(valueChanged(double)), SLOT(CheckIsEnable()));
connect(SpinBox_Dy, SIGNAL(valueChanged(double)), SLOT(CheckIsEnable()));
connect(SpinBox_Dz, SIGNAL(valueChanged(double)), SLOT(CheckIsEnable()));
connect(GroupConstructors, SIGNAL(buttonClicked(int)), SLOT(ConstructorsClicked(int)));
connect(SelectElementsButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
+ connect(SelectVectorButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
/* to close dialog if study change */
//=================================================================================
SMESHGUI_ExtrusionDlg::~SMESHGUI_ExtrusionDlg()
{
+ if ( myFilterDlg != 0 ) {
+ myFilterDlg->setParent( 0 );
+ delete myFilterDlg;
+ }
}
//=================================================================================
SpinBox_Dx->SetValue(0);
SpinBox_Dy->SetValue(0);
SpinBox_Dz->SetValue(0);
+ SpinBox_Vx->SetValue(0);
+ SpinBox_Vy->SetValue(0);
+ SpinBox_Vz->SetValue(0);
CheckBoxMesh->setChecked(false);
onSelectMesh(false);
//=================================================================================
void SMESHGUI_ExtrusionDlg::CheckIsEnable()
{
- double aX = SpinBox_Dx->GetValue();
- double aY = SpinBox_Dy->GetValue();
- double aZ = SpinBox_Dz->GetValue();
+
+ double aX = SpinBox_Vx->GetValue()*SpinBox_Dx->GetValue();
+ double aY = SpinBox_Vy->GetValue()*SpinBox_Dy->GetValue();
+ double aZ = SpinBox_Vz->GetValue()*SpinBox_Dz->GetValue();
double aModule = sqrt(aX*aX + aY*aY + aZ*aZ);
bool anIsEnable = myNbOkElements > 0 && aModule > 1.0E-38;
}
}
- myEditCurrentArgument = LineEditElements;
+ myEditCurrentArgument = (QWidget*)LineEditElements;
LineEditElements->setFocus();
if (CheckBoxMesh->isChecked())
return false;
if (myNbOkElements) {
-
+
+ gp_XYZ aNormale(SpinBox_Vx->GetValue(),
+ SpinBox_Vy->GetValue(),
+ SpinBox_Vz->GetValue());
+
+ aNormale /= aNormale.Modulus();
+
SMESH::DirStruct aVector;
- aVector.PS.x = SpinBox_Dx->GetValue();
- aVector.PS.y = SpinBox_Dy->GetValue();
- aVector.PS.z = SpinBox_Dz->GetValue();
+ aVector.PS.x = SpinBox_Dx->GetValue()*aNormale.X();
+ aVector.PS.y = SpinBox_Dy->GetValue()*aNormale.Y();
+ aVector.PS.z = SpinBox_Dz->GetValue()*aNormale.Z();
long aNbSteps = (long)SpinBox_NbSteps->value();
disconnect(mySelectionMgr, 0, this, 0);
mySelectionMgr->clearFilters();
//mySelectionMgr->clearSelected();
- SMESH::SetPickable(); // ???
- SMESH::SetPointRepresentation(false);
+ if (SMESH::GetCurrentVtkView()) {
+ SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters
+ SMESH::SetPointRepresentation(false);
+ SMESH::SetPickable();
+ }
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
aViewWindow->SetSelectionMode(ActorSelection);
mySMESHGUI->ResetState();
// clear
myActor = 0;
myIO.Nullify();
- QString aString = "";
+ QString aString = "";
// set busy flag
- myBusy = true;
-
- myEditCurrentArgument->setText(aString);
- myNbOkElements = 0;
- myBusy = false;
-
+ if(myEditCurrentArgument == (QWidget*)LineEditElements) {
+ myBusy = true;
+ LineEditElements->setText(aString);
+ myNbOkElements = 0;
+ myBusy = false;
+ }
// get selected mesh
SALOME_ListIO aList;
mySelectionMgr->selectedObjects(aList, SVTK_Viewer::Type());
myIO = IO;
myActor = SMESH::FindActorByObject(myMesh);
- if (myEditCurrentArgument == LineEditElements) {
+ if (myEditCurrentArgument == (QWidget*)LineEditElements) {
int aNbElements = 0;
// MakeGroups is available if there are groups
return;
myNbOkElements = true;
+
+ myBusy = true;
+ ((QLineEdit*)myEditCurrentArgument)->setText(aString);
+ myBusy = false;
}
+ else if(myEditCurrentArgument == (QWidget*)SpinBox_Vx){
+ TColStd_IndexedMapOfInteger aMapIndex;
+ mySelector->GetIndex(IO,aMapIndex);
+ int aNbElements = aMapIndex.Extent();
+ SMDS_Mesh* aMesh = myActor ? myActor->GetObject()->GetMesh() : 0;
- myBusy = true;
- myEditCurrentArgument->setText(aString);
- myBusy = false;
+ if(aNbElements != 1 || !aMesh)
+ return;
+
+ const SMDS_MeshFace* face = dynamic_cast<const SMDS_MeshFace*>(aMesh->FindElement(aMapIndex(aNbElements)));
+
+ if (!face)
+ return;
+ gp_XYZ aNormale = SMESH::getNormale(face);
+ SpinBox_Vx->SetValue(aNormale.X());
+ SpinBox_Vy->SetValue(aNormale.Y());
+ SpinBox_Vz->SetValue(aNormale.Z());
+
+ }
+
// OK
CheckIsEnable();
}
mySelectionMgr->clearFilters();
if (send == SelectElementsButton) {
- myEditCurrentArgument = LineEditElements;
+ myEditCurrentArgument = (QWidget*)LineEditElements;
if (CheckBoxMesh->isChecked()) {
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
aViewWindow->SetSelectionMode(ActorSelection);
}
}
}
-
+ else if (send == SelectVectorButton){
+ myEditCurrentArgument = (QWidget*)SpinBox_Vx;
+ if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+ aViewWindow->SetSelectionMode(FaceSelection);
+ }
+
myEditCurrentArgument->setFocus();
connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
SelectionIntoArgument();
ClickOnHelp();
}
}
+
+//=================================================================================
+// function : setFilters()
+// purpose : SLOT. Called when "Filter" button pressed.
+//=================================================================================
+void SMESHGUI_ExtrusionDlg::setFilters()
+{
+ if ( !myFilterDlg )
+ {
+ QList<int> types;
+ types.append( SMESH::EDGE );
+ types.append( SMESH::FACE );
+ myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, types );
+ }
+ myFilterDlg->Init( GetConstructorId() ? SMESH::FACE : SMESH::EDGE );
+
+ myFilterDlg->SetSelection();
+ myFilterDlg->SetMesh( myMesh );
+ myFilterDlg->SetSourceWg( LineEditElements );
+
+ myFilterDlg->show();
+}
class SMESH_Actor;
class SMESHGUI_IdValidator;
class SMESHGUI_SpinBox;
+class SMESHGUI_FilterDlg;
class SVTK_Selector;
class LightApp_SelectionMgr;
class SUIT_SelectionFilter;
SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */
SMESHGUI_IdValidator* myIdValidator;
LightApp_SelectionMgr* mySelectionMgr; /* User shape selection */
- QLineEdit* myEditCurrentArgument; /* Current LineEdit */
+ QWidget* myEditCurrentArgument; /* Current argument editor */
int myNbOkElements; /* to check when elements are defined */
SVTK_Selector* mySelector;
QLineEdit* LineEditElements;
QCheckBox* CheckBoxMesh;
QLabel* TextLabelVector;
+ QLabel* TextLabelDistance;
+ QPushButton* SelectVectorButton;
QLabel* TextLabelDx;
SMESHGUI_SpinBox* SpinBox_Dx;
QLabel* TextLabelDy;
SMESHGUI_SpinBox* SpinBox_Dy;
QLabel* TextLabelDz;
SMESHGUI_SpinBox* SpinBox_Dz;
+ QLabel* TextLabelVx;
+ SMESHGUI_SpinBox* SpinBox_Vx;
+ QLabel* TextLabelVy;
+ SMESHGUI_SpinBox* SpinBox_Vy;
+ QLabel* TextLabelVz;
+ SMESHGUI_SpinBox* SpinBox_Vz;
QLabel* TextLabelNbSteps;
QSpinBox* SpinBox_NbSteps;
QCheckBox* MakeGroupsCheck;
QString myHelpFileName;
+ SMESHGUI_FilterDlg* myFilterDlg;
+
private slots:
void ConstructorsClicked( int );
void CheckIsEnable();
void ActivateThisDialog();
void onTextChange( const QString& );
void onSelectMesh( bool );
+ void setFilters();
};
#endif // SMESHGUI_EXTRUSIONDLG_H
return false;
SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh();
- SMESH::ElementType anElemType = myPred->GetElementType();
- int aMeshId = anElemType == SMESH::NODE ? anActor->GetNodeObjId( theCellId )
- : anActor->GetElemObjId( theCellId );
+ SMDSAbs_ElementType anElemType = (SMDSAbs_ElementType)myPred->GetElementType();
+ int aMeshId = anElemType == SMDSAbs_Node ? anActor->GetNodeObjId( theCellId )
+ : anActor->GetElemObjId( theCellId );
// if type of element != type of predicate return true because
// this predicate is not intended for filtering sush elements
- const SMDS_MeshElement* anElem = anElemType == SMESH::NODE ? aMesh->FindNode( aMeshId )
- : aMesh->FindElement( aMeshId );
- if ( anElem != 0 && anElem->GetType() != (SMDSAbs_ElementType)myPred->GetElementType() )
- return true;
-
+ const SMDS_MeshElement* anElem = anElemType == SMDSAbs_Node ? aMesh->FindNode( aMeshId )
+ : aMesh->FindElement( aMeshId );
+ // here we guess that predicate element type can not be All in case of node selection
+ if ( !anElem || (anElemType != SMDSAbs_All && anElem->GetType() != anElemType) )
+ return false;
+
return myPred->IsSatisfy( aMeshId );
}
return false;
SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh();
- SMESH::ElementType anElemType = myPred->GetElementType();
+ SMDSAbs_ElementType anElemType = (SMDSAbs_ElementType)myPred->GetElementType();
// if type of element != type of predicate return true because
// this predicate is not intended for filtering sush elements
- const SMDS_MeshElement* anElem = anElemType == SMESH::NODE ? aMesh->FindNode( theObjId )
- : aMesh->FindElement( theObjId );
- if ( anElem != 0 && anElem->GetType() != (SMDSAbs_ElementType)myPred->GetElementType() )
- return true;
+ const SMDS_MeshElement* anElem = anElemType == SMDSAbs_Node ? aMesh->FindNode( theObjId )
+ : aMesh->FindElement( theObjId );
+ // here we guess that predicate element type can not be All in case of node selection
+ if ( !anElem || (anElemType != SMDSAbs_All && anElem->GetType() != anElemType) )
+ return false;
return myPred->IsSatisfy( theObjId );
}
#include <SUIT_ResourceMgr.h>
#include <SUIT_Session.h>
#include <SUIT_MessageBox.h>
+#include <QtxComboBox.h>
+#include <QtxColorButton.h>
#include <LightApp_Application.h>
#include <LightApp_SelectionMgr.h>
if (myTables.isEmpty())
{
- int aType = theTypes.first();
-
// create main layout
QVBoxLayout* aMainLay = new QVBoxLayout(this);
aMainLay->setMargin( 0 );
mySwitchTableGrpLayout->setMargin(0);
mySwitchTableGrpLayout->setSpacing(0);
- myTables[ aType ] = createTable(mySwitchTableGrp, aType);
- mySwitchTableGrpLayout->addWidget(myTables[ aType ]);
+ QList<int>::const_iterator typeIt = theTypes.begin();
+ for ( ; typeIt != theTypes.end(); ++typeIt ) {
+ Table* aTable = createTable(mySwitchTableGrp, *typeIt);
+ myTables[ *typeIt ] = aTable;
+ mySwitchTableGrpLayout->addWidget(aTable);
+ if ( typeIt != theTypes.begin() )
+ aTable->hide();
+ }
// create buttons
myAddBtn = new QPushButton(tr("ADD"), myTableGrp);
for (int i = 0, n = aTable->rowCount(); i < n; i++)
{
int aCriterion = GetCriterionType(i, aType);
-
- if (aCriterion == SMESH::FT_RangeOfIds ||
+ QString errMsg;
+ if (aCriterion == SMESH::FT_GroupColor ) {
+ QtxColorButton* clrBtn = qobject_cast<QtxColorButton*>(aTable->cellWidget(i, 2));
+ if (clrBtn && !clrBtn->color().isValid())
+ errMsg = tr( "GROUPCOLOR_ERROR" );
+ } else if (aCriterion == SMESH::FT_ElemGeomType ) {
+ QtxComboBox* typeBox = qobject_cast<QtxComboBox*>(aTable->cellWidget(i, 2));
+ if (typeBox && typeBox->currentId() == -1)
+ errMsg = tr( "ERROR" );
+ } else if (aCriterion == SMESH::FT_RangeOfIds ||
aCriterion == SMESH::FT_BelongToGeom ||
aCriterion == SMESH::FT_BelongToPlane ||
aCriterion == SMESH::FT_BelongToCylinder ||
aCriterion == SMESH::FT_BelongToGenSurface ||
aCriterion == SMESH::FT_LyingOnGeom) {
- if (aTable->text(i, 2).isEmpty()) {
- if (theMess)
- SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
- tr("ERROR"));
- return false;
- }
- } else {
+ if (aTable->text(i, 2).isEmpty());
+ errMsg = tr( "ERROR" );
+ }
+ else {
bool aRes = false;
bool isSignalsBlocked = aTable->signalsBlocked();
aTable->blockSignals(true);
double aThreshold = (int)aTable->text(i, 2).toDouble(&aRes);
aTable->blockSignals(isSignalsBlocked);
- if (!aRes && aTable->isEditable(i, 2)) {
- if (theMess)
- SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
- tr("ERROR"));
- return false;
- }
+ if (!aRes && aTable->isEditable(i, 2))
+ errMsg = tr( "ERROR" );
else if (aType == SMESH::EDGE &&
GetCriterionType(i, aType) == SMESH::FT_MultiConnection &&
aThreshold == 1)
- {
- if (theMess)
- SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
- tr("MULTIEDGES_ERROR"));
- return false;
- }
+ errMsg = tr( "MULTIEDGES_ERROR" );
+ }
+
+ if (!errMsg.isEmpty()) {
+ if (theMess)
+ SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"), errMsg );
+ return false;
}
QTableWidgetItem* anItem = aTable->item(i, 0);
int aCriterionType = GetCriterionType(theRow, aType);
- if ( aCriterionType != SMESH::FT_RangeOfIds &&
- aCriterionType != SMESH::FT_BelongToGeom &&
- aCriterionType != SMESH::FT_BelongToPlane &&
- aCriterionType != SMESH::FT_BelongToCylinder &&
- aCriterionType != SMESH::FT_BelongToGenSurface &&
- aCriterionType != SMESH::FT_LyingOnGeom)
+ if ( aCriterionType == SMESH::FT_GroupColor )
+ {
+ QtxColorButton* clrBtn = qobject_cast<QtxColorButton*>(aTable->cellWidget(theRow, 2));
+ if ( clrBtn )
+ {
+ const QColor qClr = clrBtn->color();
+ QString clrStr = QString( "%1;%2;%3" ).
+ arg( qClr.red()/256. ).arg( qClr.green()/256. ).arg( qClr.blue()/256. );
+ theCriterion.ThresholdStr = clrStr.toLatin1().constData();
+ }
+ }
+ else if ( aCriterionType == SMESH::FT_ElemGeomType ) {
+ QtxComboBox* typeBox = qobject_cast<QtxComboBox*>(aTable->cellWidget(theRow, 2));
+ if ( typeBox )
+ theCriterion.Threshold = (double)typeBox->currentId();
+ }
+ else if ( aCriterionType != SMESH::FT_RangeOfIds &&
+ aCriterionType != SMESH::FT_BelongToGeom &&
+ aCriterionType != SMESH::FT_BelongToPlane &&
+ aCriterionType != SMESH::FT_BelongToCylinder &&
+ aCriterionType != SMESH::FT_BelongToGenSurface &&
+ aCriterionType != SMESH::FT_LyingOnGeom)
{
theCriterion.Compare = ((ComboItem*)aTable->item(theRow, 1))->value();
theCriterion.Threshold = aTable->item(theRow, 2)->text().toDouble();
else
aTable->setEditable(false, theRow, 4);
- if (theCriterion.Type != SMESH::FT_RangeOfIds &&
+ if (theCriterion.Type == SMESH::FT_GroupColor )
+ {
+ QtxColorButton* clrBtn = qobject_cast<QtxColorButton*>(aTable->cellWidget(theRow, 2));
+ if ( clrBtn )
+ {
+ QColor qClr;
+ QString clrStr( theCriterion.ThresholdStr );
+ QStringList clrVals = clrStr.split( ";" );
+ if ( clrVals.count() > 2 )
+ qClr.setRgb( (int)256*clrVals[0].toDouble(),
+ (int)256*clrVals[1].toDouble(),
+ (int)256*clrVals[2].toDouble() );
+ clrBtn->setColor( qClr );
+ }
+ }
+ else if (theCriterion.Type == SMESH::FT_ElemGeomType )
+ {
+ QtxComboBox* typeBox = qobject_cast<QtxComboBox*>(aTable->cellWidget(theRow, 2));
+ if ( typeBox )
+ typeBox->setCurrentId( (int)(theCriterion.Threshold + 0.5) );
+ }
+ else if (theCriterion.Type != SMESH::FT_RangeOfIds &&
theCriterion.Type != SMESH::FT_BelongToGeom &&
theCriterion.Type != SMESH::FT_BelongToPlane &&
theCriterion.Type != SMESH::FT_BelongToCylinder &&
theCriterion.Type != SMESH::FT_LyingOnGeom &&
theCriterion.Type != SMESH::FT_FreeBorders &&
theCriterion.Type != SMESH::FT_FreeEdges &&
- theCriterion.Type != SMESH::FT_BadOrientedVolume)
+ theCriterion.Type != SMESH::FT_FreeNodes &&
+ theCriterion.Type != SMESH::FT_FreeFaces &&
+ theCriterion.Type != SMESH::FT_BadOrientedVolume &&
+ theCriterion.Type != SMESH::FT_LinearOrQuadratic)
aTable->item( theRow, 2 )->setText(QString("%1").arg(theCriterion.Threshold, 0, 'g', 15));
else
{
}
ComboItem* anItem = ((ComboItem*)aTable->item(aRow, 0));
+ int aCriterion = GetCriterionType(aRow);
bool toEnable = ((ComboItem*)aTable->item(aRow, 1))->value() == SMESH::FT_EqualTo &&
- GetCriterionType(aRow) != SMESH::FT_BelongToGeom &&
- GetCriterionType(aRow) != SMESH::FT_LyingOnGeom &&
- GetCriterionType(aRow) != SMESH::FT_RangeOfIds &&
- GetCriterionType(aRow) != SMESH::FT_FreeEdges &&
- GetCriterionType(aRow) != SMESH::FT_BadOrientedVolume;
+ aCriterion != SMESH::FT_BelongToGeom &&
+ aCriterion != SMESH::FT_LyingOnGeom &&
+ aCriterion != SMESH::FT_RangeOfIds &&
+ aCriterion != SMESH::FT_FreeEdges &&
+ aCriterion != SMESH::FT_FreeFaces &&
+ aCriterion != SMESH::FT_BadOrientedVolume;
+
if (!myAddWidgets.contains(anItem))
{
myAddWidgets[ anItem ] = new AdditionalWidget(myWgStack);
emit CurrentChanged(theRow, theCol);
}
+//=======================================================================
+// name : geomTypes
+// Purpose : returns available geometry types of elements
+//=======================================================================
+static QList<int> geomTypes( const int theType )
+{
+ QList<int> typeIds;
+ if ( theType == SMESH::NODE )
+ typeIds.append( SMESH::Geom_POINT );
+ if ( theType == SMESH::ALL || theType == SMESH::EDGE )
+ typeIds.append( SMESH::Geom_EDGE );
+ if ( theType == SMESH::ALL || theType == SMESH::FACE )
+ {
+ typeIds.append( SMESH::Geom_TRIANGLE );
+ typeIds.append( SMESH::Geom_QUADRANGLE );
+ typeIds.append( SMESH::Geom_POLYGON );
+ }
+ if ( theType == SMESH::ALL || theType == SMESH::VOLUME )
+ {
+ typeIds.append( SMESH::Geom_TETRA );
+ typeIds.append( SMESH::Geom_PYRAMID );
+ typeIds.append( SMESH::Geom_HEXA );
+ typeIds.append( SMESH::Geom_PENTA );
+ typeIds.append( SMESH::Geom_POLYHEDRA );
+ }
+ return typeIds;
+}
+
//=======================================================================
// name : SMESHGUI_FilterTable::onCriterionChanged()
// Purpose : Provides reaction on change of criterion
ComboItem* aCompareItem = (ComboItem*)aTable->item(row, 1);
int aCriterionType = GetCriterionType(row);
+ QtxColorButton* clrBtn = qobject_cast<QtxColorButton*>(aTable->cellWidget(row, 2));
+ QtxComboBox* typeBox = qobject_cast<QtxComboBox*>(aTable->cellWidget(row, 2));
+
+ if ( (aCriterionType == SMESH::FT_GroupColor && !clrBtn) ||
+ (aCriterionType == SMESH::FT_ElemGeomType && !typeBox) )
+ {
+ bool isSignalsBlocked = aTable->signalsBlocked();
+ aTable->blockSignals( true );
+ if ( aCriterionType == SMESH::FT_GroupColor )
+ aTable->setCellWidget( row, 2, new QtxColorButton( aTable ) );
+ else {
+ QtxComboBox* typeBox = new QtxComboBox( aTable );
+ aTable->setCellWidget( row, 2, typeBox );
+ QList<int> typeIds = geomTypes( aType );
+ QList<int>::const_iterator anIter = typeIds.begin();
+ for ( int i = 0; anIter != typeIds.end(); ++anIter, ++i) {
+ QString typeKey = QString( "GEOM_TYPE_%1" ).arg( *anIter );
+ typeBox->addItem( tr( typeKey.toLatin1().data() ) );
+ typeBox->setId( i, *anIter );
+ }
+ }
+ aTable->blockSignals( isSignalsBlocked );
+ }
+ else if ( (aCriterionType != SMESH::FT_GroupColor && clrBtn) ||
+ (aCriterionType != SMESH::FT_ElemGeomType && typeBox) )
+ {
+ bool isSignalsBlocked = aTable->signalsBlocked();
+ aTable->blockSignals( true );
+ aTable->setCellWidget( row, 2, 0 );
+ aTable->setItem( row, 2, new QTableWidgetItem() );
+ aTable->blockSignals( isSignalsBlocked );
+ }
- if (aType == SMESH::EDGE && aCriterionType == SMESH::FT_FreeBorders ||
- aType == SMESH::FACE && aCriterionType == SMESH::FT_FreeEdges ||
- aType == SMESH::VOLUME && aCriterionType == SMESH::FT_BadOrientedVolume)
+ if (aType == SMESH::NODE && aCriterionType == SMESH::FT_FreeNodes ||
+ aType == SMESH::EDGE && aCriterionType == SMESH::FT_FreeBorders ||
+ aType == SMESH::FACE && (aCriterionType == SMESH::FT_FreeEdges ||
+ aCriterionType == SMESH::FT_FreeFaces) ||
+ aType == SMESH::VOLUME && aCriterionType == SMESH::FT_BadOrientedVolume ||
+ aCriterionType == SMESH::FT_LinearOrQuadratic ||
+ aCriterionType == SMESH::FT_GroupColor ||
+ aCriterionType == SMESH::FT_ElemGeomType)
{
bool isSignalsBlocked = aTable->signalsBlocked();
aTable->blockSignals( true );
if (aCompareItem->count() > 0)
aCompareItem->clear();
aTable->setEditable(false, row, 1);
- aTable->setEditable(false, row, 2);
-
+ aTable->setEditable(aCriterionType == SMESH::FT_GroupColor ||
+ aCriterionType == SMESH::FT_ElemGeomType, row, 2);
aTable->blockSignals( isSignalsBlocked );
}
else if (aCriterionType == SMESH::FT_RangeOfIds ||
if (!aTable->isEditable(row, 2))
aTable->setEditable(true, row, 2);
}
+ else if (aCriterionType == SMESH::FT_GroupColor ||
+ aCriterionType == SMESH::FT_ElemGeomType)
+ {
+ if (!aTable->isEditable(row, 2))
+ aTable->setEditable(true, row, 2);
+ }
else
{
if (aCompareItem->count() != 3)
aTypes[ SMESH::EDGE ] = tr("EDGES");
aTypes[ SMESH::FACE ] = tr("FACES");
aTypes[ SMESH::VOLUME ] = tr("VOLUMES");
+ aTypes[ SMESH::ALL ] = tr("ELEMENTS");
}
return aTypes;
aCriteria[ SMESH::FT_BelongToCylinder ] = tr("BELONG_TO_CYLINDER");
aCriteria[ SMESH::FT_BelongToGenSurface ] = tr("BELONG_TO_GENSURFACE");
aCriteria[ SMESH::FT_LyingOnGeom ] = tr("LYING_ON_GEOM");
+ aCriteria[ SMESH::FT_FreeNodes ] = tr("FREE_NODES");
+ aCriteria[ SMESH::FT_GroupColor ] = tr("GROUP_COLOR");
}
return aCriteria;
}
aCriteria[ SMESH::FT_BelongToCylinder ] = tr("BELONG_TO_CYLINDER");
aCriteria[ SMESH::FT_BelongToGenSurface ] = tr("BELONG_TO_GENSURFACE");
aCriteria[ SMESH::FT_LyingOnGeom ] = tr("LYING_ON_GEOM");
+ aCriteria[ SMESH::FT_LinearOrQuadratic ] = tr("LINEAR");
+ aCriteria[ SMESH::FT_GroupColor ] = tr("GROUP_COLOR");
+ aCriteria[ SMESH::FT_ElemGeomType ] = tr("GEOM_TYPE");
}
return aCriteria;
}
aCriteria[ SMESH::FT_LyingOnGeom ] = tr("LYING_ON_GEOM");
aCriteria[ SMESH::FT_Length2D ] = tr("LENGTH2D");
aCriteria[ SMESH::FT_MultiConnection2D ] = tr("MULTI2D_BORDERS");
+ aCriteria[ SMESH::FT_FreeFaces ] = tr("FREE_FACES");
+ aCriteria[ SMESH::FT_LinearOrQuadratic ] = tr("LINEAR");
+ aCriteria[ SMESH::FT_GroupColor ] = tr("GROUP_COLOR");
+ aCriteria[ SMESH::FT_ElemGeomType ] = tr("GEOM_TYPE");
}
return aCriteria;
}
aCriteria[ SMESH::FT_LyingOnGeom ] = tr("LYING_ON_GEOM");
aCriteria[ SMESH::FT_BadOrientedVolume ] = tr("BAD_ORIENTED_VOLUME");
aCriteria[ SMESH::FT_Volume3D ] = tr("VOLUME_3D");
+ aCriteria[ SMESH::FT_LinearOrQuadratic ] = tr("LINEAR");
+ aCriteria[ SMESH::FT_GroupColor ] = tr("GROUP_COLOR");
+ aCriteria[ SMESH::FT_ElemGeomType ] = tr("GEOM_TYPE");
}
return aCriteria;
}
- else
+ else // SMESH::ALL
{
static QMap<int, QString> aCriteria;
+ if (aCriteria.isEmpty())
+ {
+ aCriteria[ SMESH::FT_RangeOfIds ] = tr("RANGE_OF_IDS");
+ aCriteria[ SMESH::FT_BelongToGeom ] = tr("BELONG_TO_GEOM");
+ aCriteria[ SMESH::FT_LyingOnGeom ] = tr("LYING_ON_GEOM");
+ aCriteria[ SMESH::FT_LinearOrQuadratic ] = tr("LINEAR");
+ aCriteria[ SMESH::FT_GroupColor ] = tr("GROUP_COLOR");
+ aCriteria[ SMESH::FT_ElemGeomType ] = tr("GEOM_TYPE");
+ }
+
return aCriteria;
}
}
QRadioButton* aMeshBtn = new QRadioButton(tr("MESH"), aBox);
QRadioButton* aSelBtn = new QRadioButton(tr("SELECTION"), aBox);
- QRadioButton* aGrpBtn = new QRadioButton(tr("CURRENT_GROUP"), aBox);
+ QRadioButton* aDlgBtn = new QRadioButton(tr("CURRENT_DIALOG"),aBox);
aLay->addWidget(aMeshBtn);
aLay->addWidget(aSelBtn);
- aLay->addWidget(aGrpBtn);
+ aLay->addWidget(aDlgBtn);
mySourceGrp->addButton(aMeshBtn, Mesh);
mySourceGrp->addButton(aSelBtn, Selection);
- mySourceGrp->addButton(aGrpBtn, Dialog);
+ mySourceGrp->addButton(aDlgBtn, Dialog);
aSelBtn->setChecked(true);
case SMESH::EDGE : return EdgeSelection;
case SMESH::FACE : return FaceSelection;
case SMESH::VOLUME : return VolumeSelection;
+ case SMESH::ALL : return CellSelection;
default : return ActorSelection;
}
void SMESHGUI_FilterDlg::SetMesh (SMESH::SMESH_Mesh_var theMesh)
{
myMesh = theMesh;
- if ( myMesh->_is_nil() ) {
- myButtons[BTN_OK]->setEnabled(false);
- myButtons[BTN_Apply]->setEnabled(false);
- }
+ const bool isEnable = !(myMesh->_is_nil());
+ myButtons[BTN_OK]->setEnabled(isEnable);
+ myButtons[BTN_Apply]->setEnabled(isEnable);
}
//=======================================================================
}
}
+ int aCriterionType = myTable->GetCriterionType(aRow);
if (aList.Extent() != 1 ||
!myTable->CurrentCell(aRow, aCol) ||
- myTable->GetCriterionType(aRow) != SMESH::FT_BelongToGeom &&
- myTable->GetCriterionType(aRow) != SMESH::FT_BelongToPlane &&
- myTable->GetCriterionType(aRow) != SMESH::FT_BelongToCylinder &&
- myTable->GetCriterionType(aRow) != SMESH::FT_BelongToGenSurface &&
- myTable->GetCriterionType(aRow) != SMESH::FT_LyingOnGeom)
+ aCriterionType != SMESH::FT_BelongToGeom &&
+ aCriterionType != SMESH::FT_BelongToPlane &&
+ aCriterionType != SMESH::FT_BelongToCylinder &&
+ aCriterionType != SMESH::FT_BelongToGenSurface &&
+ aCriterionType != SMESH::FT_LyingOnGeom)
return;
Handle(SALOME_InteractiveObject) anIO = aList.First();
int aRow, aCol;
+ int aCriterionType = myTable->GetCriterionType(aRow);
if (myTable->CurrentCell(aRow, aCol) &&
- (myTable->GetCriterionType(aRow) == SMESH::FT_BelongToGeom ||
- myTable->GetCriterionType(aRow) == SMESH::FT_BelongToPlane ||
- myTable->GetCriterionType(aRow) == SMESH::FT_BelongToCylinder ||
- myTable->GetCriterionType(aRow) == SMESH::FT_BelongToGenSurface ||
- myTable->GetCriterionType(aRow) == SMESH::FT_LyingOnGeom)) {
+ (aCriterionType == SMESH::FT_BelongToGeom ||
+ aCriterionType == SMESH::FT_BelongToPlane ||
+ aCriterionType == SMESH::FT_BelongToCylinder ||
+ aCriterionType == SMESH::FT_BelongToGenSurface ||
+ aCriterionType == SMESH::FT_LyingOnGeom)) {
- if (myTable->GetCriterionType(aRow) == SMESH::FT_BelongToGeom ||
- myTable->GetCriterionType(aRow) == SMESH::FT_BelongToGenSurface ||
- myTable->GetCriterionType(aRow) == SMESH::FT_LyingOnGeom) {
+ if (aCriterionType == SMESH::FT_BelongToGeom ||
+ aCriterionType == SMESH::FT_BelongToGenSurface ||
+ aCriterionType == SMESH::FT_LyingOnGeom) {
mySelectionMgr->installFilter(new GEOM_SelectionFilter( aStudy, true ));
- } else if (myTable->GetCriterionType(aRow) == SMESH::FT_BelongToPlane) {
+ } else if (aCriterionType == SMESH::FT_BelongToPlane) {
mySelectionMgr->installFilter(new GEOM_FaceFilter( aStudy, StdSelect_Plane ) );
- } else if (myTable->GetCriterionType(aRow) == SMESH::FT_BelongToCylinder) {
+ } else if (aCriterionType == SMESH::FT_BelongToCylinder) {
mySelectionMgr->installFilter(new GEOM_FaceFilter( aStudy, StdSelect_Cylinder ) );
}
myIsSelectionChanged = true;
// purpose :
//=================================================================================
SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( SMESHGUI* theModule,
- SMESH::SMESH_GroupBase_ptr theGroup )
+ SMESH::SMESH_GroupBase_ptr theGroup,
+ const bool theIsConvert )
: QDialog( SMESH::GetDesktop( theModule ) ),
mySMESHGUI( theModule ),
mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
{
initDialog( false );
if ( !theGroup->_is_nil() )
- init( theGroup );
+ init( theGroup, theIsConvert );
else
{
mySelectSubMesh->setEnabled( false );
// function : Init()
// purpose :
//=================================================================================
-void SMESHGUI_GroupDlg::init (SMESH::SMESH_GroupBase_ptr theGroup)
+void SMESHGUI_GroupDlg::init (SMESH::SMESH_GroupBase_ptr theGroup,
+ const bool theIsConvert)
{
restoreShowEntityMode();
myMesh = theGroup->GetMesh();
myTypeGroup->button(aType)->setChecked(true);
myGroup = SMESH::SMESH_Group::_narrow( theGroup );
+ myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_narrow( theGroup );
- if (!myGroup->_is_nil())
- {
- // NPAL19389: create a group with a selection in another group
- // set actor of myMesh, if it is visible, else set
- // actor of myGroup, if it is visible, else try
- // any visible actor of group or submesh of myMesh
- // commented, because an attempt to set selection on not displayed cells leads to error
- //SetAppropriateActor();
- myActor = SMESH::FindActorByObject(myMesh);
- if ( !myActor )
- myActor = SMESH::FindActorByObject(myGroup);
- SMESH::SetPickable(myActor);
+ if (myGroup->_is_nil() && myGroupOnGeom->_is_nil())
+ return;
+
+ // NPAL19389: create a group with a selection in another group
+ // set actor of myMesh, if it is visible, else set
+ // actor of theGroup, if it is visible, else try
+ // any visible actor of group or submesh of myMesh
+ // commented, because an attempt to set selection on not displayed cells leads to error
+ //SetAppropriateActor();
+ myActor = SMESH::FindActorByObject(myMesh);
+ if ( !myActor )
+ myActor = SMESH::FindActorByObject(theGroup);
+ SMESH::SetPickable(myActor);
- myGrpTypeGroup->button(0)->setChecked(true);
- onGrpTypeChanged(0);
+ int grpType = (!myGroup->_is_nil() ? 0 : (theIsConvert ? 0 : 1));
+ myGrpTypeGroup->button(grpType)->setChecked(true);
+ onGrpTypeChanged(grpType);
+ if ( grpType == 0 ) {
myCurrentLineEdit = 0;
myElements->clear();
setSelectionMode(aType);
setShowEntityMode(); // depends on myTypeId
myIdList.clear();
- if (!myGroup->IsEmpty()) {
- SMESH::long_array_var anElements = myGroup->GetListOfID();
+ if (!theGroup->IsEmpty()) {
+ SMESH::long_array_var anElements = theGroup->GetListOfID();
int k = anElements->length();
for (int i = 0; i < k; i++) {
myIdList.append(anElements[i]);
}
else
{
- myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_narrow( theGroup );
-
- if ( !myGroupOnGeom->_is_nil() )
+ QString aShapeName( "" );
+ _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
+ GEOM::GEOM_Object_var aGroupShape = myGroupOnGeom->GetShape();
+ if (!aGroupShape->_is_nil())
{
- // NPAL19389: create a group with a selection in another group
- // set actor of myMesh, if it is visible, else set
- // actor of myGroupOnGeom, if it is visible, else try
- // any visible actor of group or submesh of myMesh
- // commented, because an attempt to set selection on not displayed cells leads to error
- //SetAppropriateActor();
- myActor = SMESH::FindActorByObject(myMesh);
- if ( !myActor )
- myActor = SMESH::FindActorByObject(myGroupOnGeom);
- SMESH::SetPickable(myActor);
-
- myGrpTypeGroup->button(1)->setChecked(true);
- onGrpTypeChanged(1);
-
- QString aShapeName( "" );
- _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
- GEOM::GEOM_Object_var aGroupShape = myGroupOnGeom->GetShape();
- if (!aGroupShape->_is_nil())
- {
- _PTR(SObject) aGroupShapeSO = aStudy->FindObjectID(aGroupShape->GetStudyEntry());
- aShapeName = aGroupShapeSO->GetName().c_str();
- }
- myGeomGroupLine->setText( aShapeName );
- myNameChanged = true;
- myName->blockSignals(true);
- myName->setText( "Group On " + aShapeName);
- myName->blockSignals(false);
+ _PTR(SObject) aGroupShapeSO = aStudy->FindObjectID(aGroupShape->GetStudyEntry());
+ aShapeName = aGroupShapeSO->GetName().c_str();
}
+ myGeomGroupLine->setText( aShapeName );
+ myNameChanged = true;
+ myName->blockSignals(true);
+ myName->setText( "Group On " + aShapeName);
+ myName->blockSignals(false);
}
+ updateButtons();
}
//=================================================================================
mySelectionMgr->clearSelected();
+ if (myGroup->_is_nil()) { // creation or conversion
+ // check if group on geometry is not null
+ if (!CORBA::is_nil(myGroupOnGeom)) {
+ if (myMesh->_is_nil())
+ return false;
+ myGroup = myMesh->ConvertToStandalone( myGroupOnGeom );
+ // nullify pointer, because object become dead
+ myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil();
+ }
+ }
+
if (myGroup->_is_nil()) { // creation
if (myMesh->_is_nil())
return false;
SALOME_ListIteratorOfListIO anIt (aList);
for ( ; anIt.More(); anIt.Next()) {
- SMESH::SMESH_Group_var aGroup =
- SMESH::IObjectToInterface<SMESH::SMESH_Group>(anIt.Value());
+ SMESH::SMESH_GroupBase_var aGroup =
+ SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(anIt.Value());
if (!aGroup->_is_nil()) {
// check if mesh is the same
if (aGroup->GetType() == aType && aGroup->GetMesh()->GetId() == myMesh->GetId()) {
SMESHGUI_GroupDlg( SMESHGUI*,
SMESH::SMESH_Mesh_ptr = SMESH::SMESH_Mesh::_nil() );
SMESHGUI_GroupDlg( SMESHGUI*,
- SMESH::SMESH_GroupBase_ptr );
+ SMESH::SMESH_GroupBase_ptr,
+ const bool theIsConvert = false );
~SMESHGUI_GroupDlg();
static QString GetDefaultName( const QString& );
private:
void initDialog( bool );
void init( SMESH::SMESH_Mesh_ptr );
- void init( SMESH::SMESH_GroupBase_ptr );
+ void init( SMESH::SMESH_GroupBase_ptr,
+ const bool theIsConvert = false );
void closeEvent( QCloseEvent* );
void enterEvent( QEvent* );
void hideEvent( QHideEvent* ); /* ESC key */
#include <QLabel>
#include <QLineEdit>
#include <QKeyEvent>
+#include <QListWidget>
+#include <QButtonGroup>
+#include <SALOME_ListIteratorOfListIO.hxx>
+#include <QComboBox>
+#include <QtxColorButton.h>
#define SPACING 6
#define MARGIN 11
* Description : Perform boolean operations on groups
*/
-//=======================================================================
-// name : SMESHGUI_GroupOpDlg::SMESHGUI_GroupOpDlg
-// Purpose : Constructor
-//=======================================================================
-SMESHGUI_GroupOpDlg::SMESHGUI_GroupOpDlg( SMESHGUI* theModule, const int theMode )
+/*!
+ \brief Constructor
+ \param theModule pointer on module instance
+*/
+SMESHGUI_GroupOpDlg::SMESHGUI_GroupOpDlg( SMESHGUI* theModule )
: QDialog( SMESH::GetDesktop( theModule ) ),
mySMESHGUI( theModule ),
mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
{
setModal(false);
- myMode = theMode;
-
- if (myMode == UNION) {
- setWindowTitle(tr("UNION_OF_TWO_GROUPS"));
- myHelpFileName = "using_operations_on_groups_page.html#union_anchor";
- }
- else if (myMode == INTERSECT) {
- setWindowTitle(tr("INTERSECTION_OF_TWO_GROUPS"));
- myHelpFileName = "using_operations_on_groups_page.html#intersection_anchor";
- }
- else {
- setWindowTitle(tr("CUT_OF_TWO_GROUPS"));
- myHelpFileName = "using_operations_on_groups_page.html#cut_anchor";
- }
-
mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
QVBoxLayout* aDlgLay = new QVBoxLayout (this);
Init();
}
-//=======================================================================
-// name : SMESHGUI_GroupOpDlg::createMainFrame
-// Purpose : Create frame containing dialog's input fields
-//=======================================================================
-QWidget* SMESHGUI_GroupOpDlg::createMainFrame (QWidget* theParent)
+/*!
+ \brief Creates frame containing dialog's input fields
+ \param theParent parent widget
+ \return pointer on created widget
+*/
+QWidget* SMESHGUI_GroupOpDlg::createMainFrame( QWidget* theParent )
{
QWidget* aMainGrp = new QWidget(theParent);
QVBoxLayout* aLay = new QVBoxLayout(aMainGrp);
aNameGrpLayout->addWidget(myNameEdit);
// ------------------------------------------------------
- QGroupBox* anArgGrp = new QGroupBox(tr("ARGUMENTS"), aMainGrp);
- QGridLayout* anArgGrpLayout = new QGridLayout(anArgGrp);
- anArgGrpLayout->setMargin(MARGIN);
- anArgGrpLayout->setSpacing(SPACING);
+ myArgGrp = new QGroupBox(tr("ARGUMENTS"), aMainGrp);
- QLabel* aObj1Lab = new QLabel(myMode == CUT ? tr("MAIN_OBJECT") :tr("OBJECT_1"), anArgGrp);
- myBtn1 = new QPushButton(anArgGrp);
- myEdit1 = new QLineEdit(anArgGrp);
- myEdit1->setAlignment( Qt::AlignLeft );
- QLabel* aObj2Lab = new QLabel(myMode == CUT ? tr("TOOL_OBJECT") :tr("OBJECT_2"), anArgGrp);
- myBtn2 = new QPushButton(anArgGrp);
- myEdit2 = new QLineEdit(anArgGrp);
- myEdit2->setAlignment( Qt::AlignLeft );
-
- myEdit1->setReadOnly(true);
- myEdit2->setReadOnly(true);
+ // ------------------------------------------------------
+
+ QGroupBox* aColorBox = new QGroupBox(tr( "SMESH_SET_COLOR" ), this);
+ QHBoxLayout* aColorBoxLayout = new QHBoxLayout(aColorBox);
+ aColorBoxLayout->setMargin(MARGIN);
+ aColorBoxLayout->setSpacing(SPACING);
- QPixmap aPix (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
- myBtn1->setIcon(aPix);
- myBtn2->setIcon(aPix);
+ QLabel* aColorLab = new QLabel(tr( "SMESH_CHECK_COLOR" ), aColorBox );
+ myColorBtn = new QtxColorButton(aColorBox);
+ myColorBtn->setSizePolicy( QSizePolicy::MinimumExpanding,
+ myColorBtn->sizePolicy().verticalPolicy() );
- anArgGrpLayout->addWidget(aObj1Lab, 0, 0);
- anArgGrpLayout->addWidget(myBtn1, 0, 1);
- anArgGrpLayout->addWidget(myEdit1, 0, 2);
- anArgGrpLayout->addWidget(aObj2Lab, 1, 0);
- anArgGrpLayout->addWidget(myBtn2, 1, 1);
- anArgGrpLayout->addWidget(myEdit2, 1, 2);
+ aColorBoxLayout->addWidget(aColorLab);
+ aColorBoxLayout->addWidget(myColorBtn);
// ------------------------------------------------------
- aLay->addWidget(aNameGrp);
- aLay->addWidget(anArgGrp);
+ aLay->addWidget( aNameGrp );
+ aLay->addWidget( myArgGrp );
+ aLay->addWidget( aColorBox );
return aMainGrp;
}
-//=======================================================================
-// name : SMESHGUI_GroupOpDlg::createButtonFrame
-// Purpose : Create frame containing buttons
-//=======================================================================
+/*!
+ \brief Gets pointer on arguments group box
+ \return pointer on arguments group box
+*/
+QGroupBox* SMESHGUI_GroupOpDlg::getArgGrp() const
+{
+ return myArgGrp;
+}
+
+/*!
+ \brief Sets help file name
+ \param theFName help file name
+*/
+void SMESHGUI_GroupOpDlg::setHelpFileName( const QString& theFName )
+{
+ myHelpFileName = theFName;
+}
+
+/*!
+ \brief Gets pointer to the module instance
+ \return pointer to the module instance
+*/
+SMESHGUI* SMESHGUI_GroupOpDlg::getSMESHGUI() const
+{
+ return mySMESHGUI;
+}
+
+/*!
+ \brief Create frame containing buttons
+ \param theParent parent widget
+ \return pointer to the created frame
+*/
QWidget* SMESHGUI_GroupOpDlg::createButtonFrame (QWidget* theParent)
{
QGroupBox* aFrame = new QGroupBox(theParent);
return aFrame;
}
-//=======================================================================
-// name : SMESHGUI_GroupOpDlg::~SMESHGUI_GroupOpDlg
-// Purpose : Destructor
-//=======================================================================
+/*!
+ \brief Destructor
+*/
SMESHGUI_GroupOpDlg::~SMESHGUI_GroupOpDlg()
{
}
-//=======================================================================
-// name : SMESHGUI_GroupOpDlg::Init
-// Purpose : Init dialog fields, connect signals and slots, show dialog
-//=======================================================================
+/*!
+ \brief Init dialog fields, connect signals and slots, show dialog
+*/
void SMESHGUI_GroupOpDlg::Init()
{
mySMESHGUI->SetActiveDialogBox((QDialog*)this);
- myFocusWg = myEdit1;
-
- myGroup1 = SMESH::SMESH_GroupBase::_nil();
- myGroup2 = SMESH::SMESH_GroupBase::_nil();
-
+
// selection and SMESHGUI
connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone()));
connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), SLOT(onDeactivate()));
connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(ClickOnClose()));
- connect(myBtn1, SIGNAL(clicked()), this, SLOT(onFocusChanged()));
- connect(myBtn2, SIGNAL(clicked()), this, SLOT(onFocusChanged()));
-
// set selection mode
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
aViewWindow->SetSelectionMode(ActorSelection);
mySelectionMgr->installFilter(new SMESH_TypeFilter (GROUP));
}
-//=======================================================================
-// name : SMESHGUI_GroupOpDlg::isValid
-// Purpose : Verify validity of input data
-//=======================================================================
-bool SMESHGUI_GroupOpDlg::isValid()
+/*!
+ \brief Validate list of groups used for operation. Checks whether they corresponds
+ to the same face and have one type
+ \param theListGrp input list of groups
+ \return TRUE if groups are valid, FALSE otherwise
+*/
+bool SMESHGUI_GroupOpDlg::isValid( const QList<SMESH::SMESH_GroupBase_var>& theListGrp )
{
- // Verify validity of group name
- if (myNameEdit->text() == "") {
- SUIT_MessageBox::information(this, tr("SMESH_INSUFFICIENT_DATA"),
- tr("EMPTY_NAME"));
+ if ( theListGrp.isEmpty() )
+ {
+ SUIT_MessageBox::information( this, tr("SMESH_INSUFFICIENT_DATA"),
+ tr("INCORRECT_ARGUMENTS") );
return false;
}
- // Verufy wheter arguments speciffiyed
- if (myGroup1->_is_nil() || myGroup2->_is_nil()) {
- SUIT_MessageBox::information(this, tr("SMESH_INSUFFICIENT_DATA"),
- tr("INCORRECT_ARGUMENTS"));
- return false;
- }
+ int aMeshId = -1, aGrpType = -1;
+ QList<SMESH::SMESH_GroupBase_var>::const_iterator anIter;
+ for ( anIter = theListGrp.begin(); anIter != theListGrp.end(); ++anIter )
+ {
+ SMESH::SMESH_GroupBase_var aGrp = *anIter;
+ if ( CORBA::is_nil( aGrp ) )
+ continue; // nonsence
+
+ SMESH::SMESH_Mesh_var aMesh = aGrp->GetMesh();
+ if ( CORBA::is_nil( aMesh ) )
+ continue;
+
+ // mesh id
+ int aCurrId = aMesh->GetId();
+ if ( aMeshId == -1 )
+ aMeshId = aCurrId;
+ else
+ {
+ if ( aMeshId != aCurrId )
+ {
+ aMeshId = -1; // different meshes
+ break;
+ }
+ }
- // Verify whether arguments belongs to same mesh
- SMESH::SMESH_Mesh_ptr aMesh1 = myGroup1->GetMesh();
- SMESH::SMESH_Mesh_ptr aMesh2 = myGroup2->GetMesh();
+ // group type
+ int aCurrType = aGrp->GetType();
+ if ( aGrpType == -1 )
+ aGrpType = aCurrType;
+ else
+ {
+ if ( aGrpType != aCurrType )
+ {
+ aGrpType = -1; // different types
+ break;
+ }
+ }
- int aMeshId1 = !aMesh1->_is_nil() ? aMesh1->GetId() : -1;
- int aMeshId2 = !aMesh2->_is_nil() ? aMesh2->GetId() : -1;
+ }
- if (aMeshId1 != aMeshId2 || aMeshId1 == -1) {
+ if ( aMeshId == -1 )
+ {
SUIT_MessageBox::information(this, tr("SMESH_INSUFFICIENT_DATA"),
tr("DIFF_MESHES"));
return false;
}
- // Verify whether groups have same types of entities
- if (myGroup1->GetType() != myGroup2->GetType()) {
+ if ( aGrpType == -1 )
+ {
SUIT_MessageBox::information(this, tr("SMESH_INSUFFICIENT_DATA"),
tr("DIFF_TYPES"));
return false;
return true;
}
-//=======================================================================
-// name : SMESHGUI_GroupOpDlg::onApply
-// Purpose : SLOT called when "Apply" button pressed.
-//=======================================================================
-bool SMESHGUI_GroupOpDlg::onApply()
-{
- if (!isValid() || mySMESHGUI->isActiveStudyLocked())
- return false;
-
- SMESH::SMESH_Mesh_ptr aMesh = myGroup1->GetMesh();
- QString aName = myNameEdit->text();
- SMESH::SMESH_Group_ptr aNewGrp = SMESH::SMESH_Group::_nil();
-
- if (myMode == UNION) aNewGrp = aMesh->UnionGroups(myGroup1, myGroup2, aName.toLatin1().data());
- else if (myMode == INTERSECT) aNewGrp = aMesh->IntersectGroups(myGroup1, myGroup2, aName.toLatin1().data());
- else aNewGrp = aMesh->CutGroups(myGroup1, myGroup2, aName.toLatin1().data());
-
- if (!aNewGrp->_is_nil()) {
- mySMESHGUI->updateObjBrowser(true);
- reset();
- return true;
- } else {
- SUIT_MessageBox::critical(this, tr("SMESH_ERROR"),
- tr("SMESH_OPERATION_FAILED"));
- return false;
- }
-}
-
-//=======================================================================
-// name : SMESHGUI_GroupOpDlg::onOk
-// Purpose : SLOT called when "Ok" button pressed.
-//=======================================================================
+/*!
+ \brief SLOT called when "Ok" button pressed performs operation and closes dialog box
+*/
void SMESHGUI_GroupOpDlg::onOk()
{
- if (onApply())
+ if ( onApply() )
onClose();
}
-//=======================================================================
-// name : SMESHGUI_GroupOpDlg::onClose
-// Purpose : SLOT called when "Close" button pressed. Close dialog
-//=======================================================================
+/*!
+ \brief SLOT called when "Close" button pressed closes dialog
+*/
void SMESHGUI_GroupOpDlg::onClose()
{
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
aViewWindow->SetSelectionMode(ActorSelection);
- disconnect(mySelectionMgr, 0, this, 0);
- disconnect(mySMESHGUI, 0, this, 0);
+ disconnect( mySelectionMgr, 0, this, 0 );
+ disconnect( mySMESHGUI, 0, this, 0 );
mySMESHGUI->ResetState();
mySelectionMgr->clearFilters();
+ reset();
reject();
}
-//=================================================================================
-// function : onHelp()
-// purpose :
-//=================================================================================
+/*!
+ \brief SLOT called when "Help" button pressed shows "Help" page
+*/
void SMESHGUI_GroupOpDlg::onHelp()
{
LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
}
}
-//=======================================================================
-// name : SMESHGUI_GroupOpDlg::onSelectionDone
-// Purpose : SLOT called when selection changed
-//=======================================================================
-void SMESHGUI_GroupOpDlg::onSelectionDone()
+/*!
+ \brief Gets list of currently selected groups from selection manager
+ \param theOutList out list of groups
+ \param theOutNames out list of group of group names
+ \return TRUE if operation theOutList is not empty, FALSE otherwise
+*/
+bool SMESHGUI_GroupOpDlg::getSelectedGroups( QList<SMESH::SMESH_GroupBase_var>& theOutList,
+ QStringList& theOutNames )
{
- if (myFocusWg == myEdit1)
- myGroup1 = SMESH::SMESH_GroupBase::_nil();
- else
- myGroup2 = SMESH::SMESH_GroupBase::_nil();
+ theOutList.clear();
- myFocusWg->setText("");
+ theOutList.clear();
+ theOutNames.clear();
- SALOME_ListIO aList;
- mySelectionMgr->selectedObjects(aList);
-
- if (aList.Extent() == 1) {
+ SALOME_ListIO aListIO;
+ mySelectionMgr->selectedObjects( aListIO );
+ SALOME_ListIteratorOfListIO anIter ( aListIO );
+ for ( ; anIter.More(); anIter.Next())
+ {
SMESH::SMESH_GroupBase_var aGroup =
- SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(aList.First());
-
- if (!aGroup->_is_nil())
+ SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(anIter.Value());
+ if ( !aGroup->_is_nil())
{
- myFocusWg->setText(aGroup->GetName());
- myFocusWg->setCursorPosition( 0 );
-
- if (myFocusWg == myEdit1)
- myGroup1 = aGroup;
- else
- myGroup2 = aGroup;
+ theOutList.append( aGroup );
+ theOutNames.append( aGroup->GetName() );
}
}
+
+ return theOutList.count() > 0;
+}
+
+/*!
+ \brief Converts QT-list of group to the list acceptable by IDL interface
+ \param theIn input list
+ \return list acceptable by IDL interface
+*/
+SMESH::ListOfGroups* SMESHGUI_GroupOpDlg::convert(
+ const QList<SMESH::SMESH_GroupBase_var>& theIn )
+{
+ SMESH::ListOfGroups_var aList = new SMESH::ListOfGroups();
+ aList->length( theIn.count() );
+
+ QList<SMESH::SMESH_GroupBase_var>::const_iterator anIter = theIn.begin();
+ for ( int i = 0; anIter != theIn.end(); ++anIter, ++i )
+ aList[ i ] = *anIter;
+
+ return aList._retn();
+}
+
+/*!
+ \brief Get color to be assigned to group
+ \return color to be assigned to group
+*/
+SALOMEDS::Color SMESHGUI_GroupOpDlg::getColor() const
+{
+ QColor aQColor = myColorBtn->color();
+
+ SALOMEDS::Color aColor;
+ aColor.R = (float)aQColor.red() / 255.0;
+ aColor.G = (float)aQColor.green() / 255.0;
+ aColor.B = (float)aQColor.blue() / 255.0;
+
+ return aColor;
}
-//=======================================================================
-// name : SMESHGUI_GroupOpDlg::onDeactivate
-// Purpose : SLOT called when dialog must be deativated
-//=======================================================================
+/*!
+ \brief SLOT, called when selection is changed. Current implementation does
+ nothing. The method should be redefined in derived classes to update
+ corresponding GUI controls
+*/
+void SMESHGUI_GroupOpDlg::onSelectionDone()
+{
+}
+
+/*!
+ \brief Calls onSelectionDone() and setVisible() method of base class
+ \param visible the visible state of the dialog
+*/
+void SMESHGUI_GroupOpDlg::setVisible( bool visible )
+{
+ if ( visible )
+ {
+ onSelectionDone();
+ resize( minimumSizeHint().width(), sizeHint().height() );
+ }
+ QDialog::setVisible( visible );
+}
+
+/*!
+ \brief SLOT called when dialog must be deativated
+*/
void SMESHGUI_GroupOpDlg::onDeactivate()
{
setEnabled(false);
mySelectionMgr->clearFilters();
}
-//=======================================================================
-// name : SMESHGUI_GroupOpDlg::enterEvent
-// Purpose : Event filter
-//=======================================================================
-void SMESHGUI_GroupOpDlg::enterEvent (QEvent*)
+/*!
+ \brief Event filter updates selection mode and selection filter. This virtual method
+ is redefined from the base class it is called when dialog obtains input focus
+*/
+void SMESHGUI_GroupOpDlg::enterEvent(QEvent*)
{
mySMESHGUI->EmitSignalDeactivateDialog();
setEnabled(true);
mySelectionMgr->installFilter(new SMESH_TypeFilter (GROUP));
}
-//=======================================================================
-// name : SMESHGUI_GroupOpDlg::closeEvent
-// purpose :
-//=======================================================================
-void SMESHGUI_GroupOpDlg::closeEvent (QCloseEvent*)
+/*!
+ \brief Provides reaction on close event, closes the dialog box
+*/
+void SMESHGUI_GroupOpDlg::closeEvent(QCloseEvent*)
{
onClose();
}
-//=======================================================================
-// name : SMESHGUI_GroupOpDlg::onFocusChanged
-// Purpose : SLOT. Called when "Select" button pressed.
-//=======================================================================
-void SMESHGUI_GroupOpDlg::onFocusChanged()
-{
- const QObject* aSender = sender();
- myFocusWg = aSender == myBtn1 ? myEdit1 : myEdit2;
- onSelectionDone();
-}
-
-//=======================================================================
-// name : SMESHGUI_GroupOpDlg::reset
-// Purpose : Rest state of dialog
-//=======================================================================
+/*!
+ \brief Resets state of the dialog, initializes its fields with default value, etc.
+ Usually called by onApply() slot to reinitialize dialog fields. This virtual method
+ should be redefined in derived class to update its own fileds
+*/
void SMESHGUI_GroupOpDlg::reset()
{
myNameEdit->setText("");
- myEdit1->setText("");
- myEdit2->setText("");
- myFocusWg = myEdit1;
myNameEdit->setFocus();
}
-//=================================================================================
-// function : keyPressEvent()
-// purpose :
-//=================================================================================
+/*!
+ \brief Gets name of group to be created
+ \return name of group to be created
+ \sa setName()
+*/
+QString SMESHGUI_GroupOpDlg::getName() const
+{
+ return myNameEdit->text();
+}
+
+/*!
+ \brief Sets name of group to be created
+ \param theName name of group to be created
+ \sa getName()
+*/
+void SMESHGUI_GroupOpDlg::setName( const QString& theName )
+{
+ myNameEdit->setText( theName );
+}
+
+/*!
+ \brief Provides reaction on \93F1\94 button pressing
+ \param e key press event
+*/
void SMESHGUI_GroupOpDlg::keyPressEvent( QKeyEvent* e )
{
QDialog::keyPressEvent( e );
onHelp();
}
}
+
+/*!
+ \brief This virtual slot does nothing and should be redefined in derived classes
+ \return return false;
+*/
+bool SMESHGUI_GroupOpDlg::onApply()
+{
+ return false;
+}
+
+// === === === === === === === === === === === === === === === === === === === === ===
+
+/*!
+ \brief Constructor
+ \param theModule module
+*/
+SMESHGUI_UnionGroupsDlg::SMESHGUI_UnionGroupsDlg( SMESHGUI* theModule )
+: SMESHGUI_GroupOpDlg( theModule )
+{
+ setWindowTitle(tr("UNION_OF_GROUPS"));
+ setHelpFileName( "using_operations_on_groups_page.html#union_anchor" );
+
+ QGroupBox* anArgGrp = getArgGrp();
+ myListWg = new QListWidget( anArgGrp );
+
+ QHBoxLayout* aLay = new QHBoxLayout( anArgGrp );
+ aLay->addWidget( myListWg );
+}
+
+/*!
+ \brief Destructor
+*/
+SMESHGUI_UnionGroupsDlg::~SMESHGUI_UnionGroupsDlg()
+{
+}
+
+/*!
+ \brief This virtual method redefined from the base class resets state
+ of the dialog, initializes its fields with default value, etc.
+*/
+void SMESHGUI_UnionGroupsDlg::reset()
+{
+ SMESHGUI_GroupOpDlg::reset();
+ myListWg->clear();
+ myGroups.clear();
+}
+
+/*!
+ \brief SLOT called when apply button is pressed performs operation
+ \return TRUE if operation has been completed successfully, FALSE otherwise
+*/
+bool SMESHGUI_UnionGroupsDlg::onApply()
+{
+ if ( getSMESHGUI()->isActiveStudyLocked())
+ return false;
+
+ // Verify validity of group name
+ if ( getName() == "" )
+ {
+ SUIT_MessageBox::information(this, tr("SMESH_INSUFFICIENT_DATA"),
+ SMESHGUI_GroupOpDlg::tr("EMPTY_NAME"));
+ return false;
+ }
+
+ if ( !isValid( myGroups ) )
+ return false;
+
+ SMESH::SMESH_Mesh_var aMesh = myGroups.first()->GetMesh();
+ QString aName = getName();
+
+ bool aRes = false;
+ try
+ {
+ SMESH::ListOfGroups_var aList = convert( myGroups );
+ SMESH::SMESH_Group_var aNewGrp =
+ aMesh->UnionListOfGroups( aList, aName.toLatin1().constData() );
+ if ( !CORBA::is_nil( aNewGrp ) )
+ {
+ aNewGrp->SetColor( getColor() );
+ aRes = true;
+ }
+ }
+ catch( ... )
+ {
+ aRes = false;
+ }
+
+ if ( aRes )
+ {
+ getSMESHGUI()->updateObjBrowser(true);
+ reset();
+ return true;
+ }
+ else
+ {
+ SUIT_MessageBox::critical(this, tr("SMESH_ERROR"),
+ tr("SMESH_OPERATION_FAILED"));
+ return false;
+ }
+}
+
+/*!
+ \brief SLOT, called when selection is changed, updates corresponding GUI controls
+*/
+void SMESHGUI_UnionGroupsDlg::onSelectionDone()
+{
+ QStringList aNames;
+ getSelectedGroups( myGroups, aNames );
+ myListWg->clear();
+ myListWg->addItems( aNames );
+}
+
+// === === === === === === === === === === === === === === === === === === === === ===
+
+/*!
+ \brief Constructor
+ \param theModule module
+*/
+SMESHGUI_IntersectGroupsDlg::SMESHGUI_IntersectGroupsDlg( SMESHGUI* theModule )
+: SMESHGUI_GroupOpDlg( theModule )
+{
+ setWindowTitle(tr("INTERSECTION_OF_GROUPS"));
+ setHelpFileName( "using_operations_on_groups_page.html#intersection_anchor" );
+
+ QGroupBox* anArgGrp = getArgGrp();
+ myListWg = new QListWidget( anArgGrp );
+
+ QHBoxLayout* aLay = new QHBoxLayout( anArgGrp );
+ aLay->addWidget( myListWg );
+}
+
+/*!
+ \brief Destructor
+*/
+SMESHGUI_IntersectGroupsDlg::~SMESHGUI_IntersectGroupsDlg()
+{
+}
+
+/*!
+ \brief This virtual method redefined from the base class resets state
+ of the dialog, initializes its fields with default value, etc.
+*/
+void SMESHGUI_IntersectGroupsDlg::reset()
+{
+ SMESHGUI_GroupOpDlg::reset();
+ myListWg->clear();
+ myGroups.clear();
+}
+
+/*!
+ \brief SLOT called when apply button is pressed performs operation
+ \return TRUE if operation has been completed successfully, FALSE otherwise
+*/
+bool SMESHGUI_IntersectGroupsDlg::onApply()
+{
+ if ( getSMESHGUI()->isActiveStudyLocked())
+ return false;
+
+ // Verify validity of group name
+ if ( getName() == "" )
+ {
+ SUIT_MessageBox::information(this, tr("SMESH_INSUFFICIENT_DATA"),
+ SMESHGUI_GroupOpDlg::tr("EMPTY_NAME"));
+ return false;
+ }
+
+ if ( !isValid( myGroups ) )
+ return false;
+
+ SMESH::SMESH_Mesh_var aMesh = myGroups.first()->GetMesh();
+ QString aName = getName();
+
+ bool aRes = false;
+ try
+ {
+ SMESH::ListOfGroups_var aList = convert( myGroups );
+ SMESH::SMESH_Group_var aNewGrp =
+ aMesh->IntersectListOfGroups( aList, aName.toLatin1().constData() );
+ if ( !CORBA::is_nil( aNewGrp ) )
+ {
+ aNewGrp->SetColor( getColor() );
+ aRes = true;
+ }
+ }
+ catch( ... )
+ {
+ aRes = false;
+ }
+
+ if ( aRes )
+ {
+ getSMESHGUI()->updateObjBrowser(true);
+ reset();
+ return true;
+ }
+ else
+ {
+ SUIT_MessageBox::critical(this, tr("SMESH_ERROR"),
+ tr("SMESH_OPERATION_FAILED"));
+ return false;
+ }
+}
+
+/*!
+ \brief SLOT, called when selection is changed, updates corresponding GUI controls
+*/
+void SMESHGUI_IntersectGroupsDlg::onSelectionDone()
+{
+ QStringList aNames;
+ getSelectedGroups( myGroups, aNames );
+ myListWg->clear();
+ myListWg->addItems( aNames );
+}
+
+// === === === === === === === === === === === === === === === === === === === === ===
+
+/*!
+ \brief Constructor
+ \param theModule module
+*/
+SMESHGUI_CutGroupsDlg::SMESHGUI_CutGroupsDlg( SMESHGUI* theModule )
+: SMESHGUI_GroupOpDlg( theModule )
+{
+ setWindowTitle(tr("CUT_OF_GROUPS"));
+ setHelpFileName( "using_operations_on_groups_page.html#cut_anchor" );
+
+ QGroupBox* anArgGrp = getArgGrp();
+
+ QPixmap aPix (SMESH::GetResourceMgr( getSMESHGUI() )->loadPixmap("SMESH", tr("ICON_SELECT")));
+
+ // frame 1
+ QFrame* aFrame1 = new QFrame( anArgGrp );
+ QLabel* aLbl1 = new QLabel( tr("MAIN_OBJECT"), aFrame1 );
+ aLbl1->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ myBtn1 = new QPushButton( aFrame1 );
+ myBtn1->setIcon(aPix);
+ myListWg1 = new QListWidget( aFrame1 );
+
+ QGridLayout* aLay1 = new QGridLayout( aFrame1 );
+ aLay1->setSpacing( SPACING );
+ aLay1->addWidget( aLbl1, 0, 0 );
+ aLay1->addWidget( myBtn1, 0, 1 );
+ aLay1->addWidget( myListWg1, 1, 0, 1, 2 );
+ //QSpacerItem* aHSpacer1 = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum );
+ //aLay1->addItem( aHSpacer1, 0, 2 );
+
+
+ // frame 2
+ QFrame* aFrame2 = new QFrame( anArgGrp );
+ QLabel* aLbl2 = new QLabel( tr("TOOL_OBJECT"), aFrame2 );
+ aLbl2->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ myBtn2 = new QPushButton( aFrame2 );
+ myBtn2->setIcon(aPix);
+ myListWg2 = new QListWidget( aFrame2 );
+
+ QGridLayout* aLay2 = new QGridLayout( aFrame2 );
+ aLay2->setSpacing( SPACING );
+ aLay2->addWidget( aLbl2, 0, 0 );
+ aLay2->addWidget( myBtn2, 0, 1 );
+ aLay2->addWidget( myListWg2, 1, 0, 1, 2 );
+ //QSpacerItem* aHSpacer2 = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum );
+ //aLay2->addItem( aHSpacer2, 0, 2 );
+
+ // create button group
+
+ QButtonGroup* aGrp = new QButtonGroup( anArgGrp );
+ aGrp->addButton( myBtn1, 0 );
+ aGrp->addButton( myBtn2, 1 );
+ myBtn1->setCheckable( true );
+ myBtn2->setCheckable( true );
+ aGrp->setExclusive( true );
+ myBtn1->setChecked( true );
+
+ // fill layout
+ QHBoxLayout* aLay = new QHBoxLayout( anArgGrp );
+ aLay->setSpacing( SPACING );
+ aLay->addWidget( aFrame1 );
+ aLay->addWidget( aFrame2 );
+}
+
+/*!
+ \brief Destructor
+*/
+SMESHGUI_CutGroupsDlg::~SMESHGUI_CutGroupsDlg()
+{
+}
+
+/*!
+ \brief This virtual method redefined from the base class resets state
+ of the dialog, initializes its fields with default value, etc.
+*/
+void SMESHGUI_CutGroupsDlg::reset()
+{
+ SMESHGUI_GroupOpDlg::reset();
+
+ myListWg1->clear();
+ myGroups1.clear();
+
+ myListWg2->clear();
+ myGroups2.clear();
+}
+
+/*!
+ \brief SLOT called when apply button is pressed performs operation
+ \return TRUE if operation has been completed successfully, FALSE otherwise
+*/
+bool SMESHGUI_CutGroupsDlg::onApply()
+{
+ if ( getSMESHGUI()->isActiveStudyLocked())
+ return false;
+
+ // Verify validity of group name
+ if ( getName() == "" )
+ {
+ SUIT_MessageBox::information(this, tr("SMESH_INSUFFICIENT_DATA"),
+ SMESHGUI_GroupOpDlg::tr("EMPTY_NAME"));
+ return false;
+ }
+
+ if ( myGroups1.isEmpty() || myGroups2.isEmpty() )
+ {
+ SUIT_MessageBox::information( this, tr("SMESH_INSUFFICIENT_DATA"),
+ SMESHGUI_GroupOpDlg::tr("INCORRECT_ARGUMENTS") );
+ return false;
+ }
+
+ QList<SMESH::SMESH_GroupBase_var> aGroups = myGroups1;
+ QList<SMESH::SMESH_GroupBase_var>::iterator anIter;
+ for ( anIter = myGroups2.begin(); anIter != myGroups2.end(); ++anIter )
+ aGroups.append( *anIter );
+
+ if ( !isValid( aGroups ) )
+ return false;
+
+ SMESH::SMESH_Mesh_var aMesh = myGroups1.first()->GetMesh();
+ QString aName = getName();
+
+ bool aRes = false;
+ try
+ {
+ SMESH::ListOfGroups_var aList1 = convert( myGroups1 );
+ SMESH::ListOfGroups_var aList2 = convert( myGroups2 );
+ SMESH::SMESH_Group_var aNewGrp =
+ aMesh->CutListOfGroups( aList1, aList2, aName.toLatin1().constData() );
+ if ( !CORBA::is_nil( aNewGrp ) )
+ {
+ aNewGrp->SetColor( getColor() );
+ aRes = true;
+ }
+ }
+ catch( ... )
+ {
+ aRes = false;
+ }
+
+ if ( aRes )
+ {
+ getSMESHGUI()->updateObjBrowser(true);
+ reset();
+ return true;
+ }
+ else
+ {
+ SUIT_MessageBox::critical(this, tr("SMESH_ERROR"),
+ tr("SMESH_OPERATION_FAILED"));
+ return false;
+ }
+}
+
+/*!
+ \brief SLOT, called when selection is changed, updates corresponding GUI controls
+*/
+void SMESHGUI_CutGroupsDlg::onSelectionDone()
+{
+ QStringList aNames;
+ if ( myBtn2->isChecked() )
+ {
+ getSelectedGroups( myGroups2, aNames );
+ myListWg2->clear();
+ myListWg2->addItems( aNames );
+ }
+ else
+ {
+ getSelectedGroups( myGroups1, aNames );
+ myListWg1->clear();
+ myListWg1->addItems( aNames );
+ }
+}
+
+// === === === === === === === === === === === === === === === === === === === === ===
+
+/*!
+ \brief Constructor
+ \param theModule module
+*/
+SMESHGUI_DimGroupDlg::SMESHGUI_DimGroupDlg( SMESHGUI* theModule )
+: SMESHGUI_GroupOpDlg( theModule )
+{
+ setWindowTitle( tr( "CREATE_GROUP_OF_UNDERLYING_ELEMS" ) );
+ setHelpFileName( "creating_groups_page.html#gui_create_dim_group" );
+
+ QGroupBox* anArgGrp = getArgGrp();
+
+ QLabel* aLbl = new QLabel( tr( "ELEMENTS_TYPE" ), anArgGrp );
+
+ myCombo = new QComboBox( anArgGrp );
+ static QStringList anItems;
+ if ( anItems.isEmpty() )
+ {
+ anItems.append( tr( "NODE" ) );
+ anItems.append( tr( "EDGE" ) );
+ anItems.append( tr( "FACE" ) );
+ anItems.append( tr( "VOLUME" ) );
+ }
+ myCombo->addItems( anItems );
+ myCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+
+ myListWg = new QListWidget( anArgGrp );
+
+ // layout
+ QGridLayout* aLay = new QGridLayout( anArgGrp );
+ aLay->setSpacing( SPACING );
+ aLay->addWidget( aLbl, 0, 0 );
+ aLay->addWidget( myCombo, 0, 1 );
+ aLay->addWidget( myListWg, 1, 0, 1, 2 );
+}
+
+/*!
+ \brief Destructor
+*/
+SMESHGUI_DimGroupDlg::~SMESHGUI_DimGroupDlg()
+{
+}
+
+/*!
+ \brief This virtual method redefined from the base class resets state
+ of the dialog, initializes its fields with default value, etc.
+*/
+void SMESHGUI_DimGroupDlg::reset()
+{
+ SMESHGUI_GroupOpDlg::reset();
+ myListWg->clear();
+ myGroups.clear();
+}
+
+/*!
+ \brief Gets elements type
+ \return elements type
+ \sa setElementType()
+*/
+SMESH::ElementType SMESHGUI_DimGroupDlg::getElementType() const
+{
+ return (SMESH::ElementType)( myCombo->currentIndex() + 1 );
+}
+
+/*!
+ \brief Sets elements type
+ \param theElemType elements type
+ \sa getElementType()
+*/
+void SMESHGUI_DimGroupDlg::setElementType( const SMESH::ElementType& theElemType )
+{
+ myCombo->setCurrentIndex( theElemType - 1 );
+}
+
+/*!
+ \brief SLOT called when apply button is pressed performs operation
+ \return TRUE if operation has been completed successfully, FALSE otherwise
+*/
+bool SMESHGUI_DimGroupDlg::onApply()
+{
+ if ( getSMESHGUI()->isActiveStudyLocked())
+ return false;
+
+ // Verify validity of group name
+ if ( getName() == "" )
+ {
+ SUIT_MessageBox::information(this, tr("SMESH_INSUFFICIENT_DATA"),
+ SMESHGUI_GroupOpDlg::tr("EMPTY_NAME"));
+ return false;
+ }
+
+ if ( !isValid( myGroups ) )
+ return false;
+
+ SMESH::SMESH_Mesh_var aMesh = myGroups.first()->GetMesh();
+ QString aName = getName();
+
+ bool aRes = false;
+ try
+ {
+ SMESH::ListOfGroups_var aList = convert( myGroups );
+ SMESH::ElementType anElemType = getElementType();
+ SMESH::SMESH_Group_var aNewGrp =
+ aMesh->CreateDimGroup( aList, anElemType, aName.toLatin1().constData() );
+ if ( !CORBA::is_nil( aNewGrp ) )
+ {
+ aNewGrp->SetColor( getColor() );
+ aRes = true;
+ }
+ }
+ catch( ... )
+ {
+ aRes = false;
+ }
+
+ if ( aRes )
+ {
+ getSMESHGUI()->updateObjBrowser(true);
+ reset();
+ return true;
+ }
+ else
+ {
+ SUIT_MessageBox::critical(this, tr("SMESH_ERROR"),
+ tr("SMESH_OPERATION_FAILED"));
+ return false;
+ }
+}
+
+/*!
+ \brief SLOT, called when selection is changed, updates corresponding GUI controls
+*/
+void SMESHGUI_DimGroupDlg::onSelectionDone()
+{
+ QStringList aNames;
+ getSelectedGroups( myGroups, aNames );
+ myListWg->clear();
+ myListWg->addItems( aNames );
+}
+
+
#include CORBA_SERVER_HEADER(SMESH_Group)
class QPushButton;
+class QtxColorButton;
+class QComboBox;
+class QListWidget;
+class QGroupBox;
class QLineEdit;
class SMESHGUI;
class LightApp_SelectionMgr;
Q_OBJECT
public:
- enum { UNION, INTERSECT, CUT };
+ //enum { UNION, INTERSECT, CUT };
public:
- SMESHGUI_GroupOpDlg( SMESHGUI*, const int );
+ SMESHGUI_GroupOpDlg( SMESHGUI* );
virtual ~SMESHGUI_GroupOpDlg();
void Init();
-
+
+protected slots:
+
+ virtual bool onApply();
+ virtual void onSelectionDone();
+ virtual void setVisible ( bool visible );
+
+protected:
+
+ virtual void reset();
+
+ QString getName() const;
+ void setName( const QString& theName );
+
+ QGroupBox* getArgGrp() const;
+ void setHelpFileName( const QString& theFName );
+ SMESHGUI* getSMESHGUI() const;
+ bool isValid( const QList<SMESH::SMESH_GroupBase_var>& theListGrp );
+ bool getSelectedGroups( QList<SMESH::SMESH_GroupBase_var>& theOutList,
+ QStringList& theOutNames );
+ SMESH::ListOfGroups* convert( const QList<SMESH::SMESH_GroupBase_var>& );
+
+ SALOMEDS::Color getColor() const;
+
private:
void closeEvent( QCloseEvent* );
void enterEvent( QEvent* );
private slots:
void onOk();
- bool onApply();
void onClose();
void onHelp();
void onDeactivate();
- void onSelectionDone();
- void onFocusChanged();
private:
QWidget* createButtonFrame( QWidget* );
QWidget* createMainFrame ( QWidget* );
- bool isValid();
- void reset();
-
+
private:
QPushButton* myOkBtn;
QPushButton* myApplyBtn;
QPushButton* myHelpBtn;
QLineEdit* myNameEdit;
- QLineEdit* myEdit1;
- QLineEdit* myEdit2;
- QPushButton* myBtn1;
- QPushButton* myBtn2;
+ QGroupBox* myArgGrp;
+ QtxColorButton* myColorBtn;
SMESHGUI* mySMESHGUI;
LightApp_SelectionMgr* mySelectionMgr;
- int myMode;
SVTK_Selector* mySelector;
- QLineEdit* myFocusWg;
-
- SMESH::SMESH_GroupBase_var myGroup1;
- SMESH::SMESH_GroupBase_var myGroup2;
-
QString myHelpFileName;
};
+/*
+ Class : SMESHGUI_UnionGroupsDlg
+ Description : Perform union of several groups
+*/
+
+class SMESHGUI_EXPORT SMESHGUI_UnionGroupsDlg : public SMESHGUI_GroupOpDlg
+{
+ Q_OBJECT
+
+public:
+
+ SMESHGUI_UnionGroupsDlg( SMESHGUI* );
+ virtual ~SMESHGUI_UnionGroupsDlg();
+
+protected slots:
+ virtual bool onApply();
+ virtual void onSelectionDone();
+
+protected:
+ virtual void reset();
+
+private:
+ QListWidget* myListWg;
+ QList<SMESH::SMESH_GroupBase_var> myGroups;
+};
+
+/*
+ Class : SMESHGUI_IntersectGroupsDlg
+ Description : Perform intersection of several groups
+*/
+
+class SMESHGUI_EXPORT SMESHGUI_IntersectGroupsDlg : public SMESHGUI_GroupOpDlg
+{
+ Q_OBJECT
+
+public:
+
+ SMESHGUI_IntersectGroupsDlg( SMESHGUI* );
+ virtual ~SMESHGUI_IntersectGroupsDlg();
+
+protected slots:
+ virtual bool onApply();
+ virtual void onSelectionDone();
+
+protected:
+ virtual void reset();
+
+private:
+ QListWidget* myListWg;
+ QList<SMESH::SMESH_GroupBase_var> myGroups;
+};
+
+/*
+ Class : SMESHGUI_CutGroupsDlg
+ Description : Perform cut of several groups
+*/
+
+class SMESHGUI_EXPORT SMESHGUI_CutGroupsDlg : public SMESHGUI_GroupOpDlg
+{
+ Q_OBJECT
+
+public:
+
+ SMESHGUI_CutGroupsDlg( SMESHGUI* );
+ virtual ~SMESHGUI_CutGroupsDlg();
+
+protected slots:
+ virtual bool onApply();
+ virtual void onSelectionDone();
+
+protected:
+ virtual void reset();
+
+private:
+ QPushButton* myBtn1;
+ QPushButton* myBtn2;
+ QListWidget* myListWg1;
+ QListWidget* myListWg2;
+ QList<SMESH::SMESH_GroupBase_var> myGroups1;
+ QList<SMESH::SMESH_GroupBase_var> myGroups2;
+};
+
+/*
+ Class : SMESHGUI_DimGroupDlg
+ Description : Dialog for creating groups of entities from existing
+ groups of superior dimensions
+*/
+
+class SMESHGUI_EXPORT SMESHGUI_DimGroupDlg : public SMESHGUI_GroupOpDlg
+{
+ Q_OBJECT
+
+public:
+
+ SMESHGUI_DimGroupDlg( SMESHGUI* );
+ virtual ~SMESHGUI_DimGroupDlg();
+
+ SMESH::ElementType getElementType() const;
+ void setElementType( const SMESH::ElementType& theElemType );
+
+protected:
+ virtual void reset();
+
+protected slots:
+ virtual bool onApply();
+ virtual void onSelectionDone();
+
+private:
+ QComboBox* myCombo;
+ QListWidget* myListWg;
+ QList<SMESH::SMESH_GroupBase_var> myGroups;
+};
+
#endif // SMESHGUI_GROUPOPDLG_H
+
+
{
}
+void SMESHGUI_GenericHypothesisCreator::setInitParamsHypothesis(SMESH::SMESH_Hypothesis_ptr hyp)
+{
+ if ( !CORBA::is_nil( hyp ) && hypType() == hyp->GetName() )
+ myInitParamsHypo = SMESH::SMESH_Hypothesis::_duplicate( hyp );
+}
+
void SMESHGUI_GenericHypothesisCreator::create( SMESH::SMESH_Hypothesis_ptr initParamsHyp,
const QString& theHypName,
QWidget* parent)
{
MESSAGE( "Creation of hypothesis with initial params" );
-
- if ( !CORBA::is_nil( initParamsHyp ) && hypType() == initParamsHyp->GetName() )
- myInitParamsHypo = SMESH::SMESH_Hypothesis::_duplicate( initParamsHyp );
+ setInitParamsHypothesis( initParamsHyp );
create( false, theHypName, parent );
}
}
void SMESHGUI_GenericHypothesisCreator::onValueChanged()
+{
+ valueChanged( (QWidget*) sender() );
+}
+
+void SMESHGUI_GenericHypothesisCreator::valueChanged( QWidget* )
{
}
return myHypo;
}
-SMESH::SMESH_Hypothesis_var SMESHGUI_GenericHypothesisCreator::initParamsHypothesis() const
+//================================================================================
+/*!
+ * \brief Return hypothesis containing initial parameters
+ * \param strictly - if true, always return myInitParamsHypo,
+ * else, return myInitParamsHypo only in creation mode and if it
+ * is non-nil
+ */
+//================================================================================
+
+SMESH::SMESH_Hypothesis_var SMESHGUI_GenericHypothesisCreator::initParamsHypothesis(const bool strictly) const
{
- if ( CORBA::is_nil( myInitParamsHypo ))
+ if ( strictly )
+ return myInitParamsHypo;
+ if ( !isCreation() || CORBA::is_nil( myInitParamsHypo ))
return myHypo;
return myInitParamsHypo;
}
+bool SMESHGUI_GenericHypothesisCreator::hasInitParamsHypothesis() const
+{
+ return !CORBA::is_nil( myInitParamsHypo );
+}
+
QString SMESHGUI_GenericHypothesisCreator::hypType() const
{
return myHypType;
void create( bool, const QString&, QWidget* );
void edit( SMESH::SMESH_Hypothesis_ptr,
const QString&, QWidget* );
+ void setInitParamsHypothesis(SMESH::SMESH_Hypothesis_ptr);
virtual bool checkParams() const = 0;
virtual void onReject();
typedef QList<QWidget*> ListOfWidgets;
SMESH::SMESH_Hypothesis_var hypothesis() const;
- SMESH::SMESH_Hypothesis_var initParamsHypothesis() const;
+ SMESH::SMESH_Hypothesis_var initParamsHypothesis(const bool strict=false) const;
+ bool hasInitParamsHypothesis() const;
const ListOfWidgets& widgets() const;
ListOfWidgets& changeWidgets();
QtxDialog* dlg() const;
virtual QWidget* getCustomWidget( const StdParam&,
QWidget*, const int ) const;
virtual bool getParamFromCustomWidget( StdParam&, QWidget* ) const;
+ virtual void valueChanged( QWidget* );
virtual QString caption() const;
virtual QPixmap icon() const;
virtual QString type() const;
!myIsMesh :
myDlg->selectedObject( SMESHGUI_MeshDlg::Obj ).count(':') > nbColonsInMeshEntry;
+ // get mesh and geom object
+ SMESH::SMESH_Mesh_var aMeshVar = SMESH::SMESH_Mesh::_nil();
+ GEOM::GEOM_Object_var aGeomVar = GEOM::GEOM_Object::_nil();
+
+ QString anEntry;
if ( isSubMesh )
{
- // get mesh and geom object
- SMESH::SMESH_Mesh_var aMeshVar = SMESH::SMESH_Mesh::_nil();
- GEOM::GEOM_Object_var aGeomVar = GEOM::GEOM_Object::_nil();
-
- QString anEntry = myDlg->selectedObject
+ anEntry = myDlg->selectedObject
( myToCreate ? SMESHGUI_MeshDlg::Mesh : SMESHGUI_MeshDlg::Obj );
if ( _PTR(SObject) pObj = studyDS()->FindObjectID( anEntry.toLatin1().data() ))
{
}
}
}
-
- if ( !aMeshVar->_is_nil() && !aGeomVar->_is_nil() )
- return SMESHGUI::GetSMESHGen()->GetHypothesisParameterValues( aHypType.toLatin1().data(),
- aServerLib.toLatin1().data(),
- aMeshVar,
- aGeomVar );
}
+ else // mesh
+ {
+ if ( !myToCreate ) // mesh to edit can be selected
+ {
+ anEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Obj );
+ if ( _PTR(SObject) pMesh = studyDS()->FindObjectID( anEntry.toLatin1().data() ))
+ {
+ aMeshVar = SMESH::SMESH_Mesh::_narrow( _CAST( SObject,pMesh )->GetObject() );
+ if ( !aMeshVar->_is_nil() )
+ aGeomVar = SMESH::GetShapeOnMeshOrSubMesh( pMesh );
+ }
+ }
+ if ( aGeomVar->_is_nil() ) {
+ anEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
+ if ( _PTR(SObject) pGeom = studyDS()->FindObjectID( anEntry.toLatin1().data() ))
+ {
+ aGeomVar= GEOM::GEOM_Object::_narrow( _CAST( SObject,pGeom )->GetObject() );
+ }
+ }
+ }
+
+ if ( (!isSubMesh || !aMeshVar->_is_nil()) && !aGeomVar->_is_nil() )
+ return SMESHGUI::GetSMESHGen()->GetHypothesisParameterValues( aHypType.toLatin1().data(),
+ aServerLib.toLatin1().data(),
+ aMeshVar,
+ aGeomVar,
+ /*byMesh = */isSubMesh);
+
return SMESH::SMESH_Hypothesis::_nil();
}
// Create hypothesis
if (aCreator) {
- // When create or edit a submesh, try to initialize a new hypothesis
- // with values used to mesh a subshape
+ // Get parameters appropriate to initialize a new hypothesis
SMESH::SMESH_Hypothesis_var initParamHyp =
getInitParamsHypothesis(theTypeName, aData->ServerLibName);
myDlg->setEnabled( false );
SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator( aHyp->GetName() );
if ( aCreator ) {
+ // Get initial parameters
+ SMESH::SMESH_Hypothesis_var initParamHyp =
+ getInitParamsHypothesis( aHyp->GetName(), aHyp->GetLibName());
myDlg->setEnabled( false );
+ aCreator->setInitParamsHypothesis( initParamHyp );
aCreator->edit( aHyp.in(), aHypItem.second, dlg() );
myDlg->setEnabled( true );
}
// create sub-mesh
SMESH::SMESH_subMesh_var aSubMeshVar = aMeshVar->GetSubMesh( aGeomVar, aName.toLatin1().data() );
+ _PTR(SObject) aSubMeshSO = SMESH::FindSObject( aSubMeshVar.in() );
+ if ( aSubMeshSO )
+ SMESH::SetName( aSubMeshSO, aName.toLatin1().data() );
for ( int aDim = SMESH::DIM_0D; aDim <= SMESH::DIM_3D; aDim++ )
{
myTitleBoldCheck->setChecked ( f.bold() );
myTitleItalicCheck->setChecked( f.italic() );
- myTitleShadowCheck->setChecked( f.underline() );
+ myTitleShadowCheck->setChecked( f.overline() );
}
QColor labelColor = mgr->colorValue("SMESH", "scalar_bar_label_color",
myLabelsBoldCheck ->setChecked( f.bold() );
myLabelsItalicCheck->setChecked( f.italic() );
- myLabelsShadowCheck->setChecked( f.underline() );
+ myLabelsShadowCheck->setChecked( f.overline() );
}
int aNbColors = mgr->integerValue("SMESH", "scalar_bar_num_colors", 64);
#include "SMESHGUI_VTKUtils.h"
#include "SMESHGUI_MeshUtils.h"
#include "SMESHGUI_IdValidator.h"
+#include "SMESHGUI_FilterDlg.h"
#include <SMESH_Actor.h>
#include <SMDS_Mesh.hxx>
mySelector(SMESH::GetViewWindow(theModule)->GetSelector()),
mySelectionMgr(SMESH::GetSelectionMgr(theModule)),
mySMESHGUI(theModule),
- myBusy(false)
+ myBusy(false),
+ myFilterDlg(0)
{
setModal( false );
setAttribute( Qt::WA_DeleteOnClose, true );
SelectButtonC1A1->setIcon(image1);
LineEditC1A1 = new QLineEdit(GroupC1);
LineEditC1A1->setValidator(new SMESHGUI_IdValidator(this));
+ QPushButton* filterBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), GroupC1 );
+ connect(filterBtn, SIGNAL(clicked()), this, SLOT(setFilters()));
GroupC1Layout->addWidget(TextLabelC1A1);
GroupC1Layout->addWidget(SelectButtonC1A1);
GroupC1Layout->addWidget(LineEditC1A1);
+ GroupC1Layout->addWidget(filterBtn );
/***************************************************************/
GroupButtons = new QGroupBox(this);
//=================================================================================
SMESHGUI_RemoveElementsDlg::~SMESHGUI_RemoveElementsDlg()
{
+ if ( myFilterDlg ) {
+ myFilterDlg->setParent( 0 );
+ delete myFilterDlg;
+ myFilterDlg = 0;
+ }
}
//=================================================================================
//=================================================================================
void SMESHGUI_RemoveElementsDlg::ClickOnCancel()
{
+ if (SMESH::GetCurrentVtkView())
+ SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters
//mySelectionMgr->clearSelected();
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
aViewWindow->SetSelectionMode(ActorSelection);
disconnect(mySelectionMgr, 0, this, 0);
+ mySelectionMgr->clearFilters();
mySMESHGUI->ResetState();
reject();
}
ClickOnHelp();
}
}
+
+//=================================================================================
+// function : setFilters()
+// purpose : SLOT. Called when "Filter" button pressed.
+//=================================================================================
+void SMESHGUI_RemoveElementsDlg::setFilters()
+{
+ if ( !myFilterDlg )
+ myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, SMESH::ALL );
+
+ myFilterDlg->SetSelection();
+ myFilterDlg->SetMesh( myMesh );
+ myFilterDlg->SetSourceWg( LineEditC1A1 );
+
+ myFilterDlg->show();
+}
class QRadioButton;
class SMESHGUI;
+class SMESHGUI_FilterDlg;
class SMESH_Actor;
class SVTK_Selector;
class LightApp_SelectionMgr;
QString myHelpFileName;
+ SMESHGUI_FilterDlg* myFilterDlg;
+
private slots:
void ClickOnOk();
void ClickOnCancel();
void DeactivateActiveDialog();
void ActivateThisDialog();
void onTextChange( const QString& );
+ void setFilters();
};
#endif // SMESHGUI_REMOVEELEMENTSDLG_H
#include "SMESHGUI_VTKUtils.h"
#include "SMESHGUI_MeshUtils.h"
#include "SMESHGUI_IdValidator.h"
+#include "SMESHGUI_FilterDlg.h"
#include <SMESH_Actor.h>
#include <SMDS_Mesh.hxx>
mySelector(SMESH::GetViewWindow(theModule)->GetSelector()),
mySelectionMgr(SMESH::GetSelectionMgr(theModule)),
mySMESHGUI(theModule),
- myBusy(false)
+ myBusy(false),
+ myFilterDlg(0)
{
setModal( false );
setAttribute( Qt::WA_DeleteOnClose, true );
SelectButtonC1A1->setIcon(image1);
LineEditC1A1 = new QLineEdit(GroupC1);
LineEditC1A1->setValidator(new SMESHGUI_IdValidator(this));
+ QPushButton* filterBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), GroupC1 );
+ connect(filterBtn, SIGNAL(clicked()), this, SLOT(setFilters()));
GroupC1Layout->addWidget(TextLabelC1A1);
GroupC1Layout->addWidget(SelectButtonC1A1);
GroupC1Layout->addWidget(LineEditC1A1);
+ GroupC1Layout->addWidget(filterBtn );
/***************************************************************/
GroupButtons = new QGroupBox(this);
//=================================================================================
SMESHGUI_RemoveNodesDlg::~SMESHGUI_RemoveNodesDlg()
{
+ if ( myFilterDlg ) {
+ myFilterDlg->setParent( 0 );
+ delete myFilterDlg;
+ myFilterDlg = 0;
+ }
}
//=================================================================================
void SMESHGUI_RemoveNodesDlg::ClickOnCancel()
{
//mySelectionMgr->clearSelected();
- SMESH::SetPointRepresentation(false);
+ if (SMESH::GetCurrentVtkView()) {
+ SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters
+ SMESH::SetPointRepresentation(false);
+ }
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
aViewWindow->SetSelectionMode(ActorSelection);
disconnect(mySelectionMgr, 0, this, 0);
+ mySelectionMgr->clearFilters();
mySMESHGUI->ResetState();
reject();
}
ClickOnHelp();
}
}
+
+//=================================================================================
+// function : setFilters()
+// purpose : SLOT. Called when "Filter" button pressed.
+//=================================================================================
+void SMESHGUI_RemoveNodesDlg::setFilters()
+{
+ if ( !myFilterDlg )
+ myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, SMESH::NODE );
+
+ myFilterDlg->SetSelection();
+ myFilterDlg->SetMesh( myMesh );
+ myFilterDlg->SetSourceWg( LineEditC1A1 );
+
+ myFilterDlg->show();
+}
class QRadioButton;
class SMESHGUI;
+class SMESHGUI_FilterDlg;
class SMESH_Actor;
class SVTK_Selector;
class LightApp_SelectionMgr;
QLineEdit* LineEditC1A1;
QString myHelpFileName;
+
+ SMESHGUI_FilterDlg* myFilterDlg;
private slots:
void ClickOnOk();
void DeactivateActiveDialog();
void ActivateThisDialog();
void onTextChange( const QString& );
+ void setFilters();
};
#endif // SMESHGUI_REMOVENODESDLG_H
#include "SMESHGUI_MeshUtils.h"
#include "SMESHGUI_IdValidator.h"
#include "SMESHGUI_MeshEditPreview.h"
+#include "SMESHGUI_FilterDlg.h"
#include <SMESH_Actor.h>
#include <SMESH_TypeFilter.hxx>
#include <QGridLayout>
#include <QSpinBox>
#include <QKeyEvent>
+#include <QMenu>
// IDL includes
#include <SALOMEconfig.h>
SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( SMESHGUI* theModule )
: QDialog( SMESH::GetDesktop( theModule ) ),
mySMESHGUI( theModule ),
- mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
+ mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
+ myVectorDefinition(NONE_SELECT),
+ myFilterDlg( 0 )
{
mySimulation = new SMESHGUI_MeshEditPreview(SMESH::GetViewWindow( mySMESHGUI ));
LineEditElements = new QLineEdit(GroupArguments);
LineEditElements->setValidator(myIdValidator);
+ QPushButton* filterBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), GroupArguments );
+ connect(filterBtn, SIGNAL(clicked()), this, SLOT(setFilters()));
// Control for the whole mesh selection
CheckBoxMesh = new QCheckBox(tr("SMESH_SELECT_WHOLE_MESH"), GroupArguments);
GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0);
GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1);
GroupArgumentsLayout->addWidget(LineEditElements, 0, 2);
- GroupArgumentsLayout->addWidget(CheckBoxMesh, 1, 0, 1, 3);
- GroupArgumentsLayout->addWidget(GroupAxis, 2, 0, 1, 3);
- GroupArgumentsLayout->addWidget(GroupAngleBox, 3, 0, 1, 3);
+ GroupArgumentsLayout->addWidget(filterBtn, 0, 3);
+ GroupArgumentsLayout->addWidget(CheckBoxMesh, 1, 0, 1, 4);
+ GroupArgumentsLayout->addWidget(GroupAxis, 2, 0, 1, 4);
+ GroupArgumentsLayout->addWidget(GroupAngleBox, 3, 0, 1, 4);
GroupArgumentsLayout->addWidget(TextLabelTolerance, 4, 0, 1, 2);
- GroupArgumentsLayout->addWidget(SpinBox_Tolerance, 4, 2);
- GroupArgumentsLayout->addWidget(CheckBoxPreview, 5, 0, 1, 3);
- GroupArgumentsLayout->addWidget(MakeGroupsCheck, 6, 0, 1, 3);
+ GroupArgumentsLayout->addWidget(SpinBox_Tolerance, 4, 2, 1, 2);
+ GroupArgumentsLayout->addWidget(CheckBoxPreview, 5, 0, 1, 4);
+ GroupArgumentsLayout->addWidget(MakeGroupsCheck, 6, 0, 1, 4);
/***************************************************************/
GroupButtons = new QGroupBox(this);
Init();
+ /*Create menu to vector selection*/
+ SelectVectorMenu = new QMenu(this);
+ myMenuActions[SelectVectorMenu->addAction( tr( "MEN_POINT_SELECT" ) )] = POINT_SELECT;
+ myMenuActions[SelectVectorMenu->addAction( tr( "MEN_FACE_SELECT" ) )] = FACE_SELECT;
+ connect( SelectVectorMenu, SIGNAL( triggered( QAction* ) ), SLOT( onSelectVectorMenu( QAction* ) ) );
+
/* signals and slots connections */
connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
connect(SelectElementsButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(SelectPointButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
- connect(SelectVectorButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
+ connect(SelectVectorButton, SIGNAL(clicked()), this, SLOT(onSelectVectorButton()));
connect(SpinBox_X, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
connect(SpinBox_Y, SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
SMESHGUI_RevolutionDlg::~SMESHGUI_RevolutionDlg()
{
delete mySimulation;
+ if ( myFilterDlg ) {
+ myFilterDlg->setParent( 0 );
+ delete myFilterDlg;
+ myFilterDlg = 0;
+ }
}
//=================================================================================
disconnect(mySelectionMgr, 0, this, 0);
mySelectionMgr->clearFilters();
//mySelectionMgr->clearSelected();
- SMESH::SetPointRepresentation(false);
+ if (SMESH::GetCurrentVtkView()) {
+ SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters
+ SMESH::SetPointRepresentation(false);
+ }
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
aViewWindow->SetSelectionMode(ActorSelection);
mySMESHGUI->ResetState();
myNbOkElements = true;
} else {
- aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
- if (aNbUnits != 1)
- return;
SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh();
if (!aMesh)
return;
- const SMDS_MeshNode * n = aMesh->FindNode(aString.toInt());
- if (!n)
+ bool isNodeSelected = (myEditCurrentArgument == (QWidget*)SpinBox_X ||
+ (myEditCurrentArgument == (QWidget*)SpinBox_DX &&
+ myVectorDefinition==POINT_SELECT));
+
+ bool isFaceSelected = (myEditCurrentArgument == (QWidget*)SpinBox_DX &&
+ myVectorDefinition==FACE_SELECT);
+
+ if(isNodeSelected) {
+ aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
+ }
+ else if(isFaceSelected){
+ aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
+ }
+
+ if (aNbUnits != 1)
return;
- double x = n->X();
- double y = n->Y();
- double z = n->Z();
-
- if (myEditCurrentArgument == (QWidget*)SpinBox_X) {
- SpinBox_X->SetValue(x);
- SpinBox_Y->SetValue(y);
- SpinBox_Z->SetValue(z);
- } else if (myEditCurrentArgument == (QWidget*)SpinBox_DX) {
- SpinBox_DX->SetValue(x - SpinBox_X->GetValue());
- SpinBox_DY->SetValue(y - SpinBox_Y->GetValue());
- SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue());
+ if(isNodeSelected) {
+ const SMDS_MeshNode * n = aMesh->FindNode(aString.toInt());
+ if (!n)
+ return;
+
+ double x = n->X();
+ double y = n->Y();
+ double z = n->Z();
+
+ if (myEditCurrentArgument == (QWidget*)SpinBox_X) {
+ SpinBox_X->SetValue(x);
+ SpinBox_Y->SetValue(y);
+ SpinBox_Z->SetValue(z);
+ } else if (myEditCurrentArgument == (QWidget*)SpinBox_DX) {
+ SpinBox_DX->SetValue(x - SpinBox_X->GetValue());
+ SpinBox_DY->SetValue(y - SpinBox_Y->GetValue());
+ SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue());
+ }
+ }
+ else if(isFaceSelected){
+ const SMDS_MeshFace* face = dynamic_cast<const SMDS_MeshFace*>(aMesh->FindElement(aString.toInt()));
+ if (!face)
+ return;
+
+ gp_XYZ aNormale = SMESH::getNormale(face);
+ SpinBox_DX->SetValue(aNormale.X());
+ SpinBox_DY->SetValue(aNormale.Y());
+ SpinBox_DZ->SetValue(aNormale.Z());
+
}
}
SMESH::SetPointRepresentation(true);
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
aViewWindow->SetSelectionMode(NodeSelection);
- } else if (send == SelectVectorButton) {
- myEditCurrentArgument = (QWidget*)SpinBox_DX;
- SMESH::SetPointRepresentation(true);
- if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
- aViewWindow->SetSelectionMode(NodeSelection);
- } else {
}
myEditCurrentArgument->setFocus();
mySimulation->SetVisibility(false);
}
}
+
+//=================================================================================
+// function : onSelectVectorButton()
+// purpose : [slot]
+//=================================================================================
+void SMESHGUI_RevolutionDlg::onSelectVectorButton(){
+ if(SelectVectorMenu) {
+ SelectVectorMenu->exec( QCursor::pos() );
+ }
+}
+
+//=================================================================================
+// function : onSelectVectorMenu()
+// purpose : [slot]
+//=================================================================================
+void SMESHGUI_RevolutionDlg::onSelectVectorMenu( QAction* action){
+ if(!action)
+ return;
+
+ switch(myMenuActions[action]) {
+ case POINT_SELECT:
+ SMESH::SetPointRepresentation(true);
+ if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+ aViewWindow->SetSelectionMode(NodeSelection);
+ break;
+
+ case FACE_SELECT:
+ SMESH::SetPointRepresentation(false);
+ if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+ aViewWindow->SetSelectionMode(FaceSelection);
+ break;
+ }
+
+ myVectorDefinition = myMenuActions[action];
+ myEditCurrentArgument = (QWidget*)SpinBox_DX;
+ myEditCurrentArgument->setFocus();
+ connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
+ SelectionIntoArgument();
+}
+
+//=================================================================================
+// function : setFilters()
+// purpose : SLOT. Called when "Filter" button pressed.
+//=================================================================================
+void SMESHGUI_RevolutionDlg::setFilters()
+{
+ if ( !myFilterDlg )
+ {
+ QList<int> types;
+ types.append( SMESH::EDGE );
+ types.append( SMESH::FACE );
+ myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, types );
+ }
+ myFilterDlg->Init( GetConstructorId() ? SMESH::FACE : SMESH::EDGE );
+
+ myFilterDlg->SetSelection();
+ myFilterDlg->SetMesh( myMesh );
+ myFilterDlg->SetSourceWg( LineEditElements );
+
+ myFilterDlg->show();
+}
// Qt includes
#include <QDialog>
+#include <QMap>
// IDL includes
#include <SALOMEconfig.h>
class SMESHGUI_IdValidator;
class SMESHGUI_SpinBox;
class SMESHGUI;
+class SMESHGUI_FilterDlg;
class SMESH_Actor;
class SVTK_Selector;
class LightApp_SelectionMgr;
class SMESH_LogicalFilter;
class SALOME_Actor;
class SMESHGUI_MeshEditPreview;
+class QMenu;
+class QAction;
//=================================================================================
// class : SMESHGUI_RevolutionDlg
~SMESHGUI_RevolutionDlg();
private:
+ enum {NONE_SELECT, POINT_SELECT, FACE_SELECT};
+
void Init( bool = true);
void closeEvent( QCloseEvent* );
void enterEvent( QEvent* ); /* mouse enter the QWidget */
QSpinBox* SpinBox_NbSteps;
QLabel* TextLabelTolerance;
SMESHGUI_SpinBox* SpinBox_Tolerance;
+
+ QMenu* SelectVectorMenu;
+ QMap<QAction*,int> myMenuActions;
+ int myVectorDefinition;
+
QString myHelpFileName;
+ SMESHGUI_FilterDlg* myFilterDlg;
+
private slots:
void ConstructorsClicked( int );
void ClickOnOk();
void onVectorChanged();
void toDisplaySimulation();
void onDisplaySimulation( bool );
+ void onSelectVectorMenu( QAction* );
+ void onSelectVectorButton();
+ void setFilters();
};
#endif // SMESHGUI_REVOLUTIONDLG_H
#include "SMESHGUI_VTKUtils.h"
#include "SMESHGUI_MeshUtils.h"
#include "SMESHGUI_IdValidator.h"
+#include "SMESHGUI_FilterDlg.h"
#include <SMESH_Actor.h>
#include <SMESH_TypeFilter.hxx>
SMESHGUI_RotationDlg::SMESHGUI_RotationDlg( SMESHGUI* theModule )
: QDialog( SMESH::GetDesktop( theModule ) ),
mySMESHGUI( theModule ),
- mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
+ mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
+ myFilterDlg(0)
{
QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_MESH_ROTATION")));
QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
SelectElementsButton->setIcon(image1);
LineEditElements = new QLineEdit(GroupArguments);
LineEditElements->setValidator(myIdValidator);
+ QPushButton* filterBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), GroupArguments );
+ connect(filterBtn, SIGNAL(clicked()), this, SLOT(setFilters()));
// Control for the whole mesh selection
CheckBoxMesh = new QCheckBox(tr("SMESH_SELECT_WHOLE_MESH"), GroupArguments);
GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0);
GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1);
- GroupArgumentsLayout->addWidget(LineEditElements, 0, 2, 1, 2);
+ GroupArgumentsLayout->addWidget(LineEditElements, 0, 2, 1, 1);
+ GroupArgumentsLayout->addWidget(filterBtn, 0, 3);
GroupArgumentsLayout->addWidget(CheckBoxMesh, 1, 0, 1, 4);
GroupArgumentsLayout->addWidget(GroupAxis, 2, 0, 1, 4);
GroupArgumentsLayout->addWidget(TextLabelAngle, 3, 0, 1, 2);
//=================================================================================
SMESHGUI_RotationDlg::~SMESHGUI_RotationDlg()
{
+ if ( myFilterDlg ) {
+ myFilterDlg->setParent( 0 );
+ delete myFilterDlg;
+ myFilterDlg = 0;
+ }
}
//=================================================================================
disconnect(mySelectionMgr, 0, this, 0);
mySelectionMgr->clearFilters();
//mySelectionMgr->clearSelected();
- SMESH::SetPointRepresentation(false);
+ if (SMESH::GetCurrentVtkView()) {
+ SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters
+ SMESH::SetPointRepresentation(false);
+ }
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
aViewWindow->SetSelectionMode(ActorSelection);
mySMESHGUI->ResetState();
ClickOnHelp();
}
}
+
+//=================================================================================
+// function : setFilters()
+// purpose : SLOT. Called when "Filter" button pressed.
+//=================================================================================
+void SMESHGUI_RotationDlg::setFilters()
+{
+ if ( !myFilterDlg )
+ myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, SMESH::ALL );
+
+ myFilterDlg->SetSelection();
+ myFilterDlg->SetMesh( myMesh );
+ myFilterDlg->SetSourceWg( LineEditElements );
+
+ myFilterDlg->show();
+}
class SMESH_Actor;
class SMESHGUI_IdValidator;
class SMESHGUI_SpinBox;
+class SMESHGUI_FilterDlg;
class SVTK_Selector;
class LightApp_SelectionMgr;
class SMESH_LogicalFilter;
QString myHelpFileName;
+ SMESHGUI_FilterDlg* myFilterDlg;
+
private slots:
void ClickOnOk();
void ClickOnCancel();
void onSelectMesh( bool );
void onVectorChanged();
void onActionClicked( int );
+ void setFilters();
};
#endif // SMESHGUI_ROTATIONDLG_H
else if ( p=="hasReference" ) val = QVariant( hasReference( ind ) );
else if ( p=="isImported" ) val = QVariant( isImported( ind ) );
else if ( p=="facesOrientationMode" ) val = QVariant( facesOrientationMode( ind ) );
+ else if ( p=="groupType" ) val = QVariant( groupType( ind ) );
if( val.isValid() )
return val;
case SMESH_Actor::eLength2D: return "eLength2D";
case SMESH_Actor::eFreeEdges: return "eFreeEdges";
case SMESH_Actor::eFreeBorders: return "eFreeBorders";
+ case SMESH_Actor::eFreeFaces: return "eFreeFaces";
case SMESH_Actor::eMultiConnection: return "eMultiConnection";
case SMESH_Actor::eMultiConnection2D: return "eMultiConnection2D";
case SMESH_Actor::eArea: return "eArea";
*/
return res;
}
+
+//=======================================================================
+//function : groupType
+//purpose :
+//=======================================================================
+
+QString SMESHGUI_Selection::groupType( int ind ) const
+{
+ QString e = entry( ind );
+ _PTR(SObject) SO = SMESH::GetActiveStudyDocument()->FindObjectID( e.toLatin1().constData() );
+ QString type;
+ if( SO )
+ {
+ CORBA::Object_var obj = SMESH::SObjectToObject( SO );
+
+ SMESH::SMESH_Group_var aGroup = SMESH::SMESH_Group::_narrow( obj );
+ SMESH::SMESH_GroupOnGeom_var aGroupOnGeom = SMESH::SMESH_GroupOnGeom::_narrow( obj );
+ if( !aGroup->_is_nil() )
+ type = QString( "Group" );
+ else if ( !aGroupOnGeom->_is_nil() )
+ type = QString( "GroupOnGeom" );
+ }
+ return type;
+}
virtual QList<QVariant> entityMode( int ) const;
virtual QString controlMode( int ) const;
virtual QString facesOrientationMode( int ) const;
+ virtual QString groupType( int ) const;
SMESH_Actor* getActor( int ) const;
#include "SMESHGUI_MeshUtils.h"
#include "SMESHGUI_SpinBox.h"
#include "SMESHGUI_IdValidator.h"
+#include "SMESHGUI_FilterDlg.h"
#include <SMESH_Actor.h>
#include <SMESH_TypeFilter.hxx>
SMESHGUI_SmoothingDlg::SMESHGUI_SmoothingDlg( SMESHGUI* theModule )
: QDialog( SMESH::GetDesktop( theModule ) ),
mySMESHGUI( theModule ),
- mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
+ mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
+ myFilterDlg(0)
{
QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_SMOOTHING")));
QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
LineEditElements = new QLineEdit(GroupArguments);
LineEditElements->setValidator(myIdValidator);
+ QPushButton* filterElemBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), GroupArguments );
+ connect(filterElemBtn, SIGNAL(clicked()), this, SLOT(setElemFilters()));
// Control for the whole mesh selection
CheckBoxMesh = new QCheckBox(tr("SMESH_SELECT_WHOLE_MESH"), GroupArguments);
LineEditNodes = new QLineEdit(GroupArguments);
LineEditNodes->setValidator(myIdValidator);
+ QPushButton* filterNodeBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), GroupArguments );
+ connect(filterNodeBtn, SIGNAL(clicked()), this, SLOT(setNodeFilters()));
// Controls for method selection
TextLabelMethod = new QLabel(tr("METHOD"), GroupArguments);
GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0);
GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1);
GroupArgumentsLayout->addWidget(LineEditElements, 0, 2);
- GroupArgumentsLayout->addWidget(CheckBoxMesh, 1, 0, 1, 3);
+ GroupArgumentsLayout->addWidget(filterElemBtn, 0, 3);
+ GroupArgumentsLayout->addWidget(CheckBoxMesh, 1, 0, 1, 4);
GroupArgumentsLayout->addWidget(TextLabelNodes, 2, 0);
GroupArgumentsLayout->addWidget(SelectNodesButton, 2, 1);
GroupArgumentsLayout->addWidget(LineEditNodes, 2, 2);
+ GroupArgumentsLayout->addWidget(filterNodeBtn, 2, 3);
GroupArgumentsLayout->addWidget(TextLabelMethod, 3, 0);
- GroupArgumentsLayout->addWidget(ComboBoxMethod, 3, 2);
+ GroupArgumentsLayout->addWidget(ComboBoxMethod, 3, 2, 1, 2);
GroupArgumentsLayout->addWidget(TextLabelLimit, 4, 0);
- GroupArgumentsLayout->addWidget(SpinBox_IterationLimit, 4, 2);
+ GroupArgumentsLayout->addWidget(SpinBox_IterationLimit, 4, 2, 1, 2);
GroupArgumentsLayout->addWidget(TextLabelAspectRatio, 5, 0);
- GroupArgumentsLayout->addWidget(SpinBox_AspectRatio, 5, 2);
- GroupArgumentsLayout->addWidget(CheckBoxParametric, 6, 0, 1, 3);
+ GroupArgumentsLayout->addWidget(SpinBox_AspectRatio, 5, 2, 1, 2);
+ GroupArgumentsLayout->addWidget(CheckBoxParametric, 6, 0, 1, 4);
/***************************************************************/
GroupButtons = new QGroupBox(this);
SMESHGUI_SmoothingDlg::~SMESHGUI_SmoothingDlg()
{
// no need to delete child widgets, Qt does it all for us
+ if ( myFilterDlg != 0 ) {
+ myFilterDlg->setParent( 0 );
+ delete myFilterDlg;
+ }
}
//=================================================================================
disconnect(mySelectionMgr, 0, this, 0);
mySelectionMgr->clearFilters();
//mySelectionMgr->clearSelected();
- SMESH::SetPickable(); // ???
- SMESH::SetPointRepresentation(false);
+ if (SMESH::GetCurrentVtkView()) {
+ SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters
+ SMESH::SetPointRepresentation(false);
+ SMESH::SetPickable();
+ }
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
aViewWindow->SetSelectionMode(ActorSelection);
mySMESHGUI->ResetState();
QString aString = "";
myBusy = true;
- if (myEditCurrentArgument == (QWidget*)LineEditElements) {
- LineEditElements->setText(aString);
- myNbOkElements = 0;
+ if (myEditCurrentArgument == LineEditElements ||
+ myEditCurrentArgument == LineEditNodes) {
+ myEditCurrentArgument->setText(aString);
+ if (myEditCurrentArgument == LineEditElements)
+ myNbOkElements = 0;
+ else
+ myNbOkNodes = 0;
buttonOk->setEnabled(false);
buttonApply->setEnabled(false);
myActor = 0;
// OK
if (myEditCurrentArgument == LineEditElements)
- myNbOkElements = true;
+ myNbOkElements = aNbUnits;
else if (myEditCurrentArgument == LineEditNodes)
- myNbOkNodes = true;
+ myNbOkNodes = aNbUnits;
if (myNbOkElements && (myNbOkNodes || LineEditNodes->text().trimmed().isEmpty())) {
buttonOk->setEnabled(true);
else
TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
- if (myEditCurrentArgument != LineEditElements) {
+ if (myEditCurrentArgument != LineEditElements &&
+ myEditCurrentArgument != LineEditNodes) {
LineEditElements->clear();
+ LineEditNodes->clear();
return;
}
aViewWindow->SetSelectionMode(ActorSelection);
// mySelectionMgr->setSelectionModes(ActorSelection);
mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
- LineEditElements->setReadOnly(true);
- LineEditElements->setValidator(0);
+ myEditCurrentArgument->setReadOnly(true);
+ myEditCurrentArgument->setValidator(0);
} else {
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
- aViewWindow->SetSelectionMode(FaceSelection);
- LineEditElements->setReadOnly(false);
+ aViewWindow->SetSelectionMode(myEditCurrentArgument == LineEditElements ? FaceSelection
+ : NodeSelection );
+ myEditCurrentArgument->setReadOnly(false);
LineEditElements->setValidator(myIdValidator);
- onTextChange(LineEditElements->text());
+ onTextChange(myEditCurrentArgument->text());
}
SelectionIntoArgument();
ClickOnHelp();
}
}
+
+//=================================================================================
+// function : setFilters()
+// purpose : activate filter dialog
+//=================================================================================
+void SMESHGUI_SmoothingDlg::setFilters( const bool theIsElem )
+{
+ if ( !myFilterDlg )
+ {
+ QList<int> types;
+ types.append( SMESH::NODE );
+ types.append( SMESH::ALL );
+ myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, types );
+ }
+ myFilterDlg->Init( theIsElem ? SMESH::ALL : SMESH::NODE );
+
+ myFilterDlg->SetSelection();
+ myFilterDlg->SetMesh( myMesh );
+ myFilterDlg->SetSourceWg( theIsElem ? LineEditElements : LineEditNodes );
+
+ myFilterDlg->show();
+}
+
+//=================================================================================
+// function : setElemFilters()
+// purpose : SLOT. Called when element "Filter" button pressed.
+//=================================================================================
+void SMESHGUI_SmoothingDlg::setElemFilters()
+{
+ setFilters( true );
+}
+
+//=================================================================================
+// function : setNodeFilters()
+// purpose : SLOT. Called when node "Filter" button pressed.
+//=================================================================================
+void SMESHGUI_SmoothingDlg::setNodeFilters()
+{
+ setFilters( false );
+}
class QComboBox;
class QCheckBox;
class QSpinBox;
+class SMESHGUI;
class SMESHGUI_IdValidator;
class SMESHGUI_SpinBox;
-class SMESHGUI;
+class SMESHGUI_FilterDlg;
class SMESH_Actor;
class SVTK_Selector;
class LightApp_SelectionMgr;
void enterEvent( QEvent* ); /* mouse enter the QWidget */
void hideEvent( QHideEvent* ); /* ESC key */
void keyPressEvent( QKeyEvent* );
+ void setFilters( const bool theIsElem );
SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */
SMESHGUI_IdValidator* myIdValidator;
QString myHelpFileName;
+ SMESHGUI_FilterDlg* myFilterDlg;
+
private slots:
void ClickOnOk();
void ClickOnCancel();
void ActivateThisDialog();
void onTextChange( const QString& );
void onSelectMesh( bool );
+ void setElemFilters();
+ void setNodeFilters();
};
#endif // SMESHGUI_SMOOTHINGDLG_H
#include "SMESHGUI_VTKUtils.h"
#include "SMESHGUI_MeshUtils.h"
#include "SMESHGUI_IdValidator.h"
+#include "SMESHGUI_FilterDlg.h"
#include <SMESH_Actor.h>
#include <SMESH_TypeFilter.hxx>
SMESHGUI_SymmetryDlg::SMESHGUI_SymmetryDlg( SMESHGUI* theModule )
: QDialog( SMESH::GetDesktop( theModule ) ),
mySMESHGUI( theModule ),
- mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
+ mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
+ myFilterDlg(0)
{
QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_SYMMETRY_POINT")));
QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_SYMMETRY_AXIS")));
SelectElementsButton->setIcon(image3);
LineEditElements = new QLineEdit(GroupArguments);
LineEditElements->setValidator(myIdValidator);
+ QPushButton* filterBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), GroupArguments );
+ connect(filterBtn, SIGNAL(clicked()), this, SLOT(setFilters()));
// Control for the whole mesh selection
CheckBoxMesh = new QCheckBox(tr("SMESH_SELECT_WHOLE_MESH"), GroupArguments);
// layout
GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0);
GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1);
- GroupArgumentsLayout->addWidget(LineEditElements, 0, 2, 1, 2);
+ GroupArgumentsLayout->addWidget(LineEditElements, 0, 2, 1, 1);
+ GroupArgumentsLayout->addWidget(filterBtn, 0, 3);
GroupArgumentsLayout->addWidget(CheckBoxMesh, 1, 0, 1, 4);
GroupArgumentsLayout->addWidget(GroupMirror, 2, 0, 1, 4);
GroupArgumentsLayout->addWidget(ActionBox, 3, 0, 3, 3);
//=================================================================================
SMESHGUI_SymmetryDlg::~SMESHGUI_SymmetryDlg()
{
+ if ( myFilterDlg != 0 ) {
+ myFilterDlg->setParent( 0 );
+ delete myFilterDlg;
+ }
}
//=================================================================================
disconnect(mySelectionMgr, 0, this, 0);
mySelectionMgr->clearFilters();
//mySelectionMgr->clearSelected();
- SMESH::SetPointRepresentation(false);
+ if (SMESH::GetCurrentVtkView()) {
+ SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters
+ SMESH::SetPointRepresentation(false);
+ }
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
aViewWindow->SetSelectionMode(ActorSelection);
mySMESHGUI->ResetState();
ClickOnHelp();
}
}
+
+//=================================================================================
+// function : setFilters()
+// purpose : SLOT. Called when "Filter" button pressed.
+//=================================================================================
+void SMESHGUI_SymmetryDlg::setFilters()
+{
+ if ( !myFilterDlg )
+ myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, SMESH::ALL );
+
+ myFilterDlg->SetSelection();
+ myFilterDlg->SetMesh( myMesh );
+ myFilterDlg->SetSourceWg( LineEditElements );
+
+ myFilterDlg->show();
+}
class QPushButton;
class QRadioButton;
class QCheckBox;
+class SMESHGUI;
class SMESHGUI_IdValidator;
class SMESHGUI_SpinBox;
-class SMESHGUI;
+class SMESHGUI_FilterDlg;
class SMESH_Actor;
class SVTK_Selector;
class LightApp_SelectionMgr;
QString myHelpFileName;
+ SMESHGUI_FilterDlg* myFilterDlg;
+
private slots:
void ConstructorsClicked( int );
void ClickOnOk();
void onSelectMesh( bool );
void onVectorChanged();
void onActionClicked( int );
+ void setFilters();
};
#endif // SMESHGUI_SYMMETRYDLG_H
#include "SMESHGUI_VTKUtils.h"
#include "SMESHGUI_MeshUtils.h"
#include "SMESHGUI_IdValidator.h"
+#include "SMESHGUI_FilterDlg.h"
#include <SMESH_Actor.h>
#include <SMESH_TypeFilter.hxx>
SMESHGUI_TranslationDlg::SMESHGUI_TranslationDlg( SMESHGUI* theModule )
: QDialog( SMESH::GetDesktop( theModule ) ),
mySMESHGUI( theModule ),
- mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
+ mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
+ myFilterDlg(0)
{
QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_TRANSLATION_POINTS")));
QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_TRANSLATION_VECTOR")));
SelectElementsButton->setIcon(image2);
LineEditElements = new QLineEdit(GroupArguments);
LineEditElements->setValidator(myIdValidator);
+ QPushButton* filterBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), GroupArguments );
+ connect(filterBtn, SIGNAL(clicked()), this, SLOT(setFilters()));
// Control for the whole mesh selection
CheckBoxMesh = new QCheckBox(tr("SMESH_SELECT_WHOLE_MESH"), GroupArguments);
// layout
GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0);
GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1);
- GroupArgumentsLayout->addWidget(LineEditElements, 0, 2, 1, 6);
+ GroupArgumentsLayout->addWidget(LineEditElements, 0, 2, 1, 5);
+ GroupArgumentsLayout->addWidget(filterBtn, 0, 7);
GroupArgumentsLayout->addWidget(CheckBoxMesh, 1, 0, 1, 8);
GroupArgumentsLayout->addWidget(TextLabel1, 2, 0);
GroupArgumentsLayout->addWidget(SelectButton1, 2, 1);
//=================================================================================
SMESHGUI_TranslationDlg::~SMESHGUI_TranslationDlg()
{
+ if ( myFilterDlg ) {
+ myFilterDlg->setParent( 0 );
+ delete myFilterDlg;
+ myFilterDlg = 0;
+ }
}
//=================================================================================
disconnect(mySelectionMgr, 0, this, 0);
mySelectionMgr->clearFilters();
//mySelectionMgr->clearSelected();
- SMESH::SetPointRepresentation(false);
+ if (SMESH::GetCurrentVtkView()) {
+ SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters
+ SMESH::SetPointRepresentation(false);
+ }
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
aViewWindow->SetSelectionMode( ActorSelection );
mySMESHGUI->ResetState();
ClickOnHelp();
}
}
+
+//=================================================================================
+// function : setFilters()
+// purpose : SLOT. Called when "Filter" button pressed.
+//=================================================================================
+void SMESHGUI_TranslationDlg::setFilters()
+{
+ if ( !myFilterDlg )
+ myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, SMESH::ALL );
+
+ myFilterDlg->SetSelection();
+ myFilterDlg->SetMesh( myMesh );
+ myFilterDlg->SetSourceWg( LineEditElements );
+
+ myFilterDlg->show();
+}
class SMESHGUI;
class SMESHGUI_IdValidator;
class SMESHGUI_SpinBox;
+class SMESHGUI_FilterDlg;
class SMESH_Actor;
class SVTK_Selector;
class LightApp_SelectionMgr;
QLineEdit* LineEditNewMesh;
QString myHelpFileName;
+
+ SMESHGUI_FilterDlg* myFilterDlg;
private slots:
void ConstructorsClicked( int );
void onTextChange( const QString& );
void onSelectMesh( bool );
void onActionClicked( int );
+ void setFilters();
};
#endif // SMESHGUI_TRANSLATIONDLG_H
// SMESH includes
//
#include "SMESHGUI_Utils.h"
-
#include "SMESHGUI.h"
+#include <SMDS_MeshNode.hxx>
+#include <SMDS_MeshFace.hxx>
+
// SALOME GUI includes
#include <SUIT_Desktop.h>
#include <SUIT_Session.h>
#include <SALOME_ListIO.hxx>
+// OCC includes
+#include <gp_XYZ.hxx>
+#include <TColgp_Array1OfXYZ.hxx>
+
namespace SMESH
{
SUIT_Desktop*
_PTR(Study) aStudy = GetActiveStudyDocument();
if (aStudy->GetProperties()->IsLocked())
return;
- _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
- _PTR(GenericAttribute) anAttr =
- aBuilder->FindOrCreateAttribute(theSObject, "AttributeName");
- _PTR(AttributeName) aName = anAttr;
- if (aName)
- aName->SetValue(theName.toLatin1().data());
+ SMESHGUI::GetSMESHGen()->SetName(theSObject->GetIOR().c_str(), theName.toLatin1().data());
}
void SetValue (_PTR(SObject) theSObject, const QString& theValue)
arg(theHelpFileName));
}
}
+
+ //=======================================================================
+ /**
+ Return normale to a given face
+ */
+ //=======================================================================
+ gp_XYZ getNormale( const SMDS_MeshFace* theFace )
+ {
+ gp_XYZ n;
+ int aNbNode = theFace->NbNodes();
+ TColgp_Array1OfXYZ anArrOfXYZ(1,4);
+ SMDS_ElemIteratorPtr aNodeItr = theFace->nodesIterator();
+ int i = 1;
+ for ( ; aNodeItr->more() && i <= 4; i++ ) {
+ SMDS_MeshNode* aNode = (SMDS_MeshNode*)aNodeItr->next();
+ anArrOfXYZ.SetValue(i, gp_XYZ( aNode->X(), aNode->Y(), aNode->Z() ) );
+ }
+
+ gp_XYZ q1 = anArrOfXYZ.Value(2) - anArrOfXYZ.Value(1);
+ gp_XYZ q2 = anArrOfXYZ.Value(3) - anArrOfXYZ.Value(1);
+ n = q1 ^ q2;
+ if ( aNbNode > 3 ) {
+ gp_XYZ q3 = anArrOfXYZ.Value(4) - anArrOfXYZ.Value(1);
+ n += q2 ^ q3;
+ }
+ double len = n.Modulus();
+ if ( len > 0 )
+ n /= len;
+ return n;
+ }
+
} // end of namespace SMESH
#include <SALOME_InteractiveObject.hxx>
#include <LightApp_DataOwner.h>
+//OCC includes
+#include <gp_XYZ.hxx>
+
class SUIT_ViewWindow;
class SUIT_Desktop;
class SUIT_Study;
class SalomeApp_Module;
class LightApp_SelectionMgr;
+class SMDS_MeshFace;
+
namespace SMESH
{
SMESHGUI_EXPORT
SMESHGUI_EXPORT
void ShowHelpFile( const QString& );
+
+ /*!
+ * \brief Return the normal to a face
+ * \param theFace - input face
+ * \retval gp_XYZ - normal to a face
+ */
+SMESHGUI_EXPORT
+ gp_XYZ getNormale( const SMDS_MeshFace* theFace );
+
}
#endif // SMESHGUI_UTILS_H
<source>ICON_COMPUTE</source>
<translation>mesh_compute.png</translation>
</message>
+ <message>
+ <source>ICON_PRECOMPUTE</source>
+ <translation>mesh_precompute.png</translation>
+ </message>
<message>
<source>ICON_CONNECTION</source>
<translation>mesh_multi_edges.png</translation>
<source>ICON_FREE_EDGE</source>
<translation>mesh_free_edges.png</translation>
</message>
- <message>
+ <message>
<source>ICON_FREE_EDGE_2D</source>
<translation>mesh_free_edges_2d.png</translation>
</message>
+ <message>
+ <source>ICON_FREE_NODE</source>
+ <translation>mesh_free_nodes.png</translation>
+ </message>
+ <message>
+ <source>ICON_FREE_FACES</source>
+ <translation>mesh_free_faces.png</translation>
+ </message>
<message>
<source>ICON_HYPO</source>
<translation>mesh_hypo_length.png</translation>
<source>ICON_CLEAR_MESH</source>
<translation>mesh_clear.png</translation>
</message>
+ <message>
+ <source>ICON_UNDERLYING_ELEMS</source>
+ <translation>mesh_extractGroup.png</translation>
+ </message>
</context>
</TS>
<source>MEN_COMPUTE</source>
<translation>Compute</translation>
</message>
+ <message>
+ <source>MEN_PRECOMPUTE</source>
+ <translation>Preview</translation>
+ </message>
<message>
<source>MEN_CONNECTION</source>
<translation>Borders at Multi-Connection</translation>
<source>MEN_EDIT_GROUP</source>
<translation>Edit Group</translation>
</message>
+ <message>
+ <source>MEN_EDIT_GEOMGROUP_AS_GROUP</source>
+ <translation>Edit Group as Standalone</translation>
+ </message>
<message>
<source>MEN_EDIT_HYPO</source>
<translation>Edit Hypothesis</translation>
<source>MEN_FREE_EDGE</source>
<translation>Free Edges</translation>
</message>
+ <message>
+ <source>MEN_FREE_NODE</source>
+ <translation>Free Nodes</translation>
+ </message>
+ <message>
+ <source>MEN_FREE_FACES</source>
+ <translation>Free Faces</translation>
+ </message>
<message>
<source>MEN_GLOBAL_HYPO</source>
<translation>Global Hypothesis</translation>
<source>MEN_UN_GROUP</source>
<translation>Union Groups</translation>
</message>
+ <message>
+ <source>MEN_UNDERLYING_ELEMS</source>
+ <translation>Group of underlying entities</translation>
+ </message>
<message>
<source>MEN_UPDATE</source>
<translation>Update</translation>
<source>SMESH_EDIT_GROUP_TITLE</source>
<translation>Edit Group</translation>
</message>
+ <message>
+ <source>SMESH_EDIT_GEOMGROUP_AS_GROUP_TITLE</source>
+ <translation>Edit Group as Standalone</translation>
+ </message>
<message>
<source>SMESH_EDIT_HYPOTHESES</source>
<translation>Hypotheses Assignation</translation>
<source>STB_COMPUTE</source>
<translation>Compute</translation>
</message>
+ <message>
+ <source>STB_PRECOMPUTE</source>
+ <translation>Preview</translation>
+ </message>
<message>
<source>STB_CONNECTION</source>
<translation>Borders at Multi-Connection</translation>
<source>STB_EDIT_GROUP</source>
<translation>Edit Group</translation>
</message>
+ <message>
+ <source>STB_EDIT_GEOMGROUP_AS_GROUP</source>
+ <translation>Edit Group as Standalone</translation>
+ </message>
<message>
<source>STB_EDIT_HYPO</source>
<translation>Edit Hypothesis</translation>
<source>STB_FREE_EDGE</source>
<translation>Free Edges</translation>
</message>
+ <message>
+ <source>STB_FREE_NODE</source>
+ <translation>Free Nodes</translation>
+ </message>
+
+
+ <message>
+ <source>STB_FREE_FACES</source>
+ <translation>Free Faces</translation>
+ </message>
<message>
<source>STB_GLOBAL_HYPO</source>
<translation>Global Hypothesis</translation>
<source>STB_UN_GROUP</source>
<translation>Union Groups</translation>
</message>
+ <message>
+ <source>STB_UNDERLYING_ELEMS</source>
+ <translation>Create groups of entities from existing groups of superior dimensions</translation>
+ </message>
<message>
<source>STB_UPDATE</source>
<translation>Update</translation>
<source>TOP_COMPUTE</source>
<translation>Compute</translation>
</message>
+ <message>
+ <source>TOP_PRECOMPUTE</source>
+ <translation>Preview</translation>
+ </message>
<message>
<source>TOP_CONNECTION</source>
<translation>Borders at Multi-Connection</translation>
<source>TOP_EDIT_GROUP</source>
<translation>Edit Group</translation>
</message>
+ <message>
+ <source>TOP_EDIT_GEOMGROUP_AS_GROUP</source>
+ <translation>Edit Group as Standalone</translation>
+ </message>
<message>
<source>TOP_EDIT_HYPO</source>
<translation>Edit Hypothesis</translation>
<source>TOP_FREE_EDGE</source>
<translation>Free Edges</translation>
</message>
+ <message>
+ <source>TOP_FREE_NODE</source>
+ <translation>Free Nodes</translation>
+ </message>
+
+
+ <message>
+ <source>TOP_FREE_FACES</source>
+ <translation>Free Faces</translation>
+ </message>
<message>
<source>TOP_GLOBAL_HYPO</source>
<translation>Global Hypothesis</translation>
<source>TOP_UN_GROUP</source>
<translation>Union Groups</translation>
</message>
+ <message>
+ <source>TOP_UNDERLYING_ELEMS</source>
+ <translation>Create groups of entities from existing groups of superior dimensions</translation>
+ </message>
<message>
<source>TOP_UPDATE</source>
<translation>Update</translation>
<source>PREF_AUTO_GROUPS</source>
<translation>Automatically create groups for MED export</translation>
</message>
+ <message>
+ <source>PREF_GROUP_SEGMENT_LENGTH</source>
+ <translation>Segment length</translation>
+ </message>
+ <message>
+ <source>PREF_SEGMENT_LENGTH</source>
+ <translation>Segmentation of diagonal of boundary box of geometry</translation>
+ </message>
<message>
<source>PREF_AUTO_UPDATE</source>
<translation>Automatic update</translation>
<translation>Show bad Mesh</translation>
</message>
</context>
+ <context>
+ <name>SMESHGUI_PrecomputeDlg</name>
+ <message>
+ <source>CAPTION</source>
+ <translation>Preview and Compute mesh</translation>
+ </message>
+ <message>
+ <source>PREVIEW</source>
+ <translation>Preview</translation>
+ </message>
+ <message>
+ <source>PREVIEW_1</source>
+ <translation>1D Mesh</translation>
+ </message>
+ <message>
+ <source>PREVIEW_2</source>
+ <translation>2D Mesh</translation>
+ </message>
+ <message>
+ <source>COMPUTE</source>
+ <translation>Compute</translation>
+ </message>
+ </context>
+ <context>
+ <name>SMESHGUI_PrecomputeOp</name>
+ <message>
+ <source>CLEAR_SUBMESH_QUESTION</source>
+ <translation>A temporary submeshes on the selected geometry
+ created during preview operation.
+ Do you want to remove all this submeshes?</translation>
+ </message>
+ </context>
<context>
<name>SMESHGUI_ConvToQuadDlg</name>
<message>
Please select valid object and try again</translation>
</message>
<message>
- <source>CURRENT_GROUP</source>
- <translation>Current Group</translation>
+ <source>CURRENT_DIALOG</source>
+ <translation>Current Dialog</translation>
</message>
<message>
<source>EDGES_TLT</source>
<source>FREE_EDGES</source>
<translation>Free edges</translation>
</message>
+ <message>
+ <source>FREE_NODES</source>
+ <translation>Free nodes</translation>
+ </message>
+
+
+ <message>
+ <source>FREE_FACES</source>
+ <translation>Free faces</translation>
+ </message>
<message>
<source>ID</source>
<translation>ID</translation>
<source>LENGTH</source>
<translation>Length</translation>
</message>
+ <message>
+ <source>LENGTH2D</source>
+ <translation>Length 2D</translation>
+ </message>
<message>
<source>LESS_THAN</source>
<translation>Less than</translation>
<message>
<source>MULTIEDGES_ERROR</source>
<translation>Threshold value of borders at multi-connections can not be equal 1
+Please enter correct value and try again</translation>
+ </message>
+ <message>
+ <source>GROUPCOLOR_ERROR</source>
+ <translation>Color of group can not be undefied
Please enter correct value and try again</translation>
</message>
<message>
<source>WARPING</source>
<translation>Warping</translation>
</message>
+ <message>
+ <source>LINEAR</source>
+ <translation>Linear</translation>
+ </message>
+ <message>
+ <source>GROUP_COLOR</source>
+ <translation>Color of Group</translation>
+ </message>
+ <message>
+ <source>ELEMENTS</source>
+ <translation>Elements</translation>
+ </message>
+ <message>
+ <source>GEOM_TYPE</source>
+ <translation>Geomtry type</translation>
+ </message>
+ <message>
+ <source>GEOM_TYPE_0</source>
+ <translation></translation>
+ </message>
+ <message>
+ <source>GEOM_TYPE_0</source>
+ <translation>Point</translation>
+ </message>
+ <message>
+ <source>GEOM_TYPE_1</source>
+ <translation>Edge</translation>
+ </message>
+ <message>
+ <source>GEOM_TYPE_2</source>
+ <translation>Triangle</translation>
+ </message>
+ <message>
+ <source>GEOM_TYPE_3</source>
+ <translation>Quadrangle</translation>
+ </message>
+ <message>
+ <source>GEOM_TYPE_4</source>
+ <translation>Polygon</translation>
+ </message>
+ <message>
+ <source>GEOM_TYPE_5</source>
+ <translation>Tetrahedron</translation>
+ </message>
+ <message>
+ <source>GEOM_TYPE_6</source>
+ <translation>Pyramid</translation>
+ </message>
+ <message>
+ <source>GEOM_TYPE_7</source>
+ <translation>Hexahedron</translation>
+ </message>
+ <message>
+ <source>GEOM_TYPE_8</source>
+ <translation>Pentahedron</translation>
+ </message>
+ <message>
+ <source>GEOM_TYPE_9</source>
+ <translation>Polyhedra</translation>
+ </message>
</context>
<context>
<name>SMESHGUI_GroupOpDlg</name>
<source>ARGUMENTS</source>
<translation>Arguments</translation>
</message>
- <message>
- <source>CUT_OF_TWO_GROUPS</source>
- <translation>Cut of two groups</translation>
- </message>
<message>
<source>DIFF_MESHES</source>
<translation>Arguments of operation are not correctly specified
<translation>Arguments of operation are not specified
Please specify them and try again</translation>
</message>
- <message>
- <source>INTERSECTION_OF_TWO_GROUPS</source>
- <translation>Intersection of two groups</translation>
- </message>
- <message>
- <source>MAIN_OBJECT</source>
- <translation>Main object</translation>
- </message>
<message>
<source>NAME</source>
<translation>Name</translation>
<translation>Union of two groups</translation>
</message>
</context>
+ <context>
+ <name>SMESHGUI_UnionGroupsDlg</name>
+ <message>
+ <source>UNION_OF_GROUPS</source>
+ <translation>Union of groups</translation>
+ </message>
+ </context>
+ <context>
+ <name>SMESHGUI_DimGroupDlg</name>
+ <message>
+ <source>CREATE_GROUP_OF_UNDERLYING_ELEMS</source>
+ <translation>Create group of underlying entities</translation>
+ </message>
+ <message>
+ <source>ELEMENTS_TYPE</source>
+ <translation>Elements type</translation>
+ </message>
+ <message>
+ <source>NODE</source>
+ <translation>Node</translation>
+ </message>
+ <message>
+ <source>EDGE</source>
+ <translation>Edge</translation>
+ </message>
+ <message>
+ <source>FACE</source>
+ <translation>Face</translation>
+ </message>
+ <message>
+ <source>VOLUME</source>
+ <translation>Volume</translation>
+ </message>
+ </context>
+ <context>
+ <name>SMESHGUI_IntersectGroupsDlg</name>
+ <message>
+ <source>INTERSECTION_OF_GROUPS</source>
+ <translation>Intersection of groups</translation>
+ </message>
+ </context>
+ <context>
+ <name>SMESHGUI_CutGroupsDlg</name>
+ <message>
+ <source>CUT_OF_GROUPS</source>
+ <translation>Cut of groups</translation>
+ </message>
+ <message>
+ <source>MAIN_OBJECT</source>
+ <translation>Main object</translation>
+ </message>
+ <message>
+ <source>TOOL_OBJECT</source>
+ <translation>Tool object</translation>
+ </message>
+ </context>
<context>
<name>SMESHGUI_MakeNodeAtPointDlg</name>
<message>
<source>TOTAL_ANGLE</source>
<translation>Total Angle</translation>
</message>
+ <message>
+ <source>MEN_POINT_SELECT</source>
+ <translation>Select Point</translation>
+ </message>
+ <message>
+ <source>MEN_FACE_SELECT</source>
+ <translation>Select Plane</translation>
+ </message>
</context>
<context>
<name>SMESHGUI_SewingDlg</name>
# Author : Paul RASCLE, EDF
# Modified by : Alexander BORODIN (OCN) - autotools usage
# Module : SMESH
-# $Header$
#
include $(top_srcdir)/adm_local/unix/make_common_starter.am
-lSalomeGenericObj \
$(MED_LDFLAGS) \
-lMEDWrapper_V2_2 \
+ -lSalomeIDLMED \
$(CAS_LDPATH) \
-lTKCDF \
-lTKBO \
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
-// File : SMESH_2D_Algo_i.hxx
-// Author : Paul RASCLE, EDF
-// Module : SMESH
-// $Header$
-
+//
// File : SMESH_2smeshpy.cxx
// Created : Fri Nov 18 13:20:10 2005
// Author : Edward AGAPOV (eap)
IMPLEMENT_STANDARD_HANDLE (_pyCommand ,Standard_Transient);
IMPLEMENT_STANDARD_HANDLE (_pyGen ,_pyObject);
IMPLEMENT_STANDARD_HANDLE (_pyMesh ,_pyObject);
+IMPLEMENT_STANDARD_HANDLE (_pySubMesh ,_pyObject);
IMPLEMENT_STANDARD_HANDLE (_pyMeshEditor ,_pyObject);
IMPLEMENT_STANDARD_HANDLE (_pyHypothesis ,_pyObject);
+IMPLEMENT_STANDARD_HANDLE (_pyFilterManager ,_pyObject);
IMPLEMENT_STANDARD_HANDLE (_pyAlgorithm ,_pyHypothesis);
IMPLEMENT_STANDARD_HANDLE (_pyComplexParamHypo,_pyHypothesis);
IMPLEMENT_STANDARD_HANDLE (_pyNumberOfSegmentsHyp,_pyHypothesis);
IMPLEMENT_STANDARD_RTTIEXT(_pyCommand ,Standard_Transient);
IMPLEMENT_STANDARD_RTTIEXT(_pyGen ,_pyObject);
IMPLEMENT_STANDARD_RTTIEXT(_pyMesh ,_pyObject);
+IMPLEMENT_STANDARD_RTTIEXT(_pySubMesh ,_pyObject);
IMPLEMENT_STANDARD_RTTIEXT(_pyMeshEditor ,_pyObject);
IMPLEMENT_STANDARD_RTTIEXT(_pyHypothesis ,_pyObject);
+IMPLEMENT_STANDARD_RTTIEXT(_pyFilterManager ,_pyObject);
IMPLEMENT_STANDARD_RTTIEXT(_pyAlgorithm ,_pyHypothesis);
IMPLEMENT_STANDARD_RTTIEXT(_pyComplexParamHypo,_pyHypothesis);
IMPLEMENT_STANDARD_RTTIEXT(_pyNumberOfSegmentsHyp,_pyHypothesis);
TCollection_AsciiString
SMESH_2smeshpy::ConvertScript(const TCollection_AsciiString& theScript,
- Resource_DataMapOfAsciiStringAsciiString& theEntry2AccessorMethod)
+ Resource_DataMapOfAsciiStringAsciiString& theEntry2AccessorMethod,
+ Resource_DataMapOfAsciiStringAsciiString& theObjectNames)
{
- theGen = new _pyGen( theEntry2AccessorMethod );
+ theGen = new _pyGen( theEntry2AccessorMethod, theObjectNames );
// split theScript into separate commands
int from = 1, end = theScript.Length(), to;
theGen->AddCommand( theScript.SubString( from, to - 1 ));
from = to + 1;
}
+
// finish conversion
theGen->Flush();
#ifdef DUMP_CONVERSION
MESSAGE_BEGIN ( std::endl << " ######## RESULT ######## " << std::endl<< std::endl );
#endif
+
// reorder commands after conversion
list< Handle(_pyCommand) >::iterator cmd;
bool orderChanges;
*/
//================================================================================
-_pyGen::_pyGen(Resource_DataMapOfAsciiStringAsciiString& theEntry2AccessorMethod)
+_pyGen::_pyGen(Resource_DataMapOfAsciiStringAsciiString& theEntry2AccessorMethod,
+ Resource_DataMapOfAsciiStringAsciiString& theObjectNames)
: _pyObject( new _pyCommand( TPythonDump::SMESHGenName(), 0 )),
- myID2AccessorMethod( theEntry2AccessorMethod )
+ myID2AccessorMethod( theEntry2AccessorMethod ),
+ myObjectNames( theObjectNames )
{
myNbCommands = 0;
myHasPattern = false;
this->Process( aCommand );
return aCommand;
}
+
+ // SMESH_subMesh method?
+ map< _pyID, Handle(_pySubMesh) >::iterator id_subMesh = mySubMeshes.find( objID );
+ if ( id_subMesh != mySubMeshes.end() ) {
+ id_subMesh->second->Process( aCommand );
+ return aCommand;
+ }
+
// SMESH_Mesh method?
map< _pyID, Handle(_pyMesh) >::iterator id_mesh = myMeshes.find( objID );
if ( id_mesh != myMeshes.end() ) {
+ // check for mesh editor object
if ( aCommand->GetMethod() == "GetMeshEditor" ) { // MeshEditor creation
_pyID editorID = aCommand->GetResultValue();
Handle(_pyMeshEditor) editor = new _pyMeshEditor( aCommand );
myMeshEditors.insert( make_pair( editorID, editor ));
return aCommand;
+ }
+ // check for SubMesh objects
+ else if ( aCommand->GetMethod() == "GetSubMesh" ) { // SubMesh creation
+ _pyID subMeshID = aCommand->GetResultValue();
+ Handle(_pySubMesh) subMesh = new _pySubMesh( aCommand );
+ mySubMeshes.insert( make_pair( subMeshID, subMesh ));
}
id_mesh->second->Process( aCommand );
return aCommand;
}
+
+ //SMESH_FilterManager method?
+ if ( theCommand.Search( "aFilterManager" ) != -1 ) {
+ if ( theCommand.Search( "CreateFilterManager" ) != -1 )
+ myFilterManager = new _pyFilterManager( aCommand );
+ else if ( !myFilterManager.IsNull() )
+ myFilterManager->Process( aCommand );
+ return aCommand;
+ }
+
// SMESH_MeshEditor method?
map< _pyID, Handle(_pyMeshEditor) >::iterator id_editor = myMeshEditors.find( objID );
if ( id_editor != myMeshEditors.end() ) {
// Compute( mesh, geom )
// mesh creation
TCollection_AsciiString method = theCommand->GetMethod();
+
if ( method == "CreateMesh" || method == "CreateEmptyMesh")
{
Handle(_pyMesh) mesh = new _pyMesh( theCommand );
// CreateHypothesis()
if ( method == "CreateHypothesis" )
{
+ // issue 199929, remove standard library name (default parameter)
+ const TCollection_AsciiString & aLibName = theCommand->GetArg( 2 );
+ if ( aLibName.Search( "StdMeshersEngine" ) != -1 ) {
+ // keep first argument
+ TCollection_AsciiString arg = theCommand->GetArg( 1 );
+ theCommand->RemoveArgs();
+ theCommand->SetArg( 1, arg );
+ }
+
myHypos.push_back( _pyHypothesis::NewHypothesis( theCommand ));
return;
}
void _pyGen::Flush()
{
+ // create empty command
+ myLastCommand = new _pyCommand();
+
+ if ( !myFilterManager.IsNull() )
+ myFilterManager->Flush();
+
map< _pyID, Handle(_pyMesh) >::iterator id_mesh = myMeshes.begin();
for ( ; id_mesh != myMeshes.end(); ++id_mesh )
if ( ! id_mesh->second.IsNull() )
if ( !(*hyp)->IsWrapped() )
(*hyp)->GetCreationCmd()->SetObject( SMESH_2smeshpy::GenName() );
}
+
+ map< _pyID, Handle(_pySubMesh) >::iterator id_subMesh = mySubMeshes.begin();
+ for ( ; id_subMesh != mySubMeshes.end(); ++id_subMesh )
+ if ( ! id_subMesh->second.IsNull() )
+ id_subMesh->second->Flush();
+
+ myLastCommand->SetOrderNb( ++myNbCommands );
+ myCommands.push_back( myLastCommand );
}
//================================================================================
if ( !hyp->IsNull() &&
(*hyp)->IsAlgo() &&
theHypothesis->CanBeCreatedBy( (*hyp)->GetAlgoType() ) &&
- (*hyp)->GetGeom() == theGeom &&
+ (*hyp)->GetGeom() == theGeom &&
(*hyp)->GetMesh() == theMesh )
return *hyp;
return 0;
}
+//================================================================================
+/*!
+ * \brief Find subMesh by ID (entry)
+ * \param theSubMeshID - The subMesh ID
+ * \retval Handle(_pySubMesh) - The found subMesh
+ */
+//================================================================================
+
+Handle(_pySubMesh) _pyGen::FindSubMesh( const _pyID& theSubMeshID )
+{
+ map< _pyID, Handle(_pySubMesh) >::iterator id_subMesh = mySubMeshes.begin();
+ for ( ; id_subMesh != mySubMeshes.end(); ++id_subMesh ) {
+ Handle(_pySubMesh) sm = id_subMesh->second;
+ if ( !id_subMesh->second.IsNull() && theSubMeshID == id_subMesh->second->GetID() )
+ return sm;
+ }
+ return Handle(_pySubMesh)();
+}
+
+
//================================================================================
/*!
* \brief Change order of commands in the script
void _pyGen::SetCommandAfter( Handle(_pyCommand) theCmd, Handle(_pyCommand) theAfterCmd )
{
-#ifdef _DEBUG_
-//cout << "SET\t" << theAfterCmd->GetString() << endl << "BEFORE\t" << theCmd->GetString() << endl<<endl;
-#endif
+ setNeighbourCommand( theCmd, theAfterCmd, true );
+}
+
+//================================================================================
+/*!
+ * \brief Set one command before the other
+ * \param theCmd - Command to move
+ * \param theBeforeCmd - Command before which to insert the first one
+ */
+//================================================================================
+
+void _pyGen::SetCommandBefore( Handle(_pyCommand) theCmd, Handle(_pyCommand) theBeforeCmd )
+{
+ setNeighbourCommand( theCmd, theBeforeCmd, false );
+}
+
+//================================================================================
+/*!
+ * \brief Set one command before or after the other
+ * \param theCmd - Command to move
+ * \param theOtherCmd - Command ater or before which to insert the first one
+ */
+//================================================================================
+
+void _pyGen::setNeighbourCommand( Handle(_pyCommand)& theCmd,
+ Handle(_pyCommand)& theOtherCmd,
+ const bool theIsAfter )
+{
list< Handle(_pyCommand) >::iterator pos;
pos = find( myCommands.begin(), myCommands.end(), theCmd );
myCommands.erase( pos );
- pos = find( myCommands.begin(), myCommands.end(), theAfterCmd );
- myCommands.insert( ++pos, theCmd );
+ pos = find( myCommands.begin(), myCommands.end(), theOtherCmd );
+ myCommands.insert( (theIsAfter ? ++pos : pos), theCmd );
int i = 1;
for ( pos = myCommands.begin(); pos != myCommands.end(); ++pos)
(*pos)->SetOrderNb( i++ );
}
+//================================================================================
+/*!
+ * \brief Set command be last in list of commands
+ * \param theCmd - Command to be last
+ */
+//================================================================================
+
+Handle(_pyCommand)& _pyGen::GetLastCommand()
+{
+ return myLastCommand;
+}
+
//================================================================================
/*!
* \brief Set method to access to object wrapped with python class
myID2AccessorMethod.Bind( theID, (char*) theMethod );
}
+//================================================================================
+/*!
+ * \brief Generated new ID for object and assign with existing name
+ * \param theID - ID of existing object
+ */
+//================================================================================
+
+_pyID _pyGen::GenerateNewID( const _pyID& theID )
+{
+ int index = 1;
+ _pyID aNewID;
+ do {
+ aNewID = theID + _pyID( ":" ) + _pyID( index++ );
+ }
+ while ( myObjectNames.IsBound( aNewID ) );
+
+ myObjectNames.Bind( aNewID, myObjectNames.IsBound( theID )
+ ? (myObjectNames.Find( theID ) + _pyID( "_" ) + _pyID( index-1 ))
+ : _pyID( "A" ) + aNewID );
+ return aNewID;
+}
+
//================================================================================
/*!
* \brief Find out type of geom group
const TCollection_AsciiString method = theCommand->GetMethod();
// ----------------------------------------------------------------------
if ( method == "GetSubMesh" ) {
- mySubmeshes.push_back( theCommand );
+ Handle(_pySubMesh) subMesh = theGen->FindSubMesh( theCommand->GetResultValue() );
+ if ( !subMesh.IsNull() ) {
+ subMesh->SetCreator( this );
+ mySubmeshes.push_back( subMesh );
+ }
}
// ----------------------------------------------------------------------
else if ( method == "AddHypothesis" ) { // mesh.AddHypothesis(geom, HYPO )
theCommand->SetArg( 1, grp );
}
else {
- AddMeshAccess( theCommand );
+ _pyID type = theCommand->GetArg( 1 );
+ _pyID name = theCommand->GetArg( 2 );
+ theCommand->SetMethod( "GroupOnGeom" );
+ theCommand->RemoveArgs();
+ theCommand->SetArg( 1, grp );
+ theCommand->SetArg( 2, name );
+ theCommand->SetArg( 3, type );
}
}
// ----------------------------------------------------------------------
"GetNodeInverseElements","GetShapeID","GetShapeIDForElem","GetElemNbNodes",
"GetElemNode","IsMediumNode","IsMediumNodeOfAnyElem","ElemNbEdges","ElemNbFaces",
"IsPoly","IsQuadratic","BaryCenter","GetHypothesisList", "SetAutoColor", "GetAutoColor",
- "Clear"
+ "Clear", "ConvertToStandalone"
,"" }; // <- mark of end
sameMethods.Insert( names );
}
void _pyMesh::Flush()
{
- list < Handle(_pyCommand) >::iterator cmd, cmd2;
+ list < Handle(_pyCommand) >::iterator cmd;
// try to convert algo addition like this:
// mesh.AddHypothesis(geom, ALGO ) --> ALGO = mesh.Algo()
for ( cmd = myAddHypCmds.begin(); cmd != myAddHypCmds.end(); ++cmd )
{
Handle(_pyCommand) addCmd = *cmd;
+
_pyID algoID = addCmd->GetArg( 2 );
Handle(_pyHypothesis) algo = theGen->FindHyp( algoID );
if ( algo.IsNull() || !algo->IsAlgo() )
continue;
- // try to convert
+
+ // check and create new algorithm instance if it is already wrapped
+ if ( algo->IsWrapped() ) {
+ _pyID localAlgoID = theGen->GenerateNewID( algoID );
+ TCollection_AsciiString aNewCmdStr = localAlgoID +
+ TCollection_AsciiString( " = " ) + theGen->GetID() +
+ TCollection_AsciiString( ".CreateHypothesis( \"" ) + algo->GetAlgoType() +
+ TCollection_AsciiString( "\" )" );
+
+ Handle(_pyCommand) newCmd = theGen->AddCommand( aNewCmdStr );
+ Handle(_pyAlgorithm) newAlgo = Handle(_pyAlgorithm)::DownCast(theGen->FindHyp( localAlgoID ));
+ if ( !newAlgo.IsNull() ) {
+ newAlgo->Assign( algo, this->GetID() );
+ newAlgo->SetCreationCmd( newCmd );
+ algo = newAlgo;
+ // set algorithm creation
+ theGen->SetCommandBefore( newCmd, addCmd );
+ }
+ else
+ newCmd->Clear();
+ }
_pyID geom = addCmd->GetArg( 1 );
bool isLocalAlgo = ( geom != GetGeom() );
+
+ // try to convert
if ( algo->Addition2Creation( addCmd, this->GetID() )) // OK
{
// wrapped algo is created atfer mesh creation
addCmd->SetArg( addCmd->GetNbArgs() + 1,
TCollection_AsciiString( "geom=" ) + geom );
// sm = mesh.GetSubMesh(geom, name) --> sm = ALGO.GetSubMesh()
- for ( cmd2 = mySubmeshes.begin(); cmd2 != mySubmeshes.end(); ++cmd2 ) {
- Handle(_pyCommand) subCmd = *cmd2;
+ list < Handle(_pySubMesh) >::iterator smIt;
+ for ( smIt = mySubmeshes.begin(); smIt != mySubmeshes.end(); ++smIt ) {
+ Handle(_pySubMesh) subMesh = *smIt;
+ Handle(_pyCommand) subCmd = subMesh->GetCreationCmd();
if ( geom == subCmd->GetArg( 1 )) {
subCmd->SetObject( algo->GetID() );
subCmd->RemoveArgs();
- addCmd->AddDependantCmd( subCmd );
+ subMesh->SetCreator( algo );
}
}
}
// i.e. convertion result will be "locallength = regular1d.LocalLength(<arg of SetLength()>)"
hyp->AddArgMethod( "SetLength" );
}
+ else if ( hypType == "MaxLength" ) {
+ // set algo's method creating hyp, and algo type
+ hyp->SetConvMethodAndType( "MaxSize", "Regular_1D");
+ // set method whose 1 arg will become the 1-st arg of hyp creation command
+ // i.e. convertion result will be "maxsize = regular1d.MaxSize(<arg of SetLength()>)"
+ hyp->AddArgMethod( "SetLength" );
+ }
else if ( hypType == "NumberOfSegments" ) {
hyp = new _pyNumberOfSegmentsHyp( theCreationCmd );
hyp->SetConvMethodAndType( "NumberOfSegments", "Regular_1D");
algo = theGen->FindAlgo( myGeom, theMesh, this );
if ( algo.IsNull() )
return false;
+ // attach hypothesis creation command to be after algo creation command
+ // because it can be new created instance of algorithm
algo->GetCreationCmd()->AddDependantCmd( theCmd );
}
myIsWrapped = true;
}
// set a new creation command
GetCreationCmd()->Clear();
+ // replace creation command by wrapped instance
+ // please note, that hypothesis attaches to algo creation command (see upper)
SetCreationCmd( theCmd );
+
// clear commands setting arg values
list < Handle(_pyCommand) >::iterator argCmd = myArgCommands.begin();
( *cmd )->Clear();
}
+
+//================================================================================
+/*!
+ * \brief Assign fields of theOther to me except myIsWrapped
+ */
+//================================================================================
+
+void _pyHypothesis::Assign( const Handle(_pyHypothesis)& theOther,
+ const _pyID& theMesh )
+{
+ myIsWrapped = false;
+ myMesh = theMesh;
+
+ // myCreationCmd = theOther->myCreationCmd;
+ myIsAlgo = theOther->myIsAlgo;
+ myGeom = theOther->myGeom;
+ myType2CreationMethod = theOther->myType2CreationMethod;
+ myArgs = theOther->myArgs;
+ myArgMethods = theOther->myArgMethods;
+ myNbArgsByMethod = theOther->myNbArgsByMethod;
+ myArgCommands = theOther->myArgCommands;
+ myUnknownCommands = theOther->myUnknownCommands;
+}
+
//================================================================================
/*!
* \brief Remember hypothesis parameter values
//================================================================================
/*!
* \brief
- * \param theAdditionCmd -
- * \param theMesh -
- * \retval bool -
+ * \param theAdditionCmd - command to be converted
+ * \param theMesh - mesh instance
+ * \retval bool - status
*/
//================================================================================
return childID.SubString( 1, colPos-1 );
return "";
}
+
+//================================================================================
+/*!
+ * \brief FilterManager creates only if at least one command invoked
+ */
+//================================================================================
+
+_pyFilterManager::_pyFilterManager(const Handle(_pyCommand)& theCreationCmd):
+ _pyObject( theCreationCmd ),
+ myCmdCount( 0 )
+{
+}
+
+//================================================================================
+/*!
+ * \brief count invoked commands
+ */
+//================================================================================
+
+void _pyFilterManager::Process( const Handle(_pyCommand)& /*theCommand*/)
+{
+ myCmdCount++;
+}
+
+//================================================================================
+/*!
+ * \brief Clear creatin command if no commands invoked
+ */
+//================================================================================
+
+void _pyFilterManager::Flush()
+{
+ if ( !myCmdCount )
+ GetCreationCmd()->Clear();
+}
+
+
+//================================================================================
+/*!
+ * \brief SubMesh creation can be moved to the end of engine commands
+ */
+//================================================================================
+
+_pySubMesh::_pySubMesh(const Handle(_pyCommand)& theCreationCmd):
+ _pyObject( theCreationCmd ),
+ myCmdCount( 0 )
+{
+}
+
+//================================================================================
+/*!
+ * \brief count invoked commands
+ */
+//================================================================================
+
+void _pySubMesh::Process( const Handle(_pyCommand)& theCommand )
+{
+ myCmdCount++;
+ GetCreationCmd()->AddDependantCmd( theCommand );
+}
+
+//================================================================================
+/*!
+ * \brief Clear creatin command if no commands invoked
+ */
+//================================================================================
+
+void _pySubMesh::Flush()
+{
+ if ( !myCmdCount ) // move to the end of all commands
+ theGen->GetLastCommand()->AddDependantCmd( GetCreationCmd() );
+ else if ( !myCreator.IsNull() )
+ // move to be just after creator
+ myCreator->GetCreationCmd()->AddDependantCmd( GetCreationCmd() );
+}
class _pyObject;
class _pyGen;
class _pyMesh;
+class _pySubMesh;
class _pyHypothesis;
class _pyAlgorithm;
+class _pyFilterManager;
DEFINE_STANDARD_HANDLE (_pyCommand ,Standard_Transient);
DEFINE_STANDARD_HANDLE (_pyObject ,Standard_Transient);
DEFINE_STANDARD_HANDLE (_pyGen ,_pyObject);
DEFINE_STANDARD_HANDLE (_pyMesh ,_pyObject);
+DEFINE_STANDARD_HANDLE (_pySubMesh ,_pyObject);
DEFINE_STANDARD_HANDLE (_pyMeshEditor,_pyObject);
DEFINE_STANDARD_HANDLE (_pyHypothesis,_pyObject);
+DEFINE_STANDARD_HANDLE (_pyFilterManager,_pyObject);
DEFINE_STANDARD_HANDLE (_pyAlgorithm ,_pyHypothesis);
typedef TCollection_AsciiString _pyID;
class _pyGen: public _pyObject
{
public:
- _pyGen(Resource_DataMapOfAsciiStringAsciiString& theEntry2AccessorMethod);
+ _pyGen(Resource_DataMapOfAsciiStringAsciiString& theEntry2AccessorMethod,
+ Resource_DataMapOfAsciiStringAsciiString& theObjectNames);
//~_pyGen();
Handle(_pyCommand) AddCommand( const TCollection_AsciiString& theCommand );
void Process( const Handle(_pyCommand)& theCommand );
Handle(_pyHypothesis) FindHyp( const _pyID& theHypID );
Handle(_pyHypothesis) FindAlgo( const _pyID& theGeom, const _pyID& theMesh,
const Handle(_pyHypothesis)& theHypothesis);
+ Handle(_pySubMesh) FindSubMesh( const _pyID& theSubMeshID );
void ExchangeCommands( Handle(_pyCommand) theCmd1, Handle(_pyCommand) theCmd2 );
void SetCommandAfter( Handle(_pyCommand) theCmd, Handle(_pyCommand) theAfterCmd );
+ void SetCommandBefore( Handle(_pyCommand) theCmd, Handle(_pyCommand) theBeforeCmd );
+ Handle(_pyCommand)& GetLastCommand();
std::list< Handle(_pyCommand) >& GetCommands() { return myCommands; }
void SetAccessorMethod(const _pyID& theID, const char* theMethod );
bool AddMeshAccessorMethod( Handle(_pyCommand) theCmd ) const;
bool AddAlgoAccessorMethod( Handle(_pyCommand) theCmd ) const;
const char* AccessorMethod() const;
+ _pyID GenerateNewID( const _pyID& theID );
+
+private:
+ void setNeighbourCommand( Handle(_pyCommand)& theCmd,
+ Handle(_pyCommand)& theOtherCmd,
+ const bool theIsAfter );
+
private:
std::map< _pyID, Handle(_pyMesh) > myMeshes;
+ std::map< _pyID, Handle(_pySubMesh) > mySubMeshes;
std::map< _pyID, Handle(_pyMeshEditor) > myMeshEditors;
std::list< Handle(_pyHypothesis) > myHypos;
std::list< Handle(_pyCommand) > myCommands;
int myNbCommands;
bool myHasPattern;
Resource_DataMapOfAsciiStringAsciiString& myID2AccessorMethod;
+ Resource_DataMapOfAsciiStringAsciiString& myObjectNames;
+ Handle(_pyCommand) myLastCommand;
+ Handle(_pyFilterManager) myFilterManager;
DEFINE_STANDARD_RTTI (_pyGen)
};
{
std::list< Handle(_pyHypothesis) > myHypos;
std::list< Handle(_pyCommand) > myAddHypCmds;
- std::list< Handle(_pyCommand) > mySubmeshes;
+ std::list< Handle(_pySubMesh) > mySubmeshes;
bool myHasEditor;
public:
_pyMesh(const Handle(_pyCommand) creationCmd);
{ return myType2CreationMethod.find( algoType ) != myType2CreationMethod.end(); }
const TCollection_AsciiString& GetCreationMethod(const TCollection_AsciiString& algoType) const
{ return myType2CreationMethod.find( algoType )->second; }
- bool IsWrappable(const _pyID& theMesh) { return !myIsWrapped && myMesh == theMesh; }
+ virtual bool IsWrappable(const _pyID& theMesh) { return !myIsWrapped && myMesh == theMesh; }
virtual bool Addition2Creation( const Handle(_pyCommand)& theAdditionCmd,
const _pyID& theMesh);
static Handle(_pyHypothesis) NewHypothesis( const Handle(_pyCommand)& theCreationCmd);
void Process( const Handle(_pyCommand)& theCommand);
void Flush();
+ virtual void Assign( const Handle(_pyHypothesis)& theOther,
+ const _pyID& theMesh );
DEFINE_STANDARD_RTTI (_pyHypothesis)
};
virtual bool Addition2Creation( const Handle(_pyCommand)& theAdditionCmd,
const _pyID& theMesh);
const char* AccessorMethod() const { return "GetAlgorithm()"; }
+ virtual bool IsWrappable(const _pyID& theMesh) { return !myIsWrapped; }
DEFINE_STANDARD_RTTI (_pyAlgorithm)
};
};
DEFINE_STANDARD_HANDLE (_pySegmentLengthAroundVertexHyp, _pyHypothesis);
+// -------------------------------------------------------------------------------------
+/*!
+ * \brief FilterManager creates only if at least one command invoked
+ */
+// -------------------------------------------------------------------------------------
+class _pyFilterManager: public _pyObject
+{
+public:
+ _pyFilterManager(const Handle(_pyCommand)& theCreationCmd);
+ void Process( const Handle(_pyCommand)& theCommand);
+ virtual void Flush();
+
+ DEFINE_STANDARD_RTTI (_pyFilterManager)
+private:
+ int myCmdCount;
+};
+
+// -------------------------------------------------------------------------------------
+/*!
+ * \brief SubMesh creation can be moved to the end of engine commands
+ */
+// -------------------------------------------------------------------------------------
+class _pySubMesh: public _pyObject
+{
+public:
+ _pySubMesh(const Handle(_pyCommand)& theCreationCmd);
+ void Process( const Handle(_pyCommand)& theCommand);
+ virtual void Flush();
+ void SetCreator( const Handle(_pyObject)& theCreator ) { myCreator = theCreator; }
+
+ DEFINE_STANDARD_RTTI (_pyFilterManager)
+private:
+ int myCmdCount;
+ Handle(_pyObject) myCreator;
+};
+
#endif
{
if(--myCounter == 0){
SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
+ std::string aString = myStream.str();
+ TCollection_AsciiString aCollection(Standard_CString(aString.c_str()));
SALOMEDS::Study_ptr aStudy = aSMESHGen->GetCurrentStudy();
- if(!aStudy->_is_nil()){
- std::string aString = myStream.str();
- TCollection_AsciiString aCollection(Standard_CString(aString.c_str()));
+ if(!aStudy->_is_nil() && !aCollection.IsEmpty()){
aSMESHGen->AddToPythonScript(aStudy->StudyId(),aCollection);
if(MYDEBUG) MESSAGE(aString);
}
case FT_Area: myStream<< "aArea"; break;
case FT_FreeBorders: myStream<< "aFreeBorders"; break;
case FT_FreeEdges: myStream<< "aFreeEdges"; break;
+ case FT_FreeNodes: myStream<< "aFreeNodes"; break;
case FT_MultiConnection: myStream<< "aMultiConnection"; break;
case FT_MultiConnection2D:myStream<< "aMultiConnection2D";break;
case FT_Length: myStream<< "aLength"; break;
// Some objects are wrapped with python classes and
// Resource_DataMapOfAsciiStringAsciiString holds methods returning wrapped objects
Resource_DataMapOfAsciiStringAsciiString anEntry2AccessorMethod;
- aScript = SMESH_2smeshpy::ConvertScript( aScript, anEntry2AccessorMethod );
+ aScript = SMESH_2smeshpy::ConvertScript( aScript, anEntry2AccessorMethod, theObjectNames );
// Find entries to be replaced by names
Handle(TColStd_HSequenceOfInteger) aSeq = FindEntries(aScript);
// Set object names
anUpdatedScript += "\n\t## set object names";
- anUpdatedScript += helper + " \n\tisGUIMode = " + isPublished;
- anUpdatedScript += "\n\tif isGUIMode and salome.sg.hasDesktop():";
// anUpdatedScript += "\n\t\tsmeshgui = salome.ImportComponentGUI(\"SMESH\")";
// anUpdatedScript += "\n\t\tsmeshgui.Init(theStudy._get_StudyId())";
// anUpdatedScript += "\n";
aName = theObjectNames.Find(anEntry);
aGUIName = theNames.Find(anEntry);
mapEntries.Bind(anEntry, aName);
- anUpdatedScript += helper + "\n\t\t" + aSmeshpy + ".SetName(" + aName;
+ anUpdatedScript += helper + "\n\t" + aSMESHGen + ".SetName(" + aName;
if ( anEntry2AccessorMethod.IsBound( anEntry ) )
anUpdatedScript += helper + "." + anEntry2AccessorMethod( anEntry );
anUpdatedScript += helper + ", '" + aGUIName + "')";
}
}
- anUpdatedScript += "\n\n\t\tsalome.sg.updateObjBrowser(0)";
+ anUpdatedScript += "\n\tif salome.sg.hasDesktop():";
+ anUpdatedScript += "\n\t\tsalome.sg.updateObjBrowser(0)";
// -----------------------------------------------------------------
// store visual properties of displayed objects
CORBA::string_free(script);
}
}
-
anUpdatedScript += "\n\n\tpass\n";
// -----------------------------------------------------------------
return SMESH::FT_FreeEdges;
}
+/*
+ Class : FreeFaces_i
+ Description : Predicate for free faces
+*/
+FreeFaces_i::FreeFaces_i()
+{
+ myPredicatePtr.reset(new Controls::FreeFaces());
+ myFunctorPtr = myPredicatePtr;
+}
+
+FunctorType FreeFaces_i::GetFunctorType()
+{
+ return SMESH::FT_FreeFaces;
+}
+
+/*
+ Class : FreeNodes_i
+ Description : Predicate for free nodes
+*/
+FreeNodes_i::FreeNodes_i()
+{
+ myPredicatePtr.reset(new Controls::FreeNodes());
+ myFunctorPtr = myPredicatePtr;
+}
+
+FunctorType FreeNodes_i::GetFunctorType()
+{
+ return SMESH::FT_FreeNodes;
+}
+
/*
Class : RangeOfIds_i
Description : Predicate for Range of Ids.
return SMESH::FT_RangeOfIds;
}
+/*
+ Class : LinearOrQuadratic_i
+ Description : Predicate to verify whether a mesh element is linear
+*/
+LinearOrQuadratic_i::LinearOrQuadratic_i()
+{
+ myLinearOrQuadraticPtr.reset(new Controls::LinearOrQuadratic());
+ myFunctorPtr = myPredicatePtr = myLinearOrQuadraticPtr;
+}
+
+void LinearOrQuadratic_i::SetElementType(ElementType theType)
+{
+ myLinearOrQuadraticPtr->SetType(SMDSAbs_ElementType(theType));
+ TPythonDump()<<this<<".SetElementType("<<theType<<")";
+}
+
+FunctorType LinearOrQuadratic_i::GetFunctorType()
+{
+ return SMESH::FT_LinearOrQuadratic;
+}
+
+/*
+ Class : GroupColor_i
+ Description : Functor for check color of group to whic mesh element belongs to
+*/
+GroupColor_i::GroupColor_i()
+{
+ myGroupColorPtr.reset(new Controls::GroupColor());
+ myFunctorPtr = myPredicatePtr = myGroupColorPtr;
+}
+
+FunctorType GroupColor_i::GetFunctorType()
+{
+ return SMESH::FT_GroupColor;
+}
+
+void GroupColor_i::SetColorStr( const char* theColor )
+{
+ myGroupColorPtr->SetColorStr(
+ TCollection_AsciiString( (Standard_CString)theColor ) );
+ TPythonDump()<<this<<".SetColorStr('"<<theColor<<"')";
+}
+
+char* GroupColor_i::GetColorStr()
+{
+ TCollection_AsciiString aStr;
+ myGroupColorPtr->GetColorStr( aStr );
+ return CORBA::string_dup( aStr.ToCString() );
+}
+
+void GroupColor_i::SetElementType(ElementType theType)
+{
+ myGroupColorPtr->SetType(SMDSAbs_ElementType(theType));
+ TPythonDump()<<this<<".SetElementType("<<theType<<")";
+}
+
+/*
+ Class : ElemGeomType_i
+ Description : Predicate check is element has indicated geometry type
+*/
+ElemGeomType_i::ElemGeomType_i()
+{
+ myElemGeomTypePtr.reset(new Controls::ElemGeomType());
+ myFunctorPtr = myPredicatePtr = myElemGeomTypePtr;
+}
+
+void ElemGeomType_i::SetElementType(ElementType theType)
+{
+ myElemGeomTypePtr->SetType(SMDSAbs_ElementType(theType));
+ TPythonDump()<<this<<".SetElementType("<<theType<<")";
+}
+
+void ElemGeomType_i::SetGeometryType(GeometryType theType)
+{
+ myElemGeomTypePtr->SetGeomType(SMDSAbs_GeometryType(theType));
+ TPythonDump()<<this<<".SetGeometryType("<<theType<<")";
+}
+
+GeometryType ElemGeomType_i::GetGeometryType() const
+{
+ return (GeometryType)myElemGeomTypePtr->GetGeomType();;
+}
+
+FunctorType ElemGeomType_i::GetFunctorType()
+{
+ return SMESH::FT_ElemGeomType;
+}
+
/*
Class : Comparator_i
Description : Base class for comparators
return anObj._retn();
}
+FreeFaces_ptr FilterManager_i::CreateFreeFaces()
+{
+ SMESH::FreeFaces_i* aServant = new SMESH::FreeFaces_i();
+ SMESH::FreeFaces_var anObj = aServant->_this();
+ TPythonDump()<<aServant<<" = "<<this<<".CreateFreeFaces()";
+ return anObj._retn();
+}
+
+FreeNodes_ptr FilterManager_i::CreateFreeNodes()
+{
+ SMESH::FreeNodes_i* aServant = new SMESH::FreeNodes_i();
+ SMESH::FreeNodes_var anObj = aServant->_this();
+ TPythonDump()<<aServant<<" = "<<this<<".CreateFreeNodes()";
+ return anObj._retn();
+}
+
RangeOfIds_ptr FilterManager_i::CreateRangeOfIds()
{
SMESH::RangeOfIds_i* aServant = new SMESH::RangeOfIds_i();
return anObj._retn();
}
-
MoreThan_ptr FilterManager_i::CreateMoreThan()
{
SMESH::MoreThan_i* aServant = new SMESH::MoreThan_i();
return anObj._retn();
}
-
LogicalNOT_ptr FilterManager_i::CreateLogicalNOT()
{
SMESH::LogicalNOT_i* aServant = new SMESH::LogicalNOT_i();
return anObj._retn();
}
-
LogicalAND_ptr FilterManager_i::CreateLogicalAND()
{
SMESH::LogicalAND_i* aServant = new SMESH::LogicalAND_i();
return anObj._retn();
}
-
LogicalOR_ptr FilterManager_i::CreateLogicalOR()
{
SMESH::LogicalOR_i* aServant = new SMESH::LogicalOR_i();
return anObj._retn();
}
+LinearOrQuadratic_ptr FilterManager_i::CreateLinearOrQuadratic()
+{
+ SMESH::LinearOrQuadratic_i* aServant = new SMESH::LinearOrQuadratic_i();
+ SMESH::LinearOrQuadratic_var anObj = aServant->_this();
+ TPythonDump()<<aServant<<" = "<<this<<".CreateLinearOrQuadratic()";
+ return anObj._retn();
+}
+
+GroupColor_ptr FilterManager_i::CreateGroupColor()
+{
+ SMESH::GroupColor_i* aServant = new SMESH::GroupColor_i();
+ SMESH::GroupColor_var anObj = aServant->_this();
+ TPythonDump()<<aServant<<" = "<<this<<".CreateGroupColor()";
+ return anObj._retn();
+}
+
+ElemGeomType_ptr FilterManager_i::CreateElemGeomType()
+{
+ SMESH::ElemGeomType_i* aServant = new SMESH::ElemGeomType_i();
+ SMESH::ElemGeomType_var anObj = aServant->_this();
+ TPythonDump()<<aServant<<" = "<<this<<".CreateElemGeomType()";
+ return anObj._retn();
+}
+
Filter_ptr FilterManager_i::CreateFilter()
{
SMESH::Filter_i* aServant = new SMESH::Filter_i();
{
case FT_FreeBorders:
case FT_FreeEdges:
+ case FT_FreeFaces:
+ case FT_LinearOrQuadratic:
+ case FT_FreeNodes:
{
CORBA::ULong i = theCriteria->length();
theCriteria->length( i + 1 );
theCriteria[ theCriteria->length() - 1 ].BinaryOp = aFType;
return getCriteria( aPred2, theCriteria );
}
+ case FT_GroupColor:
+ {
+ CORBA::ULong i = theCriteria->length();
+ theCriteria->length( i + 1 );
+
+ theCriteria[ i ] = createCriterion();
+
+ GroupColor_i* aPred = dynamic_cast<GroupColor_i*>( thePred );
+ theCriteria[ i ].Type = aFType;
+ theCriteria[ i ].TypeOfElement = aPred->GetElementType();
+ theCriteria[ i ].ThresholdStr = aPred->GetColorStr();
+
+ return true;
+ }
+ case FT_ElemGeomType:
+ {
+ CORBA::ULong i = theCriteria->length();
+ theCriteria->length( i + 1 );
+
+ theCriteria[ i ] = createCriterion();
+
+ ElemGeomType_i* aPred = dynamic_cast<ElemGeomType_i*>( thePred );
+ theCriteria[ i ].Type = aFType;
+ theCriteria[ i ].TypeOfElement = aPred->GetElementType();
+ theCriteria[ i ].Threshold = (double)aPred->GetGeometryType();
+ return true;
+ }
case FT_Undefined:
return false;
case SMESH::FT_FreeEdges:
aPredicate = aFilterMgr->CreateFreeEdges();
break;
+ case SMESH::FT_FreeFaces:
+ aPredicate = aFilterMgr->CreateFreeFaces();
+ break;
+ case SMESH::FT_FreeNodes:
+ aPredicate = aFilterMgr->CreateFreeNodes();
+ break;
case SMESH::FT_BelongToGeom:
{
SMESH::BelongToGeom_ptr tmpPred = aFilterMgr->CreateBelongToGeom();
aPredicate = aFilterMgr->CreateBadOrientedVolume();
}
break;
+ case SMESH::FT_LinearOrQuadratic:
+ {
+ SMESH::LinearOrQuadratic_ptr tmpPred = aFilterMgr->CreateLinearOrQuadratic();
+ tmpPred->SetElementType( aTypeOfElem );
+ aPredicate = tmpPred;
+ break;
+ }
+ case SMESH::FT_GroupColor:
+ {
+ SMESH::GroupColor_ptr tmpPred = aFilterMgr->CreateGroupColor();
+ tmpPred->SetElementType( aTypeOfElem );
+ tmpPred->SetColorStr( aThresholdStr );
+ aPredicate = tmpPred;
+ break;
+ }
+ case SMESH::FT_ElemGeomType:
+ {
+ SMESH::ElemGeomType_ptr tmpPred = aFilterMgr->CreateElemGeomType();
+ tmpPred->SetElementType( aTypeOfElem );
+ tmpPred->SetGeometryType( (GeometryType)(aThreshold + 0.5) );
+ aPredicate = tmpPred;
+ break;
+ }
default:
continue;
case FT_RangeOfIds : return "Range of IDs";
case FT_FreeBorders : return "Free borders";
case FT_FreeEdges : return "Free edges";
+ case FT_FreeFaces : return "Free faces";
+ case FT_FreeNodes : return "Free nodes";
case FT_MultiConnection : return "Borders at multi-connections";
case FT_MultiConnection2D: return "Borders at multi-connections 2D";
case FT_Length : return "Length";
- case FT_Length2D : return "Length2D";
+ case FT_Length2D : return "Length 2D";
case FT_LessThan : return "Less than";
case FT_MoreThan : return "More than";
case FT_EqualTo : return "Equal to";
case FT_LogicalNOT : return "Not";
case FT_LogicalAND : return "And";
case FT_LogicalOR : return "Or";
+ case FT_GroupColor : return "Color of Group";
+ case FT_LinearOrQuadratic : return "Linear or Quadratic";
+ case FT_ElemGeomType : return "Element geomtry type";
case FT_Undefined : return "";
default : return "";
}
else if ( theStr.equals( "Lying on Geom" ) ) return FT_LyingOnGeom;
else if ( theStr.equals( "Free borders" ) ) return FT_FreeBorders;
else if ( theStr.equals( "Free edges" ) ) return FT_FreeEdges;
+ else if ( theStr.equals( "Free faces" ) ) return FT_FreeFaces;
+ else if ( theStr.equals( "Free nodes" ) ) return FT_FreeNodes;
else if ( theStr.equals( "Borders at multi-connections" ) ) return FT_MultiConnection;
// else if ( theStr.equals( "Borders at multi-connections 2D" ) ) return FT_MultiConnection2D;
else if ( theStr.equals( "Length" ) ) return FT_Length;
else if ( theStr.equals( "Not" ) ) return FT_LogicalNOT;
else if ( theStr.equals( "And" ) ) return FT_LogicalAND;
else if ( theStr.equals( "Or" ) ) return FT_LogicalOR;
+ else if ( theStr.equals( "Color of Group" ) ) return FT_GroupColor;
+ else if ( theStr.equals( "Linear or Quadratic" ) ) return FT_LinearOrQuadratic;
+ else if ( theStr.equals( "Element geomtry type" ) ) return FT_ElemGeomType;
else if ( theStr.equals( "" ) ) return FT_Undefined;
else return FT_Undefined;
}
}
else
aCriterion.ThresholdStr = str.GetString();
-
+
aCriteria.push_back( aCriterion );
}
Controls::FreeEdgesPtr myFreeEdgesPtr;
};
+
+ /*
+ Class : FreeFaces_i
+ Description : Predicate for free faces
+ */
+ class SMESH_I_EXPORT FreeFaces_i: public virtual POA_SMESH::FreeFaces,
+ public virtual Predicate_i
+ {
+ public:
+ FreeFaces_i();
+ FunctorType GetFunctorType();
+ };
+
+
+ /*
+ Class : FreeNodes_i
+ Description : Predicate for free nodes
+ */
+ class SMESH_I_EXPORT FreeNodes_i: public virtual POA_SMESH::FreeNodes,
+ public virtual Predicate_i
+ {
+ public:
+ FreeNodes_i();
+ FunctorType GetFunctorType();
+ };
+
/*
Class : RangeOfIds_i
protected:
Controls::RangeOfIdsPtr myRangeOfIdsPtr;
};
+
+ /*
+ Class : LinearOrQuadratic_i
+ Description : Verify whether a mesh element is linear
+ */
+ class SMESH_I_EXPORT LinearOrQuadratic_i: public virtual POA_SMESH::LinearOrQuadratic,
+ public virtual Predicate_i
+ {
+ public:
+ LinearOrQuadratic_i();
+ FunctorType GetFunctorType();
+ void SetElementType( ElementType theType );
+
+ private:
+ Controls::LinearOrQuadraticPtr myLinearOrQuadraticPtr;
+ };
+
+ /*
+ Class : GroupColor_i
+ Description : Functor for check color of group to whic mesh element belongs to
+ */
+ class SMESH_I_EXPORT GroupColor_i: public virtual POA_SMESH::GroupColor,
+ public virtual Predicate_i
+ {
+ public:
+ GroupColor_i();
+ FunctorType GetFunctorType();
+
+ void SetElementType( ElementType theType );
+ void SetColorStr( const char* theColor );
+ char* GetColorStr();
+
+ private:
+ Controls::GroupColorPtr myGroupColorPtr;
+ };
+
+ /*
+ Class : ElemGeomType_i
+ Description : Functor for check element geometry type
+ */
+ class SMESH_I_EXPORT ElemGeomType_i: public virtual POA_SMESH::ElemGeomType,
+ public virtual Predicate_i
+ {
+ public:
+ ElemGeomType_i();
+ FunctorType GetFunctorType();
+
+ void SetElementType ( ElementType theType );
+ void SetGeometryType( GeometryType theType );
+ GeometryType GetGeometryType() const;
+
+ private:
+ Controls::ElemGeomTypePtr myElemGeomTypePtr;
+ };
/*
Class : Comparator_i
FreeBorders_ptr CreateFreeBorders();
FreeEdges_ptr CreateFreeEdges();
+ FreeNodes_ptr CreateFreeNodes();
+ FreeFaces_ptr CreateFreeFaces();
RangeOfIds_ptr CreateRangeOfIds();
BadOrientedVolume_ptr CreateBadOrientedVolume();
+ LinearOrQuadratic_ptr CreateLinearOrQuadratic();
+ GroupColor_ptr CreateGroupColor();
+
+ ElemGeomType_ptr CreateElemGeomType();
+
LessThan_ptr CreateLessThan();
MoreThan_ptr CreateMoreThan();
EqualTo_ptr CreateEqualTo();
// File : SMESH_Gen_i.cxx
// Author : Paul RASCLE, EDF
// Module : SMESH
-// $Header$
//
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
SALOME_LifeCycleCORBA* SMESH_Gen_i::myLCC = NULL;
SMESH_Gen_i* SMESH_Gen_i::mySMESHGen = NULL;
+
+const int nbElemPerDiagonal = 10;
+
//=============================================================================
/*!
* GetServant [ static ]
//================================================================================
/*!
- * \brief Return hypothesis of given type holding parameter values of the existing mesh
- * \param theHypType - hypothesis type name
- * \param theLibName - plugin library name
- * \param theMesh - The mesh of interest
- * \param theGeom - The shape to get parameter values from
- * \retval SMESH::SMESH_Hypothesis_ptr - The returned hypothesis may be the one existing
- * in a study and used to compute the mesh, or a temporary one created just to pass
- * parameter values
+ * \brief Return a hypothesis holding parameter values corresponding either to the mesh
+ * existing on the given geometry or to size of the geometry.
+ * \param theHypType - hypothesis type name
+ * \param theLibName - plugin library name
+ * \param theMesh - The mesh of interest
+ * \param theGeom - The shape to get parameter values from
+ * \retval SMESH::SMESH_Hypothesis_ptr - The returned hypothesis may be the one existing
+ * in a study and used to compute the mesh, or a temporary one created just to pass
+ * parameter values
*/
//================================================================================
SMESH_Gen_i::GetHypothesisParameterValues (const char* theHypType,
const char* theLibName,
SMESH::SMESH_Mesh_ptr theMesh,
- GEOM::GEOM_Object_ptr theGeom)
- throw ( SALOME::SALOME_Exception )
+ GEOM::GEOM_Object_ptr theGeom,
+ CORBA::Boolean byMesh)
+ throw ( SALOME::SALOME_Exception )
{
Unexpect aCatch(SALOME_SalomeException);
- if ( CORBA::is_nil( theMesh ) )
+ if ( CORBA::is_nil( theMesh ) && byMesh )
THROW_SALOME_CORBA_EXCEPTION( "bad Mesh reference", SALOME::BAD_PARAM );
if ( CORBA::is_nil( theGeom ) )
THROW_SALOME_CORBA_EXCEPTION( "bad shape object reference", SALOME::BAD_PARAM );
// get mesh and shape
SMESH_Mesh_i* meshServant = SMESH::DownCast<SMESH_Mesh_i*>( theMesh );
TopoDS_Shape shape = GeomObjectToShape( theGeom );
- if ( !meshServant || shape.IsNull() )
+ if ( !meshServant && byMesh || shape.IsNull() )
return SMESH::SMESH_Hypothesis::_nil();
- ::SMESH_Mesh& mesh = meshServant->GetImpl();
+ ::SMESH_Mesh* mesh = meshServant ? &meshServant->GetImpl() : (::SMESH_Mesh*)0;
- if ( mesh.NbNodes() == 0 ) // empty mesh
+ if ( byMesh && mesh->NbNodes() == 0 ) // empty mesh
return SMESH::SMESH_Hypothesis::_nil();
// create a temporary hypothesis to know its dimention
return SMESH::SMESH_Hypothesis::_nil();
::SMESH_Hypothesis* hyp = hypServant->GetImpl();
- // look for a hypothesis of theHypType used to mesh the shape
- if ( myGen.GetShapeDim( shape ) == hyp->GetDim() )
- {
- // check local shape
- SMESH::ListOfHypothesis_var aHypList = theMesh->GetHypothesisList( theGeom );
- int nbLocalHyps = aHypList->length();
- for ( int i = 0; i < nbLocalHyps; i++ )
- if ( strcmp( theHypType, aHypList[i]->GetName() ) == 0 ) // FOUND local!
- return SMESH::SMESH_Hypothesis::_duplicate( aHypList[i] );
- // check super shapes
- TopTools_ListIteratorOfListOfShape itShape( mesh.GetAncestors( shape ));
- while ( nbLocalHyps == 0 && itShape.More() ) {
- GEOM::GEOM_Object_ptr geomObj = ShapeToGeomObject( itShape.Value() );
- if ( ! CORBA::is_nil( geomObj )) {
- SMESH::ListOfHypothesis_var aHypList = theMesh->GetHypothesisList( geomObj );
- nbLocalHyps = aHypList->length();
- for ( int i = 0; i < nbLocalHyps; i++ )
- if ( strcmp( theHypType, aHypList[i]->GetName() ) == 0 ) // FOUND global!
- return SMESH::SMESH_Hypothesis::_duplicate( aHypList[i] );
+ if ( byMesh ) {
+ // look for a hypothesis of theHypType used to mesh the shape
+ if ( myGen.GetShapeDim( shape ) == hyp->GetDim() )
+ {
+ // check local shape
+ SMESH::ListOfHypothesis_var aHypList = theMesh->GetHypothesisList( theGeom );
+ int nbLocalHyps = aHypList->length();
+ for ( int i = 0; i < nbLocalHyps; i++ )
+ if ( strcmp( theHypType, aHypList[i]->GetName() ) == 0 ) // FOUND local!
+ return SMESH::SMESH_Hypothesis::_duplicate( aHypList[i] );
+ // check super shapes
+ TopTools_ListIteratorOfListOfShape itShape( mesh->GetAncestors( shape ));
+ while ( nbLocalHyps == 0 && itShape.More() ) {
+ GEOM::GEOM_Object_ptr geomObj = ShapeToGeomObject( itShape.Value() );
+ if ( ! CORBA::is_nil( geomObj )) {
+ SMESH::ListOfHypothesis_var aHypList = theMesh->GetHypothesisList( geomObj );
+ nbLocalHyps = aHypList->length();
+ for ( int i = 0; i < nbLocalHyps; i++ )
+ if ( strcmp( theHypType, aHypList[i]->GetName() ) == 0 ) // FOUND global!
+ return SMESH::SMESH_Hypothesis::_duplicate( aHypList[i] );
+ }
+ itShape.Next();
}
- itShape.Next();
+ }
+
+ // let the temporary hypothesis find out some how parameter values by mesh
+ if ( hyp->SetParametersByMesh( mesh, shape ))
+ return SMESH::SMESH_Hypothesis::_duplicate( tmpHyp );
+ }
+ else {
+ double diagonal = 0;
+ if ( mesh )
+ diagonal = mesh->GetShapeDiagonalSize();
+ else
+ diagonal = ::SMESH_Mesh::GetShapeDiagonalSize( shape );
+ double elemSize = diagonal / myGen.GetBoundaryBoxSegmentation();
+ if ( elemSize > 0 ) {
+ // let the temporary hypothesis initialize it's values
+ if ( hyp->SetParametersByElementSize( elemSize, mesh ))
+ return SMESH::SMESH_Hypothesis::_duplicate( tmpHyp );
}
}
- // let the temporary hypothesis find out some how parameter values
- if ( hyp->SetParametersByMesh( &mesh, shape ))
- return SMESH::SMESH_Hypothesis::_duplicate( tmpHyp );
-
return SMESH::SMESH_Hypothesis::_nil();
}
+//=============================================================================
+/*!
+ * Sets number of segments per diagonal of boundary box of geometry by which
+ * default segment length of appropriate 1D hypotheses is defined
+ */
+//=============================================================================
+
+void SMESH_Gen_i::SetBoundaryBoxSegmentation( CORBA::Long theNbSegments )
+{
+ myGen.SetBoundaryBoxSegmentation( int( theNbSegments ));
+}
+
//=============================================================================
/*!
* SMESH_Gen_i::CreateMesh
return false;
}
+//=============================================================================
+/*!
+ * SMESH_Gen_i::Precompute
+ *
+ * Compute mesh as preview till indicated dimension on shape
+ */
+//=============================================================================
+
+SMESH::MeshPreviewStruct* SMESH_Gen_i::Precompute( SMESH::SMESH_Mesh_ptr theMesh,
+ GEOM::GEOM_Object_ptr theShapeObject,
+ SMESH::Dimension theDimension,
+ SMESH::long_array& theShapesId)
+ throw ( SALOME::SALOME_Exception )
+{
+ Unexpect aCatch(SALOME_SalomeException);
+ if(MYDEBUG) MESSAGE( "SMESH_Gen_i::Precompute" );
+
+ if ( CORBA::is_nil( theShapeObject ) && theMesh->HasShapeToMesh())
+ THROW_SALOME_CORBA_EXCEPTION( "bad shape object reference",
+ SALOME::BAD_PARAM );
+
+ if ( CORBA::is_nil( theMesh ) )
+ THROW_SALOME_CORBA_EXCEPTION( "bad Mesh reference",
+ SALOME::BAD_PARAM );
+
+ SMESH::MeshPreviewStruct_var result = new SMESH::MeshPreviewStruct;
+ try {
+ // get mesh servant
+ SMESH_Mesh_i* meshServant = dynamic_cast<SMESH_Mesh_i*>( GetServant( theMesh ).in() );
+ ASSERT( meshServant );
+ if ( meshServant ) {
+ // NPAL16168: "geometrical group edition from a submesh don't modifiy mesh computation"
+ meshServant->CheckGeomGroupModif();
+ // get local TopoDS_Shape
+ TopoDS_Shape myLocShape;
+ if(theMesh->HasShapeToMesh())
+ myLocShape = GeomObjectToShape( theShapeObject );
+ else
+ return result._retn();;
+
+ // call implementation compute
+ ::SMESH_Mesh& myLocMesh = meshServant->GetImpl();
+ TSetOfInt shapeIds;
+ ::MeshDimension aDim = (MeshDimension)theDimension;
+ if ( myGen.Compute( myLocMesh, myLocShape, false, aDim, &shapeIds ) )
+ {
+ int nbShapeId = shapeIds.size();
+ theShapesId.length( nbShapeId );
+ // iterates on shapes and collect mesh entities into mesh preview
+ TSetOfInt::const_iterator idIt = shapeIds.begin();
+ TSetOfInt::const_iterator idEnd = shapeIds.end();
+ std::map< int, int > mapOfShIdNb;
+ std::set< SMESH_TLink > setOfEdge;
+ std::list< SMDSAbs_ElementType > listOfElemType;
+ typedef map<const SMDS_MeshElement*, int > TNode2LocalIDMap;
+ typedef TNode2LocalIDMap::iterator TNodeLocalID;
+ TNode2LocalIDMap mapNode2LocalID;
+ list< TNodeLocalID > connectivity;
+ int i, nbConnNodes = 0;
+ std::set< const SMESH_subMesh* > setOfVSubMesh;
+ // iterates on shapes
+ for ( ; idIt != idEnd; idIt++ )
+ {
+ if ( mapOfShIdNb.find( *idIt ) != mapOfShIdNb.end() )
+ continue;
+ SMESH_subMesh* sm = myLocMesh.GetSubMeshContaining(*idIt);
+ if ( !sm || !sm->IsMeshComputed() )
+ continue;
+
+ const TopoDS_Shape& aSh = sm->GetSubShape();
+ const int shDim = myGen.GetShapeDim( aSh );
+ if ( shDim < 1 || shDim > theDimension )
+ continue;
+
+ mapOfShIdNb[ *idIt ] = 0;
+ theShapesId[ mapOfShIdNb.size() - 1 ] = *idIt;
+
+ SMESHDS_SubMesh* smDS = sm->GetSubMeshDS();
+ if ( !smDS ) continue;
+
+ if ( theDimension == SMESH::DIM_2D )
+ {
+ SMDS_ElemIteratorPtr faceIt = smDS->GetElements();
+ while ( faceIt->more() )
+ {
+ const SMDS_MeshElement* face = faceIt->next();
+ int aNbNode = face->NbNodes();
+ if ( aNbNode > 4 )
+ aNbNode /= 2; // do not take into account additional middle nodes
+
+ SMDS_MeshNode* node1 = (SMDS_MeshNode*)face->GetNode( 1 );
+ for ( int nIndx = 1; nIndx <= aNbNode; nIndx++ )
+ {
+ SMDS_MeshNode* node2 = (SMDS_MeshNode*)face->GetNode( nIndx < aNbNode ? nIndx+1 : 1 );
+ if ( setOfEdge.insert( SMESH_TLink ( node1, node2 ) ).second )
+ {
+ listOfElemType.push_back( SMDSAbs_Edge );
+ connectivity.push_back
+ ( mapNode2LocalID.insert( make_pair( node1, ++nbConnNodes)).first );
+ connectivity.push_back
+ ( mapNode2LocalID.insert( make_pair( node2, ++nbConnNodes)).first );
+ }
+ node1 = node2;
+ }
+ }
+ }
+ else if ( theDimension == SMESH::DIM_1D )
+ {
+ SMDS_NodeIteratorPtr nodeIt = smDS->GetNodes();
+ while ( nodeIt->more() )
+ {
+ listOfElemType.push_back( SMDSAbs_Node );
+ connectivity.push_back
+ ( mapNode2LocalID.insert( make_pair( nodeIt->next(), ++nbConnNodes)).first );
+ }
+ // add corner nodes by first vertex from edge
+ SMESH_subMeshIteratorPtr edgeSmIt =
+ sm->getDependsOnIterator(/*includeSelf*/false,
+ /*complexShapeFirst*/false);
+ while ( edgeSmIt->more() )
+ {
+ SMESH_subMesh* vertexSM = edgeSmIt->next();
+ // check that vertex is not already treated
+ if ( !setOfVSubMesh.insert( vertexSM ).second )
+ continue;
+ if ( vertexSM->GetSubShape().ShapeType() != TopAbs_VERTEX )
+ continue;
+
+ const SMESHDS_SubMesh* vertexSmDS = vertexSM->GetSubMeshDS();
+ SMDS_NodeIteratorPtr nodeIt = vertexSmDS->GetNodes();
+ while ( nodeIt->more() )
+ {
+ listOfElemType.push_back( SMDSAbs_Node );
+ connectivity.push_back
+ ( mapNode2LocalID.insert( make_pair( nodeIt->next(), ++nbConnNodes)).first );
+ }
+ }
+ }
+ }
+
+ // fill node coords and assign local ids to the nodes
+ int nbNodes = mapNode2LocalID.size();
+ result->nodesXYZ.length( nbNodes );
+ TNodeLocalID node2ID = mapNode2LocalID.begin();
+ for ( i = 0; i < nbNodes; ++i, ++node2ID ) {
+ node2ID->second = i;
+ const SMDS_MeshNode* node = (const SMDS_MeshNode*) node2ID->first;
+ result->nodesXYZ[i].x = node->X();
+ result->nodesXYZ[i].y = node->Y();
+ result->nodesXYZ[i].z = node->Z();
+ }
+ // fill connectivity
+ result->elementConnectivities.length( nbConnNodes );
+ list< TNodeLocalID >::iterator connIt = connectivity.begin();
+ for ( i = 0; i < nbConnNodes; ++i, ++connIt ) {
+ result->elementConnectivities[i] = (*connIt)->second;
+ }
+
+ // fill element types
+ result->elementTypes.length( listOfElemType.size() );
+ std::list< SMDSAbs_ElementType >::const_iterator typeIt = listOfElemType.begin();
+ std::list< SMDSAbs_ElementType >::const_iterator typeEnd = listOfElemType.end();
+ for ( i = 0; typeIt != typeEnd; ++i, ++typeIt )
+ {
+ SMDSAbs_ElementType elemType = *typeIt;
+ result->elementTypes[i].SMDS_ElementType = (SMESH::ElementType)elemType;
+ result->elementTypes[i].isPoly = false;
+ result->elementTypes[i].nbNodesInElement = elemType == SMDSAbs_Edge ? 2 : 1;
+ }
+
+ // correct number of shapes
+ theShapesId.length( mapOfShIdNb.size() );
+ }
+ }
+ }
+ catch ( std::bad_alloc ) {
+ INFOS( "Precompute(): lack of memory" );
+ }
+ catch ( SALOME_Exception& S_ex ) {
+ INFOS( "Precompute(): catch exception "<< S_ex.what() );
+ }
+ catch ( ... ) {
+ INFOS( "Precompute(): unknown exception " );
+ }
+ return result._retn();
+}
+
//================================================================================
/*!
* \brief Return geometrical object the given element is built on
// "Nodes on Faces" - ID of node on face
// "Face U positions" - U parameter of node on face
// "Face V positions" - V parameter of node on face
- char* aEid_DSName = "Nodes on Edges";
- char* aEu_DSName = "Edge positions";
- char* aFu_DSName = "Face U positions";
+ const char* aEid_DSName = "Nodes on Edges";
+ const char* aEu_DSName = "Edge positions";
+ const char* aFu_DSName = "Face U positions";
//char* aFid_DSName = "Nodes on Faces";
//char* aFv_DSName = "Face V positions";
return 0;
}
+//=============================================================================
+/*!
+ * SMESH_Gen_i::SetName
+ *
+ * Set a new object name
+ */
+//=============================================================================
+void SMESH_Gen_i::SetName(const char* theIOR,
+ const char* theName)
+{
+ if ( theIOR && strcmp( theIOR, "" ) ) {
+ CORBA::Object_var anObject = GetORB()->string_to_object( theIOR );
+ SALOMEDS::SObject_var aSO = ObjectToSObject( myCurrentStudy, anObject );
+ if ( !aSO->_is_nil() ) {
+ SetName( aSO, theName );
+ }
+ }
+}
+
//=============================================================================
/*!
* SMESHEngine_factory
// File : SMESH_Gen_i.hxx
// Author : Paul RASCLE, EDF
// Module : SMESH
-// $Header$
//
#ifndef _SMESH_GEN_I_HXX_
#define _SMESH_GEN_I_HXX_
// *****************************************
// Interface methods
// *****************************************
+ // Set a new Mesh object name
+ void SetName(const char* theIOR,
+ const char* theName);
+
//GEOM::GEOM_Gen_ptr SetGeomEngine( const char* containerLoc );
void SetGeomEngine( GEOM::GEOM_Gen_ptr geomcompo );
SMESH::SMESH_Hypothesis_ptr GetHypothesisParameterValues (const char* theHypType,
const char* theLibName,
SMESH::SMESH_Mesh_ptr theMesh,
- GEOM::GEOM_Object_ptr theGeom)
+ GEOM::GEOM_Object_ptr theGeom,
+ CORBA::Boolean byMesh)
throw ( SALOME::SALOME_Exception );
+ /*!
+ * Sets number of segments per diagonal of boundary box of geometry by which
+ * default segment length of appropriate 1D hypotheses is defined
+ */
+ void SetBoundaryBoxSegmentation( CORBA::Long theNbSegments );
+
// Create empty mesh on a shape
SMESH::SMESH_Mesh_ptr CreateMesh( GEOM::GEOM_Object_ptr theShapeObject )
throw ( SALOME::SALOME_Exception );
CORBA::Boolean IsReadyToCompute( SMESH::SMESH_Mesh_ptr theMesh,
GEOM::GEOM_Object_ptr theShapeObject )
throw ( SALOME::SALOME_Exception );
+
+ /*!
+ * Calculate Mesh as preview till indicated dimension on shape
+ * First, verify list of hypothesis associated with the subShape.
+ * Return mesh preview structure
+ */
+ SMESH::MeshPreviewStruct* Precompute( SMESH::SMESH_Mesh_ptr theMesh,
+ GEOM::GEOM_Object_ptr theSubObject,
+ SMESH::Dimension theDimension,
+ SMESH::long_array& theShapesId )
+ throw ( SALOME::SALOME_Exception );
// Returns errors of hypotheses definintion
SMESH::algo_error_array* GetAlgoState( SMESH::SMESH_Mesh_ptr theMesh,
// File : SMESH_Group_i.cxx
// Author : Sergey ANIKIN, OCC
// Module : SMESH
-// $Header$
//
#include "SMESH_Group_i.hxx"
#include "SMESH_Mesh_i.hxx"
void SMESH_GroupBase_i::SetName( const char* theName )
{
- // Update Python script
- TPythonDump() << _this() << ".SetName( '" << theName << "' )";
-
// Perform renaming
::SMESH_Group* aGroup = GetSmeshGroup();
- if (aGroup) {
- aGroup->SetName(theName);
-
- // Update group name in a study
- SMESH_Gen_i* aGen = myMeshServant->GetGen();
- aGen->SetName( aGen->ObjectToSObject( aGen->GetCurrentStudy(), _this() ), theName );
+ if (!aGroup) {
+ MESSAGE("can't set name of a vague group");
return;
}
- MESSAGE("can't set name of a vague group");
+
+ if ( aGroup->GetName() && !strcmp( aGroup->GetName(), theName ) )
+ return; // nothing to rename
+
+ aGroup->SetName(theName);
+
+ // Update group name in a study
+ SMESH_Gen_i* aGen = myMeshServant->GetGen();
+ aGen->SetName( aGen->ObjectToSObject( aGen->GetCurrentStudy(), _this() ), theName );
+
+ // Update Python script
+ TPythonDump() << _this() << ".SetName( '" << theName << "' )";
}
//=============================================================================
// File : SMESH_MeshEditor_i.cxx
// Author : Nicolas REJNERI
// Module : SMESH
-// $Header$
-//
+
#include "SMESH_MeshEditor_i.hxx"
#include "SMDS_MeshEdge.hxx"
//=======================================================================
//function : DumpGroupsList
-//purpose :
+//purpose :
//=======================================================================
-void SMESH_MeshEditor_i::DumpGroupsList(TPythonDump & theDumpPython,
+void SMESH_MeshEditor_i::DumpGroupsList(TPythonDump & theDumpPython,
const SMESH::ListOfGroups * theGroupList)
{
bool isDumpGroupList = theGroupList && theGroupList->length() > 0;
theDumpPython << theGroupList << " = ";
}
}
+
+//================================================================================
+/*!
+ \brief Creates a hole in a mesh by doubling the nodes of some particular elements
+ \param theNodes - identifiers of nodes to be doubled
+ \param theModifiedElems - identifiers of elements to be updated by the new (doubled)
+ nodes. If list of element identifiers is empty then nodes are doubled but
+ they not assigned to elements
+ \return TRUE if operation has been completed successfully, FALSE otherwise
+ \sa DoubleNode(), DoubleNodeGroup(), DoubleNodeGroups()
+*/
+//================================================================================
+
+CORBA::Boolean SMESH_MeshEditor_i::DoubleNodes( const SMESH::long_array& theNodes,
+ const SMESH::long_array& theModifiedElems )
+{
+ initData();
+
+ ::SMESH_MeshEditor aMeshEditor( myMesh );
+ list< int > aListOfNodes;
+ int i, n;
+ for ( i = 0, n = theNodes.length(); i < n; i++ )
+ aListOfNodes.push_back( theNodes[ i ] );
+
+ list< int > aListOfElems;
+ for ( i = 0, n = theModifiedElems.length(); i < n; i++ )
+ aListOfElems.push_back( theModifiedElems[ i ] );
+
+ bool aResult = aMeshEditor.DoubleNodes( aListOfNodes, aListOfElems );
+
+ storeResult( aMeshEditor) ;
+
+ return aResult;
+}
+
+//================================================================================
+/*!
+ \brief Creates a hole in a mesh by doubling the nodes of some particular elements
+ This method provided for convenience works as DoubleNodes() described above.
+ \param theNodeId - identifier of node to be doubled.
+ \param theModifiedElems - identifiers of elements to be updated.
+ \return TRUE if operation has been completed successfully, FALSE otherwise
+ \sa DoubleNodes(), DoubleNodeGroup(), DoubleNodeGroups()
+*/
+//================================================================================
+
+CORBA::Boolean SMESH_MeshEditor_i::DoubleNode( CORBA::Long theNodeId,
+ const SMESH::long_array& theModifiedElems )
+{
+ SMESH::long_array_var aNodes = new SMESH::long_array;
+ aNodes->length( 1 );
+ aNodes[ 0 ] = theNodeId;
+ return DoubleNodes( aNodes, theModifiedElems );
+}
+
+//================================================================================
+/*!
+ \brief Creates a hole in a mesh by doubling the nodes of some particular elements
+ This method provided for convenience works as DoubleNodes() described above.
+ \param theNodes - group of nodes to be doubled.
+ \param theModifiedElems - group of elements to be updated.
+ \return TRUE if operation has been completed successfully, FALSE otherwise
+ \sa DoubleNode(), DoubleNodes(), DoubleNodeGroups()
+*/
+//================================================================================
+
+CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeGroup(
+ SMESH::SMESH_GroupBase_ptr theNodes,
+ SMESH::SMESH_GroupBase_ptr theModifiedElems )
+{
+ if ( CORBA::is_nil( theNodes ) && theNodes->GetType() != SMESH::NODE )
+ return false;
+
+ SMESH::long_array_var aNodes = theNodes->GetListOfID();
+ SMESH::long_array_var aModifiedElems;
+ if ( !CORBA::is_nil( theModifiedElems ) )
+ aModifiedElems = theModifiedElems->GetListOfID();
+ else
+ {
+ aModifiedElems = new SMESH::long_array;
+ aModifiedElems->length( 0 );
+ }
+
+ return DoubleNodes( aNodes, aModifiedElems );
+}
+
+//================================================================================
+/*!
+ \brief Creates a hole in a mesh by doubling the nodes of some particular elements
+ This method provided for convenience works as DoubleNodes() described above.
+ \param theNodes - list of groups of nodes to be doubled
+ \param theModifiedElems - list of groups of elements to be updated.
+ \return TRUE if operation has been completed successfully, FALSE otherwise
+ \sa DoubleNode(), DoubleNodeGroup(), DoubleNodes()
+*/
+//================================================================================
+
+CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeGroups(
+ const SMESH::ListOfGroups& theNodes,
+ const SMESH::ListOfGroups& theModifiedElems )
+{
+ initData();
+
+ ::SMESH_MeshEditor aMeshEditor( myMesh );
+
+ std::list< int > aNodes;
+ int i, n, j, m;
+ for ( i = 0, n = theNodes.length(); i < n; i++ )
+ {
+ SMESH::SMESH_GroupBase_var aGrp = theNodes[ i ];
+ if ( !CORBA::is_nil( aGrp ) && aGrp->GetType() == SMESH::NODE )
+ {
+ SMESH::long_array_var aCurr = aGrp->GetListOfID();
+ for ( j = 0, m = aCurr->length(); j < m; j++ )
+ aNodes.push_back( aCurr[ j ] );
+ }
+ }
+
+ std::list< int > anElems;
+ for ( i = 0, n = theModifiedElems.length(); i < n; i++ )
+ {
+ SMESH::SMESH_GroupBase_var aGrp = theModifiedElems[ i ];
+ if ( !CORBA::is_nil( aGrp ) && aGrp->GetType() != SMESH::NODE )
+ {
+ SMESH::long_array_var aCurr = aGrp->GetListOfID();
+ for ( j = 0, m = aCurr->length(); j < m; j++ )
+ anElems.push_back( aCurr[ j ] );
+ }
+ }
+
+ bool aResult = aMeshEditor.DoubleNodes( aNodes, anElems );
+
+ storeResult( aMeshEditor) ;
+
+ return aResult;
+}
// File : SMESH_MeshEditor_i.hxx
// Author : Nicolas REJNERI
// Module : SMESH
-// $Header$
//
#ifndef _SMESH_MESHEDITOR_I_HXX_
#define _SMESH_MESHEDIOTR_I_HXX_
* \retval int - mesh ID
*/
int GetMeshId() const { return myMesh->GetId(); }
+
+ CORBA::Boolean DoubleNodes( const SMESH::long_array& theNodes,
+ const SMESH::long_array& theModifiedElems );
+
+ CORBA::Boolean DoubleNode( CORBA::Long theNodeId,
+ const SMESH::long_array& theModifiedElems );
+
+ CORBA::Boolean DoubleNodeGroup( SMESH::SMESH_GroupBase_ptr theNodes,
+ SMESH::SMESH_GroupBase_ptr theModifiedElems );
+ CORBA::Boolean DoubleNodeGroups( const SMESH::ListOfGroups& theNodes,
+ const SMESH::ListOfGroups& theModifiedElems);
private: //!< private methods
// File : SMESH_Mesh_i.cxx
// Author : Paul RASCLE, EDF
// Module : SMESH
-// $Header$
//
#include "SMESH_Mesh_i.hxx"
TPythonDump() << _this() << ".Clear()";
}
+//================================================================================
+/*!
+ * \brief Remove all nodes and elements for indicated shape
+ */
+//================================================================================
+
+void SMESH_Mesh_i::ClearSubMesh(CORBA::Long ShapeID)
+ throw (SALOME::SALOME_Exception)
+{
+ Unexpect aCatch(SALOME_SalomeException);
+ try {
+ _impl->ClearSubMesh( ShapeID );
+ }
+ catch(SALOME_Exception & S_ex) {
+ THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
+ }
+}
+
//=============================================================================
/*!
*
}
}
+//=============================================================================
+/*!
+ \brief Union list of groups. New group is created. All mesh elements that are
+ present in initial groups are added to the new one.
+ \param theGroups list of groups
+ \param theName name of group to be created
+ \return pointer on the group
+*/
+//=============================================================================
+SMESH::SMESH_Group_ptr SMESH_Mesh_i::UnionListOfGroups(const SMESH::ListOfGroups& theGroups,
+ const char* theName )
+throw (SALOME::SALOME_Exception)
+{
+ if ( !theName )
+ return SMESH::SMESH_Group::_nil();
+
+ try
+ {
+ NCollection_Map< int > anIds;
+ SMESH::ElementType aType = SMESH::ALL;
+ for ( int g = 0, n = theGroups.length(); g < n; g++ )
+ {
+ SMESH::SMESH_GroupBase_var aGrp = theGroups[ g ];
+ if ( CORBA::is_nil( aGrp ) )
+ continue;
+
+ // check type
+ SMESH::ElementType aCurrType = aGrp->GetType();
+ if ( aType == SMESH::ALL )
+ aType = aCurrType;
+ else
+ {
+ if ( aType != aCurrType )
+ return SMESH::SMESH_Group::_nil();
+ }
+
+ // unite ids
+ SMESH::long_array_var aCurrIds = aGrp->GetListOfID();
+ for ( int i = 0, n = aCurrIds->length(); i < n; i++ )
+ {
+ int aCurrId = aCurrIds[ i ];
+ anIds.Add( aCurrId );
+ }
+ }
+
+ // Create group
+ SMESH::SMESH_Group_var aResGrp = CreateGroup( aType, theName );
+ if ( aResGrp->_is_nil() )
+ return SMESH::SMESH_Group::_nil();
+
+ // Create array of identifiers
+ SMESH::long_array_var aResIds = new SMESH::long_array;
+ aResIds->length( anIds.Extent() );
+
+ NCollection_Map< int >::Iterator anIter( anIds );
+ for ( int i = 0; anIter.More(); anIter.Next(), i++ )
+ {
+ aResIds[ i ] = anIter.Value();
+ }
+ aResGrp->Add( aResIds );
+
+ // Clear python lines, created by CreateGroup() and Add()
+ SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy();
+ _gen_i->RemoveLastFromPythonScript( aStudy->StudyId() );
+ _gen_i->RemoveLastFromPythonScript( aStudy->StudyId() );
+
+ // Update Python script
+
+ TPythonDump() << aResGrp << " = " << _this() << ".UnionListOfGroups( "
+ << &theGroups << ", '" << theName << "' )";
+
+ return aResGrp._retn();
+ }
+ catch( ... )
+ {
+ return SMESH::SMESH_Group::_nil();
+ }
+}
+
//=============================================================================
/*! IntersectGroups
* New group is created. All mesh elements that are
return aResGrp._retn();
}
+//=============================================================================
+/*!
+ \brief Intersect list of groups. New group is created. All mesh elements that
+ are present in all initial groups simultaneously are added to the new one.
+ \param theGroups list of groups
+ \param theName name of group to be created
+ \return pointer on the group
+*/
+//=============================================================================
+SMESH::SMESH_Group_ptr SMESH_Mesh_i::IntersectListOfGroups(
+ const SMESH::ListOfGroups& theGroups, const char* theName )
+throw (SALOME::SALOME_Exception)
+{
+ if ( !theName )
+ return SMESH::SMESH_Group::_nil();
+
+ try
+ {
+ NCollection_DataMap< int, int > anIdToCount;
+ SMESH::ElementType aType = SMESH::ALL;
+ for ( int g = 0, n = theGroups.length(); g < n; g++ )
+ {
+ SMESH::SMESH_GroupBase_var aGrp = theGroups[ g ];
+ if ( CORBA::is_nil( aGrp ) )
+ continue;
+
+ // check type
+ SMESH::ElementType aCurrType = aGrp->GetType();
+ if ( aType == SMESH::ALL )
+ aType = aCurrType;
+ else
+ {
+ if ( aType != aCurrType )
+ return SMESH::SMESH_Group::_nil();
+ }
+
+ // calculates number of occurance ids in groups
+ SMESH::long_array_var aCurrIds = aGrp->GetListOfID();
+ for ( int i = 0, n = aCurrIds->length(); i < n; i++ )
+ {
+ int aCurrId = aCurrIds[ i ];
+ if ( !anIdToCount.IsBound( aCurrId ) )
+ anIdToCount.Bind( aCurrId, 1 );
+ else
+ anIdToCount( aCurrId ) = anIdToCount( aCurrId ) + 1;
+ }
+ }
+
+ // create map of ids
+ int nbGrp = theGroups.length();
+ NCollection_Map< int > anIds;
+ NCollection_DataMap< int, int >::Iterator anIter( anIdToCount );
+ for ( ; anIter.More(); anIter.Next() )
+ {
+ int aCurrId = anIter.Key();
+ int aCurrNb = anIter.Value();
+ if ( aCurrNb == nbGrp )
+ anIds.Add( aCurrId );
+ }
+
+ // Create group
+ SMESH::SMESH_Group_var aResGrp = CreateGroup( aType, theName );
+ if ( aResGrp->_is_nil() )
+ return SMESH::SMESH_Group::_nil();
+
+ // Create array of identifiers
+ SMESH::long_array_var aResIds = new SMESH::long_array;
+ aResIds->length( anIds.Extent() );
+
+ NCollection_Map< int >::Iterator aListIter( anIds );
+ for ( int i = 0; aListIter.More(); aListIter.Next(), i++ )
+ {
+ aResIds[ i ] = aListIter.Value();
+ }
+ aResGrp->Add( aResIds );
+
+ // Clear python lines, created by CreateGroup() and Add()
+ SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy();
+ _gen_i->RemoveLastFromPythonScript( aStudy->StudyId() );
+ _gen_i->RemoveLastFromPythonScript( aStudy->StudyId() );
+
+ // Update Python script
+
+ TPythonDump() << aResGrp << " = " << _this() << ".IntersectListOfGroups( "
+ << &theGroups << ", '" << theName << "' )";
+
+ return aResGrp._retn();
+ }
+ catch( ... )
+ {
+ return SMESH::SMESH_Group::_nil();
+ }
+}
+
//=============================================================================
/*! CutGroups
* New group is created. All mesh elements that are present in
for ( int i2 = 0, n2 = anIds2->length(); i2 < n2; i2++ )
aMap2.Add( anIds2[ i2 ] );
-
TColStd_SequenceOfInteger aSeq;
for ( int i1 = 0, n1 = anIds1->length(); i1 < n1; i1++ )
if ( !aMap2.Contains( anIds1[ i1 ] ) )
return aResGrp._retn();
}
+//=============================================================================
+/*!
+ \brief Cut lists of groups. New group is created. All mesh elements that are
+ present in main groups but do not present in tool groups are added to the new one
+ \param theMainGroups list of main groups
+ \param theToolGroups list of tool groups
+ \param theName name of group to be created
+ \return pointer on the group
+*/
+//=============================================================================
+SMESH::SMESH_Group_ptr SMESH_Mesh_i::CutListOfGroups(
+ const SMESH::ListOfGroups& theMainGroups,
+ const SMESH::ListOfGroups& theToolGroups,
+ const char* theName )
+ throw (SALOME::SALOME_Exception)
+{
+ if ( !theName )
+ return SMESH::SMESH_Group::_nil();
+
+ try
+ {
+ NCollection_Map< int > aToolIds;
+ SMESH::ElementType aType = SMESH::ALL;
+ int g, n;
+ // iterate through tool groups
+ for ( g = 0, n = theToolGroups.length(); g < n; g++ )
+ {
+ SMESH::SMESH_GroupBase_var aGrp = theToolGroups[ g ];
+ if ( CORBA::is_nil( aGrp ) )
+ continue;
+
+ // check type
+ SMESH::ElementType aCurrType = aGrp->GetType();
+ if ( aType == SMESH::ALL )
+ aType = aCurrType;
+ else
+ {
+ if ( aType != aCurrType )
+ return SMESH::SMESH_Group::_nil();
+ }
+
+ // unite tool ids
+ SMESH::long_array_var aCurrIds = aGrp->GetListOfID();
+ for ( int i = 0, n = aCurrIds->length(); i < n; i++ )
+ {
+ int aCurrId = aCurrIds[ i ];
+ aToolIds.Add( aCurrId );
+ }
+ }
+
+ NCollection_Map< int > anIds; // result
+
+ // Iterate through main group
+ for ( g = 0, n = theMainGroups.length(); g < n; g++ )
+ {
+ SMESH::SMESH_GroupBase_var aGrp = theMainGroups[ g ];
+ if ( CORBA::is_nil( aGrp ) )
+ continue;
+
+ // check type
+ SMESH::ElementType aCurrType = aGrp->GetType();
+ if ( aType == SMESH::ALL )
+ aType = aCurrType;
+ else
+ {
+ if ( aType != aCurrType )
+ return SMESH::SMESH_Group::_nil();
+ }
+
+ // unite tool ids
+ SMESH::long_array_var aCurrIds = aGrp->GetListOfID();
+ for ( int i = 0, n = aCurrIds->length(); i < n; i++ )
+ {
+ int aCurrId = aCurrIds[ i ];
+ if ( !aToolIds.Contains( aCurrId ) )
+ anIds.Add( aCurrId );
+ }
+ }
+
+ // Create group
+ SMESH::SMESH_Group_var aResGrp = CreateGroup( aType, theName );
+ if ( aResGrp->_is_nil() )
+ return SMESH::SMESH_Group::_nil();
+
+ // Create array of identifiers
+ SMESH::long_array_var aResIds = new SMESH::long_array;
+ aResIds->length( anIds.Extent() );
+
+ NCollection_Map< int >::Iterator anIter( anIds );
+ for ( int i = 0; anIter.More(); anIter.Next(), i++ )
+ {
+ aResIds[ i ] = anIter.Value();
+ }
+ aResGrp->Add( aResIds );
+
+ // Clear python lines, created by CreateGroup() and Add()
+ SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy();
+ _gen_i->RemoveLastFromPythonScript( aStudy->StudyId() );
+ _gen_i->RemoveLastFromPythonScript( aStudy->StudyId() );
+
+ // Update Python script
+
+ TPythonDump() << aResGrp << " = " << _this() << ".CutListOfGroups( "
+ << &theMainGroups << ", " << &theToolGroups << ", '"
+ << theName << "' )";
+
+ return aResGrp._retn();
+ }
+ catch( ... )
+ {
+ return SMESH::SMESH_Group::_nil();
+ }
+}
+
+//=============================================================================
+/*!
+ \brief Create groups of entities from existing groups of superior dimensions
+ System
+ 1) extract all nodes from each group,
+ 2) combine all elements of specified dimension laying on these nodes.
+ \param theGroups list of source groups
+ \param theElemType dimension of elements
+ \param theName name of new group
+ \return pointer on new group
+*/
+//=============================================================================
+SMESH::SMESH_Group_ptr SMESH_Mesh_i::CreateDimGroup(
+ const SMESH::ListOfGroups& theGroups,
+ SMESH::ElementType theElemType,
+ const char* theName )
+ throw (SALOME::SALOME_Exception)
+{
+ SMESHDS_Mesh* aMeshDS = _impl->GetMeshDS();
+
+ if ( !theName || !aMeshDS )
+ return SMESH::SMESH_Group::_nil();
+
+ SMDSAbs_ElementType anElemType = (SMDSAbs_ElementType)theElemType;
+
+ try
+ {
+ // Create map of nodes from all groups
+
+ NCollection_Map< int > aNodeMap;
+
+ for ( int g = 0, n = theGroups.length(); g < n; g++ )
+ {
+ SMESH::SMESH_GroupBase_var aGrp = theGroups[ g ];
+ if ( CORBA::is_nil( aGrp ) )
+ continue;
+
+ SMESH::ElementType aType = aGrp->GetType();
+ if ( aType == SMESH::ALL )
+ continue;
+ else if ( aType == SMESH::NODE )
+ {
+ SMESH::long_array_var aCurrIds = aGrp->GetListOfID();
+ for ( int i = 0, n = aCurrIds->length(); i < n; i++ )
+ {
+ int aCurrId = aCurrIds[ i ];
+ const SMDS_MeshNode* aNode = aMeshDS->FindNode( aCurrId );
+ if ( aNode )
+ aNodeMap.Add( aNode->GetID() );
+ }
+ }
+ else
+ {
+ SMESH::long_array_var aCurrIds = aGrp->GetListOfID();
+ for ( int i = 0, n = aCurrIds->length(); i < n; i++ )
+ {
+ int aCurrId = aCurrIds[ i ];
+ const SMDS_MeshElement* anElem = aMeshDS->FindElement( aCurrId );
+ if ( !anElem )
+ continue;
+ SMDS_ElemIteratorPtr aNodeIter = anElem->nodesIterator();
+ while( aNodeIter->more() )
+ {
+ const SMDS_MeshNode* aNode =
+ dynamic_cast<const SMDS_MeshNode*>( aNodeIter->next() );
+ if ( aNode )
+ aNodeMap.Add( aNode->GetID() );
+ }
+ }
+ }
+ }
+
+ // Get result identifiers
+
+ NCollection_Map< int > aResultIds;
+ if ( theElemType == SMESH::NODE )
+ {
+ NCollection_Map< int >::Iterator aNodeIter( aNodeMap );
+ for ( ; aNodeIter.More(); aNodeIter.Next() )
+ aResultIds.Add( aNodeIter.Value() );
+ }
+ else
+ {
+ // Create list of elements of given dimension constructed on the nodes
+ NCollection_Map< int > anElemList;
+ NCollection_Map< int >::Iterator aNodeIter( aNodeMap );
+ for ( ; aNodeIter.More(); aNodeIter.Next() )
+ {
+ const SMDS_MeshElement* aNode =
+ dynamic_cast<const SMDS_MeshElement*>( aMeshDS->FindNode( aNodeIter.Value() ) );
+ if ( !aNode )
+ continue;
+
+ SMDS_ElemIteratorPtr anElemIter = aNode->elementsIterator( anElemType );
+ while( anElemIter->more() )
+ {
+ const SMDS_MeshElement* anElem =
+ dynamic_cast<const SMDS_MeshElement*>( anElemIter->next() );
+ if ( anElem && anElem->GetType() == anElemType )
+ anElemList.Add( anElem->GetID() );
+ }
+ }
+
+ // check whether all nodes of elements are present in nodes map
+ NCollection_Map< int >::Iterator anIter( anElemList );
+ for ( ; anIter.More(); anIter.Next() )
+ {
+ const SMDS_MeshElement* anElem = aMeshDS->FindElement( anIter.Value() );
+ if ( !anElem )
+ continue;
+
+ bool isOk = true;
+ SMDS_ElemIteratorPtr aNodeIter = anElem->nodesIterator();
+ while( aNodeIter->more() )
+ {
+ const SMDS_MeshNode* aNode =
+ dynamic_cast<const SMDS_MeshNode*>( aNodeIter->next() );
+ if ( !aNode || !aNodeMap.Contains( aNode->GetID() ) )
+ {
+ isOk = false;
+ break;
+ }
+ }
+ if ( isOk )
+ aResultIds.Add( anElem->GetID() );
+ }
+ }
+
+ // Create group
+
+ SMESH::SMESH_Group_var aResGrp = CreateGroup( theElemType, theName );
+ if ( aResGrp->_is_nil() )
+ return SMESH::SMESH_Group::_nil();
+
+ // Create array of identifiers
+ SMESH::long_array_var aResIds = new SMESH::long_array;
+ aResIds->length( aResultIds.Extent() );
+
+ NCollection_Map< int >::Iterator aResIter( aResultIds );
+ for ( int i = 0; aResIter.More(); aResIter.Next(), i++ )
+ aResIds[ i ] = aResIter.Value();
+ aResGrp->Add( aResIds );
+
+ // Remove strings corresponding to group creation
+ SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy();
+ _gen_i->RemoveLastFromPythonScript( aStudy->StudyId() );
+ _gen_i->RemoveLastFromPythonScript( aStudy->StudyId() );
+
+ // Update Python script
+
+ TPythonDump() << aResGrp << " = " << _this() << ".CreateDimGroup( "
+ << &theGroups << ", " << theElemType << ", '" << theName << "' )";
+
+ return aResGrp._retn();
+ }
+ catch( ... )
+ {
+ return SMESH::SMESH_Group::_nil();
+ }
+}
+
//================================================================================
/*!
* \brief Return group items of a group present in a study
}
}
+//=============================================================================
+/*!
+ * \brief Create standalone group instead if group on geometry
+ *
+ */
+//=============================================================================
+
+SMESH::SMESH_Group_ptr SMESH_Mesh_i::ConvertToStandalone( SMESH::SMESH_GroupOnGeom_ptr theGroup )
+{
+ SMESH::SMESH_Group_var aGroup;
+ if ( theGroup->_is_nil() )
+ return aGroup._retn();
+
+ Unexpect aCatch(SALOME_SalomeException);
+
+ SMESH_GroupBase_i* aGroupToRem =
+ dynamic_cast<SMESH_GroupBase_i*>( SMESH_Gen_i::GetServant( theGroup ).in() );
+ if ( !aGroupToRem )
+ return aGroup._retn();
+
+ int anId = aGroupToRem->GetLocalID();
+ if ( !_impl->ConvertToStandalone( anId ) )
+ return aGroup._retn();
+
+ SMESH_GroupBase_i* aGroupImpl;
+ aGroupImpl = new SMESH_Group_i( SMESH_Gen_i::GetPOA(), this, anId );
+
+
+ // remove old instance of group from own map
+ _mapGroups.erase( anId );
+
+ SALOMEDS::StudyBuilder_var builder;
+ SALOMEDS::SObject_var aGroupSO;
+ SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy();
+ if ( !aStudy->_is_nil() ) {
+ builder = aStudy->NewBuilder();
+ aGroupSO = _gen_i->ObjectToSObject( aStudy, theGroup );
+ if ( !aGroupSO->_is_nil() ) {
+
+ // remove reference to geometry
+ SALOMEDS::ChildIterator_var chItr = aStudy->NewChildIterator(aGroupSO);
+ for ( ; chItr->More(); chItr->Next() )
+ // Remove group's child SObject
+ builder->RemoveObject( chItr->Value() );
+
+ // Update Python script
+ TPythonDump() << aGroupSO << " = " << _this() << ".ConvertToStandalone( "
+ << aGroupSO << " )";
+ }
+ }
+
+ // PAL7962: san -- To ensure correct mapping of servant and correct reference counting in GenericObj_i
+ SMESH_Gen_i::GetPOA()->activate_object( aGroupImpl );
+ aGroupImpl->Register();
+ // PAL7962: san -- To ensure correct mapping of servant and correct reference counting in GenericObj_i
+
+ // remember new group in own map
+ aGroup = SMESH::SMESH_Group::_narrow( aGroupImpl->_this() );
+ _mapGroups[anId] = SMESH::SMESH_GroupBase::_duplicate( aGroup );
+
+ // register CORBA object for persistence
+ //int nextId = _gen_i->RegisterObject( aGroup );
+ //if(MYDEBUG) MESSAGE( "Add group to map with id = "<< nextId);
+ builder->SetIOR( aGroupSO, _gen_i->GetORB()->object_to_string( aGroup ) );
+
+ return aGroup._retn();
+}
+
//=============================================================================
/*!
*
{
Unexpect aCatch(SALOME_SalomeException);
- // Update Python script
- TPythonDump() << _this() << ".ExportToMED( '"
- << file << "', " << auto_groups << ", " << theVersion << " )";
-
// Perform Export
PrepareForWriting(file);
- char* aMeshName = "Mesh";
+ const char* aMeshName = "Mesh";
SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy();
if ( !aStudy->_is_nil() ) {
SALOMEDS::SObject_var aMeshSO = _gen_i->ObjectToSObject( aStudy, _this() );
if ( !aMeshSO->_is_nil() ) {
aMeshName = aMeshSO->GetName();
- //SCRUTE(file);
- //SCRUTE(aMeshName);
- //SCRUTE(aMeshSO->GetID());
-
// asv : 27.10.04 : fix of 6903: check for StudyLocked before adding attributes
if ( !aStudy->GetProperties()->IsLocked() )
{
}
}
}
+ // Update Python script
+ // set name of mesh before export
+ TPythonDump() << _gen_i << ".SetName(" << _this() << ", '" << aMeshName << "')";
+
+ // check names of groups
+ checkGroupNames();
+
+ TPythonDump() << _this() << ".ExportToMED( '"
+ << file << "', " << auto_groups << ", " << theVersion << " )";
+
_impl->ExportMED( file, aMeshName, auto_groups, theVersion );
}
Unexpect aCatch(SALOME_SalomeException);
// Update Python script
+ // check names of groups
+ checkGroupNames();
TPythonDump() << _this() << ".ExportDAT( '" << file << "' )";
// Perform Export
Unexpect aCatch(SALOME_SalomeException);
// Update Python script
+ // check names of groups
+ checkGroupNames();
TPythonDump() << _this() << ".ExportUNV( '" << file << "' )";
// Perform Export
Unexpect aCatch(SALOME_SalomeException);
// Update Python script
+ // check names of groups
+ checkGroupNames();
TPythonDump() << _this() << ".ExportSTL( '" << file << "', " << isascii << " )";
// Perform Export
}
return res._retn();
}
+
+//=============================================================================
+/*!
+ * \brief Check and correct names of mesh groups
+ */
+//=============================================================================
+
+void SMESH_Mesh_i::checkGroupNames()
+{
+ int nbGrp = NbGroups();
+ if ( !nbGrp )
+ return;
+
+ SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy();
+ if ( aStudy->_is_nil() )
+ return; // nothing to do
+
+ SMESH::ListOfGroups* grpList = 0;
+ // avoid dump of "GetGroups"
+ {
+ // store python dump into a local variable inside local scope
+ SMESH::TPythonDump pDump; // do not delete this line of code
+ grpList = GetGroups();
+ }
+
+ for ( int gIndx = 0; gIndx < nbGrp; gIndx++ ) {
+ SMESH::SMESH_GroupBase_ptr aGrp = (*grpList)[ gIndx ];
+ if ( !aGrp )
+ continue;
+ SALOMEDS::SObject_var aGrpSO = _gen_i->ObjectToSObject( aStudy, aGrp );
+ if ( aGrpSO->_is_nil() )
+ continue;
+ // correct name of the mesh group if necessary
+ const char* guiName = aGrpSO->GetName();
+ if ( strcmp(guiName, aGrp->GetName()) )
+ aGrp->SetName( guiName );
+ }
+}
// File : SMESH_Mesh_i.hxx
// Author : Paul RASCLE, EDF
// Module : SMESH
-// $Header$
//
#ifndef _SMESH_MESH_I_HXX_
#define _SMESH_MESH_I_HXX_
void Clear()
throw (SALOME::SALOME_Exception);
+ void ClearSubMesh(CORBA::Long ShapeID)
+ throw (SALOME::SALOME_Exception);
+
SMESH::Hypothesis_Status AddHypothesis(GEOM::GEOM_Object_ptr aSubShapeObject,
SMESH::SMESH_Hypothesis_ptr anHyp)
throw (SALOME::SALOME_Exception);
SMESH::SMESH_GroupBase_ptr theGroup2,
const char* theName )
throw (SALOME::SALOME_Exception);
+
+ SMESH::SMESH_Group_ptr UnionListOfGroups( const SMESH::ListOfGroups& theGroups,
+ const char* theName)
+ throw (SALOME::SALOME_Exception);
SMESH::SMESH_Group_ptr IntersectGroups( SMESH::SMESH_GroupBase_ptr theGroup1,
SMESH::SMESH_GroupBase_ptr theGroup2,
const char* theName )
throw (SALOME::SALOME_Exception);
+
+ SMESH::SMESH_Group_ptr IntersectListOfGroups( const SMESH::ListOfGroups& theGroups,
+ const char* theName )
+ throw (SALOME::SALOME_Exception);
SMESH::SMESH_Group_ptr CutGroups( SMESH::SMESH_GroupBase_ptr theGroup1,
SMESH::SMESH_GroupBase_ptr theGroup2,
- const char* theName )
+ const char* theName )
throw (SALOME::SALOME_Exception);
+ SMESH::SMESH_Group_ptr CutListOfGroups( const SMESH::ListOfGroups& theMainGroups,
+ const SMESH::ListOfGroups& theToolGroups,
+ const char* theName )
+ throw (SALOME::SALOME_Exception);
+
+ SMESH::SMESH_Group_ptr CreateDimGroup( const SMESH::ListOfGroups& theGroups,
+ SMESH::ElementType theElemType,
+ const char* theName )
+ throw (SALOME::SALOME_Exception);
+
+
+ SMESH::SMESH_Group_ptr ConvertToStandalone( SMESH::SMESH_GroupOnGeom_ptr theGeomGroup );
+
// SMESH::string_array* GetLog(CORBA::Boolean clearAfterGet)
// throw (SALOME::SALOME_Exception);
std::map<int, SMESH_subMesh_i*> _mapSubMesh_i; //NRI
std::map<int, ::SMESH_subMesh*> _mapSubMesh; //NRI
+private:
+ /*!
+ * Check and correct names of mesh groups
+ */
+ void checkGroupNames();
+
private:
static int myIdGenerator;
*/
static TCollection_AsciiString
ConvertScript(const TCollection_AsciiString& theScript,
- Resource_DataMapOfAsciiStringAsciiString& theEntry2AccessorMethod);
+ Resource_DataMapOfAsciiStringAsciiString& theEntry2AccessorMethod,
+ Resource_DataMapOfAsciiStringAsciiString& theObjectNames);
/*!
* \brief Return the name of the python file wrapping IDL API
* \retval TCollection_AsciiString - The file name
*/
- static char* SmeshpyName() { return "smesh"; }
- static char* GenName() { return "smesh.smesh"; }
+ static const char* SmeshpyName() { return "smesh"; }
+ static const char* GenName() { return "smesh.smesh"; }
};
namespace SMESH
TPythonDump&
operator<<(const SMESH::ListOfGroups * theList);
- static char* SMESHGenName() { return "smeshgen"; }
- static char* MeshEditorName() { return "mesh_editor"; }
+ static const char* SMESHGenName() { return "smeshgen"; }
+ static const char* MeshEditorName() { return "mesh_editor"; }
/*!
* \brief Return marker of long string literal beginning
# Author : Nicolas REJNERI, Paul RASCLE
# Modified by : Alexander BORODIN (OCN) - autotools usage
# Module : SMESH
-# $Header$
#
include $(top_srcdir)/adm_local/unix/make_common_starter.am
ex24_cylinder.py \
ex29_refine.py \
ex30_tepal.py \
+ ex30_groupsOp.py \
+ ex31_dimGroup.py \
SMESH_test.py\
SMESH_test0.py\
SMESH_test1.py \
--- /dev/null
+\r
+import sys\r
+import salome\r
+import geompy\r
+import math\r
+import SALOMEDS\r
+import SMESH\r
+import smesh\r
+\r
+salome.salome_init()\r
+aStudyId = salome.myStudy._get_StudyId()\r
+\r
+geompy.init_geom(salome.myStudy)\r
+global Face_1\r
+Face_1 = geompy.MakeFaceHW(100, 100, 1)\r
+geompy.addToStudy( Face_1, "Face_1" )\r
+\r
+#smesh.smesh.SetCurrentStudy(aStudyId)\r
+import StdMeshers\r
+pattern = smesh.GetPattern()\r
+Mesh_1 = smesh.Mesh(Face_1)\r
+Regular_1D = Mesh_1.Segment()\r
+Nb_Segments_1 = Regular_1D.NumberOfSegments(10)\r
+Nb_Segments_1.SetDistrType( 0 )\r
+Quadrangle_2D = Mesh_1.Quadrangle()\r
+isDone = Mesh_1.Compute()\r
+\r
+# groups creation\r
+\r
+aListOfElems = [ 52, 53, 54, 55, 56, 57,\r
+ 62, 63, 64, 65, 66, 67,\r
+ 72, 73, 74, 75, 76, 77,\r
+ 82, 83, 84, 85, 86, 87 ]\r
+ \r
+aRedGroup = Mesh_1.GetMesh().CreateGroup( smesh.FACE, "Red" )\r
+aRedGroup.Add( aListOfElems );\r
+aRedGroup.SetColor( SALOMEDS.Color( 1, 0, 0 ) )\r
+\r
+aListOfElems = [ 55, 56, 57, 58, 59,\r
+ 65, 66, 67, 68, 69,\r
+ 75, 76, 77, 78, 79,\r
+ 85, 86, 87, 88, 89,\r
+ 95, 96, 97, 98, 99,\r
+ 105, 106, 107, 108, 109,\r
+ 115, 116, 117, 118, 119,\r
+ 125, 126, 127, 128, 129 ]\r
+ \r
+aGreenGroup = Mesh_1.GetMesh().CreateGroup( smesh.FACE, "Green" )\r
+aGreenGroup.Add( aListOfElems );\r
+aGreenGroup.SetColor( SALOMEDS.Color( 0, 1, 0 ) )\r
+\r
+aListOfElems = [ 63, 64, 65, 66, 67, 68, \r
+ 73, 74, 75, 76, 77, 78,\r
+ 83, 84, 85, 86, 87, 88, \r
+ 93, 94, 95, 96, 97, 98, \r
+ 103, 104, 105, 106, 107, 108, \r
+ 113, 114, 115, 116, 117, 118 ]\r
+ \r
+aBlueGroup = Mesh_1.GetMesh().CreateGroup( smesh.FACE, "Blue" )\r
+aBlueGroup.Add( aListOfElems );\r
+aBlueGroup.SetColor( SALOMEDS.Color( 0, 0, 1 ) )\r
+\r
+# UnionListOfGroups()\r
+aUnGrp = Mesh_1.UnionListOfGroups([aRedGroup, aGreenGroup, aBlueGroup], "UnionGrp" )\r
+\r
+# IntersectListOfGroups()\r
+aIntGrp=Mesh_1.IntersectListOfGroups([aRedGroup, aGreenGroup, aBlueGroup], "IntGrp" )\r
+\r
+# CutListOfGroups()\r
+aCutGrp=Mesh_1.CutListOfGroups([aRedGroup],[aGreenGroup,aBlueGroup],"CutGrp")\r
+\r
+salome.sg.updateObjBrowser( 1 )\r
+\r
--- /dev/null
+import sys\r
+import salome\r
+import geompy\r
+import math\r
+import SALOMEDS\r
+import SMESH\r
+import smesh\r
+\r
+salome.salome_init()\r
+aStudyId = salome.myStudy._get_StudyId()\r
+\r
+geompy.init_geom(salome.myStudy)\r
+\r
+geompy.init_geom(salome.myStudy)\r
+global Box_1\r
+Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200)\r
+geompy.addToStudy( Box_1, "Box_1" )\r
+\r
+#smesh.smesh.SetCurrentStudy(theStudy)\r
+import StdMeshers\r
+Mesh_1 = smesh.Mesh(Box_1)\r
+Regular_1D = Mesh_1.Segment()\r
+Nb_Segments_1 = Regular_1D.NumberOfSegments(10)\r
+Nb_Segments_1.SetDistrType( 0 )\r
+Quadrangle_2D = Mesh_1.Quadrangle()\r
+Hexa_3D = Mesh_1.Hexahedron()\r
+isDone = Mesh_1.Compute()\r
+\r
+### CreateDimGroup()\r
+\r
+aListOf3d_1=range(721,821)\r
+\r
+aGrp3D_1=Mesh_1.GetMesh().CreateGroup( smesh.VOLUME, "Src 3D 1" )\r
+aGrp3D_1.Add( aListOf3d_1 )\r
+\r
+aListOf3d_2=range(821, 921)\r
+aGrp3D_2=Mesh_1.GetMesh().CreateGroup( smesh.VOLUME, "Src 3D 2" )\r
+aGrp3D_2.Add( aListOf3d_2 )\r
+\r
+aGrp2D = Mesh_1.CreateDimGroup( [aGrp3D_1, aGrp3D_2], smesh.FACE, "Faces" )\r
+\r
+aGrp1D = Mesh_1.CreateDimGroup( [aGrp3D_1, aGrp3D_2], smesh.EDGE, "Edges" )\r
+\r
+aGrp0D = Mesh_1.CreateDimGroup( [aGrp3D_1, aGrp3D_2], smesh.NODE, "Nodes" )\r
+\r
+salome.sg.updateObjBrowser( 1 )\r
+\r
attr = sobj.FindAttribute("AttributeName")[1]
return attr.Value()
-## Sets a name to the object
-def SetName(obj, name):
- if isinstance( obj, Mesh ):
- obj = obj.GetMesh()
- elif isinstance( obj, Mesh_Algorithm ):
- obj = obj.GetAlgorithm()
- ior = salome.orb.object_to_string(obj)
- sobj = salome.myStudy.FindObjectIOR(ior)
- if not sobj is None:
- attr = sobj.FindAttribute("AttributeName")[1]
- attr.SetValue(name)
-
## Prints error message if a hypothesis was not assigned.
def TreatHypoStatus(status, hypName, geomName, isAlgo):
if isAlgo:
# From SMESH_Gen interface:
# ------------------------
+ ## Sets the given name to the object
+ # @param obj the object to rename
+ # @param name a new object name
+ # @ingroup l1_auxiliary
+ def SetName(self, obj, name):
+ print "obj_name = ", name
+ if isinstance( obj, Mesh ):
+ obj = obj.GetMesh()
+ elif isinstance( obj, Mesh_Algorithm ):
+ obj = obj.GetAlgorithm()
+ ior = salome.orb.object_to_string(obj)
+ SMESH._objref_SMESH_Gen.SetName(self, ior, name)
+
## Sets the current mode
# @ingroup l1_auxiliary
def SetEmbeddedMode( self,theMode ):
def GetPattern(self):
return SMESH._objref_SMESH_Gen.GetPattern(self)
+ ## Sets number of segments per diagonal of boundary box of geometry by which
+ # default segment length of appropriate 1D hypotheses is defined.
+ # Default value is 10
+ # @ingroup l1_auxiliary
+ def SetBoundaryBoxSegmentation(self, nbSegments):
+ SMESH._objref_SMESH_Gen.SetBoundaryBoxSegmentation(self,nbSegments)
+
# Filtering. Auxiliary functions:
# ------------------------------
else:
print "Error: The treshold should be a string."
return None
- elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume]:
+ elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume, FT_FreeNodes,
+ FT_FreeFaces, FT_ElemGeomType, FT_GroupColor]:
# At this point the treshold is unnecessary
if aTreshold == FT_LogicalNOT:
aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
else:
print "Error: given parameter is not numerucal functor type."
+ ## Creates hypothesis
+ # @param
+ # @param
+ # @return created hypothesis instance
+ def CreateHypothesis(self, theHType, theLibName="libStdMeshersEngine.so"):
+ return SMESH._objref_SMESH_Gen.CreateHypothesis(self, theHType, theLibName )
import omniORB
#Registering the new proxy for SMESH_Gen
else:
self.mesh = self.smeshpyD.CreateEmptyMesh()
if name != 0:
- SetName(self.mesh, name)
+ self.smeshpyD.SetName(self.mesh, name)
elif obj != 0:
- SetName(self.mesh, GetName(obj))
+ self.smeshpyD.SetName(self.mesh, GetName(obj))
if not self.geom:
self.geom = self.mesh.GetShapeToMesh()
# @param name a new name of the mesh
# @ingroup l2_construct
def SetName(self, name):
- SetName(self.GetMesh(), name)
+ self.smeshpyD.SetName(self.GetMesh(), name)
## Gets the subMesh object associated to a \a theSubObject geometrical object.
# The subMesh object gives access to the IDs of nodes and elements.
smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
salome.sg.updateObjBrowser(1)
+ ## Removes all nodes and elements of indicated shape
+ # @ingroup l2_construct
+ def ClearSubMesh(self, geomId):
+ self.mesh.ClearSubMesh(geomId)
+ if salome.sg.hasDesktop():
+ smeshgui = salome.ImportComponentGUI("SMESH")
+ smeshgui.Init(salome.myStudyId)
+ smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
+ salome.sg.updateObjBrowser(1)
+
## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
# @param fineness [0,-1] defines mesh fineness
# @return True or False
# @ingroup l2_grps_operon
def UnionGroups(self, group1, group2, name):
return self.mesh.UnionGroups(group1, group2, name)
-
+
+ ## Produces a union list of groups
+ # New group is created. All mesh elements that are present in
+ # initial groups are added to the new one
+ # @return an instance of SMESH_Group
+ # @ingroup l2_grps_operon
+ def UnionListOfGroups(self, groups, name):
+ return self.mesh.UnionListOfGroups(groups, name)
+
## Prodices an intersection of two groups
# A new group is created. All mesh elements that are common
# for the two initial groups are added to the new one.
# @ingroup l2_grps_operon
def IntersectGroups(self, group1, group2, name):
return self.mesh.IntersectGroups(group1, group2, name)
+
+ ## Produces an intersection of groups
+ # New group is created. All mesh elements that are present in all
+ # initial groups simultaneously are added to the new one
+ # @return an instance of SMESH_Group
+ # @ingroup l2_grps_operon
+ def IntersectListOfGroups(self, groups, name):
+ return self.mesh.IntersectListOfGroups(groups, name)
## Produces a cut of two groups
# A new group is created. All mesh elements that are present in
# the main group but are not present in the tool group are added to the new one
# @return an instance of SMESH_Group
# @ingroup l2_grps_operon
- def CutGroups(self, mainGroup, toolGroup, name):
- return self.mesh.CutGroups(mainGroup, toolGroup, name)
+ def CutGroups(self, main_group, tool_group, name):
+ return self.mesh.CutGroups(main_group, tool_group, name)
+
+ ## Produces a cut of groups
+ # A new group is created. All mesh elements that are present in main groups
+ # but do not present in tool groups are added to the new one
+ # @return an instance of SMESH_Group
+ # @ingroup l2_grps_operon
+ def CutListOfGroups(self, main_groups, tool_groups, name):
+ return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
+
+ ## Produces a group of elements with specified element type using list of existing groups
+ # A new group is created. System
+ # 1) extract all nodes on which groups elements are built
+ # 2) combine all elements of specified dimension laying on these nodes
+ # @return an instance of SMESH_Group
+ # @ingroup l2_grps_operon
+ def CreateDimGroup(self, groups, elem_type, name):
+ return self.mesh.CreateDimGroup(groups, elem_type, name)
+
+ ## Convert group on geom into standalone group
+ # @ingroup l2_grps_delete
+ def ConvertToStandalone(self, group):
+ return self.mesh.ConvertToStandalone(group)
# Get some info about mesh:
# ------------------------
# @ingroup l1_auxiliary
def GetLastCreatedElems(self):
return self.editor.GetLastCreatedElems()
+
+ ## Creates a hole in a mesh by doubling the nodes of some particular elements
+ # @param theNodes identifiers of nodes to be doubled
+ # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
+ # nodes. If list of element identifiers is empty then nodes are doubled but
+ # they not assigned to elements
+ # @return TRUE if operation has been completed successfully, FALSE otherwise
+ # @ingroup l2_modif_edit
+ def DoubleNodes(self, theNodes, theModifiedElems):
+ return self.editor.DoubleNodes(theNodes, theModifiedElems)
+
+ ## Creates a hole in a mesh by doubling the nodes of some particular elements
+ # This method provided for convenience works as DoubleNodes() described above.
+ # @param theNodes identifiers of node to be doubled
+ # @param theModifiedElems identifiers of elements to be updated
+ # @return TRUE if operation has been completed successfully, FALSE otherwise
+ # @ingroup l2_modif_edit
+ def DoubleNode(self, theNodeId, theModifiedElems):
+ return self.editor.DoubleNode(theNodeId, theModifiedElems)
+
+ ## Creates a hole in a mesh by doubling the nodes of some particular elements
+ # This method provided for convenience works as DoubleNodes() described above.
+ # @param theNodes group of nodes to be doubled
+ # @param theModifiedElems group of elements to be updated.
+ # @return TRUE if operation has been completed successfully, FALSE otherwise
+ # @ingroup l2_modif_edit
+ def DoubleNodeGroup(self, theNodes, theModifiedElems):
+ return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
+
+ ## Creates a hole in a mesh by doubling the nodes of some particular elements
+ # This method provided for convenience works as DoubleNodes() described above.
+ # @param theNodes list of groups of nodes to be doubled
+ # @param theModifiedElems list of groups of elements to be updated.
+ # @return TRUE if operation has been completed successfully, FALSE otherwise
+ # @ingroup l2_modif_edit
+ def DoubleNodeGroups(self, theNodes, theModifiedElems):
+ return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
## The mother class to define algorithm, it is not recommended to use it directly.
#
## Sets the name to the algorithm
def SetName(self, name):
- SetName(self.algo, name)
+ self.mesh.smeshpyD.SetName(self.algo, name)
## Gets the id of the algorithm
def GetId(self):
s = ","
i = i + 1
pass
- SetName(hypo, hyp + a)
+ self.mesh.smeshpyD.SetName(hypo, hyp + a)
pass
status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
return IsEqual(hyp.GetPrecision(), args[1])
return False
+ ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
+ # @param length is optional maximal allowed length of segment, if it is omitted
+ # the preestimated length is used that depends on geometry size
+ # @param UseExisting if ==true - searches for an existing hypothesis created with
+ # the same parameters, else (default) - create a new one
+ # @return an instance of StdMeshers_MaxLength hypothesis
+ # @ingroup l3_hypos_1dhyps
+ def MaxSize(self, length=0.0, UseExisting=0):
+ hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
+ if length > 0.0:
+ # set given length
+ hyp.SetLength(length)
+ if not UseExisting:
+ # set preestimated length
+ gen = self.mesh.smeshpyD
+ initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
+ self.mesh.GetMesh(), self.mesh.GetShape(),
+ False) # <- byMesh
+ preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
+ if preHyp:
+ hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
+ pass
+ pass
+ hyp.SetUsePreestimatedLength( length == 0.0 )
+ return hyp
+
## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
# @param n for the number of segments that cut an edge
# @param s for the scale factor (optional)
StdMeshers_UseExisting_1D2D.hxx \
StdMeshers_QuadToTriaAdaptor.hxx \
SMESH_StdMeshers.hxx \
- StdMeshers_TrianglePreference.hxx
+ StdMeshers_TrianglePreference.hxx \
+ StdMeshers_CompositeHexa_3D.hxx \
+ StdMeshers_MaxLength.hxx
# Libraries targets
StdMeshers_CompositeSegment_1D.cxx \
StdMeshers_UseExisting_1D2D.cxx \
StdMeshers_QuadToTriaAdaptor.cxx \
- StdMeshers_TrianglePreference.cxx
+ StdMeshers_TrianglePreference.cxx \
+ StdMeshers_CompositeHexa_3D.cxx \
+ StdMeshers_MaxLength.cxx
# additionnal information to compil and link file
// File : StdMeshers_Arithmetic1D.cxx
// Author : Damien COQUERET, OCC
// Module : SMESH
-// $Header$
//
#include "StdMeshers_Arithmetic1D.hxx"
}
return nbEdges;
}
+
+//================================================================================
+/*!
+ * \brief Initialize my parameter values by linear size of mesh element.
+ * \retval bool - true if parameter values have been successfully defined
+ */
+//================================================================================
+
+bool StdMeshers_Arithmetic1D::SetParametersByElementSize(double elemLenght,
+ const SMESH_Mesh* /*mesh*/)
+{
+ return bool( _begLength = _endLength = elemLenght );
+}
+
// File : StdMeshers_Arithmetic1D.hxx
// Author : Damien COQUERET, OCC
// Module : SMESH
-// $Header$
//
#ifndef _SMESH_ARITHMETIC1D_HXX_
#define _SMESH_ARITHMETIC1D_HXX_
*/
virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
+ /*!
+ * \brief Initialize my parameter values by linear size of mesh element.
+ * \retval bool - true if parameter values have been successfully defined
+ */
+ virtual bool SetParametersByElementSize( double elemLenght, const SMESH_Mesh* theMesh=0);
+
protected:
double _begLength, _endLength;
};
// File : StdMeshers_AutomaticLength.cxx
// Author : Edward AGAPOV, OCC
// Module : SMESH
-// $Header$
//
#include "StdMeshers_AutomaticLength.hxx"
return nbEdges;
}
+
+//================================================================================
+/*!
+ * \brief Initialize my parameter values by linear size of mesh element.
+ * \retval bool - true if parameter values have been successfully defined
+ */
+//================================================================================
+
+bool StdMeshers_AutomaticLength::SetParametersByElementSize(double elemLenght,
+ const SMESH_Mesh* theMesh)
+{
+ return false;
+
+ // assure the base automatic length is stored in _TShapeToLength
+// GetLength( theMesh, elemLenght );
+
+// // find maximal edge length
+// double maxLen = 0;
+// map<const TopoDS_TShape*, double>::iterator
+// tshape_length = _TShapeToLength.begin(), slEnd = _TShapeToLength.end();
+// for ( ; tshape_length != slEnd; ++tshape_length )
+// if ( tshape_length->second > maxLen )
+// maxLen = tshape_length->second;
+
+// // automatic length for longest element
+// double autoLen = GetLength( theMesh, maxLen );
+
+// // elemLenght = autoLen / (theCoarseConst + theFineConst * _fineness) -->
+// _fineness = ( autoLen / elemLenght - theCoarseConst ) / theFineConst;
+
+// return true;
+}
+
+
// File : StdMeshers_AutomaticLength.hxx
// Author : Edward AGAPOV, OCC
// Module : SMESH
-// $Header$
-//
+
#ifndef _SMESH_AutomaticLength_HXX_
#define _SMESH_AutomaticLength_HXX_
*/
virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
+ /*!
+ * \brief Initialize my parameter values by linear size of mesh element.
+ * \retval bool - true if parameter values have been successfully defined
+ */
+ virtual bool SetParametersByElementSize( double elemLenght, const SMESH_Mesh* theMesh=0);
+
protected:
std::map<const TopoDS_TShape*, double> _TShapeToLength;
const SMESH_Mesh* _mesh;
--- /dev/null
+// SMESH SMESH : implementaion of SMESH idl descriptions
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// File : StdMeshers_CompositeHexa_3D.cxx
+// Module : SMESH
+// Created : Tue Nov 25 11:04:59 2008
+// Author : Edward AGAPOV (eap)
+
+#include "StdMeshers_CompositeHexa_3D.hxx"
+
+#include "SMDS_Mesh.hxx"
+#include "SMDS_MeshNode.hxx"
+#include "SMDS_SetIterator.hxx"
+#include "SMESH_Block.hxx"
+#include "SMESH_Comment.hxx"
+#include "SMESH_ComputeError.hxx"
+#include "SMESH_Mesh.hxx"
+#include "SMESH_MeshEditor.hxx"
+#include "SMESH_MesherHelper.hxx"
+#include "SMESH_subMesh.hxx"
+
+#include <BRepAdaptor_Surface.hxx>
+#include <BRep_Tool.hxx>
+#include <Standard_ErrorHandler.hxx>
+#include <Standard_Failure.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopTools_MapIteratorOfMapOfShape.hxx>
+#include <TopTools_MapOfShape.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_Pnt2d.hxx>
+#include <gp_Vec.hxx>
+#include <gp_XYZ.hxx>
+
+#include <list>
+#include <set>
+#include <vector>
+
+
+#ifdef _DEBUG_
+
+// #define DEB_FACES
+// #define DEB_GRID
+#define DUMP_VERT(msg,V) \
+// { TopoDS_Vertex v = V; gp_Pnt p = BRep_Tool::Pnt(v);\
+// cout << msg << "( "<< p.X()<<", "<<p.Y()<<", "<<p.Z()<<" )"<<endl;}
+
+#else
+
+#define DUMP_VERT(msg,v)
+
+#endif
+
+//================================================================================
+// text for message about an internal error
+#define ERR_LI(txt) SMESH_Comment(txt) << ":" << __LINE__
+
+// order corresponds to right order of edges in CASCADE face
+enum EQuadSides{ Q_BOTTOM=0, Q_RIGHT, Q_TOP, Q_LEFT, Q_CHILD, Q_PARENT };
+
+enum EBoxSides{ B_BOTTOM=0, B_RIGHT, B_TOP, B_LEFT, B_FRONT, B_BACK, B_UNDEFINED };
+
+//================================================================================
+/*!
+ * \brief Convertor of a pair of integers to a sole index
+ */
+struct _Indexer
+{
+ int _xSize, _ySize;
+ _Indexer( int xSize, int ySize ): _xSize(xSize), _ySize(ySize) {}
+ int size() const { return _xSize * _ySize; }
+ int operator()(const int x, const int y) const { return y * _xSize + x; }
+};
+
+//================================================================================
+/*!
+ * \brief Wrapper of a composite or an ordinary edge.
+ */
+class _FaceSide
+{
+public:
+ _FaceSide(const _FaceSide& other);
+ _FaceSide(const TopoDS_Edge& edge=TopoDS_Edge());
+ _FaceSide(const list<TopoDS_Edge>& edges);
+ _FaceSide* GetSide(const int i);
+ const _FaceSide* GetSide(const int i) const;
+ int size() { return myChildren.size(); }
+ int NbVertices() const;
+ TopoDS_Vertex FirstVertex() const;
+ TopoDS_Vertex LastVertex() const;
+ TopoDS_Vertex Vertex(int i) const;
+ bool Contain( const _FaceSide& side, int* which=0 ) const;
+ bool Contain( const TopoDS_Vertex& vertex ) const;
+ void AppendSide( const _FaceSide& side );
+ void SetBottomSide( int i );
+ int GetNbSegments(SMESH_Mesh& mesh) const;
+ bool StoreNodes(SMESH_Mesh& mesh, vector<const SMDS_MeshNode*>& myGrid, bool reverse );
+ void SetID(EQuadSides id) { myID = id; }
+ static inline const TopoDS_TShape* ptr(const TopoDS_Shape& theShape)
+ { return theShape.TShape().operator->(); }
+ void Dump() const;
+
+private:
+
+
+ TopoDS_Edge myEdge;
+ list< _FaceSide > myChildren;
+ int myNbChildren;
+
+ //set<const TopoDS_TShape*> myVertices;
+ TopTools_MapOfShape myVertices;
+
+ EQuadSides myID; // debug
+};
+//================================================================================
+/*!
+ * \brief Class corresponding to a meshed composite face of a box.
+ * Provides simplified access to it's sub-mesh data.
+ */
+class _QuadFaceGrid
+{
+ typedef list< _QuadFaceGrid > TChildren;
+public:
+ _QuadFaceGrid();
+
+public: //** Methods to find and orient faces of 6 sides of the box **//
+
+ //!< initialization
+ bool Init(const TopoDS_Face& f);
+
+ //!< try to unite self with other face
+ bool AddContinuousFace( const _QuadFaceGrid& f );
+
+ //!< Try to set the side as bottom hirizontal side
+ bool SetBottomSide(const _FaceSide& side, int* sideIndex=0);
+
+ //!< Return face adjacent to i-th side of this face
+ _QuadFaceGrid* FindAdjacentForSide(int i, vector<_QuadFaceGrid>& faces) const; // (0<i<4)
+
+ //!< Reverse edges in order to have the bottom edge going along axes of the unit box
+ void ReverseEdges(/*int e1, int e2*/);
+
+ bool IsComplex() const { return !myChildren.empty(); }
+
+ typedef SMDS_SetIterator< const _QuadFaceGrid&, TChildren::const_iterator > TChildIterator;
+
+ TChildIterator GetChildren() const
+ { return TChildIterator( myChildren.begin(), myChildren.end()); }
+
+public: //** Loading and access to mesh **//
+
+ //!< Load nodes of a mesh
+ bool LoadGrid( SMESH_Mesh& mesh );
+
+ //!< Return number of segments on the hirizontal sides
+ int GetNbHoriSegments(SMESH_Mesh& mesh, bool withBrothers=false) const;
+
+ //!< Return number of segments on the vertical sides
+ int GetNbVertSegments(SMESH_Mesh& mesh, bool withBrothers=false) const;
+
+ //!< Return a node by its position
+ const SMDS_MeshNode* GetNode(int iHori, int iVert) const;
+
+ //!< Return node coordinates by its position
+ gp_XYZ GetXYZ(int iHori, int iVert) const;
+
+public: //** Access to member fields **//
+
+ //!< Return i-th face side (0<i<4)
+ const _FaceSide& GetSide(int i) const;
+
+ //!< Return it's face, NULL if it is composite
+ TopoDS_Face GetFace() const { return myFace; }
+
+ //!< Return normal to the face at vertex v
+ bool GetNormal( const TopoDS_Vertex& v, gp_Vec& n ) const;
+
+ SMESH_ComputeErrorPtr GetError() const { return myError; }
+
+ void SetID(EBoxSides id) { myID = id; }
+
+ void DumpGrid() const;
+
+ void DumpVertices() const;
+
+private:
+
+ bool error(std::string& text, int code = COMPERR_ALGO_FAILED)
+ { myError = SMESH_ComputeError::New( code, text ); return false; }
+
+ bool error(const SMESH_ComputeErrorPtr& err)
+ { myError = err; return ( !myError || myError->IsOK() ); }
+
+ bool loadCompositeGrid(SMESH_Mesh& mesh);
+
+ bool fillGrid(SMESH_Mesh& theMesh,
+ vector<const SMDS_MeshNode*> & theGrid,
+ const _Indexer& theIndexer,
+ int theX,
+ int theY);
+
+ bool locateChildren();
+
+ void setBrothers( set< _QuadFaceGrid* >& notLocatedBrothers );
+
+ TopoDS_Face myFace;
+ _FaceSide mySides;
+ bool myReverse;
+
+ TChildren myChildren;
+
+ _QuadFaceGrid* myLeftBottomChild;
+ _QuadFaceGrid* myRightBrother;
+ _QuadFaceGrid* myUpBrother;
+
+ _Indexer myIndexer;
+ vector<const SMDS_MeshNode*> myGrid;
+
+ SMESH_ComputeErrorPtr myError;
+
+ EBoxSides myID; // debug
+};
+
+//================================================================================
+/*!
+ * \brief Constructor
+ */
+//================================================================================
+
+StdMeshers_CompositeHexa_3D::StdMeshers_CompositeHexa_3D(int hypId, int studyId, SMESH_Gen* gen)
+ :SMESH_3D_Algo(hypId, studyId, gen)
+{
+ _name = "CompositeHexa_3D";
+ _shapeType = (1 << TopAbs_SHELL) | (1 << TopAbs_SOLID); // 1 bit /shape type
+}
+
+//================================================================================
+/*!
+ * \brief always return true
+ */
+//================================================================================
+
+bool StdMeshers_CompositeHexa_3D::CheckHypothesis(SMESH_Mesh& aMesh,
+ const TopoDS_Shape& aShape,
+ Hypothesis_Status& aStatus)
+{
+ aStatus = HYP_OK;
+ return true;
+}
+
+//================================================================================
+/*!
+ * \brief Computes hexahedral mesh on a box with composite sides
+ * \param aMesh - mesh to compute
+ * \param aShape - shape to mesh
+ * \retval bool - succes sign
+ */
+//================================================================================
+
+bool StdMeshers_CompositeHexa_3D::Compute(SMESH_Mesh& theMesh,
+ const TopoDS_Shape& theShape)
+{
+ SMESH_MesherHelper helper( theMesh );
+ _quadraticMesh = helper.IsQuadraticSubMesh( theShape );
+ helper.SetElementsOnShape( true );
+
+ // -------------------------
+ // Try to find 6 side faces
+ // -------------------------
+ vector< _QuadFaceGrid > boxFaces; boxFaces.reserve( 6 );
+ TopExp_Explorer exp;
+ int iFace, nbFaces = 0;
+ for ( exp.Init(theShape, TopAbs_FACE); exp.More(); exp.Next(), ++nbFaces )
+ {
+ _QuadFaceGrid f;
+ if ( !f.Init( TopoDS::Face( exp.Current() )))
+ return error (COMPERR_BAD_SHAPE);
+ bool isContinuous = false;
+ for ( int i=0; i < boxFaces.size() && !isContinuous; ++i )
+ isContinuous = boxFaces[ i ].AddContinuousFace( f );
+ if ( !isContinuous )
+ boxFaces.push_back( f );
+ }
+ // Check what we have
+ if ( boxFaces.size() != 6 && nbFaces != 6)
+ return error
+ (COMPERR_BAD_SHAPE,
+ SMESH_Comment("Can't find 6 sides of a box. Number of found sides - ")<<boxFaces.size());
+
+ if ( boxFaces.size() != 6 && nbFaces == 6 ) { // strange ordinary box with continuous faces
+ boxFaces.resize( 6 );
+ iFace = 0;
+ for ( exp.Init(theShape, TopAbs_FACE); exp.More(); exp.Next(), ++iFace )
+ boxFaces[ iFace ].Init( TopoDS::Face( exp.Current() ) );
+ }
+ // ----------------------------------------
+ // Find out position of faces within a box
+ // ----------------------------------------
+
+ _QuadFaceGrid *fBottom, *fTop, *fFront, *fBack, *fLeft, *fRight;
+ // start from a bottom face
+ fBottom = &boxFaces[0];
+ // find vertical faces
+ fFront = fBottom->FindAdjacentForSide( Q_BOTTOM, boxFaces );
+ fLeft = fBottom->FindAdjacentForSide( Q_RIGHT, boxFaces );
+ fBack = fBottom->FindAdjacentForSide( Q_TOP, boxFaces );
+ fRight = fBottom->FindAdjacentForSide( Q_LEFT, boxFaces );
+ // check the found
+ if ( !fFront || !fBack || !fLeft || !fRight )
+ return error(COMPERR_BAD_SHAPE);
+ // top face
+ fTop = 0;
+ for ( int i=1; i < boxFaces.size() && !fTop; ++i ) {
+ fTop = & boxFaces[ i ];
+ if ( fTop==fFront || fTop==fLeft || fTop==fBack || fTop==fRight )
+ fTop = 0;
+ }
+ // set bottom of the top side
+ if ( !fTop->SetBottomSide( fFront->GetSide( Q_TOP ) )) {
+ if ( !fFront->IsComplex() )
+ return error( ERR_LI("Error in StdMeshers_CompositeHexa_3D::Compute()"));
+ else {
+ _QuadFaceGrid::TChildIterator chIt = fFront->GetChildren();
+ while ( chIt.more() ) {
+ const _QuadFaceGrid& frontChild = chIt.next();
+ if ( fTop->SetBottomSide( frontChild.GetSide( Q_TOP )))
+ break;
+ }
+ }
+ }
+ if ( !fTop )
+ return error(COMPERR_BAD_SHAPE);
+
+ fBottom->SetID( B_BOTTOM );
+ fBack ->SetID( B_BACK );
+ fLeft ->SetID( B_LEFT );
+ fFront ->SetID( B_FRONT );
+ fRight ->SetID( B_RIGHT );
+ fTop ->SetID( B_TOP );
+
+ // orient bottom egde of faces along axes of the unit box
+ fBottom->ReverseEdges();
+ fBack ->ReverseEdges();
+ fLeft ->ReverseEdges();
+
+ // ------------------------------------------
+ // Fill columns of nodes with existing nodes
+ // ------------------------------------------
+
+ // let faces load their grids
+ if ( !fBottom->LoadGrid( theMesh )) return error( fBottom->GetError() );
+ if ( !fBack ->LoadGrid( theMesh )) return error( fBack ->GetError() );
+ if ( !fLeft ->LoadGrid( theMesh )) return error( fLeft ->GetError() );
+ if ( !fFront ->LoadGrid( theMesh )) return error( fFront ->GetError() );
+ if ( !fRight ->LoadGrid( theMesh )) return error( fRight ->GetError() );
+ if ( !fTop ->LoadGrid( theMesh )) return error( fTop ->GetError() );
+
+ int x, xSize = fBottom->GetNbHoriSegments(theMesh) + 1, X = xSize - 1;
+ int y, ySize = fBottom->GetNbVertSegments(theMesh) + 1, Y = ySize - 1;
+ int z, zSize = fFront ->GetNbVertSegments(theMesh) + 1, Z = zSize - 1;
+ _Indexer colIndex( xSize, ySize );
+ vector< vector< const SMDS_MeshNode* > > columns( colIndex.size() );
+
+ // fill node columns by front and back box sides
+ for ( x = 0; x < xSize; ++x ) {
+ vector< const SMDS_MeshNode* >& column0 = columns[ colIndex( x, 0 )];
+ vector< const SMDS_MeshNode* >& column1 = columns[ colIndex( x, Y )];
+ column0.resize( zSize );
+ column1.resize( zSize );
+ for ( z = 0; z < zSize; ++z ) {
+ column0[ z ] = fFront->GetNode( x, z );
+ column1[ z ] = fBack ->GetNode( x, z );
+ }
+ }
+ // fill node columns by left and right box sides
+ for ( y = 1; y < ySize-1; ++y ) {
+ vector< const SMDS_MeshNode* >& column0 = columns[ colIndex( 0, y )];
+ vector< const SMDS_MeshNode* >& column1 = columns[ colIndex( X, y )];
+ column0.resize( zSize );
+ column1.resize( zSize );
+ for ( z = 0; z < zSize; ++z ) {
+ column0[ z ] = fLeft ->GetNode( y, z );
+ column1[ z ] = fRight->GetNode( y, z );
+ }
+ }
+ // get nodes from top and bottom box sides
+ for ( x = 1; x < xSize-1; ++x ) {
+ for ( y = 1; y < ySize-1; ++y ) {
+ vector< const SMDS_MeshNode* >& column = columns[ colIndex( x, y )];
+ column.resize( zSize );
+ column.front() = fBottom->GetNode( x, y );
+ column.back() = fTop ->GetNode( x, y );
+ }
+ }
+
+ // ----------------------------
+ // Add internal nodes of a box
+ // ----------------------------
+ // projection points of internal nodes on box subshapes by which
+ // coordinates of internal nodes are computed
+ vector<gp_XYZ> pointsOnShapes( SMESH_Block::ID_Shell );
+
+ // projections on vertices are constant
+ pointsOnShapes[ SMESH_Block::ID_V000 ] = fBottom->GetXYZ( 0, 0 );
+ pointsOnShapes[ SMESH_Block::ID_V100 ] = fBottom->GetXYZ( X, 0 );
+ pointsOnShapes[ SMESH_Block::ID_V010 ] = fBottom->GetXYZ( 0, Y );
+ pointsOnShapes[ SMESH_Block::ID_V110 ] = fBottom->GetXYZ( X, Y );
+ pointsOnShapes[ SMESH_Block::ID_V001 ] = fTop->GetXYZ( 0, 0 );
+ pointsOnShapes[ SMESH_Block::ID_V101 ] = fTop->GetXYZ( X, 0 );
+ pointsOnShapes[ SMESH_Block::ID_V011 ] = fTop->GetXYZ( 0, Y );
+ pointsOnShapes[ SMESH_Block::ID_V111 ] = fTop->GetXYZ( X, Y );
+
+ for ( x = 1; x < xSize-1; ++x )
+ {
+ gp_XYZ params; // normalized parameters of internal node within a unit box
+ params.SetCoord( 1, x / double(X) );
+ for ( y = 1; y < ySize-1; ++y )
+ {
+ params.SetCoord( 2, y / double(Y) );
+ // column to fill during z loop
+ vector< const SMDS_MeshNode* >& column = columns[ colIndex( x, y )];
+ // points projections on horizontal edges
+ pointsOnShapes[ SMESH_Block::ID_Ex00 ] = fBottom->GetXYZ( x, 0 );
+ pointsOnShapes[ SMESH_Block::ID_Ex10 ] = fBottom->GetXYZ( x, Y );
+ pointsOnShapes[ SMESH_Block::ID_E0y0 ] = fBottom->GetXYZ( 0, y );
+ pointsOnShapes[ SMESH_Block::ID_E1y0 ] = fBottom->GetXYZ( X, y );
+ pointsOnShapes[ SMESH_Block::ID_Ex01 ] = fTop->GetXYZ( x, 0 );
+ pointsOnShapes[ SMESH_Block::ID_Ex11 ] = fTop->GetXYZ( x, Y );
+ pointsOnShapes[ SMESH_Block::ID_E0y1 ] = fTop->GetXYZ( 0, y );
+ pointsOnShapes[ SMESH_Block::ID_E1y1 ] = fTop->GetXYZ( X, y );
+ // points projections on horizontal faces
+ pointsOnShapes[ SMESH_Block::ID_Fxy0 ] = fBottom->GetXYZ( x, y );
+ pointsOnShapes[ SMESH_Block::ID_Fxy1 ] = fTop ->GetXYZ( x, y );
+ for ( z = 1; z < zSize-1; ++z ) // z loop
+ {
+ params.SetCoord( 3, z / double(Z) );
+ // point projections on vertical edges
+ pointsOnShapes[ SMESH_Block::ID_E00z ] = fFront->GetXYZ( 0, z );
+ pointsOnShapes[ SMESH_Block::ID_E10z ] = fFront->GetXYZ( X, z );
+ pointsOnShapes[ SMESH_Block::ID_E01z ] = fBack->GetXYZ( 0, z );
+ pointsOnShapes[ SMESH_Block::ID_E11z ] = fBack->GetXYZ( X, z );
+ // point projections on vertical faces
+ pointsOnShapes[ SMESH_Block::ID_Fx0z ] = fFront->GetXYZ( x, z );
+ pointsOnShapes[ SMESH_Block::ID_Fx1z ] = fBack ->GetXYZ( x, z );
+ pointsOnShapes[ SMESH_Block::ID_F0yz ] = fLeft ->GetXYZ( y, z );
+ pointsOnShapes[ SMESH_Block::ID_F1yz ] = fRight->GetXYZ( y, z );
+
+ // compute internal node coordinates
+ gp_XYZ coords;
+ SMESH_Block::ShellPoint( params, pointsOnShapes, coords );
+ column[ z ] = helper.AddNode( coords.X(), coords.Y(), coords.Z() );
+
+#ifdef DEB_GRID
+ // debug
+ //cout << "----------------------------------------------------------------------"<<endl;
+ //for ( int id = SMESH_Block::ID_V000; id < SMESH_Block::ID_Shell; ++id)
+ //{
+ // gp_XYZ p = pointsOnShapes[ id ];
+ // SMESH_Block::DumpShapeID( id,cout)<<" ( "<<p.X()<<", "<<p.Y()<<", "<<p.Z()<<" )"<<endl;
+ //}
+ //cout << "Params: ( "<< params.X()<<", "<<params.Y()<<", "<<params.Z()<<" )"<<endl;
+ //cout << "coords: ( "<< coords.X()<<", "<<coords.Y()<<", "<<coords.Z()<<" )"<<endl;
+#endif
+ }
+ }
+ }
+ // faces no more needed, free memory
+ boxFaces.clear();
+
+ // ----------------
+ // Add hexahedrons
+ // ----------------
+ for ( x = 0; x < xSize-1; ++x ) {
+ for ( y = 0; y < ySize-1; ++y ) {
+ vector< const SMDS_MeshNode* >& col00 = columns[ colIndex( x, y )];
+ vector< const SMDS_MeshNode* >& col10 = columns[ colIndex( x+1, y )];
+ vector< const SMDS_MeshNode* >& col01 = columns[ colIndex( x, y+1 )];
+ vector< const SMDS_MeshNode* >& col11 = columns[ colIndex( x+1, y+1 )];
+ for ( z = 0; z < zSize-1; ++z )
+ {
+ // bottom face normal of a hexa mush point outside the volume
+ helper.AddVolume(col00[z], col01[z], col11[z], col10[z],
+ col00[z+1], col01[z+1], col11[z+1], col10[z+1]);
+ }
+ }
+ }
+ return true;
+}
+
+//================================================================================
+/*!
+ * \brief constructor of non-initialized _QuadFaceGrid
+ */
+//================================================================================
+
+_QuadFaceGrid::_QuadFaceGrid():
+ myReverse(false), myRightBrother(0), myUpBrother(0), myIndexer(0,0), myID(B_UNDEFINED)
+{
+}
+
+//================================================================================
+/*!
+ * \brief Initialization
+ */
+//================================================================================
+
+bool _QuadFaceGrid::Init(const TopoDS_Face& f)
+{
+ myFace = f;
+ mySides = _FaceSide();
+ myReverse = false;
+ myLeftBottomChild = myRightBrother = myUpBrother = 0;
+ myChildren.clear();
+ myGrid.clear();
+ //if ( myFace.Orientation() != TopAbs_FORWARD )
+ //myFace.Reverse();
+
+ TopoDS_Vertex V;
+ list< TopoDS_Edge > edges;
+ list< int > nbEdgesInWire;
+ int nbWire = SMESH_Block::GetOrderedEdges (myFace, V, edges, nbEdgesInWire);
+ if ( nbWire != 1 )
+ return false;
+
+ list< TopoDS_Edge >::iterator edgeIt = edges.begin();
+ if ( nbEdgesInWire.front() == 4 ) // exactly 4 edges
+ {
+ for ( ; edgeIt != edges.end(); ++edgeIt )
+ mySides.AppendSide( _FaceSide( *edgeIt ));
+ }
+ else if ( nbEdgesInWire.front() > 4 ) { // more than 4 edges - try to unite some
+ list< TopoDS_Edge > sideEdges;
+ while ( !edges.empty()) {
+ sideEdges.clear();
+ sideEdges.splice( sideEdges.end(), edges, edges.begin());// edges.front()->sideEdges.back()
+ while ( !edges.empty() ) {
+ if ( SMESH_Algo::IsContinuous( sideEdges.back(), edges.front() )) {
+ sideEdges.splice( sideEdges.end(), edges, edges.begin());
+ }
+ else if ( SMESH_Algo::IsContinuous( sideEdges.front(), edges.back() )) {
+ sideEdges.splice( sideEdges.begin(), edges, --edges.end());
+ }
+ else {
+ break;
+ }
+ }
+ mySides.AppendSide( _FaceSide( sideEdges ));
+ }
+ }
+ if (mySides.size() != 4)
+ return false;
+
+#ifdef _DEBUG_
+ mySides.GetSide( Q_BOTTOM )->SetID( Q_BOTTOM );
+ mySides.GetSide( Q_RIGHT )->SetID( Q_RIGHT );
+ mySides.GetSide( Q_TOP )->SetID( Q_TOP );
+ mySides.GetSide( Q_LEFT )->SetID( Q_LEFT );
+#endif
+
+ return true;
+}
+
+//================================================================================
+/*!
+ * \brief Try to unite self with other ordinary face
+ */
+//================================================================================
+
+bool _QuadFaceGrid::AddContinuousFace( const _QuadFaceGrid& other )
+{
+ for ( int i = 0; i < 4; ++i ) {
+ const _FaceSide& otherSide = other.GetSide( i );
+ int iMyCommon;
+ if ( mySides.Contain( otherSide, &iMyCommon ) ) {
+ // check if normals of two faces are collinear at all vertices of a otherSide
+ const double angleTol = PI / 180 / 2;
+ int iV, nbV = otherSide.NbVertices(), nbCollinear = 0;
+ for ( iV = 0; iV < nbV; ++iV )
+ {
+ TopoDS_Vertex v = otherSide.Vertex( iV );
+ gp_Vec n1, n2;
+ if ( !GetNormal( v, n1 ) || !other.GetNormal( v, n2 ))
+ continue;
+ if ( n1 * n2 < 0 )
+ n1.Reverse();
+ if ( n1.Angle(n2) < angleTol )
+ nbCollinear++;
+ else
+ break;
+ }
+ if ( nbCollinear > 1 ) { // this face becomes composite if not yet is
+ DUMP_VERT("Cont 1", mySides.GetSide(iMyCommon)->FirstVertex());
+ DUMP_VERT("Cont 2", mySides.GetSide(iMyCommon)->LastVertex());
+ DUMP_VERT("Cont 3", otherSide.FirstVertex());
+ DUMP_VERT("Cont 4", otherSide.LastVertex());
+ if ( myChildren.empty() ) {
+ myChildren.push_back( *this );
+ myFace.Nullify();
+ }
+ myChildren.push_back( other );
+ int otherBottomIndex = ( 4 + i - iMyCommon + 2 ) % 4;
+ myChildren.back().SetBottomSide( other.GetSide( otherBottomIndex ));
+ // collect vertices in mySides
+ mySides.AppendSide( other.GetSide(0) );
+ mySides.AppendSide( other.GetSide(1) );
+ mySides.AppendSide( other.GetSide(2) );
+ mySides.AppendSide( other.GetSide(3) );
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+//================================================================================
+/*!
+ * \brief Try to set the side as bottom hirizontal side
+ */
+//================================================================================
+
+bool _QuadFaceGrid::SetBottomSide(const _FaceSide& bottom, int* sideIndex)
+{
+ myLeftBottomChild = myRightBrother = myUpBrother = 0;
+
+ int myBottomIndex;
+ if ( myChildren.empty() )
+ {
+ if ( mySides.Contain( bottom, &myBottomIndex )) {
+ mySides.SetBottomSide( myBottomIndex );
+ if ( sideIndex )
+ *sideIndex = myBottomIndex;
+ return true;
+ }
+ }
+ else
+ {
+ TChildren::iterator childFace = myChildren.begin(), childEnd = myChildren.end();
+ for ( ; childFace != childEnd; ++childFace )
+ {
+ if ( childFace->SetBottomSide( bottom, &myBottomIndex ))
+ {
+ TChildren::iterator orientedCild = childFace;
+ for ( childFace = myChildren.begin(); childFace != childEnd; ++childFace ) {
+ if ( childFace != orientedCild )
+ childFace->SetBottomSide( childFace->GetSide( myBottomIndex ));
+ }
+ if ( sideIndex )
+ *sideIndex = myBottomIndex;
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+//================================================================================
+/*!
+ * \brief Return face adjacent to i-th side of this face, (0<i<4)
+ */
+//================================================================================
+
+_QuadFaceGrid* _QuadFaceGrid::FindAdjacentForSide(int i, vector<_QuadFaceGrid>& faces) const
+{
+ for ( int iF = 0; iF < faces.size(); ++iF ) {
+ _QuadFaceGrid* f = &faces[ iF ];
+ if ( f != this && f->SetBottomSide( GetSide( i )))
+ return f;
+ }
+ return (_QuadFaceGrid*) 0;
+}
+
+//================================================================================
+/*!
+ * \brief Return i-th side
+ */
+//================================================================================
+
+const _FaceSide& _QuadFaceGrid::GetSide(int i) const
+{
+ if ( myChildren.empty() )
+ return *mySides.GetSide(i);
+
+ _QuadFaceGrid* me = const_cast<_QuadFaceGrid*>(this);
+ if ( !me->locateChildren() || !myLeftBottomChild )
+ return *mySides.GetSide(i);
+
+ const _QuadFaceGrid* child = myLeftBottomChild;
+ switch ( i ){
+ case Q_BOTTOM:
+ case Q_LEFT:
+ break;
+ case Q_RIGHT:
+ while ( child->myRightBrother )
+ child = child->myRightBrother;
+ break;
+ case Q_TOP:
+ while ( child->myUpBrother )
+ child = child->myUpBrother;
+ break;
+ default: ;
+ }
+ return child->GetSide( i );
+}
+
+//================================================================================
+/*!
+ * \brief Reverse edges in order to have them oriented along axes of the unit box
+ */
+//================================================================================
+
+void _QuadFaceGrid::ReverseEdges(/*int e1, int e2*/)
+{
+ myReverse = !myReverse;
+
+// #ifdef DEB_FACES
+// if ( !myFace.IsNull() )
+// TopAbs::Print(myFace.Orientation(), cout);
+// #endif
+
+ if ( myChildren.empty() )
+ {
+// mySides.GetSide( e1 )->Reverse();
+// mySides.GetSide( e2 )->Reverse();
+ DumpVertices();
+ }
+ else
+ {
+ DumpVertices();
+ TChildren::iterator child = myChildren.begin(), childEnd = myChildren.end();
+ for ( ; child != childEnd; ++child )
+ child->ReverseEdges( /*e1, e2*/ );
+ }
+}
+
+//================================================================================
+/*!
+ * \brief Load nodes of a mesh
+ */
+//================================================================================
+
+bool _QuadFaceGrid::LoadGrid( SMESH_Mesh& mesh )
+{
+ if ( !myChildren.empty() )
+ {
+ // Let child faces load their grids
+ TChildren::iterator child = myChildren.begin(), childEnd = myChildren.end();
+ for ( ; child != childEnd; ++child ) {
+ child->SetID( myID );
+ if ( !child->LoadGrid( mesh ) )
+ return error( child->GetError() );
+ }
+ // Fill myGrid with nodes of patches
+ return loadCompositeGrid( mesh );
+ }
+
+ // ---------------------------------------
+ // Fill myGrid with nodes bound to myFace
+ // ---------------------------------------
+
+ if ( !myGrid.empty() )
+ return true;
+
+ myIndexer._xSize = 1 + mySides.GetSide( Q_BOTTOM )->GetNbSegments( mesh );
+ myIndexer._ySize = 1 + mySides.GetSide( Q_LEFT )->GetNbSegments( mesh );
+
+ myGrid.resize( myIndexer.size() );
+
+ // strore nodes bound to the bottom edge
+ mySides.GetSide( Q_BOTTOM )->StoreNodes( mesh, myGrid, myReverse );
+
+ // store the rest nodes row by row
+
+ SMESHDS_SubMesh* faceSubMesh = mesh.GetSubMesh( myFace )->GetSubMeshDS();
+
+ SMDS_MeshNode dummy(0,0,0);
+ const SMDS_MeshElement* firstQuad = &dummy;// most left face above the last row of found nodes
+
+ int nbFoundNodes = myIndexer._xSize;
+ while ( nbFoundNodes != myGrid.size() )
+ {
+ // first and last nodes of the last filled row of nodes
+ const SMDS_MeshNode* n1down = myGrid[ nbFoundNodes - myIndexer._xSize ];
+ const SMDS_MeshNode* n2down = myGrid[ nbFoundNodes - myIndexer._xSize + 1];
+ const SMDS_MeshNode* n1downLast = myGrid[ nbFoundNodes-1 ];
+
+ // find the first face above the row by the first two left nodes
+ //
+ // n1up n2up
+ // o---o
+ // | |
+ // o---o o o o o
+ //n1down n2down
+ //
+ TIDSortedElemSet emptySet, avoidSet;
+ avoidSet.insert( firstQuad );
+ firstQuad = SMESH_MeshEditor::FindFaceInSet( n1down, n2down, emptySet, avoidSet);
+ if ( firstQuad && !faceSubMesh->Contains( firstQuad )) {
+ avoidSet.insert( firstQuad );
+ firstQuad = SMESH_MeshEditor::FindFaceInSet( n1down, n2down, emptySet, avoidSet);
+ }
+ if ( !firstQuad || !faceSubMesh->Contains( firstQuad ))
+ return error(ERR_LI("Error in _QuadFaceGrid::LoadGrid()"));
+
+ // find the node of quad bound to the left geom edge
+ int i2down = firstQuad->GetNodeIndex( n2down );
+ const SMDS_MeshNode* n1up = firstQuad->GetNode(( i2down+2 ) % 4 );
+ myGrid[ nbFoundNodes++ ] = n1up;
+ // the 4-the node of the first quad
+ int i1down = firstQuad->GetNodeIndex( n1down );
+ const SMDS_MeshNode* n2up = firstQuad->GetNode(( i1down+2 ) % 4 );
+ myGrid[ nbFoundNodes++ ] = n2up;
+
+ n1down = n2down;
+ n1up = n2up;
+ const SMDS_MeshElement* quad = firstQuad;
+
+ // find the rest nodes by remaining faces above the row
+ //
+ // n1up
+ // o---o--o
+ // | | | ->
+ // o---o--o o o o
+ // n1downLast
+ //
+ while ( n1down != n1downLast )
+ {
+ // next face
+ avoidSet.clear(); avoidSet.insert( quad );
+ quad = SMESH_MeshEditor::FindFaceInSet( n1down, n1up, emptySet, avoidSet );
+ if ( !quad || quad->NbNodes() % 4 > 0)
+ return error(ERR_LI("Error in _QuadFaceGrid::LoadGrid()"));
+
+ // next node
+ if ( quad->GetNode( i1down ) != n1down ) // check already found index
+ i1down = quad->GetNodeIndex( n1down );
+ n2up = quad->GetNode(( i1down+2 ) % 4 );
+ myGrid[ nbFoundNodes++ ] = n2up;
+
+ n1down = myGrid[ nbFoundNodes - myIndexer._xSize - 1 ];
+ n1up = n2up;
+ }
+ }
+
+ DumpGrid(); // debug
+
+ return true;
+}
+
+//================================================================================
+/*!
+ * \brief Find out mutual location of children: find their right and up brothers
+ */
+//================================================================================
+
+bool _QuadFaceGrid::locateChildren()
+{
+ if ( myLeftBottomChild )
+ return true;
+
+ TChildren::iterator child = myChildren.begin(), childEnd = myChildren.end();
+
+ // find a child sharing it's first bottom vertex with no other brother
+ myLeftBottomChild = 0;
+ for ( ; !myLeftBottomChild && child != childEnd; ++child )
+ {
+ TopoDS_Vertex leftVertex = child->GetSide( Q_BOTTOM ).FirstVertex();
+ bool sharedVertex = false;
+ TChildren::iterator otherChild = myChildren.begin();
+ for ( ; otherChild != childEnd && !sharedVertex; ++otherChild )
+ if ( otherChild != child )
+ sharedVertex = otherChild->mySides.Contain( leftVertex );
+ if ( !sharedVertex ) {
+ myLeftBottomChild = & (*child);
+ DUMP_VERT("0 left bottom Vertex: ",leftVertex );
+ }
+ }
+ if (!myLeftBottomChild)
+ return error(ERR_LI("Error in locateChildren()"));
+
+ set< _QuadFaceGrid* > notLocatedChilren;
+ for (child = myChildren.begin() ; child != childEnd; ++child )
+ notLocatedChilren.insert( & (*child));
+
+ // connect myLeftBottomChild to it's right and upper brothers
+ notLocatedChilren.erase( myLeftBottomChild );
+ myLeftBottomChild->setBrothers( notLocatedChilren );
+ if ( !notLocatedChilren.empty() )
+ return error(ERR_LI("Error in locateChildren()"));
+
+ return true;
+}
+
+//================================================================================
+/*!
+ * \brief Fill myGrid with nodes of patches
+ */
+//================================================================================
+
+bool _QuadFaceGrid::loadCompositeGrid(SMESH_Mesh& mesh)
+{
+ // Find out mutual location of children: find their right and up brothers
+ if ( !locateChildren() )
+ return false;
+
+ // Load nodes according to mutual location of children
+
+ // grid size
+ myIndexer._xSize = 1 + myLeftBottomChild->GetNbHoriSegments(mesh, /*withBrothers=*/true);
+ myIndexer._ySize = 1 + myLeftBottomChild->GetNbVertSegments(mesh, /*withBrothers=*/true);
+
+ myGrid.resize( myIndexer.size() );
+
+ int fromX = myReverse ? myIndexer._xSize : 0;
+ if (!myLeftBottomChild->fillGrid( mesh, myGrid, myIndexer, fromX, 0 ))
+ return error( myLeftBottomChild->GetError() );
+
+ DumpGrid();
+
+ return true;
+}
+
+//================================================================================
+/*!
+ * \brief Find right an upper brothers among notLocatedBrothers
+ */
+//================================================================================
+
+void _QuadFaceGrid::setBrothers( set< _QuadFaceGrid* >& notLocatedBrothers )
+{
+ if ( !notLocatedBrothers.empty() )
+ {
+ // find right brother
+ TopoDS_Vertex rightVertex = GetSide( Q_BOTTOM ).LastVertex();
+ DUMP_VERT("1 right bottom Vertex: ",rightVertex );
+ set< _QuadFaceGrid* >::iterator brIt, brEnd = notLocatedBrothers.end();
+ for ( brIt = notLocatedBrothers.begin(); !myRightBrother && brIt != brEnd; ++brIt )
+ {
+ _QuadFaceGrid* brother = *brIt;
+ TopoDS_Vertex brotherLeftVertex = brother->GetSide( Q_BOTTOM ).FirstVertex();
+ DUMP_VERT( "brother left bottom: ", brotherLeftVertex );
+ if ( rightVertex.IsSame( brotherLeftVertex )) {
+ myRightBrother = brother;
+ notLocatedBrothers.erase( myRightBrother );
+ }
+ }
+ // find upper brother
+ TopoDS_Vertex upVertex = GetSide( Q_LEFT ).FirstVertex();
+ DUMP_VERT("1 left up Vertex: ",upVertex);
+ brIt = notLocatedBrothers.begin(), brEnd = notLocatedBrothers.end();
+ for ( ; !myUpBrother && brIt != brEnd; ++brIt )
+ {
+ _QuadFaceGrid* brother = *brIt;
+ TopoDS_Vertex brotherLeftVertex = brother->GetSide( Q_BOTTOM ).FirstVertex();
+ DUMP_VERT("brother left bottom: ", brotherLeftVertex);
+ if ( upVertex.IsSame( brotherLeftVertex )) {
+ myUpBrother = brother;
+ notLocatedBrothers.erase( myUpBrother );
+ }
+ }
+ // recursive call
+ if ( myRightBrother )
+ myRightBrother->setBrothers( notLocatedBrothers );
+ if ( myUpBrother )
+ myUpBrother->setBrothers( notLocatedBrothers );
+ }
+}
+
+//================================================================================
+/*!
+ * \brief Store nodes of a simple face into grid starting from (x,y) position
+ */
+//================================================================================
+
+bool _QuadFaceGrid::fillGrid(SMESH_Mesh& theMesh,
+ vector<const SMDS_MeshNode*> & theGrid,
+ const _Indexer& theIndexer,
+ int theX,
+ int theY)
+{
+ if ( myGrid.empty() && !LoadGrid( theMesh ))
+ return false;
+
+ // store my own grid in the global grid
+
+ int fromX = myReverse ? theX - myIndexer._xSize: theX;
+
+ for ( int i = 0, x = fromX; i < myIndexer._xSize; ++i, ++x )
+ for ( int j = 0, y = theY; j < myIndexer._ySize; ++j, ++y )
+ theGrid[ theIndexer( x, y )] = myGrid[ myIndexer( i, j )];
+
+ // store grids of my right and upper brothers
+
+ if ( myRightBrother )
+ {
+ if ( myReverse )
+ fromX += 1;
+ else
+ fromX += myIndexer._xSize - 1;
+ if ( !myRightBrother->fillGrid( theMesh, theGrid, theIndexer, fromX, theY ))
+ return error( myRightBrother->GetError() );
+ }
+ if ( myUpBrother )
+ {
+ if ( !myUpBrother->fillGrid( theMesh, theGrid, theIndexer,
+ theX, theY + myIndexer._ySize - 1))
+ return error( myUpBrother->GetError() );
+ }
+ return true;
+}
+
+//================================================================================
+/*!
+ * \brief Return number of segments on the hirizontal sides
+ */
+//================================================================================
+
+int _QuadFaceGrid::GetNbHoriSegments(SMESH_Mesh& mesh, bool withBrothers) const
+{
+ int nbSegs = 0;
+ if ( myLeftBottomChild )
+ {
+ nbSegs += myLeftBottomChild->GetNbHoriSegments( mesh, true );
+ }
+ else
+ {
+ nbSegs = mySides.GetSide( Q_BOTTOM )->GetNbSegments(mesh);
+ if ( withBrothers && myRightBrother )
+ nbSegs += myRightBrother->GetNbHoriSegments( mesh, withBrothers );
+ }
+ return nbSegs;
+}
+
+//================================================================================
+/*!
+ * \brief Return number of segments on the vertical sides
+ */
+//================================================================================
+
+int _QuadFaceGrid::GetNbVertSegments(SMESH_Mesh& mesh, bool withBrothers) const
+{
+ int nbSegs = 0;
+ if ( myLeftBottomChild )
+ {
+ nbSegs += myLeftBottomChild->GetNbVertSegments( mesh, true );
+ }
+ else
+ {
+ nbSegs = mySides.GetSide( Q_LEFT )->GetNbSegments(mesh);
+ if ( withBrothers && myUpBrother )
+ nbSegs += myUpBrother->GetNbVertSegments( mesh, withBrothers );
+ }
+ return nbSegs;
+}
+
+//================================================================================
+/*!
+ * \brief Return a node by its position
+ */
+//================================================================================
+
+const SMDS_MeshNode* _QuadFaceGrid::GetNode(int iHori, int iVert) const
+{
+ return myGrid[ myIndexer( iHori, iVert )];
+}
+
+//================================================================================
+/*!
+ * \brief Return node coordinates by its position
+ */
+//================================================================================
+
+gp_XYZ _QuadFaceGrid::GetXYZ(int iHori, int iVert) const
+{
+ const SMDS_MeshNode* n = myGrid[ myIndexer( iHori, iVert )];
+ return gp_XYZ( n->X(), n->Y(), n->Z() );
+}
+
+//================================================================================
+/*!
+ * \brief Return normal to the face at vertex v
+ */
+//================================================================================
+
+bool _QuadFaceGrid::GetNormal( const TopoDS_Vertex& v, gp_Vec& n ) const
+{
+ if ( myChildren.empty() )
+ {
+ if ( mySides.Contain( v )) {
+ try {
+ gp_Pnt2d uv = BRep_Tool::Parameters( v, myFace );
+ BRepAdaptor_Surface surface( myFace );
+ gp_Pnt p; gp_Vec d1u, d1v;
+ surface.D1( uv.X(), uv.Y(), p, d1u, d1v );
+ n = d1u.Crossed( d1v );
+ return true;
+ }
+ catch (Standard_Failure) {
+ return false;
+ }
+ }
+ }
+ else
+ {
+ TChildren::const_iterator child = myChildren.begin(), childEnd = myChildren.end();
+ for ( ; child != childEnd; ++child )
+ if ( child->GetNormal( v, n ))
+ return true;
+ }
+ return false;
+}
+
+//================================================================================
+/*!
+ * \brief Dumps coordinates of grid nodes
+ */
+//================================================================================
+
+void _QuadFaceGrid::DumpGrid() const
+{
+#ifdef DEB_GRID
+ const char* names[] = { "B_BOTTOM", "B_RIGHT", "B_TOP", "B_LEFT", "B_FRONT", "B_BACK" };
+ cout << "****** Face " << names[ myID ] << endl;
+
+ if ( myChildren.empty() || !myGrid.empty() )
+ {
+ cout << "x size: " << myIndexer._xSize << "; y size: " << myIndexer._ySize << endl;
+ for ( int y = 0; y < myIndexer._ySize; ++y ) {
+ cout << "-- row " << y << endl;
+ for ( int x = 0; x < myIndexer._xSize; ++x ) {
+ const SMDS_MeshNode* n = myGrid[ myIndexer( x, y ) ];
+ cout << x << " ( " << n->X() << ", " << n->Y() << ", " << n->Z() << " )" << endl;
+ }
+ }
+ }
+ else
+ {
+ cout << "Nb children: " << myChildren.size() << endl;
+ TChildren::const_iterator child = myChildren.begin(), childEnd = myChildren.end();
+ for ( int i=0; child != childEnd; ++child, ++i ) {
+ cout << " *** SUBFACE " << i+1 << endl;
+ ((_QuadFaceGrid&)(*child)).SetID( myID );
+ child->DumpGrid();
+ }
+ }
+#endif
+}
+
+//================================================================================
+/*!
+ * \brief Dump vertices
+ */
+//================================================================================
+
+void _QuadFaceGrid::DumpVertices() const
+{
+#ifdef DEB_FACES
+ cout << "****** Face ";
+ const char* names[] = { "B_BOTTOM", "B_RIGHT", "B_TOP", "B_LEFT", "B_FRONT", "B_BACK" };
+ if ( myID >= B_BOTTOM && myID < B_BACK )
+ cout << names[ myID ] << endl;
+ else
+ cout << "UNDEFINED" << endl;
+
+ if ( myChildren.empty() )
+ {
+ for ( int i = 0; i < 4; ++i )
+ {
+ cout << " Side "; mySides.GetSide( i )->Dump();
+ }
+ }
+ else
+ {
+ cout << "-- Nb children: " << myChildren.size() << endl;
+ TChildren::const_iterator child = myChildren.begin(), childEnd = myChildren.end();
+ for ( int i=0; child != childEnd; ++child, ++i ) {
+ cout << " *** SUBFACE " << i+1 << endl;
+ ((_QuadFaceGrid&)(*child)).SetID( myID );
+ child->DumpVertices();
+ }
+ }
+#endif
+}
+
+//=======================================================================
+//function : _FaceSide
+//purpose : copy constructor
+//=======================================================================
+
+_FaceSide::_FaceSide(const _FaceSide& other)
+{
+ myEdge = other.myEdge;
+ myChildren = other.myChildren;
+ myNbChildren = other.myNbChildren;
+ myVertices.Assign( other.myVertices );
+ myID = other.myID;
+}
+
+//================================================================================
+/*!
+ * \brief Construct a face side of one edge
+ */
+//================================================================================
+
+_FaceSide::_FaceSide(const TopoDS_Edge& edge):
+ myEdge( edge ), myNbChildren(0)
+{
+ if ( !edge.IsNull() )
+ for ( TopExp_Explorer exp( edge, TopAbs_VERTEX ); exp.More(); exp.Next() )
+ //myVertices.insert( ptr ( exp.Current() ));
+ myVertices.Add( exp.Current() );
+}
+
+//================================================================================
+/*!
+ * \brief Construct a face side of several edges
+ */
+//================================================================================
+
+_FaceSide::_FaceSide(const list<TopoDS_Edge>& edges):
+ myNbChildren(0)
+{
+ list<TopoDS_Edge>::const_iterator edge = edges.begin(), eEnd = edges.end();
+ for ( ; edge != eEnd; ++edge ) {
+ myChildren.push_back( _FaceSide( *edge ));
+ myNbChildren++;
+// myVertices.insert( myChildren.back().myVertices.begin(),
+// myChildren.back().myVertices.end() );
+ myVertices.Add( myChildren.back().FirstVertex() );
+ myVertices.Add( myChildren.back().LastVertex() );
+ myChildren.back().SetID( Q_CHILD ); // not to splice them
+ }
+}
+
+//=======================================================================
+//function : GetSide
+//purpose :
+//=======================================================================
+
+_FaceSide* _FaceSide::GetSide(const int i)
+{
+ if ( i >= myNbChildren )
+ return 0;
+
+ list< _FaceSide >::iterator side = myChildren.begin();
+ if ( i )
+ std::advance( side, i );
+ return & (*side);
+}
+
+//=======================================================================
+//function : GetSide
+//purpose :
+//=======================================================================
+
+const _FaceSide* _FaceSide::GetSide(const int i) const
+{
+ return const_cast< _FaceSide* >(this)->GetSide(i);
+}
+
+//=======================================================================
+//function : NbVertices
+//purpose : return nb of vertices in the side
+//=======================================================================
+
+int _FaceSide::NbVertices() const
+{
+ if ( myChildren.empty() )
+ return myVertices.Extent();
+// return myVertices.size();
+
+ return myNbChildren + 1;
+}
+
+//=======================================================================
+//function : FirstVertex
+//purpose :
+//=======================================================================
+
+TopoDS_Vertex _FaceSide::FirstVertex() const
+{
+ if ( myChildren.empty() )
+ return TopExp::FirstVertex( myEdge, Standard_True );
+
+ return myChildren.front().FirstVertex();
+}
+
+//=======================================================================
+//function : LastVertex
+//purpose :
+//=======================================================================
+
+TopoDS_Vertex _FaceSide::LastVertex() const
+{
+ if ( myChildren.empty() )
+ return TopExp::LastVertex( myEdge, Standard_True );
+
+ return myChildren.back().LastVertex();
+}
+
+//=======================================================================
+//function : Vertex
+//purpose :
+//=======================================================================
+
+TopoDS_Vertex _FaceSide::Vertex(int i) const
+{
+ if ( myChildren.empty() )
+ return i ? LastVertex() : FirstVertex();
+
+ if ( i >= myNbChildren )
+ return myChildren.back().LastVertex();
+
+ return GetSide(i)->FirstVertex();
+}
+
+//=======================================================================
+//function : Contain
+//purpose :
+//=======================================================================
+
+bool _FaceSide::Contain( const _FaceSide& side, int* which ) const
+{
+ if ( !which || myChildren.empty() )
+ {
+ if ( which )
+ *which = 0;
+ int nbCommon = 0;
+// set<const TopoDS_TShape*>::iterator v, vEnd = side.myVertices.end();
+// for ( v = side.myVertices.begin(); v != vEnd; ++v )
+// nbCommon += ( myVertices.find( *v ) != myVertices.end() );
+ TopTools_MapIteratorOfMapOfShape vIt ( side.myVertices );
+ for ( ; vIt.More(); vIt.Next() )
+ nbCommon += ( myVertices.Contains( vIt.Key() ));
+ return (nbCommon > 1);
+ }
+ list< _FaceSide >::const_iterator mySide = myChildren.begin(), sideEnd = myChildren.end();
+ for ( int i = 0; mySide != sideEnd; ++mySide, ++i ) {
+ if ( mySide->Contain( side )) {
+ *which = i;
+ return true;
+ }
+ }
+ return false;
+}
+
+//=======================================================================
+//function : Contain
+//purpose :
+//=======================================================================
+
+bool _FaceSide::Contain( const TopoDS_Vertex& vertex ) const
+{
+ return myVertices.Contains( vertex );
+// return myVertices.find( ptr( vertex )) != myVertices.end();
+}
+
+//=======================================================================
+//function : AppendSide
+//purpose :
+//=======================================================================
+
+void _FaceSide::AppendSide( const _FaceSide& side )
+{
+ if ( !myEdge.IsNull() )
+ {
+ myChildren.push_back( *this );
+ myNbChildren = 1;
+ myEdge.Nullify();
+ }
+ myChildren.push_back( side );
+ myNbChildren++;
+ //myVertices.insert( side.myVertices.begin(), side.myVertices.end() );
+ TopTools_MapIteratorOfMapOfShape vIt ( side.myVertices );
+ for ( ; vIt.More(); vIt.Next() )
+ myVertices.Add( vIt.Key() );
+
+ myID = Q_PARENT;
+ myChildren.back().SetID( EQuadSides( myNbChildren-1 ));
+}
+
+//=======================================================================
+//function : SetBottomSide
+//purpose :
+//=======================================================================
+
+void _FaceSide::SetBottomSide( int i )
+{
+ if ( i > 0 && myID == Q_PARENT ) {
+ list< _FaceSide >::iterator sideEnd, side = myChildren.begin();
+ std::advance( side, i );
+ myChildren.splice( myChildren.begin(), myChildren, side, myChildren.end() );
+
+ side = myChildren.begin(), sideEnd = myChildren.end();
+ for ( int i = 0; side != sideEnd; ++side, ++i ) {
+ side->SetID( EQuadSides(i) );
+ side->SetBottomSide(i);
+ }
+ }
+}
+
+//=======================================================================
+//function : GetNbSegments
+//purpose :
+//=======================================================================
+
+int _FaceSide::GetNbSegments(SMESH_Mesh& mesh) const
+{
+ int nb = 0;
+ if ( myChildren.empty() )
+ {
+ nb = mesh.GetSubMesh(myEdge)->GetSubMeshDS()->NbElements();
+ }
+ else
+ {
+ list< _FaceSide >::const_iterator side = myChildren.begin(), sideEnd = myChildren.end();
+ for ( ; side != sideEnd; ++side )
+ nb += side->GetNbSegments(mesh);
+ }
+ return nb;
+}
+
+//=======================================================================
+//function : StoreNodes
+//purpose :
+//=======================================================================
+
+bool _FaceSide::StoreNodes(SMESH_Mesh& mesh,
+ vector<const SMDS_MeshNode*>& myGrid,
+ bool reverse )
+{
+ list< TopoDS_Edge > edges;
+ if ( myChildren.empty() )
+ {
+ edges.push_back( myEdge );
+ }
+ else
+ {
+ list< _FaceSide >::const_iterator side = myChildren.begin(), sideEnd = myChildren.end();
+ for ( ; side != sideEnd; ++side )
+ if ( reverse )
+ edges.push_front( side->myEdge );
+ else
+ edges.push_back ( side->myEdge );
+ }
+ int nbNodes = 0;
+ list< TopoDS_Edge >::iterator edge = edges.begin(), eEnd = edges.end();
+ for ( ; edge != eEnd; ++edge )
+ {
+ map< double, const SMDS_MeshNode* > nodes;
+ bool ok = SMESH_Algo::GetSortedNodesOnEdge( mesh.GetMeshDS(),
+ *edge,
+ /*ignoreMediumNodes=*/true,
+ nodes);
+ if ( !ok ) return false;
+
+ bool forward = ( edge->Orientation() == TopAbs_FORWARD );
+ if ( reverse ) forward = !forward;
+ if ( forward )
+ {
+ map< double, const SMDS_MeshNode* >::iterator u_node, nEnd = nodes.end();
+ for ( u_node = nodes.begin(); u_node != nEnd; ++u_node )
+ myGrid[ nbNodes++ ] = u_node->second;
+ }
+ else
+ {
+ map< double, const SMDS_MeshNode* >::reverse_iterator u_node, nEnd = nodes.rend();
+ for ( u_node = nodes.rbegin(); u_node != nEnd; ++u_node )
+ myGrid[ nbNodes++ ] = u_node->second;
+ }
+ nbNodes--; // node on vertex present in two adjacent edges
+ }
+ return nbNodes > 0;
+}
+
+//=======================================================================
+//function : Dump
+//purpose : dump end vertices
+//=======================================================================
+
+void _FaceSide::Dump() const
+{
+ if ( myChildren.empty() )
+ {
+ const char* sideNames[] = { "Q_BOTTOM", "Q_RIGHT", "Q_TOP", "Q_LEFT", "Q_CHILD", "Q_PARENT" };
+ if ( myID >= Q_BOTTOM && myID < Q_PARENT )
+ cout << sideNames[ myID ] << endl;
+ else
+ cout << "<UNDEFINED ID>" << endl;
+ TopoDS_Vertex f = FirstVertex();
+ TopoDS_Vertex l = LastVertex();
+ gp_Pnt pf = BRep_Tool::Pnt(f);
+ gp_Pnt pl = BRep_Tool::Pnt(l);
+ cout << "\t ( "<< ptr( f ) << " - " << ptr( l )<< " )"
+ << "\t ( "<< pf.X()<<", "<<pf.Y()<<", "<<pf.Z()<<" ) - "
+ << " ( "<< pl.X()<<", "<<pl.Y()<<", "<<pl.Z()<<" )"<<endl;
+ }
+ else
+ {
+ list< _FaceSide >::const_iterator side = myChildren.begin(), sideEnd = myChildren.end();
+ for ( ; side != sideEnd; ++side ) {
+ side->Dump();
+ cout << "\t";
+ }
+ }
+}
--- /dev/null
+// SMESH SMESH : implementaion of SMESH idl descriptions
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+//
+// File : StdMeshers_CompositeBlock_3D.hxx
+// Module : SMESH
+
+#ifndef _SMESH_CompositeSegment_1D_HXX_
+#define _SMESH_CompositeSegment_1D_HXX_
+
+#include "SMESH_StdMeshers.hxx"
+#include "SMESH_3D_Algo.hxx"
+
+class SMESH_Mesh;
+class StdMeshers_FaceSide;
+class TopoDS_Edge;
+class TopoDS_Face;
+
+/*!
+ * \brief Computes hexahedral mesh on a box with composite sides
+ *
+ * The algorithm expects faces of a box to be meshed with quadrangles so that
+ * opposite box sides have equal number of quadrangles.
+ */
+class STDMESHERS_EXPORT StdMeshers_CompositeHexa_3D: public SMESH_3D_Algo
+{
+public:
+ StdMeshers_CompositeHexa_3D(int hypId, int studyId, SMESH_Gen* gen);
+ //virtual ~StdMeshers_CompositeHexa_3D();
+
+ virtual bool Compute(SMESH_Mesh& aMesh,
+ const TopoDS_Shape& aShape);
+
+ virtual bool CheckHypothesis(SMESH_Mesh& aMesh,
+ const TopoDS_Shape& aShape,
+ Hypothesis_Status& aStatus);
+
+private:
+ // private fields
+};
+
+#endif
// SMESH StdMeshers_Deflection1D : implementaion of SMESH idl descriptions
// File : StdMeshers_Deflection1D.cxx
// Module : SMESH
-// $Header$
//
#include "StdMeshers_Deflection1D.hxx"
#include "utilities.h"
}
return nbEdges;
}
+
+//================================================================================
+/*!
+ * \brief Initialize my parameter values by linear size of mesh element.
+ * \retval bool - true if parameter values have been successfully defined
+ */
+//================================================================================
+
+bool StdMeshers_Deflection1D::SetParametersByElementSize(double /*elemLenght*/,
+ const SMESH_Mesh* /*theMesh*/)
+{
+ return false;
+}
// SMESH StdMeshers : implementaion of SMESH idl descriptions
// File : StdMeshers_Deflection1D.hxx
// Module : SMESH
-// $Header$
//
+
#ifndef _StdMeshers_Deflection1D_HXX_
#define _StdMeshers_Deflection1D_HXX_
*/
virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
- protected:
+ /*!
+ * \brief Initialize my parameter values by linear size of mesh element.
+ * \retval bool - true if parameter values have been successfully defined
+ */
+ virtual bool SetParametersByElementSize( double elemLenght, const SMESH_Mesh* theMesh=0);
+
+protected:
double _value;
};
// Moved here from SMESH_Hexa_3D.cxx
// Author : Paul RASCLE, EDF
// Module : SMESH
-// $Header$
//
#include "StdMeshers_Hexa_3D.hxx"
-#include "StdMeshers_Quadrangle_2D.hxx"
+#include "StdMeshers_CompositeHexa_3D.hxx"
#include "StdMeshers_FaceSide.hxx"
#include "StdMeshers_Penta_3D.hxx"
#include "StdMeshers_Prism_3D.hxx"
+#include "StdMeshers_Quadrangle_2D.hxx"
#include "SMESH_Gen.hxx"
#include "SMESH_Mesh.hxx"
//Unexpect aCatch(SalomeException);
MESSAGE("StdMeshers_Hexa_3D::Compute");
SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
-
+
// 0. - shape and face mesh verification
// 0.1 - shape must be a solid (or a shell) with 6 faces
ASSERT(aSubMesh);
meshFaces.push_back(aSubMesh);
}
- if (meshFaces.size() != 6)
- return error(COMPERR_BAD_SHAPE, TComm(meshFaces.size())<<" instead of 6 faces in a block");
+ if (meshFaces.size() != 6) {
+ //return error(COMPERR_BAD_SHAPE, TComm(meshFaces.size())<<" instead of 6 faces in a block");
+ static StdMeshers_CompositeHexa_3D compositeHexa(-10, 0, aMesh.GetGen());
+ if ( !compositeHexa.Compute( aMesh, aShape ))
+ return error( compositeHexa.GetComputeError() );
+ return true;
+ }
// 0.2 - is each face meshed with Quadrangle_2D? (so, with a wire of 4 edges)
// File : StdMeshers_LayerDistribution.cxx
// Author : Edward AGAPOV
// Module : SMESH
-// $Header$
//
#include "StdMeshers_LayerDistribution.hxx"
{
return false;
}
+//================================================================================
+/*!
+ * \brief Initialize my parameter values by linear size of mesh element.
+ * \retval bool - true if parameter values have been successfully defined
+ */
+//================================================================================
+
+bool StdMeshers_LayerDistribution::SetParametersByElementSize(double elemLenght,
+ const SMESH_Mesh* theMesh)
+{
+ return myHyp ? myHyp->SetParametersByElementSize(elemLenght,theMesh) : false;
+}
// File : StdMeshers_LayerDistribution.hxx
// Author : Edward AGAPOV
// Module : SMESH
-// $Header$
//
#ifndef _SMESH_LayerDistribution_HXX_
#define _SMESH_LayerDistribution_HXX_
*/
virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
+ /*!
+ * \brief Initialize my parameter values by linear size of mesh element.
+ * \retval bool - true if parameter values have been successfully defined
+ */
+ virtual bool SetParametersByElementSize( double elemLenght, const SMESH_Mesh* theMesh=0);
+
protected:
SMESH_Hypothesis* myHyp;
std::string mySavedHyp;
// Moved here from SMESH_LengthFromEdges.cxx
// Author : Paul RASCLE, EDF
// Module : SMESH
-// $Header$
//
#include "StdMeshers_LengthFromEdges.hxx"
{
return false;
}
+//================================================================================
+/*!
+ * \brief Initialize my parameter values by linear size of mesh element.
+ * \retval bool - true if parameter values have been successfully defined
+ */
+//================================================================================
+
+bool StdMeshers_LengthFromEdges::SetParametersByElementSize(double /*elemLenght*/,
+ const SMESH_Mesh* /*theMesh*/)
+{
+ return true;
+}
// Moved here from SMESH_LengthFromEdges.hxx
// Author : Paul RASCLE, EDF
// Module : SMESH
-// $Header$
//
+
#ifndef _SMESH_LENGTHFROMEDGES_HXX_
#define _SMESH_LENGTHFROMEDGES_HXX_
*/
virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
+ /*!
+ * \brief Initialize my parameter values by linear size of mesh element.
+ * \retval bool - true if parameter values have been successfully defined
+ */
+ virtual bool SetParametersByElementSize( double elemLenght, const SMESH_Mesh* theMesh=0);
+
protected:
int _mode;
};
// Moved here from SMESH_LocalLength.cxx
// Author : Paul RASCLE, EDF
// Module : SMESH
-// $Header$
//
+
#include "StdMeshers_LocalLength.hxx"
#include "SMESH_Mesh.hxx"
return nbEdges;
}
+//================================================================================
+/*!
+ * \brief Initialize my parameter values by linear size of mesh element.
+ * \retval bool - true if parameter values have been successfully defined
+ */
+//================================================================================
+
+bool StdMeshers_LocalLength::SetParametersByElementSize(double elemLenght,
+ const SMESH_Mesh* /*theMesh*/)
+{
+ return bool( _length = elemLenght );
+}
+
// Moved here from SMESH_LocalLength.hxx
// Author : Paul RASCLE, EDF
// Module : SMESH
-// $Header$
//
+
#ifndef _SMESH_LOCALLENGTH_HXX_
#define _SMESH_LOCALLENGTH_HXX_
*/
virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
+ /*!
+ * \brief Initialize my parameter values by linear size of mesh element.
+ * \retval bool - true if parameter values have been successfully defined
+ */
+ virtual bool SetParametersByElementSize( double elemLenght, const SMESH_Mesh* theMesh=0);
+
protected:
double _length;
double _precision;
// Moved here from SMESH_MaxElementArea.cxx
// Author : Paul RASCLE, EDF
// Module : SMESH
-// $Header$
//
+
#include "StdMeshers_MaxElementArea.hxx"
#include "SMESH_ControlsDef.hxx"
}
return _maxArea > 0;
}
+//================================================================================
+/*!
+ * \brief Initialize my parameter values by linear size of mesh element.
+ * \retval bool - true if parameter values have been successfully defined
+ */
+//================================================================================
+
+bool StdMeshers_MaxElementArea::SetParametersByElementSize(double elemLenght,
+ const SMESH_Mesh* /*theMesh*/)
+{
+ return bool( _maxArea = elemLenght*elemLenght );
+}
+
// Moved here from SMESH_MaxElementArea.hxx
// Author : Paul RASCLE, EDF
// Module : SMESH
-// $Header$
//
#ifndef _SMESH_MAXELEMENTAREA_HXX_
#define _SMESH_MAXELEMENTAREA_HXX_
*/
virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
+ /*!
+ * \brief Initialize my parameter values by linear size of mesh element.
+ * \retval bool - true if parameter values have been successfully defined
+ */
+ virtual bool SetParametersByElementSize( double elemLenght, const SMESH_Mesh* theMesh=0);
+
protected:
double _maxArea;
};
// Moved here from SMESH_MaxElementVolume.cxx
// Author : Paul RASCLE, EDF
// Module : SMESH
-// $Header$
//
#include "StdMeshers_MaxElementVolume.hxx"
}
return _maxVolume > 0;
}
+//================================================================================
+/*!
+ * \brief Initialize my parameter values by linear size of mesh element.
+ * \retval bool - true if parameter values have been successfully defined
+ */
+//================================================================================
+
+bool StdMeshers_MaxElementVolume::SetParametersByElementSize(double elemLenght,
+ const SMESH_Mesh* /*theMesh*/)
+{
+ return bool( _maxVolume = elemLenght*elemLenght*elemLenght );
+}
+
// Moved here from SMESH_MaxElementVolume.hxx
// Author : Paul RASCLE, EDF
// Module : SMESH
-// $Header$
-//
+
#ifndef _SMESH_MAXELEMENTVOLUME_HXX_
#define _SMESH_MAXELEMENTVOLUME_HXX_
*/
virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
+ /*!
+ * \brief Initialize my parameter values by linear size of mesh element.
+ * \retval bool - true if parameter values have been successfully defined
+ */
+ virtual bool SetParametersByElementSize( double elemLenght, const SMESH_Mesh* theMesh=0);
+
protected:
double _maxVolume;
};
--- /dev/null
+// SMESH SMESH : implementaion of SMESH idl descriptions
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// File : StdMeshers_MaxLength.cxx
+// Module : SMESH
+
+#include "StdMeshers_MaxLength.hxx"
+
+#include "SMESH_Mesh.hxx"
+#include "SMESH_Algo.hxx"
+
+#include "utilities.h"
+
+#include <BRep_Tool.hxx>
+#include <GCPnts_AbscissaPoint.hxx>
+#include <GeomAdaptor_Curve.hxx>
+#include <Geom_Curve.hxx>
+#include <TopExp.hxx>
+#include <TopLoc_Location.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <Precision.hxx>
+
+using namespace std;
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+StdMeshers_MaxLength::StdMeshers_MaxLength(int hypId, int studyId, SMESH_Gen * gen)
+ :SMESH_Hypothesis(hypId, studyId, gen)
+{
+ _length = 1.;
+ _preestimated = 0.;
+ _preestimation = false;
+ _name = "MaxLength";
+ _param_algo_dim = 1; // is used by SMESH_Regular_1D
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+StdMeshers_MaxLength::~StdMeshers_MaxLength()
+{
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+void StdMeshers_MaxLength::SetLength(double length) throw(SALOME_Exception)
+{
+ if (length <= 0)
+ throw SALOME_Exception(LOCALIZED("length must be positive"));
+ if ( _length != length ) {
+ _length = length;
+ NotifySubMeshesHypothesisModification();
+ }
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+double StdMeshers_MaxLength::GetLength() const
+{
+ return ( _preestimation && _preestimated > 0. ) ? _preestimated : _length;
+}
+
+//================================================================================
+/*!
+ * \brief Sets boolean parameter enabling/desabling usage of length computed
+ * basing on size of bounding box of shape to mesh
+ */
+//================================================================================
+
+void StdMeshers_MaxLength::SetUsePreestimatedLength(bool toUse)
+{
+ if ( toUse != _preestimation )
+ {
+ _preestimation = toUse;
+ // this parameter is just to help the user
+ //NotifySubMeshesHypothesisModification();
+ }
+}
+
+//================================================================================
+/*!
+ * \brief Store preestemated length
+ */
+//================================================================================
+
+void StdMeshers_MaxLength::SetPreestimatedLength(double length)
+{
+ if ( length > 0 )
+ _preestimated = length;
+}
+
+//================================================================================
+/*!
+ * \brief Returns value of boolean parameter enabling/desabling usage of length computed
+ * basing on size of bounding box of shape to mesh
+ */
+//================================================================================
+
+bool StdMeshers_MaxLength::GetUsePreestimatedLength() const
+{
+ return _preestimation;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+ostream & StdMeshers_MaxLength::SaveTo(ostream & save)
+{
+ save << _length << " " << _preestimated << " " << _preestimation;
+ return save;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+istream & StdMeshers_MaxLength::LoadFrom(istream & load)
+{
+ bool isOK = true;
+ double a;
+
+ isOK = (load >> a);
+ if (isOK)
+ _length = a;
+ else
+ load.clear(ios::badbit | load.rdstate());
+
+ isOK = (load >> a);
+ if (isOK)
+ _preestimated = a;
+ else
+ load.clear(ios::badbit | load.rdstate());
+
+ bool pre;
+ isOK = (load >> pre);
+ if ( isOK )
+ _preestimation = pre;
+ else
+ load.clear(ios::badbit | load.rdstate());
+
+ return load;
+}
+
+//================================================================================
+/*!
+ * \brief Initialize segment length by the mesh built on the geometry
+ * \param theMesh - the built mesh
+ * \param theShape - the geometry of interest
+ * \retval bool - true if parameter values have been successfully defined
+ */
+//================================================================================
+
+bool StdMeshers_MaxLength::SetParametersByMesh(const SMESH_Mesh* theMesh,
+ const TopoDS_Shape& theShape)
+{
+ if ( !theMesh || theShape.IsNull() )
+ return false;
+
+ _length = 0.;
+
+ Standard_Real UMin, UMax;
+ TopLoc_Location L;
+
+ int nbEdges = 0;
+ TopTools_IndexedMapOfShape edgeMap;
+ TopExp::MapShapes( theShape, TopAbs_EDGE, edgeMap );
+ for ( int iE = 1; iE <= edgeMap.Extent(); ++iE )
+ {
+ const TopoDS_Edge& edge = TopoDS::Edge( edgeMap( iE ));
+ Handle(Geom_Curve) C = BRep_Tool::Curve( edge, L, UMin, UMax );
+ GeomAdaptor_Curve AdaptCurve(C);
+
+ vector< double > params;
+ SMESHDS_Mesh* aMeshDS = const_cast< SMESH_Mesh* >( theMesh )->GetMeshDS();
+ if ( SMESH_Algo::GetNodeParamOnEdge( aMeshDS, edge, params ))
+ {
+ for ( int i = 1; i < params.size(); ++i )
+ _length += GCPnts_AbscissaPoint::Length( AdaptCurve, params[ i-1 ], params[ i ]);
+ nbEdges += params.size() - 1;
+ }
+ }
+ if ( nbEdges )
+ _length /= nbEdges;
+
+ return nbEdges;
+}
+//================================================================================
+/*!
+ * \brief Initialize my parameter values by linear size of mesh element.
+ * \retval bool - true if parameter values have been successfully defined
+ */
+//================================================================================
+
+bool StdMeshers_MaxLength::SetParametersByElementSize(double elemLenght,
+ const SMESH_Mesh* /*theMesh*/)
+{
+ _preestimation = ( elemLenght > 0.);
+ if ( _preestimation )
+ _preestimated = elemLenght;
+ return bool( _length = elemLenght );
+}
+
--- /dev/null
+// SMESH SMESH : implementaion of SMESH idl descriptions
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+
+// File : StdMeshers_MaxLength.hxx
+// Module : SMESH
+
+#ifndef _SMESH_MaxLength_HXX_
+#define _SMESH_MaxLength_HXX_
+
+#include "SMESH_StdMeshers.hxx"
+
+#include "SMESH_Hypothesis.hxx"
+#include "Utils_SALOME_Exception.hxx"
+
+class STDMESHERS_EXPORT StdMeshers_MaxLength: public SMESH_Hypothesis
+{
+ public:
+ StdMeshers_MaxLength(int hypId, int studyId, SMESH_Gen * gen);
+ virtual ~ StdMeshers_MaxLength();
+
+ void SetLength(double length) throw(SALOME_Exception);
+ double GetLength() const;
+
+ bool HavePreestimatedLength() const { return _preestimated > 0.; }
+ double GetPreestimatedLength() const { return _preestimated; }
+ void SetPreestimatedLength(double length);
+
+ void SetUsePreestimatedLength(bool toUse);
+ bool GetUsePreestimatedLength() const;
+
+ virtual std::ostream & SaveTo(std::ostream & save);
+ virtual std::istream & LoadFrom(std::istream & load);
+
+ /*!
+ * \brief Initialize segment length by the mesh built on the geometry
+ * \param theMesh - the built mesh
+ * \param theShape - the geometry of interest
+ * \retval bool - true if parameter values have been successfully defined
+ */
+ virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
+
+ /*!
+ * \brief Initialize my parameter values by linear size of mesh element.
+ * \retval bool - true if parameter values have been successfully defined
+ */
+ virtual bool SetParametersByElementSize( double elemLenght, const SMESH_Mesh* theMesh=0);
+
+ protected:
+ double _length, _preestimated;
+ bool _preestimation;
+};
+
+#endif
// File : StdMeshers_NotConformAllowed.cxx
// Author : Paul RASCLE, EDF
// Module : SMESH
-// $Header$
//
#include "StdMeshers_NotConformAllowed.hxx"
#include "utilities.h"
bool StdMeshers_NotConformAllowed::SetParametersByMesh(const SMESH_Mesh* /*theMesh*/,
const TopoDS_Shape& /*theShape*/)
{
- return false;
+ return true;
}
+//================================================================================
+/*!
+ * \brief Initialize my parameter values by linear size of mesh element.
+ * \retval bool - true if parameter values have been successfully defined
+ */
+//================================================================================
+
+bool StdMeshers_NotConformAllowed::SetParametersByElementSize(double /*elemLenght*/,
+ const SMESH_Mesh* /*theMesh*/)
+{
+ return true;
+}
+
// File : StdMeshers_NotConformAllowed.hxx
// Author : Paul RASCLE, EDF
// Module : SMESH
-// $Header$
//
#ifndef _StdMeshers_NotConformAllowed_HXX_
#define _StdMeshers_NotConformAllowed_HXX_
*/
virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
+ /*!
+ * \brief Initialize my parameter values by linear size of mesh element.
+ * \retval bool - true if parameter values have been successfully defined
+ */
+ virtual bool SetParametersByElementSize( double elemLenght, const SMESH_Mesh* theMesh=0);
+
};
#endif
// File : StdMeshers_NumberOfLayers.cxx
// Author : Edward AGAPOV
// Module : SMESH
-// $Header$
//
#include "StdMeshers_NumberOfLayers.hxx"
+#include "SMESH_Mesh.hxx"
#include "utilities.h"
using namespace std;
{
return false;
}
+
+//================================================================================
+/*!
+ * \brief Initialize my parameter values by linear size of mesh element.
+ * \retval bool - true if parameter values have been successfully defined
+ */
+//================================================================================
+
+bool StdMeshers_NumberOfLayers::SetParametersByElementSize(double elemLenght,
+ const SMESH_Mesh* theMesh)
+{
+ return bool( theMesh ? _nbLayers = int( theMesh->GetShapeDiagonalSize() / elemLenght/ 2.) : 0);
+}
+
// File : StdMeshers_NumberOfLayers.hxx
// Author : Edward AGAPOV
// Module : SMESH
-// $Header$
//
#ifndef _SMESH_NumberOfLayers_HXX_
#define _SMESH_NumberOfLayers_HXX_
*/
virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
+ /*!
+ * \brief Initialize my parameter values by linear size of mesh element.
+ * \retval bool - true if parameter values have been successfully defined
+ */
+ virtual bool SetParametersByElementSize( double elemLenght, const SMESH_Mesh* theMesh=0);
+
protected:
int _nbLayers;
};
// Moved here from SMESH_NumberOfSegments.cxx
// Author : Paul RASCLE, EDF
// Module : SMESH
-// $Header$
//
#include "StdMeshers_NumberOfSegments.hxx"
int studyId,
SMESH_Gen * gen)
: SMESH_Hypothesis(hypId, studyId, gen),
- _numberOfSegments(1),
+ _numberOfSegments(15),//issue 19923
_distrType(DT_Regular),
_scaleFactor(1.),
_convMode(1) //cut negative by default
return nbEdges;
}
+//================================================================================
+/*!
+ * \brief Initialize my parameter values by linear size of mesh element.
+ * \retval bool - true if parameter values have been successfully defined
+ */
+//================================================================================
+
+bool StdMeshers_NumberOfSegments::SetParametersByElementSize(double elemLenght,
+ const SMESH_Mesh* /*theMesh*/)
+{
+ return false;
+}
+
// Moved here from SMESH_NumberOfSegments.hxx
// Author : Paul RASCLE, EDF
// Module : SMESH
-// $Header$
//
#ifndef _SMESH_NUMBEROFSEGMENTS_HXX_
#define _SMESH_NUMBEROFSEGMENTS_HXX_
*/
virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
+ /*!
+ * \brief Initialize my parameter values by linear size of mesh element.
+ * \retval bool - true if parameter values have been successfully defined
+ */
+ virtual bool SetParametersByElementSize( double elemLenght, const SMESH_Mesh* theMesh=0);
+
virtual std::ostream & SaveTo(std::ostream & save);
virtual std::istream & LoadFrom(std::istream & load);
friend std::ostream& operator << (std::ostream & save, StdMeshers_NumberOfSegments & hyp);
// File : StdMeshers_ProjectionSource1D.cxx
// Author : Edward AGAPOV
// Module : SMESH
-// $Header$
//
#include "StdMeshers_ProjectionSource1D.hxx"
_sourceMesh = mesh;
}
+//================================================================================
+/*!
+ * \brief Initialize my parameter values by linear size of mesh element.
+ * \retval bool - true if parameter values have been successfully defined
+ */
+//================================================================================
+
+bool StdMeshers_ProjectionSource1D::SetParametersByElementSize(double /*elemLenght*/,
+ const SMESH_Mesh* /*theMesh*/)
+{
+ return false;
+}
+
// File : StdMeshers_ProjectionSource1D.hxx
// Author : Edward AGAPOV
// Module : SMESH
-// $Header$
//
#ifndef _SMESH_ProjectionSource1D_HXX_
#define _SMESH_ProjectionSource1D_HXX_
*/
virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
+ /*!
+ * \brief Initialize my parameter values by linear size of mesh element.
+ * \retval bool - true if parameter values have been successfully defined
+ */
+ virtual bool SetParametersByElementSize( double elemLenght, const SMESH_Mesh* theMesh=0);
+
protected:
TopoDS_Shape _sourceEdge;
// File : StdMeshers_ProjectionSource2D.cxx
// Author : Edward AGAPOV
// Module : SMESH
-// $Header$
-//
+
#include "StdMeshers_ProjectionSource2D.hxx"
#include "SMESH_Mesh.hxx"
_targetVertex2 = TopoDS::Vertex( s5 );
_sourceMesh = mesh;
}
+
+//================================================================================
+/*!
+ * \brief Initialize my parameter values by linear size of mesh element.
+ * \retval bool - true if parameter values have been successfully defined
+ */
+//================================================================================
+
+bool StdMeshers_ProjectionSource2D::SetParametersByElementSize(double /*elemLenght*/,
+ const SMESH_Mesh* /*theMesh*/)
+{
+ return false;
+}
+
// File : StdMeshers_ProjectionSource2D.hxx
// Author : Edward AGAPOV
// Module : SMESH
-// $Header$
-//
+
#ifndef _SMESH_ProjectionSource2D_HXX_
#define _SMESH_ProjectionSource2D_HXX_
*/
virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
+ /*!
+ * \brief Initialize my parameter values by linear size of mesh element.
+ * \retval bool - true if parameter values have been successfully defined
+ */
+ virtual bool SetParametersByElementSize( double elemLenght, const SMESH_Mesh* theMesh=0);
+
protected:
TopoDS_Shape _sourceFace;
// File : StdMeshers_ProjectionSource3D.cxx
// Author : Edward AGAPOV
// Module : SMESH
-// $Header$
-//
+
#include "StdMeshers_ProjectionSource3D.hxx"
#include "utilities.h"
_targetVertex2 = TopoDS::Vertex( s5 );
_sourceMesh = mesh;
}
+
+//================================================================================
+/*!
+ * \brief Initialize my parameter values by linear size of mesh element.
+ * \retval bool - true if parameter values have been successfully defined
+ */
+//================================================================================
+
+bool StdMeshers_ProjectionSource3D::SetParametersByElementSize(double /*elemLenght*/,
+ const SMESH_Mesh* /*theMesh*/)
+{
+ return false;
+}
+
// File : StdMeshers_ProjectionSource3D.hxx
// Author : Edward AGAPOV
// Module : SMESH
-// $Header$
-//
+
#ifndef _SMESH_ProjectionSource3D_HXX_
#define _SMESH_ProjectionSource3D_HXX_
*/
virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
+ /*!
+ * \brief Initialize my parameter values by linear size of mesh element.
+ * \retval bool - true if parameter values have been successfully defined
+ */
+ virtual bool SetParametersByElementSize( double elemLenght, const SMESH_Mesh* theMesh=0);
+
protected:
TopoDS_Shape _sourceShape;
// SMESH SMESH : implementaion of SMESH idl descriptions
// File : StdMeshers_Propagation.cxx
// Module : SMESH
-// $Header$
-//
+
#include "StdMeshers_Propagation.hxx"
#include "utilities.h"
istream & operator >> (istream & load, StdMeshers_Propagation & hyp) { return hyp.LoadFrom(load); }
bool StdMeshers_Propagation::SetParametersByMesh(const SMESH_Mesh*,
const TopoDS_Shape& ) { return false; }
+bool StdMeshers_Propagation::SetParametersByElementSize(double,const SMESH_Mesh*) { return false; }
void StdMeshers_Propagation::SetPropagationMgr(SMESH_subMesh* subMesh) { PropagationMgr::Set( subMesh ); }
/*!
* \brief Return an edge from which hypotheses are propagated from
// SMESH SMESH : implementaion of SMESH idl descriptions
// File : StdMeshers_Propagation.hxx
// Module : SMESH
-// $Header$
-//
+
#ifndef _SMESH_PROPAGATION_HXX_
#define _SMESH_PROPAGATION_HXX_
* Just return false as this hypothesis does not have parameters values
*/
virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
+
+ /*!
+ * \brief Initialize my parameter values by linear size of mesh element.
+ * \retval bool - true if parameter values have been successfully defined
+ */
+ virtual bool SetParametersByElementSize( double elemLenght, const SMESH_Mesh* theMesh=0);
+
};
#endif
// SMESH StdMeshers_QuadranglePreference : implementaion of SMESH idl descriptions
// File : StdMeshers_QuadranglePreference.cxx
// Module : SMESH
-// $Header$
-//
+
#include "StdMeshers_QuadranglePreference.hxx"
#include "utilities.h"
{
return false;
}
+
+//================================================================================
+/*!
+ * \brief Initialize my parameter values by linear size of mesh element.
+ * \retval bool - true if parameter values have been successfully defined
+ */
+//================================================================================
+
+bool StdMeshers_QuadranglePreference::SetParametersByElementSize(double /*elemLenght*/,
+ const SMESH_Mesh* /*theMesh*/)
+{
+ return false;
+}
+
// SMESH StdMeshers : implementaion of SMESH idl descriptions
// File : StdMeshers_QuadranglePreference.hxx
// Module : SMESH
-// $Header$
-//
+
#ifndef _StdMeshers_QuadranglePreference_HXX_
#define _StdMeshers_QuadranglePreference_HXX_
*/
virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
+ /*!
+ * \brief Initialize my parameter values by linear size of mesh element.
+ * \retval bool - true if parameter values have been successfully defined
+ */
+ virtual bool SetParametersByElementSize( double elemLenght, const SMESH_Mesh* theMesh=0);
+
};
#endif
// SMESH StdMeshers_QuadraticMesh : implementaion of SMESH idl descriptions
// File : StdMeshers_QuadraticMesh.cxx
// Module : SMESH
-// $Header$
-//
+
#include "StdMeshers_QuadraticMesh.hxx"
#include "utilities.h"
{
return false;
}
+
+//================================================================================
+/*!
+ * \brief Initialize my parameter values by linear size of mesh element.
+ * \retval bool - true if parameter values have been successfully defined
+ */
+//================================================================================
+
+bool StdMeshers_QuadraticMesh::SetParametersByElementSize(double /*elemLenght*/,
+ const SMESH_Mesh* /*theMesh*/)
+{
+ return false;
+}
+
// SMESH StdMeshers : implementaion of SMESH idl descriptions
// File : StdMeshers_QuadraticMesh.hxx
// Module : SMESH
-// $Header$
-//
+
#ifndef _StdMeshers_QuadraticMesh_HXX_
#define _StdMeshers_QuadraticMesh_HXX_
*/
virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
+ /*!
+ * \brief Initialize my parameter values by linear size of mesh element.
+ * \retval bool - true if parameter values have been successfully defined
+ */
+ virtual bool SetParametersByElementSize( double elemLenght, const SMESH_Mesh* theMesh=0);
+
};
#endif
// Moved here from SMESH_Regular_1D.cxx
// Author : Paul RASCLE, EDF
// Module : SMESH
-// $Header$
-//
+
#include "StdMeshers_Regular_1D.hxx"
#include "StdMeshers_Distribution.hxx"
-#include "StdMeshers_LocalLength.hxx"
-#include "StdMeshers_NumberOfSegments.hxx"
#include "StdMeshers_Arithmetic1D.hxx"
-#include "StdMeshers_StartEndLength.hxx"
-#include "StdMeshers_Deflection1D.hxx"
#include "StdMeshers_AutomaticLength.hxx"
-#include "StdMeshers_SegmentLengthAroundVertex.hxx"
+#include "StdMeshers_Deflection1D.hxx"
+#include "StdMeshers_LocalLength.hxx"
+#include "StdMeshers_MaxLength.hxx"
+#include "StdMeshers_NumberOfSegments.hxx"
#include "StdMeshers_Propagation.hxx"
+#include "StdMeshers_SegmentLengthAroundVertex.hxx"
+#include "StdMeshers_StartEndLength.hxx"
#include "SMESH_Gen.hxx"
#include "SMESH_Mesh.hxx"
_shapeType = (1 << TopAbs_EDGE);
_compatibleHypothesis.push_back("LocalLength");
+ _compatibleHypothesis.push_back("MaxLength");
_compatibleHypothesis.push_back("NumberOfSegments");
_compatibleHypothesis.push_back("StartEndLength");
_compatibleHypothesis.push_back("Deflection1D");
const StdMeshers_LocalLength * hyp =
dynamic_cast <const StdMeshers_LocalLength * >(theHyp);
ASSERT(hyp);
- //_value[ BEG_LENGTH_IND ] = _value[ END_LENGTH_IND ] = hyp->GetLength();
_value[ BEG_LENGTH_IND ] = hyp->GetLength();
- _value[ END_LENGTH_IND ] = hyp->GetPrecision();
+ _value[ PRECISION_IND ] = hyp->GetPrecision();
ASSERT( _value[ BEG_LENGTH_IND ] > 0 );
_hypType = LOCAL_LENGTH;
aStatus = SMESH_Hypothesis::HYP_OK;
}
+ else if (hypName == "MaxLength")
+ {
+ const StdMeshers_MaxLength * hyp =
+ dynamic_cast <const StdMeshers_MaxLength * >(theHyp);
+ ASSERT(hyp);
+ _value[ BEG_LENGTH_IND ] = hyp->GetLength();
+ if ( hyp->GetUsePreestimatedLength() ) {
+ if ( int nbSeg = aMesh.GetGen()->GetBoundaryBoxSegmentation() )
+ _value[ BEG_LENGTH_IND ] = aMesh.GetShapeDiagonalSize() / nbSeg;
+ }
+ ASSERT( _value[ BEG_LENGTH_IND ] > 0 );
+ _hypType = MAX_LENGTH;
+ aStatus = SMESH_Hypothesis::HYP_OK;
+ }
+
else if (hypName == "NumberOfSegments")
{
const StdMeshers_NumberOfSegments * hyp =
StdMeshers_AutomaticLength * hyp = const_cast<StdMeshers_AutomaticLength *>
(dynamic_cast <const StdMeshers_AutomaticLength * >(theHyp));
ASSERT(hyp);
- //_value[ BEG_LENGTH_IND ] = _value[ END_LENGTH_IND ] = hyp->GetLength( &aMesh, aShape );
- _value[ BEG_LENGTH_IND ] = hyp->GetLength( &aMesh, aShape );
- _value[ END_LENGTH_IND ] = Precision::Confusion(); // ?? or set to zero?
+ _value[ BEG_LENGTH_IND ] = _value[ END_LENGTH_IND ] = hyp->GetLength( &aMesh, aShape );
+// _value[ BEG_LENGTH_IND ] = hyp->GetLength( &aMesh, aShape );
+// _value[ END_LENGTH_IND ] = Precision::Confusion(); // ?? or set to zero?
ASSERT( _value[ BEG_LENGTH_IND ] > 0 );
- _hypType = LOCAL_LENGTH;
+ _hypType = MAX_LENGTH;
aStatus = SMESH_Hypothesis::HYP_OK;
}
else
void StdMeshers_Regular_1D::SetEventListener(SMESH_subMesh* subMesh)
{
-// static VertexEventListener listener;
-// SMESH_subMeshIteratorPtr smIt = subMesh->getDependsOnIterator(false,false);
-// while (smIt->more()) {
-// subMesh->SetEventListener( &listener, 0, smIt->next() );
-// }
StdMeshers_Propagation::SetPropagationMgr( subMesh );
}
switch( _hypType )
{
case LOCAL_LENGTH:
+ case MAX_LENGTH:
case NB_SEGMENTS: {
double eltSize = 1;
- if ( _hypType == LOCAL_LENGTH )
+ if ( _hypType == MAX_LENGTH )
+ {
+ double nbseg = ceil(theLength / _value[ BEG_LENGTH_IND ]); // integer sup
+ if (nbseg <= 0)
+ nbseg = 1; // degenerated edge
+ eltSize = theLength / nbseg;
+ }
+ else if ( _hypType == LOCAL_LENGTH )
{
// Local Length hypothesis
double nbseg = ceil(theLength / _value[ BEG_LENGTH_IND ]); // integer sup
}
if (!isFound) // not found by meshed edge in the propagation chain, use precision
{
- double aPrecision = _value[ END_LENGTH_IND ];
+ double aPrecision = _value[ PRECISION_IND ];
double nbseg_prec = ceil((theLength / _value[ BEG_LENGTH_IND ]) - aPrecision);
if (nbseg_prec == (nbseg - 1)) nbseg--;
}
// Moved here from SMESH_Regular_1D.hxx
// Author : Paul RASCLE, EDF
// Module : SMESH
-// $Header$
-//
+
#ifndef _SMESH_REGULAR_1D_HXX_
#define _SMESH_REGULAR_1D_HXX_
StdMeshers_SegmentLengthAroundVertex* getVertexHyp(SMESH_Mesh & theMesh,
const TopoDS_Vertex & theV);
- enum HypothesisType { LOCAL_LENGTH, NB_SEGMENTS, BEG_END_LENGTH, DEFLECTION, ARITHMETIC_1D, NONE };
+ enum HypothesisType { LOCAL_LENGTH, MAX_LENGTH, NB_SEGMENTS, BEG_END_LENGTH, DEFLECTION, ARITHMETIC_1D, NONE };
enum ValueIndex {
SCALE_FACTOR_IND = 0,
BEG_LENGTH_IND = 0,
END_LENGTH_IND = 1,
- DEFLECTION_IND = 0
+ DEFLECTION_IND = 0,
+ PRECISION_IND = 0
};
enum IValueIndex {
// SMESH SMESH : implementaion of SMESH idl descriptions
// File : StdMeshers_SegmentLengthAroundVertex.cxx
// Module : SMESH
-// $Header$
-//
+
#include "StdMeshers_SegmentLengthAroundVertex.hxx"
#include "SMESH_Mesh.hxx"
return nbSegs;
}
+
+//================================================================================
+/*!
+ * \brief Initialize my parameter values by linear size of mesh element.
+ * \retval bool - true if parameter values have been successfully defined
+ */
+//================================================================================
+
+bool StdMeshers_SegmentLengthAroundVertex::SetParametersByElementSize(double,
+ const SMESH_Mesh*)
+{
+ return false;
+}
+
// File : StdMeshers_SegmentLengthAroundVertex.hxx
// Author : Paul RASCLE, EDF
// Module : SMESH
-// $Header$
-//
+
#ifndef _SMESH_SegmentLengthAroundVertex_HXX_
#define _SMESH_SegmentLengthAroundVertex_HXX_
*/
virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
+ /*!
+ * \brief Initialize my parameter values by linear size of mesh element.
+ * \retval bool - true if parameter values have been successfully defined
+ */
+ virtual bool SetParametersByElementSize( double elemLenght, const SMESH_Mesh* theMesh=0);
+
protected:
double _length;
};
// SMESH StdMeshers_StartEndLength : implementaion of SMESH idl descriptions
// File : StdMeshers_StartEndLength.cxx
// Module : SMESH
-// $Header$
-//
+
#include "StdMeshers_StartEndLength.hxx"
#include "SMESH_Algo.hxx"
}
return nbEdges;
}
+
+//================================================================================
+/*!
+ * \brief Initialize my parameter values by linear size of mesh element.
+ * \retval bool - true if parameter values have been successfully defined
+ */
+//================================================================================
+
+bool StdMeshers_StartEndLength::SetParametersByElementSize(double elemLenght,
+ const SMESH_Mesh* /*theMesh*/)
+{
+ return bool(_begLength = _endLength = elemLenght );
+}
+
// SMESH StdMeshers : implementaion of SMESH idl descriptions
// File : StdMeshers_StartEndLength.hxx
// Module : SMESH
-// $Header$
-//
+
#ifndef _STDMESHERS_STARTENDLENGTH_HXX_
#define _STDMESHERS_STARTENDLENGTH_HXX_
*/
virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
+ /*!
+ * \brief Initialize my parameter values by linear size of mesh element.
+ * \retval bool - true if parameter values have been successfully defined
+ */
+ virtual bool SetParametersByElementSize( double elemLenght, const SMESH_Mesh* theMesh=0);
+
protected:
double _begLength, _endLength;
};
// SMESH StdMeshers_TrianglePreference
// File : StdMeshers_TrianglePreference.cxx
// Module : SMESH
-// $Header$
-//
+
#include "StdMeshers_TrianglePreference.hxx"
#include "utilities.h"
{
return false;
}
+
+//================================================================================
+/*!
+ * \brief Initialize my parameter values by linear size of mesh element.
+ * \retval bool - true if parameter values have been successfully defined
+ */
+//================================================================================
+
+bool StdMeshers_TrianglePreference::SetParametersByElementSize(double /*elemLenght*/,
+ const SMESH_Mesh* /*theMesh*/)
+{
+ return false;
+}
+
// SMESH StdMeshers : implementaion of SMESH idl descriptions
// File : StdMeshers_TrianglePreference.hxx
// Module : SMESH
-// $Header$
-//
+
#ifndef _StdMeshers_TrianglePreference_HXX_
#define _StdMeshers_TrianglePreference_HXX_
*/
virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
+ /*!
+ * \brief Initialize my parameter values by linear size of mesh element.
+ * \retval bool - true if parameter values have been successfully defined
+ */
+ virtual bool SetParametersByElementSize( double elemLenght, const SMESH_Mesh* theMesh=0);
+
};
#endif
#include <QHBoxLayout>
#include <QSlider>
#include <QLabel>
+#include <QCheckBox>
const double VALUE_MAX = 1.0e+15, // COORD_MAX
VALUE_MAX_2 = VALUE_MAX * VALUE_MAX,
if ( i < myCustomWidgets.count() ) {
QList<QWidget*>::const_iterator anIt = myCustomWidgets.begin();
QList<QWidget*>::const_iterator aLast = myCustomWidgets.end();
- for ( int j = 0 ; !w && anIt != aLast; ++anIt )
+ for ( int j = 0 ; !w && anIt != aLast; ++anIt, ++j )
if ( i == j )
w = *anIt;
}
h->SetLength( params[0].myValue.toDouble() );
h->SetPrecision( params[1].myValue.toDouble() );
}
+ else if( hypType()=="MaxLength" )
+ {
+ StdMeshers::StdMeshers_MaxLength_var h =
+ StdMeshers::StdMeshers_MaxLength::_narrow( hypothesis() );
+
+ h->SetLength( params[0].myValue.toDouble() );
+ h->SetUsePreestimatedLength( widget< QCheckBox >( 1 )->isChecked() );
+ if ( !h->HavePreestimatedLength() && !h->_is_equivalent( initParamsHypothesis() )) {
+ StdMeshers::StdMeshers_MaxLength_var hInit =
+ StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis() );
+ h->SetPreestimatedLength( hInit->GetPreestimatedLength() );
+ }
+ }
else if( hypType()=="SegmentLengthAroundVertex" )
{
StdMeshers::StdMeshers_SegmentLengthAroundVertex_var h =
item.myValue = h->GetPrecision();
p.append( item );
}
+ else if( hypType()=="MaxLength" )
+ {
+ StdMeshers::StdMeshers_MaxLength_var h =
+ StdMeshers::StdMeshers_MaxLength::_narrow( hyp );
+ // try to set a right preestimated length to edited hypothesis
+ bool noPreestimatedAtEdition = false;
+ if ( !isCreation() ) {
+ StdMeshers::StdMeshers_MaxLength_var initHyp =
+ StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis(true) );
+ noPreestimatedAtEdition =
+ ( initHyp->_is_nil() || !initHyp->HavePreestimatedLength() );
+ if ( !noPreestimatedAtEdition )
+ h->SetPreestimatedLength( initHyp->GetPreestimatedLength() );
+ }
+
+ item.myName = tr("SMESH_LOCAL_LENGTH_PARAM");
+ item.myValue = h->GetLength();
+ p.append( item );
+ customWidgets()->append(0);
+
+ item.myName = tr("SMESH_USE_PREESTIMATED_LENGTH");
+ p.append( item );
+ QCheckBox* aQCheckBox = new QCheckBox(dlg());
+ if ( !noPreestimatedAtEdition && h->HavePreestimatedLength() ) {
+ aQCheckBox->setChecked( h->GetUsePreestimatedLength() );
+ connect( aQCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( onValueChanged() ) );
+ }
+ else {
+ aQCheckBox->setChecked( false );
+ aQCheckBox->setEnabled( false );
+ }
+ customWidgets()->append( aQCheckBox );
+ }
else if( hypType()=="SegmentLengthAroundVertex" )
{
StdMeshers::StdMeshers_SegmentLengthAroundVertex_var h =
{
sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, 6 );
}
+ else if( hypType()=="MaxLength" && sb )
+ {
+ sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, 6 );
+ sb->setEnabled( !widget< QCheckBox >( 1 )->isChecked() );
+ }
else if( hypType()=="MaxElementArea" && sb )
{
sb->RangeStepAndValidator( VALUE_SMALL_2, VALUE_MAX_2, 1.0, 6 );
types.insert( "NumberOfLayers", "NUMBER_OF_LAYERS" );
types.insert( "LayerDistribution", "LAYER_DISTRIBUTION" );
types.insert( "SegmentLengthAroundVertex", "SEGMENT_LENGTH_AROUND_VERTEX" );
+ types.insert( "MaxLength", "MAX_LENGTH" );
}
QString res;
return true;
}
}
+ if ( hypType() == "MaxLength" ) {
+ param.myValue = "";
+ return true;
+ }
if ( widget->inherits( "StdMeshersGUI_ObjectReferenceParamWdg" ))
{
// show only 1st reference value
deactivateObjRefParamWdg( customWidgets() );
}
}
+
+//================================================================================
+/*!
+ * \brief
+ */
+//================================================================================
+
+void StdMeshersGUI_StdHypothesisCreator::valueChanged( QWidget* paramWidget)
+{
+ if ( hypType() == "MaxLength" && paramWidget == getWidgetForParam(1) ) {
+ getWidgetForParam(0)->setEnabled( !widget< QCheckBox >( 1 )->isChecked() );
+ if ( !getWidgetForParam(0)->isEnabled() ) {
+ StdMeshers::StdMeshers_MaxLength_var h =
+ StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis() );
+ widget< QtxDoubleSpinBox >( 0 )->setValue( h->GetPreestimatedLength() );
+ }
+ }
+}
virtual ListOfWidgets* customWidgets() const;
virtual void onReject();
+ virtual void valueChanged( QWidget* );
+
template<class T>
T* widget(int i) const {
return dynamic_cast< T* >( getWidgetForParam( i ));
<source>ICON_DLG_LOCAL_LENGTH</source>
<translation>mesh_hypo_length.png</translation>
</message>
+ <message>
+ <source>ICON_DLG_MAX_LENGTH</source>
+ <translation>mesh_hypo_length.png</translation>
+ </message>
<message>
<source>ICON_DLG_MAX_ELEMENT_AREA</source>
<translation>mesh_hypo_area.png</translation>
<source>ICON_SMESH_TREE_HYPO_LocalLength</source>
<translation>mesh_tree_hypo_length.png</translation>
</message>
+ <message>
+ <source>ICON_SMESH_TREE_HYPO_MaxLength</source>
+ <translation>mesh_tree_hypo_length.png</translation>
+ </message>
<message>
<source>ICON_SMESH_TREE_HYPO_MaxElementArea</source>
<translation>mesh_tree_hypo_area.png</translation>
<source>SMESH_LOCAL_LENGTH_TITLE</source>
<translation>Hypothesis Construction</translation>
</message>
+ <message>
+ <source>SMESH_MAX_LENGTH_HYPOTHESIS</source>
+ <translation>Max Length</translation>
+ </message>
+ <message>
+ <source>SMESH_USE_PREESTIMATED_LENGTH</source>
+ <translation>Use preestimated length</translation>
+ </message>
+ <message>
+ <source>SMESH_MAX_LENGTH_TITLE</source>
+ <translation>Hypothesis Construction</translation>
+ </message>
<message>
<source>SMESH_MAX_ELEMENT_AREA_HYPOTHESIS</source>
<translation>Max. Element Area</translation>
# Author : Julia DOROVSKIKH
# Modified by : Alexander BORODIN (OCN) - autotools usage
# Module : SMESH
-# $Header$
-#
+
include $(top_srcdir)/adm_local/unix/make_common_starter.am
# header files
StdMeshers_SegmentLengthAroundVertex_i.hxx \
StdMeshers_UseExisting_1D2D_i.hxx \
StdMeshers_TrianglePreference_i.hxx \
+ StdMeshers_MaxLength_i.hxx \
SMESH_StdMeshers_I.hxx
# Libraries targets
StdMeshers_SegmentAroundVertex_0D_i.cxx \
StdMeshers_SegmentLengthAroundVertex_i.cxx \
StdMeshers_UseExisting_1D2D_i.cxx \
- StdMeshers_TrianglePreference_i.cxx
+ StdMeshers_TrianglePreference_i.cxx \
+ StdMeshers_MaxLength_i.cxx
# additionnal information to compil and link file
libStdMeshersEngine_la_CPPFLAGS = \
--- /dev/null
+// SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// File : StdMeshers_MaxLength_i.cxx
+// Module : SMESH
+
+#include "StdMeshers_MaxLength_i.hxx"
+#include "SMESH_Gen_i.hxx"
+#include "SMESH_Gen.hxx"
+#include "SMESH_PythonDump.hxx"
+
+#include "Utils_CorbaException.hxx"
+#include "utilities.h"
+
+#include <TCollection_AsciiString.hxx>
+
+using namespace std;
+
+//=============================================================================
+/*!
+ * StdMeshers_MaxLength_i::StdMeshers_MaxLength_i
+ *
+ * Constructor
+ */
+//=============================================================================
+
+StdMeshers_MaxLength_i::StdMeshers_MaxLength_i( PortableServer::POA_ptr thePOA,
+ int theStudyId,
+ ::SMESH_Gen* theGenImpl )
+ : SALOME::GenericObj_i( thePOA ),
+ SMESH_Hypothesis_i( thePOA )
+{
+ myBaseImpl = new ::StdMeshers_MaxLength( theGenImpl->GetANewId(),
+ theStudyId,
+ theGenImpl );
+}
+
+//=============================================================================
+/*!
+ * StdMeshers_MaxLength_i::~StdMeshers_MaxLength_i
+ *
+ * Destructor
+ */
+//=============================================================================
+
+StdMeshers_MaxLength_i::~StdMeshers_MaxLength_i()
+{
+}
+
+//=============================================================================
+/*!
+ * StdMeshers_MaxLength_i::SetLength
+ *
+ * Set length
+ */
+//=============================================================================
+void StdMeshers_MaxLength_i::SetLength( CORBA::Double theLength )
+ throw ( SALOME::SALOME_Exception )
+{
+ ASSERT( myBaseImpl );
+ try {
+ this->GetImpl()->SetLength( theLength );
+ }
+ catch ( SALOME_Exception& S_ex ) {
+ THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
+ SALOME::BAD_PARAM );
+ }
+
+ // Update Python script
+ SMESH::TPythonDump() << _this() << ".SetLength( " << theLength << " )";
+}
+
+//=============================================================================
+/*!
+ * Sets preestimation flag
+ */
+//=============================================================================
+void StdMeshers_MaxLength_i::SetUsePreestimatedLength( CORBA::Boolean toUse )
+ throw ( SALOME::SALOME_Exception )
+{
+ ASSERT( myBaseImpl );
+ try {
+ this->GetImpl()->SetUsePreestimatedLength( toUse );
+ }
+ catch ( SALOME_Exception& S_ex ) {
+ THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
+ SALOME::BAD_PARAM );
+ }
+
+ // this is an internal kitchen call - no Python dump
+ // Update Python script
+ //SMESH::TPythonDump() << _this() << ".SetUsePreestimatedLength( " << toUse << " )";
+}
+
+//=============================================================================
+/*!
+ * Sets preestimation length
+ */
+//=============================================================================
+void StdMeshers_MaxLength_i::SetPreestimatedLength( CORBA::Double theLength )
+{
+ ASSERT( myBaseImpl );
+ try {
+ this->GetImpl()->SetPreestimatedLength( theLength );
+ }
+ catch ( SALOME_Exception& S_ex ) {
+ THROW_SALOME_CORBA_EXCEPTION( S_ex.what(),
+ SALOME::BAD_PARAM );
+ }
+ // this is an internal kitchen call - no Python dump
+ // Update Python script
+ //SMESH::TPythonDump() << _this() << ".SetPreestimatedLength( " << toUse << " )";
+}
+
+//=============================================================================
+/*!
+ * StdMeshers_MaxLength_i::GetLength
+ *
+ * Get length
+ */
+//=============================================================================
+CORBA::Double StdMeshers_MaxLength_i::GetLength()
+{
+ ASSERT( myBaseImpl );
+ return this->GetImpl()->GetLength();
+}
+
+//=============================================================================
+/*!
+ * StdMeshers_MaxLength_i::GetPreestimatedLength
+ */
+//=============================================================================
+CORBA::Double StdMeshers_MaxLength_i::GetPreestimatedLength()
+{
+ ASSERT( myBaseImpl );
+ return this->GetImpl()->GetPreestimatedLength();
+}
+
+//=============================================================================
+/*!
+ * Returns preestimation flag
+ */
+//=============================================================================
+CORBA::Boolean StdMeshers_MaxLength_i::GetUsePreestimatedLength()
+{
+ ASSERT( myBaseImpl );
+ return this->GetImpl()->GetUsePreestimatedLength();
+}
+
+//================================================================================
+/*!
+ * \brief Returns true if preestemated length is defined
+ */
+//================================================================================
+
+CORBA::Boolean StdMeshers_MaxLength_i::HavePreestimatedLength()
+{
+ ASSERT( myBaseImpl );
+ return this->GetImpl()->HavePreestimatedLength();
+}
+
+//=============================================================================
+/*!
+ * StdMeshers_MaxLength_i::GetImpl
+ *
+ * Get implementation
+ */
+//=============================================================================
+::StdMeshers_MaxLength* StdMeshers_MaxLength_i::GetImpl()
+{
+ return ( ::StdMeshers_MaxLength* )myBaseImpl;
+}
+
+//================================================================================
+/*!
+ * \brief Verify whether hypothesis supports given entity type
+ * \param type - dimension (see SMESH::Dimension enumeration)
+ * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
+ *
+ * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
+ */
+//================================================================================
+CORBA::Boolean StdMeshers_MaxLength_i::IsDimSupported( SMESH::Dimension type )
+{
+ return type == SMESH::DIM_1D;
+}
--- /dev/null
+// SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// File : StdMeshers_MaxLength_i.hxx
+// Module : SMESH
+
+#ifndef _SMESH_MaxLength_I_HXX_
+#define _SMESH_MaxLength_I_HXX_
+
+#include "SMESH_StdMeshers_I.hxx"
+
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
+
+#include "SMESH_Hypothesis_i.hxx"
+#include "StdMeshers_MaxLength.hxx"
+
+class SMESH_Gen;
+
+// ======================================================
+// Local Length hypothesis
+// ======================================================
+class STDMESHERS_I_EXPORT StdMeshers_MaxLength_i:
+ public virtual POA_StdMeshers::StdMeshers_MaxLength,
+ public virtual SMESH_Hypothesis_i
+{
+public:
+ // Constructor
+ StdMeshers_MaxLength_i( PortableServer::POA_ptr thePOA,
+ int theStudyId,
+ ::SMESH_Gen* theGenImpl );
+ // Destructor
+ virtual ~StdMeshers_MaxLength_i();
+
+ // Set length
+ void SetLength( CORBA::Double theLength )
+ throw ( SALOME::SALOME_Exception );
+ // Set precision
+
+ // Sets preestimation flag
+ void SetUsePreestimatedLength( CORBA::Boolean toUse)
+ throw ( SALOME::SALOME_Exception );
+
+ // Get length
+ CORBA::Double GetLength();
+
+ // Returns true if preestemated length is defined
+ CORBA::Boolean HavePreestimatedLength();
+
+ CORBA::Double GetPreestimatedLength();
+
+ // Sets preestemated length
+ void SetPreestimatedLength(CORBA::Double theLength);
+
+ // Returns preestimation flag
+ CORBA::Boolean GetUsePreestimatedLength();
+
+ // Get implementation
+ ::StdMeshers_MaxLength* GetImpl();
+
+ // Verify whether hypothesis supports given entity type
+ CORBA::Boolean IsDimSupported( SMESH::Dimension type );
+};
+
+#endif
+
// File : StdMeshers_i.cxx
// Author : Julia DOROVSKIKH
// Module : SMESH
-// $Header$
-//
+
#include "SMESH_StdMeshers_I.hxx"
#include "SMESH_Gen_i.hxx"
#include "StdMeshers_NumberOfLayers_i.hxx"
#include "StdMeshers_LayerDistribution_i.hxx"
#include "StdMeshers_SegmentLengthAroundVertex_i.hxx"
+#include "StdMeshers_MaxLength_i.hxx"
#include "StdMeshers_Regular_1D_i.hxx"
#include "StdMeshers_MEFISTO_2D_i.hxx"
// Hypotheses
if (strcmp(aHypName, "LocalLength") == 0)
aCreator = new StdHypothesisCreator_i<StdMeshers_LocalLength_i>;
+ else if (strcmp(aHypName, "MaxLength") == 0)
+ aCreator = new StdHypothesisCreator_i<StdMeshers_MaxLength_i>;
else if (strcmp(aHypName, "NumberOfSegments") == 0)
aCreator = new StdHypothesisCreator_i<StdMeshers_NumberOfSegments_i>;
else if (strcmp(aHypName, "LengthFromEdges") == 0)